DXStudio Cannon Module -- Section: DXStudio Goodies --
This is my first try to create a re-usable module for Worldweavers DXStudio. It is a laser cannon with targetting functions,
some visual effects and sound. As for it's quality, it might not completely fit your needs
or standards out-of-the-box (especially for the texturing), but could maybe work as your
base for own modules (I hope).
(This is a Carrara render.
Not ingame footage)
Features
Given a target 3D coordinate, the cannon will automatically align to this target, playing some
mechanical sound. Speed of rotations can be adjusted. If requested, a laser beam will be initiated
after alignment has completed. Automatically, there is a check if some scene object is hit. If so,
an explosion animation will be started, accompanied by a corresponding sound. In case a scene
object has been hit, a notify message is sent to the parent scene.
(The dxstudio demo application)
Restrictions
The module ('object') must not be rotated upon placing. It does only work when positioned
on the XZ-plane. Different heights (Y) do work, though. It can be scaled in the scene
editor. The cannon will not target positions that are too near (e.g., touching its own bounding
box) or can not be aligned by the cannon tube (e.g., too low in y dimension). If a shot is
being executed, alignment to new target positions will take place after having finished the shot.
Usage
Exposed module functions:
function cannonInitialize(id)
This must be called before using the module. Pass the module's id (e.g. 'objects.CannonModule_1.id')
as parameter.
function cannonSetRange(fBeamMaxRange, fBeamDuration)
Set the maximum range the laser beam can shoot (that is the range a hit detection will be done - and
the length of the beam if nothing is hit) and the duration of a shot (in seconds).
function cannonSetSpeed(fTurnSpeed, fFocusSpeed)
With this, set the turn speed and the speed of the cannon tube's up/down movement (deg/sec). Used for alignment.
function cannonSetNewTargetPosition(vTargetPosition)
Set a new 3D coordinate target position. The cannon will align to that, but not shoot. No movement
will happen if the target position can not be aligned to.
function cannonSetNewTargetPositionAndShoot(vTargetPosition)
Same as before, but the cannon will initialize a laser shot after having focused the target coordinates.
function cannonStopMovement()
Stop a currently running alignment movement (if any).
function cannonMovementRunning()
Returns true if the cannon is in the process of alignment to a given target coordinate.
False, if not.
function cannonShoot()
Initiate a laser shot. Will stop any alignment movement immediately, if present.
Whenever a hit is detected, scene.moduleNotify(msg) of the parent scene will be called.
Passing TYPE of the event (=CM aka CannonModule), ID of the module and the beam hit position TARGET.
Possible target objects must have their selectionMask set to 2 (bit1 = 1). Use 'eval()' in moduleNotify function.
Please see the .dxstudio demo program for a detailed usage demo.
Downloads
|