Bridge REPORT
Bridge REPORT
Bridge REPORT
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.
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 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.
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.
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.
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.
CHAPTER 3
REQUIREMENT SPECIFICATION
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.
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.
• Void display(void):
CHAPTER 5
IMPLEMENTATION
#include<stdio.h>
#include<GL/glut.h>
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;
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();
}
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();
;
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);
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();
//============================
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);
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);
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();
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();
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);
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();
}
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);
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();
}
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);
glVertex2f(30.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();
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
sea();
bridge();
boat();
car();
poles();
glFlush();
glutSwapBuffers();
}
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();
}
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();
gluOrtho2D(0.0,2000.0,0.0,1600.0);
}
case 2:glutIdleFunc(animate);
break;
case 3:exit(0);
}
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;
case 'y':m=0.0,j=1.0,o=1.0;
glutPostRedisplay();
break;
};
}
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;
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.
Sl
No Test Input Expected Results Observed Results Remarks
CHAPTER 7
SNAPSHOTS
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.
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.
BIBLIOGRAPHY
Book References:
Web References:
• www.opengl.org
• www.google.com
• www.sourcecode.com
• www.pearsoned.co.in
• www.wikipedia.org