Solar System - demo scence
Operations

Modules

 Transforms
 
 Models
 
 Groups
 
 Xml
 
 Printing
 

Functions

void operations_render (std::vector< float > *operations)
 

Detailed Description

Data structure for Operations

The elem will be

  1. ⟨TRANSFORM⟩ ⟨float⟩ ⟨float⟩ ⟨float⟩ [float] or
  2. ⟨LOAD_MODEL⟩ ⟨NUMBER_OF_CHARACTERS⟩ ⟨char⟩ ... ⟨char⟩

and groups will be

for example (inside a group),

LOAD_MODEL 7 'e' 'x' 'a' 'm' 'p' 'l' 'e'

our operations (world) will be

where position, lookAt, up and ⟨projection⟩ are

we'll use an array of floats, therefore we will need to cast to char when reading the model filename characters and to int when reading the number of characters.

Function Documentation

◆ operations_render()

void operations_render ( std::vector< float > *  operations)
157 {
158 unsigned int i = 0;
159
160 globalEyeX = operations->at(i);
161 globalEyeY = operations->at(i + 1);
162 globalEyeZ = operations->at(i + 2);
163 i += 3;
164
165 globalCenterX = operations->at(i);
166 globalCenterY = operations->at(i + 1);
167 globalCenterZ = operations->at(i + 2);
168 i += 3;
169
170 globalUpX = operations->at(i);
171 globalUpY = operations->at(i + 1);
172 globalUpZ = operations->at(i + 2);
173 i += 3;
174
175 globalFOV = operations->at(i);
176 globalNear = operations->at(i + 1);
177 globalFar = operations->at(i + 2);
178
179 for (i += 3; i < operations->size(); i++) {
180 switch ((int) operations->at(i)) {
181 case ROTATE:
182 glRotated(operations->at(i + 1),
183 operations->at(i + 2),
184 operations->at(i + 3),
185 operations->at(i + 4));
186 i += 4;
187 continue;
188 case TRANSLATE:
189 glTranslatef(operations->at(i + 1),
190 operations->at(i + 2),
191 operations->at(i + 3));
192 i += 3;
193 continue;
194 case SCALE:
195 glScalef(operations->at(i + 1),
196 operations->at(i + 2),
197 operations->at(i + 3));
198 i += 3;
199 continue;
200 case BEGIN_GROUP:
201 glPushMatrix();
202 continue;
203 case END_GROUP:
204 glPopMatrix();
205 continue;
206 case LOAD_MODEL:
207 int stringSize = (int) operations->at(i + 1);
208 char model[stringSize + 1];
209
210 int j;
211 for (j = 0; j < stringSize; j++)
212 model[j] = (char) operations->at(i + 2 + j);
213
214 model[j] = 0;
216 i += 1 + j - 1; //just to be explicit
217 continue;
218 }
219 }
220}
static float globalFar
Definition: engine.cpp:64
static float globalCenterX
Definition: engine.cpp:54
static float globalEyeY
Definition: engine.cpp:51
static float globalNear
Definition: engine.cpp:63
Model allocModel(const char *path)
Definition: engine.cpp:74
static float globalFOV
Definition: engine.cpp:62
static float globalUpX
Definition: engine.cpp:58
static float globalEyeZ
Definition: engine.cpp:52
void renderModel(Model model)
Definition: engine.cpp:97
static float globalUpZ
Definition: engine.cpp:60
static float globalUpY
Definition: engine.cpp:59
static float globalCenterZ
Definition: engine.cpp:56
static float globalEyeX
Definition: engine.cpp:50
static float globalCenterY
Definition: engine.cpp:55
const int TRANSLATE
Definition: parsing.h:8
const int SCALE
Definition: parsing.h:10
const int END_GROUP
Definition: parsing.h:13
const int LOAD_MODEL
Definition: parsing.h:11
const int BEGIN_GROUP
Definition: parsing.h:12
const int ROTATE
Definition: parsing.h:9
Definition: engine.cpp:66

References allocModel(), BEGIN_GROUP, END_GROUP, globalCenterX, globalCenterY, globalCenterZ, globalEyeX, globalEyeY, globalEyeZ, globalFar, globalFOV, globalNear, globalUpX, globalUpY, globalUpZ, LOAD_MODEL, renderModel(), ROTATE, SCALE, and TRANSLATE.

Referenced by renderScene(), and xml_load_and_set_env().