Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In my animation editor, I have a 3D gizmo that sits on the origin of a bone; the user drags the mesh around to rotate the bone.

I've found that translating the 2D movements of the mouse into sensible 3D transforms is not near as simple as i'd hoped.

For example what is intuitively 'up' or 'down'? How should the magnitude of rotations change with respect to dX/dY? How to implement this? What happens when the gizmo changes position or orientation with respect to the camera? ect.

So far with trial and error i've written something (very) simple that works 70% of the time. I could probably continue to hack at it until I made something that works 99% of the time, but there must be someone who needed the same thing, and spent the time coming up with a much more elegant solution.

Does anyone know of one?

share|improve this question

2 Answers 2

You could constrain rotation to just the 3 axes that align with the gizmo's vectors.

Then add a drop down box to allow the gizmo to line up with either world, local, view, etc.

This is the way 3ds max does it.

share|improve this answer
    
+1 The 3ds max's approach in which you can set gizmos to align with certain coordinate systems is really cool. –  Dave O. Feb 20 '11 at 14:23
    
I really like Max system aswell, it feels very 'robust'. In my app I go for something similar; as the bone rotation is based on the complete gizmo rotation the user can rotate around any arbitrary axis they like, and change this by rotating the gizmo independantly of the bone. The problem with this is that the gizmo moving as one has undesired effects when trying to constrain on one axis (euler angle). The next feature is adding the ability to work with an axis independantly. –  sebf Feb 20 '11 at 19:02

Download a bunch of demos of 3D-editors, like 3ds max, Milkshape3D, Blender, ZBrush .... Follow a tutorial for every of the modelers that teaches you how to construct something out of primitive objects. The reason is that the chance to have to move objects around freely in 3D space is higher when working with primitive objects than, say, when manipulating vertices.

Figure out, which software's approach you liked the most and copy as if there was no tomorrow.

share|improve this answer
    
I've been examining Max this evening trying to pick up what all the little behaviours are I like about it. The local rotation matches quite closely what I've got so i'm going to have another go with my code and see if I can emulate it. –  sebf Feb 20 '11 at 19:13
    
@sebf good luck and much success. –  Dave O. Feb 20 '11 at 19:18
    
Thank you. I've removed some of the code that tried to guess the orientation, and instead take the magnitude based on the mouse deltas like Max does and its more stable now. When I figure out how to clamp the gizmo so it aligns perfectly with the bone constraints axis' that will be the key... –  sebf Feb 20 '11 at 19:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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