espresso3d.engine.lowlevel.geometry
Class E3DTriangle

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

public class E3DTriangle
extends E3DTexturedRenderable

Author:
espresso3d Triangle class used in the engine

Field Summary
 
Fields inherited from class espresso3d.engine.renderer.base.E3DRenderable
RENDERMODE_SOLID, RENDERMODE_TEXTURED, RENDERMODE_WIREFRAME
 
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, java.lang.String textureName)
           
E3DTriangle(E3DEngine engine, E3DVector3F vertexA, E3DVector3F vertexB, E3DVector3F vertexC)
          A triangle that doesn't care about texture coords/textures.
E3DTriangle(E3DEngine engine, E3DVector3F vertexA, E3DVector3F vertexB, E3DVector3F vertexC, E3DVector3F texCoordA, E3DVector3F texCoordB, E3DVector3F texCoordC, java.lang.String textureName)
           
E3DTriangle(E3DTriangle toCopy)
           
 
Method Summary
 double getAlpha()
           
 E3DVector3F getCentroid()
           
 float[] getFloatNormalArray()
           
 float[] getFloatTexCoordArray()
           
 float[] getFloatVertexArray()
           
 float[] getFloatVertexColorArray()
           
 E3DVector3F getNormal()
           
 E3DVector4F getPlaneEquationCoords()
           
 E3DVector3F[] getTextureCoord()
           
 E3DVector3F getTextureCoordA()
          Get the texture coordinate of the first vertex
 E3DVector3F getTextureCoordB()
          Get the texture coordinate of the second vertex
 E3DVector3F getTextureCoordC()
          Get the texture coordinate of the third vertex
 E3DVector3F[] getVertex()
          Get the array of the triangle's vertices (will be length 3)
 E3DVector3F getVertexA()
          Get the first vertex of the triangle
 E3DVector3F getVertexB()
          Get the second vertex of the triangle
 E3DVector3F getVertexC()
          Get the third vertex of the triangle
 E3DVector3F[] getVertexColor()
          Get an array of colors for each of the triangles vertices
 E3DVector3F getVertexColorA()
          Get the color of the first vertex
 E3DVector3F getVertexColorB()
          Get the color of the second vertex
 E3DVector3F getVertexColorC()
          Get the color of the third vertex
 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 atPosition)
          To render outside of the normal rendering loop, this can be added to the external renderable list of the engine's because it implements renderAtPosition.
 void resetVertexColor(double color)
          Resets all the vertex colors to all be color.
 void rotate(double angle, E3DVector3F upVec, E3DVector3F translatedAmt)
          Rotate the triangle around aroundVec.
 void scale(double scaleAmt)
           
 void setAlpha(double alpha)
           
 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)
          Set the texture coordinate of the first vertex
 void setTextureCoordB(E3DVector3F textureCoord)
          Set the texture coordinate of the second vertex
 void setTextureCoordC(E3DVector3F textureCoord)
          Set the texture coordinate of the third vertex
 void setVertex(E3DVector3F[] vertex)
          Set the triangle's vertices
 void setVertex(E3DVector3F vertexA, E3DVector3F vertexB, E3DVector3F vertexC)
          Set the vertices
 void setVertexA(E3DVector3F vertex)
          Set the first vertex of the triangle
 void setVertexB(E3DVector3F vertex)
          Set the second vertex of the triangle
 void setVertexC(E3DVector3F vertex)
          Set the third vertex of the triangle
 void setVertexColor(E3DVector3F[] vertexColor)
          Set the colors of each vertex of a triangle
 void setVertexColor(E3DVector3F vertexColorA, E3DVector3F vertexColorB, E3DVector3F vertexColorC)
          Set the colors of each vertex of the triangle
 void setVertexColorA(E3DVector3F vertexColor)
          Set the color of the first vertex
 void setVertexColorB(E3DVector3F vertexColor)
          Set the color of the second vertex
 void setVertexColorC(E3DVector3F vertexColor)
          Set the color of the third vertex
 java.lang.String toString()
           
 void translate(E3DVector3F translationAmt)
          Translate the triangle vertices
 
Methods inherited from class espresso3d.engine.renderer.base.E3DTexturedRenderable
getRenderableOptionsKey, getTexture, setTexture
 
Methods inherited from class espresso3d.engine.renderer.base.E3DRenderable
getRenderMode, initCorrectGeometryRenderer, render, setRenderMode
 
Methods inherited from class espresso3d.engine.base.E3DEngineItem
getEngine, setEngine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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,
                   java.lang.String textureName)

E3DTriangle

public E3DTriangle(E3DEngine engine,
                   E3DVector3F vertexA,
                   E3DVector3F vertexB,
                   E3DVector3F vertexC)
A triangle that doesn't care about texture coords/textures. Be sure to never send this to the rendering pipeline!! This is for vertexFunctions ONLY, NOT for rendering!

Parameters:
engine -
vertexA -
vertexB -
vertexC -

E3DTriangle

public E3DTriangle(E3DEngine engine,
                   E3DVector3F vertexA,
                   E3DVector3F vertexB,
                   E3DVector3F vertexC,
                   E3DVector3F texCoordA,
                   E3DVector3F texCoordB,
                   E3DVector3F texCoordC,
                   java.lang.String textureName)
Method Detail

getVertexA

public E3DVector3F getVertexA()
Get the first vertex of the triangle

Returns:

setVertexA

public void setVertexA(E3DVector3F vertex)
Set the first vertex of the triangle

Parameters:
vertex -

getVertexB

public E3DVector3F getVertexB()
Get the second vertex of the triangle

Returns:

setVertexB

public void setVertexB(E3DVector3F vertex)
Set the second vertex of the triangle

Parameters:
vertex -

getVertexC

public E3DVector3F getVertexC()
Get the third vertex of the triangle

Returns:

setVertexC

public void setVertexC(E3DVector3F vertex)
Set the third vertex of the triangle

Parameters:
vertex -

getVertexColorA

public E3DVector3F getVertexColorA()
Get the color of the first vertex

Returns:
E3DVector3F specifying RGB components right 0.0 <= R.G.B. <= 1.0

setVertexColorA

public void setVertexColorA(E3DVector3F vertexColor)
Set the color of the first vertex

Parameters:
vertexColor - E3DVector3F specifying RGB components right 0.0 <= R.G.B. <= 1.0

getVertexColorB

public E3DVector3F getVertexColorB()
Get the color of the second vertex

Returns:
E3DVector3F specifying RGB components right 0.0 <= R.G.B. <= 1.0

setVertexColorB

public void setVertexColorB(E3DVector3F vertexColor)
Set the color of the second vertex

Parameters:
vertexColor - E3DVector3F specifying RGB components right 0.0 <= R.G.B. <= 1.0

getVertexColorC

public E3DVector3F getVertexColorC()
Get the color of the third vertex

Returns:
E3DVector3F specifying RGB components right 0.0 <= R.G.B. <= 1.0

setVertexColorC

public void setVertexColorC(E3DVector3F vertexColor)
Set the color of the third vertex

Parameters:
vertexColor - E3DVector3F specifying RGB components right 0.0 <= R.G.B. <= 1.0

getTextureCoordA

public E3DVector3F getTextureCoordA()
Get the texture coordinate of the first vertex

Returns:

setTextureCoordA

public void setTextureCoordA(E3DVector3F textureCoord)
Set the texture coordinate of the first vertex

Parameters:
textureCoord -

getTextureCoordB

public E3DVector3F getTextureCoordB()
Get the texture coordinate of the second vertex

Returns:

setTextureCoordB

public void setTextureCoordB(E3DVector3F textureCoord)
Set the texture coordinate of the second vertex

Parameters:
textureCoord -

getTextureCoordC

public E3DVector3F getTextureCoordC()
Get the texture coordinate of the third vertex

Returns:

setTextureCoordC

public void setTextureCoordC(E3DVector3F textureCoord)
Set the texture coordinate of the third vertex

Parameters:
textureCoord -

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()
Get the array of the triangle's vertices (will be length 3)

Returns:
An array of E3DVector3F's

setVertex

public void setVertex(E3DVector3F[] vertex)
Set the triangle's vertices

Parameters:
vertex - Array of the 3 vertices (E3DVector3F's) of the triangle

setVertex

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

Parameters:
vertexA -
vertexB -
vertexC -

getVertexColor

public E3DVector3F[] getVertexColor()
Get an array of colors for each of the triangles vertices

Returns:
Array of E3DVector3F's. X = R, Y = G, Z = B

setVertexColor

public void setVertexColor(E3DVector3F[] vertexColor)
Set the colors of each vertex of a triangle

Parameters:
vertexColor - Array of E3DVector3F's

setVertexColor

public void setVertexColor(E3DVector3F vertexColorA,
                           E3DVector3F vertexColorB,
                           E3DVector3F vertexColorC)
Set the colors of each vertex of the triangle

Parameters:
vertexColorA -
vertexColorB -
vertexColorC -

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


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 atPosition)
To render outside of the normal rendering loop, this can be added to the external renderable list of the engine's because it implements renderAtPosition.

Specified by:
renderAtPosition in class E3DTexturedRenderable

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 upVec,
                   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 -
upVec -
translatedAmt -

getAlpha

public double getAlpha()

setAlpha

public void setAlpha(double alpha)