MaLoader. .ma Maya Ascii Scegegraph parser for jME loading and other uses

I am doing a little finishing work on mapspinner to wrap things up, should be done with that tomorrow.



Tonight it dawned on me.



Please bare with me for a second, I promise everyone coding at jme like mad that this will be worth your time.



We need to start a project asap to fill a gap that stands in jme's path of becoming a usable engine for games.



The way I see it we have two major problems in jme.



1: It is horribly difficult to get you own content out of an app such as maya into the engine and use it. For a beginner checking out the engine for possible use it would take days or even weeks, an intermediate developer should be able to get something usable in a day or two since everything is hard the first time. By usable I mean a static model with textures.



2: It is basically impossible to build a decent level (be it with rooms or without) without coding less than 50 pages of java for various reasons such as culling optimization etc. (I know anything is possible so skip the silly comments)


  • JME is a scenegraph engine, and for level design this could actually be very good, but a lot of people are under the impression that they need binary space partitioning or octrees or something similar to have a level, this is not entirely true, scenegraph trees can be optimized quite nicely and make things very easy from a development perspective.


  • Maya (and all other 3D modelling apps) is a scenegraph based program. Trees can be designed by hand and it actually doesnt take much more time than making the computer build trees. Bounding boxes for portalling and culling could be modeled and exported/imported.



    Here is my proposal for a project:



    If you read the jme2 todo list, you'll see maya exporter, I think thats the wrong way to go about it, we all love java, and jme and are very familiar with it, in fact a lot of us know the structure off by heart. Most of us wont go and learn how to code things for maya just for a single project.



    What we need is a maya ascii importer project. The ultimate goal is to have added to the jme code an importer that will allow you to design models and levels in maya, load the .ma file in java and save it as a jme scenegraph.



    The development of such an importer would have to be in 3 tiers:



    1: Make something that will read a model from a .ma file using jme's importing system.

    2: Expand it to allow for multiple models and tree's to allow building a jme scenegraph.

    3: Build on that to allow for things like culling groups (cull out a room if you cant see it and stuff like that) int/exterior seperation et al.



    It's not such a big and terrible project to parse a maya ascii file.



    The added benefit of using an importer is testing and fixing. Any problem you experience could only lie in one place, the importer. Maya's .ma format is virtually perfect, its been used since forever for tiny and humungus scenes. So if anything goes haywire, we know the fix will lie in parsing and building jme's graph.



    Who's with me? I'm starting tonight and will keep you guys posted.


sounds like a good idea.

I guess directly importing the maya file is easier and less error prone, than to first export it to yet another format and then import it.

I would suggest creating a (temporary) google code project for the maya importer, that way, everyone who want to work on it can join that project, when its in usable state you can commit it to jme.

lanmower said:

It is horribly difficult to get you own content out of an app such as maya into the engine and use it.


I agree. That's true. For my projectss (Infernalek and IR Editor) I have spent many hours trying to find optimal (any...) workflow for 3DStudioMax <-> JME particulary with 3D morph-target based animated models. fortunately I have found one but it's terrible workflow. There is a lack of Maya/3D studio max exporters to JME format (binary and XML). I could write myself such exporters but the main problem is lack of time.

So do you guys want some code to work on?



I'll post this in the meantime, I coded like 24-hours flat on it so it will have some mess that I have missed.



http://pastebin.com/m6f86c3e4



I can triangulate a single model in maya 2008, remove the history and save it. Then load it into jme.



things that I havent gotten to testing yet is multiple models and hierarchies. Should work a little, I havent tested uv's yet cause I never loaded a texture on it. Just builds a scenegraph with the models from you scene, nothing more yet.



The main idea was to import a sphere so far. So dont expect too much.

Added this projects code to mapspinner, I hope nobody takes this personally or anything, just dont want two google code projects to bloody update. Bandwidth costs mega bucks where I live.



you'll find the sources in the

maloader

and

comjmeutilexportma



folders…



I can now import most maya models once I triangulate them and delete their history, cool eh?



I want someone to help me with the uv coordinates, I cant get something right and they end all screwed up, the relevant code is at line 90 of MaMesh.java.



If you uncomment mamesh.java as of line 110 it will run some optimizations like stripifying, could be good.



This currently only parses maya 2008 ascii's I have a copy of maya 7.0 too and will try my best to add compatibilaty.

Have modified and cleaned the code a little.



I'm struggling a bit with the uv coordinates, the new code seems theoretically correct according to maya's helpfile. (See api guide->how polygons are handled internally).



However they look rather odd when rendered in jme.



beh.

Theres like one other .ma reader on the internet and its written in actionscript it seems.

http://www.entermation.com/source/MAYA_ma_import.ls



hell if they can do it in actionscript I can do it in maya.

Internet is bloody expensive here so if anyone can search around and find other sources in any language (I can read most) I would greatly appreciate it.

I decided to help you out a little since this might be somewhat useful to me.



Here are some links I found that could be useful:

http://www.gamedev.net/reference/programming/features/mayaexporter/

http://caad.arch.ethz.ch/info/maya/manual/FileFormats/FileFormats.fm.html

http://caad.arch.ethz.ch/info/maya/manual/FileFormats/index.html



Sorry, I don’t own Maya so I won’t be able to help you code.

Hi


lanmower said:

2: It is basically impossible to build a decent level (be it with rooms or without) without coding less than 50 pages of java for various reasons such as culling optimization etc. (I know anything is possible so skip the silly comments)

- JME is a scenegraph engine, and for level design this could actually be very good, but a lot of people are under the impression that they need binary space partitioning or octrees or something similar to have a level, this is not entirely true, scenegraph trees can be optimized quite nicely and make things very easy from a development perspective.

I'm already working on these aspects, I have implemented a kind of cells-and-portals subdivision in a simplified case as a first step. The portal culling is still a bit buggy (I use then the frustum culling until its bugs are fixed) but I have a showcase with a quite big level. I thought JME 2 supports BSP at least :( Therefore, if you plan to implement the same algorithm, look at my source code instead of starting from scratch.
SomethingNew said:

I decided to help you out a little since this might be somewhat useful to me.

Here are some links I found that could be useful:
http://www.gamedev.net/reference/programming/features/mayaexporter/
http://caad.arch.ethz.ch/info/maya/manual/FileFormats/FileFormats.fm.html
http://caad.arch.ethz.ch/info/maya/manual/FileFormats/index.html

Sorry, I don't own Maya so I won't be able to help you code.


You may be able to help yet... I could give you a .ma file to look at!.

You sould tell if if you're willing...

By the way: Maybe I model loader for .x files would be useful, what do you think?

Custom said:

By the way: Maybe I model loader for .x files would be useful, what do you think?

There is already a workaround to load them by converting them into another format supported by JME 2 but it would be easier to be able to use them directly. For example, the models provided with FPS Creator are all in .x format.

@lanmower: Do you see this project extending beyond Maya once the support for Maya is starting to mature?



It might be that there are people on 'the other side of the fence' who would be willing to help with this sort of thing as well, so maybe if you're involved in some Maya communities already, you could ask around a bit? I'm not too involved in any of the modeling communities (but Blender here I come!) but I do have quite a few affiliates in Max, Maya, Blender & Cinema4D. I'll make some inquiries and see if they know some people who might be interested.

This topic inspired me to write 3D Studio Max exporter for JME :slight_smile: If I write sth constructive I'll post it here or I'll start new topic.

Great feedback and ideas guys! Thanks for your activity.



I have discovered something new about the texture uv problem.



Maya has an array of indices for both vertices and uv's.



I suppose jme lterates the uv coordinates by vertex indices so that:



vertex 15 = vertex buffer (of floats) 45 46 and 47 for x y and z

and thus the uv 15 = 30 and 31 for u and v



If that is the case, I need to reverse the method I'm using…



What my loader currently does is write out a stream of uv's from the first used uv to the last as per the index buffer

so the uv buffer is 2 floats times the size of the index buffer, but what its supposed to be is 2 times the size of the vertex data buffer divided by three. That will give me 2 uv's for every vertex and not 2 uv's for every index. The problem is finding the corresponding uv for a vertex.



I suppose then jme can only have one uv for every vertex in a trimesh, while maya can split the uv's into two if they are shared by two faces… this is in order to have a model have multiple peices of a texture be used for different connected bodyparts. Can anyone shed some light on this? I hope I havent rambled in this post.



Can someone shed some light on this if I'm incorrect?



The reason I think its so is because when I copied the uv buffer directly from the maya file into jme it looks almost right.

I suspect something very similar to what I have to do is happening in md2tojme… around line 350.



Will look into it.

Ok :slight_smile: I've got a 3ds max 2009 exporter to JME XML format :slight_smile: Currently it works very well. It exports static geometry and animations :slight_smile:

Hi,



I am interested in your project.



I download mapspinner's code and I did test but I can't load a scene of Maya.



I create a sphere with polygons and I triangulate and delete the history and I save the scene in ma.



I run the MaLoaderTest.java and throws this in the console:



13/06/2009 11:29:36 PM com.jme.renderer.lwjgl.LWJGLRenderer draw

GRAVE: missing indices on geometry object: pSphereShape1 (com.jme.scene.TriMesh)

13/06/2009 11:29:36 PM com.jme.renderer.lwjgl.LWJGLRenderer draw

GRAVE: missing indices on geometry object: pSphereShape1 (com.jme.scene.TriMesh)

13/06/2009 11:29:36 PM com.jme.renderer.lwjgl.LWJGLRenderer draw

GRAVE: missing indices on geometry object: pSphereShape1 (com.jme.scene.TriMesh)

13/06/2009 11:29:36 PM com.jme.renderer.lwjgl.LWJGLRenderer draw





I am using Maya 2009 and I don't know the difference of ma file between Maya 2008 and 2009.



Can you help me??



Thanks

Regards

Wow, from which format do yo export from .max?

Yes. Directly from 3ds max.

Hei, where can I get this :slight_smile: