I used to use ScreenPointToRay function to help me do this in Unity3d. But now I use Ogre and Bullet, I have to do this on my own.
I try to dig into Bullet's example and find out this function getRayTo which convert the point on that click on screen (camera) to the 3d world point with 'farPlane' distance from the camera (that what I think). Then they create the ray (vector AB) by set the A point is the camera position, B point is the point get from the function getRayTo above. I try to re-implement this function in my project (use Ogre for graphic, so I have to use Ogre's camera and world). But I can't get it right because I don't understand the function getRayTo from Bullet.
Please explain the algorithm to convert screen point to ray. If there is a better algorithm please teach me.
Note: the scenario to use this algorithm is to find out the position to go for the character - like in the game TouchLight - a point and click game.
https://github.com/bulletphysics/bullet3/blob/d52fb7510bbe3801431cc0a431e4c1847ee3e0f1/examples/CommonInterfaces/CommonRigidBodyBase.h#L17
↧