curObject = nObjects;
- sceneObjs[nObjects].mesh = -1;
+ sceneObjs[nObjects].mesh = -1; // Teapot is -1 mesh
sceneObjs[nObjects].texture = -1;
sceneObjs[nObjects].x = 0;
sceneObjs[nObjects].y = 0;
sceneObjs[nObjects].z = 0;
- sceneObjs[nObjects].scale = (vector*)calloc( 3, sizeof(vector[0]) );
+ sceneObjs[nObjects].scale[0] = 0;
+ sceneObjs[nObjects].scale[1] = 0;
+ sceneObjs[nObjects].scale[2] = 0;
- sceneObjs[nObjects].rotation.parameter = 0;
- sceneObjs[nObjects].rotation.vect = (vector*)calloc( 3, sizeof(vector[0]) );
-
- if ( sceneObjs[nObjects].scale == NULL || sceneObjs[nObjects].rotation.vect == NULL ) {
- fprintf(stderr, "Could not allocate memory for Scene Object! Shutting down!\n");
- exit(EXIT_FAILURE);
- }
+ sceneObjs[nObjects].rotation.amount = 0;
+ sceneObjs[nObjects].rotation.vector[0] = 0;
+ sceneObjs[nObjects].rotation.vector[1] = 0;
+ sceneObjs[nObjects].rotation.vector[2] = 0;
nObjects += 1; // New object in scene
drawFloor();\r
\r
// Draw sceneObjs array\r
- glPushMatrix();\r
- for ( int i = 0; i < nObjects; i++ ) {\r
+ for ( int i = 0; i < nObjects; i++ ) {\r
+ glPushMatrix();\r
SceneObject so = sceneObjs[i];\r
\r
// Apply rotation vector\r
- vector* rv = so.rotation.vect;\r
+ GLfloat* rv = &so.rotation.vector;\r
printf("%f, %f, %f\n", rv[0], rv[1], rv[2]);\r
- /* glRotatef(so.rotation.parameter, *rv[0], *rv[1], *rv[2]);\r
+ glRotatef(so.rotation.amount, rv[0], rv[1], rv[2]);\r
\r
// Apply scaling vector\r
- vector* sv = so.scale;\r
- glScalef(*sv[0], *sv[1], *sv[2]);\r
+ GLfloat* sv = &so.scale;\r
+ glScalef(sv[0], sv[1], sv[2]);\r
\r
// Apply translation vector\r
glTranslatef(so.x, so.y, so.z);\r
glBindTexture(GL_TEXTURE_2D, so.texture);\r
} else {\r
glBindTexture(GL_TEXTURE_2D, 0);\r
- }*/\r
+ }\r
\r
// Draw actual object\r
if ( so.mesh > 0 ) {\r
}\r
\r
glBindTexture(GL_TEXTURE_2D, 0);\r
- }\r
- glPopMatrix();\r
+ glPopMatrix();\r
+ }\r
+ \r
\r
// Draw a white ball over the light source\r
glPushMatrix();\r
GLubyte *rgbData; // Array of bytes with the colour data for the texture
} texture;
-
-typedef GLfloat vector[3]; // Vector datatype
-
typedef struct {
- GLfloat parameter; // Transform amount
- vector* vect; // Transform vector
+ GLfloat amount; // Transform amount
+ GLfloat vector[3]; // Transform vector
} transform;
typedef struct {
int mesh; // Mesh index number
int texture; // Texture index number
float x,y,z; // Scene position
- vector* scale; // Scale vector
+ GLfloat scale[3]; // Scale vector
transform rotation; // Rotation transformation
} SceneObject;