3dsMaxConvertXML matrix transform

3dsMaxConvertXML matrix transform

koichisenada
Contributor Contributor
2,653 Views
9 Replies
Message 1 of 10

3dsMaxConvertXML matrix transform

koichisenada
Contributor
Contributor
Hello everybody!
I've written a converter, which read 3DXML files into 3dsMax scenes.
But I have a trouble with matrices.
Can someone tell what's wrong with my code, which is appying transformation matrices to created 3dsMax nodes?
maxobjectSceneNode - the 3dsMax node
objectSceneNode.matrixRelative - relative transformation matrix for the node
fn transformSceneNode maxobjectSceneNode = (
idSceneNode = getUserProp maxobjectSceneNode "idSceneNode"
objectSceneNode = objectsSceneNode
matrixRelative = objectSceneNode.matrixRelative
for nodeChild in maxobjectSceneNode do (
if (matrixRelative != undefined) then ( in coordsys parent nodeChild.transform = matrixRelative )
)
for nodeChild in maxobjectSceneNode.children do (
idChildSceneNode = getUserProp nodeChild "idSceneNode"
if (idChildSceneNode != undefined) then ( transformSceneNode nodeChild )
)
)


Here are my converter and the tested 3DXML file.
The converter is being installed by extracting archive into 3dsMax 2008 or 3dsMax 9 installation folder.
Might require the project folders (Customize -> Configure User Paths...)

6269_Cd2gtUBUfk1AwBEDozcb.zip

6270_JEt9YgeJI4YIolYzID5m.zip

0 Likes
Accepted solutions (1)
2,654 Views
9 Replies
Replies (9)
Message 2 of 10

koichisenada
Contributor
Contributor
I was hoping that somebody can tell me what am I doing wrong to appy correct transformations (position/rotation/scale) to my nodes.
I have changed my code a little, so that now nodes do not form groups. Instead, when a group had a single child node, I move that node one level higher, when a group had several child nodes, I make a dummy instead of group and attachObjects to it. Also, the matrix is stored as a string right inside the node, as space delimeted list of float values. That has let me to see a more meaningful view.

From KoichiSenada.3dsMaxConvertXML.2008.02.20.PNG file you can see:
: There's a root node (Level 0) named "MainAssembly" represented as white frame outlined dummy cube, positioned at which is right. It has many child nodes (Level 1).
: Most of this level nodes are parts of the tractor itself, and they are positioned properly in relation to each other. Probably they are positioned right in relation to their parent node "MainAssembly". Also there are two green frame outlined dummies "AxleAssembly.1" and "AxleAssembly.2", they mark where asseblies should be placed.
: Here are the child nodes of two assemblies, but for some reason they aren't placed to their parent nodes, instead they are placed to , and I can't get the idea why does that happen.

You can compare the image on the left (taken from 3DXML Player) and on the right (taken from my Converter). They both represent the same 3DXML file named tractor.3dxml, don't pay attention to the difference of material looks. You can see that the original file is OK, I just can't make nodes to take their places correctly. Can anyone help me with theis function, which applies relative transformation matrices to all the nodes recursively?

fn transformSceneNode maxobjectSceneNode = (
matrixRelative = getUserProp maxobjectSceneNode "matrixRelative"
if (matrixRelative != undefined) then (
coordinates = filterString matrixRelative " "
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
pointRow1 = point3 coordinates coordinates coordinates
pointRow2 = point3 coordinates coordinates coordinates
pointRow3 = point3 coordinates coordinates coordinates
pointRow4 = point3 coordinates coordinates coordinates
matrixRelative = matrix3 pointRow1 pointRow2 pointRow3 pointRow4
)
for nodeChild in maxobjectSceneNode do (
if (matrixRelative != undefined) then (
in coordsys maxobjectSceneNode nodeChild.transform = matrixRelative )
)
)
for nodeChild in maxobjectSceneNode.children do ( transformSceneNode nodeChild )
)

You can see it creates matrixRelative from UserProp of each maxobjectSceneNode, applies it in coordsys of parent, and then does the same with its direct children...

Here are the Converter and the screenshot I've mentioned.

6299_mpPcV6SEsInFqW3JJqx9.zip

0 Likes
Message 3 of 10

koichisenada
Contributor
Contributor
Oh yes, I've managed to deal with that!
I've had the wrong idea about the matrix relation.
I've been appying the paren't matrix to child's transform in paren't coordsys, which was wrong.
Now I've fixed it so that the child's matrix is applied to child's transform in parent's coordsys.
Since then everything is positioned absolutely right!

fn transformSceneNode maxobjectSceneNode = (
for nodeChild in maxobjectSceneNode.children do (
transformSceneNode nodeChild

matrixRelative = getUserProp nodeChild "matrixRelative"
if (matrixRelative != undefined) then (
coordinates = filterString matrixRelative " "
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
coordinates = (coordinates as float)
pointRow1 = point3 coordinates coordinates coordinates
pointRow2 = point3 coordinates coordinates coordinates
pointRow3 = point3 coordinates coordinates coordinates
pointRow4 = point3 coordinates coordinates coordinates
matrixRelative = matrix3 pointRow1 pointRow2 pointRow3 pointRow4

in coordsys maxobjectSceneNode nodeChild.transform = matrixRelative
)
)
)

I have alot of things to fix (full set of all polygonal geometry's faces and all types of material declarations), which I will note when they are done. Now you guys can test what I've got.

6301_znMhGKPyrhO66cI8Xxmt.zip

0 Likes
Message 4 of 10

MartinBeh
Advisor
Advisor
That looks like a massive project; it even comes with a .net assembly (what does it do?).
I accidentally stumbled upon http://www.3dvia.com/pros/3DVIA_PrintScreen/ which takes "3D screenshots" in 3DXML - Have you tried that by chance?

-- MartinB
Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
0 Likes
Message 5 of 10

koichisenada
Contributor
Contributor
Accepted solution
Martin Breidt, thanks for your attention!

Sure thing, I'm aware of 3DVIA Printscreen
Actually that's the program which requires that BitmapOperations.DLL, since it's the only program producing 3DXML 3.0 files with textures stored as Base64 strings.
3dsMax hangs performing such an operation with extra large (2048x2048) textures, and Yannick Puech has helped me with that at this forum:
How to convert MXS and dotNet native variables and arrays?
I use just one function from that, to get "System.Drawing.Bitmap" from a Base64 encoded string of "RGB" or "RGBA" bytes.

Now I place the current versions at my folder:
4shared.com -> KoichiSenada -> 3dsMax -> 3dsMaxConvertXml, since there are already numerous forums where I present it.
0 Likes
Message 6 of 10

koichisenada
Contributor
Contributor
There's an update of 3dsMaxConvertXml at 4shared.com -> KoichiSenada -> 3dsMax -> 3dsMaxConvertXml
The current version is 2008.03.05

Updated:
- support for broken 3DXML files where <Normals> or <Positions> nodes of <VertexBuffer> contained non-float values.
Thanks to Patrik <jahaja_och@hotmail.com> for reporting such 3DXML 3.0 file produced by "3DVIA Printscreen V2.2"
In his example <Normals> was filled this way: "-1.#IND -1.#IND -1.#IND -1.#IND -1.#IND ..." which could not be parsed into float values.
0 Likes
Message 7 of 10

Anonymous
Not applicable

There's an update of 3dsMaxConvertXml at http://www.4shared.com/folder/ttVEwjIv/3dsMaxConvertXml.html

The current version is 2015.09.28

 

[2015.09.28] - support for new 3ds Max versions, using the additional system path directories instead of the older ones.
This solves the file access errors.

0 Likes
Message 8 of 10

SuperRune
Enthusiast
Enthusiast
I've tried download your 3dxml converter from 4shared, but their website requires registration. Do you have the converter available someplace that is easier to access? For example scriptspot?
0 Likes
Message 9 of 10

Anonymous
Not applicable

Um, not actually.
You can easily login into 4shared with your Google or Facebook or Twitter account
http://www.4shared.com/folder/ttVEwjIv/3dsMaxConvertXml.html

0 Likes
Message 10 of 10

SuperRune
Enthusiast
Enthusiast

OK, got the script now. I highly recommend putting it on Scriptspot.com, which is an excellent place for Max users to share and talk about their scripts 🙂

0 Likes