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

3D AEROPLANE SIMULATION

Chapter 1

INTRODUCTION
The dominant characteristics of this new computer and communication technologies have
become dominant forces in our life. Activities as wide ranging as filmmaking, publishing,
banking and education continue to undergo revolutionary changes as these technologies alter
the ways in which we conduct our daily activities. The combination of computers , networks,
and the complex visual system, through the computer graphics has led to new way of
displaying information, seeing virtual worlds and communicating with people and machines.

Computer graphics is concerned with all aspects of producing pictures or images using a
computer. The field has begun humbly almost 50 years ago, with a display of few lines on a
cathode ray tube, now we can create images by computer that are indistinguishable from
photographs of real objects. We routinely train pilots with simulated airplanes, generating
graphical displays of virtual environment of real time. Feature length movies made entirely
by computer have been successful, both critically and financially. Massive multiplayer games
can involve tens of thousands of concurrent participants.

1.1 GLUT:

It is complete API written by mark kilogram, which lets us create windows and handle the
messages. It exists for several platforms that a program, which uses GLUT, can be compiled
on many platforms without any changes in the code.

ADDITONAL LIBRARIES:

There are two libraries functions that we have learnt in OpenGL.

1 .glu :It is a set of utility functions, they are easy way of doing things that is tedious with
raw OpenGL.

2. glx :It allows you to open up X window and link it up with OpenGL so that it will draw to
that window.

DEPT OF CSE, SVCE 2022-2023 Page 1


3D AEROPLANE SIMULATION

1.2 HOW OpenGL WORKS?

To be hardware independent OpenGL provides its own data types, they all begin with “GL”.
Eg: GLfloat, Glint. There are also many symbolic constants that all begin with ”GL”. Eg:
GL_POINTS, GL_LINES. Finally commands have prefix ”gl”. Eg: glVertex3f (f, i, d).

There are utility library called as “GLU”. Here the prefixes are “GLU_”, ”glu”. GLUT
commands begin with “glut” it is same for every library. OpenGL is a widely accepted
standard for developing graphics applications. Fortunately, OpenGL is easy to learn and it
possesses most of the characteristics of other graphics systems. Graphics API’s such as
OpenGL, developed as a way to provide application programmers with the access to
hardware features that were being provided by the latest graphics hardware.

Application of Computer Graphics:

The development of computer graphics has been driven both by needs of the user
community and by advancement in technology. The applications of computer graphics of
computer graphics are many and varied, we can divide them into four categories :

1. Display of information

2. Design

3. Simulation and Animation

4. User interface

1. Display of Information:

Medical imaging possesses interesting and important data analysis problem. Modern imaging
technologies such as computed tomography (CT), magnetic resonance imaging(MRI),
ultrasound, and position emission tomography(PET), generate 3D data that must be subjected
to algorithmic manipulation to provide useful information.

The field of scientific visualization provides graphical tools that help the researchers interpret
the fast quantity of data that generate.

DEPT OF CSE, SVCE 2022-2023 Page 2


3D AEROPLANE SIMULATION

2. Design:

Professions such as engineering and architecture are concerned with design. Starting with a
set of specifications, engineers and architects seek a cost effective and esthetical solution that
satisfies the specifications.

Design is an interactive process. Design problem are either over determined such that they
possess no solution that satisfies all criteria, much less an optimal solution, or undetermined,
such that they have multiple solutions that satisfies the design criteria.

3. Simulation and Animation:

Graphics system evolved to be capable of generating sophisticated images in real time,


engineers and researchers began to use them as simulators. One of the most important use has
been in training of pilots. The use of special PLSI chips has led to a generation of arcade,
games as sophisticated as flight simulators.

The simulators can be used for designing the robot, planning its path, and simulating its
behaviour in complex environment. The success of flight simulators led to the use of
computer graphics for animation in TV, motion pictures and advertising industries. Entire
animated movies can now be made by computers at a cost less than that of movies made with
traditional ways.

4.User interface:

Our interaction with computers has become dominated by visual paradigm that includes
icons, menus and pointing devices such as mouse. From users perspectives, winding system
such as X and window system, Microsoft windows.

1.3 OPENGL:

 Graphics rendering API.

 High Quality colour images composed of geometric primitives

DEPT OF CSE, SVCE 2022-2023 Page 3


3D AEROPLANE SIMULATION

 Operating system independent

 OpenGL is an application programmer’s interface (API) that allows programmers to


write programs that access graphics hardware.

OpenGL provide a set of commands to render a two dimensional scene. That means you
provide data in OpenGL usable form and OpenGL will show you this data in scene (render
it).it is developed by many companies and it is free for use. You can develop OpenGL
applications without licensing.

OpenGL based on the state variables, there are many values for example, the colour, you can
specify a colour once and draw several polygons, lines and whatever you want. Then there
are no classes like in directX. However it is logically structured. Before we come to the
commands themselves, here are another thing.

To be hardware independent, OpenGL provides its own data types . They all begin with
“GL”. For ex: GLfloat, GLint and so on. There are also many symbolic constants; they all
begin with “GL” for ex: GL_POINTS, GL_LINES. Finally the commands have the prefix
“gl”. There is utility library called GLU, here the prefixes are “GLU” & “glu”. It is same for
every library. You want to know which library coexist with the one called before. There are
libraries for every system. Windows as the wgl*functions, UNIX system glx* and so on.

It is very important thing to know, that there are two important matrices, which affect the
transformation from 3D world to 3Dscreen. The projection matrix and the model view
matrix. The projection matrix contains information, how a vertex can be mapped tom the
screen. This contains, whether the projection shall be isometric or a form of perspective, how
wide the field of view is and so on. Into the other matrix you put information, how the objects
are moved, where the viewer is and so on.

DEPT OF CSE, SVCE 2022-2023 Page 4


3D AEROPLANE SIMULATION

The OpenGL pipeline:

Fig1.3.1: the OpenGL rendering pipeline

Commands may be either be accumulated in display lists are processed immediately through
pipeline architecture. Display lists allow for greater optimization and command reuse, but not
all commands can be put in display lists.

The first stage is evaluator. This stage effectively takes any polynomial evaluator commands
and evaluates them into their corresponding vertex and attributes commands

The second stage is 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 frame buffer address 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 frame buffer, they
may subjected to a series of conditional tests and modifications, such as blending or Z-
buffering.

DEPT OF CSE, SVCE 2022-2023 Page 5


3D AEROPLANE SIMULATION

1.4 PROJECT INTRODUCTION

The goal of this simulation is to fly as far as possible, with four controls at your disposal, this
is one of those “easy to learn, difficult to master” situations. You’ll first be provided with a
plane and a scene.

Click ‘G’ to start make your little green guy take off from the land, and it’s on!! As you
fly,you are given controls to move your plane around the screen. So it’s critical to master this
bouncy method of flying. Rings of varying sizes are placed around the scene. So, you’ll
spend most of your time avoiding these or you can dodge through them.

As far as the simulation interface is concerned, you’ll be greeted with a loading screen with
will display the name of game followed by the instruction to start the game . You’ll then see a
menu on the screen once the simulation starts with the following items:

• Up ‘W’

• Down ‘S’

• Right ‘ D’

• Left ‘ A’

• Main Menu ‘M’

The user can start the game directly ,by clicking in the word ‘G’. Otherwise, he can view the
instruction as to the simulation starts . If the player has changed his mind to play the game
sometime later, he can click on “M” button which terminates the game.

DEPT OF CSE, SVCE 2022-2023 Page 6


3D AEROPLANE SIMULATION

Chapter 2

SYSTEM REQUIREMENTS

2.1 Software Requirements:

 An MS_DOS based operating system like windows XP

 A visual C/C++ compiler is required for compiling the source code to make a
executable file which can be directly executed.

 The built in graphics and dynamic link libraries like glut and glut32, and header file
like glut.h to create 3D&3D layout.

2.2 Hardware Requirements:

 Processor : intel 486/Pentium processor and above

 Processor speed : 500MHz or above

 RAM : 64 MB or above

 Storage space : 50 MB or above

 Monitor Resolution : colour monitor with minimum resolution of 640*480

DEPT OF CSE, SVCE 2022-2023 Page 7


3D AEROPLANE SIMULATION

Chapter 3
PROJECT DESIGN
3.1 PURPOSE
Demonstration of simulation of a 3D Aeroplane design.

3.2 DESCRIPTION
Click ‘G’ to start make your little green guy take off from the land, and it’s on!! As you
fly,you are given controls to move your plane around the screen. So it’s critical to master this
bouncy method of flying. Rings of varying sizes are placed around the scene. So, you’ll
spend most of your time avoiding these or you can dodge through them.

As far as the simulation interface is concerned, you’ll be greeted with a loading screen with
will display the name of game followed by the instruction to start the game . You’ll then see a
menu on the screen once the simulation starts with the following items:

• Up ‘W’

• Down ‘S’

• Right ‘ D’

• Left ‘ A’

• Main Menu ‘M’

The user can start the game directly ,by clicking in the word ‘G’. Otherwise, he can view the
instruction as to the simulation starts . If the player has changed his mind to play the game
sometime later, he can click on “M” button which terminates the game.

DEPT OF CSE, SVCE 2022-2023 Page 8


3D AEROPLANE SIMULATION

2.3 FLOW CHART


START

MAIN

INITIALIZE CALLBACK FUNCTIONS

MAIN SCREEN DISPLAYED

KEYBOARD KEYS

W or w S or s A or a D or d

TOP DOWN LEFT SIDE RIGHT


SIDE

EVENTS OR
END

STOP

Fig2.3.1: Flowchart for Simulation of 3D Aeroplane

DEPT OF CSE, SVCE 2022-2023 Page 9


3D AEROPLANE SIMULATION

Chapter 4
IMPLEMENTATION

This program has been developed and implemented using OpenGL interface. In
corporate this facility includes glut.h header files.

 Void glBegin(glEnum mode)


Initiates a new primitive of mode and starts the collection of vertices. Values of mode include
GL_POITS, GL_LINES and GL_POLYGON.

 Void glEnd()
Terminates a list of vertices.

4.1 Attributes

 Void glColor3[b I f d ub us ui](TYPE r,TYPEg,TYPE b)


Sets the present RGB colors. Valid types are byte(b),int (i), float (f), double (d), unsigned
byte(ub), unsigned short(us) and unsigned int (ui).

1. Void glClearColor(GLclampfg,Glclampfg,Glclampfb, Glclampfa)


Sets the present RGBA clear color used when clearing the color buffer. Variable of Glclampf
are floating point numbers between 0.0 and1.0.

2. Void glPointSize(Glfloat size)


Sets the point size attribute in pixels.

4.2 Working with the window system

 Void glFlush()
Forces any buffered openGL commands to execute.

 Void glutInit(int argc,char **argv)

DEPT OF CSE, SVCE 2022-2023 Page 10


3D AEROPLANE SIMULATION

Initializes GLUT. The arguments from main are passed in and can be used by the application.

 Void glutCreateWindow(char*title)
Creates a window on the display. The string title can be used by the window. The return value
provides reference to the windows that can be used when there are multiple windows.
 void glutInitDisplayMode(unsigned int mode)
Requests a display with the properties in mode. The value of mode is determined by the
logical OR of options including the colormodel(GLUT_RGB, GLUT_INDEX) and buffering
(GLUT_SINGLE,GLUT_DOUBLE).

 void glutInitWindowSize(intwidth,int height)


Specifies the initial height and width of the window in pixels.

 void glutInitWindowPosition(intx,int y)
Specifies the initial position of top-left corner of the window in pixels.

 void glViewport(intx,inty,Glsizei height)


Specifies a width x height viewport in pixels whose lower left corner is at(x,y) Measured
from origin of the window.

 void glutMainLoop()
Causes the program to enter an event processing loop. It should be the lat statement in main.

 Void glutDisplayFunc(void(*func)(void))
Requests that the display callback be executed after the current callback returns.

 void glutSwapBuffers()
Swaps the front and back buffers.

4.3 Interaction

 Void glutReshapeFunc(void *f(intwidth,int height)

DEPT OF CSE, SVCE 2022-2023 Page 11


3D AEROPLANE SIMULATION

Registers the reshape callback function f. The callbackfunc returns the height and
width of the new window. The reshape callback invokes display callback.

 Void glutKeyboardFunc(void *f(char key,intwidth,int height)


Register the keyboard callbackfunc f. The callback function returns the ASCII ode of
the key pressed and the position of the mouse.

 Void glutIdleFunc(void (*f)(void))


Registers the display callback function f that is executed whenever there are no other
events to be handled.

 Void glutMouseFunc(void *f(intbutton,intstate,intx,int y))


Registers the mouse callbackfunction f. The callback function returns the button
(GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON),
the state of the button after the event (GLUT_UP,GLUT_DOWN). And the position of
the mouse relative to top left corner of the window.

4.4 Transformation

 void glMatrixmode(Glenum mode)


Specifies which matrix will be affected by subsequent transactions. Mode can be
GL_MODEL_VIEW,GL_PROJECTION or GL_TEXTURES.
 Void glLoadIdentity()
Sets the current transformation matrix to an identity matrix.
 void glPushMatrix()
 void glPopMatrix()
Pushes to and pops from the matrix stack corresponding tothe current matrix mode.

 void glRotate[fd](TYPE x, TYPE y,TYPE z)


Alters the current matrix by a rotation of the angle degree ahou the axis(dx,dy,dz).
TYPE is either Glfloat or Gldouble.

 void glTranslate[fd](TYPE x, TYPE y,TYPE z)

DEPT OF CSE, SVCE 2022-2023 Page 12


3D AEROPLANE SIMULATION

Alters the current matrix by a displacement of(x,y,z). TYPE is of either Glfloat or


Gldouble.

 Void glScale[fd]](TYPE x, TYPE y,TYPE z)


Alters the current matrix by scaling of(sx,sy,sz). TYPE is either Glfloat or
Gldouble.

4.5 Viewing

 Void glOrtho2D(Gldoubleleft,Gldoubleright,Gldoublebottom,Gldouble top)


Defines a two dimentional viewing rectangle in the planes z=0.

 Void gluperspective(Gldoublefov, Gldouble aspect, Gldouble near, Gldouble far)


Defines a perspective viewing volume using the y direction field of view fov
measured in degrees, the aspect ratio of the front clipping plane, and the near and far
distances.

4.6 Lighting

 Void glLight[if](Glenumface,Glenumparam,TYPE value)


Sets scalar and vector parameter param for light source light.
 Void Materialfv(Glenumface,Glenumparam,TYPE *value)
Sets parameter for face (GL_FRONT,GL_BACK,GL_FRONT_AND_BACK)

DEPT OF CSE, SVCE 2022-2023 Page 13


3D AEROPLANE SIMULATION

4.7 SOURCE CODE


#include<windows.h>
#include <GL/glut.h>
#include<bits/stdc++.h>
#include <stdlib.h>
#define rad (3.1416/180)
#define EN_SIZE 20
#include "RGBpixmap.cpp"
using namespace std;
RGBpixmap pix[6];
float zoom=4;
int tola[5000][5000];
float tX=0,tY=0,tZ=-8,rX=0,rY=0,rZ=4;
float tZ1=-20,tZ2=-40,tZ3=-60,tZ4=-80,tZ5=-100,tZ6=-120;
float rotX=0,rotY=0,rotZ=0;
float cosX=0,cosY=1,cosZ=0;
float angle=0;
float xEye=0.0f,yEye=5.0f,zEye=30.0f;
float cenX=0,cenY=0,cenZ=0,roll=0;
float radius=0;
float theta=0,slope=0;
float speed = 0.3;
float angleBackFrac = 0.2;
bool saheedMinarVisible = false;
float r[] = {0.1,0.4,0.0,0.9,0.2,0.5,0.0,0.7,0.5,0.0};
float g[] = {0.2,0.0,0.4,0.5,0.2,0.0,0.3,0.9,0.0,0.2};
float b[] = {0.4,0.5,0.0,0.7,0.9,0.0,0.1,0.2,0.5,0.0};
int TIME=0;
bool START = false;
float torusPosX[7] = {1,-2,3,-4,-2,0,2};
float torusPosY[7] = {2,3,10,6,7,4,1};

DEPT OF CSE, SVCE 2022-2023 Page 14


3D AEROPLANE SIMULATION

bool rot = false;


static void resize(int width, int height)
{
const float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 1000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void drawShohidMinar(){
glColor3d(0.4,0.2,0.2);
glPushMatrix();
glTranslated(0,1.55,0);
glScaled(2,0.05,1.5);
glutSolidCube(1);
glPopMatrix();
glColor3d(0.4,0.2,0.2);
glPushMatrix();
glTranslated(0,1.6,0);
glScaled(1.9,0.05,1.4);
glutSolidCube(1);
glPopMatrix();
//glColor3d(0.4,0.2,0.2);
//glColor3d(1,0.8,0.7);
glColor3d(0.4,0.2,0.2);
glPushMatrix();
glTranslated(0,1.65,0);
glScaled(1.8,0.05,1.3);
glutSolidCube(1);
glPopMatrix();
/// pataton

DEPT OF CSE, SVCE 2022-2023 Page 15


3D AEROPLANE SIMULATION

glColor3d(1,1,1);
glPushMatrix();
glTranslated(0,1.68,-0.4);
glScaled(0.5,0.02,0.08);
glutSolidCube(1);
glPopMatrix();
/// Piller
glPushMatrix();
glTranslated(0,1.99,-0.4);
glScaled(0.06,0.7,0.04);
glutSolidCube(1);
glPopMatrix();
/// ROD
glColor3d(0,0,0);
glPushMatrix();
glTranslated(0.07,1.99,-0.4);
glScaled(0.003,0.7,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(0.11,1.99,-0.4);
glScaled(0.003,0.7,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(0.15,1.99,-0.4);
glScaled(0.003,0.7,0.003);
glutSolidCube(1);
glPopMatrix();
///
glPushMatrix();
glTranslated(-0.22,0,0);
glPushMatrix();
glTranslated(0.07,1.99,-0.4);

DEPT OF CSE, SVCE 2022-2023 Page 16


3D AEROPLANE SIMULATION

glScaled(0.003,0.7,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(0.11,1.99,-0.4);
glScaled(0.003,0.7,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(0.15,1.99,-0.4);
glScaled(0.003,0.7,0.003);
glutSolidCube(1);
glPopMatrix();
glPopMatrix();
///Horizontal rod
glPushMatrix();
glTranslated(2.2,0,-0.1);
glScaled(4.2,1,1);
glColor3d(0,0,0);
glPushMatrix();
glTranslated(-0.528,1.85,-0.3);
glScaled(0.1,0.003,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(-0.528,2.02,-0.3);
glScaled(0.1,0.003,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(-0.528,2.18,-0.3);
glScaled(0.1,0.003,0.003);
glutSolidCube(1);
glPopMatrix();

DEPT OF CSE, SVCE 2022-2023 Page 17


3D AEROPLANE SIMULATION

glColor3d(1,1,1);
glPopMatrix();
/// ROD END
glColor3d(1,1,1);
glPushMatrix();
glTranslated(-0.22,1.99,-0.4);
glScaled(0.06,0.7,0.04);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(0.22,1.99,-0.4);
glScaled(0.06,0.7,0.04);
glutSolidCube(1);
glPopMatrix();
/// Uporer piller
glPushMatrix();
glTranslated(0,0.743,-1.424);
glRotated(45,1,0,0);
//glColor3d(1,0,1);
glPushMatrix();
glTranslated(0,1.99,-0.4);
glScaled(0.06,0.3,0.04);
glutSolidCube(1);
glPopMatrix();
//glColor3d(1,1,1);
glPushMatrix();
glTranslated(-0.22,1.99,-0.4);
glScaled(0.06,0.3,0.04);
glutSolidCube(1);
glPopMatrix()
glPushMatrix();
glTranslated(0.22,1.99,-0.4);
glScaled(0.06,0.3,0.04);
glutSolidCube(1);

DEPT OF CSE, SVCE 2022-2023 Page 18


3D AEROPLANE SIMULATION

glPopMatrix();
glPushMatrix();
glTranslated(0,2.15,-0.4);
glScaled(0.5,0.04,0.04);
glutSolidCube(1);
glPopMatrix();
///ROD
glColor3d(0,0,0);
glPushMatrix();
glTranslated(-0.641,0.43,0.1);
glScaled(1,0.73,1);
glPushMatrix();
glTranslated(0.078,1.99,-0.4);
glScaled(0.003,0.56,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(0.11,1.99,-0.4);
glScaled(0.003,0.56,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(0.145,1.99,-0.4);
glScaled(0.003,0.56,0.003);
glutSolidCube(1);
glPopMatrix();
glPopMatrix();
///Horizontal rod
glColor3d(0,0,0);
glPushMatrix();
glTranslated(-0.528,1.8,-0.3);
glScaled(0.1,0.003,0.003);
glutSolidCube(1);
glPopMatrix();

DEPT OF CSE, SVCE 2022-2023 Page 19


3D AEROPLANE SIMULATION

glPushMatrix();
glTranslated(-0.528,1.96,-0.3);
glScaled(0.1,0.003,0.003);
glutSolidCube(1);
glPopMatrix();
glColor3d(1,1,1);
///ROD
glPopMatrix()
/// pasher piller left 2
glPushMatrix();
glTranslated(0.83,0,0.39);
glRotated(-45,0,1,0);
glPushMatrix();
glTranslated(-0.605,1.88,-0.3);
glScaled(0.045,0.4,0.03);
glutSolidCube(1);
glPopMatrix();

glPushMatrix();
glTranslated(-0.45,1.88,-0.3);
glScaled(0.045,0.4,0.03);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(-0.528,2.1,-0.3);
glScaled(0.199,0.04,0.03);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(-0.528,1.68,-0.3);
glScaled(0.199,0.02,0.06);
glutSolidCube(1);
glPopMatrix();
///Horizontal rod

DEPT OF CSE, SVCE 2022-2023 Page 20


3D AEROPLANE SIMULATION

glColor3d(0,0,0);
glPushMatrix();
glTranslated(-0.528,1.8,-0.3);
glScaled(0.1,0.003,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(-0.528,1.96,-0.3);
glScaled(0.1,0.003,0.003);
glutSolidCube(1);
glPopMatrix();
glColor3d(1,1,1);
///ROD
glColor3d(0,0,0);
glPushMatrix();
glTranslated(-0.641,0.43,0.1);
glScaled(1,0.73,1);
glPushMatrix();
glTranslated(0.078,1.99,-0.4);
glScaled(0.003,0.56,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(0.11,1.99,-0.4);
glScaled(0.003,0.56,0.003);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(0.145,1.99,-0.4);
glScaled(0.003,0.56,0.003);
glutSolidCube(1);
glPopMatrix();
glPopMatrix();
glColor3d(1,1,1);

DEPT OF CSE, SVCE 2022-2023 Page 21


3D AEROPLANE SIMULATION

///ROD
glPopMatrix();
glPopMatrix();
/// Circle
glColor3d(1,0,0);
glPushMatrix();
glTranslated(0,2.1,-0.44);
glScaled(0.35,0.35,0.01);
glutSolidSphere(1,50,50);
glPopMatrix();
glColor3d(0,0,0);
glPushMatrix();
glTranslated(-0.18,1.9,-0.45);
glScaled(0.01,0.5,0.01);
glutSolidCube(1);
glPopMatrix();
glColor3d(0,0,0);
glPushMatrix();
glTranslated(0.18,1.9,-0.45);
glScaled(0.01,0.5,0.01);
glutSolidCube(1);
glPopMatrix();
///left
glColor3d(0.8,1,0);
glPushMatrix();
glTranslated(0.4,0,-1.5);
glRotated(30,0,1,0);
glScaled(0.7,0.1,3);
glRotated(-10,0,1,0);
glutSolidCube(1);
glPopMatrix();
glPopMatrix();
/// Pesoner Uporer pakha
glColor3d(0.8,1,0);

DEPT OF CSE, SVCE 2022-2023 Page 22


3D AEROPLANE SIMULATION

glPushMatrix();
glTranslated(-2.7,0.5,0);
glRotated(45,0,0,1);
glScaled(0.8,2,0.1);
glRotated(-20,0,0,1);
glutSolidCube(0.5);
glPopMatrix();
// glColor3d(0.8,1,0);
// glPushMatrix();
// glTranslated(-2.95,0.85,0);
// glRotated(90,0,1,0);
// glScaled(0.05,0.05,0.6);
// glutSolidTorus(0.5,0.5,50,50);
// glPopMatrix();
void soheedMinarEnv(){
/// Ground
glColor3d(0,0.5,0.1);
glPushMatrix();
glTranslated(0,0,0);
glScaled(EN_SIZE*2,0.3,EN_SIZE*2);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslated(-8,-2.7,-5);
glRotated(65,0,1,0);
//glRotated(15,0,1,0);
glScaled(2,2,2);
drawShohidMinar();
glPopMatrix();
glPushMatrix();
glTranslated(8,-2.7,-5);
glRotated(-65,0,1,0);
//glRotated(15,0,1,0);
glScaled(2,2,2);

DEPT OF CSE, SVCE 2022-2023 Page 23


3D AEROPLANE SIMULATION

drawShohidMinar();
glPopMatrix();
}
void environment(int n){
///Plane
if(rotX>11)rotX=11;
//cout<<rotX<<" "<<rotY<<" "<<rotZ<<endl;
speed += 0.0002;
if(speed>=0.7)speed=0.7;
}
void drawBitmapText(char *str,float x,float y,float z)
{
char *c;
glRasterPos3f(x,y+8,z);
for (c=str; *c != '\0'; c++)
{
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10, *c);
}
}
void drawStrokeText(char* str,int x,int y,int z)
{
char *c;
glPushMatrix();
glTranslatef(x, y+8,z);
glScalef(0.002f,0.002f,z);
for (c=str; *c != '\0'; c++)
{
glutStrokeCharacter(GLUT_STROKE_ROMAN , *c);
}
glPopMatrix();
}
void drawStrokeText2(char* str,int x,int y,int z)
{
char *c;

DEPT OF CSE, SVCE 2022-2023 Page 24


3D AEROPLANE SIMULATION

glPushMatrix();
glTranslatef(x, y+8,z);
glScalef(0.005f,0.005f,z);
for (c=str; *c != '\0'; c++)
{
glutStrokeCharacter(GLUT_STROKE_ROMAN , *c);
}
glPopMatrix();
}
void drawStrokeChar(char c,float x,float y,float z)
{
glPushMatrix();
glTranslatef(x, y+8,z);
glScalef(0.002f,0.002f,z);
glutStrokeCharacter(GLUT_STROKE_ROMAN , c);
glPopMatrix();
}
static void display(void)
{
const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
double a = t*90.0;
double aa=a;
if(!rot){
a=0;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt( 0.0, 4.5, 10.0,
0, 4, 0,
0, 1.0f, 0.0f)
if(START){
glPushMatrix();
glTranslated(0,0,0);
glScaled(zoom,zoom,zoom);

DEPT OF CSE, SVCE 2022-2023 Page 25


3D AEROPLANE SIMULATION

glRotated(a,0,1,0);
draw();
glPopMatrix();
drawStrokeText("UP: W, DOWN: S, LEFT: A, RIGHT: D, MAIN MENU: M",-8,0.9,0);
drawStrokeText("TIME : ",3,0,0);
int mod,number=0;
while(TIME){
mod=TIME%10;
number=number*10+mod;
TIME/=10;
}
float tmp=0;
while(number){
mod=number%10;
drawStrokeChar(mod+48,4+tmp,0,0);
number/=10;
tmp+=0.2;
}
}
else{

glPushMatrix();
glTranslated(0,3,0);
glRotated(aa,0,1,0);
glScaled(1.5,1.5,1.5);
plane();
glPopMatrix();
drawStrokeText("Press G to Start",-1,-1,0);
drawStrokeText2("Plane Game",-2,0,0);
}
//glColor3d(1,1,0);
//drawStrokeText("Osama Hosam's OpenGL Tutorials",200,200,0);
// glRasterPos2i(100, 120);
// glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

DEPT OF CSE, SVCE 2022-2023 Page 26


3D AEROPLANE SIMULATION

// glutBitmapString(GLUT_BITMAP_HELVETICA_18, "text to render");


//drawBitmapText("Osama Hosam's OpenGL Tutorials",0,0,0);
//drawStrokeChar(49,2,0,0);
glutSwapBuffers();
}
static void key(unsigned char key, int x, int y)
{
float frac = 0.3;
float rotFrac = 1;
switch (key)
{
case 27 :
case 'q': exit(0); break;
case 'r': rot=true; break;
case 't': rot=false; break;
case 'z': zoom+=0.05; break;
case 'Z': zoom-=0.05;
case 'w': tY-=frac;
rotZ+=rotFrac; break;
case 's': tY+=frac;
rotZ-=rotFrac; break;
case 'a':
tX+=frac;
rotX-=rotFrac*3;
rotY+=rotFrac/2;
break;
case 'd':
tX-=frac;
rotX+=rotFrac*3;
rotY-=rotFrac/2; break;
// case 'y': rotX-=rotFrac; break;
// case 'h': rotX+=rotFrac; break;
// case 'g': rotY+=rotFrac; break;
// case 'j': rotY-=rotFrac; break;

DEPT OF CSE, SVCE 2022-2023 Page 27


3D AEROPLANE SIMULATION

case 'g': START=true; break;


case 'm': START=false; break;
// case 'o':
// cosX-=frac*cos(rotX*rad);
// cosY+=frac*cos(rotY*rad);
// cosZ-=frac*cos(rotZ*rad);
// //cout<<"Front : "<<cosX<<" "<<cosY<<" "<<cosZ<<endl;
// break;
// case 'l':
// cosX+=frac*cos(rotX*rad);
// cosY-=frac*cos(rotY*rad);
// cosZ+=frac*cos(rotZ*rad);
// //cout<<"Back : "<<cosX<<" "<<cosY<<" "<<cosZ<<endl;
// break;
}
glutPostRedisplay();
}
static void idle(void)
{
glutPostRedisplay();
}
const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };
const GLfloat mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat high_shininess[] = { 100.0f };
/* Program entry point */
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition(0,0);

DEPT OF CSE, SVCE 2022-2023 Page 28


3D AEROPLANE SIMULATION

glutInitWindowSize(1366,720);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA);
glutCreateWindow("GLUT Shapes");
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutIdleFunc(idle);
//PlaySound("starwars.wav", NULL, SND_ASYNC|SND_FILENAME|SND_LOOP);
glClearColor(1,1,1,1);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);

glLightfv(GL_LIGHT0, GL_POSITION, light_position);


glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
glutMainLoop();
return EXIT_SUCCESS;
}

DEPT OF CSE, SVCE 2022-2023 Page 29


3D AEROPLANE SIMULATION

Chapter 5
SNAPSHOTS

Fig 5.1 : Start page

Fig 5.2 : Aeroplane Simulation

DEPT OF CSE, SVCE 2022-2023 Page 30


3D AEROPLANE SIMULATION

Fig 5.3: Aeroplane moving straight

Fig 5.4: Aeroplane going downwards

DEPT OF CSE, SVCE 2022-2023 Page 31


3D AEROPLANE SIMULATION

Fig 5.5: Aeroplane going towards right

Fig 5.6: Aeroplane going towards left

DEPT OF CSE, SVCE 2022-2023 Page 32


3D AEROPLANE SIMULATION

Chapter 6
TESTING
6.1 TESTING
Software testing is a critical element of the ultimate review of specification design
and coding. Testing of software leads to the uncovering of errors in the software functional
and performance requirements are met. Testing also provides a good indication of software
reliability and software quality as a whole. The result of different phases of testing are
evaluated and then compared with the expected results. If the errors are uncovered they are
debugged and corrected. A strategy approach to software testing has the generic
characteristics:

 Different testing techniques are appropriate at different points of time.


 Testing and debugging are different activities, but debugging must be accommodated
in the testing strategy.

Following three approaches of debugging were used:

o Debugging by Induction
o Debugging by Deduction
o Backtracking

6.2 TEST PLANS

In this test plan all major activities are described below:


 Unit testing.
 Integration testing.
 Validation testing.
 System testing.

DEPT OF CSE, SVCE 2022-2023 Page 33


3D AEROPLANE SIMULATION

Table 6.1: Test case for keyboard

SL.no Test case Expected Actual Remarks


descrition result result

1. Press ‘G’ Open the Aeroplane PASS


to start the aeroplane Simula-
simulation simula- tion opens
tion

2. Press ‘W’ Aero- Aeroplane PASS


for moving plane to moved
up move upwards
upwards

3. Press ‘S’ Aero- Aeroplane PASS


for moving plane to moved
down move down-
down- wards
wards

4. Press ‘D’ Aero- Aeroplane PASS


for moving plane to moved
right side move towards
towards right
right

5. Press ‘A’ Aero- Aeroplane PASS


for moving plane to moved
left side move towards
towards left
left

6. Press ‘M’ Exit Simula- PASS


for main from the tion exits
menu simula-
tion

DEPT OF CSE, SVCE 2022-2023 Page 34


3D AEROPLANE SIMULATION

CONCLUSIONS

An attempt has been made to develop , design and implement a ‘3DAeroplane Simulation’.
OpenGI supports enormous flexibility in the design and the use of OpenGl graphics
programs. 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.

The project was started with the designing phase in which we figured the requirements
needed, the layout design, then comes the detail designing of each function after which, was
the testing and debugging stage. We have tried to implement the project making it as user-
friendly and error free as possible. We regret any errors that may have inadvertently crept in.
The development of mini project has given us a good exposure to OpenGL by which we have
learnt some of the techniques which helps in the development of animation and gaming.

Hence it is helpful for us to even take this field as our career too and develop some other
features in openGL and provide as token of contribution to the graphics world.

DEPT OF CSE, SVCE 2022-2023 Page 35


3D AEROPLANE SIMULATION

FUTURE ENHANCEMENT

This project has been designed using C++, which works on the windows platform. The
project can be designed using other languages and better graphical interfaces. The following
features could have been incorporated.

 Virtual Reality (VR) Support: Add support for virtual reality headsets, allowing users
to experience the simulation in an immersive and 3D environment. VR technology
can greatly enhance the sense of presence and realism.

 Flight Planning and Navigation: Develop a comprehensive flight planning and


navigation system, including route planning, waypoint management, and instrument
approach procedures. Users can simulate realistic flights with accurate navigation aids
and flight plans.

 Realistic Physics Simulation: Enhance the physics simulation to accurately model the
behavior of the airplane in different flight conditions, including aerodynamics, lift,
drag, and turbulence. This will provide a more realistic flying experience for the
users.

 Real-world Scenery: Integrate satellite imagery and terrain data to create realistic
scenery, including airports, cities, and landmarks. This will enhance the visual
experience and make the simulation feel more authentic.

 Aircraft Customization: Allow users to customize the appearance of their aircraft with
different liveries, paint schemes, and decals. This feature gives users a sense of
ownership and allows them to personalize their flying experience.

DEPT OF CSE, SVCE 2022-2023 Page 36


3D AEROPLANE SIMULATION

REFERENCES
BIBLIOGRAPHY

[1] Edward Angel’s Interactive Computer Graphics Pearson Education 5 th Edition


[2] Interactive computer Graphics - A top down approach using open GL by Edward Angel
[3] Jackie L.Neider,Mark Warhol, Tom R.Davis,"OpenGL Red Book", Second Revised
Edition,2005.
[4] Donald D Hearn and M.PaulineBaker,"Computer Graphics with OpenGL",3rd
Edition.

WEBSITES

[5] www.OpenGLRedbook.com
[6] www.OpenGLsimpleexamples.com
[7] freeglut.sourceforge.net/
[ 8] Opengl.org/documentation/
[9] Opengl.org/discussion_boards/

DEPT OF CSE, SVCE 2022-2023 Page 37

You might also like