Game Development Community

dev|Pro Game Development Curriculum

Click n Pick

by J. Donavan Stanley · 04/21/2003 (12:56 pm) · 27 comments

Download Code File

This resource provides an improved mechanism for mouse selection of objects within the 3D environment. This resource improves on the mechanism used in the "Object Selection" resource to provide a more complete and general solution. This resource does NOT deal with higher level tasks such storing the selected object or "click to move" but rather makes them simpler to implement. At some point in the future, I may release my version of object selection and click to move, but implementation details for these are a design issue that varies from team to team.

Within the zip file are two patches:

world_click.patch - This adds mouse button handlers to GameTSCtrl. When the user left or right clicks over the GameTSCtrl, it will extrapolate some positional information and forward the request up to the server.

Servers can implement "serverCmdOnWorldClick" to receive these messages. This function receives the following parameters:
%client - As with all server commands, this is the client issuing the request.
%mouseVec - The mouse vector which can be used for rayCasts.
%cameraPoint - The position of the camera when the mouse was clicked.
%button - An integer identifying the mouse button. 0 for left 1 for right.
%clickCount - An integer identifying how many times the button was clicked.

The variable "$pref::ratelimits::maxClicks" controls the maximum number of clicks the user is allowed to perform per second. It currently has a default value of 4. If this click rate is exceeded a warning will appear in the console and the client will refuse to send the command to the server.

pick.patch - The patch adds two helper functions to the Sim namespace as well as the script code:

pickObject - This function accepts the mouseVector and cameraPosition from the OnWorldClick and returns the object (ID) for 3D object the user clicked on (if any). Optional parameters allow you to specify a different mask to use (more on this later) as well as indicate objects to be exempt from selection. This function expects: A Point3F vector for the mouse. A Point3F position for the camera. A pointer(c++) / ID(script) to a SceneObject that is exempt from being selected. And a S32 mask to override the default selection mask. The C++ version will return a pointer to an object or NULL. The script version will return the object ID or 0.

Sim::pickPoint / pickPoint (console version) - This function is very similar to the above except that it returns a Point3F with a world position of the mouse click.

There are a handful of script variables for tuning the behavior of these functions:

"$pref::Video::PickPointDepth" and "$pref::Video::PickObjectDepth" these two control the depth of the raycast used to determine what the user clicked on. They default to 200.

"$pref::Video::PickPointType" and "$pref::Video::PickObjectType" these two provide the default masks used. The point mask contains objects that could serve as locations such as terrain, interiors and the like. The object mask contains things the user might want to select such as items, other players, vehicles and what not.


Finally this patch adds support to the various Point classes to allow them to be created from strings. I was tried of writing dSscanf every time I needed to convert so I added new constructors and operator= functions.
Page«First 1 2 Next»
#21
04/16/2007 (7:42 am)
Has anyone implemented this in TGE 1.5?
#22
09/10/2007 (12:12 pm)
This was asked in April....no reply.

Is there any support for picking in selecting objects in TGE 1.5.2? All I want to be able to do is click on a world object (possibly noted by some kind of decal) and pop up a list of functions that can be applied to the selected object.
#23
09/20/2007 (12:39 pm)
How long are we supposed to wait until we determine the information in a thread is totally obsolete and utterly useless?
#24
07/07/2008 (7:35 am)
Torque is just a loss of time.. a real piece of junk and the people of garagegames are simply useless... After a few month of problems I just shifted to a better engine... and believe me... there is a lot out there much better than Torque.
#26
08/23/2008 (9:51 pm)
wonder why that resource has been deleted?
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10359%22

i get a

The resource associated with this URL has been deleted and is no longer available.
#27
09/17/2008 (6:23 pm)
Hi Austin,

Just remove the %22 from the end of your link and your good to go.

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10359

RT
Page«First 1 2 Next»