Game Development Community

T3D Pro 1.1 - window pixel --> ray calculation [RESOLVED]

by Keith G Wood · in Torque 3D Professional · 04/03/2013 (5:17 pm) · 2 replies

This references a section of html documentation which comes with T3D - under: Scripting --> Advanced --> RTS Prototype --> 2.2 Mouse Click Reaction.

This contains a sample code:
function PlayGui::onRightMouseDown(%this, %pos, %start, %ray)

I am interested in how this "%ray" parameter is derived? I have searched both script & engine code & can't find where it is done - can someone please point me at it?

Presumably it takes the clicked pixel position in the window, derives deviation from window centre (I'm assuming based on window size & fov?) adds this to the camera's direction to get the resultant direction in which the click is "looking"?

#1
04/03/2013 (9:47 pm)
Relevant code will be in gameTSCtrl.cpp:

The GameTSCtrl::onRightMouseDown() method calls GameTSCtrl::makeScriptCall().

GameTSCtrl::makeScriptCall() creates the "pos" "start" and "ray" params and calls the onRightMouseDown() script function with those params.
#2
04/05/2013 (7:39 pm)
Thanks for the info - that saved me a lot of searching!