0% found this document useful (0 votes)
44 views31 pages

Rocket Launcher Using Opengl

Uploaded by

A .Lisha.M . Cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views31 pages

Rocket Launcher Using Opengl

Uploaded by

A .Lisha.M . Cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

lOMoARcPSD|28459162

Rocket launcher using opengl

Computer Science and Engineering (Visvesvaraya Technological University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Lisha.M ([email protected])
lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

Chapter 1
INTRODUCTION

1.1 Computer Graphics

 Graphics provides one of the most natural means of communicating with a


computer, since our highly developed 2D Or 3D pattern-recognition abilities allow
us to perceive and process pictorial data rapidly.
 Computers have become a powerful medium for the rapid and economical
production of pictures.
 There is virtually no area in which graphical displays cannot be used to some
advantage.
 Graphics provide a so natural means of communicating with the computer that they
have become widespread.
 Interactive graphics is the most important means of producing pictures since the
invention of photography and television.
 We can make pictures of not only the real world objects but also of abstract objects
such as mathematical surfaces on 4D and of data that have no inherent geometry.
 A computer graphics system is a computer system with all the components of the
general purpose computer system. There are five major elements in system: input
devices, processor, memory, frame buffer, output devices.

Fig 1.1: CG Model

Dept. of CSE, RIT Hassan Page 1

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

1.2 OpenGL Technology

OpenGL is the premier environment for developing portable, interactive 2D and


3D graphics applications. Since its introduction in 1992, OpenGL has become the
industry's most widely used and supported 2D and 3D graphics application programming
interface (API), bringing thousands of applications to a wide variety of computer platforms.

OpenGL fosters innovation and speeds application development by incorporating a


broad set of rendering, texture mapping, special effects, and other powerful visualization
functions. Developers can leverage the power of OpenGL across all popular desktop and
workstation platforms, ensuring wide application deployment.

OpenGL Available Everywhere: Supported on all UNIX® workstations, and


shipped standard with every Windows 95/98/2000/NT and MacOS PC, no other graphics
API operates on a wider range of hardware platforms and software environments.

OpenGL runs on every major operating system including Mac OS, OS/2, UNIX,
Windows 95/98, Windows 2000, Windows NT, Linux, OPENStep, and BeOS; it also
works with every major windowing system, including Win32, MacOS, Presentation
Manager, and X-Window System. OpenGL is callable from Ada, C, C++, Fortran, Python,
Perl and Java and offers complete independence from network protocols and topologies.

The OpenGL interface Our application will be designed to access OpenGL


directly through functions in three libraries namely: gl,glu,glut

Fig 1.2: OpenGL

Dept. of CSE, RIT Hassan Page 2

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

Chapter 2

REQUIREMENT SPECIFICATION

2.1 Hardware Requirements

The standard output device is assumed to be a Color Monitor. It is quite essential


for any graphics package to have this, as provision of color options to the user is a must.
The mouse, the main input device, has to be functional i.e. used to move the car left or
right in the game. A keyboard is used for controlling and inputting data in the form of
characters, numbers i.e. to enter the player name in Need For Speed 2012, etc. Apart from
these hardware requirements there should be sufficient hard disk space and primary
memory available for proper working of the package to execute the program. Pentium III or
higher processor, 16MB or more RAM. A functional display card.

Minimum Requirements Expected are cursor movement, creating objects like


lines, squares, rectangles, polygons, etc. Transformations on objects/selected area should be
possible. Filling of area with the specified color should be possible

2.2 Software Requirements


The editor has been implemented on the OpenGL platform and mainly requires an
appropriate version of eclipse compiler to be installed and functional in Ubuntu. Thought it
is implemented in Open GL, it is pretty much performed and independent with the
restriction that there is support for the execution of C and C++ files. Text Modes is
recommended.

Developed Platform: Eclipse


Language Used In Coding: Ubuntu

Dept. of CSE, RIT Hassan Page 3

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

Chapter 3

SYSTEM DESIGN

Existing System

Existing system for a graphics is the TC++ . This system will support only the 2D
graphics. 2D graphics package being designed should be easy to use and understand. It
should provide various option such as free hand drawing , line drawing , polygon drawing ,
filled polygons, flood fill, translation , rotation , scaling , clipping etc. Even though these
properties were supported, it was difficult to render 2D graphics cannot be . Very difficult
to get a 3 Dimensional object. Even the effects like lighting , shading cannot be provided.
So we go for Microsoft Visual Studio software.

Proposed System

To achieve three dimensional effects, open GL software is proposed . It is software


which provides a graphical interface. It is a interface between application program and
graphics hardware. the advantages are:

 Open GL is designed as a streamlined.


 It’s a hardware independent interface i.e. it can be implemented on many different
hardware platforms.
 With OpenGL, we can draw a small set of geometric primitives such as points, lines
and polygons etc.
 Its provides double buffering which is vital in providing transformations.
 It is event driven software.
 It provides call back function.

Dept. of CSE, RIT Hassan Page 4

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

Fig 3.1: System Design

3.2 DETAILED DESIGN

Transformation Functions
Matrices allow arbitrary linear transformations to be represented in a consistent
format, suitable for computation. This also allows transformations to be concatenated easily
(by multiplying their matrices).

Linear transformations are not the only ones that can be represented by matrices.
Using homogenous coordinates, both affine transformation and perspective
projection on Rn can be represented as linear transformations on RPn+1 (that is, n+1-
dimensional real projective space). For this reason, 4x4 transformation matrices are widely
used in 3D computer graphics.

3-by-3 or 4-by-4 transformation matrices containing homogeneous coordinates are often


called, somewhat improperly, "homogeneous transformation matrices". However, the

Dept. of CSE, RIT Hassan Page 5

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

transformations they represent are, in most cases, definitely non-homogeneous and non-
linear (like translation, roto-translation or perspective projection). And even the matrices
themselves look rather heterogeneous, i.e. composed of different kinds of elements (see
below). Because they are multi-purpose transformation matrices, capable of representing
both affine and projective transformations, they might be called "general transformation
matrices", or, depending on the application, "affine transformation" or "perspective
projection" matrices. Moreover, since the homogeneous coordinates describe a projective
vector space, they can also be called "projective space transformation matrices".

Finding the matrix of a transformation

If one has a linear transformation T(x) in functional form, it is easy to determine the
transformation matrix A by simply transforming each of the vectors of the standard
basis by T and then inserting the results into the columns of a matrix. In other words,

For example, the function T(x) = 5x is a linear transformation. Applying the above
process (suppose that n = 2 in this case) reveals that

Examples in 2D graphics

Most common geometric transformations that keep the origin fixed are linear,
including rotation, scaling, shearing, reflection, and orthogonal projection; if an affine
transformation is not a pure translation it keeps some point fixed, and that point can be
chosen as origin to make the transformation linear. In two dimensions, linear
transformations can be represented using a 2×2 transformation matrix.

Dept. of CSE, RIT Hassan Page 6

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

Rotation:

For rotation by an angle θ anticlockwise about the origin, the functional form is x'
= xcosθ − ysinθ and y' = xsinθ + ycosθ. Written in matrix form, this becomes:

Similarly, for a rotation clockwise about the origin, the functional form is x' = xcosθ
+ ysinθ and y' = − xsinθ + ycosθ and the matrix form is:

Scaling:

For scaling (that is, enlarging or shrinking), we have

and . The matrix form is:

When , then the matrix is a squeeze mapping and preserves areas in the
plane.

Shearing:

For shear mapping (visually similar to slanting), there are two possibilities.
For a shear parallel to the x axis has x' = x + ky and y' = y; the shear matrix, applied
to column vectors, is:

A shear parallel to the y axis has x' = x and y' = y + kx, which has matrix form:

Dept. of CSE, RIT Hassan Page 7

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

Chapter 4

IMPLIMENTATION

4.1 Functions Used

Void glColor3f(float red, float green, float blue);

This function is used to mention the color in which the pixel should appear. The
number 3 specifies the number of arguments that the function would take. ‘f ’ gives the
type that is float. The arguments are in the order RGB(Red, Green, Blue). The color of the
pixel can be specified as the combination of these 3 primary colors.

Void glClearColor(int red, int green, int blue, int alpha);

This function is used to clear the color of the screen. The 4 values that are passed as
arguments for this function are (RED, GREEN, BLUE, ALPHA) where the red green and
blue components are taken to set the background color and alpha is a value that specifies
depth of the window. It is used for 3D images..

Void glFlush();

Different GL implementations buffer commands in several different locations,


including network buffers and the graphics accelerator itself. glFlush empties all of these
buffers, causing all issued commands to be executed as quickly as they are accepted by the
actual rendering engine. Though this execution may not be completed in any particular
time period, it does complete in finite time.

void glutInit(int *argcp, char **argv);

glutInit will initialize the GLUT library and negotiate a session with the window
system. During this process, glutInit may cause the termination of the GLUT program with
an error message to the user if GLUT cannot be properly initialized. Examples of this
situation include the failure to connect to the window system, the lack of window system
support for OpenGL, and invalid command line options.glutInit also processes command
line options, but the specific options parse are window system dependent.

Dept. of CSE, RIT Hassan Page 8

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glOrtho ( )

Syntax:

void glOrtho ( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble
near, GLdouble far);

The function defines an orthographic viewing volume with all parameters measured
from the centre of the projection plane.

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.

4.2 User Defined Functions

Void display(void)
In this function first we should print the instructions that we would be displayed on
the pop-up window.

Void displayloop()

Here we are display starting stage ,intermediate & final stage of Rocket.

Void myinit()

It sets background color and orthographic window.

Int main(int argc,char**argv)

Here we call all the function we defined previously in the program and this function
creates a output window.

Dept. of CSE, RIT Hassan Page 9

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

4.3 Appendix

#include<GL/glut.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
const float DEG2RAD = 3.14159/180;
void stars();
int p;
void stars1();
void static_rocket();
void rocket_to_cam_pos();
void rocket_in_motion();
void mars(float radius);

float i,j,count=0,count1=0,count3=0,flag=0,flag1=0,t=0,f=0,flag3=0;

// fucntion to display the text content of the home screen


void drawstring(int x, int y, char *s)
{
char *c;
glRasterPos2i(x, y);
for (c = s; *c != '\0'; *c++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, *c);
}

void semicircle(float radius,float u,float v)


{

glColor3f(1.0 ,1.0 ,1.0);


glBegin(GL_POLYGON);

for (int i=135; i<=315; i++)


{
float degInRad = i*DEG2RAD;
glVertex2f(u+cos(degInRad)*radius,v+(sin(degInRad))*radius);//100,100 specifies centre of
the circle
}

glEnd();
}

//determines the state of rocket launch


void control()
{
count1++;
if(count1==250)
flag=1;

else if (flag == 1 && (count1 == 600 || count1 == 601))


rocket_to_cam_pos();

Dept. of CSE, RIT Hassan Page 10

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

else if (flag == 1 && count1 >= 1000)


rocket_in_motion();
}

void stars()
{

glColor3f(1.0,1.0,1.0);
glPointSize(2.37);
glBegin(GL_POINTS);
glVertex2i(10,20);
glVertex2i(20,100);
glVertex2i(30,10);
glVertex2i(15,150);
glVertex2i(17,80);
glVertex2i(200,200);
glVertex2i(55,33);
glVertex2i(400,300);
glVertex2i(330,110);
glVertex2i(125,63);
glVertex2i(63,125);
glVertex2i(20,10);
glVertex2i(110,330);
glVertex2i(440,430);
glVertex2i(32,65);
glVertex2i(110,440);
glVertex2i(210,230);
glVertex2i(390,490);
glVertex2i(12,90);
glVertex2i(400,322);
glVertex2i(420,366);
glVertex2i(455,400);
glVertex2i(20,20);
glVertex2i(111,120);
glVertex2i(401,200);
glVertex2i(230,30);
glVertex2i(220,20);
glVertex2i(122,378);
glVertex2i(133,340);
glVertex2i(345,420);
glVertex2i(130,360);
glVertex2i(333,120);
glVertex2i(250,22);
glVertex2i(242,11);
glVertex2i(280,332);
glVertex2i(233,40);
glVertex2i(210,418);
glVertex2i(256,12);
glVertex2i(288,232);
glVertex2i(247,36);
glVertex2i(229,342);
glVertex2i(257,47);
glVertex2i(290,63);
glVertex2i(232,72);

Dept. of CSE, RIT Hassan Page 11

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glVertex2i(243,143);
glVertex2i(100,200);
glVertex2i(90,250);
glVertex2i(80,225);
glVertex2i(50,333);
glVertex2i(60,350);
glVertex2i(243,143);
glVertex2i(243,143);
glEnd();
}

void stars1()
{
int l;
glColor3f(1.0,1.0,1.0);
glPointSize(1.25);
glBegin(GL_POINTS);
glVertex2i(50,20);
glVertex2i(70,100);
glVertex2i(80,10);
glVertex2i(65,150);
glVertex2i(67,80);
glVertex2i(105,33);
glVertex2i(450,300);
glVertex2i(380,110);
glVertex2i(175,63);
glVertex2i(113,125);
glVertex2i(70,10);
glVertex2i(160,330);
glVertex2i(490,430);
glVertex2i(82,65);
glVertex2i(160,440);
glVertex2i(440,490);
glVertex2i(62,90);
glVertex2i(450,322);
glVertex2i(420,366);
glVertex2i(455,400);
glVertex2i(60,20);
glVertex2i(111,120);
glVertex2i(451,200);
glVertex2i(280,30);
glVertex2i(220,20);
glVertex2i(132,378);
glVertex2i(173,340);
glVertex2i(325,420);
glVertex2i(180,360);
glVertex2i(383,120);
glVertex2i(200,22);
glVertex2i(342,11);
glVertex2i(330,332);
glVertex2i(283,40);
glVertex2i(210,418);
glVertex2i(256,12);
glVertex2i(288,232);

Dept. of CSE, RIT Hassan Page 12

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glVertex2i(247,36);
glVertex2i(229,342);
glVertex2i(257,47);
glVertex2i(290,63);
glVertex2i(232,72);
glVertex2i(243,143);
glVertex2i(100,200);
glVertex2i(90,250);
glVertex2i(80,225);
glVertex2i(50,333);
glVertex2i(60,350);
glVertex2i(243,143);
glVertex2i(243,143);
glEnd();
for(l=0;l<=10000;l++)
;
}
void static_rocket()
{
count1++;
//if(count1==150)
//flag=1;
if(flag==0)
{
glClearColor(0.196078 ,0.6 ,0.8,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glColor3f(0.4,0.25,0.1);
glBegin(GL_POLYGON);//green ground
glVertex2f(0.0,0.0);
glVertex2f(0.0,250.0);
glVertex2f(270.0,250.0);
glVertex2f(500.0,50.0);
glVertex2f(500.0,0.0);
glEnd();
glBegin(GL_POLYGON);//green ground
glVertex2f(280.0,250.0);
glVertex2f(500.0,250.0);
glVertex2f(500.0,60.0);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);//road
glVertex2f(260.0,250.0);
glVertex2f(290.0,250.0);
glVertex2f(500.0,70.0);
glVertex2f(500.0,40.0);
glEnd();
glColor3f(0.0,0.0,0.0);

glColor3f(0.8,0.498039 ,0.196078);
glBegin(GL_POLYGON);//house 1
glVertex2f(250.0,250.0);
glVertex2f(300.0,250.0);
glVertex2f(300.0,350.0);

Dept. of CSE, RIT Hassan Page 13

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glVertex2f(250.0,350.0);
glEnd();
glColor3f(0.7,0.7,0.7);
glBegin(GL_POLYGON);//HOUSE A
glVertex2f(255,267.5);
glVertex2f(275.0,267.5);
glVertex2f(275.0,277.5);
glVertex2f(255.0,277.5);
glEnd();
glBegin(GL_POLYGON);//HOUSE B
glVertex2f(255,285.0);
glVertex2f(275.0,285);
glVertex2f(275.0,295);
glVertex2f(255.0,295);
glEnd();

glBegin(GL_POLYGON);//HOUSE C
glVertex2f(255,302.5);
glVertex2f(275.0,302.5);
glVertex2f(275.0,312.5);
glVertex2f(255.0,312.5);
glEnd();

glBegin(GL_POLYGON);//HOUSE D
glVertex2f(255,320.0);
glVertex2f(275.0,320.0);
glVertex2f(275.0,330.0);
glVertex2f(255.0,330.0);
glEnd();

glBegin(GL_POLYGON);//HOUSE E
glVertex2f(285,267.5);
glVertex2f(295.0,267.5);
glVertex2f(295.0,277.5);
glVertex2f(285.0,277.5);
glEnd();

glBegin(GL_POLYGON);//HOUSE F
glVertex2f(285,285.0);
glVertex2f(295.0,285);
glVertex2f(295.0,295);
glVertex2f(285.0,295);
glEnd();

glBegin(GL_POLYGON);//HOUSE G
glVertex2f(285,302.5);
glVertex2f(295.0,302.5);
glVertex2f(295.0,312.5);
glVertex2f(285.0,312.5);
glEnd();

glBegin(GL_POLYGON);//HOUSE H
glVertex2f(285,320.0);
glVertex2f(295.0,320.0);

Dept. of CSE, RIT Hassan Page 14

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glVertex2f(295.0,330.0);
glVertex2f(285.0,330.0);
glEnd();
glColor3f(0.647059 ,0.164706 ,0.164706);
glBegin(GL_POLYGON);//solid cone
glVertex2f(26,250);
glVertex2f(52,250);
glVertex2f(39,290);
glEnd();
semicircle(20.0,50,300);

glColor3f(0.0,0.0 ,0.0);
glBegin(GL_LINES);//wires
glVertex2f(37,313);
glVertex2f(62,310);
glVertex2f(63,287);
glVertex2f(62,310);
glEnd();
glColor3f(1.0,1.0,1.0);

glEnd();
glPointSize(2.0);

glColor3f(1.0,1.0 ,1.0);
glBegin(GL_POINTS);//road paint
glVertex2f(497,56);
glVertex2f(488,65);
glVertex2f(479,74);
glVertex2f(470,83);
glVertex2f(460,92);
glVertex2f(450,101);
glVertex2f(439,110);
glVertex2f(428,119);
glVertex2f(418,128);
glVertex2f(408,137);
glVertex2f(398,146);
glVertex2f(388,155);
glVertex2f(378,164);
glVertex2f(366,173);
glVertex2f(356,182);
glVertex2f(346,191);
glVertex2f(336,200);
glVertex2f(324,209);
glVertex2f(314,218);
glVertex2f(304,227);
glVertex2f(294,234);
glVertex2f(284,243);
glVertex2f(278,248);

glEnd();

Dept. of CSE, RIT Hassan Page 15

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glColor3f(0.0,0.0,0.0);//stand object
glBegin(GL_POLYGON);
glVertex2f(130,10.0);
glVertex2f(160,10.0);
glVertex2f(160,180.0);
glVertex2f(130,180.0);
glEnd();
glBegin(GL_LINES);
glVertex2f(130,30.0);
glVertex2f(262,30.0);

glVertex2f(130,130.0);
glVertex2f(260,130.0);
glEnd();

glColor3f(0.8,0.498039 ,0.196078);
glBegin(GL_POLYGON);//core
glVertex2f(237.5,20.0);
glVertex2f(262.5,20.0);
glVertex2f(262.5,120.0);
glVertex2f(237.5,120.0);
glEnd();

glColor3f(1.0,1.0,1.0);//bonnet
glBegin(GL_POLYGON);//front
glVertex2f(237.5,120.0);
glVertex2f(262.5,120.0);
glVertex2f(250,170.0);
glEnd();
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);//left_side_top
glVertex2f(237.5,120.0);
glVertex2f(217.5,95.0);
glVertex2f(237.5,95.0);
glEnd();
glBegin(GL_POLYGON);//left_side_bottom
glVertex2f(237.5,20.0);
glVertex2f(217.5,20.0);
glVertex2f(237.5,70.0);
glEnd();
glBegin(GL_POLYGON);//right_side_bottom
glVertex2f(262.5,20.0);
glVertex2f(282.5,20.0);
glVertex2f(262.5,70.0);
glEnd();
glBegin(GL_POLYGON);//right_side_top
glVertex2f(262.5,120.0);
glVertex2f(262.5,95.0);
glVertex2f(282.5,95.0);
glEnd();
glColor3f(0.556863 ,0.137255 ,0.419608);
glBegin(GL_POLYGON);//bottom_1_exhaust
glVertex2f(237.5,20.0);
glVertex2f(244.5,20.0);

Dept. of CSE, RIT Hassan Page 16

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glVertex2f(241,0.0);
glEnd();
glBegin(GL_POLYGON);//bottom_2_exhaust
glVertex2f(246.5,20.0);
glVertex2f(253.5,20.0);
glVertex2f(249.5,0.0);
glEnd();
glBegin(GL_POLYGON);//bottom_3_exhaust
glVertex2f(262.5,20.0);
glVertex2f(255.5,20.0);
glVertex2f(258.5,0.0);
glEnd();

glBegin(GL_POLYGON);//left_stand_holder
glVertex2f(182.5,85.0);
glVertex2f(182.5,0.0);
glVertex2f(187.5,0.0);
glVertex2f(187.5,80.0);
glVertex2f(237.5,80.0);
glVertex2f(237.5,85.0);
glVertex2f(182.5,85.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(312.5,85.0);//right_stand_holder
glVertex2f(312.5,0.0);
glVertex2f(307.5,0.0);
glVertex2f(307.5,80.0);
glVertex2f(262.5,80.0);
glVertex2f(262.5,85.0);
glVertex2f(312.5,85.0);
glEnd();

for(j=0;j<=1000000;j++)
;
glutSwapBuffers();
glutPostRedisplay();
glFlush();
}

}
void rocket_to_cam_pos()
{
count++;
count3++;

for(i=0;i<=200;i++)
{

glClearColor(0.196078 ,0.6 ,0.8,1.0);


glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glColor3f(0.8,0.498039 ,0.196078);
glBegin(GL_POLYGON);//core
glVertex2f(237.5,20.0+i);

Dept. of CSE, RIT Hassan Page 17

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glVertex2f(262.5,20.0+i);
glVertex2f(262.5,120.0+i);
glVertex2f(237.5,120.0+i);

glEnd();

glColor3f(1.0,1.0,1.0);//bonnet
glBegin(GL_POLYGON);//front
glVertex2f(237.5,120.0+i);
glVertex2f(262.5,120.0+i);
glVertex2f(250,170.0+i);
glEnd();
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);//left_side_top
glVertex2f(237.5,120.0+i);
glVertex2f(217.5,95.0+i);
glVertex2f(237.5,95.0+i);
glEnd();
glBegin(GL_POLYGON);//left_side_bottom
glVertex2f(237.5,20.0+i);
glVertex2f(217.5,20.0+i);
glVertex2f(237.5,70.0+i);
glEnd();
glBegin(GL_POLYGON);//right_side_bottom
glVertex2f(262.5,20.0+i);
glVertex2f(282.5,20.0+i);
glVertex2f(262.5,70.0+i);
glEnd();
glBegin(GL_POLYGON);//right_side_top
glVertex2f(262.5,120.0+i);
glVertex2f(262.5,95.0+i);
glVertex2f(282.5,95.0+i);
glEnd();
glColor3f(0.556863 ,0.137255 ,0.419608);
glBegin(GL_POLYGON);//bottom_1_exhaust
glVertex2f(237.5,20.0+i);
glVertex2f(244.5,20.0+i);
glVertex2f(241,0.0+i);
glEnd();
glBegin(GL_POLYGON);//bottom_2_exhaust
glVertex2f(246.5,20.0+i);
glVertex2f(253.5,20.0+i);
glVertex2f(249.5,0.0+i);
glEnd();
glBegin(GL_POLYGON);//bottom_3_exhaust
glVertex2f(262.5,20.0+i);
glVertex2f(255.5,20.0+i);
glVertex2f(258.5,0.0+i);
glEnd();

if((p%2)==0)
glColor3f(1.0,0.25,0.0);
else

Dept. of CSE, RIT Hassan Page 18

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glColor3f(1.0,0.816,0.0);

glBegin(GL_POLYGON);//outer fume
glVertex2f(237.5,20+i);
glVertex2f(234.16,16.66+i);
glVertex2f(230.82,13.32+i);
glVertex2f(227.48,9.98+i);
glVertex2f(224.14,6.64+i);
glVertex2f(220.8,3.3+i);
glVertex2f(217.5,0+i);
glVertex2f(221.56,-5+i);
glVertex2f(225.62,-10+i);
glVertex2f(229.68,-15+i);
glVertex2f(233.74,-20+i);
glVertex2f(237.8,-25+i);
glVertex2f(241.86,-30+i);
glVertex2f(245.92,-35+i);
glVertex2f(250,-40+i);
glVertex2f(254.06,-35+i);
glVertex2f(258.12,-30+i);
glVertex2f(262.18,-25+i);
glVertex2f(266.24,-20+i);
glVertex2f(270.3,-15+i);
glVertex2f(274.36,-10+i);
glVertex2f(278.42,-5+i);
glVertex2f(282.5,0+i);
glVertex2f(278.5,4+i);
glVertex2f(274.5,8+i);
glVertex2f(270.5,12+i);
glVertex2f(266.5,16+i);
glVertex2f(262.5,20+i);//28 points
glEnd();

if((p%2)==0)
glColor3f(1.0,0.816,0.0);
else
glColor3f(1.0,0.25,0.0);

glBegin(GL_POLYGON);//inner fume
glVertex2f(237.5,20+i);
glVertex2f(236.5,17.5+i);
glVertex2f(235.5,15+i);
glVertex2f(234.5,12.5+i);
glVertex2f(233.5,10+i);
glVertex2f(232.5,7.5+i);
glVertex2f(236,5+i);
glVertex2f(239.5,2.5+i);
glVertex2f(243,0+i);
glVertex2f(246.5,-2.5+i);
glVertex2f(250,-5+i);
glVertex2f(253.5,-2.5+i);
glVertex2f(257,0+i);
glVertex2f(260.5,2.5+i);
glVertex2f(264,5+i);

Dept. of CSE, RIT Hassan Page 19

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glVertex2f(267.5,7.5+i);
glVertex2f(266.5,10+i);
glVertex2f(265.5,12.5+i);
glVertex2f(264.5,15+i);
glVertex2f(263.5,17.5+i);
glVertex2f(262.5,20+i);//21 points

glEnd();
p=p+1;
for(j=0;j<=1000000;j++)
;
glutSwapBuffers();
glutPostRedisplay();
glFlush();
}
}
void rocket_in_motion()
{
count+=0.25;

for(i=195;i<=200;i++)
{
if(count>=5)
{
glClearColor(0.0 ,0.0 ,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
if(flag1==0)
{
stars();
flag1=1;
}
else
{
stars1();

flag1=0;
}

}
else
{
glClearColor(0.196078 ,0.6 ,0.8,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
}
if(count>=100)
mars(20.0);

if(count<=130){
glColor3f(0.8,0.498039 ,0.196078);
glBegin(GL_POLYGON);//core
glVertex2f(237.5,20.0+i);
glVertex2f(262.5,20.0+i);
glVertex2f(262.5,120.0+i);

Dept. of CSE, RIT Hassan Page 20

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glVertex2f(237.5,120.0+i);
glEnd();
}

if(count>=150){
static int k = i;
glColor3f(1.0,1.0,1.0);//satellite
glBegin(GL_POLYGON);//core
glVertex2f(237.5,150.0+k);
glVertex2f(252.5,150.0+k);
glVertex2f(252.5,120.0+k);
glVertex2f(237.5,120.0+k);
glEnd();

glBegin(GL_POLYGON);//side-panels
glVertex2f(237.5,140.0+k);
glVertex2f(230,140.0+k);
glVertex2f(230,130.0+k);
glVertex2f(237.5,130.0+k);

glVertex2f(262.5,140.0+k);
glVertex2f(227.5,140.0+k);
glVertex2f(227.5,130.0+k);
glVertex2f(262.5,130.0+k);
glEnd();
}

else{
glColor3f(1.0,1.0,1.0);//bonnet
glBegin(GL_POLYGON);//front
glVertex2f(237.5,120.0+i);
glVertex2f(262.5,120.0+i);
glVertex2f(250,170.0+i);
glEnd();
}

if(count<=120){
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);//left_side_top
glVertex2f(237.5,120.0+i);
glVertex2f(217.5,95.0+i);
glVertex2f(237.5,95.0+i);
glEnd();
glBegin(GL_POLYGON);//left_side_bottom
glVertex2f(237.5,20.0+i);
glVertex2f(217.5,20.0+i);
glVertex2f(237.5,70.0+i);
glEnd();
glBegin(GL_POLYGON);//right_side_bottom
glVertex2f(262.5,20.0+i);
glVertex2f(282.5,20.0+i);
glVertex2f(262.5,70.0+i);
glEnd();
glBegin(GL_POLYGON);//right_side_top

Dept. of CSE, RIT Hassan Page 21

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

glVertex2f(262.5,120.0+i);
glVertex2f(262.5,95.0+i);
glVertex2f(282.5,95.0+i);
glEnd();
}

if(count<=110){
glColor3f(0.556863 ,0.137255 ,0.419608);
glBegin(GL_POLYGON);//bottom_1_exhaust
glVertex2f(237.5,20.0+i);
glVertex2f(244.5,20.0+i);
glVertex2f(241,0.0+i);
glEnd();
glBegin(GL_POLYGON);//bottom_2_exhaust
glVertex2f(246.5,20.0+i);
glVertex2f(253.5,20.0+i);
glVertex2f(249.5,0.0+i);
glEnd();
glBegin(GL_POLYGON);//bottom_3_exhaust
glVertex2f(262.5,20.0+i);
glVertex2f(255.5,20.0+i);
glVertex2f(258.5,0.0+i);
glEnd();
}

for(j=0;j<=1000000;j++)
;
glutSwapBuffers();
glutPostRedisplay();
glFlush();
}
}

void mars(float radius)


{

glBegin(GL_POLYGON);

for (int i=0; i<=359; i++)


{
float degInRad = i*DEG2RAD;
glVertex2f(300+f+cos(degInRad)*radius,500-t+(sin(degInRad))

*radius);//100,100 specifies centre of the circle


}

glEnd();
t=t+0.1;
f=f+0.1;
}

//keys that trigger manual Lanch


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

Dept. of CSE, RIT Hassan Page 22

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

{
if (key == 'S' || key == 's'){
for(int i=0;i<300;i++)
static_rocket();
flag = 1;

if (key == 'L' || key == 'l')


{
for(int i=0;i<700;i++)
static_rocket();
}

if (key == 'Q' || key == 'q')


exit(0);

//design of homescreen
void page()
{
glColor3f(1, 1, 1);
glLineWidth(5);
glBegin(GL_LINE_LOOP);
glVertex2d(75, 425);
glVertex2d(375, 425);
glVertex2d(375, 325);
glVertex2d(75, 325);
glEnd();

drawstring(100, 400, "ROCKET LAUNCHING SIMULATION");


drawstring(100, 380, "NAME : MOHAMMED ALQHAMA");
drawstring(100, 360, "USN : 4RA20CS050");
drawstring(100, 340, "SEM : VI");

glBegin(GL_LINE_LOOP);
glVertex2d(75, 75);
glVertex2d(375, 75);
glVertex2d(375, 225);
glVertex2d(75, 225);
glEnd();

drawstring(100, 200, "INSTRUCTIONS");


drawstring(100, 180, "Press S to START");
drawstring(100, 160, "Press L to Launch Pad");
drawstring(100, 100, "Press Q to quit");
glFlush();
}

//display all components


void display()
{

Dept. of CSE, RIT Hassan Page 23

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

if (flag == 0)
{
glClear(GL_COLOR_BUFFER_BIT);
page();
glutSwapBuffers();
}
else
control();
glFlush();
}

void myinit()
{
//int i;
glClearColor(0.196078 ,0.6 ,0.8,1.0);

glPointSize(1.0);
gluOrtho2D(0.0,499.0,0.0,499.0);
}

int main(int argc,char*argv[])


{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(600,600);
glutCreateWindow("rocket");
myinit();
glutKeyboardFunc(keyboard);
glutDisplayFunc(display);
glutIdleFunc(display);

glutMainLoop();
return 0;
}

Dept. of CSE, RIT Hassan Page 24

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

Chapter 5

TESTING AND RESULT

The full designing and creating of Need For Speed 2012 has been executed under
ubuntu operating system using Eclipse, this platform provides a and satisfies the basic need
of a good compiler. Using GL/glut.h library and built in functions make it easy to design
good graphics package such as this racing game.

This game allows the gamer to overtake obstacles, and accomplish 5 levels of
intense racing. It tells the user what will happen if they collide with an obstacle i.e. setting
an example in real life. The levels automatically increment unless the vehicle has not
crashed.

Testing involves unit testing, module testing and system testing.

UNIT TESTING

Here the individual components are tested to ensure that they operate correctly.
Each component is tested independently, without other system components.

MODULE TESTING

Module is a collection of dependent components such as procedures and functions.


Since the module encapsulates related components can be tested with our other system
modules. The testing process is concerned with finding errors which results from erroneous
function calls from the main function to various individual functions.

SYSTEM TESING

The Modules are integrated to make up the entire system. The testing process is
concerned with finding errors with the results from unanticipated interactions between
module and system components. It is also concerned with validating that the system meets
its functional and non-functional requirements..

Dept. of CSE, RIT Hassan Page 25

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

Chapter 6

SNAPSHOTS

6.1. Control Instruction

Fig 6.1: Control Instruction

6.2. Launch pad

Fig 6.2: Launch Pad

Dept. of CSE, RIT Hassan Page 26

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

6.3. Stage 1

Fig 6.3: Stage 1

6.4. Stage 2

Fig 6.4: Stage 2

Dept. of CSE, RIT Hassan Page 27

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

6.5. Stage 3

Fig 6.5: Stage 3

6.6. Satellite

Fig 6.6: Satellite

Dept. of CSE, RIT Hassan Page 28

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

Chapter 7

CONCLUSION

The software development is never completed. There is always a need for


modification.There could have been other approaches to implement the system. I have tried
to my level best to make the system an interactive as possible. The system has been
developed with muchcare and free of errors and at the same time it is efficient and less time
consuming. The purpose of this project was to develop a computer graphics for animation
of Rocket Launch Simulation

The simulator incorporates accurate physics simulations, capturing the intricacies of


propulsion, aerodynamics, and gravitational forces. This attention to detail ensures a high
level of realism and enables users to gain a deeper understanding of the complexities
involved in rocket launches.

Additionally, the project offers educational value by presenting informative visuals


and data about each stage of the launch process. Users can explore the various components
of the rocket, learn about different mission objectives, and discover fascinating facts about
space exploration.

Moreover, the computer graphics techniques employed in the simulator contribute


to its visually stunning and captivating nature. The realistic rendering of the rocket, launch
pad, and surrounding environment enhances the overall user experience, making it both
informative and entertaining.

Overall, the computer graphics rocket launch simulator project showcases the
potential of blending technology and education, providing an engaging platform for users
to explore and learn about the fascinating world of rocket launches. It serves as a valuable
tool for students, space enthusiasts, and anyone interested in experiencing the thrill of space
exploration from the comfort of their own computer.

Dept. of CSE, RIT Hassan Page 29

Downloaded by Lisha.M ([email protected])


lOMoARcPSD|28459162

Rocket Launch Simulation 2022-23

REFERENCES

Books referred during this project work:

 Interactive Computer Graphics A top –down approach with OpenGL – Edward


Angel, 5th Edition, Addition-Wesley 2008.
 Computer Graphics Using OpenGL - F.S.Hill.Jr. 2nd Edition, Pearson Education,
2001.

Websites referred:

http://github.com
http://javapoint.com/xampp
http:// javapoint.com/opengl
http:// javapoint.com/html
www.google.com
www.openGL.com
www.w3schools.com
www.google.co.in
www.htmlguddies.com
www.beginneres.com
www.tutorialspoint.com

Dept. of CSE, RIT Hassan Page 30

Downloaded by Lisha.M ([email protected])

You might also like