jme.geometry.primitive
Class Triangle

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

public class Triangle
extends Primitive

Triangle handles the rendering of a single triangle shape. This triangle shape is defined by three points and maintained in an array of three Vector values. The ordering of the array is important as each index represents a corner of the triangle.

0 - Top
1 - BottomLeft
2 - BottomRight

Version:
$Id: Triangle.java,v 1.4 2003/09/08 20:29:27 mojomonkey Exp $
Author:
Samuel Wasson

Field Summary
(package private)  Vector[] points
           
 
Fields inherited from class jme.geometry.primitive.Primitive
alpha, blue, green, red
 
Constructor Summary
Triangle(Vector[] points)
          Constructor instantiates a new Triangle with the given set of points.
 
Method Summary
 Vector[] getPoints()
          getPoints returns an array of Vectors that represents each point that makes up the piece of geometry.
 void initialize()
          initialize sets up the triangle to prepare it for usage.
 void preRender()
          preRender does nothing for triangle.
 void render()
          render renders a single triangle with the defined points.
 void setPoint(int index, Vector point)
          setPoint sets a specific corner to the given point.
 void setPoints(Vector[] points)
          setPoints sets the points that define the triangle shape.
 
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
 

Field Detail

points

Vector[] points
Constructor Detail

Triangle

public Triangle(Vector[] points)
Constructor instantiates a new Triangle with the given set of points.

Parameters:
points - the points that make up the triangle.
Throws:
MonkeyRuntimeException - if points are null.
Method Detail

setPoints

public void setPoints(Vector[] points)
setPoints sets the points that define the triangle shape.

Parameters:
points - the points that make up the triangle.
Throws:
MonkeyRuntimeException - if points are null.

setPoint

public void setPoint(int index,
                     Vector point)
setPoint sets a specific corner to the given point. The index of the point should match:

0 - Top
1 - BottomLeft
2 - BottomRight

Parameters:
index - the corner to change.
point - the new point of the corner.

render

public void render()
render renders a single triangle with the defined points.

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

initialize

public void initialize()
initialize sets up the triangle to prepare it for usage.


preRender

public void preRender()
preRender does nothing for triangle.


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.