Simulation of Rocket CG Project Using OpenGL Report
Simulation of Rocket CG Project Using OpenGL Report
CONTENTS
Abstract
When the final capsule reached the orbiting location the last part is
also disconnected and the satellite is placed in orbit.
We have used input device keyboard to interact with the program
System specifications
SOFTWARE REQUIREMENTS :
HARDWARE REQUIREMENT :
GRAPHICS SYSTEM,
Pentium P4 with 256 of Ram(Min)
Introduction to openGL
As a software interface for graphics hardware, OpenGL's main purpose is to
render two- and three-dimensional objects into a frame buffer.
These objects are described as sequences of vertices or pixels.
OpenGL performs several processing steps on this data to convert it to pixels to
form the final desired image in the frame buffer.
OpenGL Fundamentals
This section explains some of the concepts inherent in OpenGL.
As shown by the first block in the diagram, rather than having all commands
proceed immediately through the pipeline, you can choose to accumulate
some of them in a display list for processing at a later time.
All elements of OpenGL state, including the contents of the texture memory
and even of the frame buffer, can be obtained by an OpenGL application.
Implementation
This program is implemented using various openGL functions which are
shown below.
Q-> Quit
Source Code
#include <windows.h>
#include<string.h>
#include<stdarg.h>
#include<stdio.h>
#include <glut.h>
void
va_list args;
va_start(args, format);
va_end(args);
glPushMatrix();
glTranslatef(-2.5, y, 0);
glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
glPopMatrix();
void satellite(){
glPushMatrix();
//Core
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,2,0);
glScaled(0.3,1,0.3);
glRotatef(90,1,0,0);
if(x<=6)
glutSolidTorus(0.5,1,30,30);
else
glutSolidCube(1);
glPopMatrix();
// Solar Panel
glPushMatrix();
glColor3f(0.2,0.2,0.2);
glTranslatef(1,2,0);
if(x>=6){
glScaled(4,1.5,0.1);
else
glScaled(0,0,0);
glRotatef(-20,1,0,0);
glutSolidCube(0.5);
glPopMatrix();
glPushMatrix();
glColor3f(0.2,0.2,0.2);
glTranslatef(-1,2,0);
if(x>=6){
glScaled(4,1.5,0.1);
else
glScaled(0,0,0);
glRotatef(-20,1,0,0);
glutSolidCube(0.5);
glPopMatrix();
glPopMatrix();
void rocket(){
glPushMatrix();
if(x>=5.5){
glTranslatef(z2,-z2,z2);
glRotatef(a1,0,1,1);
glPushMatrix();
glTranslatef(0,2.5,0);
glColor3f(0,0,1);
glScaled(2.2 ,1.5,2.2);
glRotatef(270,1,0,0);
glutSolidCone(0.2,1,30,30);
glPopMatrix();
glPopMatrix();
// Satelitte container
glPushMatrix();
if(x>=6.8){
glTranslatef(2,0,0);
glRotatef(x*40,0,1,0);
satellite();
glPopMatrix();
glPushMatrix();
if(x>=5){
glTranslatef(0,y2,y2);
glRotatef(a1,0,1,1);
glPushMatrix();
glColor3f(1,1,1);
glTranslatef(0,0.0,0);
glScaled(0.3,4.3,0.3);
glRotatef(90,1,0,0);
glutSolidTorus(0.5,1,30,30);
glPopMatrix();
glPushMatrix();
glTranslatef(0,-2.2,0);
glColor3f(0,0,1);
glScaled(3,1.5,3);
glRotatef(270,1,0,0);
glutSolidCone(0.2,1,30,30);
glPopMatrix();
glPopMatrix();
// RightSide rocket
glPushMatrix();
glTranslatef(x1,-y1,z1);
glRotatef(a1,0,1,1);
glPushMatrix();
glTranslatef(0.7,1,0);
glColor3f(0,0,1);
glScaled(1.5 ,1,1.5);
glRotatef(270,1,0,0);
glutSolidCone(0.2,1,30,30);
glPopMatrix();
glPushMatrix();
glTranslatef(0.7,-0.2,0);
glColor3f(0,1,1);
glScaled(0.2,6.5,0.2);
glRotatef(90,1,0,0);
glutSolidTorus(0.2,1,30,30);
glPopMatrix();
glPushMatrix();
glTranslatef(0.7,-2.0,0);
glColor3f(0,0,1);
glScaled(1.5,1,1.5);
glRotatef(270,1,0,0);
glutSolidCone(0.2,1,30,30);
glPopMatrix();
glPopMatrix();
// LeftSide rocket
glPushMatrix();
glTranslatef(-x1,-y1,-z1);
glRotatef(-a1,0,1,1);
glPushMatrix();
glTranslatef(-0.7,1,0);
glColor3f(0,0,1);
glScaled(1.5 ,1,1.5);
glRotatef(270,1,0,0);
glutSolidCone(0.2,1,30,30);
glPopMatrix();
glPushMatrix();
glTranslatef(-0.7,-0.2,0);
glColor3f(0,1,1);
glScaled(0.2,6.5,0.2);
glRotatef(90,1,0,0);
glutSolidTorus(0.2,1,30,30);
glPopMatrix();
glPushMatrix();
glTranslatef(-0.7,-2.0,0);
glColor3f(0,0,1);
glScaled(1.5,1,1.5);
glRotatef(270,1,0,0);
glutSolidCone(0.2,1,30,30);
glPopMatrix();
//booster
/*
glPushMatrix();
glTranslatef(2,0,0);
glColor3f(1,1,0);
glBegin(GL_POLYGON);
glVertex3f(0,0,0);
glVertex3f(1,0,0);
glVertex3f(0.8,-1,0);
glVertex3f(0,0,0);
glEnd();
glPopMatrix();
glPopMatrix();
void stars(){
for(float s2=-6;s2<=6;s2+=0.5){
glPushMatrix();
glBegin(GL_POINTS);
glVertex3f(s2,s1,0);
glEnd();
glPopMatrix();
for(float s4=-6.2;s4<=6;s4+=0.3){
glPushMatrix();
glBegin(GL_POINTS);
glVertex3f(s4,s3,0);
glEnd();
glPopMatrix();
// Draw rocket
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
//glRotatef(ang,0.0f,1.0f,0.0f);
glPushMatrix();
if(ang<=2){
glRotatef(ang*30,1,0,0);
glTranslatef(0,-2+ang,0);
else{
glRotatef(60,1,0,0);
glTranslatef(0,0,0);
glScaled(0.5,0.5,0.5);
rocket();
glPopMatrix();
//Earth
glPushMatrix();
glColor3f(0,0,1);
if(x>=6.5){
glTranslatef(0,-18,-95);
glRotatef(10*x,0,1,0);
}else{
glTranslatef(0,-10-x,-10-15*x);
glutSolidSphere(10,100,100);
glPopMatrix();
// Create Stars
glPushMatrix();
glColor3f(1,1,1);
glTranslatef(0,-ang,0);
stars();
glPopMatrix();
glFlush();
glutSwapBuffers();
void p()
x+=0.01;
if(x>=3){
x1+=0.1;
y1+=0.1;
z1+=0.01;
a1+=3;
if(x>5){
y2-=0.1;
if(x>5.5){
z2+=0.1;
rocket(x);
void doInit()
glClearColor(0.0,0.0,0.0,0);
glViewport(0,0,640,480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(30.0f,(GLfloat)640/(GLfloat)480,0.1f,200.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearDepth(2.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
void display()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-13.0f);
GLfloat mat_ambient[]={0.0f,1.0f,2.0f,1.0f};
GLfloat mat_diffuse[]={0.0f,1.5f,.5f,1.0f};
GLfloat mat_specular[]={5.0f,1.0f,1.0f,1.0f};
GLfloat mat_shininess[]={50.0f};
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
GLfloat lightIntensity[]={1.7f,1.7f,1.7f,1.0f};
GLfloat light_position3[]={0.0f,5.0f,0.0f,0.0f};
glLightfv(GL_LIGHT0,GL_POSITION,light_position3);
glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity);
glEnable(GL_COLOR_MATERIAL);
glFlush();
glutSwapBuffers();
switch(id)
case 2:glutIdleFunc(p);
break;
case 5:exit(0);
break;
glFlush();
glutSwapBuffers();
glutPostRedisplay();
if(key=='p')
glutIdleFunc(p);
if(key=='q'||key=='Q')
exit(0);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(1000,480);
glutInitWindowPosition(0,0);
glutCreateWindow("rocket");
glutDisplayFunc(display);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glutKeyboardFunc(mykey);
glutCreateMenu(menu);
glutAddMenuEntry("Launch 'p'",1);
glutAddMenuEntry("Quit 'q'",5);
glutAttachMenu(GLUT_RIGHT_BUTTON);
doInit();
glutMainLoop();
return 0;
Conclusions
Finally we conclude that this program clearly illustrate the Rocket launch by
using OpenGL and pre-built objects and has been completed successfully and
is ready to be demonstrated.
Bibliography
WE HAVE OBTAINED INFORMATION FROM MANY RESOURCES TO DESIGN AND
IMPLEMENT OUR PROJECT SUCCESSIVELY. WE HAVE ACQUIRED MOST OF THE
KNOWLEDGE FROM RELATED WEBSITES. THE FOLLOWING ARE SOME OF THE
RESOURCES :
TEXT BOOKS :
INTERACTIVE COMPUTER GRAPHICS A TOP-DOWN APPROACH
-By Edward Angel.
- Feiner hughes
WEB REFERENCES:
http://jerome.jouvie.free.fr/OpenGl/Lessons/Lesson3.php
http://google.com
http://opengl.org