Lee's Lessons
Basic Geometry
This demonstrates the ease and
flexibility of Java3D by showing just a red sphere. This code is a GREATLY stripped down version of MoveViewer.java.
The name of the java file is BasicGeometry.java. It does the basics of Java3D without all the mumbo-jumbo of the
examples of Java3D. It creates a basic universe, a branch group, a transform group and a shape. The lighting is
direct lighting but I will get into ambient and other types of lighting later. The lighting is created when the
branch group is created. To make it a little different the light comes from above and is a red light. You can play
around with the code by changing the color of the light and the direction using the Vector3D object right below
the color definition. The shape is one of the basic shapes that comes with Java3D. Its verticies have been laid
out for you. The appearance is not defined so is basically just a reflective ball. This example was just to put
up a geometry in a scene. The transform group just places the sphere in the middle of the scene. The basic universe
with a default viewing plane is used to set the proper front clipping plane. You can also change the placement
of the sphere by changing the Transform3D object. You can change the scale of the ball in the Shape constructor.
It is now 0.5f.
As usual. The code is open source. Play with it, change it, enjoy.
BasicGeometry.java
|