locked
How to rotate the 3d object with mouse moving

    Question

  • I would like control the 3d object's rotation by mouse.When i press on the object and move the mouse, the object rotate an angle.

    Thanks in advance.

    Friday, November 01, 2013 7:59 AM

Answers

  • Windows Store apps don't have a MouseMove event. You'll use pointer events for this. On PointerPressed you'll hit test to see if the user clicked on the object and then in PointerMoved you can rotate the object. Finish in PointerReleased.

    To hit test you'll need to do a bit of math: cast a ray from the camera through the point on the view plane the upset clicked and intersect that ray with your object at whatever level of detail makes sense (bounding box or sphere may be sufficient or you may want to go down to individual rectangles).

    --Rob

    Friday, November 01, 2013 2:03 PM
    Owner
  • This is the 'picking' problem where you take the mouse location, and reverse project it into a ray in the scene, then use collision-detection to find the object 'hit'.

    Here is an example of this technique http://www.braynzarsoft.net/index.php?p=D3D11PICKING

    • Marked as answer by halcyons Monday, November 04, 2013 6:19 AM
    Friday, November 01, 2013 5:39 PM

All replies

  • You want MouseMove event

    then change the Objects X, Y and Z according to the movement of the mouse... Z is normally associated with the mouse Scroll Wheel.

    You may need to work out a comparison between the object and the Window Size ... as the mouse may scroll too much for you. But that's another story :P Get the basics first then make perfect.

    Dave


    Digital Forensic Software Developer
    http:\\ccs-labs.com Mark as Answer or Vote up if useful thank you!
    Volunteer Developers Required to work on free systems that can be used to reduce online child abuse and bullying! contact: dave@ccs-labs.com if you are interested.

    Friday, November 01, 2013 10:55 AM
  • Thank you, But I want to press the object rather than anywhere. Is there any simple way to detect if I press the object.
    Friday, November 01, 2013 11:02 AM
  • Windows Store apps don't have a MouseMove event. You'll use pointer events for this. On PointerPressed you'll hit test to see if the user clicked on the object and then in PointerMoved you can rotate the object. Finish in PointerReleased.

    To hit test you'll need to do a bit of math: cast a ray from the camera through the point on the view plane the upset clicked and intersect that ray with your object at whatever level of detail makes sense (bounding box or sphere may be sufficient or you may want to go down to individual rectangles).

    --Rob

    Friday, November 01, 2013 2:03 PM
    Owner
  • This is the 'picking' problem where you take the mouse location, and reverse project it into a ray in the scene, then use collision-detection to find the object 'hit'.

    Here is an example of this technique http://www.braynzarsoft.net/index.php?p=D3D11PICKING

    • Marked as answer by halcyons Monday, November 04, 2013 6:19 AM
    Friday, November 01, 2013 5:39 PM