Multi-Button Panel
by Robert Fritzen · in Torque 3D Beginner · 10/03/2013 (12:26 pm) · 4 replies
So, now I've got a little interesting thing for everyone.
I've created a little control panel item, and on it there are four buttons. I'd like the user to be able to aim at the specific locations of the button (based on node positions) and be able to push the different buttons sending a command to the server indicating which button was placed.
Obviously we're talking about a raycast and a keyboard mapped command to "use" the panel, both of which I have in place. I need to know how to properly and easily find the closest node the player is aiming at and based on that specific node (I know which ones go to which button) send a command to the server when used.
I've created a little control panel item, and on it there are four buttons. I'd like the user to be able to aim at the specific locations of the button (based on node positions) and be able to push the different buttons sending a command to the server indicating which button was placed.
Obviously we're talking about a raycast and a keyboard mapped command to "use" the panel, both of which I have in place. I need to know how to properly and easily find the closest node the player is aiming at and based on that specific node (I know which ones go to which button) send a command to the server when used.
About the author
Illinois Grad. Retired T3D Developer / Pack Dev.
#2
Couldn't you do this:
10/15/2013 (12:48 pm)
@Richard you mean through a raycast?Couldn't you do this:
%cast = ContainerRayCast(%start, %end, %mask, %exception, %isClientCast);
if (%cast)
{
%name = getWord(%cast, 0).getName();
}
#3
10/15/2013 (7:04 pm)
Unfortunately, that gives you the object, not the individual collision shape that was hit.//TODO: make RayInfo an API type DefineEngineFunction( containerRayCast, const char*, ( Point3F start, Point3F end, U32 mask, SceneObject *pExempt, bool useClientContainer ), ( NULL, false ), "@brief Cast a ray from start to end, checking for collision against items matching mask.\n\n" "If pExempt is specified, then it is temporarily excluded from collision checks (For " "instance, you might want to exclude the player if said player was firing a weapon.)\n" "@param start An XYZ vector containing the tail position of the ray.\n" "@param end An XYZ vector containing the head position of the ray\n" "@param mask A bitmask corresponding to the type of objects to check for\n" "@param pExempt An optional ID for a single object that ignored for this raycast\n" "@param useClientContainer Optionally indicates the search should be within the " "client container.\n" "@returns A string containing either null, if nothing was struck, or these fields:\n" "<ul><li>The ID of the object that was struck.</li>" "<li>The x, y, z position that it was struck.</li>" "<li>The x, y, z of the normal of the face that was struck.</li>" "<li>The distance between the start point and the position we hit.</li></ul>" "@ingroup Game")Might be able to do something with the hit position information though....
#4
10/15/2013 (7:07 pm)
While I hope we can find a variable solution for this, I just re-modeled my button and have four different materials for each of the four buttons for my purposes. So I'm good in terms of that, but being able to determine which collision shape on the object was hit would definitely be an added bonus for T3D.
Torque Owner Richard Ranft
Roostertail Games