CG project report2_merged
CG project report2_merged
CG project report2_merged
Submitted in partial fulfillment for requirement for the award of the degree of
BACHELOR ENGINEERING
IN
COMPUTER SCIENCE AND ENGINEERING
BY
CERTIFICATE
Certified that the mini project work entitled “TRAIN ARRIVAL AND DEPARTURE”
carried out by,
NISHA BALLAL 4KV19CS054
PAVANRAJ B U 4KV19CS058
We are grateful to our institution K.V.G COLLEGE OF ENGINEERING, SULLIA with its ideas
and inspiration for having provided us the facilities that have made this project a success.
We are deeply indebted to our guides Prof. SOORAJ PRASAD M H, Assistant Professor and
Prof. SINDHU VENKATESH, Assistant Professor, Department of Computer Science &
Engineering taking pain in the successful completion of this mini project.
We express our earnest gratification to H.O.D, Dept. of Computer Science & Engineering Dr.
UJWAL U J, who helped us in getting things done and were always inspirational which provided
us the impetus to complete this project successfully.
We express our heart full thanks to the Principal, Dr. SURESHA V for providing congenial to
work on it.
We express our heart full thanks to the General Secretary, Dr. RENUKA PRASAD K V for
providing congenial to work on it. We would like to extend our thanks to all the teaching and
non-teaching staff members and the students of C.S&E department for their help, advice and
support.
ABSTRACT
The Computer Graphics mini project called “Train Arrival and Departure Simulation” is a simple
project built using OpenGL, where railway station scenario is shown. The tarin will travel in
different modes of environment like day and night modes when you press the keyboard key. This
mini project is implemented using inbuilt functions of OpenGL and designed these objects which
we have used in the project. The project is developed in two-dimensional mode. The controls
will be specified and these will be provided from the keyboard and some of the options using
menu.
TABLE OF CONTENTS
1 INTRODUCTION 1
2 REQUIREMENT SPECIFICATION 2-3
3 SYSTEM DESIGN 4
4 SYSTEM IMPLEMENTATION 5-8
5 SNAPSHOTS 9-12
6 USER MANUAL 13
7 CONCLUSIONS 14
BIBLIOGRAPHY 15
TRAIN SIMULATION 2021-22
CHAPTER 1
INTRODUCTION
Train arrival and departure is a newly designed computer graphics mini project. In this mini
project, there will be objects like train, signal, and a place called “railway station”. There will be
a train in which it will start arriving at the railway station when the signal light “green” is turned
on. It will stop at the railway station when the red light is turned on and the train will not move
from the railway station till the user displays the green light in the traffic signal when the green
light is turned on then the train will start to depart from the railway station. In this project, there
will be night mode and day mode. The project is a bit difficult to implement since there are lots
of objects in this project a train, railway station, signal light these are the main objects and some
more in the project. The train when the user displays the green signal on the traffic signal the
train will start arriving at the station. When the train approaches the station then the red signal
will be displayed then the train will stop at the railway station and then after displaying the green
light, the train will depart from the station. By pressing the right button in the mouse, you can
see a menu on the screen. Which containing some options and if you click the left button of the
mouse, we can quit the program. In the night mode, a comet movement is also designed by the
controls provided.
1.1 AIM
The project aims to show a graphical representation of railway station scenario using OpenGL
functions with variety of objects like train, railway station, railway track, sun, stars, plane,
moon etc.
CHAPTER 2
REQUIREMENT SPECIFICATION
A requirement specification is a collection of all requirements that are to be imposed on the
design and verification of the product.
2.1.2 OpenGL
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 such as points, lines, and polygons.
OpenGL is an application programming interface offering various functions to implement
primitives, models and images. This offer 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.
Most of our applications will be designed to access OpenGL directly through functions in three
libraries. They are:
➢ OpenGL Utility Library: This library uses only GL functions but contains code for
creating common objects and simplifying viewing. All functions in GLU can be created
from the core GL library but application programmers prefer not to write the code
CHAPTER 3
SYSTEM DESIGN
Systems design is the process of defining the architecture, modules, interfaces, and data for a
system to satisfy specified requirements. Systems design could be seen as the application of
systems theory to product development.
main ()
draw_circle
plotpixels
draw_pixel
CHAPTER 4
SYSTEM IMPLEMENTATION
Systems implementation is the process of defining how the information system should be built
(i.e., physical system design), ensuring that the information system is operational and used,
ensuring that the information system meets quality standard.
• void draw_pixel():
void draw_pixel(GLint cx, GLint cy)
{
glBegin(GL_POINTS);
glVertex2i(cx, cy);
glEnd();
}
• void draw_circle():
void draw_circle(GLint h, GLint k, GLint r)
{
GLint d = 1 - r, x = 0, y = r;
while (y > x)
{
plotpixels(h, k, x, y);
if (d < 0) d += 2 * x + 3;
else
{
d += 2 * (x - y) + 5;
--y;
}
++x;
}
plotpixels(h, k, x, y); }
• void idle():
void idle()
{
glClearColor(1.0, 1.0, 1.0, 1.0);
m += SPEED / 150;
n -= 2;
o += 0.2;
c += 2;
}
if (light == 0 && (i >= 2600 && i <= 3000))
{
i += SPEED / 10;
m += SPEED / 150;
n -= 2;
o += 0.2;
c += 2;
}
if (light == 0)
{
i = i;
m += SPEED / 150;
n -= 2;
o += 0.2;
c += 2;
}
else
{
i += SPEED / 10;
m += SPEED / 150;
n -= 2;
o += 0.2;
c += 2;
}
if (i > 3500)
i = 0.0;
if (m > 1100)
m = 0.0;
if (o > 75)
{
plane = 0;
}
if (c > 500)
{
comet = 0;
}
glutPostRedisplay();
}
• void mouse():
void mouse (int btn, int state, int x, int y)
{
if (btn == GLUT_LEFT_BUTTON && state == GLUT_UP)
exit (0);
}
• void keyboardFunc():
void keyboardFunc(unsigned char key, int x, int y)
{
switch (key)
{
case 'g':
case 'G':
light = 1;
break;
case 'r':
case 'R':
light = 0;
break;
case 'd':
case 'D':
day = 1;
break;
case 'n':
case 'N':
day = 0;
break;
case 't':
case 'T':
train = 1;
i = 0;
break;
};
}
CHAPTER 5
SNAPSHOTS
CHAPTER 6
USER MANUAL
This program includes interaction through keyboards.
• d/D -Day
• n/N-Night
CHAPTER 7
CONCLUSION
Arrival and departure of the train and motion of some objects were included in this project. Some
other options are also provided. You can implement some other objects by keeping the reference
of this according to your requirements to enhance the project. This project can be implemented
using 3D viewing.
BIBLIOGRAPHY
• Donald Hearn & Pauline Baker: Computer Graphics with OpenGL Version,3rd /
4th Edition, Pearson Education,2011
• Edward Angel: Interactive Computer Graphics- A Top-Down approach with
OpenGL, 5th edition. Pearson Education, 2008
• https://www3.ntu.edu.sg/home/ehchua/programming/opengl/CG_Introduction.ht
ml