Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Computer Graphics Viewing.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
HCI 530 : Seminar (HCI) Damian Schofield.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
Modelling. Outline  Modelling methods  Editing models – adding detail  Polygonal models  Representing curves  Patched surfaces.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Hierarchical Transformations Hierarchical Models Scene Graphs
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Modeling and representation 1 – comparative review and polygon mesh models 2.1 Introduction 2.2 Polygonal representation of three-dimensional objects 2.3.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Introduction to 3D Graphics Lecture 4: Scenes and Scene Graphs Anthony Steed University College London.
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
Objectives Review some advanced topics, including Review some advanced topics, including Chapter 8: Implementation Chapter 8: Implementation Chapter 9:
C O M P U T E R G R A P H I C S Stuff CMSC 435 / 634 Transformations 1/29 Geometric Transformations Readings: Chapters 5-6.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
EMSE 3123 Math and Science in Education
Image Synthesis Rabie A. Ramadan, PhD 3. 2 Our Problem.
3D Programming Concepts How objects are described in 3D and Rendering Pipelines – A conceptual way of thinking of the steps involved of converting an abstract.
COMPUTER AIDED DESIGN -(CAD)-3
Week 2 - Wednesday CS361.
TECH 104 – Technical Graphics Communication Week 13: 3D Modeling Basics.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Data Structures for Scenes, The Basics of Scene Graphs Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday,
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.
Image Synthesis Rabie A. Ramadan, PhD 1. 2 About my self Rabie A. Ramadan My website and publications
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
Image Synthesis Rabie A. Ramadan, PhD 4. 2 Review Questions Q1: What are the two principal tasks required to create an image of a three-dimensional scene?
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
GEOMETRY OUTCOME 1 CHAPTER 1 AND 3, WITH ADDED COMPONENTS.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 7. Speed-up Techniques Presented by SooKyun Kim.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
Digital Media Dr. Jim Rowan ITEC Vector Graphics Elegant way to construct digital images that –have a compact representation –are scalable –are.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
Computer Graphics Matrices
Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan.
Unit 10 Transformations. Lesson 10.1 Dilations Lesson 10.1 Objectives Define transformation (G3.1.1) Differentiate between types of transformations (G3.1.2)
In the last several lessons, you have described translations using coordinates. You have also developed strategies for determining where an object started.
TECH 104 – Technical Graphics Communication Week 12: 3D Modeling Basics.
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.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Geometry Objectives 6 – 8 Part 1
Translations 9.2 Content Standards
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.
True or False: A transformation is an operation that maps a an image onto a pre-image. Problem of the Day.
Five-Minute Check (over Lesson 9–1) CCSS Then/Now New Vocabulary
Lecture 13 Clipping & Scan Conversion
Five-Minute Check (over Lesson 3–1) Mathematical Practices Then/Now
Presentation transcript:

Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College PowerPoint Instructor’s Resource

Principles of Modeling Modeling has many parts; this chapter covers several different aspects of modeling, from the simple to the more complex

Simple Geometric Modeling The graphics primitives that are used in polygon-based modeling, and some examples of their uses

Modeling Space The geometry pipeline starts out in model space This is the space you use to define each object in your scene You can use any coordinates that are convenient for you You can also build templates for things you want to use often

Fundamental Objects OpenGL, like most fundamental graphics systems, is based on polygons Polygons require points and edges, so you also have points and line segments The simplest polygons are triangles and quadrilaterals, so these are special cases

Fundamental Objects (2) So the basic objects we work with are: Points Line segments Triangles Quadrilaterals (quads) Polygons Each is defined in terms of its vertices in order as you go around the object

Fundamental Objects (3) In your more complete modeling, you will probably also work with polyhedra, objects that have polygons as faces Examples of these: Point, line, triangle, polygon (quad), polyhedron

Fundamental Objects (4) To define one of these fundamental objects, you need to specify the vertices and the grouping This will typically look like begin(object_type) vertex(coordinates) vertex(coordinates) … vertex(coordinates) end

Fundamental Objects (5) This defines the object by defining its boundary Boundary edges go from each vertex to the next The object is closed up by an edge from the last vertex to the first The boundary edges are used in the rendering process we will see later

Fundamental Objects (6) When you define a polygon or quad, it may not necessarily be drawn as one Most polygon-based graphics systems really only draw triangles, so your object may be turned into triangles and then drawn You need to know if this will happen

Fundamental Objects (7) A major question in drawing polygons is that most graphics systems will only draw convex polygons Any non-convex polygon will likely be drawn incorrectly (you can check this!) This suggests that any polygon can be drawn with a triangle fan (described below) from any vertex

Fundamental Objects (8) Convexity example: One convex quadrilaterial and two non-convex ones (note vertex sequences)

Geometry Compression There is an overhead for each vertex you send to the graphics system Geometry compression is a way to send fewer vertices and still create the same object Graphics systems often have tools that allow geometry compression

Geometry Compression (2) The geometry compression tools are fairly simple, but useful Line strips Line loops Triangle strips Triangle fans Quad strips

Geometry Compression (3) Examples: line strip line loop

Geometry Compression (4) Examples: triangle strip triangle fan

Geometry Compression (5) Examples: quad strip with sequence of points (note this is different from the sequence if you just used quads!)

Geometry Compression (6) Geometry compression in use: a sphere (left) with a triangle fan (middle) and quad strip (right)

Aliasing and Antialiasing Most graphics systems let you choose if you want lines and edges to be antialiased -- drawn without jaggies Tradeoff is time vs image quality

Normals When we look at lighting, we will see that we need normals at each vertex A normal is a vector perpendicular to the plane of a polygon Normals can be calculated from the edges at a vertex, or they can be known from an object’s geometry

Surfaces Surfaces are common graphics objects and are relatively easy to compute You need to generate a set of points that lie on the surface and that are arranged so that they form a kind of grid You can then use the grid to create a set of triangles or quads to draw

Surfaces (2) A common example is the function surface A grid in the domain is used to create a grid on the surface

Clipping Clipping defines a plane in the model space and specified that anything on one side (your choice) is not to be seen. The clipping plane is usually specified simply by giving the coefficients in the plane equation Clipping is very useful in letting the viewer see inside an object or objects

Homogeneous Coordinates The familiar 3D space we use in graphics is sometimes viewed as being embedded in 4D space A point (x,y,z) is seen as equivalent to the homogeneous point (x,y,z,1) This lets the graphics system perform a number of operations more easily

Homogeneous Coordinates (2) Embedding 3D space in 4D is hard to see, so consider the example of 2D space embedded in 3D

Homogeneous Coordinates (3) The conversions between normal 3D and homogeneous 4D are

Transformations and Modeling Using transformations to make complex models and scenes from simple geometric parts

Transformations Are… Transformations are functions that act on points in Euclidean space, mapping them into other points We are interested in the transformations that move points in ways interesting to computer graphics

Transformations Are… (2) There are some specific kinds of transformations you have seen in the graphics pipeline Modeling transformations Viewing transformations Projection transformations We will look at them in this order

Modeling Transformations There are three transformations we will use in modeling These let us take the objects we define in their own modeling space and place them in a common world space Scaling Rotation Translation

Modeling Transformations (2) Scaling Each coordinate of a vertex is multiplied by a specific value The values for different coordinates may be different Scaling by (sx,sy,sz) with scale(sx,sy,sz) does:

Modeling Transformations (3) Rotation Rotation is a little more complex algebraically, but its operation is easily seen in the 2D example You specify a rotation by specifying the angle of rotation and the line (through the origin) with direction vector <a,b,c> that vertices are to be rotated around Rotate(theta,a,b,c)

Modeling Transformations (4) Translation Each coordinate of a vertex is offset by a specific value The values for each coordinate may differ Translating by (tx,ty,tz) with translate(tx,ty,tz) does:

Transformations Example To create a scene showing a rugby ball flying after it is kicked, we must do two things First, create the rugby ball by scaling a sphere Second, create images of the ball in flight by showing it rotated and translated several times

Transformations Example (2) First, the ball is created And then it is kicked

Composite Transformations In the rugby example, each of the balls shown flying was created by starting with a sphere and applying all three transformations: translate(rotate(scale(ball))) This is a composite transformation with several transformations applied to the geometry. This is very common.

Composite Transformations (2) Notice the order: translate(rotate(scale(ball))) This is standard notation: Transformations are written to the left of the object they act on The transformations at the right are done before transformations farther to the left

Composite Transformations (3) We write all transformations this way Tn*Tn-1*…*T2*T1 This means that T1 is applied first and Tn applied last You can phrase this as “last-specified, first-applied”

Composite Transformations (4) An important fact about transformations: Order Counts! Transformations are not commutative T1*T2 ≠ T2 * T1 So you must get your transformations in the right order to get the right results

Composite Transformations (5) There is a common order for graphics transformations scale first, rotate second, translate last This goes along with a good general rule for modeling your simple objects model objects at the origin so it is easier to transform them correctly

Composite Transformations (6) This order of application goes along with an ordering of operations The order is that the operations defined nearest the geometry are applied first So this turns into the coding sequence translate rotate scale geometry

An Example We want to create a 3D arrow from the basic shapes of a cone and a cylinder The cone and cylinder are in standard positions and of standard size

An Example (2) We must scale the cone and cylinder to appropriate sizes and then put them together to create a standard-size arrow as shown Then this standard arrow must be scaled to the size we need for our application

An Example (3) The general code for this looks like pushTransformStack scale // entire arrow pushTransformStack translate // we will move cylinder onto cone rotate scale draw cylinder popTransformStack draw cone // this is already in the right place popTransformStack

The Viewing Transformation Another important transformation in computer graphics is the viewing transformation This is the transformation that takes your models in world space and maps them into eye space You saw this in the geometry pipeline

The Viewing Transformation (2) The viewing transformation V is done last, after all the geometry is defined in world space Thus when we write the entire sequence of transformations that will be done on the geometry, the viewing transformation is written to the left of all modeling transformations

The Modelview Transformation The final product of all modeling transformations and the viewing transformation is then V*Tn*Tn-1*…*T2*T1 This product is called the modelview transformation

The Modelview Transformation (2) The order of the transformations in the modelview transformation is suggestive A modeling transformation later in the sequence is closer to the geometry, so it is defined later in the program So as the program executes, all new transformations it meets are simply multiplied at the right of the sequence

The Modelview Transformation (3) So there is only one access point to the sequence of transformations, and the state of the transformation environment at any point can be captured by saving the sequence at that point This suggests that there should be a way to store these states so we could return to any previous state

Transformation Stacks A transformation stack is an answer to the question of storing the state of the modelview transformation We will see that there is a compact way to store any transformation, so we can create a stack of transformations The contents of the stack are states of the modelview transformation at known points in the program

Transformation Stacks (2) The transformation at the top of the stack is the one used whenever any geometry is specified New modeling transformations are multiplied onto the one at the top of the stack To save the state, save a copy of the current top and add it to the stack To retrieve the last state, pop the stack

The Projection Transformation The final transformation we have is the projection transformation P This maps 3D eye space to 2D screen space and is applied after all the modeling and viewing transformations So the total transformation environment for graphics is P*V*Tn*Tn-1*…*T2*T1

Modeling for Visual Communication Some basic ideas to help you create effective communications with computer graphics

The Fundamental Idea The most important question in your decision of how to model something is How will my audience best understand this idea? Other considerations, such as finding an easy way to make your model, are secondary

The Meaning of Shapes Simple shapes can carry a lot of impact Consider some ways to mark a point with a small shape: A circle A letter x A triangle A cross A pentagram A hexagram The circle has no cultural meaning we know of; the letter x has little meaning; but the other four have a large significance to some people

The Meaning of Shapes (2) What are curves and surfaces? Are there actual physical surfaces for the electrostatic potential of Coulomb’s law, for example?

The Meaning of Shapes (3) One of the problems students face in learning science and mathematics is learning that curves and surfaces are not real, but are only abstractions that represent values How can you communicate that when it is so seductive to create beautiful pictures of surfaces?

The Meaning of Shapes (4) Another problem is using dimensions appropriately We can sometimes exchange one dimension for color, for example Color evokes responses but does not carry exact values; compare

The Meaning of Shapes (5) When the added dimension is time, it is particularly interesting to think of how to communicate it With a 2D object, we can use time as the third dimension, but is it understood?

The Meaning of Shapes (6) If the dimension of the problem goes beyond three, it can be difficult With a three dimensional model varying over time, you can use animation With more than three intrinsic dimensions it is more difficult 2D (or more) function of a 2D variable 1D (or more) function of a 3D variable there are some vocabularies for these

The Meaning of Shapes (7) For a function of a 2D variable, you can show discrete objects on a grid on a 2D space: For example: vector length (with color) and orientation Or you could use glyphs at discrete points

The Meaning of Shapes (8) For a 1D function of a 3D variable, you can show samples of the function’s values at points in 3D space

Other Content You can also add legends and labels to your image to give your audience the context to understand the image

Scene Graphs and Modeling Graphs Tools to help manage complex scenes and hierarchical models

Modeling Can Be Complex As you create scenes, you may find that you have a number of objects to work with Some of these objects may be defined only in world terms, but some may be defined in terms of other objects in the scene We need ways to describe complex and hierarchical scenes

A Solution Comes From the Scene Graph Scene graph technology is a key part of several graphics APIs java3D VRML 2 openSG It is not part of OpenGL, but it is simple to use the concepts for your modeling

What is a Scene Graph? A graph (usually a tree) whose nodes describe grouping, transformations, geometry, and appearance

Slightly Simpler Form There are a few parts of the full scene graph that we don’t need The virtual universe The locale (we just call it a scene) The view platform But the rest of the tree is straightforward to create for your work We call this a modeling graph to recognize that it’s not a full scene graph

Hierarchical Modeling The modeling graph is perhaps most useful when we work with models that have hierarchies of parts Controlling the motion of individual parts needs to take the parts’ parents’ motion into account This is difficult to do in absolute coordinates

Helicopter Example Probably the best example uses a helicopter flying above some surface The helicopter has a body and two rotors; the rotors are attached to the body but have their own motion

A Simple Modeling Graph A very simple start at a modeling graph for the scene is: But this is not complete; it does not include include any transformations, for example

A More Complete Graph A more complete modeling graph for the scene, including both transformations and appearance data, is:

Other Ways to See this Graph One of the values of thinking of modeling through a graph is that we can restructure the graph to get new views For example, if we invert the eyepoint we get a new and equivalent graph:

Changing the View With this new graph, it is easy to see that if we change the viewpoint placement transforms, we can get a new scene, as:

Using the Modeling Graph for Coding It is easy to see some rewrite rules that let us traverse the modeling graph and write code for the scene as we go The transformation stack is a key part of this process, so be sure you know how it works before using these rules

Modeling Graph Rewrite Rules As you traverse the modeling graph, Every time you go down a subtree at a grouping node, push the stack Every time you meet a transformation node, code the transformation Every time you meet a shape node, code the appearance and then code the geometry Every time you start back up a subtree, pop the stack

There Are a Few More Details There are also details about projection, viewing, lighting, and the like, but they are straightforward It is also easy to see how to change a part of a scene by allowing changes to a node over time or by a user action Modeling graphs let you focus on design and make your coding much easier