Saturday, July 12, 2008

OpenGL - computer graphics assignment

Final semester is over and so is my computer graphics assignment. My idea was to make some simple models and play with light effects. So check board, desk lights and some pieces on board will be probably easy to model and nice to see. First I draw my scene idea on piece of paper. You can find it here. And code for final implementation of assignment can be found here. This is just the main unit. You need to create project first and add this code to newly created project. Creating project is described in one of my previous post OpenGL - installation.

I will describe here in short what I have used to create such scene. For lighting the lamps I have used spot lights and two side lighting material to get glowing effect of upper part of lamps. Pieces are made using vertex function and then assigning normals for light reflection. Lamps are made with spheres and cylinders. Upper part of lamps are unclosed cylinders with different size of base radius. First part of animation moves camera from the center of check board toward positive side of y axis. Second part of animation just rotates scene over one of axises. Zoom in/out effect was achieved with parameter theta of projection function. That's pretty much it.

You can interact with animation with these key's:
a - rotate left
d - rotate right
w - zoom in
d - zoom out
p - pause animation
l - turn on/off left desk light
r - turn on/off right desk light
m - turn on/off moving desk light
b - increase amount of light of moving desk light

Saturday, July 5, 2008

OpenGL - rotating cube


Rotating cube. This is my first animation in OpenGL. You can comment/uncomment setLightening(); function in init() function to disable/enable custom lighting. Code for this example can be found here.