realbasic-games
[Top] [All Lists]

Re: rb3d: limiting rotation, quaternions into angles

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: rb3d: limiting rotation, quaternions into angles
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Thu, 27 May 2004 09:09:31 -0500
Delivered-to: realbasic-games at lists dot realsoftware dot com
List-help: <mailto:realbasic-games-request@lists.realsoftware.com?subject=help>
List-id: REALbasic Games <realbasic-games.lists.realsoftware.com>
List-post: <mailto:realbasic-games@lists.realsoftware.com>
References: <20040527114352 dot 21757 at pshome dot bangor dot ac dot uk>
At 11:43 AM +0100 5/27/04, Robert Ward wrote:

It seems to work fine, except that I want to limit the amount of pitch,
so that the camera never looks backwards, ie I want to stop pitch
rotation if the camera is already looking straight up or down.

I do that in my Cubic Panorama demo (on the CD, maybe also downloadable from the website; ask me if you can't find it in either place). What I do is simply keep mPitch and mYaw variables, which I increment based on the mouse or keyboard. Then to update the camera, I do something like this:

  cam.orientation.SetRotateAboutAxis( 0.0, 1.0, 0.0, mYaw )
  cam.Pitch mPitch

The first line resets the orientation of the camera to just the yaw, and then the second line pitches it from there. Now all you have to do is limit mPitch to the range [-pi, pi] and you're done.

Best,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout           REAL Software, Inc.                |
|    joe at realsoftware dot com       http://www.realsoftware.com        |
`------------------------------------------------------------------'
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>