Jump to content
  • Advertisement
Sign in to follow this  
Endar

md2 texturing

This topic is 4727 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have an md2 model that won't be textured. Whenever I try the model just appears black. I thought previously this was because I was setting the color of the vertices to black, but I changed them to white, and I found that the model appears completely black when textured (the texture is a mostly black color). I thought this was strange, so I tried texturing with another texture, something which wouldn't properly fit on the model, but something that I would at least be able to see. The texture had a lot of blue, so the model ended up turning blue (a single color, not several shades). This is fairly confusing for me because using the same bitmap loading code I can load and display another bitmap on another model fine, so that leads me to believe that it is not the bitmap loading code. So the only thing left is the texture coords. Is it possible to verify that these are correct? This is how they are being calculated:
m_numST = modelHeader->m_numST;

stPtr = (stIndex_t*)&buffer[modelHeader->offsetST];

float height;
float width;
// if we don't have a texture
if( m_texture == NULL ){
	width = 1.0f;		// no texture coords
	height = 1.0f;
}
else{
	// set the proper texture height and width
	width = m_texture->getSize().width;
	height = m_texture->getSize().height;
}
// read in the texture coords
for (i = 0; i < m_numST; i++){
	m_vertexList.u = (float)stPtr.s / (float)width;
	m_vertexList.v = (float)stPtr.t / (float)height;
}

Any ideas what could be causing this apart from stuffed tex coords?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Quote:
Any ideas what could be causing this apart from stuffed tex coords?


How about a black texture?

Share this post


Link to post
Share on other sites
Well, I posted this almost 12 hours ago and have been checking it through the day with only 1 reply.

I think it deserves a bump.

Share this post


Link to post
Share on other sites
Try using a standard q2 model with a 256x256 map.
I had a problem like this long ago that was because my texture was at a different size than the models map.
I don't know if your problem is the same but you should give it a try.
Also be sure texturing is enabled...

Share this post


Link to post
Share on other sites
A few things pop into my mind: are you using lighting, and if not, have you tried setting the colour to white (since GL_MODULATE'd make the entire model black if you were using black for your colour, regardless of the texture).

Share this post


Link to post
Share on other sites
Well, I've got lighting disabled, and the color of each vertex is white. And since I don't know what GL_MODULATE is, its probably fair to say that I'm not using it.

This is the part of my code where I init OGL things:

glShadeModel(GL_SMOOTH); // enable smooth shading

glDisable(GL_LIGHTING); // lighting disabled
glFrontFace(GL_CW);
glEnable(GL_CULL_FACE);

glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);// really nice perspective calculations

glClearDepth(1.0f); // set gl clear depth
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

glEnable(GL_TEXTURE_2D); // enable 2D texturing



And, plus, I can load a simple cube from my own model file (just the vertices and everything written straight to the file, no compression or anything fancy), and I can texture it, and it works perfectly.

Share this post


Link to post
Share on other sites
Quote:
Original post by Endar
I thought this was strange, so I tried texturing with another texture, something which wouldn't properly fit on the model, but something that I would at least be able to see. The texture had a lot of blue, so the model ended up turning blue (a single color, not several shades).


This makes me think that there is something wrong with the texture coords on the model...

If you are able to render other md2s just fine, then when you performed the test stated above you would have expected the model to look like a mess of colors from the not-matching texture... even if the texture was not the standard size, you'd think that you would see more than one color.

is there a way to make sure that the model has texture coordinates that look right?

Share this post


Link to post
Share on other sites
Unless someone can give me an idea, I don't think there is an easy way.

I've been looking at them, and they haven't been anything stupid, the ones that I've seen have all been between 0-1, and, as far as I can tell with my beginner's experience, they look okay.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!