Posts

Showing posts from August, 2016

3.4 Summary | JAVA 3D Programming | Chapter 3

Image
3.4 Summary This example has rather plunged you in at the deep−end of the Java 3D pool. I hope you have enjoyed the guided tour of some of the capabilities of Java 3D. In the chapters to come we will be picking apart many of the features listed and showing you how to get the most out of them for your Java 3D application. Do not be too concerned if the example code presented in this chapter looks very intimidating, and the descriptions were too vague. You can refer to this example as topics such as scenegraphs, geometry, and appearances are explained in detail in later chapters. This example should have given you a sense of the power of Java 3D and can serve as a good test bed for experimenting with your own applications or trying out the ideas presented in later chapters. Before you start designing your application, it is important that you understand the data structure that underlies Java 3D rendering—the scenegraph. Once you have a firm grasp of it you will quickly be...

3.3 Exercises for the reader | JAVA 3D Programming | Chapter 3

Image
3.3 Exercises for the reader When you run the example, I would encourage you to make some changes and see their effects. For example: Colors and lighting See how the color of the Material and the color of the directional light interact to produce the actual rendered color. Sophisticated lighting equations are at work to combine the effects of both at runtime. Try changing the shininess parameter to (80.0f) to increase or decrease the apparent shininess of the smaller Sphere. Try removing the setMaterial call and see how rendering is affected. Animation parameters The Alpha class that is used to control the PositionInterpolator can be parameterized using nine variables (figure 3.2) to produce a sophisticated timing function. Figure 3.2 The phases of the Alpha class: trigger time (1), phase delay (2), increasing alpha (3), increasing alpha ramp (4), at one (5), decreasing alpha (6), decreasing alpha ramp (7), at zero (8), loop count (9) I’ll discu...

3.2 Your first Java 3D application | JAVA 3D Programming | Chapter 3

Image
3.2 Your first Java 3D application          The SimpleTest example (figure 3.1) is intended to build upon the HelloUniverse example that comes with the Java 3D distribution. I’ve attempted to expand upon HelloUniverse by documenting the relationships between the various constructs used in the example and showcasing some of the features of Java 3D that enable you to build fairly complex applications with very little code. This example is 280 lines (less than 100 without comments) and illustrates some fairly complex functionality: Figure 3.1 The SimpleTest example. One hundred lines of Java code give you an animated scene, including a  graphical textured background with directional lighting Background geometry, in this case the scene is placed within a Sphere.  Textured geometry, an image is applied to the inside of the background Sphere to give the illusion of a distant skyline. Lighting, a single directional light is created t...

3.1.6 Java class decompiler (optional) | JAVA 3D Programming | Chapter 3

Image
3.1.6 Java class decompiler (optional) When things get really sticky and you can’t understand what Java 3D is doing it can be useful to decompile the Java 3D class files. You will need to decompress the Java 3D JAR files and extract the class files prior to decompling them. A popular (and free) decompiler is JAD (JAva Decompiler). Find it at http://www.geocities.com/SiliconValley/Bridge/8617/jad.html .  Ok good luck, See you in next tutorial

3.1.5 Performance analysis tools (optional) | JAVA 3D Programming | Chapter 3

Image
3.1.5 Performance analysis tools (optional) As you formalize your designs and requirements it is often helpful to drop into a performance measurement tool to see where your code is spending its time. Two popular commercial tools for Java optimization are:   OptimizeIt, VMGear ( http://www.vmgear.com ) JProbe, Sitraka ( http://www.sitraka.com/software/jprobe/ ) You can also use the free (but harder to interpret) performance measurement capabilities of the Java 2 JVM. See the documentation for the java –Xprof argument for details. Ok good luck, See you in next tutorial

3.1.4 Java 2 development environment (optional) | JAVA 3D Programming | Chapter 3

Image
3.1.4 Java 2 development environment (optional) Every developer has their favorite programmer’s editor, and an increasing number of Integrated Development Environments (IDEs) are available that support Java 2. They range from free to expensive, and have a wide variety of features. Some of the more popular IDEs for Java 2 development are: Kawa, Allaire ( http://www.allaire.com/ ) All the examples for this book were built using Kawa. Unfortunately, after Allaire was acquired by Macromedia, development of Kawa was discontinued. JBuilder, Borland ( http://www.inprise.com/jbuilder/ ) Emacs, GNU ( http://www.gnu.org/software/emacs/ ) Visual CaféWebGain ( http://www.webgain.com/Products/VisualCafe_Overview.html ) NetBeans ( http://www.netbeans.org ) Eclipse (Open Source, IBM) ( http://www.eclipse.org/ ) IntelliJ IDEA ( http://www.intellij.com/ ) Ok good luck, See you in next tutorial :)

3.1.3 Documentation | JAVA 3D Programming | Chapter 3

Image
3.1.3 Documentation Java 3D programming involves general Java programming, high−performance programming, 3D graphics algorithms, 2D graphics programming, UI design, and many other issues. A good reference library or collection of electronic bookmarks will save you a lot of time and help you to avoid some of the pitfalls that have befallen your predecessors. Though far from exhaustive, the list of references which follows should give you some indication of fruitful areas to start researching. Java 2 SDK JavaDoc and reference books—Java 2 is a complex technology. If you are going to write good Java 3D code you are going to require the latest Java 2 documentation and some good reference books. Swing reference book—If you are developing an application that uses Swing (JFC) for the UI you will want to get a good Swing reference book. These weighty tomes can save you a lot of time during development. A good place to start is Swing by Mathew Robinson and Pavel Vorobiev (...

3.1.2 Java 3D 1.2 JDK | JAVA 3D Programming | Chapter 3

Image
3.1.2 Java 3D 1.2 JDK Download the latest release of the Java 3D SDK at http://www.javasoft.com/products/java−media/3D/index.html . The OpenGL version of Java 3D has historically been more stable and ahead of the DirectX release in terms of features. At the time of print the latest release is Java 3D 1.2.1. You should install Java 3D into the same directory as the Java 2 SDK, typically c:\jdk1.3. This will ensure that all your Java 2 demo applications are installed into the same place. You can then use REGEDIT to edit the Windows registry to remove all references to the JRE installation directory (which is also installed when you install the SDK). Replace all occurrences of c:\program files\javasoft\jre\1.3\… with the SDK installation location, usually c:\jdk1.3\jre\… This will enable running the Java 3D demos from the command line, and ensure that only one Java 2 runtime environment is installed on your machine.                Do...

3.1.1 Java 2 SDK | JAVA 3D Programming | Chapter 3

Image
3.1.1 Java 2 SDK Check the Sun web site ( http://java.sun.com ) and download the latest release. Java 2 SDK 1.3.1 (JDK 1.3.1) is the latest release at the time of print. You can also find it at http://www.javasoft.com/j2se/1.3/ .  Remove all previous versions of the SDK, JDK, or JRE prior to installing the new SDK. After installation launch the Java plug−in control applet from the Windows Control Panel and set the Java Runtime Environment (JRE) to the newly installed SDK location. This will enable running Java 3D applets using the Java 2 plug−in. Ok good luck, See you in next tutorial :)

3.1 Installation | JAVA 3D Programming | Chapter 3

Image
3.1 Installation Our first step, obviously, is to install everything we need for Java 3D development. Refer to appendix B and the bibliography for useful sources of information or additional help. Ok good luck, See you in next tutorial  :)

3D Graphics Programming | Chapter 3

Image
CHAPTER 3 Getting started, Hello Java 3D! 3.1 Installation 3.2 Your first Java 3D application 3.3 Exercises for the reader 3.4 Summary Now the fun begins. It’s time to begin conquering the Java 3D development environment, setting ourselves up for serious Java 3D fun in the chapters to come. I’ll introduce a realistic Java 3D application to test your configuration, and allow you to experiment with some of the features described in later chapters. You’ll look at a simple Java 3D example, SimpleTest, that illustrates building an AWT−based Java 3D application. The SimpleTest example uses the Sun utility classes MainFrame and SimpleUniverse (included with your Java 3D distribution) to hide some of the complexities that we will be delving into in the chapters to come. Ok good luck, See you in next tutorial

2.5 Summary | JAVA 3D Programming | Chapter 2

Image
2.5 Summary The MyJava3D example application should have demystified some of the magic of 3D rendering and provided the opportunity to experiment with and test your own rendering functionality. A useful exercise would be to add some form of depth sorting or a Z−buffer to the AwtRenderingEngine. With some enhancements, it might be useful in its own right as a lightweight 100 percent Java rendering engine. The example reinforces how much more convenient it is to leverage a graphics API such as Java 3D. Not only does Java 3D handle (through OpenGL or Direct3D) low−level issues such as Z−buffering, but it also defines classes for specifying geometry and a rendering abstraction called the scenegraph. The next chapter steps you through creating your first simple Java 3D application, so let’s go!

2.4 Putting it together—MyJava3D | JAVA 3D Programming | Chapter 2

Image
2.4 Putting it together—MyJava3D The MyJava3D example defines the RenderingEngine interface. This interface defines a simple rendering contract between a client and a 3D renderer implementation. The RenderingEngine interface defines a simple renderer that can render 3D geometry described using a Java 3D GeometryArray. The GeometryArray contains the 3D points and normal vectors for the 3D model to be rendered. In addition to adding GeometryArrays to the RenderingEngine (addGeometry method), the viewpoint of the viewer can be specified (setViewAngle), the direction of a single light can be specified (setLightAngle), the scaling factor to be applied to the model can be varied (setScale), and the size of the rendering screen defined (setScreenSize). To render all the GeometryArrays added to the RenderingEngine using the current light, screen, scale, and view parameters, clients can call the render method, supplying a Graphics object to render into, along with an option...