PDA

View Full Version : ge2 vertices order



LiquidFlare
02-11-2004, 05:24 PM
I am trying to load a .ge2 file generated by maya into opengl. I have no problem parsing it, however I can not figure out the order in which the file stores an object's coordinates. What order and in what gl type do I need to render the object's coordinates with? Thank you for your time.

mikael_aronsson
02-12-2004, 03:30 AM
My first hit on google...
http://www.codeproject.com/useritems/ge2loader.asp

LiquidFlare
02-12-2004, 07:26 PM
I've read that page before (I actually Google everything first before I ask). The app that he made that you can download only parses and stores the vertices, it does not render the object. Maybe I just don't get what he is saying but I don't understand what order to render the vertices. I read them in order and tried to pass them through a vertex array using triangle strips, normal triangles, etc., but had no luck. So my question is, what order do you render the vertices and in what format (ie, triangle strip).

dvm
02-13-2004, 04:42 AM
I'm not helping much, but a while back I've tried loading some 3ds max files for opengl. The thing I noticed after some failed attempts to render the object correctly was that the object did not have only one type of polygon. It had quads, triangles, maybe even strips (I noticed it after loading the models in 3ds max which rendered them correctly). So my suggestions is that each "chunk" probably includes information on the type of polygons it has. If you are able to read these (I wasn't, didn't try as much), perhaps a simple switch statement can render the polygons correctly. Hope I've shed some light.

Nychold
02-13-2004, 06:06 AM
Okay, this is what the article is saying. In a GE2 file, there's a "list" of data:

name
vertList
normList
uvList
faceParts
triCount
tri

Actually, it's just data organized in this manner. I'm assuming you've already loaded the vertices, normals, and texture coordinates (u-v or s-t coords). Now, that "tri" entry is a list of indices. This identifies the element in the vertices list to be rendered, and all the indices are in groups of three. Therefore, you would render a GE2 file like this:




glBegin(GL_TRIANGLES);
{
int index1,index2,index3;
// Assume: int *tri;
// Assume: float *vertList;
// Assume: float *uvList;
// Assume: tri points to the next triangle
// to be rendered
// Assume: vertList points to the BEGINNING
// of the vertex list
// Assume: uvList points to the BEGINNING
// of the texture coordinate list
index1=*tri++;
index2=*tri++;
index3=*tri++;

glTexCoord2f(uvList[index1*2],uvList[index1*2+1]);
glVertex3f(vertList[index1*3],vertList[index1*3+1],vertList[index1*3+2]);

glTexCoord2f(uvList[index2*2],uvList[index2*2+1]);
glVertex3f(vertList[index2*3],vertList[index2*3+1],vertList[index2*3+2]);

glTexCoord2f(uvList[index3*2],uvList[index3*2+1]);
glVertex3f(vertList[index3*3],vertList[index3*3+1],vertList[index3*3+2]);
}
glEnd();


Slap a for loop around that, and you've just rendered an object...I think. ^_^ It's something like that anyway...pardoning any typos I make. XD

[This message has been edited by Nychold (edited 02-13-2004).]

LiquidFlare
02-13-2004, 02:40 PM
Actually, for some reason my file output is not organized in that manner. I have the following components in my file:

name
vertices
segments
faces
normals
uv-array
face-parts

What options in output did you set in Maya to get that file structure. Thanks.

LiquidFlare
02-13-2004, 02:47 PM
I think I understand what you are getting at however. It looks like the face section has vertice order. There are three values in each row and the biggest number is in fact the last vertice number. I thought this was wrong earlier because I output in quads once and the lines still had 3 points (which makes no sense for quads). I'll try that and get back to you guys. Thanks for all the help.

LiquidFlare
02-13-2004, 07:19 PM
Awesome. It works now. I can't thank you guys enough.