Class GTri
java.lang.Object
com.j3d.engine.react.events.EventEmitter
com.j3d.engine.scene.nodes.geometry.GObject
com.j3d.engine.scene.nodes.geometry.GTri
- All Implemented Interfaces:
EventEmitterInterface,EventListener,IdempotentEventListener<GPointMovedEvent,,Vector3> CanCopy,DecomposeWhenDrawn<Triangle>,SceneObject,HasProperties
public class GTri
extends GObject
implements IdempotentEventListener<GPointMovedEvent,Vector3>, DecomposeWhenDrawn<Triangle>
GTri represents a Triangle. What'd you expect kau.
A GTri's pivot is set to it's geometric centre between the 3 points.
Unlike the other GObjects, a GTri is a bit more complicated in that it can be defined in terms of its points or its lines. It is also where most of the "complex" engine stuff are done like depth calculations or normal calculations.
A GTri, is stored by reference like any other GObject within a Thing.
it is also stored within SceneRenderer for draw ordering.
- Author:
- Lehlogonolo Poole
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprivate booleanWhether this triangle is double sided or not.private booleanprotected GLineLeg A, connected to Leg B and Leg Cprotected GLineLeg B, connected to Leg A and Leg Cprotected GLineLeg C, connected to Leg A and Leg Bprivate RenderState<Triangle, GObject> booleanprotected WindingThe winding of the triangleFields inherited from class com.j3d.engine.scene.nodes.geometry.GObject
col, pivotProperty, propertiesFields inherited from class com.j3d.engine.react.events.EventEmitter
registered -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddProps()doublearea()Calculates the area of the triangle.doubleCalculates the depth of the tri relative to the camera's forward direction.voidcopy(CopyProperties props) Copies the properties of this object based on the providedCopyProperties.private GTrivoidbooleanDeletes itselfprivate voiddrawDist()Private method to draw the triangle's distance depth and normal overlays.booleandoubleCalculates the Euclidean distance from the triangle's pivot to the camera position.explode()static GTriConstructs a GTri.static GTrifromV3Raw(String id, Color col, GLine gLine, GLine gLine1, GLine gLine2, GPoint gPoint, GPoint gPoint1, GPoint gPoint2) Returns the duplicate object that events of typeTwill calculate/generate.getLegA()Gets Leg AgetLegB()Gets Leg BgetLegC()Gets Leg CCreates a stream of this triangle's edges.private WindinggetWindingFromCopy(CopyProperties properties) voidhandlePossibleDuplicates(EventType type, GPointMovedEvent payload) The handler to pass through for this specific type.inthashCode()booleanbooleanChecks if this triangle is double-sided.booleanisHidden()normal()Calculates the normal vector of the triangle given three vertices.voidonEvent(EventType event, EventPayload properties) onEvent is called byEventEmitterviaEventEmitter.broadcast(EventType, EventPayload).voidsetDoubleSided(boolean doubleSided) Sets whether this triangle is double-sided.voidsetHidden(boolean hidden) voidsetWinding(GPoint A, GPoint B, GPoint C) toObject()toString()Methods inherited from class com.j3d.engine.scene.nodes.geometry.GObject
asReference, getColour, getId, getName, getPivot, getProperties, setColour, setId, setPivotMethods inherited from class com.j3d.engine.react.events.EventEmitter
attachListener, broadcast, detachAll, detachListener, genericAttach, genericBroadcast, genericDetach, genericDetachAll, isAttachedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.j3d.engine.scene.nodes.geometry.base.DecomposeWhenDrawn
invalidateAll
-
Field Details
-
LegA
Leg A, connected to Leg B and Leg C -
LegB
Leg B, connected to Leg A and Leg C -
LegC
Leg C, connected to Leg A and Leg B -
winding
The winding of the triangle -
doubleSided
private boolean doubleSidedWhether this triangle is double sided or not. If it is, it's unaffected by back-face culling. (Infinite 2d surface) -
deletedState
protected boolean deletedState -
renderState
-
showNorm
public boolean showNorm
-
-
Constructor Details
-
GTri
Constructs a new GTri from 3 points.- Parameters:
c- The colourA- Point AB- Point BC- Point C- See Also:
-
GTri
Constructs a new GTri from 3 lines.- Parameters:
c- The colour.A- The first line.B- The second line.C- The third line.
-
GTri
Constructs a new GTri from a winding and 3 lines.- Parameters:
c- The colour.A- The first line.B- The second line.C- The third line.winding- The winding of the triangle.
-
-
Method Details
-
fromRaw
Constructs a GTri.- Parameters:
id- The id of the triangle defined by the filecol- The colour of the triangle defined by the filelegA- The constructed reference of the first leglegB- The constructed reference of the second leglegC- The constructed reference of the third leg- Returns:
- A GTri
-
fromV3Raw
-
toTriangle
-
toRenderState
-
addProps
private void addProps() -
isHidden
public boolean isHidden() -
setHidden
public void setHidden(boolean hidden) -
normal
Calculates the normal vector of the triangle given three vertices. -
getLegA
Gets Leg A- Returns:
- GLine
-
getLegB
Gets Leg B- Returns:
- GLine
-
getLegC
Gets Leg C- Returns:
- GLine
-
area
public double area()Calculates the area of the triangle.- Returns:
- The area.
-
calcDepth
public double calcDepth()Calculates the depth of the tri relative to the camera's forward direction.- Returns:
- The depth value.
-
euclideanDist
public double euclideanDist()Calculates the Euclidean distance from the triangle's pivot to the camera position.- Returns:
- The Euclidean distance.
-
setWinding
-
getWinding
-
copy
Description copied from interface:CanCopyCopies the properties of this object based on the providedCopyProperties. The implementation should handle how the copying is performed, potentially creating a new instance or modifying an existing one.- Specified by:
copyin interfaceCanCopy- Overrides:
copyin classGObject- Parameters:
props- The properties defining how the copy operation should be performed.- Throws:
InvalidCopyException- If the copy operation cannot be completed due to invalid properties or state.
-
copy
-
getWindingFromCopy
-
toString
-
deleteSelf
public boolean deleteSelf()Description copied from class:GObjectDeletes itself- Overrides:
deleteSelfin classGObject- Returns:
- true if the object was deleted
-
isDoubleSided
public boolean isDoubleSided()Checks if this triangle is double-sided. Double-sided triangles are unaffected by back-face culling.- Returns:
trueif the triangle is double-sided,falseotherwise.
-
setDoubleSided
public void setDoubleSided(boolean doubleSided) Sets whether this triangle is double-sided.- Parameters:
doubleSided-trueto make the triangle double-sided,falsefor single-sided.
-
getLegStream
Creates a stream of this triangle's edges.- Returns:
- A stream of GLines
-
onEvent
Description copied from interface:EventListeneronEvent is called byEventEmitterviaEventEmitter.broadcast(EventType, EventPayload). Allowing the emitter to call any other object that implements this.- Specified by:
onEventin interfaceEventListener- Overrides:
onEventin classGObject- Parameters:
event- The type of eventproperties- The given event payload
-
getDupeObjectToCheck
Description copied from interface:IdempotentEventListenerReturns the duplicate object that events of typeTwill calculate/generate.- Specified by:
getDupeObjectToCheckin interfaceIdempotentEventListener<GPointMovedEvent,Vector3> - Returns:
- The duplicate object to check against.
-
handlePossibleDuplicates
Description copied from interface:IdempotentEventListenerThe handler to pass through for this specific type.- Specified by:
handlePossibleDuplicatesin interfaceIdempotentEventListener<GPointMovedEvent,Vector3> - Parameters:
type- The type of event.payload- The payload given.
-
explode
-
equals
-
hashCode
public int hashCode() -
isDeletedState
public boolean isDeletedState()- Overrides:
isDeletedStatein classGObject
-
decompose
public void decompose()- Specified by:
decomposein interfaceDecomposeWhenDrawn<Triangle>
-
getDecomposeList
- Specified by:
getDecomposeListin interfaceDecomposeWhenDrawn<Triangle>
-
genericRenderStateList
- Overrides:
genericRenderStateListin classGObject
-
drawDist
private void drawDist()Private method to draw the triangle's distance depth and normal overlays. -
getEngineObjectType
- Specified by:
getEngineObjectTypein classGObject
-
toObject
-