Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Bridge REPORT

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

LIFT-OVER BRIDGE

CHAPTER 1

INTRODUCTION

Although computer graphics is a vast field that encompasses almost any graphical
aspect, we are mainly interested in the generation of images of 2 and 3-dimensional
scenes. Computer imagery has applications for film special effects, simulation and
training, games, medical imagery, flying logos, etc. Computer graphics relies on an
internal model of the scene, that is, a mathematical representation suitable for graphical
computations. One such real life scene we found interesting is the working of the Lift-
over Bridge or the Bascule Bridge and we have tried to incorporate this in this project.

A Bascule bridge (also called the Draw Bridge) is a movable bridge with a counter
weight that continuously balances the span or “Leaf” throughout the entire upward swing
in providing clearance for water traffic.

Bascule is basically a French term for ‘seesaw’ and ‘balance’. Lift-over bridges
operate using the same principle and are the most common type of movable bridge in
existence as they open quickly and require relatively less energy to operate. Although the
Bascule Bridge has been in use since ancient times, it was not until the 1850s that
engineers developed the ability to move very long, heavy spans quickly for practical
purposes. The main advantage of Lift Over bridges are:
➢ It lifts the bascules and allows the ships and other water way bodies under it.
➢ The lift over bridge would be having two bascules which seem to be a single block
when the bridge is closed. Whenever it is necessary to open the bascules, the bridge
would take the help of towers which would be constructed on either side of the bascules.
These towers act as supporting strength for the opening and closing bascules.
➢ The heavy cable helps to lift the bascules and place them back down. These cables
also determine the speed at which the bascules should lift up and down across the water
bodies.

Dept of CSE, GAT 2020-2021 1


LIFT-OVER BRIDGE

The whole process of opening the bascules, allowing a ship to pass and bringing them
down again for the resumption of road traffic takes only few minutes.
One of the most famous examples of the bascules is the Tower Bridge, which spans the
River Thames just below London Bridge. It is the most distinctive of London's bridges
and its construction was a masterly engineering achievement. The building of the Tower
Bridge came about because the development of cross-Thames traffic had far outstripped
the capacity of the existing bridges.

The lift over bridge performs following functions:


➢ The bridge allows the vehicles to move on it.
➢ When a ship approaches the bridge, a signal will be given to stop the movement of
vehicles over the bridge. As soon as the vehicles stop, the cables start to lift the bascules
up with the support of two towers.
➢ Now the ship travels under the bridge without any disturbance and as soon as the ship
passes the bridge area, the cables will lease down the bascules to make the way for road
traffic.

The Lift over bridge which performs all these functions has been implemented using
OpenGL functions and contains the Menu options and the Keyboard interface. It has the
following features and performs the following functions:

➢ OpenGL based bridge which lifts its roadway automatically whenever a ship sails
towards it.
➢ The bridge automatically returns to its normal position when a ship sails under it.
➢ A vehicle (car or bus) travels over the bridge.
➢ Other Options includes START ANIMATION, STOP ANIMATION and EXIT.
➢ The project is implemented on C platform with the help of OpenGL in-built functions.
Care is taken to provide an easy-to-use mouse and keyboard interface involving an icon
based interaction.

Dept of CSE, GAT 2020-2021 2


LIFT-OVER BRIDGE

CHAPTER 2
LITERATURE SURVEY

CG (Computer graphics) started with the display of data on hardcopy plotters and
cathode ray tube screens soon after the introduction of computer themselves. It includes
the creation, storage, and manipulation of models and images of objects. These models
include physical, mathematical, engineering, architectural, and even conceptual or
abstract structures, natural phenomena, and so on. Computer Graphics today is largely
interactive- the user controls the contents, structure, and appearance of objects and their
displayed images by using input devices, such as keyboard, mouse or touch sensitive
panel on the screen. Bitmap graphics is used for user-computer interaction. A Bitmap is
an ones and zeros representation of points (pixels, short for ‘picture elements’) on the
screen. Bitmap graphics provide easy-to-use and inexpensive graphics based applications.

The concept of ‘desktop’ is a popular metaphor for organizing screen space. By


means of a window manager, the user can create, position, and resize rectangular screen
areas, called windows, that acted as virtual graphics terminals, each running an
application. This allowed users to switch among multiple activities just by pointing at the
desired window, typically with the mouse. Graphics provides one of the most natural
means of communicating with the computer, since our highly developed 2D and 3D
pattern – recognition abilities allow us to perceive and process pictorial data rapidly and
efficiently. In many design, implementation, and construction processes, the information
pictures can give is virtually indispensable.

Computer graphics is the creation and manipulation of pictures with the aid of
computers. It is divided into two broad classes:
➢ Non-Interactive Graphics.
➢ Interactive Graphics.

2.1.1 Non-Interactive graphics –


This is a type of graphics where observer has no control over the pictures produced
on the screen. It is also called as Passive graphics.

Dept of CSE, GAT 2020-2021 3


LIFT-OVER BRIDGE

2.1.2 Interactive Graphics-


This is the type of computer graphics in which the user can control the pictures
produced. It involves two-way communication between user and computer. The computer
upon receiving signal from the input device can modify the displayed picture
appropriately. To the user it appears that the picture changes instantaneously in response
to his commands. The following fig. shows the basic graphics system:

Input devices Image in FB output devices


Fig 2.1: Basic Graphics System.

2.2 About OpenGL -


OpenGL is an open specification for an applications program interface for defining
2D and 3D objects. The specification is cross-language, cross-platform API for writing
applications that produce 2D and 3D computer graphics. It renders 3D objects to the
screen, providing the same set of instructions on different computers and graphics
adapters. Thus it allows us to write an application that can create the same effects in any
operating system using any OpenGL-adhering graphics adapter.

In Computer graphics, a 3-dimensional primitive can be anything from a single


point to an ‘n’ sided polygon. From the software standpoint, primitives utilize the basic 3-
dimensional rasterization algorithms such as Bresenham's line drawing algorithm,
polygon scan line fill, texture mapping and so forth.

Dept of CSE, GAT 2020-2021 4


LIFT-OVER BRIDGE

OpenGL is a low-level, procedural API, requiring the programmer to dictate the exact
steps required to render a scene. OpenGL's low-level design requires programmers to
have a good knowledge of the graphics pipeline, but also gives a certain amount of
freedom to implement novel rendering algorithms.

Fig 2.2: The OpenGL rendering pipeline.

2.3 Advantages of OpenGL-

➢ With different 3D accelerators, by presenting the programmer to hide the complexities


of interfacing with a single, uniform API.

➢ To hide the differing capabilities of hardware platforms, by requiring that all


implementations support the full OpenGL feature set (using software emulation if
necessary).

Dept of CSE, GAT 2020-2021 5


LIFT-OVER BRIDGE

CHAPTER 3
REQUIREMENT SPECIFICATION

3.1 SOFTWARE REQUIREMENTS


• Operating system – Windows 10
• Code::Blocks 17.12
• OPENGL library files – GL, GLU, GLUT
• Language used is C/C++

3.2 HARDWARE REQUIREMENTS


• Processor – Intel i5 7th Gen
• Memory – 8GB RAM
• 1TB Hard Disk Drive
• Mouse or other pointing device
• Keyboard
• Display device

Dept of CSE, GAT 2020-2021 6


LIFT-OVER BRIDGE

CHAPTER 4
SYSTEM DEFINITION
4.1 PROJECT DESCRIPTION
The Lift Over Bridge can be implemented using some of the OpenGL inbuilt
functions along with some user defined functions. The inbuilt OpenGL functions that
are used mentioned under the FUNCTIONS USED category. The user defined
functions are mentioned under USER DEFINED FUNCTIONS category.

4.2 USER DEFINED FUNCTIONS


• void glutMainLoop(void);

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 stop.
• glutPostRedisplay()
GlutPostRedisplay, glutPostWindowRedisplay — marks the current or specified window
as needing to be redisplayed.
• Void sea():
This function depicts the sea by drawing some horizontal lines on the window and
translating them in the direction opposite to that of the ship.
• Void bridge():
This function depicts the bridge in the scene.
• Void boat():
This function depicts the ship in the scene.
• Void car():
This function used to draw the object bus in the scene..
• Void pole():
This function used to draw the poles on the both sides of the bridge. Each side two pole
are drawn using the OpenGL inbuilt functions.

• Void animate():

This function used to give the step size of translation for each object in the scene.

Dept of CSE, GAT 2020-2021 7


LIFT-OVER BRIDGE

• Void main_menu(int ch):


This function would provide the menu that consists following options:
a) START ANIMATION
b) STOP ANIMATION
c) QUIT
• Void keyboard(unsigned char key, int y):

• Void display(void):

• int main(int argc, char**argv):

Dept of CSE, GAT 2020-2021 8


LIFT-OVER BRIDGE

CHAPTER 5
IMPLEMENTATION

5.1 Source Code:

#include<stdio.h>
#include<GL/glut.h>

//////////////////////////////////////// Declaration of global variables /////////////////////////

float y=0,ang=0,i=0,k=0,n=0;
float a=900,b=880,c=900,d=900,p,q=0,s;
float g=0; // car translate indicator
float m=.80,j=.50,o=.15;

////////////////////////////// sea function to display river ///////////////////////////////

void sea()
{
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glColor3f(0.0,0.50,1.0);
glVertex2f(0.0,0.0);
glVertex2f(2000.0,0.0);
glVertex2f(2000.0,1600.0);
glVertex2f(0.0,1600.0);
glEnd();

glPushMatrix();
glTranslatef(0,q,0);

glBegin(GL_LINES);
glColor3f(1.0,1.0,1.0);
for(p=0;p<20000;p=p+100)
for(s=0;s<20000;s=s+100)
glVertex2f(100.0+s,100.0+p);
glVertex2f(200.0+s,100.0+p);
glEnd();

glPopMatrix();
}

//////////////////////////////////////// Bridge function ////////////////////////////////////

Dept of CSE, GAT 2020-2021 9


LIFT-OVER BRIDGE

void bridge()
{
glBegin(GL_POLYGON);
glColor3f(0.40,0.40,0.40);
glVertex2f(0.0,900.0);
glVertex2f(500.0,900.0);
glVertex2f(500.0,1200.0); //bridge top 1
glVertex2f(0.0,1200.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,1.0,1.0);
glVertex2f(100.0,1030.0);
glVertex2f(200.0,1030.0);
glVertex2f(200.0,1040.0); //strip1
glVertex2f(100.0,1040.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,1.0,1.0);
glVertex2f(300.0,1030.0);
glVertex2f(400.0,1030.0);
glVertex2f(400.0,1040.0); //strip2
glVertex2f(300.0,1040.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,1.0,.0);
glVertex2f(0.0,1170.0);
glVertex2f(500.0,1170.0);
glVertex2f(500.0,1175.0); //yellow strip1
glVertex2f(0.0,1175.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,1.0,0.0);
glVertex2f(0.0,920.0);
glVertex2f(500.0,920.0);
glVertex2f(500.0,930.0); //yellow strip2
glVertex2f(0.0,930.0);
glEnd();

// brige up

glPushMatrix();
;

Dept of CSE, GAT 2020-2021 10


LIFT-OVER BRIDGE

glBegin(GL_POLYGON);
glColor3f(0.46,0.46,0.46);
glVertex2f(500.0,900.0); //bridge top 2
//up
glVertex2f(900.0-k,900.0+n);
glVertex2f(900.0-k,1200.0+n);
//up
glVertex2f(500.0,1200.0);
glEnd();

glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(20.0,1400.0);
glVertex2f(900.0-k,900.0+n); //pole thread front
glVertex2f(0.0,1400.0);
glVertex2f(900.0-k,880.0+n);
glEnd();

glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(30.0,1550.0);
glVertex2f(900.0-k,1200.0+n); //pole thread back
glVertex2f(50.0,1550.0);
glVertex2f(900.0-k,1203.0+n);
glEnd();

glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.0);
glVertex2f(500.0,880.0);
glVertex2f(900.0-k,880.0+n); //base1
glVertex2f(900.0-k,900.0+n);
glVertex2f(500.0,900.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(0.46,0.46,0.46);
glVertex2f(900.0+k,900.0+n);
//up
glVertex2f(1300.0,900.0); // bridge top3
glVertex2f(1300.0,1200.0);
//up
glVertex2f(900.0+k,1200.0+n);

Dept of CSE, GAT 2020-2021 11


LIFT-OVER BRIDGE

glEnd();

glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.0);
glVertex2f(900.0+k,880.0+n);
glVertex2f(1300.0,880.0); // base 2
glVertex2f(1300.0,900.0);
glVertex2f(900.0+k,900.0+n);
glEnd();
glPopMatrix();

// printf("i== %f\t k==%f\n",i,k);

//============================
glBegin(GL_POLYGON);
glColor3f(0.40,0.40,0.40);
glVertex2f(1300.0,900.0);
glVertex2f(2000.0,900.0); //bridge top 4
glVertex2f(2000.0,1200.0);
glVertex2f(1300.0,1200.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,1.0,0.0);
glVertex2f(1300.0,1170.0);
glVertex2f(2000.0,1170.0);
glVertex2f(2000.0,1175.0); //yellow strip3
glVertex2f(1300.0,1175.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0,1.0,0.0);
glVertex2f(1300.0,920.0);
glVertex2f(2000.0,920.0);
glVertex2f(2000.0,930.0); // yellow strip4
glVertex2f(1300.0,930.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,1.0,1.0);
glVertex2f(1400.0,1030.0);
glVertex2f(1500.0,1030.0);
glVertex2f(1500.0,1040.0); //strip3
glVertex2f(1400.0,1040.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,1.0,1.0);

Dept of CSE, GAT 2020-2021 12


LIFT-OVER BRIDGE

glVertex2f(1600.0,1030.0);
glVertex2f(1700.0,1030.0);
glVertex2f(1700.0,1040.0); //strip4
glVertex2f(1600.0,1040.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,1.0,1.0);
glVertex2f(1800.0,1030.0);
glVertex2f(1900.0,1030.0);
glVertex2f(1900.0,1040.0); //strip5
glVertex2f(1800.0,1040.0);
glEnd();

glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(1725.0,1550.0);
glVertex2f(900.0+k,1200.0+n); //rite pole thread
glVertex2f(1745.0,1550.0);
glVertex2f(900.0+k,1200.0+n);
glEnd();

glBegin(GL_POLYGON);
glColor3f(0.25,0.25,0.25);
glVertex2f(200.0,800.0); //6 point polygon 1
glVertex2f(200.0,700.0);
glVertex2f(300.0,700.0);
glVertex2f(300.0,800.0);
glVertex2f(350.0,880.0);
glVertex2f(150.0,880.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.0);
glVertex2f(0.0,880.0);
glVertex2f(500.0,880.0); //base3
glVertex2f(500.0,900.0);
glVertex2f(0.0,900.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.0); //base4
glVertex2f(1300.0,880.0);
glVertex2f(2000.0,880.0);
glVertex2f(2000.0,900.0);
glVertex2f(1300.0,900.0);
glEnd();

glBegin(GL_POLYGON);

Dept of CSE, GAT 2020-2021 13


LIFT-OVER BRIDGE

glColor3f(0.25,0.25,0.25);
glVertex2f(1500.0,800.0);
glVertex2f(1500.0,700.0);
glVertex2f(1600.0,700.0); //6 point polygon2
glVertex2f(1600.0,800.0);
glVertex2f(1650.0,880.0);
glVertex2f(1450.0,880.0);
glEnd();

////////////////////////////////////////// Boat function ///////////////////////////////

void boat()
{
glPushMatrix();

glTranslatef(0,y,0);
glPushMatrix();
glBegin(GL_POLYGON);
glColor3f(m,j,o);
glVertex2f(900.0,700.0);
glVertex2f(800.0,620.0);
glVertex2f(750.0,500.0);
glVertex2f(750.0,200.0); //ship
glVertex2f(900.0,50.0);
glVertex2f(1050.0,200.0);
glVertex2f(1050.0,500.0);
glVertex2f(1000.0,620.0);

glEnd();

glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.0); // ship back 1
glVertex2f(750.0,200.0);
glVertex2f(900.0,0.0);
glVertex2f(900.0,50.0);
glVertex2f(751.0,200.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(0.1,0.1,0.1);
glVertex2f(901.0,0.0); //ship back 2
glVertex2f(1050.0,200.0);
// glVertex2f(1051.0,200.0);
glVertex2f(901.0,50.0);
glEnd();

Dept of CSE, GAT 2020-2021 14


LIFT-OVER BRIDGE

glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(900.0,700.0);
glVertex2f(820.0,600.0); //boat grill
glVertex2f(820.0,600.0);
glVertex2f(800.0,620.0);
glVertex2f(820.0,600.0);
glVertex2f(770.0,500.0);
glVertex2f(770.0,500.0);
glVertex2f(750.0,500.0);
glVertex2f(770.0,500.0);
glVertex2f(770.0,200.0);
glVertex2f(770.0,200.0);
glVertex2f(750.0,200.0);
glVertex2f(770.0,200.0);
glVertex2f(900.0,70.0);
glVertex2f(900.0,70.0);
glVertex2f(900.0,50.0);
glVertex2f(900.0,70.0);
glVertex2f(1030.0,200.0);
glVertex2f(1030.0,200.0);
glVertex2f(1050.0,200.0);
glVertex2f(1030.0,200.0);
glVertex2f(1030.0,500.0);
glVertex2f(1030.0,500.0);
glVertex2f(1050.0,500.0);
glVertex2f(1030.0,500.0);
glVertex2f(980.0,620.0);
glVertex2f(980.0,620.0);
glVertex2f(1000.0,620.0);
glVertex2f(980.0,620.0);
glVertex2f(900.0,700.0);
glVertex2f(770.0,350.0);
glVertex2f(750.0,350.0);
glVertex2f(770.0,450.0);
glVertex2f(750.0,450.0);
glVertex2f(770.0,250.0);
glVertex2f(750.0,250.0);
glVertex2f(1030.0,250.0);
glVertex2f(1050.0,250.0);
glVertex2f(1030.0,350.0);
glVertex2f(1050.0,350.0);
glVertex2f(1030.0,450.0);
glVertex2f(1050.0,450.0);
glVertex2f(840.0,130.0);
glVertex2f(820.0,110.0);
glVertex2f(975.0,110);
glVertex2f(955.0,125.0);

Dept of CSE, GAT 2020-2021 15


LIFT-OVER BRIDGE

glEnd();

// printf("g==%d\n",g);

glBegin(GL_POLYGON);
glColor3f(0.10,0.10,0.);
glVertex2f(850.0,400.0); //boat inside polygon
glVertex2f(950.0,400.0);
glVertex2f(950.0,500.0);
glVertex2f(850.0,500.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.0);
glVertex2f(850.0,400.0);//table on ship1
glVertex2f(850.0,350.0);
glVertex2f(860.0,350.0);
glVertex2f(860.0,400.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.0);
glVertex2f(920.0,400.0);//2
glVertex2f(930.0,380.0);
glVertex2f(930.0,380.0);
glVertex2f(920.0,400.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.0);
glVertex2f(950.0,400.0);//3
glVertex2f(950.0,350.0);
glVertex2f(940.0,350.0);
glVertex2f(940.0,400.0);
glEnd();

glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.0);
glVertex2f(860.0,400.0);
glVertex2f(860.0,380.0);
glVertex2f(870.0,380.0);//4
glVertex2f(870.0,400.0);
glEnd();
glPopMatrix();
glPopMatrix();
}

Dept of CSE, GAT 2020-2021 16


LIFT-OVER BRIDGE

//////////////////////////////////////////// bus/car function //////////////////////////////////


void car()
{
glPushMatrix();

glTranslatef(g,0,0);

//glPushMatrix();
//glTranslatef(1820.0,1030.0,0.0);
//glutSolidSphere(1.0,200,200);
//glPopMatrix();

glBegin(GL_POLYGON); // car
glColor3f(1.0,0.0,0.0);
glVertex2f(1800.0,1050.0);
glVertex2f(1950.0,1050.0);
glVertex2f(1950.0,1150.0);
glVertex2f(1800.0,1150.0);
glEnd();

glBegin(GL_POLYGON); // car
glColor3f(0.0,0.0,0.0);
glVertex2f(1770.0,1030.0);
glVertex2f(1800.0,1050.0);
glVertex2f(1800.0,1150.0);
glVertex2f(1770.0,1130.0);
glEnd();

glBegin(GL_POLYGON); // car
glColor3f(0.0,0.0,0.0);
glVertex2f(1770.0,1030.0);
glVertex2f(1930.0,1030.0);
glVertex2f(1950.0,1050.0);
glVertex2f(1800.0,1050.0);
glEnd();

glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(1820.0,1080.0);
glVertex2f(1920.0,1080.0);
glVertex2f(1920.0,1080.0);
glVertex2f(1920.0,1110.0);
glVertex2f(1920.0,1110.0); //carrier
glVertex2f(1820.0,1110.0);
glVertex2f(1820.0,1110.0);

Dept of CSE, GAT 2020-2021 17


LIFT-OVER BRIDGE

glVertex2f(1820.0,1080.0);
glVertex2f(1840.0,1080.0);
glVertex2f(1840.0,1110.0);
glVertex2f(1860.0,1080.0);
glVertex2f(1860.0,1110.0);
glVertex2f(1880.0,1080.0);
glVertex2f(1880.0,1110.0);
glVertex2f(1900.0,1080.0);
glVertex2f(1900.0,1110.0);
glEnd();

glBegin(GL_LINES);
glColor3f(1.0,0.0,0.0);
glVertex2f(1780.0,1035.0); //head lamp
glVertex2f(1780.0,1045.0);
glEnd();

glBegin(GL_LINES);
glColor3f(1.0,0.0,0.0);
glVertex2f(1780.0,1125.0); //head lamp
glVertex2f(1780.0,1135.0);
glEnd();

glBegin(GL_LINES);
glColor3f(1.0,0.0,0.0);
glVertex2f(1790.0,1055.0); //horn grill
glVertex2f(1790.0,1125.0);
glEnd();

glBegin(GL_LINES);
glColor3f(1.0,0.0,0.0);
glVertex2f(1800.0,1040.0); //side window
glVertex2f(1928.0,1040.0);
glEnd();
glPopMatrix();
}

/////////////////////////////////////////////////// Pole Function ///////////////////////////////

void poles()
{
glBegin(GL_POLYGON); // left pole behind
glColor3f(0.0,0.0,0.0);
glVertex2f(30.0,1200.0);
glVertex2f(50.0,1200.0);
glVertex2f(50.0,1550.0);

Dept of CSE, GAT 2020-2021 18


LIFT-OVER BRIDGE

glVertex2f(30.0,1550.0);
glEnd();

glBegin(GL_POLYGON); // right pole behind


glColor3f(0.0,0.0,0.0);
glVertex2f(1725.0,1200.0);
glVertex2f(1745.0,1200.0);
glVertex2f(1745.0,1550.0);
glVertex2f(1725.0,1550.0);
glEnd();

glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(1750.0,1400.0);
glVertex2f(900.0+k,900.0+n); //right pole thread front
glVertex2f(1770.0,1400.0);
glVertex2f(900.0+k,880.0+n);
glEnd();

glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(20.0,1400.0);
glVertex2f(900.0-k,900.0+n); //pole thread front
glVertex2f(0.0,1400.0);
glVertex2f(900.0-k,880.0+n);
glEnd();

glBegin(GL_POLYGON); // left pole front


glColor3f(0.0,0.0,0.0);
glVertex2f(0.0,900.0);
glVertex2f(20.0,900.0);
glVertex2f(20.0,1400.0);
glVertex2f(0.0,1400.0);
glEnd();

glBegin(GL_POLYGON); // right pole front


glColor3f(0.0,0.0,0.0);
glVertex2f(1750.0,900.0);
glVertex2f(1770.0,900.0);
glVertex2f(1770.0,1400.0);
glVertex2f(1750.0,1400.0);
glEnd();
}

Dept of CSE, GAT 2020-2021 19


LIFT-OVER BRIDGE

/////////////////////////////// display function ///////////////////////////

void display(void)
{

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
sea();
bridge();
boat();
car();
poles();

glFlush();
glutSwapBuffers();
}

///////////////////////////////// function to animate bridge stripes //////////////////////////////

void animate()
{
q=q-.5;
y=y+0.2;

i+=0.2;
if((i>=135) && (i<=439))
{ k=k+0.1;
n=n+0.1;
}
if(i>=1200 && !(k<=0 && n<=0))
{
k=k-0.1;
n=n-0.1;
}

if(k<=0)
g-=0.5;

glutPostRedisplay();
}

/////////////////////////////////// myinit function //////////////////////////////////

void myinit()
{
glClearColor(1.0,1.0,1.0,1.0);
glColor3f(1.0,1.0,1.0);
glPointSize(1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

Dept of CSE, GAT 2020-2021 20


LIFT-OVER BRIDGE

gluOrtho2D(0.0,2000.0,0.0,1600.0);
}

/////////////////////////////////// Menu function ///////////////////////

void main_menu(int ch)


{
switch(ch)
{
case 1:glutIdleFunc(NULL);
break;

case 2:glutIdleFunc(animate);
break;

case 3:exit(0);
}

///////////////////////////////// K/B function for changing boat color //////////////////

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


{
switch( key )
{
case 'r':m=1.0,j=0.0,o=0.0;
glutPostRedisplay();
break;

case 'g':m=0.0,j=1.0,o=0.0;
glutPostRedisplay();
break;

case 'b':m=0.0,j=0.0,o=1.0;
glutPostRedisplay();
break;

case 'w':m=1.0,j=1.0,o=1.0;
glutPostRedisplay();
break;

case 'm':m=1.0,j=.0,o=1.0;
glutPostRedisplay();
break;

case 'c':m=.0,j=1.0,o=1.0;
glutPostRedisplay();
break;

Dept of CSE, GAT 2020-2021 21


LIFT-OVER BRIDGE

case 'y':m=0.0,j=1.0,o=1.0;
glutPostRedisplay();
break;

};
}

////////////////////////////////////////////// main function ///////////////////////////////////

int main(int argc,char **argv)


{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(2000,1600);
glutInitWindowPosition(0,0);
glutCreateWindow("BRIDGE");

glutCreateMenu(main_menu);
glutAddMenuEntry("Stop Animation",1);
glutAddMenuEntry("Start Animation",2);

glutAddMenuEntry("Quit",3);
glutAttachMenu(GLUT_RIGHT_BUTTON);

glutKeyboardFunc(keyboard);
glutKeyboardFunc(keyboard);
printf("press 'r' to change the ship color to red\n");
printf("press 'g' to change the ship color to green\n");
printf("press 'b' to change the ship color to brown\n");
printf("press 'c' to change the ship color to cyan\n");
printf("press 'm' to change the ship color to magenta\n");
printf("press 'w' to change the ship color to white\n");
printf("press 'y' to change the ship color to light grey\n");
glutDisplayFunc(display);
myinit();
glClearColor (1.0, 1.0, 0.0, 1.0);
glutMainLoop();
return 0;

//////////////////////////////////// The End :D ///////////////////////////

Dept of CSE, GAT 2020-2021 22


LIFT-OVER BRIDGE

CHAPTER 6
TESTING AND RESULTS
6.1 DIFFERENT TYPES OF TESTING

Unit Testing
Individual components are tested to ensure that they operate correctly. Each
component is tested independently, without other system components

Module Testing
A module is a collection of dependent components such as a object class, an
abstract Data type or some looser collection of procedures and functions. A
module related Components, so can be tested without other system modules.

System Testing
This is concerned with finding errors that result from unanticipated interaction
between Sub-system interface problems.

Acceptance Testing
The system is tested with data supplied by the system customer rather than
simulated test data.

Dept of CSE, GAT 2020-2021 23


LIFT-OVER BRIDGE

6.2 TEST CASES


The test cases provided here test the most important features of the project.

Sl
No Test Input Expected Results Observed Results Remarks

1 Right click Menu to be displayed Menu displayed Pass


2 Left click Menu not to be displayed Menu not displayed Pass
Click on menu item
3 The field is to be ploughed. The field is ploughed. Pass
“PLOUGHING”
Click on menu item Description of power plant to Description of power
4 Pass
“SEEDING” be displayed plant displayed
Click on menu item The water comes out of The water comes out of
5 Pass
“WATERING” pump set. pump set.
Click on menu item The crops grown is The crop grown is
6 Pass
“HARVEST” harvested. harvested.
Click on menu item
7 Exit Exit Pass
“Quit”

Table 5.2.1: Test Case

Dept of CSE, GAT 2020-2021 24


LIFT-OVER BRIDGE

CHAPTER 7
SNAPSHOTS

• Snap shot of Initial stage of the Lift over bridge :

• Snap Shot Showing Main Menu (mouse interface) :

Dept of CSE, GAT 2020-2021 25


LIFT-OVER BRIDGE

• Snapshot shows the lifting up the bascules :

• Snap Shot Shows the changing the colors of boat:

Dept of CSE, GAT 2020-2021 26


LIFT-OVER BRIDGE

• Snap Shot Shows the Bridge moving down:

• Snap Shot Shows the Vehicle Crossing Over the Bridge:

Dept of CSE, GAT 2020-2021 27


LIFT-OVER BRIDGE

CONCLUSIONS AND FUTURE SCOPE

General Constraints:
• As the software is being built to run on Ubuntu platform, which gives access to
limited conventional memory, the efficient use of the memory is very important.
• As the program needs to be run even on low-end machines the code should be
efficient and optimal with the minimal redundancies.
• Needless to say, the computation of algorithms should also be robust and fast.
• It is built assuming that the standard output device (monitor) supports colors.

Assumptions and Dependencies:


• One of the assumptions made in the program is that the required libraries like GL,
GLU and glut have been included.
• The user's system is required to have the C compiler of the appropriate version.
• The system is also expected to have a keyboard and mouse connected since we
provide the inputs via these devices.

Further Enhancements:
The following are some of the features that can be included in the revised versions of this
code are:
• Sounds of sea, boat, bus and bridge movement can be incorporated.
• Support for different types of vehicles all moving simultaneously on bridge.
• Support for advanced 3D representation of the entire scenario.
• Support for transparency of layers and originality.

Dept of CSE, GAT 2020-2021 28


LIFT-OVER BRIDGE

BIBLIOGRAPHY

Book References:

• Ariponnammal, S. and Natarajan, S. (1994) ‘Transport Phenomena of Sm Sel-X Asx’,


Pramana – Journal of Physics Vol.42, No.1, pp.421-425.
• Barnard, R.W. and Kellogg, C. (1980) ‘Applications of Convolution Operators to
Problems in Univalent Function Theory’, Michigan Mach, J., Vol.27, pp.81–94.
• Shin, K.G. and McKay, N.D. (1984) ‘Open Loop Minimum Time Control of Mechanical
Manipulations and its Applications’, Proc.Amer.Contr.Conf., San Diego, CA, pp. 1231-
1236.

Web References:

• www.opengl.org
• www.google.com
• www.sourcecode.com
• www.pearsoned.co.in
• www.wikipedia.org

Dept of CSE, GAT 2020-2021 29

You might also like