Previous Blog Next Blog
Prev/Next Blog
by date

Torque X Builder 3D Progress: The Axis Gizmo

Torque X Builder 3D Progress: The Axis Gizmo
Name:John Kanalakis
Date Posted:Apr 22, 2008
Rating:5.0 out of 5
Public:YES
Comments:YES
RSS Feed:GarageGames Blog feedor Subscribe with .
Profile Page:View profile page for John Kanalakis

Blog post
Torque X Builder 3D is coming along very nicely. I have received a lot of great community encouragement and feedback. And as a part of that community, I'm doing my best to factor in all the feedback. I'm also limiting how much I "perfect" the tool in order to get it finished as quickly as possible. Today's focus is on the Axis Gizmo. Since the main goal of TXB 3D is to make Torque X 3D scene creation easier, the Axis Gizmo is a really big part of hitting that goal.

The problem is that creating an Axis Gizmo is not as easy as it sounds. I spent a lot of time researching differnt methods of creating an Axis Gizmo and the one thing I found is that there really is not much information out there about it (or I'm really bad at online researching ;) ). This becomes even more complicated when you need to work within the limitations of the XNA Framework, where simple rendering primitives, such as line and circle drawing, simply don't exist. So, what does one do? I broke the problem out into two smaller problems: rendering the gizmo and processing the user input. I naturally started with the easier problem.

Processing Input
Processing input is pretty straight forward in Torque X, since it just involves creating an InputMap and processing Move structures, just like any other Torque X game does. It took a little more to work to figure out the dragging functionality, and was implemented by tracking the mouse button states. The scene object movement is accomplished by setting the T3DSceneComponent position position by scaling the mouse input. The harder part to figure out was how to select objects in the first place. In short, you need to get the position of the camera, take the mouse's X and Y screen coordinate, scale the position to the view frustrum (accounting for FOV and Aspect Ratio), and then cast a ray forward into the scene and test which 3D shape's bounding box is hit. So, now that shapes are being selected and dragged around the screen, I needed to have some sort of visual representation for the Gizmo.

Rendering the Gizmo
I started out by creating one by hand. The following lame gizmo (shown in the last blog) was created by dynamically generating 3 tall and thin boxes. It was functional, but the Gizmo looked pretty bad as you can see here:



The biggest lesson learned was that the "implementing the Gizmo as a mesh" solution was working. Great! Now, it's a matter of getting it to look good. I received a lot of great community feedback to work with (Thanks James B. and Chris K.). So, I popped open my favorite 3D Modeling program and produced 3 models to represent the Gizmo in the three different functional states (move, rotate, and scale). I exported the models into the .FBX format (native to XNA) and used the T3DXNARenderComponent to render them on screen. The models are simple enough to scale them up and down to match the size of the object selected. Here's how they look in each mode:

Translation Gizmo Arrows



Rotation Gizmo Rings



Scaling Gizmo Blocks



The Gizmo meshes can probably be improved, but most likely won't for a while. Since they are working out well enough, I'm moving off to the next challenge. Again, I'm taking every possible shortcut to get this out as quickly as possible. I just wanted to take a few minutes and write about creating the Gizmo, because everything involved used stock Torque X code. This is just a testament to the power of Torque X that's already built-in... Great Job GG!

John K.

Recent Blog Posts
List:05/04/08 - Torque X Book Completed
04/22/08 - Torque X Builder 3D Progress: The Axis Gizmo
04/07/08 - Development Journal for Torque X Builder 3D
03/31/08 - Torque X 2.0 Tutorials Updated
11/04/07 - A New Casual Game
10/26/07 - Torque X: Progress, Pics, and Free Code
12/25/06 - Rocket Commander XNA
07/06/06 - Solitaire Blaster Preview Images

Submit ResourceSubmit your own resources!

Rene Damm   (Apr 22, 2008 at 03:18 GMT)
Hey, great work. Liked how you turned something that looked like a limitation at first into an opportunity to come up with a superior solution. Those 3D gizmos are great.

Tom Eastman (Eastbeast314)   (Apr 22, 2008 at 04:14 GMT)
Looking like a sweet tool now!

James Brad Barnette   (Apr 22, 2008 at 16:48 GMT)
Great Job man

Davey Jackson   (Apr 23, 2008 at 07:38 GMT)
John once again puts the "Uber" in Uber : )

Jonathon Stevens   (Apr 24, 2008 at 04:41 GMT)
pure P I M P John

John Kanalakis   (Apr 24, 2008 at 18:21 GMT)   Resource Rating: 5
Thank you guys! I wanted to post my woes about creating an Axis Gizmo so that there is finally some useful information out there on the web for someone else interested in creating a 3D editor. I had the hardest time finding information, ultimately gave up and started experimenting. Anyway, thanks again for the support.

John K.

You must be a member and be logged in to either append comments or rate this resource.