# 3ds Max Exporter (Vertices and Matrices)

This topic is 5037 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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"

##### Share on other sites
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.

##### Share on other sites
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 )

##### Share on other sites
^^ 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.

##### Share on other sites
btw how do I apply the inverse to vertices!?

##### Share on other sites

How do I apply the inverse to the vertices?
[/Quote]
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
[/Quote]

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.

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
do you bind your mesh to bones if so you can transform the vertices to local space of the assigned bone

##### Share on other sites
Slightly OT: How good is the SDK documentation that comes with 3dsMax6?

1. 1
2. 2
3. 3
4. 4
Rutin
16
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631417
• Total Posts
2999969
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!