Esempio n. 1
0
vector<KeyFrame>
ModelLoaderMD3::loadKeyFrames(const FileName &fileName,
                              const FileName &skinName,
                              TextureFactory &textureFactory) const {
	FILE * stream = fopen(fileName.c_str(), "rb");

	
	VERIFY(stream && !ferror(stream), "MD3 failed to open: "+fileName.str());
	
	Header header = readHeader(stream);
	
	Frame *frames = readFrames(stream, header);
	
	Tag *tags = readTags(stream, header);
	
	Surface *surfaces = readSurfaces(stream, header);
	
	fclose(stream);
	
	vector<KeyFrame> keyFrames = buildKeyFrame(surfaces,
	                             fileName,
	                             skinName,
	                             header,
	                             textureFactory);
	                             
	delete [] frames;
	delete [] tags;
	delete [] surfaces;
	
	return keyFrames;
}
Esempio n. 2
0
void ModelStatic::LoadObj( const char *filename )
{
	if ( !readSurfaces( filename, m_surfaces ) )
	{
		std::vector< ModelGeometry* > geoms;
		std::vector< std::string > materials;
		std::vector< std::string > surfaceName;
		::LoadObj( geoms, materials, surfaceName, filename );
		char path[256];
		SplitPath( path, filename );
		for ( unsigned int i=0; i<geoms.size(); i++)
		{
			RenderSurface surf;
			surf.name = surfaceName[i];
			surf.geom = geoms[i];
			surf.mat = materialManager()->Load( (materials[i] + std::string(".material")).c_str() );
			m_surfaces.push_back( surf );
		}
		writeSurfaces( filename, m_surfaces );
	}
}