void animateSceneCenterMovement() { calculateBezier(points); for(int i = 0; i < bezierPoints.size(); ++i) { center.i = bezierPoints[i].x; center.j = bezierPoints[i].y; center.k = bezierPoints[i].z; ObjectModel* n = removePolygons(original); //pronadji matricu transformacije za postojece ociste i glediste float* MatrixViewT; float* MatrixProjectionT; MakeTransform(eye, center, &MatrixViewT, &MatrixProjectionT); float* Matrix; MatrixMultiply(MatrixViewT, 4, 4, MatrixProjectionT, 4, 4, &Matrix); ObjectModel* o = TransformCopy(n, Matrix); o->normalize(); free(MatrixViewT); free(MatrixProjectionT); free(Matrix); drawBody(o); delete n; delete o; sleep(1); } //glutSwapBuffers(); printf("Animacija gotova.\n"); }
int main(int argc, LiteSQL_Char **argv) { int rc = parseArgs(argc,argv); if (rc!=0) { Logger::error(help); return -1; } if (options.printHelp) { LiteSQL_cout << help << std::endl; } ObjectModel model; try { if (!model.loadFromFile(argv[argc-1])) { LiteSQL_String msg = LiteSQL_L( "could not load file '" ) + LiteSQL_String(argv[argc-1]) + LiteSQL_L( "'" ); Logger::error(msg); return -1; } else { return generateCode(model); } } catch (Except e) { Logger::error(e); return -1; } }
void DataMarkerLabel::slot_copyAllFrame() { ObjectModel *pModel = m_pEditData->getObjectModel(); ObjectItem *pItem = pModel->getObject(m_pEditData->getSelIndex()); if (!pItem) { return; } m_pEditData->setCopyAllFrameData(pItem, m_value); }
void DataMarkerLabel::slot_deleteAllFrame() { ObjectModel *pModel = m_pEditData->getObjectModel(); ObjectItem *pItem = pModel->getObject(m_pEditData->getSelIndex()); if (!pItem) { return; } m_pEditData->cmd_deleteAllFrame(pItem->getIndex(), m_value); }
void DataMarkerLabel::mousePressEvent(QMouseEvent *ev) { m_bMouseMove = false; m_bPressLeft = false; m_moveMode = kMoveMode_None; #if 0 if ( ev->button() != Qt::LeftButton ) { ev->ignore(); return ; } #endif m_oldMousePos = ev->pos(); m_bPressLeft = true; m_pressFrame = m_pressCurrentFrame = -1; ObjectModel *pModel = m_pEditData->getObjectModel(); QModelIndex index = m_pEditData->getSelIndex(); ObjectItem *pItem = pModel->getItemFromIndex(index); // 移動予定のフレームデータ取得 if (ev->y() < height() / 3) { if (pModel->isLayer(index)) { for (int i = m_frameStart; i <= m_frameEnd; i++) { if (ev->pos().x() >= getX(i) && ev->pos().x() < getX(i + 1)) { if (pItem->getFrameDataPtr(i)) { m_pressCurrentFrame = m_pressFrame = i; m_moveMode = kMoveMode_Layer; } break; } } } } else if (pModel->isObject(index) && ev->y() < height() * 2 / 3) { for (int i = m_frameStart; i <= m_frameEnd; i++) { if (ev->pos().x() >= getX(i) && ev->pos().x() < getX(i + 1)) { if (pItem->getFrameDataPtr(i, true)) { m_pressCurrentFrame = m_pressFrame = i; m_moveMode = kMoveMode_Object; } break; } } } }
ObjectModel *SUROpener::openSUR(QString fileName) { Parser parser(fileName); ObjectModel *om = new ObjectModel(); for (int i=0; i<parser.getCoordinates().size(); i++) { Parser::Coordinate c = parser.getCoordinates().at(i); om->addVertex(c.x, c.y, c.z); } for (int i=0; i<parser.getIncidences().size(); i++) { Parser::Incidence in= parser.getIncidences().at(i); om->addTriangle(in.a-1, in.b-1, in.c-1); } om->normalize(); return om; }
void renderScene() { // ObjectModel* n = new ObjectModel(original); ObjectModel* n = removePolygons(original); //pronadji matricu transformacije za postojece ociste i glediste float* MatrixViewT; float* MatrixProjectionT; MakeTransform(eye, center, &MatrixViewT, &MatrixProjectionT); float* Matrix; MatrixMultiply(MatrixViewT, 4, 4, MatrixProjectionT, 4, 4, &Matrix); ObjectModel* o = TransformCopy(n, Matrix); o->normalize(); free(MatrixViewT); free(MatrixProjectionT); free(Matrix); drawBody(o); delete n; delete o; //delete original; }
bool Anm2DAsm::makeFromEditData2Inc(EditData &rEditData, QString qsFname) { qsFname = QFileInfo(qsFname).baseName().toUpper(); m_pModel = rEditData.getObjectModel(); if (m_bFlat) { ObjectModel *p = new ObjectModel(); p->copy(m_pModel); p->flat(); m_pModel = p; } ObjectItem *pRoot = m_pModel->getItemFromIndex(QModelIndex()); // ObjectItem *pObj = pRoot->child(0); addString("; このファイルはAnimationCreatorにより生成されました。\n"); addString("\n"); for (int i = 0; i < pRoot->childCount(); i++) { ObjectItem *pObj = pRoot->child(i); addString("%define\t\tACO_" + qsFname + "__" + pObj->getName().replace(" ", "_").toUpper().toUtf8() + QString("\t\t%1").arg(i) + "\n"); } addString("\n"); for (int i = 0; i < pRoot->childCount(); i++) { ObjectItem *pObj = pRoot->child(i); QVector4D qv4AreaMin = QVector4D(FLT_MAX, FLT_MAX, FLT_MAX, 0); QVector4D qv4AreaMax = QVector4D(FLT_MIN, FLT_MIN, FLT_MIN, 0); QString qsLabel = "ACL_" + qsFname + "__" + pObj->getName().replace(" ", "_").toUpper().toUtf8() + "__"; addString("%define\t\t" + qsLabel + "ROOT\t\t0\n"); makeFromEditDataArea(pObj, &qv4AreaMin, &qv4AreaMax, true); addString("\t\t; Area:" + QString("(%1, %2, %3)-(%4, %5, %6) size:(%7, %8, %9)").arg(qv4AreaMin.x(), 0, 'f').arg(qv4AreaMin.y(), 0, 'f').arg(qv4AreaMin.z(), 0, 'f').arg(qv4AreaMax.x(), 0, 'f').arg(qv4AreaMax.y(), 0, 'f').arg(qv4AreaMax.z(), 0, 'f').arg(qv4AreaMax.x() - qv4AreaMin.x(), 0, 'f').arg(qv4AreaMax.y() - qv4AreaMin.y(), 0, 'f').arg(qv4AreaMax.z() - qv4AreaMin.z(), 0, 'f') + "\n"); m_nCnt = 1; for (int j = 0; j < pObj->childCount(); j++) { ObjectItem *pChild = pObj->child(j); makeFromEditData2IncTip(qsLabel, pChild); } addString("\n"); } return true; }
// アニメ再生中 void AnimeGLWidget::drawLayers_Anime() { ObjectModel *pModel = m_pEditData->getObjectModel(); ObjectItem *pItem = pModel->getObject(m_pEditData->getSelIndex()); if (!pItem) { return; } if (m_pSetting->getUseZSort()) { m_drawList.clear(); } drawLayers(pItem); if (m_pSetting->getUseZSort()) { sortDrawList(); drawList(); } }
int main(int argc, char** argv) { if (argc != 2) { printf("Trebam ulaznu .obj datoteku kao prvi i jedini argument komandne linije.\n"); exit(1); } char* filename = argv[1]; ObjectModel* obj = new ObjectModel(filename); printf("Unosite naredbe\n"); float x, y, z; int status; char prompt[100]; while(1) { fgets(prompt, sizeof(prompt), stdin); if (!strcmp(prompt, "normiraj\n")) { obj->normalize(); std::cout << obj->dumpToObj(); //getchar(); continue; } else if (!strcmp(prompt, "quit\n")) { break; } else { sscanf(prompt, "%f %f %f", &x, &y, &z); obj->checkPoint(x, y, z, &status); if (!status) { printf("Tocka nije unutar tijela!\n"); } else if (status == 1) { printf("Tocka je na rubu tijela\n"); } else { printf("Tocka je unutar tijela\n"); } } } return 0; }
void DataMarkerLabel::paintEvent(QPaintEvent * /*event*/) { QPainter painter(this); painter.drawRect(0, 0, width() - 1, height() - 1); if (m_frameEnd - m_frameStart < 1) { return; } drawFrameBase(painter); ObjectModel *pModel = m_pEditData->getObjectModel(); QModelIndex index = m_pEditData->getSelIndex(); ObjectItem *obj = pModel->getObject(index); if (!obj) { return; } QList<int> frames; drawLayer(obj->getIndex(), painter, index, frames); if (m_pressCurrentFrame >= 0) { int x0 = getX(m_pressCurrentFrame); int x1 = getX(m_pressCurrentFrame + 1); int y0 = 0; QColor col = QColor(255, 0, 0, 128); if (pModel->isObject(index)) { y0 = height() / 3; col.setRed(255); } painter.fillRect(x0, y0, x1 - x0, height() / 3, col); } }
void generateQueryDensity(int seed, const std::string &link_name, const boost::shared_ptr<CollisionModel > &cm, const ObjectModel &om, std::vector<QueryDensity::QueryDensityElement > &qd_vec) { double sum_weights = 0.0; int ori_iterations = 0; std::mt19937 gen(seed); for (int i = 0; i < qd_vec.size(); i++) { Eigen::Vector3d p, p2; Eigen::Vector4d q, q2; Eigen::Vector2d r; ori_iterations += om.sample(gen(), p, q, r); if (!cm->sampleForR(gen(), link_name, r, p2, q2)) { std::cout << "ERROR: cm->sampleForR" << std::endl; } double weight = cm->getMarginalDensityForR(link_name, r); KDL::Frame T_O_F( KDL::Frame(KDL::Rotation::Quaternion(q(0), q(1), q(2), q(3)), KDL::Vector(p(0), p(1), p(2))) ); KDL::Frame T_C_F( KDL::Frame(KDL::Rotation::Quaternion(q2(0), q2(1), q2(2), q2(3)), KDL::Vector(p2(0), p2(1), p2(2))) ); KDL::Frame T_L_C; if (!cm->getT_L_C(link_name, T_L_C)) { std::cout << "ERROR: generateQueryDensity: " << link_name << std::endl; } KDL::Frame T_O_C = T_O_F * T_C_F.Inverse(); qd_vec[i].p_ = Eigen::Vector3d(T_O_C.p.x(), T_O_C.p.y(), T_O_C.p.z()); if (qd_vec[i].p_(2) != qd_vec[i].p_(2)) { std::cout << "ERROR: generateQueryDensity: qd_vec[i]: " << qd_vec[i].p_.transpose() << std::endl; std::cout << "T_O_C " << T_O_C << std::endl; std::cout << "T_O_F " << T_O_F << std::endl; std::cout << "T_C_F " << T_C_F << std::endl; return; } double qx, qy, qz, qw; T_O_C.M.GetQuaternion(qx, qy, qz, qw); qd_vec[i].q_ = Eigen::Vector4d(qx, qy, qz, qw); qd_vec[i].weight_ = weight; sum_weights += qd_vec[i].weight_; } // normalize the weights for (int i = 0; i < qd_vec.size(); i++) { qd_vec[i].weight_ /= sum_weights; } std::cout << "generateQueryDensity: " << link_name << " total_it: " << qd_vec.size() << " ori_it: " << ori_iterations << " om.features: " << om.getFeaturesCount() << std::endl; }
void LitesqlParser::onStartElement(const XML_Char *fullname, const XML_Char **atts) { // Logger::report("starting " <<fullname ); history.push_back(m_parseState); if (xmlStrEqual(fullname,(XML_Char*) Database::TAG )) { if (m_parseState!=ROOT) { m_parseState = ERROR; } else { m_parseState = DATABASE; DatabasePtr pDb(new xml::Database); pDb->name = safe((char*)xmlGetAttrValue(atts,"name")); pDb->include = safe((char*)xmlGetAttrValue(atts,"include")); pDb->nspace = safe((char*)xmlGetAttrValue(atts,"namespace")); m_pObjectModel->db = pDb; Logger::report("database = " , m_pObjectModel->db->name); } } else if (xmlStrEqual(fullname,(XML_Char*)Object::TAG)) { if (m_parseState!=DATABASE) { m_parseState = ERROR; } else { ObjectPtr pObj(obj = new Object( (char*)xmlGetAttrValue(atts,"name"), safe((char*)xmlGetAttrValue(atts,"inherits")))); m_pObjectModel->objects.push_back(pObj); Logger::report("object = ",obj->name); m_parseState = OBJECT; } } else if (xmlStrEqual(fullname,(XML_Char*)Field::TAG)) { Field* pNewField = new Field( (char*)xmlGetAttrValue(atts,"name"), field_type(xmlGetAttrValue(atts,"type")), safe( (char*)xmlGetAttrValue(atts,"default")), field_indexed(xmlGetAttrValue(atts,"indexed")), field_unique(xmlGetAttrValue(atts,"unique")), field_length(xmlGetAttrValue(atts,"length")) ); switch(m_parseState) { case OBJECT: if (!obj) { Logger::error("parsing field inside object, but currentObject == NULL "); } else { Logger::report("field = ",obj->name); Field::Ptr field(fld = pNewField); obj->fields.push_back(field); }; m_parseState = FIELD; break; case RELATION: if (!rel) { Logger::error("parsing field inside relation, but currentRelation == NULL "); } else { Field::Ptr field(rel_fld = pNewField); rel->fields.push_back(field); Logger::report("field = ",rel_fld->name ); } m_parseState = FIELD; break; default: delete pNewField; m_parseState = ERROR; } } else if (xmlStrEqual(fullname,(XML_Char*)Index::TAG)) { Index::Ptr ptrIndex(new Index(index_unique(xmlGetAttrValue(atts,"unique")))); switch (m_parseState) { case OBJECT: idx = ptrIndex; obj->indices.push_back(ptrIndex); m_parseState = INDEX; break; case RELATION: idx = ptrIndex; rel->indices.push_back(ptrIndex); m_parseState = INDEX; break; default: m_parseState = ERROR; } } else if (xmlStrEqual(fullname,(XML_Char*)IndexField::TAG)) { if (m_parseState!=INDEX) { m_parseState = ERROR; } else { IndexField idxField((char*)xmlGetAttrValue(atts,"name")); idx->fields.push_back(idxField); } m_parseState = INDEXFIELD; } else if (xmlStrEqual(fullname,(XML_Char*)Value::TAG)) { if (m_parseState!=FIELD) { m_parseState = ERROR; } else { if (fld) { fld->value(Value((char*)xmlGetAttrValue(atts,"name"), (char*)xmlGetAttrValue(atts,"value"))); } Logger::report("value = " ); } } else if (xmlStrEqual(fullname,(XML_Char*)Method::TAG)) { if (m_parseState!=OBJECT) { m_parseState = ERROR; } else { Method::Ptr m(mtd = new Method( safe((char*)xmlGetAttrValue(atts,"name")), safe((char*)xmlGetAttrValue(atts,"returntype")) )); obj->methods.push_back(m); m_parseState= METHOD; Logger::report("method = ",mtd->name ); } } else if (xmlStrEqual(fullname,(XML_Char*)Param::TAG)) { if (m_parseState!=METHOD) { m_parseState = ERROR; } else { char* pszName = (char*)xmlGetAttrValue(atts,"name"); mtd->param(Param(pszName,strdup((char*)xmlGetAttrValue(atts,"type")))); m_parseState= PARAM; Logger::report("param = ",pszName); } } else if (xmlStrEqual(fullname,(XML_Char*)Relation::TAG)) { if (m_parseState!=DATABASE) { m_parseState = ERROR; } else { Relation::Ptr ptrRelation(rel = new Relation( safe((char*)xmlGetAttrValue(atts,"id")), safe((char*)xmlGetAttrValue(atts,"name")), relation_unidir(xmlGetAttrValue(atts,"unidir")))); m_pObjectModel->relations.push_back(ptrRelation); Logger::report( "relation = " + ptrRelation->getName()); m_parseState = RELATION; } } else if (xmlStrEqual(fullname,(XML_Char*)Relate::TAG)) { if (m_parseState!=RELATION) { m_parseState = ERROR; } else { Relate::Ptr ptrRel( new Relate( safe((char*)xmlGetAttrValue(atts,"object")), relate_limit(xmlGetAttrValue(atts,"limit")), relate_unique(xmlGetAttrValue(atts,"unique")), safe((char*)xmlGetAttrValue(atts,"handle")) ) ); rel->related.push_back(ptrRel); Logger::report("relate = " ); } } else if (xmlStrEqual(fullname,(XML_Char*)"include")) { string filename((char*)xmlGetAttrValue(atts,"name")); if (m_parseState!=DATABASE) { m_parseState = ERROR; } else { Logger::report("include \"" + filename + '"' ); ObjectModel includedModel; if (!includedModel.loadFromFile(filename)) { Logger::report("error on parsing included file \"" + filename + '"' ); } m_pObjectModel->objects.insert(m_pObjectModel->objects.end(),includedModel.objects.begin(),includedModel.objects.end()); m_pObjectModel->relations.insert(m_pObjectModel->relations.end(),includedModel.relations.begin(),includedModel.relations.end()); m_parseState = INCLUDE; } } else { m_parseState = UNKNOWN; Logger::error("unknown = ",fullname ); } }
bool Anm2DAsm::makeFromEditData(EditData &rEditData) { m_pModel = rEditData.getObjectModel(); if (m_bFlat) { ObjectModel *p = new ObjectModel(); p->copy(m_pModel); p->flat(); m_pModel = p; } ObjectItem *pRoot = m_pModel->getItemFromIndex(QModelIndex()); // 画像をラベル化 // 未使用画像をスキップするテーブル構築 int nVram = 0; { for (int i = 0; i < rEditData.getImageDataListSize(); i++) { if (i >= KM_VRAM_MAX) { return false; } EditData::ImageData *p = rEditData.getImageData(i); if (!p) continue; QFileInfo fi(p->fileName); QString sImageLabel = fi.fileName(); sImageLabel = QString("ID_") + sImageLabel.replace(".", "_").toUpper(); sImageLabel = sImageLabel.toUtf8(); m_aqsVramID[i] = sImageLabel; m_bUnused[i] = true; } for (int i = 0; i < pRoot->childCount(); i++) { ObjectItem *pObj = pRoot->child(i); for (int j = 0; j < pObj->childCount(); j++) { ObjectItem *pChild = pObj->child(j); subUnusedVramSkip(pChild); } } for (int i = 0; i < rEditData.getImageDataListSize(); i++) { if (m_bUnused[i] == false) nVram++; } } addString(";----------------------------------------------------------------\n"); addString("; @kamefile\t" + pRoot->getName().toUtf8() + "\n"); addString(";---------------------------------------------------------------- HEADER\n"); addString("\t\t\%include\t\"../imageid.inc\"\n"); addString("\n"); addString(";---------------------------------------------------------------- DATA\n"); addString("%define\t\tNO_READ\t\t0\n"); addString("%define\t\tF32(f32)\t\t__float32__(f32)\n"); addString("data:\n"); addString(";---------------------------------------------------------------- ANM_HEAD\n"); addString("\t\t\tdb\t\t'ANM0'\t\t; ANM0\n"); addString("\t\t\tdd\t\t00000003h\t\t; uVersion\n"); addString("\t\t\tdd\t\t" + QString("%1").arg(/*rEditData.getImageDataListSize()*/ nVram) + "\t\t; nVram\n"); addString("\t\t\tdd\t\t.vram\t\t; pauVram\n"); addString("\t\t\tdd\t\t" + QString("%1").arg(pRoot->childCount()) + "\t\t; nObject\n"); addString("\t\t\tdd\t\t.object\t\t; paObj\n"); addString("\t\n"); addString("\t.vram:\n"); for (int i = 0; i < rEditData.getImageDataListSize(); i++) { if (i >= KM_VRAM_MAX) { return false; } if (m_bUnused[i]) continue; EditData::ImageData *p = rEditData.getImageData(i); if (!p) continue; QFileInfo fi(p->fileName); QString sImageLabel = fi.fileName(); sImageLabel = QString("ID_") + sImageLabel.replace(".", "_").toUpper(); sImageLabel = sImageLabel.toUtf8(); m_aqsVramID[i] = sImageLabel; addString("\t\t\tdd\t\t" + m_aqsVramID[i] + "\n"); } addString("\t\n"); addString("\t.object:\n"); for (int i = 0; i < pRoot->childCount(); i++) { addString("\t\t\tdd\t\tanmobj" + QString("%1").arg(i) + "\n"); } addString("\n"); for (int i = 0; i < pRoot->childCount(); i++) { ObjectItem *pObj = pRoot->child(i); QVector4D qv4AreaMin = QVector4D(FLT_MAX, FLT_MAX, FLT_MAX, 0); QVector4D qv4AreaMax = QVector4D(FLT_MIN, FLT_MIN, FLT_MIN, 0); addString(";---------------------------------------------------------------- ANM_OBJ\n"); addString("; " + QString(pObj->getName().toUtf8()) + "\n"); addString("anmobj" + QString("%1").arg(i) + ":\n"); if (pObj->childCount()) { if (pObj->getLoop()) { addString("\t\t\tdd\t\t00000001h\t\t; bFlag\n"); } else { addString("\t\t\tdd\t\t00000000h\t\t; bFlag\n"); } // 最小矩形算出 for (int j = 0; j < pObj->childCount(); j++) { ObjectItem *pChild = pObj->child(j); makeFromEditDataArea(pChild, &qv4AreaMin, &qv4AreaMax, true); } addString("\t\t\tdd\t\t" + QString("F32(%1), F32(%2), F32(%3), F32(%4)").arg(qv4AreaMin.x(), 0, 'f').arg(qv4AreaMin.y(), 0, 'f').arg(qv4AreaMax.x(), 0, 'f').arg(qv4AreaMax.y(), 0, 'f') + "\t\t; fvArea\n"); addString("\t\t\tdd\t\t" + QString("%1").arg(pObj->childCount()) + "\t\t; nTip\n"); addString("\t\t\tdd\t\t.tips\t\t; papTip\n"); addString("\t\n"); addString("\t.tips:\n"); for (int j = 0; j < pObj->childCount(); j++) { addString("\t\t\tdd\t\tobj" + QString("%1").arg(i) + "tip" + QString("%1").arg(j) + "\n"); } addString("\n"); for (int j = 0; j < pObj->childCount(); j++) { QString qsLabel = "obj" + QString("%1").arg(i) + "tip" + QString("%1").arg(j); ObjectItem *pChild = pObj->child(j); if (!makeFromEditDataTip(qsLabel, pChild)) { return false; } } } else { addString("\t\t\tdd\t\t00000000h\t\t; bFlag\n"); addString("\t\t\tdd\t\t0, 0, 0, 0\t\t; fvArea\n"); addString("\t\t\tdd\t\t" + QString("%1").arg(pObj->childCount()) + "\t\t; nTip\n"); addString("\t\t\tdd\t\tNO_READ\t\t; papTip\n"); } } addString("\n"); return true; }