-
Notifications
You must be signed in to change notification settings - Fork 1
Shapebase
A scriptable, renderable shape. ShapeBase is the renderable shape from which most of the scriptable, game objects are derived, including the Player, Vehicle and Item classes. ShapeBase provides collision detection, audio channels, and animation as well as damage (and damage states), energy, and the ability to mount Images and objects. ShapeBase objects are not normally instantiated in the scene; derived classes such as Player, WheeledVehicle, and, StaticShape are used instead. But ShapeBase (and the associated datablock, ShapeBaseData) may be used to provide functionality common to all derived objects. A ShapeBase object consists of a DTS or DAE shape file. This file has the following requirements:
Generally in a Torque game, each client is in control of a single game object (such as a Player in an FPS game, or a WheeledVehicle in a racing game). In a game where the client has control over multiple objects (such as units in an RTS), the control object may be the Camera that determines the client's view of the world (although in general, the client's camera object does not need to be the same as the control object). The object controlled by the client is important for several reasons:
ShapeBase includes basic enery and damage systems that may be used by derived classes as required. For example, the Player class uses energy to determine whether the character is capabable of running and jumping, which can be used to mimic the character getting tired and having to rest before continuing. The Player class also uses the damage system PlayerData::onDestroyed callback to trigger a death animation. The Vehicle classes use the current damage level to trigger particle emitters, so a vehicle could progressively generate more smoke as it becomes more damaged. ShapeBase also includes parameters to 'blow up' the object when it is Destroyed (damage level above ShapeBaseData::destroyedLevel). Blowing up an object can generate an explosion and debris, as well as exclude the object from rendering. Parameters to control the object's energy and damage functionality can be found in the ShapeBaseData datablock.
Increment the current damage level by the specified amount.
Apply an impulse to the object.
Repair damage by the specified amount. Note that the damage level is only reduced by repairRate per tick, so it may take several ticks for the total repair to complete.
Check if this object can cloak.
Change one of the materials on the shape. This method changes materials per mapTo with others. The material that is being replaced is mapped to unmapped_mat as a part of this transition.
Destroy an animation thread, which prevents it from playing.
Print a list of visible and hidden meshes in the shape to the console for debugging purposes.
Get the position at which the AI should stand to repair things. If the shape defines a node called "AIRepairNode", this method will return the current world position of that node, otherwise "0 0 0".
Returns the vertical field of view in degrees for this object if used as a camera.
Get the client (if any) that controls this object. The controlling client is the one that will send moves to us to act on.
Get the object (if any) that controls this object.
Get the object's current damage level as a percentage of maxDamage.
Get the object's damage state.
Returns the default vertical field of view in degrees for this object if used as a camera.
Get the object's current energy level as a percentage of maxEnergy.
Get the position of the 'eye' for this object. If the object model has a node called 'eye', this method will return that node's current world position, otherwise it will return the object's current world position.
Get the 'eye' transform for this object. If the object model has a node called 'eye', this method will return that node's current transform, otherwise it will return the object's current transform.
Get the forward direction of the 'eye' for this object. If the object model has a node called 'eye', this method will return that node's current forward direction vector, otherwise it will return the object's current forward direction vector.
Get the alt trigger state of the Image mounted in the specified slot.
Get the ammo state of the Image mounted in the specified slot.
Get the generic trigger state of the Image mounted in the specified slot.
Get the loaded state of the Image mounted in the specified slot.
Get the script animation prefix of the Image mounted in the specified slot.
Get the skin tag ID for the Image mounted in the specified slot.
Get the name of the current state of the Image in the specified slot.
Get the target state of the Image mounted in the specified slot.
Get the trigger state of the Image mounted in the specified slot.
Get the world position this object is looking at. Casts a ray from the eye and returns information about what the ray hits.
Get the model filename used by this shape.
Get the Image mounted in the specified slot.
Get the first slot the given datablock is mounted to on this object.
Get the muzzle position of the Image mounted in the specified slot. If the Image shape contains a node called 'muzzlePoint', then the muzzle position is the position of that node in world space. If no such node is specified, the slot's mount node is used instead.
Get the muzzle vector of the Image mounted in the specified slot. If the Image shape contains a node called 'muzzlePoint', then the muzzle vector is the forward direction vector of that node's transform in world space. If no such node is specified, the slot's mount node is used instead. If the correctMuzzleVector flag (correctMuzzleVectorTP in 3rd person) is set in the Image, the muzzle vector is computed to point at whatever object is right in front of the object's 'eye' node.
Get the Image that will be mounted next in the specified slot. Calling mountImage when an Image is already mounted does one of two things:
This command retrieves the ID of the pending Image (2nd case above).
Get the per-tick repair amount.
Get the name of the shape.
Get the name of the skin applied to this shape.
Get the world transform of the specified mount slot.
Get the number of materials in the shape.
Get the name of the indexed shape material.
Get the object's current velocity.
Reimplemented in Camera.
Check if the given state exists on the mounted Image.
Check if the object is in the Destroyed damage state.
Check if the object is in the Disabled or Destroyed damage state.
Check if the object is in the Enabled damage state.
Check if the object is hidden.
Check if the current Image state is firing.
Check if the given datablock is mounted to any slot on this object.
Mount a new Image.
Pause an animation thread. If restarted using playThread, the animation will resume from the paused position.
Attach a sound to this shape and start playing it.
Start a new animation thread, or restart one that has been paused or stopped.
Set the hidden state on all the shape meshes. This allows you to hide all meshes in the shape, for example, and then only enable a few.
Set the vertical field of view in degrees for this object if used as a camera.
Set the cloaked state of this object. When an object is cloaked it is not rendered.
Set the damage flash level. Damage flash may be used as a postfx effect to flash the screen when the client is damaged.
Set the object's current damage level.
Set the object's damage state.
Set the damage direction vector. Currently this is only used to initialise the explosion if this object is blown up.
Set this object's current energy level.
Add or remove this object from the scene. When removed from the scene, the object will not be processed or rendered.
Reimplemented from SimObject.
Set the alt trigger state of the Image mounted in the specified slot.
Set the ammo state of the Image mounted in the specified slot.
Set the generic trigger state of the Image mounted in the specified slot.
Set the loaded state of the Image mounted in the specified slot.
Set the script animation prefix for the Image mounted in the specified slot. This is used to further modify the prefix used when deciding which animation sequence to play while this image is mounted.
Set the target state of the Image mounted in the specified slot.
Set the trigger state of the Image mounted in the specified slot.
Setup the invincible effect. This effect is used for HUD feedback to the user that they are invincible.
Set the hidden state on the named shape mesh.
Set the recharge rate. The recharge rate is added to the object's current energy level each tick, up to the maxEnergy level set in the ShapeBaseData datablock.
Set amount to repair damage by each tick. Note that this value is separate to the repairRate field in ShapeBaseData. This value will be subtracted from the damage level each tick, whereas the ShapeBaseData field limits how much of the applyRepair value is subtracted each tick. Both repair types can be active at the same time.
Set the name of this shape.
Apply a new skin to this shape. 'Skinning' the shape effectively renames the material targets, allowing different materials to be used on different instances of the same model.
Set the playback direction of an animation thread.
Set the position within an animation thread.
Set the playback time scale of an animation thread.
Set the object's velocity.
Set the white-out level. White-out may be used as a postfx effect to brighten the screen in response to a game event.
Fade the object in or out without removing it from the scene. A faded out object is still in the scene and can still be collided with, so if you want to disable collisions for this shape after it fades out use setHidden to temporarily remove this shape from the scene.
Stop a sound started with playAudio.
Stop an animation thread. If restarted using playThread, the animation will start from the beginning again.
Unmount the mounted Image in the specified slot.
Called on the server when the client has requested a FOV change. When the client requests that its field of view should be changed (because they want to use a sniper scope, for example) this new FOV needs to be validated by the server. This method is called if it exists (it is optional) to validate the requested FOV, and modify it if necessary. This could be as simple as checking that the FOV falls within a correct range, to making sure that the FOV matches the capabilities of the current weapon. Following this method, ShapeBase ensures that the given FOV still falls within the datablock's cameraMinFov and cameraMaxFov. If that is good enough for your purposes, then you do not need to define the validateCameraFov() callback for your ShapeBase.
Is this object AI controlled. If True then this object is considered AI controlled and not player controlled.
The skin applied to the shape. 'Skinning' the shape effectively renames the material targets, allowing different materials to be used on different instances of the same model. Using getSkinName() and setSkinName() is equivalent to reading and writing the skin field directly. Any material targets that start with the old skin name have that part of the name replaced with the new skin name. The initial old skin name is "base". For example, if a new skin of "blue" was applied to a model that had material targets base_body and face, the new targets would be blue_body and face. Note that face was not renamed since it did not start with the old skin name of "base". To support models that do not use the default "base" naming convention, you can also specify the part of the name to replace in the skin field itself. For example, if a model had a material target called shapemat, we could apply a new skin "shape=blue", and the material target would be renamed to bluemat (note "shape" has been replaced with "blue"). Multiple skin updates can also be applied at the same time by separating them with a semicolon. For example: "base=blue;face=happy_face". Material targets are only renamed if an existing Material maps to that name, or if there is a diffuse texture in the model folder with the same name as the new target. |