Interactive OpenGL Animation

Similar documents
Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

Rasterization Overview

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Viewing with Computers (OpenGL)

CS 4620 Program 3: Pipeline

CS 130 Final. Fall 2015

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

Chapter 5. Projections and Rendering

OpenGL Transformations

A simple OpenGL animation Due: Wednesday, January 27 at 4pm

Lecture 4 Advanced Computer Graphics (CS & SE )

Motivation. Culling Don t draw what you can t see! What can t we see? Low-level Culling

CS 184: Assignment 2 Scene Viewer

Homework #2 and #3 Due Friday, October 12 th and Friday, October 19 th

CS451Real-time Rendering Pipeline

CS4202: Test. 1. Write the letter corresponding to the library name next to the statement or statements that describe library.

CCSI 3161 Project Flight Simulator

Overview. By end of the week:

Models and Architectures

CS 381 Computer Graphics, Fall 2012 Midterm Exam Solutions. The Midterm Exam was given in class on Tuesday, October 16, 2012.

CHAPTER 1 Graphics Systems and Models 3

Lecturer Athanasios Nikolaidis

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

BCC Sphere Transition

Shading and Texturing Due: Friday, Feb 17 at 6:00pm

Computer Science 474 Spring 2010 Viewing Transformation

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

Raycasting. Chapter Raycasting foundations. When you look at an object, like the ball in the picture to the left, what do

Computer Graphics: Programming, Problem Solving, and Visual Communication

Computer graphics 2: Graduate seminar in computational aesthetics

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Homework #2. Shading, Ray Tracing, and Texture Mapping

Three-Dimensional Viewing Hearn & Baker Chapter 7

Terrain rendering (part 1) Due: Monday, March 10, 10pm

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

TSBK03 Screen-Space Ambient Occlusion

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

CSE328 Fundamentals of Computer Graphics

Rendering Objects. Need to transform all geometry then

CS 4204 Computer Graphics

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Graphics and Interaction Rendering pipeline & object modelling

BSc Computing Year 3 Graphics Programming 3D Maze Room Assignment Two. by Richard M. Mann:

SPACE - A Manifold Exploration Program

CSCI 4620/8626. The 2D Viewing Pipeline

CSE 167: Lecture #4: Vertex Transformation. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Blue colour text questions Black colour text sample answers Red colour text further explanation or references for the sample answers

Computer Graphics I Lecture 11


Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

3D Rendering Pipeline

Surface Rendering. Surface Rendering

Chapter 32 Light: Reflection and Refraction. Copyright 2009 Pearson Education, Inc.

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

Lecture 4. Viewing, Projection and Viewport Transformations

MET71 COMPUTER AIDED DESIGN

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Or select Reset button under the application button (3ds Max symbol top left of screen)

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Animation Basics. Learning Objectives

Tutorial 4: Texture Mapping Techniques

Real Time Rendering of Complex Height Maps Walking an infinite realistic landscape By: Jeffrey Riaboy Written 9/7/03

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Announcements. Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

ECE 104 Fundamentals of Computer Graphics Project 1

Graphics pipeline and transformations. Composition of transformations

Virtual Environments

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

CS559 Computer Graphics Fall 2015

Viewing. Reading: Angel Ch.5

Adaptive Point Cloud Rendering

The Alice Scene Editor

CSE4030 Introduction to Computer Graphics

Advanced Computer Graphics (CS & SE )

Advances in MicroStation 3D

CPSC 436D: Video Game Programming Intro to Game Graphics Assignment

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

TDA361/DIT220 Computer Graphics, January 15 th 2016

Projection: Mapping 3-D to 2-D. Orthographic Projection. The Canonical Camera Configuration. Perspective Projection

3 Polygonal Modeling. Getting Started with Maya 103

CS Simple Raytracer for students new to Rendering

Computer graphics Labs: Blender (1/3) Modelling, transparency and reflection

Full Screen Layout. Main Menu Property-specific Options. Object Tools ( t ) Outliner. Object Properties ( n ) Properties Buttons

Introduction to Computer Graphics with WebGL

Texture. Texture Mapping. Texture Mapping. CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Topics and things to know about them:

Topic 10: Scene Management, Particle Systems and Normal Mapping. CITS4242: Game Design and Multimedia

Pipeline Operations. CS 4620 Lecture 14

Designing a Self-Calibrating Pipeline for Projection Mapping Application. Kevin Wright Kevin Moule

Project 2: 3D transforms and Cameras

Character Modeling COPYRIGHTED MATERIAL

OpenGL refresher. Advanced Computer Graphics 2012

Optics II. Reflection and Mirrors

The Graphics Pipeline and OpenGL I: Transformations!

OpenGL. Toolkits.

Transcription:

Syracuse University SURFACE Syracuse University Honors Program Capstone Projects Syracuse University Honors Program Capstone Projects Spring 5-1-2011 Interactive OpenGL Animation Lusha Zhang Follow this and additional works at: https://surface.syr.edu/honors_capstone Part of the Computer Engineering Commons Recommended Citation Zhang, Lusha, "Interactive OpenGL Animation" (2011). Syracuse University Honors Program Capstone Projects. 254. https://surface.syr.edu/honors_capstone/254 This Honors Capstone Project is brought to you for free and open access by the Syracuse University Honors Program Capstone Projects at SURFACE. It has been accepted for inclusion in Syracuse University Honors Program Capstone Projects by an authorized administrator of SURFACE. For more information, please contact surface@syr.edu.

Interactive OpenGL Animation A Capstone Project Submitted in Partial Fulfillment of the Requirements of the Renée Crown University Honors Program at Syracuse University Lusha Zhang Candidate for B. S. Degree and Renée Crown University Honors May 2011 Honors Capstone Project in Computer Science Capstone Project Advisor: Ernest Sibert Honors Reader: Marjory Baruch Honors Director: James Spencer, Interim Director Date:

Abstract This is an interactive animation created using C language, with support from the OpenGL, GLUT and the SDL frameworks. The concept behind this animation is to utilize the functions provided by OpenGL to achieve visual effects involving lighting, texture, motion, modeling and interaction. Based on experiment and research on various libraries, the Simple DirectMedia Layer (SDL) framework was chosen to implement an audio frame buffer to play background music. The animation involved significant mathematical calculation in terms of motion and modeling. The animation is an underwater scene that contains randomly generated bubbles, a dolphin and a whale. Textures were applied to surrounding surfaces that construct the underwater environment. Lighting was optimized to make all the objects in the scene visible and genuine. Timing was adjusted to obtain smooth rendering. The dolphin and the whale were constructed vertex-wise using display lists. In terms of interaction, the animation allows users to traverse the scene using keyboard input. Users can also choose to play and stop background music, which was composed using GarageBand. The animation has met the proposed requirements. The OpenGL application programming interface (API) provides a basic and easy-to-use library for 2D and 3D graphic development. It constitutes the foundation of higher-level platforms such as Blender and Autodesk Maya. This report is presented as a system requirements specification, augmented with explanations of various technical issues and certain implementation consideration.

Contents 1. Introduction:... 1 1.1 Purpose:... 1 1.2 Scope:... 1 1.3 Definitions:... 1 2. General Description:... 2 2.1 Perspective:... 2 2.2 Functionality:... 3 2.3 User Characteristics:... 3 2.4 General Constraints:... 3 2.5 Dependencies:... 3 3. Specific Requirements:... 4 3.1 Functional Requirements:... 4 3.1.1 Viewport Initialization:... 4 3.1.2 Camera Initialization:... 4 3.1.3 Water Surface:... 4 3.1.4 Floor Surface:... 4 3.1.5 Surrounding Water:... 5 3.1.6 Play Music:... 5 3.1.7 Stop Music:... 5 3.1.8 Bubbles:... 5 3.1.9 Load Texture:... 6 3.1.10 Traversing:... 6 3.1.11 Display Function:... 6 3.1.12 Set Lighting:... 6 3.1.13 Timer:... 7 3.1.14 Error Checking:... 7 3.1.15 Audio Mixer:... 7

3.1.16 Right-Click Pop-up Menu:... 8 3.1.17 Animating Dolphin and Whale:... 8 3.1.18 Animating Submarine:... 8 3.2 User Interface:... 9 3.2.1 Software Interface:... 9 3.2.2 Hardware Interface:... 9 3.2.3 Communication Interface:... 9 3.3. Performance requirements:... 9 3.4 Design Constraints:... 10 3.4.1 Software Constraints:... 10 3.4.2 Hardware Constraints:... 10 3.4.3 Traversing Constraints:... 10 3.5 Attributes:... 10 3.5.1 Rendering Issues:... 10 3.5.2 Maintainability:... 11 3.5.3 Transferability:... 11 4. Appendix:... 12 Architecture Diagram:... 12 References:... 13 5. Capstone Project Summary:... 14

1 1. Introduction 1.1 Purpose The purpose of this document is to describe the specific functionalities and features of an OpenGL Animation. The methods used to implement the interaction, animating, modeling and lighting involved in this animation will be explained in this document, so that it can be referred to future research. The document will also explore the mathematical approach of modeling and animating in OpenGL. 1.2 Scope The OpenGL Animation will allow users to traverse the scene. Constraints will be applied to avoid rendering issues, such as users going out of the boundaries and infinite loops caused by the improper use of display functions. 1.3 Definitions Display List: a group of OpenGL commands stored for future implementation. When a display list is called, the commands in the list are executed in its predefined order. Viewport: a rectangular area used to project a 3D scene to the position of a virtual camera. A viewport is a region used to display a portion of a scene.

2 Modelview Matrix: the matrix that contains both modeling and viewing transformations that place the viewer at the origin with the view direction aligned with the negative Z axis. Projection Matrix: a matrix that handles the transformation from the eye coordinates to the clip coordinates--from a 3D scene into a 2D image. Identity Matrix: a matrix that represents the identity transformation. Frustum: the field of view of a virtual camera that defines how far the viewer can see in a 3D space. Normal Vector: a vector that is perpendicular to a surface. Mipmaps: pre-calculated, optimized collections of images that accompany a main texture in order to increase rendering speed. 2. General Description 2.1 Perspective The goal of this animation is to create a generally pleasing, tranquil environment, which contains three purposes. The first purpose of the designer is to investigate the random generator. Water bubbles need to be randomly generated in terms of location and rising speed. To investigate modeling, mathematical calculation is applied at the vertex level. The second purpose is to conduct interaction with the user. The third part is to smoothly animate the objects.

3 2.2 Functionality Have a window interface Allow users to traverse the scene smoothly through keyboard commands Have a right-click pop-up menu Load a default.wav file Allow users to choose to play or stop the background music Allow users to quit the animation Provide error checking Keep the viewpoint within the scene 2.3 User Characteristics The viewer, who will watch the animation and traverse the scene, must have access to computers with Mac OS X 10.5 or later. The viewer must also be able to open the executable file and follow the instructions stated in the Readme.txt file. 2.4 General Constraints Users cannot cross the boundaries of the environment. The bubbles are randomly generated within the boundaries of the environment. 2.5 Dependencies The following frameworks will be used to support graphics and audio implementation: OpenGL.framework

4 GLUT.framework SDL.framework AppKit.framework 3. Specific Requirements 3.1 Functional Requirements 3.1.1 Viewport Initialization The Viewport size must be initialized with proper width and height. The frustum must have settings for the user to see the scene clearly without distortion. 3.1.2 Camera Initialization The virtual camera must be initialized at a location at which the viewer can see the whole setting. 3.1.3 Water Surface The water surface must be constructed using proper geometry and must have proper texture applied. 3.1.4 Floor Surface The floor surface must be constructed using proper geometry and must have proper texture applied.

5 3.1.5 Surrounding Water The surrounding water walls must be constructed using proper geometry and must have proper texture applied. 3.1.6 Play Music The animation provides a right-click pop-up menu, which contains the option Play Music. It allows the viewer to turn on background music. 3.1.7 Stop Music The right-click pop-up menu provides the option to the viewer to stop playing background music. 3.1.8 Bubbles Creating bubbles must include two parts--modeling and animating. Solid sphere must be chosen with proper radius and division to create a bubble. Each bubble must have material applied. The ambient light, diffusion, specular reflection, shininess and emission settings must reflect the genuine appearance of water bubbles in an aesthetic way. The location of bubbles must be randomly generated, but must not be outside of the scene. The bubbles must rise from the bottom to the water surface smoothly.

6 3.1.9 Load Texture This function must load a.raw file into the buffer and bind the corresponding texture mipmap before applying texture to objects. 3.1.10 Traversing Keyboard interaction must allow the viewer to traverse the scene using keyboard commands. Rotation Left and right arrow keys must allow the viewer to turn left and right, respectively, at a conveniently chosen angle and to rotate smoothly every time. Parallel Movement Up and down arrow keys must allow the viewer to move forward and backward, respectively, by a certain distance each time. 3.1.11 Display Function The display function must coordinate all the models and settings, and is called in every GLUT loop to render each frame. 3.1.12 Set Lighting Lighting settings must make all the objects in the scene visible and optimize the visual presentation of colors and texture. It must be included in the display function and initialization.

7 3.1.13 Timer A timer function must maintain the redisplaying of the scene to be smooth. 3.1.14 Error Checking The animation must be able to check for the following conditions that would cause errors or rendering issues: Before playing background music, the animation must check if the.wav file is loaded correctly. If the file is not found, the error checking function generates an error message and terminates the program. Functions that handle the rotation and parallel movement of the virtual camera must verify that the new location of the viewer is within the boundaries of the scene before making a move. If the viewer is about to be out of bounds, the traverse functions must set the viewer at the nearest boundary. 3.1.15 Audio Mixer Audio mixer initialization must specify the settings for OpenGL animation with 22Khz, 16-bit and 2 channels. The mixer function must load a.wav file, convert it to fit the initial settings and build an audio converter. When reaching the end of the music, the mixer must free the loaded data.

8 3.1.16 Right-Click Pop-up Menu Right clicking must retrieve a menu offering the following options: Quit the animation Play background music Stop background music 3.1.17 Animating the Dolphin and the Whale The Dolphin and the Whale Display List The display lists must store the vertex and normal coordinates of a dolphin and a whale. Drawing functions The functions must call the display list and apply proper texture to the model. Swim functions The functions act like a pilot, leading the animated objects to follow predesigned routes with suitable speeds and rotation. 3.1.18 Animating Submarine Submarine Display List The display lists must store the modeling commands to construct the submarine using fundamental geometric shapes.

9 Animating function This function must manipulate the submarine to move back and forth. 3.2 User Interface: 3.2.1 Software Interface: The user will interact with our software through a GLUT window. 3.2.2 Hardware Interface: A sound card is needed for playing the.wav file. 3.2.3 Communication Interface: GLUT Window: A viewport with specified width and height for the viewer to traverse the scene. Pop-up Menu: A right-click menu to allow the user to quit the animation, play background music and stop the music. 3.3. Performance requirements: The animation must meet all the functional requirements stated in 3.1. Rendering must be optimized to cause no slowdown of the animation. Keyboard interaction must be accurate. The animation must work with any.wav file.

10 3.4 Design Constraints: 3.4.1 Software Constraints: The following Xcode Frameworks will support the animation: The SDL Framework OpenGL 2.0 and later The GLUT Framework Mac OS X version 10.5 or later 3.4.2 Hardware Constraints: User computers must meet the minimum graphics requirements. 512 MB of internal RAM at least 125 MB video RAM at least Mouse Keyboard 1.25 GHz G4 PowerPC or faster processor Audio card to play music 3.4.3 Traversing Constraints: Users are not allowed to cross the boundaries of the scene. 3.5 Attributes: 3.5.1 Rendering Issues: The animation was created under rigorous testing to avoid rendering slowdown. Users can traverse the scene smoothly.

11 Background music is played at suitable frequency and channel settings to avoid twisted sound effects. Functions must be called in suitable order to avoid an infinite loop and system slowdown. 3.5.2 Maintainability: Code will be commented well and support more implementation. 3.5.3 Transferability: The animation will have the ability to work on Mac OS X 10.5 or later.

12 4. Appendix: Architecture Diagram: This architecture diagram is included for further understanding of the different layers of the animation and how they will work together. Animation Level Audio Mixer Models Pop-up Menu Keyboard Function Animating Functions Application Framework GLUT.framework SDL.framework OpenGL.framework AppKit.framework

13 References: http://www.libsdl.org/intro.en/usingsound.html http://pyopengl.sourceforge.net/documentation/manual/glunewquadric.3 G.xml http://wiki.libsdl.org/moin.cgi/sdl_loadwav http://usa.autodesk.com/adsk/servlet/index?siteid=123112&id=9469002 http://www.opengl.org/about/overview/#1 http://developer.apple.com/library/mac/#documentation/musicaudio/conc eptual/coreaudiooverview/coreaudioframeworks/coreaudioframewor ks.html http://www.meandmark.com/sdlopenglpart1.html http://gpwiki.org/index.php/c:how_to_set_up_your_sdl_build_environ ment#macos_x:_xcode http://glprogramming.com/red/chapter07.html http://www.songho.ca/opengl/gl_projectionmatrix.html http://glprogramming.com/red/appendixe.html http://glprogramming.com/red/chapter02.html#name5 http://www.teachenglishinasia.net/asiablog/asian-water-lilies-and-lotusflowers http://itc.blogs.com/greenstream/blogs_about_water/ http://www.cs.uregina.ca/links/class-info/405/www/lab3/ http://lcs.syr.edu/faculty/baruch/cis425625/lectures/lectures.html