anybody familiar with blind data editors and exporters supported by maya for instance

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

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)

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)

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 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…

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

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

> 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 &lt; m_aShapeList.size(); k++ ) {
			if( m_aShapeList[k]-&gt;name == fnDep.name() )
				m_aSceneTree[i]-&gt;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: utputAnimCurve()
// 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: utputAnimCurve(MDagPath &node,const char *attribute)
{
MFnDependencyNode fnDep(node.node());

//	identation for ascii export
//
MString tabs = "";
for(unsigned int i=0;i&lt;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&lt;attrConnections.length();i++)
{
	if( attrConnections[i].node().apiType() == MFn::kAnimCurveTimeToAngular | |
		attrConnections[i].node().apiType() == MFn::kAnimCurveTimeToDistance | |
		attrConnections[i].node().apiType() == MFn::kAnimCurveTimeToTime | |
		attrConnections[i].node().apiType() == MFn::kAnimCurveTimeToUnitless | |
		attrConnections[i].node().apiType() == MFn::kAnimCurveUnitlessToAngular | |
		attrConnections[i].node().apiType() == MFn::kAnimCurveUnitlessToDistance | |
		attrConnections[i].node().apiType() == MFn::kAnimCurveUnitlessToTime | |
		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&lt;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,"

“);
}
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…

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

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&lt;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();

}

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).]

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) | | 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&lt;&lt;(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).]

[b]
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.

[/b]

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).

[b]
also get this error

///
friend OPENMAYA_EXPORT ostream& operator&lt;&lt;(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
[/b]

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

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).]

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,numNormals,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&lt;numFaces;f++)
	{
		MIntArray vertexIndecies(fnMesh.polygonVertexCount(f));
		fnMesh.getPolygonVertices(f, vertexIndecies);
		faceVertIndex[f]=vertexIndecies;

	}

	unsigned int i;

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

	}

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

	}

	for(f=0;f&lt;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).]

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
",
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
", 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
", 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
", 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&lt; 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,"

");

//	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.

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

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);

}

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 :slight_smile: Voo

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

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).]

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