Vous êtes sur la page 1sur 3

CHAPTER 1 Introducing Java 3D

collection of high level constructs for creating, rendering, and manipulating 3D scene graph makes 3D programming easier: emphasizes scene design (rendering) and hides graphics pipeline supports complex graphical elements (e.g. lighting modes, picking, collision detection)

Overview of Java 3D
prior to 1.5: 2 Java 3D variants: 1 implemented on top of OpenGL and 1 on top of DirectX Graphics o OpenGL is cross language, cross-platform API for 3D (and 2D) computer graphics o DirectX Graphics API supports rendering pipeline describing all geometry in terms of vertices and pixels 1.5: JOGL rendering pipeline added easier to develop future Mac versions o offers lightweight JCanvas3D class as alternative to Canvas3D class Java 3D 1.6 use JOGL binding to combine OpenGL and Java 3D rendering more closely should be installed after Java SE

Overview of the Scene Graph


organizes and manages 3D application graphics pipeline is hidden and replaced by treelike structure built from nodes o represent 3D models, lights, sounds, background, camera nodes are typed o Group nodes has grouped child nodes so that operations can be applied en masse o Leaf nodes represent visible things (e.g. shapes) or nontangible entities in scene (e.g. lights) may have node components to specify color, reflectivity, other or Leaf attributes can contain behaviors, represented by nodes holding code affect other nodes at runtime o e.g. move shapes, detect and respond to shape collisions, cycle lighting

Some Java 3D Scene Graph Nodes


Java 3D API is set of classes that subclass Group and Leaf nodes o Leaf subclasses define 3D shapes and environmental nodes o Group subclasses extend basic node positioning and orientation for its children BranchGroup allows children to be added or removed from graph at runtime TransformGroup permits position and orientation of children to be changed main shape class is 3D that uses Geometry and Appearance classes

The HelloUniverse Scene Graph


VirtualUniverse is top node and represents virtual world space and its coordinate system Locale is scene graphs location in virtual world and always contains two subgraphs o content branch graph can contain geometry, lighting, textures, worlds background) The content branch graph differs significantly from one application to another. The ColorCube is composed from a Shape3D node and associated Geometry and Appearance components. Its rotation is carried out by a Behavior node, which affects the TransformGroup parent of the ColorCubes shape. o view branch graph, and specifies the users position, orientation, and perspective as he looks into the virtual world from the physical world The ViewPlatform node stores viewers position in the virtual world; the View node states how to turn what viewer sees into a physical world image (e.g., a 2D picture on the monitor). The Canvas3D node is a Java GUI component that allows the 2D image to be placed inside a Java application or applet. VirtualUniverse, Locale, and view branch graph often have same structure across applications -

relevant nodes can be created with Java 3Ds SimpleUniverse utility class

Java 3D Strengths
The Scene Graph
simplifies 3D programming speeds up resulting code hides low-level 3D graphics elements and allows programmer to manage and organize 3D scene supports wide range of complex graphical elements used to group shapes with common properties carries out view, occlusion and execution culling, level of detail selection, behavior pruning o optimizations that must be coded directly by programmer in lower level APIs uses multithreading to carry out parallel graph traversal and rendering optimization

Performance
at high level by scene graph optimizations - at low level by being built on top of OpenGL or DirectX Graphics Some programmer-specified scene graph optimizations are available through capability bits, which state what operations can/cannot be carried out at runtime (e.g., prohibiting a shape from moving). Java 3D also permits the programmer to bypass the scene graph, either totally, by means of the immediate mode, or partially, via the mixed mode. Immediate mode gives the programmer greater control over rendering and scene management, but isnt often required. Mixed mode mixes the immediate and retained modes so a program can utilize lower-level rendering and a scene graph together. Retained mode programs (the default Java 3D coding style) only use the scene graph API.

Unique Features
Java 3Ds view model separates the virtual and physical worlds (through the ViewPlatform and View nodes). This makes it straightforward to reconfigure an application to utilize a range of output devices, from a monitor to eyeglasses with stereo displays to CAVEs (rooms with projected images covering every wall). Virtual world behavior is coded with Behavior nodes in the scene graph and triggered by events. Among other things, Behavior nodes offer a different style of animation based on responding to events instead of the usual update-redraw cycle used in most games programs. The core Java 3D API package, javax.media.j3d, supports basic polygons and triangles within a scene graph, while the com.sun.j3d packages add a range of utility classes, including ColorCube and SimpleUniverse, mouse and keyboard navigation behaviors, audio device handling, and loaders for several 3D file formats. Geometry compression is possible, often reducing size by an order of magnitude. When this is combined with Javas NIO and networking, it facilitates the ready transfer of large quantities of data between applications, such as multiplayer games. Java 3D supports both of the popular programmable shader languages, OpenGLs GLSL (the default), and NVIDIAs Cg. This allows programmer to create specialized rendering effects such as bump mapping and shadowsvery easily. Java 3D offers 2D and 3D audio output, with ambient and spatialized sound. Unfortunately, there are bugs in the sound system, so spatialized sound isnt available by default in Java 3D 1.5. Version 1.6 will probably include JOALMixer class instead, which will act as programming interface to a JOAL-based audio device. JOAL is a Java binding for a 3D audio API called OpenAL, which is supported by many sound cards.

Java Integration
offers object orientation, threads, exception handling can easily make use of other Java APIs (e.g. JMF and JAI)

Documentation and Examples

Criticisms of Java 3D for Games Programming


Java 3Ds Level of Abstraction
contains overhead because of optimizations that dont need to be implemented in a low-level API A powerful, high-level, and flexible 3D graphics API needs both a scene graph and a way to efficiently access the graphics pipeline. These two mechanisms are aimed at different levels in 3D graphics programming, sometimes called the entity level and the rendering level. An applications entity level requires a data structure for organizing the scene objects, while the rendering level handles light mapping, shadows, radiosity, vertex shading, and so on. Great games are designed at the entity level, in terms of game play, characters, scenarios, and story elements. The look and feel of a great gamethe light and dark, the atmosphereis created at the rendering level. Although Java 3D is best known for entity-level programming (via the scene graph), it also supports rendering-level coding. For example, Java 3D can perform vertex and pixel shading using either the GLSL or Cg shading languages. Its also possible to achieve some striking effects by employing multitextures, rendering attributes, and blending functions. - code is harder to tune for speed OpenGL or DirectX o programmer can move to Java 3Ds mixed or immediate modes - hiding of low-level graphics API harder to code around bugs in APIs or drivers

Java 3D Games
Java 3D Model Loaders for Games - tool for quickly populating game with people, artifacts, and scenery Extra Gaming Libraries

Java 3D Support

Alternatives to Java 3D
JOGL and LWJGL

Vous aimerez peut-être aussi