Here is the poem that the mood of my forest scene is based on:
The Donkey --- G.K. Chesterton When fishes flew and forests walked And figs grew upon thorn, Some moment when the moon was blood, Then surely i was born; With monstrous head and sickening cry And ears like errant wings, The devil's walking parody On all four-footed things. The tattered outlaw of the earth, Of ancient crooked will; Starve, scourge, deride me: I am dumb, I keep my secret still. Fools! For I also had my hour; One far fierce hour and sweet: There was a shout about my ears, And palms before my feet.The particular elements of the poem that I attempted to implement were the flying fishes, the moon of blood, palm trees and of course a donkey.
Terrain suitable to the context.
The first problem that I tackled was that of creating a suitable terrain. In order to do this, I first made a bumpy,
textured floor using Blender and exported this as an .OFF object.
w.addObject (new Object (Point (0.0, 10.0, 0.0), 90.0, Vector (1.0, 0.0, 0.0), 600.0, readOff ("newfloor"), Colour (0.2, 0.7, 0.2), 50.0));To this I added several tree OFF objects to make up my forest. The floor initially looked like this:
At least one of the following effects: fog, motion blur, depth of field, shadows, environment mapping, transparency.
For this section I implemented fog as we had done in prac 16 and shadows similar to the way we implemented them in Prac 15.
To see the effect it was first necessary to enable the fog.
void initializeGL () { glShadeModel (GL_SMOOTH); glEnable (GL_DEPTH_TEST); glEnable (GL_FOG); glEnable (GL_NORMALIZE); glEnable (GL_LIGHTING); .... GLint fogMode; GLfloat density; GLfloat fogColor[4] = {0.1, 0.2, 0.3, 1.0}; fogMode = GL_EXP2; glFogi (GL_FOG_MODE, fogMode); glFogfv (GL_FOG_COLOR, fogColor); glFogf (GL_FOG_DENSITY, 0.05); glClearColor(0.1, 0.2, 0.3, 1.0); }
void paintGL () { ... ... //to draw shadows: for (std::vector
A path to be followed by the camera/viewer, using splines.
I decided to use a BSpline for my camera path and so used the spline code from Prac 3 as a starting point.
To implement it I needed to instantiate an object of the Curve
class which we had access to. Once I had added this object to the World class,
Curve* curvecam;I could use it in my main method as follows:
//camera bits string splinedefn = "BSpline 3 6 [{0,200.0,-100.0} {80.0,100.0,-50.0} {100.0,70.0,-20.0} {110.0,50.0,-20.0} {80.0,70.0,-50.0} {-10.0,100.0,-100.0}] [ 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]"; istringstream stm (splinedefn); w.curvecam = Curve::createCurve (stm);In order to get the camera transformations to actually follow the spline I needed to associate the transformation co-ordinates with the curve co-ordinates:
//moving the camera according to the BSpline coordinates: Ti::transformTranslate (0.0, 0.0, world->curvecam->curveAt(tval).coord[2]); Ti::transformRotate (world->curvecam->curveAt(tval).coord[0], 0.0, 1.0, 0.0); tval +=0.01; //so that the camera movements loop around if (tval >= 1) tval = 0.0;(tval was previously initialised to 0.0).
At least one light, producing specular highlights.
The lighting code I only modified slightly, changing the colour and position of my lights and making sure that
everything was enabled correctly. My modified code is as follows:
void initializeGL () { ... glEnable (GL_LIGHTING); glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); GLfloat global_ambient[] = { 0.0, 0.1, 0.0, 1.0 }; glLightModelfv (GL_LIGHT_MODEL_AMBIENT, global_ambient); glLightModeli (GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); ...In my main method:
w.addLight (new Light (Point (-50.0, 10.0, 0.0), Colour (0.8, 0.6, 0.6))); w.addLight (new Light (Point (0.0, 10.0, 0.0), Colour (1.0, 0.1, 0.1)));The specular highlights were only really visible when the fog was turned off though.
An animated object containing internal transformations (moving parts,for example, flapping bird, walking dog).
I had many problems getting an animated object. My intention was to animate my own version of the donkey (as applicable to
the poem) showing the donkey looking at the blood red moon. However... my animation failed to export properly resulting in
a "segmentation fault". The donkey's motion was supposed to be something along the lines of:
Texture mapping.
I performed texture mapping on my floor object to create a grassy terrain. I also tried to add texture to my version of the
animated donkey object.
These are the textures that I used:
A number of objects moving according to a flocking algorithm.
Here I re-used the code that we had been given in Prac 18 but adjusted the number of boids, their proximity and influence
on each other. To stick with the theme of my poem, I used blender to enlarge a fish OFF object that I could then set to be
the boid in the main method.
#define NUMBOIDS 15 #define LIMIT 100.0 #define PROXIMITY 20.0 #define INFLUENCE 50.0 #define BoidD 0.9// how much of previous direction is maintained. #define BoidC 0.7 // cohesion #define BoidA 0.2 // alignment #define BoidS 0.2 // separation #define BoidR 0.5 // random factor ... int main (int argc, char * argv []) { ... bug = readOff ("salmon3"); ...