|
|
openGL in 3d
-
in a 3-dimensional environment, we are able to create animated scenes using c or c++. although the actual commands to
draw objects in openGL are quite complicated, we can use some predefined functions (such as
glSolidTaurus()) to make our lifes easier.
-
in order to have objects be independent of each other, we use "matricies". matricies can be compared to drawing
different things on different sheets of overhead transparency, and then overlapping them; each one can be manipulated
independently of the others. in order to use matricies, we use the following two functions.
-
-
glPushMatrix()
-
this "pushes" a matrix onto the stack. in other words, it creates a new matrix that can be worked with.
-
glPopMatrix()
-
this "pops" a matrix off the stack. it signals the end of the matrix we want to work with.
-
although with these functions we can draw shapes, it would be very boring if these shapes were all the exact same size,
at the same angle, and in the same place. thus, we use the following modifier functions to change the way our objects
look.
-
-
glScalef()
-
changes the x, y, and z dimensions of an object to give it a different
shape or a different size. for example, a cube changed in only the y direction would make it a tall rectangular prism.
-
glRotatef()
-
changes the orientation of the object.
-
glTranslatef()
-
moves the object to a specified coordinate.
-
to enhance our 3-dimensional animated scene, we can simulate the different properties of light. just as in theatre,
light can make or break an animated scene. below are the constants we use to set the different qualities of light.
-
-
GL_DIFFUSE
-
diffused light is the light that comes from a general direction, but does not reflect well. for example, the source of
diffused light outside on a cloudy day is the sun.
-
GL_SPECULAR
-
specular light is a concentrated ray of light that reflects off the surfaces of the objects. this can be compared to
how something "sparkles". an example is shining a flashlight on a mirror.
-
GL_AMBIENT
-
this is the light that is all over the place. it basically gives the base light value of all the surfaces. if a room
is very well-lit, there is a lot of ambient light. if it is totally dark, there is no ambient light.
our first assignment is to create an orginal simple scene of 3-dimensional objects with keyboard and/or mouse interaction.
more
our second assignment is to create an animation of a scene in 3-D openGL that demonstrates a physics concept.
more
|