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