

































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Encontra documentos específicos para os exames da tua universidade
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Tutorial Java3D - Visão Geral Permission to use, copy, modify, and distribute this documentation for NON-COMMERCIAL purposes and without fee is hereby granted provided that this copyright notice appears in all copies.
Tipologia: Notas de estudo
1 / 41
Esta página não é visível na pré-visualização
Não perca as partes importantes!


































tutorial v1.5 (Java 3D API v1.1.2)
Getting Started with Java 3D Tutorial Preface
The Java 3D Tutorial
© 1999 Sun Microsystems, Inc. 2550 Garcia Avenue, Mountain View, California 94043-1100 U.S.A All Rights Reserved.
The information contained in this document is subject to change without notice.
SUN MICROSYSTEMS PROVIDES THIS MATERIAL "AS IS" AND MAKES NO WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SUN MICROSYSTEMS SHALL NOT BE LIABLE FOR ERRORS CONTAINED HEREIN OR FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS IN CONNECTION WITH THE FURNISHING, PERFORMANCE OR USE OF THIS MATERIAL, WHETHER BASED ON WARRANTY, CONTRACT, OR OTHER LEGAL THEORY).
THIS DOCUMENT COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY MADE TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION. SUN MICROSYSTEMS, INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR PROGRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME.
Some states do not allow the exclusion of implied warranties or the limitations or exclusion of liability for incidental or consequential damages, so the above limitations and exclusion may not apply to you. This warranty gives you specific legal rights, and you also may have other rights which vary from state to state.
Permission to use, copy, modify, and distribute this documentation for NON-COMMERCIAL purposes and without fee is hereby granted provided that this copyright notice appears in all copies.
This documentation was prepared for Sun Microsystems by K Computing (530 Showers Drive, Suite 7-225, Mountain View, CA 94040, 770-982-7881, www.kcomputing.com). For further information about course development or course delivery, please contact either Sun Microsystems or K Computing.
Java, JavaScript, Java 3D, HotJava, Sun, Sun Microsystems, and the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. All other product names mentioned herein are the trademarks of their respective owners.
Getting Started with Java 3D Tutorial Preface
Getting Started with Java 3D Tutorial Preface
Welcome to version 1.5 of The Java 3D API Tutorial. This tutorial contains seven chapters explaining the most frequently used features of the Java 3D API.
Since the tutorial has been developed and released incrementally, several versions of the tutorial exist. For this reason the revision history may be important to readers of earlier versions. The following table presents the revision history for the tutorial.
Table 0-1 Revision History of the Tutorial.
tutorial version
date new chapter(s) major revision of chapters*
minor revision of chapters*
1.0 Feb 99 1 and 2 n/a n/a
1.1 Apr 99 0 and 6 1 and 2 n/a
1.2 May 99 3 0 and 2 1 and 6
1.3 Jun 99 4 0 1, 2, 3 and 6
1.4 August 99 5 0, 1 and 4 2, 3, and 6
1.5 October 99 7 0 1, 2, 3, 4, 5, and 6
*For the purposes of this table, a major revision is a change to fix a mistake of fact in some part of the chapter. It could be as little as little as changing one line of code, fixing a single sentence, or adding something inadvertently omitted, but involves a fix of substance. A minor revision is a change that does not affect the meaning of the chapter (e.g. formatting, or including new links in the PDF file).
The tutorial is a collection of modules. Each Module is a collection of chapters (except this one, Module 0 has only one chapter, Chapter 0). The chapters in a Module are related. See section 0.1.2 for more information on module and chapter dependencies.
With each chapter of the tutorial being published as separate documents, the following features have been employed:
Getting Started with Java 3D Tutorial Preface
Here is a listing of the table of contents for each of the published chapters. If you are reading this online you can use the links to the appropriate place in the appropriate document.
1.1 What is Java 3D...................................................................................... 1- 1.2 The Java 3D API .................................................................................... 1- 1.3 Building a Scene Graph........................................................................... 1- 1.4 A Basic Recipe for Writing Java 3D Programs ........................................ 1- 1.5 Some Java 3D Terminology..................................................................... 1- 1.6 Simple Recipe Example: HelloJava3Da ................................................... 1- 1.7 Rotating the Cube ................................................................................... 1- 1.8 Capabilities and Performance .................................................................. 1- 1.9 Adding Animation Behavior .................................................................... 1- 1.10 Chapter Summary ................................................................................... 1- 1.11 Self Test ................................................................................................. 1-
2.1 Virtual Universe Coordinate System ........................................................ 2- 2.2 Visual Object Definition Basics............................................................... 2- 2.3 Geometric Utility Classes ........................................................................ 2- 2.4 Mathematical Classes.............................................................................. 2- 2.5 Geometry Classes.................................................................................... 2- 2.6 Appearance and Attributes ...................................................................... 2- 2.7 Self Test ................................................................................................. 2-
Module 3: Lights and Textures
Getting Started with Java 3D Tutorial Preface
Throughout the tutorial are reference blocks - summaries of the API for certain classes. The reference blocks are provided in the tutorial to make reading easier, not to replace the Java 3D API Specification Guide or any other reference. The reference blocks were checked for accuracy when this document was published, but the Java 3D API may have changed. If you are having trouble with a program, be sure to check a current edition of the Java 3D API Specification. Also, refer to section 2.2 (page 2-4) for more information on reference blocks.
This is a tutorial for the Java 3D API version 1.1.2. It is composed of the text (this document), several other text documents and a number of example applications. The text of the tutorial is available in the Acrobat (PDF) file format. The PDF files include thumbnails, links, and bookmarks making them easier to use online. The files are also readable in hardcopy form. However, several of the images are in color and details are lost when printed monochromatically.
The tutorial documents are available online with the source for the example programs, all of which can be downloaded from http://java.sun.com/products/java-media/3D/collateral/
This tutorial is meant for the Java programmer with some graphics experience, with little or no knowledge of Java 3D. If in addition to being familiar with Java you are familiar with the terms pixel, image plane, RGB, and render, then you have the background to proceed. You don’t need to know about z-buffer, 3D transforms, or any other 3D graphics API to understand this tutorial, but it may help. In any case, this tutorial is written to be very accessible.
As with all of our products, we strive for excellence in quality. If you have any questions, comments, or have an error to report, please consult the Java 3D Home Page, http://www.java.sun.com/products/java-media/3D, for contact information.
Double outline sections are advanced sections
Single outline sections are document meta-information sections
Consult the Java 3D Home Page for the most current information.
The cover image is of a twisted strip rendered by Java 3D. The program is discussed in Section 2.6. The code is available with the examples distributed with this tutorial.
Getting Started with Java 3D Tutorial Preface
All software associated with this tutorial is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
This software included with this tutorial is not designed or intended for use in on-line control of aircraft, air traffic, aircraft navigation or aircraft communications; or in the design, construction, operation or maintenance of any nuclear facility. Licensee represents and warrants that it will not use or redistribute the Software for such purposes.
Getting Started with the Java 3D API A. Summary of Example Programs
A ColorCube orbits around the origin in this program. The code of this program does not appear in the text of the tutorial. It simply demonstrates a use of the Axis.java class (see above).
This code is an example of a class that defines a number of color constants. The application spins the yo-yo about the y-axis to show the geometry.
This program displays a yo-yo using four TriangleFanArray geometry objects with colors. The application spins the yo-yo about the y-axis to show the geometry.
This program displays a yo-yo created with two Cone objects. A default Appearance object is used. The application spins the yo-yo about the y-axis to show the geometry.
This program displays a twisted strip as an example of using the TriangleStripArray. The twist strip program also demonstrates culling.
This program displays a yo-yo visual object created with four TriangleFanArray objects. A default Appearance object is used. The application spins the yo-yo about the y-axis to show the geometry.
This program displays the TriangleFanArray object with the Appearance set to display lines only. The application spins the yo-yo about the y-axis to show the geometry.
This program displays the TriangleFanArray object with the Appearance set to points lines only. The application spins the yo-yo about the y-axis to show the geometry.
Getting Started with the Java 3D API A. Summary of Example Programs
This application demonstrates defining geometry for the background of a virtual world. The scene is of a grid of lines to represent the ground, a PointArray for stars, and a LineArray for a constellation. The stars and constellation are in the background. The viewer can move around in the scene and experience the relative motion between the ground and the stars in the background.
The interaction (motion) is provided through the KeyNavigator class (documented in Chapter 4) and a BoundingLeaf application bounds, which provides interaction in the virtual world without bounds. The BoundingLeaf is added to the view branch graph in this application.
This application demonstrates the use of the GeometryInfo class to create Java 3D geometry specified by arbitrary polygons. This application creates the surface of a car using polygons. The Triangulator, Stripifier, and NormalGenerator classes are used to convert the polygons into triangle strips with normals so the specified geometry can be shaded. A wire frame view of the geometry can be viewed by providing any command line argument when invoking the program. For example: java GeomInfoApp -lines will show the wire frame instead of the shaded surfaces.
A simple example of using the Text2D object to add text to a Java 3D virtual world. The Text2D object rotates in the virtual world.
A simple example of using the Text3D object to add text to a Java 3D virtual world. The Text3D object rotates in the virtual world.
The programs collected in the examples/Interaction subdirectory correspond to the topics presented in Chapter 4. Creating and using behaviors to provide user interaction is the subject of the chapter.
This program demonstrates using the postId() method and WakeupOnBehaviorPost WakeupCriterion objects to coordinate behavior objects. In this program two behavior classes are defined: OpenBehavior and CloseBehavior. Then one instance of each behavior class are used to open and close a door. Actually, a ColorCube is used as a stand-in for the door.
This program demonstrates using a KeyNavigatorBehavior object to provide keyboard based viewer navigation in the virtual world. The user is able to press keys to move forward, back, left, right, up and down as well as rotate left, right, up and down.
Getting Started with the Java 3D API A. Summary of Example Programs
This program illustrates the billboard behavior provided by Billboard Class objects. A Billboard object orients a visual object such that it always faces the viewer. The user of this program is free to navigate the virtual world using the arrow keys. Refer to Section 5.3 for more information on applications and API of the Billboard Class.
This program uses one Alpha object and one RotationInterpolator to rotate an analog clock face once per minute. The clock face, defined in Clock.java, is constructed from one Alpha object and two RotationInterplotors. The main program, in ClockApp.java, is a simple example of using a RotationInterpolator. The construction of the clock is somewhat more complex.
This program illustrates six different interpolator classes in one scene to illustrate the variety of interpolator classes available.
This program uses a DistanceLOD object to represent a visual object as one of several different geometric representations of varying levels of detail. The DistanceLOD object picks one of the geometric representations based on the distance between the visual object and the viewer.
In this program, a custom behavior classes animates a stick figure walking based on four GeometryArray object key frames. Of course, to truly appreciate the animations, you have to run the program.
In this program, three other behavior classes create animations based on some, or all, of the GeometryArray objects of MorphApp. They are called (left to right in the figure) "In Place", "Tango", and "Broken". Not all of the animations are good. Of course, to truly appreciate the animations, you have to run the program.
This program renders a scene where three planes are lit by three different lights. One light is directional, one is a point light, and one is a spot light. See Figure 6-16.
This program is a basic example of using lights. It renders a scene with a plane and a sphere. See Figure 6-2.
This program is a basic example of using lights. It renders a scene with a single sphere. See Figure 6-15, among others.
This program demonstrates the lighting of a two sided object (setBackFaceNormalsFlip()).See Figure 6-21.
Getting Started with the Java 3D API A. Summary of Example Programs
This program demonstrates the use of scoping to limit the influence of light sources. See Figure 6-25.
This program illustrates the difference between local eye lighting and infinite eye lighting. See Figure 6-29.
This program demonstates SimpleShadow class. SimpleShadow creates shadow polygons for simple visual objects in certain scenes. See Figure 6-28.
This program renders a static scene of nine spheres with different material properties. The only difference among the material properties of the spheres is the shininess value. See Figure 6-20.
This program illustrates the difference various values for the spot light parameters make in rendering. See Figure 6-18.
This program loads a single texture image into four Texture2D objects for use with four visual objects. Each of the four textures are configured with a Boundary Color and different Boundary Mode settings. The resulting image illustrates the interaction between the Boundary Mode setting in the presence of a Boundary Color.
This program loads a single texture image into four Texture2D objects for use with four visual objects. Each of the four textures are configured with a different set of Boundary Mode settings (CLAMP or WRAP). The resulting image illustrates the possible combinations of Boundary Mode setting for a 2D texture.
This program loads a single texture image into a Texture2D object with the MIPmap Mode set to MULTI_LEVEL. The images for each level (other than the base level) are created at runtime from the loaded base image by the TextureLoader utility. Compare this program to MIPmapApp2.
This program loads multiple texture images into a Texture2D object with the MIPmap Mode set to MULTI_LEVEL. Each image is loaded by the TextureLoader utility. Compare this program to MIPmapApp.
This program loads multiple texture images into a Texture2D object with the MIPmap Mode set to MULTI_LEVEL. Each image is loaded by the TextureLoader utility. The texture images used distinguish this application from the typical MIPmap application. The textures are solid color and alternate between red and green on each level. The resulting image shows how textures from a variety of levels can be used for a single visual object.
Getting Started with the Java 3D API B. Reference Material
Henry Sowizral, Kevin Rushforth, and Michael Deering, The Java 3D API Specification , Addison- Wesley, Reading, Mass., December 1997. ISBN 0-201-32576- This book describes version 1.0 of the Java 3D API. There are some differences between this specification and the current release of the product. It is comprehensive in coverage, but not intended as a programmer’s guide. It is also available online at http://java.sun.com/products/java-media/3D It is also available in Japanese: translated by Yukio Andoh, Rika Takeuchi; ISBN 4-7561-3017-
Ken Arnold and James Gosling, The Java Programming Language , Addison-Wesley, Reading, Mass. The Java reference.
David M. Geary, graphic JAVA Mastering the AWT , Sunsoft Press, 1997 Complete coverage of the AWT.
Foley, vanDam, Feiner, and Hughes, Computer Graphics , Addison-Wesley This book is widely considered the “bible of computer graphics”. Comprehensive coverage of general computer graphics concepts including representation of points, lines, surfaces, and transformations. Other topics include projection, texturing, z-buffer, and many, many others.
OpenGL ARB, OpenGL Programming Guide , Addison-Wesley While not directly related, this book provides a good foundation in graphics programming via the OpenGL API. Java 3D resembles OpenGL in many ways and some implementations of Java 3D are built on an OpenGL implementation.
http://java.sun.com/products/java-media/3D/
Follow the "Java 3D Implementation" link to the download.html page. Also from this page, you can download documentation for Java 3D API classes.
For additional information, refer to these Sun Microsystems pages on the World Wide Web:
http://java.sun.com/products/java-media/3D
The Java 3D marketing homepage, this links to many related pages.
http://java.sun.com/
The Java Software web site, with the latest information on Java technology, product information, news, and features.
Getting Started with the Java 3D API B. Reference Material
http://java.sun.com/products/jdk/1.2/ JDK 1.2 Product and Download Page
http://java.sun.com/docs Java Platform Documentation provides access to white papers, the Java Tutorial and other documents.
http://developer.java.sun.com/ The Java Developer Connection web site. (Free registration required.) Additional technical information, news, and features; user forums; support information, and much more.
http://java.sun.com/products/ Java Technology Products & API
http://www.sun.com/solaris/java/ Java Development Kit for Solaris - Production Release
For additional information, refer to the the Java 3D web page for links to related resources.