[Grabbers Pic 1] Chapter 4.   The Colliding Grabbers

 

This chapter looks at how to use Java 3D's built-in Box, Cylinder, and Sphere shapes to create articulated models. The shapes are linked together by TransformGroups acting as joints, which can be rotated and moved. This functionality is essential if you want to build humanoid figures with operational limbs, or machinery with working parts.

[Grabbers Pic 2]

The Arms3D example consist of two arms (grabbers). Each grabber can rotate at its 'elbow' around the x-, y-, and z- axes. A grabber's forearm ends with two 'fingers' which can open and close. The grabbers can slide in unison over the floor forwards, backwards, left or right, but the two arms always stay the same distance apart.

The screenshots on the right show the grabbers in different poses, and the drawing further down the page highlights a grabber's elbow and finger joints.

Articulated models also need collision detection abilities, to prevent them from moving through objects in the scene. Arms3D demonstrates a simple form of collision detection and recovery, which stops the grabbers from rotating through each other. The detection code also reports when a grabber's fingers touch or pass through the floor (but doesn't stop the fingers).

[Grabbers Joints Pic]

Rotation and translation commands entered at the keyboard are caught by a Java 3D Behavior. Another Behavior subclass is used to monitor the grabbers' joints, and trigger collision checking.

The grabbers' appearance is a combination of a shiny metallic Java 3D Material object and a texture (a GIF image) to add extra detail.

The x- and z- axes of the checkboard floor are labeled with 2D text, which is useful when positioning the grabbers. I'll be reusing the floor code in several later examples.

Arms3D employs the same lighting scheme and background colour as in Life3D. Java 3D's OrbitBehavior class is again utilized to move the camera around the scene.

 

Downloads


Navigation:


Dr. Andrew Davison
E-mail: ad@coe.psu.ac.th
Back to my home page