Introduction
First of all, a little background on the code within.
What is it:
It's a neat little class that loads the GE2 file format as exported with Maya.
What can it be used for:
You can use it to load a scene or object exported by Maya GE2 file format. And then, you can modify further the structures and data / and or render it. Summing it up, use it in your 3D engine if you want to load Maya objects.
How does it work:
The intended way to use it is like:
- Simply include the ge2loader.cpp and hpp into your project.
- Proceed to make an instance of the object.
- Call the
loadGroup
method with a file name (sample object supplied).
Please note, if you really don't have any idea as to what GE2 is, then please do a bit of research. Or at least have a look at the file structure in the sample object, creatively called Dork.
#include "..\MODULES\objGameExchange2\ge2loader.hpp"
class ge gameExchange;
void main ( void )
{
int ret = gameExchange.loadGroup("dork\\dork.grp");
if ( ret==-1) cout << "error\n\n";
}
I don't feel that this class can be very useful to anyone at all unless they intend to plug it into a 3D rendering environment. In my opinion, GE2 export is probably the most useful of all the available exporters that you get with Maya. Future plans are to code an editor that utilizes this GE2; the editor being an intermediate tool that fine tunes the scene for game dev. purposes such as texturing, BSP generation etc... I know it's a big dream but I have had big dreams before, just have a look at my homepage.
At this time, I won't go into a detailed description on the file format or the loader code itself. But rest assured that it does work. Please visit my homepage for more information on my little coding projects.
I have had a few people asking me how to use the data structure for rendering, I have included this email where I explain how to use the data structure.
My reply to Mondi's query:
Sorry for the late reply, I have not been enthusiastic to look up the info to help you, primarily because I know I lost my source code to this long ago :( Anyway I'm bored today and decided to download the ge2loader.zip from my homepage and have a quick look and attempt to explain things to you :). So referring to ge2loader.zip. The object is called a
, within my demo code.
a.obj.cout
tells me there are 6 objects to render. The objects exists at a.obj.o[0]
to a.obj.o.[5]
.
An object is made up of:
name
vertList
normList
uvList
faceParts
triCount
tri
OK, let's do a theoretical example. What you want to do is render the first triangle. If you debug the demo code and have a look at the structure, you will see that the first Tri
of the first object named "InsideFaceShape
" expands to:
v[0]
= 454
v[1]
= 455
v[2]
= 1
This is telling me to look up those vertices:
So, to render the first tri
of the first object:
Beginrender() {
glvertex3f (
a.obj.o[0].vertList.v[a.obj.o[0].tri[0].v[0]].x,
a.obj.o[0].vertList.v[a.obj.o[0].tri[0].v[0]].y,
a.obj.o[0].vertList.v[a.obj.o[0].tri[0].v[0]].z,
)
glvertex3f (
a.obj.o[0].vertList.v[a.obj.o[0].tri[0].v[1]].x,
a.obj.o[0].vertList.v[a.obj.o[0].tri[0].v[1]].y,
a.obj.o[0].vertList.v[a.obj.o[0].tri[0].v[1]].z,
)
glvertex3f (
a.obj.o[0].vertList.v[a.obj.o[0].tri[0].v[2]].x,
a.obj.o[0].vertList.v[a.obj.o[0].tri[0].v[2]].y,
a.obj.o[0].vertList.v[a.obj.o[0].tri[0].v[2]].z,
)
}
OK, now I know it seems terribly complex, and when I did this code, I was rushing and didn't think out the structures well. One of the things that is probably confusing you is Obj
and o
... Instead, I should have named:
Obj
as ObjList
- and
o
as Obj
Another thing is faceParts
, I cant remember exactly.. but what it is that each triangle has a material description.. best way to analyze it is to start debug mode and expand the structure in a Watch list.
As far as this goes for use in a big project, it probably isn't good enough, but it's fairly useful to load all the text files into a structure, and hopefully is quite usable for testing.
> "mondi" "RJ++" <robertj@nettaxi.com> [CodeProject]
> Game Exchange 2 File LoaderDate: Sun, 27 Oct 2002 05:32:17 -0500
>
>Hi there,
>
>I've been experimenting with the ge2 format for awhile now,
>your code helped me clear up a few issues i was having.
>
>question though, being not a terribly good programmer
>could you point me in the right direction for
>accessing the vertex/face/normal lists so that
>I could get my app to render the objects?
>
>it would be incredibly helpful :)
>
>thanks
>
>mondi