Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!snorkelwacker.mit.edu!ai-lab!ai.mit.edu!sundar From: sundar@ai.mit.edu (Sundar Narasimhan) Newsgroups: comp.windows.x Subject: Re: 3d rotation in room coords? Message-ID: <13709@life.ai.mit.edu> Date: 5 Mar 91 18:01:55 GMT References: <9103050342.AA20065@maui.coral.com> Sender: news@ai.mit.edu Reply-To: sundar@ai.mit.edu Organization: MIT Artificial Intelligence Laboratory Lines: 39 In article <9103050342.AA20065@maui.coral.com>, tomt@maui.coral.COM (Tom Tulinsky) writes: |> |> I'd like to allow the user to do 3d rotations of an object in the |> 'room' coordinate system; i.e. y is toward the ceiling, x is to his |> right, and z is out of the screen (rt-handed). I want this to be true |> even after he has done some rotations.... The naive way of |> implementing rotations accumulates them so that a 90 deg. y rotation, |> the x axis is now pointing out of the screen, where the room z axis |> is. |> |> I've tried everything I can think of, and can't get it to work. |> |> My latest version, (using the Vogle package from uunet, somewhat like |> SGI GL) does the y rotation, then tries to calculate where the xroom |> vector is, and uses an arbitrary rotation routine to rotate about it. |> The result: it just interchanges the order of rotations: the X |> axis is constant but the Y axis is rotated by xrot. (also it only |> works for y<0). I understand what you want to do, but not what your implementation does entirely. Here's what I have used in the past for something like this. (I'm assuming from your code, that you want your mouse to control viewer position). Think of viewing the object from the surface of a sphere. Your eye point can be specified by 2 co-ordinates (you can think of them as latitude and longitude). Have your mouse motion map to these co-ordinates. (For example, you can have up down motion map to -90 to +90 degrees latitude wise, and your right-left motion map to -180 to +180 degrees longitude wise). Once you have these co-ordinates it is a simple matter to compute where the eye point is, and then other things needed for graphics like the view vector and so on. Maintain your up vector to be always up toward the ceiling.* Hope this helps. * There is a subtlety associated with keeping the up vector pointing up all the time (especially as your eye point gets way up and you are looking almost directly down). If what you want are realistic fly-bys then you can't keep the up-vector constant.