Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

pfSoundNode Class Reference

Performer-Juggler sound node. More...

#include <pfSoundNode.h>

List of all members.

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


Detailed Description

Performer-Juggler sound node.

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.

Note:
This pfSoundNode does not trigger the Sound object, you must do that.

Definition at line 55 of file pfSoundNode.h.


Constructor & Destructor Documentation

pfSoundNode::pfSoundNode const std::string &    soundHandle,
bool    isPositional = true
 

Todo:
the constructor takes a Sound, which does not mean that it was aquired with a getHandle function... fixme.. who manages this memory? should be sound manager... but... what if it wasn't created by the manager?

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 }

virtual pfSoundNode::~pfSoundNode   [inline, virtual]
 

Definition at line 65 of file pfSoundNode.h.

00066    {
00067    }


Member Function Documentation

pfSoundNode& pfSoundNode::operator= const pfSoundNode &    rhs [inline]
 

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    }

void pfSoundNode::setObs float    x,
float    y,
float    z
[inline]
 

Sets the listener.

Definition at line 82 of file pfSoundNode.h.

00083    {
00084       mX = x; mY = y; mZ = z;
00085    }

const std::string& pfSoundNode::sound   const [inline]
 

Definition at line 87 of file pfSoundNode.h.

Referenced by pfSoundNode.

00088    {
00089       return mSound;
00090    }

void pfSoundNode::setSound const std::string &    sound [inline]
 

Definition at line 92 of file pfSoundNode.h.

Referenced by pfSoundNode.

00093    {
00094       mSound = sound;
00095    }

void pfSoundNode::setPositional bool    isPositional [inline]
 

Definition at line 97 of file pfSoundNode.h.

Referenced by pfSoundNode.

00098    {
00099       mIsPositional = isPositional;
00100    }

int pfSoundNode::app pfTraverser *    [virtual]
 

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 }

virtual int pfSoundNode::needsApp void    [inline, virtual]
 

Definition at line 106 of file pfSoundNode.h.

00107    {
00108       return TRUE;
00109    }

void pfSoundNode::init   [static]
 

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 }

pfType* pfSoundNode::getClassType void    [inline, static]
 

Definition at line 119 of file pfSoundNode.h.

Referenced by pfSoundTraverser::soundNodesDisable, pfSoundTraverser::soundNodesEnable, pfSoundTraverser::soundNodesStop, and pfSoundTraverser::soundNodesTrigger.

00120    {
00121       return classType;
00122    }


Member Data Documentation

float pfSoundNode::mX [protected]
 

Definition at line 112 of file pfSoundNode.h.

Referenced by operator=.

float pfSoundNode::mY [protected]
 

Definition at line 112 of file pfSoundNode.h.

Referenced by operator=.

float pfSoundNode::mZ [protected]
 

Definition at line 112 of file pfSoundNode.h.

Referenced by operator=.

std::string pfSoundNode::mSound [protected]
 

Definition at line 113 of file pfSoundNode.h.

Referenced by app, and operator=.

bool pfSoundNode::mIsPositional [protected]
 

Definition at line 114 of file pfSoundNode.h.

Referenced by app, and operator=.


The documentation for this class was generated from the following files:
Generated on Sun May 2 15:11:05 2004 for VR Juggler by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002