0% found this document useful (0 votes)
11 views22 pages

Content Project Report

Cgip project report

Uploaded by

mohdmushtaq9296
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views22 pages

Content Project Report

Cgip project report

Uploaded by

mohdmushtaq9296
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Chapter-1

INTRODUCTION
1.1 Computer Graphics

● Graphics provides one of the most natural means of communicating with a computer,
since our highly developed 2D or 3D pattern-recognition abilities allow us to perceive
and process pictorial data rapidly.

● Computers have become a powerful medium for the rapid and economical production of
pictures.

● Graphics provide a so natural means of communicating with the computer that they have
become widespread.

● Interactive graphics is the most important means of producing pictures since the
invention of photography and television.

● We can make pictures of not only the real world objects but also of abstract objects such
as mathematical surfaces on 4D and of data that have no inherent geometry.

● A computer graphics system is a computer system with all the components of the general
purpose computer system. There are five major elements in system: input devices,
processor, memory, frame buffer, output devices.

Figure 1.1 GRAPHICS SYSTEM


1.2 OpenGL Technology

OpenGL is the premier environment for developing portable, interactive 2D and 3D graphics
applications. Since its introduction in 1992, OpenGL has become the industry's most widely used
and supported 2D and 3D graphics application programming interface (API), bringing thousands
of applications to a wide variety of computer platforms.
OpenGL fosters innovation and speeds application development by incorporating a broad set of
rendering, texture mapping, special effects, and other powerful visualization functions.
Developers can leverage the power of OpenGL across all popular desktop and workstation
platforms, ensuring wide application deployment.
OpenGL Available Everywhere: Supported on all UNIX® workstations, and shipped standard
with every Windows 95/98/2000/NT and MacOS PC, no other graphics API operates on a wider
range of hardware platforms and software environments.
OpenGL runs on every major operating system including Mac OS, OS/2, UNIX, Windows
95/98, Windows 2000, Windows NT, Linux, Open Step, and BeOS; it also works with every
major windowing system, including Win32, MacOS, Presentation Manager, and X-Window
System. OpenGL is callable from Ada, C, C++, FORTRAN, Python, Perl and Java and offers
complete independence from network protocols and topologies.

The OpenGL interface


Our application will be designed to access OpenGL directly through functions in three libraries
namely: gl,glu,glut.

Figure 1.2 LIBRARY ORGANISATION


Page 2 of 22
1.3 PROJECT DESCRIPTION:
It depicts a 3 Dimensional city containing a normal environment where the user can
navigate across the scene using keys and mouse movement.

1.4 FUNCTIONS USED:


1. glClear -Takes a single argument that is the bitwise OR of several values indicating
which buffer is to be cleared.

2. glClearColor -Specifies the red, green, blue, and alpha values used by glClear to clear
the color buffers.

3. glLoadIdentity

Replaces the current matrix with the identity matrix.

4. glMatrixMode

Sets the current matrix mode, mode can be GL_MODELVIEW,


GL_PROJECTION or GL_TEXTURE.

5. glutCreateWindow

Creates a top-level window.

6. glutDisplayFunc

Sets the display callback for the current window

7. glutInit

Initializes the GLUT library and negotiates a session with the window system.

8. glutInitDisplayMode

The initial display mode is used when creating top-level windows, sub windows
and overlays to determine the OpenGL display mode for the to-be-created window or overlay.
Page 3 of 22
9. glutInitWindowPosition

Sets the initial window position.

10. glutInitWindowSize

It specifies the size of the window to be created.

11. glvertex()

It is used to set the x,y,z vertex values.

12. glutBitmapCharacter

Displays an character on the screen.

13. glutSwapBuffers

Swaps between the front and back buffers.

14. glFlush()

Forces any buffered OpenGL commands to exec

15. glEnd()

Terminates a list of vertices.

Page 4 of 22
Chapter-2
REQUIREMENTS SPECIFICATION

3.1 Hardware requirements:


❖ Pentium or higher processor.
❖ 128 MB or more RAM.
❖ A standard keyboard, and Microsoft compatible mouse
❖ VGA monitor.

3.2 Software requirements:


❖ The graphics package has been designed for OpenGL; hence the machine must
Have Dev C++.
❖ Software installed preferably 6.0 or later versions with mouse driver installed.
❖ GLUT libraries, Glut utility toolkit must be available.
❖ Operating System: Windows
❖ Version of Operating System: Windows XP, Windows NT and Higher
❖ Language: C

Page 5 of 22
Chapter-3

INTERFACE AND ARCHITECTURE


3.1 Interface
Interface is to communicate between the user and the computer. It provides an
environment to communicate with the software using the hardware devices like mouse, joysticks,
keyboard etc

glutKeyboardFunc Function

▪ glutKeyboardFunc allow us to give input using keyboard.

SYNTAX:

void glutKeyboardFunc(unsigned char key, int x, int y);

PARAMETERS:

▪ Key : The pressed key ASCII value is stored in it.


▪ X and Y Gives the position of pointer.

glutMouseFunc Function

▪ glutMouseFunc allow us to give input using mouse.

SYNTAX:

void glutmouseFunc(int btn,int state, int x, int y);

Page 6 of 22
START
3.2 Architecture:

Character
control

KEYBOARD MOUSE

MOVEMENT

360 lookout

W forward

A left

S backward

D right

Q Increase
angle

Decrease
Z
angle

Page 7 of 22
Chapter-4
IMPLEMENTATION

➢ TO ENABLE MOUSE INTERFACE:


void mouseMovement(int x, int y)

int diffx=x-lastx; //check the difference between the current x and the last x position
int diffy=y-lasty; //check the difference between the current y and the last y position
lastx=x; //set lastx to the current x position
lasty=y; //set lasty to the current y position
xrot += (float) diffy;
if (xrot >140) xrot -= 140;
if (xrot < -90) xrot += 90; //set the xrot to xrot with the addition of the difference in
the y position
yrot += (float) diffx; //set the xrot to yrot with the addition of the difference in the
x position
}

➢ TO ENABLE KEYBOARD INTERFACE:


void keyboard (unsigned char key, int x, int y)

if (key=='q')
{
xrot += 1;
if (xrot >90) xrot -= 90;
}

if (key=='z')
{
xrot -= 1;
if (xrot < -90) xrot += 90;
}

if (key=='w')
Page 8 of 22
{
float xrotrad, yrotrad;
yrotrad = (yrot / 180 * 3.141592654f);
xrotrad = (xrot / 180 * 3.141592654f);
xpos += float(sin(yrotrad));
zpos -= float(cos(yrotrad));
ypos -= float(sin(xrotrad));
}

if (key=='s')
{
float xrotrad, yrotrad;
yrotrad = (yrot / 180 * 3.141592654f);
xrotrad = (xrot / 180 * 3.141592654f);
xpos -= float(sin(yrotrad));
zpos += float(cos(yrotrad));
ypos += float(sin(xrotrad));
}

if (key=='d')
{
float yrotrad;
yrotrad = (yrot / 180 * 3.141592654f);
xpos += float(cos(yrotrad));
zpos += float(sin(yrotrad));
}

if (key=='a')
{
float yrotrad;
yrotrad = (yrot / 180 * 3.141592654f);
xpos -= float(cos(yrotrad));
zpos -= float(sin(yrotrad));
}

if (key=='1')
{

glTranslatef(xpos,-100,zpos);
glutPostRedisplay();
}

Page 9 of 22
if (key=='2')
{
glTranslated(xpos,-200,zpos);
glFlush();
}

if (key=='3')
{

glTranslated(xpos,-400,zpos);

if (key==27)
{
exit(0);
}

➢ TO DRAW HOUSE:
void house1()

{
//front
glPushMatrix();
glColor3f(0.255,0.250,0.255);
glRotated(0,0,0,0);
glTranslated(0,0,0);
glScaled(80,70,0.5);
glutSolidCube(1);
glPopMatrix();
//back
glPushMatrix();
glColor3f(0.255,0.250,0.255);
glRotated(0,0,0,0);
glTranslated(0,0,60);

Page 10 of 22
glScaled(80,70,0.5);
glutSolidCube(1);
glPopMatrix();
}

➢ THIRD PERSON CAMERA:

void camera_man()
{
//camera and man
glTranslatef(0.0f,-5.0f, (-cRadius/2));//camera position
glRotatef(xrot,1.0,0.0,0.0);//camera rotation angle

//glColor3f(1.0f, 0.0f, 0.0f);


// glutSolidSphere(0.5,slices,stacks); //Our character to follow

glPushMatrix();
glTranslatef(0.0f,-2.0f,-cRadius);
glColor3f(1,1,0);
glScalef(0.9,1.8,1);
glutSolidSphere(1,slices,stacks);//chest
glPopMatrix();

glPushMatrix();
glTranslatef(0.0f,0.7f,-cRadius);
glColor3f(0.870588,0.721569,0.529412);
glScalef(0.8,1.3,0.8);
glutSolidSphere(1,slices,stacks);//head
glPopMatrix();

glPushMatrix();
glTranslatef(-1.2f,-1.3f,-cRadius);
glRotatef(-30,0,0,1);
glColor3f(1,1,0);
glScalef(0.3,1,0.3);
glutSolidSphere(1,slices,stacks);//left upper arm
glPopMatrix();

glPushMatrix();
glTranslatef(-1.5f,-2.9f,-cRadius-0.2);
glRotatef(20,1,0,0);

Page 11 of 22
glColor3f(0.870588,0.721569,0.529412);
glScalef(0.3,1,0.3);

glutSolidSphere(1,slices,stacks);//left lower arm


glPopMatrix();

glPushMatrix();
glTranslatef(1.2f,-1.3f,-cRadius);
glRotatef(30,0,0,1);
glColor3f(1,1,0);
glScalef(0.3,1,0.3);
glutSolidSphere(1,slices,stacks);//right upper arm
glPopMatrix();

glPushMatrix();
glTranslatef(1.5f,-2.9f,-cRadius-0.2);
glRotatef(20,1,0,0);
glColor3f(0.870588,0.721569,0.529412);
glScalef(0.3,1,0.3);
glutSolidSphere(1,slices,stacks);//right lower arm
glPopMatrix();

glPushMatrix();
glTranslatef(0.6f,-4.7f,-cRadius);
glRotatef(5,0,0,1);
glColor3f(0,0,1);
glScalef(0.4,1.3,0.3);
glutSolidSphere(1,slices,stacks);//right upper leg
glPopMatrix();

glPushMatrix();
glTranslatef(0.7f,-6.7f,-cRadius);
glRotatef(3,0,0,1);
glColor3f(0,0,1);
glScalef(0.3,1.2,0.27);
glutSolidSphere(1,slices,stacks);//right lower leg
glPopMatrix();

glPushMatrix();
glTranslatef(-0.6f,-4.7f,-cRadius);
glRotatef(-5,0,0,1);
glColor3f(0,0,1);
glScalef(0.4,1.3,0.3);
Page 12 of 22
glutSolidSphere(1,slices,stacks);//left upper leg
glPopMatrix();

glPushMatrix();
glTranslatef(-0.7f,-6.7f,-cRadius);
glRotatef(-3,0,0,1);
glColor3f(0,0,1);
glScalef(0.3,1.2,0.27);
glutSolidSphere(1,slices,stacks);//left lower leg
glPopMatrix();

glRotatef(yrot,0.0,1.0,0.0); //rotate our camera on the y-axis (up and down)


glTranslated(-xpos,-8.0f,-zpos); //translate the screento the position of our camera(lower body)

➢ STARS:
Void stars()
{
glPushMatrix();
glColor3f(0.9,0.91,0.98);
glTranslatef(0,400,330);
glutSolidSphere(4,slices,stacks);
glPopMatrix();
}

➢ MOON:
Void moon()
{
glPushMatrix();
glColor3f(0.9,0.9,0.9);
glTranslatef(500,700,-500);
glutSolidSphere(50,slices,stacks);

Page 13 of 22
glPopMatrix(); }

Chapter-5

SNAPSHOTS

Page 14 of 22
Page 15 of 22
Page 16 of 22
Chapter-6

FUTURE ENHANCEMENT

❖ The city can be developed into a Smart City.


❖ Different polygon filling algorithms can be used to provide textures to the buildings.
❖ Moving objects can be added on the roads by using collision preventing algorithm.
❖ Can implement traffic signal system.
❖ We can also implement smart street light system.

Page 17 of 22
Chapter-7

CONCLUSION

The Project has been developed as per requirements specified by the Vishweshwaraiah
Technological University as a partial fulfillment of the Computer Graphics Lab for 6 th Semester,
Computer Science and Engineering. All the requirements given have been implemented in the
project.

Page 18 of 22
Chapter-8

REFERENCES

Books:
1.Edward Angel-”Interactive computer Graphics A Top-Down Approach with OpenGL”,5th
edition,Addison-Wesley,2008.
2.“Computer Graphics”:Donald Hearn,M.Pauline Baker”.

Websites:
1.en.wikipedia.org/wiki/OpenGL
2.www.opengl.org/resources/code/samples/redbook

Page 19 of 22
Chapter-9

APPENDIX

9.1 User Manual

Opengl programs can be implemented using codeblocks software. For this purpose any edition of
codeblocks should be installed. The software can be acquired on the net or can be purchased
elsewhere.

First a simple setup must be run for installation. In accordance for the opengl programs to run
correctly some files need to be included in some of the folders of codeblocks after installation.

The procedure to install the glut libraries and dll's (to download it go to
http://reality.sgi.com/opengl/glut3/glut3.html ) is as follows:

1. After downloading the glut.zip file (you should get the latest ver. 3.7) unzip it into a folder

2. The folder must contain the following :

glut.dll

glut32.dll

glut.h

glut.lib

glut32.lib

3. Both glut.dll and glut32.dll must be copied into windows directory (windows or winnt,
depends on if you are using Windows95/98 or Windows NT)

4. Copy your glut.h to:

<drive>:\< codeblocks path>\include\GL\glut.h

*** The drive must be put where codeblocks was installed instead of the <drive> ***
Page 20 of 22
*** The directory must be put where codeblocks was installed instead of the < codeblocks path>

5. glut.lib and glut32.lib should be copied to:

<drive>:\< codeblocks path>\lib\glut.lib

<drive>:\< codeblocks path>\lib\glut32.lib

*** The drive must be put where codeblocks was installed instead of the <drive> ***

*** The directory must be put where d codeblocks was installed instead of the < codeblocks
path>

6. The above is the final step for installing glut libraries.

The procedure that follows shows how to start up an opengl project and setup the setting so as to
compile and run programs. This is assuming that the appropriate files are already downloaded
and installed in the directories as specified in their documentation.

1. Start codeblocks and create a new project.

2. The project has to be a "Win32 Console Application"

3. Type in the name of the project and where it will be on the hard drive.

4. Chose an empty project and click next or finish

5. First thing to be done when the project opens up is to click on the "Project" menu item from
the top.

Page 21 of 22
9.2 Personal Details

NAME: MOHAMMAD ASHIQ


USN: 1DT14CS048
SEMESTER : 6th Sem
DEPARTMENT : COMPUTER SCIENCE AND ENGINEERING
COLLEGE:DAYANANDA SAGAR ACADEMY OF TECHNOLOGY AND
MANAGEMENT
EMAIL ID: [email protected]

NAME: MANOJ V
USN: 1DT14CS045
SEMESTER : 6th Sem
DEPARTMENT: COMPUTER SCIENCE AND ENGINEERING
COLLEGE:DAYANANDA SAGAR ACADEMY OF TECHNOLOGY AND
MANAGEMENT
EMAIL ID: [email protected]

Page 22 of 22

You might also like