PDA

View Full Version : anybody familiar with blind data editors and exporters supported by maya for instance



wildeyedboyfromfreecloud
02-11-2002, 05:20 PM
just curious. i've been eyeing the function in maya. but i'm having trouble deciphering the manual. and i'm not sure if it is supported independant of maya. seems rather counter intuitive in this authors opinion. well what i don't understand about it is how to get an array of data types like vertecies for instance. well if no one is interested i won't ramble forward. just curious
sincerely

Micahel

jwatte
02-11-2002, 05:48 PM
The Maya SDK should contain sample exporters that you can start from. I say "should" because I don't have Maya experience beyond looking at their web site http://www.aliaswavefront.com/en/WhatWeDo/maya/see/solutions/m_builder.shtml (3DSMax comes with several exporter samples, as does Blender)

wildeyedboyfromfreecloud
02-11-2002, 06:01 PM
yeah i would rather work with 3DS files. since someon has deciphered their data structure as i understand. but i currently don't have a windows 98 computer to put it on. so i haven't really considered the option. i'm using mostly OBJ files. and a SDL technique that i got from my computer graphics textbook for my raytracer. i have obj that supports materials textures hard and soft normals and calculates shadow planes. i would like to be able to preprocess shadow planes i think i will write a routine that rights obj files with shadow planes and neihboring face data tonight. but i won't to use a bone tree architexture and other data such as animation that i would like to be able to export from modeling software like maya 3dmax and whatnot. until i can write my own modeling routine. but i can't find any people to help me develop my graphics engine so my time is rather divided. hopefully i will. but in the meantime i'd rather be able to use the blind data editor if it is worth anything rather than taking a break to write an interactive data editor.


Originally posted by jwatte:
The Maya SDK should contain sample exporters that you can start from. I say "should" because I don't have Maya experience beyond looking at their web site http://www.aliaswavefront.com/en/WhatWeDo/maya/see/solutions/m_builder.shtml (3DSMax comes with several exporter samples, as does Blender)

Rob The Bloke
02-12-2002, 01:29 PM
used quite a lot of the Maya SDK, it's a bit unfriendly when you first take a look, but it doesn't take long to get what you need. (took a week for my first exporter which supported everything I needed at the time and has been extended every so often....).

The Maya SDK provides the source code for the obj file translator, which should be a fairly useful way of getting what you need in a format that you're already familiar with. Essentually, the SDK provides a set of base-classes to write your own plugins. For example, all file translators are derived from MPxFileTranslator, which provides some methods for you to overide, the one of most interest to you is `writer` which is called when you need to export the file.

All objects in Maya are stored as MObject's, essentually a handle to the object that informs you of what type it is through the function `apiType`. If you find a node that is of some use, you can use a function set to retrieve the data from the node ( all beginning with MFn, ie, MFnMesh ).

In maya there are two main types of node :

a dag node is a node that is present in the scene hierarchy, and is always either a shape or a transform. You'll need to traverse the scene graph and pick out the useful nodes (use the MFnDagNode function set to call `isIntermediateObject()` to determine it's usefullness...). All meshes, joints, lights camera's etc are DagNodes.

the second is a dependency node (from which the dag nodes are derived). This details any node that can exist as data in Maya. For example, materials, textures etc....

A few additional points that may catch you out :

1. If you are going to sample any animated joints etc, store MDagPath's to the node and re-bind the function set for each node everytime you move the current time on.

2. MObjects can become invalidated if the frame changes.

3. The file translator should have an additional mel script that creates the export options UI.

4. If you want to find connections between attributes, use the MFnDependencyNode.findPlug() function to get a plug node to the attribute you want to check. Check that plug node's connections to see if any of the nodes at the other end are useful, (for example, you can query the "color" attribute of a material to get the texture node, or the "rotateX" attribute of a joint to find any animation curves)

5. Have a look at the "exportSkinClusterCmd" plugin example to see how to grab skin weighting info.

as an additional suggestion, you may want to have a look at the dot XSI file format (I personally feel it's one of the best formats available, and is easy to extend), the www.softimage.com (http://www.softimage.com) website provides a freely downloadable FTK for the file which includes file loaders and full file format specs. It also has a 3DS max exporter for download, and there are a couple of Maya exporters in development.....

wildeyedboyfromfreecloud
02-12-2002, 03:47 PM
i'm assuming dag objects are Directed Acyclic Graph nodes. correct me if i'm wrong. i've looked through it. earlier this morning i created a skeleton and opened up it's attribute spread sheet and just copy pasted the translation data. which is all you really need because from what i gather each translation is relative to the orientation of the parent joint. then i arranged them so that they are in a logical parent child ordering. so i have a file but surely there is a better way. hopefully i won't need a recursive algorithm to read the file data. probably will. i just haven't spent enough time to the maya sdk. if i can't work out an inverse kinamatics algorithm i will have to get animation data somehow. i was thinking i would use 3ds when the time comes. i think i will check out the obj exporter source code now out of curosity. i really apreciate the attention

Michael

wildeyedboyfromfreecloud
02-12-2002, 04:07 PM
hey, i checked out some source code for exporting animation. and i just realised that maya ascii format is not encoded. i will have to look into that. thanks

Rob The Bloke
02-13-2002, 12:08 AM
> i'm assuming dag objects are Directed Acyclic Graph nodes.

yup, basically the DAG graph holds a series of input/output connections that start you from the original shape and take you through a series of transformations, deformations etc to get to your final object. The idea is that it's a bit more flexible than your standard hierarchies.

> so i have a file but surely there is a better way......

yup, the way I retrieve the animation data is fairly simple, and I've finally got back to my usual machine so this time it'll come with some source code.....

First off I build up a very basic set of structures that hold all of the transforms in the scene by way of references (note, I never grab the data from the scene until the point at which I output it. The main reason is one of memory requirements. Maya is a bit memory hungry, and the scenes created by an artist can be huge in size, so I try to minimise memory overhead.)

the transform reference structure i use looks like this :

struct SXFormRef
{
SXFormRef() : parent(NULL),bUsed(false) {}

MDagPath path; // the path to the object through the dag hierarchy
bool bUsed; // flag to determine if this node is required for export
MString name; // the name of the transform

SXFormRef* parent; // pointer to the parent of the node
std::vector< SXFormRef* > children; // a list of this nodes children
std::vector< SShapeRef* > geometry; // a list of the geometry under this node
};

you may notice the array of geometries that can be children of the transforms, these can be lights, camera's, meshes, curves etc, the structure I use for those are :

struct SShapeRef
{
SShapeRef() : bUsed(false) {}

MDagPath path; // path through the hierarchy to the node
MString name; // the maya name of the shape
bool bUsed; // is the node used.
};

I hold MDagPaths to the objects because these are guarenteed to be valid at any point during export.

After the writer function is called, I build up all of these references by walking through all the dependency nodes in the scene once and storing any known node type in one of four lists, transforms, shapes, materials and textures.

This looks a wee bit like :

MItDependencyNodes iter(MFn::kInvalid);
for(;!iter.isDone();iter.next()) {
MObject object = iter.item();
bool output = true;
if(object.hasFn(MFn::kDagNode)) {
MFnDagNode fnDAG(object);
if(fnDAG.isIntermediateObject())
{
output = false;
}
}
if(output) {
switch (object.apiType())
{
// if the node is a shape, ie, it has a parent transform
// then generate a SShapeRef node and add to the list
case MFn::kMesh:
{
MFnDagNode fnDag(object);
SShapeRef *pShape = new SShapeRef;
pShape->name = fnDag.name();
fnDag.getPath(pShape->path);
m_aShapeList.push_back(pShape);
}
break;

// if the node is a transform, then generate a SXFormRef
// structure in the list for this node. It will be checked
// to determine hierarchy information.later
case MFn::kTransform:
case MFn::kJoint:
{
MFnTransform fnTransform(object);
SXFormRef *pTransform = new SXFormRef;
fnTransform.getPath(pTransform->path);
pTransform->name = fnTransform.name();
m_aSceneTree.push_back(pTransform);
}
break;
default:
break;
}
}


This is slightly cut down a bit cos I grab a load of extra things like lattice, blend shapes etc....

Once all data nodes have been retrieved, I walk through all of my references and work out what is parented to what :

for(i=0;i<m_aSceneTree.size();i++)
{
MFnTransform fnTransform(m_aSceneTree[i]->path);
// work out if this node has a parent
if(fnTransform.parentCount() > 0) {
MFnDependencyNode fnParent(fnTransform.parent(0));
for( j=0; j < m_aSceneTree.size(); j++ ) {
if( fnParent.name() == m_aSceneTree[j]->name ) {
m_aSceneTree[i]->parent = m_aSceneTree[j];
break;
}
}
}
// process each of the children
unsigned int iChildCount = fnTransform.childCount();
for( j=0; j < iChildCount; j++ ) {
// if the child is a transform
if( fnTransform.child(j).hasFn(MFn::kTransform) ) {
MFnDependencyNode fnDep( fnTransform.child(j) );
// get the reference that we held for it
for( k=0; k < m_aSceneTree.size(); k++ )
{
if( m_aSceneTree[k]->name == fnDep.name() )
m_aSceneTree[i]->children.push_back(m_aSceneTree[k]);
}
}

// if not a transform it must be a shape so see if we have it
else {
MFnDependencyNode fnDep(fnTransform.child(j));
// get the reference that we held for it
for( k = 0; k < m_aShapeList.size(); k++ ) {
if( m_aShapeList[k]->name == fnDep.name() )
m_aSceneTree[i]->geometry.push_back(m_aShapeList[k]);
}
}
}
}

having built up the hierachies, I walk through the data I've recovered and flag which nodes I want to export. This usually involves pulling out the default Maya camera's and removing transforms that have no effect (hence the bUsed flags).

I tend to grab the animation as hermite curves for specific attributes, using the following function :

//////////////////////////////////////////////////////////////////////////////
// proc : rglExport: http://www.opengl.org/discussion_boards/ubb/redface.gifutputAnimCurve()
// params : node -
// attribute - the attribute to output
// returns : true if output ok
// notes : queries the values of the attributes and locates an animation
// curve if present.
//////////////////////////////////////////////////////////////////////////////

bool rglExport: http://www.opengl.org/discussion_boards/ubb/redface.gifutputAnimCurve(MDagPath &node,const char *attribute)
{
MFnDependencyNode fnDep(node.node());

// identation for ascii export
//
MString tabs = "";
for(unsigned int i=0;i<level;i++)
{
tabs += " ";
}

// find the attribute plug
//
MPlug Attr = fnDep.findPlug(attribute);

// find any connections to the attribute
//
MPlugArray attrConnections;
Attr.connectedTo(attrConnections,true,true);

MFnAnimCurve fnAnim;
unsigned int iKeyCount = 0;

// find an animation curve.
//
for(i=0;i<attrConnections.length();i++)
{
if( attrConnections[i].node().apiType() == MFn::kAnimCurveTimeToAngular &#0124; &#0124;
attrConnections[i].node().apiType() == MFn::kAnimCurveTimeToDistance &#0124; &#0124;
attrConnections[i].node().apiType() == MFn::kAnimCurveTimeToTime &#0124; &#0124;
attrConnections[i].node().apiType() == MFn::kAnimCurveTimeToUnitless &#0124; &#0124;
attrConnections[i].node().apiType() == MFn::kAnimCurveUnitlessToAngular &#0124; &#0124;
attrConnections[i].node().apiType() == MFn::kAnimCurveUnitlessToDistance &#0124; &#0124;
attrConnections[i].node().apiType() == MFn::kAnimCurveUnitlessToTime &#0124; &#0124;
attrConnections[i].node().apiType() == MFn::kAnimCurveUnitlessToUnitless )
{
fnAnim.setObject( attrConnections[i].node() );
iKeyCount = fnAnim.numKeys();
break;
}
}

// get the current value of the attribute
//
float fValue;
Attr.getValue(fValue);

// output data
//
if(m_bAscii)
{
fprintf(m_File," %s%s VAL %f KEYS %d",tabs.asChar(),attribute,fValue,iKeyCount);

// output the keyframe information (if any exists)
//
for(unsigned int j=0;j<iKeyCount;j++)
{
float time = fnAnim.time(j).as(MTime::kSeconds);
float value = fnAnim.value(j);
float inTangent,outTangent,tmp;
fnAnim.getTangent(j,tmp,inTangent,true);
fnAnim.getTangent(j,tmp,outTangent,false);

fprintf(m_File," VAL %f TIME %f IN %f OUT %f",
value,time,inTangent,outTangent);
}
fprintf(m_File,"\n");
}
else
{
fprintf(m_File," %s%s VAL %f KEYS %d",tabs.asChar(),attribute,fValue,iKeyCount);
for(unsigned int j=0;j<iKeyCount;j++)
{
float time = fnAnim.time(j).as(MTime::kSeconds);
float value = fnAnim.value(j);
float inTangent,outTangent,tmp;
fnAnim.getTangent(j,tmp,inTangent,true);
fnAnim.getTangent(j,tmp,outTangent,false);

fprintf(m_File," VAL %f TIME %f IN %f OUT %f",
value,time,inTangent,outTangent);
}
}
return true;
}

all that then remains is to traverse the transform hierarchy I've created, query each node type, and use the related function set to output the data to a file......

Hopefully that should get you started ....

> hopefully i won't need a recursive algorithm to read the file data. probably will.

very difficult to avoid.....

>if i can't work out an inverse kinamatics algorithm i will have to get animation data somehow.

IK chains comprise of three types, IK_Roots, IK_Effectors and IK_Joints. Should be able to grab that data from Maya or XSI files also....

Ask if you have any other questions....

Rob The Bloke
02-13-2002, 12:13 AM
Originally posted by wildeyedboyfromfreecloud:
hey, i checked out some source code for exporting animation. and i just realised that maya ascii format is not encoded. i will have to look into that. thanks

maya ascii files contain a series of 10 mel commaand that re-create the scene data. Although feasably possible to get the data from them, you will have to know an awful lot about the maya data structures before you'll be able to get anything useful. For example, create a single sphere and export it to maya ascii, you'll see a set of commands that place values on a polySphereCreator node (or similar), but there wont be any actual poly data in the file. It's not really of any use to anything else other than Maya. I'd say that that is likely to be the hard option IMHO

wildeyedboyfromfreecloud
02-13-2002, 12:34 PM
yeah i didn't have time to look at the ascii file format before i typed that. your code was beautiful. i forgot to mention i looked at the example source code for loading animation curves. hermite i think. actually i was looking into curve design all yesterday evening. i actually have a routine i wrote that generates pseudo-random trees and renders them in 3d. i want to convert the limbs to point interpolating curves. i recall hermite i think. i worked out a lame algorithm for loading in a skeleton. but i have to format it by hand. its not as terrible as it seems. i should have thought about using the std vector lists. well i was basically just trying to get data on your basic 7 cannon humanoid skeleton into the program. i will definately need to develope a robust exporter sooner than later. you are rather helpful for a human. sure there is nothing wrong with you? you seem experienced maybe you would be willing to help me out if you are into that kinda thing, i have hit a speed bump with my tree algorithm. i have it set up to extrude a tapered rotating nGon, pending LOD, and everything works grand. except 1 thing. i need to construct local coord systems at the branches with the Z axis lying along the branch. a frenet frame i think is the popular term. once i have the curves i will just use there derivitives. but for all its worth i can't get my z axis to align with my branches and i have no earthly idea why. well to be perfectly honest i just remembered i asked the most seasoned computer graphics teacher at my local univernisity and he said he saw no reason why it wouldn't work. well don't worry about it. its just so iretating. and staring at it doesn't seem to fix the problem.

thanks Michael

if you are curious,
here are the gory details and the source code. i've pithed around with all the numbers. one thing i don't understand is why the up vector would effect the coordinate sytem. i mean if you asked an electron in an insulated wire which direction is up. he would just be like... up what is this up??? so it seems to me it may as well be arbitrary or at least the x or y axis. but if i change it it effects the entire mutually perpendicular setup. i figure i may run into the same difficulties trying to properly align my bones. or maybe not. in all honesty i'm having a little bit of difficulty getting all these axis to get along with each other. also i have an AI system but to get my object its transformation matrix, geometry and its bounding box, frustum, frustum bisectors to allign i have to play with the numbers in a nonintuitive way. it works but i have negative signs here and there. so where i got something mal adjusted. and i'm trying to calibrate for it everywhere maybe. i hope not.

void extrudedNgon(int n, Point3 pathStart, Point3 pathEnd, Vector3 Path, float length, float radius, float radius2, float rotAngle)
{
if(n<3) return;

Vector3 path;
Vector3 u;
Vector3 v;
Vector3 up; up.set(0,0,1);

float m[16];


path.set(pathStart.x - pathEnd.x, pathStart.y - pathEnd.y, pathStart.z - pathEnd.z);// make n
u.set(up.cross(path));
path.normalize(); u.normalize();
v.set(path.cross(u));


m[0] = u.x; m[4] = u.y; m[8] = u.z; m[12] = pathStart.x;
m[1] = v.x; m[5] = v.y; m[9] = v.z; m[13] = pathStart.y;
m[2] = path.x; m[6] = path.y; m[10] = path.z; m[14] = pathStart.z;
m[3] = 0; m[7] = 0; m[11] = 0; m[15] = 1.0;

glMatrixMode(GL_MODELVIEW);
glPushMatrix();

glMultMatrixf(m);


//@@@@@@@@@@@@@@ draw local coord system @@@@@@@@@@@@@@@@@@@

glDisable(GL_LIGHTING);

glBegin(GL_LINES);

glColor3f(0.0,0.0,1.0);

glVertex3f(0,0,0);
glVertex3f(0,0,length/2); //draw z axis


glColor3f(0.0,1.0,0.0);

glVertex3f(0,0,0);
glVertex3f(length/4,0,0); //draw x axis


glColor3f(1.0,0.0,0.0);

glVertex3f(0,0,0);
glVertex3f(0,length/4,0); //draw y axis

glColor3f(1.0,1.0,1.0);

glEnd();

//@@@@@@@@@@@@@@ end of draw local coord system @@@@@@@@@@@@@@@@@@@

glEnable(GL_LIGHTING);

float angle = rotAngle * PI / 180; // initial angle
float angleInc = 2 * PI / n; // angle increment

// draw a tapered cylinder in local coord space extruded along z axis

glBegin(GL_QUADS);

glVertex3f(radius*cos(angle), radius*sin(angle),0);
glVertex3f(radius2*cos(angle), radius2*sin(angle),length);

for(int k=0;k<n;k++)
{
angle+=angleInc;
Point3 v1; v1.set(radius*cos(angle), radius*sin(angle),0);
Point3 v2; v2.set(radius2*cos(angle), radius2*sin(angle),length);


glVertex3fv(v2.v);
glVertex3fv(v1.v);

glVertex3fv(v1.v);
glVertex3fv(v2.v);


}

glEnd();

glPopMatrix();

}

wildeyedboyfromfreecloud
02-13-2002, 01:25 PM
oops, bit my tongue. XP

my next project is to make this work. that is the least i could do i think i feel. i have tomorrow off. hopefully i will get it straightened out. thanks again i really apreciate it.
sincerely,

Michael

[This message has been edited by wildeyedboyfromfreecloud (edited 02-13-2002).]

wildeyedboyfromfreecloud
02-13-2002, 09:03 PM
i know this sounds weird. but for some reason about a four thirds of the time when i'm working with the MAYA headers

i get a few errors that only point to this bit of code in MTypes.h, actually i couldn't compile your code because of 4 compile time errors pointing to this code:

#if defined(NT_PLUGIN) &#0124; &#0124; defined(NT_APP)
#define STRICT
#define _BOOL

#include <windows.h>

#ifndef NT_APP
#define EXPORT _declspec(dllexport)
extern HINSTANCE MhInstPlugin;
#endif

.
.
.
.

#ifndef _BOOL
typedef unsigned char bool;
#if !defined(true) && !defined(false)
#ifndef TRUE_AND_FALSE_DEFINED
#define TRUE_AND_FALSE_DEFINED
enum {false,true};
#endif // TRUE_AND_FALSE_DEFINED
#endif // true and false

#endif // _BOOL

here are the errors:

c:\program files\microsoft visual studio\vc98\include\maya\mtypes.h(212) : error C2371: 'bool' : redefinition; different basic types
c:\avalon\camera.cpp(0) : see declaration of 'bool'
c:\program files\microsoft visual studio\vc98\include\maya\mtypes.h(216) : error C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\maya\mtypes.h(216) : error C2143: syntax error : missing ';' before '}'
c:\program files\microsoft visual studio\vc98\include\maya\mtypes.h(216) : error C2143: syntax error : missing ';' before '}'

i think i understand what is going on up there. if i comment it out i don't get the compile time errors. honestly i don't like using other peoples code unless i more or less have too.


its interesting this time that it actually referenced by to my camera class. i'm not very sure what is going on here.

from what i tell it is being called by a maya file and it is a maya file.
if i comment it out. the program links but i get a slew of link errors. this occurs even if my whole routine is like

#include <math.h>
#include <maya/MSimple.h>
#include <maya/MPoint.h>
#include <maya/MPointArray.h>
#include <maya/MDoubleArray.h>
#include <maya/MFnNurbsCurve.h>

void main()
{


};

also get this error

///
friend OPENMAYA_EXPORT ostream& operator<<(ostream&, const MString& );
///
friend OPENMAYA_EXPORT MString operator+(const char *, const MString& );

microsoft visual studio\vc98\include\maya\mstring.h(142) : error C2872: 'ostream' : ambiguous symbol
c:\program files\microsoft visual studio\vc98\include\maya\mstring.h(142) : error C2872: 'ostream' : ambiguous symbol

i hate to be a pain but i don't know what else to do.

[This message has been edited by wildeyedboyfromfreecloud (edited 02-14-2002).]

Rob The Bloke
02-15-2002, 09:43 AM
here are the errors:

c:\program files\microsoft visual studio\vc98\include\maya\mtypes.h(212) : error C2371: 'bool' : redefinition; different basic types
c:\avalon\camera.cpp(0) : see declaration of 'bool'
c:\program files\microsoft visual studio\vc98\include\maya\mtypes.h(216) : error C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\maya\mtypes.h(216) : error C2143: syntax error : missing ';' before '}'
c:\program files\microsoft visual studio\vc98\include\maya\mtypes.h(216) : error C2143: syntax error : missing ';' before '}'

i think i understand what is going on up there. if i comment it out i don't get the compile time errors. honestly i don't like using other peoples code unless i more or less have too.



I know whats going on here, there are a number of defines that are required by a maya plugin.This only happens if you create the project manually, and not with the Maya plug-in wizard for VC++. I can't remember the defines off hand (and have had too many drinks today to be of much use), but if you have a look in the project settings of another plugin in the devkit, there's some defines in there like : NT_PLUGIN, and one more (as I recall).

The project should be set to make a dll and output an mll plugin thing.

I'll check it out in the morning when I can focus again.

There should be no main() functionn defined in your plugin, the project will use dllMain(), but that is hidden away in the Maya libs. The only functions you need to ccreate are initialise plugin and uninitialise plugin (have a look at any of the examples in the devkit).


also get this error

///
friend OPENMAYA_EXPORT ostream& operator<<(ostream&, const MString& );
///
friend OPENMAYA_EXPORT MString operator+(const char *, const MString& );

microsoft visual studio\vc98\include\maya\mstring.h(142) : error C2872: 'ostream' : ambiguous symbol
c:\program files\microsoft visual studio\vc98\include\maya\mstring.h(142) : error C2872: 'ostream' : ambiguous symbol


easy one, anything from stl should be included AFTER the maya includes, I don;'t know why, and it is a pain, but if you have the maya includes then the stl/iostream headers it'll compile nicely.

Check the other stuff later when I'm sober, Rob

wildeyedboyfromfreecloud
02-15-2002, 09:16 PM
thanks, i got all your code to compile tonight. hopefully tomorrow morning i will i will start flushing out the rest of it. no questions off the top of my head (right now i had to add). i doubt i would have tried doing anything like this anytime soon without your advice. thanks a million. and be careful

Michael

[This message has been edited by wildeyedboyfromfreecloud (edited 02-15-2002).]

wildeyedboyfromfreecloud
02-16-2002, 05:56 PM
i have to admit working with maya is proving awkward at best. this is the bit i worked up to export mesh data. but it isn't working out convienently to say the least. there is no face structure. and working around that is rather counter intuitive. could you give me some advice or maybe share another snippet of code. that would be cool. btw that code probably isn't correct. i was just trying to get a handle on what was going on and trying to figure out from what angle to attack. and obviously i've yet to come to a conclusion. also i read that the mesh nodes point structure is used for manipulating the base verts. ie they start at zero and keep track of tweaks. where as the vert structure is the actual verticies of the mesh. but as far as i can tell you cannot get at the vert data from the mesh node.


if(m_bAscii)
{
fprintf(m_File," %s%s VAL %f %d/%d/%d",tabs.asChar(),attribute,fValue,numVertices,numNor mals,numFaces);

// output the vertices information (if any exists)
//

MFloatPointArray points(numVertices, 0);
fnMesh.getPoints(points,MSpace::kPreTransform);

MFloatVectorArray normals(numNormals,0);
fnMesh.getNormals(normals,MSpace::kPreTransform);

MFloatArray U(numVertices,0);
MFloatArray V(numVertices,0);
fnMesh.getUVs(U,V);

MIntArray *faceVertIndex;

faceVertIndex = new MIntArray[numFaces];

unsigned int f;

for(f=0;f<numFaces;f++)
{
MIntArray vertexIndecies(fnMesh.polygonVertexCount(f));
fnMesh.getPolygonVertices(f, vertexIndecies);
faceVertIndex[f]=vertexIndecies;

}

unsigned int i;

for(i=0;i<numVertices;i++)
{
fprintf(m_File,"v %f/%f/%f", points[i].x, points[i].y, points[i].z);

}

for(i=0;i<numNormals;i++)
{
fprintf(m_File,"v %f/%f/%f", normals[i].x, normals[i].y, normals[i].z);

}

for(f=0;f<numFaces;f++)
{
fprintf(m_File,"v %f/%f/%f", faceVertIndex[f]normals[i].x, normals[i].y, normals[i].z);

}


[This message has been edited by wildeyedboyfromfreecloud (edited 02-16-2002).]

Rob The Bloke
02-18-2002, 09:10 AM
You'll need to check the syntax of this, but you should be able to use MItMeshPolygon iterator class to walk through all of the polygons individually and pull out more meaningful values, this should more or less do the job.... :

// grab vertex array for mesh
MFloatPointArray points(numVertices, 0);
fnMesh.getPoints(points,MSpace::kPreTransform);

// grab all normals for the mesh
MFloatVectorArray normals(numNormals,0);
fnMesh.getNormals(normals,MSpace::kPreTransform);

// grab the U & V tex coords
MFloatArray U(numVertices,0);
MFloatArray V(numVertices,0);
fnMesh.getUVs(U,V);

// output some data
fprintf(m_File," %s%s VAL %f %d %d %d %d\n",
tabs.asChar(),
attribute,
fValue,
numVertices,
numNormals,
U.length(),
numFaces);

unsigned int i;

// output each vertex (zero based index)
for(i=0;i<numVertices;i++)
{
fprintf(m_File,"v %f %f %f\n", points[i].x, points[i].y, points[i].z);
}

// output each normal
for(i=0;i<numNormals;i++)
{
fprintf(m_File,"vn %f %f %f\n", normals[i].x, normals[i].y, normals[i].z);
}

// output the uv's.....
for(i=0;i<U.length();i++)
{
fprintf(m_File,"vt %f %f\n", U[i], V[i]);
}

// use an iterator to walk through each face
// (cunning trick that gives us more info than MFnMesh)
//
MItMeshPolygon itPoly(fnMesh.node());
while( !itPoly.isDone() )
{
// output number off verts for this face
fprintf(m_File,"f %d ",itPoly.polygonVertexCount());

// for each vertex making up the face, output indices
// for "vert/normal/uv"
for(i=0;i< itPoly.polygonVertexCount();i++)
{
// output face with UV indices only if the face has uvs
if(itPoly.hasUVs())
{
int uv_index;
itPoly.getUVIndex(i,uv_index);
fprintf("%d/%d/%d ",
itPoly.vertexIndex(i),
itPoly.normalIndex(i),
uv_index);
}
else
// if no uv's, ignore them.....
{
fprintf("%d/%d/ ",
itPoly.vertexIndex(i),
itPoly.normalIndex(i));
}
}
fprintf(m_File,"\n");

// move to next polygon in mesh
itPoly.next();
}

// the face data that is output will be in the form
// "f <vertCount> v1/n1/t1 .... vn/nn/tn"
//
// where the numbers are zero based indices that references the elements in the
// vertex arrays, normal arrays and tex coord arrays.

wildeyedboyfromfreecloud
02-18-2002, 03:16 PM
yes, i'd found MITMeshPolygon last night. i saw some potential there but didn't have time to tear through it. was next on my agenda. i really apreciate the advice. will do. i've been thinking about how to get at the Maya data. do you have to do it as a plugin or can you do it as a stand alone app that takes a maya formatted file. i looked at the mayaFileIO class. but it didn't look like it was good for much. it doesn't seem to allow you to get at the data or do any thing to usefule with it. and if you have to get at it with a plugin. then how do you go about it implementing the plug in after it is loaded. i know you use the command prompt, but it seems it takes generic plugin commands. can you specify your own to enter at the command line or would that even be sensible. i'm sure i will figure it out but just by scanning through the example implementations in the maya devkit docs i didn't get a concise understanding of what was going on exactly. for instance "createNode -flag_n- -"nodename_x"-" da da da... thanks again don't know what i would do without ya

Rob The Bloke
02-19-2002, 05:08 AM
It's easiest to do the exporter as a plug-in. Once you have the plugin it is very easy to turn it into a standalone application. You can create the app with just a basic main() function, and then use MLibrary to initialise and load the scene.

I just ripped off this quickly so it'll prolly have a few errors, it basically initialises the maya library, calls a mel command to load the exporter plugin, and then exports the file. You should be able to alter it to do command line parameters for a batched build process.

main(int argc, char **argv)
{
MStatus status;
// load maya libs & run initialisation
status = MLibrary::initialize (argv[0], true);
if ( !status ) {
status.perror("MLibrary::initialize");
return (1);
}
// use a mel command to load your own plugin and any others required for export.
MString cmd="loadPlugin \"C:/aw/maya4.0/bin/plug-ins/objExport.mll\"";
MGlobal::executeCommand(cmd);
MFileIO io;

// load some maya binary or ascii file
io.open( "C:/testFile.mb" );

// export it as an *.obj file
io.exportAll("C:/testFile.obj","obj");

// kill the maya library....
MLibrary::cleanup();
return (0);
}

wildeyedboyfromfreecloud
02-19-2002, 09:45 AM
actually i have all that. how can you export it as a new file format. i suppose you have to run the plugin inbetween that loads in the new file format. or once you have the maya file loaded in via Mio can you get at its data as node/class objects rather than just unintelligible strings. hmm maybe there is a class function somewhere that takes an io object and loads it into memory i guess so you can operate on it,

just out of curiosity,
would it be possible to interface maya with your own routine. so you could say use its iksolver for instance to drive your own routine in realtime. i'm sure it is to a degree but to what degree i wonder.

well i'll sort all this stuff out in due time. no need to spoil me less you just want to. apreciate it ^_^ Voo

[This message has been edited by wildeyedboyfromfreecloud (edited 02-19-2002).]

wildeyedboyfromfreecloud
02-19-2002, 10:42 AM
I think the most sensible thing for me to do is to just modify the objexport source code provided in the devkit. everything i need seems to be there. i will expand upon it and learn from it. i apreciate all the help. let me know if there is anything i should know.
best of luck in all your endeavors,

Michael

[This message has been edited by wildeyedboyfromfreecloud (edited 02-19-2002).]

wildeyedboyfromfreecloud
02-19-2002, 07:00 PM
i would like to ask for your advice regarding file format. how would you suggest a file format that supports, animation, geometry, skeleton, material data, and so on would need look like most reasonably. and how would traversing the file look. i'm real iffy on this. as for joints. should i try to make it recursive, or should i have indexes for my joints that point to a particular joints parent and children. i'd really apreciate any advice. really i'm just concerned with grouping and animation data, which i intend to figure out sooner than later. thanks

Michale

wildeyedboyfromfreecloud
02-20-2002, 07:56 PM
if i still have your attention or anyones. so i modified the objexporter to do some of the things i wanted it to. i should already know this i guess, but i can't get it to compile without a "main" function. like all the other plugins do. and with the main function obviously maya wont recognize the intitialize and uninitialize functions so i don't get far. i've tried everything. the project settings and code are all in the exact same format as all plugins... i've read through the maya docs. i haven't a clue what stone i've left unturned. its late i'm burned out. if someone can drop me a clue i'd realy apreciate it.
sincerely,

Michael

ps: i guess i could just jump to the stand alone app with the main function but i'd rather get aquainted with the plugin format first i think. oiii the room is unjulating.

[This message has been edited by wildeyedboyfromfreecloud (edited 02-20-2002).]

Rob The Bloke
02-21-2002, 08:56 AM
a dll requires dllMain(), this is defined in one of the maya headers (maya/MFnPlugin.h i think) The only functions you have to define are initialisePlugin & uninitialisePlugin. These functions are required to be exported in the project settings, that should be it. You should of sourse include maya/MFnPlugin.h . . .

wildeyedboyfromfreecloud
02-21-2002, 10:34 AM
sorry to be a bother. of course MFnPugin and what not are in there. but there is presumably a windows library file that spits this out at link if i dont have a "main" function:

LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main

also none off the plugins included a dllMain function. presumably it is defined in one of the maya headers as i think you'd stated.

sorry. i just loaded into another plugin file and it worked ok. i don't know what is wrong in my workspace. i've really looked at every option at least 20 times.

well btw do you know what the mel script should look like to utilize an MPxFileTranslator object. or maybe i could look into the customizable GUI support. thanks

michael

i gotta race off too school. apreciate it.



[This message has been edited by wildeyedboyfromfreecloud (edited 02-21-2002).]

wildeyedboyfromfreecloud
02-21-2002, 10:39 AM
sorry i was so rude. thanks for the advice jwatte,m i really apreciate it.


Originally posted by jwatte:
The Maya SDK should contain sample exporters that you can start from. I say "should" because I don't have Maya experience beyond looking at their web site http://www.aliaswavefront.com/en/WhatWeDo/maya/see/solutions/m_builder.shtml (3DSMax comes with several exporter samples, as does Blender)

oi, is it laundry time already???
later

Rob The Bloke
02-27-2002, 06:25 PM
Sorry I haven't replied for a bit, lot of work on....

the following is a list of all lib's I link to:

Foundation.lib Image.lib OpenMaya.lib OpenMayaAnim.lib OpenMayaUI.lib XSICore.lib XSIFtk.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

in addition, the following must be specified in the Project Options box under the Link tab of the settings dialog:

/export:initializePlugin /export:uninitializePlugin

the following pre-processor definitions are used under the C/C++ tab :

WIN32,_DEBUG,_WINDOWS,_MBCS,NT_PLUGIN,_WINDLL,_AFX DLL,_CONSOLE

that should be all you need.

In addition, if you want to debug your plug-in, you need to do the following :

1. In the Debug tab of the project settings specify the "Executable for debug session" to as C:/AW/Maya4.0/bin/maya.exe (or wherever you maya is located)

2. change the catagory to "Additional Dlls" and add the path to your compiled plugin under the local name bit.

You should now be able to place breakpoints and stuff through your plugin code.

In response to the file format question, I think the most flexible is a chunk based format where each data chunk has any number of child chunks of varying size. The xsi file format or the DirectX X file are both pretty good examples and worth checking out.

I tend to use a more limited file format myself. I specify data in following sections in the file :

1. All Textures first
2. All Materials next because they reference the textures
3. "Shapes", ie any Geometry, Lights, Cameras, Curves, Nurbs, etc. These may or may not reference the materials defined before hand.
4. Transforms in a hierarchical structure. Each transform can have a set of child transforms, and a list of the shapes that are parented under it. The shape list is just names or indices to the shape list that appeared previously, this allows for geometry instancing.
5. Any expressions, skin weights, animation curves etc.

The reason for this ordering is so that I can load the file sequentually and will always know that if say, a mesh uses a certain material, the material will have already been loaded. It means the scene hierarchy can be constructed as the file is loaded rather than building up refernces afterwards. Seems abit more logical to me...

wildeyedboyfromfreecloud
02-27-2002, 06:29 PM
don't worry about it.
yeah i'm halfway familiar with chunks. that is the format the 3ds files are in... so kinda put the maya project on the back burner for the meantime. i got a little stuck. i loaded my exporter in and i was trying to get it to work like OBJexport. whereas you click on export in the file dropdown.

i modified this mel script file that the objexport plugin referenced that created the GUI. but i couldn't get my pulgin to link with it. i'm not sure if maya builds it automatically for all file translator plugins. or well the whole project just got anoying and i was burning to much time on it. here is the GUI building mel file. it doesn't work if i just pop it in the command prompt the way i want it to. i'm trying not to sound too juvenile. but boy is this a headache. all i did initially is modify the objexporter to export the necesary data for volumetric shadowing. here is the mel cript.

// $RCSfile: objExportOptions.mel $ $Revision: /main/1 $

global proc int AvalonExportOptions ( string $parent,
string $action,
string $initialSettings,
string $resultCallback )
//
// Description:
// This script posts the OBJ file translator options.
// The optionsString is of the form:
// varName1=value1;varName2=value2;...
//
// Parameters:
// $parent - the elf parent layout for this options layout. It is
// always a scrollLayout.
// $action - the action that is to be performed with this invokation
// of this proc. Valid options are:
// "query" - construct the options string and pass it
// to the resultCallback.
// "post" - post all the elf controls.
// $initialSettings - the current options string in effect at the
// time this script is invoked.
// $resultCallback -
// This is the proc to be called with the result string.
// resultCallback ( string $optionsString )
//
// Returns:
// 1 if successfull.
// 0 otherwise.
//
{
int $bResult;
string $currentOptions;
string $optionList[];
string $optionBreakDown[];
int $index;

if ($action == "post") {
setParent $parent;

columnLayout -adj true objTypeCol;
radioButtonGrp
-l "Groups"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objGroups;
radioButtonGrp
-l "Point groups"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objPtGroups;
radioButtonGrp
-l "Materials"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objMaterials;
radioButtonGrp
-l "Smoothing"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objSmoothing;
radioButtonGrp
-l "Normals"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objNormals;
radioButtonGrp
-l "Shadows"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objShadows;



// Now set to current settings.
$currentOptions = $initialSettings;
if (size($currentOptions) > 0) {
tokenize($currentOptions, ";", $optionList);
for ($index = 0; $index < size($optionList); $index++) {
tokenize($optionList[$index], "=", $optionBreakDown);

if ($optionBreakDown[0] == "groups") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objGroups;
} else {
radioButtonGrp -e -sl 1 objGroups;
}
} else if ($optionBreakDown[0] == "ptgroups") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objPtGroups;
} else {
radioButtonGrp -e -sl 1 objPtGroups;
}
} else if ($optionBreakDown[0] == "materials") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objMaterials;
} else {
radioButtonGrp -e -sl 1 objMaterials;
}
} else if ($optionBreakDown[0] == "smoothing") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objSmoothing;
} else {
radioButtonGrp -e -sl 1 objSmoothing;
}
} else if ($optionBreakDown[0] == "normals") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objNormals;
} else {
radioButtonGrp -e -sl 1 objNormals;
}
} else if ($optionBreakDown[0] == "shadows") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objShadows;
} else {
radioButtonGrp -e -sl 1 objShadows;
}
}
}
}
$result = 1;

} else if ($action == "query") {

if (`radioButtonGrp -q -sl objGroups` == 1) {
$currentOptions = $currentOptions + "groups=1";
} else {
$currentOptions = $currentOptions + "groups=0";
}

if (`radioButtonGrp -q -sl objPtGroups` == 1) {
$currentOptions = $currentOptions + ";ptgroups=1";
} else {
$currentOptions = $currentOptions + ";ptgroups=0";
}

if (`radioButtonGrp -q -sl objMaterials` == 1) {
$currentOptions = $currentOptions + ";materials=1";
} else {
$currentOptions = $currentOptions + ";materials=0";
}

if (`radioButtonGrp -q -sl objSmoothing` == 1) {
$currentOptions = $currentOptions + ";smoothing=1";
} else {
$currentOptions = $currentOptions + ";smoothing=0";
}


if (`radioButtonGrp -q -sl objNormals` == 1) {
$currentOptions = $currentOptions + ";normals=1";
} else {
$currentOptions = $currentOptions + ";normals=0";
}


if (`radioButtonGrp -q -sl objShadows` == 1) {
$currentOptions = $currentOptions + ";shadows=1";
} else {
$currentOptions = $currentOptions + ";shadows=0";
}

eval($resultCallback+" \""+$currentOptions+"\"");
$result = 1;
} else {
$bResult = 0;
}

return $bResult;
}


sorry bout the drag. the translator is loaded in so i can go to export and choose it as an export type. but then i get this error in the maya status report bar

rror: Cannot link to "AvalonExportOptions". Check number and types of arguments expected on procedure definition.

i apreciate the help but don't let yourself get stressed out over me. its not worth it i'm sure. thanks

michale

[This message has been edited by wildeyedboyfromfreecloud (edited 02-27-2002).]

Devulon
03-01-2002, 03:18 AM
Don't let Maya programming get you down. I don't have Maya (never used it) so I haven't done any programming with it. I have on the other hand written a couple max plugins. Initially for model loading I started by using the ASE Ascii Exporter that comes with max (the SDK actually has the complete source as well) and then I would parse the ASE file into my own format. Carmack actually did that for Quake 3 (before it went skeletal). Eventually trying to parse the ASE became a big pain in the ass. With a big model/scene the ASE can get really large and I only wanted a very small subset of what it exported. ASE exports almost everything that is in the MAX file (in terms of raw data at least). I finally got sick of it and started looking at writing MAX plugins. After the initial compiling/linking problems from Microsoft's out of date libraries/headers (the ones that ship with VC++ 6.0 are WRONG !!!) things got easier. Max plugins are all very similar to write and I found that after a week I got it all working. Currently I am still working on my exporter plugin. Trying to add some extra functionality (vertex weights). Gonna try to do some nice skeleton based animation. This should be fun to watch.

Anyway, I know this didn't really answer any of your questions but I thought it might be nice to tell the world of my experience with max plugins and the max sdk. All in all the more i use it the more I give it 2 thumbs up, it works and works well. (:

It seems the more I read on writing plugins for my the development setup is almost Identical to max. It seems that its jus the way that Maya exposes the innards of itself are a little more messy. And life goes on.

Happy Coding.

[This message has been edited by Devulon (edited 03-01-2002).]

Rob The Bloke
03-01-2002, 08:00 AM
Originally posted by wildeyedboyfromfreecloud:
don't worry about it.
yeah i'm halfway familiar with chunks. that is the format the 3ds files are in... so kinda put the maya project on the back burner for the meantime. i got a little stuck. i loaded my exporter in and i was trying to get it to work like OBJexport. whereas you click on export in the file dropdown.

i modified this mel script file that the objexport plugin referenced that created the GUI. but i couldn't get my pulgin to link with it. i'm not sure if maya builds it automatically for all file translator plugins. or well the whole project just got anoying and i was burning to much time on it. here is the GUI building mel file. it doesn't work if i just pop it in the command prompt the way i want it to. i'm trying not to sound too juvenile. but boy is this a headache. all i did initially is modify the objexporter to export the necesary data for volumetric shadowing. here is the mel cript.

// $RCSfile: objExportOptions.mel $ $Revision: /main/1 $

global proc int AvalonExportOptions ( string $parent,
string $action,
string $initialSettings,
string $resultCallback )
//
// Description:
// This script posts the OBJ file translator options.
// The optionsString is of the form:
// varName1=value1;varName2=value2;...
//
// Parameters:
// $parent - the elf parent layout for this options layout. It is
// always a scrollLayout.
// $action - the action that is to be performed with this invokation
// of this proc. Valid options are:
// "query" - construct the options string and pass it
// to the resultCallback.
// "post" - post all the elf controls.
// $initialSettings - the current options string in effect at the
// time this script is invoked.
// $resultCallback -
// This is the proc to be called with the result string.
// resultCallback ( string $optionsString )
//
// Returns:
// 1 if successfull.
// 0 otherwise.
//
{
int $bResult;
string $currentOptions;
string $optionList[];
string $optionBreakDown[];
int $index;

if ($action == "post") {
setParent $parent;

columnLayout -adj true objTypeCol;
radioButtonGrp
-l "Groups"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objGroups;
radioButtonGrp
-l "Point groups"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objPtGroups;
radioButtonGrp
-l "Materials"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objMaterials;
radioButtonGrp
-l "Smoothing"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objSmoothing;
radioButtonGrp
-l "Normals"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objNormals;
radioButtonGrp
-l "Shadows"
-nrb 2 -cw3 175 75 75
-la2 "On" "Off" objShadows;



// Now set to current settings.
$currentOptions = $initialSettings;
if (size($currentOptions) > 0) {
tokenize($currentOptions, ";", $optionList);
for ($index = 0; $index < size($optionList); $index++) {
tokenize($optionList[$index], "=", $optionBreakDown);

if ($optionBreakDown[0] == "groups") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objGroups;
} else {
radioButtonGrp -e -sl 1 objGroups;
}
} else if ($optionBreakDown[0] == "ptgroups") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objPtGroups;
} else {
radioButtonGrp -e -sl 1 objPtGroups;
}
} else if ($optionBreakDown[0] == "materials") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objMaterials;
} else {
radioButtonGrp -e -sl 1 objMaterials;
}
} else if ($optionBreakDown[0] == "smoothing") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objSmoothing;
} else {
radioButtonGrp -e -sl 1 objSmoothing;
}
} else if ($optionBreakDown[0] == "normals") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objNormals;
} else {
radioButtonGrp -e -sl 1 objNormals;
}
} else if ($optionBreakDown[0] == "shadows") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 objShadows;
} else {
radioButtonGrp -e -sl 1 objShadows;
}
}
}
}
$result = 1;

} else if ($action == "query") {

if (`radioButtonGrp -q -sl objGroups` == 1) {
$currentOptions = $currentOptions + "groups=1";
} else {
$currentOptions = $currentOptions + "groups=0";
}

if (`radioButtonGrp -q -sl objPtGroups` == 1) {
$currentOptions = $currentOptions + ";ptgroups=1";
} else {
$currentOptions = $currentOptions + ";ptgroups=0";
}

if (`radioButtonGrp -q -sl objMaterials` == 1) {
$currentOptions = $currentOptions + ";materials=1";
} else {
$currentOptions = $currentOptions + ";materials=0";
}

if (`radioButtonGrp -q -sl objSmoothing` == 1) {
$currentOptions = $currentOptions + ";smoothing=1";
} else {
$currentOptions = $currentOptions + ";smoothing=0";
}


if (`radioButtonGrp -q -sl objNormals` == 1) {
$currentOptions = $currentOptions + ";normals=1";
} else {
$currentOptions = $currentOptions + ";normals=0";
}


if (`radioButtonGrp -q -sl objShadows` == 1) {
$currentOptions = $currentOptions + ";shadows=1";
} else {
$currentOptions = $currentOptions + ";shadows=0";
}

eval($resultCallback+" \""+$currentOptions+"\"");
$result = 1;
} else {
$bResult = 0;
}

return $bResult;
}


sorry bout the drag. the translator is loaded in so i can go to export and choose it as an export type. but then i get this error in the maya status report bar

rror: Cannot link to "AvalonExportOptions". Check number and types of arguments expected on procedure definition.

i apreciate the help but don't let yourself get stressed out over me. its not worth it i'm sure. thanks

michale

[This message has been edited by wildeyedboyfromfreecloud (edited 02-27-2002).]

When you resister the file translator in the plugin you specify the script name for the export option GUI, ie,

const char *const objOptionScript = "objExportOptions";
const char *const objDefaultOptions =
"groups=1;"
"ptgroups=1;"
"materials=1;"
"smoothing=1;"
"normals=1;"
;

MStatus initializePlugin( MObject obj )
{
MFnPlugin plugin( obj, "Alias|Wavefront", "3.0", "Any");

// Register the translator with the system
return plugin.registerFileTranslator( "OBJexport", "none",
ObjTranslator::creator,
(char *)objOptionScript,
(char *)objDefaultOptions );
}

the script name "objExportOptions" must contain a global proc with exactly the same name for maya to run the script, in this case "objExportOptions". By the looks of your script it should work, I'm guessing that the problem must be that it isn't in one of the script directorys.

Try putting it in the

"my documents\maya\4.0\scripts\"

directory. Maya should automatically source it from there. The only actions it should perform are the "post" action where it creates the user interface using the optionString to determine what the settings should be for the controls, and "query" where you construct a string that is passed into your writer function of the plugin which you can then split up to determine the options set by the user.

Just ask if there's anything else you need help on.

Rob.

wildeyedboyfromfreecloud
03-01-2002, 11:13 AM
yep, that was it. got it in 2 secs aftter reading your directory suggestion. i don't know whether to be happy or sad, after i deliberated over it for like an hour a week ago. well any progress is good progress. i've been doing a lot of cool stuff. right now i implementing ROAM into my pseudo random terrain engine. and i will probably get back on maya as soon as that cat is in the bag. so if i have any issues. you will see this familar post bumped back on top of the forum. apreciate all the help.
deeply indebted,

Michael

wildeyedboyfromfreecloud
03-01-2002, 11:21 AM
Originally posted by Devulon:
Don't let Maya programming get you down. I don't have Maya (never used it) so I haven't done any programming with it. I have on the other hand written a couple max plugins. Initially for model loading I started by using the ASE Ascii Exporter that comes with max (the SDK actually has the complete source as well) and then I would parse the ASE file into my own format. Carmack actually did that for Quake 3 (before it went skeletal). Eventually trying to parse the ASE became a big pain in the ass. With a big model/scene the ASE can get really large and I only wanted a very small subset of what it exported. ASE exports almost everything that is in the MAX file (in terms of raw data at least). I finally got sick of it and started looking at writing MAX plugins. After the initial compiling/linking problems from Microsoft's out of date libraries/headers (the ones that ship with VC++ 6.0 are WRONG !!!) things got easier. Max plugins are all very similar to write and I found that after a week I got it all working. Currently I am still working on my exporter plugin. Trying to add some extra functionality (vertex weights). Gonna try to do some nice skeleton based animation. This should be fun to watch.

Anyway, I know this didn't really answer any of your questions but I thought it might be nice to tell the world of my experience with max plugins and the max sdk. All in all the more i use it the more I give it 2 thumbs up, it works and works well. (:

It seems the more I read on writing plugins for my the development setup is almost Identical to max. It seems that its jus the way that Maya exposes the innards of itself are a little more messy. And life goes on.

Happy Coding.

[This message has been edited by Devulon (edited 03-01-2002).]

i apreciate the words of incouragement. i suppose it is just a right of passage. its good to know i'm not the only one suffering. just kidding. yeah maya is rather dastardly. i wish i had a system i could load max on to. mayas inards are like a convoluted spider web of madness, no i'm just kidding actually its rather beautiful in its sensibility. its a good intro into working with very interdependent data structures like dependancy graphs and what not. but yeah it seems like somewhere they could have made it easier. its not as much working with the classes and architecture which are quite nice. but just the beuracracy and some of the little quirks that are waiting to trip you up and leave you with that... oh, thats all i had to do... feeling. its cool to know someone who has been there done that. otherwise , well lets just say i'm glad i don't feel the necesity to fenture into uncharted territory with respect to this matter. but yeah i'm sure some good will come of it all. i hope.
sincerely

Michael

Rob The Bloke
03-02-2002, 03:12 AM
If it makes you feel any better, I'm banging my head against the table with it as well. Think exporting's bad? try importing stuff!!

There are a few areas that are a lot less convoluted, such as coding your own shaders and such. Thats where the API makes a lot more sense, In fact the worst area with it the importing/exporting stuff. Dammit.