Vis 2 Demo  1.0
Technical illustration type real-time rendering of geometry
 All Classes Namespaces Files Functions Variables Typedefs Macros
SpinningCubeTextured.cpp
Go to the documentation of this file.
1 #include "SpinningCubeTextured.h"
2 
3 using namespace vis2;
4 
5 SpinningCubeTextured::SpinningCubeTextured(glm::mat4 _modelMatrix, Shader* _shader, Texture* _diffuseTexture)
6  : GeometricObjectTextured( _modelMatrix,
7  _shader,
8  _diffuseTexture,
9  generic_positions,
10  (unsigned int) TEXTURED_CUBE_VERTEX_COUNT,
11  generic_normlas,
12  (unsigned int) TEXTURED_CUBE_VERTEX_COUNT,
13  generic_uv,
14  (unsigned int) TEXTURED_CUBE_VERTEX_COUNT,
15  generic_indices,
16  (unsigned int) TEXTURED_CUBE_INDEX_COUNT)
18 {
19 }
20 
22 {
23 }
24 
25 void SpinningCubeTextured::update(double _deltaT)
26 {
27  // implements "the spinning cube" by rotating a matrix by &angle in deg around &axis
28  this->modelMatrix = glm::rotate( this->modelMatrix,
29  45.0f * (float)_deltaT,
30  glm::vec3(-0.1f, 1.0f, -0.1f));
31 }
32 
33 void SpinningCubeTextured::draw(glm::mat4 & _projectionMatrix)
34 {
35  GeometricObjectTextured::draw(_projectionMatrix);
36 }
37 
38 // ------------------- the static arrays --------------------------- //
39 
41 {
42  // Back
43  -0.5f, -0.5f, -0.5f,
44  -0.5f, 0.5f, -0.5f,
45  0.5f, 0.5f, -0.5f,
46  0.5f, -0.5f, -0.5f,
47 
48  // Front
49  -0.5f, -0.5f, 0.5f,
50  0.5f, -0.5f, 0.5f,
51  0.5f, 0.5f, 0.5f,
52  -0.5f, 0.5f, 0.5f,
53 
54  // Top
55  0.5f, 0.5f, 0.5f,
56  0.5f, 0.5f, -0.5f,
57  -0.5f, 0.5f, -0.5f,
58  -0.5f, 0.5f, 0.5f,
59 
60  // Bottom
61  0.5f, -0.5f, 0.5f,
62  -0.5f, -0.5f, 0.5f,
63  -0.5f, -0.5f, -0.5f,
64  0.5f, -0.5f, 0.5f,
65 
66  // Right
67  0.5f, 0.5f, 0.5f,
68  0.5f, -0.5f, 0.5f,
69  0.5f, -0.5f, -0.5f,
70  0.5f, 0.5f, -0.5f,
71 
72  // Left
73  -0.5f, 0.5f, 0.5f,
74  -0.5f, 0.5f, -0.5f,
75  -0.5f, -0.5f, -0.5f,
76  -0.5f, -0.5f, 0.5f,
77 };
78 
80 {
81  // Back
82  0.0f, 0.0f, -1.0f,
83  0.0f, 0.0f, -1.0f,
84  0.0f, 0.0f, -1.0f,
85  0.0f, 0.0f, -1.0f,
86 
87  // Front
88  0.0f, 0.0f, 1.0f,
89  0.0f, 0.0f, 1.0f,
90  0.0f, 0.0f, 1.0f,
91  0.0f, 0.0f, 1.0f,
92 
93  // Top
94  0.0f, 1.0f, 0.0f,
95  0.0f, 1.0f, 0.0f,
96  0.0f, 1.0f, 0.0f,
97  0.0f, 1.0f, 0.0f,
98 
99  // Bottom
100  0.0f, -1.0f, 0.0f,
101  0.0f, -1.0f, 0.0f,
102  0.0f, -1.0f, 0.0f,
103  0.0f, -1.0f, 0.0f,
104 
105  // Right
106  1.0f, 0.0f, 0.0f,
107  1.0f, 0.0f, 0.0f,
108  1.0f, 0.0f, 0.0f,
109  1.0f, 0.0f, 0.0f,
110 
111  // Left
112  -1.0f, 0.0f, 0.0f,
113  -1.0f, 0.0f, 0.0f,
114  -1.0f, 0.0f, 0.0f,
115  -1.0f, 0.0f, 0.0f
116 
117 };
118 
120 {
121  1.0f, 0.0f,
122  1.0f, 1.0f,
123  0.0f, 1.0f,
124  0.0f, 0.0f,
125 
126  0.0f, 0.0f,
127  1.0f, 0.0f,
128  1.0f, 1.0f,
129  0.0f, 1.0f,
130 
131  0.0f, 0.0f,
132  1.0f, 0.0f,
133  1.0f, 1.0f,
134  0.0f, 1.0f,
135 
136  0.0f, 0.0f,
137  1.0f, 0.0f,
138  1.0f, 1.0f,
139  0.0f, 1.0f,
140 
141  1.0f, 1.0f,
142  1.0f, 0.0f,
143  0.0f, 0.0f,
144  0.0f, 1.0f,
145 
146  0.0f, 1.0f,
147  1.0f, 1.0f,
148  1.0f, 0.0f,
149  0.0f, 0.0f
150 };
151 
153 {
154  0, 1, 2,
155  0, 2, 3,
156 
157  4, 5, 6,
158  4, 6, 7,
159 
160  8, 9, 10,
161  8, 10, 11,
162 
163  12, 13, 14,
164  12, 14, 15,
165 
166  16, 17, 18,
167  16, 18, 19,
168 
169  20, 21, 22,
170  20, 22, 23
171 };