Example #1
0
bool Model :: Load(std :: string name,ModelLoader &loader,Texture &tex)
{
	// attempt to load the file
	if(!loader.Load(name))
		return false;

	// do we have to clean up?
	if(frames)
		this->Clear();

	// get the model information
	int		modelframes=loader.GetNumFrames();
	int		nummeshes=loader.GetNumMeshes();
	float	modelfps=(float)loader.GetFPS();

	// tidy up the values
	if(modelframes<=0)
		return false;
	if(modelfps==0.0f)
		modelfps=1.0f;

	// and setup our model
	if(!this->Setup(modelframes,modelfps))
		return false;
	
	// now set up the frames
	for(int ct=0; ct<numframes; ct++)
	{
		// setup the frame
		if(!frames[ct].Setup(nummeshes))
		{
			this->Clear();
			return false;
		}
		
		// add the meshes
		for(int ct2=0; ct2<nummeshes; ct2++)
		{
			Mesh msh;	// temporary mesh
			
			// get the mesh
			if(!loader.Get(ct,ct2,&tex,&msh))
				return false;

			// and set it to the frame
			frames[ct].SetMesh(ct2,msh);
		}
	}

	// success
	return true;
}