Create a Transfrom Gizmo

Started by
3 comments, last by paic 16 years, 2 months ago
Hi, I am using D3D9. I want to create a transform gizmo to move, rotate and scale my objects, like the ones you get in 3dsmax etc. What would I typically use for it? Should I use ID3DXLine? The idea dor the gizmo is something like this....
Advertisement

Hi,

I don't see any problem with drawing such a thing on the screen using lines and triangle mesh for the cones + some text.

Of course, you'll want your gizmo to be visible even if it is behind / inside an object - so you may need to turn of z-comparison/writes.

Implementing the functionality is another thing. You'd need a kind of a grip object which would react to the cursor movement. For example if the user clicks on the z axis, then the grip object would instruct to move the object by z-axis according to the mouse movement. Practically, to implement this, you'll need to do some ray-object intersection test to know which part of the gizmo is being clicked on in order to find the right function.

Good luck!
Thnks kauna.

Quote: Of course, you'll want your gizmo to be visible even if it is behind / inside an object - so you may need to turn of z-comparison/writes.


I assume that one can just turn off z-comparison writes for the specific gizmo(or lines) that on renders. Would this be the same as Z-Buffer testing?

I also assume that it is possible then to test ray intersection with a ID3DXLine?
Wouldn't it maybe be a better idea to draw it using D3DDrawPrimitive and D3DPT_LINELIST or D3DPT_LINESTRIP ?
The rendering of the gizmo and the way you handle mouse and transformation can be completely seperated. You can have 2 different classes, one for rendering, one for handling mouse, movement, etc. Or you can have 1 class doing both.
So for rendering, use the method you feel the most comfortable with, be it DrawPrimitive or ID3DXLine.
For example, in my editor, my manipulators classes inherit from my Mesh class, and I just load a static Mesh from a file. In my case this has the advantage to enable ray casting on the manipulators, to detect which axis is being clicked. And since the Mesh class provides everything for rendering, it's already included in the engine without more work (except adding a few renderstates :)

This topic is closed to new replies.

Advertisement