Robotic Animals. New Concepts 3 Dimensional World Full Screen Animation Multiple Frames of Reference Camera vs Object Motion Lighting Complex Hierarchical.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

CSE 457 Modeler Help Session Lovingly brought to you by: TA Steve.
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.
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
Computer Graphics Lecture 4 Geometry & Transformations.
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
David Luebke5/16/2015 Administrivia l Back on track: canceling OpenGL lecture 2 l Assignment 1 –Greg Yukl found an alternate XForms site:
Lab 1: OpenGL Tutorial CS 282. What’s the plan for today? Go over our framework code. Learn some basic OpenGL! Reveal Lab 1 Answer questions.
1 3D modelling with OpenGL Brian Farrimond Robina Hetherington.
Computer Graphics Coursework Cookbook original from Anthony Jones modified Dan Cornford (Oct 2010)
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
OpenGL 3D and Animation for Simulating a Solar System
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.
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
Hierarchical Transformations Hierarchical Models Scene Graphs
Introduction to OpenGL Jian Huang This set of slides are extracted from the Interactive OpenGL Programming course given by Dave Shreine, Ed Angel and Vicki.
Geometric Objects and Transformations Chapter 4. Points, Scalars and Vectors  Points - position in space  Scalars - real numbers, complex numbers obey.
CAP4730: Computational Structures in Computer Graphics Introduction to OpenGL.
Mouse-Based Viewing & Navigation Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 3, 2003.
INTRO TO COMPUTER GRAPHICS TEXT EDWARD ANGEL: EDITION 5 CS770/870
CS 481 Preview, Some Lighting Details Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 19, 2003.
Week 2 - Wednesday CS361.
Geometric Transforms Changing coordinate systems.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
OpenGL - Lighting, Shading and Material Properties
Intro to RayGL  Kris Zarns. What it does Creates SDL (scene description language) files for POVRay from OpenGL & Glut code  One file per frame/swap-buffer.
OpenGL and Parametric Curves Advanced Multimedia Technology: Computer Graphics Yung-Yu Chuang 2005/12/21 with slides by Brian Curless, Zoran Popovic, Robin.
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.
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 
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.
Modeling with OpenGL Practice with OpenGL transformations.
Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003.
OpenGL Lighting Jian-Liang Lin 2002 Hidden-Surface Removal -1 Original Code: while (1) { get_viewing_point_from_mouse_position(); glClear(GL_COLOR_BUFFER_BIT);
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Hierarchical Modeling.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
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.
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.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
OpenGL LAB III.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
Introduction of OpenGL - 3D Graphic and Animation
- Introduction - Graphics Pipeline
School of Computer Science
© University of Wisconsin, CS559 Spring 2004
CS451Real-time Rendering Pipeline
Projection in 3-D Glenn G. Chappell
More on Widgets, Misc. Topics
Hierarchical Modeling
Preview of 3-D Graphics Glenn G. Chappell
Presentation transcript:

Robotic Animals

New Concepts 3 Dimensional World Full Screen Animation Multiple Frames of Reference Camera vs Object Motion Lighting Complex Hierarchical Drawing/Animation

3 Dimensional World 3 parameters (x,y,z) – 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

Full Screen Animation In the 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 the user looks at front, then swap them when we are ready to show them the new picture - glutSwapBuffers() -- implicitly flushes. Look for GLUT_DOUBLE for glutInitDisplayMode() We want to take up the whole screen -- use glutFullScreen() after glutCreateWindow(…)

Multiple Frames of Reference The arm rotates about the shoulder The forearm rotates about the elbow The hand rotates about the wrist 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() (you might use these for some special effects though) We want to update the states using some constants for the rate of each rotation and the amount of time that has passed before we draw the scene each time. x += v*dt

Camera vs Object Motion OpenGL doesn’t make a distinction here, but you should (to avoid getting lost) Scene is rendered from eye’s frame of reference Simulation is run from the body’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. (45 degrees is a decent field of view) In your display callback, the first change to the modelview matrix should be the camera’s transformation (with gluLookAt), after that everything 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

Lighting (magic for now) Turn on lighting using glEnable() with GL_LIGHTING and GL_LIGHT0 Specify material properties with glMaterial (how much light an object reflects) Specify light properties with glLight (how much light is emitted and from where) Enable GL_NORMALIZE -- fixes normal vectors on geometry from glut Enable GL_COLOR_MATERIAL -- makes glColor work like painting assignment

Complex Hierarchical Drawing Using Current State Variables glPushMatrix(); drawTower(tower_height); glTranslate(0,tower_height,0); glRotate(arm_angle,1,0,0); drawControlBox(); drawArm(arm_length); glTranslate(0,0,arm_length); glPushMatrix(); glRotate(pulley_angle,1,0,0); drawPulley(); glPopMatrix(); glTranslate(-cable_length,0,0); drawBarrel(); glPopMatrix(); glPushMatrix(); glTranslate(first_barrel,0,0); for(I=0; I<4; I++) { drawBarrel(); glTranslate(barrel_spacing,0,0); } glPopMatrix(); arm_angle pulley_angle Origin x y z tower_height arm_length cable_length 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: e04.ppt

Requirements Display a 3D scene with at least two camera angles Draw an animal with the following parts: –Body –Head –4 Legs, each with multiple segments (thigh, calf) –1 Tail with multiple segments so it can curl (10) Make your animal walk in a circle, jump, or stand on two legs like a horse The movement must be fairly complex and have parts that move at different speeds

Implementation Suggestion Familiarize yourself with drawing shapes and drawing them together Plan out (on paper) what your animal will look like Make a few small functions ( initSimulation(), updateSimulation(), drawBody(…), drawLeg(…), placeLight(), etc.) You may need to “fix” the example code (i.e. the camera and/or viewing frustum) Draw a simplistic form of your animal Add simulation code Add more complexities and controls For complex animations a reverseRotation() function or a rotationDirection variable might be useful

“Simulation code” CONSTANTS armSpinRate = 10 elbowSpinRate = 35 (all in degrees per second) VARIABLES (and initialization) armSpin = 0 elbowSpin = 0 lastTicks = getTicks() UPDATE (per-frame) nowTicks = getTicks() dt = (nowTicks-lastTicks)/ armSpin += armSpinRate*dt elbowSpin += elbowSpinRate*dt lastTicks = nowTicks

Primitives glutSolidSphere() glutSolidCube() glutSolidCone() gluCylinder() – needs a quadric made with gluNewQuadric() gluDisk() glVertex3f() You might also want to look at glScale() for getting shapes to be the right size

Graphical Extras Ground A really big quad Water A really big semi-transparent quad Starfield for 100 stars { theta = rand in 0-2*pi phi = rand in 0-2*pi Push matrix Rotate theta on x Rotate phi on y Translate star distance on z Draw point (with color based on sin(time) ?) Pop matrix }

Resources OpenGL Programming Guide (The Red Book) Programming Guide Viewing Lighting PyOpenGL Man Pages (Great OpenGL API doc) Man Pages NeHe OpenGL Tutorials OpenGL Tutorials