OpenGL 3D and Animation for Simulating a Solar System

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

School of Computer Science University of Seoul. How can we create a window? How can we handle the events? What kind of objects can we render? How can.
Better Interactive Programs
Computer Graphics 2D & 3D Transformation.
This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts.
Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
CS 4363/6353 INTRODUCTION TO COMPUTER GRAPHICS. WHAT YOU’LL SEE Interactive 3D computer graphics Real-time 2D, but mostly 3D OpenGL C/C++ (if you don’t.
Six compound procedures and higher-order procedures.
1 3D modelling with OpenGL Brian Farrimond Robina Hetherington.
Materials and Lighting in MeshShop CMPS 160 Assignment 4.
OpenGL and Projections
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
Painterly Rendering CMPS Assignment 2. OpenGL OpenGL is a cross-language, cross- platform specification defining and API for 2D and 3D graphics.
Robotic Animals. New Concepts 3 Dimensional World Full Screen Animation Multiple Frames of Reference Camera vs Object Motion Lighting Complex Hierarchical.
Robotic Animals. New Concepts 3 Dimensional World Full Screen Animation Multiple Frames of Reference Camera vs Object Motion Lighting Complex Hierarchical.
OpenGL (II). How to Draw a 3-D object on Screen?
Computer Graphics (Fall 2004) COMS 4160, Lecture 3: Transformations 1
CS148: Introduction to Computer Graphics and Imaging Midterm Review Session.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Mouse-Based Viewing & Navigation Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 3, 2003.
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
OpenGL and Parametric Curves Advanced Multimedia Technology: Computer Graphics Yung-Yu Chuang 2005/12/21 with slides by Brian Curless, Zoran Popovic, Robin.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
CS 450: COMPUTER GRAPHICS PORTRAIT OF AN OPENGL PROGRAM SPRING 2015 DR. MICHAEL J. REALE.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.
Modeler Help Session CSEP 557, Spring Help Session Overview The Modeler Application Modeler Code Overview Constructing Your Model Hierarchical Modeling.
CS559: Computer Graphics Lecture 15: Hierarchical Modeling and Shading Li Zhang Spring 2008.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Lecture 11: Exam Revision 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271  Coursework.
Computing & Information Sciences Kansas State University Lecture 19 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 19 of 42 William H. Hsu.
Computer Graphics Bing-Yu Chen National Taiwan University.
Interactive Computer Graphics CS 418 MP1: Dancing I TA: Zhicheng Yan Sushma S Kini Mary Pietrowicz Slides Taken from: “An Interactive Introduction to OpenGL.
Modeling with OpenGL Practice with OpenGL transformations.
OpenGL Selection. Three Selection Methods Color coding (OpenGL) Selection mode (OpenGL) Selection ray (generic)
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
CGGM Lab. Tan-Chi Ho 2001 Viewing and Transformation.
Lecture 7 Midterm Review. OpenGL Libraries gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture.
1 OpenGL Transformations. 2 Objectives Learn how to carry out transformations in OpenGL ­Rotation ­Translation ­Scaling Introduce OpenGL matrix modes.
Introduction to Input/Interaction Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 19, 2003.
CS559: Computer Graphics Lecture 13: Hierarchical Modeling and Curves Li Zhang Spring 2010.
OpenGL and You I Cast, Therefore I Am. Ray Casting Idea is simple, implementation takes some work –Cast rays as if you were the camera –Determine intersection.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
Some Notes on 3-D Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 24, 2003.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 17 Animations, Loops.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
OpenGL LAB III.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Under the direction of Susan Rodger
Introduction to Computer Graphics
Introduction of OpenGL - 3D Graphic and Animation
School of Computer Science
Camera Position (5.6) we specify the position and orientation of the camera to determine what will be seen. use gluLookAt (eye x, y, z, at x, y, z, up.
The Earth The Earth is the third planet from the Sun.
Projection in 3-D Glenn G. Chappell
More on Widgets, Misc. Topics
Modeler Help Session CSE 457, Autumn 2007
OpenGL program.
Modeler Help Session CSE 457, Spring 2008
Class 10 Part 1 What values to use for Frustum The Trick
Modeler Code Basics CSE P 557, Autumn 2006
Modeler Help Session CSE 457, Spring 2007
Preview of 3-D Graphics Glenn G. Chappell
Presentation transcript:

OpenGL 3D and Animation for Simulating a Solar System Assignment 3 CMPS 160

Demo My code is in 3 files: main.cc systems.h systems.cc 364 lines of non-base code I have multiple systems of planets and moons (you only need 1 planet and 1 moon to get credit)

New Concepts 3 dimensional world Complex hidden state Full screen animation Multiple frames of reference Camera vs Object Motion How do these changes affect my design compared to the 2D painting program?

3D World 3 parameters (x,y,z), duh - glVertex3f(…) Using perspective projection instead of orthographic - gluPerspective(…) Objects can occlude (block visibility) one another, we need a depth buffer to figure out when this is happening - glutInitDisplayMode(…) with GLUT_DEPTH, glEnable(GL_DEPTH_TEST), glClear(..) with GL_DEPTH_BUFFER_BIT

Complex Hidden State For a simple sun, earth, moon simulation we need to track… Sun: earth’s orbital rotation state Earth: earth’s axial rotation state moon’s orbital rotation state Moon: moon’s axial rotation state AND on top of that we need up update this state using some constants for the rate of each rotation and the amount of time that has passed before we draw the scene each time!

Full Screen Animation In painting assignment we only drew one picture. This program should draw new pictures over and over as fast as it can. All painting goes in the display callback Add an idle callback that tells GLUT to git’ drawin’ again - glutPostRedisplay() We don’t want the user to watch us drawing so we draw to a back buffer while user looks at front, then swap them when we are ready to show them the new picture - glutSwapBuffers() -- implicitly flushes We want to take up the whole screen -- use glutFullScreen() after glutCreateWindow(…)

Multiple Frames of Reference (the important part of this assignment) Earth rotates around the sun Earth rotates around its own axis The Moon rotates around Earth The Moon rotates around its own axis OpenGL does all of the hard math for you as long as you tell it what frame you want to work in - glTranslate, glRotate, glPushMatrix, glPopMatrix, glScale… Ideally, you can do the whole assignment without sin() and cos()

Camera vs Object Motion OpenGL doesn’t make a distinction here, but you should. Scene is rendered from eye’s frame of reference. Simulation is run from the sun’s frame of reference. Use gluLookAt(…) or other functions to move the simulated world’s origin with respect to the eye before drawing the world. This has same logical effect as moving the eye within the world.

Camera Setup In your reshape callback reset the projection matrix to be a perspective projection with the appropriate aspect ratio, nothing more. In your display callback, the first thing change to the modelview matrix should be the camera’s transformation (with gluLook at), after that everything (the solar system) you draw will be relative to the shifted origin so it looks correct from the eye point. Save the modelview matrix anytime you think you’ll need its state back later.

Complex Hierarchical Drawing Using the Current State Variables (easier viewing on your own computer) arm_length glPushMatrix(); drawTower(tower_height); glTranslate(0,tower_height,0); glRotate(arm_angle,1,0,0); drawControlBox(); drawArm(arm_length); glTranslate(0,0,arm_length); glRotate(pulley_angle,0,1,0); drawPulley(); glPopMatrix(); glTranslate(-cable_length,0,0); drawBarrel(); glTranslate(first_barrel,0,0); for(I=0; I<4; I++) { glTranslate(barrel_spacing,0,0); } pulley_angle arm_angle cable_length tower_height Origin z x y firsrt_barrel barrel_spacing

“I still don’t really feel like I understand OpenGL in general” At other schools there are whole classes on OpenGL or at least a few lecture sessions about it cmps160 is more concept-based, you only learn to program with OpenGL in the lab. I learned OpenGL myself from examples and documentation. However, if you learn best through colorful PowerPoint presentations, here is a good starter covering everything up through this assignment: http://www.cs.virginia.edu/~gfx/Courses/2004/Intro.Spring.04/Lectures/lecture04.ppt

Base Code You write main.cc from scratch this time (really!). Copying the old main.cc is fine, but you’ll still have to make some major changes to the contents of your callbacks. We provide two functions (in helper.h) to make your solar system pretty if you desire: helperSetupLighting() -- call this in main after you have registered the callbacks helperPlaceLight() -- call this when you are drawing the scene in the display callback -- places the sun’s lighting at the current origin