dummy.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 #define GLM_MESSAGES
00033 #include "../glm.hpp"
00034 #include <limits>
00035 
00036 struct material
00037 {
00038         glm::vec4 emission; // Ecm
00039         glm::vec4 ambient; // Acm
00040         glm::vec4 diffuse; // Dcm
00041         glm::vec4 specular; // Scm
00042         float shininess; // Srm
00043 };
00044 
00045 struct light
00046 {
00047         glm::vec4 ambient; // Acli
00048         glm::vec4 diffuse; // Dcli
00049         glm::vec4 specular; // Scli
00050         glm::vec4 position; // Ppli
00051         glm::vec4 halfVector; // Derived: Hi
00052         glm::vec3 spotDirection; // Sdli
00053         float spotExponent; // Srli
00054         float spotCutoff; // Crli
00055         // (range: [0.0,90.0], 180.0)
00056         float spotCosCutoff; // Derived: cos(Crli)
00057         // (range: [1.0,0.0],-1.0)
00058         float constantAttenuation; // K0
00059         float linearAttenuation; // K1
00060         float quadraticAttenuation;// K2
00061 };
00062 
00063 
00064 // Sample 1
00065 #include <glm/vec3.hpp>// glm::vec3
00066 #include <glm/geometric.hpp>// glm::cross, glm::normalize
00067 
00068 glm::vec3 computeNormal
00069 (
00070         glm::vec3 const & a,
00071         glm::vec3 const & b,
00072         glm::vec3 const & c
00073 )
00074 {
00075         return glm::normalize(glm::cross(c - a, b - a));
00076 }
00077 
00078 typedef unsigned int GLuint;
00079 #define GL_FALSE 0
00080 void glUniformMatrix4fv(GLuint, int, int, float*){}
00081 
00082 // Sample 2
00083 #include <glm/vec3.hpp> // glm::vec3
00084 #include <glm/vec4.hpp> // glm::vec4, glm::ivec4
00085 #include <glm/mat4x4.hpp> // glm::mat4
00086 #include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective
00087 #include <glm/gtc/type_ptr.hpp> // glm::value_ptr
00088 void func(GLuint LocationMVP, float Translate, glm::vec2 const & Rotate)
00089 {
00090         glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f);
00091         glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate));
00092         glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f));
00093         glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f));
00094         glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f));
00095         glm::mat4 MVP = Projection * View * Model;
00096         glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP));
00097 }
00098 
00099 // Sample 3
00100 #include <glm/vec2.hpp>// glm::vec2
00101 #include <glm/packing.hpp>// glm::packUnorm2x16
00102 #include <glm/integer.hpp>// glm::uint
00103 #include <glm/gtc/type_precision.hpp>// glm::i8vec2, glm::i32vec2
00104 std::size_t const VertexCount = 4;
00105 // Float quad geometry
00106 std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2);
00107 glm::vec2 const PositionDataF32[VertexCount] =
00108 {
00109         glm::vec2(-1.0f,-1.0f),
00110         glm::vec2( 1.0f,-1.0f),
00111         glm::vec2( 1.0f, 1.0f),
00112         glm::vec2(-1.0f, 1.0f)
00113         };
00114 // Half-float quad geometry
00115 std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::uint);
00116 glm::uint const PositionDataF16[VertexCount] =
00117 {
00118         glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, -1.0f))),
00119         glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, -1.0f))),
00120         glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, 1.0f))),
00121         glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, 1.0f)))
00122 };
00123 // 8 bits signed integer quad geometry
00124 std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2);
00125 glm::i8vec2 const PositionDataI8[VertexCount] =
00126 {
00127         glm::i8vec2(-1,-1),
00128         glm::i8vec2( 1,-1),
00129         glm::i8vec2( 1, 1),
00130         glm::i8vec2(-1, 1)
00131 };
00132 // 32 bits signed integer quad geometry
00133 std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2);
00134 glm::i32vec2 const PositionDataI32[VertexCount] =
00135 {
00136         glm::i32vec2 (-1,-1),
00137         glm::i32vec2 ( 1,-1),
00138         glm::i32vec2 ( 1, 1),
00139         glm::i32vec2 (-1, 1)
00140 };
00141 
00142 struct intersection
00143 {
00144         glm::vec4 position;
00145         glm::vec3 normal;
00146 };
00147 
00148 /*
00149 // Sample 4
00150 #include <glm/vec3.hpp>// glm::vec3
00151 #include <glm/geometric.hpp>// glm::normalize, glm::dot, glm::reflect
00152 #include <glm/exponential.hpp>// glm::pow
00153 #include <glm/gtc/random.hpp>// glm::vecRand3
00154 glm::vec3 lighting
00155 (
00156         intersection const & Intersection,
00157         material const & Material,
00158         light const & Light,
00159         glm::vec3 const & View
00160 )
00161 {
00162         glm::vec3 Color(0.0f);
00163         glm::vec3 LightVertor(glm::normalize(
00164                 Light.position - Intersection.position +
00165                 glm::vecRand3(0.0f, Light.inaccuracy));
00166 
00167         if(!shadow(Intersection.position, Light.position, LightVertor))
00168         {
00169                 float Diffuse = glm::dot(Intersection.normal, LightVector);
00170                 if(Diffuse <= 0.0f)
00171                         return Color;
00172                 if(Material.isDiffuse())
00173                         Color += Light.color() * Material.diffuse * Diffuse;
00174                 if(Material.isSpecular())
00175                 {
00176                         glm::vec3 Reflect(glm::reflect(
00177                                 glm::normalize(-LightVector),
00178                                 glm::normalize(Intersection.normal)));
00179                         float Dot = glm::dot(Reflect, View);
00180                         float Base = Dot > 0.0f ? Dot : 0.0f;
00181                         float Specular = glm::pow(Base, Material.exponent);
00182                         Color += Material.specular * Specular;
00183                 }
00184         }
00185         return Color;
00186 }
00187 */
00188 int main()
00189 {
00190         return 0;
00191 }


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:16