3D positions


M

Mike

Hi
I try to move openal sound positions with an airplane in C++. I saw
(below) that I could draw in opengl but i wonder how I could use this
for my sound positions?
Many thanks
Michael


openal listener using this float value:
sim/graphics/view/view_x
etc.

aircraft sound positions use those float values:
sim/flightmodel/position/local_x
lX = local_x etc.
SourcesPos[1][0] = (lX/100)-pTheta;//pitch
SourcesPos[1][1] = (lY/100)+(heading/100);
SourcesPos[1][2] = (lZ/100)+pPhi;//roll

--------------------

A given aircraft in X-Plane can be thought to have its own coordinate
system with the same units (meters) as world coordinate systems, but
positioned differently:

* The origin is at the default center of gravity for the aircraft.
* The X axis points to the right side of the aircraft.
* The Y axis points up.
* The Z axis points to the tail of the aircraft.

You can draw in aircraft coordinates using these OpenGL
transformations:

glTranslatef(local_x, local_y, local_z);
glRotatef (-heading, 0.0,1.0,0.0);
glRotatef (-pitch,-1.0,0.0,0.0);
glRotatef (-roll, 0.0,0.0,1.0);

where local_x, local_y, and local_z is the plane's location in
"local" (OpenGL) coordinates, and pitch, heading, and roll are the
Euler angles for the plane. Be sure to use glPushMtarix and
glPopMatrix to restore the coordinate system.
 
Ad

Advertisements

W

Wolfgang.Draxinger

Am Sat, 19 Jun 2010 05:13:04 -0700 (PDT)
schrieb Mike said:
Hi
I try to move openal sound positions with an airplane in C++. I saw
(below) that I could draw in opengl but i wonder how I could use this
for my sound positions?
Many thanks
Michael

First of all: OpenAL is not related to OpenGL in direct "bloodline".
The API design deliberately follows OpenGL. However OpenAL is not
discussed on this NG: Completely different library/API, not related to
graphics, but sound.

Before drawing the plane, X-Plane transforms your modelview matrix
so, that all further incoming coordinates are relative to the coordinate
frame defined by the aircraft, i.e. Z axis along the fuselage, X
parallel to the wings.

So independent if you're in cockpit view mode, or follower, or
something else, the geometry and transformations sent to drawing
commands stay the same.

Similar with OpenAL, only instead of transforming drawn geometry you're
moving sound sources. And just like in OpenGL in OpenAL the listener
always is in the origin.

So what you do is: For every matrix manipulation done in OpenGL do the
very same thing with OpenAL. Position your sound sources at the same
location, where the geometry, which shall visualize the sound source is
placed.

OpenAL brings a few nice examples of how to combine OpenGL and OpenAL.
I suggest you have a look at them.


Wolfgang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top