# md2 texturing

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

## 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;

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 on other sites
Quote:
 Any ideas what could be causing this apart from stuffed tex coords?

How about a black texture?

##### Share on other sites
This is the texture that I'm trying to use: linky

This is straight from the irrlicht engine v0.1

##### 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 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 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 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 shadingglDisable(GL_LIGHTING);		// lighting disabledglFrontFace(GL_CW);		glEnable(GL_CULL_FACE);glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);// really nice perspective calculationsglClearDepth(1.0f);		// set gl clear depthglEnable(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 on other sites
Quote:
 Original post by EndarI 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 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 on other sites
You might check my previous post. I had similar problems myself.

clicky

The part after previous post - is with error. Above it is the solved.

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631759
• Total Posts
3002138
×