md2 texturing

Started by
28 comments, last by Endar 18 years, 5 months ago
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?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Advertisement
Quote:Any ideas what could be causing this apart from stuffed tex coords?


How about a black texture?

This is the texture that I'm trying to use: linky

This is straight from the irrlicht engine v0.1
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
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.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
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...
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:
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.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
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?
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.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
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.

This topic is closed to new replies.

Advertisement