espresso3d.engine.lowlevel.geometry
Class E3DQuad

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.E3DQuad

public class E3DQuad
extends E3DTexturedRenderable

Author:
Curt A quad is a renderable, texturable rectangle. This is normally only used for particle geometry. But could be used elsewhere on the external renderable list if desired. Be sure to ONLY modify vertex position information through the quad object itself -- IE: do NOT get the vertex and modify the vertex object itself. It will cause normals to NOT be recalculated if you do so and will cause lots of problems.

Constructor Summary
E3DQuad(E3DEngine engine)
           
E3DQuad(E3DEngine engine, E3DVector3F vertexPosA, E3DVector3F vertexPosB, E3DVector3F vertexPosC, E3DVector3F vertexPosD)
          Instantiate a quad that can only be used for accessing is various functions on vertexPos's.
E3DQuad(E3DEngine engine, E3DVector3F vertexPosA, E3DVector3F vertexPosB, E3DVector3F vertexPosC, E3DVector3F vertexPosD, E3DVector2F texCoordA, E3DVector2F texCoordB, E3DVector2F texCoordC, E3DVector2F texCoordD, E3DVector3F vertexColorA, E3DVector3F vertexColorB, E3DVector3F vertexColorC, E3DVector3F vertexColorD, java.lang.String textureName)
           
E3DQuad(E3DEngine engine, E3DVector3F vertexPosA, E3DVector3F vertexPosB, E3DVector3F vertexPosC, E3DVector3F vertexPosD, E3DVector2F texCoordA, E3DVector2F texCoordB, E3DVector2F texCoordC, E3DVector2F texCoordD, java.lang.String textureName)
           
E3DQuad(E3DQuad toCopy)
           
 
Method Summary
 void appendTexCoordBuffer(java.nio.FloatBuffer texCoordBuffer)
           
 void appendTexCoordDetail0Buffer(java.nio.FloatBuffer texCoordDetail0Buffer)
           
 void appendTexCoordDetail1Buffer(java.nio.FloatBuffer texCoordDetail1Buffer)
           
 void appendVertexBuffer(java.nio.FloatBuffer vertexBuffer)
           
 void appendVertexColorBuffer(java.nio.FloatBuffer vertexColorBuffer)
           
 E3DVector3F checkSegmentCollision(E3DVector3F startPos, E3DVector3F endPos)
          Checks for full fledged collision between the line segment formed between startPos and endPos and the triangle and returns the intersection point (or null if no collision occurs)
 boolean doesSegmentCrossPlane(E3DVector3F startPos, E3DVector3F endPos)
           
 double getDistanceToPoint(E3DVector3F point)
           
 E3DVector3F getNormal()
           
 E3DVector4F getPlaneEquationCoords()
          Returns a vector with the 4 parameters of the quad's plane
 E3DVector3F getPlaneIntersectionPoint(E3DVector3F startPos, E3DVector3F endPos)
          Gets the intersection point of the line segment formed between startPos and endPos and the triangle if it intersects
 E3DVector2F[] getTextureCoord()
          Get array of texture coords for the quad.
 E3DVector2F getTextureCoordA()
          Get the first texture coordinate
 E3DVector2F getTextureCoordB()
          Get the second texture coordinate
 E3DVector2F getTextureCoordC()
          Get the third texture coordinate
 E3DVector2F getTextureCoordD()
          Get the fourth texture coordinate
 E3DVector2F[] getTextureCoordDetail0()
          Get array of texture coords for the quad.
 E3DVector2F getTextureCoordDetail0A()
          Get the first texture coordinate
 E3DVector2F getTextureCoordDetail0B()
          Get the second texture coordinate
 E3DVector2F getTextureCoordDetail0C()
          Get the third texture coordinate
 E3DVector2F getTextureCoordDetail0D()
          Get the fourth texture coordinate
 E3DVector2F[] getTextureCoordDetail1()
          Get array of texture coords for the quad.
 E3DVector2F getTextureCoordDetail1A()
          Get the first texture coordinate
 E3DVector2F getTextureCoordDetail1B()
          Get the second texture coordinate
 E3DVector2F getTextureCoordDetail1C()
          Get the third texture coordinate
 E3DVector2F getTextureCoordDetail1D()
          Get the fourth texture coordinate
 E3DVector3F[] getVertexColor()
          Get the color of the vertices.
 E3DVector3F getVertexColorA()
          Get the color of the first vertex of the quad
 E3DVector3F getVertexColorB()
          Get the color of the second vertex of the quad
 E3DVector3F getVertexColorC()
          Get the color of the third vertex of the quad
 E3DVector3F getVertexColorD()
          Get the color of the fourth vertex of the quad
 E3DVector3F getVertexPos(int index)
           
 E3DVector3F getVertexPosA()
          Get the position of the first vertex of the quad
 E3DVector3F getVertexPosB()
          Get the position of the second vertex of the quad
 E3DVector3F getVertexPosC()
          Get the position of the third vertex of the quad
 E3DVector3F getVertexPosD()
          Get the position of the fourth vertex of the quad
 boolean isPointInQuad(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 render()
          To render outside of the normal rendering loop, this can be added to the external renderable list of the engine's because it implements render.
 void resetVertexColor(double color)
          Resets all the vertex colors to all be color.
 void rotate(double angle, E3DVector3F upVec, E3DVector3F translatedAmt)
          Rotate the quad around aroundVec.
 void scale(double scaleAmt)
          Scale the quad
 void setTextureCoord(E3DVector2F[] textureCoord)
          Set the texture coordinates of the quad
 void setTextureCoord(E3DVector2F texCoordA, E3DVector2F texCoordB, E3DVector2F texCoordC, E3DVector2F texCoordD)
          Set the texture coordinates of the quad
 void setTextureCoordDetail0(E3DVector2F[] TextureCoordDetail0)
          Set the texture coordinates of the quad
 void setTextureCoordDetail0(E3DVector2F texCoordA, E3DVector2F texCoordB, E3DVector2F texCoordC, E3DVector2F texCoordD)
          Set the texture coordinates of the quad
 void setTextureCoordDetail1(E3DVector2F[] TextureCoordDetail1)
          Set the texture coordinates of the quad
 void setTextureCoordDetail1(E3DVector2F texCoordA, E3DVector2F texCoordB, E3DVector2F texCoordC, E3DVector2F texCoordD)
          Set the texture coordinates of the quad
 void setVertexColor(E3DVector3F[] vertexColor)
          Set the color of the vertices of the quad
 void setVertexColor(E3DVector3F vertexColorA, E3DVector3F vertexColorB, E3DVector3F vertexColorC, E3DVector3F vertexColorD)
          Set the color of the vertices of the quad
 void setVertexPos(E3DVector3F[] vertexPos)
          Set the positiosn of all the vertices
 void setVertexPos(E3DVector3F vertexPosA, E3DVector3F vertexPosB, E3DVector3F vertexPosC, E3DVector3F vertexPosD)
          Set the positions of all the vertices
 void setVertexPosA(E3DVector3F vertexPos)
          Set the position of the first vertex of the quad
 void setVertexPosB(E3DVector3F vertexPos)
          Set the position of the second vertex of the quad
 void setVertexPosC(E3DVector3F vertexPos)
          Set the position of the third vertex of the quad
 void setVertexPosD(E3DVector3F vertexPos)
          Set the position of the fourth vertex of the quad
 void setVertices(E3DTexturedVertex[] vertices)
          Set the vertices of the quad.
 void setVertices(E3DTexturedVertex vertexA, E3DTexturedVertex vertexB, E3DTexturedVertex vertexC, E3DTexturedVertex vertexD)
          Set the vertices of the quad
 java.lang.String toString()
          Get a string with the quads vertice values listed
 void translate(E3DVector3F translationAmt)
          Translate the quad vertices
 
Methods inherited from class espresso3d.engine.renderer.base.E3DTexturedRenderable
getKey, getTexture, getTextureDetail0, getTextureDetail1, isTextureAvailable, isTextureDetail0Available, isTextureDetail1Available, setTexture, setTextureDetail0, setTextureDetail1
 
Methods inherited from class espresso3d.engine.renderer.base.E3DRenderable
getBlendMode, getRenderMode, initCorrectGeometryRenderer, isKeyChanged, setBlendMode, setKeyChanged, setRenderMode
 
Methods inherited from class espresso3d.engine.base.E3DEngineItem
getEngine, setEngine
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

E3DQuad

public E3DQuad(E3DEngine engine)

E3DQuad

public E3DQuad(E3DQuad toCopy)

E3DQuad

public E3DQuad(E3DEngine engine,
               E3DVector3F vertexPosA,
               E3DVector3F vertexPosB,
               E3DVector3F vertexPosC,
               E3DVector3F vertexPosD,
               E3DVector2F texCoordA,
               E3DVector2F texCoordB,
               E3DVector2F texCoordC,
               E3DVector2F texCoordD,
               java.lang.String textureName)

E3DQuad

public E3DQuad(E3DEngine engine,
               E3DVector3F vertexPosA,
               E3DVector3F vertexPosB,
               E3DVector3F vertexPosC,
               E3DVector3F vertexPosD,
               E3DVector2F texCoordA,
               E3DVector2F texCoordB,
               E3DVector2F texCoordC,
               E3DVector2F texCoordD,
               E3DVector3F vertexColorA,
               E3DVector3F vertexColorB,
               E3DVector3F vertexColorC,
               E3DVector3F vertexColorD,
               java.lang.String textureName)

E3DQuad

public E3DQuad(E3DEngine engine,
               E3DVector3F vertexPosA,
               E3DVector3F vertexPosB,
               E3DVector3F vertexPosC,
               E3DVector3F vertexPosD)
Instantiate a quad that can only be used for accessing is various functions on vertexPos's. Do NOT pass to the rendering pipeline!!

Parameters:
engine -
vertexPosA -
vertexPosB -
vertexPosC -
vertexPosD -
Method Detail

render

public void render()
To render outside of the normal rendering loop, this can be added to the external renderable list of the engine's because it implements render.

Specified by:
render in class E3DRenderable

getTextureCoord

public E3DVector2F[] getTextureCoord()
Get array of texture coords for the quad. There will be 4

Returns:

getTextureCoordA

public E3DVector2F getTextureCoordA()
Get the first texture coordinate

Returns:

getTextureCoordB

public E3DVector2F getTextureCoordB()
Get the second texture coordinate

Returns:

getTextureCoordC

public E3DVector2F getTextureCoordC()
Get the third texture coordinate

Returns:

getTextureCoordD

public E3DVector2F getTextureCoordD()
Get the fourth texture coordinate

Returns:

setTextureCoord

public void setTextureCoord(E3DVector2F[] textureCoord)
Set the texture coordinates of the quad

Parameters:
textureCoord - An array of 4 E3DVector3F's

setTextureCoord

public void setTextureCoord(E3DVector2F texCoordA,
                            E3DVector2F texCoordB,
                            E3DVector2F texCoordC,
                            E3DVector2F texCoordD)
Set the texture coordinates of the quad

Parameters:
texCoordA -
texCoordC -
texCoordD -

getTextureCoordDetail0

public E3DVector2F[] getTextureCoordDetail0()
Get array of texture coords for the quad. There will be 4

Returns:

getTextureCoordDetail0A

public E3DVector2F getTextureCoordDetail0A()
Get the first texture coordinate

Returns:

getTextureCoordDetail0B

public E3DVector2F getTextureCoordDetail0B()
Get the second texture coordinate

Returns:

getTextureCoordDetail0C

public E3DVector2F getTextureCoordDetail0C()
Get the third texture coordinate

Returns:

getTextureCoordDetail0D

public E3DVector2F getTextureCoordDetail0D()
Get the fourth texture coordinate

Returns:

setTextureCoordDetail0

public void setTextureCoordDetail0(E3DVector2F[] TextureCoordDetail0)
Set the texture coordinates of the quad

Parameters:
TextureCoordDetail0 - An array of 4 E3DVector3F's

setTextureCoordDetail0

public void setTextureCoordDetail0(E3DVector2F texCoordA,
                                   E3DVector2F texCoordB,
                                   E3DVector2F texCoordC,
                                   E3DVector2F texCoordD)
Set the texture coordinates of the quad

Parameters:
texCoordA -
texCoordC -
texCoordD -

getTextureCoordDetail1

public E3DVector2F[] getTextureCoordDetail1()
Get array of texture coords for the quad. There will be 4

Returns:

getTextureCoordDetail1A

public E3DVector2F getTextureCoordDetail1A()
Get the first texture coordinate

Returns:

getTextureCoordDetail1B

public E3DVector2F getTextureCoordDetail1B()
Get the second texture coordinate

Returns:

getTextureCoordDetail1C

public E3DVector2F getTextureCoordDetail1C()
Get the third texture coordinate

Returns:

getTextureCoordDetail1D

public E3DVector2F getTextureCoordDetail1D()
Get the fourth texture coordinate

Returns:

setTextureCoordDetail1

public void setTextureCoordDetail1(E3DVector2F[] TextureCoordDetail1)
Set the texture coordinates of the quad

Parameters:
TextureCoordDetail1 - An array of 4 E3DVector3F's

setTextureCoordDetail1

public void setTextureCoordDetail1(E3DVector2F texCoordA,
                                   E3DVector2F texCoordB,
                                   E3DVector2F texCoordC,
                                   E3DVector2F texCoordD)
Set the texture coordinates of the quad

Parameters:
texCoordA -
texCoordC -
texCoordD -

getVertexPos

public E3DVector3F getVertexPos(int index)

setVertices

public void setVertices(E3DTexturedVertex[] vertices)
Set the vertices of the quad.


setVertices

public void setVertices(E3DTexturedVertex vertexA,
                        E3DTexturedVertex vertexB,
                        E3DTexturedVertex vertexC,
                        E3DTexturedVertex vertexD)
Set the vertices of the quad

Parameters:
vertexA -
vertexB -
vertexC -
vertexD -

getVertexPosA

public E3DVector3F getVertexPosA()
Get the position of the first vertex of the quad

Returns:

setVertexPosA

public void setVertexPosA(E3DVector3F vertexPos)
Set the position of the first vertex of the quad

Parameters:
vertexPos -

getVertexPosB

public E3DVector3F getVertexPosB()
Get the position of the second vertex of the quad

Returns:

setVertexPosB

public void setVertexPosB(E3DVector3F vertexPos)
Set the position of the second vertex of the quad

Parameters:
vertexPos -

getVertexPosC

public E3DVector3F getVertexPosC()
Get the position of the third vertex of the quad

Returns:

setVertexPosC

public void setVertexPosC(E3DVector3F vertexPos)
Set the position of the third vertex of the quad

Parameters:
vertexPos -

getVertexPosD

public E3DVector3F getVertexPosD()
Get the position of the fourth vertex of the quad

Returns:

setVertexPosD

public void setVertexPosD(E3DVector3F vertexPos)
Set the position of the fourth vertex of the quad

Parameters:
vertexPos -

setVertexPos

public void setVertexPos(E3DVector3F vertexPosA,
                         E3DVector3F vertexPosB,
                         E3DVector3F vertexPosC,
                         E3DVector3F vertexPosD)
Set the positions of all the vertices

Parameters:
vertexPosA -
vertexPosB -
vertexPosC -
vertexPosD -

setVertexPos

public void setVertexPos(E3DVector3F[] vertexPos)
Set the positiosn of all the vertices


getVertexColor

public E3DVector3F[] getVertexColor()
Get the color of the vertices.

Returns:
Array containing 4 E3DVector3F's

getVertexColorA

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

Returns:

getVertexColorB

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

Returns:

getVertexColorC

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

Returns:

getVertexColorD

public E3DVector3F getVertexColorD()
Get the color of the fourth vertex of the quad

Returns:

setVertexColor

public void setVertexColor(E3DVector3F[] vertexColor)
Set the color of the vertices of the quad

Parameters:
vertexColor - An array of 4 E3DVector3F's

setVertexColor

public void setVertexColor(E3DVector3F vertexColorA,
                           E3DVector3F vertexColorB,
                           E3DVector3F vertexColorC,
                           E3DVector3F vertexColorD)
Set the color of the vertices of the quad

Parameters:
vertexColorA -
vertexColorB -
vertexColorC -
vertexColorD -

resetVertexColor

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

Parameters:
color - Value between 0 and 1 to set all R,G,B values to for all vertices

normaliseVertexColors

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


appendVertexBuffer

public void appendVertexBuffer(java.nio.FloatBuffer vertexBuffer)

appendVertexColorBuffer

public void appendVertexColorBuffer(java.nio.FloatBuffer vertexColorBuffer)

appendTexCoordBuffer

public void appendTexCoordBuffer(java.nio.FloatBuffer texCoordBuffer)

appendTexCoordDetail0Buffer

public void appendTexCoordDetail0Buffer(java.nio.FloatBuffer texCoordDetail0Buffer)

appendTexCoordDetail1Buffer

public void appendTexCoordDetail1Buffer(java.nio.FloatBuffer texCoordDetail1Buffer)

getNormal

public E3DVector3F getNormal()
Returns:
Returns the normal of the quad

getPlaneEquationCoords

public E3DVector4F getPlaneEquationCoords()
Returns a vector with the 4 parameters of the quad's plane

Returns:

translate

public void translate(E3DVector3F translationAmt)
Translate the quad vertices


scale

public void scale(double scaleAmt)
Scale the quad

Parameters:
scaleAmt -

toString

public java.lang.String toString()
Get a string with the quads vertice values listed


rotate

public void rotate(double angle,
                   E3DVector3F upVec,
                   E3DVector3F translatedAmt)
Rotate the quad around aroundVec. Translated amt is how far the quad 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 -

isPointInQuad

public boolean isPointInQuad(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:

getDistanceToPoint

public double getDistanceToPoint(E3DVector3F point)

doesSegmentCrossPlane

public boolean doesSegmentCrossPlane(E3DVector3F startPos,
                                     E3DVector3F endPos)

getPlaneIntersectionPoint

public E3DVector3F getPlaneIntersectionPoint(E3DVector3F startPos,
                                             E3DVector3F endPos)
Gets the intersection point of the line segment formed between startPos and endPos and the triangle if it intersects

Parameters:
startPos -
endPos -
Returns:
returns intersection point

checkSegmentCollision

public E3DVector3F checkSegmentCollision(E3DVector3F startPos,
                                         E3DVector3F endPos)
Checks for full fledged collision between the line segment formed between startPos and endPos and the triangle and returns the intersection point (or null if no collision occurs)

Returns:
Returns the intersection point vector if there is a collision between the line segment (startPos, endPos) and triangle. Otherwise, returns null;