Bus Stop Simulation Report
Bus Stop Simulation Report
Basic Electical and electonical engineering (Dr. M.G.R. Educational And Research
Institute)
A
MINI PROJECT REPORT
ON
“BUS STOP SIMULATION”
Submitted By:
ASHISH MORAMBE
(USN:3BK20CS004)
KEERTIRANI
BET’S
BASAVAKALYANENGINEERINGCOLLEGE
BASAVAKALYAN-585327
Certificate
This is to certify that the project work entitled " BUS STOP SIMULATION" work
carriedout by ASHISH (USN:3BK20CS004) student of VI semester (CBCS) B.E. (Computer
Science & Engineering) in partial fulfillment for the Computer Graphics Lab with Mini
Project(18CSL67) prescribed by Visvesvaraya Technological University, Belagavi during the
academic year 2022-2023.
Date 1)
2)
ACKNOWLEDGMENT
First and foremost our sincere thanks to our principal Dr.Ashokkumar Vanageri for
forwarding us to carry out my project and offering adequate duration in completing my
project. I am also grateful to the Head of department of Computer science & Engineering
Prof.Suvarnalata Hiremath for her constructive suggestions & encouragement during
my
project .
I express our heartfelt thanks to our all staff members of our department ,who helped
us a lot in the completion of directly and indirectly within the schedule period.
Last but not least we would like to thanks our friends and family members for
increased and propels and encouragement throughout in this position.
ASHISH
(3BK20CS004
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 a openGl 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 cocepts and usage
of pre built function in opengl simulation of a bus is being done using.
This project depicts two scenes one scene where the bus moves from left the screen to the right near the
house of the student whom it is picking up and in the and second scene we can see the collage 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 bus goes near the bus stop sign.
TABLE OF CONTENTS
Abstract
01 Introduction 01
1.1.Computer Graphics
1.2.OpenGL Interface
1.3.OpenGL Overview
02 System Specification 05
2.1.Hardware Requirements
3.1.Overview
3.2.User Interface
3.3.Purpose
3.4.Scope
04 Implementation of Sourcecode 10
05 Testing 23
24
06 Result
07 Conclusion 27
Reference
CHAPTER1
INTRODUCTION
Graphics provides one of the most natural means of communicating within a computer,
since our highly developed 2D and 3D pattern-recognition abilities allow us to perceive and
process pictorial data rapidly and effectively. Interactive computer graphics is the most
important means of producing pictures since the invention of photography and television. It
has the added advantage that, with the computer, we can make pictures not only of concrete
real world objects but also of abstract, synthetic objects, such as mathematical surfaces and of
data that have no inherent geometry, such as survey results.
Computer graphics started with the display of data on hardcopy plotters and cathode ray tube
screens soon after the introduction of computers themselves. It has grown to include the
creation, storage, and manipulation of models and images of objects. These models come
from a diverse and expanding set of fields, and include physical, mathematical, engineering,
architectural, and even conceptual structures, natural phenomena, and so on. Computer
graphics today is largely interactive. The user controls the contents, structure, and appearance
of the objects and of their displayed images by using input devices, such as keyboard, mouse,
or touch-screen.
Graphics today is used in many different areas. Graphics provides one of the most natural
means of communicating within a computer, since our highly developed 2D and 3D pattern-
recognition abilities allow us to perceive and process pictorial data rapidly and effectively.
Interactive computer graphics is the most important means of producing pictures since the
invention of photography and television. It has the added advantage that, with the computer,
we can make pictures not only of concrete real world objects but also of abstract, synthetic
objects, such as mathematical surfaces and of data that have no inherent geometry, such as
survey results. OpenGL is an application program interface (API) offering various functions
to implement primitives, models and images. This offers functions to create and manipulate
render lighting, coloring, viewing the models. OpenGL offers different coordinate system and
frames. OpenGL offers translation, rotation and scaling of objects.
Due to close relationships between the input devices and the display, the handling of such
devices is included in the study of computer graphics. The advantages of the interactive
graphics are many in number. Graphics provides one of the most natural means of
communicating with a computer, since our highly developed 2D and 3D patter-recognition
abilities allow us to perceive and process data rapidly and efficiently. In many design,
implementation, and construction processes today, the information pictures can give is
virtually indispensable. Scientific visualization became an important field in the 1980s when
the scientists and engineers realized that they could not interpret the prodigious quantities of
data produced in supercomputer runs without summarizing the data and highlighting trends
and phenomena in various kinds of graphical representations.
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.
OpenGL(Open Graphics Library) is the interface between a graphic program and graphics
hardware. It is streamlined. In other words, it provides low-level functionality. For example,
all objects are built from points, lines and convex polygons. Higher level objects like cubes
are implemented as six four-sided polygons.
OpenGL supports features like 3-dimensions, lighting, anti-aliasing, shadows, textures, depth
effects, etc.
It is a state machine. At any moment during the execution of a program there is a current
model transformation
Commands may either be accumulated in display lists, or processed immediately through the
pipeline. Display lists allow for greater optimization and command reuse, but not all
commands can be put in display lists.
The first stage in the pipeline is the evaluator. This stage effectively takes any polynomial
evaluator commands and evaluates them into their corresponding vertex and attribute
commands.
The second stage is the per-vertex operations, including transformations, lighting, primitive
assembly, clipping, projection, and viewport mapping.
The third stage is rasterization. This stage produces fragments, which are series of
framebuffer addresses and values, from the viewport-mapped primitives as well as bitmaps
and pixel rectangles.
The fourth stage is the per-fragment operations. Before fragments go to the framebuffer, they
may be subjected to a series of conditional tests and modifications, such as blending or z-
buffering.
Parts of the framebuffer may be fed back into the pipeline as pixel rectangles. Texture
memory may be used in the rasterization process when texture mapping is enabled.
CHAPTER2
SYSTEM SPECIFICATION
2GB RAM
DVD drive
Keyboard
Compiler – C Compiler
OpenGL 2.0
2.3 FUNCTIONAL REQUIREMENTS:
OpenGL APIs:
If we want to have a control on the flow of program and if we want to interact with the
window system then we use OpenGL API’S. Vertices are represented in the same manner
internally, whether they are specified as two-dimensional or three-dimensional entities,
everything that we do are here will be equally valid in three dimensions. Although OpenGL is
easy to learn, compared with other APIs, it is nevertheless powerful. It supports the simple
three dimensional programs and also supports the advanced rendering techniques.
GL/glut.h:
We use a readily available library called the OpenGL Utility Toolkit (GLUT), which provides
the minimum functionality that should be expected in any modern windowing system.
The application program uses only GLUT functions and can be recompiled with the GLUT
library for other window system. OpenGL makes a heavy use of macros to increase code
readability and avoid the use of magic numbers. In most implementation, one of the include
lines
CHAPTER3
3.1 OVERVIEW:
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 l.
On the basis of the research conducted at the bus stops in Krakow and Warsaw, the movement processes,
related with functioning of a bus stop have been identified. As a result, the simulation model imitating its
functioning has been formulated and verified. The stop has been analyzed as a system, in which the input
flow comprises of municipal bus transport, whereas the service time corresponds the dwell time. The
formulas for time losses incurred due to queuing to reach the boarding and alighting zones have been
derived, constituting a basis for operative capacity estimation of a bus stop and specifying the selection
determinants for the number of boarding and alighting zones in regards to traffic intensity as well as
boarding and alighting time
glVertex*(): The glVertex function commands are used within glBegin/glEnd pairs to
specify point, line, and polygon vertices. The current color and normal texture
coordinates, fog coordinates are associated with the vertex when glVertex is called.
glColor*(): It sets a few four-valued RGBA color. glColor has two major
variants:glColor3 and glColor4.glColor3 variants specify the new red, green and
blue values explicitly and set the current alpha value to1.0implicity.
glOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top):
which defines a two-dimensional orthograhic viewing region. This is equivalent to
calling glOrtho with near=-1 and far=1.
glClear():. glClear sets the bitplane area of the window to values previously selected
by glClearColor.
glClearColor(): Specifies the red, green, blue and alpha values used by glClear to
clear the color buffers.
glLoadIdentity(): The current matrix with the identity matrix. It is used to replace
the current matrix with the identity matrix.
3.3 PURPOSE:
The computer graphics (CG) mini project titled “sinking ship” is an easy project that is
developed using OpenGL in which a ship will be traveling in the sea. While the ship
traveling in the sea in the middle an obstacle will be placed and the ship will hit the obstacle
and the ship will sink into the sea. The objects designed in this project are a ship and an
obstacle that looks like a stone. A ship will be traveling in the sea when it reaches some
extent an obstacle will appear in the way of the ship and the ship will hit the obstacle and the
ship will sink soon into the sea. The controls will be specified and these controls will be
provided from the keyboard.To move the ship into the sea the control will be on the keyboard
by pressing any key the ship will start to move in the sea. the obstacle will appear
automatically after some time in the way of the ship and the ship will hit the obstacle and
sink in the sea soon.
3.4 SCOPE:
The computer graphics (CG) mini project titled “sinking ship” is an easy project that is
developed using OpenGL in which a ship will be traveling in the sea. While the ship
traveling in the sea in the middle an obstacle will be placed and the ship will hit the obstacle
and the ship will sink into the sea. The objects designed in this project are a ship and an
obstacle that looks like a stone. A ship will be traveling in the sea when it reaches some
extent an obstacle will appear in the way of the ship and the ship will hit the obstacle and the
ship will sink soon into the sea. The controls will be specified and these controls will be
provided from the keyboard.
CHAPTER 4
IMPLEMENTATION
4.1SOURCE 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
GLfloat xangle=0.0,yangle=0.0,zangle=0.0; /* axis angles */
/* */
/*****************************DECLARATIONS************************
****/
/* */
{135,370,70}, {400,370,70},
{400,490,70}, {135,500,70},
{135,447,70},{400,447,70},
{425,467,-70},{410,520,-70},
{385,500,70}, {160,467,-70},
{320,467,-70},{320,520,-70},
{380,520,-70},{380,390,-70},{320,390,-70}};
{135,370-175,70}, {400,370-175,70},
{400,490-175,70}, {135,500-175,70},
{135,447-175,70},{400,447-175,70},
{425,467-175,-70},{410,520-175,-70},
{385,500-175,70}, {160,467-175,-70},
{320,467-175,-70},{320,520-175,-70},
{380,520-175,-70},{380,390-175,-70},{320,390-175,-70}};
// FUNCTION wheel
/* */
void wheel1()
{
glColor3f(0,0,0);
glPushMatrix();
glTranslatef(345,377,-70);
glutSolidTorus(5,15,100,90);
glPopMatrix();
glPushMatrix();
glTranslatef(190,377,-70);
glutSolidTorus(5,15,100,90);//front two wheels tyre
glPopMatrix();
glColor3ub(100,100,100);
glPushMatrix();
glTranslatef(345,377,-70);
glutSolidTorus(5,5,10,69);
glPopMatrix();
glPushMatrix();
glTranslatef(190,377,-70);
glutSolidTorus(5,5,10,69);
glPopMatrix();// front two
wheels
}
void wheel2()
{
glColor3f(0,0,0);
glPushMatrix();
glTranslatef(180,370,70);
glutSolidTorus(5,15,100,90);
glPopMatrix();
glPushMatrix();
glTranslatef(335,370,70);
glutSolidTorus(5,15,100,90);
glPopMatrix(); //back two wheels
tyre glColor3ub(100,100,100);
glPushMatrix();
glTranslatef(335,370,70);
glutSolidTorus(5,5,10,69);
glPopMatrix();
glPushMatrix();
glTranslatef(180,370,70);
glutSolidTorus(5,5,10,69);
glPopMatrix(); //back two
wheels
}
/* */
// FUNCTION cube
/* */
void polygon(int a, int b, int c , int d,int E,int f)
{
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();
/* */
// FUNCTION bus_stop
/* */
void bus_stop()
{
glColor3ub(100,100,100);
glBegin(GL_POLYGON);
glVertex3i(340-200,470,-110);
glVertex3i(680-200,470,-110);
glVertex3i(710-200,500,-240);
glVertex3i(370-200,500,-240);
glEnd();
glColor3ub(100,100,100);
glBegin(GL_POLYGON);
glVertex3i(340-200,470,-110);
glVertex3i(680-200,470,-110);
glVertex3i(680-200,450,-110);
glVertex3i(340-200,450,-110);
glEnd();
glBegin(GL_POLYGON);
glVertex3i(680-200,470,-110);
glVertex3i(710-200,500,-240);
glVertex3i(710-200,480,-240);
glVertex3i(680-200,450,-110);
glEnd();
glBegin(GL_POLYGON);
glVertex3i(710-200,500,-240);
glVertex3i(710-200,480,-240);
glVertex3i(370-200,480,-240);
glColor3f(1.0,1.0,1.0);
glBegin(GL_LINE_STRIP);
glVertex3i(340-200,470,-110);
glVertex3i(680-200,470,-110);
glVertex3i(710-200,500,-240);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_LINE_STRIP);
glVertex3i(680-200,470,-110);
glVertex3i(680-200,450,-110);
glEnd();
glColor3ub(10,170,80);
glBegin(GL_POLYGON);
glVertex3i(395-200,580,-200);
glVertex3i(690-200,580,-200);
glVertex3i(690-200,520,-200);
glVertex3i(395-200,520,-200);
glEnd();
glColor3f(0,0,0);
glBegin(GL_LINES);
glVertex3i(395-200,580,-200);
glVertex3i(690-200,580,-200);
glVertex3i(690-200,520,-200);
glVertex3i(395-200,520,-200);
glEnd();
/************* right ************/
glColor3ub(10,50,80);
glBegin(GL_POLYGON);
glVertex3i(690-200,625,-200);
glVertex3i(670-200,610,-140);
glVertex3i(670-200,475,-140);
glVertex3i(690-200,490,-200);
glEnd();
glColor3ub(0,0,0);
glBegin(GL_POLYGON);
glVertex3i(425-200,530,-180);
glVertex3i(520-200,530,-180);
glVertex3i(500-200,515,-150);
glVertex3i(405-200,515,-150);
glEnd();
glColor3ub(0,0,0);
glBegin(GL_LINES);
glVertex3i(425-200,515,-160);
glVertex3i(425-200,480,-160);
glVertex3i(437-200,515,-170);
glVertex3i(437-200,487,-170);
glEnd();
glColor3ub(0,0,0);
glBegin(GL_LINES);
glVertex3i(485-200,515,-163);
glVertex3i(485-200,480,-163);
glVertex3i(495-200,515,-170);
glVertex3i(495-200,487,-170);
glEnd();
glColor3ub(0,10,20);
glBegin(GL_POLYGON);
glVertex3i(560-200,530,-180);
glVertex3i(655-200,530,-180);
glVertex3i(635-200,515,-150);
glVertex3i(540-200,515,-150);
glEnd();
glColor3ub(0,0,0);
glBegin(GL_LINES);
glVertex3i(560-200,515,-160);
glVertex3i(560-200,480,-160);
glVertex3i(572-200,515,-170);
glVertex3i(572-200,487,-170);
glEnd();
glColor3ub(0,0,0);
glBegin(GL_LINES);
glVertex3i(620-200,515,-163);
glVertex3i(620-200,480,-163);
glVertex3i(630-200,515,-170);
glVertex3i(630-200,487,-170);
glEnd();
/******** upper ********/
glColor3ub(10,50,80);
glBegin(GL_POLYGON);
glVertex3i(350-200,620,-120);
glVertex3i(700-200,620,-120);
glVertex3i(700-200,600,-120);
glVertex3i(350-200,600,-120);
glEnd();
glBegin(GL_POLYGON);
glVertex3i(350-200,620,-120);
glVertex3i(700-200,620,-120);
glVertex3i(720-200,640,-240);
glVertex3i(380-200,640,-240);
glEnd();
glBegin(GL_POLYGON);
glVertex3i(700-200,620,-120);
glVertex3i(720-200,640,-240);
glVertex3i(720-200,620,-240);
glVertex3i(700-200,600,-120);
glEnd();
glBegin(GL_POLYGON);
glVertex3i(350-200,600,-120);
glVertex3i(350-200,620,-120);
glVertex3i(380-200,640,-240);
glVertex3i(380-200,620,-240);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_LINES);
glVertex3i(350-200,620,-120);
glVertex3i(700-200,620,-120);
glVertex3i(700-200,620,-120);
glVertex3i(720-200,640,-240);
glVertex3i(700-200,620,-120);
glVertex3i(700-200,600,-120);
glEnd();
}
/* */
// FUNCTION road
/* */
void road2()
{
/************** left part of road *********/
int x,y;
glColor3ub(7,255,13);
glBegin(GL_POLYGON);
glVertex2i(0,650);
glVertex2i(1000,650);
glVertex2i(1000,0);
glVertex2i(0,0);
glEnd();
glColor3ub(30,40,50);
glBegin(GL_POLYGON);
glVertex2i(0,420);
glVertex2i(1000,420);
glVertex2i(1000,300);
glVertex2i(0,300);
glEnd();
glBegin(GL_POLYGON);
glVertex2i(750,650);
glVertex2i(900,650);
glVertex2i(1000,0);
glVertex2i(650,0);
glEnd();
glColor3f(1.0,0.9,0.0);
for(x=0;x<1000;x=x+60)
{
glBegin(GL_POLYGON);
glVertex2f(x,352.5+19);
glVertex2f(x,357.5+19);
glVertex2f(x+30,357.5+19);
glVertex2f(x+30,352.5+19);
glEnd();
}
for(y=650;y>0;y=y-60)
{
glBegin(GL_POLYGON);
glVertex2f(822,y);
glVertex2f(826,y);
glVertex2f(826,y-30);
glVertex2f(822,y-30);
glEnd();
glutMainLoop();
return 1;
}
CHAPTER 5
TESTING
Testing process started with the testing of individual program units such as functions or
objects. These were then integrated into sub-systems and systems, and interactions of these
units were tested.
Testing involves verification and validation.
Validation: “Are we building right product?”
Verification: “Are we building the product right?”
The ultimate goal of the verification and validation process is to establish confidence that the
software system is ‘fit for purpose’. The level of required confidence depends on the system’s
purpose, the expectations of the system users and the current marketing environment for the
system.
With the verification and validation process, there are two complementary approaches to the
system checking and analysis:
Software inspections or peer reviews analyses and check system representations such as the
requirements document, design diagrams, and the program source code. Software testing
involves running an implementation of the software with test data.
CHAPTER 6
RESULT
Ashish
CHAPTER 7
CONCLUSION
To design and implement “Bus Stop Simulation”. OpenGL supports enormous flexibility
in the design and the use of OpenGL graphics program. The presence of many built-
in classes methods take care of much functionality and reduce the job of coding as well as
makes the implementation simpler. We have implemented the project making it user-
friendly and error free as possible. We regret any errors that may have inadvertently crept
in.
REFERENCES