Exemplo n.º 1
0
// Builds the model from the 3DS file data
// Returns true for success false otherwise
bool ModelLoader::buildFrom3DS(Mesh &mesh, unsigned int meshNum)
{
	// Make sure we have valid objects just in case.
	if(m_3DModel.pObject.size() <= 0){
		return false;
	}

	// Get the current object that we want to build
	Object3DS *pObject = &m_3DModel.pObject[meshNum];
			
	int numTexCoords = pObject->numTexVertex;
	int numVerts = pObject->numOfVerts;
	int numIndices = pObject->numOfFaces*3;

	// If the number of texture coordinates does not equal
	// the number of (x,y,z) positions, skip this mesh object.  We
	// only handle mesh objects that have an equal number of (x,y,z)'s and
	// (u,v)'s
	if(numTexCoords != numVerts)
		return false;

	// Check to see if this object has a texture map, build a texture for it
	if(pObject->bHasTexture){

		const char* name = m_3DModel.pMaterials[pObject->materialID].strFile;
		mesh.BuildTextureData(name);
	}

	mesh.BuildVertexData(pObject, numVerts, numTexCoords, numIndices);

	return true;
}