├── CMakeLists.txt ├── README.md ├── include ├── BBox.h ├── BVH.h ├── Camera.h ├── IntersectionInfo.h ├── Material.h ├── Object.h ├── Ray.h ├── Renderer.h ├── Scene.h ├── Sphere.h ├── Triangle.h ├── glm │ ├── CMakeLists.txt │ ├── core │ │ ├── _detail.hpp │ │ ├── _fixes.hpp │ │ ├── _swizzle.hpp │ │ ├── _swizzle_func.hpp │ │ ├── _vectorize.hpp │ │ ├── dummy.cpp │ │ ├── func_common.hpp │ │ ├── func_common.inl │ │ ├── func_exponential.hpp │ │ ├── func_exponential.inl │ │ ├── func_geometric.hpp │ │ ├── func_geometric.inl │ │ ├── func_integer.hpp │ │ ├── func_integer.inl │ │ ├── func_matrix.hpp │ │ ├── func_matrix.inl │ │ ├── func_noise.hpp │ │ ├── func_noise.inl │ │ ├── func_packing.hpp │ │ ├── func_packing.inl │ │ ├── func_trigonometric.hpp │ │ ├── func_trigonometric.inl │ │ ├── func_vector_relational.hpp │ │ ├── func_vector_relational.inl │ │ ├── hint.hpp │ │ ├── intrinsic_common.hpp │ │ ├── intrinsic_common.inl │ │ ├── intrinsic_exponential.hpp │ │ ├── intrinsic_exponential.inl │ │ ├── intrinsic_geometric.hpp │ │ ├── intrinsic_geometric.inl │ │ ├── intrinsic_matrix.hpp │ │ ├── intrinsic_matrix.inl │ │ ├── intrinsic_trigonometric.hpp │ │ ├── intrinsic_trigonometric.inl │ │ ├── intrinsic_vector_relational.hpp │ │ ├── intrinsic_vector_relational.inl │ │ ├── setup.hpp │ │ ├── type.hpp │ │ ├── type_float.hpp │ │ ├── type_gentype.hpp │ │ ├── type_gentype.inl │ │ ├── type_half.hpp │ │ ├── type_half.inl │ │ ├── type_int.hpp │ │ ├── type_mat.hpp │ │ ├── type_mat.inl │ │ ├── type_mat2x2.hpp │ │ ├── type_mat2x2.inl │ │ ├── type_mat2x3.hpp │ │ ├── type_mat2x3.inl │ │ ├── type_mat2x4.hpp │ │ ├── type_mat2x4.inl │ │ ├── type_mat3x2.hpp │ │ ├── type_mat3x2.inl │ │ ├── type_mat3x3.hpp │ │ ├── type_mat3x3.inl │ │ ├── type_mat3x4.hpp │ │ ├── type_mat3x4.inl │ │ ├── type_mat4x2.hpp │ │ ├── type_mat4x2.inl │ │ ├── type_mat4x3.hpp │ │ ├── type_mat4x3.inl │ │ ├── type_mat4x4.hpp │ │ ├── type_mat4x4.inl │ │ ├── type_size.hpp │ │ ├── type_vec.hpp │ │ ├── type_vec.inl │ │ ├── type_vec1.hpp │ │ ├── type_vec1.inl │ │ ├── type_vec2.hpp │ │ ├── type_vec2.inl │ │ ├── type_vec3.hpp │ │ ├── type_vec3.inl │ │ ├── type_vec4.hpp │ │ └── type_vec4.inl │ ├── ext.hpp │ ├── glm.hpp │ ├── gtc │ │ ├── half_float.hpp │ │ ├── half_float.inl │ │ ├── matrix_access.hpp │ │ ├── matrix_access.inl │ │ ├── matrix_integer.hpp │ │ ├── matrix_inverse.hpp │ │ ├── matrix_inverse.inl │ │ ├── matrix_transform.hpp │ │ ├── matrix_transform.inl │ │ ├── noise.hpp │ │ ├── noise.inl │ │ ├── quaternion.hpp │ │ ├── quaternion.inl │ │ ├── random.hpp │ │ ├── random.inl │ │ ├── swizzle.hpp │ │ ├── swizzle.inl │ │ ├── type_precision.hpp │ │ ├── type_precision.inl │ │ ├── type_ptr.hpp │ │ └── type_ptr.inl │ ├── gtx │ │ ├── associated_min_max.hpp │ │ ├── associated_min_max.inl │ │ ├── bit.hpp │ │ ├── bit.inl │ │ ├── closest_point.hpp │ │ ├── closest_point.inl │ │ ├── color_cast.hpp │ │ ├── color_cast.inl │ │ ├── color_space.hpp │ │ ├── color_space.inl │ │ ├── color_space_YCoCg.hpp │ │ ├── color_space_YCoCg.inl │ │ ├── compatibility.hpp │ │ ├── compatibility.inl │ │ ├── component_wise.hpp │ │ ├── component_wise.inl │ │ ├── constants.hpp │ │ ├── constants.inl │ │ ├── epsilon.hpp │ │ ├── epsilon.inl │ │ ├── euler_angles.hpp │ │ ├── euler_angles.inl │ │ ├── extend.hpp │ │ ├── extend.inl │ │ ├── extented_min_max (1).inl │ │ ├── extented_min_max.hpp │ │ ├── extented_min_max.inl │ │ ├── fast_exponential.hpp │ │ ├── fast_exponential.inl │ │ ├── fast_square_root.hpp │ │ ├── fast_square_root.inl │ │ ├── fast_trigonometry.hpp │ │ ├── fast_trigonometry.inl │ │ ├── gradient_paint.hpp │ │ ├── gradient_paint.inl │ │ ├── handed_coordinate_space.hpp │ │ ├── handed_coordinate_space.inl │ │ ├── inertia.hpp │ │ ├── inertia.inl │ │ ├── int_10_10_10_2.hpp │ │ ├── int_10_10_10_2.inl │ │ ├── integer (1).inl │ │ ├── integer.hpp │ │ ├── integer.inl │ │ ├── intersect.hpp │ │ ├── intersect.inl │ │ ├── log_base.hpp │ │ ├── log_base.inl │ │ ├── matrix_cross_product.hpp │ │ ├── matrix_cross_product.inl │ │ ├── matrix_interpolation.hpp │ │ ├── matrix_interpolation.inl │ │ ├── matrix_major_storage.hpp │ │ ├── matrix_major_storage.inl │ │ ├── matrix_operation.hpp │ │ ├── matrix_operation.inl │ │ ├── matrix_query.hpp │ │ ├── matrix_query.inl │ │ ├── mixed_product.hpp │ │ ├── mixed_product.inl │ │ ├── multiple.hpp │ │ ├── multiple.inl │ │ ├── noise.hpp │ │ ├── noise.inl │ │ ├── norm.hpp │ │ ├── norm.inl │ │ ├── normal.hpp │ │ ├── normal.inl │ │ ├── normalize_dot.hpp │ │ ├── normalize_dot.inl │ │ ├── number_precision.hpp │ │ ├── number_precision.inl │ │ ├── ocl_type.hpp │ │ ├── ocl_type.inl │ │ ├── optimum_pow.hpp │ │ ├── optimum_pow.inl │ │ ├── orthonormalize.hpp │ │ ├── orthonormalize.inl │ │ ├── perpendicular.hpp │ │ ├── perpendicular.inl │ │ ├── polar_coordinates.hpp │ │ ├── polar_coordinates.inl │ │ ├── projection.hpp │ │ ├── projection.inl │ │ ├── quaternion.hpp │ │ ├── quaternion.inl │ │ ├── random.hpp │ │ ├── random.inl │ │ ├── raw_data (1).hpp │ │ ├── raw_data.hpp │ │ ├── raw_data.inl │ │ ├── reciprocal.hpp │ │ ├── reciprocal.inl │ │ ├── rotate_vector.hpp │ │ ├── rotate_vector.inl │ │ ├── simd_mat4.hpp │ │ ├── simd_mat4.inl │ │ ├── simd_vec4.hpp │ │ ├── simd_vec4.inl │ │ ├── simplex (1).hpp │ │ ├── simplex.hpp │ │ ├── simplex.inl │ │ ├── spline.hpp │ │ ├── spline.inl │ │ ├── std_based_type.hpp │ │ ├── std_based_type.inl │ │ ├── string_cast.hpp │ │ ├── string_cast.inl │ │ ├── transform.hpp │ │ ├── transform.inl │ │ ├── transform2.hpp │ │ ├── transform2.inl │ │ ├── ulp.hpp │ │ ├── ulp.inl │ │ ├── unsigned_int.hpp │ │ ├── unsigned_int.inl │ │ ├── vec1.hpp │ │ ├── vec1.inl │ │ ├── vector_access.hpp │ │ ├── vector_access.inl │ │ ├── vector_angle.hpp │ │ ├── vector_angle.inl │ │ ├── vector_query.hpp │ │ ├── vector_query.inl │ │ ├── verbose_operator.hpp │ │ ├── verbose_operator.inl │ │ ├── wrap.hpp │ │ └── wrap.inl │ └── virtrev │ │ └── xstream.hpp ├── glm_vec3_func.h ├── rand48 │ └── erand48.inc └── tiny_obj_loader │ ├── tiny_obj_loader.cc │ └── tiny_obj_loader.h ├── res ├── dragon.mtl ├── dragon.obj ├── scene01.mtl ├── scene01.obj ├── scene02.mtl └── scene02.obj ├── result └── scene01.ppm └── src ├── BBox.cpp ├── BVH.cpp ├── Camera.cpp ├── Renderer.cpp ├── Scene.cpp └── main.cpp /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.4) 2 | project(CornellBox) 3 | 4 | if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") 5 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-narrowing -march=native -m64 -O3 -static -funroll-loops") 6 | endif() 7 | 8 | FIND_PACKAGE( OpenMP REQUIRED) 9 | if(OPENMP_FOUND) 10 | message("OPENMP FOUND") 11 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 13 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") 14 | endif() 15 | 16 | include_directories( 17 | . 18 | include 19 | include/rand48 20 | include/tiny_obj_loader 21 | include/glm) 22 | 23 | 24 | set(_RESOURCES 25 | res/scene01.obj 26 | res/scene01.mtl 27 | res/scene02.obj 28 | res/scene02.mtl) 29 | 30 | set(_HEADERS 31 | include/BBox.h 32 | include/BVH.h 33 | include/Camera.h 34 | include/glm_vec3_func.h 35 | include/IntersectionInfo.h 36 | include/Material.h 37 | include/Object.h 38 | include/Ray.h 39 | include/Renderer.h 40 | include/Scene.h 41 | include/Sphere.h 42 | include/Triangle.h 43 | include/tiny_obj_loader/tiny_obj_loader.h 44 | include/rand48/erand48.inc 45 | include/tiny_obj_loader/tiny_obj_loader.cc) 46 | 47 | set(SOURCE_FILES 48 | src/BBox.cpp 49 | src/BVH.cpp 50 | src/Camera.cpp 51 | src/main.cpp 52 | src/Renderer.cpp 53 | src/Scene.cpp) 54 | 55 | 56 | 57 | add_executable( 58 | CornellBox ${SOURCE_FILES} 59 | ${_HEADERS}) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CornellBox 2 | 3 | Using monte carlo path tracing method to render the famous CornellBox. 4 | 5 | ## Features 6 | - Mesh Rendering 7 | - Obj Model Import 8 | - Fast-BVH for Ray/Object Intersection Testing. 9 | - Diffuse, specular, and emission material types 10 | 11 | ## Compiling and Running 12 | Requires cmake and OpenMP for multithreading. 13 | 14 | Compile: 15 | ``` 16 | $ mkdir build 17 | $ cd build 18 | $ cmake .. 19 | $ make 20 | ``` 21 | 22 | ## Obj model material info 23 | describe in corresponding .mtl file in 'res' folder. 24 | the information contains: 25 | - material type(mtl_type): REFR, DIFF, SPEC 26 | - material color(color) 27 | - emitted factor(Ke) 28 | - ambient factor(Ka) 29 | - diffuse factor(Kd) 30 | - specular factor(Ks) 31 | -------------------------------------------------------------------------------- /include/BBox.h: -------------------------------------------------------------------------------- 1 | #ifndef BBox_h 2 | #define BBox_h 3 | 4 | #include "glm\glm.hpp" 5 | #include "Ray.h" 6 | #include 7 | 8 | struct BBox { 9 | glm::vec3 min, max, extent; 10 | BBox() { } 11 | BBox(const glm::vec3& min, const glm::vec3& max); 12 | BBox(const glm::vec3& p); 13 | 14 | bool intersect(const Ray& ray, float *tnear, float *tfar) const; 15 | void expandToInclude(const glm::vec3& p); 16 | void expandToInclude(const BBox& b); 17 | uint32_t maxDimension() const; 18 | float surfaceArea() const; 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/BVH.h: -------------------------------------------------------------------------------- 1 | #ifndef BVH_h 2 | #define BVH_h 3 | 4 | #include "BBox.h" 5 | #include 6 | #include 7 | #include "Object.h" 8 | #include "IntersectionInfo.h" 9 | #include "Ray.h" 10 | 11 | //! Node descriptor for the flattened tree 12 | struct BVHFlatNode { 13 | BBox bbox; 14 | uint32_t start, nPrims, rightOffset; 15 | }; 16 | 17 | //! \author Brandon Pelfrey 18 | //! A Bounding Volume Hierarchy system for fast Ray-Object intersection tests 19 | class BVH { 20 | 21 | uint32_t nNodes, nLeafs, leafSize; 22 | std::vector* build_prims; 23 | 24 | //! Build the BVH tree out of build_prims 25 | void build(); 26 | 27 | // Fast Traversal System 28 | BVHFlatNode *flatTree; 29 | 30 | public: 31 | BVH() = default; 32 | BVH(std::vector* objects, uint32_t leafSize = 4); 33 | bool getIntersection(const Ray& ray, IntersectionInfo *intersection, bool occlusion) const; 34 | 35 | ~BVH(); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /include/Camera.h: -------------------------------------------------------------------------------- 1 | #ifndef __CAMERA_H__ 2 | #define __CAMERA_H__ 3 | 4 | #include "erand48.inc" 5 | #include "glm/glm.hpp" 6 | #include "ray.h" 7 | 8 | class Camera { 9 | 10 | private: 11 | int m_width; 12 | double m_width_recp; 13 | int m_height; 14 | double m_height_recp; 15 | double m_ratio; 16 | double m_x_spacing; 17 | double m_x_spacing_half; 18 | double m_y_spacing; 19 | double m_y_spacing_half; 20 | glm::vec3 m_position; 21 | glm::vec3 m_direction; 22 | glm::vec3 m_x_direction; 23 | glm::vec3 m_y_direction; 24 | 25 | public: 26 | Camera(glm::vec3 position, glm::vec3 target, int width, int height); 27 | int get_width(); 28 | int get_height(); 29 | Ray get_ray(int x, int y, bool jitter, unsigned short *Xi); 30 | 31 | }; 32 | 33 | #endif //CAMERA_H -------------------------------------------------------------------------------- /include/IntersectionInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef IntersectionInfo_h_ 2 | #define IntersectionInfo_h_ 3 | 4 | class Object; 5 | class Material; 6 | 7 | struct IntersectionInfo { 8 | float u, v; 9 | float t; // Intersection distance along the ray 10 | const Object* object; // Object that was hit 11 | glm::vec3 hit; // Location of the intersection 12 | const Material* mtl; 13 | }; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/Material.h: -------------------------------------------------------------------------------- 1 | #ifndef _Material_h_ 2 | #define _Material_h_ 3 | 4 | #include "glm/glm.hpp" 5 | 6 | 7 | enum MaterialType { 8 | DIFF, SPEC, REFR, ROUGHPLASTIC}; 9 | 10 | 11 | class Material { 12 | 13 | public: 14 | MaterialType type; 15 | glm::vec3 color; 16 | glm::vec3 emission; 17 | float alpha; 18 | 19 | public: 20 | Material() = default; 21 | Material(MaterialType type_, glm::vec3 color_, glm::vec3 emission_, float alpha_ = 0) 22 | : type(type_), color(color_), emission(emission_), alpha(alpha_){} 23 | 24 | }; 25 | 26 | 27 | #endif // !Material_h_ 28 | -------------------------------------------------------------------------------- /include/Object.h: -------------------------------------------------------------------------------- 1 | #ifndef Object_h_ 2 | #define Object_h_ 3 | 4 | #include 5 | #include "glm_vec3_func.h" 6 | #include "IntersectionInfo.h" 7 | #include "Material.h" 8 | #include "glm/glm.hpp" 9 | #include "Ray.h" 10 | #include "BBox.h" 11 | using glm::vec3; 12 | 13 | class Object { 14 | public: 15 | //! All "Objects" must be able to test for intersections with rays. 16 | virtual bool getIntersection( 17 | const Ray& ray, 18 | IntersectionInfo* intersection) 19 | const = 0; 20 | 21 | //! Return an object normal based on an intersection 22 | virtual vec3 getNormal(const IntersectionInfo& I) const = 0; 23 | 24 | //! Return a bounding box for this object 25 | virtual BBox getBBox() const = 0; 26 | 27 | //! Return the centroid for this object. (Used in BVH Sorting) 28 | virtual vec3 getCentroid() const = 0; 29 | 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/Ray.h: -------------------------------------------------------------------------------- 1 | #ifndef Ray_h 2 | #define Ray_h 3 | 4 | #include "glm/glm.hpp" 5 | 6 | struct Ray { 7 | glm::vec3 o; // Ray Origin 8 | glm::vec3 d; // Ray Direction 9 | glm::vec3 inv_d; // Inverse of each Ray Direction component 10 | 11 | Ray() = default; 12 | Ray(const glm::vec3& o, const glm::vec3& d) 13 | : o(o), d(d), inv_d(glm::vec3(1/d.x, 1/d.y, 1/d.z)) { } 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /include/Renderer.h: -------------------------------------------------------------------------------- 1 | #ifndef _Renderer_h_ 2 | #define _Renderer_h_ 3 | 4 | #include "glm/glm.hpp" 5 | #include "Scene.h" 6 | #include "camera.h" 7 | 8 | class Renderer { 9 | 10 | private: 11 | Scene *m_scene; 12 | Camera *m_camera; 13 | glm::vec3 *m_pixel_buffer; 14 | 15 | public: 16 | Renderer(Scene *scene, Camera *camera); 17 | void render(int samples = 100, const char *file_path = "image.ppm"); 18 | }; 19 | 20 | #endif -------------------------------------------------------------------------------- /include/Scene.h: -------------------------------------------------------------------------------- 1 | #ifndef _Scene_h_ 2 | #define _Scene_h_ 3 | 4 | #include "Material.h" 5 | #include "Triangle.h" 6 | #include "BVH.h" 7 | #include 8 | #include "erand48.inc" 9 | #include "tiny_obj_loader.h" 10 | class Scene 11 | { 12 | private: 13 | std::vector tris; 14 | BVH bvh; 15 | 16 | public: 17 | std::vector m_shapes; 18 | std::vector m_materials; 19 | std::vector materials; 20 | Scene() = default; 21 | Scene(const char* filename); 22 | 23 | glm::vec3 radiance(const Ray &r, int depth, unsigned short *Xi); 24 | void add(const char* filename); 25 | }; 26 | 27 | #endif -------------------------------------------------------------------------------- /include/Sphere.h: -------------------------------------------------------------------------------- 1 | #ifndef Sphere_h_ 2 | #define Sphere_h_ 3 | 4 | #include 5 | #include "Object.h" 6 | #include "glm_vec3_func.h" 7 | 8 | //! For the purposes of demonstrating the BVH, a simple sphere 9 | struct Sphere : public Object { 10 | glm::vec3 center; // Center of the sphere 11 | float r, r2; // Radius, Radius^2 12 | 13 | Sphere() = default; 14 | Sphere(const glm::vec3& center, float radius) 15 | : center(center), r(radius), r2(radius*radius) { } 16 | 17 | bool getIntersection(const Ray& ray, IntersectionInfo* I) const { 18 | glm::vec3 s = center - ray.o; 19 | float sd = dot(s, ray.d); 20 | float ss = dot(s, s); 21 | 22 | // Compute discriminant 23 | float disc = sd*sd - ss + r2; 24 | 25 | // Complex values: No intersection 26 | if( disc < 0.f ) return false; 27 | 28 | // Assume we are not in a sphere... The first hit is the lesser valued 29 | I->object = this; 30 | I->t = sd - sqrt(disc); 31 | return true; 32 | } 33 | 34 | glm::vec3 getNormal(const IntersectionInfo& I) const { 35 | return normalize(I.hit - center); 36 | } 37 | 38 | BBox getBBox() const { 39 | return BBox(center-glm::vec3(r,r,r), center+glm::vec3(r,r,r)); 40 | } 41 | 42 | glm::vec3 getCentroid() const { 43 | return center; 44 | } 45 | 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/Triangle.h: -------------------------------------------------------------------------------- 1 | #ifndef Triangle_h_ 2 | #define Triangle_h_ 3 | 4 | 5 | #include 6 | #include "Object.h" 7 | #include "glm_vec3_func.h" 8 | using glm::vec3; 9 | 10 | 11 | struct Triangle : public Object { 12 | vec3 v0, v1, v2; 13 | vec3 n0, n1, n2; 14 | vec3 e1, e2; 15 | vec3 n; 16 | Material *mtl; 17 | vec3 center; // Center of the Triangle; 18 | 19 | Triangle() = default; 20 | Triangle(vec3 v0_, vec3 v1_, vec3 v2_, 21 | vec3 n0_, vec3 n1_, vec3 n2_, 22 | Material *m_ = NULL) 23 | :v0(v0_), v1(v1_), v2(v2_), 24 | n0(n0_), n1(n1_), n2(n2_), 25 | mtl(m_) 26 | { 27 | e1 = v1 - v0, e2 = v2 - v0; 28 | n = normalize(cross(e1, e2)); 29 | center = (v0 + v1 + v2) / (float)3; 30 | } 31 | 32 | bool getIntersection(const Ray& ray, IntersectionInfo* I) const { 33 | float u, v, t_temp = 0; 34 | 35 | vec3 pvec = cross(ray.d, e2); 36 | double det = dot(e1, pvec); 37 | if (det == 0) return false; 38 | double invDet = 1. / det; 39 | vec3 tvec = ray.o - v0; 40 | u = dot(tvec, pvec) * invDet; 41 | if (u < 0 || u > 1) return false; 42 | vec3 qvec = cross(tvec, e1); 43 | v = dot(ray.d, qvec) * invDet; 44 | if (v < 0 || u + v > 1) return false; 45 | t_temp = dot(e2, qvec) * invDet; // Set distance along ray to intersection 46 | if (t_temp > 1e-9){ // Fairly arbritarily small value, scared to change 47 | I->t = t_temp; // it as it works. 48 | I->object = this; 49 | I->hit = ray.o + ray.d * I->t; 50 | I->mtl = mtl; 51 | I->u = u; 52 | I->v = v; 53 | return true; 54 | } 55 | return false; 56 | } 57 | 58 | vec3 getNormal(const IntersectionInfo& I) const { 59 | return (1 - I.u - I.v) * n0 + I.u * n1 + I.v * n2; 60 | } 61 | 62 | BBox getBBox() const { 63 | vec3 min = vec3( 64 | std::fmin(std::fmin(v0.x, v1.x), v2.x), 65 | std::fmin(std::fmin(v0.y, v1.y), v2.y), 66 | std::fmin(std::fmin(v0.z, v1.z), v2.z) 67 | ); 68 | vec3 max = vec3( 69 | std::fmax(std::fmax(v0.x, v1.x), v2.x), 70 | std::fmax(std::fmax(v0.y, v1.y), v2.y), 71 | std::fmax(std::fmax(v0.z, v1.z), v2.z) 72 | ); 73 | return BBox(min, max); 74 | } 75 | 76 | vec3 getCentroid() const { 77 | return center; 78 | } 79 | 80 | }; 81 | 82 | 83 | 84 | #endif -------------------------------------------------------------------------------- /include/glm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(NAME glm) 2 | 3 | file(GLOB ROOT_SOURCE *.cpp) 4 | file(GLOB ROOT_INLINE *.inl) 5 | file(GLOB ROOT_HEADER *.hpp) 6 | 7 | file(GLOB_RECURSE CORE_SOURCE ./core/*.cpp) 8 | file(GLOB_RECURSE CORE_INLINE ./core/*.inl) 9 | file(GLOB_RECURSE CORE_HEADER ./core/*.hpp) 10 | 11 | file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp) 12 | file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl) 13 | file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp) 14 | 15 | file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp) 16 | file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl) 17 | file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp) 18 | 19 | file(GLOB_RECURSE VIRTREV_SOURCE ./virtrev/*.cpp) 20 | file(GLOB_RECURSE VIRTREV_INLINE ./virtrev/*.inl) 21 | file(GLOB_RECURSE VIRTREV_HEADER ./virtrev/*.hpp) 22 | 23 | source_group("Core Files" FILES ${CORE_SOURCE}) 24 | source_group("Core Files" FILES ${CORE_INLINE}) 25 | source_group("Core Files" FILES ${CORE_HEADER}) 26 | source_group("GTC Files" FILES ${GTC_SOURCE}) 27 | source_group("GTC Files" FILES ${GTC_INLINE}) 28 | source_group("GTC Files" FILES ${GTC_HEADER}) 29 | source_group("GTX Files" FILES ${GTX_SOURCE}) 30 | source_group("GTX Files" FILES ${GTX_INLINE}) 31 | source_group("GTX Files" FILES ${GTX_HEADER}) 32 | source_group("VIRTREV Files" FILES ${VIRTREV_SOURCE}) 33 | source_group("VIRTREV Files" FILES ${VIRTREV_INLINE}) 34 | source_group("VIRTREV Files" FILES ${VIRTREV_HEADER}) 35 | 36 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) 37 | 38 | add_executable(${NAME} 39 | ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER} 40 | ${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER} 41 | ${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER} 42 | ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER} 43 | ${VIRTREV_SOURCE} ${VIRTREV_INLINE} ${VIRTREV_HEADER}) 44 | -------------------------------------------------------------------------------- /include/glm/core/_fixes.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/_fixes.hpp 25 | /// @date 2011-02-21 / 2011-11-22 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #include 30 | 31 | //! Workaround for compatibility with other libraries 32 | #ifdef max 33 | #undef max 34 | #endif 35 | 36 | //! Workaround for compatibility with other libraries 37 | #ifdef min 38 | #undef min 39 | #endif 40 | 41 | //! Workaround for Android 42 | #ifdef isnan 43 | #undef isnan 44 | #endif 45 | 46 | //! Workaround for Android 47 | #ifdef isinf 48 | #undef isinf 49 | #endif 50 | 51 | //! Workaround for Chrone Native Client 52 | #ifdef log2 53 | #undef log2 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /include/glm/core/dummy.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/dummy.cpp 25 | /// @date 2011-01-19 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /// 28 | /// GLM is a header only library. There is nothing to compile. 29 | /// dummy.cpp exist only a wordaround for CMake file. 30 | /////////////////////////////////////////////////////////////////////////////////// 31 | 32 | #define GLM_MESSAGES 33 | #include "../glm.hpp" 34 | #include "../ext.hpp" 35 | 36 | //#error "GLM is a header only library" 37 | 38 | int main() 39 | { 40 | 41 | } 42 | -------------------------------------------------------------------------------- /include/glm/core/func_common.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aovoc/CornellBox/f1198485f41c01715a4766865a5256938c786d60/include/glm/core/func_common.hpp -------------------------------------------------------------------------------- /include/glm/core/func_common.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aovoc/CornellBox/f1198485f41c01715a4766865a5256938c786d60/include/glm/core/func_common.inl -------------------------------------------------------------------------------- /include/glm/core/func_integer.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aovoc/CornellBox/f1198485f41c01715a4766865a5256938c786d60/include/glm/core/func_integer.hpp -------------------------------------------------------------------------------- /include/glm/core/hint.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/hint.hpp 25 | /// @date 2008-08-14 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_core_type 30 | #define glm_core_type 31 | 32 | namespace glm 33 | { 34 | // Use dont_care, nicest and fastest to optimize implementations. 35 | class dont_care {}; 36 | class nicest {}; 37 | class fastest {}; 38 | }//namespace glm 39 | 40 | #endif//glm_core_type 41 | -------------------------------------------------------------------------------- /include/glm/core/intrinsic_common.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_common.hpp 25 | /// @date 2009-05-11 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_detail_intrinsic_common 30 | #define glm_detail_intrinsic_common 31 | 32 | #include "setup.hpp" 33 | 34 | #if((GLM_ARCH & GLM_ARCH_SSE2) != GLM_ARCH_SSE2) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | namespace glm{ 39 | namespace detail 40 | { 41 | __m128 sse_abs_ps(__m128 x); 42 | 43 | __m128 sse_sgn_ps(__m128 x); 44 | 45 | //floor 46 | __m128 sse_flr_ps(__m128 v); 47 | 48 | //trunc 49 | __m128 sse_trc_ps(__m128 v); 50 | 51 | //round 52 | __m128 sse_nd_ps(__m128 v); 53 | 54 | //roundEven 55 | __m128 sse_rde_ps(__m128 v); 56 | 57 | __m128 sse_rnd_ps(__m128 x); 58 | 59 | __m128 sse_ceil_ps(__m128 v); 60 | 61 | __m128 sse_frc_ps(__m128 x); 62 | 63 | __m128 sse_mod_ps(__m128 x, __m128 y); 64 | 65 | __m128 sse_modf_ps(__m128 x, __m128i & i); 66 | 67 | //GLM_FUNC_QUALIFIER __m128 sse_min_ps(__m128 x, __m128 y) 68 | 69 | //GLM_FUNC_QUALIFIER __m128 sse_max_ps(__m128 x, __m128 y) 70 | 71 | __m128 sse_clp_ps(__m128 v, __m128 minVal, __m128 maxVal); 72 | 73 | __m128 sse_mix_ps(__m128 v1, __m128 v2, __m128 a); 74 | 75 | __m128 sse_stp_ps(__m128 edge, __m128 x); 76 | 77 | __m128 sse_ssp_ps(__m128 edge0, __m128 edge1, __m128 x); 78 | 79 | __m128 sse_nan_ps(__m128 x); 80 | 81 | __m128 sse_inf_ps(__m128 x); 82 | 83 | }//namespace detail 84 | }//namespace glm 85 | 86 | #include "intrinsic_common.inl" 87 | 88 | #endif//GLM_ARCH 89 | #endif//glm_detail_intrinsic_common 90 | -------------------------------------------------------------------------------- /include/glm/core/intrinsic_exponential.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_exponential.hpp 25 | /// @date 2009-05-11 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_detail_intrinsic_exponential 30 | #define glm_detail_intrinsic_exponential 31 | 32 | #include "setup.hpp" 33 | 34 | #if((GLM_ARCH & GLM_ARCH_SSE2) != GLM_ARCH_SSE2) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | namespace glm{ 39 | namespace detail 40 | { 41 | /* 42 | GLM_FUNC_QUALIFIER __m128 sse_rsqrt_nr_ss(__m128 const x) 43 | { 44 | __m128 recip = _mm_rsqrt_ss( x ); // "estimate" opcode 45 | const static __m128 three = { 3, 3, 3, 3 }; // aligned consts for fast load 46 | const static __m128 half = { 0.5,0.5,0.5,0.5 }; 47 | __m128 halfrecip = _mm_mul_ss( half, recip ); 48 | __m128 threeminus_xrr = _mm_sub_ss( three, _mm_mul_ss( x, _mm_mul_ss ( recip, recip ) ) ); 49 | return _mm_mul_ss( halfrecip, threeminus_xrr ); 50 | } 51 | 52 | GLM_FUNC_QUALIFIER __m128 sse_normalize_fast_ps( float * RESTRICT vOut, float * RESTRICT vIn ) 53 | { 54 | __m128 x = _mm_load_ss(&vIn[0]); 55 | __m128 y = _mm_load_ss(&vIn[1]); 56 | __m128 z = _mm_load_ss(&vIn[2]); 57 | 58 | const __m128 l = // compute x*x + y*y + z*z 59 | _mm_add_ss( 60 | _mm_add_ss( _mm_mul_ss(x,x), 61 | _mm_mul_ss(y,y) 62 | ), 63 | _mm_mul_ss( z, z ) 64 | ); 65 | 66 | 67 | const __m128 rsqt = _mm_rsqrt_nr_ss( l ); 68 | _mm_store_ss( &vOut[0] , _mm_mul_ss( rsqt, x ) ); 69 | _mm_store_ss( &vOut[1] , _mm_mul_ss( rsqt, y ) ); 70 | _mm_store_ss( &vOut[2] , _mm_mul_ss( rsqt, z ) ); 71 | 72 | return _mm_mul_ss( l , rsqt ); 73 | } 74 | */ 75 | }//namespace detail 76 | }//namespace glm 77 | 78 | #endif//GLM_ARCH 79 | #endif//glm_detail_intrinsic_exponential 80 | -------------------------------------------------------------------------------- /include/glm/core/intrinsic_exponential.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_exponential.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /include/glm/core/intrinsic_geometric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_geometric.hpp 25 | /// @date 2009-05-08 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_core_intrinsic_geometric 30 | #define glm_core_intrinsic_geometric 31 | 32 | #include "setup.hpp" 33 | 34 | #if((GLM_ARCH & GLM_ARCH_SSE2) != GLM_ARCH_SSE2) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | #include "intrinsic_common.hpp" 39 | 40 | namespace glm{ 41 | namespace detail 42 | { 43 | //length 44 | __m128 sse_len_ps(__m128 x); 45 | 46 | //distance 47 | __m128 sse_dst_ps(__m128 p0, __m128 p1); 48 | 49 | //dot 50 | __m128 sse_dot_ps(__m128 v1, __m128 v2); 51 | 52 | // SSE1 53 | __m128 sse_dot_ss(__m128 v1, __m128 v2); 54 | 55 | //cross 56 | __m128 sse_xpd_ps(__m128 v1, __m128 v2); 57 | 58 | //normalize 59 | __m128 sse_nrm_ps(__m128 v); 60 | 61 | //faceforward 62 | __m128 sse_ffd_ps(__m128 N, __m128 I, __m128 Nref); 63 | 64 | //reflect 65 | __m128 sse_rfe_ps(__m128 I, __m128 N); 66 | 67 | //refract 68 | __m128 sse_rfa_ps(__m128 I, __m128 N, __m128 eta); 69 | 70 | }//namespace detail 71 | }//namespace glm 72 | 73 | #include "intrinsic_geometric.inl" 74 | 75 | #endif//GLM_ARCH 76 | #endif//glm_core_intrinsic_geometric 77 | -------------------------------------------------------------------------------- /include/glm/core/intrinsic_matrix.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_common.hpp 25 | /// @date 2009-06-05 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_detail_intrinsic_matrix 30 | #define glm_detail_intrinsic_matrix 31 | 32 | #include "setup.hpp" 33 | 34 | #if((GLM_ARCH & GLM_ARCH_SSE2) != GLM_ARCH_SSE2) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | #include "intrinsic_geometric.hpp" 39 | 40 | namespace glm{ 41 | namespace detail 42 | { 43 | void sse_add_ps(__m128 in1[4], __m128 in2[4], __m128 out[4]); 44 | 45 | void sse_sub_ps(__m128 in1[4], __m128 in2[4], __m128 out[4]); 46 | 47 | __m128 sse_mul_ps(__m128 m[4], __m128 v); 48 | 49 | __m128 sse_mul_ps(__m128 v, __m128 m[4]); 50 | 51 | void sse_mul_ps(__m128 const in1[4], __m128 const in2[4], __m128 out[4]); 52 | 53 | void sse_transpose_ps(__m128 const in[4], __m128 out[4]); 54 | 55 | void sse_inverse_ps(__m128 const in[4], __m128 out[4]); 56 | 57 | void sse_rotate_ps(__m128 const in[4], float Angle, float const v[3], __m128 out[4]); 58 | 59 | __m128 sse_det_ps(__m128 const m[4]); 60 | 61 | __m128 sse_slow_det_ps(__m128 const m[4]); 62 | 63 | }//namespace detail 64 | }//namespace glm 65 | 66 | #include "intrinsic_matrix.inl" 67 | 68 | #endif//GLM_ARCH 69 | #endif//glm_detail_intrinsic_matrix 70 | -------------------------------------------------------------------------------- /include/glm/core/intrinsic_trigonometric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_trigonometric.hpp 25 | /// @date 2009-06-09 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_detail_intrinsic_trigonometric 30 | #define glm_detail_intrinsic_trigonometric 31 | 32 | #include "setup.hpp" 33 | 34 | #if((GLM_ARCH & GLM_ARCH_SSE2) != GLM_ARCH_SSE2) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | namespace glm{ 39 | namespace detail 40 | { 41 | 42 | }//namespace detail 43 | }//namespace glm 44 | 45 | #include "intrinsic_trigonometric.inl" 46 | 47 | #endif//GLM_ARCH 48 | #endif//glm_detail_intrinsic_trigonometric 49 | -------------------------------------------------------------------------------- /include/glm/core/intrinsic_trigonometric.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_trigonometric.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /include/glm/core/intrinsic_vector_relational.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_vector_relational.hpp 25 | /// @date 2009-06-09 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_detail_intrinsic_vector_relational 30 | #define glm_detail_intrinsic_vector_relational 31 | 32 | #include "setup.hpp" 33 | 34 | #if((GLM_ARCH & GLM_ARCH_SSE2) != GLM_ARCH_SSE2) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | namespace glm{ 39 | namespace detail 40 | { 41 | 42 | }//namespace detail 43 | }//namespace glm 44 | 45 | #include "intrinsic_vector_relational.inl" 46 | 47 | #endif//GLM_ARCH 48 | #endif//glm_detail_intrinsic_vector_relational 49 | -------------------------------------------------------------------------------- /include/glm/core/type_half.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aovoc/CornellBox/f1198485f41c01715a4766865a5256938c786d60/include/glm/core/type_half.inl -------------------------------------------------------------------------------- /include/glm/core/type_mat.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/type_mat.hpp 25 | /// @date 2010-01-26 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_core_type_mat 30 | #define glm_core_type_mat 31 | 32 | #include "type_gentype.hpp" 33 | 34 | namespace glm{ 35 | namespace detail 36 | { 37 | //template 38 | //< 39 | // typename T, 40 | // template class C, 41 | // template class R 42 | //> 43 | //struct matType 44 | //{ 45 | // enum ctor{null}; 46 | // typedef T value_type; 47 | // typedef std::size_t size_type; 48 | // typedef C col_type; 49 | // typedef R row_type; 50 | // static size_type const col_size; 51 | // static size_type const row_size; 52 | //}; 53 | 54 | //template 55 | //< 56 | // typename T, 57 | // template class C, 58 | // template class R 59 | //> 60 | //typename matType::size_type const 61 | //matType::col_size = matType::col_type::value_size; 62 | 63 | //template 64 | //< 65 | // typename T, 66 | // template class C, 67 | // template class R 68 | //> 69 | //typename matType::size_type const 70 | //matType::row_size = matType::row_type::value_size; 71 | 72 | }//namespace detail 73 | }//namespace glm 74 | 75 | #endif//glm_core_type_mat 76 | -------------------------------------------------------------------------------- /include/glm/core/type_mat.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/type_mat.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /include/glm/core/type_size.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/type_size.hpp 25 | /// @date 2008-10-05 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_core_type_size 30 | #define glm_core_type_size 31 | 32 | #include 33 | 34 | namespace glm{ 35 | namespace detail 36 | { 37 | //typedef std::size_t size_t; 38 | typedef int sizeType; 39 | 40 | }//namespace detail 41 | }//namespace glm 42 | 43 | #endif//glm_core_type_size 44 | -------------------------------------------------------------------------------- /include/glm/core/type_vec.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/type_vec.hpp 25 | /// @date 2010-01-26 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_core_type_vec 30 | #define glm_core_type_vec 31 | 32 | #include "type_gentype.hpp" 33 | 34 | namespace glm{ 35 | namespace detail 36 | { 37 | 38 | }//namespace detail 39 | }//namespace glm 40 | 41 | #endif//glm_core_type_vec 42 | -------------------------------------------------------------------------------- /include/glm/core/type_vec.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/type_vec.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /include/glm/gtc/matrix_access.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtc_matrix_access 24 | /// @file glm/gtc/matrix_access.hpp 25 | /// @date 2005-12-27 / 2011-05-16 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtc_matrix_access GLM_GTC_matrix_access: Access matrix rows and columns 31 | /// @ingroup gtc 32 | /// 33 | /// Defines functions to access rows or columns of a matrix easily. 34 | /// need to be included to use these functionalities. 35 | /////////////////////////////////////////////////////////////////////////////////// 36 | 37 | #ifndef GLM_GTC_matrix_access 38 | #define GLM_GTC_matrix_access GLM_VERSION 39 | 40 | // Dependency: 41 | #include "../glm.hpp" 42 | 43 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 44 | # pragma message("GLM: GLM_GTC_matrix_access extension included") 45 | #endif 46 | 47 | namespace glm 48 | { 49 | /// @addtogroup gtc_matrix_access 50 | /// @{ 51 | 52 | /// Get a specific row of a matrix. 53 | /// @see gtc_matrix_access 54 | template 55 | typename genType::row_type row( 56 | genType const & m, 57 | int index); 58 | 59 | /// Set a specific row to a matrix. 60 | /// @see gtc_matrix_access 61 | template 62 | genType row( 63 | genType const & m, 64 | int index, 65 | typename genType::row_type const & x); 66 | 67 | /// Get a specific column of a matrix. 68 | /// @see gtc_matrix_access 69 | template 70 | typename genType::col_type column( 71 | genType const & m, 72 | int index); 73 | 74 | /// Set a specific column to a matrix. 75 | /// @see gtc_matrix_access 76 | template 77 | genType column( 78 | genType const & m, 79 | int index, 80 | typename genType::col_type const & x); 81 | 82 | /// @} 83 | }//namespace glm 84 | 85 | #include "matrix_access.inl" 86 | 87 | #endif//GLM_GTC_matrix_access 88 | -------------------------------------------------------------------------------- /include/glm/gtc/matrix_access.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtc_matrix_access 24 | /// @file glm/gtc/matrix_access.inl 25 | /// @date 2005-12-27 / 2011-06-05 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | namespace glm 30 | { 31 | template 32 | GLM_FUNC_QUALIFIER genType row 33 | ( 34 | genType const & m, 35 | int index, 36 | typename genType::row_type const & x 37 | ) 38 | { 39 | genType Result = m; 40 | for(typename genType::size_type i = 0; i < genType::row_size(); ++i) 41 | Result[i][index] = x[i]; 42 | return Result; 43 | } 44 | 45 | template 46 | GLM_FUNC_QUALIFIER typename genType::row_type row 47 | ( 48 | genType const & m, 49 | int index 50 | ) 51 | { 52 | typename genType::row_type Result; 53 | for(typename genType::size_type i = 0; i < genType::row_size(); ++i) 54 | Result[i] = m[i][index]; 55 | return Result; 56 | } 57 | 58 | template 59 | GLM_FUNC_QUALIFIER genType column 60 | ( 61 | genType const & m, 62 | int index, 63 | typename genType::col_type const & x 64 | ) 65 | { 66 | genType Result = m; 67 | Result[index] = x; 68 | return Result; 69 | } 70 | 71 | template 72 | GLM_FUNC_QUALIFIER typename genType::col_type column 73 | ( 74 | genType const & m, 75 | int index 76 | ) 77 | { 78 | return m[index]; 79 | } 80 | }//namespace glm 81 | -------------------------------------------------------------------------------- /include/glm/gtc/matrix_inverse.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtc_matrix_inverse 24 | /// @file glm/gtc/matrix_inverse.hpp 25 | /// @date 2005-12-21 / 2011-06-05 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtc_matrix_inverse GLM_GTC_matrix_inverse: Additional matrix inverse function 31 | /// @ingroup gtc 32 | /// 33 | /// Defines additional matrix inverting functions. 34 | /// need to be included to use these functionalities. 35 | /////////////////////////////////////////////////////////////////////////////////// 36 | 37 | #ifndef GLM_GTC_matrix_inverse 38 | #define GLM_GTC_matrix_inverse GLM_VERSION 39 | 40 | // Dependency: 41 | #include "../glm.hpp" 42 | 43 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 44 | # pragma message("GLM: GLM_GTC_matrix_inverse extension included") 45 | #endif 46 | 47 | namespace glm 48 | { 49 | /// @addtogroup gtc_matrix_inverse 50 | /// @{ 51 | 52 | /// Fast matrix inverse for affine matrix. 53 | /// 54 | /// @param m Input matrix to invert. 55 | /// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate. 56 | /// @see gtc_matrix_inverse 57 | template 58 | genType affineInverse(genType const & m); 59 | 60 | /// Compute the inverse transpose of a matrix. 61 | /// 62 | /// @param m Input matrix to invert transpose. 63 | /// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate. 64 | /// @see gtc_matrix_inverse 65 | template 66 | GLM_FUNC_QUALIFIER typename genType::value_type inverseTranspose( 67 | genType const & m); 68 | 69 | /// @} 70 | }//namespace glm 71 | 72 | #include "matrix_inverse.inl" 73 | 74 | #endif//GLM_GTC_matrix_inverse 75 | -------------------------------------------------------------------------------- /include/glm/gtc/noise.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtc_noise 24 | /// @file glm/gtc/noise.hpp 25 | /// @date 2011-04-21 / 2011-09-27 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtc_noise GLM_GTC_noise: Procedural noise functions 31 | /// @ingroup gtc 32 | /// 33 | /// Defines 2D, 3D and 4D procedural noise functions 34 | /// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": 35 | /// https://github.com/ashima/webgl-noise 36 | /// Following Stefan Gustavson's paper "Simplex noise demystified": 37 | /// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf 38 | /// need to be included to use these functionalities. 39 | /////////////////////////////////////////////////////////////////////////////////// 40 | 41 | #ifndef GLM_GTC_noise 42 | #define GLM_GTC_noise GLM_VERSION 43 | 44 | // Dependency: 45 | #include "../glm.hpp" 46 | 47 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 48 | # pragma message("GLM: GLM_GTC_noise extension included") 49 | #endif 50 | 51 | namespace glm 52 | { 53 | /// @addtogroup gtc_noise 54 | /// @{ 55 | 56 | /// Classic perlin noise. 57 | /// @see gtc_noise 58 | template class vecType> 59 | T perlin( 60 | vecType const & p); 61 | 62 | /// Periodic perlin noise. 63 | /// @see gtc_noise 64 | template class vecType> 65 | T perlin( 66 | vecType const & p, 67 | vecType const & rep); 68 | 69 | /// Simplex noise. 70 | /// @see gtc_noise 71 | template class vecType> 72 | T simplex( 73 | vecType const & p); 74 | 75 | /// @} 76 | }//namespace glm 77 | 78 | #include "noise.inl" 79 | 80 | #endif//GLM_GTC_noise 81 | -------------------------------------------------------------------------------- /include/glm/gtc/type_precision.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtc_swizzle 24 | /// @file glm/gtc/swizzle.inl 25 | /// @date 2009-06-14 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | namespace glm 30 | { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /include/glm/gtx/closest_point.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_bit 24 | /// @file glm/gtx/bit.hpp 25 | /// @date 2005-12-30 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_closest_point GLM_GTX_closest_point: Find closest point 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Find the point on a straight line which is the closet of a point. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_closest_point 39 | #define GLM_GTX_closest_point GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_closest_point extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_closest_point 51 | /// @{ 52 | 53 | /// Find the point on a straight line which is the closet of a point. 54 | /// @see gtx_closest_point 55 | template 56 | detail::tvec3 closestPointOnLine( 57 | detail::tvec3 const & point, 58 | detail::tvec3 const & a, 59 | detail::tvec3 const & b); 60 | 61 | /// @} 62 | }// namespace glm 63 | 64 | #include "closest_point.inl" 65 | 66 | #endif//GLM_GTX_closest_point 67 | -------------------------------------------------------------------------------- /include/glm/gtx/closest_point.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-30 5 | // Updated : 2008-10-05 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/closest_point.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | #ifndef glm_gtx_closest_point 11 | #define glm_gtx_closest_point 12 | 13 | namespace glm 14 | { 15 | template 16 | GLM_FUNC_QUALIFIER detail::tvec3 closestPointOnLine 17 | ( 18 | detail::tvec3 const & point, 19 | detail::tvec3 const & a, 20 | detail::tvec3 const & b 21 | ) 22 | { 23 | valType LineLength = distance(a, b); 24 | detail::tvec3 Vector = point - a; 25 | detail::tvec3 LineDirection = (b - a) / LineLength; 26 | 27 | // Project Vector to LineDirection to get the distance of point from a 28 | valType Distance = dot(Vector, LineDirection); 29 | 30 | if(Distance <= valType(0)) return a; 31 | if(Distance >= LineLength) return b; 32 | return a + LineDirection * Distance; 33 | } 34 | }//namespace glm 35 | 36 | #endif//glm_gtx_closest_point 37 | -------------------------------------------------------------------------------- /include/glm/gtx/color_space_YCoCg.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2008-10-28 5 | // Updated : 2008-10-28 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/color_space_YCoCg.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tvec3 rgb2YCoCg 14 | ( 15 | detail::tvec3 const & rgbColor 16 | ) 17 | { 18 | detail::tvec3 result; 19 | result.x/*Y */ = rgbColor.r / valType(4) + rgbColor.g / valType(2) + rgbColor.b / valType(4); 20 | result.y/*Co*/ = rgbColor.r / valType(2) + rgbColor.g * valType(0) - rgbColor.b / valType(2); 21 | result.z/*Cg*/ = - rgbColor.r / valType(4) + rgbColor.g / valType(2) - rgbColor.b / valType(4); 22 | return result; 23 | } 24 | 25 | template 26 | GLM_FUNC_QUALIFIER detail::tvec3 rgb2YCoCgR 27 | ( 28 | detail::tvec3 const & rgbColor 29 | ) 30 | { 31 | detail::tvec3 result; 32 | result.x/*Y */ = rgbColor.g / valType(2) + (rgbColor.r + rgbColor.b) / valType(4); 33 | result.y/*Co*/ = rgbColor.r - rgbColor.b; 34 | result.z/*Cg*/ = rgbColor.g - (rgbColor.r + rgbColor.b) / valType(2); 35 | return result; 36 | } 37 | 38 | template 39 | GLM_FUNC_QUALIFIER detail::tvec3 YCoCg2rgb 40 | ( 41 | detail::tvec3 const & YCoCgColor 42 | ) 43 | { 44 | detail::tvec3 result; 45 | result.r = YCoCgColor.x + YCoCgColor.y - YCoCgColor.z; 46 | result.g = YCoCgColor.x + YCoCgColor.z; 47 | result.b = YCoCgColor.x - YCoCgColor.y - YCoCgColor.z; 48 | return result; 49 | } 50 | 51 | template 52 | GLM_FUNC_QUALIFIER detail::tvec3 YCoCgR2rgb 53 | ( 54 | detail::tvec3 const & YCoCgRColor 55 | ) 56 | { 57 | detail::tvec3 result; 58 | valType tmp = YCoCgRColor.x - (YCoCgRColor.z / valType(2)); 59 | result.g = YCoCgRColor.z + tmp; 60 | result.b = tmp - (YCoCgRColor.y / valType(2)); 61 | result.r = result.b + YCoCgRColor.y; 62 | return result; 63 | } 64 | }//namespace glm 65 | -------------------------------------------------------------------------------- /include/glm/gtx/compatibility.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-03-16 5 | // Updated : 2008-10-24 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/compatibility.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | // isfinite 13 | template 14 | GLM_FUNC_QUALIFIER bool isfinite( 15 | genType const & x) 16 | { 17 | # if(GLM_COMPILER & GLM_COMPILER_VC) 18 | return _finite(x); 19 | # elif(GLM_COMPILER & GLM_COMPILER_GCC) 20 | # if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) 21 | return _isfinite(x) != 0; 22 | # else 23 | return std::isfinite(x) != 0; 24 | # endif 25 | # else 26 | return std::isfinite(x) != 0; 27 | # endif 28 | 29 | } 30 | 31 | template 32 | GLM_FUNC_QUALIFIER detail::tvec2 isfinite( 33 | detail::tvec2 const & x) 34 | { 35 | return detail::tvec2( 36 | isfinite(x.x), 37 | isfinite(x.y)); 38 | } 39 | 40 | template 41 | GLM_FUNC_QUALIFIER detail::tvec3 isfinite( 42 | detail::tvec3 const & x) 43 | { 44 | return detail::tvec3( 45 | isfinite(x.x), 46 | isfinite(x.y), 47 | isfinite(x.z)); 48 | } 49 | 50 | template 51 | GLM_FUNC_QUALIFIER detail::tvec4 isfinite( 52 | detail::tvec4 const & x) 53 | { 54 | return detail::tvec4( 55 | isfinite(x.x), 56 | isfinite(x.y), 57 | isfinite(x.z), 58 | isfinite(x.w)); 59 | } 60 | 61 | }//namespace glm 62 | -------------------------------------------------------------------------------- /include/glm/gtx/component_wise.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_component_wise 24 | /// @file glm/gtx/component_wise.hpp 25 | /// @date 2007-05-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_component_wise GLM_GTX_component_wise: Component wise 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Operations between components of a type 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_component_wise 39 | #define GLM_GTX_component_wise GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_component_wise extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_component_wise 51 | /// @{ 52 | 53 | /// Add all vector components together. 54 | /// @see gtx_component_wise 55 | template 56 | typename genType::value_type compAdd( 57 | genType const & v); 58 | 59 | /// Multiply all vector components together. 60 | /// @see gtx_component_wise 61 | template 62 | typename genType::value_type compMul( 63 | genType const & v); 64 | 65 | /// Find the minimum value between single vector components. 66 | /// @see gtx_component_wise 67 | template 68 | typename genType::value_type compMin( 69 | genType const & v); 70 | 71 | /// Find the maximum value between single vector components. 72 | /// @see gtx_component_wise 73 | template 74 | typename genType::value_type compMax( 75 | genType const & v); 76 | 77 | /// @} 78 | }//namespace glm 79 | 80 | #include "component_wise.inl" 81 | 82 | #endif//GLM_GTX_component_wise 83 | -------------------------------------------------------------------------------- /include/glm/gtx/component_wise.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-05-21 5 | // Updated : 2010-02-12 6 | // Licence : This source is under MIT License 7 | // File : gtx_component_wise.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v) 14 | { 15 | typename genType::size_type result = typename genType::value_type(0); 16 | for(typename genType::size_type i = 0; i < v.length(); ++i) 17 | result += v[i]; 18 | return result; 19 | } 20 | 21 | template 22 | GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v) 23 | { 24 | typename genType::value_type result = typename genType::value_type(1); 25 | for(typename genType::size_type i = 0; i < v.length(); ++i) 26 | result *= v[i]; 27 | return result; 28 | } 29 | 30 | template 31 | GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v) 32 | { 33 | typename genType::value_type result = typename genType::value_type(v[0]); 34 | for(typename genType::size_type i = 1; i < v.length(); ++i) 35 | result = min(result, v[i]); 36 | return result; 37 | } 38 | 39 | template 40 | GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v) 41 | { 42 | typename genType::value_type result = typename genType::value_type(v[0]); 43 | for(typename genType::size_type i = 1; i < v.length(); ++i) 44 | result = max(result, v[i]); 45 | return result; 46 | } 47 | }//namespace glm 48 | -------------------------------------------------------------------------------- /include/glm/gtx/epsilon.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_epsilon 24 | /// @file glm/gtx/epsilon.hpp 25 | /// @date 2007-05-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtc_half_float (dependence) 30 | /// @see gtc_quaternion (dependence) 31 | /// 32 | /// @defgroup gtx_epsilon GLM_GTX_epsilon: Epsilon comparison 33 | /// @ingroup gtx 34 | /// 35 | /// @brief Comparison functions for a user defined epsilon values. 36 | /// 37 | /// need to be included to use these functionalities. 38 | /////////////////////////////////////////////////////////////////////////////////// 39 | 40 | #ifndef GLM_GTX_epsilon 41 | #define GLM_GTX_epsilon GLM_VERSION 42 | 43 | // Dependency: 44 | #include "../glm.hpp" 45 | #include "../gtc/half_float.hpp" 46 | #include "../gtc/quaternion.hpp" 47 | 48 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 49 | # pragma message("GLM: GLM_GTX_epsilon extension included") 50 | #endif 51 | 52 | namespace glm 53 | { 54 | /// @addtogroup gtx_epsilon 55 | /// @{ 56 | 57 | /// Returns the component-wise compare of |x - y| < epsilon. 58 | /// @see gtx_epsilon 59 | template 60 | bool equalEpsilon( 61 | genTypeT const & x, 62 | genTypeT const & y, 63 | genTypeU const & epsilon); 64 | 65 | /// Returns the component-wise compare of |x - y| >= epsilon. 66 | /// @see gtx_epsilon 67 | template 68 | bool notEqualEpsilon( 69 | genTypeT const & x, 70 | genTypeT const & y, 71 | genTypeU const & epsilon); 72 | 73 | /// @} 74 | }//namespace glm 75 | 76 | #include "epsilon.inl" 77 | 78 | #endif//GLM_GTX_epsilon 79 | -------------------------------------------------------------------------------- /include/glm/gtx/extend.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_extend 24 | /// @file glm/gtx/extend.hpp 25 | /// @date 2006-01-07 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_extend GLM_GTX_extend: Position extending 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Extend a position from a source to a position at a defined length. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_extend 39 | #define GLM_GTX_extend GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_extend extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_extend 51 | /// @{ 52 | 53 | /// Extends of Length the Origin position using the (Source - Origin) direction. 54 | /// @see gtx_extend 55 | template 56 | genType extend( 57 | genType const & Origin, 58 | genType const & Source, 59 | typename genType::value_type const Length); 60 | 61 | /// @} 62 | }//namespace glm 63 | 64 | #include "extend.inl" 65 | 66 | #endif//GLM_GTX_extend 67 | -------------------------------------------------------------------------------- /include/glm/gtx/extend.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2006-01-07 5 | // Updated : 2008-10-05 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/extend.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | genType extend 14 | ( 15 | genType const & Origin, 16 | genType const & Source, 17 | genType const & Distance 18 | ) 19 | { 20 | return Origin + (Source - Origin) * Distance; 21 | } 22 | 23 | template 24 | detail::tvec2 extend 25 | ( 26 | detail::tvec2 const & Origin, 27 | detail::tvec2 const & Source, 28 | valType const & Distance 29 | ) 30 | { 31 | return Origin + (Source - Origin) * Distance; 32 | } 33 | 34 | template 35 | detail::tvec3 extend 36 | ( 37 | detail::tvec3 const & Origin, 38 | detail::tvec3 const & Source, 39 | valType const & Distance 40 | ) 41 | { 42 | return Origin + (Source - Origin) * Distance; 43 | } 44 | 45 | template 46 | detail::tvec4 extend 47 | ( 48 | detail::tvec4 const & Origin, 49 | detail::tvec4 const & Source, 50 | valType const & Distance 51 | ) 52 | { 53 | return Origin + (Source - Origin) * Distance; 54 | } 55 | }//namespace glm 56 | -------------------------------------------------------------------------------- /include/glm/gtx/fast_trigonometry.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2006-01-08 5 | // Updated : 2011-10-14 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/fast_trigonometry.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | #include "../core/_vectorize.hpp" 11 | 12 | namespace glm 13 | { 14 | // sin 15 | template 16 | GLM_FUNC_QUALIFIER T fastSin(T const & x) 17 | { 18 | return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040)); 19 | } 20 | 21 | VECTORIZE_VEC(fastSin) 22 | 23 | // cos 24 | template 25 | GLM_FUNC_QUALIFIER T fastCos(T const & x) 26 | { 27 | return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888)); 28 | } 29 | 30 | VECTORIZE_VEC(fastCos) 31 | 32 | // tan 33 | template 34 | GLM_FUNC_QUALIFIER T fastTan(T const & x) 35 | { 36 | return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539)); 37 | } 38 | 39 | VECTORIZE_VEC(fastTan) 40 | 41 | // asin 42 | template 43 | GLM_FUNC_QUALIFIER T fastAsin(T const & x) 44 | { 45 | return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159)); 46 | } 47 | 48 | VECTORIZE_VEC(fastAsin) 49 | 50 | // acos 51 | template 52 | GLM_FUNC_QUALIFIER T fastAcos(T const & x) 53 | { 54 | return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2) 55 | } 56 | 57 | VECTORIZE_VEC(fastAcos) 58 | 59 | // atan 60 | template 61 | GLM_FUNC_QUALIFIER T fastAtan(T const & y, T const & x) 62 | { 63 | T sgn = sign(y) * sign(x); 64 | return abs(fastAtan(y / x)) * sgn; 65 | } 66 | 67 | VECTORIZE_VEC_VEC(fastAtan) 68 | 69 | template 70 | GLM_FUNC_QUALIFIER T fastAtan(T const & x) 71 | { 72 | return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909)); 73 | } 74 | 75 | VECTORIZE_VEC(fastAtan) 76 | 77 | }//namespace glm 78 | -------------------------------------------------------------------------------- /include/glm/gtx/gradient_paint.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_gradient_paint 24 | /// @file glm/gtx/gradient_paint.hpp 25 | /// @date 2009-03-06 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_optimum_pow (dependence) 30 | /// 31 | /// @defgroup gtx_gradient_paint GLM_GTX_gradient_paint: Procedural gradient color 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Functions that return the color of procedural gradient for specific coordinates. 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_gradient_paint 39 | #define GLM_GTX_gradient_paint GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | #include "../gtx/optimum_pow.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 46 | # pragma message("GLM: GLM_GTX_gradient_paint extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_gradient_paint 52 | /// @{ 53 | 54 | /// Return a color from a radial gradient. 55 | /// @see - gtx_gradient_paint 56 | template 57 | valType radialGradient( 58 | detail::tvec2 const & Center, 59 | valType const & Radius, 60 | detail::tvec2 const & Focal, 61 | detail::tvec2 const & Position); 62 | 63 | /// Return a color from a linear gradient. 64 | /// @see - gtx_gradient_paint 65 | template 66 | valType linearGradient( 67 | detail::tvec2 const & Point0, 68 | detail::tvec2 const & Point1, 69 | detail::tvec2 const & Position); 70 | 71 | /// @} 72 | }// namespace glm 73 | 74 | #include "gradient_paint.inl" 75 | 76 | #endif//GLM_GTX_gradient_paint 77 | -------------------------------------------------------------------------------- /include/glm/gtx/gradient_paint.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2009-03-06 5 | // Updated : 2009-03-09 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/gradient_paint.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | valType radialGradient 14 | ( 15 | detail::tvec2 const & Center, 16 | valType const & Radius, 17 | detail::tvec2 const & Focal, 18 | detail::tvec2 const & Position 19 | ) 20 | { 21 | detail::tvec2 F = Focal - Center; 22 | detail::tvec2 D = Position - Focal; 23 | valType Radius2 = pow2(Radius); 24 | valType Fx2 = pow2(F.x); 25 | valType Fy2 = pow2(F.y); 26 | 27 | valType Numerator = (D.x * F.x + D.y * F.y) + sqrt(Radius2 * (pow2(D.x) + pow2(D.y)) - pow2(D.x * F.y - D.y * F.x)); 28 | valType Denominator = Radius2 - (Fx2 + Fy2); 29 | return Numerator / Denominator; 30 | } 31 | 32 | template 33 | valType linearGradient 34 | ( 35 | detail::tvec2 const & Point0, 36 | detail::tvec2 const & Point1, 37 | detail::tvec2 const & Position 38 | ) 39 | { 40 | detail::tvec2 Dist = Point1 - Point0; 41 | return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist); 42 | } 43 | }//namespace glm 44 | -------------------------------------------------------------------------------- /include/glm/gtx/handed_coordinate_space.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_handed_coordinate_space 24 | /// @file glm/gtx/handed_coordinate_space.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_handed_coordinate_space GLM_GTX_handed_coordinate_space: Space Handedness 31 | /// @ingroup gtx 32 | /// 33 | /// @brief To know if a set of three basis vectors defines a right or left-handed coordinate system. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_handed_coordinate_space 39 | #define GLM_GTX_handed_coordinate_space GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_handed_coordinate_space extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_handed_coordinate_space 51 | /// @{ 52 | 53 | //! Return if a trihedron right handed or not. 54 | //! From GLM_GTX_handed_coordinate_space extension. 55 | template 56 | bool rightHanded( 57 | detail::tvec3 const & tangent, 58 | detail::tvec3 const & binormal, 59 | detail::tvec3 const & normal); 60 | 61 | //! Return if a trihedron left handed or not. 62 | //! From GLM_GTX_handed_coordinate_space extension. 63 | template 64 | bool leftHanded( 65 | detail::tvec3 const & tangent, 66 | detail::tvec3 const & binormal, 67 | detail::tvec3 const & normal); 68 | 69 | /// @} 70 | }// namespace glm 71 | 72 | #include "handed_coordinate_space.inl" 73 | 74 | #endif//GLM_GTX_handed_coordinate_space 75 | -------------------------------------------------------------------------------- /include/glm/gtx/handed_coordinate_space.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2009-02-19 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/handed_coordinate_space.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER bool rightHanded 14 | ( 15 | detail::tvec3 const & tangent, 16 | detail::tvec3 const & binormal, 17 | detail::tvec3 const & normal 18 | ) 19 | { 20 | return dot(cross(normal, tangent), binormal) > T(0); 21 | } 22 | 23 | template 24 | GLM_FUNC_QUALIFIER bool leftHanded 25 | ( 26 | detail::tvec3 const & tangent, 27 | detail::tvec3 const & binormal, 28 | detail::tvec3 const & normal 29 | ) 30 | { 31 | return dot(cross(normal, tangent), binormal) < T(0); 32 | } 33 | }//namespace glm 34 | -------------------------------------------------------------------------------- /include/glm/gtx/inertia.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2006-04-21 5 | // Updated : 2006-12-06 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/inertia.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tmat3x3 boxInertia3 14 | ( 15 | T const & Mass, 16 | detail::tvec3 const & Scale 17 | ) 18 | { 19 | detail::tmat3x3 Result(T(1)); 20 | Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12); 21 | Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12); 22 | Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); 23 | return Result; 24 | } 25 | 26 | template 27 | GLM_FUNC_QUALIFIER detail::tmat4x4 boxInertia4 28 | ( 29 | T const & Mass, 30 | detail::tvec3 const & Scale 31 | ) 32 | { 33 | detail::tmat4x4 Result(T(1)); 34 | Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12); 35 | Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12); 36 | Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); 37 | return Result; 38 | } 39 | 40 | template 41 | GLM_FUNC_QUALIFIER detail::tmat3x3 diskInertia3 42 | ( 43 | T const & Mass, 44 | T const & Radius 45 | ) 46 | { 47 | T a = Mass * Radius * Radius / T(2); 48 | detail::tmat3x3 Result(a); 49 | Result[2][2] *= T(2); 50 | return Result; 51 | } 52 | 53 | template 54 | GLM_FUNC_QUALIFIER detail::tmat4x4 diskInertia4 55 | ( 56 | T const & Mass, 57 | T const & Radius 58 | ) 59 | { 60 | T a = Mass * Radius * Radius / T(2); 61 | detail::tmat4x4 Result(a); 62 | Result[2][2] *= T(2); 63 | Result[3][3] = T(1); 64 | return Result; 65 | } 66 | 67 | template 68 | GLM_FUNC_QUALIFIER detail::tmat3x3 ballInertia3 69 | ( 70 | T const & Mass, 71 | T const & Radius 72 | ) 73 | { 74 | T a = T(2) * Mass * Radius * Radius / T(5); 75 | return detail::tmat3x3(a); 76 | } 77 | 78 | template 79 | GLM_FUNC_QUALIFIER detail::tmat4x4 ballInertia4 80 | ( 81 | T const & Mass, 82 | T const & Radius 83 | ) 84 | { 85 | T a = T(2) * Mass * Radius * Radius / T(5); 86 | detail::tmat4x4 Result(a); 87 | Result[3][3] = T(1); 88 | return Result; 89 | } 90 | 91 | template 92 | GLM_FUNC_QUALIFIER detail::tmat3x3 sphereInertia3 93 | ( 94 | T const & Mass, 95 | T const & Radius 96 | ) 97 | { 98 | T a = T(2) * Mass * Radius * Radius / T(3); 99 | return detail::tmat3x3(a); 100 | } 101 | 102 | template 103 | GLM_FUNC_QUALIFIER detail::tmat4x4 sphereInertia4 104 | ( 105 | T const & Mass, 106 | T const & Radius 107 | ) 108 | { 109 | T a = T(2) * Mass * Radius * Radius / T(3); 110 | detail::tmat4x4 Result(a); 111 | Result[3][3] = T(1); 112 | return Result; 113 | } 114 | }//namespace glm 115 | -------------------------------------------------------------------------------- /include/glm/gtx/int_10_10_10_2.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_int_10_10_10_2 24 | /// @file glm/gtx/int_10_10_10_2.hpp 25 | /// @date 2010-07-07 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_raw_data (dependence) 30 | /// 31 | /// @defgroup gtx_int_10_10_10_2 GLM_GTX_int_10_10_10_2: Packed integer 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Pack vector to 1010102 integers. Storage only. 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_int_10_10_10_2 40 | #define GLM_GTX_int_10_10_10_2 GLM_VERSION 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | #include "../gtx/raw_data.hpp" 45 | 46 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 47 | # pragma message("GLM: GLM_GTX_int_10_10_10_2 extension included") 48 | #endif 49 | 50 | namespace glm 51 | { 52 | /// @addtogroup gtx_int_10_10_10_2 53 | /// @{ 54 | 55 | //! From GLM_GTX_int_10_10_10_2 extension. 56 | //! Cast a vec4 to an u_10_10_10_2. 57 | dword uint10_10_10_2_cast(glm::vec4 const & v); 58 | 59 | /// @} 60 | }//namespace glm 61 | 62 | #include "int_10_10_10_2.inl" 63 | 64 | #endif//GLM_GTX_int_10_10_10_2 65 | -------------------------------------------------------------------------------- /include/glm/gtx/int_10_10_10_2.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2010-07-07 5 | // Updated : 2010-07-07 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/int_10_10_10_2.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | GLM_FUNC_QUALIFIER dword uint10_10_10_2_cast 13 | ( 14 | glm::vec4 const & v 15 | ) 16 | { 17 | return dword(uint(v.x * 2047.f) << 0 | uint(v.y * 2047.f) << 10 | uint(v.z * 2047.f) << 20 | uint(v.w * 3.f) << 30); 18 | } 19 | }//namespace glm 20 | -------------------------------------------------------------------------------- /include/glm/gtx/integer.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-24 5 | // Updated : 2006-12-06 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/integer.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm{ 11 | namespace gtx{ 12 | namespace integer 13 | { 14 | // pow 15 | GLM_FUNC_QUALIFIER int pow(int x, int y) 16 | { 17 | if(y == 0) 18 | return 1; 19 | int result = x; 20 | for(int i = 1; i < y; ++i) 21 | result *= x; 22 | return result; 23 | } 24 | 25 | // sqrt: From Christopher J. Musial, An integer square root, Graphics Gems, 1990, page 387 26 | GLM_FUNC_QUALIFIER int sqrt(int x) 27 | { 28 | if(x <= 1) return x; 29 | 30 | int NextTrial = x >> 1; 31 | int CurrentAnswer; 32 | 33 | do 34 | { 35 | CurrentAnswer = NextTrial; 36 | NextTrial = (NextTrial + x / NextTrial) >> 1; 37 | } while(NextTrial < CurrentAnswer); 38 | 39 | return CurrentAnswer; 40 | } 41 | 42 | // mod 43 | GLM_FUNC_QUALIFIER int mod(int x, int y) 44 | { 45 | return x - y * (x / y); 46 | } 47 | 48 | // factorial (!12 max, integer only) 49 | template 50 | GLM_FUNC_QUALIFIER genType factorial(genType const & x) 51 | { 52 | genType Temp = x; 53 | genType Result; 54 | for(Result = 1; Temp > 1; --Temp) 55 | Result *= Temp; 56 | return Result; 57 | } 58 | 59 | template 60 | GLM_FUNC_QUALIFIER detail::tvec2 factorial( 61 | detail::tvec2 const & x) 62 | { 63 | return detail::tvec2( 64 | factorial(x.x), 65 | factorial(x.y)); 66 | } 67 | 68 | template 69 | GLM_FUNC_QUALIFIER detail::tvec3 factorial( 70 | detail::tvec3 const & x) 71 | { 72 | return detail::tvec3( 73 | factorial(x.x), 74 | factorial(x.y), 75 | factorial(x.z)); 76 | } 77 | 78 | template 79 | GLM_FUNC_QUALIFIER detail::tvec4 factorial( 80 | detail::tvec4 const & x) 81 | { 82 | return detail::tvec4( 83 | factorial(x.x), 84 | factorial(x.y), 85 | factorial(x.z), 86 | factorial(x.w)); 87 | } 88 | 89 | }//namespace integer 90 | }//namespace gtx 91 | }//namespace glm 92 | -------------------------------------------------------------------------------- /include/glm/gtx/log_base.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_log_base 24 | /// @file glm/gtx/log_base.hpp 25 | /// @date 2008-10-24 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_log_base GLM_GTX_log_base: Log with base 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Logarithm for any base. base can be a vector or a scalar. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_log_base 39 | #define GLM_GTX_log_base GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_log_base extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_log_base 51 | /// @{ 52 | 53 | //! Logarithm for any base. 54 | //! From GLM_GTX_log_base. 55 | template 56 | genType log( 57 | genType const & x, 58 | genType const & base); 59 | 60 | /// @} 61 | }//namespace glm 62 | 63 | #include "log_base.inl" 64 | 65 | #endif//GLM_GTX_log_base 66 | -------------------------------------------------------------------------------- /include/glm/gtx/log_base.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2008-10-24 5 | // Updated : 2008-10-24 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/log_base.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | #include "../core/_vectorize.hpp" 11 | 12 | namespace glm 13 | { 14 | template 15 | GLM_FUNC_QUALIFIER genType log( 16 | genType const & x, 17 | genType const & base) 18 | { 19 | assert(x != genType(0)); 20 | 21 | return glm::log(x) / glm::log(base); 22 | } 23 | 24 | VECTORIZE_VEC_SCA(log) 25 | VECTORIZE_VEC_VEC(log) 26 | }//namespace glm 27 | -------------------------------------------------------------------------------- /include/glm/gtx/matrix_cross_product.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_matrix_cross_product 24 | /// @file glm/gtx/matrix_cross_product.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_extented_min_max (dependence) 30 | /// 31 | /// @defgroup gtx_matrix_cross_product GLM_GTX_matrix_cross_product: Cross product matrix form 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Build cross product matrices 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_matrix_cross_product 40 | #define GLM_GTX_matrix_cross_product GLM_VERSION 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 46 | # pragma message("GLM: GLM_GTX_matrix_cross_product extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_matrix_cross_product 52 | /// @{ 53 | 54 | //! Build a cross product matrix. 55 | //! From GLM_GTX_matrix_cross_product extension. 56 | template 57 | detail::tmat3x3 matrixCross3( 58 | detail::tvec3 const & x); 59 | 60 | //! Build a cross product matrix. 61 | //! From GLM_GTX_matrix_cross_product extension. 62 | template 63 | detail::tmat4x4 matrixCross4( 64 | detail::tvec3 const & x); 65 | 66 | /// @} 67 | }//namespace glm 68 | 69 | #include "matrix_cross_product.inl" 70 | 71 | #endif//GLM_GTX_matrix_cross_product 72 | -------------------------------------------------------------------------------- /include/glm/gtx/matrix_cross_product.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2005-12-21 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/matrix_cross_product.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tmat3x3 matrixCross3 14 | ( 15 | detail::tvec3 const & x 16 | ) 17 | { 18 | detail::tmat3x3 Result(T(0)); 19 | Result[0][1] = x.z; 20 | Result[1][0] = -x.z; 21 | Result[0][2] = -x.y; 22 | Result[2][0] = x.y; 23 | Result[1][2] = x.x; 24 | Result[2][1] = -x.x; 25 | return Result; 26 | } 27 | 28 | template 29 | GLM_FUNC_QUALIFIER detail::tmat4x4 matrixCross4 30 | ( 31 | detail::tvec3 const & x 32 | ) 33 | { 34 | detail::tmat4x4 Result(T(0)); 35 | Result[0][1] = x.z; 36 | Result[1][0] = -x.z; 37 | Result[0][2] = -x.y; 38 | Result[2][0] = x.y; 39 | Result[1][2] = x.x; 40 | Result[2][1] = -x.x; 41 | return Result; 42 | } 43 | 44 | }//namespace glm 45 | -------------------------------------------------------------------------------- /include/glm/gtx/matrix_interpolation.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_matrix_interpolation 24 | /// @file glm/gtx/matrix_interpolation.hpp 25 | /// @date 2011-03-05 / 2011-06-07 26 | /// @author Ghenadii Ursachi (the.asteroth@gmail.com) 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_matrix_interpolation GLM_GTX_matrix_interpolation: Rotation and translation matrix interpolation 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Allows to directly interpolate two exiciting matrices. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_matrix_interpolation 39 | #define GLM_GTX_matrix_interpolation GLM_VERSION 40 | 41 | // Dependency: 42 | //#include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_matrix_interpolation extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_matrix_interpolation 51 | /// @{ 52 | 53 | //! Get the axis and angle of the rotation from a matrix. 54 | //! From GLM_GTX_matrix_interpolation extension. 55 | template 56 | void axisAngle( 57 | detail::tmat4x4 const & mat, 58 | detail::tvec3 & axis, 59 | T & angle); 60 | 61 | //! Build a matrix from axis and angle. 62 | //! From GLM_GTX_matrix_interpolation extension. 63 | template 64 | detail::tmat4x4 axisAngleMatrix( 65 | detail::tvec3 const & axis, 66 | T const angle); 67 | 68 | //! Build a interpolation of 4 * 4 matrixes. 69 | //! From GLM_GTX_matrix_interpolation extension. 70 | //! Warning! works only with rotation and/or translation matrixes, scale will generate unexpected results. 71 | template 72 | detail::tmat4x4 interpolate( 73 | detail::tmat4x4 const & m1, 74 | detail::tmat4x4 const & m2, 75 | T const delta); 76 | 77 | /// @} 78 | }//namespace glm 79 | 80 | #include "matrix_interpolation.inl" 81 | 82 | #endif//GLM_GTX_matrix_interpolation 83 | -------------------------------------------------------------------------------- /include/glm/gtx/matrix_operation.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2009-08-29 5 | // Updated : 2009-08-29 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/matrix_operation.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tmat2x2 diagonal2x2 14 | ( 15 | detail::tvec2 const & v 16 | ) 17 | { 18 | detail::tmat2x2 Result(valType(1)); 19 | Result[0][0] = v[0]; 20 | Result[1][1] = v[1]; 21 | return Result; 22 | } 23 | 24 | template 25 | GLM_FUNC_QUALIFIER detail::tmat2x3 diagonal2x3 26 | ( 27 | detail::tvec2 const & v 28 | ) 29 | { 30 | detail::tmat2x3 Result(valType(1)); 31 | Result[0][0] = v[0]; 32 | Result[1][1] = v[1]; 33 | return Result; 34 | } 35 | 36 | template 37 | GLM_FUNC_QUALIFIER detail::tmat2x4 diagonal2x4 38 | ( 39 | detail::tvec2 const & v 40 | ) 41 | { 42 | detail::tmat2x4 Result(valType(1)); 43 | Result[0][0] = v[0]; 44 | Result[1][1] = v[1]; 45 | return Result; 46 | } 47 | 48 | template 49 | GLM_FUNC_QUALIFIER detail::tmat3x2 diagonal3x2 50 | ( 51 | detail::tvec2 const & v 52 | ) 53 | { 54 | detail::tmat3x2 Result(valType(1)); 55 | Result[0][0] = v[0]; 56 | Result[1][1] = v[1]; 57 | return Result; 58 | } 59 | 60 | template 61 | GLM_FUNC_QUALIFIER detail::tmat3x3 diagonal3x3 62 | ( 63 | detail::tvec3 const & v 64 | ) 65 | { 66 | detail::tmat3x3 Result(valType(1)); 67 | Result[0][0] = v[0]; 68 | Result[1][1] = v[1]; 69 | Result[2][2] = v[2]; 70 | return Result; 71 | } 72 | 73 | template 74 | GLM_FUNC_QUALIFIER detail::tmat3x4 diagonal3x4 75 | ( 76 | detail::tvec3 const & v 77 | ) 78 | { 79 | detail::tmat3x4 Result(valType(1)); 80 | Result[0][0] = v[0]; 81 | Result[1][1] = v[1]; 82 | Result[2][2] = v[2]; 83 | return Result; 84 | } 85 | 86 | template 87 | GLM_FUNC_QUALIFIER detail::tmat4x4 diagonal4x4 88 | ( 89 | detail::tvec4 const & v 90 | ) 91 | { 92 | detail::tmat4x4 Result(valType(1)); 93 | Result[0][0] = v[0]; 94 | Result[1][1] = v[1]; 95 | Result[2][2] = v[2]; 96 | Result[3][3] = v[3]; 97 | return Result; 98 | } 99 | 100 | template 101 | GLM_FUNC_QUALIFIER detail::tmat4x3 diagonal4x3 102 | ( 103 | detail::tvec3 const & v 104 | ) 105 | { 106 | detail::tmat4x3 Result(valType(1)); 107 | Result[0][0] = v[0]; 108 | Result[1][1] = v[1]; 109 | Result[2][2] = v[2]; 110 | return Result; 111 | } 112 | 113 | template 114 | GLM_FUNC_QUALIFIER detail::tmat4x2 diagonal4x2 115 | ( 116 | detail::tvec2 const & v 117 | ) 118 | { 119 | detail::tmat4x2 Result(valType(1)); 120 | Result[0][0] = v[0]; 121 | Result[1][1] = v[1]; 122 | return Result; 123 | } 124 | }//namespace glm 125 | -------------------------------------------------------------------------------- /include/glm/gtx/mixed_product.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_mixed_product 24 | /// @file glm/gtx/mixed_product.hpp 25 | /// @date 2007-04-03 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_mixed_product GLM_GTX_mixed_producte: Mixed product 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Mixed product of 3 vectors. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_mixed_product 39 | #define GLM_GTX_mixed_product GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_mixed_product extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_mixed_product 51 | /// @{ 52 | 53 | /// @brief Mixed product of 3 vectors (from GLM_GTX_mixed_product extension) 54 | template 55 | valType mixedProduct( 56 | detail::tvec3 const & v1, 57 | detail::tvec3 const & v2, 58 | detail::tvec3 const & v3); 59 | 60 | /// @} 61 | }// namespace glm 62 | 63 | #include "mixed_product.inl" 64 | 65 | #endif//GLM_GTX_mixed_product 66 | -------------------------------------------------------------------------------- /include/glm/gtx/mixed_product.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-04-03 5 | // Updated : 2008-09-17 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/mixed_product.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER valType mixedProduct 14 | ( 15 | detail::tvec3 const & v1, 16 | detail::tvec3 const & v2, 17 | detail::tvec3 const & v3 18 | ) 19 | { 20 | return dot(cross(v1, v2), v3); 21 | } 22 | }//namespace glm 23 | -------------------------------------------------------------------------------- /include/glm/gtx/multiple.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_multiple 24 | /// @file glm/gtx/multiple.hpp 25 | /// @date 2009-10-26 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_extented_min_max (dependence) 30 | /// 31 | /// @defgroup gtx_multiple GLM_GTX_multiple: Multiples 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Find the closest number of a number multiple of other number. 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_multiple 40 | #define GLM_GTX_multiple GLM_VERSION 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 46 | # pragma message("GLM: GLM_GTX_multiple extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_multiple 52 | /// @{ 53 | 54 | //! Higher Multiple number of Source. 55 | //! From GLM_GTX_multiple extension. 56 | template 57 | genType higherMultiple( 58 | genType const & Source, 59 | genType const & Multiple); 60 | 61 | //! Lower Multiple number of Source. 62 | //! From GLM_GTX_multiple extension. 63 | template 64 | genType lowerMultiple( 65 | genType const & Source, 66 | genType const & Multiple); 67 | 68 | /// @} 69 | }//namespace glm 70 | 71 | #include "multiple.inl" 72 | 73 | #endif//GLM_GTX_multiple 74 | -------------------------------------------------------------------------------- /include/glm/gtx/multiple.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2009-10-26 5 | // Updated : 2011-06-07 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/multiple.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | // Dependency: 10 | // - GLM core 11 | /////////////////////////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "../core/_vectorize.hpp" 14 | 15 | namespace glm 16 | { 17 | ////////////////////// 18 | // higherMultiple 19 | 20 | template 21 | GLM_FUNC_QUALIFIER genType higherMultiple 22 | ( 23 | genType const & Source, 24 | genType const & Multiple 25 | ) 26 | { 27 | genType Tmp = Source % Multiple; 28 | return Tmp ? Source + Multiple - Tmp : Source; 29 | } 30 | 31 | template <> 32 | GLM_FUNC_QUALIFIER detail::half higherMultiple 33 | ( 34 | detail::half const & SourceH, 35 | detail::half const & MultipleH 36 | ) 37 | { 38 | float Source = SourceH.toFloat(); 39 | float Multiple = MultipleH.toFloat(); 40 | 41 | int Tmp = int(float(Source)) % int(Multiple); 42 | return detail::half(Tmp ? Source + Multiple - float(Tmp) : Source); 43 | } 44 | 45 | template <> 46 | GLM_FUNC_QUALIFIER float higherMultiple 47 | ( 48 | float const & Source, 49 | float const & Multiple 50 | ) 51 | { 52 | int Tmp = int(Source) % int(Multiple); 53 | return Tmp ? Source + Multiple - float(Tmp) : Source; 54 | } 55 | 56 | template <> 57 | GLM_FUNC_QUALIFIER double higherMultiple 58 | ( 59 | double const & Source, 60 | double const & Multiple 61 | ) 62 | { 63 | long Tmp = long(Source) % long(Multiple); 64 | return Tmp ? Source + Multiple - double(Tmp) : Source; 65 | } 66 | 67 | VECTORIZE_VEC_VEC(higherMultiple) 68 | 69 | ////////////////////// 70 | // lowerMultiple 71 | 72 | template 73 | GLM_FUNC_QUALIFIER genType lowerMultiple 74 | ( 75 | genType const & Source, 76 | genType const & Multiple 77 | ) 78 | { 79 | genType Tmp = Source % Multiple; 80 | return Tmp ? Source - Tmp : Source; 81 | } 82 | 83 | template <> 84 | GLM_FUNC_QUALIFIER detail::half lowerMultiple 85 | ( 86 | detail::half const & SourceH, 87 | detail::half const & MultipleH 88 | ) 89 | { 90 | float Source = SourceH.toFloat(); 91 | float Multiple = MultipleH.toFloat(); 92 | 93 | int Tmp = int(float(Source)) % int(float(Multiple)); 94 | return detail::half(Tmp ? Source - float(Tmp) : Source); 95 | } 96 | 97 | template <> 98 | GLM_FUNC_QUALIFIER float lowerMultiple 99 | ( 100 | float const & Source, 101 | float const & Multiple 102 | ) 103 | { 104 | int Tmp = int(Source) % int(Multiple); 105 | return Tmp ? Source - float(Tmp) : Source; 106 | } 107 | 108 | template <> 109 | GLM_FUNC_QUALIFIER double lowerMultiple 110 | ( 111 | double const & Source, 112 | double const & Multiple 113 | ) 114 | { 115 | long Tmp = long(Source) % long(Multiple); 116 | return Tmp ? Source - double(Tmp) : Source; 117 | } 118 | 119 | VECTORIZE_VEC_VEC(lowerMultiple) 120 | }//namespace glm 121 | -------------------------------------------------------------------------------- /include/glm/gtx/noise.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_noise 24 | /// @file glm/gtx/noise.hpp 25 | /// @date 2011-04-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_noise GLM_GTX_noise: Procedural noise functions 31 | /// @ingroup gtx 32 | /// 33 | /// Defines 2D, 3D and 4D procedural noise functions 34 | /// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": 35 | /// https://github.com/ashima/webgl-noise 36 | /// Following Stefan Gustavson's paper "Simplex noise demystified": 37 | /// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf 38 | /// Defines the half-precision floating-point type, along with various typedefs for vectors and matrices. 39 | /// need to be included to use these functionalities. 40 | /////////////////////////////////////////////////////////////////////////////////// 41 | 42 | #ifndef GLM_GTX_noise 43 | #define GLM_GTX_noise GLM_VERSION 44 | 45 | // Dependency: 46 | #include "../glm.hpp" 47 | #include "../gtc/noise.hpp" 48 | 49 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 50 | # pragma message("GLM: GLM_GTX_noise extension included") 51 | #endif 52 | 53 | namespace glm 54 | { 55 | /// @addtogroup gtx_noise 56 | /// @{ 57 | 58 | /// @} 59 | }//namespace glm 60 | 61 | #include "noise.inl" 62 | 63 | #endif//glm_gtx_noise 64 | -------------------------------------------------------------------------------- /include/glm/gtx/noise.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": 5 | // https://github.com/ashima/webgl-noise 6 | // Following Stefan Gustavson's paper "Simplex noise demystified": 7 | // http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | // Created : 2011-04-21 10 | // Updated : 2011-04-21 11 | // Licence : This source is under MIT License 12 | // File : glm/gtx/noise.inl 13 | /////////////////////////////////////////////////////////////////////////////////////////////////// 14 | // Dependency: 15 | // - GLM core 16 | /////////////////////////////////////////////////////////////////////////////////////////////////// 17 | 18 | namespace glm{ 19 | 20 | }//namespace glm 21 | -------------------------------------------------------------------------------- /include/glm/gtx/normal.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_normal 24 | /// @file glm/gtx/normal.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_extented_min_max (dependence) 30 | /// 31 | /// @defgroup gtx_normal GLM_GTX_normal: Compute normals 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Compute the normal of a triangle. 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_normal 40 | #define GLM_GTX_normal GLM_VERSION 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 46 | # pragma message("GLM: GLM_GTX_normal extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_normal 52 | /// @{ 53 | 54 | //! Computes triangle normal from triangle points. 55 | //! From GLM_GTX_normal extension. 56 | template 57 | detail::tvec3 triangleNormal( 58 | detail::tvec3 const & p1, 59 | detail::tvec3 const & p2, 60 | detail::tvec3 const & p3); 61 | 62 | /// @} 63 | }//namespace glm 64 | 65 | #include "normal.inl" 66 | 67 | #endif//GLM_GTX_normal 68 | -------------------------------------------------------------------------------- /include/glm/gtx/normal.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2011-06-07 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/normal.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tvec3 triangleNormal 14 | ( 15 | detail::tvec3 const & p1, 16 | detail::tvec3 const & p2, 17 | detail::tvec3 const & p3 18 | ) 19 | { 20 | return normalize(cross(p1 - p2, p1 - p3)); 21 | } 22 | }//namespace glm 23 | -------------------------------------------------------------------------------- /include/glm/gtx/normalize_dot.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_normalize_dot 24 | /// @file glm/gtx/normalize_dot.hpp 25 | /// @date 2007-09-28 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_fast_square_root (dependence) 30 | /// 31 | /// @defgroup gtx_normalize_dot GLM_GTX_normalize_dot: Normalize dot product 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Dot product of vectors that need to be normalize with a single square root. 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_normalize_dot 40 | #define GLM_GTX_normalize_dot GLM_VERSION 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | #include "../gtx/fast_square_root.hpp" 45 | 46 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 47 | # pragma message("GLM: GLM_GTX_normalize_dot extension included") 48 | #endif 49 | 50 | namespace glm 51 | { 52 | /// @addtogroup gtx_normalize_dot 53 | /// @{ 54 | 55 | //! Normalize parameters and returns the dot product of x and y. 56 | //! It's faster that dot(normalize(x), normalize(y)). 57 | //! From GLM_GTX_normalize_dot extension. 58 | template 59 | typename genType::value_type normalizeDot( 60 | genType const & x, 61 | genType const & y); 62 | 63 | //! Normalize parameters and returns the dot product of x and y. 64 | //! Faster that dot(fastNormalize(x), fastNormalize(y)). 65 | //! From GLM_GTX_normalize_dot extension. 66 | template 67 | typename genType::value_type fastNormalizeDot( 68 | genType const & x, 69 | genType const & y); 70 | 71 | /// @} 72 | }//namespace glm 73 | 74 | #include "normalize_dot.inl" 75 | 76 | #endif//GLM_GTX_normalize_dot 77 | -------------------------------------------------------------------------------- /include/glm/gtx/normalize_dot.inl: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | ////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-09-28 5 | // Updated : 2008-10-07 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/normalize_dot.inl 8 | ////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER genType normalizeDot 14 | ( 15 | genType const & x, 16 | genType const & y 17 | ) 18 | { 19 | return 20 | glm::dot(x, y) * 21 | glm::inversesqrt(glm::dot(x, x) * 22 | glm::dot(y, y)); 23 | } 24 | 25 | template 26 | GLM_FUNC_QUALIFIER valType normalizeDot 27 | ( 28 | detail::tvec2 const & x, 29 | detail::tvec2 const & y 30 | ) 31 | { 32 | return 33 | glm::dot(x, y) * 34 | glm::inversesqrt(glm::dot(x, x) * 35 | glm::dot(y, y)); 36 | } 37 | 38 | template 39 | GLM_FUNC_QUALIFIER valType normalizeDot 40 | ( 41 | detail::tvec3 const & x, 42 | detail::tvec3 const & y 43 | ) 44 | { 45 | return 46 | glm::dot(x, y) * 47 | glm::inversesqrt(glm::dot(x, x) * 48 | glm::dot(y, y)); 49 | } 50 | 51 | template 52 | GLM_FUNC_QUALIFIER valType normalizeDot 53 | ( 54 | detail::tvec4 const & x, 55 | detail::tvec4 const & y 56 | ) 57 | { 58 | return 59 | glm::dot(x, y) * 60 | glm::inversesqrt(glm::dot(x, x) * 61 | glm::dot(y, y)); 62 | } 63 | 64 | template 65 | GLM_FUNC_QUALIFIER genType fastNormalizeDot 66 | ( 67 | genType const & x, 68 | genType const & y 69 | ) 70 | { 71 | return 72 | glm::dot(x, y) * 73 | fastInverseSqrt(glm::dot(x, x) * 74 | glm::dot(y, y)); 75 | } 76 | 77 | template 78 | GLM_FUNC_QUALIFIER valType fastNormalizeDot 79 | ( 80 | detail::tvec2 const & x, 81 | detail::tvec2 const & y 82 | ) 83 | { 84 | return 85 | glm::dot(x, y) * 86 | fastInverseSqrt(glm::dot(x, x) * 87 | glm::dot(y, y)); 88 | } 89 | 90 | template 91 | GLM_FUNC_QUALIFIER valType fastNormalizeDot 92 | ( 93 | detail::tvec3 const & x, 94 | detail::tvec3 const & y 95 | ) 96 | { 97 | return 98 | glm::dot(x, y) * 99 | fastInverseSqrt(glm::dot(x, x) * 100 | glm::dot(y, y)); 101 | } 102 | 103 | template 104 | GLM_FUNC_QUALIFIER valType fastNormalizeDot 105 | ( 106 | detail::tvec4 const & x, 107 | detail::tvec4 const & y 108 | ) 109 | { 110 | return 111 | glm::dot(x, y) * 112 | fastInverseSqrt(glm::dot(x, x) * 113 | glm::dot(y, y)); 114 | } 115 | }//namespace glm 116 | -------------------------------------------------------------------------------- /include/glm/gtx/number_precision.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-05-10 5 | // Updated : 2007-05-10 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/number_precision.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /include/glm/gtx/ocl_type.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aovoc/CornellBox/f1198485f41c01715a4766865a5256938c786d60/include/glm/gtx/ocl_type.inl -------------------------------------------------------------------------------- /include/glm/gtx/optimum_pow.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2005-12-27 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/optimum_pow.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER genType pow2(const genType& x) 14 | { 15 | return x * x; 16 | } 17 | 18 | template 19 | GLM_FUNC_QUALIFIER genType pow3(const genType& x) 20 | { 21 | return x * x * x; 22 | } 23 | 24 | template 25 | GLM_FUNC_QUALIFIER genType pow4(const genType& x) 26 | { 27 | return x * x * x * x; 28 | } 29 | 30 | GLM_FUNC_QUALIFIER bool powOfTwo(int x) 31 | { 32 | return !(x & (x - 1)); 33 | } 34 | 35 | GLM_FUNC_QUALIFIER detail::tvec2 powOfTwo(const detail::tvec2& x) 36 | { 37 | return detail::tvec2( 38 | powOfTwo(x.x), 39 | powOfTwo(x.y)); 40 | } 41 | 42 | GLM_FUNC_QUALIFIER detail::tvec3 powOfTwo(const detail::tvec3& x) 43 | { 44 | return detail::tvec3( 45 | powOfTwo(x.x), 46 | powOfTwo(x.y), 47 | powOfTwo(x.z)); 48 | } 49 | 50 | GLM_FUNC_QUALIFIER detail::tvec4 powOfTwo(const detail::tvec4& x) 51 | { 52 | return detail::tvec4( 53 | powOfTwo(x.x), 54 | powOfTwo(x.y), 55 | powOfTwo(x.z), 56 | powOfTwo(x.w)); 57 | } 58 | }//namespace glm 59 | -------------------------------------------------------------------------------- /include/glm/gtx/orthonormalize.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_orthonormalize 24 | /// @file glm/gtx/orthonormalize.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_extented_min_max (dependence) 30 | /// 31 | /// @defgroup gtx_orthonormalize GLM_GTX_orthonormalize: Orthonormalize 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Orthonormalize matrices. 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_orthonormalize 40 | #define GLM_GTX_orthonormalize GLM_VERSION 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 46 | # pragma message("GLM: GLM_GTX_orthonormalize extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_orthonormalize 52 | /// @{ 53 | 54 | //! Returns the orthonormalized matrix of m. 55 | //! From GLM_GTX_orthonormalize extension. 56 | template 57 | detail::tmat3x3 orthonormalize( 58 | const detail::tmat3x3& m); 59 | 60 | //! Orthonormalizes x according y. 61 | //! From GLM_GTX_orthonormalize extension. 62 | template 63 | detail::tvec3 orthonormalize( 64 | const detail::tvec3& x, 65 | const detail::tvec3& y); 66 | 67 | /// @} 68 | }//namespace glm 69 | 70 | #include "orthonormalize.inl" 71 | 72 | #endif//GLM_GTX_orthonormalize 73 | -------------------------------------------------------------------------------- /include/glm/gtx/orthonormalize.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2005-12-21 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/orthonormalize.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tmat3x3 orthonormalize 14 | ( 15 | const detail::tmat3x3& m 16 | ) 17 | { 18 | detail::tmat3x3 r = m; 19 | 20 | r[0] = normalize(r[0]); 21 | 22 | float d0 = dot(r[0], r[1]); 23 | r[1] -= r[0] * d0; 24 | r[1] = normalize(r[1]); 25 | 26 | float d1 = dot(r[1], r[2]); 27 | d0 = dot(r[0], r[2]); 28 | r[2] -= r[0] * d0 + r[1] * d1; 29 | r[2] = normalize(r[2]); 30 | 31 | return r; 32 | } 33 | 34 | template 35 | GLM_FUNC_QUALIFIER detail::tvec3 orthonormalize 36 | ( 37 | const detail::tvec3& x, 38 | const detail::tvec3& y 39 | ) 40 | { 41 | return normalize(x - y * dot(y, x)); 42 | } 43 | }//namespace glm 44 | -------------------------------------------------------------------------------- /include/glm/gtx/perpendicular.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_perpendicular 24 | /// @file glm/gtx/perpendicular.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_projection (dependence) 30 | /// 31 | /// @defgroup gtx_perpendicular GLM_GTX_perpendicular: Perpendicular 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Perpendicular of a vector from other one 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_perpendicular 40 | #define GLM_GTX_perpendicular GLM_VERSION 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | #include "../gtx/projection.hpp" 45 | 46 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 47 | # pragma message("GLM: GLM_GTX_perpendicular extension included") 48 | #endif 49 | 50 | namespace glm 51 | { 52 | /// @addtogroup gtx_perpendicular 53 | /// @{ 54 | 55 | //! Projects x a perpendicular axis of Normal. 56 | //! From GLM_GTX_perpendicular extension. 57 | template 58 | vecType perp( 59 | vecType const & x, 60 | vecType const & Normal); 61 | 62 | /// @} 63 | }//namespace glm 64 | 65 | #include "perpendicular.inl" 66 | 67 | #endif//GLM_GTX_perpendicular 68 | -------------------------------------------------------------------------------- /include/glm/gtx/perpendicular.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2009-03-06 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/perpendicular.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER vecType perp 14 | ( 15 | vecType const & x, 16 | vecType const & Normal 17 | ) 18 | { 19 | return x - proj(x, Normal); 20 | } 21 | }//namespace glm 22 | -------------------------------------------------------------------------------- /include/glm/gtx/polar_coordinates.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_polar_coordinates 24 | /// @file glm/gtx/polar_coordinates.hpp 25 | /// @date 2007-03-06 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_polar_coordinates GLM_GTX_polar_coordinates: Polar coordinates 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Conversion from Euclidean space to polar space and revert. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_polar_coordinates 39 | #define GLM_GTX_polar_coordinates GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_polar_coordinates extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_polar_coordinates 51 | /// @{ 52 | 53 | //! Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude. 54 | //! From GLM_GTX_polar_coordinates extension. 55 | template 56 | detail::tvec3 polar( 57 | detail::tvec3 const & euclidean); 58 | 59 | //! Convert Polar to Euclidean coordinates. 60 | //! From GLM_GTX_polar_coordinates extension. 61 | template 62 | detail::tvec3 euclidean( 63 | detail::tvec3 const & polar); 64 | 65 | /// @} 66 | }//namespace glm 67 | 68 | #include "polar_coordinates.inl" 69 | 70 | #endif//GLM_GTX_polar_coordinates 71 | -------------------------------------------------------------------------------- /include/glm/gtx/polar_coordinates.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-03-06 5 | // Updated : 2009-05-01 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/polar_coordinates.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tvec3 polar 14 | ( 15 | detail::tvec3 const & euclidean 16 | ) 17 | { 18 | T length = length(euclidean); 19 | detail::tvec3 tmp = euclidean / length; 20 | T xz_dist = sqrt(tmp.x * tmp.x + tmp.z * tmp.z); 21 | 22 | return detail::tvec3( 23 | degrees(atan(xz_dist, tmp.y)), // latitude 24 | degrees(atan(tmp.x, tmp.z)), // longitude 25 | xz_dist); // xz distance 26 | } 27 | 28 | template 29 | GLM_FUNC_QUALIFIER detail::tvec3 euclidean 30 | ( 31 | detail::tvec3 const & polar 32 | ) 33 | { 34 | T latitude = radians(polar.x); 35 | T longitude = radians(polar.y); 36 | return detail::tvec3( 37 | cos(latitude) * sin(longitude), 38 | sin(latitude), 39 | cos(latitude) * cos(longitude)); 40 | } 41 | 42 | }//namespace glm 43 | -------------------------------------------------------------------------------- /include/glm/gtx/projection.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_projection 24 | /// @file glm/gtx/projection.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_projection GLM_GTX_projection: Projection 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Projection of a vector to other one 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_projection 39 | #define GLM_GTX_projection GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_projection extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_projection 51 | /// @{ 52 | 53 | //! Projects x on Normal. 54 | //! From GLM_GTX_projection extension. 55 | template 56 | vecType proj( 57 | vecType const & x, 58 | vecType const & Normal); 59 | 60 | /// @} 61 | }//namespace glm 62 | 63 | #include "projection.inl" 64 | 65 | #endif//GLM_GTX_projection 66 | -------------------------------------------------------------------------------- /include/glm/gtx/projection.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2009-03-06 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/projection.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER vecType proj 14 | ( 15 | vecType const & x, 16 | vecType const & Normal 17 | ) 18 | { 19 | return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal; 20 | } 21 | }//namespace glm 22 | -------------------------------------------------------------------------------- /include/glm/gtx/raw_data (1).hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_raw_data 24 | /// @file glm/gtx/raw_data.hpp 25 | /// @date 2008-11-19 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_raw_data GLM_GTX_raw_data: Raw data 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Projection of a vector to other one 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_raw_data 39 | #define GLM_GTX_raw_data GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | #include "../gtc/type_precision.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 46 | # pragma message("GLM: GLM_GTX_raw_data extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_raw_data 52 | /// @{ 53 | 54 | //! Type for byte numbers. 55 | //! From GLM_GTX_raw_data extension. 56 | typedef uint8 byte; 57 | 58 | //! Type for word numbers. 59 | //! From GLM_GTX_raw_data extension. 60 | typedef uint16 word; 61 | 62 | //! Type for dword numbers. 63 | //! From GLM_GTX_raw_data extension. 64 | typedef uint32 dword; 65 | 66 | //! Type for qword numbers. 67 | //! From GLM_GTX_raw_data extension. 68 | typedef uint64 qword; 69 | 70 | /// @} 71 | }// namespace glm 72 | 73 | #include "raw_data.inl" 74 | 75 | #endif//GLM_GTX_raw_data 76 | -------------------------------------------------------------------------------- /include/glm/gtx/raw_data.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_raw_data 24 | /// @file glm/gtx/raw_data.hpp 25 | /// @date 2008-11-19 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_raw_data GLM_GTX_raw_data: Raw data 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Projection of a vector to other one 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_raw_data 39 | #define GLM_GTX_raw_data GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | #include "../gtc/type_precision.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 46 | # pragma message("GLM: GLM_GTX_raw_data extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_raw_data 52 | /// @{ 53 | 54 | //! Type for byte numbers. 55 | //! From GLM_GTX_raw_data extension. 56 | typedef uint8 byte; 57 | 58 | //! Type for word numbers. 59 | //! From GLM_GTX_raw_data extension. 60 | typedef uint16 word; 61 | 62 | //! Type for dword numbers. 63 | //! From GLM_GTX_raw_data extension. 64 | typedef uint32 dword; 65 | 66 | //! Type for qword numbers. 67 | //! From GLM_GTX_raw_data extension. 68 | typedef uint64 qword; 69 | 70 | /// @} 71 | }// namespace glm 72 | 73 | #include "raw_data.inl" 74 | 75 | #endif//GLM_GTX_raw_data 76 | -------------------------------------------------------------------------------- /include/glm/gtx/raw_data.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2008-11-19 5 | // Updated : 2008-11-19 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/raw_data.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | // Dependency: 10 | // - GLM core 11 | /////////////////////////////////////////////////////////////////////////////////////////////////// 12 | -------------------------------------------------------------------------------- /include/glm/gtx/simd_vec4.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aovoc/CornellBox/f1198485f41c01715a4766865a5256938c786d60/include/glm/gtx/simd_vec4.hpp -------------------------------------------------------------------------------- /include/glm/gtx/simplex (1).hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2011-04-09 5 | // Updated : 2011-04-09 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/simplex.hpp 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | // Dependency: 10 | // - GLM core 11 | /////////////////////////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef glm_gtx_simplex 14 | #define glm_gtx_simplex 15 | 16 | // Dependency: 17 | #include "../glm.hpp" 18 | 19 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 20 | # pragma message("GLM: GLM_GTX_simplex extension included") 21 | #endif 22 | 23 | namespace glm{ 24 | namespace gtx{ 25 | namespace spline ///< GLM_GTX_simplex extension: Spline functions 26 | { 27 | /// \addtogroup gtx_spline 28 | ///@{ 29 | 30 | //! Return a point from a catmull rom curve. 31 | //! From GLM_GTX_spline extension. 32 | template 33 | genType catmullRom( 34 | genType const & v1, 35 | genType const & v2, 36 | genType const & v3, 37 | genType const & v4, 38 | typename genType::value_type const & s); 39 | 40 | //! Return a point from a hermite curve. 41 | //! From GLM_GTX_spline extension. 42 | template 43 | genType hermite( 44 | genType const & v1, 45 | genType const & t1, 46 | genType const & v2, 47 | genType const & t2, 48 | typename genType::value_type const & s); 49 | 50 | //! Return a point from a cubic curve. 51 | //! From GLM_GTX_spline extension. 52 | template 53 | genType cubic( 54 | genType const & v1, 55 | genType const & v2, 56 | genType const & v3, 57 | genType const & v4, 58 | typename genType::value_type const & s); 59 | 60 | /// @} 61 | }// namespace simplex 62 | }// namespace gtx 63 | }// namespace glm 64 | 65 | #include "simplex.inl" 66 | 67 | namespace glm{using namespace gtx::simplex;} 68 | 69 | #endif//glm_gtx_spline 70 | 71 | -------------------------------------------------------------------------------- /include/glm/gtx/simplex.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2011-04-09 5 | // Updated : 2011-04-09 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/simplex.hpp 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | // Dependency: 10 | // - GLM core 11 | /////////////////////////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef glm_gtx_simplex 14 | #define glm_gtx_simplex 15 | 16 | // Dependency: 17 | #include "../glm.hpp" 18 | 19 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 20 | # pragma message("GLM: GLM_GTX_simplex extension included") 21 | #endif 22 | 23 | namespace glm{ 24 | namespace gtx{ 25 | namespace spline ///< GLM_GTX_simplex extension: Spline functions 26 | { 27 | /// \addtogroup gtx_spline 28 | ///@{ 29 | 30 | //! Return a point from a catmull rom curve. 31 | //! From GLM_GTX_spline extension. 32 | template 33 | genType catmullRom( 34 | genType const & v1, 35 | genType const & v2, 36 | genType const & v3, 37 | genType const & v4, 38 | typename genType::value_type const & s); 39 | 40 | //! Return a point from a hermite curve. 41 | //! From GLM_GTX_spline extension. 42 | template 43 | genType hermite( 44 | genType const & v1, 45 | genType const & t1, 46 | genType const & v2, 47 | genType const & t2, 48 | typename genType::value_type const & s); 49 | 50 | //! Return a point from a cubic curve. 51 | //! From GLM_GTX_spline extension. 52 | template 53 | genType cubic( 54 | genType const & v1, 55 | genType const & v2, 56 | genType const & v3, 57 | genType const & v4, 58 | typename genType::value_type const & s); 59 | 60 | /// @} 61 | }// namespace simplex 62 | }// namespace gtx 63 | }// namespace glm 64 | 65 | #include "simplex.inl" 66 | 67 | namespace glm{using namespace gtx::simplex;} 68 | 69 | #endif//glm_gtx_spline 70 | 71 | -------------------------------------------------------------------------------- /include/glm/gtx/simplex.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aovoc/CornellBox/f1198485f41c01715a4766865a5256938c786d60/include/glm/gtx/simplex.inl -------------------------------------------------------------------------------- /include/glm/gtx/spline.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_spline 24 | /// @file glm/gtx/spline.hpp 25 | /// @date 2007-01-25 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_spline GLM_GTX_spline: Spline 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Spline functions 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_spline 39 | #define GLM_GTX_spline GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | #include "../gtx/optimum_pow.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 46 | # pragma message("GLM: GLM_GTX_spline extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_spline 52 | /// @{ 53 | 54 | //! Return a point from a catmull rom curve. 55 | //! From GLM_GTX_spline extension. 56 | template 57 | genType catmullRom( 58 | genType const & v1, 59 | genType const & v2, 60 | genType const & v3, 61 | genType const & v4, 62 | typename genType::value_type const & s); 63 | 64 | //! Return a point from a hermite curve. 65 | //! From GLM_GTX_spline extension. 66 | template 67 | genType hermite( 68 | genType const & v1, 69 | genType const & t1, 70 | genType const & v2, 71 | genType const & t2, 72 | typename genType::value_type const & s); 73 | 74 | //! Return a point from a cubic curve. 75 | //! From GLM_GTX_spline extension. 76 | template 77 | genType cubic( 78 | genType const & v1, 79 | genType const & v2, 80 | genType const & v3, 81 | genType const & v4, 82 | typename genType::value_type const & s); 83 | 84 | /// @} 85 | }//namespace glm 86 | 87 | #include "spline.inl" 88 | 89 | #endif//GLM_GTX_spline 90 | 91 | -------------------------------------------------------------------------------- /include/glm/gtx/spline.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-01-25 5 | // Updated : 2009-02-19 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/spline.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm{ 11 | 12 | template 13 | GLM_FUNC_QUALIFIER genType catmullRom 14 | ( 15 | genType const & v1, 16 | genType const & v2, 17 | genType const & v3, 18 | genType const & v4, 19 | typename genType::value_type const & s 20 | ) 21 | { 22 | typename genType::value_type s1 = s; 23 | typename genType::value_type s2 = pow2(s); 24 | typename genType::value_type s3 = pow3(s); 25 | 26 | typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s; 27 | typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2); 28 | typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s; 29 | typename genType::value_type f4 = s3 - s2; 30 | 31 | return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2); 32 | 33 | } 34 | 35 | template 36 | GLM_FUNC_QUALIFIER genType hermite 37 | ( 38 | genType const & v1, 39 | genType const & t1, 40 | genType const & v2, 41 | genType const & t2, 42 | typename genType::value_type const & s 43 | ) 44 | { 45 | typename genType::value_type s1 = s; 46 | typename genType::value_type s2 = pow2(s); 47 | typename genType::value_type s3 = pow3(s); 48 | 49 | typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1); 50 | typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2; 51 | typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s; 52 | typename genType::value_type f4 = s3 - s2; 53 | 54 | return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2; 55 | } 56 | 57 | template 58 | GLM_FUNC_QUALIFIER genType cubic 59 | ( 60 | genType const & v1, 61 | genType const & v2, 62 | genType const & v3, 63 | genType const & v4, 64 | typename genType::value_type const & s 65 | ) 66 | { 67 | return ((v1 * s + v2) * s + v3) * s + v4; 68 | } 69 | 70 | }//namespace glm 71 | -------------------------------------------------------------------------------- /include/glm/gtx/std_based_type.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_std_based_type 24 | /// @file glm/gtx/std_based_type.hpp 25 | /// @date 2008-06-08 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_extented_min_max (dependence) 30 | /// 31 | /// @defgroup gtx_std_based_type GLM_GTX_std_based_type: Add types based on STL 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Adds vector types based on STL value types. 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_std_based_type 39 | #define GLM_GTX_std_based_type GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | #include 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 46 | # pragma message("GLM: GLM_GTX_std_based_type extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_std_based_type 52 | /// @{ 53 | 54 | /// Vector type based of two std::size_t components. 55 | /// @see - GLM_GTX_std_based_type 56 | typedef detail::tvec2 size2; 57 | 58 | /// Vector type based of three std::size_t components. 59 | /// @see - GLM_GTX_std_based_type 60 | typedef detail::tvec3 size3; 61 | 62 | /// Vector type based of four std::size_t components. 63 | /// @see - GLM_GTX_std_based_type 64 | typedef detail::tvec4 size4; 65 | 66 | /// Vector type based of two std::size_t components. 67 | /// @see - GLM_GTX_std_based_type 68 | typedef detail::tvec2 size2_t; 69 | 70 | /// Vector type based of three std::size_t components. 71 | /// @see - GLM_GTX_std_based_type 72 | typedef detail::tvec3 size3_t; 73 | 74 | /// Vector type based of four std::size_t components. 75 | /// @see - GLM_GTX_std_based_type 76 | typedef detail::tvec4 size4_t; 77 | 78 | /// @} 79 | }//namespace glm 80 | 81 | #include "std_based_type.inl" 82 | 83 | #endif//GLM_GTX_std_based_type 84 | -------------------------------------------------------------------------------- /include/glm/gtx/std_based_type.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2008-06-08 5 | // Updated : 2008-06-08 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/std_based_type.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /include/glm/gtx/string_cast.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_string_cast 24 | /// @file glm/gtx/string_cast.hpp 25 | /// @date 2008-04-26 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtc_half_float (dependence) 30 | /// @see gtx_integer (dependence) 31 | /// @see gtx_quaternion (dependence) 32 | /// 33 | /// @defgroup gtx_string_cast GLM_GTX_string_cast: String cast 34 | /// @ingroup gtx 35 | /// 36 | /// @brief Setup strings for GLM type values 37 | /// 38 | /// need to be included to use these functionalities. 39 | /////////////////////////////////////////////////////////////////////////////////// 40 | 41 | #ifndef GLM_GTX_string_cast 42 | #define GLM_GTX_string_cast GLM_VERSION 43 | 44 | // Dependency: 45 | #include "../glm.hpp" 46 | #include "../gtc/half_float.hpp" 47 | #include "../gtx/integer.hpp" 48 | #include "../gtx/quaternion.hpp" 49 | #include 50 | 51 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 52 | # pragma message("GLM: GLM_GTX_string_cast extension included") 53 | #endif 54 | 55 | namespace glm 56 | { 57 | /// @addtogroup gtx_string_cast 58 | /// @{ 59 | 60 | /// Create a string from a GLM type value. 61 | /// From GLM_GTX_string_cast extension. 62 | template 63 | std::string to_string(genType const & x); 64 | 65 | /// @} 66 | }//namespace glm 67 | 68 | #include "string_cast.inl" 69 | 70 | #endif//GLM_GTX_string_cast 71 | -------------------------------------------------------------------------------- /include/glm/gtx/transform.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2009-04-29 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/transform.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tmat4x4 translate( 14 | T x, T y, T z) 15 | { 16 | return translate( 17 | detail::tmat4x4(1.0f), 18 | detail::tvec3(x, y , z)); 19 | } 20 | 21 | template 22 | GLM_FUNC_QUALIFIER detail::tmat4x4 translate( 23 | detail::tmat4x4 const & m, 24 | T x, T y, T z) 25 | { 26 | return translate( 27 | m, detail::tvec3(x, y , z)); 28 | } 29 | 30 | template 31 | GLM_FUNC_QUALIFIER detail::tmat4x4 translate( 32 | detail::tvec3 const & v) 33 | { 34 | return translate( 35 | detail::tmat4x4(1.0f), v); 36 | } 37 | 38 | template 39 | GLM_FUNC_QUALIFIER detail::tmat4x4 rotate( 40 | T angle, 41 | T x, T y, T z) 42 | { 43 | return rotate( 44 | detail::tmat4x4(1), angle, detail::tvec3(x, y, z)); 45 | } 46 | 47 | template 48 | GLM_FUNC_QUALIFIER detail::tmat4x4 rotate( 49 | T angle, 50 | detail::tvec3 const & v) 51 | { 52 | return rotate( 53 | detail::tmat4x4(1), angle, v); 54 | } 55 | 56 | template 57 | GLM_FUNC_QUALIFIER detail::tmat4x4 rotate( 58 | detail::tmat4x4 const & m, 59 | T angle, 60 | T x, T y, T z) 61 | { 62 | return rotate( 63 | m, angle, detail::tvec3(x, y, z)); 64 | } 65 | 66 | template 67 | GLM_FUNC_QUALIFIER detail::tmat4x4 scale(T x, T y, T z) 68 | { 69 | return scale( 70 | detail::tmat4x4(1), detail::tvec3(x, y, z)); 71 | } 72 | 73 | template 74 | GLM_FUNC_QUALIFIER detail::tmat4x4 scale( 75 | detail::tmat4x4 const & m, 76 | T x, T y, T z) 77 | { 78 | return scale( 79 | m, detail::tvec3(x, y, z)); 80 | } 81 | 82 | template 83 | GLM_FUNC_QUALIFIER detail::tmat4x4 scale( 84 | detail::tvec3 const & v) 85 | { 86 | return scale( 87 | detail::tmat4x4(1.0f), v); 88 | } 89 | 90 | }//namespace glm 91 | -------------------------------------------------------------------------------- /include/glm/gtx/unsigned_int.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /////////////////////////////////////////////////////////////////////////////////// 23 | 24 | #if(defined(GLM_MESSAGES)) 25 | # pragma message("GLM: GLM_GTX_unsigned_int extension is deprecated, include GLM_GTX_integer instead") 26 | #endif 27 | -------------------------------------------------------------------------------- /include/glm/gtx/unsigned_int.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-24 5 | // Updated : 2008-10-07 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/unsigned_int.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | 13 | }//namespace glm 14 | -------------------------------------------------------------------------------- /include/glm/gtx/vec1.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aovoc/CornellBox/f1198485f41c01715a4766865a5256938c786d60/include/glm/gtx/vec1.inl -------------------------------------------------------------------------------- /include/glm/gtx/vector_access.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_vector_access 24 | /// @file glm/gtx/vector_access.hpp 25 | /// @date 2006-01-16 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_vector_access GLM_GTX_vector_access: Vector access 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Function to set values to vectors 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_vector_access 39 | #define GLM_GTX_vector_access GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_vector_access extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_vector_access 51 | /// @{ 52 | 53 | //! Set values to a 2 components vector. 54 | //! From GLM_GTX_vector_access extension. 55 | template 56 | void set( 57 | detail::tvec2 & v, 58 | valType const & x, 59 | valType const & y); 60 | 61 | //! Set values to a 3 components vector. 62 | //! From GLM_GTX_vector_access extension. 63 | template 64 | void set( 65 | detail::tvec3 & v, 66 | valType const & x, 67 | valType const & y, 68 | valType const & z); 69 | 70 | //! Set values to a 4 components vector. 71 | //! From GLM_GTX_vector_access extension. 72 | template 73 | void set( 74 | detail::tvec4 & v, 75 | valType const & x, 76 | valType const & y, 77 | valType const & z, 78 | valType const & w); 79 | 80 | /// @} 81 | }//namespace glm 82 | 83 | #include "vector_access.inl" 84 | 85 | #endif//GLM_GTX_vector_access 86 | -------------------------------------------------------------------------------- /include/glm/gtx/vector_access.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2006-01-16 5 | // Updated : 2008-10-07 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/vector_access.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER void set 14 | ( 15 | detail::tvec2& v, 16 | valType const & x, 17 | valType const & y 18 | ) 19 | { 20 | v.x = x; 21 | v.y = y; 22 | } 23 | 24 | template 25 | GLM_FUNC_QUALIFIER void set 26 | ( 27 | detail::tvec3& v, 28 | valType const & x, 29 | valType const & y, 30 | valType const & z 31 | ) 32 | { 33 | v.x = x; 34 | v.y = y; 35 | v.z = z; 36 | } 37 | 38 | template 39 | GLM_FUNC_QUALIFIER void set 40 | ( 41 | detail::tvec4& v, 42 | valType const & x, 43 | valType const & y, 44 | valType const & z, 45 | valType const & w 46 | ) 47 | { 48 | v.x = x; 49 | v.y = y; 50 | v.z = z; 51 | v.w = w; 52 | } 53 | }//namespace glm 54 | -------------------------------------------------------------------------------- /include/glm/gtx/vector_angle.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_vector_angle 24 | /// @file glm/gtx/vector_angle.hpp 25 | /// @date 2005-12-30 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_quaternion (dependence) 30 | /// @see gtx_epsilon (dependence) 31 | /// 32 | /// @defgroup gtx_vector_angle GLM_GTX_vector_angle: Vector angle 33 | /// @ingroup gtx 34 | /// 35 | /// @brief Compute angle between vectors 36 | /// 37 | /// need to be included to use these functionalities. 38 | /////////////////////////////////////////////////////////////////////////////////// 39 | 40 | #ifndef GLM_GTX_vector_angle 41 | #define GLM_GTX_vector_angle GLM_VERSION 42 | 43 | // Dependency: 44 | #include "../glm.hpp" 45 | #include "../gtx/epsilon.hpp" 46 | #include "../gtx/quaternion.hpp" 47 | #include "../gtx/rotate_vector.hpp" 48 | 49 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 50 | # pragma message("GLM: GLM_GTX_vector_angle extension included") 51 | #endif 52 | 53 | namespace glm 54 | { 55 | /// @addtogroup gtx_vector_angle 56 | /// @{ 57 | 58 | //! Returns the absolute angle between two vectors 59 | //! Parameters need to be normalized. 60 | //! From GLM_GTX_vector_angle extension 61 | template 62 | GLM_FUNC_QUALIFIER typename vecType::value_type angle( 63 | vecType const & x, 64 | vecType const & y); 65 | 66 | //! Returns the oriented angle between two 2d vectors 67 | //! Parameters need to be normalized. 68 | //! From GLM_GTX_vector_angle extension. 69 | template 70 | GLM_FUNC_QUALIFIER T orientedAngle( 71 | detail::tvec2 const & x, 72 | detail::tvec2 const & y); 73 | 74 | //! Returns the oriented angle between two 3d vectors based from a reference axis. 75 | //! Parameters need to be normalized. 76 | //! From GLM_GTX_vector_angle extension. 77 | template 78 | GLM_FUNC_QUALIFIER T orientedAngle( 79 | detail::tvec3 const & x, 80 | detail::tvec3 const & y, 81 | detail::tvec3 const & ref); 82 | 83 | /// @} 84 | }// namespace glm 85 | 86 | #include "vector_angle.inl" 87 | 88 | #endif//GLM_GTX_vector_angle 89 | -------------------------------------------------------------------------------- /include/glm/gtx/vector_angle.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-30 5 | // Updated : 2008-09-29 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/vector_angle.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER typename genType::value_type angle 14 | ( 15 | genType const & x, 16 | genType const & y 17 | ) 18 | { 19 | return degrees(acos(dot(x, y))); 20 | } 21 | 22 | //! \todo epsilon is hard coded to 0.01 23 | template 24 | GLM_FUNC_QUALIFIER valType orientedAngle 25 | ( 26 | detail::tvec2 const & x, 27 | detail::tvec2 const & y 28 | ) 29 | { 30 | valType Angle = glm::degrees(acos(dot(x, y))); 31 | detail::tvec2 TransformedVector = glm::rotate(x, Angle); 32 | if(all(equalEpsilon(y, TransformedVector, valType(0.01)))) 33 | return Angle; 34 | else 35 | return -Angle; 36 | } 37 | 38 | template 39 | GLM_FUNC_QUALIFIER valType orientedAngle 40 | ( 41 | detail::tvec3 const & x, 42 | detail::tvec3 const & y, 43 | detail::tvec3 const & ref 44 | ) 45 | { 46 | valType Angle = glm::degrees(glm::acos(glm::dot(x, y))); 47 | 48 | if(glm::dot(ref, glm::cross(x, y)) < valType(0)) 49 | return -Angle; 50 | else 51 | return Angle; 52 | } 53 | }//namespace glm 54 | -------------------------------------------------------------------------------- /include/glm/gtx/verbose_operator.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_verbose_operator 24 | /// @file glm/gtx/verbose_operator.hpp 25 | /// @date 2007-05-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_verbose_operator GLM_GTX_verbose_operator: Verbose operator 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Use words to replace operators 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_verbose_operator 39 | #define GLM_GTX_verbose_operator GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_verbose_operator extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_verbose_operator 51 | /// @{ 52 | 53 | //! Addition of two values 54 | //! From GLM_GTX_verbose_operator extension. 55 | template 56 | genTypeT add(genTypeT const & a, genTypeU const & b); 57 | 58 | //! Substration of two values 59 | //! From GLM_GTX_verbose_operator extension. 60 | template 61 | genTypeT sub(genTypeT const & a, genTypeU const & b); 62 | 63 | //! Multiplication of two values 64 | //! From GLM_GTX_verbose_operator extension. 65 | template 66 | genTypeT mul(genTypeT const & a, genTypeU const & b); 67 | 68 | //! Division of two values 69 | //! From GLM_GTX_verbose_operator extension. 70 | template 71 | genTypeT div(genTypeT const & a, genTypeU const & b); 72 | 73 | //! Multiplication and addition of three values 74 | //! From GLM_GTX_verbose_operator extension. 75 | template 76 | genTypeT mad(genTypeT const & a, genTypeU const & b, genTypeV const & c); 77 | 78 | /// @} 79 | }// namespace glm 80 | 81 | #include "verbose_operator.inl" 82 | 83 | #endif//GLM_GTX_verbose_operator 84 | -------------------------------------------------------------------------------- /include/glm/gtx/verbose_operator.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2006-04-20 5 | // Updated : 2008-09-29 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/verbose_operator.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER genType add(genType const & a, genType const & b) 14 | { 15 | return a + b; 16 | } 17 | 18 | template 19 | GLM_FUNC_QUALIFIER genType sub(genType const & a, genType const & b) 20 | { 21 | return a - b; 22 | } 23 | 24 | template 25 | GLM_FUNC_QUALIFIER detail::tmat2x2 mul 26 | ( 27 | detail::tmat2x2 const & a, 28 | detail::tmat2x2 const & b 29 | ) 30 | { 31 | return a * b; 32 | } 33 | 34 | template 35 | GLM_FUNC_QUALIFIER detail::tmat3x3 mul 36 | ( 37 | detail::tmat3x3 const & a, 38 | detail::tmat3x3 const & b 39 | ) 40 | { 41 | return a * b; 42 | } 43 | 44 | template 45 | GLM_FUNC_QUALIFIER detail::tmat4x4 mul 46 | ( 47 | detail::tmat4x4 const & a, 48 | detail::tmat4x4 const & b 49 | ) 50 | { 51 | return a * b; 52 | } 53 | 54 | template 55 | GLM_FUNC_QUALIFIER detail::tvec2 mul 56 | ( 57 | detail::tmat2x2 const & m, 58 | detail::tvec2 const & v 59 | ) 60 | { 61 | return m * v; 62 | } 63 | 64 | template 65 | GLM_FUNC_QUALIFIER detail::tvec3 mul 66 | ( 67 | detail::tmat3x3 const & m, 68 | detail::tvec3 const & v) 69 | { 70 | return m * v; 71 | } 72 | 73 | template 74 | GLM_FUNC_QUALIFIER detail::tvec4 mul 75 | ( 76 | detail::tmat4x4 const & m, 77 | detail::tvec4 const & v 78 | ) 79 | { 80 | return m * v; 81 | } 82 | 83 | template 84 | GLM_FUNC_QUALIFIER detail::tvec2 mul 85 | ( 86 | detail::tvec2 const & v, 87 | detail::tmat2x2 const & m 88 | ) 89 | { 90 | return v * m; 91 | } 92 | 93 | template 94 | GLM_FUNC_QUALIFIER detail::tvec3 mul 95 | ( 96 | detail::tvec3 const & v, 97 | detail::tmat3x3 const & m 98 | ) 99 | { 100 | return v * m; 101 | } 102 | 103 | template 104 | GLM_FUNC_QUALIFIER detail::tvec4 mul 105 | ( 106 | detail::tvec4 const & v, 107 | detail::tmat4x4 const & m 108 | ) 109 | { 110 | return v * m; 111 | } 112 | 113 | template 114 | GLM_FUNC_QUALIFIER genType div(genType const & a, genType const & b) 115 | { 116 | return a / b; 117 | } 118 | 119 | template 120 | GLM_FUNC_QUALIFIER genTypeT mad(genTypeT const & a, genTypeU const & b, genTypeV const & c) 121 | { 122 | return a * b + c; 123 | } 124 | }//namespace glm 125 | -------------------------------------------------------------------------------- /include/glm/gtx/wrap.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_wrap 24 | /// @file glm/gtx/wrap.hpp 25 | /// @date 2009-11-25 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_wrap GLM_GTX_wrap: Texture coordinate wrap modes 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Wrapping mode of texture coordinates. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_wrap 39 | #define GLM_GTX_wrap GLM_VERSION 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext)) 45 | # pragma message("GLM: GLM_GTX_wrap extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_wrap 51 | /// @{ 52 | 53 | //! Simulate GL_CLAMP OpenGL wrap mode 54 | //! From GLM_GTX_wrap extension. 55 | template 56 | genType clamp(genType const & Texcoord); 57 | 58 | //! Simulate GL_REPEAT OpenGL wrap mode 59 | //! From GLM_GTX_wrap extension. 60 | template 61 | genType repeat(genType const & Texcoord); 62 | 63 | //! Simulate GL_MIRROR_REPEAT OpenGL wrap mode 64 | //! From GLM_GTX_wrap extension. 65 | template 66 | genType mirrorRepeat(genType const & Texcoord); 67 | 68 | /// @} 69 | }// namespace glm 70 | 71 | #include "wrap.inl" 72 | 73 | #endif//GLM_GTX_wrap 74 | -------------------------------------------------------------------------------- /include/glm_vec3_func.h: -------------------------------------------------------------------------------- 1 | #ifndef glm_vec3_func_h_ 2 | #define glm_vec3_func_h_ 3 | 4 | inline glm::vec3 mult(glm::vec3 a, glm::vec3 b){ 5 | return glm::vec3(a.x*b.x, a.y*b.y, a.z*b.z); } 6 | 7 | inline float dot(glm::vec3 a, glm::vec3 b){ 8 | return a.x * b.x + a.y *b.y + a.z * b.z; 9 | } 10 | 11 | inline glm::vec3 normalize(glm::vec3 a){ 12 | return glm::vec3(a / sqrt(dot(a, a))); 13 | } 14 | 15 | inline glm::vec3 cross(glm::vec3 a, glm::vec3 b){ 16 | return glm::vec3(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x); 17 | } 18 | 19 | #endif -------------------------------------------------------------------------------- /include/rand48/erand48.inc: -------------------------------------------------------------------------------- 1 | #ifndef _erand48_inc_ 2 | #define _erand48_inc_ 3 | 4 | /*------------------------------------------------------------------------- 5 | * 6 | * erand48.c 7 | * 8 | * This file supplies versions of erand48(), lrand48(), and srand48() 9 | * for machines that lack them. (These are all the members of the drand48 10 | * family that Postgres currently requires. We name the file after erand48 11 | * because that is the one that configure tests for.) 12 | * 13 | * 14 | * Copyright (c) 1993 Martin Birgmeier 15 | * All rights reserved. 16 | * 17 | * You may redistribute unmodified or modified versions of this source 18 | * code provided that the above copyright notice and this and the 19 | * following conditions are retained. 20 | * 21 | * This software is provided ``as is'', and comes with no warranties 22 | * of any kind. I shall in no event be liable for anything that happens 23 | * to anyone/anything when using this software. 24 | * 25 | * IDENTIFICATION 26 | * $PostgreSQL: pgsql/src/port/erand48.c,v 1.1 2009/07/16 17:43:52 tgl Exp $ 27 | * 28 | *------------------------------------------------------------------------- 29 | */ 30 | 31 | //#include "c.h" 32 | 33 | #include 34 | 35 | #define RAND48_SEED_0 (0x330e) 36 | #define RAND48_SEED_1 (0xabcd) 37 | #define RAND48_SEED_2 (0x1234) 38 | #define RAND48_MULT_0 (0xe66d) 39 | #define RAND48_MULT_1 (0xdeec) 40 | #define RAND48_MULT_2 (0x0005) 41 | #define RAND48_ADD (0x000b) 42 | 43 | static unsigned short _rand48_seed[3] = { 44 | RAND48_SEED_0, 45 | RAND48_SEED_1, 46 | RAND48_SEED_2 47 | }; 48 | static unsigned short _rand48_mult[3] = { 49 | RAND48_MULT_0, 50 | RAND48_MULT_1, 51 | RAND48_MULT_2 52 | }; 53 | static unsigned short _rand48_add = RAND48_ADD; 54 | 55 | 56 | __forceinline static void 57 | _dorand48(unsigned short xseed[3]) 58 | { 59 | unsigned long accu; 60 | unsigned short temp[2]; 61 | 62 | accu = (unsigned long) _rand48_mult[0] * (unsigned long) xseed[0] + 63 | (unsigned long) _rand48_add; 64 | temp[0] = (unsigned short) accu; /* lower 16 bits */ 65 | accu >>= sizeof(unsigned short) * 8; 66 | accu += (unsigned long) _rand48_mult[0] * (unsigned long) xseed[1] + 67 | (unsigned long) _rand48_mult[1] * (unsigned long) xseed[0]; 68 | temp[1] = (unsigned short) accu; /* middle 16 bits */ 69 | accu >>= sizeof(unsigned short) * 8; 70 | accu += _rand48_mult[0] * xseed[2] + _rand48_mult[1] * xseed[1] + _rand48_mult[2] * xseed[0]; 71 | xseed[0] = temp[0]; 72 | xseed[1] = temp[1]; 73 | xseed[2] = (unsigned short) accu; 74 | } 75 | 76 | 77 | __forceinline double 78 | erand48(unsigned short xseed[3]) 79 | { 80 | _dorand48(xseed); 81 | return ldexp((double) xseed[0], -48) + 82 | ldexp((double) xseed[1], -32) + 83 | ldexp((double) xseed[2], -16); 84 | } 85 | 86 | __forceinline long 87 | lrand48(void) 88 | { 89 | _dorand48(_rand48_seed); 90 | return ((long) _rand48_seed[2] << 15) + ((long) _rand48_seed[1] >> 1); 91 | } 92 | 93 | __forceinline void 94 | srand48(long seed) 95 | { 96 | _rand48_seed[0] = RAND48_SEED_0; 97 | _rand48_seed[1] = (unsigned short) seed; 98 | _rand48_seed[2] = (unsigned short) (seed > 16); 99 | _rand48_mult[0] = RAND48_MULT_0; 100 | _rand48_mult[1] = RAND48_MULT_1; 101 | _rand48_mult[2] = RAND48_MULT_2; 102 | _rand48_add = RAND48_ADD; 103 | } 104 | 105 | #endif -------------------------------------------------------------------------------- /include/tiny_obj_loader/tiny_obj_loader.cc: -------------------------------------------------------------------------------- 1 | #define TINYOBJLOADER_IMPLEMENTATION 2 | #include "tiny_obj_loader.h" 3 | -------------------------------------------------------------------------------- /res/dragon.mtl: -------------------------------------------------------------------------------- 1 | # 3ds Max Wavefront OBJ Exporter v0.94b - (c)2007 guruware 2 | # File Created: 04.07.2010 10:41:39 3 | 4 | newmtl wire_087224198 5 | Ns 32 6 | d 1 7 | Tr 1 8 | Tf 1 1 1 9 | illum 2 10 | Ka 0.0000 0.0000 0.0000 11 | Kd 0.3412 0.8784 0.7765 12 | Ks 0.3500 0.3500 0.3500 13 | -------------------------------------------------------------------------------- /res/scene01.mtl: -------------------------------------------------------------------------------- 1 | newmtl blinn1SG 2 | mtl_type REFR 3 | color 0.999 0.999 0.999 4 | illum 4 5 | Kd 0.52 0.52 0.52 6 | Ka 0.27 0.27 0.27 7 | Tf 0.00 0.00 0.00 8 | Ni 1.80 9 | Ks 1.00 1.00 1.00 10 | 11 | newmtl blinn2SG 12 | mtl_type DIFF 13 | color 0 0 0 14 | Ke 40.0 40.0 40.0 15 | illum 4 16 | Kd 0.80 0.80 0.80 17 | Ka 0.78 0.78 0.78 18 | Tf 1.00 1.00 1.00 19 | Ni 1.00 20 | Ks 0.50 0.50 0.50 21 | 22 | newmtl initialShadingGroup 23 | mtl_type DIFF 24 | color 0.75 0.75 0.75 25 | illum 4 26 | Kd 0.50 0.50 0.50 27 | Ka 0.00 0.00 0.00 28 | Tf 1.00 1.00 1.00 29 | Ni 1.00 30 | 31 | newmtl lambert2SG 32 | mtl_type DIFF 33 | color 0.75 0.25 0.25 34 | illum 4 35 | Kd 1.00 0.00 0.00 36 | Ka 0.00 0.00 0.00 37 | Tf 1.00 1.00 1.00 38 | Ni 1.00 39 | 40 | newmtl lambert3SG 41 | mtl_type DIFF 42 | color 0.25 0.25 0.75 43 | illum 4 44 | Kd 0.00 0.01 1.00 45 | Ka 0.00 0.00 0.00 46 | Tf 1.00 1.00 1.00 47 | Ni 1.00 48 | 49 | newmtl mia_material_x1SG 50 | mtl_type SPEC 51 | color 0.999 0.999 0.999 52 | illum 4 53 | Kd 0.50 0.50 0.50 54 | Ka 0.00 0.00 0.00 55 | Tf 1.00 1.00 1.00 56 | Ni 1.00 57 | 58 | 59 | newmtl lamber1SG 60 | mtl_type DIFF 61 | color 0 0 0 62 | illum 4 63 | Kd 0.50 0.50 0.50 64 | Ka 0.00 0.00 0.00 65 | Tf 1.00 1.00 1.00 66 | Ni 1.00 67 | 68 | -------------------------------------------------------------------------------- /res/scene02.mtl: -------------------------------------------------------------------------------- 1 | newmtl initialShadingGroup 2 | mtl_type DIFF 3 | color 0.4 0.4 0.4 4 | 5 | 6 | newmtl lambert2SG 7 | mtl_type DIFF 8 | color 0 0 0 9 | Ke 901.803 901.803 901.803 10 | 11 | 12 | newmtl lambert3SG 13 | mtl_type DIFF 14 | color 0 0 0 15 | Ke 1.23457 1.23457 1.23457 16 | 17 | 18 | newmtl lambert4SG 19 | mtl_type DIFF 20 | color 0 0 0 21 | Ke 11.1111 11.1111 11.1111 22 | 23 | newmtl lambert5SG 24 | mtl_type DIFF 25 | color 0 0 0 26 | Ke 100 100 100 27 | 28 | 29 | newmtl mia_material_x_passes1SG 30 | mtl_type ROUGHPLASTIC 31 | color 0.07 0.09 0.13 32 | alpha 0.005 33 | 34 | 35 | newmtl mia_material_x_passes4SG 36 | mtl_type ROUGHPLASTIC 37 | color 0.07 0.09 0.13 38 | alpha 0.02 39 | 40 | 41 | newmtl mia_material_x_passes2SG 42 | mtl_type ROUGHPLASTIC 43 | color 0.07 0.09 0.13 44 | alpha 0.05 45 | 46 | 47 | newmtl mia_material_x_passes3SG 48 | mtl_type ROUGHPLASTIC 49 | color 0.07 0.09 0.13 50 | alpha 0.1 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/BBox.cpp: -------------------------------------------------------------------------------- 1 | #include "BBox.h" 2 | #include 3 | 4 | BBox::BBox(const glm::vec3& min, const glm::vec3& max) 5 | : min(min), max(max) { extent = max - min; } 6 | 7 | BBox::BBox(const glm::vec3& p) 8 | : min(p), max(p) { extent = max - min; } 9 | 10 | void BBox::expandToInclude(const glm::vec3& p) { 11 | if (min.x > p.x) min.x = p.x; 12 | if (min.y > p.y) min.y = p.y; 13 | if (min.z > p.z) min.z = p.z; 14 | 15 | if (max.x < p.x) max.x = p.x; 16 | if (max.y < p.y) max.y = p.y; 17 | if (max.z < p.z) max.z = p.z; 18 | extent = max - min; 19 | } 20 | 21 | void BBox::expandToInclude(const BBox& b) { 22 | expandToInclude(b.min); 23 | expandToInclude(b.max); 24 | } 25 | 26 | uint32_t BBox::maxDimension() const { 27 | uint32_t result = 0; 28 | if(extent.y > extent.x) result = 1; 29 | if(extent.z > extent.y) result = 2; 30 | return result; 31 | } 32 | 33 | float BBox::surfaceArea() const { 34 | return 2.f*( extent.x*extent.z + extent.x*extent.y + extent.y*extent.z ); 35 | } 36 | 37 | bool BBox::intersect(const Ray& ray, float *tnear, float *tfar) const { 38 | float tx1 = (min.x - ray.o.x)*ray.inv_d.x; 39 | float tx2 = (max.x - ray.o.x)*ray.inv_d.x; 40 | 41 | float tmin = std::min(tx1, tx2); 42 | float tmax = std::max(tx1, tx2); 43 | 44 | float ty1 = (min.y - ray.o.y)*ray.inv_d.y; 45 | float ty2 = (max.y - ray.o.y)*ray.inv_d.y; 46 | 47 | tmin = std::max(tmin, std::min(ty1, ty2)); 48 | tmax = std::min(tmax, std::max(ty1, ty2)); 49 | 50 | float tz1 = (min.z - ray.o.z)*ray.inv_d.z; 51 | float tz2 = (max.z - ray.o.z)*ray.inv_d.z; 52 | 53 | tmin = std::max(tmin, std::min(tz1, tz2)); 54 | tmax = std::min(tmax, std::max(tz1, tz2)); 55 | *tnear = tmin; 56 | *tfar = tmax; 57 | 58 | return tmax >= tmin; 59 | } 60 | -------------------------------------------------------------------------------- /src/Camera.cpp: -------------------------------------------------------------------------------- 1 | #include "ray.h" 2 | #include "camera.h" 3 | #include "glm_vec3_func.h" 4 | 5 | Camera::Camera(glm::vec3 position, glm::vec3 target, int width, int height) { 6 | m_width = width; 7 | m_width_recp = 1. / m_width; 8 | m_height = height; 9 | m_height_recp = 1. / m_height; 10 | m_ratio = (double)m_width / m_height; 11 | 12 | m_position = position; 13 | m_direction = normalize(target-m_position); 14 | m_x_direction = cross(glm::vec3(0, -1, 0),normalize(m_direction)); 15 | m_y_direction = cross( m_x_direction,normalize(m_direction)); 16 | 17 | m_x_spacing = (2.0 * m_ratio) / (double)m_width; 18 | m_y_spacing = (double)2.0 / (double)m_height; 19 | m_x_spacing_half = m_x_spacing * 0.5; 20 | m_y_spacing_half = m_y_spacing * 0.5; 21 | } 22 | 23 | int Camera::get_width() { return m_width; } 24 | int Camera::get_height() { return m_height; } 25 | 26 | // Returns ray from camera origin through pixel at x,y 27 | Ray Camera::get_ray(int x, int y, bool jitter, unsigned short *Xi) { 28 | 29 | double x_jitter; 30 | double y_jitter; 31 | 32 | // If jitter == true, jitter point for anti-aliasing 33 | if (jitter) { 34 | x_jitter = (erand48(Xi) * m_x_spacing) - m_x_spacing_half; 35 | y_jitter = (erand48(Xi) * m_y_spacing) - m_y_spacing_half; 36 | 37 | } 38 | else { 39 | x_jitter = 0; 40 | y_jitter = 0; 41 | } 42 | 43 | glm::vec3 pixel = m_position + m_direction * (float)2; 44 | pixel = pixel - m_x_direction*(float)m_ratio + m_x_direction*(float)((x * 2 * m_ratio)*m_width_recp + x_jitter); 45 | pixel = pixel + m_y_direction - m_y_direction*(float)((y * 2.0)*m_height_recp + y_jitter); 46 | 47 | return Ray(m_position, normalize(pixel - m_position)); 48 | } -------------------------------------------------------------------------------- /src/Renderer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "Scene.h" 6 | #include "Renderer.h" 7 | 8 | // Clamp float to min/max of 0/1 9 | inline float clamp(float x){ return x < 0 ? 0 : x>1 ? 1 : x; } 10 | // Clamp to between 0-255 11 | inline int toInt(float x){ return int(clamp(x) * 255 + .5); } 12 | 13 | Renderer::Renderer(Scene *scene, Camera *camera) { 14 | m_scene = scene; 15 | m_camera = camera; 16 | m_pixel_buffer = new glm::vec3[m_camera->get_width()*m_camera->get_height()]; 17 | } 18 | 19 | void Renderer::render(int samples, const char *file_path) { 20 | int width = m_camera->get_width(); 21 | int height = m_camera->get_height(); 22 | 23 | clock_t start = clock(); 24 | 25 | #pragma omp parallel for schedule(dynamic, 1) // OpenMP 26 | for (int y = 0; y < height; y++){ // Loop over image rows 27 | fprintf(stderr, "\rRendering (%d spp) %5.2f%%", samples, 100.*y / (height - 1)); 28 | unsigned short Xi[3] = { 0, 0, y*y*y }; 29 | for (unsigned short x = 0; x < width; x++){ // Loop cols 30 | glm::vec3 color; 31 | for (int k = 0; k < samples; k++){ 32 | Ray ray = m_camera->get_ray(x, y, k > 0, Xi); 33 | color = color + m_scene->radiance(ray, 0, Xi); 34 | } 35 | m_pixel_buffer[(y)*width + x] = color / (float)samples; 36 | } 37 | } 38 | printf("\n%f sec\n", (float)(clock() - start) / CLOCKS_PER_SEC); 39 | FILE *f = fopen(file_path, "w"); // Write image to PPM file. 40 | fprintf(f, "P3\n%d %d\n%d\n", width, height, 255); 41 | for (int i = 0; i < width*height; i++){ 42 | fprintf(f, "%d %d %d ", toInt(m_pixel_buffer[i].x), \ 43 | toInt(m_pixel_buffer[i].y), toInt(m_pixel_buffer[i].z)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "BVH.h" 6 | #include "Sphere.h" 7 | #include "Triangle.h" 8 | #include "tiny_obj_loader.h" 9 | #include "Scene.h" 10 | #include "Renderer.h" 11 | #include "Camera.h" 12 | #include "glm/glm.hpp" 13 | using std::vector; 14 | 15 | std::vector shapes; 16 | std::vector materials; 17 | 18 | 19 | int main(int argc, char **argv) { 20 | Scene scene("../res/scene01.obj"); 21 | Camera camera = Camera(glm::vec3(0, 5, 14) , glm::vec3(0, 5, -14), 1024, 768); 22 | Renderer renderer(&scene, &camera); 23 | renderer.render(100, "../result/scene01.ppm"); 24 | 25 | system("pause"); 26 | return 0; 27 | } 28 | --------------------------------------------------------------------------------