void fbxLoader2::processNode(FbxNode* node) { //FbxNodeAttribute::EType attributeType; if(node->GetNodeAttribute()) { switch(node->GetNodeAttribute()->GetAttributeType()) { case FbxNodeAttribute::eMesh: processMesh(node); break; case FbxNodeAttribute::eSkeleton: break; case FbxNodeAttribute::eLight: break; case FbxNodeAttribute::eCamera: break; } } for(int i = 0; i<node->GetChildCount(); i++) { processNode(node->GetChild(i)); } }
//--------------------------------------------------------------------- void OptimiseTool::processMeshFile(Ogre::String file, Ogre::String outFile) { StatefulMeshSerializer* meshSerializer = OgreEnvironment::getSingleton().getMeshSerializer(); print("Loading mesh " + file + "..."); MeshPtr mesh; try { mesh = meshSerializer->loadMesh(file); } catch(std::exception& e) { warn(e.what()); warn("Unable to open mesh file " + file); warn("file skipped."); return; } print("Optimising mesh..."); processMesh(mesh); meshSerializer->saveMesh(outFile, true); print("Mesh saved as " + outFile + "."); if (mFollowSkeletonLink && mesh->hasSkeleton()) { // In this case keep file name. processSkeletonFile(mesh->getSkeletonName(), mesh->getSkeletonName()); } }
void processSceneRecursive(const aiScene *scene, cJSON *list, const aiMatrix4x4 &transform, aiNode *nodes) { for(unsigned i = 0; i < nodes->mNumMeshes; i++) { aiMesh *mesh = scene->mMeshes[nodes->mMeshes[i]]; std::string meshname = processMesh(i, nodes, mesh); std::string occlusionName = createOcclusionGeometry(meshname, nodes, mesh); // Format mesh name std::string n(nodes->mName.data, nodes->mName.length); std::stringstream ss; ss << n << "_" << i; std::string materialfile = processMaterial(i, scene->mMaterials[mesh->mMaterialIndex]); std::string entity = outputJsonEntityFile(ss.str(), transform, meshname, materialfile, occlusionName); //outputJsonMeshFile(materialfile, meshname, outdir + "/Meshes/" + ss.str()); cJSON_AddStringToArray(list, entity.c_str()); } aiMatrix4x4 t = nodes->mTransformation * transform; for(unsigned i = 0; i < nodes->mNumChildren; i++) { processSceneRecursive(scene, list, t, nodes->mChildren[i]); } }
void core::ModelLoader::processNode(const aiScene *scene, aiNode *node, Model *m){ if(node->mNumMeshes > 0) for(unsigned int x = 0; x < node->mNumMeshes; x++) processMesh(scene, node, scene->mMeshes[node->mMeshes[x]], m); if(node->mNumChildren > 0) for(unsigned int x = 0; x < node->mNumChildren; x++) processNode(scene, node->mChildren[x], m); };
void Model::processNode(aiNode *node, const aiScene *scene) { // Process all the node's meshes (if any) for(GLuint i = 0; i < node->mNumMeshes; i++) { aiMesh* mesh = scene->mMeshes[node->mMeshes[i]]; meshes.push_back(processMesh(mesh, scene)); } // Then do the same for each of its children for(GLuint i = 0; i < node->mNumChildren; i++) { this->processNode(node->mChildren[i], scene); } }
void Model::processNode(aiNode* node) { for (size_t i = 0; i < node->mNumMeshes; i++) { processMesh(scene->mMeshes[node->mMeshes[i]]); } for (size_t i = 0; i < node->mNumChildren; i++) { processNode(node->mChildren[i]); } }
void Model::processAttribute(FbxNodeAttribute *attribute, int level, Data &model) { if (!attribute) return; FbxString typeName = getAttributeTypeName(attribute->GetAttributeType()); FbxString attrName = attribute->GetName(); LOG(INFO) << "Attribute " << typeName.Buffer() << " Name " << attrName; switch (attribute->GetAttributeType()) { case FbxNodeAttribute::eSkeleton: return; case FbxNodeAttribute::eMesh: processMesh(attribute->GetNode()->GetMesh(), model); case FbxNodeAttribute::eCamera: return; case FbxNodeAttribute::eLight: return; } }
/* Recursively processes the meshes of the model */ void OBJLoader::recursiveProcess(aiNode* node, const aiScene* scene) { //process for(std::size_t i=0; i<node->mNumMeshes;i++) { aiMesh* mesh = scene->mMeshes[node->mMeshes[i]]; processMesh(mesh, scene); } //recursion for(std::size_t i=0; i<node->mNumChildren; i++) { recursiveProcess(node->mChildren[i], scene); } }
void Model::processNode(aiNode * node, const aiScene * scene) { for (GLuint i = 0; i < node->mNumMeshes; i++) { aiMesh* mesh = scene->mMeshes[node->mMeshes[i]]; processMesh(mesh, scene); } for (GLuint i = 0; i < node->mNumChildren; i++) { processNode(node->mChildren[i], scene); } }
void OGLModel::processNode(aiNode *pNode, const aiScene *pScene) { for (GLuint i = 0; i < pNode->mNumMeshes; ++i) { aiMesh *pMesh = pScene->mMeshes[pNode->mMeshes[i]]; OGLMesh meshData; processMesh(pMesh, pScene, meshData); m_OGLMeshes.push_back(meshData); } for (GLuint i = 0; i < pNode->mNumChildren; ++i) { processNode(pNode->mChildren[i], pScene); } }
void Model::processNode(aiNode *node, const aiScene *scene) { // Process all the node's meshes for (GLuint a = 0; a < node->mNumMeshes; a++) { aiMesh *currentMesh = scene->mMeshes[node->mMeshes[a]]; m_pMeshes->push_back(processMesh(currentMesh, scene, std::string(node->mName.C_Str()))); } // Do the same for all child-nodes for (GLuint a = 0; a < node->mNumChildren; a++) { processNode(node->mChildren[a], scene); } }
void processAttribute(FbxNodeAttribute * attribute, GameObject * go) { if (!attribute) return; FbxString typeName = GetAttributeTypeName(attribute->GetAttributeType()); FbxString attrName = attribute->GetName(); PrintTabs(); std::cout << "Attribute " << typeName.Buffer() << " Name " << attrName << std::endl; switch (attribute->GetAttributeType()) { case FbxNodeAttribute::eSkeleton: return; case FbxNodeAttribute::eMesh: processMesh(attribute->GetNode()->GetMesh(),go); case FbxNodeAttribute::eCamera: return; case FbxNodeAttribute::eLight: return; } }
/** * Performs the conversion from the XML file format to the G3D binary format. * * @param doc: XML DOM document for input. * @param outfile: Binary file, opened as "wb", for output. */ int xml2g3d(xmlDocPtr doc, FILE *outfile) { struct FileHeader fh; struct ModelHeader mh; xmlNode *root_element; xmlNode *curNode; xmlChar version[] = "version"; /* fetch the root element and check it */ root_element = xmlDocGetRootElement(doc); assert(root_element->type == XML_ELEMENT_NODE); if (strcmp((char*)root_element->name, "G3D") != 0) { printf("G3D document not found!\n"); return FALSE; } if (strcmp((char*)xmlGetProp(root_element, version), "4") != 0) { printf("Only version 4 G3D documents can be handled!\n"); return FALSE; } /* write out the file header */ memset(&fh, 0, sizeof(struct FileHeader)); fh.id[0] = 'G'; fh.id[1] = '3'; fh.id[2] = 'D'; fh.version=4; fwrite(&fh, sizeof(struct FileHeader), 1, outfile); /* write out the model header */ memset(&mh, 0, sizeof(struct ModelHeader)); mh.meshCount = (uint16)countChildren(root_element, (xmlChar*)"Mesh"); mh.type = 0; fwrite(&mh, sizeof(struct ModelHeader), 1, outfile); /* process each mesh in the file */ curNode = root_element->children; for (; curNode; curNode = curNode->next) { if (curNode->type == XML_ELEMENT_NODE) { if (strcmp((char*)curNode->name, "Mesh") == 0) { if (processMesh(curNode, outfile) == FALSE) return FALSE; } } } return TRUE; }
void Model::processNode(aiNode* node, const aiScene* scene){ // Process each mesh located at the current node for(GLuint i = 0; i < node->mNumMeshes; i++) { // The node object only contains indices to index the actual objects in the scene. // The scene contains all the data, node is just to keep stuff organized (like relations between nodes). aiMesh* mesh = scene->mMeshes[node->mMeshes[i]]; m_meshes.emplace_back(std::move(processMesh(mesh, scene))); } // After we've processed all of the meshes (if any) we then recursively process each of the children nodes for(GLuint i = 0; i < node->mNumChildren; i++) { this->processNode(node->mChildren[i], scene); } }
void Model::processAttrib(FbxNodeAttribute *attrib, int level) { if (!attrib) return; FbxString typeName = GetAttribTypeName(attrib->GetAttributeType()); FbxString attrName = attrib->GetName(); //PrintTabs(level); //printf("Attribute %s Name %s\n", typeName.Buffer(), attrName); switch (attrib->GetAttributeType()) { case FbxNodeAttribute::eMesh: processMesh(attrib->GetNode()->GetMesh(), level); break; case FbxNodeAttribute::eCamera: return; case FbxNodeAttribute::eLight: return; } }
bool Parser::processObject() { std::string strType; if(!readBloqueTxt("type", strType)) return false; if(strType == "plane") { if(!processPlane()) return false; } else if(strType == "sphere") { if(!processSphere()) return false; } else if(strType == "cylinder") { if(!processCylinder()) return false; } else if(strType == "box") { if(!processBox()) return false; } else if(strType == "parallelogram") { if(!processParallelogram()) return false; } else if(strType == "triangle") { if(!processTriangle()) return false; } else if(strType == "mesh") { if(!processMesh()) return false; } else // Tipo de objeto desconocido. return false; return true; }
void ObjectLoader::loadMesh(Mesh* mesh, XmlTreeNode* node){ // Primero buscamos si hay algun mesh que pertenezca a otro archivo de mesh, y en tal caso lo cargamos ya agremos al mesh padre for(int i=0; i < node->getChildNodes().size(); i++){ XmlTreeNode* childNode = node->getChildNodes()[i]; if(childNode->getName().compare("Mesh") == 0){ XmlNodeAttribute* meshFilePathAtt = childNode->searchForAttribute("meshPath"); if(meshFilePathAtt != NULL){ Mesh* loadedMesh = MeshFactory::getInstance()->createMeshFromFile(meshFilePathAtt->getValue().c_str()); if(mesh != NULL){ // Agregamos todos los hijos del mesh cargado al mesh padre, eliminando del medio al mesh root for(int i=0; i < loadedMesh->getChilds()->size(); i++){ mesh->addChild(loadedMesh->getChilds()->at(i)); } } else{ Logger::getInstance()->logError(new Log("ObjectLoader#loadMesh: No se pudo cargar el mesh " + meshFilePathAtt->getValue())); } } } } // Ahora por cada hijo del mesh padre, buscamos su correspondiente definicion y ajustamos sus propiedades for(unsigned int i=0; i < mesh->getChilds()->size(); i++){ Mesh* childMesh = mesh->getChilds()->at(i); XmlTreeNode* childNode = node->searchDirectChild("Mesh", i); if(childNode != NULL){ XmlNodeAttribute* nameAttribute = childNode->searchForAttribute("name"); XmlNodeAttribute* meshFilePathAtt = childNode->searchForAttribute("meshPath"); if(!meshFilePathAtt && !nameAttribute) continue; if(nameAttribute->getValue().compare(childMesh->getName())==0){ processMesh(childMesh, childNode); loadMesh(childMesh, childNode); } else Logger::getInstance()->logDebug(new Log("ObjectLoader#loadMesh: Mesh name " + mesh->getName() + " difiere del node name " + childNode->getName())); } } // Reevaluo que shader se adapta mejor al mesh mesh->setShaderProgram(ShaderManager::getInstance()->reevaluateTheBestShader(mesh)); }
void ProxyEntity::validated() { mDestroyTimer->cancel(); processMesh( mProxy->getMesh() ); }
void fbxLoader2::processMesh(FbxNode* node) { FbxMesh* mesh = node->GetMesh(); this->readAnimationWeigths(mesh); if(mesh!=NULL && mesh->IsTriangleMesh()) { for (int i = 0; i<mesh->GetControlPointsCount(); i++) { readVertex(mesh, i, &vertex[i]); vertexArray[i].position = D3DXVECTOR3(vertex[i]); } int a = mesh->GetPolygonVertexCount(); for (int i = 0; i<mesh->GetPolygonVertexCount(); i++) { readUV(mesh, i, 0, &uv[i]); readNormal(mesh, i, &normal[i]); indices[i].indice = mesh->GetPolygonVertices()[i]; indices[i].normal1 = normal[i]; indices[i].uv1 = uv[i]; indicesMeshCount++; } } //vertexLists.push_back(vertexArray); indiceLists.push_back(indices); FbxAnimStack* pAnimStack = FbxCast<FbxAnimStack>(scene->GetSrcObject(FBX_TYPE(FbxAnimStack))); int numAnimLayers = pAnimStack->GetMemberCount(FBX_TYPE(FbxAnimLayer)); this->setBindPoseCluster(node); for (int i = 0; i < numAnimLayers; i++) { FbxAnimLayer* pAnimLayer = pAnimStack->GetMember(FBX_TYPE(FbxAnimLayer), i); FbxAnimCurve* animCv = this->findSkeletonRootBone(scene->GetRootNode())->GetChild(0)->LclTranslation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_X); if (animCv) { FbxTimeSpan animationLength; int p = animCv->KeyGetCount(); animCv->GetTimeInterval(animationLength); for(int j = 0; j<animationStructure->GetFramesNumber();j++) { FbxTime timeKey = animCv->KeyGet(j).mTime; //FbxTime interval = (duration/p)*j + animationLength.GetStart(); //int intervalVal = (duration.GetSecondCount()/p)*j + animationLength.GetStart().GetSecondCount(); const FbxTime pTime = animCv->KeyGet(j).mTime; FbxAMatrix pGlobalPos = GetGlobalPosition(node, pTime, scene->GetPose(j)); ComputeSkinDeformation(pGlobalPos, mesh, timeKey, scene->GetPose(j), j); } } } for(int i = 0; i<node->GetChildCount(); i++) { processMesh(node->GetChild(i)); } }
void ResourcePool::Config() { for (vector<Branch>::iterator branch = resourceBranch.childBranches.begin(); branch != resourceBranch.childBranches.end(); ++branch) { if (branch->branchName == "MeshContainer") { for (vector<Attribute>::iterator attri = branch->attributes.begin(); attri != branch->attributes.end(); ++attri) { Attribute tempAttri = *attri; string attriName = tempAttri.name; string attriValue = tempAttri.value; if (attriName == "Directory") { processMesh(attriValue); } } } else if (branch->branchName == "TextureContainer") { for (vector<Attribute>::iterator attri = branch->attributes.begin(); attri != branch->attributes.end(); ++attri) { Attribute tempAttri = *attri; string attriName = tempAttri.name; string attriValue = tempAttri.value; if (attriName == "Directory") { processTexture(attriValue); } } } else if (branch->branchName == "ColorContainer") { for (vector<Attribute>::iterator attri = branch->attributes.begin(); attri != branch->attributes.end(); ++attri) { Attribute tempAttri = *attri; string attriName = tempAttri.name; string attriValue = tempAttri.value; if (attriName == "Directory") { processColor(attriValue); } } } else if (branch->branchName == "ShaderContainer") { for (vector<Attribute>::iterator attri = branch->attributes.begin(); attri != branch->attributes.end(); ++attri) { Attribute tempAttri = *attri; string attriName = tempAttri.name; string attriValue = tempAttri.value; if (attriName == "Directory") { processShader(attriValue); } } } else if (branch->branchName == "SoundContainer") { for (vector<Attribute>::iterator attri = branch->attributes.begin(); attri != branch->attributes.end(); ++attri) { Attribute tempAttri = *attri; string attriName = tempAttri.name; string attriValue = tempAttri.value; if (attriName == "Directory") { soundPool->processSound(attriValue); } } } } }
void RefinementAlgorithm::run(){ processMesh(); }