intro.doc

34
Paper planes INTRODUCTION Computer graphics is concerned with all aspects of producing pictures or images using 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 field began humbly almost 50 years ago, with the display of a few lines on a cathode ray tube(CRT).We can create images by computer that are indistinguishable from photographs of real objects. History The phrase “Computer Graphics” was coined in 1960 by William Fetter, a graphic designer for Boeing. The field of computer graphics developed with the emergence of computer graphics hardware. The term computer graphics includes almost everything on computers that is not text or sound. Today almost every computer can do some graphics, and people have Department of CSE,TOCE Page 1

Upload: bhavankrishna

Post on 24-Dec-2015

2 views

Category:

Documents


0 download

TRANSCRIPT

Paper planes

INTRODUCTION

Computer graphics is concerned with all aspects of producing pictures or images using 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 field began humbly almost 50 years ago, with the display of a few lines on a cathode

ray tube(CRT).We can create images by computer that are indistinguishable from

photographs of real objects.

History

The phrase “Computer Graphics” was coined in 1960 by William Fetter, a graphic designer

for Boeing. The field of computer graphics developed with the emergence of computer

graphics hardware. The term computer graphics includes almost everything on computers that

is not text or sound. Today almost every computer can do some graphics, and people have

even come to expect to control their computer through icons and pictures rather than just by

typing. Although the term often refers to three-dimensional computer graphics, it also

encompasses two-dimensional graphics and image processing. OpenGL is an operating

system and hardware platform independent graphics library designed to be easily portable yet

rapidly executable.

Department of CSE,TOCE

Page 1

Paper planes

Applications

We think of computer graphics as drawing pictures on computers, also called rendering. The

pictures can be photographs, drawings, movies, or simulations -- pictures of things which do

not yet exist and maybe could never exist or they may be pictures from places we cannot see

directly, such as medical images from inside your body.

The areas where computer graphics is widely used is in massive multiplier games that can

involve tens of thousands of concurrent participants, to train pilots with simulated airplanes,

feature-length movies made entirely by computers have been successful both critically and

financially. Although computer graphics is a vast field that encompasses almost any graphical

aspect, we are mainly interested in the generation of images of 3-dimensional scenes.

Computer imagery has applications for film special effects, simulation and training, games,

medical imagery, flying logos, etc

Department of CSE,TOCE

Page 2

Paper planes

BASIC DRAWING TOOLS

OpenGL API:

OpenGL (Open Graphics Library) is a standard specification defining a cross-language,

cross- platform API for writing applications that produce 2D and 3D computer graphics.

OpenGL was developed by Silicon Graphics Inc. (SGI) in 1992 and is widely used in CAD,

virtual reality, scientific visualization, information visualization, and flight simulation.

OpenGL is managed by the non-profit technology consortium, the Khronos group.

OpenGL serves two main purposes:

To hide the complexities of interfacing with different 3D accelerators, by presenting

the programmer with a single, uniform API.

To hide the differing capabilities of hardware platforms, by requiring that all

implementations support the full OpenGL feature set (using software emulation if

necessary).

OpenGL's basic operation is to accept primitives such as points, lines and polygons, and

convert them into pixels. Most OpenGL commands either issue primitives to the graphics

pipeline, or configure how the pipeline processes these primitives.

Department of CSE,TOCE

Page 3

Paper planes

GLUT-Open GL Utility Kit

GLUT is the OpenGL Utility Toolkit, a window system independent toolkit for writing

OpenGL programs. It implements a simple windowing application programming interface

(API) for OpenGL. GLUT makes it considerably easier to learn about and explore OpenGL

programming. GLUT provides a portable API so you can write a single OpenGL program

that works across all PC and workstation OS platforms.

GLUT is designed for constructing small to medium sized OpenGL programs. While GLUT

is well-suited to learning OpenGL and developing simple OpenGL applications, GLUT is not

a full-featured toolkit so large applications requiring sophisticated user interfaces are better

off using native window system toolkits. GLUT is simple, easy, and small.

The GLUT library has both C and C++ (same as C), FORTRAN, and Ada programming

bindings. The GLUT source code distribution is portable to nearly all OpenGL

implementations and platforms. The current version is 3.7. Additional releases of the library

are not anticipated. GLUT is not open source.

Most of our applications will be designed to access OpenGL directly through functions in

three libraries. Functions in the main GL library have names that begin with the letters gl and

are stored in a library usually referred as GL.The second is the OpenGL Utility Library

(GLU). This library uses only GL functions but contains code for creating common objects

and simplifying viewing.

To interface with the window system and to get input from external devices into our

programs, we need atleast one library. For the X window systemws, it is wall etc

GLUT will use GLX and X libraries.

#include<GL/glut.h>

OR

#include<GLUT/glut.h>

Department of CSE,TOCE

Page 4

Paper planes

HEADER FILES

In our application, we use four header files: glut.h ,stdio.h,unistd.h and math.h

In glut.h header we use,

glEnable

glShadeModel

glClear

glLightfv

glMaterialfv

glRotatef

glTranslatef

glColor3f

glMatrixMode

glutSolidSphere

glutSwapBuffers

glutInit

glutDisplayFunc

glutReshapeFunc

glutMouseFunc

glutKeyboardFunc

glutBitmapCharacter

glLoadIdentity

glutCreateMenu

SYSTEM REQUIREMENTSDepartment of CSE,TOCE

Page 5

Paper planes

System requirements are intended to communicate in precise way, the functions that the

system must provide. To reduce ambiguity, they may be written in a structured form of

natural language supplemented by tables and system models.

HARDWARE REQUIREMENTS:

The physical components required are:

Processor - Pentium Pro

2.0 GHz CPU

Memory - 128MB RAM

40 GB Hard Disk Drive

Mouse or other pointing device

Keyboard

SOFTWARE REQUIREMENTS:

The softwares used in building this program are as specified:

Operating system - Windows XP

Microsoft Visual C++ editor.

Compiler - C++ Compiler.

Graphics Library - glut.h

Open GL 2.0

FUNCTIONAL REQUIREMENTS:

glLoadIdentity ():-Sets the current transformation matrix to an identity matrix.

Department of CSE,TOCE

Page 6

Paper planes

glPushMatrix ():

glPopMatrix ():-Pushes to and pops from matrix stack corresponding to the current matrix

mode.

glMatrixMode (GLenum mode):-Specifies which matrix will be affected by subsequent

transformation.

GL_MODELVIEW, GL_PROJECTION.

glRotate[fd](TYPE angle,TYPE dx,TYPE dy,TYPE dz):-Multiplies the current

matrix that rotates, objects the angle parameter and specifies the angle of rotation in degrees.

glTranslate[fd](TYPE x, TYPE y, TYPE z):-Multiplies the current matrix by a matrix

that moves an object by the given x,y,z values.

glutPostRedisplay();-Requests that the display callback be executed after the current

callback returns.

glutDisplayFunc(void (*func)(void)):-Registers the display function func that is

executed after the callback returns.

glutKeyboardFunc(void *f(char key,int width,int height)):- Registers the keyboard

function f. the callback function returns the ASCII code of the key pressed and the position of

the mouse.

glFlush():- Forces any buffered OpenGL commands to execute.

glutSolidSphere( TYPE radius, TYPE slices, TYPE stack):- Draws a solid sphere

of given radius.

glutSwapBuffers():- Swaps front and back buffers.

Department of CSE,TOCE

Page 7

Paper planes

glEnable (GLenum features):-

glEnable (GL_DEPTH_TEST):- This function enables depth test for hidden surface

removal.

FLOWCHART

Department of CSE,TOCE

Page 8

Start

Paper planes

ANALYSIS AND DESIGN

Department of CSE,TOCE

Page 9

Output Window

Stop

Remove Plane

Add Plane Motion

On/Off

Paper planes

ALGORITHM:

Step 1:Start.

Step 2: Standard GLUT initialization.

Step 3:Set the display mode.

Step 4:Create the Window.

Step 5:Display function callback.

Step 6:Activating the Keyboard.

Step 7:Callback to the visibility function.

Step 8:Create the menu with options to add a plane, removing a plane, motion on/off and to

quit.

Step 9:Clear the depth buffer.

Step 10: Clear the background color.

Step11: Set the matrix to Projection mode.

Step 12: Call glFrustum function.

Step 13: Set the matrix to Modelview mode.

Step 14: Add three planes initially by calling add_plane() function thrice.

Step 15: Enter to event processing loop by calling glutMainLoop() function.

Step16:Stop

IMPLEMENTATION

Department of CSE,TOCE

Page 10

Paper planes

User Defined Functions:

animate(): This function calls another function tick() and initializes glutPostRedisplay().

draw(): This function paints the background from black to blue shade color with smooth

shade. It also draws the plane with right and left wings ,tip and other properties.

Keyboard():-This function makes use of keyboard keys,space key is used for a unit

moment of planes and Esc key is used to exit from output window.

main(): This function initializes the standard GLUT library along with callbacks to all the

other user defined functions through display callback. Here is where the program starts

executing.

menu(): This function creates a user friendly menu on the output window. It can be

implemented using mouse. It has four options, to add a plane, to remove a plane, to start/stop

the motion of the planes and to quit.

add_plane(): This function adds a plane if the total planes count is not greater then 15. The

color and speed of the plane is set randomly. Color of the planes may be either of Red, White,

Green, Magenta, Yellow or Cyan.

remove_plane(): This function removes a plane if there is/are any. It removes the

previously added plane. It is independent of the movement of planes.

tick(): This function calls tick_per_plane() function for all the planes.

tick_per_plane(): This function sets the angle for the plane moment. It also specifies the

movement of planes in X, Y and Z axes, i.e; in three dimension.

TESTING

Department of CSE,TOCE

Page 11

Paper planes

Testing process started with the testing of individual program units such as functions or

objects. These were then integrated into sub-systems and systems, and interactions of

these units were tested.

Testing involves verification and validation.

Validation: “Are we building the right product?”

Verification: “Are we building the product right?”

The ultimate goal of the verification and validation process is to establish confidence

that the software system is ‘fit for purpose’. The level of required confidence depends on

the system’s purpose, the expectations of the system users and the current marketing

environment for the system:

Software functions, User expectations, Marketing environment.With the verification and

validation process, there are two complementary approaches to the system checking and

analysis:

Software inspections or peer reviews analyses and check system representations such as

the requirements document, design diagrams, and the program source code. Software testing

involves running an implementation of the software with test data

There are two distinct types of testing that may be used at different stages in the software

process:

Validation testing is intended to show that the software is what the customer wants-that it

meets its requirements. Defect testing is intended to reveal defects in the system rather than to

simulate its operational use

TEST CASES

Department of CSE,TOCE

Page 12

Paper planes

OBEJCTIVE OUTPUT RESULT

1 To add a plane Planes count

increased by 1

PASS

2 To remove a plane Planes count

decrease by 1

PASS

3 To make the plane

move

Planes started

moving randomly

PASS

SNAPSHOT

Department of CSE,TOCE

Page 13

Paper planes

Showing menu to add plane

Showing menu to remove plane

Department of CSE,TOCE

Page 14

Paper planes

Showing menu to motion off

Showing menu to Quit

Department of CSE,TOCE

Page 15

Paper planes

Conclusion

We started with modest aim with no prior experience in any programming projects as this,

but ended up in learning many things, fine tuning the programming skills and getting into the

real world of software development with an exposure to corporate environment. During the

development of any software of significant utility, we are forced with the tradeoff between

speed of execution and amount of memory consumed. This is simple interactive

application. It is extremely user friendly and has the features, which makes simple graphics

project. It has an open source and no security features has been included. The user is free to

alter the code for feature enhancement. Checking and verification of all possible types of the

functions are taken care. Care was taken to avoid bugs. Bugs may be reported to creator as

the need.

Future Enhancement:

The future enhancement of paper planes project is to have bigger planes, to have 3D view of

the plane, to get the shadow of each planes and to rotate each plane in opposite direction as

well as reverse direction.

Department of CSE,TOCE

Page 16

Paper planes

BIBLIOGRAPHY

1. Interactive Computer Graphics - A top down approach with OpenGL.

-Edward Angel, 5th Edition, Addison Wesley, 2008

Department of CSE,TOCE

Page 17

Paper planes

Department of CSE,TOCE

Page 18

Paper planes

Department of CSE,TOCE

Page 19

Paper planes

Department of CSE,TOCE

Page 20

Paper planes

Department of CSE,TOCE

Page 21

Paper planes

Department of CSE,TOCE

Page 22

Paper planes

Department of CSE,TOCE

Page 23

Paper planes

Department of CSE,TOCE

Page 24

Paper planes

Department of CSE,TOCE

Page 25

Paper planes

Department of CSE,TOCE

Page 26

Paper planes

Department of CSE,TOCE

Page 27

Paper planes

Department of CSE,TOCE

Page 28