Move object without modemover
#1
Hi everybody,
i'd want to move object without using modemover (only using drag and drop with mouse).
Is it possibile?
can i have some sample code?
thanks
#2
If you want to drag an object over an existing 3D object (for example a bottom plane), then this is very easy to do by using EventManager3D. In this case you set IsDragSurface to true on the object that you want as drag surface. Then you subscribe to the MouseDrag event. 

To see that in action, check the "EventManager3D / Mouse Drag sample".


A more general solution to this is to use 3D ray to 3D plane intersection. This requires more work, but allows you to drag the 3D object in 3D space without any other 3D objects that work act as a drag surface - there you drag the object on top of an imaginary 3D plane. The plane is defined by plane's normal vector (for a horizontal plane use (0,1,0)) and a 3D position on the plane (this can be the initial position of the 3D object that you need to move).

Then just call the Camera.GetMousePositionOnPlane method and pass the current mouse position to the method (with the plane normal and position) and you will get a Boolean that specifies if an intersection exists and all a 3D position on the plane.

See the "Cameras / Mouse 3D ray sample" for a demo on how to use GetMousePositionOnPlane method.



To see an example on how to get
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)