On 11/01/2009 10:28 AM, Erik Hofman wrote:
> At this time I've tried about everything to get the listener orientation 
> aligned properly. What's needed it converting the ViewOrientation matrix 
> (quaternation) and/or ViewOrientationOffset matrix (quaternation) to 
> align with OpenGL and get the look-at and look-up vector from it.
> the look-at vector should match the OpenGL view vector and the up-vector 
> is the perpendicular vector pointing out of the top of the listeners head.
> 
> It looks like I'm really close (for testing I've commented out some 
> position offset and velocity vector code) but to me it's not yet 100% 
> right, as if I'm missing something. I would really appreciate it if 
> someone who knows his way around this could take a look at 
> SGSoundManager::update_pos_and_orientation() in 
> SimGear/simgear/sound/soundmgr_openal.cxx
> View related values are set in FlightGear/src/Main/viewmgr.cxx: both 
> recalcLookFrom() anf recalcLookAt()

I know a fair bit about quaternions and rotations in general.

I don't know my way around the soundmgr code, but I will take 
a look.  At first glance this code looks much friendlier than 
the corresponding viewmgr code, in the sense that its comments
are more numerous and much more meaningful.

> Luckily I seem to get the best ideas when I'm frustrated since I now 
> found out that the up-vector of the listener was actually pointing down. 

One small thing I can say about that:  In aeronautical engineering,
the body x,y,z directions are conventionally defined as follows:

  x = out the nose of the aircraft
  y = out the starboard wingtip
  z = out the bottom of the aircraft

This is diagrammed at http://www.av8n.com/how/htm/motion.html#fig-axes

If the aircraft is not in level flight, these axes are _not_
aligned with the earth-based notions of horizontal and vertical.

This convention may seem counterintuitive at first, but actually
it has several advantages:
 -- It means that {x,y,z} is a right-handed basis set.
 -- Rotation in the xy plane is /positive/ yaw, 
  i.e. clockwise as seen from above, looking in the +z direction.
 -- Rotation in the yz plane is /positive/ roll,
  i.e. clockwise as seen from behind, looking in the +x direction.
 -- Rotation in the zx plane is /positive/ pitch
  i.e. nose upward,
  i.e. clockwise looking in the +y direction.

See e.g. http://www.av8n.com/how/htm/motion.html#fig-rotations

This has been the standard in the aeronautics community for 50 
years that I know of, and probably longer than that.

On the other hand, nobody was born knowing this.  Therefore, 
in the spirit of open software, it would be nice if it were 
conspicuously documented in the FG software.  This would make
the software more maintainable and more extensible.

Contrast this with the OpenAL convention:
 --) The bad news is that this OpenGL / OpenAL convention violates
  the long-established aviation convention.  This is a trap for the
  unwary.  It creates problems for anybody who wants to take code
  from one part of FG and use it an another.

 -- The good news is that simgear/sound/soundmgr_openal.cxx
  contains the following comment, which IMHO is a quite
  commendable example of how comments should be used:
    /**
     * Description: ORIENTATION is a pair of 3-tuples representing the
     * 'at' direction vector and 'up' direction of the Object in
     * Cartesian space. AL expects two vectors that are orthogonal to
     * each other. These vectors are not expected to be normalized. If
     * one or more vectors have zero length, implementation behavior
     * is undefined. If the two vectors are linearly dependent,
     * behavior is undefined.
     * This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
     */

  It would be nice if viewmgr.cxx had correspondingly clear comments
  about the semantics of its key variables, such as 
   -- ViewOrientation ... What is the "standard" orientation?  I
    am guessing that an aircraft at latitude zero and longitude zero,
    in level flight, heading north, is in the "standard" orientation,
    represented the "identity" quaternion (i.e. zero degrees of
    rotation) ... but the code would be more open, more maintainable,
    and more extensible if would-be contributors didn't have to guess 
    about such things.

   -- ViewOrientationOffset. ... Offset?  Offset of what relative to
    what?

  If somebody on the list knows the answers to such questions, perhaps
  they could contribute an explanatory patch.....


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to