|
|
|||
File indexing completed on 2026-06-02 08:58:13
0001 //////////////////////////////////////////////////////////// 0002 // 0003 // SFML - Simple and Fast Multimedia Library 0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org) 0005 // 0006 // This software is provided 'as-is', without any express or implied warranty. 0007 // In no event will the authors be held liable for any damages arising from the use of this software. 0008 // 0009 // Permission is granted to anyone to use this software for any purpose, 0010 // including commercial applications, and to alter it and redistribute it freely, 0011 // subject to the following restrictions: 0012 // 0013 // 1. The origin of this software must not be misrepresented; 0014 // you must not claim that you wrote the original software. 0015 // If you use this software in a product, an acknowledgment 0016 // in the product documentation would be appreciated but is not required. 0017 // 0018 // 2. Altered source versions must be plainly marked as such, 0019 // and must not be misrepresented as being the original software. 0020 // 0021 // 3. This notice may not be removed or altered from any source distribution. 0022 // 0023 //////////////////////////////////////////////////////////// 0024 0025 #ifndef SFML_LISTENER_HPP 0026 #define SFML_LISTENER_HPP 0027 0028 //////////////////////////////////////////////////////////// 0029 // Headers 0030 //////////////////////////////////////////////////////////// 0031 #include <SFML/Audio/Export.hpp> 0032 #include <SFML/System/Vector3.hpp> 0033 0034 0035 namespace sf 0036 { 0037 //////////////////////////////////////////////////////////// 0038 /// \brief The audio listener is the point in the scene 0039 /// from where all the sounds are heard 0040 /// 0041 //////////////////////////////////////////////////////////// 0042 class SFML_AUDIO_API Listener 0043 { 0044 public: 0045 0046 //////////////////////////////////////////////////////////// 0047 /// \brief Change the global volume of all the sounds and musics 0048 /// 0049 /// The volume is a number between 0 and 100; it is combined with 0050 /// the individual volume of each sound / music. 0051 /// The default value for the volume is 100 (maximum). 0052 /// 0053 /// \param volume New global volume, in the range [0, 100] 0054 /// 0055 /// \see getGlobalVolume 0056 /// 0057 //////////////////////////////////////////////////////////// 0058 static void setGlobalVolume(float volume); 0059 0060 //////////////////////////////////////////////////////////// 0061 /// \brief Get the current value of the global volume 0062 /// 0063 /// \return Current global volume, in the range [0, 100] 0064 /// 0065 /// \see setGlobalVolume 0066 /// 0067 //////////////////////////////////////////////////////////// 0068 static float getGlobalVolume(); 0069 0070 //////////////////////////////////////////////////////////// 0071 /// \brief Set the position of the listener in the scene 0072 /// 0073 /// The default listener's position is (0, 0, 0). 0074 /// 0075 /// \param x X coordinate of the listener's position 0076 /// \param y Y coordinate of the listener's position 0077 /// \param z Z coordinate of the listener's position 0078 /// 0079 /// \see getPosition, setDirection 0080 /// 0081 //////////////////////////////////////////////////////////// 0082 static void setPosition(float x, float y, float z); 0083 0084 //////////////////////////////////////////////////////////// 0085 /// \brief Set the position of the listener in the scene 0086 /// 0087 /// The default listener's position is (0, 0, 0). 0088 /// 0089 /// \param position New listener's position 0090 /// 0091 /// \see getPosition, setDirection 0092 /// 0093 //////////////////////////////////////////////////////////// 0094 static void setPosition(const Vector3f& position); 0095 0096 //////////////////////////////////////////////////////////// 0097 /// \brief Get the current position of the listener in the scene 0098 /// 0099 /// \return Listener's position 0100 /// 0101 /// \see setPosition 0102 /// 0103 //////////////////////////////////////////////////////////// 0104 static Vector3f getPosition(); 0105 0106 //////////////////////////////////////////////////////////// 0107 /// \brief Set the forward vector of the listener in the scene 0108 /// 0109 /// The direction (also called "at vector") is the vector 0110 /// pointing forward from the listener's perspective. Together 0111 /// with the up vector, it defines the 3D orientation of the 0112 /// listener in the scene. The direction vector doesn't 0113 /// have to be normalized. 0114 /// The default listener's direction is (0, 0, -1). 0115 /// 0116 /// \param x X coordinate of the listener's direction 0117 /// \param y Y coordinate of the listener's direction 0118 /// \param z Z coordinate of the listener's direction 0119 /// 0120 /// \see getDirection, setUpVector, setPosition 0121 /// 0122 //////////////////////////////////////////////////////////// 0123 static void setDirection(float x, float y, float z); 0124 0125 //////////////////////////////////////////////////////////// 0126 /// \brief Set the forward vector of the listener in the scene 0127 /// 0128 /// The direction (also called "at vector") is the vector 0129 /// pointing forward from the listener's perspective. Together 0130 /// with the up vector, it defines the 3D orientation of the 0131 /// listener in the scene. The direction vector doesn't 0132 /// have to be normalized. 0133 /// The default listener's direction is (0, 0, -1). 0134 /// 0135 /// \param direction New listener's direction 0136 /// 0137 /// \see getDirection, setUpVector, setPosition 0138 /// 0139 //////////////////////////////////////////////////////////// 0140 static void setDirection(const Vector3f& direction); 0141 0142 //////////////////////////////////////////////////////////// 0143 /// \brief Get the current forward vector of the listener in the scene 0144 /// 0145 /// \return Listener's forward vector (not normalized) 0146 /// 0147 /// \see setDirection 0148 /// 0149 //////////////////////////////////////////////////////////// 0150 static Vector3f getDirection(); 0151 0152 //////////////////////////////////////////////////////////// 0153 /// \brief Set the upward vector of the listener in the scene 0154 /// 0155 /// The up vector is the vector that points upward from the 0156 /// listener's perspective. Together with the direction, it 0157 /// defines the 3D orientation of the listener in the scene. 0158 /// The up vector doesn't have to be normalized. 0159 /// The default listener's up vector is (0, 1, 0). It is usually 0160 /// not necessary to change it, especially in 2D scenarios. 0161 /// 0162 /// \param x X coordinate of the listener's up vector 0163 /// \param y Y coordinate of the listener's up vector 0164 /// \param z Z coordinate of the listener's up vector 0165 /// 0166 /// \see getUpVector, setDirection, setPosition 0167 /// 0168 //////////////////////////////////////////////////////////// 0169 static void setUpVector(float x, float y, float z); 0170 0171 //////////////////////////////////////////////////////////// 0172 /// \brief Set the upward vector of the listener in the scene 0173 /// 0174 /// The up vector is the vector that points upward from the 0175 /// listener's perspective. Together with the direction, it 0176 /// defines the 3D orientation of the listener in the scene. 0177 /// The up vector doesn't have to be normalized. 0178 /// The default listener's up vector is (0, 1, 0). It is usually 0179 /// not necessary to change it, especially in 2D scenarios. 0180 /// 0181 /// \param upVector New listener's up vector 0182 /// 0183 /// \see getUpVector, setDirection, setPosition 0184 /// 0185 //////////////////////////////////////////////////////////// 0186 static void setUpVector(const Vector3f& upVector); 0187 0188 //////////////////////////////////////////////////////////// 0189 /// \brief Get the current upward vector of the listener in the scene 0190 /// 0191 /// \return Listener's upward vector (not normalized) 0192 /// 0193 /// \see setUpVector 0194 /// 0195 //////////////////////////////////////////////////////////// 0196 static Vector3f getUpVector(); 0197 }; 0198 0199 } // namespace sf 0200 0201 0202 #endif // SFML_LISTENER_HPP 0203 0204 0205 //////////////////////////////////////////////////////////// 0206 /// \class sf::Listener 0207 /// \ingroup audio 0208 /// 0209 /// The audio listener defines the global properties of the 0210 /// audio environment, it defines where and how sounds and musics 0211 /// are heard. If sf::View is the eyes of the user, then sf::Listener 0212 /// is his ears (by the way, they are often linked together -- 0213 /// same position, orientation, etc.). 0214 /// 0215 /// sf::Listener is a simple interface, which allows to setup the 0216 /// listener in the 3D audio environment (position, direction and 0217 /// up vector), and to adjust the global volume. 0218 /// 0219 /// Because the listener is unique in the scene, sf::Listener only 0220 /// contains static functions and doesn't have to be instantiated. 0221 /// 0222 /// Usage example: 0223 /// \code 0224 /// // Move the listener to the position (1, 0, -5) 0225 /// sf::Listener::setPosition(1, 0, -5); 0226 /// 0227 /// // Make it face the right axis (1, 0, 0) 0228 /// sf::Listener::setDirection(1, 0, 0); 0229 /// 0230 /// // Reduce the global volume 0231 /// sf::Listener::setGlobalVolume(50); 0232 /// \endcode 0233 /// 0234 ////////////////////////////////////////////////////////////
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|