Class Box


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.

By default all primitives with the same parameters share their geometry (e.g., you can have 50 shperes in your scene, but the geometry is stored only once). A change to one primitive will effect all shared nodes. Another implication of this implementation is that the capabilities of the geometry are shared, and once one of the shared nodes is live, the capabilities cannot be set. Use the GEOMETRY_NOT_SHARED flag if you do not wish to share geometry among primitives with the same parameters.

  • Field Details

  • Constructor Details

    • Box

      public Box()
      Constructs a default box of 1.0 in all dimensions. Normals are generated by default, texture coordinates are not.
    • Box

      public Box(float xdim, float ydim, float zdim, Appearance ap)
      Constructs a box of a given dimension and appearance. Normals are generated by default, texture coordinates are not.
      Parameters:
      xdim - X-dimension size.
      ydim - Y-dimension size.
      zdim - Z-dimension size.
      ap - Appearance
    • Box

      public Box(float xdim, float ydim, float zdim, int primflags, Appearance ap, int numTexUnit)
      Constructs a box of a given dimension, flags, and appearance.
      Parameters:
      xdim - X-dimension size.
      ydim - Y-dimension size.
      zdim - Z-dimension size.
      primflags - primitive flags.
      ap - Appearance
    • Box

      public Box(float xdim, float ydim, float zdim, int primflags, Appearance ap)
  • Method Details

    • getShape

      public Shape3D getShape(int partId)
      Gets one of the faces (Shape3D) from the box that contains the geometry and appearance. This allows users to modify the appearance or geometry of individual parts.
      Specified by:
      getShape in class Primitive
      Parameters:
      partId - The part to return.
      Returns:
      The Shape3D object associated with the partID. If an invalid partId is passed in, null is returned.
    • setAppearance

      public void setAppearance(Appearance ap)
      Sets appearance of the box. This will set each face of the box to the same appearance. To set each face's appearance separately, use getShape(partId) to get the individual shape and call shape.setAppearance(ap).
      Specified by:
      setAppearance in class Primitive
    • getAppearance

      public Appearance getAppearance(int partId)
      Gets the appearance of the specified part of the box.
      Specified by:
      getAppearance in class Primitive
      Parameters:
      partId - identifier for a given subpart of the box
      Returns:
      The appearance object associated with the partID. If an invalid partId is passed in, null is returned.
      Since:
      Java 3D 1.2.1
    • cloneNode

      public Node cloneNode(boolean forceDuplicate)
      Used to create a new instance of the node. This routine is called by cloneTree to duplicate the current node. cloneNode should be overridden by any user subclassed objects. All subclasses must have their cloneNode method consist of the following lines:

           public Node cloneNode(boolean forceDuplicate) {
               UserSubClass usc = new UserSubClass();
               usc.duplicateNode(this, forceDuplicate);
               return usc;
           }
       
      Overrides:
      cloneNode in class Group
      Parameters:
      forceDuplicate - when set to true, causes the duplicateOnCloneTree flag to be ignored. When false, the value of each node's duplicateOnCloneTree variable determines whether NodeComponent data is duplicated or copied.
      See Also:
    • duplicateNode

      public void duplicateNode(Node originalNode, boolean forceDuplicate)
      Copies all node information from originalNode into the current node. This method is called from the cloneNode method which is, in turn, called by the cloneTree method.

      For any NodeComponent objects contained by the object being duplicated, each NodeComponent object's duplicateOnCloneTree value is used to determine whether the NodeComponent should be duplicated in the new node or if just a reference to the current node should be placed in the new node. This flag can be overridden by setting the forceDuplicate parameter in the cloneTree method to true.

      Overrides:
      duplicateNode in class Node
      Parameters:
      originalNode - the original node to duplicate.
      forceDuplicate - when set to true, causes the duplicateOnCloneTree flag to be ignored. When false, the value of each node's duplicateOnCloneTree variable determines whether NodeComponent data is duplicated or copied.
      See Also:
    • getXdimension

      public float getXdimension()
      Returns the X-dimension size of the Box
      Since:
      Java 3D 1.2.1
    • getYdimension

      public float getYdimension()
      Returns the Y-dimension size of the Box
      Since:
      Java 3D 1.2.1
    • getZdimension

      public float getZdimension()
      Returns the Z-dimension size of the Box
      Since:
      Java 3D 1.2.1