Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dopeflow

Rendering a .md2 via vertex array, texturing problem

This topic is 5608 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

K so Ive managed to render a md2 animated mesh using a vertex array with no problem at all, but Im running into some problems with the texturing. Basically Im just not sure how to load the texture array that you pass to glTexCoordPointer(2, GL_FLOAT, 0, texVB); every frame. I thought it would be something like: texVB= new float[2*m_numVertices]; and then for each vertices load the (s,t) values but apparently the number of texture coord can be different than the number of vertices? Anyway just looking for some pointers, right now I can texture the mesh but its just textured badly. Like not the right uv values for sure.

Share this post


Link to post
Share on other sites
Advertisement
You want to have 6 values for each poly. One (s,t) for each (triangular) Facet's corner. A mesh does have more Texture vertices than geometry vertices because the same Vertex can be "attached" to more than one part of the skin. For example, two contiguous poly's are mapped to different parts of the skin, the two vertices that they share can't have the same texture coords for both polys.

M


--------------------------------------------------
"I have never let my schooling interfere with my education. " --- M.Twain
Marcus Hays
www.phrenicgames.com

[edited by - mhays on May 4, 2003 6:07:32 PM]

Share this post


Link to post
Share on other sites
K well i mean what i do seems logical to me....
I load the md2 header and get the number of st''s from that.

Then create a "buffer" to the texture info in the file.

stIndex_t *stPtr;
stPtr = (stIndex_t*)&buffer[modelHeader->offsetST];
texVB= new float[2*m_numST];

and load up the st''s into my array which is the array i pass
to glTexCoordPointer(2, GL_FLOAT, 0, texVB);

for (t = 0; t < m_numST; t++)
{
texVB[2*t+0]= (float)stPtr[t].s / (float)m_modelTex->width;
texVB[2*t+1]= (float)stPtr[t].t / (float)m_modelTex->height;
}

That should work no?

Share this post


Link to post
Share on other sites
i think u load the texcoords right but how do u render the object?

btw if ur using a vertex array, how do u do the animation between keyframes (do u load another array with interpolated values? )

Share this post


Link to post
Share on other sites
I just render using glDrawElements, calling glTexCoordPointer before... its textured, just badly textured.

As for how I use vertex arrays with animation,
its simple you create an array
float *vertexB[number_of_frames];
then you load all the arrays for all the frame like this

for(int f= 0; f < number of_frames; ++f)
{
vertexB[f]= new float[number of vertices of mesh];
for(int v= 0; v < number of vertices; ++v)
{
load up vertices...
}
}

This makes up for a pretty big array im aware , but I have a mesh manager that makes sure each mesh is only loaded once so its not too bad.

[edited by - dopeflow on May 5, 2003 6:50:34 PM]

Share this post


Link to post
Share on other sites
mhays what you said could be right I think, I tried though but its not working either.

Heres how I load the texture array now:


  
texVB= new float[6*m_numTriangles];
for(int t = 0; t < m_numTriangles; t++)
{
texVB[6*i+0]= m_st[m_triIndex[t].stIndex[0]].s;
texVB[6*i+1]= m_st[m_triIndex[t].stIndex[0]].t;
texVB[6*i+2]= m_st[m_triIndex[t].stIndex[2]].s;
texVB[6*i+3]= m_st[m_triIndex[t].stIndex[2]].t;
texVB[6*i+4]= m_st[m_triIndex[t].stIndex[1]].s;
texVB[6*i+5]= m_st[m_triIndex[t].stIndex[1]].t;
}


This is after I load up the tri index obviously, which I know is right because when i rendered vertex per vertex it was working perfectly.

Just need to get that damn texture array working hehe
im doing 0 - 2 - 1 order because thats how it was in the book, but I also tried 0 - 1 - 2, not working either. Texture is still badly applied.

[edited by - dopeflow on May 6, 2003 7:35:08 PM]

Share this post


Link to post
Share on other sites
Been trying the same thing.
ran into the same problem.

to draw it I simply loaded the vertex(s) into the card,
Then called them glDrawElements.

the problem is the one vertex can be use for many triangles.
as well as one vertex can have many texture points.

If you want to do all the drawing in one call then you need to make the vertex to texture arrays a one to one relationship and ajust the calling list to suit.

this has the virtue of speed, but the problem of more memory needing to be both allocated and then pushed across the buffers.

my 2cents.



Armand
-------------------------
It is a good day to code.

Share this post


Link to post
Share on other sites
hmm there has to be a way around this, the quake2 models arent perfectly fit (the number of STs can be different than the number of vertices) and im sure they render via vertex arrays too.

I know theres a way

Share this post


Link to post
Share on other sites
Anyone has been able to render a md2 with vertex arrays, using glVertexPointer
and
glTexCoordPointer

with correct texturing??

Share this post


Link to post
Share on other sites

  • 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!