CG Rocket Launching Final Report

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 30

ABSTRACT

The rocket launching project is a 2D animation of a satellite launching process.


In our project rocket will be static prior to launching. When a launch is
performed through interactions, the countdown begins for the launch. The
countdown is 10 to 0, once the countdown is finished rocket is launched. Once
the rocket is launched, actual animation starts here. Rocket starts moving into
the sky, after sometime it reaches the space. The next phase of the rocket launch
is dismantling stage1, in this stage the first fuel supplier will be dismantled.
Now rocket starts moving with the help of second fuel supplier. The next stage
will be dismantling stage2, here the fuel supplier 2 will be dismantled. The next
phase is forced dismantling stage, where the unwanted parts are expelled. After
this phase satellite is launched.
ACKNOWLEDGEMENT

Firstly, I thank the Management late Shri A. Krishnappa, Chairman SEA College of
Engineering and Technology for Providing Necessary infrastructure and creating good
environment.

I would like to express my profound thanks to our respected principal


Dr. B VENKATANARAYANA for the encouragement and support given by him.

I would like to express my sincere thanks to our respected Dr. B.LOGANAYAGI HOD
of Computer science and engineering department, for his assistance and guidance.

I am thankful for the support rendered by my Project guide and coordinator prof.
SASWATI for her valuable suggestions.
I am also obliged, to the faculty members of CSE Department who rendered their valuable
assistance for the Project.

And, I would like to express my heart full gratitude to my parents who have extended their
help throughout my Project.

And finally, I would like to express my heart full gratitude to my friends and all those who
have extended their help throughout my Project

BHUVANA.KV (1SP20CS012)
CONTENTS

INDEX Page No.

1. INTRODUCTION
Computer Graphics 1
1.2 OpenGL Technology 2

2. Requirements And Specifications


Hardware Requirements 3
2.2 Software Requirements 3

3. Software Design
System Design 4
3.2 Detailed Design 5

4. Implementation
Functions Used 8

5. Testing and Results 12

6. Snap Shots 13

7. Appendix 17

8. Bibliography 28
ROCKET LAUNCHING

Chapter 1

INTRODUCTION
Computer Graphics
 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
 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.

DEPT OF CSE(SEACET) 2022-2023 1


ROCKET LAUNCHING

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.
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.

DEPT OF CSE(SEACET) 2022-2023 2


ROCKET LAUNCHING

Chapter 2

 REQUIREMENTS AND SPECIFICATIONS

Hardware Requirements

• Processor: Intel i3
• RAM: 4GB
• Hard Disk: 3.1GB
• Monitor: EGVGA compatible
• Keyboard: Standard 101 key keyboard
• Backup Media: Hard disk
• Mouse(PS/2)

Software Requirements

• Operating System: Windows 10


• Language Tool: OpenGL
• Compiler: DEV C++ Compiler
• Libraries: Supporting glut32.a, opengl32.a & glu32.a
• Documentation Tool: Visual C++ 6 or higher versions like 2008

DEPT OF CSE(SEACET) 2022-2023 3


ROCKET LAUNCHING

Chapter 3

SOFTWARE DESIGN
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:

1. Open GL is designed as a streamlined.


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

DEPT OF CSE(SEACET) 2022-2023 4


ROCKET LAUNCHING

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
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

DEPT OF CSE(SEACET) 2022-2023 5


ROCKET LAUNCHING

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.

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(SEACET) 2022-2023 6


ROCKET LAUNCHING

Chapter 4

IMPLEMENTATION

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 glutKeyboardFunc();
void glutKeyboardFunc(void (*func)(unsigned char

key, int x, int y));

where func is the new keyboard callback function. glutKeyboardFunc sets the keyboard
callback for the current window. When a user types into the window, each key press
generating an ASCII character will generate a keyboard callback. The key callback
parameter is the generated ASCII character. The x and y callback parameters indicate the
mouse location in window relative coordinates when the key was pressed. When a new
window is created, no keyboard callback is initially registered, and ASCII key strokes in
the window are ignored. Passing NULL to glutKeyboardFunc disables the generation of
keyboard callbacks.

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,
DEPT OF CSE(SEACET) 2022-2023 7
ROCKET LAUNCHING

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 glMatrixMode(GLenum mode);

where mode Specifies which matrix stack is the target for subsequent matrix operations.
Three values are accepted: GL_MODELVIEW, GL_PROJECTION, and
GL_TEXTURE. The initial value is GL_MODELVIEW.

glMatrixMode sets the current matrix mode. mode can assume one of three values:

GL_MODELVIEW Applies subsequent matrix operations to the modelview matri


stack.

GL_PROJECTION Applies subsequent matrix operations to the projection matrix


stack.

void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)

where x,y
Specify the lower left corner of the viewport rectangle, in pixels. The initial value is (0,
0).
width,height
Specify the width and height of the viewport. When a GL context is first attached to a
surface (e.g. window),width and height are set to the dimensions of that surface.
GlViewport specifies the affine transformation of x and y from normalized device
coordinates to window coordinates. Let (xnd, ynd) be normalized device coordinates. Then
the window coordinates (xw, yw) are computed as follows:

xw = ( xnd + 1 ) width/2 + x

yw = ( ynd + 1 ) height/2 + y
Viewport width and height are silently clamped to a range that depends on the
implementation. To query this range, call glGetInteger with argument
GL_MAX_VIEWPORT_DIMS.

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

DEPT OF CSE(SEACET) 2022-2023 8


ROCKET LAUNCHING

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.

void glutReshapeFunc(void (*func)(int width, int height));

glutReshapeFunc sets the reshape callback for the current window. The reshape callback
is triggered when a window is reshaped. A reshape callback is also triggered immediately
before a window's first display callback after a window is created or whenever an overlay
for the window is established. The width andheight parameters of the callback specify the
new window size in pixels. Before the callback, the current window is set to the window
that has been reshaped.
If a reshape callback is not registered for a window or NULL is passed
to glutReshapeFunc (to deregister a previously registered callback), the default reshape
callback is used. This default callback will simply

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.
glutPostRedisplay()
glutPostRedisplay, glutPostWindowRedisplay — marks the current or specified window
as needing to be redisplayed.

DEPT OF CSE(SEACET) 2022-2023 9


ROCKET LAUNCHING

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(SEACET) 2022-2023 10


ROCKET LAUNCHING

Chapter 5

TESTING AND RESULTS


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.

Testin 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(SEACET) 2022-2023 11


ROCKET LAUNCHING

Chapter 6

SNAP SHOTS

Fig 6.1. Snap Shot Showing Starting Stage of Rocket

DEPT OF CSE(SEACET) 2022-2023 12


ROCKET LAUNCHING

Fig.6.2 Snap Shot Showing intermediate stage and fume of


Rocket changing

Fig.6.3.Snap Shot Showing Rocket entering in outer phase

DEPT OF CSE(SEACET) 2022-2023 13


ROCKET LAUNCHING

Fig.6.4 Snap Shot Showing Rocket entering into last phase

DEPT OF CSE(SEACET) 2022-2023 14


ROCKET LAUNCHING

Chapter7
APPENDIX
#include<GL/glut.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
const float DEG2RAD = 3.14159/180;
void display1();
void stars();
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;
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);
}

glEnd();
}

void display1()
{
count1++;
if(count1==250)
flag=1;
if(flag==0)
static_rocket();
else if((count1==151)| (count1==152))
rocket_to_cam_pos();
else
rocket_in_motion();
}

void stars()
{

glColor3f(1.0,1.0,1.0);

DEPT OF CSE(SEACET) 2022-2023 15


ROCKET LAUNCHING

glPointSize(0.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);
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();
}

DEPT OF CSE(SEACET) 2022-2023 16


ROCKET LAUNCHING

void stars1()
{
int l;
glColor3f(1.0,1.0,1.0);
glPointSize(0.3);
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);
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();

DEPT OF CSE(SEACET) 2022-2023 17


ROCKET LAUNCHING

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);
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);
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);
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);
glVertex2f(250.0,250.0);
glVertex2f(300.0,250.0);
glVertex2f(300.0,350.0);
glVertex2f(250.0,350.0);
glEnd();
glColor3f(0.7,0.7,0.7);
glBegin(GL_POLYGON);
glVertex2f(255,267.5);
glVertex2f(275.0,267.5);
glVertex2f(275.0,277.5);
glVertex2f(255.0,277.5);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(255,285.0);
glVertex2f(275.0,285);
glVertex2f(275.0,295);
glVertex2f(255.0,295);
glEnd();

DEPT OF CSE(SEACET) 2022-2023 18


ROCKET LAUNCHING

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

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

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

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

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

glBegin(GL_POLYGON);
glVertex2f(285,320.0);
glVertex2f(295.0,320.0);
glVertex2f(295.0,330.0);
glVertex2f(285.0,330.0);
glEnd();
glColor3f(0.647059 ,0.164706 ,0.164706);
glBegin(GL_POLYGON);
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);
glVertex2f(37,313);
glVertex2f(62,310);
glVertex2f(63,287);
glVertex2f(62,310);
glEnd();

DEPT OF CSE(SEACET) 2022-2023 19


ROCKET LAUNCHING

glColor3f(1.0,1.0,1.0);

glEnd();
glPointSize(2.0);

glColor3f(1.0,1.0 ,1.0);
glBegin(GL_POINTS);
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();

glColor3f(0.8,0.498039 ,0.196078);
glBegin(GL_POLYGON);
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);
glBegin(GL_POLYGON);
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);
glVertex2f(237.5,120.0);
glVertex2f(217.5,95.0);
glVertex2f(237.5,95.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(237.5,20.0);

DEPT OF CSE(SEACET) 2022-2023 20


ROCKET LAUNCHING

glVertex2f(217.5,20.0);
glVertex2f(237.5,70.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(262.5,20.0);
glVertex2f(282.5,20.0);
glVertex2f(262.5,70.0);
glEnd();
glBegin(GL_POLYGON);
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);
glVertex2f(237.5,20.0);
glVertex2f(244.5,20.0);
glVertex2f(241,0.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(246.5,20.0);
glVertex2f(253.5,20.0);
glVertex2f(249.5,0.0);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(262.5,20.0);
glVertex2f(255.5,20.0);
glVertex2f(258.5,0.0);
glEnd();

glBegin(GL_POLYGON);
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);
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();
}

DEPT OF CSE(SEACET) 2022-2023 21


ROCKET LAUNCHING

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);
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);
glBegin(GL_POLYGON);
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);
glVertex2f(237.5,120.0+i);
glVertex2f(217.5,95.0+i);
glVertex2f(237.5,95.0+i);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(237.5,20.0+i);
glVertex2f(217.5,20.0+i);
glVertex2f(237.5,70.0+i);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(262.5,20.0+i);
glVertex2f(282.5,20.0+i);
glVertex2f(262.5,70.0+i);
glEnd();
glBegin(GL_POLYGON);
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);
glVertex2f(237.5,20.0+i);
glVertex2f(244.5,20.0+i);
glVertex2f(241,0.0+i);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(246.5,20.0+i);
glVertex2f(253.5,20.0+i);

DEPT OF CSE(SEACET) 2022-2023 22


ROCKET LAUNCHING

glVertex2f(249.5,0.0+i);
glEnd();
glBegin(GL_POLYGON);
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 rocket_in_motion()
{
count++;

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;
}

}
els
e
{

glClearColor(0.196078 ,0.6 ,0.8,1.0);


glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
}
if(count>=100)
mars(20.0);
glColor3f(0.8,0.498039 ,0.196078);
glBegin(GL_POLYGON);
glVertex2f(237.5,20.0+i);
glVertex2f(262.5,20.0+i);
glVertex2f(262.5,120.0+i);
glVertex2f(237.5,120.0+i);

glEnd();

DEPT OF CSE(SEACET) 2022-2023 23


ROCKET LAUNCHING

glColor3f(1.0,1.0,1.0);

DEPT OF CSE(SEACET) 2022-2023 24


ROCKET LAUNCHING

glBegin(GL_POLYGON);
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);
glVertex2f(237.5,120.0+i);
glVertex2f(217.5,95.0+i);
glVertex2f(237.5,95.0+i);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(237.5,20.0+i);
glVertex2f(217.5,20.0+i);
glVertex2f(237.5,70.0+i);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(262.5,20.0+i);
glVertex2f(282.5,20.0+i);
glVertex2f(262.5,70.0+i);
glEnd();
glBegin(GL_POLYGON);
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);
glVertex2f(237.5,20.0+i);
glVertex2f(244.5,20.0+i);
glVertex2f(241,0.0+i);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(246.5,20.0+i);
glVertex2f(253.5,20.0+i);
glVertex2f(249.5,0.0+i);
glEnd();
glBegin(GL_POLYGON);
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++)

DEPT OF CSE(SEACET) 2022-2023 25


ROCKET LAUNCHING

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

*radius);
}

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

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

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

void createGLUTMenus() {

glutAddMenuEntry("LAUNCH",1);

glutAddMenuEntry("EXIT",2);

glutAttachMenu(GLUT_RIGHT_BUTTON);
}

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


{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(500,500);
glutCreateWindow("rocket");

glutIdleFunc(display1);
glutDisplayFunc(display1);

myinit();

glutMainLoop();
return 0;
}

DEPT OF CSE(SEACET) 2022-2023 26


ROCKET LAUNCHING

Chapter 8

BIBLIOGRAPHY

Book References:
 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.

Web References:
www.opengl.org
www.sourcecode.com

DEPT OF CSE(SEACET) 2022-2023 27

You might also like