Exemple #1
0
    /// <summary>
    /// Construct a new AudioEmitter3D.  This will automatically start the specified sound playing.
    /// </summary>
    /// <param name="parentObj">The GameObj3D this sound is attached to.  You may specify "null".</param>
    /// <param name="sound">The sound to play.  You may specify "null".</param>
    public AudioEmitter3D(GameObj3D parentObj, string sound, Vector3? offset)
    {
        m_parentObj = parentObj;
        m_offset = Vector3.Zero;
        if (null != offset)
        {
            m_offset = (Vector3)offset;
        }

        //set up the emitter
        m_emitter = new AudioEmitter();
        Matrix objMat = Matrix.Identity;
        if (null != parentObj)
        {
            objMat = m_parentObj.GetMatrix();
        }
        m_emitter.Forward = objMat.Forward;
        m_emitter.Up = objMat.Up;
        m_emitter.Position = Vector3.Transform(m_offset, objMat);
        m_emitter.Velocity = Vector3.Zero;

        m_oldPos = m_emitter.Position;

        m_sound.Invalidate();

        if (null != sound)
            PlaySound(sound);
    }
Exemple #2
0
    /// <summary>
    /// Construct a new AudioEmitter3D.  This will automatically start the specified sound playing.
    /// </summary>
    /// <param name="parentObj">The GameObj3D this sound is attached to.  You may specify "null".</param>
    /// <param name="sound">The sound to play.  You may specify "null".</param>
    public AudioEmitter3D(GameObj3D parentObj, string sound, Vector3?offset)
    {
        m_parentObj = parentObj;
        m_offset    = Vector3.Zero;
        if (null != offset)
        {
            m_offset = (Vector3)offset;
        }

        //set up the emitter
        m_emitter = new AudioEmitter();
        Matrix objMat = Matrix.Identity;

        if (null != parentObj)
        {
            objMat = m_parentObj.GetMatrix();
        }
        m_emitter.Forward  = objMat.Forward;
        m_emitter.Up       = objMat.Up;
        m_emitter.Position = Vector3.Transform(m_offset, objMat);
        m_emitter.Velocity = Vector3.Zero;

        m_oldPos = m_emitter.Position;

        m_sound.Invalidate();

        if (null != sound)
        {
            PlaySound(sound);
        }
    }