#include <ps_sound.h>
Inheritance diagram for NL3D::CPSSound:
Nevrax France
Definition at line 50 of file ps_sound.h.
Public Member Functions | |
virtual void | basisChanged (TPSMatrixMode systemBasis) |
virtual bool | completeBBox (NLMISC::CAABBox &box) const |
NLMISC::CVector | computeI (void) const |
NLMISC::CVector | computeJ (void) const |
NLMISC::CVector | computeK (void) const |
virtual bool | doesProduceBBox (void) const |
virtual void | enumTexs (std::vector< NLMISC::CSmartPtr< ITexture > > &dest, IDriver &drv) |
virtual std::string | getClassName ()=0 |
IDriver * | getDriver () const |
shortcut to get an instance of the driver | |
float | getEmissionPercent (void) const |
get the percent of sound emission. | |
uint32 | getExternID (void) const |
get the extern ID of this located bindable | |
const CFontGenerator * | getFontGenerator (void) const |
Shortcut to get the font generator if one was set (const version). | |
CFontGenerator * | getFontGenerator (void) |
Shortcut to get the font generator if one was set. | |
const CFontManager * | getFontManager (void) const |
Shortcut to get the font manager if one was set (const version). | |
CFontManager * | getFontManager (void) |
*************************************************************************************** | |
float | getGain (void) const |
get the current gain. meningful only if a scheme is not used | |
const CPSAttribMaker< float > * | getGainScheme (void) const |
get the current gain scheme (const version) | |
CPSAttribMaker< float > * | getGainScheme (void) |
get the current gain scheme | |
const NLMISC::CMatrix & | getInvertedSysMat (void) const |
shortcut to get the inverted matrix of the system | |
const NLMISC::CMatrix & | getInvertedViewMat (void) const |
shortcut to get the inverted view matrix | |
const NLMISC::CMatrix & | getLocalToWorldMatrix () const |
Shortcut to get the local to world matrix. | |
TPSLod | getLOD (void) const |
get the valid lods for that object | |
bool | getMute (void) const |
test wether mute has been activated | |
std::string | getName (void) const |
get the located bindable name (edition purpose) | |
const CPSLocated * | getOwner (void) const |
get the located that owns this bindable (const version) | |
CPSLocated * | getOwner (void) |
get the located that owns this bindable | |
float | getPitch (void) const |
get the current pitch. meaningful only if a scheme is not used | |
const CPSAttribMaker< float > * | getPitchScheme (void) const |
get the current pitch scheme (const version) | |
CPSAttribMaker< float > * | getPitchScheme (void) |
get the current pitch scheme | |
virtual uint32 | getPriority (void) const |
return priority | |
const NLMISC::TStringId & | getSoundName (void) const |
get the name of the sound | |
bool | getSpawn (void) const |
test wether sound spawning is enabled | |
const NLMISC::CMatrix & | getSysMat (void) const |
*************************************************************************************** | |
uint32 | getType (void) const |
return this bindable type | |
bool | getUseOriginalPitchFlag () const |
virtual bool | getUserMatrixUsageCount () const |
const NLMISC::CMatrix & | getViewMat (void) const |
shortcut to get the view matrix | |
virtual bool | hasEmitters (void) const |
tells wether there are alive emitters | |
virtual bool | hasParticles (void) const |
tells wether there are alive entities / particles | |
bool | isActive () const |
virtual void | motionTypeChanged (bool parametric) |
called when a located has switch between incrmental / parametric motion. The default does nothing | |
NLMISC_DECLARE_CLASS (CPSSound) | |
virtual void | notifyTargetRemoved (CPSLocated *ptr) |
*************************************************************************************** | |
void | reactivateSound () |
virtual void | releaseAllRef () |
*************************************************************************************** | |
virtual void | releaseRefTo (const CParticleSystemProcess *other) |
void | setActive (bool active) |
Activate / Deactivate this object. When not active, the owning system won't try to call the 'step' method. | |
void | setEmissionPercent (float percent) |
set a percent of sound emission. If set to 1, it try to emit all sounds | |
void | setExternID (uint32 id) |
*************************************************************************************** | |
void | setGain (float gain) |
set a constant gain. Any previous gain scheme is discarded. | |
void | setGainScheme (CPSAttribMaker< float > *gain) |
void | setLOD (TPSLod lod) |
void | setMute (bool enabled=true) |
set mute on/off. The default is off. WARNING : It is not saved by this object | |
void | setName (const std::string &name) |
set the located bindable name (edition purpose) | |
void | setPitch (float pitch) |
set a constant pitch. Any previous pitch scheme is discarded. | |
void | setPitchScheme (CPSAttribMaker< float > *pitch) |
void | setSoundName (const NLMISC::TStringId &soundName) |
set the name of the sound | |
void | setSpawn (bool enabled=true) |
tells wether sound emissions are spawned or not | |
void | setupDriverModelMatrix (void) |
shortcut to setup the model matrix (system basis or world basis) | |
void | setUseOriginalPitchFlag (bool useOriginalPitch) |
virtual void | setZBias (float value) |
virtual void | step (TPSProcessPass pass, TAnimationTime ellapsedTime, TAnimationTime realEt) |
void | stopSound () |
virtual void | systemDateChanged () |
object | |
CPSSound () | |
ctor | |
virtual void | serial (NLMISC::IStream &f) throw (NLMISC::EStream) |
serialisation. Derivers must override this, and call their parent version | |
~CPSSound () | |
dtor | |
Protected Member Functions | |
virtual void | bounceOccured (uint32 index) |
virtual void | deleteElement (uint32 index) |
void | displayIcon2d (const NLMISC::CVector tab[], uint nbSegs, float scale) |
*************************************************************************************** | |
virtual void | newElement (CPSLocated *emitterLocated, uint32 emitterIndex) |
void | removeAllSources () |
virtual void | resize (uint32 size) |
virtual void | setOwner (CPSLocated *psl) |
*************************************************************************************** | |
Protected Attributes | |
bool | _Active |
float | _EmissionPercent |
uint32 | _ExternID |
float | _Gain |
CPSAttribMaker< float > * | _GainScheme |
TPSLod | _LOD |
tells when this object must be dealt with | |
bool | _Mute |
std::string | _Name |
CPSLocated * | _Owner |
float | _Pitch |
CPSAttribMaker< float > * | _PitchScheme |
NLMISC::TStringId | _SoundName |
bool | _SoundReactivated |
CPSAttrib< UPSSoundInstance * > | _Sounds |
bool | _SoundStopped |
bool | _SpawnSounds |
bool | _UseOriginalPitch |
Friends | |
class | CPSLocated |
|
ctor
Definition at line 42 of file ps_sound.cpp. References _SoundName, and NLMISC::CStringMapper::emptyId().
00042 : _Gain(1.f), 00043 _GainScheme(NULL), 00044 _Pitch(1.f), 00045 _PitchScheme(NULL), 00046 _EmissionPercent(1), 00047 _SpawnSounds(false), 00048 _Mute(false), 00049 _SoundStopped(false), 00050 _SoundReactivated(false), 00051 _UseOriginalPitch(false) 00052 { 00053 if (CParticleSystem::getSerializeIdentifierFlag()) _Name = std::string("sound"); 00054 _SoundName = NLMISC::CStringMapper::emptyId(); 00055 } |
|
dtor
Definition at line 95 of file ps_sound.cpp. References _GainScheme, _PitchScheme, and removeAllSources().
00096 { 00097 removeAllSources(); 00098 delete _GainScheme; 00099 delete _PitchScheme; 00100 } |
|
Called when the basis of the owner changed. the default behaviour does nothing
Reimplemented in NL3D::CPSForce. Definition at line 968 of file ps_located.h.
00968 {} |
|
a bounce occured, so some action could be done. The default behaviour does nothing
Reimplemented in NL3D::CPSEmitter. Definition at line 1011 of file ps_located.h.
01011 {} |
|
Reimplemented in NL3D::CPSFanLight, NL3D::CPSQuad, and NL3D::CPSShockWave. Definition at line 884 of file ps_located.h.
00884 { return false ;} |
|
Compute a vector that will map to (1 0 0) after view and model transform. This allow to have object that always faces the user, whatever basis they are in Definition at line 931 of file ps_located.h. References NL3D::CPSLocated::computeI(). Referenced by NL3D::CPSLocatedBindable::displayIcon2d(), NL3D::CPSFanLightHelper::drawFanLight(), NL3D::CPSFaceLookAtHelper::drawLookAt(), NL3D::CPSFaceLookAtHelper::drawLookAtAlignOnMotion(), NL3D::CPSGravity::show(), and NL3D::CPSEmitter::showTool().
00931 { return _Owner->computeI(); } |
|
Compute a vector that will map to (0 1 0) after view and model transform. This allow to have object that always faces the user, whatever basis they are in Definition at line 936 of file ps_located.h. References NL3D::CPSLocated::computeJ(). Referenced by NL3D::CPSFaceLookAtHelper::drawLookAt().
00936 { return _Owner->computeJ(); } |
|
Compute a vector that will map to (0 0 1) after view and model transform. This allow to have object that always faces the user, whatever basis they are in Definition at line 940 of file ps_located.h. References NL3D::CPSLocated::computeK(). Referenced by NL3D::CPSLocatedBindable::displayIcon2d(), NL3D::CPSFanLightHelper::drawFanLight(), NL3D::CPSFaceLookAtHelper::drawLookAt(), NL3D::CPSFaceLookAtHelper::drawLookAtAlignOnMotion(), and NL3D::CPSEmitter::showTool().
00940 { return _Owner->computeK(); } |
|
Delete an element given its index Attributes of the located that hold this bindable (pos etc...) are still accessible for the given index. index out of range -> nl_assert Implements NL3D::CPSLocatedBindable. Definition at line 402 of file ps_sound.cpp. References _GainScheme, _PitchScheme, _Sounds, NL3D::CPSAttribMaker< float >::deleteElement(), NL3D::CPSAttribMaker< float >::hasMemory(), index, NL3D::CPSAttrib< UPSSoundInstance * >::remove(), and uint32. Referenced by removeAllSources().
00403 { 00404 if (_GainScheme && _GainScheme->hasMemory()) _GainScheme->deleteElement(index); 00405 if (_PitchScheme && _PitchScheme->hasMemory()) _PitchScheme->deleteElement(index); 00406 if (_Sounds[index]) 00407 { 00408 _Sounds[index]->setLooping(false); 00409 _Sounds[index]->release(); 00410 } 00411 _Sounds.remove(index); 00412 } |
|
*************************************************************************************** show an drawing to represent the object, and in red if it is selected
Definition at line 2038 of file ps_located.cpp. References NL3D::CPSLocatedBindable::computeI(), NL3D::CPSLocatedBindable::computeK(), NL3D::CParticleSystem::getCurrentEditedElement(), NL3D::CPSLocatedBindable::getDriver(), NL3D::CParticleSystemProcess::getOwner(), NL3D::CPSLocated::getPos(), NL3D::CPSLocated::getSize(), index, NL3D::CMaterial::setBlend(), NL3D::CMaterial::setBlendFunc(), NL3D::CMaterial::setColor(), NL3D::CMaterial::setLighting(), NL3D::CPSLocatedBindable::setupDriverModelMatrix(), NL3D::CMaterial::setZFunc(), NL3D::CMaterial::setZWrite(), size, uint, uint32, NLMISC::CLine::V0, NLMISC::CLine::V1, NLMISC::CVector::x, and NLMISC::CVector::y. Referenced by NL3D::CPSSpring::show(), NL3D::CPSCentralGravity::show(), and NL3D::CPSParticle::showTool().
02039 { 02040 uint32 size = _Owner->getSize(); 02041 if (!size) return; 02042 setupDriverModelMatrix(); 02043 02044 const CVector I = computeI(); 02045 const CVector K = computeK(); 02046 02047 static std::vector<NLMISC::CLine> lines; 02048 02049 lines.clear(); 02050 02051 // ugly slow code, but not for runtime 02052 for (uint k = 0; k < size; ++k) 02053 { 02054 // center of the current particle 02055 const CVector p = _Owner->getPos()[k]; 02056 02057 02058 02059 for (uint l = 0; l < nbSegs; ++l) 02060 { 02061 NLMISC::CLine li; 02062 li.V0 = p + scale * (tab[l << 1].x * I + tab[l << 1].y * K); 02063 li.V1 = p + scale * (tab[(l << 1) + 1].x * I + tab[(l << 1) + 1].y * K); 02064 lines.push_back(li); 02065 } 02066 02067 CMaterial mat; 02068 02069 mat.setBlendFunc(CMaterial::one, CMaterial::one); 02070 mat.setZWrite(false); 02071 mat.setLighting(false); 02072 mat.setBlend(true); 02073 mat.setZFunc(CMaterial::less); 02074 02075 02076 02077 CPSLocated *loc; 02078 uint32 index; 02079 CPSLocatedBindable *lb; 02080 _Owner->getOwner()->getCurrentEditedElement(loc, index, lb); 02081 02082 mat.setColor((lb == NULL || this == lb) && loc == _Owner && index == k ? CRGBA::Red : CRGBA(127, 127, 127)); 02083 02084 02085 CDRU::drawLinesUnlit(lines, mat, *getDriver() ); 02086 } 02087 02088 } |
|
Reimplemented in NL3D::CPSForce. Definition at line 888 of file ps_located.h.
00888 { return true; } |
|
Reimplemented in NL3D::CPSFanLight, NL3D::CPSQuad, NL3D::CPSRibbon, NL3D::CPSRibbonLookAt, and NL3D::CPSShockWave. Definition at line 977 of file ps_located.h.
00977 {} |
|
*************************************************************************************** this should be called before to delete any bindable inserted in a system, but this is done by the system, so you should never need calling it. This has been introduced because calls in dtor are not polymorphic to derived class (which are already destroyed anyway), and some infos are needed in some dtor. The default behaviour does nothing Reimplemented in NL3D::CPSTargetLocatedBindable. Definition at line 1975 of file ps_located.cpp. References NL3D::CParticleSystemProcess::getOwner(), NL3D::CPSLocatedBindable::getUserMatrixUsageCount(), and NL3D::CParticleSystem::releaseRefForUserSysCoordInfo().
01976 { 01977 if (_Owner && _Owner->getOwner()) 01978 { 01979 _Owner->getOwner()->releaseRefForUserSysCoordInfo(getUserMatrixUsageCount()); 01980 } 01981 } |
|
Implemented in NLAIAGENT::CNumericIndex, NLAIC::IPointerGestion, NLAIC::CIdentType, and CAutomataDesc. Referenced by NLMISC::CClassRegistry::checkObject(), and NL3D::GetTextureSize(). |
|
|
get the percent of sound emission.
Definition at line 141 of file ps_sound.h. References _EmissionPercent.
00141 { return _EmissionPercent; } |
|
get the extern ID of this located bindable
Definition at line 964 of file ps_located.h. References NL3D::CPSLocatedBindable::_ExternID, and uint32. Referenced by NL3D::CPSLocated::bind(), and NL3D::CParticleSystem::unregisterLocatedBindableExternID().
00964 { return _ExternID; } |
|
Shortcut to get the font generator if one was set (const version).
Definition at line 904 of file ps_located.h. References NL3D::CParticleSystemProcess::getFontGenerator(), and nlassert.
|
|
Shortcut to get the font generator if one was set.
Definition at line 897 of file ps_located.h. References NL3D::CParticleSystemProcess::getFontGenerator(), and nlassert. Referenced by NL3D::CPSZoneRectangle::show(), NL3D::CPSZoneCylinder::show(), NL3D::CPSZoneDisc::show(), NL3D::CPSZonePlane::show(), NL3D::CPSCylindricVortex::show(), NL3D::CPSGravity::show(), and NL3D::CPSEmitterRectangle::showTool().
|
|
Shortcut to get the font manager if one was set (const version).
Definition at line 2099 of file ps_located.cpp. References NL3D::CParticleSystemProcess::getFontManager(), and nlassert.
|
|
***************************************************************************************
Definition at line 2091 of file ps_located.cpp. References NL3D::CParticleSystemProcess::getFontManager(), and nlassert. Referenced by NL3D::CPSZoneRectangle::show(), NL3D::CPSZoneCylinder::show(), NL3D::CPSZoneDisc::show(), NL3D::CPSZonePlane::show(), NL3D::CPSCylindricVortex::show(), NL3D::CPSGravity::show(), and NL3D::CPSEmitterRectangle::showTool().
|
|
get the current gain. meningful only if a scheme is not used
Definition at line 90 of file ps_sound.h. References _Gain.
00091 { 00092 return _Gain; 00093 } |
|
get the current gain scheme (const version)
Definition at line 106 of file ps_sound.h. References _GainScheme.
00107 { 00108 return _GainScheme; 00109 } |
|
get the current gain scheme
Definition at line 100 of file ps_sound.h. References _GainScheme.
00101 { 00102 return _GainScheme; 00103 } |
|
shortcut to get the inverted matrix of the system
Definition at line 2116 of file ps_located.cpp. References NL3D::CParticleSystem::getInvertedSysMat(), NL3D::CParticleSystemProcess::getOwner(), and nlassert.
|
|
shortcut to get the inverted view matrix
Definition at line 2134 of file ps_located.cpp. References NL3D::CParticleSystem::getInvertedViewMat(), NL3D::CParticleSystemProcess::getOwner(), and nlassert.
|
|
Shortcut to get the local to world matrix.
Definition at line 1144 of file ps_located.h. References NL3D::CPSLocated::getLocalToWorldMatrix(), and nlassert. Referenced by NL3D::CPSRibbonLookAt::displayRibbons(), newElement(), NL3D::CPSZoneRectangle::show(), NL3D::CPSZoneCylinder::show(), NL3D::CPSZoneDisc::show(), NL3D::CPSZonePlane::show(), NL3D::CPSLight::show(), NL3D::CPSGravity::show(), NL3D::CPSEmitterRectangle::showTool(), NL3D::CPSLight::step(), and NL3D::CPSMesh::updatePos().
|
|
get the valid lods for that object
Definition at line 954 of file ps_located.h. References NL3D::CPSLocatedBindable::_LOD, and NL3D::TPSLod.
00954 { return _LOD; } |
|
test wether mute has been activated
Definition at line 153 of file ps_sound.h. References _Mute.
00153 { return _Mute; } |
|
get the located bindable name (edition purpose)
Definition at line 948 of file ps_located.h.
00948 { return _Name; } |
|
get the located that owns this bindable (const version)
Definition at line 944 of file ps_located.h.
00944 { return _Owner; } |
|
get the located that owns this bindable
Definition at line 942 of file ps_located.h. Referenced by NL3D::CPSLocated::deleteElement(), NL3D::CParticleSystemInstanceUser::emit(), NL3D::CPSFaceLookAt::CSecondSize::getSizeOwner(), newElement(), NL3D::CPSLocated::registerIntegrableForce(), NL3D::CParticleSystem::registerLocatedBindableExternID(), NL3D::CParticleSystemInstanceUser::removeByID(), resize(), NL3D::CPSLight::resize(), step(), NL3D::CPSLocated::unregisterIntegrableForce(), and NL3D::CParticleSystem::unregisterLocatedBindableExternID().
00942 { return _Owner; } |
|
get the current pitch. meaningful only if a scheme is not used
Definition at line 115 of file ps_sound.h. References _Pitch.
00116 { 00117 return _Pitch; 00118 } |
|
get the current pitch scheme (const version)
Definition at line 131 of file ps_sound.h. References _PitchScheme.
00132 { 00133 return _PitchScheme; 00134 } |
|
get the current pitch scheme
Definition at line 125 of file ps_sound.h. References _PitchScheme.
00126 { 00127 return _PitchScheme; 00128 } |
|
return priority
Implements NL3D::CPSLocatedBindable. Definition at line 67 of file ps_sound.h. References uint32.
00067 { return 500; }
|
|
get the name of the sound
Definition at line 81 of file ps_sound.h. References _SoundName.
00082 { 00083 return _SoundName; 00084 } |
|
test wether sound spawning is enabled
Definition at line 147 of file ps_sound.h. References _SpawnSounds.
00147 { return _SpawnSounds; } |
|
***************************************************************************************
Definition at line 2108 of file ps_located.cpp. References NL3D::CParticleSystemProcess::getOwner(), NL3D::CParticleSystem::getSysMat(), and nlassert.
|
|
return this bindable type
Implements NL3D::CPSLocatedBindable. Definition at line 103 of file ps_sound.cpp. References NL3D::PSSound, and uint32.
00104 { 00105 return PSSound; 00106 } |
|
Definition at line 164 of file ps_sound.h. References _UseOriginalPitch.
00164 { return _UseOriginalPitch; } |
|
Reimplemented in NL3D::CPSEmitter. Definition at line 974 of file ps_located.h. Referenced by NL3D::CPSLocatedBindable::finalize(), and NL3D::CPSLocatedBindable::setOwner().
00974 { return 0; }
|
|
shortcut to get the view matrix
Definition at line 2125 of file ps_located.cpp. References NL3D::CParticleSystemProcess::getOwner(), NL3D::CParticleSystem::getViewMat(), and nlassert. Referenced by NL3D::CPSRibbonLookAt::displayRibbons(), and NL3D::CPSFaceLookAtHelper::drawLookAt().
|
|
tells wether there are alive emitters
Definition at line 958 of file ps_located.h.
00958 { return false; } |
|
tells wether there are alive entities / particles
Reimplemented in NL3D::CPSParticle. Definition at line 956 of file ps_located.h.
00956 { return false; } |
|
Definition at line 844 of file ps_located.h. References NL3D::CPSLocatedBindable::_Active. Referenced by NL3D::CParticleSystem::hasActiveEmitters().
00844 { return _Active; } |
|
called when a located has switch between incrmental / parametric motion. The default does nothing
Reimplemented in NL3D::CPSRibbonBase. Definition at line 971 of file ps_located.h. Referenced by NL3D::CPSLocated::bind().
00971 {} |
|
set position and activate the sound Implements NL3D::CPSLocatedBindable. Definition at line 355 of file ps_sound.cpp. References _EmissionPercent, _Gain, _GainScheme, _Mute, _Pitch, _PitchScheme, _SoundName, _Sounds, _SoundStopped, _SpawnSounds, _UseOriginalPitch, NL3D::CPSAttribMaker< float >::get(), NL3D::CPSLocatedBindable::getLocalToWorldMatrix(), NL3D::CPSLocatedBindable::getOwner(), NL3D::CPSLocated::getPos(), NL3D::CPSLocated::getSpeed(), NL3D::CPSAttribMaker< float >::hasMemory(), index, NL3D::CPSAttrib< UPSSoundInstance * >::insert(), NL3D::CPSAttribMaker< float >::newElement(), nlassert, and uint32. Referenced by step().
00356 { 00357 nlassert(_Owner); 00358 if (_GainScheme && _GainScheme->hasMemory()) _GainScheme->newElement(emitterLocated, emitterIndex); 00359 if (_PitchScheme && _PitchScheme->hasMemory()) _PitchScheme->newElement(emitterLocated, emitterIndex); 00360 // if there's a sound server, we generate a new sound instance 00361 if (!_Mute && !_SoundStopped && CParticleSystem::getSoundServer()) 00362 { 00363 if ((rand() % 99) * 0.01f < _EmissionPercent) 00364 { 00365 uint32 index = _Sounds.insert(CParticleSystem::getSoundServer()->createSound(_SoundName, _SpawnSounds)); 00366 00367 00368 00370 if (_Sounds[index]) 00371 { 00372 const NLMISC::CMatrix &mat = getLocalToWorldMatrix(); 00373 float pitch; 00374 if (_UseOriginalPitch) 00375 { 00376 pitch = _Sounds[index]->getPitch(); 00377 } 00378 else 00379 { 00380 pitch = _PitchScheme ? _PitchScheme->get(getOwner(), 0) : _Pitch; 00381 } 00382 _Sounds[index]->setSoundParams(_GainScheme ? _GainScheme->get(getOwner(), 0) : _Gain, 00383 mat * _Owner->getPos()[index], 00384 _Owner->getSpeed()[index], 00385 pitch 00386 ); 00387 _Sounds[index]->play(); 00388 } 00389 } 00390 else 00391 { 00392 _Sounds.insert(NULL); 00393 } 00394 } 00395 else 00396 { 00397 _Sounds.insert(NULL); 00398 } 00399 } |
|
|
|
*************************************************************************************** Can be used by located bindable that have located as targets (emitter, collision zone, forces) to be notified that one of their target has been removed. To do this : The object that focus the target must call registerDTorObserver on the target, with himself as a parameter When the target is removed, this target will call this method for all registered CPSLocated The default behaviour remove this object as an observer
Reimplemented in NL3D::CPSEmitter, and NL3D::CPSTargetLocatedBindable. Definition at line 1996 of file ps_located.cpp. References NL3D::CPSLocated::unregisterDtorObserver(). Referenced by NL3D::CPSLocated::releaseRefTo().
01997 {
01998 ptr->unregisterDtorObserver(this);
01999 }
|
|
Definition at line 77 of file ps_sound.cpp. References _SoundReactivated.
00078 { 00079 //if (!_SoundStopped) return; 00080 _SoundReactivated = true; 00081 } |
|
*************************************************************************************** Release any reference this obj may have to other process of the system For example, this is used when detaching a located bindable from a system. Reimplemented in NL3D::CPSEmitter, NL3D::CPSLight, NL3D::CPSTargetLocatedBindable, and NL3D::CPSMesh. Definition at line 2170 of file ps_located.cpp. Referenced by NL3D::CPSLocatedBindable::setOwner().
02171 { 02172 } |
|
Release any reference this obj may have on the given process. For example, this is used when detaching a located bindable from a system. Reimplemented in NL3D::CPSEmitter, and NL3D::CPSTargetLocatedBindable. Definition at line 871 of file ps_located.h.
00871 {} |
|
Definition at line 84 of file ps_sound.cpp. References _Sounds, deleteElement(), NL3D::CPSAttrib< UPSSoundInstance * >::getSize(), sint32, and size. Referenced by step(), and ~CPSSound().
|
|
Resize the bindable attributes containers should not be called directly. Call CPSLocated::resize instead Implements NL3D::CPSLocatedBindable. Definition at line 415 of file ps_sound.cpp. References _GainScheme, _PitchScheme, _Sounds, NL3D::CPSLocatedBindable::getOwner(), NL3D::CPSAttribMaker< float >::hasMemory(), nlassert, NL3D::CPSAttrib< UPSSoundInstance * >::resize(), NL3D::CPSAttribMaker< float >::resize(), size, and uint32.
00416 { 00417 nlassert(size < (1 << 16)); 00418 if (_GainScheme && _GainScheme->hasMemory()) _GainScheme->resize(size, getOwner()->getSize()); 00419 if (_PitchScheme && _PitchScheme->hasMemory()) _PitchScheme->resize(size, getOwner()->getSize()); 00420 _Sounds.resize(size); 00421 } |
|
serialisation. Derivers must override this, and call their parent version
Reimplemented from NL3D::CPSLocatedBindable. Definition at line 246 of file ps_sound.cpp. References NLMISC::CStringMapper::map(), sint, sint32, and NLMISC::CStringMapper::unmap().
00247 { 00248 CPSLocatedBindable::serial(f); 00249 // version 3 : added option to keep original pitch from the .sound 00250 sint ver = f.serialVersion(3); 00251 if (f.isReading()) 00252 { 00253 std::string soundName; 00254 f.serial(soundName); 00255 _SoundName = NLMISC::CStringMapper::map(soundName); 00256 } 00257 else 00258 { 00259 std::string soundName = NLMISC::CStringMapper::unmap(_SoundName); 00260 f.serial(soundName); 00261 } 00262 00263 sint32 nbSounds; 00264 bool hasScheme; 00265 if (f.isReading()) 00266 { 00267 f.serial(nbSounds); // we are very unlikely to save a system with sounds being played in it, 00268 // but we need to keep datas coherency. 00269 if (_Owner) 00270 { 00271 _Sounds.resize(_Owner->getMaxSize()); 00272 } 00273 } 00274 else 00275 { 00276 nbSounds = _Sounds.getSize(); // number of used sound 00277 f.serial(nbSounds); 00278 } 00279 00280 00281 if (f.isReading()) 00282 { 00283 delete _GainScheme; 00284 _GainScheme = NULL; 00285 delete _PitchScheme; 00286 _PitchScheme = NULL; 00287 } 00288 // save Gain infos 00289 hasScheme = _GainScheme != NULL; 00290 f.serial(hasScheme); 00291 if (hasScheme) 00292 { 00293 f.serialPolyPtr(_GainScheme); 00294 } 00295 else 00296 { 00297 f.serial(_Gain); 00298 } 00299 // serial pitch infos 00300 if (ver >= 3) 00301 { 00302 bool useOriginalPitch = _UseOriginalPitch; 00303 f.serial(useOriginalPitch); 00304 _UseOriginalPitch = useOriginalPitch; 00305 if (!_UseOriginalPitch) 00306 { 00307 // serialize pitch infos (no needed otherwise) 00308 hasScheme = _PitchScheme != NULL; 00309 f.serial(hasScheme); 00310 if (hasScheme) 00311 { 00312 f.serialPolyPtr(_PitchScheme); 00313 } 00314 else 00315 { 00316 f.serial(_Pitch); 00317 } 00318 } 00319 } 00320 else 00321 { 00322 hasScheme = _PitchScheme != NULL; 00323 f.serial(hasScheme); 00324 if (hasScheme) 00325 { 00326 f.serialPolyPtr(_PitchScheme); 00327 } 00328 else 00329 { 00330 f.serial(_Pitch); 00331 } 00332 } 00333 00334 if (ver > 1) 00335 { 00336 f.serial(_EmissionPercent); 00337 f.serial(_SpawnSounds); 00338 } 00339 00340 if (f.isReading()) 00341 { 00342 _SoundStopped = true; 00343 // insert blank sources 00344 for (sint k = 0; k < nbSounds; ++k) 00345 { 00346 newElement(NULL, 0); 00347 } 00348 _SoundStopped = false; 00349 _SoundReactivated = true; 00350 } 00351 } |
|
Activate / Deactivate this object. When not active, the owning system won't try to call the 'step' method.
Definition at line 843 of file ps_located.h. References NL3D::CPSLocatedBindable::_Active. Referenced by NL3D::CParticleSystem::activateEmitters(), and NL3D::CParticleSystemInstanceUser::setActive().
00843 { _Active = active; } |
|
set a percent of sound emission. If set to 1, it try to emit all sounds
Definition at line 137 of file ps_sound.h. References _EmissionPercent.
00137 { _EmissionPercent = percent; } |
|
*************************************************************************************** set the extern ID of this located bindable. 0 means no extern access. The map of ID-locatedBindable. Is in th particle system, so this located bindable must have been attached to a particle system, otherwise an assertion is raised Definition at line 2149 of file ps_located.cpp. References NL3D::CPSLocatedBindable::_ExternID, NL3D::CParticleSystemProcess::getOwner(), NL3D::CParticleSystem::registerLocatedBindableExternID(), uint32, and NL3D::CParticleSystem::unregisterLocatedBindableExternID().
02150 { 02151 if (id == _ExternID) return; 02152 CParticleSystem *ps = NULL; 02153 if (_Owner && _Owner->getOwner()) 02154 { 02155 ps = _Owner->getOwner(); 02156 } 02157 if (ps) 02158 { 02159 ps->unregisterLocatedBindableExternID(this); 02160 _ExternID = 0; 02161 } 02162 if (id != 0) 02163 { 02164 if (ps) ps->registerLocatedBindableExternID(id, this); 02165 _ExternID = id; 02166 } 02167 } |
|
set a constant gain. Any previous gain scheme is discarded.
Definition at line 208 of file ps_sound.cpp. References _Gain, and _GainScheme.
00209 { 00210 delete _GainScheme; 00211 _GainScheme = NULL; 00212 _Gain = Gain; 00213 } |
|
Set a gain scheme. It must have been allocated by new, and is then owned by this object Definition at line 216 of file ps_sound.cpp. References _GainScheme, NL3D::CPSLocated::getMaxSize(), NL3D::CPSLocated::getSize(), NL3D::CPSAttribMaker< float >::hasMemory(), and NL3D::CPSAttribMaker< float >::resize().
00217 { 00218 delete _GainScheme; 00219 _GainScheme = Gain; 00220 if (_Owner) 00221 { 00222 if (_GainScheme && _GainScheme->hasMemory()) _GainScheme->resize(_Owner->getMaxSize(), _Owner->getSize()); 00223 } 00224 } |
|
set the LODs that apply to that object (warning : it is based on the position of the system, and don't act on a per instance basis ...) To have per instance precision, you must use an attribute maker that has LOD as its input Definition at line 952 of file ps_located.h. References NL3D::CPSLocatedBindable::_LOD.
00952 { _LOD = lod; } |
|
set mute on/off. The default is off. WARNING : It is not saved by this object
Definition at line 150 of file ps_sound.h. References _Mute.
00150 { _Mute = enabled; } |
|
set the located bindable name (edition purpose)
Definition at line 946 of file ps_located.h.
00946 { _Name = name; } |
|
***************************************************************************************
Reimplemented in NL3D::CPSEmitter. Definition at line 1948 of file ps_located.cpp. References NL3D::CParticleSystem::addRefForUserSysCoordInfo(), NL3D::CPSLocatedBindable::deleteElement(), NL3D::CParticleSystemProcess::getOwner(), NL3D::CPSLocated::getSize(), NL3D::CPSLocatedBindable::getUserMatrixUsageCount(), NL3D::CPSLocatedBindable::releaseAllRef(), NL3D::CParticleSystem::releaseRefForUserSysCoordInfo(), and uint. Referenced by NL3D::CPSLocated::bind(), and NL3D::CPSLocated::unbind().
01949 { 01950 if (psl == _Owner) return; 01951 if (psl == NULL) 01952 { 01953 releaseAllRef(); 01954 if (_Owner) 01955 { 01956 // empty this located bindable. Need to be empty if it must be rebound to another located. 01957 for (uint k = 0; k < _Owner->getSize(); ++k) 01958 { 01959 deleteElement(0); 01960 } 01961 } 01962 } 01963 if (_Owner && _Owner->getOwner()) 01964 { 01965 _Owner->getOwner()->releaseRefForUserSysCoordInfo(getUserMatrixUsageCount()); 01966 } 01967 _Owner = psl; 01968 if (_Owner && _Owner->getOwner()) 01969 { 01970 _Owner->getOwner()->addRefForUserSysCoordInfo(getUserMatrixUsageCount()); 01971 } 01972 } |
|
set a constant pitch. Any previous pitch scheme is discarded.
Definition at line 227 of file ps_sound.cpp. References _Pitch, and _PitchScheme.
00228 { 00229 delete _PitchScheme; 00230 _PitchScheme = NULL; 00231 _Pitch = pitch; 00232 } |
|
Set a pitch scheme. It must have been allocated by new, and is then owned by this object Definition at line 235 of file ps_sound.cpp. References _PitchScheme, NL3D::CPSLocated::getMaxSize(), NL3D::CPSLocated::getSize(), NL3D::CPSAttribMaker< float >::hasMemory(), and NL3D::CPSAttribMaker< float >::resize().
00236 { 00237 delete _PitchScheme; 00238 _PitchScheme = pitch; 00239 if (_Owner) 00240 { 00241 if (_PitchScheme && _PitchScheme->hasMemory()) _PitchScheme->resize(_Owner->getMaxSize(), _Owner->getSize()); 00242 } 00243 } |
|
set the name of the sound
Definition at line 75 of file ps_sound.h. References _SoundName.
00076 { 00077 _SoundName = soundName; 00078 } |
|
tells wether sound emissions are spawned or not
Definition at line 144 of file ps_sound.h. References _SpawnSounds.
00144 { _SpawnSounds = enabled; } |
|
|
force the sound to use original pitch that has been entered in the .sound sheet This remove any existing pitchScheme Definition at line 424 of file ps_sound.cpp. References _PitchScheme, and _UseOriginalPitch.
00425 { 00426 if (_PitchScheme) 00427 { 00428 delete _PitchScheme; 00429 _PitchScheme = NULL; 00430 } 00431 _UseOriginalPitch = useOriginalPitch; 00432 } |
|
Reimplemented in NL3D::CPSDot, NL3D::CPSFanLight, NL3D::CPSMesh, NL3D::CPSConstraintMesh, NL3D::CPSParticle, NL3D::CPSQuad, NL3D::CPSRibbon, NL3D::CPSRibbonLookAt, NL3D::CPSShockWave, and NL3D::CPSTailDot. Definition at line 980 of file ps_located.h. References value.
00980 {} |
|
process one pass for the sound. This is usually done during the motion pass Implements NL3D::CPSLocatedBindable. Definition at line 109 of file ps_sound.cpp. References _Gain, _GainScheme, _Mute, _Pitch, _PitchScheme, _SoundReactivated, _Sounds, _SoundStopped, _UseOriginalPitch, NL3D::CPSAttrib< T >::begin(), NL3D::CPSAttrib< UPSSoundInstance * >::begin(), NL3D::CPSAttrib< UPSSoundInstance * >::end(), NL3D::CPSLocated::getLocalToWorldMatrix(), NL3D::CPSLocatedBindable::getOwner(), NL3D::CPSLocated::getPos(), NL3D::CPSLocated::getSize(), NL3D::CPSLocated::getSpeed(), NL3D::CPSAttribMaker< float >::make(), NLMISC::CMatrix::mulVector(), newElement(), nlassert, NL3D::PSMotion, removeAllSources(), sint32, size, NL3D::SoundBufSize, NL3D::TAnimationTime, uint, and uint32.
00110 { 00111 if (pass != PSMotion) return; 00112 const uint32 size = _Owner->getSize(); 00113 if (!size) return; 00114 if (_SoundStopped && !_SoundReactivated) 00115 { 00116 return; 00117 } 00118 if (_SoundReactivated) 00119 { 00120 _SoundStopped = false; 00121 _SoundReactivated = false; 00122 if (!_Mute) 00123 { 00124 sint32 k; 00125 // delete all sounds, and rebuild them all 00126 removeAllSources(); 00127 for (k = 0; k < (sint32) size; ++k) 00128 { 00129 newElement(NULL, 0); 00130 } 00131 } 00132 // don't need to reupdate sound 00133 return; 00134 } 00135 nlassert(_Owner); 00136 uint32 toProcess, leftToDo = size; 00137 00138 float Gains[SoundBufSize]; 00139 float frequencies[SoundBufSize]; 00140 00141 uint GainPtInc = _GainScheme ? 1 : 0; 00142 uint pitchPtInc = _PitchScheme ? 1 : 0; 00143 float *currVol, *currPitch; 00144 00145 00146 CPSAttrib<UPSSoundInstance *>::iterator it = _Sounds.begin(), 00147 endIt = _Sounds.end(); 00148 CPSAttrib<NLMISC::CVector>::const_iterator posIt = _Owner->getPos().begin(); 00149 CPSAttrib<NLMISC::CVector>::const_iterator speedIt = _Owner->getSpeed().begin(); 00150 00151 do 00152 { 00153 toProcess = leftToDo > SoundBufSize ? SoundBufSize : leftToDo; 00154 // compute Gain 00155 currVol = _GainScheme ? (float *) _GainScheme->make(getOwner(), size - leftToDo, Gains, sizeof(float), toProcess, true) 00156 : &_Gain; 00157 if (!_UseOriginalPitch) 00158 { 00159 // compute pitch 00160 currPitch = _PitchScheme ? (float *) _PitchScheme->make(getOwner(), size - leftToDo, frequencies, sizeof(float), toProcess, true) 00161 : &_Pitch; 00162 endIt = it + toProcess; 00163 const CMatrix &localToWorld = _Owner->getLocalToWorldMatrix(); 00164 do 00165 { 00166 if (*it) // was this sound instanciated? 00167 { 00168 (*it)->setSoundParams(*currVol, 00169 localToWorld * *posIt, 00170 localToWorld.mulVector(*speedIt), 00171 *currPitch); 00172 } 00173 currVol += GainPtInc; 00174 currPitch += pitchPtInc; 00175 ++posIt; 00176 ++speedIt; 00177 ++it; 00178 } 00179 while (it != endIt); 00180 } 00181 else 00182 { 00183 // keep original pitch 00184 endIt = it + toProcess; 00185 const CMatrix &localToWorld = _Owner->getLocalToWorldMatrix(); 00186 do 00187 { 00188 if (*it) // was this sound instanciated? 00189 { 00190 (*it)->setSoundParams(*currVol, 00191 localToWorld * *posIt, 00192 localToWorld.mulVector(*speedIt), 00193 (*it)->getPitch()); 00194 } 00195 currVol += GainPtInc; 00196 ++posIt; 00197 ++speedIt; 00198 ++it; 00199 } 00200 while (it != endIt); 00201 } 00202 leftToDo -= toProcess; 00203 } 00204 while (leftToDo); 00205 } |
|
Definition at line 58 of file ps_sound.cpp. References _SoundReactivated, _Sounds, _SoundStopped, NL3D::CPSAttrib< UPSSoundInstance * >::begin(), and NL3D::CPSAttrib< UPSSoundInstance * >::end().
00059 { 00060 _SoundReactivated = false; 00061 if (_SoundStopped) return; 00062 CPSAttrib<UPSSoundInstance *>::iterator it = _Sounds.begin() 00063 , endIt = _Sounds.end(); 00064 while (it != endIt) 00065 { 00066 if (*it) 00067 { 00068 (*it)->release(); 00069 (*it) = NULL; 00070 } 00071 ++it; 00072 } 00073 _SoundStopped = true; 00074 } |
|
PRIVATE USE : called by the system when its date has been manually changed. This his usually for object that expect time to be always increasing, so that they can reset their datas Reimplemented in NL3D::CPSRibbonBase. Definition at line 1038 of file ps_located.h.
01038 {} |
|
Reimplemented in NL3D::CPSForce. Definition at line 986 of file ps_located.h. |
|
Definition at line 1033 of file ps_located.h. Referenced by NL3D::CPSLocatedBindable::isActive(), and NL3D::CPSLocatedBindable::setActive(). |
|
Definition at line 178 of file ps_sound.h. Referenced by getEmissionPercent(), newElement(), and setEmissionPercent(). |
|
Definition at line 1027 of file ps_located.h. Referenced by NL3D::CPSLocatedBindable::getExternID(), NL3D::CPSLocatedBindable::setExternID(), and NL3D::CPSLocatedBindable::~CPSLocatedBindable(). |
|
Definition at line 174 of file ps_sound.h. Referenced by getGain(), newElement(), setGain(), and step(). |
|
Definition at line 175 of file ps_sound.h. Referenced by deleteElement(), getGainScheme(), newElement(), resize(), setGain(), setGainScheme(), step(), and ~CPSSound(). |
|
tells when this object must be dealt with
Definition at line 1029 of file ps_located.h. Referenced by NL3D::CPSLocatedBindable::getLOD(), and NL3D::CPSLocatedBindable::setLOD(). |
|
Definition at line 180 of file ps_sound.h. Referenced by getMute(), newElement(), setMute(), and step(). |
|
Definition at line 1031 of file ps_located.h. |
|
|
Definition at line 176 of file ps_sound.h. Referenced by getPitch(), newElement(), setPitch(), and step(). |
|
Definition at line 177 of file ps_sound.h. Referenced by deleteElement(), getPitchScheme(), newElement(), resize(), setPitch(), setPitchScheme(), setUseOriginalPitchFlag(), step(), and ~CPSSound(). |
|
Definition at line 173 of file ps_sound.h. Referenced by CPSSound(), getSoundName(), newElement(), and setSoundName(). |
|
Definition at line 182 of file ps_sound.h. Referenced by reactivateSound(), step(), and stopSound(). |
|
Definition at line 172 of file ps_sound.h. Referenced by deleteElement(), newElement(), removeAllSources(), resize(), step(), and stopSound(). |
|
Definition at line 181 of file ps_sound.h. Referenced by newElement(), step(), and stopSound(). |
|
Definition at line 179 of file ps_sound.h. Referenced by getSpawn(), newElement(), and setSpawn(). |
|
Definition at line 183 of file ps_sound.h. Referenced by getUseOriginalPitchFlag(), newElement(), setUseOriginalPitchFlag(), and step(). |