#include <pfSoundNode.h>
Public Methods | |
| pfSoundNode (const std::string &soundHandle, bool isPositional=true) | |
| virtual | ~pfSoundNode () |
| pfSoundNode & | operator= (const pfSoundNode &rhs) |
| void | setObs (float x, float y, float z) |
| Sets the listener. More... | |
| const std::string & | sound () const |
| void | setSound (const std::string &sound) |
| void | setPositional (bool isPositional) |
| virtual int | app (pfTraverser *) |
| virtual int | needsApp (void) |
Static Public Methods | |
| void | init () |
| pfType * | getClassType (void) |
Protected Attributes | |
| float | mX |
| float | mY |
| float | mZ |
| std::string | mSound |
| bool | mIsPositional |
This node automatically updates the Sound's position information. You should keep a pointer to the Sound, so that you can trigger and change other properties of it.
Definition at line 55 of file pfSoundNode.h.
|
||||||||||||
|
Definition at line 39 of file pfSoundNode.cpp. References setPositional, setSound, and sound.
00039 : mIsPositional( true ) 00040 { 00041 this->setPositional( isPositional ); 00042 this->setSound( sound ); 00043 this->setType(classType); // Set the type 00044 } |
|
|
Definition at line 65 of file pfSoundNode.h.
00066 {
00067 }
|
|
|
Definition at line 69 of file pfSoundNode.h. References mIsPositional, mSound, mX, mY, and mZ.
00070 {
00071 pfDCS::operator=(rhs);
00072 mX = rhs.mX;
00073 mY = rhs.mY;
00074 mZ = rhs.mZ;
00075 mSound = rhs.mSound;
00076 mIsPositional = rhs.mIsPositional;
00077
00078 return *this;
00079 }
|
|
||||||||||||||||
|
Sets the listener.
Definition at line 82 of file pfSoundNode.h.
|
|
|
Definition at line 87 of file pfSoundNode.h. Referenced by pfSoundNode.
00088 {
00089 return mSound;
00090 }
|
|
|
Definition at line 92 of file pfSoundNode.h. Referenced by pfSoundNode.
|
|
|
Definition at line 97 of file pfSoundNode.h. Referenced by pfSoundNode.
00098 {
00099 mIsPositional = isPositional;
00100 }
|
|
|
Definition at line 53 of file pfSoundNode.cpp. References vrj::GetVjVec, mIsPositional, and mSound.
00054 {
00055 // update the sound attributes (position) based on the current
00056 // position of this node.
00057 // only do it if the sound is a positional sound.
00058 if (mSound != "" && mIsPositional == true)
00059 {
00060 // get position of this sound in relation to the user's orientation and position
00061 // NOTE: the sound will change position if the user rotates without translation.
00062 // it should orbit the user, so that the audio will pan correctly.
00063 pfMatrix matrix, traverserMatrix, dcsMatrix;
00064 matrix.makeIdent();
00065
00066 //: take the sound from soundspace to userspace.
00067
00068 // add in any offset due to this DCS node
00069 // (since the traverser hasn't yet added it to it's matrix stack.)
00070 // *NOTE: this is the matrix that takes the sound from local(sound)space to modelspace.
00071 this->getMat( dcsMatrix ); //TODO: don't call this.
00072 // ...to get the location of the sound in modelspace, you'd do an invertFull here, but we want it in user space..
00073 matrix.postMult( dcsMatrix );
00074
00075 // add in any offset due to navigation and any other DCS xforms currently on the traverser's stack.
00076 // this is the position of the model's origin in relation to a user at position 0,0,0
00077 // this is just the nav matrix, which should be on the matrix stack right now...
00078 // *NOTE: this is the matrix that takes the sound from modelspace to userspace
00079 trav->getMat( traverserMatrix );
00080 // ...to get the location of the sound in modelspace, you'd do an invertFull here, but we want it in user space..
00081 matrix.postMult( traverserMatrix );
00082
00083 pfCoord coord;
00084 matrix.getOrthoCoord( &coord );
00085
00086 // set my sound's position.
00087 pfVec3 pf_soundPosition = coord.xyz;
00088 gmtl::Vec3f soundPosition = vrj::GetVjVec( pf_soundPosition );
00089 sonix::instance()->setPosition( mSound, soundPosition[0], soundPosition[1], soundPosition[2] );
00090
00091 // Engine's update should be called by the app's frame process,
00092 // or in juggler's manager (not both, of course)...
00093
00094 // use this for debugging the location of the sound reletive to the user.
00095 //std::cout<<"["<<mSound->getName()<<"] sound in userspace: "<<soundPosition[0]<<" "<<soundPosition[1]<<" "<<soundPosition[2]<<"\n"<<std::flush;
00096 }
00097 else
00098 {
00099 // redundant (fixme), but make sure it's 0.0f,0.0f,0.0f
00100 // this makes the sound the same as the observer.
00101 sonix::instance()->setPosition( mSound, 0.0f, 0.0f, 0.0f );
00102 }
00103
00104 return pfDCS::app( trav ); // call the parent class's app()
00105
00106 }
|
|
|
Definition at line 106 of file pfSoundNode.h.
00107 {
00108 return TRUE;
00109 }
|
|
|
Definition at line 115 of file pfSoundNode.cpp. Referenced by pfSoundTraverser::preForkInit.
00116 {
00117 vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
00118 << "[pfSoundNode] Registering sound node with performer.\n"
00119 << vprDEBUG_FLUSH;
00120
00121 if (classType == NULL)
00122 {
00123 pfDCS::init(); // Initialize my parent
00124 classType = new pfType(pfDCS::getClassType(), "pfSoundNode"); // Create the new type
00125 }
00126 }
|
|
|
Definition at line 119 of file pfSoundNode.h. Referenced by pfSoundTraverser::soundNodesDisable, pfSoundTraverser::soundNodesEnable, pfSoundTraverser::soundNodesStop, and pfSoundTraverser::soundNodesTrigger.
00120 {
00121 return classType;
00122 }
|
|
|
Definition at line 112 of file pfSoundNode.h. Referenced by operator=. |
|
|
Definition at line 112 of file pfSoundNode.h. Referenced by operator=. |
|
|
Definition at line 112 of file pfSoundNode.h. Referenced by operator=. |
|
|
Definition at line 113 of file pfSoundNode.h. |
|
|
Definition at line 114 of file pfSoundNode.h. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002