+ All Categories
Home > Documents > Own Project

Own Project

Date post: 03-Jun-2018
Category:
Upload: surya-prakash-singh
View: 217 times
Download: 0 times
Share this document with a friend

of 23

Transcript
  • 8/11/2019 Own Project

    1/23

    Boundary Simulation

    Department of CSE Page 1

    CHAPTER 1

    INTRODUCTION

    Computer Graphics is concerned with all aspects of producing pictures or images using

    a computer. Interactive Computer Graphics (ICG) involves two way communications between

    the user and the computer.

    1.1 Aim of the Project

    The aim of project is how to use the GLU polygon tessellator to determine the 2D

    boundary of OpenGL rendered objects.

    1.2Project Description

    The project boundary simulation is implemented on the basic platform OpenGL which

    included in our curriculum. This project is developed using various APIs. This project makes use of

    library called as GLUT.

    The basic concept of the project involves the use of various textures and primitives to design different

    screen savers. The user is provided with a menu which can be viewed by right clicking the mouse. The

    project is coded for various options which can be done by right clicking the mouse on previously

    developed pattern. Various options present in the menu are:

    Torus: select a torus object.

    Cube:select a cube object.

    Sphere:select a sphere object.

    Icosahedron:select a icosahedrons object.

    Teapot:select the teapot.

    Change dimension:change the dimension of object from 2D to 3D and vice versa.

    Exit:exit from the window.

  • 8/11/2019 Own Project

    2/23

    Boundary Simulation

    Department of CSE Page 2

    1.3 COMPUTER GRAPHICS

    The dominant characteristic of this new millennium is how computer and communication

    technologies have become dominant forces in our life. Activities as wideranging as

    filmmaking, publishing, banking, and education continue to undergo revolutionary changes as

    these technologies alter the ways in which we conduct our daily activities. The combination of

    computers, networks, and the complex visual systems, through computer graphics, has led to

    new ways of displaying information, seeing virtual worlds and communicating with people and

    machines

    Computer graphics is concerned with all aspects of producing pictures or images using a

    computer. The field began humbly almost 50 years ago, with a display of few lines on a

    cathode-ray-tube; now, we can create images by computer that are indistinguishable from

    photographs of real objects. We routinely train pilots with simulated airplanes, generating

    graphical displays of a virtual environment of real time. Featurelength movies made entirely

    by computer have been successful, both critically and financially. Massive multiplayer games

    can involve tens of thousands of concurrent participants.

    1.4

    APPLICATIONS OF COMPUTER GRAPHICS

    Display of information

    Design

    Simulation and animation

    User interfaces

    DISPLAY OF INFORMATION

    Classical graphics technique arose as a medium to convey information among people. We have

    computer plotting packages that provide a variety of plotting techniques and color tools that

    can handle multiple large data sets.

    The field of information visualization is becoming increasingly more important as we

    have to deal with understanding complex phenomena from problems in bioinformatics

    to detecting security threats.

    The field of scientific visualization provides graphical tools that help the researchersinterpret the fast quantity of data that they generate.

  • 8/11/2019 Own Project

    3/23

    Boundary Simulation

    Department of CSE Page 3

    Medical imaging posses interesting and important data analysis problems. Modern

    imaging technologies such as computed tomography (CT), magnetic resonance imaging

    (MRI), ultrasound and positron emission tomography (PET)-generate 3D data that must

    be subjected to algorithmic manipulation to provide useful information.

    DESIGN

    Professions such as engineering and architectures are concerned with design. Starting

    with a set of specifications, engineers and architects seek a cost effective and esthetical

    solution that satisfies the specifications.

    The use of interactive graphical tools in computer aided design (CAD) pervades fields

    including as architecture , medical engineering , the design of very-large-scale

    integrated (VLSI) circuits, and the creation of characters for animation.

    SIMULATION AND ANIMATION

    Graphics system evolved to be capable of generating sophisticated images in real

    time, engineers and researchers began to use them as simulators. One of the most

    important uses has been in the training of pilots. The use of special PLSI chips has led

    to a generation of arcade, games as sophisticated as flight simulators.

    The simulator can be used for designing the robot, planning its path, and simulating its

    behaviour in complex environment. The success of flight simulators led to the use of

    computer graphics for animation in the TV, motion picture and advertising industries.

    Entire animated movies can now be made by computers at a cost less than that of

    movies made with tradition hand animation techniques.

    The graphic technology for games, both in the form of the graphics processing units

    that are on graphics cards in personal computers and in game boxes such as the Xbox

    and the play stations, is being used for simulation rather than expensive specialized

    hardware.

    USER INTERFACES

    Our interaction with computers has become dominated by a visual paradigm that includes

    windows, icons, menus and a pointing device such as a mouse. From users perspective,

    winding system such as the X window system, Microsoft windows, and the Macintosh Os x

    defer only in derails

  • 8/11/2019 Own Project

    4/23

    Boundary Simulation

    Department of CSE Page 4

    Millions of people have become Internet users. Their access is through graphical

    network browsers, such as Firefox and Internet explorer. Although we are familiar with

    style of graphical user interface used on most workstations, advances in computer

    graphics have made possible other forms of interfaces. OpenGL doesn't provide high-level commands for describing models of three-

    dimensional objects. Such commands might allow you to specify relatively complicated

    shapes such as automobiles, parts of the body, airplanes, or molecules.

    With OpenGL, you must build up your desired model from a small set ofgeometric

    primitives- points, lines, and polygons.

    program

    Figure1.1 Application Programmers Model of Graphics System

    The interface between an application program and a graphics system can be specified

    through a set of functions the resides in a graphics library .These specification are

    called the application programmers interface (API).The application programmers

    model of the system is shown in Figure 1.1. The application programmer sees only the

    API and is thus shielded from the details of both the hardware and the software

    implementation of the graphics library.

    1.5 OPENGL

    OpenGL is a library of functions for fast 3D rendering. OpenGL does not have any way to

    obtain input from user. As a software interface for graphic hardware OpenGL main purpose is

    to render 2D and 3D objects into frame buffer. These objects are described as a sequence of

    vertices or pixels. OpenGL performs several processing steps of these data to convert it into

    pixel to form the final desired image in the frame buffer.

    Application

    program

    Graphics

    library

    (API)

    DriversMouse

    Display

  • 8/11/2019 Own Project

    5/23

    Boundary Simulation

    Department of CSE Page 5

    OpenGL is a hardware and system independent interface. An OpenGL application will work on

    every platform as long as there as an installed implementation. Because their systemsindependent there are no function to create windows etc, but there are helper functions for each

    platform. A very useful thing is GLUT.

    1.5.1 GLUT

    It is a complete API written by Mark Kilgard, which lets us create windows and handle

    the messages. It exists for several platforms that mean that a program, which uses GLUT,

    can be compiled on many platforms without any changes in the code.

    Figure 1.2 Library organization

    ADDITIONAL LIBRARIES

    There are two libraries that we have that came with OpenGL:

    1: GLU: It is a set of utility functions. They are easy way of doing things that is tedious with

    raw OpenGL.

    2: GLX: It allows you to open up X window and link it up with OpenGL so that it will draw to

    that window.

    OpenGL

    application

    GLU

    GL

    GLUT

    GLX

    Xlib, Xtk Frame

    Buffer

  • 8/11/2019 Own Project

    6/23

    Boundary Simulation

    Department of CSE Page 6

    HOW OPENGL WORKS

    To be hardware independent OpenGL provides its own data types. They all begin with GL.

    Example: GLfloat, Glint

    There are also many symbolic constants ;they all begin with GL,like

    GL_POINTS,GL_POLYGON.

    Finally commands have prefix gl. Example: glVertex3f.

    OPENGL VERSION AND EXTENSIONS

    One of the main features of OpenGL is that the API has been very stable there were upgrades

    from OpenGL 1.0 through OpenGL 1.5 that were released over a 10-year period, each of which

    was compatible with previous releases. OpenGL 2.0, which was released in 2004, was a major

    upgrade but still retains code compatibility with earlier versions. The current release is

    OpenGL 2.1. Thus, any program written on an older version of OpenGL runs as expected on

    later version. Changes to OpenGL reflect advances in hardware that became common to many

    graphics processors

    1.6 Graphics Function

    Function calls Outputs

    Data Input

    Figure 1.3

    Our basic model of a graphics package is a black box, a term that engineers use to

    denote a system whose properties are described only by its inputs and outputs. We describe an

    API through the functions in its library. Some of the functions are:

    The primitive functions define the low-level objects or atomic entities that our system

    can display.

    Attribute functions allow us to perform operations ranging from choosing the color

    with which we display a line segment, to picking a pattern with which to fill the inside

    of a polygon, to selecting a typeface for the titles of a graph.

    Application

    programs

    Graphics

    system

    ip /op

    devices

  • 8/11/2019 Own Project

    7/23

    Boundary Simulation

    Department of CSE Page 7

    Transformation function allows carrying out transformations of objects, such as

    rotation, translation, and scaling.

    A set of input functions allow us to deal with the diverse forms of input that

    characterize modern graphics systems. The control functions enable us to communicate with the window systems, to initialize

    our programs, and to deal with any errors that take place during the execution of

    programs.

  • 8/11/2019 Own Project

    8/23

    Boundary Simulation

    Department of CSE Page 8

    CHAPTER 2

    REQUIREMENT SPECIFICATION

    A software requirement definition is an abstract description of the services which thesystem should provide, and the constraints under which the system must operate. It should only

    specify the external behaviour of the system.

    2.1 Functional Requirements

    Functional Requirements defines the internal working of the software, i.e., the

    calculations, technical details, data manipulation and processing and other specific

    functionality that show how the cases are to be satisfied and how they are supported by non-

    functional requirements, which impose constraints on the design or the implementation.

    The following are the Functional requirements

    The ability to display the menu when the ENTER button is clicked.

    When the corresponding menu is selected, the corresponding option should be

    performed.

    Move the vehicle only when green light is on .

    Stop the vehicle when red light is on .

    Provide the signal simulation environment to the user .

    2.2 Non Functional Requirements

    Nonfunctional requirements are requirements which specify criteria that can be used to

    judge the operation of the system, rather than specific behaviors. This should be contrasted

    with functional requirements that specify specific behavior or functions. Typical nonfunctional

    requirements are reliability and scalability. Nonfunctional requirements are constraints,

    quality attributes and quality of service requirements.

    The following are the Non Functional Requirements:

    The application should provide a simple interface

  • 8/11/2019 Own Project

    9/23

    Boundary Simulation

    Department of CSE Page 9

    2.3 Software and Hardware Requirements

    Software Requirements

    1. OPERATING SYSTEM : Windows XP or Higher version

    2. FRONT END : Microsoft Visual Studio 2005(.NET 2.0).

    3.

    CODING LANGUAGE : C, C++

    Hardware Requirements

    This software requires a hardware requirement of a processor of speed 333 MHz, 32MB or

    above RAM capacity, a graphic card, a Keyboard and a min.100kb of hard disk space.

    1.

    SYSTEM : Pentium IV 2.4 GHz or above

    2. HARD DISK : 20 GB or above

    3. MONITOR : 15 VGA color

    4. RAM : 256 MB

    5. Micro Processor : Pentium 4

    6.

    keyboard : 1

    7. CPU Clock : 166MHZ Onwards

  • 8/11/2019 Own Project

    10/23

    Boundary Simulation

    Department of CSE Page 10

    CHAPTER 3

    DESIGN

    3.1 InitializationInitialize to interact with the windows. Initialize the display mode- double buffer and depth

    buffer. Initialize the various callback functions for creating 3d objects, mouse interface and

    keyboard interface, for displaying and selecting the interactive options, for selecting option

    from menu or to rotate the object. Initialize the window position and size and create the

    window to display the output.

    3.2 Flow of control

    Start

    Main

    Initialise openGL()

    Callback function.

    MENU

    C1

  • 8/11/2019 Own Project

    11/23

    Boundary Simulation

    Department of CSE Page 11

    \

    Figure 1.4 Flow chart

    TORUS

    CUBE

    ISOHEDRON

    TEAPOT

    CLOSE

    Display

    Solid torus

    Display

    Cube

    Display

    Tea pot

    Display

    Isohedron

    KEYBOARD

    up down left right

    Rotate

    upward

    Rotate

    down

    Rotate

    right

    Rotate

    left

    C1

    STOP

  • 8/11/2019 Own Project

    12/23

    Boundary Simulation

    Department of CSE Page 12

    CHAPTER 4

    IMPLEMENTATION

    To implement the current system we have used different functions of our project which are as

    follows:

    4.1 USER FUNCTIONS

    Render():is the process of generating an image from a model, by means of a software

    program. The model is a description of three dimensional objects in a strictly defined

    language or data structure. It would contain geometry, viewpoint, texture and lighting

    information.

    Display():the function is called by glutDisplayfunc(), this function enable and disable

    the lighting,depth test and cull_face according to the value of boundary.

    Special():This function gets the input from the keyboard and rotate the object in

    different axis . It checks for the keys such as up, down, left and right.

    determineBoundary(): this functionfind out the external edges (boundary) of the

    given object.

    Text():the function prints a text in the screan.

    Menu() :The function receive the value from the menu displayed on screan and do the

    task according to the case. And exits from the window when clicked on close.

    4.2 BUILT IN FUNCTIONS

    GlTranslate ():Alters the current matrix by a displacement of(x,y,z).TYPE is either

    GLfloat or GLdouble.

    glutCreateMenu():Returns an identifier for a top level menu and register the callback

    function f that returns an integer value corresponding to the menu entry selected.

    GlutAddMenuEntry ():glutAddMenuEntry adds a menu entry to the bottom of the

    current menu. The string name will be displayed for the newly added menu entry. If

    the menu entry is selected by the user, the menu's callback will be called passing value

    as the callback's parameter.

    GlLoadIdentity ():replaces the current matrix with the identity matrix. It issemantically equivalent to calling glLoadMatrix with the 4X4 identity matrix.

  • 8/11/2019 Own Project

    13/23

    Boundary Simulation

    Department of CSE Page 13

    GlClearColor (): specifies the red, green, blue, and alpha values used by glClear to

    clear the color buffers. Values specified by glClearColor are clamped to the range

    [0 1].

    GlMatrixMode ():sets the current matrix mode. mode can assume one of four values:

    GL_MODELVIEW-Applies subsequent matrix operations to the modelview

    matrix stack.

    GL_PROJECTION-Applies subsequent matrix operations to the projection

    matrix stack.

    GluPerspective (): specifies a viewing frustum into the world coordinate system. In

    general, the aspect ratio in gluPerspective should match the aspect ratio of the

    associated viewport.

    glDisable (): disable server-side GL capabilities.

    glEnable ():enable server-side GL capabilities.

    glutSolidTorus (): render a solid or wireframe torus (doughnut) respectively.

    glutSolidCube (): render a solid or wireframe cube respectively.

    glutSolidSphere (): Renders a sphere centered at the modeling coordinates origin of

    the specified radius.

    glutSolidIcosahedron (): This function draws a regular, solid 20-sided polyhedron

    centered at the origin. The distance from the origin to the vertices is 1.

    glutBitmapCharacter ():renders a bitmap character using OpenGL.

    gluTessBeginContour():delimit the definition of a polygon contour. Within each

    gluTessBeginContour /gluTessEndContourpair, there can be zero or more calls to

    gluTessVertex. The vertices specify a closed contour (the last vertex of each contour is

    automatically linked to the first.

    glFeedbackBuffer():function controls feedback. Feedback, like selection, is an

    OpenGL mode. The mode is selected by calling glRenderModewith

    GL_FEEDBACK. When OpenGL is in feedback mode, no pixels are produced by

    rasterization. Instead, information about primitives that would have been rasterized is

    fed back to the application using OpenGL.

    gluNewTess(): function creates and returns a pointer to a new tessellation object.

    Refer to this object when calling tessellation functions. A return value of zero means

    there is not enough memory to allocate to the object.

  • 8/11/2019 Own Project

    14/23

    Boundary Simulation

    Department of CSE Page 14

    GLU_TESS_BEGIN():The begin callback is invoked likeglBeginto indicate the start

    of a (triangle) primitive. The function takes a single argument of type GLenum. If the

    GLU_TESS_BOUNDARY_ONLYproperty is set to GL_FALSE, then the argument

    is set to either GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, orGL_TRIANGLES. If the GLU_TESS_BOUNDARY_ONLYproperty is set to

    GL_TRUE, then the argument will be set to GL_LINE_LOOP.

    glLightfv():this function is used to set up the properties of proper light souce.

    GLU_TESS_BOUNDARY_ONLY():Specifies a Boolean value (set value to

    GL_TRUE or GL_FALSE). When you set value to GL_TRUE, a set of closed contours

    separating the polygon interior and exterior is returned instead of a tessellation.

    Exterior contours are oriented counterclockwise with respect to the normal; interior

    contours are oriented clockwise. The GLU_TESS_BEGIN and

    GLU_TESS_BEGIN_DATA callbacks use the type GL_LINE_LOOP for each

    contour.

    http://publib.boulder.ibm.com/infocenter/pseries/v5r3/topic/com.ibm.aix.opengl/doc/openglrf/glBegin.htm#b5ae449820vbiahttp://publib.boulder.ibm.com/infocenter/pseries/v5r3/topic/com.ibm.aix.opengl/doc/openglrf/glBegin.htm#b5ae449820vbiahttp://publib.boulder.ibm.com/infocenter/pseries/v5r3/topic/com.ibm.aix.opengl/doc/openglrf/glBegin.htm#b5ae449820vbiahttp://publib.boulder.ibm.com/infocenter/pseries/v5r3/topic/com.ibm.aix.opengl/doc/openglrf/glBegin.htm#b5ae449820vbia
  • 8/11/2019 Own Project

    15/23

    Boundary Simulation

    Department of CSE Page 15

    CHAPTER 5

    TESTING

    Testing in general means validation and verification. It shows that the system

    conforms to its specifications and system meets all expectation of the user. It involves 5

    different kind of testing.

    5.1 TEST CASES FOR KEYBOARD:

    Sl

    No.

    Test case

    Description

    Expected Result Actual Result Remarks

    1. Press UP KEY Rotate the 3d object

    In upward direction

    Rotate the 3d object

    In upward direction

    PASS

    2. Press DOWN

    KEY

    Rotate the 3d object

    In left direction

    Rotate the 3d object

    In left direction

    PASS

    3. Press LEFT

    key

    Rotate the 3d object

    In left direction

    Rotate the 3d object

    In left direction

    PASS

    4. Press Right

    Key

    Rotate the 3d object

    In right direction

    Rotate the 3d object

    In right direction

    PASS

    Table1.1 test case for keyboard

  • 8/11/2019 Own Project

    16/23

    Boundary Simulation

    Department of CSE Page 16

    CHAPTER 6

    6.1 SNAPSHOTS

    Figure 1.5 Displaying menu when right clicked.

  • 8/11/2019 Own Project

    17/23

    Boundary Simulation

    Department of CSE Page 17

    Figure 1.6 3D view of cube

  • 8/11/2019 Own Project

    18/23

    Boundary Simulation

    Department of CSE Page 18

    The boundary of cube

  • 8/11/2019 Own Project

    19/23

    Boundary Simulation

    Department of CSE Page 19

    Figure 1.7 3D view of torus

  • 8/11/2019 Own Project

    20/23

    Boundary Simulation

    Department of CSE Page 20

    Figure 1.8 boundary of the torus.

  • 8/11/2019 Own Project

    21/23

    Boundary Simulation

    Department of CSE Page 21

    CHAPTER 7

    CONCLUSION

    The project BOUNDARY SIMULATION has many features in it which uses maximum

    concepts provided in OpenGL such as lighting, shading, viewing, rendering etc. It has been

    provided with simple interfaces so that the user can use it without the thorough knowledge of

    OpenGL.

    This is very reliable graphics package supporting various primitive objects like polygon,

    line loops, etc. Also color selection, menu, keyboard based interface are included.

  • 8/11/2019 Own Project

    22/23

    Boundary Simulation

    Department of CSE Page 22

    CHAPTER 8

    FUTURE ENHANCEMENTS

    In this package we may consider the further enhancements like-

    We can change the pattern some different textures.

    Different colors can be implemented for the objects.

    The objects size can be increased and decreased.

    Add different types of lighting can be used.

    Object can be moved in different directions

    Different viewing can be used.

  • 8/11/2019 Own Project

    23/23

    Boundary Simulation

    CHAPTER 9

    BIBLIOGRAPHY

    Book References:[1] Edward AngelsInteractive Computer Graphics Pearson Edition 5th2007

    [2] EditionM.Baumann OpenGL Programming with Glut. First Edition

    [3] Yeshwant KanetkarComputer Graphics with C. Third Edition

    Websites:

    [4] http://www.opengl.org

    [5]http://www.wikipedia.com


Recommended