lllistener.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * @file lllistener.h
  3. * @brief Description of LISTENER base class abstracting the audio support.
  4. *
  5. * $LicenseInfo:firstyear=2000&license=viewergpl$
  6. *
  7. * Copyright (c) 2000-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LISTENER_H
  33. #define LL_LISTENER_H
  34. #include "llvector3.h"
  35. class LLListener
  36. {
  37. public:
  38. LLListener();
  39. virtual ~LLListener() = default;
  40. virtual void set(const LLVector3& pos, const LLVector3& vel,
  41. const LLVector3& up, const LLVector3& at);
  42. LL_INLINE virtual void setPosition(const LLVector3& pos)
  43. {
  44. mPosition = pos;
  45. }
  46. LL_INLINE virtual void setVelocity(const LLVector3& vel)
  47. {
  48. mVelocity = vel;
  49. }
  50. LL_INLINE virtual void orient(const LLVector3& up, const LLVector3& at)
  51. {
  52. mListenUp = up;
  53. mListenAt = at;
  54. }
  55. LL_INLINE virtual void translate(const LLVector3& offset)
  56. {
  57. mPosition += offset;
  58. }
  59. LL_INLINE virtual void setDopplerFactor(F32 factor)
  60. {
  61. mDopplerFactor = factor;
  62. }
  63. LL_INLINE virtual void setRolloffFactor(F32 factor)
  64. {
  65. mRolloffFactor = factor;
  66. }
  67. LL_INLINE virtual F32 getDopplerFactor() { return mDopplerFactor; }
  68. LL_INLINE virtual F32 getRolloffFactor() { return mRolloffFactor; }
  69. // No need for virtual methods here.
  70. LL_INLINE LLVector3 getPosition() { return mPosition; }
  71. LL_INLINE LLVector3 getAt() { return mListenAt; }
  72. LL_INLINE LLVector3 getUp() { return mListenUp; }
  73. LL_INLINE virtual void commitDeferredChanges() {}
  74. protected:
  75. LLVector3 mPosition;
  76. LLVector3 mVelocity;
  77. LLVector3 mListenAt;
  78. LLVector3 mListenUp;
  79. F32 mDopplerFactor;
  80. F32 mRolloffFactor;
  81. };
  82. #endif // LL_LISTENER_H