Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.Scenery.Element Class Reference

Game world element. More...

Inheritance diagram for Dragengine.Scenery.Element:
Dragengine.Gui.MainMenus.Interactive.IMMCameraSpot Dragengine.Scenery.BehaviorElement Dragengine.Gui.MainMenus.Interactive.IMMEnvironmentMap Dragengine.Gui.MainMenus.Interactive.IMMLight Dragengine.Gui.MainMenus.Interactive.IMMParticleEmitter Dragengine.Gui.MainMenus.Interactive.IMMProp Dragengine.Gui.MainMenus.Interactive.IMMSpeaker Dragengine.Scenery.AttachSlot Dragengine.Scenery.AttachableBaseBillboard Dragengine.Scenery.AttachableBaseForceField Dragengine.Scenery.AttachableBaseLight Dragengine.Scenery.AttachableBaseParticleEmitter Dragengine.Scenery.AttachableBaseSpeaker Dragengine.Scenery.BaseActor Dragengine.Scenery.BaseBillboard Dragengine.Scenery.BaseForceField Dragengine.Scenery.BaseLight Dragengine.Scenery.BaseParticleEmitter Dragengine.Scenery.BaseSky Dragengine.Scenery.BaseSpeaker Dragengine.Scenery.BaseWorld Dragengine.Scenery.EnvironmentMap Dragengine.Scenery.GhostElement Dragengine.Scenery.InfoConvoCoordSystem Dragengine.Scenery.PhysicsElement Dragengine.Scenery.SimpleElement Dragengine.Scenery.TriggerConversation Dragengine.Scenery.TriggerEvaluate Dragengine.Scenery.TriggerShout Dragengine.Scenery.TriggerTimer Dragengine.Scenery.TriggerToggle Dragengine.Scenery.TriggerTouch

Public Member Functions

void addToGameWorld ()
Dictionary debugInformation ()
 Debug information as Dictionary.
void dispose ()
 Dispose of element.
void enterFrame ()
 Frame update started.
ElementClass getClass ()
DMatrix getElementMatrix ()
 Matrix to transform from element space into world space.
GameWorld getGameWorld ()
UniqueID getID ()
DMatrix getInverseElementMatrix ()
 Matrix to transform from world space into element space.
bool getIsScaled ()
 Is scaled.
Quaternion getOrientation ()
 Orientation.
Element getParent ()
DVector getPosition ()
 Position.
Vector getScaling ()
 Scaling.
StubElement getStub ()
 Element stub used to create the element.
bool getTouchable ()
bool getVisible ()
void init (StubElement stub)
 Initialize element from stub.
bool isChildOf (Element parent)
bool isDisposed ()
 Element has been disposed of.
bool isMyselfOrChildOf (Element parent)
bool isNotDisposed ()
 Element has not been disposed of.
void log (String message)
 Log using BaseGameApp Console if present.
Element new (ElementClass elementClass)
void onSetGameWorld ()
void onSetGeometry ()
 Position, orientation or scaling changed.
void onSetOrientation ()
 Orientation changed.
void onSetParent ()
void onSetPosition ()
 Position changed.
void onSetScaling ()
 Scaling changed.
void onSetTouchable ()
void onSetVisible ()
void postThink (float elapsed)
void readFromFile (PersistencyEnvironment env, FileReader reader)
 Read element from file reader.
void removeFromGameWorld ()
void removeFromGameWorldIfPresent ()
 Remove element from game world if present.
void safeDispose ()
 Remove element from game world if present and dispose of element.
void setGameWorld (GameWorld gameWorld)
void setGeometry (DVector position, Quaternion orientation)
 Set position and orientation.
void setGeometry (DVector position, Quaternion orientation, Vector scaling)
 Set position, orientation and scaling of element.
void setID (UniqueID id)
void setOrientation (Quaternion orientation)
 Set orientation.
void setParent (Element parent)
void setPosition (DVector position)
 Set position.
void setScaling (Vector scaling)
 Set scaling.
void setStub (StubElement stub)
 Set element stub used to create the element.
void setTouchable (bool touchable)
void setVisible (bool visible)
void think (float elapsed)
String toString ()
void updateStubGeometryFromElement ()
 Update stub position, rotation and scaling from element.
void visit (ElementVisitor visitor)
void writeToFile (PersistencyEnvironment env, FileWriter writer)
 Write element to file writer.
void writeToFileWithStub (PersistencyEnvironment env, FileWriter writer)
 Write element to file writer with stub.

Static Public Member Functions

static Element readElementFromFileWithStub (PersistencyEnvironment env, FileReader reader, ElementClassList ElementClassList)
 Load element from file reader with stub supporting null element.
static void writeElementToFileWithStub (PersistencyEnvironment env, FileWriter writer, Element element)
 Write element to file writer with stub supporting null element.

Public Attributes

ElementClass pClass
GameWorld pGameWorld
UniqueID pID
bool pIsScaled
DMatrix pMatrix
DMatrix pMatrixInverse
Quaternion pOrientation
Element pParent
DVector pPosition
Vector pScaling
StubElement pStub
bool pTouchable
bool pVisible

Detailed Description

Game world element.

Member Function Documentation

◆ addToGameWorld()

void Dragengine.Scenery.Element.addToGameWorld ( )

Adds the element content to the game world if required.

Reimplemented in Dragengine.Scenery.BaseActor.

References pMatrix, pOrientation, and pPosition.

Referenced by debugInformation(), Dragengine.Scenery.BehaviorElement.onSetPosition(), and readFromFile().

◆ debugInformation()

◆ dispose()

void Dragengine.Scenery.Element.dispose ( )

◆ enterFrame()

void Dragengine.Scenery.Element.enterFrame ( )

Frame update started.

To receive this event call GameWorld.addEnterFrameOnce() from inside addToGameWorld(). This event is called at the beginning of the next frame update before think() of any element is called.

Use this method as a one-time call to carry out tasks required to be done once before any elements start thinking. Typically this is done after adding a new element to a game world to finish connections to other elements in the game world which can not be established before all required elements are added too.

Warning
Do not call GameWorld.addEnterFrameOnce() or GameWorld.removeEnterFrameOnce() from inside enterFrame(). Do this from addToGameWorld(), removeFromGameWorld(), think() or postThink().

References getParent(), onSetGeometry(), pParent, and setParent().

Referenced by debugInformation(), and Dragengine.Scenery.BehaviorElement.onSetPosition().

◆ getClass()

◆ getElementMatrix()

DMatrix Dragengine.Scenery.Element.getElementMatrix ( )

Matrix to transform from element space into world space.

References pMatrix, and pOrientation.

Referenced by onSetParent(), and onSetPosition().

◆ getGameWorld()

GameWorld Dragengine.Scenery.Element.getGameWorld ( )

Retrieves the game world or null if not attached.

References getPosition(), and pPosition.

Referenced by Dragengine.Scenery.BehaviorElement.onSetPosition(), and think().

◆ getID()

UniqueID Dragengine.Scenery.Element.getID ( )

Retrieves the unique id or null if not set.

References pClass.

Referenced by setGeometry().

◆ getInverseElementMatrix()

DMatrix Dragengine.Scenery.Element.getInverseElementMatrix ( )

Matrix to transform from world space into element space.

References getScaling(), onSetOrientation(), pMatrixInverse, and pScaling.

Referenced by onSetParent().

◆ getIsScaled()

bool Dragengine.Scenery.Element.getIsScaled ( )

Is scaled.

Referenced by removeFromGameWorldIfPresent().

◆ getOrientation()

Quaternion Dragengine.Scenery.Element.getOrientation ( )

Orientation.

Referenced by setTouchable(), and Dragengine.Scenery.BaseActor.visit().

◆ getParent()

Element Dragengine.Scenery.Element.getParent ( )

Retrieves the parent or null if not attached.

References getClass().

Referenced by enterFrame(), and toString().

◆ getPosition()

DVector Dragengine.Scenery.Element.getPosition ( )

Position.

Referenced by getGameWorld().

◆ getScaling()

Vector Dragengine.Scenery.Element.getScaling ( )

Scaling.

References pOrientation, pPosition, and pScaling.

Referenced by getInverseElementMatrix().

◆ getStub()

StubElement Dragengine.Scenery.Element.getStub ( )

Element stub used to create the element.

References pOrientation.

Referenced by Dragengine.Scenery.BehaviorElement.onSetPosition(), and updateStubGeometryFromElement().

◆ getTouchable()

bool Dragengine.Scenery.Element.getTouchable ( )

Determines if the element is touchable.

References pMatrix, and pMatrixInverse.

Referenced by writeToFileWithStub().

◆ getVisible()

bool Dragengine.Scenery.Element.getVisible ( )

Determines if the element is visible.

References pPosition, and setPosition().

Referenced by readFromFile().

◆ init()

void Dragengine.Scenery.Element.init ( StubElement stub)

Initialize element from stub.

Stub is stored in element for saving. Stub can be changed in certain situations. In general though the stub should be kept unchanged.

Reimplemented in Dragengine.Gui.MainMenus.Interactive.IMMCameraSpot, Dragengine.Scenery.BaseActor, and Dragengine.Scenery.SimpleElementOnRail.

References isDisposed().

Referenced by Dragengine.Scenery.BehaviorElement.addAttachableBehavior(), Dragengine.Scenery.BehaviorElement.getAttachableBehaviorAt(), and setPosition().

◆ isChildOf()

bool Dragengine.Scenery.Element.isChildOf ( Element parent)

Determines if a this element is parented directly or indirectly to the given element. If the element is the same as the given element false is returned.

References pScaling, and setScaling().

Referenced by debugInformation(), and toString().

◆ isDisposed()

bool Dragengine.Scenery.Element.isDisposed ( )

Element has been disposed of.

Referenced by init().

◆ isMyselfOrChildOf()

bool Dragengine.Scenery.Element.isMyselfOrChildOf ( Element parent)

Determines if a this element is parented directly or indirectly to the given element. If the element is the same as the given element true is returned.

References pIsScaled, pMatrix, pMatrixInverse, and pScaling.

Referenced by debugInformation().

◆ isNotDisposed()

bool Dragengine.Scenery.Element.isNotDisposed ( )

Element has not been disposed of.

References dispose(), pClass, pGameWorld, pParent, and pStub.

Referenced by setID().

◆ log()

void Dragengine.Scenery.Element.log ( String message)

Log using BaseGameApp Console if present.

Referenced by debugInformation().

◆ new()

Element Dragengine.Scenery.Element.new ( ElementClass elementClass)

Creates a new element object.

References new(), pClass, and pPosition.

Referenced by new().

◆ onSetGameWorld()

void Dragengine.Scenery.Element.onSetGameWorld ( )

Game world changed.

References pMatrixInverse.

Referenced by debugInformation(), and readFromFile().

◆ onSetGeometry()

void Dragengine.Scenery.Element.onSetGeometry ( )

Position, orientation or scaling changed.

Referenced by debugInformation(), enterFrame(), Dragengine.Scenery.BehaviorElement.onSetPosition(), and removeFromGameWorld().

◆ onSetOrientation()

void Dragengine.Scenery.Element.onSetOrientation ( )

◆ onSetParent()

void Dragengine.Scenery.Element.onSetParent ( )

Parent changed.

References getElementMatrix(), getInverseElementMatrix(), and pMatrixInverse.

Referenced by debugInformation(), and think().

◆ onSetPosition()

void Dragengine.Scenery.Element.onSetPosition ( )

Position changed.

Reimplemented in Dragengine.Scenery.BehaviorElement.

References getElementMatrix(), and pMatrix.

Referenced by debugInformation(), and setTouchable().

◆ onSetScaling()

void Dragengine.Scenery.Element.onSetScaling ( )

◆ onSetTouchable()

void Dragengine.Scenery.Element.onSetTouchable ( )

◆ onSetVisible()

void Dragengine.Scenery.Element.onSetVisible ( )

◆ postThink()

void Dragengine.Scenery.Element.postThink ( float elapsed)

Called after the physics system has carried out collision detection and physics simulations. The element has to update its states like position or rotation from its registered physics objects like Colliders or Components. Complex animated elements also update here the skeletal animations.

Parameters
elapsedTime elapsed since last frame update in seconds

References setGameWorld().

Referenced by debugInformation(), and Dragengine.Scenery.BehaviorElement.onSetPosition().

◆ readElementFromFileWithStub()

Element Dragengine.Scenery.Element.readElementFromFileWithStub ( PersistencyEnvironment env,
FileReader reader,
ElementClassList ElementClassList )
static

Load element from file reader with stub supporting null element.

Reads element class name from reader. If element class name is empty null element is returned. Otherwise stub and element is read from file reader. Uses ElementClass.loadElement() if supported.

References pStub.

Referenced by debugInformation().

◆ readFromFile()

void Dragengine.Scenery.Element.readFromFile ( PersistencyEnvironment env,
FileReader reader )

Read element from file reader.

The default implementation reads a single byte expecting value 0 indicating version 0. This allows subclasses to add persistency support by overwriting this method without super calling it.

Reimplemented in Dragengine.Scenery.BaseActor.

References addToGameWorld(), getVisible(), onSetGameWorld(), and pVisible.

Referenced by debugInformation(), and Dragengine.Scenery.BehaviorElement.onSetPosition().

◆ removeFromGameWorld()

void Dragengine.Scenery.Element.removeFromGameWorld ( )

Removes the element content from the game world if placed there before.

References onSetGeometry(), pIsScaled, pMatrix, pMatrixInverse, pOrientation, pPosition, pScaling, and setGeometry().

Referenced by debugInformation(), Dragengine.Scenery.BehaviorElement.onSetPosition(), and visit().

◆ removeFromGameWorldIfPresent()

void Dragengine.Scenery.Element.removeFromGameWorldIfPresent ( )

Remove element from game world if present.

References getIsScaled(), onSetScaling(), and pIsScaled.

Referenced by debugInformation().

◆ safeDispose()

void Dragengine.Scenery.Element.safeDispose ( )

Remove element from game world if present and dispose of element.

This is the prefered way to dispose of an element no matter if it is part of a game world or not. Do not use dispose() directly otherwise clean up logic done by removeFromGameWorld() is skipped.

References pOrientation, pPosition, and setGeometry().

Referenced by debugInformation().

◆ setGameWorld()

void Dragengine.Scenery.Element.setGameWorld ( GameWorld gameWorld)

Sets the game world or null if not attached.

Referenced by postThink().

◆ setGeometry() [1/2]

void Dragengine.Scenery.Element.setGeometry ( DVector position,
Quaternion orientation )

Set position and orientation.

References getID(), and pID.

Referenced by removeFromGameWorld(), and safeDispose().

◆ setGeometry() [2/2]

void Dragengine.Scenery.Element.setGeometry ( DVector position,
Quaternion orientation,
Vector scaling )

Set position, orientation and scaling of element.

References pID, and setID().

◆ setID()

void Dragengine.Scenery.Element.setID ( UniqueID id)

Sets the unique id or null to unset it.

References isNotDisposed(), and pClass.

Referenced by setGeometry().

◆ setOrientation()

void Dragengine.Scenery.Element.setOrientation ( Quaternion orientation)

Set orientation.

References pID, and pStub.

Referenced by setStub(), and Dragengine.Scenery.BaseActor.visit().

◆ setParent()

void Dragengine.Scenery.Element.setParent ( Element parent)

Sets the parent or null if not attached.

References pClass.

Referenced by enterFrame().

◆ setPosition()

void Dragengine.Scenery.Element.setPosition ( DVector position)

Set position.

References init().

Referenced by getVisible().

◆ setScaling()

void Dragengine.Scenery.Element.setScaling ( Vector scaling)

Set scaling.

References pIsScaled, and pScaling.

Referenced by isChildOf().

◆ setStub()

void Dragengine.Scenery.Element.setStub ( StubElement stub)

Set element stub used to create the element.

References pOrientation, and setOrientation().

Referenced by updateStubGeometryFromElement().

◆ setTouchable()

void Dragengine.Scenery.Element.setTouchable ( bool touchable)

Sets if the element is touchable.

References getOrientation(), and onSetPosition().

Referenced by writeToFileWithStub().

◆ setVisible()

void Dragengine.Scenery.Element.setVisible ( bool visible)

Sets if the element is visible.

References pPosition.

Referenced by Dragengine.Scenery.BaseActor.visit(), and writeToFile().

◆ think()

void Dragengine.Scenery.Element.think ( float elapsed)

Thinks about what the element is going to do in this frame. This is the place to use AI functions to determine the next motions beeing it displacement, rotation or other shape changes. The game world will use this information to carry out changes to the elements. An element does not change its state by itself rather waits for the game world to apply the required changes. Execute here als updates to dynamic skins that are independant, hence not requiring the game world to be uptodate for rendering.

Parameters
elapsedTime elapsed since last frame update in seconds

References getGameWorld(), onSetParent(), and pGameWorld.

Referenced by debugInformation(), and Dragengine.Scenery.BehaviorElement.onSetPosition().

◆ toString()

String Dragengine.Scenery.Element.toString ( )

Return string representation of this Element.

References getParent(), and isChildOf().

Referenced by debugInformation().

◆ updateStubGeometryFromElement()

void Dragengine.Scenery.Element.updateStubGeometryFromElement ( )

Update stub position, rotation and scaling from element.

Version
1.23

References getStub(), pStub, and setStub().

Referenced by debugInformation().

◆ visit()

void Dragengine.Scenery.Element.visit ( ElementVisitor visitor)

Visit this element.

Reimplemented in Dragengine.Gui.MainMenus.Interactive.IMMCameraSpot, Dragengine.Gui.MainMenus.Interactive.IMMEnvironmentMap, Dragengine.Gui.MainMenus.Interactive.IMMHotSpot, Dragengine.Gui.MainMenus.Interactive.IMMLight, Dragengine.Gui.MainMenus.Interactive.IMMParticleEmitter, Dragengine.Gui.MainMenus.Interactive.IMMProp, Dragengine.Gui.MainMenus.Interactive.IMMSpeaker, Dragengine.Scenery.AnimatedElement, Dragengine.Scenery.AttachableBaseBillboard, Dragengine.Scenery.AttachableBaseForceField, Dragengine.Scenery.AttachableBaseLight, Dragengine.Scenery.AttachableBaseParticleEmitter, Dragengine.Scenery.AttachableBaseSpeaker, Dragengine.Scenery.AttachSlot, Dragengine.Scenery.BaseActor, Dragengine.Scenery.BaseBillboard, Dragengine.Scenery.BaseForceField, Dragengine.Scenery.BaseLight, Dragengine.Scenery.BaseParticleEmitter, Dragengine.Scenery.BaseSky, Dragengine.Scenery.BaseSpeaker, Dragengine.Scenery.BaseVRActor, Dragengine.Scenery.BaseWorld, Dragengine.Scenery.EnvironmentMap, Dragengine.Scenery.GhostElement, Dragengine.Scenery.HiddenElement, Dragengine.Scenery.InfoConvoCoordSystem, Dragengine.Scenery.PhysicsElement, Dragengine.Scenery.SimpleElement, Dragengine.Scenery.SimpleElementOnRail, Dragengine.Scenery.TriggerConversation, Dragengine.Scenery.TriggerEvaluate, Dragengine.Scenery.TriggerShout, Dragengine.Scenery.TriggerTimer, Dragengine.Scenery.TriggerToggle, Dragengine.Scenery.TriggerTouch, and Dragengine.Scenery.TwoStateAnimatedElement.

References pGameWorld, and removeFromGameWorld().

Referenced by debugInformation(), and Dragengine.Scenery.BehaviorElement.onSetPosition().

◆ writeElementToFileWithStub()

void Dragengine.Scenery.Element.writeElementToFileWithStub ( PersistencyEnvironment env,
FileWriter writer,
Element element )
static

Write element to file writer with stub supporting null element.

Writes element class name, then the stub parameters and then the element parameters. If no stub exists an empty one is used for writing stub parameters. If element is null empty element class name is written. Empty element class name is used during loading to indicate a null element.

References onSetTouchable(), and pTouchable.

Referenced by debugInformation().

◆ writeToFile()

void Dragengine.Scenery.Element.writeToFile ( PersistencyEnvironment env,
FileWriter writer )

Write element to file writer.

The default implementation writes a single byte of value 0 indicating version 0. This allows subclasses to add persistency support by overwriting this method without super calling it.

Reimplemented in Dragengine.Scenery.BaseActor.

References onSetVisible(), pVisible, and setVisible().

Referenced by debugInformation(), and Dragengine.Scenery.BehaviorElement.onSetPosition().

◆ writeToFileWithStub()

void Dragengine.Scenery.Element.writeToFileWithStub ( PersistencyEnvironment env,
FileWriter writer )

Write element to file writer with stub.

Writes element class name, then the stub parameters and then the element parameters. If no stub exists an empty one is used for writing stub parameters.

References getTouchable(), pTouchable, and setTouchable().

Referenced by debugInformation().

Member Data Documentation

◆ pClass

ElementClass Dragengine.Scenery.Element.pClass

◆ pGameWorld

GameWorld Dragengine.Scenery.Element.pGameWorld

◆ pID

UniqueID Dragengine.Scenery.Element.pID

◆ pIsScaled

bool Dragengine.Scenery.Element.pIsScaled

◆ pMatrix

◆ pMatrixInverse

◆ pOrientation

◆ pParent

Element Dragengine.Scenery.Element.pParent

◆ pPosition

◆ pScaling

◆ pStub

◆ pTouchable

bool Dragengine.Scenery.Element.pTouchable

◆ pVisible

bool Dragengine.Scenery.Element.pVisible

The documentation for this class was generated from the following file: