Nicolas Gauvin (nicolas++at++cae.ca)
Mon, 30 Sep 1996 10:54:26 -0400
Here is a way that I find very intuitive to move an object in 3D based on the
2D mouse position. The idea is to restrict the movement of the object to the 3D
plane that is perpendicular to the viewer and that contains the initial
intersection point.
1) Do a channel pick to get 3D world coord of initial clicking position
2) Find the 3D equation of the plane that contain this point and is
perpendicular to the current viewing direction of the channel. ie its normal is
the normalised vector of the current channel viewing direction.
3) While the user is moving the mouse, compute the 3D vector
starting from the eye point of the channel and pointing in the direction of
the current channel orientation offseted by the mouse position. Use the
current (x,y) position of the mouse in the channel and the channel
horizontal
and vertical FOV to compute the mouse orientation offset.
4) Intersect this vector with the plane equation computed in 2 to find
the new 3D position of your object based on mouse position.
This way you will be able to move the object in 3D based on 2D mouse position.
This should work in theory. In practive the tricky part is to compute the
direction of the intersection vector correctly in 3.
If you also want to be able to move the object closer or farther to the
viewpoint then restrict its movement to the 3D vector going from the initial
intersection point to the eye point using another mouse button.
--
Nicolas Gauvin CAE Electronics Ltd., 8585 Cote De Liesse
Software Developer Saint-Laurent, Quebec, Canada, H4L-4X4
3-D Graphics Applications tel: +1 514 341 2000 extension 2275
nicolas++at++cae.ca fax: +1 514 340 5496
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:39 PDT