CubeTwister 2.0alpha141 2011-10-13

idx3d
Class idx3d_Triangle

java.lang.Object
  extended by idx3d.idx3d_Triangle

public class idx3d_Triangle
extends java.lang.Object

Defines a 3d triangle.

Version:
3.3 2006-02-22 Werner Randelshofer: Avoid unnecessary object creation.
3.2 2003-12-18 Werner Randelshofer: Methods setMaterial and getMaterial added. These methods allows for individual materials per triangle. Dependency note: This change also requires changes in class idx3d_RenderPipeline. Moved responsibility for texture location from class idx3d_Vertex to this class. Dependency note: This change also requires changes in idx3d_Vertex, idx3d_Rasterizer.

Field Summary
 int id
           
 idx3d_Vector n
          Normal vector of flat triangle.
 idx3d_Vector n2
          Projected Normal vector.
 boolean outOfFrustrum
          visibility tag for frustrum clipping.
 idx3d_Vertex p1
          First vertex.
 idx3d_Vertex p2
          Second vertex.
 idx3d_Vertex p3
          Third vertex.
 idx3d_Object parent
          The object which contains this triangle.
 int[] tx
          Texture x-coordinates (absolute).
 int[] ty
          Texture y-coordinates (absolute).
 float[] u
          Texture x-coordinates (relative).
 float[] v
          Texture y-coordinates (relative).
 boolean visible
          Visibility tag for clipping.
 
Constructor Summary
idx3d_Triangle(idx3d_Vertex a, idx3d_Vertex b, idx3d_Vertex c)
           
 
Method Summary
 void clipFrustrum(int w, int h)
          Backface culling and frustrum clipping.
 boolean degenerated()
           
 idx3d_Vector getCenter()
           
 idx3d_Triangle getClone()
           
 float getDist()
           
 idx3d_InternalMaterial getMaterial()
          Returns the material which shall be used to render this triangle.
 idx3d_Vertex getMedium()
           
 idx3d_InternalMaterial getTriangleMaterial()
          Returns the local material setting.
 idx3d_Vector getWeightedNormal()
           
 idx3d_Vector getWeightedNormalInto(idx3d_Vector resultVector)
           
 void project(idx3d_Matrix normalProjection)
           
 void regenerateNormal()
           
 void scaleTextureCoordinates(float fx, float fy)
           
 void setTriangleMaterial(idx3d_InternalMaterial material)
          Sets an individual material for this triangle.
 void setUV(float u1, float v1, float u2, float v2, float u3, float v3)
           
 void setUV(int vertex, float u, float v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

public idx3d_Object parent
The object which contains this triangle.


visible

public boolean visible
Visibility tag for clipping.


outOfFrustrum

public boolean outOfFrustrum
visibility tag for frustrum clipping.


p1

public idx3d_Vertex p1
First vertex.


p2

public idx3d_Vertex p2
Second vertex.


p3

public idx3d_Vertex p3
Third vertex.


n

public idx3d_Vector n
Normal vector of flat triangle.


n2

public idx3d_Vector n2
Projected Normal vector.


id

public int id

u

public float[] u
Texture x-coordinates (relative).


v

public float[] v
Texture y-coordinates (relative).


tx

public int[] tx
Texture x-coordinates (absolute).


ty

public int[] ty
Texture y-coordinates (absolute).

Constructor Detail

idx3d_Triangle

public idx3d_Triangle(idx3d_Vertex a,
                      idx3d_Vertex b,
                      idx3d_Vertex c)
Method Detail

setTriangleMaterial

public void setTriangleMaterial(idx3d_InternalMaterial material)
Sets an individual material for this triangle. This allows for multi-material idx3d_Objects at the triangle level. Set this to null, to use the material specified by the parent idx3d_Object.

Parameters:
material - A material or null.

getTriangleMaterial

public idx3d_InternalMaterial getTriangleMaterial()
Returns the local material setting.

Returns:
Returns the material used to render this triangle.

getMaterial

public idx3d_InternalMaterial getMaterial()
Returns the material which shall be used to render this triangle. If this triangle does not have an individual material, the material of the parent idx3d_Object is returned.

Returns:
Returns the material used to render this triangle.

clipFrustrum

public void clipFrustrum(int w,
                         int h)
Backface culling and frustrum clipping.


project

public void project(idx3d_Matrix normalProjection)

setUV

public void setUV(float u1,
                  float v1,
                  float u2,
                  float v2,
                  float u3,
                  float v3)

setUV

public void setUV(int vertex,
                  float u,
                  float v)

scaleTextureCoordinates

public void scaleTextureCoordinates(float fx,
                                    float fy)

regenerateNormal

public void regenerateNormal()

getWeightedNormal

public idx3d_Vector getWeightedNormal()

getWeightedNormalInto

public idx3d_Vector getWeightedNormalInto(idx3d_Vector resultVector)

getMedium

public idx3d_Vertex getMedium()

getCenter

public idx3d_Vector getCenter()

getDist

public float getDist()

degenerated

public boolean degenerated()

getClone

public idx3d_Triangle getClone()

(c) Werner Randelshofer.
All rights reserved.