2/05/2014

OpenAL 3D sound


 
/*
from OpenAL 1.1 documents. pdf
 
3.4.4. Linear Distance Clamped Model
This is the linear model, extended to guarantee that for distances below
AL_REFERENCE_DISTANCE, gain is clamped.
distance = max(distance, AL_REFERENCE_DISTANCE)
distance = min(distance, AL_MAX_DISTANCE)

gain = (1 – AL_ROLLOFF_FACTOR *
            (distance – AL_REFERENCE_DISTANCE) /
            (AL_MAX_DISTANCE – AL_REFERENCE_DISTANCE))
 
 
*/
 
 
 
// code ..

defaultRolloff=1;
defaultReferenceDistance=3;
defaultMaxDistance=10;

 alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
 
 // false is 3d sound
 alSourcei(tempsample.alSource, AL_SOURCE_RELATIVE, false); // 3d sound. 
 
 alSourcef(tempsample.alSource,AL_ROLLOFF_FACTOR,defaultRolloff);
 alSourcef(tempsample.alSource, AL_REFERENCE_DISTANCE,defaultReferenceDistance);
 alSourcef(tempsample.alSource,AL_MAX_DISTANCE,defaultMaxDistance);

 // exactly listener orientation value
 alListenerfv(AL_ORIENTATION, vec);


 
RESULT :
 
 
 
 
 
 
 
 

댓글 없음: