1 Additional 3D Topics  Splitting polygons  Off screen rendering for capture of rendered images.  Sound in Java 3D scene graphs  Advanced textures.

Slides:



Advertisements
Similar presentations
Computer Graphics- SCC 342
Advertisements

Lecture Notes #11 Curves and Surfaces II
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Cubic Curves CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2006.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
© University of Wisconsin, CS559 Spring 2004
Jehee Lee Seoul National University
1 Curves and Surfaces. 2 Representation of Curves & Surfaces Polygon Meshes Parametric Cubic Curves Parametric Bi-Cubic Surfaces Quadric Surfaces Specialized.
Q about GL to render polygon glBegin(GL_TRIANGLES) glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,1,0); glEnd();
MIT EECS 6.837, Durand and Cutler Curves & Surfaces.
MIT EECS 6.837, Durand and Cutler Curves & Surfaces.
Modelling. Outline  Modelling methods  Editing models – adding detail  Polygonal models  Representing curves  Patched surfaces.
1 Lecture 13 Modeling Curved Lines and Surfaces. 2 Types of Surfaces Ruled Surfaces B-Splines and Bezier Curves Surfaces of Revolution.
Bezier and Spline Curves and Surfaces Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
ENDS 375 Foundations of Visualization Geometric Representation 9/30/04.
ENDS 375 Foundations of Visualization Geometric Representation 10/5/04.
Modelling: Curves Week 11, Wed Mar 23
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Curves Week 13, Mon 24 Nov 2003.
Bezier and Spline Curves and Surfaces CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Parts of Mortenson Chapter 6-9,
Curves and Surfaces (cont’) Amy Zhang. Conversion between Representations  Example: Convert a curve from a cubic B-spline curve to the Bézier form:
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
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.
11/19/02 (c) 2002, University of Wisconsin, CS 559 Last Time Many, many modeling techniques –Polygon meshes –Parametric instancing –Hierarchical modeling.
19/13/ :20 UML Graphics II Parametric Curves and Surfaces Session 3.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition Chapter 16.
Graphics Graphics Korea University cgvr.korea.ac.kr Creating Virtual World I 김 창 헌 Department of Computer Science Korea University
CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005
V. Space Curves Types of curves Explicit Implicit Parametric.
Introduction to Computer Graphics with WebGL
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 12 Additional 3D Topics.
CS 445 / 645 Introduction to Computer Graphics Lecture 23 Bézier Curves Lecture 23 Bézier Curves.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
Quadratic Surfaces. SPLINE REPRESENTATIONS a spline is a flexible strip used to produce a smooth curve through a designated set of points. We.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Subdivision Schemes Basic idea: Start with something coarse, and refine it into smaller pieces for rendering –We have seen how subdivision may be used.
Parametric Surfaces Define points on the surface in terms of two parameters Simplest case: bilinear interpolation s t s x(s,t)x(s,t) P 0,0 P 1,0 P 1,1.
Curves and Surfaces 2.0 CSE3AGR - Paul Taylor 2009.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
CS 376 Introduction to Computer Graphics 04 / 25 / 2007 Instructor: Michael Eckmann.
Representation of Curves & Surfaces Prof. Lizhuang Ma Shanghai Jiao Tong University.
04/18/02(c) 2002 University of Wisconsin Last Time Hermite Curves Bezier Curves.
In the name of God Computer Graphics Bastanfard. Curve Function(2) Other method is approximate it using a poly-line. Just locate a set of points along.
Rendering Curves and Surfaces Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico 1 Angel:
Review CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005.
11/26/02(C) University of Wisconsin Last Time BSplines.
3D Object Representations 2011, Fall. Introduction What is CG?  Imaging : Representing 2D images  Modeling : Representing 3D objects  Rendering : Constructing.
Local Illumination and Shading
Splines Sang Il Park Sejong University. Particle Motion A curve in 3-dimensional space World coordinates.
Computing & Information Sciences Kansas State University Lecture 30 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 30 of 42 Wednesday, 09.
Kansas State University Department of Computing and Information Sciences CIS 736: Computer Graphics Lecture 13 of 42 Wednesday, 15 February 2006 William.
Curves University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
Graphics Review Geometry, Color & Shading Brad Tennis Leslie Wu
3D Object Representations 2009, Fall. Introduction What is CG?  Imaging : Representing 2D images  Modeling : Representing 3D objects  Rendering : Constructing.
Digital Media Dr. Jim Rowan ITEC 2110 Vector Graphics II.
Introduction to Parametric Curve and Surface Modeling.
Chapter 10: Computer Graphics
© University of Wisconsin, CS559 Spring 2004
CS 445 / 645 Introduction to Computer Graphics
3D Object Representations
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Spring 2004
Dr. Jim Rowan ITEC 2110 Vector Graphics II
Three-Dimensional Object Representation
Introduction to Parametric Curve and Surface Modeling
Dr. Jim Rowan ITEC 2110 Vector Graphics II
Presentation transcript:

1 Additional 3D Topics  Splitting polygons  Off screen rendering for capture of rendered images.  Sound in Java 3D scene graphs  Advanced textures  Simple shadows  Dynamic geometry change  3D curves and surfaces

2 Splitting Polygons  We can specify a 3D shape as a collection of polygon faces –In principle, can use any kind of polygon –With more that 3 vertexes, it is possible to have something that isn't planar –Concave polygons don't necessarily fill properly  Usual practice is to use triangles

3 Polygons  A convex polygon is one for which –all the interior angles are less than 180 degrees –the interior is entirely to one side of the infinite extension of any edge –a line connecting any pair of interior points is inside the polygon.

4 Splitting a Convex Polygon  Given the vertex list (v 1, v 2, …, v n ) where the vertexes are in counterclockwise order –Create a triangle from the first three vertexes –Remove the middle vertex from the list –Repeat until there are only 3 vertexes left –Create a triangle from the last three vertexes

5 Concave Poygons  Use the angle between each successive pair of edges to determine if polygon is concave.  Treat each edge as a vector. –Vectors should go in counter- clockwise  Calculate the cross product for each successive pair of edges.  If any cross product is negative, the polygon is concave.

6 Splitting Concave Polygons  Find a convex triple in the vertex list by looking for a negative cross product  Extend the first edge of the pair of edges until it intersects another polygon edge. –Form a triangle from the vertexes that form the second vector and the new point –Remove the end of the second vector from the vertex list  Repeat until remaining vertexes form convex polygon

7 Rotational Method for Splitting  For each vertex in order –Move vertex to the origin –Rotate to put next vertex on x-axis –If next vertex in sequence is below x-axis, split off a triangle and remove that vertex from list –Repeat until remaining polygon is convex

8 Off-Screen rendering  What if you want to save or print a rendered scene?  Canvas3D supports an off-screen rendering mode  To use –create off-screen canvas –stop the view –attach the off-screen canvas –start the view –render the off-screen buffer –when rendering completes  retrieve the image  detach the off-screen buffer

9 Off-Screen Rendering  Create off screen canvas using public Canvas3D(GraphicsConfiguration gc, boolean offScreen)‏  Attach to view view.addCanvas3D(canvas)‏  Capture images ImageComponent2D buffer = new ImageComponent2D(ImageComponent.FORMAT_RGB, bImage); canvas.setOffScreenBuffer(buffer); canvas.renderOffScreenBuffer(); canvas.waitForOffScreenRendering(); bImage = offScreenCanvas.getOffScreenBuffer().getImage();  OffScreen.java

10 Sound  Sound is often used in applications that use 3D graphics –e.g. games  Java3D has classes to support sound –Added as leaf nodes in scene graphs –Similar to Light

11 Using Sound: Sound3D.java  Create an AudioDevice su.getViewer.createAudioDevice();  Create a MediaContainer to hold sound data MediaContainer mc = new MediaContainer(url);  Create a Sound object and add it to the scene graph BackgroundSound sound = new backgroundSound(); sound.setSoundData( mc); sound.setSchedulingBounds( bounds); root.addChild( sound);

12 3D Texture Mapping  2D texture maps put a 2D image onto a 3D surface –For some surfaces, this may not look very natural  Using a 3D volumetric texture source provides a more natural mapping  Usually use computer-generated textures for this –Procedural textures  There are a few sources of data that provide volumetric data –CAT scans

13 3D Texture Mapping  Consumes more computing resources in terms of generation and storage of 3D texture data  Realistic texture features of true 3D characteristics can be rendered with relatively simple mapping functions  Texture consists of a 3D array of pixel values  Texture coordinates need three values (r, s, t)

12/05/08 Procedural textures  Often used to simulate natural textures such as marble or wood  Natural textures frequently have some periodic variation associated with them –Not perfectly periodic - need some randomness imposed onto the periodic behavior

15 Perlin Noise  Invented by Ken Perlin  Widely used for things like fire, smoke, clouds  A kind of gradient noise –Uses a grid of random gradients (unit vectors)  Contribution to noise at x from each neighboring grid point is proportional to the dot product of the gradient and the vector from the grid point to x.

16 Perlin Noise  Want a function that is smooth and random at the same time –noise(x) is a fractal sum

17 Example: Marble Texture  Create a marble texture using –sin(x + turbulence(p))‏

12/05/08 Bump Mapping  Applying a 2D texture to a surface is not as realistic as a truly textured surface –the normal is constant across a face so the interaction with light is different  Bump mapping uses a varying surface normal to simulate the effect of a rough surface 

12/05/08 Shadows  Java3D API provides only a local illumination model –Illumination of any object depends only on the lights and not on any other objects –No shadows or reflections  To compute these kinds of effects need a global illumination model

12/05/08 Global Illumination Models  Very complex  Not practical for real-time rendering  Examples –Ray-tracing –Luminosity

21 Artificial Shadows  Create a projection of each object to use for the shadow  Similar to a view projection

12/05/08 Shadow.java  Shadow of a Dodecahedron is projected onto a stone wall –Wall is a texture-mapped rectangle –Gray shadow is just in front of the wall –Shadow is computed when the scene graph is built

12/05/08 GeometryChange  Occasionally need to be able to modify actual geometry while the scene graph is live –Shadow of a moving object needs to be recomputed every time the object moves  GeometryUpdater interface provides a means to do this

24 Dynamic Geometry Change  Create the geometry with BY_REFERENCE flag set.  Write a class implementing the GeometryUpdater interface. public void updateData(Geometry)  Implement a Behavior class. –Call the GeometryArray method to trigger the update. public void updateData(GeometryUpdater)

25 Example: MovingShadows.java

12/05/08 Curves and Curved Surfaces  Java3D doesn't support curves or curved surfaces  Parametric equations provide one way to generate curves and curved surfaces based on a set of equations  More generally, curves and surfaces (in both 2D and 3D) can be specified by a set of points plus a procedure for interpolating between those points –Bezier curves –B-splines

12/05/08 Types of curves  Bezier curves  Spline –a sequence of smoothly-joined polynomial curves  B-spline –widely used in CG  Bicubic surfaces

12/05/08 Bezier curves  Bezier curves are defined by a set of control points –Quadratic curves in Java2D are second-order Bezier curves –Cubic curves in Java2D are third-order Bezier curves

29 Bezier Curves  General Bezier curve is specified by a set of n control points –B n,i (t) is the Bernstein basis  A third-order Bezier curve has 4 control points

12/05/08 de Castlejau Algorithm  Allows you to compute a point on a Bezier curve using linear interpolation  Can also be used to subdivide a Bezier curve into segments

31 deCasteljau Algorithm  Start with a sequence of control points p 0 0, p 1 0, p 2 0, p 3 0  Compute successively shorter sequences p i k = (1 - t) p i k-1 + t p i+1 k-1  Curve is s(t) = p 0 3

32 Subdivision

33 BezierCurve.java  Create a LineStripArrary  Use deCasteljau algorithm to subdivide the given curve into shorter segments  Subdivide recursively until segments are short enough to be approximated by a line –Program uses a fixed level of subdivisions –More generally, use a flatness test

34 Bezier Surfaces  Create surfaces by extending a Bezier curve along anotherr curve –Tensor product of Bezier curves  Bicubic Bezier surface is the common type –m = n = 3  deCasteljau algorithm can be applied

12/05/08 Bezier surfaces  Think of surface as family of Bezier curves  For a particular value of u, S(v) is a Bezier curve with control points –for j=0, 1, 2, 3

12/05/08 BezierSurface.java  Based on a bicubic spline  Create a polygon mesh from mxn points  Use a TriangleStripArray

37 The Utah Teapot  A famous object in computer graphics –Constructed by Martin Newell in 1975 –Used to test rendering algorithms  Constructed with Bezier patches –Contains 306 vertices defining 32 bicubic Bezier surface patches

12/05/08 B-Spline Curves  Often used for modeling curved surfaces  Also defined by a set of control points –Doesn't always interpolate the points  A set of knot values is used to control smoothnes and continuity –Uniform B-spline has uniformly-spaced knot values  NURBS : Non-uniform rational B-spline

12/05/08 B-Spline Curves  For B-spline of degree k have –n+1 control points (p 0, p 1, …, p n ) –n + k + 2 knots (t 0 <= t 1 <= …<= t n+k+1 )  N k,i are normalized B-spline blending functions  Curve only defined from [t 3 to t n+k-2 )

12/05/08 Cubic B-Spline  Extension of Bezier curves  Uniformly distributed knots –t i+1 - t i = 1, i = 3, 4, …, n  Duplicated knots at ends mean force endpoints to be on the curve –t 1 = t 2 = t 3 = t 4 –t n+1 = t n+2 = t n+3 = t n+4  For n=3, this is a cubic Bezier curve