iDevGames Forums
Convert Maya model into OpenGL - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Convert Maya model into OpenGL (/thread-5243.html)



Convert Maya model into OpenGL - creater16 - Jul 25, 2005 07:53 PM

Hello all, i am doing a project which is needed to create a 3D environment with interactive control. I know it is easier to just draw all the complex images in MAYA(.ma .API or .obj format maybe) and then import to OpenGL. But i am just wondering how to convert it into openGL code(without data lost).


thanks alot !!


Convert Maya model into OpenGL - OneSadCookie - Jul 25, 2005 08:43 PM

It's quite easy to make a program to read .OBJ files. If you search the forum you'll find plenty of threads about it, including some with example code.


Convert Maya model into OpenGL - AnotherJake - Jul 25, 2005 09:20 PM

Other than using the .obj format, which is quite limited, the out-of-the-box plug-ins to export from Maya for games have been deprecated as far as I can tell, but you might still find documentation for them as "Games Translators" in the Maya docs folder in the GamesTransfer directory (click on index.html of course). I don't remember the proper way to get to it through the Maya help menu, but you can find it there too I think. Other than that there are two other practical ways to get data out of Maya and into your own OpenGL program as far as I have discovered. Neither of them are easy by any stretch of the imagination for anything more than just plain mesh data (even that can be tricky with Maya unless you just export .obj). Both of them involve writing your own exporter and importer. One, you can try to export all your data through MEL but it's often slow as mud. Or two, you have to go through Maya API which is super fast but presents many issues and is time-consuming to develop with since linking to it takes about two minutes per build on a dual 867. I have messed with option two for a while and it's not impossible but there are many issues and bugs to overcome.

I don't know how much experience with 3D coding you have, but if you're trying to make an entire complex scene and have it be interactive I would honestly recommend going with something like Blender instead.


Convert Maya model into OpenGL - creater16 - Jul 26, 2005 02:58 AM

AnotherJake Wrote:if you're trying to make an entire complex scene and have it be interactive I would honestly recommend going with something like Blender instead.


Blender? would you mind explain more about that please.


Convert Maya model into OpenGL - OneSadCookie - Jul 26, 2005 03:23 AM

http://blender3d.org/


Convert Maya model into OpenGL - unknown - Jul 27, 2005 05:59 AM

You could write a plugin for maya that exports the object into a .c and .h file that would just draw all the polygons and stuff individually. So what you would end up with is a .c file with 500 lines of opengl code that needs put into a display list which is what an obj loader would do anyway.


Convert Maya model into OpenGL - AnotherJake - Jul 27, 2005 09:53 AM

If you're going through Maya API, it's actually much easier and more space efficient to export your objects from Maya as binary data and simply load them into your GL program and feed the data to something like glDrawElements instead. Getting it into your program is not the problem, it's all the hoops you have to jump through to get it *out* of Maya in the first place. Maya API can be a real bear to deal with, and Maya itself will rarely leave a clean data set for you, which means you have to clean up the geometry yourself before you export it. Using MEL you'd probably output a text file or two and you could do as you suggest. I wouldn't export a .c file though. It would be wiser to have generic drawing code in your program which automatically knows what to do with any of your imported Maya data.


Convert Maya model into OpenGL - unknown - Jul 27, 2005 10:03 AM

What I mean is to export from maya somthing similar to this:

.h: draw()
.c: void draw() { glCircle(0, 0, 10) glLine(-1, 1) }

<fake code>

Then your code would just call that method instead of using a data resource and loader, its a bad method though I just thought thats what creater16 was looking for.


Convert Maya model into OpenGL - AnotherJake - Jul 27, 2005 11:24 AM

unknown Wrote:What I mean is to export from maya somthing similar to this:
I understood what you suggested. I am trying to communicate to you that it's just plain impractical to do things that way. You shouldn't build complex data into your program. Using a loader is the only practical way to go. 1) It's easier to modify the data without having to re-build your application. 2) A program with all the data built into it will create a large memory footprint when it's launched. There is no need to have all the data for all the levels of your game in memory at the same time; it's better to load them as needed instead. 3) It's a pain in the rear to bother formatting text with GL commands in them. It's much easier to dump floats to disk either binary or text. Text is unecessary for private use since you don't need to explain the format to others. 4) It's easier to read one generic drawing routine that handles all of the data in a few lines rather than seemingly endless lines of custom GL code for each object.

I have an old test program that I wrote to load and draw models from my first Maya exporter. The file that does all of the loading and drawing is a whopping 291 lines with lots of fluff and comments. It's extremely simple to load a chunk of data that is already preformatted for glDrawElements or whatever you wish. If you're writing your own export plugin you quickly figure out that you can format that data on the way out in surprisingly simple ways so that your program on the other side doesn't have to do much work. The way you suggested is not simple, nor is it practical.


Convert Maya model into OpenGL - unknown - Jul 27, 2005 11:48 AM

I agree completly, I wasnt suggesting its what they should do but explaining how they could do what I thought they were asking.


Convert Maya model into OpenGL - aarku - Jul 27, 2005 01:09 PM

If you are just looking for end results, you may want to check out Unity.

http://otee.dk/unity/

Adding a Maya scene is two drag and drops. If this doesn't sound like your intentions, ignore me. Smile

-Jon


Convert Maya model into OpenGL - creater16 - Jul 27, 2005 07:18 PM

AnotherJake Wrote:I have an old test program that I wrote to load and draw models from my first Maya exporter. The file that does all of the loading and drawing is a whopping 291 lines with lots of fluff and comments. It's extremely simple to load a chunk of data that is already preformatted for glDrawElements or whatever you wish.

Thankyou AnotherJake, but i am just wondering wold you mind sending me your maya exporter as my reference please?

many thanks


Convert Maya model into OpenGL - AnotherJake - Jul 27, 2005 09:38 PM

Sure I guess. I just sent you an email. I don't want to share my animation code (sorry) but I can send an older hacked-up version that exports the models as materials, triangles, vertices, normals, and texture coordinates. The code was developed partly from the Maya dev docs, partly from Brian Greenstone's book, and partly from my own maniacal concoctions, so don't expect it to make much sense! If you're developing on Windows, then the Cocoa code probably won't make much sense either.


Convert Maya model into OpenGL - creater16 - Jul 28, 2005 03:58 AM

i have sent you my E-mail already. thanks