#2) Running Source Code



















#3) gluLookAt(...) and glTransformf(...) are both transform views, glTransformf(...) is just a matrix multiply instead of specifying every little detail of the eyepoint, center and up vector.

#5) For this implemenation, I basically centered the object on the origin, so the objects origin is the world origin. With this in mind, no transformations were needed and keypresses control the rotation of the world.






































#include
#include

// Rotation amounts
static GLfloat xangle = 0.0f;
static GLfloat yangle = 0.0f;

void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}

void SpecialKeys(int key, int x, int y)
{
if(key == GLUT_KEY_UP) {
yangle++;
}

if(key == GLUT_KEY_DOWN) {
yangle--;
}

if(key == GLUT_KEY_LEFT) {
xangle--;
}

if(key == GLUT_KEY_RIGHT) {
xangle++;
}
// Refresh the Window
glutPostRedisplay();
}


void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glLoadIdentity (); /* clear the matrix */
/* viewing transformation */
//gluLookAt(eye, center, up vector);
gluLookAt (0, 0, 5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glRotatef(xangle, 0, 1, 0);
glRotatef(yangle, 1, 0, 0);

//Front Face
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, 1.0f);
glVertex3f(1, 1, 1);
glVertex3f(1, -1, 1);
glVertex3f(-1, -1, 1);
glVertex3f(-1, 1, 1);
glEnd();

//Back Face
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, -1.0f);
glVertex3f(1, 1, -1);
glVertex3f(1, -1, -1);
glVertex3f(-1, -1, -1);
glVertex3f(-1, 1, -1);
glEnd();

glColor3f(0.0f, 1.0f, 0.0f);
//Right Face
glBegin(GL_QUADS);
glNormal3f(1.0f, 0.0f, 0.0f);
glVertex3f(1, 1, 1);
glVertex3f(1, -1, 1);
glVertex3f(1, -1, -1);
glVertex3f(1, 1, -1);
glEnd();

//Left Face
glBegin(GL_QUADS);
glNormal3f(-1.0f, 0.0f, 0.0f);
glVertex3f(-1, 1, 1);
glVertex3f(-1, -1, 1);
glVertex3f(-1, -1, -1);
glVertex3f(-1, 1, -1);
glEnd();

glColor3f(0.0f, 0.0f, 1.0f);
//Top Face
glBegin(GL_QUADS);
glNormal3f(0.0f, 1.0f, 0.0f);
glVertex3f(1, 1, 1);
glVertex3f(-1, 1, 1);
glVertex3f(-1, 1, -1);
glVertex3f(1, 1, -1);
glEnd();

//Bottom Face
glBegin(GL_QUADS);
glNormal3f(0.0f, -1.0f, 0.0f);
glVertex3f(1, -1, 1);
glVertex3f(-1, -1, 1);
glVertex3f(-1, -1, -1);
glVertex3f(1, -1, -1);
glEnd();

glFlush ();
}

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
glMatrixMode (GL_MODELVIEW);
}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutSpecialFunc(SpecialKeys);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}


The Perspect Example introduces a perspective view of 3 dimensional objects. In relation to real life, things that are farther away will appear smaller than they actually are. With an increase in distance from the observer, the volume or field of view that is taken in gets larger, yet the objects appear smaller.

Also seen in the Perspect example is the use of lighting to give a better approach of perspective. Lighting gives the appearance of being luminated by some form of light, therefore giving shadow or shade.

Each quad face is specified by connecting 4 vertices and a normal which specifies the projection of the plane.

I altered the example to produce a blue table, changing the color, evening up the sides and removing some faces :). Although its quite interesting to model this way, I have found maya to be somewhat quite easier :(, given a drawing program instead of coding.



















I hard coded the coordinates for the points and plotted the connected vertices for each B(t) in 3Dimensions.

OpenGL is an API tied to the hardware, not a programming language or compiler.

One thing that stuck out at me when reading the three articles is that there exists an OpenGL ES, which is a subset of the functionality taken from desktop OpenGL and used in embedded devices such as phones, consoles, appliances and vehicles that have smaller hardware. Such functionality is giving way to awesome graphical interfaces for entertainment or applicational purposes, such as a car's GPS.

Another thing that I found interesting is that OpenGL, again being an API, is supported by multiple programming languages. With the persistant use of Processing 1.0 in class, we can find that the OpenGL library is highly supported by the language. By importing the library, we can directly accelerate the graphics card to provide substantial use for what we code. Since Processing 1.0 is a well defined language for graphic design, it's methods are closely related to the OpenGL library. After importing the library, all methods could be substatially the same. A call to line(x0, y0, x1, y1) will execute the same way, yet they will be rendered differently and more likely faster.

The last thing I found interesting is how other languages provide use for the library. Processing 1.0 is just one example, yet the possibilites of what other languages provide is quite extravagant. PyOpenGL is a python supported version of OpenGL. Python is a scripting language which runs in real time and can provide fast and direct access to the uses of OpenGL. With the access of the real time capabilities simply drawing objects and shapes can be accomplished. Instead of having to compile everytime a change is made, the real time capabilites can be seen almost instantaneously. When looking at programs such as Maya, an advanced modeling application, we can see the possibilites of these uses. Maya offers its own language, the Maya Embedded Language or MEL for short, but also includes the uses of Python. Both offer the concept of creating, removing, saving and manipulating graphical objects with simple commands.


Bounce.cpp running in Dev-C++
















In the process of creating my Super Creatures set, I wanted a dynamically random simulation of the Super Formula designed by Johan Gielis to produce a body, secondary body and facial features. The program I wrote has setup two useful methods.

One method is “creature”, which will randomly create a creature around the world origin, wherever that may be. The creature method will distinctly develop a random body, a transparent secondary body which is also color coordinated with the base body, a random number of eyes between 2 and 4 and a mouth.

The body parts and the mouth are all developed using the method called “superform”, which implies the super formula. The “superform” method accepts a few key parameters including: the desired width & height and the six distinct parameters of the super formula, notably A, B, m, n1, n2, n3. Through the use of the parameters we can plug them into the super formula, which at a certain degree between 0 and 2PI (a full circle), will produce a point. Cycling through the range of 0 to 2PI in increments of .0001, we can come up with multiple vertices and finally connect them all to produce a shape. This shape is then displayed according to the previously defined fills and stroke qualities.

The desired width and height were usually decreased as the body pieces began to fit on the body. Yet to keep the dynamics of the program, all super shapes developed were and are random. Mostly modifying the parameters m, n1, n2 and n3, we can come up with all kinds of shapes.

Further exploration of radians between 0 and multiples of 2PI has shown quite extravagant shapes. Yet the way it has been implemented, the allowed range will only go from 0 to 4PI, since the program can run out of allowable memory due to so many vertices of a shape.


Also this formula can be simulated to produce 3 dimensional values and produce 3D Super Shapes.

I give credit to Johan Gielis for a functional method to produce super shapes and nodebox.com for giving me inspiration.