24
Basic 3D Graphics Chapter 5

Basic 3D Graphics Chapter 5. Bird’s Eye View Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

Embed Size (px)

Citation preview

Page 1: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

Basic 3D Graphics

Chapter 5

Page 2: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

2

Bird’s Eye View Basic 3D Graphics

– Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph, background, bounds, and making changes in a live scene graph

Graphics Contents Geometric Transformation Views

Page 3: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

3

Objectives To describe the 3D rendering process To present an overview of Java 3D programs To define Java 3D scene graph To classify components of a scene graph To apply background nodes To understand and apply bounds objects To make changes in live scene graphs

Page 4: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

4

Key Classes and Methods (1/2) com.sun.j3d.util.applet.Mainframe – A utility class to display an applet in a frame. javax.media.j3d.VirtualUniverse – A class encapsulating a coordinate space of the

entire virtual universe. javax.media.j3d.Locale – A class defining a coordinate space with float data type

anchored in the virtual universe. javax.media.j3d.HiResCoord – A fixed-point data type to represent high-resolution

coordinates of the virtual universe. com.sun.j3d.util.universe.SimipleUniverse – A convenience class with a default

implementation of the virtual universe, a locale, and a view branch of the scene graph.

javax.media.j3d.SceneGraphObject – An abstract class served as the root class for all scene-graph elements.

javax.media.j3d.Node – A class for nodes in a scene graph. javax.media.j3d.NodeComponent – A class for node components in a scene graph. javax.media.j3d.Group – A class for group nodes in a scene graph. javax.media.j3d.Leaf – A class for leaf nodes in a scene graph.

Page 5: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

5

Key Classes and Methods (2/2) javax.media.j3d.SceneGraphObject.setCapability(int) – A method to allow certain

manipulations of the object in a live scene graph. javax.media.j3d.Group.addChild(Node) – A method to add child nodes in a scene

graph. javax.media.j3d.branchGroup – A special type of group nodes that can be attached to

locale. javax.media.j3d.branchGroup.compile() – A method to compile the scene graph to

improve the performance. javax.media.j3d.background – A leaf node defining the background color, image, and

geometry of a scene. javax.media.j3d.Bounds – A node-component class encapsulating a spatial volume that

is used by environmental nodes to limit their scope of activation. javax.media.j3d.boundingLeaf – A leaf class encapsulating a spatial volume that is used

by environmental nodes to limit their scope of activation. javaxmedia.j3d.BoundingBox – A class encapsulating box-shaped bounds. javax.media.j3d.BoundingSphere – A class encapsulating spherical bounds. javax.media.j3d.BoundingPolytope – A class encapsulating polytope bounds.

Page 6: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

6

Key Terms Geometry – A structural definition of a visual object. Appearance – A collection of rendering attributes of a visual object. DAG (directed acyclic graph) – A directed graph with no directed

cycles. Scene graph – A DAG specifying the graph scene to be rendered. Tree – A graph formed by recursively adding distinct child nodes. Leaf node – A node in a tree that has children. Internal node – A node in a tree that has children. Primitive – A basic visual object that may be used to build a model. Capability bit – A flag in SceneGraphObject that gives

permission to performing a specific operation in a live scene graph.

Page 7: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

7

3D Model and View

World Space Image

Light

Visual Object

Viewer

Page 8: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

8

Rendering Considerations Geometry of the graphics objects Location and position of the objects Geometric transformations applied to objects and views Material properties and texture of the objects Lights and their characteristics Type of projections in a view View position, field of view, and other properties Illumination and shading models Dynamic behaviors of various components Reactions to the user inputs

Page 9: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

9

Java 3D Overview

Automatic rendering Modeling with a scene graph Object oriented

Source

A Java 3D Hello program

Page 10: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

10

Scene Graph: DAG

a

c

b

d

e f

A digraph

a

c

b

d

e f

A DAG A tree

a

c b d

e f g

h

Page 11: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

11

Scene Graph: Legend Virtual Universe

Locale

Group Node

Leaf Node

Node Component

Other Object

Parent-Child Link

Reference

Page 12: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

12

Scene Graph

Page 13: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

13

Scene Graph: Classes

SceneGraphObject

Node

NodeComponent

Group

Leaf

VirtualUniverse

Locale

SimpleUniverse

Page 14: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

14

Superstructure VirtualUniverse – the universe HiResCoord – 256bit fixed point numbers Locale – a “smaller” space

Page 15: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

15

Group Nodes

BranchGroup OrderedGroup Primitive SharedGroup Swith TransformGroup

Page 16: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

16

Leaf Nodes

Leaf

AlternateAppearance

Background

Fog

Clip

BoundingLeaf

Behavior

Light

Link

ModelClip

SoundScape

Sound

Shape3D

Morph

ViewPlatform

Page 17: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

17

Node Components

NodeComponent

Alpha

Appearance

Geometry

DepthComponent

ColoringAttributes

AuralAttributes

ImageComponent

LineAttributes

PolygonAttributes

PointAttributes

MediaContainer

Material

RenderingAttributes

TexCoordGeneration

TransparencyAttributes

TextureUnitState

TextureAttributes

Texture

Font3D

Page 18: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

18

Scene Graph

The Java 3D “Hello” program

View Canvas3D

BG

TG

Physical Body

Physical Environment

ViewPlatform

BG

TG

Light

SimpleUniverse

Shape3D

Text3D Appearance

Material

Bounds

Page 19: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

19

Use SimpleUniverse Create a Canvas3D object Create a SimpleUniverse object Add content branch

Page 20: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

20

Do It Yourself

Create superstructure– VirtualUniverse– Locale

Create the view branch– BranchGroup– TransformGroup– ViewPlatform– View– PhysicalBody– PhysicalEnvironment

Source

Page 21: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

21

Background Default background: black Change background with the Background node

Source

Background()Background(Color3f color)Background(float r, float g, float b)Background(ImageComponent2D image)Background(BranchGroup geometry)

Page 22: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

22

Bounds Environmental nodes need to be limited by

bounds Two ways:

– Bounds, node component– BoundingLeaf, node

Bounds

BoundingBox

BoundingSphere

BoundingPolytope

Source

Page 23: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

23

Live Scene Graph A branch is live when attached to Locale Compile may improve performance Set capability bits explicitly to change attributes

in a live scene graph

Source

public final void setCapability(int bit)

Page 24: Basic 3D Graphics Chapter 5. Bird’s Eye View  Basic 3D Graphics –Basic concepts of 3D graphics, rendering pipeline, Java 3D programming, scene graph,

24

Summary We discuss the fundamental concepts of 3D computer graphics and the basic architecture of

the Java 3D system. In a 3D graphics system, a virtual world is built to model a 3D graphics scene. The model is

viewed from a particular perspective to produce a rendering of the scene. The Java 3D API is built on the key concept of scene graphs. A scene graph incorporates all

the graphics descriptions and attributes of a scene to be rendered into a single data structure.

The rules for constructing the scene graphs and their building blocks are introduced. A scene graph is a DAG, with nodes being objects from classes of superstructures, nodes, and node components.

The overall structure of a Java 3D program is presented. By using a scene graph and its related objects, we can build a 3D graphics model and let Java 3D render the scene automatically.

The background of a scene can be change using the Background leaf node. Environmental nodes such as Light and Background need to set bounds to limit their influence in rendering. Bounds and BoundingLeaf objects are two ways of setting bounds.

A branch graph can be compiled to improve rendering efficiency. A component of a live scene graph can be modified only if appropriate capability bits are set.