Thursday, December 20, 2007

Open GL - Assignment 1

Assignment 1

The first assignment was to model a favourite toy of ours using openGL, where not only simple polygons can be used to model the toy, but also lighting, movement enabled functions and many other features to further improve the toy.
What i modelled was an M-16 rifle.

It was pretty tough at first to model such an object, as there were many different small and sophisticated parts that i have to model.
For some of the curved parts, i tried using polygons, but since Polygons may pose quite a bit of a problems sometime, i stick to using Quads.
For the lighting, i used a specular lighting instead of a diffuse lighting, as the rifle's surface is metalic and shiny.

This is the final Product of my M-16 model. Lighting was included, including rotation functions to view different parts of the rifle, there is also a passive function where the rifle fires constanly, bullets can be seen shooting out and the empty shells dropping.
Final Model
The file/code for the model can be downloaded through the download box at the right.

Open GL - Practical 7

Practical 7

Practical 7 is for us to learn how to create quadratic ojects such as cylinders and disk and also to creat lighting.

These are the shapes i came up with
Cylinder

Cylinder with lighting

Disk
Sample code for the cylinder:

glPushMatrix();
glTranslatef(0, 0, -20);
cylinder = gluNewQuadric();
glColor3ub(255,0,0);
gluCylinder(cylinder,5,5,30,32,32);//bigger
gluQuadricDrawStyle(cylinder, GLU_FILL);

glPushMatrix();
glTranslatef(0, 0, -20);
glColor3ub(0,0,255);
gluCylinder(cylinder,8,8,20,32,32);//bigger
gluQuadricDrawStyle(cylinder, GLU_FILL);
glPopMatrix();

glPushMatrix();
glTranslatef(0, 0, 20);
glColor3ub(0,255,0);
gluCylinder(cylinder,2,2,40,32,32);//bigger
gluQuadricDrawStyle(cylinder, GLU_FILL);
glPopMatrix();

glPopMatrix();

Thursday, December 13, 2007

Open GL - Practical 5

Practical 5


For practical 5, we were ask to try out playing with Modelview Matrix and understanding how to use glPopMatrix(); and glPushMatrix();
This are the following practical exercises.

Exercise 1

1) glVertex3f(0,0,0); = (0*4+2, 0*4+3, 0*4+1) = (2, 3, 1)
glVertex3f(0,1,0); = (0*4+2, 1*4+3, 0*4+1) = (2, 7, 1)
glVertex3f(1,1,0); = (1*4+2, 1*4+3, 0*4+1) = (6, 7, 1)
glVertex3f(1,0,0); = (1*4+2, 0*4+3, 0*4+1) = (6, 3, 1)

2) The matrix is a scaling followed by a translation. Scaling is (4); translation is by (2, 3, 1).

3) The reason is because the function will multiply the current Model View matrix with whatever the function called. So if 2 or more matrix of transformation are implied, it will be over written and the results will not be accurate. That’s why the stack system is used to store the previous transformation.


Exercise 3

glBegin(GL_QUADS);
glColor3ub(255,0,0); //red
glVertex3f(10.0f, 10.0f, 10.0);
glVertex3f(10.0f, -10.0f, 10.0);
glVertex3f(-10.0f, -10.0f, 10.0);
glVertex3f(-10.0f, 10.0f, 10.0);

glColor3ub(0,0,255); //blue
glVertex3f(10.0f, 10.0f, 10.0);
glVertex3f(10.0f, 10.0f, -10.0);
glVertex3f(10.0f, -10.0f, -10.0);
glVertex3f(10.0f, -10.0f, 10.0);

glColor3ub(255,255,0); //yellow
glVertex3f(-10.0f, 10.0f, 10.0);
glVertex3f(-10.0f, 10.0f, -10.0);
glVertex3f(-10.0f, -10.0f, -10.0);
glVertex3f(-10.0f, -10.0f, 10.0);

glColor3ub(255,255/2,0); //brown/orange
glVertex3f(10.0f, 10.0f, -10.0);
glVertex3f(10.0f, -10.0f, -10.0);
glVertex3f(-10.0f, -10.0f, -10.0);
glVertex3f(-10.0f, 10.0f, -10.0);

glColor3ub(0,255,0); //green
glVertex3f(10.0f, 10.0f, 10.0);
glVertex3f(-10.0f, 10.0f, 10.0);
glVertex3f(-10.0f, 10.0f, -10.0);
glVertex3f(10.0f, 10.0f, -10.0);

glColor3ub(255,0,255); //pink
glVertex3f(10.0f, -10.0f, 10.0);
glVertex3f(-10.0f, -10.0f, 10.0);
glVertex3f(-10.0f, -10.0f, -10.0);
glVertex3f(10.0f, -10.0f, -10.0);
glEnd();


Programming Exercise - Create a solar system





Creating the solar system. First, the basic layout has to be made, so i create lots of sphere and a torus, used push, pop and translation matrix to get them in place.
Than functions had to be included to rotate some of the spheres and spin the torus. I did this using keyboard functions by declaring global variables and fucntions.

For example:

GLfloat yy = 0.0f;
GLfloat zz = 0.0f;

glRotatef(::yy,0,1,0);
glRotatef(::zz,0,0,1);

void Keyboard(unsigned char key, int x, int y)
{
switch(key) //check which key is pressed
{
case 'a':
yy++;
break;
case 'w':
zz--;
break;
case 's':
zz++;
break;
case 'd':
yy--;
break;
}
}

Wednesday, November 14, 2007

Open GL - Practical 4

Practical 4

This are some of the things we did in practical 4.
Using Open Gl to create different shapes in 3D space such as spheres and triangles.


This is the Open Gl depth test, we did this so as to practice coding shapes in 3D, this is to show whether the objects are being blocked or not.


This is the simple Final Product we had to come out with, note that this is not 4 different coloured rectangles lying on top of each other, this is just the view from 1 side, to explain this, the picture of it in 3D space is shown below.



The codes and answers to practical 4 are in the download box.

Thursday, November 1, 2007

Computer Graphic - Open GL

Practical 2

Computer Graphic is very interesting. We were ask to get familiair with Open GL by learning the basics, Open GL is a kind of programming language that draws shapes and many other interesting stuff, a little different from C++.
We were thrown the main assignment of coding a meltdown, a meltdown is basically some sort of liquid flowing down a vertical piece of glass, where the liquid slowly melts itself down. In basic Open GL, there are 3 points to code for plotting a point, the X-axis, Y-axis and Z-axis.
So we were actually having loads of fun playing around with Open GL, occasionally disturbing each other =).
The 3 things coded are a StaticScreen, SineWave and a MeltDown.
The sample videos can be downloaded at the right hand side.


Practical 3

Again, we played around Open GL once more, this time to grasp the main concept of using it. So we did some simple shapes of different colors. What we did basically was to plot the point and make lines, squares, triangles and many other shapes. This are just some of the screenshots taken.
The sample codes can be downloaded at the right hand side.







Wednesday, October 24, 2007

Mathematics I Recap

Grades:

This are just some info about my level of mathematics and the stuff that i learned from my first semester.

'O' Level: B3. I dont know why i got a B3 for maths and an A2 for science.... It should be the other way round, i practice so much more for my maths than my science.... Anyway maths is my favourite subject.
NYP Semester-1: D+. Pretty weird for some1 who loves maths eh? I guess that this is because i did not concentrate in lectures at all, either im talking, playing my friend's psp or just daydreaming...
But i plan to work hard for my maths this Semester-2!! So just wait and see ^^.


Semester-1 Mathematics:

Basically, there are a few main chapters to Mathematics 1. They are Mathematical Foundation, Vector Geometry & Matrices.

Mathematical Foundation is just a refreshment of our minds as it's definitely been a long time since we touch maths.
Vector Geometry is some sort of the chapter i don't really like as there are many new formulaes introduced, this is mainly because i did not take A-Maths in secondary school. Vectors are something like equations of magnitudes and direction. I learned many stuff such as vectors in 2-D and 3-D, unit and directional vector, cosines and Dot product.

Matrices is a chapter that i am really interested in, the only reason is because it is FUN!! Although it is pretty similiar to vectors, i love it as there's loads of calculation involve in it. I learned many interesting stuff such as doing matrix multiplication, Transpose and inverse of matrix, homogeneous co-ordinates.

Thursday, October 18, 2007

Game Review: METAL GEAR SOLID 3. Snake Eater

Title Of The Game






Platform Of Game



Genre of Game: Stealth/Tactical Espionage Action

Developer: Konami Computer Entertainment Japan / Kojima Productions

Product Model Year: December 16. 2004

Graphics:

High – definition realistic graphics can be seen throughout the game. Tiny little movements such as crawling in the grass or moving in the waters looks almost as if it were real. Realistic is also what describes the game's graphics, for example, limps are torn off if a grenade was tossed right beside the enemy, gunfire, explosives all look real.


Fire effects


Explosion effects



Sound:

High – Definition sound that proves clearly when either crawling in the grass swimming in the river, the distinct sounds can be heard clearly from the chirping of birds to bombs going off. Even the sound of footsteps can be heard very distinctively. In the dessert, it feels as if you are really there as the wind blowing seems to be blowing into your ear.


Description/Story of the game:

MGS-3 is a prequel to the Metal Gear games and occurs in 1964. Unlike other traditional Metal Gear games, this one takes place outside in the Soviet Union. The game also talks about the Philosophers and the Philosophers Legacy, the Philosophers are a perverse group of people composed of the US, China, and the Soviet Union. They run the entire world without anyone knowing it. Ultimately, the Philosophers deteriorated because of quarrels with each other. (Play the game to understand more). Since it is a prequel, the protagonist is Naked Snake (not to be confused with Solid Snake). Naked Snake (yourself), is a former U.S Special Force and CIA operative.


In the aftermath of the Second World War, the world was torn in two between East and West.It was the beginning of a new era - the Cold War. On October 16, 1962. The President of the United States received word that the Soviet Union had deployed nuclear missiles in Cuba, the world trembles with fear as the prospect of a nuclear war loomed closer. But the world was saved when the Soviet union decided to withdraw the plan. However, they had a secret condition to this crisis......


The game begins with you talking to Magor Zero and The Boss (Naked Snake's formal teacher) while you are sent to the jungles on a first mission to rescue a scientist called 'Sokolov', as the enemy Colonel Volgin is using him to create a machine called Shagohod that is capable of launching a nuclear strike independently. Everything went according to plan till someone betrays and deflected to Colonel Volgin's side and handed him 2 nuclear weapons. Lots of trouble started brewing between the United States and the Soviet Union as 1 of the weapons was fired.
The story goes on and Snake meets Eva (formal NSA agent), and planned to help each other as both have almost the same intentions. Many more enemies appear in the story as they try to stop the Shagohad.



Shagohad


Game Play:

Stealth Espionage Action takes place in the jungles, where survival is the major theme throughout the game as you must adapt through the harsh conditions while battling enemy soldiers.
During the game, various tactics or plans can be put into action, one of the main attribute of this game is to maintained camouflage by choosing different uniforms to suit the environment, your camouflage meter is at the top right, indicating to % of your camouflage, usually getting at least 80% is fairly good.


Usage of camoflauge to kill enemies.


Changing your camoflauge through the menu.


MGS 3 will be a little different from MGS 2 as there is no map showing you were the enemies are, detecting enemies will be up to you to use various high tech equipment such as motion detectors and sonar, etc.


In MGS-2, the map is shown at the top right section.
There is no such map system in MGS-3.


When you are spotted by enemies, the alert system will be announced and reinforcements will be sent to terminate you. When wounded, medical aid needs to be done by you by opening up the menu and use various medical ingredients to treat yourself. Food also has to be hunted on your own using weapons and knives. Enemies and allies will be met throughout the game. Various weapons and items also has to be gathered on your own by exploring the environment or killing enemy soldiers to acquire what you need.



The countdown timer for alert mode
appears if you are seen


Conclusion:
It is a game worth playing, not only the graphic and sound are up to standard, the story line is very intriguing (read description of the game). Playing this also gives you the feel of how it feels like to survive in the jungles of an enemy territory all by yourself, survival is the key point in this game. It is a very fun stealth mission.
For people who loves action games, stealth missions, espionage warfare with gunfire, this is a highly recommended game for the teens.


Links to MGS-3. Snake Eater:


Game FAQ: http://www.gamefaqs.com/console/ps2/game/914828.html


History Of Metal Gear: http://www.gamespot.com/gamespot/features/video/mg_history/