Jump to content
  • Advertisement
Sign in to follow this  
D3DXVECTOR3

3ds Max Exporter (Vertices and Matrices)

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!