Class GTri
java.lang.Object
com.j3d.engine.react.events.EventEmitter
com.j3d.engine.react.events.EventEmitterAndListener
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 final 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 TypeFieldDescriptionprivate booleanprivate booleanWhether this triangle is double sided or not.private booleanprivate GLineLeg A, connected to Leg B and Leg Cprivate GLineLeg B, connected to Leg A and Leg Cprivate GLineLeg C, connected to Leg A and Leg Bprivate RenderState<Triangle, GObject> booleanprivate WindingThe winding of the triangleFields inherited from class GObject
col, pivotProperty, propertiesFields inherited from class 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 GTrivoidThe actual decomposition.booleanDeletes 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) Fetches the actual decomposition list.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()Converts this SceneObject to aEngineObjectbeing a Jaiva-readableArrayListof data.toString()Methods inherited from class GObject
asReference, getColour, getId, getName, getPivot, getProperties, getTags, setColour, setId, setPivotMethods inherited from class EventEmitter
attachListener, broadcast, detachAll, detachListener, genericAttach, genericBroadcast, genericDetach, genericDetachAll, isAttachedMethods inherited from interface DecomposeWhenDrawn
invalidateAllMethods inherited from interface SceneObject
tag
-
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
private boolean deletedState -
renderState
-
showNorm
public boolean showNorm
-
-
Constructor Details
-
GTri
-
GTri
-
GTri
-
-
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
-
getLegB
-
getLegC
-
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
-
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
-
isDeletedState
public boolean isDeletedState()- Overrides:
isDeletedStatein classGObject
-
decompose
public void decompose()Description copied from interface:DecomposeWhenDrawnThe actual decomposition.- Specified by:
decomposein interfaceDecomposeWhenDrawn<Triangle>
-
getDecomposeList
Description copied from interface:DecomposeWhenDrawnFetches the actual decomposition list.- Specified by:
getDecomposeListin interfaceDecomposeWhenDrawn<Triangle>- Returns:
- The arraylist of decomposed stuff
-
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
Description copied from interface:SceneObjectConverts this SceneObject to aEngineObjectbeing a Jaiva-readableArrayListof data.- Specified by:
toObjectin interfaceSceneObject- Overrides:
toObjectin classGObject- Returns:
- An
EngineObject
-