Class Thing
- All Implemented Interfaces:
SceneObjectList,SceneObject,HasProperties
SceneObjectList
which makes up an entire 3d object made of GTris, GPoints and GLines.
A Thing, can be transformed in any means necessary and is the only "object" which the user can actually interact with. They can interact with GObjects but a Thing is the first tangible thing. (pun intended)
A Thing is the first user tangible object. So it naturally has to interact with
the app in many different ways whther it be showing itself in the JTree
or being written to a ProjectFile
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Vector3The centroid of the Thing, calculated from the GPoints it contains.private booleanGoverned bySceneObjectList, whether this Thing is for deletion or not.private booleanGoverned bySceneObjectList, whether this Thing is hidden or not.private UUIDThe unique identifier for this Thing.private booleanA Flag set by the Thing itself to check whether its part of the background. if so it only draws the axes and the background.private StringThe name of this Thing.The master list of GObjects that compose this 3D Thing.private final BiConsumer<Thing, DefaultMutableTreeNode> What the thing should do when it gets selected within the tree GUIprivate LayerThe parent layer of this Thing.The list of points that compose this 3D Thing.private booleanWhether all triangles that get added to this Thing should be single sided or not.private DefaultMutableTreeNodeRequired bySceneObjectList, The actual tree node reference for this Thing within the Tree GUI.private TreeNodeIdentity<Thing> Required bySceneObjectList, The Tree Node Identity object defining this Thing within the Tree GUI. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds one or more GObjects to this Thing.private voidaddProps()private voidcalculateCentroid(GObject[] gObjects) copy(SceneManager sceneManager, Layer l) Creates a copy of this Thing, adding its GObjects to the specified sceneManager and layer.Deletes the object.voiddraw(Graphics2D graphics2D) Draws this Thing to the screen.static ThingConstructs a Thing.Returns the centroid of this Thing.getId()Returns the unique identifier of this Thing.Returns theTreeNodeIdentityfor the given object to use within theLayerTreegetName()Gets the name of this Thing.Returns the GObjects that compose this Thing.BiConsumer<? extends SceneObjectList, DefaultMutableTreeNode> The callback for when the object is selected in the tree.The actual tree node for the representation of this object withinLayerTreevoidAn internal delete method which all implementors should override for instantaneous deletion.voidA method to initialise anything swing related within the constructor.booleanLabels the object as for deletion.booleanisHidden()Whether the given object is hidden or notbooleanisSolid()static voidmoveObjects(ArrayList<GObject> stuff, Thing to) voidprivate voidremoveObjects(ArrayList<GObject> stuff) Rotates the Thing around a given axis by a given angle.Rotates the Thing around a given axis by a given angle.scale(double scale) Scales the Thing by a uniform factor around its centroid.Scales the Thing by a vector factor around its centroid.voidsetForDeletion(boolean forDeletion) Marks the object for deletion.voidsetHidden(boolean hidden) Hides the object.private voidSets this thing's unique identifierprivate voidsolidify()Solidifies the Thing by setting all itsGTris to be single-sided.Toggles the visibility of the object.Translates the Thing by a given vector.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.j3d.engine.scene.nodes.SceneObjectList
toggleSaved
-
Field Details
-
centroid
The centroid of the Thing, calculated from the GPoints it contains. -
id
The unique identifier for this Thing. -
name
The name of this Thing. -
properties
-
onSelectCallback
What the thing should do when it gets selected within the tree GUI -
objects
The master list of GObjects that compose this 3D Thing. -
points
The list of points that compose this 3D Thing. -
solid
private boolean solidWhether all triangles that get added to this Thing should be single sided or not. -
parent
The parent layer of this Thing. -
isBg
private boolean isBgA Flag set by the Thing itself to check whether its part of the background. if so it only draws the axes and the background. -
forDeletion
private boolean forDeletionGoverned bySceneObjectList, whether this Thing is for deletion or not. -
treeNodeIdentity
Required bySceneObjectList, The Tree Node Identity object defining this Thing within the Tree GUI. -
treeNode
Required bySceneObjectList, The actual tree node reference for this Thing within the Tree GUI.
-
-
Constructor Details
-
Thing
Constructs a Thing.- Parameters:
l- The parent layer of the Thing.name- The name of the Thing.invokeSwingHooks- Whether to run GUI related hooks
-
Thing
Constructs a Thing and runs GUI related hooks.- Parameters:
l- The parent layer of the Thing.name- The name of the Thing.
-
-
Method Details
-
getName
Gets the name of this Thing.- Specified by:
getNamein interfaceSceneObject- Returns:
- The name of this Thing.
-
fromRaw
Constructs a Thing.- Parameters:
name- The name of the Thing defined in the file.id- The ID of the Thing defined in the file.hidden- Whether the Thing is hidden or not.l- The parent layer of the Thing.- Returns:
- A Thing
-
setId
Sets this thing's unique identifier- Parameters:
uuid- The new UUID- See Also:
-
invokeSwingHooks
public void invokeSwingHooks()Description copied from interface:SceneObjectListA method to initialise anything swing related within the constructor. This is typically called within the SceneObjectList's constructor who needs to create an object outside the EDT thread.A use case (the current use case) would be when an SceneObjectList is loaded from disk to memory and the
Spinnerdialog is blocking the EDT thread. After the throbber has finished, you may call invokeSwingHooks safely rather than fighting with a blocked EDT thread.- Specified by:
invokeSwingHooksin interfaceSceneObjectList
-
addObjs
Adds one or more GObjects to this Thing.- Parameters:
gObjects- The GObjects to add.
-
calculateCentroid
-
draw
Draws this Thing to the screen.- Parameters:
graphics2D- The Graphics2D instance
-
getId
Returns the unique identifier of this Thing.- Specified by:
getIdin interfaceSceneObject- Returns:
- The UUID of this Thing.
-
getObjects
Returns the GObjects that compose this Thing.- Returns:
- The GObjects that compose this Thing.
-
getCentroid
Returns the centroid of this Thing.- Returns:
- The centroid of this Thing.
-
getProperties
Description copied from interface:HasPropertiesReturns anArrayListofPropertyobjects associated with this instance. Each property can hold a value of a specific type and have a specific key type.- Specified by:
getPropertiesin interfaceHasProperties- Returns:
- an ArrayList of properties.
-
solidify
Solidifies the Thing by setting all itsGTris to be single-sided.- Returns:
- This Thing, for method chaining.
-
addProps
private void addProps() -
setName
-
moveObjects
-
removeObjects
-
copy
Creates a copy of this Thing, adding its GObjects to the specified sceneManager and layer.- Parameters:
sceneManager- The sceneManager to associate the new Thing with.l- The layer to add the new Thing to.- Returns:
- An Action that performs the copy operation and itself returns the new Thing.
-
scale
Scales the Thing by a uniform factor around its centroid.- Parameters:
scale- The uniform scaling factor.- Returns:
- An Action which performs the scae operation.
-
scale
Scales the Thing by a vector factor around its centroid.- Parameters:
scale- The scaling vector, where each component scales along its respective axis.- Returns:
- An Action which performs the scale operation.
-
translate
Translates the Thing by a given vector.- Parameters:
v- The translation vector.- Returns:
- An Action which performs the translation operation.
-
rotate
Rotates the Thing around a given axis by a given angle.- Parameters:
axis- The rotation axis.angleDegrees- The rotation angle in degrees.- Returns:
- An Action which performs the rotation operation.
-
rotate
Rotates the Thing around a given axis by a given angle.- Parameters:
centre- The rotation centre.axis- The rotation axis.angleDegrees- The rotation angle in degrees.- Returns:
- An Action which performs the rotation operation.
-
instantDelete
public void instantDelete()Description copied from interface:SceneObjectListAn internal delete method which all implementors should override for instantaneous deletion.This method should not be called by a user interface things. However, any object overriding the method must provide a way to delete everything relating to it.
- Specified by:
instantDeletein interfaceSceneObjectList
-
getIdentity
Description copied from interface:SceneObjectListReturns theTreeNodeIdentityfor the given object to use within theLayerTree- Specified by:
getIdentityin interfaceSceneObjectList- Returns:
- The identity
-
getTreeNode
Description copied from interface:SceneObjectListThe actual tree node for the representation of this object withinLayerTree- Specified by:
getTreeNodein interfaceSceneObjectList- Returns:
- The tree node
-
getOnSelect
Description copied from interface:SceneObjectListThe callback for when the object is selected in the tree.- Specified by:
getOnSelectin interfaceSceneObjectList- Returns:
- The callback
-
isHidden
public boolean isHidden()Description copied from interface:SceneObjectListWhether the given object is hidden or not- Specified by:
isHiddenin interfaceSceneObjectList- Returns:
- true if hidden, false otherwise
-
setHidden
public void setHidden(boolean hidden) Description copied from interface:SceneObjectListHides the object. This is for internal use. GUI and other user things should make use ofSceneObjectList.toggleVisibility()instead.- Specified by:
setHiddenin interfaceSceneObjectList
-
isForDeletion
public boolean isForDeletion()Description copied from interface:SceneObjectListLabels the object as for deletion. Has similar implications as being hidden however it will be cleaned up later and won't be available on lists.- Specified by:
isForDeletionin interfaceSceneObjectList- Returns:
- true if the object was marked for deletion
-
setForDeletion
public void setForDeletion(boolean forDeletion) Description copied from interface:SceneObjectListMarks the object for deletion.- Specified by:
setForDeletionin interfaceSceneObjectList
-
toggleVisibility
Description copied from interface:SceneObjectListToggles the visibility of the object.- Specified by:
toggleVisibilityin interfaceSceneObjectList- Returns:
- An action that toggles the visibility of the object and returns the new visibility state.
-
deleteLater
Description copied from interface:SceneObjectListDeletes the object.The use of the word "later" is because the action of deletion is only ever done once the Action object is out of the history's bounds. At that point
CleanableAction.cleanup()is called, which actually deletes.- Specified by:
deleteLaterin interfaceSceneObjectList- Returns:
- An action that deletes the object.
-
objectsStream
-
isSolid
public boolean isSolid() -
remove
-