The documentation for com.sun.j3d.utils.geometry.Box is confused. It says 'length,
width and height' in the long comments, and then
says 'dimensions' in the constructor arguments. Dimensions could imply either
absolute coverage or a radius from the origin. In
fact the actual construction arguments are length / 2, width / 2 , height / 2 such
that the actual box manufactured occupies twice
the coverage of the passed arguments.
- Andy
/****
public class Box
extends Primitive
Box is a geometry primitive created with a given length, width, and height. It is
centered at the origin. By default, it lies within
the bounding box, [-1,-1,-1] and [1,1,1]. When a texture is applied to a box, it is
map CCW like on a Cylinder. A texture is mapped
CCW from the back of the body. The top and bottom faces are mapped such that the
texture appears front facing when the faces are
rotated 90 toward the viewer.
Constructor Summary :
Box(float xdim, float ydim, float zdim, Appearance ap)
Constructs a box of a given dimension and appearance.
****/
public void test(Group parent) {
float scale = 1.0f;
Color3f ambient = new Color3f(0.2f, 0.2f, 0.2f);
Color3f emmisive = new Color3f(0.0f, 0.0f, 0.0f);
Color3f diffuse = new Color3f(0.9f, 0.0f, 0.0f);
Color3f specular = new Color3f(0.9f, 0.9f, 0.9f);
Material material = new Material(ambient, emmisive, diffuse, specular, 70);
PolygonAttributes polygonal = new PolygonAttributes();
polygonal.setPolygonMode(PolygonAttributes.POLYGON_LINE);
polygonal.setCullFace(PolygonAttributes.CULL_NONE);
Appearance appearance = new Appearance();
appearance.setMaterial(material);
appearance.setPolygonAttributes(polygonal);
/* make a box one half the size of a surrounding sphere */
TransformGroup transform = new TransformGroup();
transform.setTransform( new Transform3D( new Quat4f( 0.0f, 0.0f, 0.0f, 1.0f ) , new
Vector3f( 0.0f, 3.0f, 10.0f ) , 1.0f ) );
transform.addChild( new Box(scale,scale,scale, Box.GENERATE_NORMALS, appearance ) );
transform.addChild( new Sphere(scale, Sphere.GENERATE_NORMALS, 5 , appearance ) );
parent.addChild( transform );
/* make another box exactly one box over from the first box */
TransformGroup transform2 = new TransformGroup();
transform2.setTransform( new Transform3D( new Quat4f( 0.0f, 0.0f, 0.0f, 1.0f ) , new
Vector3f( scale, 3.0f, 10.0f ) , 1.0f ) );
transform2.addChild( new Box(scale,scale,scale, Box.GENERATE_NORMALS, appearance ) );
parent.addChild( transform2 );
/* a third box with default arguments - appears to be correct */
Box box = new Box();
box.setAppearance( appearance );
TransformGroup transform3 = new TransformGroup();
transform3.setTransform( new Transform3D( new Quat4f( 0.0f, 0.0f, 0.0f, 1.0f ) , new
Vector3f( - scale, 3.0f, 10.0f ) , 1.0f ) );
transform3.addChild( box );
parent.addChild( transform3 );
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".