VISVESVARAYA TECHNOLOGICAL UNIVERSITY
BELGAUM-590014
A Computer Graphics and Visualization
Mini-Project Report
On
“CAR PARK”
A Mini-project report submitted in partial fulfilment of the requirements for the award of the
degree of Bachelor of Engineering in Computer Science and Engineering of Visvesvaraya
Technological University, Belgaum.
Submitted by:
CHANDRASHEKAR.G (1DT18CS031)
AND
LEELAVATHI.B (1DT19CS05)
Under the Guidance of:
Anoop G L
(Asst. Professor, Dept of CSE)
Rashmi K S
(Asst. Professor, Dept of CSE)
Department of Computer Science and Engineering
(Accredited by NBA, New Delhi)
DAYANANDA SAGAR ACADEMY OF TECHNOLOGY AND
MANAGEMENT
Kanakpura Road,Udayapura, Bangalore
2020-2021
DAYANANDA SAGAR ACADEMY OF TECHNOLOGY AND
MANAGEMENT,
Kanakpura Road,Udayapura, Bangalore
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
(Accredited by NBA, New Delhi)
CERTIFICATE
This is to certify that the Mini-Project on Computer Graphics and Visualization work entitled
“CAR PARK” has been successfully carried out by CHANDRASHEKAR.G (1DT18CS031)
And LEELAVATHI.B (1DT19CS405) a bonafide students of Dayananda Sagar Academy
of Technology and Management in partial fulfilment of the requirements for the award of
degree in Bachelor of Engineering in Computer Science and Engineering of Visvesvaraya
Technological University, Belgaum during academic year 2020-2021. It is certified that
all corrections/suggestions indicated for Internal Assessment have been incorporated in
the report deposited in the departmental library. The mini project report has been approved as it
satisfies the academic requirements in respect of project work for the said degree.
Anoop G L Rashmi K S
Asst. Professor Asst. Professor
Dr. C. NANDINI
(Vice Principal & HOD, Dept. of CSE)
Examiners: Signature with Date
1:
2:
ABSTRACT
The aim of this project is to create a 3-D/VIRTUAL CAR PARK. The viewer is allowed
to roam around in the parking area and see the cars closely and to drive a car and park it in the
car park area. The parking area is surrounded by a number of houses. First the co-ordinates of the
car is calculated and then using the OPENGL PRIMITIVES the car is constructed.
The PRIMITIVES used are:-
1. GL_LINES
2. GL_POLYGON
3. GL_QUADS
4. GL_TRIANGLE
In a similar way the 3D house is constructed. A display list is constructed for each of these
objects. These display lists are used everytime a car or house has to be constructed. So, to create
the 36 cars in the parking lot the “carr_display_list “ is called 36 times from within a loop and
are translated each time by suitable values to place them correctly. Similarly, to construct the
houses “house_display_list” is called and are suitably translated, scaled and rotated to place them
properly.
ACKNOWLEDGEMENT
While presenting this Graphics Project on “CAR PARK”, I feel that it is our duty to
acknowledge the help rendered to us by various persons.
Firstly I thank God for showering his blessings on me. I am grateful to my institution
Dayananda Sagar Academy of Technology for providing me a congenial atmosphere to carry out
the project successfully.
I would like to express my heartfelt gratitude to Dr.B R Lakshmikantha, Principal,
CEC, Bangalore, for extending his support.
I would also like to express my heartfelt gratitude to Dr.C Nandini, Prof. Vice
Principal & HOD, Computer Science and Engineering Department, whose guidance and
support was truly invaluable.
I am very grateful to my guide, Rashmi K S , Asst. Professor , Department of
Computer Science, for his/her valuable guidance and advice at every stage of my project
which helped me in the successful completion of my project.
I would also indebted to my Parents and Friends for their continued moral and material
support throughout the course of project and helping me in finalize the presentation.
My heartful thanks to all those have contributed bits, bytes and words to accomplish this
Project.
Thanking you all,
CHANDRASHEKAR.G (1DT18CS031)
LEELAVATHI.B (1DT19CS405)
TABLE OF CONTENTS
CHAPTER NO. CHAPTER NAME PAGE NO.
1. INTRODUCTION ………………… 1
1.1 Introduction To OpenGL…………………… 1
1.2 Computer Graphics ………………………..…. 1
1.3 A Brief History of OpenGL……………………. 2
1.3.1 What is OpenGL…………………………..3
1.3.2 Programming using OpenGL:
A first Introduction………….3
1.4 OpenGL(Open Graphics Library)……………….4
2 REQUIREMENT SPECIFICATION ………….5
2. 1Hardware Requirements ………………………….5
2. 2Software Requirements ………………………….5
3 SYSTEM DESIGN…………………………….6
3.1System Architecture.……………………………...6
4 IMPLEMENTATION…………………………7
4.1 Implementation of OpenGL Built in functions used.7
4. 2Implementation of User Defined functions……….9
5 SNAPSHOTS……..………………………………13
5.1Intialscene ……….………………………………13
5.2Frontview……..………………………………….14
5.3Topview….…………………………………….15
5.4Controlmenu……………………………………15
6 FUCTURE ENHANCEMENT……………...…18
REFERENCES………………………………..19
Appendix A.1:Source code…………………………….20
CAR PARK
CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION TO OPEN-GL
Computer Graphics is a complex and diversified technology.To technology
it is necessary to subdivide it into manageable Parts. This can be accomplished by
considering that the end product of computer graphics is a picture. The picture may, of
course, be used for a large variety of purposes; e.g., it may be an engineering drawing, an
exploded parts illustration for a service manual, a business graph, an architectural
rendering for a proposed construction or design project, an advertising illustration, or a
single frame from an animated movie. The picture is the c2 fundamental cohesive concept
in computer graphics.
Consider how: Pictures are represented in computer graphics.
• Pictures are prepared for presentation.
• Previously prepared pictures are presented.
• Interaction with the picture is accomplished.
Here “picture” is used in its broadest sense to mean any collection of lines, points, text, etc.
displayed on a graphics device.
1.2 Computer Graphics
The totality of computer graphics software encompasses the concepts from data
structures, from data base design and management, from the psychology, ergonometric of the
man-machine interface, from programming languages and operating system.
Numerous computer graphics standards can be grouped following categories.
• First is the graphics application interface, where ideas are translated into a form that is
understandable by a computer system. Current representative standards are the GKS,
[CSE, DSATM] 2020-21 Page 6
CAR PARK
GKS-3D, and the Programmer’s Hierarchical Interactive Graphics Standards (PHIGS).
• The Second is concerned with the storage and transmission of data between graphics
manufacturing systems. The current standard in this area is the Initial Graphics Exchange
Specification (IGES).
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.
Fig. 1.1: A graphics system
1.3 A Brief History Of OpenGl
OpenGL was developed by Silicon Graphics and is popular in the video games industry where it
competes with Direct3D on Microsoft Windows IrisGL, a propietary graphics API, is the
precursor of OpenGL. It is developed by Silicon Graphics Inc. (SGI). IrisGL was used as the
starting point of an open standard for computer graphics that would save time porting applications
by avoiding direct hardware access. After SGI cleaned up IrisGL and opened up the standard to
other companies, OpenGL was born.
In 1992 the OpenGL Architectural Review Board (OpenGL ARB) was established. The OpenGL
ARB is a group of companies that maintain and update the OpenGL standard.
[CSE, DSATM] 2020-21 Page 7
CAR PARK
In 2003 the first OpenGL (Exchange Specification) ES specification was released. OpenGL ES is
a subset of OpenGL designed for mobile phones, embedded devices and video game systems.
In 2004 the OpenGL 2.0 specification was released, including the GLSL (OpenGL Shading
1.3.1 What is Open-GL?
• OpenGL is a Software Interface to Graphics Hardware
• OpenGL is designed as a streamlined, hardware-independent interface to be implemented
on many different hardware platforms
• It Consists of about 250 Distinct Commands.
• It is Hardware-independent Interface
• No command for windows or user input handling
• Does not include low-level I/O management
• It is developed primarily by SGI
• It consists of 2D/3D graphics, lower-level primitives (polygons)
• It is Basis for higher-level libraries/toolkits
What does it do?
• Main purpose is to render two and three dimensional objects into a frame buffer. These
objects are described as sequences of vertices (which define geometric objects) or pixels
(which define images).
1.3.2 Programming using OpenGL: A first Introduction
OpenGL is an API …
• Application programmers’ interface: link between
• low-level: graphics hardware
• high-level: application program you write
OpenGL is a …
Library for 2D and 3D graphics programming
[CSE, DSATM] 2020-21 Page 8
CAR PARK
• 200+ functions for building application programs
• Portable to many platforms (Win, Mac, Unix, Linux)
• Callable from many programming languages (C, Java,Perl, Python)
Operations
• Specify geometric primitives (lines, pixels, polygons ...)
• Apply geometric transformations
• Specify camera, light, color, texture information, etc.
• No windowing or (platform-specific) input/interaction
• functions— these are the jobs of GLUT
1.4 OpenGL-Related Libraries
OpenGL provides a powerful but primitive set of rendering commands, and all higher-level
drawing must be done in terms of these commands. Also, OpenGL programs have to use the
underlying mechanisms of the windowing system. A number of libraries exist to allow you to
simplify your programming tasks, including the following:
• The OpenGL Utility Library (GLU) contains several routines that use lower-level OpenGL
commands to perform such tasks as setting up matrices for specific viewing orientations and
projections, performing polygon tessellation, and rendering surfaces. GLU routines use the
prefix glu.
• The OpenGL Utility Toolkit (GLUT) is a window system-independent toolkit, written by
Mark Kilgard, to hide the complexities of differing window system APIs. GLUT is the
subject of the next section, and it’s described in more detail in Mark Kilgard’s book
OpenGL Programming for the X Window System (ISBN 0-201-48359-9). GLUT routines
use the prefix glut. "How to Obtain the Sample Code" in the Preface describes how to
obtain the source code for GLUT, using ftp.
[CSE, DSATM] 2020-21 Page 9
CAR PARK
CHAPTER 2
REQUIREMENTS SPECIFICATION
2.1 HARDWARE REQUIREMENTS
• Processor : Pentium PC
• RAM : 512MB
• Hard Disk : 20GB(approx)
• Display : VGA Color Monitor
2.2 SOFTWARE CONSTRAINTS
• Operating System : Windows 98SE/2000/XP/Vista/UBUNTU
• Language : Open Gl
• Compiler : Eclipse/Microsoft Visual studio 2005
2.3 MISCELLANEOUS REQUIREMENTS:
All the required library and header files should be available in the include directories. The files
associated with this editor should be placed in either the same folder or in a specified folder.
2.4 LANGUAGE USED IN CODING:
C/C++ and OpenGL as an API.
[CSE, DSATM] 2020-21 Page 10
CAR PARK
CHAPTER 3
SYSTEM DESIGN
Design of any software depends on the architecture of the machine on which that software
runs, for which the designer needs to know the system architecture. Design process involves
design of suitable algorithms, modules, subsystems, interfaces etc.
3.1 System Architecture
CONTROL FLOW DIAGRAM
Fig. 3.1: System Control flow diagram
[CSE, DSATM] 2020-21 Page 11
CAR PARK
CHAPTER 4
IMPLEMENTATION
The implementation stage of this model involves the following phases.
• Implementation of OpenGL built in functions.
• User defined function Implementation.
4.1 Implementation of OpenGL Built In Functions used:
1.glutInit():
glutInit is used to initialize the GLUT library.
Usage:void glutInit(int *argcp, char **argv);
Description:glutInit will initialize the GLUT library and negotiate a session with the window
system.
2.glutInitDisplayMode():
glutInitDisplayMode sets the initial display mode.
Usage:void glutInitDisplayMode (unsigned int mode);
Mode-Display mode, normally the bitwise OR-ing of GLUT display mode bit masks.
Description: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.
3.glutCreateWindow(): glutCreateWindow
creates a top-level window.
Usage:intglutCreateWindow(char *name);
Name - ASCII character string for use as window name.
Description:glutCreateWindow creates a top-level window. The name will be provided to the
window system as the window's name. The intent is that thewindow system will label the
window with the name. Implicitly, the currentwindowis set to thenewly created window. Each
created window has a unique associated OpenGL context.
[CSE, DSATM] 2020-21 Page 12
CAR PARK
4.glutDisplayFunc():
glutDisplayFunc sets the display callback for the current window.
Usage:void glutDisplayFunc(void (*func)(void));
Func- The new display callback function.
Description:glutDisplayFunc sets the display callback for the current window. When GLUT
determines that the normal plane for the window needs to be redisplayed, the display callback for
the window is called. Before the callback, the current window is set to the window needing to be
redisplayed and the layer in use is set to the normal plane. The display callback is called with no
parameters. The entire normal plane region should be redisplayed in response to the callback.
5.glutMainLoop():
glutMainLoop enters the GLUT event processing loop.
Usage:void glutMainLoop(void);
Description: glutMainLoop enters the GLUT event processing loop. This routine should be
called at most once in a GLUT program. Once called, this routine will never return. It will call as
necessary any callbacks that have been registered.
6.glMatrixMode( ):
The two most important matrices are the model-view and projection matrix. At any time, the
state includes values for both of these matrices, which are initially set to identity matrices. There
is only a single set of functions that can be applied to any type of matrix. Select the matrix to
which the operations apply by first set in the matrix mode, a variable that is set to one type of
matrix and is also part of the state.
7.glutTimerFunc();
glutTimerFunc registers a timer callback to be triggered in a specified number of milliseconds.
Usage:voidglutTimerFunc(unsigned intmsecs,void (*func)(int value), value);
Description:glutTimerFunc registers the timer callback func to be triggered in at least msecs
CSE, DSATM 2020-21 Page 10
CAR PARK
milliseconds. The value parameter to the timer callback will be the value of the value parameter
to glutTimerFunc. Multiple timer callbacks at same or differing times may be registered
simultaneously. The number of milliseconds is a lower bound on the time before the callback is
generated. GLUT attempts to deliver the timer callback as soon as possible after the expiration of
the callback's time interval. There is no support for canceling a registered callback. Instead,
ignore a callback based on its value parameter when it is triggered.
4.2 Implementation of User Defined Functions:
1.void myInit(void):
Here the initialization function init() is used to set the OpenGL state variables dealing with
viewing and attributes-parameters that is prefered to set once, independently of the display
function.
2.void circle(float x,float y,double r):
Here the function circle() is used to draw the curves in the cloud and sun it basically uses
OpenGL glVertex() having ‘x’ and ‘y’ attributes specifying ‘x’ and ‘y’ co-ordinate position
respectively.
3.void Sun():
Basically this function is used to draw Sun on the Screen by calling circle() function and we use
glColor3f() to give color to the sun.
4.void sky():
This function is the baground for sun and cloud using glBegin(QUADS).we have done sky the
light is incidented from sun which is traversed throw sky.
5.void river():
This function is used to draw river we have used glBegin(QUADS) up on which incident
refraction takes place in river.
CSE, DSATM 2020-21 Page 11
CAR PARK
6.void normal():
7.void line1(),void line2():
This functions is used to draw incident and refracted ray respectively rays are drawn using
glBegin(GL_LINES) and the rays are moved using mathametical function.
8.void Cloud1(), void Cloud2(), void Cloud3():
This functions is used to draw the cloud using combinations of circle() function and is moved
using glTranslate() function.
9.fish1(),fish2(),fish3():
This functions is used to draw the fishes using the combination of gl(QUADS) and
gl(TRIANGLES), and gl(POINTS) is used to draw the eyes for the fish.
10.DrawTrees():
This function is used to draw the tree in the water, the trees is drawn using
glBegin(GL_POLYGON);
11.void bitmap(int x, int y, char *string,void *font):
This function takes the following parameters ‘x’ and ‘y’ co-ordinate pixel position , the string
which has to displayed in the screen and the font size of the string which has to be displayed on
the screen. glRasterPos2f(x,y); is used to do display the string.
12.void fonts():
This function contains one dimensional array the content of the array is the various font styles, in
which we have specified the various font styles used to display the Strings on the screen.
13.void menu():
This function is used to display the menu content using bitmap() function.
CSE, DSATM 2020-21 Page 12
CAR PARK
14.void discription():
This function is used to display the Snell’s law definition using bitmap() function.
15.void incident_Display(), void refraction_Display() :
This functions specify incident and refraction display respectively in this function we have called
the used defined functions based up on the requirement.
16.void menuset():
This function is used in the Display() function to diplay the content for each frame on the screen
based up on the key pressed in the keyboard using glMatrixMode(GL_PROJECTION); and
glMatrixMode(GL_MODELVIEW); .
17.Display():
In this function we have used the flag and depending on the flag the corresponding frame is
displayed on the screen.
18.void keyboardFunc( unsigned char key, int x, int y ):
This function has following parameters char which represents the the character on the keyboard
depending up the character we have pressed the corresponding flag bit is enabled and the content
is displayed accordingly x and y are the pixel position.
19.void TimeEvent(int values):
This function is used to move the ray of light.This function uses “glutTimerFunc()” that calls
back this function once timer ellapses.
20. void mouse(int btn, int state, int x, int y):
This function is used to get the x and y co-ordinate value which was helpful while drawing an
objects.
CSE, DSATM 2020-21 Page 13
CAR PARK
21. int main(argc, char ** argv):
This is the function from where the execution of the program begins.
In this function we have certain “gl” functions used to initialize the basic glut window with
desired properties. After initialization the display function is called with respect to the window
and finally the last statement of this section is the glutMainLoop(). Which is an event processing
function that enters into an infinite loop.
CSE, DSATM 2020-21 Page 14
CAR PARK
CHAPTER 5
SNAPSHOTS
Fig 5.1
5.1: INITIAL SCENE:
This is the first scene which appears when the program is executed.
CSE, DSATM 2020-21 Page 15
CAR PARK
5.2 FRONT VIEW :
On pressing the “S” key the camera moves backwards and upwards simultaneously. The user can
press “W” key to move the camera in the front direction in the same way but the path traversed is
exactly opposite.
Fig. 5.2:FRONT VIEW
CSE, DSATM 2020-21 Page 16
CAR PARK
Fig. 5.3:TOP VIEW
Explanation of the figure
On pressing the “t” key the camera changes to a position so that the user can see the top view of the
whole parking area.
CSE, DSATM 2020-21 Page 17
CAR PARK
Fig. 5.4: CONTROL MENU
The controls are:-
1. UP KEY - > to move the viewer in forward direction.
2. DOWN KEY - > to move the viewer in backwards direction.
3. LEFT KEY - > to rotate the camera to the left of the viewer.
4. RIGHT KEY - > to rotate the camera to the right of the viewer.
5. T - >top view.
6. S - > to move away.
7. W - >to move near.
8. D - > to move right.
9. A - > to move left.
10. Q - >quit
CSE, DSATM 2020-21 Page 18
CAR PARK
CHAPTER 6
FUTURE ENHANCEMENT
The currently developed project can improve in many areas. Time constraint and deficient
knowledge has been a major factor in limiting the features offered by this display model.
The following features were thought a propos, but not implemented.
• More interactive feature addition.
• Implementing the project in 3D.
• Adding arc to the Car park.
• Adding score to the Car park.
• Adding more features to the Car park.
• Adding more powers to the Car park.
• Making the view for different resolution
CSE, DSATM 2020-21 Page 19
CAR PARK
REFERENCES
1. Interactive Computer Graphics A Top-Down Approach with OpenGL -
Edward Angel, 5 th Edition, Addison-Wesley, 2008
2. The Official Guide to Learning OpenGL, by Jackie Neider, Tom Davis,
Mason Woo (THE RED BOOK)
3. OpenGL Super Bible by Richard S. Wright, Jr. and Michael Sweet
4. http://www.cs.rutgers.edu/~decarlo/428/glman.html online man pages.
5. http://www.opengl.org/sdk/docs/man online man pages.
6. http://nehe.gamedev.net OpenGL tutorial
CSE, DSATM 2020-21 Page 20
CAR PARK
APPENDIX
A1: SOURCE CODE
#include <GL/glut.h>
#include <math.h>
#include <stdlib.h>
static float angle = 0.0, ratio;
static float x = 0.0f, y = 1.75f, z = 5.0f;
static float lx = 0.10f, ly = 0.10f, lz = -1.0f;
static GLint carr_display_list, house_display_list;
float theta = 0.01, fxincr = 0.1, fzincr = 0, temp, theta1, fx = -10, fz = 80;
int xxxx = 0, yyyy = 0, kk = 0, housevisible = 0, movecarvar = 0;
int
a[36] = { 55,97,44,152,55,171,108,86,168,99,147,207,238,55,233,167,105,80,134,29
,253,130,32,240,110,199,224,121,93,199,180,61,110,251,77,237 };
int
b[36] = { 102,194,110,152,153,184,137,113,55,138,104,43,240,255,203,8,100,53,88,
64,127,64,87,5,2,144,211,128,10,89,27,11,175,185,157,241 };
int
c[36] = { 159,243,133,253,233,228,141,18,46,195,75,52,253,204,169,30,78,94,68,11
,4,2,33,12,2,25,195,76,26,54,98,103,205,173,65,242 };
void changeSize(int w, int h)
CSE, DSATM 2020-21 Page 21
CAR PARK
if (h == 0) // Prevent a divide by zero, when window is too
short
// (you cant make a window of zero width).
h = 1;
ratio = 1.0f * w / h; // Reset the coordinate system before modifying
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h); // Set the viewport to be the entire window
gluPerspective(45, ratio, 1, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(x, y, z, x + lx, y + ly, z + lz, 0.0f, 1.0f, 0.0f);
void drawcarr()
glTranslatef(.0, 0.8, 0.0);
glEnable(GL_BLEND); //TRANCPARENCY1
glBlendFunc(GL_ONE, GL_ZERO);//TRANCPARENCY2
glBegin(GL_LINE_LOOP);
glVertex3f(-1.12, -.48, 0.7);//a
glVertex3f(-0.86, -.48, 0.7);//b
glVertex3f(-.74, -0.2, 0.7);//c
glVertex3f(-.42, -.2, 0.7);//d
glVertex3f(-0.3, -.48, 0.7);//e
CSE, DSATM 2020-21 Page 22
CAR PARK
glVertex3f(.81, -0.48, 0.7);//f
glVertex3f(.94, -0.2, 0.7);//g
glVertex3f(1.24, -.2, 0.7);//h
glVertex3f(1.38, -.48, 0.7);//i
glVertex3f(1.52, -.44, 0.7);//j
glVertex3f(1.52, .14, 0.7);//k
glVertex3f(1.14, 0.22, 0.7);//l
glVertex3f(0.76, .22, 0.7);//m
glVertex3f(.52, 0.56, 0.7);//n
glVertex3f(-0.1, 0.6, 0.7);//0
glVertex3f(-1.02, 0.6, 0.7);//p
glVertex3f(-1.2, 0.22, 0.7);//q
glVertex3f(-1.2, -.28, 0.7);//r
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(-1.12, -.48, -0.7);//a'
glVertex3f(-0.86, -.48, -0.7);//b'
glVertex3f(-.74, -0.2, -0.7);//c'
glVertex3f(-.42, -.2, -0.7);//d'
glVertex3f(-0.3, -.48, -0.7);//e'
glVertex3f(.81, -0.48, -0.7);//f'
glVertex3f(.94, -0.2, -0.7);//g'
glVertex3f(1.24, -.2, -0.7);//h'
glVertex3f(1.38, -.48, -0.7);//i'
glVertex3f(1.52, -.44, -0.7);//j'
CSE, DSATM 2020-21 Page 23
CAR PARK
glVertex3f(1.52, .14, -0.7);//k'
glVertex3f(1.14, 0.22, -0.7);//l'
glVertex3f(0.76, .22, -0.7);//m'
glVertex3f(.52, 0.56, -0.7);//n'
glVertex3f(-0.1, 0.6, -0.7);//o'
glVertex3f(-1.02, 0.6, -0.7);//p'
glVertex3f(-1.2, 0.22, -0.7);//q'
glVertex3f(-1.2, -.28, -0.7);//r'
glEnd();
glBegin(GL_LINES);
glVertex3f(-1.12, -.48, 0.7);//a
glVertex3f(-1.12, -.48, -0.7);//a'
glVertex3f(-0.86, -.48, 0.7);//b
glVertex3f(-0.86, -.48, -0.7);//b'
glVertex3f(-.74, -0.2, 0.7);//c
glVertex3f(-.74, -0.2, -0.7);//c'
glVertex3f(-.42, -.2, 0.7);//d
glVertex3f(-.42, -.2, -0.7);//d'
glVertex3f(-0.3, -.48, 0.7);//e
glVertex3f(-0.3, -.48, -0.7);//e'
glVertex3f(.81, -0.48, 0.7);//f
glVertex3f(.81, -0.48, -0.7);//f'
glVertex3f(.94, -0.2, 0.7);//g
glVertex3f(.94, -0.2, -0.7);//g'
glVertex3f(1.24, -.2, 0.7);//h
CSE, DSATM 2020-21 Page 24
CAR PARK
glVertex3f(1.24, -.2, -0.7);//h'
glVertex3f(1.38, -.48, 0.7);//i
glVertex3f(1.38, -.48, -0.7);//i'
glVertex3f(1.52, -.44, 0.7);//j
glVertex3f(1.52, -.44, -0.7);//j'
glVertex3f(1.52, .14, 0.7);//k
glVertex3f(1.52, .14, -0.7);//k'
glVertex3f(1.14, 0.22, 0.7);//l
glVertex3f(1.14, 0.22, -0.7);//l'
glVertex3f(0.76, .22, 0.7);//m
glVertex3f(0.76, .22, -0.7);//m'
glVertex3f(.52, 0.56, 0.7);//n
glVertex3f(.52, 0.56, -0.7);//n'
glVertex3f(-0.1, 0.6, 0.7);//0
glVertex3f(-0.1, 0.6, -0.7);//o'
glVertex3f(-1.02, 0.6, 0.7);//p
glVertex3f(-1.02, 0.6, -0.7);//p'
glVertex3f(-1.2, 0.22, 0.7);//q
glVertex3f(-1.2, 0.22, -0.7);//q'
glVertex3f(-1.2, -.28, 0.7);//r
glVertex3f(-1.2, -.28, -0.7);//r'
glEnd();
glBegin(GL_POLYGON); // top filling
glVertex3f(-0.1, 0.6, 0.7);//o
glVertex3f(-0.1, 0.6, -0.7);//o'
CSE, DSATM 2020-21 Page 25
CAR PARK
glVertex3f(-1.02, 0.6, -0.7);//p'
glVertex3f(-1.02, 0.6, 0.7);//p
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-0.1, 0.6, 0.7);//o
glVertex3f(-0.1, 0.6, -0.7);//o'
glVertex3f(.52, 0.56, -0.7);//n'
glVertex3f(.52, 0.56, 0.7);//n
glEnd();
glBegin(GL_POLYGON); //back filling
glVertex3f(-1.2, 0.22, 0.7);//q
glVertex3f(-1.2, 0.22, -0.7);//q'
glVertex3f(-1.2, -.28, -0.7);//r'
glVertex3f(-1.2, -.28, 0.7);//r
glEnd();
glBegin(GL_POLYGON);
glVertex3f(1.52, .14, 0.7);//k
glVertex3f(1.14, 0.22, 0.7);//l
glVertex3f(1.14, 0.22, -0.7);//l'
glVertex3f(1.52, .14, -0.7);//k'
glEnd();
glBegin(GL_POLYGON);
glVertex3f(0.76, .22, 0.7);//m
glVertex3f(0.76, .22, -0.7);//m'
glVertex3f(1.14, 0.22, -0.7);//l'
CSE, DSATM 2020-21 Page 26
CAR PARK
glVertex3f(1.14, 0.22, 0.7);//l
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-1.12, -.48, 0.7);//a
glVertex3f(-0.86, -.48, 0.7);//b
glVertex3f(-.74, -0.2, 0.7);//c
glVertex3f(-0.64, 0.22, 0.7);//cc
glVertex3f(-1.08, 0.22, 0.7);//dd
glVertex3f(-1.2, 0.22, 0.7);//q
glVertex3f(-1.2, -.28, 0.7);//r
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-.74, -0.2, 0.7);//c
glVertex3f(-0.64, 0.22, 0.7);//cc
glVertex3f(-0.5, 0.22, 0.7);//hh
glVertex3f(-0.5, -0.2, 0.7);//pp
glEnd();
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.22, 0.7);//gg
glVertex3f(1.14, 0.22, 0.7);//l
glVertex3f(1.24, -.2, 0.7);//h
glVertex3f(0.0, -0.2, 0.7);//oo
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-1.12, -.48, -0.7);//a'
CSE, DSATM 2020-21 Page 27
CAR PARK
glVertex3f(-0.86, -.48, -0.7);//b'
glVertex3f(-.74, -0.2, -0.7);//c'
glVertex3f(-0.64, 0.22, -0.7);//cc'
glVertex3f(-1.08, 0.22, -0.7);//dd'
glVertex3f(-1.2, 0.22, -0.7);//q'
glVertex3f(-1.2, -.28, -0.7);//r'
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-.74, -0.2, -0.7);//c'
glVertex3f(-0.64, 0.22, -0.7);//cc'
glVertex3f(-0.5, 0.22, -0.7);//hh'
glVertex3f(-0.5, -0.2, -0.7);//pp'
glEnd();
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.22, -0.7);//gg'
glVertex3f(1.14, 0.22, -0.7);//l'
glVertex3f(1.24, -.2, -0.7);//h'
glVertex3f(0.0, -0.2, -0.7);//oo'
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-1.2, 0.22, 0.7);//q
glVertex3f(-1.08, 0.22, 0.7);//dd
glVertex3f(-0.98, 0.5, 0.7);//aa
glVertex3f(-1.02, 0.6, 0.7);//p
glEnd();
CSE, DSATM 2020-21 Page 28
CAR PARK
glBegin(GL_POLYGON);
glVertex3f(-1.02, 0.6, 0.7);//p
glVertex3f(-0.98, 0.5, 0.7);//aa
glVertex3f(0.44, 0.5, 0.7);//jj
glVertex3f(.52, 0.56, 0.7);//n
glVertex3f(-0.1, 0.6, 0.7);//0
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-0.64, 0.5, 0.7);//bb
glVertex3f(-0.64, 0.22, 0.7);//cc
glVertex3f(-0.5, 0.22, 0.7);//hh
glVertex3f(-0.5, 0.5, 0.7);//ee
glEnd();
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.5, 0.7);//ff
glVertex3f(0.0, 0.22, 0.7);//gg
glVertex3f(0.12, 0.22, 0.7);//ll
glVertex3f(0.12, 0.5, 0.7);//ii
glEnd();
glBegin(GL_POLYGON);
glVertex3f(.52, 0.56, 0.7);//n
glVertex3f(0.44, 0.5, 0.7);//jj
glVertex3f(0.62, 0.22, 0.7);//kk
glVertex3f(0.76, .22, 0.7);//m
glEnd();
CSE, DSATM 2020-21 Page 29
CAR PARK
glBegin(GL_POLYGON);
glVertex3f(-.42, -.2, 0.7);//d
glVertex3f(.94, -0.2, 0.7);//g
glVertex3f(.81, -0.48, 0.7);//f
glVertex3f(-0.3, -.48, 0.7);//e
glEnd();
glBegin(GL_POLYGON);
glVertex3f(1.14, 0.22, 0.7);//l
glVertex3f(1.52, .14, 0.7);//k
glVertex3f(1.52, -.44, 0.7);//j
glVertex3f(1.38, -.48, 0.7);//i
glVertex3f(1.24, -.2, 0.7);//h
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-1.2, 0.22, -0.7);//q'
glVertex3f(-1.08, 0.22, -0.7);//dd'
glVertex3f(-0.98, 0.5, -0.7);//aa'
glVertex3f(-1.02, 0.6, -0.7);//p'
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-1.02, 0.6, -0.7);//p'
glVertex3f(-0.98, 0.5, -0.7);//aa'
glVertex3f(0.44, 0.5, -0.7);//jj'
glVertex3f(.52, 0.56, -0.7);//n'
glVertex3f(-0.1, 0.6, -0.7);//0'
CSE, DSATM 2020-21 Page 30
CAR PARK
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-0.64, 0.5, -0.7);//bb'
glVertex3f(-0.64, 0.22, -0.7);//cc'
glVertex3f(-0.5, 0.22, -0.7);//hh'
glVertex3f(-0.5, 0.5, -0.7);//ee'
glEnd();
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.5, -0.7);//ff'
glVertex3f(0.0, 0.22, -0.7);//gg'
glVertex3f(0.12, 0.22, -0.7);//ll'
glVertex3f(0.12, 0.5, -0.7);//ii'
glEnd();
glBegin(GL_POLYGON);
glVertex3f(.52, 0.56, -0.7);//n'
glVertex3f(0.44, 0.5, -0.7);//jj'
glVertex3f(0.62, 0.22, -0.7);//kk'
glVertex3f(0.76, .22, -0.7);//m'
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-.42, -.2, -0.7);//d'
glVertex3f(.94, -0.2, -0.7);//g'
glVertex3f(.81, -0.48, -0.7);//f'
glVertex3f(-0.3, -.48, -0.7);//e'
glEnd();
CSE, DSATM 2020-21 Page 31
CAR PARK
glBegin(GL_POLYGON);
glVertex3f(1.14, 0.22, -0.7);//l'
glVertex3f(1.52, .14, -0.7);//k'
glVertex3f(1.52, -.44, -0.7);//j'
glVertex3f(1.38, -.48, -0.7);//i'
glVertex3f(1.24, -.2, -0.7);//h'
glEnd();
glBegin(GL_POLYGON); // door1 body- rear, near
glVertex3f(-0.5, 0.22, 0.7);//hh
glVertex3f(0.0, 0.22, 0.7);//gg
glVertex3f(0.0, -0.2, 0.7);//oo
glVertex3f(-0.5, -0.2, 0.7);//pp
glEnd();
glBegin(GL_POLYGON); // door body- rear, far
glVertex3f(-0.5, 0.22, -0.7);//hh'
glVertex3f(0.0, 0.22, -0.7);//gg'
glVertex3f(0.0, -0.2, -0.7);//oo'
glVertex3f(-0.5, -0.2, -0.7);//pp'
glEnd();
glBegin(GL_POLYGON); // door2 body- near, driver
glVertex3f(0.12, 0.22, 0.7);//ll
glVertex3f(0.62, 0.22, 0.7);//kk
glVertex3f(0.62, -0.2, 0.7);//mm
glVertex3f(0.12, -0.2, 0.7);//nn
glEnd();
CSE, DSATM 2020-21 Page 32
CAR PARK
glBegin(GL_POLYGON); // door2 body- far, driver
glVertex3f(0.12, 0.22, -0.7);//ll'
glVertex3f(0.62, 0.22, -0.7);//kk'
glVertex3f(0.62, -0.2, -0.7);//mm'
glVertex3f(0.12, -0.2, -0.7);//nn'
glEnd();
glBegin(GL_POLYGON);//front**
glVertex3f(1.52, .14, 0.7);//k
glVertex3f(1.52, .14, -0.7);//k'
glVertex3f(1.52, -.44, -0.7);//j'
glVertex3f(1.52, -.44, 0.7);//j
glEnd();
glTranslatef(-.58, -.52, 0.7); //translate to 1st tyre
glColor3f(0.09, 0.09, 0.09); // tyre color********
glutSolidTorus(0.12f, .14f, 10, 25);
glTranslatef(1.68, 0.0, 0.0); //translate to 2nd tyre
glutSolidTorus(0.12f, .14f, 10, 25);
glTranslatef(0.0, 0.0, -1.4); //translate to 3rd tyre
glutSolidTorus(0.12f, .14f, 10, 25);
glTranslatef(-1.68, 0.0, 0.0); //translate to 4th tyre which is behind 1st tyrerearback
glutSolidTorus(0.12f, .14f, 10, 25);
glTranslatef(.58, .52, 0.7); //translate to origin
glRotatef(90.0, 0.0, 1.0, 0.0);
glTranslatef(0.0, 0.0, -1.40);
glutSolidTorus(0.2f, .2f, 10, 25);
CSE, DSATM 2020-21 Page 33
CAR PARK
glTranslatef(0.0, 0.0, 1.40);
glRotatef(270.0, 0.0, 1.0, 0.0);
glBegin(GL_POLYGON); //bottom filling
glColor3f(0.25, 0.25, 0.25);
glVertex3f(-0.3, -.48, 0.7);//e
glVertex3f(-0.3, -.48, -0.7);//e'
glVertex3f(.81, -0.48, -0.7);//f'
glVertex3f(.81, -0.48, 0.7);//f
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-.42, -.2, 0.7);//d
glVertex3f(-.42, -.2, -0.7);//d'
glVertex3f(-0.3, -.48, -0.7);//e'
glVertex3f(-0.3, -.48, 0.7);//e
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-1.2, -.28, 0.7);//r
glVertex3f(-1.2, -.28, -0.7);//r'
glVertex3f(-1.12, -.48, -0.7);//a'
glVertex3f(-1.12, -.48, 0.7);//a
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-1.12, -.48, 0.7);//a
glVertex3f(-1.12, -.48, -0.7);//a'
glVertex3f(-0.86, -.48, -0.7);//b'
CSE, DSATM 2020-21 Page 34
CAR PARK
glVertex3f(-0.86, -.48, 0.7);//b
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-0.86, -.48, 0.7);//b
glVertex3f(-0.86, -.48, -0.7);//b'
glVertex3f(-.74, -0.2, -0.7);//c'
glVertex3f(-.74, -0.2, 0.7);//c
glEnd();
glBegin(GL_POLYGON);
glVertex3f(-.74, -0.2, 0.7);//c
glVertex3f(-.74, -0.2, -0.7);//c'
glVertex3f(-.42, -.2, -0.7);//d'
glVertex3f(-.42, -.2, 0.7);//d
glEnd();
glBegin(GL_POLYGON);
glVertex3f(.81, -0.48, 0.7);//f
glVertex3f(.81, -0.48, -0.7);//f'
glVertex3f(.94, -0.2, -0.7);//g'
glVertex3f(.94, -0.2, 0.7);//g
glEnd();
glBegin(GL_POLYGON);
glVertex3f(.94, -0.2, 0.7);//g
glVertex3f(.94, -0.2, -0.7);//g'
glVertex3f(1.24, -.2, -0.7);//h'
glVertex3f(1.24, -.2, 0.7);//h
CSE, DSATM 2020-21 Page 35
CAR PARK
glEnd();
glBegin(GL_POLYGON);
glVertex3f(1.24, -.2, 0.7);//h
glVertex3f(1.24, -.2, -0.7);//h'
glVertex3f(1.38, -.48, -0.7);//i'
glVertex3f(1.38, -.48, 0.7);//i
glEnd();
glBegin(GL_POLYGON);
glVertex3f(1.38, -.48, 0.7);//i
glVertex3f(1.38, -.48, -0.7);//i'
glVertex3f(1.52, -.44, -0.7);//j'
glVertex3f(1.52, -.44, 0.7);//j
glEnd();
glBegin(GL_LINE_LOOP); // door outline- rear, front
glColor3f(1.0, 1.0, 1.0);
glVertex3f(-0.5, 0.22, 0.7);//hh
glVertex3f(0.0, 0.22, 0.7);//gg
glVertex3f(0.0, -0.2, 0.7);//oo
glVertex3f(-0.5, -0.2, 0.7);//pp
glEnd();
glBegin(GL_LINE_LOOP); // door2 outline- near, driver
glVertex3f(0.12, 0.22, 0.7);//ll
glVertex3f(0.62, 0.22, 0.7);//kk
glVertex3f(0.62, -0.2, 0.7);//mm
glVertex3f(0.12, -0.2, 0.7);//nn
CSE, DSATM 2020-21 Page 36
CAR PARK
glEnd();
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_LINE_LOOP); // door2 outline- far, driver
glVertex3f(0.12, 0.22, -0.7);//ll'
glVertex3f(0.62, 0.22, -0.7);//kk'
glVertex3f(0.62, -0.2, -0.7);//mm'
glVertex3f(0.12, -0.2, -0.7);//nn'
glEnd();
glBegin(GL_LINE_LOOP); // door outline- rear, far
glVertex3f(-0.5, 0.22, -0.7);//hh'
glVertex3f(0.0, 0.22, -0.7);//gg'
glVertex3f(0.0, -0.2, -0.7);//oo'
glVertex3f(-0.5, -0.2, -0.7);//pp'
glEnd();
glBegin(GL_POLYGON); //front**
glVertex3f(1.52, .14, 0.7);//k
glVertex3f(1.52, .14, -0.7);//k'
glVertex3f(1.52, -.44, -0.7);//j'
glVertex3f(1.52, -.44, 0.7);//j
glEnd();
glColor3f(0.0, 0.0, 1.0);
// transparent objects are placed next ..
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//TRANCPARENCY3
//windscreen
CSE, DSATM 2020-21 Page 37
CAR PARK
glBegin(GL_POLYGON);
glColor4f(0.0, 0.0, 0.0, 0.7); //COLOR =WHITE TRANSPARENT
glVertex3f(0.562, .5, .6);//AAA
glVertex3f(.562, .5, -.6);//AAA'
glVertex3f(.76, .22, -.6);//MMM'
glVertex3f(.76, .22, .6);//MMM
glEnd();
glBegin(GL_POLYGON); //rear window
//COLOR =WHITE TRANSPARENT
glVertex3f(-1.068, 0.5, 0.6);//pp
glVertex3f(-1.068, 0.5, -0.6);//pp'
glVertex3f(-1.2, 0.22, -0.6);//qq'
glVertex3f(-1.2, 0.22, 0.6);//qq
glEnd();
glBegin(GL_POLYGON); //leftmost window front
glVertex3f(-0.98, 0.5, 0.7);//aa
glVertex3f(-0.64, 0.5, 0.7);//bb
glVertex3f(-0.64, 0.22, 0.7);//cc
glVertex3f(-1.08, 0.22, 0.7);//dd
glEnd();
glBegin(GL_POLYGON); //leftmost window back
glVertex3f(-0.98, 0.5, -0.7);//aa
glVertex3f(-0.64, 0.5, -0.7);//bb
glVertex3f(-0.64, 0.22, -0.7);//cc
glVertex3f(-1.08, 0.22, -0.7);//dd
CSE, DSATM 2020-21 Page 38
CAR PARK
glEnd();
glBegin(GL_POLYGON); //middle window front
glVertex3f(-0.5, 0.5, 0.7);
glVertex3f(0.0, 0.5, 0.7);
glVertex3f(0.0, 0.22, 0.7);
glVertex3f(-0.5, 0.22, 0.7);
glEnd();
glBegin(GL_POLYGON); //middle window back
glVertex3f(-0.5, 0.5, -0.7);
glVertex3f(0.0, 0.5, -0.7);
glVertex3f(0.0, 0.22, -0.7);
glVertex3f(-0.5, 0.22, -0.7);
glEnd();
glBegin(GL_POLYGON); //rightmost window front
glVertex3f(0.12, 0.5, 0.7);//ii
glVertex3f(0.44, 0.5, 0.7);//jj
glVertex3f(0.62, 0.22, 0.7);//kk
glVertex3f(0.12, 0.22, 0.7);//ll
glEnd();
glBegin(GL_POLYGON); //rightmost window back
glVertex3f(0.12, 0.5, -0.7);//ii'
glVertex3f(0.44, 0.5, -0.7);//jj'
glVertex3f(0.62, 0.22, -0.7);//kk'
glVertex3f(0.12, 0.22, -0.7);//ll'
glEnd();
CSE, DSATM 2020-21 Page 39
CAR PARK
glColor3f(0.0, 0.0, 1.0);
void drawhouse()
glBegin(GL_LINE_LOOP);
glVertex3f(-2.6, -.84, 2.5);//m
glVertex3f(-2.6, 0.84, 2.5);//n
glVertex3f(-3.04, 0.84, 2.8);//o
glVertex3f(0, 1.95, 2.8);//p
glVertex3f(3.04, 0.84, 2.8);//w
glVertex3f(2.6, 0.84, 2.5);//q
glVertex3f(2.6, -0.84, 2.5);//r
glVertex3f(1.59, -0.84, 2.5);//s
glVertex3f(1.59, 0.16, 2.5);//t
glVertex3f(-1.59, 0.16, 2.5);//u
glVertex3f(-1.59, -0.84, 2.5);//v
glEnd();
glBegin(GL_LINES);
glVertex3f(1.59, -0.84, 2.5);//s
glVertex3f(-1.59, -0.84, 2.5);//v
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(-2.6, -.84, -2.5);//m'
glVertex3f(-2.6, 0.84, -2.5);//n'
CSE, DSATM 2020-21 Page 40
CAR PARK
glVertex3f(-3.04, 0.84, -2.8);//o'
glVertex3f(0, 1.95, -2.8);//p'
glVertex3f(3.04, 0.84, -2.8);//w'
glVertex3f(2.6, 0.84, -2.5);//q'
glVertex3f(2.6, -0.84, -2.5);//r'
glVertex3f(1.59, -0.84, -2.5);//s'
glVertex3f(1.59, 0.16, -2.5);//t'
glVertex3f(-1.59, 0.16, -2.5);//u'
glVertex3f(-1.59, -0.84, -2.5);//v'
glEnd();
glBegin(GL_LINES);
glVertex3f(-2.6, -.84, 2.5);//m
glVertex3f(-2.6, -.84, -2.5);//m'
glVertex3f(-2.6, 0.84, 2.5);//n
glVertex3f(-2.6, 0.84, -2.5);//n'
glVertex3f(-3.04, 0.84, 2.8);//o
glVertex3f(-3.04, 0.84, -2.8);//o'
glVertex3f(0, 1.95, 2.8);//p
glVertex3f(0, 1.95, -2.8);//p'
glVertex3f(3.04, 0.84, 2.8);//w
glVertex3f(3.04, 0.84, -2.8);//w'
glVertex3f(2.6, 0.84, 2.5);//q
glVertex3f(2.6, 0.84, -2.5);//q'
glVertex3f(2.6, -0.84, 2.5);//r
glVertex3f(2.6, -0.84, -2.5);//r'
CSE, DSATM 2020-21 Page 41
CAR PARK
glVertex3f(1.59, -0.84, 2.5);//s
glVertex3f(1.59, -0.84, -2.5);//s'
glVertex3f(-1.59, -0.84, 2.5);//v
glVertex3f(-1.59, -0.84, -2.5);//v'
glEnd();
glColor3ub(255, 185, 1); //*************
glBegin(GL_QUADS);
glVertex3f(-2.6, -.84, 2.5);//m
glVertex3f(-2.6, 0.16, 2.5);//uu
glVertex3f(-1.59, 0.16, 2.5);//u
glVertex3f(-1.59, -0.84, 2.5);//v
glVertex3f(-2.6, 0.16, 2.5);//uu
glVertex3f(-2.6, 0.84, 2.5);//n
glVertex3f(2.6, 0.84, 2.5);//q
glVertex3f(2.6, 0.16, 2.5);//tt
glVertex3f(1.59, -0.84, 2.5);//s
glVertex3f(1.59, 0.16, 2.5);//t
glVertex3f(2.6, 0.16, 2.5);//tt
glVertex3f(2.6, -0.84, 2.5);//r
glVertex3f(-2.6, -.84, -2.5);//m'
glVertex3f(-2.6, 0.16, -2.5);//uu'
glVertex3f(-1.59, 0.16, -2.5);//u'
glVertex3f(-1.59, -0.84, -2.5);//v'
glVertex3f(-2.6, 0.16, -2.5);//uu'
glVertex3f(-2.6, 0.84, -2.5);//n'
CSE, DSATM 2020-21 Page 42
CAR PARK
glVertex3f(2.6, 0.84, -2.5);//q'
glVertex3f(2.6, 0.16, -2.5);//tt'
glVertex3f(1.59, -0.84, -2.5);//s'
glVertex3f(1.59, 0.16, -2.5);//t'
glVertex3f(2.6, 0.16, -2.5);//tt'
glVertex3f(2.6, -0.84, -2.5);//r'
glVertex3f(-2.6, -.84, 2.5);//m
glVertex3f(-2.6, -.84, -2.5);//m'
glVertex3f(-2.6, 0.84, -2.5);//n'
glVertex3f(-2.6, 0.84, 2.5);//n
glVertex3f(2.6, 0.84, 2.5);//q
glVertex3f(2.6, 0.84, -2.5);//q'
glVertex3f(2.6, -0.84, -2.5);//r'
glVertex3f(2.6, -0.84, 2.5);//r
glEnd();
glBegin(GL_TRIANGLES);
glVertex3f(0, 1.95, 2.5);//p
glVertex3f(3.04, 0.84, 2.5);//w
glVertex3f(-3.04, 0.84, 2.5);//o
glVertex3f(0, 1.95, -2.5);//p'
glVertex3f(3.04, 0.84, -2.5);//w'
glVertex3f(-3.04, 0.84, -2.5);//o'
glEnd();
glColor3ub(255, 102, 0); //***********top color
glBegin(GL_QUADS);
CSE, DSATM 2020-21 Page 43
CAR PARK
glVertex3f(0, 1.95, 2.8);//p
glVertex3f(0, 1.95, -2.8);//p'
glVertex3f(3.04, 0.84, -2.8);//w'
glVertex3f(3.04, 0.84, 2.8);//w
glVertex3f(-3.04, 0.84, 2.8);//o
glVertex3f(-3.04, 0.84, -2.8);//o'
glVertex3f(0, 1.95, -2.8);//p'
glVertex3f(0, 1.95, 2.8);//p
glEnd();
glColor3ub(116, 18, 0); //*******base color
glBegin(GL_QUADS);
glVertex3f(-2.6, -.84, 2.5);//m
glVertex3f(2.6, -0.84, 2.5);//r
glVertex3f(2.6, -0.84, -2.5);//r'
glVertex3f(-2.6, -.84, -2.5);//m'
glEnd();
GLuint createDL()
GLuint carrDL;
carrDL = glGenLists(1); // Create the id for the list
glNewList(carrDL, GL_COMPILE); // start list
drawcarr(); // call the function that contains the rendering commands
glEndList(); // endList
return(carrDL);
CSE, DSATM 2020-21 Page 44
CAR PARK
GLuint createDL2() //******************
GLuint houseDL;
houseDL = glGenLists(1); // Create the id for the list
glNewList(houseDL, GL_COMPILE); // start list
drawhouse(); // call the function that contains the rendering commands
glEndList(); // endList
return(houseDL);
} //**************
void initScene()
glEnable(GL_DEPTH_TEST);
carr_display_list = createDL();
house_display_list = createDL2(); //***********
void renderScene(void)
int i, j;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(.7, 0.85, 1.0, 1.0);
glColor3f(0.25f, 0.25f, 0.25f); // Draw ground
glBegin(GL_QUADS);
glVertex3f(-100.0f, 0.0f, -100.0f);
glVertex3f(-100.0f, 0.0f, 100.0f);
CSE, DSATM 2020-21 Page 45
CAR PARK
glVertex3f(100.0f, 0.0f, 100.0f);
glVertex3f(100.0f, 0.0f, -100.0f);
glEnd();
for (i = -3; i < 3; i++) // Draw 36 car
for (j = -3; j < 3; j++)
glPushMatrix();
glTranslatef((i) * 10.0, 0, (j) * 10.0);
glColor3ub(a[i], b[j], c[i]);
glCallList(carr_display_list);
glPopMatrix();
if (housevisible)
glPushMatrix();
glScalef(2.0, 2.0, 2.0);
glTranslatef(0.0, .85, -20.0);
glCallList(house_display_list);
glTranslatef(10.0, 0.0, 0.0);
glCallList(house_display_list);
glTranslatef(-20.0, 0.0, 0.0);
glCallList(house_display_list);
glRotatef(90, 0.0, 1.0, 0.0);
glTranslatef(-10.0, 0.0, -10.0);
glCallList(house_display_list);
CSE, DSATM 2020-21 Page 46
CAR PARK
glTranslatef(-10.0, 0.0, 0.0);
glCallList(house_display_list);
glTranslatef(-10.0, 0.0, 0.0);
glCallList(house_display_list);
glPopMatrix();
glPushMatrix();
glTranslatef(10.0, 3.4, -80.0);
glScalef(4.0, 4.0, 4.0);
glCallList(house_display_list);
glTranslatef(-10.0, 0.0, 0.0);
glCallList(house_display_list);
glPopMatrix();
glPushMatrix();
glRotatef(90, 0.0, 1.0, 0.0);
glScalef(2.0, 2.0, 2.0);
glTranslatef(0.0, 0.85, 15.0);
glCallList(house_display_list);
glTranslatef(10.0, 0., 0.0);
glCallList(house_display_list);
glTranslatef(-20.0, 0., 0.0);
glCallList(house_display_list);
glPopMatrix();
if (fxincr != 0)
theta1 = (atan(fzincr / fxincr) * 180) / 3.141;
CSE, DSATM 2020-21 Page 47
CAR PARK
else if (fzincr > 0)
theta1 = -90.0;
else theta1 = 90.0;
if (fxincr > 0 && fzincr < 0)
theta1 = -theta1;
else if (fxincr < 0 && fzincr < 0)
theta1 = 180 - theta1;
else if (fxincr < 0 && fzincr>0)
theta1 = -180 - theta1;
else if (fxincr > 0 && fzincr > 0)
theta1 = -theta1;
glPushMatrix();
glTranslatef(fx, 0, fz);
glRotatef(theta1, 0, 1, 0);
glColor3f(0.8, 0.8, 0);
glCallList(carr_display_list);
glPopMatrix();
CSE, DSATM 2020-21 Page 48
CAR PARK
glutSwapBuffers();
void orientMe(float ang)
lx = sin(ang);
lz = -cos(ang);
glLoadIdentity();
gluLookAt(x, y, z, x + lx, y + ly, z + lz, 0.0f, 1.0f, 0.0f);
void moveMeFlat(int i)
if (xxxx == 1)
y = y + i * (lz) * 0.1; //*********
if (yyyy == 1)
x = x + i * (lz) * .1;
else
z = z + i * (lz) * 0.5;
x = x + i * (lx) * 0.5;
glLoadIdentity();
gluLookAt(x, y, z, x + lx, y + ly, z + lz, 0.0f, 1.0f, 0.0f);
CSE, DSATM 2020-21 Page 49
CAR PARK
void processNormalKeys(unsigned char key, int x, int y)
glLoadIdentity();
if (key == 'q')
exit(0);
if (key == 't')
gluLookAt(1, 190, 50, 0, 0, -10, 0.0, 1.0, .0);
if (key == 'a')
moveMeFlat(4);xxxx = 1, yyyy = 0;
if (key == 's')
moveMeFlat(-4);xxxx = 1, yyyy = 0;
if (key == 'w')
moveMeFlat(4);yyyy = 1;xxxx = 0;
if (key == 'd')
moveMeFlat(-4);yyyy = 1;xxxx = 0;
void inputKey(int key, int x, int y)
switch (key)
case GLUT_KEY_LEFT: angle -= 0.05f;orientMe(angle);break;
case GLUT_KEY_RIGHT: angle += 0.05f;orientMe(angle);break;
case GLUT_KEY_UP: moveMeFlat(2);xxxx = 0, yyyy = 0;break;
case GLUT_KEY_DOWN: moveMeFlat(-2);xxxx = 0, yyyy = 0;break;
CSE, DSATM 2020-21 Page 50
CAR PARK
void movecar(int key, int x, int y)
switch (key)
case GLUT_KEY_LEFT:temp = fxincr;
fxincr = fxincr * cos(theta) + fzincr * sin(theta);
fzincr = -temp * sin(theta) + fzincr * cos(theta);
fx += fxincr;
fz += fzincr;
break;
case GLUT_KEY_RIGHT:temp = fxincr;
fxincr = fxincr * cos(-theta) + fzincr * sin(-
theta);
fzincr = -temp * sin(-theta) + fzincr * cos(-theta);
fx += fxincr;
fz += fzincr;
break;
case GLUT_KEY_UP:fx += fxincr;
fz += fzincr;break;
case GLUT_KEY_DOWN:fx -= fxincr;
fz -= fzincr; break;
glutPostRedisplay();
CSE, DSATM 2020-21 Page 51
CAR PARK
void ProcessMenu(int value) // Reset flags as appropriate in response to menu selections
glutPostRedisplay();
void ProcessMenu1(int value)
switch (value)
case 1:if (housevisible == 0)
housevisible = 1;
else
housevisible = 0;
glutPostRedisplay();
break;
case 2:if (movecarvar == 0)
glutSpecialFunc(movecar);
movecarvar = 1;
else
glutSpecialFunc(inputKey);
movecarvar = 0;
break;
CSE, DSATM 2020-21 Page 52
CAR PARK
void menu()
int control;
int control1;
control = glutCreateMenu(ProcessMenu);
glutAddMenuEntry("**CONTROLS**", 1);
glutAddMenuEntry("1) UP KEY:to move in Forward Direction.", 1);
glutAddMenuEntry("2) DOWN KEY:to move in Backward Direction.", 1);
glutAddMenuEntry("3) LEFT KEY:to Turn Left .", 1);
glutAddMenuEntry("4) RIGHT KEY:to Turn Right .", 1);
glutAddMenuEntry("5) d:moves Towards Right. ", 1);
glutAddMenuEntry("6) a:moves Towards Left.", 1);
glutAddMenuEntry("7) s:moves Away.", 1);
glutAddMenuEntry("8) w:moves Near.", 1);
glutAddMenuEntry("9) t:Top view.", 1);
glutAddMenuEntry("10) q:Quit.", 1);
glutAttachMenu(GLUT_RIGHT_BUTTON);
control1 = glutCreateMenu(ProcessMenu1);
glutAddMenuEntry("HOUSE", 1);
glutAddMenuEntry("MOVE CAR", 2);
glutAttachMenu(GLUT_LEFT_BUTTON);
int main(int argc, char** argv)
CSE, DSATM 2020-21 Page 53
CAR PARK
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(0, 0);
glutInitWindowSize(1010, 710);
glutCreateWindow("car lot");
initScene();
glutKeyboardFunc(processNormalKeys);
glutSpecialFunc(inputKey);
menu();
glutDisplayFunc(renderScene);
glutIdleFunc(renderScene);
glutReshapeFunc(changeSize);
glutMainLoop();
return(0);
CSE, DSATM 2020-21 Page 54
CAR PARK
A. 2 User Manual
Enter any key on the visualizer window, you will be asked for options
1. UP KEY - > to move the viewer in forward direction.
2. DOWN KEY - > to move the viewer in backwards direction.
3. LEFT KEY - > to rotate the camera to the left of the viewer.
4. RIGHT KEY - > to rotate the camera to the right of the viewer.
5. T - >top view.
6. S - > to move away.
7. W - >to move near.
8. D - > to move right.
9. A - > to move left.
10. Q - >quit
A.3 Personal Details
NAME: CHANDRASHEKAR.G
USN: 1DT18CS031
SEMESTER AND SECTION: 6TH SEM, A SEC
DEPARTMENT: COMPUTER SCIENCE AND ENGINEERING
NAME: LEELAVATHI.B
USN:1DT19CS405
SEMESTER AND SECTION: 6TH SEM, A SEC
DEPARTMENT: COMPUTER SCIENCE AND ENGINEERING
CSE, DSATM 2020-21 Page 55
CAR PARK
CSE, DSATM 2020-21 Page 56
CAR PARK
CSE, DSATM 2020-21 Page 57
CAR PARK
CSE, DSATM 2020-21 Page 58
CAR PARK
CSE, DSATM 2020-21 Page 20
CAR PARK
CSE, DSATM 2020-21 Page 21
CAR PARK
CSE, DSATM 2020-21 Page 22