A Brief "Plain English" Introduction to Java3D Concepts
Construction of a Virtual World
To create a virtual world we can use Sun's convenience class "SimpleUniverse". This will create for us a ViewPlatform and a SceneGraph. We then add a "BranchGroup". A BranchGroup is the handle to which we can add objects to our world.
Let's call our BranchGroup "BG". We add an object to our scene via BG.addChild(object). Objects could be many things, not all of which are "physical". We can add Shape3Ds (our typical physical actual object), lights, behaviors, sounds, etc. Most of our scene creation is going to be built from Shape3Ds or groups of Shape3Ds.
A Shape3D consists of geometry and appearance. Geometry is made from a series of points (vertices), a form of "connect the dots". For example a triangle is defined by three vertices. Each vertex is defined by an x,y,z set of coordinates (where it is in the world). Four vertices would make a rectangle. A lot of objects will be formed by combining rectangles - for instance a wall is simply a set of rectangles (front, back, sides, top). We can group several rectangles together using a "TransformGroup". The TransformGroup can then be moved, rotated and hence positioned in our virtual world.
We can move through our world by moving our ViewPlatform. It's that simple. Ok, it takes a few lines of code to get the TransformGroup which controls the viewing platform from a SimpleUniverse. Once we have the transform group for the viewing platform we can navigate by translating (moving) and/or rotating that view (looking up/down/left/right).
Back to our Shape3D. Remember we said it has both geometry and appearance? What is appearance? Obviously appearance is what defines how the Shape3D looks. It might be just a color or a blend of colors, it might be transparent, it might be shiny or dull. Or it might be textured. Texturing is using an image to color our Shape3D. We can load a picture (file - typically a GIF or JPG) and apply it to a shape. Note: textures should be sized in powers of 2 (ie 16x16, 32x64, 256x256, 512x1024).
Light will effect how an object (Shape3D) looks depending on how the appearance of that object is defined (is it shiny or dull, etc). Java supports three primary types of light - ambient, directional, point. Ambient light is background lighting (ie so the underside of objects isn't completely black). Directional lighting is sort of like the sun and illuminates objects from a specific direction. A point light is a source of light that comes from a point. All lights have a region of influence (typically a bounding sphere) - outside of that region they have NO effect. Also note that lights are modeled very simply. Objects do NOT block light, hence shadows are not created.