How To Emit a Particle
by John Peter · in Torque 3D Beginner · 07/20/2010 (11:52 am) · 2 replies
Hi All
I have a Magic box. If the User click the Magic box The Fire should Emit.
I know how to Emit a Fire particle. But i want to mount in the Magic Box with Proper Direction .
The Fire should come from Magic Box only.
How can i do it.
Thanks and Regards
John
I have a Magic box. If the User click the Magic box The Fire should Emit.
I know how to Emit a Fire particle. But i want to mount in the Magic Box with Proper Direction .
The Fire should come from Magic Box only.
How can i do it.
Thanks and Regards
John
About the author
Associate Rene Damm
For the clicking, bind a button click to a script function that triggers the raycast.
For the raycast, use GuiCanvas::getCursorPosition (you probably need to translate from true screen-space coordinates to window-space coordinates using GuiCanvas::screenToClient) and GuiTSCtrl::unproject to project the current mouse cursor to world-space coordinates. Then subtract that vector from the camera position, turn that vector into a unit vector, multiply it by the distance by which you want to cast, and then add it to the camera position to get the position of the raycast endpoint.
Then do a containerRayCast and see if your magic box got hit.
For any other kind of picking that you need, you can the simply extend the processing of the raycast result.
Word of caution, though... I suck at math so the vector math here may be faulty plus there may be a much simpler way to do this that I'm totally overlooking.