Esempio n. 1
0
	void sb7fbxmodel::ProcessNode(FbxNode* pNode)
	{
		if(pNode->GetNodeAttribute())
		{
			switch(pNode->GetNodeAttribute()->GetAttributeType())
			{
			case FbxNodeAttribute::eMesh:
				ProcessMesh(pNode);
				break;
			case FbxNodeAttribute::eSkeleton:
				ProcessSkeleton(pNode);
				break;
			case FbxNodeAttribute::eLight:
				ProcessLight(pNode);
				break;
			case FbxNodeAttribute::eCamera:
				ProcessCamera();
				break;
			}
		}

		for(int i = 0 ; i < pNode->GetChildCount() ; ++i)
		{
			ProcessNode(pNode->GetChild(i));
		}
	}
Esempio n. 2
0
		void FbxLoader::ProcessMeshNode(FbxNode* node, Node& mnode)
		{
			if(!node)
				return;

			if(node->GetNodeAttribute()) {
				auto type = node->GetNodeAttribute()->GetAttributeType();
				if(type == FbxNodeAttribute::eMesh) {
					mnode.type = Node::eMesh;
					ProcessControlPoints(node, mnode);

					ProcessBoneAndAnimation(node, mnode);

					ProcessMesh(node, mnode);
					BindMaterial(node, mnode);
				}
				else if(type == FbxNodeAttribute::eSkeleton) {
					mnode.type = Node::eBone;
				}
			}

			ComputeNodeMatrix(node, mnode, true);
			const int count = node->GetChildCount();
			mnode.childNodes.resize(count);

			for(int i = 0; i < count; i++) {
				auto child = node->GetChild(i);
				auto& childNode = mnode.childNodes[i];
				childNode.name = child->GetName();
				childNode.parentName = mnode.name;
				ProcessMeshNode(node->GetChild(i), childNode);
			}
		}
Esempio n. 3
0
void ModelResource::ProcessNode(aiNode *node, const aiScene *scene)
{
	for (unsigned int i = 0; i < node->mNumMeshes; i++)
	{
		aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
		Meshes.push_back(ProcessMesh(mesh, scene));
	}

	for (unsigned int i = 0; i < node->mNumChildren; i++)
	{
		ProcessNode(node->mChildren[i], scene);
	}
}
Esempio n. 4
0
File: Model.cpp Progetto: amxxL/Game
void Model::ProcessNode(aiNode* node, aiScene const* scene, DirectX::XMMATRIX const& parentTransformMatrix)
{
    DirectX::XMMATRIX nodeTransformMatrix = DirectX::XMMatrixTranspose(DirectX::XMMATRIX(&node->mTransformation.a1)) * parentTransformMatrix;

    for (uint32 i = 0; i < node->mNumMeshes; ++i)
    {
        aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
        meshes.push_back(ProcessMesh(mesh, scene, nodeTransformMatrix));
    }

    for (uint32 i = 0; i < node->mNumChildren; ++i)
    {
        ProcessNode(node->mChildren[i], scene, nodeTransformMatrix);
    }
}
Esempio n. 5
0
void Model::ProcessNode(aiNode* node, const aiScene* scene)
{
	for (uint i = 0; i < node->mNumMeshes; i++)
	{
		aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
		Mesh m = ProcessMesh(mesh, scene);
		m_Meshs.push_back(m);
		m_RenderMeshs.push_back(RenderMesh(m));
	}

	for (uint i = 0; i < node->mNumChildren; i++)
	{
		this->ProcessNode(node->mChildren[i], scene);
	}
}
Esempio n. 6
0
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]];
		meshes.push_back(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++)
	{
		ProcessNode(node->mChildren[i], scene);
	}

}
Esempio n. 7
0
void FBXScene::ProcessNode(FbxNode* pNode, FbxNodeAttribute::EType attributeType)
{
	if( !pNode )
		return;

	FbxNodeAttribute* pNodeAttribute = pNode->GetNodeAttribute();

	if (pNodeAttribute)
	{
		if( pNodeAttribute->GetAttributeType() == attributeType )
		{
			switch(pNodeAttribute->GetAttributeType())
			{
			case FbxNodeAttribute::eSkeleton:
				{
					ProcessSkeleton(pNode);
					break;
				}

			case FbxNodeAttribute::eMesh:
				{
					ProcessMesh(pNode);
					break;
				}

			case FbxNodeAttribute::eNurbsCurve:
				{
					ProcessCurve(pNode);
					break;
				}

			default:
				break;
			};
		}
	}

	for( int i = 0; i < pNode->GetChildCount(); ++i )
	{
		ProcessNode(pNode->GetChild(i), attributeType);
	}
}
int SceneLoader::LoadFile(const char* filename)
{
	Assimp::Importer importer;

	const aiScene *scene = importer.ReadFile(filename, 0);
	scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace | aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_JoinIdenticalVertices);
	if (!scene)
	{
		std::stringstream oss;
		oss << "ERROR - File: " << filename << " not found." << std::endl;
		std::string debugMsg(oss.str());
		OutputDebugStringA(debugMsg.c_str());
		return false;
	}
	DrawableObject *newObject = new DrawableObject();
	std::vector<Vertex> vertexList;
	std::vector<UINT> indexList;
	std::stringstream oss;
	for (unsigned int i = 0; i < scene->mRootNode->mNumChildren; ++i)
	{
		bool successfulLoad = true;
		aiNode* currentNode = scene->mRootNode->mChildren[i];
		BuildShaders(d3dDevice, *newObject, mShaderManager);
		for (unsigned int j = 0; j < currentNode->mNumMeshes; ++j)
		{
			ProcessMesh(d3dDevice, *scene->mMeshes[currentNode->mMeshes[j]], *newObject, vertexList, indexList, scene->mMeshes[currentNode->mMeshes[j]]->mMaterialIndex - 1);
			//LoadMaterials(d3dDevice, scene->mMeshes[currentNode->mMeshes[j]]->mMaterialIndex, *newObject, scene);
			oss << "MatIndex = " << scene->mMeshes[currentNode->mMeshes[j]]->mMaterialIndex << "\n";
		}
	}
	std::string debugMsg(oss.str());
	OutputDebugStringA(debugMsg.c_str());
	for (unsigned int i = 0; i < scene->mNumMaterials; ++i)
	{
		LoadMaterials(d3dDevice, i, *newObject, scene);
	}
	newObject->GetMeshData()->Initialize(d3dDevice, vertexList, indexList);
	mDrawableObjects.push_back(newObject);

	return mDrawableObjects.size() - 1;
}
Esempio n. 9
0
void FbxParser::ProcessNode(FbxNode* pNode,std::vector<GS::BaseMesh*>& meshs, 
							std::vector<GS::Light*>& lights, GS::Camera& camera)
{
    FbxNodeAttribute::EType lAttributeType;
    int i;

    if(pNode->GetNodeAttribute() == NULL)
    {
         return ;
    }
    else
    {
        lAttributeType = (pNode->GetNodeAttribute()->GetAttributeType());

        switch (lAttributeType)
        {
	    default:
	        break;
        //case FbxNodeAttribute::eMarker:  
        //    DisplayMarker(pNode);
        //    break;

        //case FbxNodeAttribute::eSkeleton:  
        //    DisplaySkeleton(pNode);
        //    break;

        case FbxNodeAttribute::eMesh:      
            ProcessMesh(pNode, meshs);
            break;

        //case FbxNodeAttribute::eNurbs:      
        //    DisplayNurb(pNode);
        //    break;

        //case FbxNodeAttribute::ePatch:     
        //    DisplayPatch(pNode);
        //    break;

        case FbxNodeAttribute::eCamera:    
            ProcessCamera(pNode, camera);
            break;

        case FbxNodeAttribute::eLight:     
            ProcessLight(pNode, lights);
            break;

        //case FbxNodeAttribute::eLODGroup:
        //    DisplayLodGroup(pNode);
        //    break;
        }   
    }

   /* DisplayUserProperties(pNode);
    DisplayTarget(pNode);
    DisplayPivotsAndLimits(pNode);
    DisplayTransformPropagation(pNode);
    DisplayGeometricTransform(pNode);*/

    for(i = 0; i < pNode->GetChildCount(); i++)
    {
        ProcessNode(pNode->GetChild(i), meshs, lights, camera);
    }
}