Introduction to 3D Graphics Lecture 4: Scenes and Scene Graphs Anthony Steed University College London.

Slides:



Advertisements
Similar presentations
Points, Vectors, Lines, Spheres and Matrices
Advertisements

CMPE 466 COMPUTER GRAPHICS
Computer Graphics Scan Conversion Polygon Faculty of Physical and Basic Education Computer Science Dep Lecturer: Azhee W. MD.
1 Planes, Polygons and Objects ©Anthony Steed
Extended Gaussian Images
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
CS 450: Computer Graphics OVERVIEW OF POLYGONS
Introduction to 3D Graphics Lecture 5: From Realism to Real-Time Anthony Steed University College London.
Geometry (Many slides adapted from Octavia Camps and Amitabh Varshney)
Computer Graphics - Class 14
Math for CSTutorial 11 Course Outline Homogeneous Coordinates.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Math for CSLecture 11 Mathematical Methods for Computer Science Lecture 1.
CS 376 Introduction to Computer Graphics 04 / 06 / 2007 Instructor: Michael Eckmann.
CSE 681 Object Intersection. CSE 681 Object Representation Implicit forms F(x,y,z) = 0 Explicit forms Analytic form x = F(y,z) testing generating Parametric.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Hidden Surface Removal
Introduction to 3D Graphics Lecture 3: General Camera Model Anthony Steed University College London.
Week 13 - Wednesday CS361.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
CS-321 Dr. Mark L. Hornick 1 3-D Object Modeling.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
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.
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
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
1 Ray Tracing Polyhedra ©Anthony Steed
Vertex – A point at which two or more edges meet Edge – A line segment at which two faces intersect Face – A flat surface Vertices, Edges, Faces.
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.
CS 325 Introduction to Computer Graphics 02 / 17 / 2010 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
1 General Camera ©Anthony Steed Overview n Simple camera is limiting and it is necessary to model a camera that can be moved n We will define.
1 Scene Graphs ©Anthony Steed Scene Graph Overview n Building Scene Structures n Traversal n Examples n Instancing and Re-Use n More Transformations.
Geometric Objects and Transformation
1 Scene Graphs Week 4.2 ©Anthony Steed
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Computer Graphics Basic 3D Geometry CO2409 Computer Graphics Week 5-1.
Background Mathematics Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Transformations Objective: to develop an understanding of the four transformations. Starter – if 24 x 72 = 2016, find the value of: 1)2.8 x 72 = 2)2.8.
1 Dr. Scott Schaefer Intersecting Simple Surfaces.
CGDD 4003 THE MATH LECTURE (BOILED DOWN, YET LIGHTLY SALTED)
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?
DOT PRODUCT CROSS PRODUCT APPLICATIONS
Lesson 5 Definition of Rotation and Basic Properties
12.1 Exploring Solids.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Lecture 5: Introduction to 3D
Computer Graphics Matrices
Determining 3D Structure and Motion of Man-made Objects from Corners.
Section 12-1 Exploring Solids. Polyhedron Three dimensional closed figure formed by joining three or more polygons at their side. Plural: polyhedra.
Copyright © Ed2Net Learning Inc.1. 2 Warm Up x y y = 3x - 11) x y y = x - 62)
1 Planes, Polygons and Objects ©Anthony Steed
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
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.
TRANSFORMATION GEOMETRY
Computer Graphics Lecture 21 Triangles and Planes Taqdees A
Chapter 12 Math 181.
Chapter III Modeling.
Ray Tracing Polyhedra ©Anthony Steed
S4 Coordinates and transformations 1
CHAPTER 3 VECTORS NHAA/IMK/UNIMAP.
Polygons.
Presentation transcript:

Introduction to 3D Graphics Lecture 4: Scenes and Scene Graphs Anthony Steed University College London

No More Spheres!

Overview n Polygons –Representation –Intersection n Polyhedra –Face sets –Winged edge n Scene graphs

Polygons n A polygon (face) Q is defined by a series of points n The points are must be co-planar n 3 points define a plane, but a 4th point need not lie on that plane

Types of Polygon n Simple - Concave, Convex n Complex We like simple, concave polygons since they are easy to break into triangles

Equation of a Plane n a,b,c and d are constants that define a unique plane and x,y and z form a vector P.

Deriving a,b,c & d (1) p 0 p 2 p 1 p n The cross product defines a normal to the plane n There are two normals (they are opposite) n Vectors in the plane are all orthogonal to the plane normal vector

Deriving a,b,c & d (2) n So p-p 0 is normal to n therefore n But if n = (n 1,n 2,n 3 ) –a= n 1 b= n 2 c= n 3 (n.p) –d = n.p0 = n 1 *x 0 + n 2 *y 0 + n 3* z 0

Half-Space n A plane cuts space into 2 half-spaces n Define n If l(p) =0 –point on plane n If l(p) > 0 –point in positive half-space n If l(p) <0 – point in negative half-space

Outline of Polygon Ray Casting n Three steps –Does the ray intersect the plane of the polygon? n i.e. is the ray not orthogonal to the plane normal –Intersect ray with plane –Test whether intersection point lies within polygon on the plane

Does the ray intersect the plane? n Ray eq. is p 0 + t.d n Plane eq. is n.(x,y,z) = k n Then test is n.d !=0

Where does it intersect? n Substitute line equation into plane equation n Solve for t n Find p i

Is this point inside the polygon? n Many tests are possible –Winding number (can be done in 3D) –Infinite ray test (done in 2D)

Winding Number Test n Sum the angle subtended by the vertices 1 n-1 p1p1 p2p2 p n-1

Inside and Outside n Not just draw (stroke, fill) n For closed Shapes –Hit test - inside or outside based on a winding rules (non-zero or even-odd)

Counting Edge Crosses n Draw a line from the test point to the outside –Count +1 if you cross an edge in an anti-clockwise sense –Count -1 if you cross and edge in a clockwise sense +1

Overview n Polygons –Representation –Intersection n Polyhedra –Face sets –Winged edge n Scene graphs

Polyhedra n Polygons are often grouped together to form polyhedra –Each edge connects 2 vertices and is the join between two polygons –Each vertex joins 3 edges –No faces intersect n V-E+F=2 –For cubes, tetrahedra, cows etc...

Example Polhedron vo v1 v2 v3 v4 v5 e1 e2 e3 e4 e5 e6 e7 e9 e8 n F0=v0v1v4 n F1=v5v3v2 n F2=v1v2v3v4 n F3=v0v4v3v5 n F4=v0v5v2v1 n V=6,F=5, E=9 n V-E+F=2

Representing Polyhedron (1) n Exhaustive (array of vertex lists) –faces[1] = (x0,y0,z0),(x1,y1,z1),(x3,y3,z3) –faces[2] = (x2,y2,z2),(x0,y0,z0),(x3,y3,z3) –etc …. n Very wasteful since same vertex appears at 3(or more) points in the list –Is used a lot though!

Representing Polyhedron (2) n Indexed Face set n Vertex array –vertices[0] = (x0,y0,z0) –vertices[1]=(x1,y1,z1) –etc … n Face array (list of indices into vertex array) –faces[0] = 0,2,1 –faces[1]=2,3,1 –etc...

Vertex order matters n Polygon v0,v1,v4 is NOT equal to v0,v4,v1 n The normal point in different directions n Usually a polygon is only visible from points in its positive half-space n This is known as back-face culling vo v1 v2 v3 v4 v5 n Polygon v0,v1,v4 is NOT equal to v0,v4,v1 n The normal point in different directions n Usually a polygon is only visible from points in its positive half-space n This is known as back-face culling vo v1 v3 v4 v5

Representing Polyhedron (3) n Even Indexed face set wastes space –Each face edge is represented twice n Winged edge data structure solves this –vertex list –edge list (vertex pairs) –face list (edge lists)

The Edge List Structure e NV(e) PFace(e)NFace(e) PCW(e)NCCW(e) NCW(e) PCCW(e) PV(e) n Edge contains –Next edge CW –Next edge CCW –Prev edge CW –Prev edge CCW –Next face –Prev face –Next vertex –Prev vertex

Advantages of Winged Edge n Simple searches are rapid –find all edges –find all faces of a vertex –etc… n Complex operations –polygon splitting is easy (LOD) –silhouette finding –potentially efficient for hardware –etc…

Building the WE n Build indexed face set n Traverse each face in CCW order building edges –label p and n vertices, p and n faces and link previous CCW edge n we fill in next CCW on next edge in this face n we fill in next CW and prev CW when traversing the adjacent face.

Overview n Polygons –Representation –Intersection n Polyhedra –Face sets –Winged edge n Scene graphs

Concept of Scene Graph n Objects placed relative to one another n Objects made of similar components n Directed acyclic graph root

Use for Animation/Modelling B S U E F H

n One object has a local transformation relative to its parent –shoulder is translation (0 1 0) from base –upper arm is translation (0 3 0) from shoulder –elbow is translation (0 3 0) from upper arm –fore arm is rotation Z by -90 then translation (0 2 0)

Rendering Traverse n Must get object definitions in WC before passing to camera n For object under Base –p.B is in WC n “inherit” matrices down stack n So for object under shoulder –p.SB is in WC –(p.S is in base coordinates)

In general n On traverse –“push” on graph descend –“pop” on graph ascend n Combined matrix is current transform (CTM)

Sharing Nodes n E.G. One table many places n Table1 has CTM T1T0 n Table2 has CTM T2T0 table table2 table1 T1 T2 T0

Spherical Coordinates n Represent a point on a using two angles and . Where r = length(x,y,z) Z P(x,y,z)   X Y Q O Q is projection of P onto XY plane is angle between X axis and OQ  is angle between OP and Z axis

Spherical Coordinates n Length OQ = r sin(  ) n So –x = r sin(  )cos( ) –y = r sin(  )sin( ) –z = r cos(  )

Rotation About an Arbitrary Axis Z X Y O p1 p2 

… 1. Translate p1 so it is at the origin 2. Let p3 = p2-p1 (new position of p2) find spherical co-ordinate of p3 (r, , ) 3. Rotate about Z by - to bring p3 into ZX plane 4. Rotate about Y by -  to bring p3 onto Z axis 5. Now rotate about Z by  6. Invert steps 4-1

… Z Y O p1 p2 Z Y O p3 StartTranslate

… Z Y p3 Rotate1 Z Y p3 Rotate2 

… Z Y p3 After Steps 1-4 n Now we apply the transformation we are after n Invert steps 4-1

Summary n Established a set of techniques for describing scenes made of polygons –Particularly the roles of local-coordinates, which form the modelling matrix stack in OpenGl n Described how to ray-cast these shapes –The mathematics of this will be crucial when we turn to projection next week.