|
Represents geometry to be mounted to a ShapeBase object. More...
Public Member Functions | |
Callbacks | |
void | onMount (ShapeBase obj, int slot, float dt) |
Called when the Image is first mounted to the object. | |
void | onUnmount (ShapeBase obj, int slot, float dt) |
Called when the Image is unmounted from the object. | |
Public Attributes | |
bool | accuFire |
Flag to control whether the Image's aim is automatically converged with the crosshair. | |
Point3F | camShakeAmp |
Amplitude of the camera shaking effect. | |
Point3F | camShakeFreq |
Frequency of the camera shaking effect. | |
DebrisData | casing |
DebrisData datablock to use for ejected casings. | |
bool | cloakable |
Whether this Image can be cloaked. | |
bool | computeCRC |
If true, verify that the CRC of the client's Image matches the server's CRC for the Image when loaded by the client. | |
bool | correctMuzzleVector |
Flag to adjust the aiming vector to the eye's LOS point. | |
bool | emap |
Whether to enable environment mapping on this Image. | |
MatrixPosition | eyeOffset |
"X Y Z" translation offset from the ShapeBase model's eye node. | |
MatrixRotation | eyeRotation |
"X Y Z ANGLE" rotation offset from the ShapeBase model's eye node. | |
bool | firstPerson |
This flag must be set for the adjusted LOS muzzle vector to be computed. | |
float | lightBrightness |
Brightness of the light this Image emits. | |
ColorF | lightColor |
The color of light this Image emits. | |
int | lightDuration |
Duration in SimTime of Pulsing and WeaponFire type lights. | |
float | lightRadius |
Radius of the light this Image emits. | |
ShapeBaseImageLightType | lightType |
The type of light this Image emits. | |
float | mass |
Mass of this Image. | |
int | maxConcurrentSounds |
Maximum number of sounds this Image can play at a time. | |
float | minEnergy |
Minimum Image energy for it to be operable. | |
int | mountPoint |
Mount node # to mount this Image to. | |
MatrixPosition | offset |
"X Y Z" translation offset from this Image's mountPoint node to attach to. | |
ProjectileData | Projectile |
The projectile fired by this Image. | |
MatrixRotation | rotation |
"X Y Z ANGLE" rotation offset from this Image's mountPoint node to attach to. | |
bool | shakeCamera |
Flag indicating whether the camera should shake when this Image fires. | |
filename | shapeFile |
The DTS or DAE model to use for this Image. | |
Point3F | shellExitDir |
Vector direction to eject shell casings. | |
float | shellExitVariance |
Variance (in degrees) from the shellExitDir vector to eject casings. | |
float | shellVelocity |
Speed at which to eject casings. | |
bool | stateAllowImageChange [31] |
If false, other Images will temporarily be blocked from mounting while the state machine is executing the tasks in this state. | |
bool | stateDirection [31] |
Direction of the animation to play in this state. | |
bool | stateEjectShell [31] |
If true, a shell casing will be ejected in this state. | |
ParticleEmitterData | stateEmitter [31] |
Emitter to generate particles in this state (from muzzle point or specified node). | |
string | stateEmitterNode [31] |
Name of the node to emit particles from. | |
float | stateEmitterTime [31] |
How long (in seconds) to emit particles on entry to this state. | |
float | stateEnergyDrain [31] |
Amount of energy to subtract from the Image in this state. | |
bool | stateFire [31] |
The first state with this set to true is the state entered by the client when it receives the 'fire' event. | |
bool | stateIgnoreLoadedForReady [31] |
If set to true, and both ready and loaded transitions are true, the ready transition will be taken instead of the loaded transition. | |
ShapeBaseImageLoadedState | stateLoadedFlag [31] |
Set the loaded state of the Image. | |
caseString | stateName [31] |
Name of this state. | |
ShapeBaseImageRecoilState | stateRecoil [31] |
Type of recoil sequence to play on the ShapeBase object on entry to this state. | |
bool | stateScaleAnimation [31] |
If true, the timeScale of the stateSequence animation will be adjusted such that the sequence plays for stateTimeoutValue seconds. | |
caseString | stateScript [31] |
Method to execute on entering this state. | |
string | stateSequence [31] |
Name of the sequence to play on entry to this state. | |
bool | stateSequenceRandomFlash [31] |
If true, a random frame from the muzzle flash sequence will be displayed each frame. | |
SFXTrack | stateSound [31] |
Sound to play on entry to this state. | |
ShapeBaseImageSpinState | stateSpinThread [31] |
Controls how fast the 'spin' animation sequence will be played in this state. | |
float | stateTimeoutValue [31] |
Time in seconds to wait before transitioning to stateTransitionOnTimeout. | |
string | stateTransitionOnAltTriggerDown [31] |
Name of the state to transition to when the alt trigger state of the Image changes to false (alt fire button up). | |
string | stateTransitionOnAltTriggerUp [31] |
Name of the state to transition to when the alt trigger state of the Image changes to true (alt fire button down). | |
string | stateTransitionOnAmmo [31] |
Name of the state to transition to when the ammo state of the Image changes to true. | |
string | stateTransitionOnLoaded [31] |
Name of the state to transition to when the loaded state of the Image changes to 'Loaded'. | |
string | stateTransitionOnNoAmmo [31] |
Name of the state to transition to when the ammo state of the Image changes to false. | |
string | stateTransitionOnNoTarget [31] |
Name of the state to transition to when the Image loses a target. | |
string | stateTransitionOnNotLoaded [31] |
Name of the state to transition to when the loaded state of the Image changes to 'Empty'. | |
string | stateTransitionOnNotWet [31] |
Name of the state to transition to when the Image exits the water. | |
string | stateTransitionOnTarget [31] |
Name of the state to transition to when the Image gains a target. | |
string | stateTransitionOnTimeout [31] |
Name of the state to transition to when we have been in this state for stateTimeoutValue seconds. | |
string | stateTransitionOnTriggerDown [31] |
Name of the state to transition to when the trigger state of the Image changes to false (fire button released). | |
string | stateTransitionOnTriggerUp [31] |
Name of the state to transition to when the trigger state of the Image changes to true (fire button down). | |
string | stateTransitionOnWet [31] |
Name of the state to transition to when the Image enters the water. | |
bool | stateWaitForTimeout [31] |
If false, this state ignores stateTimeoutValue and transitions immediately if other transition conditions are met. | |
bool | useRemainderDT |
If true, allow multiple timeout transitions to occur within a single tick (useful if states have a very small timeout). | |
bool | usesEnergy |
Flag indicating whether this Image uses energy instead of ammo. The energy level comes from the ShapeBase object we're mounted to. |
Represents geometry to be mounted to a ShapeBase object.
Unlike other datablocks, ShapeBaseImageData does not have an associated xBase class associated with it.
Instead, this datablock is an abstraction of geometry that can only be mounted to a ShapeBase object and is only used by a ShapBase object.
The most common use for ShapeBaseImageData objects (referred to as Images hereafter) is for weapons carried by a Player or Vehicle object, and much of the functionality provided by the Image is aimed at that use-case. Images include a powerful state machine to control animations, sounds, script callbacks, and state transitions. This state system is downloaded to the client so that clients can predict state changes and animate accordingly.
The following example - a grenade launcher weapon - demonstates the flexibility of the system. The weapon includes states and transitions to handle the normal ready->fire->reload->ready loop as well as noammo->dryfire for firing when the weapon is out of ammo.
datablock ShapeBaseImageData( GrenadeLauncherImage ) { // Initial start up state stateName[0] = "Preactivate"; stateTransitionOnLoaded[0] = "Activate"; stateTransitionOnNoAmmo[0] = "NoAmmo"; // Activating the gun. // Called when the weapon is first mounted and there is ammo. stateName[1] = "Activate"; stateTransitionOnTimeout[1] = "Ready"; stateTimeoutValue[1] = 0.6; stateSequence[1] = "Activate"; // Ready to fire, just waiting for the trigger stateName[2] = "Ready"; stateTransitionOnNoAmmo[2] = "NoAmmo"; stateTransitionOnTriggerDown[2] = "CheckWet"; stateSequence[2] = "Ready"; // Fire the weapon. Calls the fire script which does the actual work. stateName[3] = "Fire"; stateTransitionOnTimeout[3] = "PostFire"; stateTimeoutValue[3] = 0.4; stateFire[3] = true; stateAllowImageChange[3] = false; stateSequence[3] = "Fire"; stateScript[3] = "onFire"; stateSound[3] = GrenadeLauncherFireSound; // Check ammo stateName[4] = "PostFire"; stateTransitionOnAmmo[4] = "Reload"; stateTransitionOnNoAmmo[4] = "NoAmmo"; // Play the reload animation, and transition into stateName[5] = "Reload"; stateTransitionOnTimeout[5] = "Ready"; stateTimeoutValue[5] = 0.2; stateAllowImageChange[5] = false; stateSequence[5] = "Reload"; stateEjectShell[5] = false; // set to true to enable shell casing eject stateSound[5] = GrenadeLauncherReloadSound; // No ammo in the weapon, just idle until something shows up. // Play the dry fire sound if the trigger iS pulled. stateName[6] = "NoAmmo"; stateTransitionOnAmmo[6] = "Reload"; stateSequence[6] = "NoAmmo"; stateTransitionOnTriggerDown[6] = "DryFire"; // No ammo dry fire stateName[7] = "DryFire"; stateTimeoutValue[7] = 1.0; stateTransitionOnTimeout[7] = "NoAmmo"; stateSound[7] = GrenadeLauncherFireEmptySound; // Check if wet stateName[8] = "CheckWet"; stateTransitionOnWet[8] = "WetFire"; stateTransitionOnNotWet[8] = "Fire"; // Wet fire stateName[9] = "WetFire"; stateTransitionOnTimeout[9] = "PostFire"; stateTimeoutValue[9] = 0.4; stateFire[9] = true; stateAllowImageChange[9] = false; stateSequence[9] = "Fire"; stateScript[9] = "onWetFire"; stateSound[9] = GrenadeLauncherFireSound; };
Images are mounted into a slot on the target ShapeBase derrived object as shown below.
$WeaponSlot = 0; ... // Use a weapon by mounting it onto the given ShapeBase derrived object. // %data is the weapon whose .image member points to its ShapeBaseImageData datablock // %obj is the object to mount the weapon on function Weapon::onUse( %data, %obj ) { // Default behavior for all weapons is to mount it into the object's weapon // slot, as defined by $WeaponSlot here, and is usually slot 0. We begin by // checking if the requested weapon is already mounted. if ( %obj.getMountedImage($WeaponSlot) != %data.image.getId() ) { // The requested weapon is not mounted on $WeaponSlot so mount it now. %obj.mountImage( %data.image, $WeaponSlot ); } }
The DTS or DAE model used for the Image has the following requirements:
void ShapeBaseImageData::onMount | ( | ShapeBase | obj, | |
int | slot, | |||
float | dt | |||
) |
Called when the Image is first mounted to the object.
obj | object that this Image has been mounted to | |
slot | Image mount slot on the object | |
dt | time remaining in this Image update |
void ShapeBaseImageData::onUnmount | ( | ShapeBase | obj, | |
int | slot, | |||
float | dt | |||
) |
Called when the Image is unmounted from the object.
obj | object that this Image has been unmounted from | |
slot | Image mount slot on the object | |
dt | time remaining in this Image update |
Flag to control whether the Image's aim is automatically converged with the crosshair.
Currently unused.
Point3F ShapeBaseImageData::camShakeAmp |
Amplitude of the camera shaking effect.
Point3F ShapeBaseImageData::camShakeFreq |
Frequency of the camera shaking effect.
DebrisData datablock to use for ejected casings.
Whether this Image can be cloaked.
Currently unused.
If true, verify that the CRC of the client's Image matches the server's CRC for the Image when loaded by the client.
Flag to adjust the aiming vector to the eye's LOS point.
Whether to enable environment mapping on this Image.
MatrixPosition ShapeBaseImageData::eyeOffset |
"X Y Z" translation offset from the ShapeBase model's eye node.
When in first person view, this is the offset from the eye node to place the gun. This gives the gun a fixed point in space, typical of a lot of FPS games.
MatrixRotation ShapeBaseImageData::eyeRotation |
This flag must be set for the adjusted LOS muzzle vector to be computed.
The color of light this Image emits.
Duration in SimTime of Pulsing and WeaponFire type lights.
Radius of the light this Image emits.
The type of light this Image emits.
float ShapeBaseImageData::mass |
Mass of this Image.
This is added to the total mass of the ShapeBase object.
Maximum number of sounds this Image can play at a time.
Any value <= 0 indicates that it can play an infinite number of sounds.
Minimum Image energy for it to be operable.
Mount node # to mount this Image to.
This should correspond to a mount# node on the ShapeBase derived object we are mounting to.
MatrixPosition ShapeBaseImageData::offset |
The projectile fired by this Image.
MatrixRotation ShapeBaseImageData::rotation |
Flag indicating whether the camera should shake when this Image fires.
filename ShapeBaseImageData::shapeFile |
The DTS or DAE model to use for this Image.
Point3F ShapeBaseImageData::shellExitDir |
Vector direction to eject shell casings.
Variance (in degrees) from the shellExitDir vector to eject casings.
Speed at which to eject casings.
If false, other Images will temporarily be blocked from mounting while the state machine is executing the tasks in this state.
For instance, if we have a rocket launcher, the player shouldn't be able to switch out while firing. So, you'd set stateAllowImageChange to false in firing states, and true the rest of the time.
bool ShapeBaseImageData::stateDirection[31] |
Direction of the animation to play in this state.
True is forward, false is backward.
bool ShapeBaseImageData::stateEjectShell[31] |
If true, a shell casing will be ejected in this state.
Emitter to generate particles in this state (from muzzle point or specified node).
string ShapeBaseImageData::stateEmitterNode[31] |
Name of the node to emit particles from.
float ShapeBaseImageData::stateEmitterTime[31] |
How long (in seconds) to emit particles on entry to this state.
float ShapeBaseImageData::stateEnergyDrain[31] |
Amount of energy to subtract from the Image in this state.
Energy is drained at stateEnergyDrain units/tick as long as we are in this state.
bool ShapeBaseImageData::stateFire[31] |
The first state with this set to true is the state entered by the client when it receives the 'fire' event.
If set to true, and both ready and loaded transitions are true, the ready transition will be taken instead of the loaded transition.
A state is 'ready' if pressing the fire trigger in that state would transition to the fire state.
Set the loaded state of the Image.
caseString ShapeBaseImageData::stateName[31] |
Name of this state.
Type of recoil sequence to play on the ShapeBase object on entry to this state.
If true, the timeScale of the stateSequence animation will be adjusted such that the sequence plays for stateTimeoutValue seconds.
caseString ShapeBaseImageData::stateScript[31] |
Method to execute on entering this state.
Scoped to this image class name, then ShapeBaseImageData. The script callback function takes the same arguments as the onMount callback.
string ShapeBaseImageData::stateSequence[31] |
Name of the sequence to play on entry to this state.
If true, a random frame from the muzzle flash sequence will be displayed each frame.
The name of the muzzle flash sequence is the same as stateSequence, with "_vis" at the end.
Sound to play on entry to this state.
Controls how fast the 'spin' animation sequence will be played in this state.
float ShapeBaseImageData::stateTimeoutValue[31] |
Time in seconds to wait before transitioning to stateTransitionOnTimeout.
Name of the state to transition to when the alt trigger state of the Image changes to false (alt fire button up).
Name of the state to transition to when the alt trigger state of the Image changes to true (alt fire button down).
string ShapeBaseImageData::stateTransitionOnAmmo[31] |
Name of the state to transition to when the ammo state of the Image changes to true.
string ShapeBaseImageData::stateTransitionOnLoaded[31] |
Name of the state to transition to when the loaded state of the Image changes to 'Loaded'.
string ShapeBaseImageData::stateTransitionOnNoAmmo[31] |
Name of the state to transition to when the ammo state of the Image changes to false.
Name of the state to transition to when the Image loses a target.
Name of the state to transition to when the loaded state of the Image changes to 'Empty'.
string ShapeBaseImageData::stateTransitionOnNotWet[31] |
Name of the state to transition to when the Image exits the water.
string ShapeBaseImageData::stateTransitionOnTarget[31] |
Name of the state to transition to when the Image gains a target.
string ShapeBaseImageData::stateTransitionOnTimeout[31] |
Name of the state to transition to when we have been in this state for stateTimeoutValue seconds.
Name of the state to transition to when the trigger state of the Image changes to false (fire button released).
Name of the state to transition to when the trigger state of the Image changes to true (fire button down).
string ShapeBaseImageData::stateTransitionOnWet[31] |
Name of the state to transition to when the Image enters the water.
If false, this state ignores stateTimeoutValue and transitions immediately if other transition conditions are met.
If true, allow multiple timeout transitions to occur within a single tick (useful if states have a very small timeout).
Flag indicating whether this Image uses energy instead of ammo. The energy level comes from the ShapeBase object we're mounted to.