Wednesday, December 12, 2007

Week 9: Assignment 1



Now this is my complete version of assignment 1. I modelled a bass guitar based on the above picture taken.


So this is my model..
Plotting on a graph paper with the x and y axis before startin doing it on openGL really helps alot with the visualisation. So alot of time is saved and the job is easily done.

Week 8: Assignment 1

I actually started off with an alien. Here's how it goes.

After doing halfway, I have to redo. I won't even dare to hand it in. It looks too lousy to pass. So practically this is just a practise to start off with.

Wednesday, November 28, 2007

Practical 7


#include "glut.h"
GLfloat angle= 0.0f;
GLfloat width= 40.0f;
GLfloat height= 30.0f;
int x=0;
int 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 MyDisplay()
{
GLfloat mat_diffuse[] = { 0.1, 0.5, 0.8, 1.0 };
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat low_shininess[] = { 5.0 };
//Clear buffer.
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess);

GLUquadricObj *Cylinder;
GLUquadricObj *Disk;
glEnable(GL_DEPTH);
glClear(GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);
Cylinder = gluNewQuadric();
Disk = gluNewQuadric();
gluQuadricDrawStyle(Cylinder, GLU_FILL);
//glLoadIdentity();
glPopMatrix();

glBegin(GL_LINES);
glColor3f(1,1,1);
glVertex3f(0,0,0);
glVertex3f(400,0,0);
glVertex3f(0,0,0);
glVertex3f(0,400,0);
glVertex3f(0,0,0);
glVertex3f(0,0,400);
glEnd();

glPushMatrix();
glTranslatef(::x,y,0);
glColor3f(1,0,0);
gluCylinder(Cylinder,15,15,40,32,32);
glColor3f(0,1,0);
gluDisk(Disk,0.5,1.5,32,32);
glEnd();

glutSwapBuffers();
}

// Called by GLUT library when the window has changed size

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

void SetupRC()
{
GLfloat final = width / height;
gluPerspective(90, 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(640, 480);
glutCreateWindow("My Practical 7");
glutDisplayFunc(MyDisplay);
init();
glutReshapeFunc(Rescale);
SetupRC();
glutMainLoop();
}

Practical 6



#include "glut.h"

GLfloat angle= 0.0f;
GLfloat width= 40.0f;
GLfloat height= 30.0f;
int x=0;
int y=0;
int z=0;

void drawBody()
{
glColor3f(0,0,1);
glBegin(GL_QUADS);
glVertex3f(-15,5,0);
glVertex3f(15,5,0);
glVertex3f(15,-20,0);
glVertex3f(-15,-20,0);
glEnd();

glColor3f(0,0,1);
glBegin(GL_QUADS);
glVertex3f(-15,5,10);
glVertex3f(15,5,10);
glVertex3f(15,-20,10);
glVertex3f(-15,-20,10);
glEnd();

glColor3f(0,0,1);
glBegin(GL_QUADS);
glVertex3f(15,5,10);
glVertex3f(15,5,0);
glVertex3f(15,-20,0);
glVertex3f(15,-20,10);
glEnd();

glColor3f(0,0,1);
glBegin(GL_QUADS);
glVertex3f(-15,5,10);
glVertex3f(-15,5,0);
glVertex3f(-15,-20,0);
glVertex3f(-15,-20,10);
glEnd();

glColor3f(0,0,1);
glBegin(GL_QUADS);
glVertex3f(-15,5,0);
glVertex3f(15,5,0);
glVertex3f(15,5,10);
glVertex3f(-15,5,10);
glEnd();

glColor3f(0,0,1);
glBegin(GL_QUADS);
glVertex3f(-15,-20,0);
glVertex3f(15,-20,0);
glVertex3f(15,-20,10);
glVertex3f(-15,-20,10);
glEnd();
}

void drawLimb()
{
glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex3f(-5,5,8);
glVertex3f(1,5,8);
glVertex3f(1,-15,8);
glVertex3f(-5,-15,8);
glEnd();

glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex3f(-5,5,2);
glVertex3f(1,5,2);
glVertex3f(1,-15,2);
glVertex3f(-5,-15,2);
glEnd();

glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex3f(1,5,8);
glVertex3f(1,5,2);
glVertex3f(1,-15,2);
glVertex3f(1,-15,8);
glEnd();

glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex3f(-5,5,8);
glVertex3f(-5,5,2);
glVertex3f(-5,-15,2);
glVertex3f(-5,-15,8);
glEnd();

glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex3f(-5,5,2);
glVertex3f(1,5,2);
glVertex3f(1,5,8);
glVertex3f(-5,5,8);
glEnd();

glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex3f(-5,-15,2);
glVertex3f(1,-15,2);
glVertex3f(1,-15,8);
glVertex3f(-5,-15,8);
glEnd();
}

void drawLimb2()
{
glColor3f(1,1,0);
glBegin(GL_QUADS);
glVertex3f(-5,5,10);
glVertex3f(5,5,10);
glVertex3f(5,-15,10);
glVertex3f(-5,-15,10);
glEnd();

glColor3f(1,1,0);
glBegin(GL_QUADS);
glVertex3f(-5,5,0);
glVertex3f(5,5,0);
glVertex3f(5,-15,0);
glVertex3f(-5,-15,0);
glEnd();

glColor3f(1,1,0);
glBegin(GL_QUADS);
glVertex3f(5,5,10);
glVertex3f(5,5,0);
glVertex3f(5,-15,0);
glVertex3f(5,-15,10);
glEnd();

glColor3f(1,1,0);
glBegin(GL_QUADS);
glVertex3f(-5,5,10);
glVertex3f(-5,5,0);
glVertex3f(-5,-15,0);
glVertex3f(-5,-15,10);
glEnd();

glColor3f(1,1,0);
glBegin(GL_QUADS);
glVertex3f(-5,5,0);
glVertex3f(5,5,0);
glVertex3f(5,5,10);
glVertex3f(-5,5,10);
glEnd();

glColor3f(1,1,0);
glBegin(GL_QUADS);
glVertex3f(-5,-15,0);
glVertex3f(5,-15,0);
glVertex3f(5,-15,10);
glVertex3f(-5,-15,10);
glEnd();
}

void drawHead()
{
glColor3f(1,0,1);
glutSolidSphere(9.5,36,25);
}

void MyDisplay()
{
glClear(GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);
//glLoadIdentity();

glEnable(GL_DEPTH);
glPopMatrix();
glBegin(GL_LINES);
glColor3f(1,1,1);
glVertex3f(0,0,0);
glVertex3f(400,0,0);
glVertex3f(0,0,0);
glVertex3f(0,400,0);
glVertex3f(0,0,0);
glVertex3f(0,0,400);
glEnd();

glPushMatrix();
glTranslatef(::x,y,z);
glPushMatrix();
glTranslatef(-15, 0.0, 0.0);
drawLimb();
glPopMatrix();
glPushMatrix();
glTranslatef(-20, -15.0, 13);
glRotatef(90.0, 1.0, 0.0, 0.0);
drawLimb();
glPopMatrix();

glPushMatrix();
glTranslatef(-40, -60, -25);
drawLimb2();
glPopMatrix();
glPushMatrix();
glTranslatef(-15, -60, -25);
drawLimb2();
glPopMatrix();
glPushMatrix();
drawBody();
glPopMatrix();

glPushMatrix();
glTranslatef(20, 0.0, 0.0);
drawLimb();
glPopMatrix();
glPushMatrix();
glTranslatef(10, -14.0, 3);
glRotatef(50.0, 1.0, 0.0, 0.0);
drawLimb();
glPopMatrix();
glPushMatrix();
glTranslatef(-17, -5, -12);
drawHead();
glPopMatrix();
glutPostRedisplay();
glutSwapBuffers();
}

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

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

void Keyboard(unsigned char key, int x, int y)
{
switch(key) //check which key is pressed
{
case 'a':
::x--; //add 1 to global x.
break;
case 'd':
::x++; //minus 1 to global x.
break;
case 'w':
::y++;
break;
case 's':
::y--;
break;
case 'q':
::z--;
break;
case 'e':
::z++;
break;
}
glutPostRedisplay();
}

void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE GLUT_RGB GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("My Practical 6");
glutDisplayFunc(MyDisplay);
glutReshapeFunc(Rescale);
glutKeyboardFunc(Keyboard);
SetupRC();
glutMainLoop();
}

Thursday, November 22, 2007

PRACTICAL 5


#include "glut.h"

GLfloat angle= 0.0f;
GLfloat width= 40.0f;
GLfloat height= 30.0f;
int x=0;int y=0;

void MyDisplay()
{
glEnable(GL_DEPTH);
glClear(GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); //glLoadIdentity();
glPopMatrix();
glBegin(GL_LINES);
glColor3f(1,1,1);
glVertex3f(0,0,0);
glVertex3f(400,0,0);
glVertex3f(0,0,0);
glVertex3f(0,400,0);
glVertex3f(0,0,0);
glVertex3f(0,0,400);
glEnd();

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

glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex3f(0,0,0);
glVertex3f(0,20,0);
glVertex3f(20,20,0);
glVertex3f(20,0,0);
glEnd();

glColor3f(0,0,1);
glBegin(GL_QUADS);
glVertex3f(0,0,0);
glVertex3f(0,0,20);
glVertex3f(0,20,20);
glVertex3f(0,20,0);
glEnd();

glColor3f(0,1,0);
glBegin(GL_QUADS);
glVertex3f(0,20,0);
glVertex3f(0,20,20);
glVertex3f(20,20,20);
glVertex3f(20,20,0);
glEnd();

glColor3f(1,1,0);
glBegin(GL_QUADS);
glVertex3f(0,0,0);
glVertex3f(0,0,20);
glVertex3f(20,0,20);
glVertex3f(20,0,0);
glEnd();

glColor3f(0,1,1);
glBegin(GL_QUADS);
glVertex3f(20,0,0);
glVertex3f(20,0,20);
glVertex3f(20,20,20);
glVertex3f(20,20,0);
glEnd();

glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex3f(0,0,20);
glVertex3f(0,20,20);
glVertex3f(20,20,20);
glVertex3f(20,0,20);
glEnd();

glutSwapBuffers();
} // Called by GLUT library when the window has changed size

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

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

void Keyboard(unsigned char key, int x, int y)
{
switch(key) //check which key is pressed
{
case 'a': ::x++; //add 1 to global x.
break;
case 'd': ::x--; //minus 1 to global x.
break;
case 'w': ::y++;
break;
case 's': ::y--;
break;
}

glutPostRedisplay();
}

void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE GLUT_RGB GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("My Practical 5");
glutDisplayFunc(MyDisplay);
glutReshapeFunc(Rescale);
glutKeyboardFunc(Keyboard);
SetupRC();
glutMainLoop();
}

PRACTICAL 4


#include "glut.h"
void MyDisplay()
{
glClear(GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);
glColor3ub(255,255,255);
glVertex3f(0.0f, 0.0f, 100.0);
glVertex3f(0.0f, 0.0f, -10.0);
glVertex3f(100.0f, 0.0f, 0.0);
glVertex3f(-10.0f, 0.0f, 0.0);
glVertex3f(0.0f, 100.0f, 0.0);
glVertex3f(0.0f, -10.0f, 0.0);
glEnd();

glColor3f(0, 1, 0);
glBegin(GL_QUADS);
glVertex3f(-35,-30,11);
glVertex3f(-35,30,11);
glVertex3f(-30,30,11);
glVertex3f(-30,-30,11);
glEnd( );

glColor3f(1, 0, 0);
glBegin(GL_QUADS);
glVertex3f(-40,-20,10);
glVertex3f(-40,-10,10);
glVertex3f(40,-10,14);
glVertex3f(40,-20,14);
glEnd( );

glColor3f(0, 0, 1);
glBegin(GL_QUADS);
glVertex3f(-40,20,12);
glVertex3f(-40,25,12);
glVertex3f(40,25,12);
glVertex3f(40,20,12);
glEnd( );

glColor3f(1, 1, 0);
glBegin(GL_QUADS);
glVertex3f(30,-30,13);
glVertex3f(30,30,13);
glVertex3f(35,30,13);
glVertex3f(35,-30,13);
glEnd( );

glutSwapBuffers();
} // Called by GLUT library when the window has changed sizevoid Rescale

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

void SetupRC()
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0,0,0,1);
glOrtho(-64,64,48,-48,1,50);
gluLookAt(0,0,20,0,2,0,0,2,0);
glEnable(GL_DEPTH_TEST);
}

void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE GLUT_RGB GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("My Practical 4");
glutDisplayFunc(MyDisplay);
glutReshapeFunc(Rescale);
SetupRC();
glutMainLoop();
}

PRACTICAL 3

#include "glut.h"
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);
glColor3f(1, 0, 0);
glBegin(GL_TRIANGLES);
glVertex3f(1,0,0);
glVertex3f(0.5,0.5,0);
glVertex3f(0.5,0,0);
glEnd( );

glColor3f(0, 1, 0);
glBegin(GL_TRIANGLES);
glVertex3f(0,0,0);
glVertex3f(0.3,0.5,0);
glVertex3f(0.3,0,0);
glEnd( );

glColor3f(1, 1, 0);
glBegin(GL_TRIANGLES);
glVertex3f(-1,-1,0);
glVertex3f(-0.3,-0.4,0);
glVertex3f(-0.3,0,0);
glEnd( );

glColor3f(0, 1, 1);
glBegin(GL_TRIANGLES);
glVertex3f(0,0,0);
glVertex3f(-0.3,-0.5,0);
glVertex3f(-0.3,0,0);
glEnd( );

glColor3f(0, 0, 1);
glBegin(GL_QUADS);
glVertex3f(0,0,0);
glVertex3f(0.3,0,0);
glVertex3f(0.3,0.3,0);
glVertex3f(0,0.3,0);
glEnd( );

glColor3f(0, 1, 1);
glBegin(GL_QUADS);
glVertex3f(-0.3,-0.6,0);
glVertex3f(-0.1,-0.6,0);
glVertex3f(-0.1,-0.9,0);
glVertex3f(-0.3,-0.9,0);
glEnd( );

glColor3f(1, 0, 1);
glBegin(GL_QUADS);
glVertex3f(-0.9,0.9,0);
glVertex3f(-0.6,0.9,0);
glVertex3f(-0.6,0.4,0);
glVertex3f(-0.9,0.4,0);
glEnd( );

glColor3f(1, 1, 1);
glBegin(GL_QUADS);
glVertex3f(0.3,-0.3,0);
glVertex3f(0.6,-0.3,0);
glVertex3f(0.6,-0.6,0);
glVertex3f(0.3,-0.6,0);
glEnd( );

glutSwapBuffers();
glBegin(GL_POINTS);
glVertex3f(10.0f, 0.0f, 0.0f);
glEnd();
}

void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE GLUT_RGB GLUT_DEPTH);
glutInitWindowSize(640,480);
glutInitWindowPosition(100, 100);
glutCreateWindow("Squares and Triangles");
glutDisplayFunc(myDisplay);
glutMainLoop();
}

Wednesday, October 31, 2007

Week 3

Software Engineering:
-Handing in of proposal.
-Showing Mr Johnny Tan uml diagrams.

Product and Project Management
-Presentation

Maths 2:
TEST.
Can do. No need study.

Advance C++:
Starting to enjoy lab sessions. Learn about constructor and destructor. We got pop quiz, I 1st time can do.

Computer graphics:
Learn to create polygons using vectors.

Week 2

Advance C++:
Classes was easy, I was startin to enjoy the C++ practical lab, lecture was boring as usual. We learn how to use classes function. And as usual, we spend 3 hours in the lab .

Maths 2:
New formulas, new ways of solving equation.

Computer Graphics:
2D rendering, updating blog =D.

Data structure:
Revision of pointers.

Project and Product Management:
Doing powerpoint for presentation of proposal.

Software engineering:
learning how to draw uml diagram.

Sunday, October 21, 2007

Sem 2: Week 1

School reopened, time to get back to work. =D

Advance C++: Well nothing much on the 1st week, just some revision on last sem's C++ work, making use of switch structures, struct, functions, array and so on.

Computer Graphics: Nothing much yet, just making a blog. Haha.

Data Structure: Learning how to step in and step over for debugging. This can help us for debugging in the future. =)

Maths 2: Just some easy to work out new formulas.

Wednesday, October 17, 2007

World of Warcraft

Title: World of Warcraft


Platform: Mac OS X, Windows


Genre: MMORPG


Developer: Bizzard Entertainment


Product Model Year: July 21, 2005

Game Requirements:

Windows
Windows 2000, Windows Vista or Windows XP
Intel Pentium III or AMD Athlon 800 MHz
512
MB or more of RAM
32 MB 3D
video card with Hardware T&L or better
6.0
GB free HD space
CD-ROM drive
56 kbit/s or faster Internet connection

Macintish
Mac OS X 10.3.9 or newer
933 MHz or higher G4, or G5, or Intel processor
512 MB RAM or higher
ATI or NVIDIA video card with 32 MB Video RAM or more
6.0 GB free HD space
4× CD-ROM drive
56 kbit/s or faster Internet connection


Description of the game:

Game Play:

World of Warcraft is a MMORPG. As with other MMORPGs, players control a character avatar within a persistent game world, exploring the landscape, fighting monsters, and interacting with NPCs as well as other players. The game rewards success with money, items, and experience, which in turn allow players to improve their skill and power. Players can level their characters from level one up to level 60, level 70 if they have The Burning Crusade expansion or level 80 if they have the yet to be released Wrath of the Lich King expansion.
In addition, players may opt to take part in battles against other players of an enemy faction, in PvP battlegrounds or in normal world zones subject to the rules in place on the particular server. Duels can also be fought between members of the same or opposing factions, although these do not provide tangible rewards. Many players also choose to join guilds in order to conduct raids against enemy territory and instances.



Graphics:

The Graphic is one of the best that I have ever played. The tiny details were all there(Characters, trees, mountains, buildings, etc.)
Shadows were clearly seen and is very realistic. The background is fantastic. Everything is just so real...


Sound:

Sound is excellent. The way the npcs talk, the sound of combat, the footsteps, all sound real. There is even the sound of the weather, globin airships, as well as the sound of insects.


Conclusion:

World of Warcraft (WOW) is one of the biggest game ever created, with over millions of gamers addicted to it. The quest is never ending and the game has an aim, not like some other never-ending grinding MMORPG games. Although the game requires money to play, it is not a waste to try playing it.

Mathematics 1

Grade for Maths 1 : A

Review of Maths 1

1) Algebra

-Quadratic equation
-Coordinate Geometry
-Trigonometry

-Reference Angle

2) Vector Geometry
-Components of Vectors in 2D
-Components of Vectors in 3D
-Unit Vectors and Direction Vectors
-Direction cosines and Direction Rations
-Dot product
-Scalar ProductProduct of 2 vectors

3) Matrix Notation and Terminology
-Identity matrix
-Addition of matrix
-Scalar multiplication
-Matrix multiplication
-Transpose of matrix
-Inverse of matrix
-Linear systems and inverses
-Determinants
-Transformations in Homogeneous Co-ordinates

END.