I'm trying to achieve the same effect than 3ds max gizmo drawn on the bottom-left and up-right side of the viewports, these ones:

enter image description here

So, let's say i got already the 3d models of those 2 gizmos. What's the transformation i should apply to them?

I think my current attempt is not correct actually, for instance:

enter image description here

Let's say i can apply a model/view/projection matrix on a subviewport to the 3d model... right now i'd be using

model      = mat4.extract_rotation(self.camera.view)
view       = identity()
projection = identity()

where extract_rotation is getting the upper-left 3x3 submatrix of a 4x4 matrix.

Anyway, what's the theory behind these 3ds max gizmos and how i can mimick them on my opengl test?


In your 3D rendering process, you do multiple transformations from one space to another. Recall, that we use a 4*4 matrix to represent the three basic transformations: Scaling, Translating and Rotating.

What your 3 axis gizmo is showing you is the rotation of your camera. You don't care about the scale or translation. So, every time you move the camera, you only apply the rotation part of it to the gizmo, instead of the whole matrix. Here is a small post if you don't remember how to extract the rotation matrix out of a 4*4 transformation matrix.

Going a step further, you can also do it the opposite way, and apply the rotation you do on the gizmo (such as the cube on the upper right in your screenshot) to your main camera, and thus easily align your main view on the axis you want.

Please note that you still have to apply the projection matrix to your gizmos, as you're still projecting the 3D objects to a 2D screen!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.