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;
}
md2 texturing
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:
Any ideas what could be causing this apart from stuffed tex coords?
Quote:Any ideas what could be causing this apart from stuffed tex coords?
How about a black texture?
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.
I think it deserves a bump.
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...
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...
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).
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:
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.
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.
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement