Loading And Rendering MDLs

Started by
-1 comments, last by d h k 18 years, 8 months ago
Hello everybody, I downloaded the MDL Viewer demo at NeHe's page and wanted to include MDL support to my simple ego-shooter project. The demo runs and compiles fine with VC++. I then copied all the header and source files (except the main source file) and copied them to my folder and included the MDLs in my main source file. It compiles fine, but whenever I call the MdlModel[0].Init ( filename ); function, it does overwrite all my textures in the map with the models one and it does not display the MDL model... This is my model draw function (which should probably be fine):

void DrawModels( )
{
	glFrontFace ( GL_CCW );
	glCullFace ( GL_FRONT );
	glEnable ( GL_CULL_FACE );			

	switch(Action)
	{
		case 0:
		{
			if ( Animation != 0 )
			{
				Animation=0;
				MdlModel[0].SetSequence ( 0 ); //1st sequence
				}
				break;
			}
		case 1:
		{
			if(Animation!=1)
			{
				Animation = 1;
				MdlModel[0].SetSequence(4); //4th sequence of the hassassin model
			}
			break;
		}
	} 

	MdlModel[0].SetBlending ( 1, 1.0f );

	static float	Previous;
	float Current	= GetTickCount( ) / 1000.0f;
		for(int Models=0;Models<1;Models++)
		{
			MdlModel[Models].AdvanceFrame(Current - Previous);
			//MdlModel[Models].SetBlending(1, 0.0f);
		}
			MdlModel[0].DrawModel ( );
		Previous	= Current;
	glDisable ( GL_CULL_FACE );
}


The problem is (as said) in the init function, but that function is defined in one of the files I copied, so it HAS to be the very same than in my code. Anyways, here we go:

void TMDLModel::Init(char *Filename)
{ 
	char	TextureName[256];
	char	SeqGroupName[256];

	Header	= LoadModel(Filename);

	if (0 == Header->NumTextures)
	{
		strcpy(TextureName, Filename);
		strcpy(&TextureName[strlen(TextureName) - 4], "T.mdl");

		TextureHeader	= LoadModel(TextureName);
	}
	
	else
	{
		TextureHeader	= Header;
	}

	if (Header->NumSeqGroups > 1)
	{
		for (long Loop = 1; Loop < Header->NumSeqGroups; Loop++)
		{
			strcpy(SeqGroupName, Filename);
			sprintf(&SeqGroupName[strlen(SeqGroupName) - 4], "%02d.mdl", Loop);

			AnimationHeader[Loop]	= LoadDemandSequences(SeqGroupName);
		}
	}
}


I call this init function in my GLInit function as I am supposed to and that's about what the other file does and there it works... What am I dong wrong/Has anybody experience with this?

This topic is closed to new replies.

Advertisement