Presentation is loading. Please wait.

Presentation is loading. Please wait.

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 6 Graphics Contents.

Similar presentations


Presentation on theme: "Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 6 Graphics Contents."— Presentation transcript:

1 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 6 Graphics Contents

2 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 2 Objectives F To understand geometry and appearance, the basic attributes of visual objects F To describe points and vectors F To apply GeometryArray family of classes for constructing geometry F To apply GeometryInfo class for constructing geometry F To use geometric primitives F To use texts and fonts as geometric objects F To use the Appearance class and the associated node component classes

3 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 3 Points and Vectors Homogeneous coordinates

4 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 4 Points and Vectors

5 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 5 Surface Equations Implicit equation Parametric equation

6 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 6 Surface Represented with Polygons

7 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 7 Shape3D Node A Shape3D leaf node usually references Geometry and Appearance objects

8 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 8 Geometry Classes

9 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 9 PointArray PointArray pa = new PointArray(3, GeometryArray.COORDINATES); pa.setCoordinate(0, new Point3f(0f, 0f, 0f)); pa.setCoordinate(1, new Point3f(1f, 0f, 0f)); pa.setCoordinate(2, new Point3f(0f, 1f, 0f));

10 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 10 LineArray LineArray la = new LineArray(6, GeometryArray.COORDINATES); Point3f[] coords = new Point3f[6]; coords[0] = new Point3f(0f, 0f, 0f); coords[1] = new Point3f(1f, 1f, 0f); coords[2] = new Point3f(1f, 0f, 0f); coords[3] = new Point3f(2f, 1f, 0f); coords[4] = new Point3f(2f, 1f, 0f); coords[5] = new Point3f(3f, 0f, 0f); la.setCoordinates(0, coords);

11 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 11 TriangleArray TriangleArray ta = new TriangleArray(6, GeometryArray.COORDINATES); Point3f[] coords = new Point3f[6]; coords[0] = new Point3f(0f, 0f, 0f); coords[1] = new Point3f(1f, 1f, 0f); coords[2] = new Point3f(1f, 0f, 0f); coords[3] = new Point3f(1f, 0f, 0f); coords[4] = new Point3f(2f, 1f, 0f); coords[5] = new Point3f(3f, 0f, 0f); ta.setCoordinates(0, coords);

12 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 12 QuadArray QuadArray qa = new QuadArray(8, GeometryArray.COORDINATES); Point3f[] coords = new Point3f[8]; coords[0] = new Point3f(0f, 0f, 0f); coords[1] = new Point3f(1f, 0f, 0f); coords[2] = new Point3f(1f, 1f, 0f); coords[3] = new Point3f(0f, 1f, 0f); coords[4] = new Point3f(1f, 1f, 0f); coords[5] = new Point3f(0f, 1f, 0f); coords[6] = new Point3f(0f, 1f, 1f); coords[7] = new Point3f(1f, 1f, 1f); qa.setCoordinates(0, coords);

13 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 13 StripArray TriangleStripArray TriangleFanArray

14 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 14 IndexedArray int[] stripIndexCounts = {4, 4}; IndexedTriangleStripArray itsa = new IndexedTriangleStripArray(7, GeometryArray.COORDINATES, 8, stripIndexCounts); Point3f[] coords = new Point3f[7]; coords[0] = new Point3f(0f, 0f, 0f); coords[1] = new Point3f(0f, 1f, 0f); coords[2] = new Point3f(1f, 1f, 0f); coords[3] = new Point3f(2f, 1f, 0f); coords[4] = new Point3f(-1f, 0f, 0f); coords[5] = new Point3f(-1f, -1f, 0f); coords[6] = new Point3f(-2f, -1f, 0f); itsa.setCoordinates(0, coords); int[] indices = {0, 1, 2, 3, 0, 4, 5, 6}; itsa.setCoordinateIndices(0, indices);

15 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 15 The Tetrahedron F One of five regular polyhedra F Vertices: –(1, 1, 1), (1, -1, -1), (-1, 1, -1), (-1, -1, 1) F Indices: –0,1,2, 0,3,1, 1,3,2, 2,3,0 F Normals: –(1, 1, -1), (1, -1, 1), (-1, -1, -1), (-1, 1, 1) SourceRun

16 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 16 Surface Normals The surface normal at a point is perpendicular to the tangent plane The cross product is useful for calculating normals

17 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 17 Normal Calculation Parametric equation Derivatives Normal

18 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 18 GeometryInfo Class Source Run NormalGenerator Stripifier Utility classes

19 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 19 Polygon Mesh Vertices Quadangle Source Run

20 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 20 Primitives Source Run

21 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 21 Font and Text Font font = new Font(“Serif”, Font.BOLD, 1); FontExtrusion extrusion = new FontExtrusion(); Font3D font3d = new Font3D(font, extrusion); Text3D text = new Text3D(font3d, “Hello”); Text2D text = new Text2D(“Hello”, Color.blue, “Serif”, 16, Font.Italic); Create a Text3D object Create a Text2D object

22 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 22 Appearance Classes

23 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 23 Shading Model F Flat shading: a fixed color for a face F Gouraud shading: interpolating vertex colors

24 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 24 Coloring F The lighting model is applied if the Appearance references a valid Material object and the Material object enables lighting. F If vertex colors are present and not ignored, they are used to render the polygons. The enabling of the vertex colors is controlled by a RenderingAttributes object. When vertex colors are used, the shading mode of the polygons is determined by the ColoringAttributes object. A flat shading assigns a single color to a polygon and a Gouraud shading interpolates the vertex colors in the interior of a polygon. F If lighting is not enabled and the vertex colors of the geometry are not present or ignored, the color specified by the ColoringAttributes object will be used for coloring the geometry. SourceRun


Download ppt "Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 6 Graphics Contents."

Similar presentations


Ads by Google