Skip to main content
gamedev.net
🔒 Locked

Rotating objects with mouse

Started by Kubo Mar 9, 2008 at 4:26 PM 1 replies 1.2k views
Original Post
Kubo
Kubo
Hi, I do not have a lot of experiences with Direct3D using C# programming. I have a quite big problem. Maybe not for you :) I want to rotate cube with mouse (when left button is pressed and moving with mouse). I have already implemented picking to test if user has caught the cube with mouse. I rotate cube with Matrix.RotateX(), Matrix.RotateY() methods on OnMouseMove() event. But this way I rotate also all axes. Is there any possiblity to rotate only cube ???
jollyjeffers
jollyjeffers
The Direct3D/D3DX API's don't really have features that directly do this sort of work for you so I'm going to move it over to 'Maths & Physics' for further discussion. They may be able to guide you as to the sort of mathematics you want to use and you can then map these back to, for example, member functions of the Matrix class.

Two things to suggest:

1. Do some searching around for "arc ball rotation" - often its implemented as a camera movement technique, but you can probably map the same principles to rotating a single object.

2. When you issue a draw command to D3D it'll use the current pipeline state. Obvious as that sounds it may not be so obvious that you can just reset/change the current matrix transform between draw calls. That way your matrix transformations only affect the appropriate object.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
Kubo
Kubo
Thanks for help, I have solved it by using quaternion structure (arc ball) ...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.