Skip to main content
gamedev.net
🔒 Locked

Problem with textures...

Started by ZitherMan Aug 2, 2002 at 8:48 PM 4 replies 400+ views
Original Post
ZitherMan
ZitherMan
I''m having a problem texturing in my engine. The model just gets white. I was wondering if anyone knows what the error could be caused by? It''s a MD2 file, i know the bitmap loadin works (i loaded a model by another system, without pointers, and it worked) GL_TEXTURE_2D is enabled. Here is some code: The header
  
class mesh : public actor
{
public:
//	MD2 *thisModel;

        TEXTURE *thisTexture;
	GLfloat x,y,z;
	GLfloat position[3];

	mesh(char* filename, char* skinFile, GLfloat scaleX, GLfloat scaleY, GLfloat scaleZ);
	GLvoid draw();
	
};
  
The functions..
  
mesh::mesh(char* filename, char* skinFile, GLfloat scaleX, GLfloat scaleY, GLfloat scaleZ)
{
	thisTexture = new TEXTURE;
	thisTexture->LoadBMP(skinFile, GL_LINEAR, GL_LINEAR);
	thisModel = new MD2;
	thisModel->Load(filename);
	thisModel->SetState(IDLE1);
	
}

GLvoid mesh::draw()
{
	glLoadIdentity();
	glTranslatef(x, y, z);
	glBindTexture(GL_TEXTURE_2D, thisTexture->ID);
	glScalef(0.05f, 0.05f, 0.05f);
	thisModel->Animate(thisModel->stateStart, thisModel->stateEnd, 1.00f);

	glLoadIdentity();

}
  
And finally, the creation of an instance.
  
mesh* pyramid = new mesh("models/Invader/tris.md2", "models/Invader/Alien.bmp", 0.5f, 0.5f, 0.5f);
  
----------------------------
When hell freez
variant
variant
Are you making sure to call glBindTexture(GL_TEXTURE_2D,*thisTexture)?
ZitherMan
ZitherMan
glBindTexture(GL_TEXTURE_2D, thisTexture->ID);

thats how i do it
----------------------------
When hell freez
TangentZ
TangentZ
You didn''t show what happens in "Animate". Have you checked
if you got the texture coordinates correct? Did you do
glEnable(GL_TEXTURE_2D)? etc.



Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
llvllatrix
llvllatrix
If that is trent''s code then go through his model tutorial. I think md2s only support 1 texture per model. What trent does is he creates the model without the texture. He then has a texture class that he binds. Then he draws.

If you need more textures per model then try milkshape or md3.

You can find milkshape at rsn.gamedev.net.

Or if u want email(thereisnocowlevel@hotmail.com) me and ill send u the modified version of trent''s milkshape loader i wrote. Its done using IPicture (thanks NeHe) and supports bmps, jpgs, and gifs. They also dont have to be square (thank god). It also supports milkshape''s alpha maps, which is basically an extension of the masking tutorial. The only thing is no animation

You can find md3 at www.gametutorials.com. They also have a whole lot of other formats like 3ds and i think even maia. They also show you how to animate as well.
ZitherMan
ZitherMan
thanks for your help. Yes i have GL_TEXTURES_2D enabled and yes, i have a separate texture class.

Is there any free md3 exporter for gMax?
----------------------------
When hell freez

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.