Using MEL to construct a custom ascii file format

Hi guys,

I would like to write a script in MEL that would allow me to output the geometry data in my custom ascii file format.

In order to do this I need to know the MEL hooks which allow me to access the gemotry data. Can anyone provide hints/tips/help with this??

Cheers,

Mark.

The answer to your questions depends on what information you want from what types of objects.

I wrote a custom ascii text file exporter for our game engine, and am in the middle of another one. I am only concerned with writting the worldspace positions, the type of object in the scene , and some custom attributes on those objects.

It really is quite easy to accomplish, I just need some more information to give you an accurate answer.

Thanks for your reply Mike, much obliged.

My basic requirements are:

Light info.

For each object
Material name
Env map?
for each vertex
position
normal information
colour
texture info (name, 8 x texture co-ords)
(texture co-ords for bump maps etc)

We are unhappy with Maya's built in exporters (especially the vrml export) so felt it would be useful to create our own!

Cheers,

Mark.

I think you would be much happier if you did this in the API as opposed to MEL. An exporter written in C is going to be a lot faster than one that runs in MEL. Unless you are working on a project of very small size, Having a slow exporter is going to really kill you in the long run.

--JeffD

Thanks, Jeff.

What C API commands are required to carry this out?

also - can you point me at some documentation for carrying out such a task?

Cheers,

Mark.

actually I've written very effective MEL-based exporters for all of this stuff, and it's not that bad speed-wise. The only way to do it, though, is to query each attribute separately and assemble the information however the output file format requires.

Depending on what you're doing, the API MIGHT be overkill for the problem, although if you're building your exporter to last for years it's probably worth it to engineer it to last.

-- Mark

Here is a quick outliine of the functionality of my exporter.

Get the input from the interface for location to save the file, the name of the file, and a prefix for all the objects.

For each object in my selection list:

I get the objects history. I then step through the history and get the nodeType of each member of the history. If the nodeType is a skinCluster I write out the object in a certain format, if the nodeType is "locatator" I write the info out in a different format, and if I get to the end of the history without encountering either of the above nodeTypes, I write it out in a third format.

When I'm writting the data, I get different things for each type of object. There are some common things between all objects, like position in world space, and rotation in world space.

All of the special case data is written based on whether the object in question has custom attributes assigned to them i.e. if I want to tell the game that a certain object uses morph targets I apply a custom attribute called "morph" to the object, when my exporter encounters the "morph" attribute, it checks the value of the attribute and if it is 1, it writes the object out as a , if the value is 0 or it doesn't find the attribute, it moves on.

Using the above method, I am about to start writting an exporter that will be used to define our cameras, trigger sounds and particle effects, allow tagging of animations, all based on data inside of Maya. I will be using custom attributes assigned to special objects (probably locators) to write out animation script files, camera data files, and probably a couple other files as well.

Hope that gives you a little insight as to what is possible, and maybe a little pointer in the right direction to start.