Example #1
0
    ModelPart* AssimpModelImporter::CreateModelPart(aiMesh* mesh) const {
        vector<Vector3f> positions = ExtractPositions(mesh);
        vector<Vector3f> normals = ExtractNormals(mesh);
        vector<Vector2f> texCoords = ExtractTexCoords(mesh, 0);
        vector<Vector4i> joints; 
        vector<Vector4f> weights;
        vector<ModelPartBone> bones;
        ExtractJointsAndWeights(mesh, joints, weights, bones);
        vector<U32> indices = ExtractIndices(mesh);

        Geometry* geometry = new Geometry();
        geometry->SetPositions(begin(positions), end(positions));
        geometry->SetNormals(begin(normals), end(normals));
        geometry->SetTexCoords(begin(texCoords), end(texCoords));
        geometry->SetJoints(begin(joints), end(joints));
        geometry->SetWeights(begin(weights), end(weights));
        geometry->SetIndices(begin(indices), end(indices), D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

        VertexData* vertexData = nullptr;
        if (scene->HasAnimations()) {
            vertexData = new VertexData(P0N0T0A0Builder(geometry));
        } else {
            vertexData = new VertexData(P0N0T0Builder(geometry));
        }

        string meshName = mesh->mName.C_Str();

        if (meshName.empty()) {
            meshName = FindNodeName(FindMeshIndex(mesh));
        }

        ModelPart* modelPart = new ModelPart(meshName, vertexData, GetMaterialByName(meshName), geometry->GetTriangles(), bones);

        return modelPart;
    }
Example #2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
dtNavMeshQuery* CRecastMgr::GetNavMeshQuery( const char *meshName )
{
	int idx = FindMeshIndex( meshName );
	if( m_Meshes.IsValidIndex( idx ) )
	{
		return m_Meshes[idx]->GetNavMeshQuery();
	}
	return NULL;
}