diff --git a/RayTracer/Dependencies/Math/include/MathLibrary.h b/RayTracer/Dependencies/Math/include/MathLibrary.h new file mode 100644 index 0000000..fa1e7b3 --- /dev/null +++ b/RayTracer/Dependencies/Math/include/MathLibrary.h @@ -0,0 +1,310 @@ +#pragma once +#include +#include + +//Contains: math, float, vec2, vec3. + +namespace Math +{ + //Float PI + const float PI = 3.1415927f; + const float PI_2 = 1.5707965f; + const float PI_4 = 0.7853982f; + + float remap01(const float& a, const float& b, const float& t); + float notSoRandomFloat01(); + void rotateAroundPoint2D(float& posX, float& posY, const float& targetX, const float& targetY, float angle); + float radToDeg(const float& radians); + float degToRad(const float& degrees); + void wrapFloat(float& value, const float& min, const float& max); +}; + +//Vec2 +class vec2 +{ +public: +#pragma warning(push) +#pragma warning(disable : 4201) + union + { + struct + { + float x; + float y; + }; + float v[2]; + }; + +public: + vec2(); + vec2(float x, float y); + + vec2& operator=(const vec2 rhs); + + vec2& operator+=(const vec2& rhs); + vec2& operator-=(const vec2& rhs); + vec2& operator*=(float rhs); + vec2& operator/=(float rhs); + + float operator[](int index) const; + float& operator[](int index); + + inline float dot(vec2 const& rhs) const; + vec2& normalize(); + vec2 normalized(); + inline float length() const; + + static float dot(const vec2& lhs, const vec2& rhs); + static float length(const vec2& lhs); +}; + +inline float vec2::dot(vec2 const& rhs) const +{ + return (v[0] * rhs[0]) + (v[1] * rhs[1]); +} + +inline float vec2::length() const +{ + return sqrtf((v[0] * v[0]) + (v[1] * v[1])); +} + +inline float vec2::dot(const vec2& lhs, const vec2& rhs) +{ + return lhs.dot(rhs); +} + +inline float vec2::length(const vec2& lhs) +{ + return lhs.length(); +} + +inline std::istream& operator>>(std::istream& lhs, vec2& rhs) +{ + lhs >> rhs.v[0] >> rhs.v[1]; + return lhs; +} + +inline std::ostream& operator<<(std::ostream& lhs, const vec2& rhs) +{ + lhs << rhs.v[0] << " " << rhs.v[1]; + return lhs; +} + +vec2 operator+(const vec2& lhs, const vec2& rhs); +vec2 operator-(const vec2& lhs, const vec2& rhs); +vec2 operator*(const vec2& lhs, float rhs); +vec2 operator*(float lhs, const vec2& rhs); +vec2 operator*(const vec2& lhs, const vec2& rhs); +vec2 operator/(const vec2& lhs, float rhs); +vec2 operator/(float lhs, const vec2& rhs); +vec2 operator/(const vec2& lhs, const vec2& rhs); +bool operator==(const vec2& lhs, const vec2& rhs); +bool operator!=(const vec2& lhs, const vec2& rhs); + +//Vec3 +class vec3 +{ +public: +#pragma warning(push) +#pragma warning(disable : 4201) + union + { + struct + { + float x; + float y; + float z; + }; + struct + { + float r; + float g; + float b; + }; + float v[3]; + }; + +public: + vec3(); + vec3(float x, float y, float z); + + vec3& operator=(const vec3& rhs); + + vec3& operator+=(const vec3& rhs); + vec3& operator-=(const vec3& rhs); + vec3& operator*=(float rhs); + vec3& operator/=(float rhs); + + float operator[](int index) const; + float& operator[](int index); + + inline float dot(vec3 const& rhs) const; + inline vec3 cross(vec3 const& rhs) const; + vec3& normalize(); + vec3 normalized() const; + inline float length() const; + vec3& inverse(); + vec3 inversed() const; + vec3& round(); + vec3 rounded() const; + vec3& ceil(); + vec3 ceiled() const; + vec3& floor(); + vec3 floored() const; + + static float dot(vec3 const& lhs, vec3 const& rhs); + static float length(const vec3& lhs); + static vec3 cross(const vec3& lhs, const vec3& rhs); + static float angle(const vec3& lhs, const vec3& rhs); + static float distance(const vec3& lhs, const vec3& rhs); + static void normalize(vec3& lhs); + static vec3 normalized(const vec3& lhs); + static void clamp(vec3& lhs, const float& min, const float& max); + static vec3 project(const vec3& lhs, const vec3& rhs); + static vec3 reflect(const vec3& lhs, const vec3& rhs); + static vec3 reflect2(const vec3& lhs, const vec3& rhs); + static vec3 refract(const vec3& dir, const vec3& normal, const float& eta); + static vec3 refract2(const vec3& dir, const vec3& normal, const float& eta); + static vec3 refract3(const vec3& dir, const vec3& normal, const float& ri1, const float& ri2); + static vec3 refract4(const vec3& dir, const vec3& normal, const float& ri1); + static vec3 random01(); + static vec3 randomPointInUnitSphere(); + static vec3 randomPointInUnitSphere2(); +}; + +//Ref: https://docs.google.com/document/d/12m5C-Fp3xP_zohZyFc-RsvFBmUFEuJR1rkjaHqLb_Z4/edit#heading=h.5j4d6ppmg9m0 +///Returns the dot product of 2 vectors. +inline float vec3::dot(vec3 const& rhs) const +{ + return (v[0] * rhs[0]) + (v[1] * rhs[1]) + (v[2] * rhs[2]); +} + +///Returns the cross product of 2 vectors. +inline vec3 vec3::cross(vec3 const& rhs) const +{ + return vec3((v[1] * rhs[2] - rhs[1] * v[2]), + (v[2] * rhs[0] - rhs[2] * v[0]), + (v[0] * rhs[1] - rhs[0] * v[1])); +} + +///Retuns the length of the vector. +inline float vec3::length() const +{ + return sqrtf((v[0] * v[0]) + (v[1] * v[1]) + (v[2] * v[2])); +} + +inline std::istream& operator>>(std::istream& lhs, vec3& rhs) +{ + lhs >> rhs.v[0] >> rhs.v[1] >> rhs.v[2]; + return lhs; +} + +inline std::ostream& operator<<(std::ostream& lhs, vec3& rhs) +{ + lhs << rhs.v[0] << " " << rhs.v[1] << " " << rhs.v[2]; + return lhs; +} + +vec3 operator+(const vec3& lhs, const vec3& rhs); +vec3 operator-(const vec3& lhs, const vec3& rhs); +vec3 operator*(const vec3& lhs, float rhs); +vec3 operator*(float lhs, const vec3& rhs); +vec3 operator*(const vec3& lhs, const vec3& rhs); +vec3 operator/(const vec3& lhs, float rhs); +vec3 operator/(float lhs, const vec3& rhs); +vec3 operator/(const vec3& lhs, const vec3& rhs); +bool operator==(const vec3& lhs, const vec3& rhs); +bool operator!=(const vec3& lhs, const vec3& rhs); + +//Mat4 +class mat4 +{ +public: +#pragma warning(push) +#pragma warning(disable : 4201) + union + { + float m[16]; + //struct + //{ + // float m_00; float m_01; float m_02; float m_03; + // float m_10; float m_11; float m_12; float m_13; + // float m_20; float m_21; float m_22; float m_23; + // float m_30; float m_31; float m_32; float m_33; + //}; + + float mm[4][4]; + struct + { + vec3 xAxis; + float wx; + vec3 yAxis; + float wy; + vec3 zAxis; + float wz; + vec3 translation; + float one; + }; + }; + +public: + mat4(); + mat4(float a); + mat4(vec3 a_Row0, float a_03, + vec3 a_Row1, float a_13, + vec3 a_Row2, float a_23, + vec3 a_Row3, float a_33); + mat4(float a_00, float a_01, float a_02, float a_03, + float a_10, float a_11, float a_12, float a_13, + float a_20, float a_21, float a_22, float a_23, + float a_30, float a_31, float a_32, float a_33); + + mat4& operator=(const mat4& rhs); + mat4& operator+=(const mat4 &rhs); + mat4& operator-=(const mat4 &rhs); + mat4& operator*=(const mat4 &rhs); + + float determinant() const; + + static mat4 identity(); + //static mat4 inverse(); + static mat4 rotateX(const float a_Radians); + static mat4 rotateY(const float a_Radians); + static mat4 rotateZ(const float a_Radians); + static mat4 translate(const vec3& a_Translation); + static mat4 scale(const vec3& a_Scale); + + //static mat4 lookat(const vec3 &a_Eye, const vec3 &a_Center, const vec3 &a_Up); + //static mat4 projection(float a_FovY, float a_AspectRatio, float a_Near, float a_Far); +}; + +mat4 operator+(const mat4 &lhs, const mat4 &rhs); +mat4 operator-(const mat4 &lhs, const mat4 &rhs); +mat4 operator*(const mat4 &lhs, const mat4 &rhs); +mat4 operator*(const float &lhs, const mat4 &rhs); +vec3 operator*(const vec3 &lhs, const mat4 &rhs); + +inline std::ostream& operator<<(std::ostream& lhs, const mat4& rhs) +{ + for (unsigned int i = 0; i < 16; ++i) + { + lhs << rhs.m[i] << " "; + + if (((i + 1) % 4) == 0) + { + lhs << "\n"; + } + } + + return lhs; +} + +inline std::istream& operator>>(std::istream& lhs, mat4& rhs) +{ + for (unsigned int i = 0; i < 16; ++i) + { + lhs >> rhs.m[i]; + } + + return lhs; +} \ No newline at end of file diff --git a/RayTracer/Dependencies/Math/lib/Math-d.lib b/RayTracer/Dependencies/Math/lib/Math-d.lib new file mode 100644 index 0000000..d86fd64 Binary files /dev/null and b/RayTracer/Dependencies/Math/lib/Math-d.lib differ diff --git a/RayTracer/Dependencies/Math/lib/Math.lib b/RayTracer/Dependencies/Math/lib/Math.lib new file mode 100644 index 0000000..67232cb Binary files /dev/null and b/RayTracer/Dependencies/Math/lib/Math.lib differ diff --git a/RayTracer/Dependencies/Math64/include/MathLibrary.h b/RayTracer/Dependencies/Math64/include/MathLibrary.h new file mode 100644 index 0000000..fa1e7b3 --- /dev/null +++ b/RayTracer/Dependencies/Math64/include/MathLibrary.h @@ -0,0 +1,310 @@ +#pragma once +#include +#include + +//Contains: math, float, vec2, vec3. + +namespace Math +{ + //Float PI + const float PI = 3.1415927f; + const float PI_2 = 1.5707965f; + const float PI_4 = 0.7853982f; + + float remap01(const float& a, const float& b, const float& t); + float notSoRandomFloat01(); + void rotateAroundPoint2D(float& posX, float& posY, const float& targetX, const float& targetY, float angle); + float radToDeg(const float& radians); + float degToRad(const float& degrees); + void wrapFloat(float& value, const float& min, const float& max); +}; + +//Vec2 +class vec2 +{ +public: +#pragma warning(push) +#pragma warning(disable : 4201) + union + { + struct + { + float x; + float y; + }; + float v[2]; + }; + +public: + vec2(); + vec2(float x, float y); + + vec2& operator=(const vec2 rhs); + + vec2& operator+=(const vec2& rhs); + vec2& operator-=(const vec2& rhs); + vec2& operator*=(float rhs); + vec2& operator/=(float rhs); + + float operator[](int index) const; + float& operator[](int index); + + inline float dot(vec2 const& rhs) const; + vec2& normalize(); + vec2 normalized(); + inline float length() const; + + static float dot(const vec2& lhs, const vec2& rhs); + static float length(const vec2& lhs); +}; + +inline float vec2::dot(vec2 const& rhs) const +{ + return (v[0] * rhs[0]) + (v[1] * rhs[1]); +} + +inline float vec2::length() const +{ + return sqrtf((v[0] * v[0]) + (v[1] * v[1])); +} + +inline float vec2::dot(const vec2& lhs, const vec2& rhs) +{ + return lhs.dot(rhs); +} + +inline float vec2::length(const vec2& lhs) +{ + return lhs.length(); +} + +inline std::istream& operator>>(std::istream& lhs, vec2& rhs) +{ + lhs >> rhs.v[0] >> rhs.v[1]; + return lhs; +} + +inline std::ostream& operator<<(std::ostream& lhs, const vec2& rhs) +{ + lhs << rhs.v[0] << " " << rhs.v[1]; + return lhs; +} + +vec2 operator+(const vec2& lhs, const vec2& rhs); +vec2 operator-(const vec2& lhs, const vec2& rhs); +vec2 operator*(const vec2& lhs, float rhs); +vec2 operator*(float lhs, const vec2& rhs); +vec2 operator*(const vec2& lhs, const vec2& rhs); +vec2 operator/(const vec2& lhs, float rhs); +vec2 operator/(float lhs, const vec2& rhs); +vec2 operator/(const vec2& lhs, const vec2& rhs); +bool operator==(const vec2& lhs, const vec2& rhs); +bool operator!=(const vec2& lhs, const vec2& rhs); + +//Vec3 +class vec3 +{ +public: +#pragma warning(push) +#pragma warning(disable : 4201) + union + { + struct + { + float x; + float y; + float z; + }; + struct + { + float r; + float g; + float b; + }; + float v[3]; + }; + +public: + vec3(); + vec3(float x, float y, float z); + + vec3& operator=(const vec3& rhs); + + vec3& operator+=(const vec3& rhs); + vec3& operator-=(const vec3& rhs); + vec3& operator*=(float rhs); + vec3& operator/=(float rhs); + + float operator[](int index) const; + float& operator[](int index); + + inline float dot(vec3 const& rhs) const; + inline vec3 cross(vec3 const& rhs) const; + vec3& normalize(); + vec3 normalized() const; + inline float length() const; + vec3& inverse(); + vec3 inversed() const; + vec3& round(); + vec3 rounded() const; + vec3& ceil(); + vec3 ceiled() const; + vec3& floor(); + vec3 floored() const; + + static float dot(vec3 const& lhs, vec3 const& rhs); + static float length(const vec3& lhs); + static vec3 cross(const vec3& lhs, const vec3& rhs); + static float angle(const vec3& lhs, const vec3& rhs); + static float distance(const vec3& lhs, const vec3& rhs); + static void normalize(vec3& lhs); + static vec3 normalized(const vec3& lhs); + static void clamp(vec3& lhs, const float& min, const float& max); + static vec3 project(const vec3& lhs, const vec3& rhs); + static vec3 reflect(const vec3& lhs, const vec3& rhs); + static vec3 reflect2(const vec3& lhs, const vec3& rhs); + static vec3 refract(const vec3& dir, const vec3& normal, const float& eta); + static vec3 refract2(const vec3& dir, const vec3& normal, const float& eta); + static vec3 refract3(const vec3& dir, const vec3& normal, const float& ri1, const float& ri2); + static vec3 refract4(const vec3& dir, const vec3& normal, const float& ri1); + static vec3 random01(); + static vec3 randomPointInUnitSphere(); + static vec3 randomPointInUnitSphere2(); +}; + +//Ref: https://docs.google.com/document/d/12m5C-Fp3xP_zohZyFc-RsvFBmUFEuJR1rkjaHqLb_Z4/edit#heading=h.5j4d6ppmg9m0 +///Returns the dot product of 2 vectors. +inline float vec3::dot(vec3 const& rhs) const +{ + return (v[0] * rhs[0]) + (v[1] * rhs[1]) + (v[2] * rhs[2]); +} + +///Returns the cross product of 2 vectors. +inline vec3 vec3::cross(vec3 const& rhs) const +{ + return vec3((v[1] * rhs[2] - rhs[1] * v[2]), + (v[2] * rhs[0] - rhs[2] * v[0]), + (v[0] * rhs[1] - rhs[0] * v[1])); +} + +///Retuns the length of the vector. +inline float vec3::length() const +{ + return sqrtf((v[0] * v[0]) + (v[1] * v[1]) + (v[2] * v[2])); +} + +inline std::istream& operator>>(std::istream& lhs, vec3& rhs) +{ + lhs >> rhs.v[0] >> rhs.v[1] >> rhs.v[2]; + return lhs; +} + +inline std::ostream& operator<<(std::ostream& lhs, vec3& rhs) +{ + lhs << rhs.v[0] << " " << rhs.v[1] << " " << rhs.v[2]; + return lhs; +} + +vec3 operator+(const vec3& lhs, const vec3& rhs); +vec3 operator-(const vec3& lhs, const vec3& rhs); +vec3 operator*(const vec3& lhs, float rhs); +vec3 operator*(float lhs, const vec3& rhs); +vec3 operator*(const vec3& lhs, const vec3& rhs); +vec3 operator/(const vec3& lhs, float rhs); +vec3 operator/(float lhs, const vec3& rhs); +vec3 operator/(const vec3& lhs, const vec3& rhs); +bool operator==(const vec3& lhs, const vec3& rhs); +bool operator!=(const vec3& lhs, const vec3& rhs); + +//Mat4 +class mat4 +{ +public: +#pragma warning(push) +#pragma warning(disable : 4201) + union + { + float m[16]; + //struct + //{ + // float m_00; float m_01; float m_02; float m_03; + // float m_10; float m_11; float m_12; float m_13; + // float m_20; float m_21; float m_22; float m_23; + // float m_30; float m_31; float m_32; float m_33; + //}; + + float mm[4][4]; + struct + { + vec3 xAxis; + float wx; + vec3 yAxis; + float wy; + vec3 zAxis; + float wz; + vec3 translation; + float one; + }; + }; + +public: + mat4(); + mat4(float a); + mat4(vec3 a_Row0, float a_03, + vec3 a_Row1, float a_13, + vec3 a_Row2, float a_23, + vec3 a_Row3, float a_33); + mat4(float a_00, float a_01, float a_02, float a_03, + float a_10, float a_11, float a_12, float a_13, + float a_20, float a_21, float a_22, float a_23, + float a_30, float a_31, float a_32, float a_33); + + mat4& operator=(const mat4& rhs); + mat4& operator+=(const mat4 &rhs); + mat4& operator-=(const mat4 &rhs); + mat4& operator*=(const mat4 &rhs); + + float determinant() const; + + static mat4 identity(); + //static mat4 inverse(); + static mat4 rotateX(const float a_Radians); + static mat4 rotateY(const float a_Radians); + static mat4 rotateZ(const float a_Radians); + static mat4 translate(const vec3& a_Translation); + static mat4 scale(const vec3& a_Scale); + + //static mat4 lookat(const vec3 &a_Eye, const vec3 &a_Center, const vec3 &a_Up); + //static mat4 projection(float a_FovY, float a_AspectRatio, float a_Near, float a_Far); +}; + +mat4 operator+(const mat4 &lhs, const mat4 &rhs); +mat4 operator-(const mat4 &lhs, const mat4 &rhs); +mat4 operator*(const mat4 &lhs, const mat4 &rhs); +mat4 operator*(const float &lhs, const mat4 &rhs); +vec3 operator*(const vec3 &lhs, const mat4 &rhs); + +inline std::ostream& operator<<(std::ostream& lhs, const mat4& rhs) +{ + for (unsigned int i = 0; i < 16; ++i) + { + lhs << rhs.m[i] << " "; + + if (((i + 1) % 4) == 0) + { + lhs << "\n"; + } + } + + return lhs; +} + +inline std::istream& operator>>(std::istream& lhs, mat4& rhs) +{ + for (unsigned int i = 0; i < 16; ++i) + { + lhs >> rhs.m[i]; + } + + return lhs; +} \ No newline at end of file diff --git a/RayTracer/Dependencies/Math64/lib/Math-d.lib b/RayTracer/Dependencies/Math64/lib/Math-d.lib new file mode 100644 index 0000000..77f750c Binary files /dev/null and b/RayTracer/Dependencies/Math64/lib/Math-d.lib differ diff --git a/RayTracer/Dependencies/Math64/lib/Math.lib b/RayTracer/Dependencies/Math64/lib/Math.lib new file mode 100644 index 0000000..a2875c7 Binary files /dev/null and b/RayTracer/Dependencies/Math64/lib/Math.lib differ diff --git a/RayTracer/Dependencies/SFML/include/SFML/Audio.hpp b/RayTracer/Dependencies/SFML/include/SFML/Audio.hpp new file mode 100644 index 0000000..3167927 --- /dev/null +++ b/RayTracer/Dependencies/SFML/include/SFML/Audio.hpp @@ -0,0 +1,56 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_AUDIO_HPP +#define SFML_AUDIO_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#endif // SFML_AUDIO_HPP + +//////////////////////////////////////////////////////////// +/// \defgroup audio Audio module +/// +/// Sounds, streaming (musics or custom sources), recording, +/// spatialization. +/// +//////////////////////////////////////////////////////////// diff --git a/RayTracer/Dependencies/SFML/include/SFML/Audio/AlResource.hpp b/RayTracer/Dependencies/SFML/include/SFML/Audio/AlResource.hpp new file mode 100644 index 0000000..dd7d44c --- /dev/null +++ b/RayTracer/Dependencies/SFML/include/SFML/Audio/AlResource.hpp @@ -0,0 +1,70 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_ALRESOURCE_HPP +#define SFML_ALRESOURCE_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +namespace sf +{ +//////////////////////////////////////////////////////////// +/// \brief Base class for classes that require an OpenAL context +/// +//////////////////////////////////////////////////////////// +class SFML_AUDIO_API AlResource +{ +protected: + + //////////////////////////////////////////////////////////// + /// \brief Default constructor + /// + //////////////////////////////////////////////////////////// + AlResource(); + + //////////////////////////////////////////////////////////// + /// \brief Destructor + /// + //////////////////////////////////////////////////////////// + ~AlResource(); +}; + +} // namespace sf + + +#endif // SFML_ALRESOURCE_HPP + +//////////////////////////////////////////////////////////// +/// \class sf::AlResource +/// \ingroup audio +/// +/// This class is for internal use only, it must be the base +/// of every class that requires a valid OpenAL context in +/// order to work. +/// +//////////////////////////////////////////////////////////// diff --git a/RayTracer/Dependencies/SFML/include/SFML/Audio/Export.hpp b/RayTracer/Dependencies/SFML/include/SFML/Audio/Export.hpp new file mode 100644 index 0000000..9e5e09c --- /dev/null +++ b/RayTracer/Dependencies/SFML/include/SFML/Audio/Export.hpp @@ -0,0 +1,48 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_AUDIO_EXPORT_HPP +#define SFML_AUDIO_EXPORT_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Define portable import / export macros +//////////////////////////////////////////////////////////// +#if defined(SFML_AUDIO_EXPORTS) + + #define SFML_AUDIO_API SFML_API_EXPORT + +#else + + #define SFML_AUDIO_API SFML_API_IMPORT + +#endif + + +#endif // SFML_AUDIO_EXPORT_HPP diff --git a/RayTracer/Dependencies/SFML/include/SFML/Audio/InputSoundFile.hpp b/RayTracer/Dependencies/SFML/include/SFML/Audio/InputSoundFile.hpp new file mode 100644 index 0000000..317b952 --- /dev/null +++ b/RayTracer/Dependencies/SFML/include/SFML/Audio/InputSoundFile.hpp @@ -0,0 +1,263 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_INPUTSOUNDFILE_HPP +#define SFML_INPUTSOUNDFILE_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + + +namespace sf +{ +class InputStream; +class SoundFileReader; + +//////////////////////////////////////////////////////////// +/// \brief Provide read access to sound files +/// +//////////////////////////////////////////////////////////// +class SFML_AUDIO_API InputSoundFile : NonCopyable +{ +public: + + //////////////////////////////////////////////////////////// + /// \brief Default constructor + /// + //////////////////////////////////////////////////////////// + InputSoundFile(); + + //////////////////////////////////////////////////////////// + /// \brief Destructor + /// + //////////////////////////////////////////////////////////// + ~InputSoundFile(); + + //////////////////////////////////////////////////////////// + /// \brief Open a sound file from the disk for reading + /// + /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. + /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. + /// + /// \param filename Path of the sound file to load + /// + /// \return True if the file was successfully opened + /// + //////////////////////////////////////////////////////////// + bool openFromFile(const std::string& filename); + + //////////////////////////////////////////////////////////// + /// \brief Open a sound file in memory for reading + /// + /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. + /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. + /// + /// \param data Pointer to the file data in memory + /// \param sizeInBytes Size of the data to load, in bytes + /// + /// \return True if the file was successfully opened + /// + //////////////////////////////////////////////////////////// + bool openFromMemory(const void* data, std::size_t sizeInBytes); + + //////////////////////////////////////////////////////////// + /// \brief Open a sound file from a custom stream for reading + /// + /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. + /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. + /// + /// \param stream Source stream to read from + /// + /// \return True if the file was successfully opened + /// + //////////////////////////////////////////////////////////// + bool openFromStream(InputStream& stream); + + //////////////////////////////////////////////////////////// + /// \brief Get the total number of audio samples in the file + /// + /// \return Number of samples + /// + //////////////////////////////////////////////////////////// + Uint64 getSampleCount() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the number of channels used by the sound + /// + /// \return Number of channels (1 = mono, 2 = stereo) + /// + //////////////////////////////////////////////////////////// + unsigned int getChannelCount() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the sample rate of the sound + /// + /// \return Sample rate, in samples per second + /// + //////////////////////////////////////////////////////////// + unsigned int getSampleRate() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the total duration of the sound file + /// + /// This function is provided for convenience, the duration is + /// deduced from the other sound file attributes. + /// + /// \return Duration of the sound file + /// + //////////////////////////////////////////////////////////// + Time getDuration() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the read offset of the file in time + /// + /// \return Time position + /// + //////////////////////////////////////////////////////////// + Time getTimeOffset() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the read offset of the file in samples + /// + /// \return Sample position + /// + //////////////////////////////////////////////////////////// + Uint64 getSampleOffset() const; + + //////////////////////////////////////////////////////////// + /// \brief Change the current read position to the given sample offset + /// + /// This function takes a sample offset to provide maximum + /// precision. If you need to jump to a given time, use the + /// other overload. + /// + /// The sample offset takes the channels into account. + /// If you have a time offset instead, you can easily find + /// the corresponding sample offset with the following formula: + /// `timeInSeconds * sampleRate * channelCount` + /// If the given offset exceeds to total number of samples, + /// this function jumps to the end of the sound file. + /// + /// \param sampleOffset Index of the sample to jump to, relative to the beginning + /// + //////////////////////////////////////////////////////////// + void seek(Uint64 sampleOffset); + + //////////////////////////////////////////////////////////// + /// \brief Change the current read position to the given time offset + /// + /// Using a time offset is handy but imprecise. If you need an accurate + /// result, consider using the overload which takes a sample offset. + /// + /// If the given time exceeds to total duration, this function jumps + /// to the end of the sound file. + /// + /// \param timeOffset Time to jump to, relative to the beginning + /// + //////////////////////////////////////////////////////////// + void seek(Time timeOffset); + + //////////////////////////////////////////////////////////// + /// \brief Read audio samples from the open file + /// + /// \param samples Pointer to the sample array to fill + /// \param maxCount Maximum number of samples to read + /// + /// \return Number of samples actually read (may be less than \a maxCount) + /// + //////////////////////////////////////////////////////////// + Uint64 read(Int16* samples, Uint64 maxCount); + +private: + + //////////////////////////////////////////////////////////// + /// \brief Close the current file + /// + //////////////////////////////////////////////////////////// + void close(); + + //////////////////////////////////////////////////////////// + // Member data + //////////////////////////////////////////////////////////// + SoundFileReader* m_reader; ///< Reader that handles I/O on the file's format + InputStream* m_stream; ///< Input stream used to access the file's data + bool m_streamOwned; ///< Is the stream internal or external? + Uint64 m_sampleOffset; ///< Sample Read Position + Uint64 m_sampleCount; ///< Total number of samples in the file + unsigned int m_channelCount; ///< Number of channels of the sound + unsigned int m_sampleRate; ///< Number of samples per second +}; + +} // namespace sf + + +#endif // SFML_INPUTSOUNDFILE_HPP + + +//////////////////////////////////////////////////////////// +/// \class sf::InputSoundFile +/// \ingroup audio +/// +/// This class decodes audio samples from a sound file. It is +/// used internally by higher-level classes such as sf::SoundBuffer +/// and sf::Music, but can also be useful if you want to process +/// or analyze audio files without playing them, or if you want to +/// implement your own version of sf::Music with more specific +/// features. +/// +/// Usage example: +/// \code +/// // Open a sound file +/// sf::InputSoundFile file; +/// if (!file.openFromFile("music.ogg")) +/// /* error */; +/// +/// // Print the sound attributes +/// std::cout << "duration: " << file.getDuration().asSeconds() << std::endl; +/// std::cout << "channels: " << file.getChannelCount() << std::endl; +/// std::cout << "sample rate: " << file.getSampleRate() << std::endl; +/// std::cout << "sample count: " << file.getSampleCount() << std::endl; +/// +/// // Read and process batches of samples until the end of file is reached +/// sf::Int16 samples[1024]; +/// sf::Uint64 count; +/// do +/// { +/// count = file.read(samples, 1024); +/// +/// // process, analyze, play, convert, or whatever +/// // you want to do with the samples... +/// } +/// while (count > 0); +/// \endcode +/// +/// \see sf::SoundFileReader, sf::OutputSoundFile +/// +//////////////////////////////////////////////////////////// diff --git a/RayTracer/Dependencies/SFML/include/SFML/Audio/Listener.hpp b/RayTracer/Dependencies/SFML/include/SFML/Audio/Listener.hpp new file mode 100644 index 0000000..9fb7fff --- /dev/null +++ b/RayTracer/Dependencies/SFML/include/SFML/Audio/Listener.hpp @@ -0,0 +1,234 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_LISTENER_HPP +#define SFML_LISTENER_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +namespace sf +{ +//////////////////////////////////////////////////////////// +/// \brief The audio listener is the point in the scene +/// from where all the sounds are heard +/// +//////////////////////////////////////////////////////////// +class SFML_AUDIO_API Listener +{ +public: + + //////////////////////////////////////////////////////////// + /// \brief Change the global volume of all the sounds and musics + /// + /// The volume is a number between 0 and 100; it is combined with + /// the individual volume of each sound / music. + /// The default value for the volume is 100 (maximum). + /// + /// \param volume New global volume, in the range [0, 100] + /// + /// \see getGlobalVolume + /// + //////////////////////////////////////////////////////////// + static void setGlobalVolume(float volume); + + //////////////////////////////////////////////////////////// + /// \brief Get the current value of the global volume + /// + /// \return Current global volume, in the range [0, 100] + /// + /// \see setGlobalVolume + /// + //////////////////////////////////////////////////////////// + static float getGlobalVolume(); + + //////////////////////////////////////////////////////////// + /// \brief Set the position of the listener in the scene + /// + /// The default listener's position is (0, 0, 0). + /// + /// \param x X coordinate of the listener's position + /// \param y Y coordinate of the listener's position + /// \param z Z coordinate of the listener's position + /// + /// \see getPosition, setDirection + /// + //////////////////////////////////////////////////////////// + static void setPosition(float x, float y, float z); + + //////////////////////////////////////////////////////////// + /// \brief Set the position of the listener in the scene + /// + /// The default listener's position is (0, 0, 0). + /// + /// \param position New listener's position + /// + /// \see getPosition, setDirection + /// + //////////////////////////////////////////////////////////// + static void setPosition(const Vector3f& position); + + //////////////////////////////////////////////////////////// + /// \brief Get the current position of the listener in the scene + /// + /// \return Listener's position + /// + /// \see setPosition + /// + //////////////////////////////////////////////////////////// + static Vector3f getPosition(); + + //////////////////////////////////////////////////////////// + /// \brief Set the forward vector of the listener in the scene + /// + /// The direction (also called "at vector") is the vector + /// pointing forward from the listener's perspective. Together + /// with the up vector, it defines the 3D orientation of the + /// listener in the scene. The direction vector doesn't + /// have to be normalized. + /// The default listener's direction is (0, 0, -1). + /// + /// \param x X coordinate of the listener's direction + /// \param y Y coordinate of the listener's direction + /// \param z Z coordinate of the listener's direction + /// + /// \see getDirection, setUpVector, setPosition + /// + //////////////////////////////////////////////////////////// + static void setDirection(float x, float y, float z); + + //////////////////////////////////////////////////////////// + /// \brief Set the forward vector of the listener in the scene + /// + /// The direction (also called "at vector") is the vector + /// pointing forward from the listener's perspective. Together + /// with the up vector, it defines the 3D orientation of the + /// listener in the scene. The direction vector doesn't + /// have to be normalized. + /// The default listener's direction is (0, 0, -1). + /// + /// \param direction New listener's direction + /// + /// \see getDirection, setUpVector, setPosition + /// + //////////////////////////////////////////////////////////// + static void setDirection(const Vector3f& direction); + + //////////////////////////////////////////////////////////// + /// \brief Get the current forward vector of the listener in the scene + /// + /// \return Listener's forward vector (not normalized) + /// + /// \see setDirection + /// + //////////////////////////////////////////////////////////// + static Vector3f getDirection(); + + //////////////////////////////////////////////////////////// + /// \brief Set the upward vector of the listener in the scene + /// + /// The up vector is the vector that points upward from the + /// listener's perspective. Together with the direction, it + /// defines the 3D orientation of the listener in the scene. + /// The up vector doesn't have to be normalized. + /// The default listener's up vector is (0, 1, 0). It is usually + /// not necessary to change it, especially in 2D scenarios. + /// + /// \param x X coordinate of the listener's up vector + /// \param y Y coordinate of the listener's up vector + /// \param z Z coordinate of the listener's up vector + /// + /// \see getUpVector, setDirection, setPosition + /// + //////////////////////////////////////////////////////////// + static void setUpVector(float x, float y, float z); + + //////////////////////////////////////////////////////////// + /// \brief Set the upward vector of the listener in the scene + /// + /// The up vector is the vector that points upward from the + /// listener's perspective. Together with the direction, it + /// defines the 3D orientation of the listener in the scene. + /// The up vector doesn't have to be normalized. + /// The default listener's up vector is (0, 1, 0). It is usually + /// not necessary to change it, especially in 2D scenarios. + /// + /// \param upVector New listener's up vector + /// + /// \see getUpVector, setDirection, setPosition + /// + //////////////////////////////////////////////////////////// + static void setUpVector(const Vector3f& upVector); + + //////////////////////////////////////////////////////////// + /// \brief Get the current upward vector of the listener in the scene + /// + /// \return Listener's upward vector (not normalized) + /// + /// \see setUpVector + /// + //////////////////////////////////////////////////////////// + static Vector3f getUpVector(); +}; + +} // namespace sf + + +#endif // SFML_LISTENER_HPP + + +//////////////////////////////////////////////////////////// +/// \class sf::Listener +/// \ingroup audio +/// +/// The audio listener defines the global properties of the +/// audio environment, it defines where and how sounds and musics +/// are heard. If sf::View is the eyes of the user, then sf::Listener +/// is his ears (by the way, they are often linked together -- +/// same position, orientation, etc.). +/// +/// sf::Listener is a simple interface, which allows to setup the +/// listener in the 3D audio environment (position, direction and +/// up vector), and to adjust the global volume. +/// +/// Because the listener is unique in the scene, sf::Listener only +/// contains static functions and doesn't have to be instantiated. +/// +/// Usage example: +/// \code +/// // Move the listener to the position (1, 0, -5) +/// sf::Listener::setPosition(1, 0, -5); +/// +/// // Make it face the right axis (1, 0, 0) +/// sf::Listener::setDirection(1, 0, 0); +/// +/// // Reduce the global volume +/// sf::Listener::setGlobalVolume(50); +/// \endcode +/// +//////////////////////////////////////////////////////////// diff --git a/RayTracer/Dependencies/SFML/include/SFML/Audio/Music.hpp b/RayTracer/Dependencies/SFML/include/SFML/Audio/Music.hpp new file mode 100644 index 0000000..5351905 --- /dev/null +++ b/RayTracer/Dependencies/SFML/include/SFML/Audio/Music.hpp @@ -0,0 +1,337 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_MUSIC_HPP +#define SFML_MUSIC_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include + + +namespace sf +{ +class InputStream; + +//////////////////////////////////////////////////////////// +/// \brief Streamed music played from an audio file +/// +//////////////////////////////////////////////////////////// +class SFML_AUDIO_API Music : public SoundStream +{ +public: + + //////////////////////////////////////////////////////////// + /// \brief Structure defining a time range using the template type + /// + //////////////////////////////////////////////////////////// + template + struct Span + { + //////////////////////////////////////////////////////////// + /// \brief Default constructor + /// + //////////////////////////////////////////////////////////// + Span() + { + + } + + //////////////////////////////////////////////////////////// + /// \brief Initialization constructor + /// + /// \param off Initial Offset + /// \param len Initial Length + /// + //////////////////////////////////////////////////////////// + Span(T off, T len): + offset(off), + length(len) + { + + } + + T offset; ///< The beginning offset of the time range + T length; ///< The length of the time range + }; + + // Define the relevant Span types + typedef Span