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

Better Interactive Programs
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)
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
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
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
COMP 175: Computer Graphics March 10, 2015
CS 481 Preview, Some Lighting Details Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 19, 2003.
GLWidget Description Jason Goffeney 3/8/2006. GLWidget The GLWidget class extends the Qt QGLWidget. The QGLWidget is a Qt Widget that happens to have.
Week 2 - Wednesday CS361.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Hank Childs, University of Oregon
OpenGL - Lighting, Shading and Material Properties
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Hank Childs, University of Oregon Nov. 14th, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 13: CW/CCW, constructing geometry.
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.
OpenGL Selection. Three Selection Methods Color coding (OpenGL) Selection mode (OpenGL) Selection ray (generic)
Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003.
Lecture 2: Some definitions of terms 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
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.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Lecture 7 Midterm Review. OpenGL Libraries gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture.
CS559: Computer Graphics Lecture 13: Hierarchical Modeling and Curves Li Zhang Spring 2010.
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.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
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
Hank Childs, University of Oregon
© University of Wisconsin, CS559 Spring 2004
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
CS451Real-time Rendering Pipeline
Projection in 3-D Glenn G. Chappell
More on Widgets, Misc. Topics
Hierarchical Modeling
CS 352: Computer Graphics Chapter 5: Viewing.
Prepared by your friendly, phantom TA Jennifer
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 - glPerspective(…) Objects can occlude (block visibility) one another, we need a depth buffer to figure out when this is happening glEnable(GL_DEPTH_TEST), glClear(..) with GL_DEPTH_BUFFER_BIT

OpenGL Animation QGLWidget provides an OpenGL context from the Qt Framework, all we have to do is override 3 functions, initializeGL(), resizeGL() and paintGL() The starter code shows how a QTimer can be used to redraw the scene at a given rate 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 – QGLWidget does ‘double buffering’ by default, if you’re interested in details check the swapBuffers() method

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 resizeGL() function 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:

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 GL Triangles, Quads, etc. solidCone(…) - provided in starter code gluCylinder(…) – needs a quadric made with gluNewQuadric(…) gluDisk(…) gluSphere(…) Use 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