250 likes | 416 Vues
Basic 3D Graphics. Chapter 5. 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. Objectives.
E N D
Basic 3D Graphics Chapter 5
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
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
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.
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.
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.
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
Java 3D Overview • Automatic rendering • Modeling with a scene graph • Object oriented A Java 3D Hello program Source
Scene Graph: DAG A tree A DAG A digraph
Superstructure • VirtualUniverse – the universe • HiResCoord – 256bit fixed point numbers • Locale – a “smaller” space
Group Nodes • BranchGroup • OrderedGroup • Primitive • SharedGroup • Swith • TransformGroup
Scene Graph The Java 3D “Hello” program
Use SimpleUniverse • Create a Canvas3D object • Create a SimpleUniverse object • Add content branch
Do It Yourself • Create superstructure • VirtualUniverse • Locale • Create the view branch • BranchGroup • TransformGroup • ViewPlatform • View • PhysicalBody • PhysicalEnvironment Source
Background • Default background: black • Change background with the Background node Background() Background(Color3f color) Background(float r, float g, float b) Background(ImageComponent2D image) Background(BranchGroup geometry) Source
Bounds • Environmental nodes need to be limited by bounds • Two ways: • Bounds, node component • BoundingLeaf, node Source
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 public final void setCapability(int bit) Source
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.