3ds Max Exporter (Vertices and Matrices)

Started by
14 comments, last by Lantz 19 years, 7 months ago
I'm writing an exporter plugin for 3ds max and I have a problem getting the vertices. The vertices I get are already scaled/rotated/translated, but I want them from the origin so that I can set the scale/rotation/translation via the matrices. I cant find any info about this, its for 3ds Max 5 btw :) One more thing is there a way to get just the name of the texture and not the full path!? ie "Metal.jpg" and not "C:\3ds Max\Maps\Metal.jpg"
Advertisement
1. You can get the current transformation matrix of each node. Just build the inverse and apply it to the vertices and you'll get your vertices in object space. I've decided not to do that and store my vertices in worldspace and also provide the the local matrix (along with hierachy). That's very nice if you just want to write or debug your fileformat (since you can leave out all the math and get something usable on the screen).

2. If you really think that's a wise idea write that on your own.

If I remember right there was a function called splitpath that does the work for you.. Otherwise char * name = strrchr (string, '\')+1 does the trick.



Quote:
One more thing is there a way to get just the name of the texture and not the full path!? ie "Metal.jpg" and not "C:\3ds Max\Maps\Metal.jpg"


I do exactly that in my Milkshape3D exporter by using the following simple function:
std::string cPlugIn::ExtractNameFromAbsolutePath( std::string& str ){	// just modify the str	std::string texName;    int len = 0;	len = (int)( str.size() );	for ( int i = len-1; i >=0; i-- )	{		if ( str == '\\' || str == '/' )			break;	}	// last '\' is in i index	texName = str.substr( i+1, len-i-1 );// copy the texture name	return texName;}


I use std::string for flexibility. It takes std::string as param, but i can send a char* by using: string( strPtr )
(Remon) M. Sazzad Karim
^^ Thanks for the code :)

The reason why I want the vertices in object space is because some object are scaled with -1 and for some reason they are not applied to the vertices when exporting.

The function in the SDK is BMMSplitFilename. This will split the file into path, file and the extention.
btw how do I apply the inverse to vertices!?

How do I apply the inverse to the vertices?

Multiply the vertex coords with it. With the normal you have to be more careful, since you normally transform a normal with the inverse transpose of transformation matrix.
If you use DX you want to look the functions
D3DXTransformCoord() and D3DXTransformNormal(). For the case you have to create you matrix from a translation vector, a scale vector and rotation quaternion there is function for this as well. Look for something like D3DXAffineTransformation() - IIRC.
If you want to decompose the matrix you can use D3DXDecomposeMatrix().


is there a way to get just the name of the texture and not the full path


std::string( pFilename ) str;std::string::size_type pos = str.find_last_of( "\\" );std::string tex = str.substr( pos );


Hence that you must use std::string::size_type, using int could cause some hard to find bugs. See "The C++ Standard Library" for an explanation of this.


Hi I wrote an exporter for 3ds Max 5. It exports meshes/skeletal animation using the IGame interface. I provide the full source and a brief tutorial on how to create your own. Basically why I do is make the object and IGame Object and query the interface to return all the info I want.
IIRC, you can get your vertices untransformed from 3dsmax...
I did have the same problem in the begining, this because one of the interface functions did give you an transformed mesh/node you can get the same data untransformed by calling another function insted. right now i can recall what the names of the invloved functions was, but seek and you shall find =)

good luck!

// ziruz
do you bind your mesh to bones if so you can transform the vertices to local space of the assigned bone

http://www.8ung.at/basiror/theironcross.html
Slightly OT: How good is the SDK documentation that comes with 3dsMax6?
[email=algorhythmic@transcendenz.co.uk]algorhythmic[/email] | home | xltronic | whatever you do will be insignificant, but it is very important that you do it - mahatma gandhi

This topic is closed to new replies.

Advertisement