Torque 3D - Script Manual: SceneObject Class Reference

TorqueScript

Main   Class List   Namespace List   Online

SceneObject Class Reference
[Game Objects]

A networkable object that exists in the 3D world. More...

Inheritance diagram for SceneObject:

List of all members.

Public Member Functions

Point3F getEulerRotation ()
 Get Euler rotation of this object.
VectorF getForwardVector ()
 Get the direction this object is facing.
TransformF getInverseTransform ()
 Get the object's inverse transform.
int getMountedObject (int slot)
 Get the object mounted at a particular slot.
int getMountedObjectCount ()
 Get the number of objects mounted to us.
int getMountedObjectNode (int slot)
 Get the mount node index of the object mounted at our given slot.
int getMountNodeObject (int node)
 Get the object mounted at our given node index.
Box3F getObjectBox ()
 Get the object's bounding box (relative to the object's origin).
int getObjectMount ()
 Get the object we are mounted to.
Point3F getPosition ()
 Get the object's world position.
VectorF getRightVector ()
 Get the right vector of the object.
Point3F getScale ()
 Get the object's scale.
TransformF getTransform ()
 Get the object's transform.
int getType ()
 Return the type mask for this object.
VectorF getUpVector ()
 Get the up vector of the object.
Box3F getWorldBox ()
 Get the object's world bounding box.
Point3F getWorldBoxCenter ()
 Get the center of the object's world bounding box.
bool isGlobalBounds ()
 Check if this object has a global bounds set.
bool isMounted ()
 Check if we are mounted to another object.
bool mountObject (SceneObject objB, int slot, TransformF txfm=MatrixF::Identity)
 Mount objB to this object at the desired slot with optional transform.
void setScale (Point3F scale)
 Set the object's scale.
void setTransform (TransformF txfm)
 Set the object's transform (orientation and position).
void unmount ()
 Unmount us from the currently mounted object if any.
bool unmountObject (SceneObject target)
 Unmount an object from ourselves.

Public Attributes

Editing

bool isRenderEnabled
 Controls client-side rendering of the object.
bool isSelectionEnabled
 Determines if the object may be selected from wihin the Tools.
Mounting

int mountNode
 Node we are mounted to.
pid mountPID
 PersistentID of object we are mounted to.
MatrixPosition mountPos
 Position we are mounted at ( object space of our mount object ).
MatrixRotation mountRot
 Rotation we are mounted at ( object space of our mount object ).
Transform

MatrixPosition position
 Object world position.
MatrixRotation rotation
 Object world orientation.
Point3F scale
 Object world scale.

Static Public Attributes

static bool isRenderable
 Disables rendering of all instances of this type.
static bool isSelectable
 Disables selection of all instances of this type.

Detailed Description

A networkable object that exists in the 3D world.

The SceneObject class provides the foundation for 3D objects in the Engine. It exposes the functionality for:

  • Position, rotation and scale within the world.
  • Working with a scene graph (in the Zone and Portal sections), allowing efficient and robust rendering of the game scene.
  • Various helper functions, including functions to get bounding information and momentum/velocity.
  • Mounting one SceneObject to another.
  • An interface for collision detection, as well as ray casting.
  • Lighting. SceneObjects can register lights both at lightmap generation time, and dynamic lights at runtime (for special effects, such as from flame or a projectile, or from an explosion).

You do not typically work with SceneObjects themselves. The SceneObject provides a reference within the game world (the scene), but does not render to the client on its own. The same is true of collision detection beyond that of the bounding box. Instead you use one of the many classes that derrive from SceneObject, such as TSStatic.

Difference Between setHidden() and isRenderEnabled

When it comes time to decide if a SceneObject should render or not, there are two methods that can stop the SceneObject from rendering at all. You need to be aware of the differences between these two methods as they impact how the SceneObject is networked from the server to the client.

The first method of manually controlling if a SceneObject is rendered is through its SceneObject::isRenderEnabled property. When set to false the SceneObject is considered invisible but still present within the scene. This means it still takes part in collisions and continues to be networked.

The second method is using the setHidden() method. This will actually remove a SceneObject from the scene and it will no longer be networked from the server to the cleint. Any client-side ghost of the object will be deleted as the server no longer considers the object to be in scope.


Member Function Documentation

Point3F SceneObject::getEulerRotation (  ) 

Get Euler rotation of this object.

Returns:
the orientation of the object in the form of rotations around the X, Y and Z axes in degrees.
VectorF SceneObject::getForwardVector (  ) 

Get the direction this object is facing.

Returns:
a vector indicating the direction this object is facing.
Note:
This is the object's y axis.
TransformF SceneObject::getInverseTransform (  ) 

Get the object's inverse transform.

Returns:
the inverse transform of the object
int SceneObject::getMountedObject ( int  slot  ) 

Get the object mounted at a particular slot.

Parameters:
slot mount slot index to query
Returns:
ID of the object mounted in the slot, or 0 if no object.
int SceneObject::getMountedObjectCount (  ) 

Get the number of objects mounted to us.

Returns:
the number of mounted objects.
int SceneObject::getMountedObjectNode ( int  slot  ) 

Get the mount node index of the object mounted at our given slot.

Parameters:
slot mount slot index to query
Returns:
index of the mount node used by the object mounted in this slot.
int SceneObject::getMountNodeObject ( int  node  ) 

Get the object mounted at our given node index.

Parameters:
node mount node index to query
Returns:
ID of the first object mounted at the node, or 0 if none found.
Box3F SceneObject::getObjectBox (  ) 

Get the object's bounding box (relative to the object's origin).

Returns:
six fields, two Point3Fs, containing the min and max points of the objectbox.
int SceneObject::getObjectMount (  ) 

Get the object we are mounted to.

Returns:
the SimObjectID of the object we're mounted to, or 0 if not mounted.
Point3F SceneObject::getPosition (  ) 

Get the object's world position.

Returns:
the current world position of the object

Reimplemented in Camera.

VectorF SceneObject::getRightVector (  ) 

Get the right vector of the object.

Returns:
a vector indicating the right direction of this object.
Note:
This is the object's x axis.
Point3F SceneObject::getScale (  ) 

Get the object's scale.

Returns:
object scale as a Point3F
TransformF SceneObject::getTransform (  ) 

Get the object's transform.

Returns:
the current transform of the object
int SceneObject::getType (  ) 

Return the type mask for this object.

Returns:
The numeric type mask for the object.
VectorF SceneObject::getUpVector (  ) 

Get the up vector of the object.

Returns:
a vector indicating the up direction of this object.
Note:
This is the object's z axis.
Box3F SceneObject::getWorldBox (  ) 

Get the object's world bounding box.

Returns:
six fields, two Point3Fs, containing the min and max points of the worldbox.
Point3F SceneObject::getWorldBoxCenter (  ) 

Get the center of the object's world bounding box.

Returns:
the center of the world bounding box for this object.
bool SceneObject::isGlobalBounds (  ) 

Check if this object has a global bounds set.

If global bounds are set to be true, then the object is assumed to have an infinitely large bounding box for collision and rendering purposes.

Returns:
true if the object has a global bounds.
bool SceneObject::isMounted (  ) 

Check if we are mounted to another object.

Returns:
true if mounted to another object, false if not mounted.
bool SceneObject::mountObject ( SceneObject  objB,
int  slot,
TransformF  txfm = MatrixF::Identity 
)

Mount objB to this object at the desired slot with optional transform.

Parameters:
objB Object to mount onto us
slot Mount slot ID
txfm (optional) mount offset transform
Returns:
true if successful, false if failed (objB is not valid)
void SceneObject::setScale ( Point3F  scale  ) 

Set the object's scale.

Parameters:
scale object scale to set
void SceneObject::setTransform ( TransformF  txfm  ) 

Set the object's transform (orientation and position).

Parameters:
txfm object transform to set
void SceneObject::unmount (  ) 

Unmount us from the currently mounted object if any.

bool SceneObject::unmountObject ( SceneObject  target  ) 

Unmount an object from ourselves.

Parameters:
target object to unmount
Returns:
true if successful, false if failed

Member Data Documentation

Controls client-side rendering of the object.

See also:
isRenderable()

Determines if the object may be selected from wihin the Tools.

See also:
isSelectable()

Node we are mounted to.

PersistentID of object we are mounted to.

Unlike the SimObjectID that is determined at run time, the PersistentID of an object is saved with the level/mission and may be used to form a link between objects.

MatrixPosition SceneObject::mountPos

Position we are mounted at ( object space of our mount object ).

MatrixRotation SceneObject::mountRot

Rotation we are mounted at ( object space of our mount object ).

MatrixPosition SceneObject::position

Object world position.

MatrixRotation SceneObject::rotation

Object world orientation.

Object world scale.



Copyright © GarageGames, LLC. All Rights Reserved.