From: Ash Tyndall Date: Fri, 21 Oct 2011 08:44:13 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ae7da963e8c91eb4463b8c9f60d0b82c4a2155ce;p=atyndall%2Fcits2231.git --- diff --git a/helper.c b/helper.c index b13e8f9..68907c8 100644 --- a/helper.c +++ b/helper.c @@ -321,4 +321,21 @@ void drawAxisLines() { glDisable(GL_BLEND); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); +} + +void addSceneObject(int id) { + // **NOTE: Currently only adds the teapot + + nObjects += 1; // New object in scene + + sceneObjs[nObjects].mesh = -1; + 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].rotation.parameter = 0; + sceneObjs[nObjects].rotation.vect = (vector*)calloc( 3, sizeof(vector[0]) ); } \ No newline at end of file diff --git a/helper.h b/helper.h index 0ed5d21..f6d86c8 100644 --- a/helper.h +++ b/helper.h @@ -24,4 +24,6 @@ void drawSquare(int recurseLevel, float x1, float z1, float x2, float z2); void drawFloor(); void drawAxisLines(); +void addSceneObject(int id); + #endif /* HELPER_H */ diff --git a/scene.c b/scene.c index ca09d1d..07824dd 100644 --- a/scene.c +++ b/scene.c @@ -113,7 +113,8 @@ void processLightEvents(int id) { * @param id ID of object selected */ void processObjectEvents(int id) { - + // **NOTE: For the testing phase, only have the teapot + addSceneObject(id); } /** @@ -407,7 +408,7 @@ void init() { glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, direction0); //glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 90.0); - glLighti(GL_LIGHT0, GL_SPOT_EXPONENT,100); + //glLighti(GL_LIGHT0, GL_SPOT_EXPONENT,100); glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1); glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1); @@ -415,7 +416,7 @@ void init() { glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, direction1); //glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 90.0); - glLighti(GL_LIGHT1, GL_SPOT_EXPONENT,100); + //glLighti(GL_LIGHT1, GL_SPOT_EXPONENT,100); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, glightmodel); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); diff --git a/types.h b/types.h index 573418d..197eb03 100644 --- a/types.h +++ b/types.h @@ -34,10 +34,20 @@ typedef struct { GLubyte *rgbData; // Array of bytes with the colour data for the texture } texture; + +typedef GLfloat vector[3]; // Vector datatyle + +typedef struct { + GLfloat parameter; // Transform amount + vector* vect; // Transform vector +} transform; + typedef struct { - // You'll need to add scale, rotation, material, mesh number, etc., - // to this structure - float x,y,z; + int mesh; // Mesh index number + int texture; // Texture index number + float x,y,z; // Scene position + vector* scale; // Scale vector + transform rotation; // Rotation transformation } SceneObject; // Menu enum