Animator Help Session. Surface of Revolution You will write OpenGL code to draw a surface by rotating a curve. Each vertex must have an appropriate: 

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

CSE 457 Modeler Help Session Lovingly brought to you by: TA Steve.
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
SE 313 – Computer Graphics Lecture 13: Lighting and Materials Practice Lecturer: Gazihan Alankuş 1.
SE 313 – Computer Graphics Lecture 14: Armatures Lecturer: Gazihan Alankuş 1.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.
1Notes  Assignment 0 marks should be ready by tonight (hand back in class on Monday)
Due: Thursday, April 28 th by the stroke of midnight! TA: Jeff Booth.
Modeler Help Session CSE 457, Spring 2006 Modeler Due: Thursday, October 26th Modeler Artifact Due: Monday, Oct. 30th Project TA: Sierra
Modeler Help Session CSE 457, Fall 2005 Modeler Due: Oct 28, Friday Modeler Artifact Due: Oct 31, Monday Project TA: Jeremy
Animation. Outline  Key frame animation  Hierarchical animation  Inverse kinematics.
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
Animator Project CSE 557. In this project… Create your own hierarchical model Create keyframe animations Create smooth keyframe animations Create particle.
10/5/04© University of Wisconsin, CS559 Fall 2004 Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 3 due Oct 12 in class.
COMP 175: Computer Graphics March 10, 2015
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Mouse-Based Viewing & Navigation Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 3, 2003.
COMP 175: Computer Graphics March 24, 2015
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.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
CS 445 / 645 Introduction to Computer Graphics Lecture 23 Bézier Curves Lecture 23 Bézier Curves.
Animator Help Session. Agenda Introduction Curve implementation - Requirements - What are all those vectors? - Where should I put things? Particle System.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Modeler Help Session CSEP 557, Spring Help Session Overview The Modeler Application Modeler Code Overview Constructing Your Model Hierarchical Modeling.
 Checking out, building, and using the sample solution  Part 1: Surface of Revolution  Part 2: Hierarchical Modeling  Part 3: Blinn-Phong Shader 
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
Multimedia System and Networking UTD Slide- 1 University of Texas at Dallas B. Prabhakaran Rigging.
Project 1: Animation System Assigned: 01/17/06 Due: 01/31/06.
Computer Science Term 1, 2006 Tutorial 2 Assignment 3 – The Virtual World.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Advanced Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 31, 2003.
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Agenda Introduction Curve implementation - Requirements - What are all those vectors? - Where should I put things? Particle System - Requirements - What.
Computer Graphics Matrices
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.
Animator Help Session November 20 th, 2002,. Agenda Introduction Curve implementation - What are all those vectors? - Where should I put things? Particle.
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.
3D Animation 3. Animation Dr. Ashraf Y. Maghari Information Technology Islamic University of Gaza Ref. Book: The Art of Maya.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Animator Help Session.
Assigned: Thursday, May 13th
COMP 175: Computer Graphics February 9, 2016
Modeler Help Session CSE 457, Autumn 2008
Projection in 3-D Glenn G. Chappell
Particle systems Good animation principles Creating your artifact
Modeler Help Session CSE 457, Spring 2006
Modeler Help Session CSE 457, Spring 2005
More on Widgets, Misc. Topics
Modeler Help Session CSE 457, Autumn 2007
Introduction to Grasshopper for rhino
Animator Help Session Nov 24th, :30am.
Modeler Help Session CSE 457, Spring 2008
Agenda Introduction Curve implementation - Requirements
Animator Help Session May 18th, :00 May 19th, :00.
Assigned: Thursday, May 12th Due: Wednesday, May 25th
Modeler Code Basics CSE P 557, Autumn 2006
Modeler Help Session CSE 457, Spring 2007
Animator Help Session May 21st, :30 May 22nd, :30.
Prepared by your friendly, phantom TA Jennifer
Presentation transcript:

Animator Help Session

Surface of Revolution You will write OpenGL code to draw a surface by rotating a curve. Each vertex must have an appropriate:  Texture coordinate pair  Vertex normal  Position Replace code for drawRevolution() in modelerdraw.cpp  The divisions variable determines number of slices Load new curve with File->”Load Revolution Curve File”

How to start Drawing a curve  Using the curve editor tool  Start by left click with ctrl key on  Save dense point samples into.apts file  Load point samples in modeler

Curve file format A curve file is basically a.txt file with a list of x,y coordinates for control points.apts  Densely sampled points on a curve.cfg: curve configuration file  Row 1: sample density  Row 2: curve interpolation method

Slicing it into Triangle Strips Divide the surface into “bands” by longitude Compute vertex positions and normals  Using sin(), cos() in c++ code  See lecture notes for normal computation Connect the dots with OpenGL triangles

Connecting dots in a modern way Use glDrawElements with GL_TRIANGLES (required!) The order of vertices matters  Right-hand rule

Connecting dots It’s okay to use glBegin(), glEnd() for testing shapes, but don’t use them in the final submitted code Don’t use GL_QUAD_STRIP or GL_TRIANGLE_STRIP in the final submission, either. In the submitted code, you need to build a triangle mesh and send it to OpenGL  Using glDrawElements with GL_TRIANGLES

An Example This is an overly simplified example of drawing a plane using glDrawElements. The plane consists of two connecting triangles and the normal vectors of all vertices are pointing up. // preparing the data for the vertices positions GLfloat vertices[12] = { 0,0,0, 0,0,-1, 1,0,0, 1,0,-1 }; // normal directions GLfloat normals[12] = {0,1,0, 0,1,0, 0,1,0, 0,1,0}; // texture coordinate GLfloat texture_uv[8] = {0,0, 0,1, 1,0, 1,1}; // vertex indices to form triangles, the order of the vertices follows the right hand rule GLuint indices[6] = { 1,0,2, 1,2,3 } int indices_length = 6; glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertices); glNormalPointer(GL_FLOAT,0,normals); glTexCoordPointer(2,GL_FLOAT,0,texture_uv); glDrawElements(GL_TRIANGLES, indices_length,GL_UNSIGNED_INT, indices); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);

Texture Mapping See lecture slides for texture mapping  Basic idea: use longitude and arc length (curve distance) as texture coordinates Each vertex must have an appropriate:  Vertex normal  Position  Texture Coordinate Pair u,v Є [0,1]

Part 2: Hierarchical Modeling You must make a character with:  2 levels of branching  Something drawn at each level  Meaningful controls Otherwise, you will be overwhelmed when you animate it! You will need to:  Extend the Model class  Override the draw() method  Add properties that Modeler users can control  Give an instance of your class to ModelerUserInterface in the main() function

Building a Scene of your own In sample.cpp, the Scene class extends Model  draw() method draws the green floor, sphere, and cylinder, etc.  Add and replace drawing commands of your own You can use these draw commands as OpenGL references  Modelerdraw.cpp drawBox drawCylinder drawRevolution

Add a radio button for your scene Add a new radio button for your scene at the end of the list

Add Properties to Control It Kinds of properties (in properties.h):  BooleanProperty = checkbox  RangeProperty = slider  RGBProperty = color  ChoiceProperty = radio buttons Need to add it to: 1. Class definition 2. Constructor 3. Property list See sample.cpp for example

OpenGL Is A State Machine glEnable()/glDisable() changes state Once you change something, it stays that way until you change it to something new OpenGL’s state includes:  Current color  Transformation matrices  Drawing modes  Light sources

OpenGL’s Transformation Matrix Just two of them: projection and modelview. We’ll modify modelview. Matrix applied to all vertices and normals These functions multiply transformations: glRotated(), glTranslated(), glScaled() Applies transformations in REVERSE order from the order in which they are called. Transformations are cumulative. Since they’re all “squashed” into one matrix, you can’t “undo” a transformation.

Transformations: Going “Back” How do we get back to an earlier transformation matrix? We can “remember” it  OpenGL maintains a stack of matrices.  To store the current matrix, call glPushMatrix().  To restore the last matrix you stored, call glPopMatrix().

Hierarchical Modeling in OpenGL Draw the body Use glPushMatrix() to remember the current matrix. Imagine that a matrix corresponds to a set of coordinate axes:  By changing your matrix, you can move, rotate, and scale the axes OpenGL uses.

Hierarchical Modeling in OpenGL Apply a transform:  glRotated()  glTranslated()  glScaled() Here, we apply glTranslated(1.5,2,0)  All points translated 1.5 units left and 2 units up  It’s as if we moved our coordinate axes!

Hierarchical Modeling in OpenGL Draw an ear.  This ear thinks it was drawn at the origin. Transformations let us transform objects without changing their geometry!  We didn’t have to edit that ear’s drawing commands to transform it

Hierarchical Modeling in OpenGL Call glPopMatrix() to return to the body’s coordinate axes. To draw the other ear, call glPushMatrix() again…

Hierarchical Modeling in OpenGL Apply another transform…  Where will the ear be drawn now?

Hierarchical Modeling in OpenGL Draw the other ear

Hierarchical Modeling in OpenGL Then, call glPopMatrix() to return to the body’s “axes”  Technically, you don’t need to if that second ear is the last thing you draw.  But what if you wanted to add something else to the body?

Rule: A Pop For Every Push Make sure there’s a glPopMatrix() for every glPushMatrix()!  You can divide your draw() function into a series of nested methods, each with a push at the beginning and a pop at the end.

Levels of Branching Your scene must have two levels of branching like in this diagram.  Circles are objects  Arrows are transformations Call glPushMatrix() for green, so you can draw orange after drawing red  Do the same for orange You must draw something at each level.

Multiple-Joint Slider Needs to control multiple aspects of your model.  Example: Rotate multiple joints at once Don’t get too complicated!  Wait for Animator in four weeks!

Part 3. Blinn-Phong Shader We provide a directional light shader in OpenGL Shading Language (GLSL) You must extend it to support point lights. Files to edit:  shader.frag – your fragment shader  shader.vert – your vertex shader

Useful GLSL Variables gl_LightSource[i].position.xyz – the position of light source i. gl_FrontLightProduct[i] – object that stores the product of a light’s properties with the current surface’s material properties:  Example: gl_FrontLightProduct[i].diffuse == gl_FrontMaterial.diffuse * gl_LightSource[i].diffuse

Part 4. Your Custom Shader Anything you want! Can earn extra credit! Ask TA’s for estimated extra credit value of an option. See the OpenGL orange book in the lab for details + code. Can still use sample solution to test (depending on complexity) Warnings  Don’t modify any files except your model file and the required modifications  Or, your model might not work in Animator (project 4)

Part 4. Your Custom Shader

Curve Implementation What are all those vectors? In any specific curveEvaluator class ptvCtrlPts: a collection of control points that you specify in the curve editor ptvEvaluatedCurvePts: a collection of evaluated curve points that you return from the function calculated using the curve type’s formulas fAniLength: maximum time that a curve is defined bWrap: a flag indicating whether or not the curve should be wrapped

Curve Implementation Where should I put things? Create curve evaluator classes for each that inherit from CurveEvaluator  Bezier  B-spline  Catmull-Rom In GraphWidget class  Change the skeleton to call your new constructors in the GraphWidget class.

Particle System Requirements Particle System class  Should have pointers to all particles and a marching variable (time) for simulation  If you have two separate simulations (say, cloth sim and particles that respond to viscous drag) you may want to make that distinction here (as well as in your force and particle implementation Solver  In the skeleton, this actually exists within the Particle System class Particles

Particle System Requirements Two distinct forces  Distinct may mean forces whose values are calculated with different equations (gravity and drag are distinct because gravity eq is of form f=ma, where drag is defined in terms of a drag coefficient and velocity)  Alternatively (and better): distinct may mean that one force is a unary force and another is a n-ary force or spacially driven force Connect to Hierarchical model

Particle System What should I implement? Canonical components  Constructor  Destructor  etc Simulation functions  drawParticles()  startSimulation()  computeForcesAndUpdateParticles()  stopSimulation()

Particle System What should I implement? Particle struct or class  you may have several of these if you have multiple types of simulations  If this is the case, take advantage of inheritance Force class  An elegant implementation would include a generic Force class and a variety of distinct forces that inherit from it

Particle System Embedding in your hierarchy Need to find World Coordinates of Particles - Model View Matrix - Inverse Camera Transformation - Generate world coordinate for particles by undoing camera transformations to the point you want to launch from. Euler Method Hooking up your particle System

Particle System Some Cool Forces Particles in a lattice  Cloth simulation  Deformable objects Flocking  Will require multiple forces: Attractive force that affects far away particles Repulsive force that affects nearby particles What else?

Particle System Creating Your Artifact Choice of curve types  Bezier Curves Recall the animation of a bouncing ball When the ball hits the ground, the curve describing its position should have a C 1 discontinuity Without C 1 discontinuity here, the animation will look wrong  Catmull-Rom is usually the preferred curve choice… but unless your project supports the option to add C 1 discontinuity at will, you might find yourself trying to fight the Catmull-Rom to create pauses and other timing goodies

Particle System Creating Your Artifact Compositing  Recommended that you break your intended artifact up into shorter clips combining them all in the end.  This will make your life easier for many reasons: Splitting up work is straightforward Changing camera angles is GOOD for a composition You can incrementally complete your artifact  Adobe Premiere Play around with it, check the website for some details on how to use it. The user interface is pretty intuitive.

Extra Credit ideas Tension control for Catmull-Rom  Interpolating splines are cool because keyframing the parameter values that you want is more intuitive…  But what about the time instances not keyed? Without control of curve tension, you may not get the parameter values that you would really like, and your animation could suffer Allow control points to have C 0, C 1, or C 2 continuity  This can be VERY helpful in creating a good animation Initialize particle velocity with velocity of model hierarchy node to which it is attached  This is fairly easy and will make your particle system noticeably more realistic

Extra Credit ideas Billboarding  Adding support for sprites (billboarding) can DRASTICALLY increase the aesthetic quality of your simulation  Additional benefit: very easy to ‘skin’ particles and make multiple instance of same particle look unique Baking  A must for complicated simulations or for particle systems with a lot of particles

Extra Credit ideas Collision detection Better forces Texture Maps Motion Blur Lens flare

Animating well vs. well… just animating Story Boarding Timing Sound Lights and Camera Lasseter’s Animation Principles