⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intro.html

📁 JAVA多媒体开发类库说明
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>  <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">  <title>The Java 3D API - Introduction</title></head><body><h2>Introduction to the Java 3D API</h2><p>The Java 3D API is an applicationprogramming interface used for writing three-dimensional graphicsapplications and applets. It gives developers high-level constructs forcreating and manipulating 3D geometry and for constructing thestructures used in rendering that geometry. Application developers candescribe very large virtual worlds using these constructs, whichprovide Java 3D with enough information to render these worldsefficiently.</p><p>Java 3D delivers Java's "write once, run anywhere"benefit todevelopers of 3D graphics applications. Java 3D is part of theJavaMedia suite of APIs, making it available on a wide range ofplatforms. It also integrates well with the Internet becauseapplications and applets written using the Java 3D API have access tothe entire set of Java classes.</p><p>The Java 3D API draws its ideas from existinggraphics APIs and fromnew technologies. Java 3D's low-level graphics constructs synthesizethe best ideas found in low-level APIs such as Direct3D, OpenGL,QuickDraw3D, and XGL. Similarly, its higher-level constructs synthesizethe best ideas found in several scene graph-based systems. Java 3Dintroduces some concepts not commonly considered part of the graphicsenvironment, such as 3D spatial sound. Java 3D's sound capabilitieshelp to provide a more immersive experience for the user.<br></p><p><i>NOTE: Prior to version 1.4, theJava&nbsp;3D API was formally specified by aseparate Java&nbsp;3D API Specification Guide, published separatelyfrom the javadoc. As of version 1.4,the javadoc-generated API reference is definitive. Relevant portions ofthe guide have been included here and supersede any previouslypublishedinformation.</i></p><p></p><h2>Programming Paradigm</h2>Java 3D is an object-oriented API. Applications construct individualgraphics elements as separate objects and connect them together into atreelike structure called a <em>scene graph</em>. The applicationmanipulates these objects using their predefined accessor, mutator, andnode-linking methods.<h3>The Scene Graph ProgrammingModel</h3>Java 3D's scene graph-based programming model provides a simple andflexible mechanism for representing and rendering scenes. The scenegraph contains a complete description of the entire scene, or virtualuniverse. This includes the geometric data, the attribute information,and the viewing information needed to render the scene from aparticular point of view. The "<a href="SceneGraphOverview.html">SceneGraph Basics</a>" document provides more information on the Java 3Dscene graph programming model.<p>The Java 3D API improves on previous graphics APIsby eliminating manyof the bookkeeping and programming chores that those APIs impose. Java3D allows the programmer to think about geometric objects rather thanabout triangles-about the scene and its composition rather than abouthow to write the rendering code for efficiently displaying the scene.</p><p></p><h3>Rendering Modes</h3>Java 3D includes three different rendering modes: immediate mode,retained mode, and compiled-retained mode (see "<a href="Rendering.html">Executionand Rendering Model</a>").Each successive rendering mode allows Java 3D more freedom inoptimizing an application's execution. Most Java 3D applications willwant to take advantage of the convenience and performance benefits thatthe retained and compiled-retained modes provide.<h4>Immediate Mode</h4>Immediate mode leaves little room for globaloptimization at the scene graph level. Even so, Java 3D has raised thelevel of abstraction and accelerates immediate mode rendering on aper-object basis. An application must provide a Java 3D draw methodwith a complete set of points, lines, or triangles, which are thenrendered by the high-speed Java 3D renderer. Of course, the applicationcan build these lists of points, lines, or triangles in any manner itchooses.<h4>Retained Mode</h4>Retained mode requires an application to construct a scene graph andspecify which elements of that scene graph may change during rendering.The scene graph describes the objects in the virtual universe, thearrangement of those objects, and how the application animates thoseobjects.<h4>Compiled-Retained Mode</h4>Compiled-retained mode, like retained mode, requires the application toconstruct a scene graph and specify which elements of the scene graphmay change during rendering. Additionally, the application can compilesome or all of the subgraphs that make up a complete scene graph. Java3D compiles these graphs into an internal format. The compiledrepresentation of the scene graph may bear little resemblance to theoriginal tree structure provided by the application, however, it isfunctionally equivalent. Compiled-retained mode provides the highestperformance.<h3>Extensibility</h3>Most Java 3D classes expose only accessor and mutator methods. Thosemethods operate only on that object's internal state, making itmeaningless for an application to override them. Therefore, Java 3Ddoes not provide the capability to override the behavior of Java 3Dattributes. To make Java 3D work correctly, applications must call "<code>super.setXxxxx</code>"for any attribute state set method that is overridden.<p>Applications can extend Java 3D's classes and addtheir own methods.However, they may not override Java 3D's scene graph traversalsemantics because the nodes do not contain explicit traversal and drawmethods. Java 3D's renderer retains those semantics internally.</p><p>Java 3D <em>does</em> provide hooks for mixingJava 3D-controlled scene graph rendering and user-controlled renderingusing Java 3D's immediate mode constructs (see "<a href="Immediate.html#Mixed">Mixed-Mode Rendering</a>"). Alternatively,the application canstop Java 3D's renderer and do all its drawing in immediate mode (see "<a href="Immediate.html#PureImmediate">Pure Immediate-Mode Rendering</a>").</p><p>Behaviors require applications to extend theBehavior object and tooverride its methods with user-written Java code. These extendedobjects should contain references to those scene graph objects thatthey will manipulate at run time. The "<a href="Behaviors.html">Behaviorsand Interpolators</a>" document describes Java 3D's behaviormodel.</p><p></p><h2>High Performance</h2>Java 3D's programming model allows the Java 3D API to do the mundanetasks, such as scene graph traversal, managing attribute state changes,and so forth, thereby simplifying the application's job. Java 3D doesthis without sacrificing performance. At first glance, it might appearthat this approach would create more work for the API; however, itactually has the opposite effect. Java 3D's higher level of abstractionchanges not only the amount but, more important, also the kind of workthe API must perform. Java 3D does not need to impose the same type ofconstraints as do APIs with a lower level of abstraction, thus allowingJava 3D to introduce optimizations not possible with these lower-levelAPIs.<p>Additionally, leaving the details of rendering toJava 3D allows it totune the rendering to the underlying hardware. For example, relaxingthe strict rendering order imposed by other APIs allows paralleltraversal as well as parallel rendering. Knowing which portions of thescene graph cannot be modified at run time allows Java 3D to flattenthe tree, pretransform geometry, or represent the geometry in a nativehardware format without the need to keep the original data.</p><p></p><h3>Layered Implementation</h3>Besides optimizations at the scene graph level, one of the moreimportant factors that determines the performance of Java 3D is thetime it takes to render the visible geometry. Java 3D implementationsare layered to take advantage of the native, low-level API that isavailable on a given system. In particular, Java 3D implementationsthat use Direct3D and OpenGL are available. This means that Java 3Drendering will be accelerated across the same wide range of systemsthat are supported by these lower-level APIs.<h3>Target Hardware Platforms</h3>Java 3D is aimed at a wide range of 3D-capable hardware and softwareplatforms, from low-cost PC game cards and software renderers at thelow end, through midrange workstations, all the way up to veryhigh-performance specialized 3D image generators.<p>Java 3D implementations are expected to provideuseful rendering rateson most modern PCs, especially those with 3D graphics acceleratorcards. On midrange workstations, Java 3D is expected to provideapplications with nearly full-speed hardware performance.</p><p>Finally, Java 3D is designed to scale as theunderlying hardwareplatforms increase in speed over time. Tomorrow's 3D PC gameaccelerators will support more complex virtual worlds than high-pricedworkstations of a few years ago. Java 3D is prepared to meet thisincrease in hardware performance.</p><p></p><h2><a name="Structuring"></a>Structuring the Java 3D Program</h2><p>This section illustrates how a developer mightstructure a Java 3D application. The simple application in this examplecreates a scene graph that draws an object in the middle of a windowand rotates the object about its center point.</p><h3>Java 3D Application SceneGraph</h3><p>The scene graph for the sample application is shown below.</p><p>The scene graph consists of superstructurecomponents&#8212;a VirtualUniverseobject and a Locale object&#8212;and a set of branch graphs. Each branchgraph is a subgraph that is rooted by a BranchGroup node that isattached to the superstructure. For more information, see "<a href="SceneGraphOverview.html">Scene Graph Basics</a>."</p><p><a name="Figure_1"></a><img style="width: 500px; height: 263px;" alt="Applicationscene graph" title="Application scene graph" src="intro.gif"></p><p></p><ul>  <font size="-1"><b><i>Figure 1 &#8211; </i>Application Scene Graph</b></font></ul><p>A VirtualUniverse object defines a named universe. Java 3D permits thecreation of more than one universe, though the vast majority ofapplications will use just one. The VirtualUniverse object provides agrounding for scene graphs. All Java 3D scene graphs must connect to aVirtualUniverse object to be displayed. For more information, see "<a href="VirtualUniverse.html">Scene Graph Superstructure</a>."</p><p>Below the VirtualUniverse object is a Locale object.The Locale objectdefines the origin, in high-resolution coordinates, of its attachedbranch graphs. A virtual universe may contain as many Locales asneeded. In this example, a single Locale object is defined with itsorigin at (0.0, 0.0, 0.0).</p><p>The scene graph itself starts with the <a href="../BranchGroup.html">BranchGroup</a>nodes.A BranchGroup serves as the root of asubgraph, called a <em>branch graph</em>, of the scene graph. OnlyBranchGroup objects can attach to Locale objects.</p><p>In this example there are two branch graphs and,thus, two BranchGroupnodes. Attached to the left BranchGroup are two subgraphs. One subgraphconsists of a user-extended Behavior leaf node. The Behavior nodecontains Java code for manipulating the transformation matrixassociated with the object's geometry.</p><p>The other subgraph in this BranchGroup consists of aTransformGroupnode that specifies the position (relative to the Locale), orientation,and scale of the geometric objects in the virtual universe. A singlechild, a Shape3D leaf node, refers to two component objects: a Geometryobject and an Appearance object. The Geometry object describes thegeometric shape of a 3D object (a cube in our simple example). TheAppearance object describes the appearance of the geometry (color,texture, material reflection characteristics, and so forth).</p><p>The right BranchGroup has a single subgraph thatconsists of aTransformGroup node and a ViewPlatform leaf node. The TransformGroupspecifies the position (relative to the Locale), orientation, and scaleof the ViewPlatform. This transformed ViewPlatform object defines theend user's view within the virtual universe.</p><p>Finally, the ViewPlatform is referenced by a Viewobject that specifiesall of the parameters needed to render the scene from the point of viewof the ViewPlatform. Also referenced by the View object are otherobjects that contain information, such as the drawing canvas into whichJava 3D renders, the screen that contains the canvas, and informationabout the physical environment.</p><p></p><h3>Recipe for a Java 3D Program</h3><p>The following steps are taken by the example program to create thescene graph elements and link them together. Java 3D will then renderthe scene graph and display the graphics in a window on the screen:</p><ul>1. Create a Canvas3D object and add it to the Applet panel.  <p>2. Create a BranchGroup as the root of the scene branch graph.</p>  <p>3. Construct a Shape3D node with a TransformGroup node above it.</p>  <p>4. Attach a RotationInterpolator behavior to the TransformGroup.</p>  <p>5. Call the simple universe utility function to do the following:</p>  <ul>a. Establish a virtual universe with a single high-resolution Locale(see "<a href="SceneGraphOverview.html">Scene Graph Basics</a>").    <p>b. Create the PhysicalBody, PhysicalEnvironment, View, andViewPlat-form objects.</p>    <p>c. Create a BranchGroup as the root of the view platform branchgraph.</p>    <p>d. Insert the view platform branch graph into the Locale.</p>  </ul>6. Insert the scene branch graph into the simple universe's Locale.</ul><p>The Java 3D renderer then starts running in an infinite loop. Therenderer conceptually performs the following operations:</p><pre>    while(true) {<br>        Process input<br>        If (request to exit) break<br>        Perform Behaviors<br>        Traverse the scene graph and render visible objects<br>    }<br>    Cleanup and exit<br></pre><h3>HelloUniverse: A Sample Java3D Program</h3><p><a href="HelloUniverse.html">Click here</a> to see code fragmentsfrom a simple program, <code>HelloUniverse.java</code>,that creates a cube and a RotationInterpolator behavior object thatrotates the cube at a constant rate of pi/2 radians per second.<br></p><h2>Other Documents<br></h2><p>Here are other documents that provide explanatory material,previously included as part ofthe Java 3D API Specification Guide.<br></p><ul>  <li><a href="Concepts.html">Java 3D Concepts</a></li>  <li><a href="SceneGraphOverview.html">Scene Graph Basics</a></li>  <li><a href="VirtualUniverse.html">Scene Graph Superstructure</a></li>  <li><a href="SceneGraphSharing.html">Reusing Scene Graphs</a></li>  <li><a href="ViewModel.html">View Model</a></li>  <li><a href="Behaviors.html">Behaviors and Interpolators</a></li>  <li><a href="Rendering.html">Execution and Rendering Model</a></li>  <li><a href="Immediate.html">Immediate-Mode Rendering</a></li></ul><p><br></p></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -