espresso3d.engine.geometry
Class E3DTriangle

java.lang.Object
  extended byespresso3d.engine.base.E3DEngineItem
      extended byespresso3d.engine.renderer.base.E3DRenderable
          extended byespresso3d.engine.geometry.E3DTriangle

public class E3DTriangle
extends E3DRenderable

Author:
espresso3d Triangle class used in the engine

Constructor Summary
E3DTriangle(E3DEngine engine)
           
E3DTriangle(E3DEngine engine, double ax, double ay, double az, double bx, double by, double bz, double cx, double cy, double cz, double tax, double tay, double tbx, double tby, double tcx, double tcy, int glTextureID)
           
E3DTriangle(E3DTriangle toCopy)
           
 
Method Summary
 E3DVector3F getCentroid()
           
 E3DEngine getEngine()
           
 float[] getFloatNormalArray()
           
 float[] getFloatTexCoordArray()
           
 float[] getFloatVertexArray()
           
 float[] getFloatVertexColorArray()
           
 int getGlTextureID()
           
 E3DVector3F getNormal()
           
 E3DVector4F getPlaneEquationCoords()
           
 E3DVector3F[] getTextureCoord()
           
 E3DVector3F getTextureCoordA()
           
 E3DVector3F getTextureCoordB()
           
 E3DVector3F getTextureCoordC()
           
 E3DVector3F[] getVertex()
           
 E3DVector3F getVertexA()
           
 E3DVector3F getVertexB()
           
 E3DVector3F getVertexC()
           
 E3DVector3F[] getVertexColor()
           
 E3DVector3F getVertexColorB()
           
 E3DVector3F getVertexColorG()
           
 E3DVector3F getVertexColorR()
           
 boolean isPointInTriangle(E3DVector3F point)
          This pointInTriangle checks if the point is on the inside of all the line segments of the triangle It is slightly faster than isPointInTriangleByAngles
 boolean isPointInTriangleByAngles(E3DVector3F point)
          This checks if a point is in a triangle by seeing if the interior angles add up to 360Deg.
 void normaliseVertexColors()
          Ensures all vertex colors are <= 1.0
 void renderAtPosition(E3DVector3F position)
           
 void resetVertexColor(double color)
          Resets all the vertex colors to all be color.
 void rotate(double angle, E3DVector3F aroundVec, E3DVector3F translatedAmt)
          Rotate the triangle around aroundVec.
 void scale(double scaleAmt)
           
 void setEngine(E3DEngine engine)
           
 void setGlTextureID(int glTextureID)
           
 void setNormal(E3DVector3F normal)
           
 void setPlaneEquationCoords(E3DVector4F planeEq)
           
 void setTextureCoord(E3DVector3F[] textureCoord)
           
 void setTextureCoord(E3DVector3F textureCoordA, E3DVector3F textureCoordB, E3DVector3F textureCoordC)
          Set the texture coords
 void setTextureCoordA(E3DVector3F textureCoord)
           
 void setTextureCoordB(E3DVector3F textureCoord)
           
 void setTextureCoordC(E3DVector3F textureCoord)
           
 void setVertex(E3DVector3F[] vertex)
           
 void setVertex(E3DVector3F vertexA, E3DVector3F vertexB, E3DVector3F vertexC)
          Set the vertices
 void setVertexA(E3DVector3F vertex)
           
 void setVertexB(E3DVector3F vertex)
           
 void setVertexC(E3DVector3F vertex)
           
 void setVertexColor(E3DVector3F[] vertexColor)
           
 void setVertexColor(E3DVector3F vertexColorR, E3DVector3F vertexColorG, E3DVector3F vertexColorB)
           
 void setVertexColorB(E3DVector3F vertexColor)
           
 void setVertexColorG(E3DVector3F vertexColor)
           
 void setVertexColorR(E3DVector3F vertexColor)
           
 java.lang.String toString()
           
 void translate(E3DVector3F translationAmt)
          Translate the triangle vertices
 
Methods inherited from class espresso3d.engine.renderer.base.E3DRenderable
render
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

E3DTriangle

public E3DTriangle(E3DEngine engine)

E3DTriangle

public E3DTriangle(E3DTriangle toCopy)

E3DTriangle

public E3DTriangle(E3DEngine engine,
                   double ax,
                   double ay,
                   double az,
                   double bx,
                   double by,
                   double bz,
                   double cx,
                   double cy,
                   double cz,
                   double tax,
                   double tay,
                   double tbx,
                   double tby,
                   double tcx,
                   double tcy,
                   int glTextureID)
Method Detail

getVertexA

public E3DVector3F getVertexA()

setVertexA

public void setVertexA(E3DVector3F vertex)

getVertexB

public E3DVector3F getVertexB()

setVertexB

public void setVertexB(E3DVector3F vertex)

getVertexC

public E3DVector3F getVertexC()

setVertexC

public void setVertexC(E3DVector3F vertex)

getVertexColorR

public E3DVector3F getVertexColorR()

setVertexColorR

public void setVertexColorR(E3DVector3F vertexColor)

getVertexColorG

public E3DVector3F getVertexColorG()

setVertexColorG

public void setVertexColorG(E3DVector3F vertexColor)

getVertexColorB

public E3DVector3F getVertexColorB()

setVertexColorB

public void setVertexColorB(E3DVector3F vertexColor)

getTextureCoordA

public E3DVector3F getTextureCoordA()

setTextureCoordA

public void setTextureCoordA(E3DVector3F textureCoord)

getTextureCoordB

public E3DVector3F getTextureCoordB()

setTextureCoordB

public void setTextureCoordB(E3DVector3F textureCoord)

getTextureCoordC

public E3DVector3F getTextureCoordC()

setTextureCoordC

public void setTextureCoordC(E3DVector3F textureCoord)

getEngine

public E3DEngine getEngine()
Overrides:
getEngine in class E3DEngineItem
Returns:
Returns the engine.

setEngine

public void setEngine(E3DEngine engine)
Overrides:
setEngine in class E3DEngineItem
Parameters:
engine - The engine to set.

getTextureCoord

public E3DVector3F[] getTextureCoord()
Returns:
Returns the textureCoord.

setTextureCoord

public void setTextureCoord(E3DVector3F[] textureCoord)
Parameters:
textureCoord - The textureCoords to set

setTextureCoord

public void setTextureCoord(E3DVector3F textureCoordA,
                            E3DVector3F textureCoordB,
                            E3DVector3F textureCoordC)
Set the texture coords

Parameters:
textureCoordA -
textureCoordB -
textureCoordC -

getVertex

public E3DVector3F[] getVertex()
Returns:
Returns the vertex.

setVertex

public void setVertex(E3DVector3F[] vertex)
Parameters:
vertex - Array of the 3 vertices

setVertex

public void setVertex(E3DVector3F vertexA,
                      E3DVector3F vertexB,
                      E3DVector3F vertexC)
Set the vertices

Parameters:
vertexA -
vertexB -
vertexC -

getVertexColor

public E3DVector3F[] getVertexColor()
Returns:
Returns the vertexColor.

setVertexColor

public void setVertexColor(E3DVector3F[] vertexColor)
Parameters:
vertexColor - The vertexColor to set.

setVertexColor

public void setVertexColor(E3DVector3F vertexColorR,
                           E3DVector3F vertexColorG,
                           E3DVector3F vertexColorB)

resetVertexColor

public void resetVertexColor(double color)
Resets all the vertex colors to all be color. Value between 0 and 1 should be used


normaliseVertexColors

public void normaliseVertexColors()
Ensures all vertex colors are <= 1.0


getGlTextureID

public int getGlTextureID()
Returns:
Returns the glTextureID.

setGlTextureID

public void setGlTextureID(int glTextureID)
Parameters:
glTextureID - The glTextureID to set.

getFloatVertexArray

public float[] getFloatVertexArray()

getFloatVertexColorArray

public float[] getFloatVertexColorArray()

getFloatNormalArray

public float[] getFloatNormalArray()

getFloatTexCoordArray

public float[] getFloatTexCoordArray()

getCentroid

public E3DVector3F getCentroid()

isPointInTriangle

public boolean isPointInTriangle(E3DVector3F point)
This pointInTriangle checks if the point is on the inside of all the line segments of the triangle It is slightly faster than isPointInTriangleByAngles

Parameters:
point -
Returns:

isPointInTriangleByAngles

public boolean isPointInTriangleByAngles(E3DVector3F point)
This checks if a point is in a triangle by seeing if the interior angles add up to 360Deg. This is slightly slower than isPointInTriangle, but left for testing sake.

Parameters:
point -
Returns:

renderAtPosition

public void renderAtPosition(E3DVector3F position)
Specified by:
renderAtPosition in class E3DRenderable

setNormal

public void setNormal(E3DVector3F normal)
Parameters:
normal - The normal to set.

getNormal

public E3DVector3F getNormal()
Returns:
Returns the normal.

getPlaneEquationCoords

public E3DVector4F getPlaneEquationCoords()

setPlaneEquationCoords

public void setPlaneEquationCoords(E3DVector4F planeEq)

translate

public void translate(E3DVector3F translationAmt)
Translate the triangle vertices


scale

public void scale(double scaleAmt)

toString

public java.lang.String toString()

rotate

public void rotate(double angle,
                   E3DVector3F aroundVec,
                   E3DVector3F translatedAmt)
Rotate the triangle around aroundVec. Translated amt is how far the triangle has been translated from the origin (it needsd this so it can be centered around the up vec correctly and then rotate and moved back)

Parameters:
angle -
aroundVec -
translatedAmt -