Yes, I'm sure that OpenGL code snipplet I posted is correct. That's what
I've been doing for every car/aircraft/boat "simulation" I've created so
far.
Let's take aircraft for example.
First you roll it (-180...+180 deg.). During this operation it's Z axis
(points forward) remains unchanged.
Now you apply pitch (-90...+90 deg.) - Z axis points a bit more up or
down, but it keeps it's heading.
Finally you apply heading (0...360 deg.).
To apply such sequential operation to a mesh in OpenGL you need to call
glRotatef in exactly the opposite order. So "heading" is issued first and
"roll" is the last glRotatef issued.
> Are you certain about this? In OpenGL matrices are transformed by "Mv".
> That
> is, matrix multiplied by vertex?
>
> On Thu, Aug 28, 2008 at 11:41 AM, <gl...@mo...> wrote:
>
>> > The function 'glmMatRotateYPR3f' calculates a combined rotation matrix
>> > that
>> > rotates a vector around the Y-axis (yaw), followed by X-axis (pitch),
>> > followed by Z-axis (roll). In the actual code, the matrix needs to be
>> > created in reverse? That, the matrix is Z*X*Y? Am I correct with this?
>>
>>
>> It should be equivalent to:
>>
>> glRotatef(yaw, 0, 1, 0);
>> glRotatef(pitch, 1, 0, 0);
>> glRotatef(roll, 0, 0, 1);
|