Thursday, December 13, 2007

Week 8

I worked on our given Assignment one Week 8. Another 3 hours just passed easily... Sorry but I don't have any screenshots or codes to provide because I didn't save any for Week 8's work. :P

Week 7

On Week 7 of Sememster 2, Computer Graphics lab session was regarding lighting. Lighting was pretty easy... just declaring the light source position, changing colours and it wasn't all that rocket science after all that.


The code:

#include "glut.h"

GLfloat angle = 0.0f;
GLfloat width = 40.0f;
GLfloat height = 30.0f;

double x = 0, y = 0;

void init(void)
{
GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat position[] = { 0.0, 3.0, 2.0, 0.0 };
GLfloat lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 };
glClearColor(0.0, 0.1, 0.1, 0.0);

//Enable Depth test
glShadeModel(GL_SMOOTH);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}

void DrawCylinder()
{
GLUquadricObj *Cylinder;
GLUquadricObj *Disk;

Cylinder = gluNewQuadric();
Disk = gluNewQuadric();

glColor3f(1,0,0);
gluCylinder(Cylinder,15,15,40,32,32);

glColor3f(0,1,0);
gluDisk(Disk,0.5,1.5,32,32);
gluQuadricDrawStyle(Cylinder, GLU_FILL);
}

void MyDisplay()
{
GLfloat mat_diffuse[] = { 0.2, 0.5, 1, 1.0 };
GLfloat mat_specular[] = { 0.8, 1.0, 1.0, 1.0 };
GLfloat low_shininess[] = { 2.0 };

glEnable(GL_DEPTH);
glClear(GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);

glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess);

glPopMatrix();
//Lines
glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(50,0,0);
glEnd();

glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(0,50,0);
glEnd();

glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(0,0,50);
glEnd();
//End of lines

glPushMatrix();
glTranslatef(::x,::y,0);

DrawCylinder();

glutSwapBuffers();
}

void Rescale(GLsizei w, GLsizei h)
{
glViewport(0,0,w,h);
}

void Keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case 'd':
::x+=10;
break;
case 'a':
::x-=10;
break;
case 'w':
::y+=10;
break;
case 's':
::y-=10;
break;
}
glutPostRedisplay();
}

void SetupRC()
{
GLfloat final = width / height;
gluPerspective(60, final, 0, 1000);
gluLookAt(90,90,90,0,1,0,0,1,0);
glFlush();
glPushMatrix();
}

void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE GLUT_RGB GLUT_DEPTH);
glutInitWindowSize(800, 600);
glutCreateWindow("My Pratical 7");
glutDisplayFunc(MyDisplay);
init();
glutReshapeFunc(Rescale);
glutKeyboardFunc(Keyboard);
SetupRC();
glutMainLoop();
}


Some pictures:

Thursday, November 29, 2007

Week 6

Week 6
Week 6's Computer Graphics lesson was as enjoyable as it is frustrating. We had to deal with piecing our 3D cubes, sphere and quad. Pretty crazy when you have to think for an hour just to plot the dimensions of all the 3D figures, and then translate and rotate the objects accordingly. 3hours totally used without knowledge that time passed so quickly. I understood most parts but didn't catch everything really. Going to query classmates on how to complete the sphere and how not to allow the 3D figures to seperate during rotation.

Week 5


Week 5

Week 5's Computer Graphics lesson was moderately tough. The plotting in a 3D environment was annoying. Coordinates and more coordinates... mathematical calculations - my worst nightmare. We had to rely on matrice calculations to determine and plot our 3D cube. Finally when we succeeded, we had to move the cube around in the 3D environment, which was simple once you got the idea of how it all works. Pop and push.

Week 4



Week 4
Week 4 was pretty simple. Easily understable as it was like a repeat session of week 3, just that we create QUADS instead of Triangles this time.

Sunday, November 25, 2007

Week 3

In this week's lab edition of Computer Graphics, I learnt how to create 3D shapes in OpenGL. It was a rather bland and frustrating session though, but when the results of my hard work were finally out, I felt satisfied. There was the face culling which was alittle tough to understand... it's about not drawing invisible polygons I think. The most fun part... which was not fun at all was putting colours into the triangles. Haha.

Thursday, November 1, 2007

Week 2

Week 2
Monday:
Software Engineering Fundamentals lecture was quite boring as always. =;=
UML and more UML. The diagrams were quite simple really... just some arrows here and there. Wonder how some people can't draw them. The lecture was understandable as Mister Tan explained the parts well. Hahaha. Then it was Product and Project Management was alright. The part-time lectuerer talks like one of my friends. I understood most of his lesson and found the contents rather interesting for example, he was talking about his company and his personal experience and stuff... short but really good information to know.

Maths tutorial was fun as always. Miss Soh is still great as a Mathematics teacher. (:
What she taught, I always understood so no problems here.

Tuesday:
Meh, C++ day. =;=
9a.m to 6p.m of C++ is really a killer.

First off was Computer Graphics lecture... frankly I didn't really pay total attention. Just caught some parts of it. But I know it's something like a recap of last year's DES monitor explanation thingy. Next was Mr Ng with a Advanced C++ lecture which was mysteriously "not as boring" as I expected. Hahaha. No offence. :x

An hour of break and back to the computer for practical. I'm actually very pleased with how the school set up the schedule in which the lecture was right before the lab session. Helps with the memorising of the lecture contents. As usual, did most of it myself.

2 hour break interval... DSA lecture. SLEEPY. Well, kept awake by the cold anyways. Good explanation on pointers too by Mr Low. Made me understand it better.

Thursday:
Blah blah blah, Computer Graphics. First introduction to OpenGL. Didn't catch much at first. I was like "HUH!?" Then grasped the concept a little later and then it was smooth sailing. Maths lecture was boring once again as usual.
Friday:
Down with fever. XD

Thursday, October 18, 2007

Practical 1

Hello peeps,
First Week
Monday, 15th October 2007:

Part 2: Mathematics I Recap
  1. Algebra
  2. Quadratic equations
  3. Vectors
  4. Matrices
  5. LOL

I understood matrices more than vectors. Vectors I was a little confused here and there, but could cope with it. Overall, I found Maths 1 easy if I had followed the lessons... but did not. :P



Part 3: Review of a Computer Game

Title of Game: GTA: San Andreas <3

Platform of Game: Playstation 2

Genre of Game: Action/Adventure: Modern

Developer: Rockstar North

Product Model Year: 2004

Game Requirements: =.=



Description of Game:

Gameplay:

The gameplay of this game was one of the largest factors why GTA: San Andreas was a big hit, especially with their diehard fans of their great series. GTA: San Andreas offered control of their main antagonist, Carl Johnson, otherwise better known as CJ. With Johnson, you can do a buttload of stuff throughout the game! Shooting innocent cops along the street, getting involved in fierce gun fights, and even working out in the gym. There are stats to max out, totalling to at least a hundred hours of game time spent to enjoy the game fully. Typical side-missions, mini-games and many others lead to an even larger amount of things added to your to-do list. As if the main storyline wasn't enough! :P

Graphics:

The graphics in this game compared to what producers offer now, three years later, are not that great already. Although that few years back, the graphics offered by this game were considered one of the hottest... competable even with the great Final Fantasy series, known for their extremely realistic graphics. Looking at the crazy size of this game, graphics were actually not expected to be good. In fact, many were anticipating worser graphics than the previous series, GTA: Vice City. But, Rockstar North managed to come out stronger, stunning critics and fans alike with their graphics.

Sound:

The sound of this game is amazing... totally alluring in fact! Turn on da music in vehicles and you can listen to radio stations ranging from gangster rap, country music to hip-hop. The voice actors were great, getting in the accents of african-americans and those living in the ghetto. On the streets, you can hear cars zooming past you, or even an aeroplane above, crossing the borders.

Conclusion:

GTA: San Andreas over the span of 3 years have not yet lost its spark among gamers, with buyers still searching for the game on the shelves. The game is superb, like the diaries of CJ, you live it out for him, decide whatever he does, whenever he does. Don't rent it, BUY IT!