Airshow Project Report
Airshow Project Report
CHAPTER 1
INTRODUCTION
Computer graphics is a dynamic field within computer science that focuses on the
creation, manipulation, and representation of visual content on computers. It encompasses
both 2D and 3D graphics, allowing for the rendering of flat images and the creation and
manipulation of three-dimensional objects and scenes. Key processes in computer graphics
include rendering, which generates images from models using techniques like ray tracing and
shading; modeling, which involves creating mathematical representations of 3D objects; and
animation. Computer graphics finds applications in a wide range of fields, from entertainment
industries like movies and video games to design, education, training, and scientific
visualization. The continuous advancements in technology drive the evolution of computer
graphics, leading to increasingly realistic and complex visualizations and interactive
experiences.
Computer Graphics is concerned with all aspect of producing pictures or image using
computer. The field began humble almost 50 years ago, with the display of few lines on the
cathode-ray tube(CRT); now, we can create image using computer that are indistinguishable
from photographs from the real objects.
Graphics is created using computers and, more generally, the representation and
manipulation of pictorial data by a computer. The development of computer graphics has
made computers easier to interact with and better for understanding and interpreting many
types of data. Developments in computer graphics have had a profound impact on many types
of media and have revolutionized the animation and video game industry. The phrase
“Computer Graphics” was coined in 1960 by William Fetter, a graphic designer for Boeing.
In today‟s world advanced technology, interactive computer graphics has become a powerful
tool for the production of realistic features. Today‟s we find computer graphics used in
various areas that include science, engineering, medicine, business, industry, art,
entertainment etc. The main reason for effectiveness of the interactive computer graphics is
the speed with which the user can understand the displayed information.
The graphics in OpenGL provides a wide variety of built-in function. The computer
graphics remains one of the most exciting and rapidly growing computer fields. It has
become a common element in user interface, data visualization, TV commercials, motion
picture and many other applications. The current trend of computer graphics is to incorporate
more physics principles into 3D graphics algorithm to better simulate the complex
interactions between objects and lighting environment.
OpenGL is a standard specification that defines an API that is multi-language and multi-
platform and that enables the codification of applications that output computerized graphics
in 2D and 3D. The interface consists in more than 250 different functions, which can be used
to draw complex tridimensional scenes with simple primitives. It consists of many functions
that help to create a real world object and an particular existence for an object can be given.
CHAPTER 2
SYESTEM REQUIREMENTS AND SPECIFICATION
The functional requirements specify the library functions utilized in the system,
including standard and user-defined functions. This chapter outlines the essential system
requirements and specifications for the development and deployment of the software project.
It is crucial to establish a clear understanding of both the functional and non-functional
requirements to ensure that the system operates as intended and meets user expectations. The
interactions between the system and its users, including the inputs, outputs, and behaviors of
the system. In this project, the non-functional requirements include the custom functions
developed to enhance the system's visual and interactive capabilities. To successfully run the
developed application, certain hardware and software prerequisites must be met. The
hardware requirements include specifications for the processor, RAM, hard disk, graphics
memory, and peripheral devices.
glutInitDisplayMode(…);
Here we specify RGB color system and also double buffering.
Declaration:
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(…);
This function specifies a window in the top left corner of the display.
Declaration: glutInitWindowSize(600,600);
glutCreateWindow(“…”);
This creates an OpenGL window using the glut function where the title at the
top of the window is given by the string inside the parameter of the above
function.
Declaration: glutCreateWindow(“AIRSHOW”);
glutReshapeFunc(…);
The reshape event is generated whenever the window is resized, such as user
interaction.
Declaration: glutReshapeFunc(reshape);
glutDisplayFunc(…);
Graphics are sent to the screen through a function called the display call back,
here the function named „func‟ will be called whenever the windowing system
determines that OpenGL window needs to be redisplayed.
Declaration: glutDisplayFunc(display);
glutIdleFunc(…);
glutIdle function checks idle call back i.e it can perform a background
processing task or continuous animation when windows system events are not
being received.
Declaration: glutIdleFunc(straight);
glutMouseFunc(…);
This function handles mouse click events.
Declaration: glutMouseFunc(mouse);
glutKeyboardFunc(…);
This function handles keyboard events.
Declaration: glutKeyboardFunc(keyboard);
glViewport(…);
Specifies within to height viewport in pixels whose lower left corner is (x,y)
measured from origin of the window.
Declaration: glViewport (0,0,width,height);
glMatrixMode(…);
This function specifies which matrix will be affected by subsequent
transformation in GL_MODELVIEW and GL_PROJECTION.
Declaration: glMatrixMode (…);
glLoadIdentity (…);
This function sets the current transformation matrix to an identity matrix.
Declaration: glLoadIdentity( );
glColor3f(…);
In RGB color we have three attributes to set. The first is the clear color, which
is set to black and we can select the rendering color for points
Declaration: glClearColor(0.0,0.0,0.0,0.0); glColor3f(0.0,0.0,0.0);
The smoke() function is used to show the color and transparency of smoke that
is liberated out of the planes.
The wings() function is used to render the front, back, top, bottom portions of
the wings and providing colors to them.
The plane() function is used to form the body of the plane by calling different
functions like wing(), fin().
The display() function consists of gluLookAt() which calculates the position
of eye and rotation of current smoke particles.
The cloud() function uses functions like PushMatrix() ,Scalef() ,Translatef() ,
sphere() to render the clouds.
CHAPTER 3
SYSTEM DESIGN
The System Design chapter serves as a blueprint for the architecture and structure of
the software project, detailing how components interact, how data flows through the system,
and how modules are integrated to achieve the desired functionality. This comprehensive
design framework ensures a methodical, scalable, and maintainable development process.
The primary objectives of system design include modularity, scalability, maintainability,
performance, and usability. Modularity breaks the system into manageable parts, scalability
allows the system to handle increased loads, maintainability ensures ease of updates,
performance optimizes resource utilization, and usability focuses on creating intuitive user
interfaces.
System design for the project "Airshow" involves creating the user interface and the
various features necessary for the OpenGL-based application to function effectively. . By
leveraging various OpenGL functions and user-defined functions, the system handles user
interactions through mouse and keyboard events, simulates realistic plane movements, and
renders environmental elements and smoke effects. This design ensures that the application is
responsive, visually engaging, and easy to interact with, providing users with a dynamic
airshow experience.
The user interface (UI) design specifies how users will interact with the system. In the
context of the OpenGL application..
START
Main() Init()
Display() Keyboard() Mouse()
Bridge(), Plane(),
Ground(),
Cloud(), glutIdleFunc(straight)
DrawSmoke(),
translate(),
popMatrix()
pushMatrix(),
translate(), popMatrix()
The features of the system focus on the core functionalities required to simulate the
airshow, including plane movements, smoke effects, and environmental elements. These
features are implemented through a series of functions that handle different aspects of the
simulation.
Plane Movement:
forward(): Calculates the direction of the plane by checking its Z-coordinate
and Y-coordinate. This function updates the plane's position based on user
inputs.
up(): Moves the plane up by adjusting its Y-coordinate.
down(): Moves the plane down by adjusting its Y-coordinate.
Smoke Effects
smoke(): Shows the color and transparency of smoke emitted from the planes.
It uses parameters to set the size and alpha value (transparency) of the smoke
particles.
drawSmoke(): Draws the smoke particles by calculating their positions, sizes,
and transparency levels over time. It uses multiple smoke particles to create a
realistic effect.
Environmental Elements:
ground(): Renders the ground surface where the airshow takes place, including
grass and other textures.
cloud(): Uses various functions like PushMatrix(), Scalef(), Translatef(), and
Plane Components
wing(): Renders the wings of the plane, including front, back, top, and bottom
portions, and applies colors to them.
fin(): Renders the fin of the plane, including front, back, and sides.
plane(): Forms the body of the plane by calling different functions like wing()
and fin(), and applies the appropriate colors based on user inputs.
The model design for the Airshow project involves the detailed structure and
organization of the software components required to simulate an airshow using OpenGL. It
includes the data structures, modules, and their interactions to achieve the desired
functionality. This design ensures that the software is maintainable, extendable, and efficient
in simulating an airshow using OpenGL. By separating concerns into different modules, each
handling specific tasks such as input processing, plane movement, smoke effects, and
rendering, the system can provide a seamless and interactive experience for users.
3.2.1 Structures
Plane Structure
Attributes:
position: A structure containing x, y, and z coordinates representing the plane's
current position.
direction: A structure containing dx, dy, and dz representing the plane's
current direction.
speed: A float representing the plane's current speed.
color: A structure containing r, g, b values representing the plane's color.
Environment Structure
Attributes:
ground_texture: A reference to the ground texture used in the simulation.
cloud_positions: A list of structures containing x, y, and z coordinates
representing the positions of clouds in the sky.
Initialization Module
Functions:
initialize(): Sets up the OpenGL context, loads textures, and initializes the
planes and environment.
Initialization:
initialize() sets up the OpenGL context, registers callback functions for mouse
and keyboard events, loads textures, and initializes the plane and environment
structures.
Input Handling:
Plane Movement:
movePlane() updates the plane's position based on its current speed and
direction.
changeDirection() and accelerate() adjust the plane's direction and speed based
on user inputs.
CHAPTER 4
IMPLEMENTATION
The Implementation chapter marks the transition from planning and design to the
actual construction of the software project. This phase is where theoretical designs and
specifications are transformed into working code and functional systems Key activities
during the implementation phase include writing the source code, developing user interfaces,
integrating various system components, and conducting unit and integration testing. Source
code development follows the specifications detailed in the design documents, employing
best practices in coding standards, documentation, and version control. Integration involves
combining individual modules and components into a cohesive system, ensuring that they
work together as intended. This step often reveals issues related to component interaction,
which are addressed through debugging and refinement. Testing is an integral part of
implementation, aimed at identifying and resolving defects early. Unit testing verifies the
functionality of individual components, while integration testing ensures that combined
components operate correctly.
GL/glut.h header file includes necessary definitions and functions for using the
OpenGL Utility Toolkit (GLUT) library.
stdlib.h in C/C++ provides functions for memory allocation (malloc, free), string
conversion (atoi, atof), random number generation (rand, srand), and system
interactions (system, exit).
math.h in C/C++ provides mathematical functions such as trigonometric (sin, cos),
logarithmic (log, log10) and exponential (exp, pow),
string.h in C/C++ provides functions for manipulating arrays of characters, including
operations like copying (strcpy, strncpy), concatenating (strcat, strncat), comparing
(strcmp, strncmp), and searching (strchr, strstr).
#include<stdlib.h>
#include <GL/glut.h>
#include <math.h>
#include<string.h>
4.2. Global variable declaration : The program uses several global variables to manage
the state of the simulation
4.3. Camera position: These variables represent the camera's position in the 3D space.
4.4 Rotation: These variables control the rotation of objects in the scene.
4.5 Object Position: These variables represent the position of objects in the scene.
4.6 Smoke particle rotation: These arrays store the rotation angles and positions of
smoke particles.
static int spinxs[150];
static int spinys[150];
static int spinzs[150];
float sx[150];
float sy[150];
float sz[150];
float sa[150];
float ss[150];
4.7 Counters: This function is designed to render text onto the screen in an OpenGL
environment. It allows developers to specify the position (x, y coordinates), the actual
text (string), and the font style (font) to be used for rendering.
int i = 0,f=0;
void output(int x, int y, char *string,void *font)
{
int len, i;
glRasterPos2f(x, y);
len = (int) strlen(string);
for (i = 0; i < len; i++) {
glutBitmapCharacter(font, string[i]);
}
}
4.9 Smoke : This function draws a smoke particle, typically used for visual effects in
simulations or animations.
void smoke(float size, float alpha, float R, float G, float B)
{
glPushMatrix();
//Colour and transparency of Smoke
glColor4f(R,G,B,alpha);
glTranslatef(0,0,-15);
glutSolidSphere((1 + size),16,16);
glPopMatrix();
}
4.10 Draw Smoke: Draws a trail of smoke particles, typically simulating the path left by
an object (like a plane) moving through the air.
void drawSmoke(float R, float G, float B, float x, float y, int reflect)
{
// Calculate each position, size and transparency of smoke
4.11 Slab and Bridge: Functions used to draw slabs and a bridge. Constructs a bridge
using multiple slabs
void slab(float r, float g, float b)
{
glColor3f(r,g,b);
glutSolidCube(1);
}
void bridge()
{
glPushMatrix();
glScalef(20,1,10);
slab(0.5,0.5,0.5);
glPopMatrix();
glPushMatrix();
glScalef(20,2,1);
glTranslatef(0,0.75,4.5);
slab(0.3,0.3,0.3);
glPopMatrix();
glPushMatrix();
glScalef(20,2,1);
glTranslatef(0,0.75,-4.5);
slab(0.3,0.3,0.3);
glPopMatrix();
glPushMatrix();
glScalef(1,4,1);
glTranslatef(0,-0.65,4.5);
slab(0.3,0.3,0.3);
glPopMatrix();
glPushMatrix();
glScalef(1,4,1);
glTranslatef(0,-0.65,-4.5);
slab(0.3,0.3,0.3);
glPopMatrix();
}
4.12: Ground: Draws the ground . In OpenGL, drawing the ground could involve using
polygons or other primitives to create a flat surface upon which other objects are
placed.
void ground()
{
glBegin(GL_POLYGON);
glColor3f(0.0,0.128,0.0);
glVertex3f(-100,0,100);
glVertex3f(0,0,100);
glVertex3f(-30,0,50);
glVertex3f(0,0,0);
glVertex3f(-50,0,-100);
glVertex3f(-100,0,-100);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0,0.128,0.0);
glVertex3f(10,0,0);
glVertex3f(-20,0,50);
glVertex3f(10,0,100);
glVertex3f(100,0,100);
glVertex3f(100,0,-100);
glVertex3f(-40,0,-100);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0,0.128,0.0);
glVertex3f(0,-10,100);
glVertex3f(-30,-10,50);
glVertex3f(-30,0,50);
glVertex3f(0,0,100);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0,0.128,0.0);
glVertex3f(-30,-10,50);
glVertex3f(0,-10,0);
glVertex3f(0,0,0);
glVertex3f(-30,0,50);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.4,0.2,0.16);
glVertex3f(0,-10,0);
glVertex3f(-50,-10,-100);
glVertex3f(-50,0,-100);
glVertex3f(0,0,0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.4,0.25,0.16);
glVertex3f(-40,-10,-100);
glVertex3f(10,-10,0);
glVertex3f(10,0,0);
glVertex3f(-40,0,-100);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.4,0.25,0.16);
glVertex3f(10,-10,0);
glVertex3f(-20,-10,50);
glVertex3f(-20,0,50);
glVertex3f(10,0,0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.4,0.25,0.16);
glVertex3f(-20,-10,50);
glVertex3f(10,-10,100);
glVertex3f(10,0,100);
glVertex3f(-20,0,50);
glEnd();
glBegin(GL_POLYGON);
glColor4f(0,0.6,0.6,0.0);
glVertex3f(-100,-2,100);
glVertex3f(100,-2,100);
glVertex3f(100,-2,-100);
glVertex3f(-100,-2,-100);
glEnd();
}
4.13: wings and fin: These functions are intended to draw specific parts of a plane, such
as wings and fins (tail). The specific drawing code for these functions was not provided,
but they would typically involve OpenGL commands to create geometric shapes (like
polygons or triangles) that represent these airplane components.
void wing(int Colour)
{
float rs=0; //Side red
float re=0; //Edge red
float bs=0; //Side blue
float be=0; //Edge blue
float gs=0; //Side green
float ge=0; //Edge green
if (Colour == 1){
rs = 0.75;
re = 0.5;
} else if (Colour == 2){
bs = 0.75;
be = 0.5;
} else if (Colour == 3){
bs = 0.75;
be = 0.5;
}
//Front
glBegin(GL_POLYGON);
glColor3f(re,ge,be);
glVertex3f(1.5,-1,10);
glVertex3f(25,-0.25,0);
glVertex3f(25,0.25,0);
glVertex3f(1.5,1,10);
glEnd();
//Back
glBegin(GL_POLYGON);
glColor3f(re,ge,be);
glVertex3f(1.5,1,-1);
glVertex3f(25,0.25,-7);
glVertex3f(25,-0.25,-7);
glVertex3f(1.5,-1,-1);
glEnd();
//Top
glBegin(GL_POLYGON);
glColor3f(rs,gs,bs);
glVertex3f(1.5,1,10);
glVertex3f(25,0.25,0);
glVertex3f(25,0.25,-7);
glVertex3f(1.5,1,-1);
glEnd();
//Bottom
glBegin(GL_POLYGON);
glColor3f(rs,gs,bs);
glVertex3f(1.5,-1,-1);
glVertex3f(25,-0.25,-7);
glVertex3f(25,-0.25,0);
glVertex3f(1.5,-1,10);
glEnd();
//End
glBegin(GL_POLYGON);
glColor3f(re,ge,be);
glVertex3f(25,-0.25,0);
glVertex3f(25,-0.25,-7);
glVertex3f(25,0.25,-7);
glVertex3f(25,0.25,0);
glEnd();
}
//Fin
void fin(int Colour)
{
float rs=0;
float re=0;
float bs=0;
float be=0;
float gs=0;
float ge=0;
if (Colour == 1){
rs = 0.75;
re = 0.5;
} else if (Colour == 2){
bs = 0.75;
be = 0.5;
} else if (Colour == 3){
bs = 0.75;
be = 0.5;
}
//Front
glBegin(GL_POLYGON);
glColor3f(re,ge,be);
glVertex3f(-0.5,2,-7);
glVertex3f(0.5,2,-7);
glVertex3f(0,9.5,-10);
glEnd();
//Back
glBegin(GL_POLYGON);
glColor3f(re,ge,be);
glVertex3f(0,9.5,-12);
glVertex3f(0.5,2,-11);
glVertex3f(-0.5,2,-11);
glEnd();
//Side A
glBegin(GL_POLYGON);
glColor3f(rs,gs,bs);
glVertex3f(0.5,2,-7);
glVertex3f(0.5,2,-11);
glVertex3f(0,9.5,-12);
glVertex3f(0,9.5,-10);
glEnd();
//Side B
glBegin(GL_POLYGON);
glColor3f(rs,gs,bs);
glVertex3f(0,9.5,-10);
glVertex3f(0,9.5,-12);
glVertex3f(-0.5,2,-11);
glVertex3f(-0.5,2,-7);
glEnd();
}
4.14 plane: Constructs a plane using functions like sphere, wing, and fin (specific code
not provided). This function would integrate the drawing of various components
(sphere for body, wings, fins) to render a complete airplane model.
void plane(int Colour)
{
float rb=0;
float gb=0;
float bb=0;
if (Colour == 1){
rb = 0.65;
} else if (Colour == 2){
gb = 1.0,rb=1.0,bb=1.0;
} else if (Colour == 3){
bb = 0.65;
}
//Body
glPushMatrix();
glTranslatef(0,0,4);
glScaled(1,0.8,5);
sphere(rb,gb,bb,1);
glPopMatrix();
//Windscreen
glPushMatrix();
glTranslatef(0,2,16);
glScaled(0.5,0.4,0.75);
sphere(0,0,0,0.75);
glPopMatrix();
//Left Wing
wing(Colour);
//Right Wing
glPushMatrix();
glScalef(-1,-1,1);
wing(Colour);
glPopMatrix();
glPushMatrix();
glScalef(0.4,0.4,0.4);
glTranslatef(0,3,-25);
wing(Colour);
glPopMatrix();
glPushMatrix();
glScalef(-0.4,-0.4,0.4);
glTranslatef(0,-3,-25);
wing(Colour);
glPopMatrix();
//Fin
fin(Colour);
}
4.15 Cloud: Draws a cloud (specific implementation details were not provided). Clouds
in OpenGL graphics are often rendered using a combination of primitive shapes (like
spheres or ellipsoids) and techniques such as particle systems or procedural generation
to achieve a cloud-like appearance.
void cloud()
{
glPushMatrix();
glScalef(1.5,1,1.25);
glTranslatef(0,12,0);
sphere(1,1,1,0.9);
glPopMatrix();
glPushMatrix();
glScalef(1.5,1,1.25);
glTranslatef(0,5,3);
sphere(1,1,1,0.9);
glPopMatrix();
glPushMatrix();
glScalef(1.5,1,1.25);
glTranslatef(4,7,0);
sphere(1,1,1,0.9);
glPopMatrix();
glPushMatrix();
glScalef(1.5,1,1.25);
glTranslatef(-4,7,0);
sphere(1,1,1,0.9);
glPopMatrix();
glPushMatrix();
glScalef(2,1.5,2);
glTranslatef(0,5,0);
sphere(1,1,1,0.5);
glPopMatrix();
}
4.16 Reshape function is called when the window size changes, allowing the application
to adjust its rendering settings accordingly.
4.17 Display callback function display routine this where the drawing takes place
void display1(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* clear
window */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(cx, cy, cz, x/2, y/2, z/2, 0.0, 1.0, 0.0); //position of the eye
//Calculate position and rotation of current smoke particle
sx[i] = x;
sy[i] = y;
sz[i] = z;
spinxs[i] = spinx;
spinys[i] = spiny;
spinzs[i] = spinz;
sa[i] = 1;
ss[i] = 0;
//Bridge
for (int b = 0; b < 600; b=b+20)
{
glPushMatrix();
glTranslatef(-300+b,-47,0);
bridge();
glPopMatrix();
}
//Bridge Reflection
glPushMatrix();
glScalef(-1,-1,1);
glTranslatef(0,56,0);
bridge();
glPopMatrix();
glPushMatrix();
glScalef(-1,-1,1);
glTranslatef(-20,56,0);
bridge();
glPopMatrix();
//Ground
glPushMatrix();
glScalef(3,1,3);
glTranslatef(0,-50,0);
ground();
glPopMatrix();
glPushMatrix();
glScalef(0.5,0.5,0.5);
glTranslatef(x-120,y,z);
glRotatef(spinx,1,0,0);
glRotatef(spiny,0,1,0);
glRotatef(spinz,0,0,1);
plane(1);
glPopMatrix();
glPushMatrix();
glScalef(0.5,0.5,0.5);
glTranslatef(x+120,y,z);
glRotatef(spinx,1,0,0);
glRotatef(spiny,0,1,0);
glRotatef(spinz,0,0,1);
plane(1);
glPopMatrix();
glPushMatrix();
glScalef(0.5,0.5,0.5);
glTranslatef(x-60,y,z);
glRotatef(spinx,1,0,0);
glRotatef(spiny,0,1,0);
glRotatef(spinz,0,0,1);
plane(1);
glPopMatrix()
;
glPushMatrix();
glScalef(0.5,0.5,0.5);
glTranslatef(x,y,z);
glRotatef(spinx,1,0,0);
glRotatef(spiny,0,1,0);
glRotatef(spinz,0,0,1);
plane(1);
glPopMatrix();
glPushMatrix();
glScalef(0.5,0.5,0.5);
glTranslatef(x+60,y,z);
glRotatef(spinx,1,0,0);
glRotatef(spiny,0,1,0);
glRotatef(spinz,0,0,1);
plane(1);
glPopMatrix();
drawSmoke(1,0.5,0.2,120,0,1);
drawSmoke(1,0.5,0.2,60,0,1);
drawSmoke(1,1,1,0,0,1);
drawSmoke(0,0.64,0,-60,0,1);
drawSmoke(0,0.64,0,-120,0,1);
//Increase count
i++;
//Reset count
if (i > 149) i = 0;
//Clouds
glPushMatrix();
glTranslatef(-40,10,0);
glScalef(2,1.5,2);
cloud();
glPopMatrix();
glPushMatrix();
glTranslatef(40,10,0);
glScalef(1.5,1,1.5);
cloud();
glPopMatrix();
glPushMatrix();
glTranslatef(0,20,-70);
glRotatef(45,0,1,0);
glScalef(1,1,1);
cloud();
glPopMatrix();
glPushMatrix();
glTranslatef(30,20,70);
glRotatef(45,1,0,0);
glScalef(0.5,0.5,0.5);
cloud();
glPopMatrix();
glPushMatrix();
glTranslatef(-70,20,70);
glRotatef(35,0,1,0);
glScalef(2,1,2);
cloud();
glPopMatrix();
glutSwapBuffers();
glFlush();
}
void init(void)
{
glClearColor(0.45,0.8,0.88,0); /* window will be cleared to sky blue
*/
glEnable(GL_DEPTH_TEST);
//Enable Alpha channel
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER, 0./255.);
glEnable(GL_CULL_FACE); // Enable back culling
glCullFace(GL_BACK); // Cull back faces
}
if(id==1)
spinz = (spinz + 10) % 360;
if(s==1)
forward(4);
glutPostRedisplay();
}
void up()
{
if (spinx >= 360)
{
spinx = 0;
}
spinx = (spinx -1) % 360;
forward(4);
glutPostRedisplay();
}
void down()
{
if (spinx >= 360) {
spinx = 0;
}
spinx = (spinx +1) % 360;
forward(4);
glutPostRedisplay();
}
case GLUT_RIGHT_BUTTON:
if (state == GLUT_DOWN)
{ id=0;
glutIdleFunc(straight);
break;
}
}
}
void *fonts[]=
{
GLUT_BITMAP_9_BY_15,
GLUT_BITMAP_TIMES_ROMAN_10,
GLUT_BITMAP_TIMES_ROMAN_24,
GLUT_BITMAP_HELVETICA_18,
GLUT_BITMAP_HELVETICA_12
};
4.21 Front page and menu functions to display the front page, menu and help screen
void front()
{
glColor3f(0.5,0.2,0.6);
output(365,130," GOVERNMENT ENGINEERING COLLEGE",fonts[3]);
glColor3f(0.3,0.5,0.8);
output(375,100,"DEPT. OF COMPUTER SCIENCE & ENGG.",fonts[0]);
glColor3f(0.8,0.1,0.2);
output(300,600,"GRAPHICAL IMPLEMENTATION OF
AIRSHOW",fonts[2]);
glColor3f(1.0,0.0,1.0);
output(450,500,"SUBMITTED BY :",fonts[0]);
glColor3f(0.3,0.5,0.8);
output(225,450,"ANUSHA M",fonts[3]);
output(180,300,"",fonts[3]);
output(220,400,"(4GK21CS003)",fonts[0]);
// glColor3f(0.6,0.25,0.0);
output(380,200,"[ PRESS ANY KEY TO CONTINUE ]",fonts[3]);
}
void menu()
{
glColor3f(0.8,0.1,0.2);
output(170,480,"GRAPHICAL IMPLEMENTATION OF
AIRSHOW",fonts[2]);
glColor3f(0.0,0.6,0.3);
output(300,400,"SELECT AN OPTION",fonts[2]);
output(300,380,"-----------------",fonts[2]);
glColor3f(0.3,0.5,0.8);
output(300,340,"[1] PROCEED",fonts[3]);
output(300,300,"[2] HELP",fonts[3]);
output(300,260,"[3] INTRODUCTION",fonts[3]);
output(300,220,"[b] BACK",fonts[3]);
output(300,180,"[q] QUIT",fonts[3]);
glColor3f(0.5,0.2,0.6);
}
void help()
{
glColor3f(0.8,0.1,0.2);
output(170,600,"GRAPHICAL IMPLEMENTATION OF
AIRSHOW",fonts[2]);
glColor3f(0.0,0.6,0.3);
output(180,560,"=> RIGHT CLICK MOUSE TO STOP THE ROTATIONAL
TRANSLATION <=",fonts[3]);
output(180,520,"=> LEFT CLICK MOUSE FOR ROTATION
TRANSLATION <=",fonts[3]);
output(180,480,"=> [U] FOR MOVEUP <=",fonts[3]);
output(180,440,"=> [D] FOR MOVEDOWN <=",fonts[3]);
output(180,400,"=> [P] FOR PAUSE <=",fonts[3]);
output(180,360,"=> [S] FOR START <=",fonts[3]);
output(180,320,"=> [R] FOR RESET <=",fonts[3]);
glColor3f(0.3,0.5,0.8);
output(400,280,"SELECT AN OPTION",fonts[2]);
output(400,265,"-----------------",fonts[2]);
output(400,230,"[h] HOME",fonts[3]);
output(400,190,"[b] BACK",fonts[3]);
output(400,150,"[q] QUIT",fonts[3]);
glColor3f(0.5,0.2,0.6);
output(600,60,"[ Dept. of CS&E, GIT ]",fonts[0]);
}
void intro()
{
glColor3f(0.8,0.1,0.2);
output(170,480,"GRAPHICAL IMPLEMENTATION OF
AIRSHOW",fonts[2]);
glColor3f(0.0,0.6,0.3);
output(160,430,"IN THIS AIRSHOW A GROUP OF AIRPLANE EMITS
COLORFUL SMOKE",fonts[0]);
glColor3f(0.5,0.2,0.6);
output(600,60,"[ Dept. of CS&E, GIT ]",fonts[0]);
}
void menuset()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1000, 0.0, 750,-2000,1500);
glMatrixMode(GL_MODELVIEW);
glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
}
void display()
{
if(f==0)
{
menuset();
front();
glutSwapBuffers();
}
else if(f==1)
{
menuset();
menu();
glutSwapBuffers();
}
else if(f==3)
{
menuset();
help();
glutSwapBuffers();
}
else if(f==4)
{
menuset();
intro();
glutSwapBuffers();
}
else
{
glClearColor(0.45,0.8,0.88,0.0);
display1();
}
}
case 'q':
case 'Q':exit(0);
}
}
else if(f==2)
{
switch(key)
{
case 'q':
case 'Q':exit(0);break;
case 'b':
case 'B':f=1;break;
case 'h':
case 'H':f=0;break;
case 'r':
case 'R':
spinx=0.0;
spiny=0.0;
spinz=0.0;
x = 0.0;
y = 0.0;
z = 0.0;
for (i = 0; i<150; i++)
{
sx[i] = x;
sy[i] = y;
sz[i] = z;
spinxs[i] = spinx;
spinys[i] = spiny;
spinzs[i] = spinz;
sa[i] = 1;
ss[i] = 0;
}
glutIdleFunc(NULL);
glutPostRedisplay();
break;
case 'p':
case 'P':
s=0;
spinx=0.0;
spiny=0.0;
spinz=0.0;
glutIdleFunc(NULL);
glutPostRedisplay();
break;
case'u':
case 'U':
up();
break;
case 'D':
case 'd':
down();
break;
case 'S':
case 's':s=1;
glutIdleFunc(straight);
break; }
}
else if(f==3)
{
switch(key)
{
case 'b':
case 'B':f=1;break;
case 'h':
case 'H':f=0;break;
case 'q':
case 'Q':exit(0);
}
}
else
{ switch(key)
{
case 'b':
case 'B':f=1;break;
case 'h':
case 'H':f=0;break;
case 'q':
case 'Q':exit(0);
}
}
reshape( 1400,700 );
glutPostRedisplay( );
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glEnable(GL_DEPTH_TEST);
glutInitWindowSize (1400, 700);
glutInitWindowPosition (0, 0);
glutCreateWindow ("AIRSHOW");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(mouse);
glutKeyboardFunc(keyboardFunc);
glutMainLoop();
return 0;
}
CHAPTER 5
TESTING
Testing is a critical phase in the software development lifecycle that ensures the
application performs as expected and meets the specified requirements. For the Airshow
project, the testing chapter includes detailed descriptions of the test cases. This chapter aims
to ensure the robustness, accuracy, and performance of the airshow simulation.
Objective: Verify that the plane moves correctly based on direction and speed.
Result: The plane should move to new position.
Objective: Verify that smoke particles are emitted correctly from the plane's position.
Result: A smoke particle should be created at the plane's position.
Objective: Verify that the plane's movement and smoke emission are integrated
correctly.
Result: The plane should move and a smoke particle should be created
Plane Movement
Test 2 with rotation and Yes Tested right
Smoke Integration
Objective: Verify that the user can interact with the simulation using mouse and
keyboard.
Use mouse clicks and keyboard inputs to control the plane.
Collect user feedback on the responsiveness and accuracy.
Result: Users should be able to control the plane easily, and the simulation should
respond correctly to inputs.
CHAPTER 6
EXPERIMENTAL RESULTS
The project designed has been tested for its working, and is found to be working
properly to meet all its requirements.The project has been found to be giving correct outputs
to the inputs that were given, like pressing of left mouse button will rotate the planes,
pressing of right mouse button will stop the rotation of the plane and keyboard button R will
reset the movement of planes.
The designed project has been tested for errors and has been found to be meeting all
the requirements of design with which it was started. Thus the project is declared to be
working properly. Working of the project is represented as follows.
CHAPTER 7:
CONCLUSION AND FUTURE ENHANCEMENT
REFERENCES
[1]. Edward Angel, Interactive Computer Graphics A Top-Down Approach with OpenGL,
5th Edition, Pearson Education, 2008.
[2]. James D Foley, Andries Van Dam, Steven K Feiner, John F Hughes, Computer
Graphics with OpenGL; Pearson Education 1997.
[3]. http://www.opengl.com