Object Selection
by Jeremy Noetzelman · in Torque Game Engine · 09/23/2001 (6:10 am) · 10 replies
Is there an existing methodology for object selection during gameplay?
ie I'd like to be able to click on various shapes (players, statics, etc) and have a gui box get updated with data specific to that instance.
So, I need to know when a shape has been clicked on. Is there anything to do that in the SDK at this point?
ie I'd like to be able to click on various shapes (players, statics, etc) and have a gui box get updated with data specific to that instance.
So, I need to know when a shape has been clicked on. Is there anything to do that in the SDK at this point?
#2
09/27/2001 (10:39 pm)
I've looked through editor.cs and editor.bind.cs, slogged through most of the .cs files in all the directories, in fact, and nothing jumps out at me after five or six read-throughs. I'm not very good at this, granted, but I can't find the editor commands for the mouse, or any script commands in general that seem to select objects. Perhaps it's a special GUI window? I really can't find it in the scripts.
#5
09/28/2001 (3:57 am)
Im interested in that also... cant seem to find out how to do it.
#6
10/06/2001 (8:52 am)
Regarding the mission editor, I'd bet this is mostly happening in code. Search for things like onMouseDown and onMouseDragged.
#7
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2173
10/11/2002 (7:24 pm)
Here's the tutorial on this by David Myershttp://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2173
#8
With David's code,:
-You click an area.
-It draws a ray from your camera to the x,y,z coords you clicked.
-If there's an object(or any type - which can be specified in script), it will pass the unique handle to the code.
-Once in the code, it gets a Ghost Index for the handle you specified, and stores it in gIndex.
**Note: bstream->writeInt(gIndex,10); - Can someone tell me what this does?
-Then the function drawing the box, void ShapeBase::renderObject, in shapeBase.ccasks for the handle that you selected, and if that handle isnt -1 or NULL, it then draws the box around this handle.
----
My questions:
o Why does it ask for the ghost? Doesnt seem like it uses the ghost index number in drawing the box.
o How can we remove the box on all items, if the handle passed is NULL(de-selection)?
o Does the ray that is drawn out in the first steps stop at an object it hits, or does it go through all of them. This leads to the question, can 1 ray identify multiple items. If I have 2 objects sitting on top of each other, can I set up a toggle for (go to next item) ?
Thanks,
Jared
10/12/2002 (11:26 am)
David's code is great. Everything worked smoothly when I added it last night. (have some questions though) Now, I'm trying to figure out de-selection of the item you clicked on.With David's code,:
-You click an area.
-It draws a ray from your camera to the x,y,z coords you clicked.
-If there's an object(or any type - which can be specified in script), it will pass the unique handle to the code.
-Once in the code, it gets a Ghost Index for the handle you specified, and stores it in gIndex.
**Note: bstream->writeInt(gIndex,10); - Can someone tell me what this does?
-Then the function drawing the box, void ShapeBase::renderObject, in shapeBase.ccasks for the handle that you selected, and if that handle isnt -1 or NULL, it then draws the box around this handle.
----
My questions:
o Why does it ask for the ghost? Doesnt seem like it uses the ghost index number in drawing the box.
o How can we remove the box on all items, if the handle passed is NULL(de-selection)?
o Does the ray that is drawn out in the first steps stop at an object it hits, or does it go through all of them. This leads to the question, can 1 ray identify multiple items. If I have 2 objects sitting on top of each other, can I set up a toggle for (go to next item) ?
Thanks,
Jared
Torque 3D Owner Phil Carlisle
My guess is that its doing some ray cast against the objects bounding box, but thats just a guess.
Phil.