Computer Graphics Lecture 3 Modeling and Structures.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Sec 1-6 Concept: Polygons
Polygon Scan Conversion – 11b
SI23 Introduction to Computer Graphics
Data Visualization Lecture 4 Two Dimensional Scalar Visualization
SI23 Introduction to Computer Graphics
1Computer Graphics Building Models John Shearer Culture Lab – space 2
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 7 Scanline algorithm and polygon clipping Taku Komura.
1 Motion and Manipulation Configuration Space. Outline Motion Planning Configuration Space and Free Space Free Space Structure and Complexity.
Representation of spatial data
Computer Graphics- SCC 342
COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
CMPE 466 COMPUTER GRAPHICS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
CP411 polygon Lecture 6 1. Scan conversion algorithm for circle 2. Draw polygons 3. Antialiasing.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Computer Graphics Scan Conversion Polygon Faculty of Physical and Basic Education Computer Science Dep Lecturer: Azhee W. MD.
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
Closest Point Transform: The Characteristics/Scan Conversion Algorithm Sean Mauch Caltech April, 2003.
Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.
POLYGONS! gone! Polly.
Classes of Polygons Planar polygons Non-planar polygons Simple
THE WORLD OF POLYGONS LESSON 4.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
Polygons Not Polygons.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
Content Subdivision First some basics (control point polygon, mesh)
Polygonal Meshes 3D Object Representation -Tyler Abrams.
The Art Gallery Problem
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.
CS 551 / 645: Introductory Computer Graphics
C O M P U T E R G R A P H I C S Stuff Jian Chen January 15, 2010 Transformations 1/10 Describing Shape By Andries van Dam.
CS 445 / 645 Introduction to Computer Graphics Lecture 8 Triangle Rasterization Lecture 8 Triangle Rasterization.
Rasterization Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
Triangle Scan Conversion. 2 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) –Determine which.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
CAP4730: Computational Structures in Computer Graphics
Drawing Triangles CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
Vertices, Edges and Faces By Jordan Diamond. Vertices In geometry, a vertices is a special kind of point which describes the corners or intersections.
Introduction to Computer Graphics CS 445 / 645 Lecture 9 Chapter 4: Rasterization L. McMillan MIT notes (Fall ’98)
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner Rasterization.
Lee Byung-Gook Dongseo Univ.
12.1 Exploring Solids.
Computing & Information Sciences Kansas State University Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 32 of 42 Wednesday, 11.
Polygons Advanced Geometry Polygons Lesson 1. Polygon a closed figure Examples NO HOLES NO CURVES SIDES CANNOT OVERLAP all sides are segments.
Lecture 15: Raster Graphics and Scan Conversion
Section 12-1 Exploring Solids. Polyhedron Three dimensional closed figure formed by joining three or more polygons at their side. Plural: polyhedra.
Solid Modeling Dr. Scott Schaefer.
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Determine the name of the polygon
Computer Graphics Clipping.
Computer Graphics Filling.
Constructing Objects in Computer Graphics
Introduction to Polygons
Types of Polygons Polygon- a flat closed figure made of straight line segments Circle the figures that are polygons. Cross out the figures 
that are.
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Constructing Objects in Computer Graphics By Andries van Dam©
The Art Gallery Problem
The Art Gallery Problem
Agenda Polygon Terminology Types of polygons Inside Test
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
Prepared by Narendra V G CSE MIT
Agenda Polygon Terminology Types of polygons Inside Test
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Clipping University of British Columbia CPSC 314 Computer Graphics
Polygons.
Presentation transcript:

Computer Graphics Lecture 3 Modeling and Structures

Computer Graphics 3/10/2008Lecture 32 Polygon Surfaces Basic form of representation in most applications – all real-time displays. Easy to process, fast to process. Some applications may allow other descriptions, eg. Splines, but reduce all objects to polygons for processing. Fits easily into scan-line algorithms.

Computer Graphics 3/10/2008Lecture 33 Types of polygons. Types Triangles Trapezoids Quadrilaterals Convex Concave Self- intersecting Multiple loops Holes Concave Hole Convex Self – intersecting Two approaches : Generalise scan conversion Split into triangles.

Computer Graphics 3/10/2008Lecture 34 Definitions. A polygon is convex if: for all edges, all other vertices lie on the same side of the edge. Otherwise it is concave. Concave polygons can be difficult to process. Concave Convex

Computer Graphics 3/10/2008Lecture 35 Triangles are Always Convex Mathematically very simple – involving simple linear equations. Three points guaranteed coplaner. Any polygon can be decomposed into triangles. Triangles can approximate arbitrary shapes. For any orientation on screen, a scan line will intersect only a single segment (scan).

Computer Graphics 3/10/2008Lecture 36 Any polygon decomposes Convex polygons trivially decompose but non-convex polygons are non-trivial and in some overlapping or intersecting cases, new vertices have to be introduced.

Computer Graphics 3/10/2008Lecture 37 Arbitrary shapes with triangles Any 2D shape (or 3D surface) can be approximated with locally linear polygons. To improve, need only increase no. of edges

Computer Graphics 3/10/2008Lecture 38 Quadrilaterals are simple too and often mixed with triangles

Computer Graphics 3/10/2008Lecture 39 How do we represent polygons? Polygonal Geometry. V1 V2 V3 P1 P2 E1 E2 E3 Store all polygon vertices explicitly. Inefficient Cannot manipulate vertex positions.

Computer Graphics 3/10/2008Lecture 310 Representing Shapes. Polygonal Geometry. V1 V2 V3 P1 P2 E1 E2 E3 Use pointer into vertex list. Need to search to find adjacent polygons. Edges are drawn twice. Use pointer to edge list that points to vertex list. Store all polygon vertices explicitly. Inefficient Cannot manipulate vertex positions.

Computer Graphics 3/10/2008Lecture 311 Standard polygonal data structure

Computer Graphics 3/10/2008Lecture 312 Filling, or tiling a triangle. Calculate bounding box for triangle. Loop through pixels in box Test for lying inside the triangle Draw fragment if inside box Bounding box

Computer Graphics 3/10/2008Lecture 313 Triangle tiler. tile3( vert v[3] ) { int x, y; bbox b; bound3(v,&b); // calculate bounding box for( y=b.ymin; y<b.ymax, y++ ) for( x=b.xmin; x<b.xmax, x++ ) if( inside3(v,x,y) ) draw_fragment(x,y); } Bounding box

Computer Graphics 3/10/2008Lecture 314 Testing for inside a triangle. Write equation for all edges in implicit form Need to order vertices in consistent order so inside the polygon is on same side of line. Can terminate test early if point fails with an edge.

Computer Graphics 3/10/2008Lecture 315 Incremental triangle Tiler tile3( vert v[3] ) { int x, y; bbox b;edge l0, l1, l2; float e0, e1, e2; make_edge(&v[0],&v[1],&l2); // Calculate a,b & c for the edges make_edge(&v[1],&v[2],&l0); make_edge(&v[2],&v[0],&l1); bound3(v,&b); // Calculate bounding box e0 = l0.a * b.xmin + l0.b * b.ymin + l0.c; // Calculate f(x,y) for e1 = l1.a * b.xmin + l1.b * b.ymin + l1.c; // the 3 edges. e2 = l2.a * b.xmin + l2.b * b.ymin + l2.c; for( y=b.ymin; y<b.ymax, y++ ) { for( x=b.xmin; x<b.xmax, x++ ) { if( e0<=0 && e1<=0 && e2<=0 ) draw_fragment(x,y); // Draw if e0 += l0.a; e1 += l1.a; e2 += l2.a; // inside triangle } e0 += l0.a * (b.xmin - b.xmax) + l0.b; // same for e1 & e2. }

Computer Graphics 3/10/2008Lecture 316 Gaps and Singularities. Common edge between polygons, (drawn twice?) Missed pixels (slivers)

Computer Graphics 3/10/2008Lecture 317 What to do with common edges Draw a fragment –Problem : double hits. –Wasted effort –Problem when it comes to transparency, blending or complex operations. Dont draw a fragment. –Gaps? –Rule: draw pixels on left and bottom edges

Computer Graphics 3/10/2008Lecture 318 Gaps Solution : shadow test Left as an exercise.

Computer Graphics 3/10/2008Lecture 319 Summary Test for point inside triangle by testing point with implicit form of edges. Problem with gaps. Problem with concave polygons.

Computer Graphics 3/10/2008Lecture 320 Polygon decomposition into triangles. Now that we have an inside test, we can convert polygons to triangles. –Triangles simple, convex and planar. P2 P0 P1P3 P4 P5 P6 P7 Simple for convex polygons. Concave more difficult.

Computer Graphics 3/10/2008Lecture 321 Polygon decomposition Test all vertices to check they are outside of ABC. –Test one edge at a time to reject vertices early A B C D Vertex D fails test.

Computer Graphics 3/10/2008Lecture 322 Polygon decomposition If all vertices outside store triangle, remove vertex and proceed with next leftmost vertex. If a vertex is inside, form new triangle with leftmost inside vertex and point A, proceed as before. A B C D Test ABD in same manner as before,

Computer Graphics 3/10/2008Lecture 323 Jordan Curve Theorem. Another test for inside/outside of a polygon. Two definitions of inside : Even-Odd parity Winding number Even no. crossings : Outside polygon Odd no. crossings : Inside polygon.

Computer Graphics 3/10/2008Lecture 324 Jordan Curve Theorem. Doesnt work for self-intersecting polygons Even no. crossings : Outside polygon Odd no. crossings : Inside polygon

Computer Graphics 3/10/2008Lecture 325 Jordan Curve Theorem. Non-zero Winding Number -Use direction of line as well as crossing -Set a value, e = 0 -For right-left crossings, e + +, for left-right e - - -For inside, e !=

Computer Graphics 3/10/2008Lecture 326 Singularities Two types of singularity in Jordan curve algorithm : Horizontal line along scanline Edge passes through point. These represent limiting cases of a fill.

Computer Graphics 3/10/2008Lecture 327 Scanline algorithm. Incremental Jordan test. Sort vertex events according to y value. y

Computer Graphics 3/10/2008Lecture 328 Scanline algorithm. Incremental Jordan test. Sort vertex events according to y value. Treat each vertex as an edge event, i.e a change of edge crossing the scanline. Use scanline coherence, i.e the value for the previous scanline is very similar to the next. Maintain active edge list.

Computer Graphics 3/10/2008Lecture 329 Active edge list. Delete Create Replace Vertices are events in the edge list – edges become active, inactive or are replaced by other edges. - Sort intercepts by x crossing. - Output span between left and right edge. y

Computer Graphics 3/10/2008Lecture 330 Summary Perform Jordan test incrementally. Keep list of active edges. Fill from left to right edge at each scanline Use equation of line to increment position of edge. Read text on filling algorithms such as Foley et al., pp and pp

Computer Graphics 3/10/2008Lecture 331 How do we draw triangles faster? Represent triangle as 3 vertices and 3 edges. If were performing a transformation on the triangle, we need to transform the position of 3 points. 3 matrix operations per triangle

Computer Graphics 3/10/2008Lecture 332 Triangular fans. Triangles used in complex polygonal geometry. Triangular Fan. To add new triangle, only 1 vertex needs to be added. Red - existing vertices. Black - new vertex

Computer Graphics 3/10/2008Lecture 333 Tri-strip Use triangles to represent a solid object as a mesh. Triangles frequently appear in strips : A new triangle is defined by 1 new vertex added to the strip.

Computer Graphics 3/10/2008Lecture 334 How do we draw triangles faster? For tri-strips and fans, only need to transform position of 1 point per triangle. –1 matrix operation per triangle. –Much faster ! Also Quad-strip - 2 vertices per quad

Computer Graphics 3/10/2008Lecture 335 Summary Triangles –3 matrix operations per transformation. Triangle Fan –Connected group sharing 1 common vertex, and 1 from previous triangle. –1 matrix operation per transformation. Tri-strip. –Group of triangles sharing 2 vertices from previous triangle. –1 matrix operation per transformation.