jme.geometry.primitive
Class Box

java.lang.Object
  extended byjme.geometry.primitive.Primitive
      extended byjme.geometry.primitive.Box
All Implemented Interfaces:
Geometry

public class Box
extends Primitive

Box defines a primitive object of a box shape. The box is made up of six sides, with eight vertices. The vertices of the box is defined by an array of Vertex3f. The order of this array is important due to the fact that the point is defined by it's index. The indices to point match is as follows:
0 - Front face, top left
1 - Front face, top right
2 - Front face, bottom left
3 - Front face, bottom right
4 - Back face, top left
5 - Back face, top right
6 - Back face, bottom left
7 - Back face, bottom right

Version:
$Id: Box.java,v 1.5 2003/09/08 20:29:27 mojomonkey Exp $
Author:
Mark Powell

Field Summary
 
Fields inherited from class jme.geometry.primitive.Primitive
alpha, blue, green, red
 
Constructor Summary
Box()
          Constructor instantiates an empty Box with all points of the box defined as (0,0,0).
Box(float size)
          Constructor instantiates a new Box object that is a perfect cube with the given size for a side.
Box(Vector[] corners)
          Constructor instantiates a new Box object with the defined points defining the dimensions.
 
Method Summary
 Vector[] getPoints()
          getPoints returns an array of Vectors that represents each point that makes up the piece of geometry.
 void initialize()
          initialize initializes the box for use.
 void preRender()
          preRender does not perform any action for Box.
 void render()
          render renders the box with normals facing outward.
 void setCorner(int corner, Vector point)
          setCorner sets a single point of the box.
 void setCorners(Vector[] corners)
          setCorners sets the points of the box.
 
Methods inherited from class jme.geometry.primitive.Primitive
clean, getTextureId, setColor, setTexture, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Box

public Box()
Constructor instantiates an empty Box with all points of the box defined as (0,0,0).


Box

public Box(Vector[] corners)
Constructor instantiates a new Box object with the defined points defining the dimensions.

Parameters:
corners - the points of the box.
Throws:
MonkeyRuntimeException - if corners is null.

Box

public Box(float size)
Constructor instantiates a new Box object that is a perfect cube with the given size for a side. The center of the cube is (0,0,0).

Parameters:
size - the length of a side of the cube.
Method Detail

render

public void render()
render renders the box with normals facing outward. If a texture is assigned, the texture will be rendered on each face of the box.

Specified by:
render in interface Geometry
Specified by:
render in class Primitive

initialize

public void initialize()
initialize initializes the box for use.


preRender

public void preRender()
preRender does not perform any action for Box.


setCorners

public void setCorners(Vector[] corners)
setCorners sets the points of the box.

Parameters:
corners - the points of the box.
Throws:
MonkeyRuntimeException - if corners is null.

setCorner

public void setCorner(int corner,
                      Vector point)
setCorner sets a single point of the box. Using the mapping of: 0 - Front face, top left
1 - Front face, top right
2 - Front face, bottom left
3 - Front face, bottom right
4 - Back face, top left
5 - Back face, top right
6 - Back face, bottom left
7 - Back face, bottom right

Parameters:
corner - the corner to change.
point - the new point for the corner.

getPoints

public Vector[] getPoints()
Description copied from interface: Geometry
getPoints returns an array of Vectors that represents each point that makes up the piece of geometry.

Returns:
the array of vectors for the points.