Game Development Community

Mouse click with TGE 1.4.2

by Harrison Brock · in Torque Game Engine · 11/22/2006 (7:04 am) · 1 replies

I have been like at the editTSCtrl.cc file and seen this methods.

void EditTSCtrl::onMouseDown(const GuiEvent & event)
{
make3DMouseEvent(mLastEvent, event);
on3DMouseDown(mLastEvent);
}

and

void EditTSCtrl::make3DMouseEvent(Gui3DMouseEvent & gui3DMouseEvent, const GuiEvent & event)
{
(GuiEvent&)(gui3DMouseEvent) = event;

// get the eye pos and the mouse vec from that...
Point3F sp(event.mousePoint.x, event.mousePoint.y, 1);

Point3F wp;
unproject(sp, &wp);

gui3DMouseEvent.pos = smCamPos;
gui3DMouseEvent.vec = wp - smCamPos;
gui3DMouseEvent.vec.normalize();
}


Can this been use to see if an object like a coin or something has been click in 3D space?

#1
11/24/2006 (2:54 am)
It would seem so, but you'll have to alter that function for use in a regular TSControl (the main render GUI element used when not in the editor). You'll then most likely want to use a raycast to find out if you've clicked on something you care to interact with.

I believe you'll find this resource useful for your purposes:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7335