Package com.ijurnove.cpu3d
Class Triangle
java.lang.Object
com.ijurnove.cpu3d.Triangle
- All Implemented Interfaces:
Rotatable,Scalable,Translatable,Comparable<Triangle>
public class Triangle
extends Object
implements Comparable<Triangle>, Translatable, Rotatable, Scalable
A
Triangle holds three Point3ds, three point normals, three UV coordinates, and one surface normal. Point normals define the direction
each vertex is facing. The surface normal defines the direction the entire Triangle is facing. UV coordinates define the texture coordinates at
each vertex.
Texture and Material data is taken from the parent Shape3d.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected double[]barycentricCoords(double pX, double pY) intcopy()Returns a copy of thisTriangle.protected voidflip()Returns the center of thisTriangle.Returns the parentShape3d'sMaterial.Returns the parentShape3dof thisTriangle.Vector3d[]Returns the direction theTriangleis facing at each vertex.Returns the direction theTriangleis facing.Returns the parentShape3d's texture.UV[]Returns the UV coordinates at each vertex.Point3d[]Returns the vertices.protected booleanprotected booleanisShown()protected voidprotected voidprotected voidprotected booleanoverlapsWithRect(int minX, int minY, int maxX, int maxY) protected voidprotected voidprotected Point3dpoint3dFromBary(double[] weights) voidRotates this object about a given point on a specified axis.voidScales this object by a given amount from a point.protected voidvoidsetPointNormals(Vector3d v1Norm, Vector3d v2Norm, Vector3d v3Norm) Sets the point normals at each vertex.protected voidsetShown(boolean shown) voidsetTextureCoords(UV v1coords, UV v2coords, UV v3coords) Sets the UV coordinates at each vertex.protected voidshiftOnX(double distance) protected voidshiftOnY(double distance) protected voidshiftOnZ(double distance) voidtranslate(double x, double y, double z) Shifts this object's X, Y, and Z position by the given values.protected voidprotected voidvrtx1()Returns the first vertex.vrtx2()Returns the second vertex.vrtx3()Returns the third vertex.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.ijurnove.cpu3d.Translatable
translate
-
Constructor Details
-
Triangle
Constructs a newTrianglewith the given vertices and point normals.- Parameters:
v1- the first vertexv2- the second vertexv3- the third vertexpn1- the first point normalpn2- the second point normalpn3- the third point normal
-
Triangle
-
Triangle
-
-
Method Details
-
setParent
-
getParent
Returns the parentShape3dof thisTriangle.- Returns:
- the parent Shape3d of this Triangle
-
copy
Returns a copy of thisTriangle.- Returns:
- an identical Triangle
-
maybeCalculatePointNormals
protected void maybeCalculatePointNormals() -
getPointNormals
Returns the direction theTriangleis facing at each vertex.- Returns:
- the point normals
-
getVertices
Returns the vertices.- Returns:
- the vertices
-
getTextureCoords
Returns the UV coordinates at each vertex.- Returns:
- the UV coordinates of each vertex
-
vrtx1
Returns the first vertex.- Returns:
- the first vertex
-
vrtx2
Returns the second vertex.- Returns:
- the second vertex
-
vrtx3
Returns the third vertex.- Returns:
- the third vertex
-
getTexture
Returns the parentShape3d's texture.- Returns:
- the texture of the parent Shape3d
-
getMaterial
Returns the parentShape3d'sMaterial.- Returns:
- the Material of the parent Shape3d
-
getCenter
Returns the center of thisTriangle.- Returns:
- the center
-
getSurfNorm
Returns the direction theTriangleis facing.- Returns:
- the direction the Triangle is facing
-
isShown
protected boolean isShown() -
setShown
protected void setShown(boolean shown) -
flip
protected void flip() -
point3dFromBary
-
markForPointNormalCalculation
protected void markForPointNormalCalculation() -
setPointNormals
Sets the point normals at each vertex.- Parameters:
v1Norm- the first point normal to setv2Norm- the second point normal to setv3Norm- the third point normal to set
-
setTextureCoords
Sets the UV coordinates at each vertex.- Parameters:
v1coords- the first UV to setv2coords- the second UV to setv3coords- the third UV to set
-
updateValues
protected void updateValues() -
isFacingViewer
protected boolean isFacingViewer() -
shiftOnX
protected void shiftOnX(double distance) -
shiftOnY
protected void shiftOnY(double distance) -
shiftOnZ
protected void shiftOnZ(double distance) -
translate
public void translate(double x, double y, double z) Description copied from interface:TranslatableShifts this object's X, Y, and Z position by the given values.- Specified by:
translatein interfaceTranslatable- Parameters:
x- how far the object should be translated along the X axisy- how far the object should be translated along the Y axisz- how far the object should be translated along the Z axis
-
compareTo
- Specified by:
compareToin interfaceComparable<Triangle>
-
updateBaryCache
protected void updateBaryCache() -
barycentricCoords
protected double[] barycentricCoords(double pX, double pY) -
overlapsWithRect
protected boolean overlapsWithRect(int minX, int minY, int maxX, int maxY) -
perspProjectionForPointShadowMap
-
perspProjection
-
orthoProjection
-
rotate
Description copied from interface:RotatableRotates this object about a given point on a specified axis. 0 corresponds to the X axis, 1 corresponds to the Y axis, and 2 corresponds to the Z axis. -
scale
Description copied from interface:ScalableScales this object by a given amount from a point.
-