Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / 3ds max5 plugin writing problem(exporting) Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

April 15, 2005, 04:25 AM


I am writing a plugin for 3dmax5 which allow me to save geometry and texture coords to my own format. But I have a problem with modyficators and stack. When I export to my own file format without "uw modifiers" (or somthing like this) everything is ok, but if i add this and export there is no data in exported file. I have to collapse stack for every object and then everything is ok. My question is : how to recall function to collapse stack for object. In fact is should be done for all object on the scene. I use vc6.0. Mayby some source code :))
BTW. The plugin is extremply simple-saving only vertex and wv cords and textures. no lighting , normals etc.


Erik Faye-Lund

April 15, 2005, 06:10 AM

i know this might be a bit off-topic, but have you considered using the IGameInterface instead? (if you do, you don't have to bother collapsing the stack etc, you get a lot cleaner code, and you still get the power of being able to use the maxsdk when IGame doesn't cut it..)


April 15, 2005, 07:43 AM

i totally agree with Erik, you should definitively have a look at this library. a good point is that IGame seems to be completly supported by discreet, which also provide it now in the Max SDK with each new version of max. it means you can really rely on it, without the risk for your plugin code base not to be compilable with future version of max...


April 15, 2005, 03:02 PM


ok thanks for replay, i'll consider this today:) but still i wanted to know if it possible and how to do that(collapsing stock:)) . So if anybody know how to do that plase share your knoledge!!


April 15, 2005, 03:21 PM

Isn't "stack collapsing" an artist responsability ? Let them collapse the stack after applying the modifiers. One day they will be waiting for you to create the 3d models procedurally ehehe. Anyway, you may want to look at class IDerivedObject in 3d studio max api. Good luck.


April 15, 2005, 03:39 PM

Call EvalWorldState() on the node to get the object as it appears in the scene
(ie. after world space modifiers have been applied on it)

  2. Object *pWorldStateObj = pNode->EvalWorldState(0).obj;
  3. TriObject *pTriObj = (TriObject *)pWorldStateObj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));

Thomas Rued

April 17, 2005, 12:02 AM

Worth mentioning is the fact that some modifiers aren't really "compatible" with traditional real-time 3d engines, that rely solely on the final result of the modifier stack.

An example is Meshsmooth, mirror, etc. that add's vertices to the final result. This works fine for static geometry, but if you have a skin or physique modifier _lower_ in the stack it will not know of these extra vertices add'ed later, giving you a strange animation in your exported version.


April 17, 2005, 12:15 PM

One additional note. To prevent memory leaks, you should do this when you are done exporting:

  2. if (pWorldStateObj != pTriObj)
  3. {
  4.     pTriObj->DeleteThis();
  5.     pTriObj = 0;
  6. }



April 20, 2005, 02:26 AM


I did it :
Object *pWorldStateObj = pNode->EvalWorldState(0).obj;
TriObject *pTriObj = (TriObject *)pWorldStateObj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));

as you said, but it seems not woking:
my code is following:

int callback( INode* inode )
Object* pObject = inode->EvalWorldState(0).obj;
Class_ID classID = pObject->ClassID();
SClass_ID superClassID = pObject->SuperClassID();
if (superClassID!=GEOMOBJECT_CLASS_ID) return 0;

t3DObject OBJEKT;

TriObject *pTriObject = (TriObject*)pObject->ConvertToType( 0, Class_ID( TRIOBJ_CLASS_ID,0 ) );
Mesh *pMesh = &( pTriObject->GetMesh() );
OBJEKT.bHasTexture =true;
OBJEKT.materialID =FindMaterial(inode);

OBJEKT.numOfFaces =pMesh->numFaces;
OBJEKT.numOfVerts =pMesh->numVerts;
OBJEKT.numTexVertex =pMesh->numTVerts;
OBJEKT.pFaces=new tFace[OBJEKT.numOfFaces];
OBJEKT.pVerts=new CVector3[OBJEKT.numOfVerts];
OBJEKT.pTexVerts=new CVector2[OBJEKT.numTexVertex];

Matrix3 M = inode->GetObjectTM(0);
int a;
for (a=0; a!=pMesh->numVerts; a++)
Point3 w;
for (a=0; a!=pMesh->numFaces; a++)
Face w;
for (a=0; a!=pMesh->numTVerts; a++)
for (a=0; a!=pMesh->numFaces; a++)
TVFace f;
return 0;
And 3d objecs are ok(the geometry) but texture coords are wrong. Are any Ideas why?? (oh btw when i mannualy do "collapse stact" it works)


April 20, 2005, 05:15 AM

Which modifier doesn't work?

My code is similar to yours, and it works fine. I only tried UVW Map modifier though.


April 21, 2005, 03:48 AM


Ok it works! My lame error - this "exporter" export well, but my program which schow model on the screen has bug in displaying texture coords. (at first i was exported file to 3ds and then convert to my format, and the structure was a bit different)

Thanks all for replaying :)

This thread contains 11 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.