source_pos[0] = 0.0; source_pos[1] = 0.0; source_pos[2] = 0.0;
offset_pos[0] = 0.0; offset_pos[1] = 0.0; offset_pos[2] = 0.0;
source_vel[0] = 0.0; source_vel[1] = 0.0; source_vel[2] = 0.0;
+ inner = outer = 360.0; outergain = 0.0;
// clear errors from elsewhere?
alGetError();
alSourcef( source, AL_PITCH, pitch );
alSourcef( source, AL_GAIN, volume );
alSourcefv( source, AL_POSITION, source_pos );
+ alSourcefv( source, AL_DIRECTION, direction );
+ alSourcef( source, AL_CONE_INNER_ANGLE, inner );
+ alSourcef( source, AL_CONE_OUTER_ANGLE, outer );
+ alSourcef( source, AL_CONE_OUTER_GAIN, outergain);
alSourcefv( source, AL_VELOCITY, source_vel );
alSourcei( source, AL_LOOPING, loop );
source_pos[0] = 0.0; source_pos[1] = 0.0; source_pos[2] = 0.0;
offset_pos[0] = 0.0; offset_pos[1] = 0.0; offset_pos[2] = 0.0;
source_vel[0] = 0.0; source_vel[1] = 0.0; source_vel[2] = 0.0;
+ inner = outer = 360.0; outergain = 0.0;
// clear errors from elsewhere?
alGetError();
alSourcef( source, AL_PITCH, pitch );
alSourcef( source, AL_GAIN, volume );
alSourcefv( source, AL_POSITION, source_pos );
+ alSourcefv( source, AL_DIRECTION, direction );
+ alSourcef( source, AL_CONE_INNER_ANGLE, inner );
+ alSourcef( source, AL_CONE_OUTER_ANGLE, outer );
+ alSourcef( source, AL_CONE_OUTER_GAIN, outergain );
alSourcefv( source, AL_VELOCITY, source_vel );
alSourcei( source, AL_LOOPING, loop );
// A constant offset to be applied to the final source_pos
ALfloat offset_pos[3];
+ // The orientation of the sound (direction and cut-off angles)
+ ALfloat direction[3];
+ ALfloat inner, outer, outergain;
+
// Velocity of the source sound.
ALfloat source_vel[3];
alSourcefv( source, AL_POSITION, final_pos );
}
+ /**
+ * Set the orientation of the sound source, both for direction
+ * and audio cut-off angles.
+ */
+ inline void set_orientation( ALfloat *dir, ALfloat inner_angle=360.0,
+ ALfloat outer_angle=360.0,
+ ALfloat outer_gain=0.0)
+ {
+ inner = inner_angle;
+ outer = outer_angle;
+ outergain = outer_gain;
+ alSourcefv( source, AL_DIRECTION, dir);
+ alSourcef( source, AL_CONE_INNER_ANGLE, inner );
+ alSourcef( source, AL_CONE_OUTER_ANGLE, outer );
+ alSourcef( source, AL_CONE_OUTER_GAIN, outergain );
+ }
+
/**
* Set velocity of sound source (uses same coordinate system as opengl)
*/
offset_pos[2] = pos->getDoubleValue("z", 0.0);
}
+ //
+ // Orientation
+ //
+ sgVec3 dir;
+ float inner, outer, outer_gain;
+ sgSetVec3( dir, 0.0, 0.0, 0.0 );
+ inner = outer = 360.0;
+ outer_gain = 0.0;
+ pos = node->getChild("orientation");
+ if ( pos != NULL ) {
+ dir[0] = pos->getDoubleValue("x", 0.0);
+ dir[1] = pos->getDoubleValue("y", 0.0);
+ dir[2] = pos->getDoubleValue("z", 0.0);
+ inner = pos->getDoubleValue("inner-angle", 360.0);
+ outer = pos->getDoubleValue("outer-angle", 360.0);
+ outer_gain = pos->getDoubleValue("outer-gain", 0.0);
+ }
+
+
//
// Initialize the sample
//
}
_sample->set_offset_pos( offset_pos );
+ _sample->set_orientation(dir, inner, outer, outer_gain);
_sample->set_volume(v);
_sample->set_reference_dist( reference_dist );
_sample->set_max_dist( max_dist );