示例#1
0
		WeakMeshResourceData MeshNodeResourceData::GetMeshByName(const std::string& meshName) const
		{
			WeakMeshResourceData mesh;

			unsigned int meshIndex;
			for (meshIndex = 0; meshIndex < this->m_meshList.size(); ++meshIndex)
			{
				auto currentMesh = this->m_meshList[meshIndex];

				if (currentMesh->GetName() == meshName)
					mesh = std::dynamic_pointer_cast<MeshResourceData>(currentMesh);
			}

			if (mesh.expired())
			{

				for (meshIndex = 0; meshIndex < this->m_children.size(); ++meshIndex)
				{
					auto currentChild = this->m_children[meshIndex];

					mesh = currentChild->GetMeshByName(meshName);
				}
			}

			return mesh;
		}
示例#2
0
文件: Entity.cpp 项目: Rocks25/Voa
void Entity::AddMesh(Mesh *mesh)
{
	if(GetMeshByName(mesh->GetName())==0)
		_Meshes.push_back(mesh);
	else
		delete mesh;
}
示例#3
0
//------------------------------------------------------------------------
// Load a mesh from the model file.
// ----------------------------------------------------------------------
// Param -> IN:
//      const char*:    Path to the model file.
//------------------------------------------------------------------------
FlyMesh* FlyMeshManager::LoadMesh( const char* cFilename )
{
    FlyMesh* pMesh;
    MeshNode node;

    // Check whether the mesh is loaded ?
    if( (pMesh = GetMeshByName(cFilename)) )
        return pMesh;

    // Create a new mesh.
    pMesh = new FlyMesh();
    if( !pMesh ) return NULL;

    // Load the mesh file.
    if( FAILED(pMesh->LoadMeshFromFile(cFilename)) )
    {
        delete pMesh;
        return NULL;
    }

    // Add the new mesh resource node.
    node.pMesh = pMesh;
    node.nReference = 0;
    m_Meshes.push_back( node );

    return pMesh;
}
示例#4
0
//------------------------------------------------------------------------
// Create a null mesh manually.
// ----------------------------------------------------------------------
// Param -> IN:
//      const char*:    Name of the mesh.
//------------------------------------------------------------------------
FlyMesh* FlyMeshManager::CreateManualMesh( const char* cName )
{
    FlyMesh* pMesh;
    MeshNode node;

    // Check whether the mesh has existed ?
    if( (pMesh = GetMeshByName(cName)) )
        return pMesh;

    // Create a new mesh.
    pMesh = new FlyMesh();
    if( !pMesh ) return NULL;
    pMesh->SetName( cName );

    // Add the new mesh resource node.
    node.pMesh = pMesh;
    node.nReference = 0;
    m_Meshes.push_back( node );

    return pMesh;
}