Game Development Community

dev|Pro Game Development Curriculum

Torque Mission Editor Snapping Tool...

by Daniel Hopkins · 09/15/2008 (2:13 pm) · 20 comments

Download Code File

Howdy! After posting my first blog I'm now ready to post my first resource. The idea of this resource has been bopping around in my head ever since I bought Torque and found the technique for add objects to the scene to be rather difficult. I don't know about you, but trying to figure out how to orient my camera right so as to add the object the way I want to took a lot of time to even begin to master. So, when I decided to get back into Torque a couple days ago, I decided to take care of that problem. INTRODUCING: Object snapping!!

What does it do, you ask? Well, when you open the creator tree and click on the object you want to add (a snowy tree), instead of immediately dropping it into the scene, it goes into "object add mode." This clears the editor out of your way for a better view, and adds a temporary [snowy tree] object which is projected onto the terrain or interior at which your mouse is pointing. When you have it in the right spot, left-click to create a "hard" copy--point and click. Now, instead of going back to the editor, it remains in add mode and creates a new temporary object of the same type: allowing you to point, click, and add it to your scene[multiple snowy trees]. So, actually, the process is more like: point-click, point-click...until you're done adding the object. Once you're done, right click and the editor will reappear exactly as it was before, allowing you to select another object (perhaps a green tree) to add or do whatever. This alone is a valuable capability as it allows you to quickly add objects to your scene by skipping the "move camera-drop object-re-orient object-move camera-drop object--...." pipeline altogether. Again, click-click...and you're done.

Now that might be great, but it's not all. Not only does it place the object at the projected positoin, but it also orients the objects according to the surface normals!!! So, no need to re-orient trees on sloped terrain, just point and...well...click!! It also does the same for interiors so adding objects to the walls becomes a cinch!! All you have to do is point and...oh, never mind. As you can tell, I'm really excited about it. It's made creating scenes in Torque that much easier for me.

To top it all off, it allows you to rotate your object along its relative z and y axis and adjust its height relative to the surface. This gives you almost complete control of the object's placement without having to exit adding mode and/or adjust the object using the axis gizmo.

Just so you know, this tool does not replace the original adding modes--it merely adds to them. Once integrated, it creates two new menu items in the "dropping object" section:

1) "Drop to cursor(Snap)": activates the tool
and
2) "Snap uses surface normals": allows you to toggle the object-to-surface normal orientation.

As the code is kind of long, I'm not going to post all the changes. However, the installation and using guide is included with the download.

Belows is a screenshot of a little scene I made using the tool, limiting myself to the following conditions:

1) all objects must be added WITHOUT changing the camera orientation

2) all objects must remain as they were placed: NO use of axis gizmos

The screenshot was made without changing the camera's orientation from that used to add the objects. Observe the power of point and click!!

img149.imageshack.us/img149/7529/screenshot00200002qf6.png

Enjoy!!

P.S. Although the code was mine, I had some mathematic questions and a source question answered by:

James Ford and Gary"ChunkyKs." Special thanks goes to them.

#1
09/15/2008 (2:59 pm)
Wow, amazing tool! This should be added into the main branch.
#2
09/15/2008 (10:44 pm)
That sounds great! Thanks a lot!
#3
09/15/2008 (10:48 pm)
Lol - Daniel, not only is a wonderful addition, I also have a fun time reading your presentation. You worked at TV marketting or something? :D
#4
09/16/2008 (7:31 am)
good stuff mate! I will be looking at integrating this later. Will be a great tool to have at my disposal.
#5
09/17/2008 (10:35 am)
Absolutely fantastic, thank you.
#6
09/17/2008 (3:42 pm)
Daniel, I spoke too soon!! This is pure magic man, I can't wait to show you what I'm going to do with it :)
#7
09/18/2008 (12:27 pm)
Excellent resource, thank you. I immediately discovered its benefits testing with fences. Made the process infinitely easier.
#8
09/19/2008 (2:31 am)
Looks *really* useful - has it been tested in TGEA? (before I go and try it myself :)
#9
09/19/2008 (6:41 pm)
What can i say? Absolutely Fantastically Amazing.
#10
09/20/2008 (5:34 pm)
Hey guys! Thanks for the nice reviews!! I had to go somewhere for a week and left before the resource was approved, so I haven't gotten a chance until now to check up on it. Thanks again for your support!

@Novack: Lol...no :)

@Dave Young: Cool, glad it helped! I can't either :)

@Eikon Games: Sorry, no it hasn't. I'm hoping to upgrade to TGEA in a while, but until then, I'll only be testing on TGE 1.52
#11
09/22/2008 (2:47 pm)
Great resource!!!
I will be able to check the code I would have needed to write to do the same.
Right on time! ;-)
#12
09/23/2008 (9:30 am)
Wonderful!
#13
10/28/2008 (3:29 pm)
@Eikon Games and anyone interested:
I just bought TGEA and integrated the tool. As the folders and script files are considerably different, it took a bit longer than I thought. If anyone's interested in integrating it into TGEA and doesn't want to go through the hassle of figuring it out, make a post here, or contact me via my public email address and I'll update the .zip file to include the TGEA installation guide.
#14
11/14/2008 (3:08 am)
Yeah really interested in the TGEA port of this... Can you update the zip or share?

Tnx a lot, it's a nice resource to have!

;-)
#15
12/02/2008 (1:35 pm)
hi there, I'm also very interested in a TGEA port of this resource, its a good one
#16
12/02/2008 (1:45 pm)
I posted the TGEA port on the update resource page, here:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=15449

Cheers,
Dante
#17
12/02/2008 (9:50 pm)
@Dante: Thanks again!
#18
01/16/2009 (1:17 am)
Is there any chance to find the source files for this fantastic resource or I'm blinded to find ?? Also on the update site of this resource I can not find any download link.
#19
01/20/2009 (10:27 am)
Hi!
I'm having some difficulties with using this tool,
I have compiled it as it should, Added the .gui and .cs to the editor map.
Then when I start up Torque I go into the creator.
I create an object (Tried interiors, static shapes and shapes)
Then the creator gets out of the way (So i have the whole screen as it is supposed to do).
But when I click on a terrain or interior with the mouse nothing happens.
I also cant seem to get out of the mode by clicking the right mouse button.
I can get out the mode by pressing Ctrl+fn+F11 (I'm on an Imac) which is the hot key for toggle camera.

I tried with the normal version posted here as wel as with the files updated. (your update to it)
I cant figure out what I'm doing wrong so is there anyone who knows the answer to this?

btw, I installed it in a clean Torque app.
#20
04/01/2009 (9:34 pm)
@Michael Schaumburg: If by "source files" you mean all the files I changed to implement the resource, I believe I packed them in with the download. Are they not there?

The download link is now at the top (or at least I can see it). Maybe something went wrong when the site got updated. Try downloading again and see what happens.

@Tim Cottenham: Hmmm...I'm not sure what the problem is. Are you using TGE or TGEA?