/* ========================================================================== * ÀÛ ¼º ÀÚ : À̼ø±Ô * ÀÛ ¼º ÀÏ : 2007.01.23 * ³» ¿ë : »ç¿îµå Àå¸é ³ëµå * ÁÖÀÇ»çÇ× : *===========================================================================*/ #pragma once #include "SceneNode.h" #include "Sphere.h" class cDynamicSceneNode; /// »ç¿îµå Àå¸é ³ëµå ÀÎÀÚ class cSoundSceneNodeParam : public cSceneNodeParam { public: cSoundSceneNodeParam(); public: /// ¹ÝÁö¸§ float mRadius; /// °¨¼è °Å¸® float mAttenDistance; /// ¹Ýº¹ Ƚ¼ö unsigned int mLoopCount; /// Àç»ý °£°Ý float mLoopInterval; /// À½·® ºñÀ² [0, 1] float mVolumeRatio; /// ResourceManager °ü¸® ÆÇ´Ü bool mManaged; bool mEffectSound; /// follow °´Ã¼ cDynamicSceneNode* mpOwnerSceneNode; }; inline cSoundSceneNodeParam::cSoundSceneNodeParam() : mRadius( 1000.0f ) , mAttenDistance( 100.0f ) , mLoopCount( 0 ) , mLoopInterval( 0.0f ) , mVolumeRatio( 1.0f ) , mpOwnerSceneNode(0) , mManaged( false ) { mQueryType = NiPick::QUERY_FIRST; mPickSort = NiPick::SORT_OFF; mPickIntersect = NiPick::INTERSECT_BOUND; mPickFrontOnly = false; mEffectSound = false; } /// »ç¿îµå Àå¸é ³ëµå class cSoundSceneNode : public cSceneNode { friend class cSceneManager; friend class cSoundEditor; public: /// ó¸® void OnProcess( unsigned long deltaTime, unsigned long accumTime ); /// ÇÈÅ· bool Pick( const cRay& ray ); /// Áß½ÉÁ¡ virtual const NiPoint3& GetCenter(); /// ¹ÝÁö¸§ void SetRadius( float radius ); virtual float GetRadius(); /// °¨¼è °Å¸® void SetAttenDistance( float dist ); float GetAttenDistance() const; /// Á¦°Å ÇÔ¼ö inline bool IsRemoved() { return mRemoved; } void Remove(); void ParentNodeRemove(); inline void FadeOut() { mFadeOut = true; } void ActiveSound( bool active ); void UpdatVolumeRatio(); virtual inline NiNode* GetNiNode() { return 0; } virtual inline NiAVObject* GetNiObj() { return (NiAVObject*)mSound; } virtual void UpdatePickInfo( void* /*extra*/ ); protected: cSoundSceneNode( eType type = eSOUND ); virtual ~cSoundSceneNode(); /// ÃʱâÈ­ virtual bool Init( cSoundSceneNodeParam& param ); /// ¹Ýº¹ Ƚ¼ö void SetLoopCount( unsigned int count ); int GetLoopCount() const; /// Àç»ý °£°Ý void SetLoopInterval( float interval ); float GetLoopInterval() const; /// À½·® void SetVolumeRatio( float ratio ); float GetVolumeRatio() const; void RemoveSelf(); protected: void SetRemoveFlag( bool val ) { mRemoved = val; } protected: /// ¿£Áø ³ëµå NiAudioSourcePtr mSound; /// ¸®½º³Ê ÁøÀÔ ¿©ºÎ bool mListenerEntered; bool mOldListenerEntered; /// ¹ÝÁö¸§ float mRadius; /// °¨¼è °Å¸® float mAttenDistance; /// ¹Ýº¹ ȸ¼ö unsigned int mLoopCount; unsigned int mTempCount; /// Àç»ý °£°Ý float mLoopInterval; float mTempInterval; /// À½·® float mVolumeRatio; float mGain; float mTargetGain; /// ¸®½º³Ê ±¸ cSphere mListenerSphere; bool mRemoved; bool mFadeOut; bool mEffectSound; // unsigned long mOwnerSceneNodeIdx; cDynamicSceneNode* mpOwnerSceneNode; bool mActiveApp; }; inline const NiPoint3& cSoundSceneNode::GetCenter() { return mSound->GetWorldTranslate(); } inline void cSoundSceneNode::SetRadius( float radius ) { mNeedUpdateTransform = true; mRadius = radius; } inline float cSoundSceneNode::GetRadius() { return mRadius; } inline void cSoundSceneNode::SetAttenDistance( float dist ) { mAttenDistance = dist; } inline float cSoundSceneNode::GetAttenDistance() const { return mAttenDistance; } inline void cSoundSceneNode::SetLoopCount( unsigned int count ) { mLoopCount = count; } inline int cSoundSceneNode::GetLoopCount() const { return mLoopCount; } inline void cSoundSceneNode::SetLoopInterval( float interval ) { mLoopInterval = interval; } inline float cSoundSceneNode::GetLoopInterval() const { return mLoopInterval; } inline void cSoundSceneNode::SetVolumeRatio( float ratio ) { mVolumeRatio = ratio; } inline float cSoundSceneNode::GetVolumeRatio() const { return mVolumeRatio; }