Report of Bus Stop Simulation
Report of Bus Stop Simulation
BACHELOR OF ENGINEERING
In
COMPUTER SCIENCE AND ENGINEERING
Submitted By
M. CHANDRAMOULI 1VA19CS026
YASHAS H M 1VA19CS061
KISHAN KUMAR M 1VA19CS063
NIMMALA GIREESH 1VA19CS064
CERTIFICATE
External Viva:
Name of the Examiner Signature with date
1.
2.
ACKNOWLEDGEMENT
The completion of Mini project brings with and sense of satisfaction, but it is never
completed without thanking the persons who are all responsible for its successful
completion. First and foremost, I wish to express our deep sincere feelings of gratitude to
my Institution, Sai Vidya Institute of Technology, for providing mean opportunity to do
our education.
I would like to thank the Management and Prof. M R Holla, Director, Sai Vidya
Institute of Technology for providing the facilities.
Finally, I would like to thank all the Teaching, Technical faculty and supporting
staff members of Department of Computer Science and Engineering, Sai Vidya Institute
of Technology, Bengaluru, for their support.
M. Chandramouli 1VA19CS026
Yashas H M 1VA19CS061
Kishan Kumar M 1VA19CS063
Nimmala Gireesh 1VA19CS064
I
ABSTRACT
The main aim of this Mini Project is to illustrate the concepts and usage of pre-built functions in
OpenGL. Creating Figures like Bus and the surrounding environment using inbuilt functions
provided by the glut library. The environment is built in –ve Y-axis and translated to +ve Y-axis to
make it look like the bus is moving.
In this report, we will go through the whole process related to our interesting project. A table of
content will guide us to each individual part of this report.
Bus stop simulation is an open GL computer graphics project using open GL function it is a user
interactive program where in the user can view the required display by making use of the input
devices Keyboard and mouse.
The main aim of the transport Simulation Computer Graphics Mini Project is to illustrate the
concepts and usage of pre-built functions in OpenGL. Simulation of a bus is being done using
computer graphics. Car Simulation is a project where we can also change the color, name, of the bus
and other graphics. We can also interchange the boy or girl picking and dropping by the bus.
This project depicts two scenes, one scene where the bus moves from left of the screen to the right
near the house of the student whom it is picking up and in the second scene, we can see the college
where the bus we will drop the student and once again moves from left to right of the screen.
It has additional feature of changing the gender of the student being picked by changing their clothes,
picking and dropping is automatically done when the bus goes near the bus stop sign.
II
Table of Contents
ACKNOWLEDGEMENT I
ABSTRACT II
TABLE OF CONTENTS III
LIST OF FIGURES V
LIST OF TABLES VI
CHAPTER 1
INTRODUCTION………………………………………………………………………………..1
1.1 Aim…………………………………………………………………………………………….1
1.4 Interface………………………………………………………………………………………..3
CHAPTER 2
REQUIREMENT SPECIFICATION…………………………………………………………...4
CHAPTER 3
DESIGN…………………………………………………………………………………………...5
3.2 OPERTATION………………………………………………………………………………..5
3.3 ANIMATIONS………………………………………………………………………………..5
3.4 FLOWCHART………………………………………………………………………………..6
III
CHAPTER 4
IMPLEMENTATION……………………………………………………………………………7
CHAPTER 5
SOURCE CODE………………………………………………………………………………...10
CHAPTER 6
TEST CASE……………………………………………………………………………………..26
CHAPTER 7
SNAPSHOTS……………………………………………………………………………………29
CHAPTER 8
CONCLUSION…………..…………………………………………………………………….32
REFERENCE…………………….……………………………………………………………32
IV
List of Figures
1.2.1 OPEN GL 2
V
List of Tables
VI
VIRTUAL TRANSPORT SIMULATION
CHAPTER 1
INTRODUCTION
1.1 AIM
The main aim of the transport Simulation Computer Graphics Mini Project is to illustrate the
concepts and usage of pre-built functions in OpenGL. Simulation of a bus is being done using
computer graphics. Car Simulation is a project where we can also change the color, name, of
the bus and other graphics. We can also interchange the boy or girl picking and dropping by
the bus
OpenGL (Open Graphics Library) is a software interface to graphics hardware. The interface
consists of over 250 different function calls which can be used to draw complex two and three-
dimensional scenes from simple geometric primitives.
A vertex defines a point, an endpoint of a line, or a corner of a polygon where two edges meet.
Data is associated with a vertex, and each vertex and its associated data are processed
independently, in order, and in the same way.
The type of clipping depends on which primitive the group of vertices represents.
Commands are always processed in the order in which they are received, although there may
be an indeterminate delay before a command takes effect. This means that each primitive is
drawn completely before any subsequent command takes effect. It also means that state-
querying commands return data that's consistent with complete execution of all previously
issued OpenGL commands.
OpenGL offers translation, rotation and scaling of objects. Most of our applications will be
designed to access OpenGL directly through functions in three libraries.
They are:
1. Main GL: Library has names that begin with the letter gl and are stored in a library
usually referred to as GL
2. . OpenGL Utility Library (GLU): This library uses only GL functions but contains code
for creating common objects and simplifying viewing.
3. OpenGL Utility Toolkit (GLUT): This provides the minimum functionality that
should be accepted in any modern windowing system.
i) User Interface: User able to control the movement of the bus by using keyboard arrow
keys
ii) Selection: User can change the type of student picking up from either male or female.
iii) Pickup/drop: Whenever a bus stop signs arrive the bus automatically picks and drops
the student
1.4 INTERFACE
1) Mouse_Interface:
Left-click button: this action is used in the beginning of the simulation in order to start
to the next phase we have to click the left-button of mouse
2) Keyboard Interface:
i) Left-arrow key: This action is used to move the bus in only one direction from left
to right
CHAPTER 2
REQUIREMENT SPECIFICATION
• Compiler – C Compiler
• OpenGL 2.0
• Microprocessor: 1.0 GHz and above CPU based on either AMD or INTEL Microprocessor Architecture
• Main memory : 2 GB RAM
• Hard Disk : 40 GB
• Hard disk speed in RPM:5400 RPM
• Keyboard: QWERTY Keyboard
• Mouse :2 or 3 Button mouse
• Monitor : 1024 x 768 display resolution
CHAPTER 3
DESIGN
• Introduction window : It is a window that shows the information regarding the developers
of the project.
• Output window (1) : Main outer window that holds the content. It includes the first
working interface in which the operation takes place. The operation includes the bus
picking of the girl from the bus stop and moving ahead.
• Output window (2) : The second working interface includes the bus dropping of the girl
in front of the college and moving towards the parking slot.
3.2 Operations :
The main operation includes movement of the bus based on the instructions specified. The
key used for this operation is right arrow which helps in the movement of the bus
3.3 Animations :
The animations included in the interface contains some of the pre-defined functions such
as glutSolidSphere, glutSolidTorus etc.. and some of the user defined functions such as
void wheel(), void lamppost() etc
FIGURE 3.4.1
CHAPTER 4
IMPLEMENTATION
into stacks.
8. glPushMatrix : The glPushMatrix function pushes the current matrix stack down by one,
duplicating the current matrix. That is, after a glPushMatrix call, the matrix on the top of
the stack is identical to the one below it.
9. glPopMatrix : The glPopMatrix function pops the current matrix stack, replacing the
current matrix with the one below it on the stack. Initially, each of the stacks contains one
matrix, an identity matrix.
10. glRasterPos3f(x,y,z) : The current raster position consists of three window coordinates
(x, y, z), a clip coordinate w value, an eye coordinate distance, a valid bit, and associated
color data and texture coordinates.
Even though these properties were supported, it was difficult to render 2D graphics cannot be very
difficult to get a 3 Dimensional object. Even the effects like lighting, shading cannot be provided.
So we go for Microsoft Visual Studio software.
To achieve three dimensional effects, open GL software is proposed. It is software which provides
a graphical interface. It is an interface between application program and graphics hardware. The
advantages are:
2. It’s a hardware independent interface i.e it can be implemented on many different hardware
platforms.
3. With Open GL we can draw a small set of geometric primitives such as points, lines and
polygons etc.
CHAPTER 5
SOURCE CODE
#include <stdlib.h>
#include <GL/glut.h>
#include<string.h>
#include<stdio.h>
int x=-150,o=0,xd=-150;
int x1=0,z=0;
float a=0,a1=0,moving,angle=0;
float z5=0,u=0,flag12=0,begin;
float k=0,y2=0;
int flag=0,flag55=0,var=0,flag1=0,flag551=0,vari=0,vard=0,varid=0,then=0;
float p=0.0,q=0.0;
#define maxx 10
#define maxy 12
#define dx 27.7
#define dy 12
void wheel();
void wheel2();
// FUNCTION cube
glBegin(GL_POLYGON);
glColor3fv(colors[E]);
glVertex3fv(vertices[a]);
glVertex3fv(vertices[b]);
glVertex3fv(vertices[c]);
glVertex3fv(vertices[d]);
if(f!=0)
glVertex3fv(vertices[f]);
glEnd();
void colorcube(){
int i;
wheel1();
polygon(0,1,5,4,0,0);
polygon(13,14,18,0,0,0);
polygon(15,16,17,18,2,0);
polygon(16,11,2,1,0,17);
polygon(0,4,8,13,0,0);
polygon(1,10,9,5,0,0);
polygon(9,10,2,6,1,0);
polygon(4,5,9,8,0,0);
polygon(8,9,6,12,1,7);
glColor3ub(100,40,50);
for(i=0;i<=180;i+=45)
glBegin(GL_LINES);
glVertex3f(180+i,447,70);
glVertex3f(180+i,500,70);
glEnd();
polygon(13,8,7,3,1,0);
polygon(3,15,14,13,1,0);
polygon(6,2,11,12,0,0);
polygon(11,3,7,12,0,0);
wheel2();
void bus_stop();
void road2();
void text2();
void text3();
void text4d();
void text5d();
void line();
TION Woman
void tree12();
void tree1()
void woman();
void man();
void lamppost();
void lamppost1();
void lamppost2();
void lamppost4();
void wheel1d();
void wheel2d();
wheel2d();
void road2d();
void textd();
void text2d();
void text3d();
void buildingd();
void lined();
void walld();
void bus_move();
if(x<50)
{ x+=3;
glPushMatrix();
glTranslatef(-100,0,-90);
woman();
glPopMatrix();
glPushMatrix();
glTranslatef(x,0,0);
wheel1();
colorcube();
wheel2();
line();
text1();
glPopMatrix();
if(x>=50)
vari=1;
if(flag55==1 )
x+=6;
glPushMatrix();
glTranslatef(x,0,0);
wheel1();
colorcube();
wheel2();
line();
text1();
glPopMatrix();
if(x>=865)
var=1;
void bus_moved()
if(xd>50)
xd+=3;
glPushMatrix();
glTranslatef(-100,0,-90);
womand();
glPopMatrix();
glPushMatrix();
glTranslatef(xd,0,0);
wheel1d();
colorcubed();
wheel2d();
lined();
text1d();
glPopMatrix();
if(flag551==1)
xd+=5;
glPushMatrix();
glTranslatef(xd,0,0);
wheel1d();
colorcubed();
wheel2d();
lined();
text1d();
glPopMatrix();
if(xd>50)
varid=1;
switch ( Key )
//bus_move();
//p+=50;
glutPostRedisplay();
break;
case GLUT_KEY_RIGHT:
//rota(); /
glutPostRedisplay();
break;
void display(void)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
if(then==0)
intro();
texti();
if(then==1)
if(flag)
glPushMatrix();
glTranslatef(-1.0,0.0,-3.5);
glRotatef(xangle+25,1.0,0.0,0.0);
glRotatef(yangle,0.0,1.0,0.0);
glRotatef(zangle,0.0,0.0,1.0);
road2();
glPushMatrix();
glTranslatef(0,00,-50);
bus_stop();
glPopMatrix();
tree1();
tree12();
man();
lamppost();
lamppost1();
lamppost2();
text2();
bus_move();
// text1();
glPopMatrix();
else
{ road2();
bus_stop();
text();
tree1();
tree12();
man();
lamppost();
lamppost1();
lamppost2();
lamppost4();
text2();
bus_move();
flag55=1;
if(vari==1)
text3();
if(x==865)
vari=0;
if(var==1)
if(flag1)
glPushMatrix();
glTranslatef(-1.0,0.0,-3.5);
glRotatef(xangle+25,1.0,0.0,0.0);
glRotatef(yangle,0.0,1.0,0.0);
glRotatef(zangle,0.0,0.0,1.0);
road2d();
buildingd();
walld();
text2d();
gated();
treed();
tree1d();
tree2d();
shrubd();
shrub1d();
shrub2d();
shrub3d();
shrub4d();
stopd();
text3d();
text4d();
bus_moved();
glPopMatrix();
else
road2d();
textd();
buildingd();
walld();
text2d();
gated();
treed();
tree1d();
tree2d();
shrubd();
shrub1d();
shrub2d();
shrub3d();
shrub4d();
stopd();
text3d();
text4d();
bus_moved();
flag551=1;
if(varid==1)
text5d();
glFlush();
glutSwapBuffers();
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(-2.0,2.0,-2.0*(GLfloat)h/(GLfloat)w,2.0*(GLfloat)h/(GLfloat)w,-
10.0,10.0);
else
glOrtho(-2.0*(GLfloat)w/(GLfloat)h,2.0*(GLfloat)w/(GLfloat)h,-2.0,2.0,-
10.0,10.0);
glMatrixMode(GL_MODELVIEW);
glutInit(&argc, argv);
glutInitWindowSize(1000,650);
glutInitWindowPosition(0,0);
glutCreateWindow("BUS STOP");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutSpecialFunc( SpecialKeyFunc );
glutReshapeFunc(myreshape);
glutMainLoop();
return 1; }
CHAPTER 6
TEST CASES
CHAPTER 7
SNAPSHOTS
CONLCUSION
An attempt has been made to develop an OpenGL package which meets necessary requirements
of the user successfully. Since it is user friendly, it enables the user to interact efficiently and
easily.
The development of the mini project has given us a good exposure to OpenGL by which we have
learnt some of the technique which help in development of animated pictures, gaming.
Hence it is helpful for us even to take up this field as our career too and develop some other features
in OpenGL and provide as a token of contribution to the graphics world.
REFERENCES
1 https://en.wikipedia.org/wiki/OpenGL
2 https://www.javatpoint.com/application-of-computer-graphics
3 https://cglabprojects.blogspot.com/2014/04/moving-bus-animation.html
4 https://github.com/abd-abdullah/Computer-Graphics-BUS-STOP
5 https://devfolio.co/@sowmya
6 https://www.researchgate.net/publication/344285614_A_PROJECT_ON_3D_CAR_SIMU
LATION/link/5f63657f299bf1b53edba413/download
7 https://solutionsbyabhishek.blogspot.com/2016/12/computer-graphics-bus-stop.html