# OpenGL MaxScript transforms

## Recommended Posts

Hello, I'm trying to write a 3DSMax MaxScript exporter to save to a custom format geometry, keyframes, material and hierarchies. I had no problems with geometry, materials and keyframes but I messed it up with hierarchies. I can build the hierarchy but when I add keyframes to it translations rotations and/or scales looks wrong. I've tryied to work out the offset transform, etc. that 3DXMax uses for transforms, but I couldn't get anything. Can anyone tell me how to proper manipulate the transforms of objects without messing the hierarchies relative position, transformations, etc. I need the transforms in object space, but it would be good to know how to get them in world, etc. spaces. Also, how do I transform left-handed rotations to right-handed (Or is it the other way about? I don't remember right now, but I want to use OpenGL). Thanks a lot.

##### Share on other sites
Not sure about the hierarchies thing, I've not gotten that far with my 3ds parser yet, but to tranform between the different world axes is fairly simple. To begin with 3dMax has its world axes on their side, ie: z looks up and y looks into the screen, so first you have to multiply all your verts by the following matrix to get the y axis going up:

1, 0, 0
0, 0, 1
0, 1, 0

Only problem now is that the z axis is flipped due to the difference in handed coord systems. This is fixed now by simply negating all the verts' z coords. Just one more thing that you might not have encountered yet. When you rotate your meshes in 3ds it doesn't update the mesh normals for you so they'll end up reflecting light incorrectly in OpenGL or DirectX. Hence before applying the world axis correction above to the normals you first have to multiply them by the meshes rotation matrix. Hope this helps

PS: Just occured to me, with the normals above I'm talking about when you export to an .ASE file. It might be different when working from within the package, I'm not sure.

##### Share on other sites
To get an object's transform in local space, that is relative to it's parent, you multiply it's transform by the inverse of it's parent's transform. For example, to collect the local transforms for all of the objects in the scene you could do this:

(    local SceneTransforms = #()    for Obj in Objects do    (        local ObjLocalTransform = Obj.transform        if( Obj.parent != undefined ) then        (            ObjLocalTransform = Obj.transform * ( inverse Obj.parent.transform )        )        append SceneTransforms ObjLocalTransform    ))

Hope that helps!

-John

##### Share on other sites
Tanks a lot. I'll try and update my exporter. Now I have another starting point for reading and experimenting

##### Share on other sites
Ups, that was me but forgot to logg-in.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627676
• Total Posts
2978582
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 11
• 12
• 10
• 12
• 22