Re: Rotation problem
- From: Tony <donotreply@xxxxxxxxxxxxxx>
- Date: Thu, 23 Oct 2008 08:37:57 -0500
You need to get some preliminaries out of the way before you worry about
this. Forget about using glRotate, as it's practically worthless since
you're going to have to be able to rotate your own vertices within your
model at some point. Learn to do your rotations via direct matrix
manipulation.
Don't bother with quaternions, either, as they don't gain you anything over
matrices and are just extra work for something that matrices already do.
Quaternions are good ONLY for rotation, while matrices are good for
rotation, translation, scaling, and shearing. Any rotational benefits
quaterions provide are lost with the need to convert back to matrices. I
found the ArcBall algorithm to be needlessly obtuse, and a pointless
exercise which seems to exist largely as an excuse to use quaternions.
Get a small book on Linear Algebra and learn basic matrix math. There are
books that concentrate solely on matrix math that are fairly cheap. Spend
a week or two getting familiar with it (it's not very hard), then find a
web site that covers matrix rotation around an arbitrary axis. This is the
end result you are after. You can skip to this last part right away and
just copy the code you find on the web if you're impatient, but you'll get
further if you understand the matrix structure as it relates to 3D graphics
(again, it's not hard) and how to perform basic matrix operations (such as
multiplying a matrix and a vector).
Once you have the ability to rotate around an arbitrary axis, rotating a
model in place via the mouse is easy. Essentially, you'll just calculate
how far the mouse has moved in both the X and Y directions, construct an
axis perpendicular to the plane formed by those differences, and rotate
your object around that axis by the length of the mouse motion. There are
tweaks for rotational speed, but those will come to you naturally once
you've reached this point.
As tempting as it seems, don't try to shortcut the learning process. Do
your linear algebra homework, and most of this will be much easier down the
road.
antianti@xxxxxxxxxxxxxx wrote:
Can someone explain how I can do this rotation
properly? Do I need to change the view point?
Thanks.
.
- Prev by Date: Re: Opening a window and closing it after some actions
- Next by Date: Re: Opening a window and closing it after some actions
- Previous by thread: Opening a window and closing it after some actions
- Next by thread: Simple Rotation Question
- Index(es):
Relevant Pages
|