CodeBase - Mouse-Matrix Coordinates
Return to the CodeBase listing
Category: 3D
Version: 1.0
Information
Uploaded: 25th Sep 2003 17:37
Modified: 1st Jan 1970 01:00
Author: JamesBlond
Summary
This function calculates the mouse vector from the camera into open space and then travels along it until it hits the matrix.
Full Description
Here's how it works:<br /> I basically projected the mouse coordinates onto an imaginary plane which faces the camera and is r# units away from it. hmax# and wmax# are the height and width of that plane. Then I imagined theres a 2d coordinate system on that plane and used linear interpolation to get the mousecoordinates on that plane (mw#,mh#). Then I converted these coordinates into length and height from the camera to the center of the plane (cl#,ch#) and from the center of the plane to the mouse coordinates on that plane (sl#,sh#). Then I threw these lengths and heights into 3d space taking into acount the camera rotation to get a point in actual 3d space ox#,oy#,oz#. Finaly I travelled alond the line between the camera and that point using linear interpolation again until I hit the matrix.
Comments
No comments yet.