Torque 2D/Reference Guide
From TDN
| [edit] t2dSceneObject(Core Object) All scene-based objects are based upon this object therefore all objects have the abilities outlined below. | |||
| Methods | |||
| Name | Synopsis | Parameter(s) & Example Format | Detail |
| addToScene() | Add self to Selected SceneGraph. | (t2dSceneGraph) “%obj.addToScene(mySceneGraph )” | t2dSceneGraph– Scene Graph to be added to. NOTE:-This is identical to the “t2dSceneGraph::addToScene()” function. |
| removeFromScene() | Remove self from SceneGraph. | - “%obj.removeFromScene()” | NOTE:-This is identical to the “t2dSceneGraph::removeFromScene()” function. If the object is deleted, it will automatically be removed from any scene which it is within. |
| safeDelete() | Safely deletes object. | - “%obj.safeDelete()” | Allows you to delete any t2dSceneObject at anytime, even in script callbacks. As a rule in TGE, don’t use the “.delete()” method within a script-callback from that object. Doing so can cause it to “pull the rug out from under its feet”. This function defers the deletion until such a time as its safe to do so. Use this function on all objects, even in script callbacks and be safe in the knowledge that you won’t cause a problem. |
| setEnabled() | Sets the objects enabled status. | (status?) “%obj.setEnabled( true )” | status?– Is the object enabled/disabled. A disabled object is ignored by the t2dSceneGraph object (scene) which it is added to. This means that any physics, collision-detection, mounting or rendering does not happen. If you simply don’t want it to render then use the setVisible() function. Any objects that are mounted will be automatically dismounted if the object is disabled. |
| setLifetime() | Set Objects' Lifetime. | (lifetime) “%obj.setLifetime( 10 )” | lifetime - Lifetime of object (seconds). Setting a lifetime for an object results in the object being automatically destroyed when its lifetime is up. This lifetime is its life within a scene. Setting a lifetime of 0 gives the object infinite life which is the default. |
| setVisible() | Sets the objects visible status. | (status?) “%obj.setVisible( true )” | status? – Sets the visibility of the object. |
| getEnabled() | Gets the objects enabled status. | - “%value = %obj.getEnabled()” | Retrieves the enabled/disabled status. |
| getLifetime() | Gets the objects lifetime. | - “%value = %obj.getLifetime()” | Retrieves the objects remaining lifetime. |
| getVisible() | Gets the objects visible status. | - “%value = %obj.getVisible()” | Retrieves the visibility status. |
| setArea() | Sets the objects area. | (x1 / y1 / x2 / y2) “%obj.setArea( “-20 -10 20 10” )” | x1/y1 – Top-Left position of object. x2/y2 – Bottom-Left position of object. NOTE:- This sets both the position and size of the object so that it covers the area specified. Note that the objects current rotation is set to zero so that the area can be correctly set! Also, it is perfectly acceptable to pass the top-left and bottom-right in the wrong order as described above; T2D will automatically correct this for you. |
| setPosition() | Sets the objects position. | (x / y) “%obj.setPosition( “20 10” )” | x/y - Position of object within the scene. |
| setPositionX() | Sets the objects position X-Component. | (x) “%obj.setPositionX( 20 )” | x - X Position of object within the scene. |
| setPositionY() | Sets the objects position Y-Component. | (y) “%obj.setPositionY( 10 )” | y - Y Position of object within the scene. |
| setSize() | Sets the objects size. | (width [/ height]) “%obj.setSize( “30 20” )” | width/height - Dimensions of object. NOTE:- As a shortcut, If you only pass a single parameter here, it is used to set the width and height. |
| setSizeX() | Sets the objects size X-Component. | (width) “%obj.setSizeX( 30 )” | width – Width (X) dimension of object. NOTE:- This is identical to “setWidth()”. |
| setSizeY() | Sets the objects size Y-Component. | (height) “%obj.setSizeY( 20 )” | height – Width (X) dimension of object. NOTE:- This is identical to “setHeight()”. |
| setWidth() | Sets the objects width. | (width) “%obj.setWidth( 30 )” | width – Width (X) dimension of object. NOTE:- This is identical to “setSizeX()”. |
| setHeight() | Sets the objects height. | (height) “%obj.setHeight( 10 )” | height – Height (Y) dimension of object. NOTE:- This is identical to “setSizeY()”. |
| setLayer() | Sets the objects layer. | (int layer) “%obj.setLayer( 31 )” | layer - Rendering Layer to place object (0-31). Default is 0. NOTE:- 0 is the front whereas 31 is the back. |
| setGraphGroup() | Sets the objects group. | (int group) “%obj.setGraphGroup( 31 )” | group - Collision-group to assign the object to (0-31). Default is 0. |
| getArea() | Gets the objects area. | - “%values = %obj.getArea()” | Retrieves the area (X1/Y1/X2/Y2) occupied by the object (in world units). See “setArea()”. NOTE:- The area is always the clipping rectangle (bounding-box) and not the axially-align bounding-box. This can be visualized as the largest box surrounding the object using “setDebugOn(BIT(1));”. |
| getAreaMin() | Gets the objects area minimum point. | - “%values = %obj.getAreaMin()” | Retrieves the point (X1/Y1) occupied by the object (in world units). See “setArea()”. NOTE:- The area is always the clipping rectangle (bounding-box) and not the axially-align bounding-box. This can be visualized as the largest box surrounding the object using “setDebugOn(BIT(1));”. This call returns the first two values returned by “getArea()”. |
| getAreaMax() | Gets the objects area maximum point. | - “%values = %obj.getAreaMax()” | Retrieves the point (X2/Y2) occupied by the object (in world units). See “setArea()”. NOTE:- The area is always the clipping rectangle (bounding-box) and not the axially-align bounding-box. This can be visualized as the largest box surrounding the object using “setDebugOn(BIT(1));”. This call returns the last two values returned by “getArea()”. |
| getPosition() | Gets the current position. | - “%value = %obj.getPosition()” | Retrieves (X/Y) position. |
| getPositionX() | Gets the objects position X-Component. | - “%value = %obj.getPositionX()” | Retrieves (X) position. |
| getPositionY() | Gets the objects position Y-Component. | - “%value = %obj.getPositionY()” | Retrieves (Y) position. |
| getSize() | Gets the current size. | - “%value = %obj.getSize()” | Retrieves the object (X/Y) size. |
| getSizeX() | Gets the current size X-Component. | - “%value = %obj.getSizeX()” | Retrieves the object (X) size. NOTE:- This is identical to “getWidth()”. |
| getSizeY() | Gets the current size Y-Component. | - “%value = %obj.getSizeY()” | Retrieves the object (Y) size. NOTE:- This is identical to “getHeight()”. |
| getWidth() | Gets the current Width | - “%value = %obj.getWidth()” | Retrieves the object width. NOTE:- This is identical to “getSizeX()”. |
| getHeight() | Gets the current Height | - “%value = %obj.getHeight()” | Retrieves the object height. NOTE:- This is identical to “getSizeY()”. |
| getLayer() | Gets the current layer. | - “%value = %obj.getLayer()” | Retrieves the objects layer. |
| getGraphGroup() | Gets the Objects Group | - “%value = %obj.getGraphGroup()” | Retrieves the collision-group. |
| setRotation() | Sets the objects rotation. | (rotation) “%obj.setRotation( 45 )” | rotation - Angle of rotation around its pivot-point. |
| setMountRotation() | Sets the objects Mount rotation. | (mountRotation) “%obj.setMountRotation( 90 )” | mountRotation – Similar to setAutoMountRotation but this specifies an absolute rotation for the mount system rather than a continous rotation. |
| setAutoRotation() | Sets the objects auto rotation speed. | (autoRotationSpeed) “%obj.setAutoRotation( 45 )” | autoRotationSpeed – Degrees/Second rotation for the object. The object will automatically rotate around its own pivot-point. |
| setAutoMountRotation() | Sets the objects auto mount rotation speed. | (autoMountRotationSpeed) “%obj.setAutoMountRotation( 30 )” | autoMountRotationSpeed – Degrees/Second rotation for mount-points. When objects are mounted to this object, they are mounted to their own mount-point. Because you can have as many objects mounted to another, these mounts are contained with a mount-system. This means that the object can rotate the mount system itself. If the object is rotation, this mount system is also rotated. You may not want the object to rotate but automatically get the mount system to rotate on its own. This means that mounted objects will spin independantly of the object itself. |
| getRotation() | Gets the current rotation. | - “%value = %obj.getRotation()” | Retrieves the objects current rotation. |
| getMountRotation() | Gets the mount rotation | - “%value = %obj.getMountRotation()” | Retrieves the mount rotation. |
| getAutoRotation() | Gets the objects auto rotation angle. | - “%value = %obj.getAutoRotation()” | Retrieves the auto-rotation angle. |
| getAutoMountRotation() | Gets the objects auto mount-rotation angle. | - “%value = %obj.getAutoMountRotation()” | Retrieves the auto mount-rotation angle. |
| setWorldLimit() | Set World Limit | (limitMode$, [minX / minY / maxX / maxY], callback?). “%obj.setWorldLimit( “bounce”, “-50 -35 50 35” )” | limitMode$ – Sets the world limit mode ("OFF", “NULL”, "CLAMP", "STICKY", "BOUNCE", "KILL") minXY/maxXY – Sets the world rectangle (using the top-left/bottom-right) NOTE:- This can be an extremely useful and flexible method of constraining/controlling the object automatically withi the world. When the object enters a region outside of the specified rectangle, the limit mode is handled accordingly, these are:- OFF – Turns-off the limit mode. NULL – No automonomous action; can be used in coordination with the callback to do custom actions. RIGID – Implements the rigid-body physics reponse. BOUNCE – Similar to CLAMP with the exception that the velocity is not zeroed but reversed causing the object to ‘bounce’ off the world-limit rectangle. CLAMP– The appropriate axis-component of the linear-velocity is reset. Colliding with the upper/lower world-limit zeros the vertical velocity. Colliding with the left/right world-limit zeros the horizontal velocity. This results in the object “sliding” around the world-limit rectangle. STICKY – An object is brought complete to rest no matter which limit is hit. KILL – Causes the object to be automatically destroyed. This can be useful for projectiles to ensure that they don’t hang around the scene when they move outside a specified region. Lifetime can be use for this but quite often, the ilfetime is not known but a spatial region is. callback? – Specifies whether the “onWorldLimit” script-callback will occur. The default is false. |
| setPositionTarget() | Sets the position target. | (positionTargetX / positionTargetY, [autoStop?], [callback?], [snap?], [targetMargin]) “%obj.setPositionTarget(“30 20”, true, true, true, 0.01))” | positionTargetX/Y – Sets the target position in the world. autoStop – Whether to reset any linear-velocity when the target is reached. The default is true. callback – Whether to callback “onPositionTarget()” when the target is reached. The default is false. snap – Whether to position the object exactly to the position-target when it is reached. The default is true. targetMargin – Specfies a margin (proximity) to the target position that is allowed to qualify as reaching the target position. The default is “0.1”. NOTE:- This call does not move the object to the target position but rather allows an object, when it has reached a position, to be optionally stopped and/or a callback actioned. There is also the ability to specify a proximity to the target-position so it doesn’t have to be exact. The object can also optionally be snapped to the target position. When the target has been reached, the target-position is turned-off using “setPositionTargetOff()”. |
| setPositionTargetOff() | Turns-off the position target. | - “%obj.setPositionTargetOff()” | Stops the position-target function “setPositionTarget()”. It is not necessary to call this function if the target has been reached or if you simply require a different target position. |
| setRotationTarget() | Sets a rotation target. | (rotationTarget, [autoStop?], [callback?], [snap?], [targetMargin]) “%obj.setRotationTarget(90, true, true, true, 0.01))” | rotationTarget – Sets the target rotation in degrees. autoStop – Whether to reset any angular-velocity / auto-rotation when the target is reached. The default is true. Note inclusion of auto-rotation resetting! callback – Whether to callback “onRotationTarget()” when the target is reached. The default is false. snap – Whether to set the objects’ rotation exactly to the rotation-target when it is reached. The default is true. targetMargin – Specfies a margin (proximity) to the target rotation that is allowed to qualify as reaching the target rotation. The default is “0.1”. NOTE:- This call does not rotate the object to the target rotation but rather allows an object, when it has reached a rotation, to be optionally stopped and/or a callback actioned. There is also the ability to specify a proximity to the target-rotation so it doesn’t have to be exact. The object can also optionally be snapped to the target rotation. |
| setRotationTargetOff() | Turns-off the rotation target. | - “%obj.setPositionRotationOff()” | Stops the rotation-target function “setPositionRotation()”. It is not necessary to call this function if the target has been reached or if you simply require a different target rotation. |
| moveTo() | Moves to a position and sets the position target. | (positionTargetX / positionTargetY, linearSpeed, [autoStop?], [callback?], [snap?], [targetMargin]) “%obj.moveTo(“30 20”, 10, true, true, true, 0.01))” | positionTargetX/Y – Sets the target position in the world. linearSpeed – Speed to move to position-target (world-unit/sec). autoStop – Whether to reset any linear-velocity when the target is reached. The default is true. callback – Whether to callback “onPositionTarget()” when the target is reached. The default is false. snap – Whether to position the object exactly to the position-target when it is reached. The default is true. targetMargin – Specfies a margin (proximity) to the target position that is allowed to qualify as reaching the target position. The default is “0.1”. NOTE:- This call calculates/sets the linear velocity required to move to the specified position at the selected speed. It additionally sets a target-position for the specified position (see “setPositionTarget()”). It is important to note that if the movement is interrupted by a collision, the target is still set! If the object (at some point in the future) occupies the target area then the object move is completed as normal. Essentially, the object is not forced to the target, only sent. |
| rotateTo() | Rotates to a rotation and sets the rotation target, | (rotationTarget, angularSpeed, [autoStop?], [callback?], [snap?], [targetMargin]) “%obj.rotateTo(90, 45, true, true, true, 0.01))” | rotationTarget – Sets the target rotation in degrees. angularSpeed – Speed to rotate to rotation-target (degree/sec). autoStop – Whether to reset any angular-velocity / auto-rotation when the target is reached. The default is true. Note inclusion of auto-rotation resetting! callback – Whether to callback “onRotationTarget()” when the target is reached. The default is false. snap – Whether to set the objects’ rotation exactly to the rotation-target when it is reached. The default is true. targetMargin – Specfies a margin (proximity) to the target rotation that is allowed to qualify as reaching the target rotation. The default is “0.1”. NOTE:- This call calculates/sets the angular velocity required to rotate to the specified position at the selected speed. It additionally sets a target-rotation for the specified rotation (see “setRotationTarget()”). It is important to note that if the movement is interrupted by a collision, the target is still set! If the object (at some point in the future) rotates to the target rotation then the object rotation is completed as normal. Essentially, the object is not forced to rotate to the target, only rotated. |
| getWorldLimit() | Gets the objects world limit. | - “%value = %obj.getWorldLimit()” | Retrieves the following parameters:- “World Limit / MinX / MinY / MaxX / MaxY / Callback?”. |
| setAtRest() | Sets the object at rest (no momentum). | - “%obj.setAtRest()” | Stops the object from moving. The object will start to move again if any forces are applied to it. |
| setLinearVelocity() | Set Objects' Linear Velocity | (velocityX / velocityY) “%obj.setLinearVelocity( “5 1” )” | velocityX/Y – X/Y components of the Linear Velocity. |
| setLinearVelocityPolar() | Set Objects' Linear Velocity as Polar Speed. | (angle, speed) “%obj.setLinearVelocityPolar( 120, 10 )” | angle – Angle that the speed will be applied. speed – Speed to be applied. NOTE:- The two components combine to form a velocity. |
| setLinearVelocityX() | Set Objects' Linear Velocity X-Component | (velocityX) “%obj.setLinearVelocityX( 5 )” | velocityX – Sets the linear velocities X-component only leaving the Y-component unaltered. |
| setLinearVelocityY() | Set Objects' Linear Velocity Y-Component | (velocityY) “%obj.setLinearVelocityY( 1 )” | velocityY – Sets the linear velocities Y-component only leaving the X-component unaltered. |
| setAngularVelocity() | Set Objects' Angular Velocity | (velocity) “%obj.setAngularVelocity( 90 )” | velocity – Angular Velocity (deg/sec). |
| setForwardMovementOnly() | Sets Forward Movement Only | (forwardMovementOnly?) “%obj.setForwardMovementOnly( true )” | forwardMovementOnly – Forward Movement Status. NOTE:- This option applies any linear velocity that the object has, into the ‘forward’ direction only. ‘Forwards’ for the object is its’ current rotation e.g. zero-degree is the screen “up”. Any directionality from linear-velocity is ignored and applied by its magnitude only e.g. “setLinearVelocity(“10 10”) sets the objects speed to the length of this velocity (approx 14). To make speed simple, just use a call “setLinearVelocityX( 10 )” or you can use “setForwardSpeed()” which does just that. It is very important to understand that collision-detection will work fine when this option is enabled but collision-responses will not work as expected as the velocity-changes they produce won’t be applied as the responses intended. To clarify, if you enable this option, apply some velocity either directly or via an impulse and set the object to auto-rotation, it will continually move in circles. The option is designed for objects such as vehicles or missles that move according to their direction. |
| setForwardSpeed() | Sets Forward Speed | (forwardSpeed) “%obj.setForwardSpeed( 100 )” | forwardSpeed – Forward Speed (world units/sec) NOTE:- This is simply a shortcut that internally sets the linear velocity to “(0,forwardSpeed)”. This function only works when “setForwardMovementOnly()” is active. |
| setImpulseForce() | Apply an instantaneous directed force. | (impulseForceX / impulseForceY, [gravitic?]) “%obj.setImpulseForce( “100 0”, true )” | impulseForceX/Y – X/Y components of the force to apply to the object. Doing this will increase the linear velocity of the object. gravitic? – Any force applied to an object is dependant upon its mass/inertia. The larger the mass, the less the force will have on its velocity. Gravity works independent of mass so this flag allows you to bypass the standard calculation. The default is false. NOTE:- The effect of this command is cummulative. Equal and opposite forces will cancel each other out. |
| setImpulseForcePolar() | Apply an instantaneous directed polar force. | (angle, force, [gravitic?]) “%obj.setImpulseForcePolar( 90, 100, true )” | angle – Angle that the force will be applied. force – Magnitude of the force to be applied. gravitic? – Any force applied to an object is dependant upon its mass/inertia. The larger the mass, the less the force will have on its velocity. Gravity works independent of mass so this flag allows you to bypass the standard calculation. The default is false. NOTE:- This function can be a useful alternative to “setImpulseForce()” where you want to apply a force in terms of angles rather than forces acting on individual axii. |
| setConstantForce() | Apply a constant directed force. | (constantForceX / constantForceY, [gravitic?]) “%obj.setConstantForce( “200 0”, true )” | constantForceX/Y – Force to constantly apply to the object. A typical used constant force is gravity. This force changes the linear velocity of the object. gravitic? – Any force applied to an object is dependant upon its mass/inertia. The larger the mass, the less the force will have on its velocity. Gravity works independent of mass so this flag allows you to bypass the standard calculation. The default is false. NOTE:- A typical used constant force is gravity. This force changes the linear velocity of the object. |
| setConstantForcePolar() | Apply a constant directed polar force. | (angle, force, [gravitic?]) “%obj.setConstantForcePolar( 90, 200, true )” | angle – Angle that the force will constantly be applied. force – Magnitude of the force to be applied. gravitic? – Any force applied to an object is dependant upon its mass/inertia. The larger the mass, the less the force will have on its velocity. Gravity works independent of mass so this flag allows you to bypass the standard calculation. The default is false. |
| stopConstantForce() | Stops any constant directed force. | - “%obj.stopConstantForce()” | Stops any constant force that has previous been started. This is identical to calling "%obj.setConstantForce("0 0")" but slightly quicker. |
| setMinLinearVelocity() | Set Minimum allowed linear velocity. | (minVelocity) “%obj.setMinLinearVelocity( 0.5 )” | minVelocity – Sets the objects minimum linear velocity. |
| setMaxLinearVelocity() | Set Maximum allowed linear velocity. | (maxVelocity) “%obj.setMaxLinearVelocity( 100 )” | maxVelocity – Sets the objects maximum linear velocity. |
| setMinAngularVelocity() | Set Minimum allowed angular velocity. | (minVelocity) “%obj.setMinAngularVelocity( 1 )” | minVelocity – Sets the objects minimum angular velocity. (deg/sec) |
| setMaxAngularVelocity() | Set Maximum allowed angular velocity. | (maxVelocity) “%obj.setMaxAngularVelocity( 180 )” | maxVelocity – Sets the objects maximum angular velocity. (deg/sec) |
| getLinearVelocity() | Gets the Objects' Linear Velocity | - “%value = %obj.getLinearVelocity()” | Retrieves the objects linear velocity (X / Y) |
| getLinearVelocityX() | Gets the Objects' Linear Velocity X-Component | - “%value = %obj.getLinearVelocityX()” | Retrieves the objects linear velocity X component. |
| getLinearVelocityY() | Gets the Objects' Linear Velocity Y-Component | - “%value = %obj.getLinearVelocityY()” | Retrieves the objects linear velocity Y component. |
| getLinearVelocityPolar() | Get Objects' Linear Velocity as Polar Angle/Speed. | - “%value = %obj.getLinearVelocityPolar()” | Retrieves the objects linear velocity as angle/speed. |
| getAngularVelocity() | Gets the Objects' Angular Velocity | - “%value = %obj.getAngularVelocity()” | Retrieves the objects angular velocity. |
| getConstantForce() | Gets the objects constant-force. | - “%value = %obj.getConstantForce()” | Retrieves the constant-force (X / Y). |
| getMinLinearVelocity() | Gets Minimum allowed linear velocity. | - “%value = %obj.getMinLinearVelocity()” | Retrieves the objects minimum linear velocity. |
| getMaxLinearVelocity() | Gets Maximum allowed linear velocity. | - “%value = %obj.getMaxLinearVelocity()” | Retrieves the objects maximum linear velocity. |
| getMaxAngularVelocity() | Gets Maximum allowed angular velocity. | - “ %value = %obj.getMaxAngularVelocity()” | Retrieves the objects maximum angular velocity. (deg/sec) |
| getMinAngularVelocity() | Gets Minimum allowed angular velocity. | - “%value = %obj.getMinAngularVelocity()” | Retrieves the objects minimum angular velocity. (deg/sec) |
| mount() | Mounts onto a specified object. | (t2dSceneObject, [offsetX / offsetY], [mountForce], [trackRotation?], [sendToMount?], [ownedByMount?] , [inheritAttributes?]) “%linkIndex = %obj.mount(%parentObj, “0 1”, 0, true, true, true, true)” | t2dSceneObject - The object to be mounted to. Any object can be mounted, including chains of objects but circular loops of mounts are not allowed e.g. you try to mount an object which itself is mounted to something else which in turn, somewhere is mounted back to this object. offsetX/Y – Offset from the target objects pivot-point. These coordinates are not in world-units or pixels!!! The coordinates are in the local-space of the object to which you're mounting. For instance; a value of "1" for X equates to the right-side of the object whereas a value of "-1" for X equates to the left-side of the object. A value of "1" for Y equates to the bottom-side of the object whereas a value of "-1" for Y equates to the top-side of the object. This seemingly strange system is very useful as it is independent of either the current position or size of the object. Resizing the object doesn't invalidate the mount-positions. You can use values beyond "-1" and "+1" so that the mount-point extend beyond the object. Note that mount-points are referenced to the object in its unrotated state so no matter what the rotation of the object, mount-offsets are not affected. mountForce - The force constantly applied to the object allowing it to ‘chase’ the specified mount point. This allows you to have a non-rigid mount on the object which, if it moves, this object will ‘chase’ the mount point using this force. A force of 0 indicates that the mount is rigid and will track the mount-point perfectly every frame (this is the default). trackRotation? – Specifies that when mounted, should this object track the target objects rotation e.g. rotate with it. The object will constantly track its mount-point which will mean that it may rotate around the object (if it had a large offset from the target object) but rotation here means that the object also rotates around its own pivot-point. The default is true. sendToMount? – Indicates whether the object should be sent directly to the specified mount point immediately. If this is not specified then the object will immediately start moving towards the mount-point. If the mountForce is 0 then the object will move to the mount-point on the next frame anyway, regardless of this setting. The default is true. ownedByMount? – Indicates whether the object is to be owned by the object its mounting to. What this means is that when the object that we’re mounting to, is deleted, this object is automatically deleted. This is extremely useful for objects that are mounted that you don’t want to explicitly track. The default is true. inheritAttributes? – Indicates whether the object inherits attributes from the object being mounted to. At the moment, the following atributes are inherited:- - Enabled, Visible and Flip. When the object is dismounted, these attributes are not restored to their previous settings before the object was mounted, the changes are permanent. The default is true. NOTE:- Using an offset of (0,0); both objects will be aligned using their pivot-points. For instance, if one object has the pivot-point at top/left and the other center/center then the fully mounted objects will overlap with the top/left and center/center of the objects at the same position. You can mount as many objects to another object as you require, there are no limits apart from a small computational increase. This function returns the “link-index” which can be used by “getLinkPoint()” to retrieve the current position of the mount-point. Note that the mount is placed onto the object that’s being mounted-to and not the object that’s mounting. The function will return “-1” if the mount is invalid for any reason. |
| addLinkPoint() | Adds a Link-point to the Object. | (offsetX / offsetY) “%obj.addLinkPoint( “0 1” )” | offsetX/Y – Defines the link-point which is this offset from the objects pivot-point. NOTE:- This function behaves similar to the “mount()” function with the exception that the “link-point” doesn’t have an object attached but is used simply so that an absolute position can be referenced and which is automatically adjusted according to position, size and rotation of the object. The function returns a reference index used to retrieve the link-point (See “getLinkPoint()”) or “-1’ is an error occurs. |
| getIsMounted() | Gets the ‘Is Mounted’ status. | - “%value = %obj.getIsMounted()” | Retrieves whether the object is mounted or not. |
| getMountedParent() | Gets the mounted parent. | - “%object = %obj.getMountedParent()” | Retrieves whether the object that we (may/are) mounted to. |
| getLinkPoint() | Gets a Link-Point. | (int linkIndex) “%value = %obj.getLinkPoint( 0 )” | Retrieves the selected link-index. (X / Y) |
| getLinkCount() | Gets the Link-Point Count. | - “%value = %obj.getLinkCount()” | Retrieves the number of link-points. |
| getLocalPoint() | Converts a world-position into a local-point for the object. | (X / Y) “%value = %obj.getLocalPoint( “30 40” )” | X / Y – Selected world-position. NOTE:- Converts the specified world-point into a normalised local-point for the object. This function will take into account the rotation of the object and therefore the point will be in “normalised object-space” e.g. the coordinate-system of the object. Note that points within the objects space will range from -1 to 1 but objects outside of the objects scale will be bigger. These values can be used in functions which take normalised local-space coordinates. Use this to convert a world-unit into a local mount/link coordinate. |
| getIsPointInObject() | Gets whether the point is within the object. | (X / Y) %value = %obj.getIsPointInObject()” | X / Y – Selected world-position. NOTE:- This function will check to see if the point overlaps the object and is as accurate as the collision bounds. |
| dismount() | Dismounts object. | - “%obj.dismount()” | Dismounts any object which the object may be mounted to (see “mount”). |
| setCollisionActive() | Sets the collision active status. | (send?, receive?) “%obj.setCollisionActive(true, true)” | send – Specifies whether collisions are sent to other others. receive – Specifies whether collisions are received from other objects. NOTE:- Here you can specify bi-directionally, which collisions you’re interested in. For an object to collide with this object, it needs to specify that it can receive collisions. Without this, the object will not be collided with. |
| setCollisionMasks() | Sets the collision masks. | (groupMask, [layerMask]) “%obj.setCollisionMasks(BIT(0)|BIT(1), BIT(0))” | groupMask – Specifies which group(s) sent collisions are valid on. layerMask – Specifies which layer(s) sent collisions are valid on. Default is all. NOTE:- This is the primary control for selecting what sent collisions you’re interested in. |
| setCollisionAgainst() | Sets the collision masks against a specific object. | (t2dSceneObject, [clearMasks]) “%obj.setCollisionAgainst( enemyObj, false ))” | t2dSceneObject – Specifies which object to use group/layer masks from. clearMasks – Specifies if the existing object masks should be cleared before the merge. The default is false (off). NOTE:- This function is a shortcut which allows you to merge the group/layer masks from a specified object into the collision group/layer masks of the source object. This can make it easier to specify one to one or one to many collisions without referring directly to specific groups/layers. A single call will setup a one to one collision with the “clearMasks” option set to true. To set up one to many collisions, you use true for the "clearMasks" option on the initial call and leave it on the default (false) for subsequent calls which allows you to merge multiple objects. Essentially, when "clearMasks" is false (default), the specified object is merged against the existing collision masks rather than overwrite them. |
| setCollisionGroups | Sets the collision against a set of groups. | (groups$) “%obj.setCollisionGroups("0 3 5 7" )” | groups – Specifies a set of groups to collide against as a space-separated string. NOTE:- This function is just an alternative method of specifying collision-groups. It has identical functionality as "setCollisionMasks()" or "setCollisionAgainst()". |
| setCollisionLayers | Sets the collision against a set of layers. | (layers$) “%obj.setCollisionLayers("0 4 5 6 8 9" )” | layers – Specifies a set of layers to collide against as a space-separated string. NOTE:- This function is just an alternative method of specifying collision-layers. It has identical functionality as "setCollisionMasks()" or "setCollisionAgainst()". |
| setCollisionPhysics() | Sets the collision physics status. | (send?, receive?) “%obj.setCollisionPhysics( true, true )” | send – Specifies whether sent collisions feed into the physics system. receive – Specifies whether received collisions feed into the physics system. NOTE:- You can specify bi-directionally, which collision directions affect the objects physics. |
| setCollisionMaxIterations() | Sets the maximum collision iterations allowed. | (iterations) “%obj.setCollisionMaxIterations( 1 )” | iterations– Maximum iteration count. Default is 1. NOTE:- When an object encounters a collision, it will move to that position and do the specified collision response. This movement will more than likely not be the full elapsed frame-time. If the maximum iteration count is higher than 1, the object will continue to check for collisions from the old collision-point until all of the frame-time has elapsed or until the iteration count is reached. A value of zero allows an unlimited number of iterations to occur but this can be extremely expensive and should be used with caution. |
| setCollisionDetection() | Sets the collision detection mode. | (detectionMode$) “%obj.setCollisionDetection( FULL )” | detectionMode$– Collision detection mode. The default mode is FULL. The following are available:- FULL – Detection uses Swept-Circle followed by the more accurate Swept-Polygon. POLY GON– Detection uses Swept-Polygon only (disables swept-circle check). CIRCLE – Detection uses Swept-Circle only (disables swept-polygon check). CUSTOM – Uses custom-collision-detection. Note that custom detections can only be implemented in C++! |
| setCollisionResponse() | Sets the collision response mode. | (responseMode$) “%obj.setCollisionResponse( bounce )” | responseMode$– Collision response mode. The default mode is CLAMP. The following are available:- RIGID – Implements the rigid-body physics reponse. BOUNCE – Similar to CLAMP with the exception that the velocity is not zeroed but reversed causing the object to ‘bounce’ off the world-limit rectangle. CLAMP– The appropriate axis-component of the linear-velocity is reset. This results in the object “sliding” off other objects. STICKY – An object is brought complete to rest no irrelevant of the collision details. KILL – Causes the object to be automatically destroyed. This can be useful for projectiles to ensure that they don’t hang around the scene when they collide with another object. CUSTOM – Uses custom-collision-response. Note that custom collision responses can only be implemented in C++. |
| setCollisionMaterial() | Sets the collision material. | (collisionMaterialDatablock$) “%obj.setCollisionMaterial( myCollisionMaterial )” | collisionMaterialDatablock$ – Specifies the collision material datablock. This is a quick way to specify density, static&dynamic friction, restitution etc. |
| setCollisionCallback() | Sets the collision callback. | (status?) “%obj.setCollisionCallback( true )” | status? – Specifies whether the “onCollision” callback is made if a collision occurs. |
| setCollisionPolyCustom() | Sets a custom collision polygon. | (edgeCount, vertexList$) “%obj.setCollisionPolyCustome(4, “-1 -1 1 -1 1 1 -1 1”)” | edgeCount – Specifies the number of edges for the collision custom polygon. vertexList$ - Specifies the vertices for the polygon. The list must contain edgeCount coordinate pairs. All coordinates must be within the range -1 to +1. |
| setCollisionPolyPrimitive() | Sets a primitive collision polygon. | (edgeCount) “%obj.setCollisionPolyPrimitive( 4 )” | edgeCount – Specifies the number of edges for the collision primitive polygon. It is defined within an ellipse which subscribes the objects width/height The default is 4 edges (quad) which has a special definition which exactly cover the whole area of the object and not within the ellipse described above. |
| setCollisionCircleSuperscribed() | Sets the collision-circle superscribed mode. | (superscribeMode?) “%obj.setCollisionCircleSuperscribed( true )” | superscribeMode? – If TRUE then use superscribe-mode else usesubscribe mode NOTE:- In superscribe mode, the circle completely covers the objects bounding-box ensuring that at least the area of the bounding-box is queried for collision but the circle also extends beyond the bounding-box so collisions outside the bounding-box occur. In subscribe mode, the circle covers the largest inner-axis of the bounding-box. This means that a good proportion of the bounding-box is tested but because the circles’ radius is based upon the largest axis, the bounding-box’s corners are not covered and also the circle extends beyond the other axis. It is important to note that the circle-scale (“setCollisionCircleScale()”) differs slightly in definition between the the two modes described here. |
| setCollisionCircleScale() | Sets the collision-circle scale. | (scale) “%obj.setCollisionCircleScale( “0.5” )” | scale - Scales the collision circle. NOTE:- In subscribe mode (see “setCollisionCircleMode()”) the scale acts identically as the polygon scale and scales the radius of the circle. In superscribe mode, the circle is first extended to completely cover the bounding-box, then scaled. In this mode, it is unlikely that the scaling would be used. |
| setCollisionPolyScale() | Sets the collision-polygon scale. | (widthScale / heightScale) “%obj.setCollisionPolyScale( “1 0.5” )” | widthScale - Scales the collision polygon heightScale – Scales the collision polygon. NOTE:- This directly replaced the obsolete “setCollisionScale()” call. |
| setCollisionSuppress() | Sets the collision suppress. | (status?) “%obj.setCollisionSuppress( true )” | status? – Sets the collision suppress status. NOTE:- This is a great way to temporarily disable collisions (sent/received) without having to alter collision settings. |
| setPhysicsSuppress() | Sets the physics suppress. | (status?) “%obj.setPhysicsSuppress( true )” | status? – Sets the physics suppress status. NOTE:- This is a great way to temporarily disable physics (sent/received) without having to alter collision settings. This will also stop other objects affecting the physics of this object. Also, the object will not move or rotate and any linear/angular velocities will be rest. |
| setImmovable() | Sets the object immovable. | ([status?]) “%obj.setImmovable( true )” | status? – Sets whether the object is immovable or not. Default is true. NOTE:- It is important to note that this is now a separate flag and no longer sets either the Mass/Density to zero. |
| setAutoMassInertia() | Sets the auto mass/inertia calculation mode. | (status?) “%obj.setAutoMassInertia( true )” | status? – The rigid-body physics needs to know an objects mass/inertial-moment (see below). This can be configured explcitly using the appropriate “setMass()” or “setInertialMoment()” calls or both of these values can be automatically calculated using the objects density and the area of the collision-polygon. By default, this mode is off and so the explicit values of mass/inertial-moment are used instead. In this mode, density is ignored. |
| setDensity() | Sets the objects density. | (density) “%obj.setDensity( 0.01 )” | density – The larger the objects density, the larger the mass/inertia will be. The density is only used when “auto mass/inertia” is active (see “setAutoMassInertia()”). |
| setMass() | Sets the objects mass. | (mass) “%obj.setMass( 1.5 )” | mass – The larger the objects mass, the less effect forces will have on the object. This is overwritten if “auto mass/inertia” is active (see “setAutoMassInertia()”). |
| setInertialMoment() | Sets the objects inertial moment. | (inertial moment) “%obj.setInertialMoment( 0.01 )” | inertial moment – The larger the objects inertial moment, the less effect turning-forces will have on the object. This is overwritten if “auto mass/inertia” is active (see “setAutoMassInertia()”). |
| setFriction() | Sets the objects Friction. | (friction) “%obj.setFriction( 0.1 )” | friction – Objects friction. Dynamic friction, otherwise known as kinetic friction, is the friction force that resists the movement of the object against another surface when it is moving. The larger the dynamic friction, the more force will be applied to slow the object when moving against a surface. NOTE:- All friction forces only affect the object when it is in contact with another surface. |
| setRestitution() | Sets the objects restitution. | (restitution) “%obj.setRestitution( 0.8 )” | restitution – Sets the objects restitution. NOTE:- The objects restitution controls how elastic collisions are. Zero results in no bounce whereas one results in a perfect bounce! |
| setDamping() | Sets the objects damping. | (damping) “%obj.setDamping( 0.25 )” | damping – Damping magnitude. Zero specifies no damping whereas One specifies full damping. NOTE:- The damping value is the percentage amount of both linear and angular velocity to bleed-off per second. A value of one will result in the object begin at rest after one second. |
| setForceScale() | Sets the objects force scale. | (forceScale) “%obj.setForceScale( 2.5 )” | forceScale – The objects new force scale. Default is 1. NOTE:- The larger the mass/inertia, proportionally larger forces are required to change the objects velocity. So as to keep the actual force magnitudes smaller, this option allows you to linearly scale the force applied. A setting of 100 results in 100 times more force being applied to the object, no matter how the force is generated. |
| castCollision() | Casts Collision from current position. | (time) “%obj.castCollision( 1.0 )” | time – time to check for collision using current object setup. NOTE:- This function allows you to check to see if the object, usings its current setup, will collide over a specified period of time. As stated above, the check will use its existing settings, including linear-velocity. You are obviously free to setup position, velocity and other settings, do the “castCollision()” and then restore the settings if you wish. It returns the following information as a space-separated string if a collision occurs else an empty string. The position returned is the position of the casting object at the time of collision, NOT the collision point. - collision object - collision time - position x - position y - collision normal x - collision normal y |
| castCollisionList() | Casts Collision from current position. | (time) “%obj.castCollisionList( 1.0 )” | time – time to check for collision using current object setup. NOTE:- This function is identical to “castCollision()” with the exception that only the collision objects are returned rather than full collision information. It returns a complete list of objects sorted by collision time as a space-separated string if a collision occurs else an empty string. No other information other than the object itself is returned. |
| getCollisionActive() | Gets the collision active status. | - “%value = %obj.getCollisionActive()” | Retrieves the collision send/receive active status (send / receive). |
| getCollisionMasks() | Gets the collision masks. | - “%value = %obj.getCollisionMasks()” | Retrieves the collision masks (groupMask / layerMask). |
| getCollisionPhysics() | Gets the collision physics status. | - “%value = %obj.getCollisionPhysics()” | Retrieves the collision physics send/receive status (send / receive). |
| getCollisionDetection() | Gets the collision mode. | - “%value = %obj.getCollisionDetection()” | Retrieves the collision detection mode. |
| getCollisionResponse() | Gets the stock collision response. | - “%value$ = %obj.getCollisionResponse()” | Retrieves the stock collision response mode. |
| getCollisionMaxIterations() | Gets the maximum collision iterations allowed. | - “%value = %obj.getCollisionmaxIterations()” | Retrieves the collision maximum iterations. |
| getCollisionCallback() | Gets the collision callback. | - “%value = %obj.getCollisionCallback()” | Retrieves the collision callback status. |
| getCollisionPoly() | Gets the collision polygon edges. | - “%values = %obj.getCollisionPoly ()” | Retrieves the collision polygon edges as a space-separate string. |
| getCollisionPolyCount() | Gets the collision polygon edge count. | - “%value = %obj.getCollisionPolyCount()” | Retrieves the collision polygon edge count. |
| getCollisionPolyScale() | Gets the collision-polygon scale. | - “%value = %obj.getCollisionPolyScale()” | Retrieves the collision-polygon scale (width / height). |
| getCollisionCircleScale() | Gets the collision-circle scale. | - “%value = %obj.getCollisionCircleScale()” | Retrieves the collision0circle scale (radius-scale). |
| getCollisionSuppress() | Gets the collision suppress status. | - “%value = %obj.getCollisionSuppress()” | Retrieves the collision suppress status. |
| getPhysicsSuppress() | Gets the physics suppress. | - “%value = %obj.getPhysicsSuppress()” | Retrieve the physics suppress status. |
| getAutoMassInertia() | Get the auto mass/inertia calculation mode. | - “%status = %obj.getAutoMassInertia()” | Retrieve the auto mass/inertia status. |
| getDensity() | Gets the objects density. | - “%value = %obj.getDensity()” | Retrieves the objects density. |
| getMass() | Gets the objects mass. | - “%value = %obj.getMass()” | Retrieves the objects mass. |
| getInertialMoment() | Gets the objects inertial moment. | - “%value = %obj.getInertialMoment()” | Retrieves the objects inertial moment. |
| getFriction() | Gets the objects Friction. | - “%value = %obj.getFriction()” | Retrieves the objects friction. |
| getRestitution() | Gets the objects restitution. | - “%value = %obj.getRestitution()” | Retrieves the objects restitution. |
| getDamping() | Gets the objects damping. | - “%value = %obj.getDamping()” | Retrieves the objects damping. |
| getForceScale() | Gets the objects force scale. | - “%value = %obj.getForceScale()” | Retrieves the objects force scale. |
| setBlending() | Sets the Rendering Blend Options. | (blendStatus?, [srcBlendFactor], [dstBlendFactor]) “%obj.setBlending( true, SRC_ALPHA, ONE_MINUS_SRC_ALPHA)” | blendStatus – Sets the blending status on/off. (default is true). srcBlendFactor – Specifies the source blend factor. dstBlendFactor – Specifies the destination blend factor. NOTE:- These blend-factors directly relate the the blend factors used in OpenGL but don’t use the “GL_” prefix. You can find further information on blending factors on any OpenGL reference of “glBlendFunc”. (Defaults are bold). srcBlendFactors are: "ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA", "DST_ALPHA", "ONE_MINUS_DST_ALPHA", "SRC_ALPHA_SATURATE" dstBlendFactors are: "ZERO", "ONE", "SRC_COLOR", "ONE_MINUS_SRC_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA", "DST_ALPHA", "ONE_MINUS_DST_ALPHA" |
| setBlendColor() or setBlendColour() | Sets the Rendering Blend Color. | (blend R / G / B / [A]) “%obj.setBlendColor( “1 0.25 0.5 1” )” | R,G,B,[A] – Sets the blend color for the object (normalised values 0.0 -> 1.0). NOTE:- This color value is used by the blending equation above (see "setBlending()") therefore the resultant color is dependant upon the blending equation used. |
| setBlendAlpha() | Sets the Rendering Alpha (transparency). | (alpha) “%obj.setBlendAlpha( 1 )” | alpha – Sets the alpha-level (transparency) for the object (normalised values 0.0 -> 1.0). NOTE:- This alpha-level is fed into the blending equation above (see "setBlending()") therefore the resultant alpha is dependant upon the blending equation used. |
| setFlip() | Sets the objects flip. | (flipX?, flipY?) “%obj.setFlip( true, false )” | flipX/Y – Specifies whether each axis is flipped. NOTE:- Mount points are flipped as well as object rendering. Objects that are mounted and owned objects are also flipped appropriately. |
| setDebugOn() | Sets Debug On Mode(s). | (debugMask) “%obj.setDebugOn( BIT(0) | BIT(4) )” | debugMask – Specifies which debug-modes are ON. NOTE:-See Notes for Debug Modes above! |
| setDebugOff() | Sets Debug Off Mode(s). | (debugMask) “%obj.setDebugOff( BIT(0) | BIT(4) )” | mdebugMask – Specifies which debug-modes are OFF. NOTE:- The current debug modes show/hide the following (note that these are indentical to the scene-level debug bits to provide consistency but means that some bits are not-applicable and are therefore marked N/A):- BIT#0 – N/A (Statistics Debug Banner). BIT#1 – Object Bounding/Clipping-Boxes. BIT#2 – Object Mount-Nodes. BIT#3 – Object Mount-Links (force tracking paths). BIT#4 – Object World-Limit. BIT#5 – Object Collision Bounds. |
| getBlending() | Gets the Rendering Blend Options. | - “%value = %obj.getBlending()” | Retrieves the blend options (“Status/SrcFactor/DstFactor”) – See “setBlending()”. |
| getBlendColor() or getBlendColour() | Gets the Rendering Blend Color. | - “%value = %obj.getBlendColor()” | Retrieves the blend color “R/G/B/A”. – See “setBlendColor() or setBlendColour()”. |
| getBlendAlpha() | Gets the Rendering Alpha (transparency). | - “%value = %obj.getBlendAlpha()” | Retrieves the blend alpha (transparency) – See “setBlendAlpha()”. |
| getFlip() | Gets the mount flip | - “%value = %obj.getFlip()” | Retrieves the mount flip. (X? / Y?) |
| clone() | Creates a new copied object. | - “%newObj =%obj.clone()” | Creates a new object of the same type and copies the source configuration to it. NOTE:- The source object must be in a scenegraph before it can be cloned. |
| copy() | Makes an exact copy of an object. | (t2dSceneObject) “%status = %dstObj.copy( %srcObj )” | t2dSceneObject – Source Object to be copied. NOTE:- The source object must be in a scenegraph before it can be copied. This is similar to the “clone()” method but unlike clone, this method doesn’t create any objects, it copies one objects configuration to another, both of which must exist before the method is called. |
| loadCopy() | Loads a copy of an object from disk. | (objectFile$) “%status = %Obj.loadCopy( “~/myObject.dat” )” | objectFile$ – File containing previously saved object copy configuration. NOTE:- The object must be in a scenegraph before it can load the copy from disk. |
| saveCopy() | Save a copy of an object to disk. | (objectFile$) “%status = %Obj.saveCopy( “~/myObject.dat” )” | objectFile$ – File to save object copy configuration to. NOTE:- The object must be in a scenegraph before it can save the copy to disk. |
| setTimerOn() | Starts the periodic timer for this object. | (timePeriod) “%Obj.setTimerOn( 1500 )” | timePeriod – Period to produce callback “onTimer()”. This will continue until “setTimerOff()” is called. NOTE:- Times are in milliseconds (1000 = 1 sec) as used in the “schedule” function. |
| setTimerOff() | Stops the periodic timer for this object. | - “%Obj.setTimerOff()” | Stops the periodic timer for this object. |
| setUseMouseEvents() | Sets if mouse-events can be monitored. | (mouseStatus?) “%obj.setUseMouseEvents()” | Sets if mouse-events can be monitored. NOTE:- Mouse-events will only be monitored if the t2dSceneWindow that is attached to the t2dSceneGraph, which this object is in, has its “setUseObjectMouseEvents()” option enabled). This option defaults to false. Also note that because multiple windows can be attached to the same scene, it is possible for mouse-events to come from multiple-windows to the same object. This can be filtered at the t2dSceneWindow-level using the function mentioned above. |
| attachGui() | Attaches a single Gui-Control Element to the scene-object. | (guiControl, t2dSceneWindow, [sizeControl?]) “%obj.attachGui(myControl mySceneWindow, true)” | guiControl – Gui-Control to be attached to scene-object. t2dSceneWindow – Scene-Window to bind the gui-control to. sizeControl – Whether to size the control the dimensions of the scene-object. NOTE:- By attaching a gui-control, you specify that the scene-object will resposition the control in realtime so that it is positioned directly over the center of the scene-object and be placed as a child of the specified scene-window (if it isn’t already). If the optional sizeControl flag is true (defaults to false) the gui-control will also be sized to be the non-AA bounding-box dimensions (largest rectangle in debug-mode) meaning that rotating an object will animate the x/y dimensions as the object rotates. |
| detachGui() | Detachs any Gui-Control Element from the scene-object. | - “%obj.detachGui()” | NOTE- See “attachGui()” for more details. |
| getUseMouseEvents() | Gets if mouse-events can be monitored. | - “%status = %obj.getUseMouseEvents()” | Gets if mouse-events can be monitored. (See “setUseMouseEvents()” above). |
| CALLBACKS | |||
| Name | Synopsis | Parameter(s) | Detail |
| onCollision() | Object collision has occurred. | (srcCollisionObject, dstCollisionObject, srcRef$, dstRef$, collisionTime, collisionNormal, contactCount, contactPoints$) | srcCollisionObject – Object that sent the collision. dstCollisionObject – Object that received the collision. srcRef$/dstRef$ - Custom string that objects can send during a collision. Currently, only the t2dTileLayer uses this and returns the logical tile X/Y. collisionTime – Time from current position using current velocities until collision. collisionNormal – Collision Normal! contactCount – Specifies how many collision-points occurred. contactPoints$ - contactCount coordinate pairs e.g. 2 or 4 values for the collision contacts. These are in world-space. |
| onWorldLimit() | Object has triggered the world limit. | (this, limitMode$, limit$) | this – Current Object (self)! limitMode – The limit mode the object is in. limit$ – Indicates which limit was triggered (“left”, “right”, “top” or “bottom”). |
| onPositionTarget() | Object has reached the position target, | (this) | this – Current Object (self)! |
| onRotationTarget() | Object has reached the rotation target, | (this) | this – Current Object (self)! |
| onTimer() | Callback for object periodic timer. | (this) | this – Current Object (self)! |
| onMouseDown() | Left Mouse Button Pressed. | (this, modifier, worldPosition$, mouseClicks) | (See “t2dSceneWindow::onMouseDown()”). NOTE:- Mouse-events are received if this object has mouse-events active“t2dSceneObject::setUseMouseEvents(true)” and a t2dSceneWindow is attached to the t2dSceneGraph that this object is in and that window has“t2dSceneWindow::setUseObjectMouseEvents(true)”. |
| onMouseUp() | Left Mouse Button Released. | (this, modifier, worldPosition$, mouseClicks) | (See “t2dSceneWindow::onMouseUp()”). |
| onMouseMove() | Mouse has been moved. | (this, modifier, worldPosition$, mouseClicks) | (See “t2dSceneWindow::onMouseDown()”). |
| onMouseDragged() | Mouse has been dragged (Left Button) | (this, modifier, worldPosition$, mouseClicks) | (See “t2dSceneWindow::onMouseDragged()”). |
| onRightMouseDown() | Right Mouse Button Pressed. | (this, modifier, worldPosition$, mouseClicks) | (See “t2dSceneWindow::onRightMouseUp()”). |
| onRightMouseUp() | Right Mouse Button Released. | (this, modifier, worldPosition$, mouseClicks) | (See “t2dSceneWindow::onRightMouseDown()”). |
| onRightMouseDragged() | Mouse has been dragged (Right Button) | (this, modifier, worldPosition$, mouseClicks) | (See “t2dSceneWindow::onRightMouseDragged()”). |
[edit] t2dScroller(t2dSceneObject)An object which uses a non-animated FULL-mode imageMap and can automatically scroll in any direction through the texture. | |||
| Function | Synopsis | Parameter(s) & Example Format | Detail |
| setImageMap() | Sets the imageMap Name. | (imageMapName$) “ %obj.setImageMap( myImageMap )” | imageMapName - Specifies the imageMap datablock name to use. NOTE:- The imageMap mode must be set to FULL mode; KEY/CELL modes are not supported! See t2dImageMapDatablock for more details on imageMaps. |
| setRepeat() | Sets the Repeat X/Y repetition. | (repeatX / repeatY) “ %obj.setRepeat( “2 1” )” | repeatX/Y – Specifies how many times to repeat the texture within the scrolling-view in each direction. |
| setScroll() | Sets the Scroll Speed/Direction using offset X/Y components. | (offsetX / offsetY) “ %obj.setScroll( “10 5” )” | offsetX/Y – Specifies how much the view should scroll in each direction (world-units/sec). The actual size/repetition of the texture is irrelevant to the speed as the system will calculate the appropriate conversion automatically. NOTE:- To stop scrolling, set the offsets to zero. |
| setScrollPolar() | Sets the Scroll Speed/Direction Polarwise. | (angle, scrollSpeed) “ %obj.setScrollPolar( 30, 10 )” | angle – Angle for the scroll. scrollSpeed – Speed of the scroll (world-units/sec). NOTE:- Identical in function to “setScroll()”. |
| setScrollPosition() | Sets the Scroll Position. | (positionX / positionY]) “ %obj.setScrollPosition( “50 25” )” | positionX/Y – Sets the position offset in world-units. |
[edit] t2dStaticSprite(t2dSceneObject)An object which uses imageMaps only to provide general-purpose sprites. | |||
| Function | Synopsis | Parameter(s) & Example Format | Detail |
| setImageMap() | Sets the imageMap Name / Frame. | (imageMapName$, [int frame]) “ %obj.setImageMap( myImageMap )” | imageMapName - Specifies the imageMap datablock name to use. frame – Specifies the imageMap frame to use (default is #0). NOTE:- This is provided for convienience to allow both values to be set simultaneously. |
| setFrame() | Sets the imageMap Frame. | (int frame) “ %obj.setFrame( 0 )” | frame – Specifies the imageMap frame to use. |
| getFrame() | Gets the imageMap Frame. | - “%frame = %obj.getFrame()” | Retrieves the current imagemap frame. |
| getImageMap() | Gets the imageMap Name. | - “%name = %obj.getImageMap()” | Retrieves the current imagemap name. |
[edit] t2dAnimatedSprite(t2dSceneObject)An object which uses Animations only to provide general-purpose sprites. | |||
| Function | Synopsis | Parameter(s) & Example Format | Detail |
| playAnimation() | Starts the sprite animation. | (animationName$, [autoRestore?], [startFrame], [mergeTime?]) “%obj.playAnimation( myAnimation, true, 0, false )” | animationName – Animation datablock name. autoRestore? – Specifies whether to restore the animation to the currently running animation (if any) when the specified animation is finished. If the specified animation is a cycling animation then it never finishes therefore this parameter is ignored. The default is off. startFrame – Specifies which animation frame-index to start from. if specified, this overrides "randomStart" and "startFrame" of the t2dAnimationDatablock. mergeTime? – Specifies if the new animation should be merged with the previous one. Essentially, if the previous animation was 50% complete, the new animation will start at 50% time. This allows you to setup different animations such as player walking left and player running left that have the same number of frames; merging time means that the same-positioned frame in the new animation where the animation starts. |
| setAnimationFrame | Sets the current animation frame index. | (frameIndex) “ %obj.setAnimationFrame( 0 )” | frameIndex – Animation Frame Index. NOTE:- Sets the current animation frame index. This value is valid from 0 to the number of frames-1 in the animation. If the animation is not cycling and has finished, setting the animation frame will have no effect. |
| setFrameChangeCallback | Sets the frame-change callback status. | (callback?) “ %obj.setFrameChangeCallback( true )” | callback? – Status of the frame-change callback. NOTE:- The frame-change callback is false (off) by default. You should be cautious about activating this callback on lots of animated-sprites as it can quickly reduce performance on some systems. |
| getAnimationName() | Gets the current animation name. | - “%value = %obj.getAnimationName()” | Retrieves the current animation datablock name. |
| getAnimationFrame() | Gets the current animation frame being played. | - “%value = %obj.getAnimationFrame()” | Retrieves the current animation frame. |
| getAnimationTime() | Gets the current animation time. | - “%value = %obj.getAnimationTime()” | Retrieves the current animation time. The time is not normalised time e.g. it cycles from 0 to "animationTime" (t2dAnimationDatablock). |
| getIsAnimationFinished() | Checks if animation has finished. | - “%value = %obj.getAnimationFinished()” | Checks if current animation has finished. NOTE:- Only applies to non-looping animations as looping animations never finish. |
| CALLBACKS | |||
| Callback | Synopsis | Parameter(s) | Detail |
| onAnimationStart | Signals a new animation has started. | this | this – Current Object (self)! |
| onFrameChange | Signals when the current frame has changed. | this, currentFrameIndex | this – Current Object (self)! currentFrameIndex – Current Frame Index. NOTE:- This callback isn't called by default. See "setFrameChangeCallback()" call. |
| onAnimationEnd | Signals an end to the current animation. | this | this – Current Object (self)! |
[edit] t2dChunkedSprite(t2dSceneObject)An object which uses chunked-Images only to provide general-purpose large, non-power-of-two sprites. | |||
| Function | Synopsis | Parameter(s) & Example Format | Detail |
| setChunkedImage() | Sets the chunked-image Name. | (chunkedImageName$) “%obj.setChunkedImage( myChunkedImage )” | chunkedImageName - Specifies the chunked-image datablock name to use. |
| setRepeat() | Sets the Repeat X/Y repetition. | (int repeatX / int repeatY) “%obj.setRepeat( “4 2” )” | repeatX/Y – Specifies how many times to repeat the texture within the objects size in each direction. |
[edit] t2dTileMap(t2dSceneObject)An object which provides an API to generate and render scrollable rectilinear tilemaps. | |||
| Function | Synopsis | Parameter(s) & Example Format | Detail |
| createTileLayer() | Creates a Tile Layer. | (int tileCountX / int tileCountY / tileSizeX / tileSizeY) “%layeIdr = %obj.createTileLayer(“100 50 5 5”)” | tileCountX/Y – Number of tiles in the X/Y-Axis. tileSizeX/Y – Size of tiles in X/Y-Axis. NOTE:- The tileSizeX/Y typically matches the tile-imagery dimensions (in pixels). This can be changed to make tiles overlap/space-out for interesting effects. A tile-layer object is returned if sucessful. |
| deleteAllLayers() | Deletes all Tile Layer(s). | - “%obj.deleteAllLayers()” | Deletes all tile layers! |
| deleteTileLayer() | Deletes a Tile Layer (by index) | (int layerIndex) “%obj.deleteTileLayerLayer( 0 )” | layerIndex – Selected Tile-Layer Index. NOTE:- Destroys tile-layer object and all tiles currently defined within it. |
| deleteTileLayerId() | Deletes a Tile Layer (by Id). | (tileLayerObject) “%obj.deleteTileLayerId( %layerId )” | tileLayerObject – Selected Tile-Layer. NOTE:- Destroys tile-layer object and all tiles currently defined within it. |
| getTileLayer() | Returns Tile Layer by Index. | (tileIndex) “%layer = %obj.getTileLayer()” | tileIndex – Tile-Layer Index (zero-based). NOTE:- Returns the tile-layer object from the specified index. |
| getTileLayerCount() | Returns Tile Layer Count. | - “%value = %obj.getTileLayerCount()” | Retrieves the tile-layer count. Tile-Layer objects can be retrieved with “getTileLayer()” using zero to one-minus this value. |
| loadTileMap() | Loads a Tilemap from disk. | (tileMapFile$) “%status = %obj.loadTileMap( “tilemap.map” )” | tileMapFile - Tile-Map File. NOTE:- Loads all currently configured tile-layers/tiles from disk. |
| loadTileMapDataBlock() | Loads a Tilemap from a Datablock. | (tileMapDatablock$) “%status = %obj.loadTileMapDataBlock( myTilemapDatablock )” | tileMapDatablock – Tile-Map Datablock which contains tilemap path/filename. |
| saveTileMap() | Saves a Tilemap File. | (tileMapFile$) “%status = %obj.saveTileMap( “tilemap.map” )” | tileMapFile - Tile-Map File. NOTE:- Saves all currently configured tile-layers/tiles to disk. |
| CALLBACKS | |||
| Callback | Synopsis | Parameter(s) | Detail |
| onTileScript | Tile Script Displayed (only once per tile) | (this, tileLayerObject, int tileX / int tileY, script$) | this – Current Object (self)! (t2dTileMap) tileLayerObject – Tile-Layer Object. (t2dTileLayer) tileX/Y – Selected Tile. script – Script defined in tile. This could be anything, possibly even a function-name which could be executed in the script-callback. NOTE:- This callback only happens once for any tile script, once it has been displayed. |
[edit] t2dTileLayer(child of t2dTileMap) (t2dSceneObject)An object which provides an API to generate and render scrollable rectilinear tilemaps. | |||
| Function | Synopsis | Parameter(s) & Example Format | Detail |
| clearLayer() | Deletes all layer tiles. | - “%obj.clearLayer()” | NOTE:- This will not affect the defined dimensions of the tile-layer, simply remove all defined tiles from it. |
| resetLayer() | Resets the Layer | - “%obj.resetLayer()” | NOTE:-Resets all dynamic properties of the tile-layer such as whether a tile-script has been actioned or properties of animated or active tiles. This is automatically called when a tile is loaded to reset its state. This does not happen when a scene is loaded/saved as scene state is maintained for scene load/saves. |
| clearTile() | Clears a Tile. | (int tileX / int tileY) “%obj.clearTile( “0 0” )” | tileX/Y – Selected Tile. This completely removes the tile from the tile-layer. |
| setTileSize() | Sets size for all tiles. | (tileSizeX / tileSizeY) “%obj.setTileSize( “5 5” )” | tileSizeX/Y – Size for all tiles. NOTE:- You can change the size of the tiles dynamically. Tile size is specified in world-units. |
| resizeLayer() | Resize the Layer | (int newTileCountX / int newTileCountY ) “%obj.resizeLayer( “200 100” )” | newTileCountX/Y – New Tile Counts for each X/Y Axis. NOTE:- Tile Layers can be resized down to 1x1. When upscaling the tile-counts, no tile information is lost but when down-scaling, any tiles outside the new, smaller region will be lost. |
| getTileSize() | Get size for all tiles. | - “%values = %obj.getTileSize()” | Returns (x / y) size for all tiles. |
| getTileCount() | Get count of tiles in X/Y axes. | - “%value = %obj.getTileCount()” | Returns (x / y) count for tile-layer. |
| setActiveTile() | Sets an Active Tile. | (int tileX / int tileY, activeTileClass$, [activeTileDataBlockName$]) “%tileObj = %obj.setActiveTile( “0 0”, myActiveTileClass, myActiveTileDatablock )” | tileX/Y – Selected Tile. activeTileClass – Active-Tile Class to use. This must be a valid defined active-class. activeTileDatablockName – Active-Tile Configuration Datablock. NOTE:- Returns tile object. |
| setAnimatedTile() | Sets an Animated Tile. | (tileX / tileY, animationName, [forceUnique?]) “%status = %obj.setAnimatedTile( “0 0”, myAnimation, true )” | tileX/Y – Selected Tile. animationName – t2dAnimationDatablock object name to use for the animated tile. forceUnique – Forces this tile to have its own animation controller. This means that the animation frame is independent of other tiles using the same animation datablock. The default is false meaning that any tiles using this animation will reuse an existing animation which can greatly reduce memory/cpu overhead; the downside being that non-unique animations are all sync’d together. Typically, non-unique animations would be used unless there’s a specific animated effect you require else having a requirement that a specified animation be out-of-sync than the rest. The default is false. NOTE:- Returns success status (true/false). |
| setStaticTile() | Sets a Static Tile. | (int tileX / int tileY, imageMapName$, [frame]) “%status = %obj.setStaticTile( “0 0”, myImageMap, 0 )” | tileX/Y – Selected Tile. imageMapName – t2dImageMapDatablock object name to use for the static tile. frame – Frame to use from the specified “imageMapName”. Default is 0. NOTE:- Returns success status (true/false). |
| setTileScript () | Sets a Tile Script. | (int tileX / int tileY, script$) “%status = %obj.setTileScript( “0 0”, “myTileScript” )” | tileX/Y – Selected Tile. script – script (data) passed when tile is displayed. NOTE:- The “script” data is passed via the “onScriptTile” callback as well as the “tileX/Y” position of the tile itself. It is an easy task to make this data a function call which can be executed via a “onScriptTile” handler. Returns success status (true/false). |
| setTileCustomData() | Sets Custom-Data for tile. | (int tileX / int tileY, customData$) “%status = %obj.setTileCustomData( “0 0”, “myData” )” | tileX/Y – Selected Tile. customData – custom-data associated with tile. NOTE:- Unlike a tile-script, this data is completely passive and can be used for any purpose. The tile-system does not use it in anyway. Returns success status (true/false). |
| setTileFlip() | Sets Tile Flipping. | (int tileX / int tileY, flipHorz?, flipVert?) “%obj.setTileFlip( “0 0”, true, false )” | tileX/Y – Selected Tile. flipHorz – Flips the tile imagery along the horizontal axis. flipVert – Flips the tile imagery along the vertical axis. |
| getTileScript() | Gets tile script. | (int tileX / int tileY) “%values = %obj.getTileScript( “0 0” )” | tileX/Y – Selected Tile. Returns tile script as space-separated string as below:- “script$ / scriptActioned?”. |
| getTileCustomData() | Gets tile custom-data. | (int tileX / int tileY) “%value = %obj.getTileCustomData( “0 0” )” | tileX/Y – Selected Tile. Returns the tiles custom-data (if any). |
| getTileFlip() | Gets tile flip options. | (int tileX / int tileY) “%values = %obj.getFlip( “0 0” )” | tileX/Y – Selected Tile. Returns tile flip options as space-separated string as below:- “flipHorizontal? / flipVertical?”. |
| getTileType() | Gets tile type. | (int tileX / int tileY) “%values = %obj.getTileType( “0 0” )” | tileX/Y – Selected Tile. Returns tile type as space-separated string as below:- static-tile – “static / imageMapName$ / imageMap-Frame”. animated-tile – “animated / animationName$”. active-tile – “active / className$ / tileObject”. empty or invalid tile – “” (empty string). |
| pickTile() | Picks a tile. | ( x / y ) “%values = %obj.pickTile( “100 50” )” | X/Y – World Position. Returns the logical tile position (x / y) if one exists at the specified world-position else returns nothing. All rotation and panning is taken into account. |
| setPanPosition() | Sets Pan Position. | (panX / panY) “%obj.setPanPosition( “100 40” )” | panX/Y – Selected absolute pan-position. NOTE:- Coordinates/dimensions used within the Tile-Map system relate directly to those specified when the Tile-Layer is created. If the tiles are spaced 32x64 then it takes a pan of 32x64 units to move right/down a single tile. |
| setAutoPan() | Sets Auto-Pan. | (autoPanX / autoPanY) “%obj.setAutoPan( “10 0” )” | autoPanX/Y – Sets automatic panning for Axis-components (per/sec) NOTE:- See “setPanPosition()” for description of coordinates. |
| setAutoPanPolar() | Sets Auto-Pan (Polarwise). | (angle, panSpeed) “%obj.setAutoPanPolar( 90, 10 )” | angle – Angle that the force will be applied. panSpeed – Speed to pan tiles. NOTE:- Use as an alternative to “setAutoPan()”. |
| setWrap() | Sets Wrap Options. | (wrapX?, wrapY?) “%obj.setWrap( true, true )” | wrapX/Y – Specifies whether each axis wraps tiles. The default is false. NOTE:- With wrapping off, no tiles are rendered beyond the tile-layers’ dimensions. With wrapping on, tiles wrap from the opposite side of the tile-layer. You can specify this independantly on both axis. |
| setGridOn() | Sets Tile-Layer Debug-Grid Status. | (status?) “%obj.setGridOn( true )” | status– Specifies if the grid is on or not. |
| setTileCollisionActive() | Sets Tile Collision Active Status. | (int tileX / int tileY, receiveCollision?) “%obj.setTileCollisionActive( “0 0”, true )” | tileX/Y – Selected Tile. receiveCollision? – Specifies whether a collision can be received for this tile. |
| setTileCollisionPolyCustom() | Sets a custom collision polygon on the tile. | (int tileX / int tileY, edgeCount, vertexList$) “%obj.setTileCollisionPolyCustom( “0 0”, 4, “-1 -1 1 -1 1 1 -1 1” )” | tileX/Y – Selected Tile. edgeCount – Specifies the number of edges for the collision custom polygon. vertexList$ - Specifies the vertices for the polygon. The list must contain edgeCount coordinate pairs. All coordinates must be within the range -1 to +1. |
| setTileCollisionPolyPrimitive() | Sets a primitive collision polygon on the tile. | (int tileX / int tileY, edgeCount) “%obj.setTileCollisionPolyPrimitive( “0 0”, 4 )” | tileX/Y – Selected Tile. edgeCount – Specifies the number of edges for the collision primitive polygon. It is defined within an ellipse which subscribes the objects width/height The default is 4 edges (quad) which has a special definition which exactly cover the whole area of the object and not within the ellipse described above. |
| setTileCollisionScale() | Sets the collision scale on the tile. | (int tileX / int tileY, widthScale / heightScale) “%obj.setTileCollisionScale( “0 0”, “0.5 0.25” )” | tileX/Y – Selected Tile. Width/Height Scale - Scales the collision polygon NOTE:- Only down-scaling can take place but must be non-zero. >0 and <=1. |
| getTileCollision() | Get tile collision info. | (int tileX / int tileY) “%values = %obj.getTileCollision( “0 0” )” | tileX/Y – Selected Tile. Returns the following collision information as a space separated string:- - Word#0 = Collision active flag - see setTileCollisionActive() - Words#1&2 = Collision Scale (x / y ) – see setTileCollisionScale() - Word#3 = Collision Polygon Edge Count – see setTileCollisionPolyPrimitive/Custom - Words#4+ = List of Polygon Coordinates (x1 / y1 / x2 / y2 / x3 / y3 / … / xn / yn) |
| loadTileLayer() | Loads a TileLayer from disk. | (tileLayerFile$) “%status = %obj.loadTileLayer( “tilelayer.lyr” )” | tileLayerFile - Tile-Layer File. |
| saveTileLayer() | Saves a TileLayer File. | (tileLayerFile$) “%status = %obj.saveTileLayer( “tilelayer.lyr” )” | tileLayerFile - Tile-Layer File. NOTE:- Saves tile-layer/tiles to disk. |
[edit] t2dParticleEffect(t2dSceneObject)An object which provides an API to generate and render layered particle emitters. | |||
| Function | Synopsis | Parameter(s) & Example Format | Detail |
| addEmitter() | Adds an Emitter to the Effect. | - “%emitter = %obj.addEmitter()” | Adds an emitter to the effect. A t2dParticleEmitter object is returned which is configured independantly of the effect. You should not attempt to destroy this object yourself as it is controlled by the effect; it will be destroyed when the effect is destroyed. NOTE:- The emitter index is return for future reference. |
| removeEmitter() | Removes an Emitter from the Effect. | (emitterObject) “%obj.removeEmitter( emitterObject )” | emitterObject – Object returned from addEmitter() function. NOTE:- Destroys emitter and instantly removes all its particles from the effect. |
| clearEmitters() | Clear All Emitters from Effect. | - “%obj.clearEmitters()” | Clears all the emitters from the effect. NOTE:- This will instantly remove any active particles within the removed emitters. |
| moveEmitter() | Moves the Emitter Object. | (int emitterFromIndex, int emitterToIndex) “%obj.moveEmitter( fromIndex, toIndex )” | emitterFromIndex – The index of the emitter to move. emitterFromTo – The index of the emitter position to move to. NOTE:- The new position would be the logical index without the selected object! |
| findEmitterObject() | Finds Emitter Object from Effect. | (emitterName$) “%emitter = %obj.findEmitterObject( “myEmitter” )” | emitterName$ - Retrieves the emitter object using the emitters name (assuming it has been set). |
| getEmitterCount() | Gets Emitter Count for Effect. | - “%value = %obj.getEmitterCount()” | Retrieves the number of emitters associated with this effect. Emitter Objects can then be access from zero to one-minus this value using the getEmitterId() function. |
| getEmitterObject() | Gets Emitter Object from Effect. | (int emitterIndex) “%emitter = %obj.getEmitterObject( emitterIndex )” | Retrieves the emitter object (so that it can be configured) using its emitter-index. |
| playEffect() | Plays the Particle Effect. | (resetParticles?) “%obj.playEffect( true )” | resetParticles? – Specifies whether any existing particles should be cleared. This is useful for effects that turn on/off repeatedly and existing particles need to die naturally rather then be reset. NOTE:- Starts the effect playing at zero-age. |
| stopEffect() | Stops the Particle Effect. | ([waitForParticles?, killEffect?]) “%obj.stopEffect( true, true )” | waitForParticles – Emission immediately halts but this specifies whether the effect should wait for the existing particles for all emitters to complete before finally stopping the effect. With this flag off, the particles are immediately and abruptly removed whereas with the flag on, all existing particles expire naturally according to their configurations. killEffect – Specifies whether the effect-object is deleted immediately after the stop has completed. This deletion will take place either immediately or after all particles have expired dependant upon the “waitForParticles” flag. NOTE:- If the effect is already playing then the effect is restarted which will result in any existing particles being displayed being instantly removed. |
| loadEffect() | Loads a Particle Effect. | (effectFile$) “%status = %obj.loadEffect( “myEffect.eff” )” | effectFile$ - Loads Particle Effect from File previous saved with “saveEffect()”. NOTE:- Returns a flag indicating if the load was sucessful. |
| saveEffect() | Saves a Particle Effect. | (effectFile$) “%status = %obj.saveEffect( “myEffect.eff” )” | effectFile$ - Saves Particle Effect File for use with “loadEffect()”. NOTE:- Returns a flag indicating if the save was sucessful. |
| setEffectLifeMode() | Sets the Effect Life Mode/Time. | (lifeMode$, time) “%obj.setEffectLifeMode( “KILL”, 5.0 )” | lifeMode – Specifies the life mode which should be one of the following:- - “INFINITE” – No time parameter needed as this means the effect will last forever and continue to age appropriately. (default) - “CYCLE” – The time parameter specifies when the effects age should be reset. At this time, all time-graphs dependant upon the effects-age start sampling from the beginning. - “KILL” – The time parameter specifies when the effect-object should be automatically deleted. The effect will wait for all existing particles to expire before proceeding to delete the effect-object. See “waitForParticles” parameter in stopEffect(). - “STOP” – The time parameter specifies when the effect-object should be automatically stopped. The effect will wait for all existing particles to expire before being fully stopped. See “waitForParticles” parameter in stopEffect(). time – Specifies the time for the selected mode. |
| getEffectLifeMode() | Gets Effect Life Mode. | - “%value = %obj.getEffectLifeMode()” | Retrieves the Effect Life Mode and associated time as a space-separated string. NOTE:- INFINITE mode will always return 0.0 for the time field! |
| selectGraph() | Selects graph-field for editing. | (graphName$) “%obj.selectGraph( “quantity_scale” )” | graphName - Specifies the Graph Name to edit. Once a graph-field is selected, you can use the other graph commands to manipulate its data-keys. NOTE:- This state-method of selecting a graph-field and then editing its data is not only faster but can lead to cleaner script-code. *** A list of particle effect/emitter fields are provided further down this reference *** |
| addDataKey() | Add Data-Key to Graph | (time, value) “%keyIndex = %obj.addDataKey( 1, 10 )” | time – Time to add the data-key. The time must be above 0.0 but does not have an upper-bound limit. Graph-fields that are over particle-life (“_life”) have an upper-limit of 1.0 as this signifies the death of the particle. Values higher than this limit are clamped at 1.0. value – The value for the data-key. Each graph has its own upper and lower limits for this value dependant upon its usage. NOTE:- The zero-based index for the added data-key is returned. Negative values indicate an error. Note that each graph has a default key at time=0.0; this key cannot be removed and adding a data-key at this time results in the default key simply being assigned the specified value. |
| removeDataKey() | Remove Data-Key from Graph. | (int keyIndex) “%obj.removeDataKey()” | keyIndex – Zero-based index of data-key for graph. NOTE:- You cannot have a graph with no keys so Key Zero cannot be removed! Returns a flag indicating success/failure. |
| clearDataKeys() | Clear Data-Keys from Graph. | - “%obj.clearDataKeys()” | Clears Data-Keys from current graph and resets default key to default value. |
| setTimeRepeat() | Set Time-Repeat for Graph. | (timeRepeat) “%obj.setTimeRepeat( 1 )” | (See “getTimeRepeat()”). |
| setDataKeyValue() | Set Data-Key Value in Graph. | (int keyIndex, value) “%obj.setDataKeyValue( 0, 10.0 )” | keyIndex – Zero-based index of data-key for graph. value – Value to set key to. Must be within min/max bounds for graph. NOTE:- Returns a flag indicating success/failure. |
| getDataKey() | Get Data-Key Time and Value from Graph. | (int keyIndex) “%key = %obj.getDataKey( 0 )” | keyIndex – Zero-based index of data-key for graph. This index is the value returned from the addDataKey() function. NOTE:- Both the time and the value are return as a space-separated string. |
| getDataKeyCount() | Get Data-Key Count from Graph. | - “%value = %obj.getDataKeyCount()” | Retrieves the number of data-keys in the current graph. Keys can then be accessed from zero to one-minus this value (keys are zero-based). |
| getGraphValue() | Get Time-Value from Graph. | (time) “%value = %obj.getGraphValue( 0.5 )” | Retrieves the interpolated value at the specified time for the current graph. NOTE:- All values are linearly-interpolated between data-keys; in the near-future, catmull-rom splines will be supported as well as geometric editing for mirroring etc. |
| getMinTime() | Get Min-Time from Graph. | - “%value = %obj.getMinTime()” | Retrieves the minimum time allowed for any data-key within the current graph. |
| getMaxTime() | Get Max-Time from Graph. | - “%value = %obj.getMaxTime()” | Retrieves the maximum time allowed for any data-key within the current graph. |
| getMinValue() | Get Min-Value from Graph. | - “%value = %obj.getMinValue()” | Retrieves the minimum value allowed for any data-key within the current graph. |
| getMaxValue() | Get Max-Value from Graph. | - “%value = %obj.getMaxValue()” | Retrieves the maximum value allowed for any data-key within the current graph. |
| getTimeRepeat() | Get Time-Repeat for Graph. | - “%value = %obj.getTimeRepeat()” | Retrieves the time-repeat value for the current graph. |
| CALLBACKS | |||
| Callback | Synopsis | Parameter(s) | Detail |
| onStopEffect | Signals that the effect has now stopped. | (this) | this – Current Object (self)! NOTE:- This callback may not happen immediately after a “stopEffect()” call if the “waitForParticles” flag is set. This is also the case if the “KILL” life-mode is used. |
[edit] t2dParticleEmitter(child of t2dParticleEffect – Based upon SimObject)An object which provides an API to generate and render particle emissions. | |||
| Function | Synopsis | Parameter(s) & Example Format | Detail |
| loadEmitter() | Loads a Particle Effect. | (emitterFile$) “%status = %obj.loadEmitter( “myEmitter.emi” )” | emitterFile$ - Loads Particle Emitter from File previous saved with “saveEmitter()”. NOTE:- Returns a flag indicating if the load was sucessful. |
| saveEmitter() | Saves a Particle Emitter. | (emitterFile$) “%status = %obj.saveEmitter( “myEmitter.emi” )” | emitterFile$ - Saves Particle Emitter File for use with “loadEmitter()”. NOTE:- Returns a flag indicating if the save was sucessful. |
| setVisible() | Set the Emitters’ Visibility. | (status?) “%obj.setVisible( true )” | (See “getVisible()”). |
| getVisible() | Gets the Emitters’ Visibility. | - “%value = %obj.getVisible()” | Rerieves the emitters visibility status. NOTE:- Unlike other T2D objects, making an emitter invisible, destroys any existing particles and stops the emitter from creating any more. |
| setBlending() | Sets the Rendering Blend Options. | ( blendStatus?, [srcBlendFactor], [dstBlendFactor]) “%obj.setBlending( true, SRC_ALPHA, ONE_MINUS_SRC_ALPHA)” | blendStatus – Sets the blending status on/off. (default is true). srcBlendFactor – Specifies the source blend factor. dstBlendFactor – Specifies the destination blend factor. NOTE:- This is identical to the t2dSceneObject call but this object is a not derived from this so has a duplicate call. The parent t2dParticleEffect is derived from t2dSceneObject but its blend-factors (as well as other properties) are ignored here. These blend-factors directly relate the the blend factors used in OpenGL but don’t use the “GL_” prefix. You can find further information on blending factors on any OpenGL reference of “glBlendFunc”. (Defaults are bold). srcBlendFactors are: "ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA", "DST_ALPHA", "ONE_MINUS_DST_ALPHA", "SRC_ALPHA_SATURATE" dstBlendFactors are: "ZERO", "ONE", "SRC_COLOR", "ONE_MINUS_SRC_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA", "DST_ALPHA", "ONE_MINUS_DST_ALPHA" |
| getBlending() | Gets the Rendering Blend Options. | - “%value = %obj.getBlending()” | Retrieves the blend options (“Status/SrcFactor/DstFactor”) – See “setBlending()”. |
| setEmitterName() | Set the Emitters Name. | (emitterName$) “%obj.setEmitterName( “CoolEmitter” )” | (See “getEmitterName()”). |
| setEmitterType() | Set Emitter Type. | (emitterType$) “%obj.setEmitterType( “AREA” )” | (See “getEmitterType()”). |
| setPivotPoint() | Set the Pivot-Point. | (pivotX / pivotY) “%obj.setPivotPoint( “0.5 0.5” )” | (See “getPivotPoint()”). |
| setFixedForceAngle() | Set Fixed-Force Angle. | (fixedForceAngle) “%obj.setFixedForceAngle( 90 )” | (See “getFixedForceAngle()”). |
| setFixedAspect() | Set Fixed-Aspect. | (fixedAspect?) “%obj.setFixedAspect( true )” | (See “getFixedAspect()”). |
| setImageMap() | Set the ImageMap/Frame. | (imageMapName$, [int frame]) “%obj.setImageMap( myImageMap, 0 )” | (See “getImageMapNameFrame()”). |
| setAnimationName() | Set the Animation. | (animationName$) “%obj.setAnimationName( myAnimation )” | (See “getAnimationName()”). |
| setUseEffectEmission() | Set Use-Effect-Emission Flag. | (useEffectEmission?) “%obj.setUseEffectEmission( true )” | (See “getUseEffectEmission()”). |
| setIntenseParticles() | Set Intense-Particles Flag. | (intenseParticles?) “%obj.setIntensityParticles( true )” | (See “getIntenseParticles()”). |
| setSingleParticle() | Set Single-Particle Flag. | (singleParticle?) “%obj.setSingleParticle( true )” | (See “getSingleParticle()”). |
| setAttachPositionToEmitter() | Set Attach-Position-To-Emitter Flag. | (attachPositionToEmitter?) “%obj.setAttachPositionToEmitter( true )” | (See “getAttachPositionToEmitter()”). |
| setAttachRotationToEmitter() | Set Attach-Rotation-To-Emitter Flag. | (attachRotationToEmitter?) “%obj.setAttachRotationToEmitter( true )” | (See “getAttachRotationToEmitter()”). |
| setLinkEmissionRotation() | Set Link-Emission-Rotation Flag. | (linkEmissionRotation?) “%obj.setLinkEmissionRotation( true )” | (See “getLinkEmissionRotation()”). |
| setFirstInFrontOrder() | Set First-InFront-Order Flag. | (firstInFrontOrder?) “%obj.setFirstInFrontOrder( true )” | (See “getFirstInFrontOrder()”). |
| getEmitterName() | Get the Emitters’ Name. | - “%value = %obj.getEmitterName()” | Retrieves the emitters name. NOTE:- It is not essential for the emitter to have a name. In-fact, by default, all emitters have no name and they can all be the same within the effect. The purpose of this function is to allow an editor to delineate and assign emitter names so that a user can manipulate it via the GUI using it. The name is additionally loaded/saved with the emitter so that this data can be encapsulated within the object without the editor having to do so. |
| getEmitterType() | Get Emitter Type. | - “%value = %obj.getEmitterType()” | Get the emitter type. This can be either “POINT”, “LINEX”, “LINEY” or “AREA”. |
| getPivotPoint() | Get Pivot-Point. | - “%value = %obj.getPivotPoint()” | Retrieves the Particle Pivot-Point. This is the point at which the particle rotates around. (0,0) is the top-left; (1,1) is the bottom-right, (0.5, 0.5) is the center etc. NOTE:- Larger/Negative values can be used to create bigger radii rotations which make the particle movements more complex producing “swirling” motions. The point is return as a string with the two values separated with a space. |
| getFixedForceAngle() | Get Fixed-Force-Angle. | - “%value = %obj.getFixedForceAngle()” | Retrieves the “Fixed Force Angle”. The “Fixed Force Angle” is the basis for the “Fixed Force” graphs and is used as a base polar-vector whose magnitude is modulate by the graphs. This is typically used for gravity/wind effects. |
| getFixedAspect() | Get Fixed-Aspect. | - “%value = %obj.getFixedAspect()” | Retrieves the “Fixed Aspect” flag. In “Fixed Aspect” mode, the particle dimensions along the X and Y axis are calculated using the “sizeX” only graphs. The “sizeY” graphs are ignored. |
| getImageMapNameFrame() | Get ImageMap Name and Frame. | - “%values = %obj.getImageMapNameFrame()” | Retrieves the ImageMap Name and frame assigned to this emitter (if any). An empty string indicates that no imageMap/frame is set. |
| getAnimationName() | Get Animation Name. | - “%value= %obj.getAnimationName()” | Retrieves the Animation Name assigned to this emitter (if any). An empty string indicates that no animation is set. |
| getUsingAnimation() | Get Using Flag. | - “%value = %obj.getUsingAnimation()” | This flag is true if a sucessful “setAnimationName()” function is used. If a subsequent “setImageMap()” function is used then it will be false. |
| getUseEffectEmission() | Get Use-Effect-Emission Flag. | - “%value = %obj.getUseEffectEmission()” | Retrieves the “Use Effect Emission” Flag. This flag controls whether the emission settings for the emitter are ignored and the effects emission settings are used. The default is true meaning that the emitters emission settings are ignore in favor of the effects settings. This can be very useful in having a majority of emitters using a single, global emission setting but odd ones using their own. |
| getIntenseParticles() | Get Intense-Particles Flag. | - “%value = %obj.getIntenseParticles()” | Retrieves the “Intense Particles” flag. This flag controls whether the “intensity” of the particle increases when particles overlap. This can be used to make the particles look energetic. |
| getSingleParticle() | Get Single-Particle Flag. | - “%value = %obj.getSingleParticle()” | Retrieves the “Single Particle” flag. This flag forces the emitter to emit on a single-particle with infinite lifetime. The particle also ignores any emission velocities or any field that would otherwise cause it to move. This is used to generate halo/flare type effects with an emitter generating only one. |
| getAttachPositionToEmitter() | Get Attach-Position-To-Emitter Flag. | - “%value = %obj.getAttachPositionToEmitter()” | Retrieves the “Attach Position To Emitter” flag. In “Attach Position to Emitter” mode, the particles are attached to the emitters position. As the emitter moves, so do the particles. |
| getAttachRotationToEmitter() | Get Attach-Rotation-To-Emitter Flag. | - “%value = %obj.getAttachRotationToEmitter()” | Retrieves the “Attach Rotation To Emitter” flag. In “Attach Rotation to Emitter” mode, the particles are attached to the emitters rotation. As the emitter rotates, the particles rotate around the emitter using its location as a pivot-point. NOTE:- This does not affect particle orientation. This can only be used when “Attach Position to Emitter” mode is active. |
| getLinkEmissionRotation() | Get Link-Emission-Rotation Flag. | - “%value = %obj.getLinkEmissionRotation()” | Retrieves the “Link Emission Rotation” flag. This flag controls whether the emission is linked to the rotation of the effect. When |
| getFirstInFrontOrder() | Get First-In-Front-Order Flag. | - “%value = %obj.getFirstInFrontOrder()” | Retrieves the “First In-Front Order” flag. This flag controls whether older particles always appear in-front (for this emitter) or vice-versa. “First” refers to the first particles being emitted and therefore the oldest, being in-front. |
| setParticleOrientation() | Set Particle Orientation. | (particleOrientationMode$) “%obj.setParticleOrientation( “ALIGNED” )” | (See “getParticleOrientation()”). |
| setAlignAngleOffset() | Set Align-Orientation Angle Offset. | (alignAngleOffset) “%obj.setAlignAngleOffset( 90 )” | (See “getAlignAngleOffset()”). |
| setAlignKeepAligned() | Set Align-Orientation Keep-Aligned Flag. | (keepAligned?) “%obj.setAlignKeepAligned( true )” | (See “getAlignKeepAligned()”). |
| setFixedAngleOffset() | Set Fixed-Orientation Angle-Offset. | (randomAngle) “%obj.setFixedAngleOffset( 90 )” | (See “getFixedAngleOffset()”). |
| setRandomAngleOffset() | Set Random-Orientation Angle-Offset. | (randomAngle) “%obj.setRandomAngleOffset( 90 )” | (See “getRandomAngleOffset()”). |
| setRandomArc() | Set Random-Orientation Arc. | (randomArc) “%obj.setRandomArc( 30 )” | (See “getRandomArc()”). |
| getParticleOrientation() | Get Particle Orientation. | - “%value = %obj.getParticleOrientation()” | Retrieves the Particle Orientation Mode. Returned modes are “ALIGNED”, “FIXED” or “”RANDOM”. |
| getAlignAngleOffset() | Get Align-Orientation Angle-Offset. | - “%value = %obj.getAlignAngleOffset()” | Retrieves the “Align Angle Offset” value. In “Align” orientation mode, this angle is added onto the existing particle alignment. |
| getAlignKeepAligned() | Get Align-Orientation Keep-Aligned Flag. | - “%value = %obj.getAlignKeepAligned()” | Retrieves the “Align Keep-Aligned” flag. In “Align” orientation mode, this flag ensures that the particle stays aligned to its motion. On this alignment is added the “Align Angle Offset”. |
| getFixedAngleOffset() | Get Fixed-Orientation Angle-Offset. | - “%value = %obj.getFixedAngleOffset()” | Retrieves the “Fixed Angle Offset” value. In “Fixed” orientation mode, this angle is using as the orientation for all the particles. |
| getRandomAngleOffset() | Get Random-Orientation Angle-Offset. | - “%value = %obj.getRandomAngleOffset()” | Retrieves the “Random Angle Offset” value. In “Random” orientation mode, this angle is used as a base-angle to which the “Random Arc” is added. |
| getRandomArc() | Get Random-Orientation Arc. | - “%value = %obj.getRandomArc()” | Retrieves the “Random Arc” value. In “Random” orientation mode, this arc-angle is used as a random arc which is added to the “Random Angle Offset”. NOTE:- The random arc is is a distribution around the “Random Angle Offset”. This means that if the “Random Angle Offset” was set to 90-deg and the “Random Arc” was set to 30-deg then a random angle between 75 to 105-deg is choosen; the “Random Arc” is centered on the “Random Angle Offset”. |
| selectGraph() | Selects graph-field for editing. | (graphName$) “%obj.selectGraph( “quantity_base” )” | graphName - Specifies the Graph Name to edit. Once a graph-field is selected, you can use the other graph commands to manipulate its data-keys. NOTE:- This state-method of selecting a graph-field and then editing its data is not only faster but can lead to cleaner script-code. |
| addDataKey() | Add Data-Key to Graph | (time, value) “%obj.addDataKey( 1, 10 )” | time – Time to add the data-key. The time must be above 0.0 but does not have an upper-bound limit. Graph-fields that are over particle-life (“_life”) have an upper-limit of 1.0 as this signifies the death of the particle. Values higher than this limit are clamped at 1.0. value – The value for the data-key. Each graph has its own upper and lower limits for this value dependant upon its usage. NOTE:- The zero-based index for the added data-key is returned. Negative values indicate an error. Note that each graph has a default key at time=0.0; this key cannot be removed and adding a data-key at this time results in the default key simply being assigned the specified value. |
| removeDataKey() | Remove Data-Key from Graph. | (int keyIndex) “%obj.removeDataKey( 0 )” | keyIndex – Zero-based index of data-key for graph. NOTE:- You cannot have a graph with no keys so Key Zero cannot be removed! |
| clearDataKeys() | Clear Data-Keys from Graph. | - “%obj.clearDataKeys()” | Clears Data-Keys from current graph and resets default key to default value. |
| setTimeRepeat() | Set Time-Repeat for Graph. | (timeRepeat) “%obj.setTimeRepeat( 1 )” | (See “getTimeRepeat()”). |
| setDataKeyValue() | Set Data-Key Value in Graph. | (int keyIndex, value) “%obj.setDataKeyValue( 0, 10.0 )” | keyIndex – Zero-based index of data-key for graph. value – Value to set key to. Must be within min/max bounds for graph. NOTE:- Returns a flag indicating success/failure. |
| getDataKey() | Get Data-Key Time and Value from Graph. | (int keyIndex) “%key = %obj.getDataKey( 0 )” | keyIndex – Zero-based index of data-key for graph. This index is the value returned from the addDataKey() function. NOTE:- Both the time and the value are return as a space-separated string. |
| getDataKeyCount() | Get Data-Key Count from Graph. | - “%value = %obj.getDataKeyCount()” | Retrieves the number of data-keys in the current graph. Keys can then be accessed from zero to one-minus this value (keys are zero-based). |
| getGraphValue() | Get Time-Value from Graph. | (time) “%value = %obj.getGraphValue( 0.5 )” | Retrieves the interpolated value at the specified time for the current graph. NOTE:- All values are linearly-interpolated between data-keys; in the near-future, catmull-rom splines will be supported as well as geometric editing for mirroring etc. |
| getMinTime() | Get Min-Time from Graph. | - “%value = %obj.getMinTime()” | Retrieves the minimum time allowed for any data-key within the current graph. |
| getMaxTime() | Get Max-Time from Graph. | - “%value = %obj.getMaxTime()” | Retrieves the maximum time allowed for any data-key within the current graph. |
| getMinValue() | Get Min-Value from Graph. | - “%value = %obj.getMinValue()” | Retrieves the minimum value allowed for any data-key within the current graph. |
| getMaxValue() | Get Max-Value from Graph. | - “%value = %obj.getMaxValue()” | Retrieves the maximum value allowed for any data-key within the current graph. |
| getTimeRepeat() | Get Time-Repeat for Graph. | - “%value = %obj.getTimeRepeat()” | Retrieves the “Time Repeat” value. This value controls how many times the current graph is repeated. Setting it to 0.0 (the default) means that the graph is not repeated at all but any value greater than this (doesn’t have to be an integer) cause the graph to repeat that many times. NOTE:- With over-life (“_life”) graphs, this is directly how many times the graph repeats but with all other graphs, the time-reference comes from the age of the effect itself and is relative to the current age of the emitter. What this means is that for all other non (“_life”) graphs, this value acts like a timescale. Setting a zero value means that the reference time runs exactly as the effects age but raising the value increases the time-scale accordingly. Setting a value of 0.5 means that the time for the graph will run 50% faster (150%); a value of 1.2 means that the time for the graph will run 120% faster (220%). |
[edit] t2dSceneGraphAn object which allows t2dSceneObject objects to be added to it resulting in a ‘scene’ of objects that can be rendered using a t2dSceneWindow object. | |||
| Methods | |||
| Name | Synopsis | Parameter(s) & Example Format | Detail |
| initialise() | Initialise Scene Graph. | (int containerBinSize, int containerBinCount, useLayerSorting?, lastInFrontSorting? “%obj.initialise( 20, 256, true, true )” | containerBinSize – Specifies the bin size within the container system. Whenever an object is added to the scene, the scenegraph places an entry into the container-system bins that the object covers. The container bin-size/count define a grid which is used to make quick determinations for searching (picking/rendering/collisions) of objects. This is called the broad-phase search. Setting the bin-sizes too small results in objects overlapping lots of bins (all of which need to be checked). Setting the bin-sizes too big results in lots of objects being put into the same bins causing lots of checks. Both result in a loss of performance. This is typically something you tweak during performance tuning. The debug-banner contains information on the quantity/maximum bins searched for picking/render and collision-detection. containerBinCount – Specifies the bin quanity within the container system. The world is extremely large and is therefore impractical to have huge quantitys of bins. To get around this, the bin-system wraps around at BinSize*BinCount. A game typically has a playable area and having as few wraps as possible is preferred but with extremely large play-areas, a balance of memory needed for the bins/number of wraps in the play area should be calculated. useLayerSorting – Specifies whether the system uses layer sorting. Objects within the container system are automatically separated into their layers when they are retrieved by the scenegraph prior to rendering. When the objects are within their layers, they are in a random order with respect to other objects within the same layer. This option specifies that the system should sort those object depending on the order which they were created (see lastInFrontSorting). lastInFrontSorting? – Specifies whether layer-sorting orders the last-object to be added in-front (e.g. the newest) or the first (oldest). NOTE:-You do not need to call this function unless you have a specific reason to do so. It is only there to allow advanced customisation for performance tuning purposes! |
| addToScene() | Add t2dSceneObject to Scene. | (t2dSceneObject) “%obj.addToScene( mySceneObject )” | t2dSceneObject – Adds the specified object to the scene. NOTE:- A t2dSceneObject can only be within a single scene at one time. |
| removeFromScene() | Remove t2dSceneObject from Scene. | (t2dSceneObject) “%obj.removeFromScene()” | t2dSceneObject – Removes the specified object from the scene. NOTE:- If the object is deleted, it will automatically be removed from any scene it’s in. |
| clearScene() | Clear Scene of all t2dSceneObject objects. | ([deleteObjects?]) “%obj.clearScene( true )” | deleteObjects? – Specifies whether the objects removed from the scene should be destroyed. The default is true. |
| loadScene() | Loads a Scene from a Disk File. | (file$) “%status = %obj.loadScene( “myScene.scn” )” | file – Specifies the file from which the scene will be loaded. NOTE:- This will load a previously saved scene from file. It contains all the objects at the exact moment they were saved, including individual particles and their settings etc. This is an instanaeous snapshot of a scene rather than a method to save object settings. |
| saveScene() | Saves a Scene to a Disk File. | (file$) “%status = %obj.saveScene( “myScene.scn” )” | file – Specifies the file from which the scene will be saved. |
| pickLine() | Picks objects that intersect specified line with optional group/layer masks. | (start x / y, end x / y, [groupMask], [layerMask], [showInvisible?], [excludeObjectId] ) “%values = %obj.pickLine( “-30 -20”, “30 20”, BIT(0)|BIT(1), BIT(0), true, %someObj )” | start x/y – Start world position of line. end x/y – End world position of line. groupMask – Selects the group(s) to search for (default is all groups). layerMask – Selects the layer(s) which to search within (default is all layers). showInvisible? – Specifies whether to include invisible objects in the pick. Default is false. excludeObjectId – Specifies an object to exclude from the pick. Very useful is you're searching the area around a specific object but you don't want that object to be picked. NOTE:- The result will be a list of objects which satisfy the criteria above and overlap the specified ray. The result is a string of object IDs separated with spaces. The order list is sorted by collision-time (unlike layer order from front->backwards that the other pick functions use). |
| pickPoint() | Picks objects at location with optional group/layer masks. | (x / y, [groupMask], [layerMask], [showInvisible?], [excludeObjectId] ) “%values = %obj.pickPoint( “0 0”, BIT(0)|BIT(1), BIT(0), true, %someObj )” | x/y – World position to check for objects. groupMask – Selects the group(s) to search for (default is all groups). layerMask – Selects the layer(s) which to search within (default is all layers). showInvisible? – Specifies whether to include invisible objects in the pick. Default is false. excludeObjectId – Specifies an object to exclude from the pick. Very useful is you're searching the area around a specific object but you don't want that object to be picked. NOTE:- The result will be a list of objects which satisfy the criteria above and overlap the specified point. The result is a string of object IDs separated with spaces. The order list is sorted by layer order from front->backwards. |
| pickRadius() | Picks objects that intersect the specified circle with optional group/layer masks. | (x / y, radius, [groupMask], [layerMask], [showInvisible?], [excludeObjectId] ) “%values = %obj.pickPadius( “0 0”, 25, BIT(0)|BIT(1), BIT(0), true, %someObj )” | x/y – Center of circle. radius – The radius of the check groupMask – Selects the group(s) to search for (default is all groups). layerMask – Selects the layer(s) which to search within (default is all layers). showInvisible? – Specifies whether to include invisible objects in the pick. Default is false. excludeObjectId – Specifies an object to exclude from the pick. Very useful is you're searching the area around a specific object but you don't want that object to be picked. NOTE:- The result will be a list of objects which satisfy the criteria above and overlap the specified circle. The result is a string of object IDs separated with spaces. The order list is sorted by layer order from front->backwards. |
| pickRect() | Picks objects that intersect the specified rectangle with optional group/layer masks. | (start x / y, end x / y, [groupMask], [layerMask], [showInvisible?], [excludeObjectId] ) “%values = %obj.pickRect( “-30 -20”, “30 20”, BIT(0)|BIT(1), BIT(0), true, %someObj )” | start x/y – Top/left world position of rectangle. end x/y – Bottom/right world position of rectangle. groupMask – Selects the group(s) to search for (default is all groups). layerMask – Selects the layer(s) which to search within (default is all layers). showInvisible? – Specifies whether to include invisible objects in the pick. Default is false. excludeObjectId – Specifies an object to exclude from the pick. Very useful is you're searching the area around a specific object but you don't want that object to be picked. NOTE:- The result will be a list of objects which satisfy the criteria above and overlap the specified rectangle. The result is a string of object IDs separated with spaces. The order list is sorted by layer order from front->backwards. |
| setConstantForce() | Apply a constant directed force. | (constantForceX / constantForceY, gravitic?) “%obj.setConstantForce( “0 50”, true )” | constantForceX/Y – Force to constantly apply to all the objects in the scene. gravitic? – Any force applied to an object is dependant upon its mass/inertia. The larger the mass, the less the force will have on its velocity. Gravity works independent of mass so this flag allows you to bypass the standard calculation. The default is false. NOTE:- A typical used constant force is gravity. This force changes the linear velocity all objects in the scene. This won’t affect immovable objects. |
| setConstantForcePolar() | Apply a constant directed polar force. | (angle, force, [gravitic?]) “%obj.setConstantForcePolar( 180, 50, true )” | angle – Angle that the force will constantly be applied. force – Magnitude of the force to be applied. gravitic? – Any force applied to an object is dependant upon its mass/inertia. The larger the mass, the less the force will have on its velocity. Gravity works independent of mass so this flag allows you to bypass the standard calculation. The default is false. |
| stopConstantForce() | Stops any constant directed force. | - “%obj.stopConstantForce()” | Stops any constant force that has previous been started. This is identical to calling "%obj.setConstantForce("0 0")" but slightly quicker. |
| setScenePause() | Sets the Scene Graph Pause Status. | (status?) “%obj.setScenePause( true )” | status? - Sets whether the scene is paused or not. NOTE:- Prior versions of T2D allowed the scene time to be scaled, effectively speeding-up or slowing-down the scene. This cannot easily be achieved now with the new physics system but this function does allow the scene to stop. |
| getConstantForce() | Gets the constant scene force. | - “%value = %obj.getConstantForce()” | Retrieves the constant scene force. |
| getScenePause() | Gets the Scene Graph Pause Status. | - “%value = %obj.getScenePause()” | Indicates whether the scene is paused or not. |
| setDebugOn() | Sets Debug On Mode(s). | (debugMask) “%obj.setDebugOn( BIT(0) | BIT(1) )” | debugMask – Specifies which debug-modes are ON. NOTE:-See Notes for Debug Modes above. |
| setDebugOff() | Sets Debug Off Mode(s). | (debugMask) “%obj.setDebugOff( BIT(0) | BIT(1) )” | debugMask – Specifies which debug-modes are OFF. NOTE:- The current debug modes show/hide the following:- BIT#0 – Statistics Debug Banner. BIT#1 – Object Bounding/Clipping-Boxes. BIT#2 – Object Mount-Nodes. BIT#3 – Object Mount-Links (force tracking paths). BIT#4 – Object World-Limit. BIT#5 – Object Collision Bounds. |
| getSceneObjectCount() | Gets the Scene Graph Object-Count. | - “%value = %obj.getSceneObjectCount()” | Retrieves the current scene Object-Count. |
| getSceneObjectList() | Gets the Scene Graph Object-List. | - “%objectListl = %obj.getSceneObjectList()” | Retrieves the current scene Object-List. NOTE:- A complete list of objects as a space-separated string is returned. |
| getSceneTime() | Gets the Scene Graph Time. | - “%value = %obj.getSceneTime()” | Retrieves the current scene time. NOTE:- Due to the fact that the scene time can be scale and generally manipulated for various effects, you should use this as a basis for other timestamps. It is perfectly fine to use it with reference to T2D and its subsequent objects. Just be aware that due to scaling, this doesn’t necessarily relate to a direct timebase! |
| setLayerDrawOrder() | Sets the Layer Draw Order for specified t2dSceneObject. | (t2dSceneObject, orderCommand$ ) “%obj.setLayerDrawOrder( mySceneObject, FRONT )” | t2dSceneObject – Selected object to change Draw Order of. orderCommand$ - Draw Order Command:- “FRONT” – Moves the object to the front of its current layer. “BACK” – Moves the object to the back of its current layer. “FORWARD” – Moves the object forward within its current layer. “BACKWARD” – Moves the object backward within its current layer. NOTE:- This call will not change the objects layer but rather it’s order within the layer. The function returns a flag indicating whether it actually moved or not. |
| setSceneDrawOrder() | Sets the Scene Draw Order for specified t2dSceneObject. | (t2dSceneObject, orderCommand$ ) “%obj.setSceneDrawOrder( mySceneObject, FRONT )” | t2dSceneObject – Selected object to change Draw Order of. orderCommand$ - Draw Order Command:- “FRONT” – Moves the object to the front of the whole scene. “BACK” – Moves the object to the back of the whole scene. “FORWARD” – Moves the object forward within the whole scene. “BACKWARD” – Moves the object backward within the whole scene. NOTE:- Unlike the “setLayerDrawOrder” function, this call will change the objects layer. The “FRONT”/”BACK” commands move the object to the front/back layer and front/back within the layer. The “FORWARD”/”BACKWARD” commands move the object forward/backward within the layer first; if the object is already at the front/back then the object will be moved forward/backward a layer. This will happen until the object is moved or hits the front/back layer. This is used to move the object forward/backward through the whole scene, including the discreet layers whereas the “setLayerDrawOrder” function only does this within layers. |
| setScenePhysicsFPSActive() | Sets the physics FPS Active Status. | (status?) “%obj.setScenePhysicsFPSActive( true )” | status? – Sets the FPS active status. NOTE:- The scene physics will attempt to maintain a constant FPS and will iterate when below the specified FPS limit. This functionality is critical to a well-balanced and stable physics system. This function allows you to bypass that system and run using incoming time-intervals only in a continuous “free-running” manner although the FPS limit is still monitor and will switch to an iterative method if needed. |
| setScenePhysicsLimitFPS() | Sets the physics simulation Limit. | (fps) “%obj.setScenePhysicsLimitFPS( 20 )” | fps – The frames per second limit. NOTE:- The physics system prefers a constant update-rate. To try to achieve this, the system will iterate when the fps gets too low. This specifies the fps threshold at which point the system will begin to iterate the scene processing (see “setScenePhysicsMaxIterations()”). |
| setScenePhysicsTargetFPS() | Sets the physics simulation Target. | (fps) “%obj.setScenePhysicsTargetFPS( 80 )” | fps – The frames per second target. NOTE:- The physics system prefers a constant update-rate. This specifies the target FPS which the system will try to achieve by whatever means necessary. If the system runs faster than this, the simulation will still only run at this limit. |
| setScenePhysicsMaxIterations() | Sets the physics simulation Maximum Iterations. | (maxIterations) “%obj.setScenePhysicsMaxIterations( 3 )” | maxItertations – The maximum iterations allowed. NOTE:- The physics system prefers a constant update-rate. To try to achieve this, the system will iterate when the fps gets too low. This specifies the maximum iterations allowed. The system will split up the elapsed time into target FPS chunks so that the simulation stays as stable as possible. Care should be taken with this setting as each iteration can take considerable processing time and can result in a further degredation of the simulation accuracy and worse FPS. |
| getScenePhysicsFPSActive() | Gets the physics FPS Active Status. | - “%value = %obj.getScenePhysicsFPSActive()” | Retrieves the physics FPS active status. |
| getScenePhysicsLimitFPS() | Gets the physics simulation Limit. | - “%value = %obj.getScenePhysicsLimitFPS()” | Retrieves the physics simulation limit. |
| getScenePhysicsTargetFPS() | Gets the physics simulation Target. | - “%value = %obj.getScenePhysicsTargetFPS()” | Retrieves the physics simulation target. |
| getScenePhysicsMaxIterations() | Gets the physics simulation Maximum Iterations. | - “%value = %obj.getScenePhysicsMaxIterations()” | Retrieves the physics simulation maximum iterations. |
| Callbacks | |||
| Name | Synopsis | Parameter(s) | Detail |
| onSafeDelete() | Signals that an object is about to be safely deleted. | (this, t2dSceneObject) | this – Current Object (self)! t2dSceneObject – Object being deleted. |
| onUpdateScene() | Pseudo Main-Loop Callback. | (this) | this – Current Object (self)! NOTE:- If you need to know the current scene-time during this function then you can use “getSceneTime()”. |
[edit] t2dSceneWindow(GUIControl)An object which renders t2dSceneObject objects contained within a t2dSceneGraph object (scene). | ||||
| Function | Synopsis | Parameter(s) & Example Format | Detail | |
| setSceneGraph() | Sets the t2dSceneGraph Object which this window will render. | ([t2dSceneGraph]) “%obj.setSceneGraph( mySceneGraph )” | t2dSceneGraph – Specifies which scene-graph to render. NOTE:- If no scenegraph is specified then the call effectively becomes a call to “resetSceneGraph()”. | |
| resetSceneGraph() | Stops the window from rendering any scene graph. | - “%obj.resetSceneGraph()” | NOTE:- This is effectively the opposite of “setSceneGraph()”. | |
| setCurrentCameraPosition() | Set current camera position. | (x / y / [width / height]) “%obj.setCurrentCameraPosition( “0 0 100 75” )” …or… “%obj.setCurrentCameraPosition( “0 0” )” | x/y – Position to CENTER camera on. width/height – Area of camera to use. NOTE:- The width/height parameters can be omitted (together) to allow you to specify a new position only. Setting the camera area allows you to set an absolute area whereas position allows you to center on a position and specify a camera width/height similar to a field-of-view. | |
| setCurrentCameraZoom() | Set current camera Zoom Factor. | (zoomFactor) “%obj.setCurentCameraZoom( 1 )” | zoomFactor – Sets the current camera zoom factor. NOTE:- Zoom factors don’t adjust either the camera position or area. Setting a zoom of 2.5 results in a smaller viewed area e.g. an effective zoom-in. Setting a value of 0.5 results is a bigger viewed area e.g. an effective zoom-out. A zoom of 1 is the default and results in a view as specified by the associated functions. The zoom is always around the center of the view. | |
| setCurrentCameraArea() | Set current camera area. | (x / y / width / height) “%obj.setCurrentCameraArea( “-50 -37.5 100 75” )” | x/y – Top-Left position of camera area. width/height – Area of camera to use. NOTE:- All commands that begin with setCurrentXXX instantaneously set the camera to the specified values. Commands that begin with setTargetXXX are setting-up a move ready to be executed. | |
| getCurrentCameraPosition() | Get Current Camera Position. | - “%value = %obj.getCurrentCameraPosition()” | Retrieves current camera position as (X / Y). Note that this may be constantly changing if the camera is in motion. | |
| getCurrentCameraArea() | Get Current Camera Area. | - “%value = %obj.getCurrentCameraArea()” | Retrieves current camera area as (X / Y / Width / Height). Note that this may be constantly changing if the camera is in motion. | |
| getCurrentCameraZoom() | Get Current Camera Zoom Factor. | - “%value = %obj.getCurrentCameraZoom()” | Retrieves current camera zoom. Note that this may be constantly changing if the camera is in motion. | |
| setTargetCameraPosition() | Set target camera position. | (x / y / [width / height]) “%obj.setTargetCameraPosition( “0 0 100 75” )” …or… “%obj.setTargetCameraPosition( “0 0” )” | x/y – Position to CENTER camera on. width/height – Area of camera to use. NOTE:- The width/height parameters can be omitted (together) to allow you to specify a new position only. | |
| setTargetCameraArea() | Set target camera area. | (x / y / width / height) “%obj.setTargetCameraArea( “-50 -37.5 100 75” )” | x/y – Top-Left position of camera area. width/height – Area of camera to use. | |
| setTargetCameraZoom() | Set target camera Zoom Factor. | (zoomFactor) “%obj.setTargetCameraZoom( 2 )” | zoomFactor – Sets the current camera zoom factor. NOTE:- Identical to setCurrentCameraZoom except the camera settings are queued. | |
| setCameraInterpolationMode() | Set camera interpolation mode. | (interpolationMode$) “%obj.setCameraInterpolationMode( SIGMOID )” | interpolationMode – Interpolation Mode can be: - “LINEAR” – Standard Linear Ramp (abrupt start/stop). - “SIGMOID” – Slow Start, Slow Stop (smooth movement). NOTE:- The camera system allows moves to be setup and then executed. This simply controls how long it takes for the move to take place. | |
| setCameraInterpolationTime() | Set camera interpolation time. | (interpolationTime) “%obj.setCameraInterpolationTime( 1.5 )” | interpolationTime – Time taken to interpolate between camera moves. NOTE:- The camera system allows moves to be setup and then executed. This simply controls how long it takes for the move to take place if an interpolation-time isn’t specified. In other words, this is the default time taken. | |
| startCameraMove() | Start Camera Move. | ([interpolationTime]) “%obj.startCameraMove( 2.5 )” | interpolationTime – Specifies the time that the queued camera move will take (in secs). | |
| stopCameraMove() | Stop Camera Move. | - “%obj.stopCameraMove()” | Instantly stops any camera move that’s currently running (if any). The camera stops where it is. | |
| completeCameraMove() | Complete Camera Move | - “%obj.completeCameraMove()” | Completes any pending camera move and moves instantly to the target position/zoom. | |
| undoCameraMove() | Undo Camera Move. | ([interpolationTime]) “%obj.undoCameraMove( 0.5 )” | interpolationTime – Specifies the time that the undo move will take. NOTE:- When a camera move is handled, the position before the move is stored in a queue. A total of 64 camera moves are stored. This command will step back through the camera moves allowing you to ‘undo’ the camera moves. This can be very handy when you move the camera to a new position and want to simply move back. | |
| getIsCameraMoving() | Get Current Camera Moving Status. | - “%value = %obj.getIsCameraMoving()” | Retrieves whether the current camera is moving. Note that moving means that not only does the camera window change but the zoom may as well. | |
| startCameraShake() | Start Camera Shake. | (shakeMagnitude, time) “%obj.startCameraShake( 30, 2 )” | shakeMagnitude – Camera Shake Magnitude. This value is in pixels, not world-units and controls how severe the camera-shaking is. time – Time that the shake will be in effect. The shake will decrease to nothing over this period so you won’t get the full shake during this whole time. NOTE:- Because the “shakeMagnitude” unit is pixels, you’ll get the same shaking effect independent of the window-size/zoom used. | |
| stopCameraShake() | Stop Camera Shake. | - “%obj.stopCameraShake()” | Instantly stops any camera shake that’s currently running (if any). | |
| mount() | Mounts Camera onto a specified object. | (t2dSceneObject, [offsetX / offsetY], [mountForce], [sendToMount?]) “%obj.mount( mySceneObject, “1 1”, 0, true )” | t2dSceneObject – Object to mount the camera onto. The camera will be centered on the mount-point which is a specified offset from the objects pivot-point. offsetX/Y – See t2dSceneObject::mount()::offsetX/Y mountForce – See t2dSceneObject::mount()::mountForce sendToMount? – See t2dSceneObject::mount()::sendToMount? | |
| dismount() | Dismounts Camera from object. | - “%obj.dismount()” | Dismounts the camera from any mounted object. | |
| getIsCameraMounted() | Get Current Camera Mounted Status. | - “%value = %obj.getIsCameraMounted()” | Retrieves whether the current camera is mounted. | |
| setRenderMasks() | Sets the layer/group mask which control what is rendered. | (groupMask, layerMask) “%obj.setRenderMasks( BIT(0) | BIT(1), BIT(0) )” | groupMask – Specifies which group(s) to render. layerMask – Specifies which layer(s) to render. NOTE:- As with nearly all properties within T2D, these values can be changed at any time. | |
| setViewLimitOn() | Sets the area limit the camera can view. | (minX / minY / maxX / maxY) “%obj.setViewLimitOn( “-50 -37.5 50 37.5” )” | minX/minY/maxX/maxY – Area which the camera is allowed to view. NOTE:- When the view limit is on, the camera will not be allowed to view outside this area, whether the camera is mounted, zoomed, moved, interpolating, whatever. | |
| setViewLimitOff() | Sets the area limit off. | - “%obj.setViewLimitOff()” | Turns off the view limit (see “setViewLimitOn()” below) | |
| setDebugBanner() | Set Debug Font/Size/textColor/backgroundColor. | (fontName, fontSize, textR/G/B/[A]$, backgroundR/G/B/[A]$) “%obj.setDebugBanner( “arial”, 12, “1 0.5 0 1”, “0 0.5 1 1” )” | fontName – Sets the font to use for the debug banner. fontSize – Sets the font-size to use for the debug banner. textRGB[A] – Sets the text color for the debug banner (normalised values 0.0 -> 1.0) backgroundRGBA – Sets the text-background color for the debug banner. NOTE:- The colors above are specified as a string and contain either 3 or optionally 4 component color values separated with spaces. | |
| setLockMouse() | Set the window mouse-lock status. | (lockStatus?) “%obj.setLockMouse( false )” | lockStatus? – Sets whether the mouse is locked to the t2dSceneWindow. NOTE:- This ensures that events such as “mouseDown” that happen within the window have their opposite event, in this case “mouseUp”, sent to this window even if the mouse is outside the window when it happens. With this option off, the “mouseUp” event can be sent to another window. All relevant mouse events use this option. This option defaults to OFF | |
| setMousePosition() | Sets the current mouse position. | (worldMousePosition) “%objj.setMousePosition(“30 -20”)” | Sets the current mouse position (in world-units). If the scene-window isn’t attached to a scenegraph then this call is ignored and a console warning issued. | |
| setUseWindowMouseEvents() | Sets whether mouse-events are monitored by the scene-window. | (mouseStatus?) “%obj.setUseWindowMouseEvents( true )” | mouseStatus? – Sets whether mouse-events are monitored by the scene-window (see t2dSceneWindow::MouseCallbacks below). NOTE:- This option defaults to ON. | |
| setUseObjectMouseEvents() | Sets whether mouse-events are monitored by the scene-object(s). | (mouseStatus?) “%obj.setUseObjectMouseEvents( true )” | mouseStatus? – Sets whether mouse-events are monitored by the scene-object(s) (see t2dSceneObject::MouseCallbacks). NOTE:- This option defaults to OFF. It is important to note that the primary reason this option defaults to OFF it because it can potentially be very computationally expensive as the function “t2dSceneGraph::pickPoint()” is used to determine which objects coincide with the mouse-event. Also note that the object needs to have its “t2dSceneObject::setUseMouseEvents()” option set to ON. | |
| setObjectMouseEventFilter() | Sets a filter for the scene-object(s) that are notified of mouse-events. | (groupMask , layerMask, [useInvisible?]) “%obj.ObjectMouseEventFilter(BIT(0),BIT(1),false)” | groupMask – Specifies which object-group(s) to allow. layerMask – Specifies which object-layer(s) to allow. useInvisible – Specifies if invisible objects are allowed. NOTE:- The defaults here are all groups/layers and not using invisible objects. | |
| getUseWindowMouseEvents() | Gets whether mouse-events are monitored by the scene-window. | - “%status = %obj.getUseWindowMouseEvents()” | Retrieves whether mouse-events are monitored by the scene-window. | |
| getUseObjectMouseEvents() | Gets whether mouse-events are monitored by the scene-object(s). | - “%status = %obj.getUseObjectMouseEvents()” | Retrieves whether mouse-events are monitored by the scene-objects(s). NOTE:- See “t2dSceneObject::setUseMouseEvents()”. | |
| getMousePosition() | Gets the current mouse position. | - “%position = %obj.getMousePosition()” | Retrives the current mouse position (in world-units) even if the mouse isn’t over the scene-window. If the scene-window isn’t attached to a scenegraph then the coordinates used are in scene-window local coordinates. | |
| getLockMouse() | Gets the window mouse-lock status. | - “%status = %obj.getLockMouse()” | Retrieves the mouse-lock status for the t2dSceneWindow. | |
| getWindowExtents() | Get Current Window Extents. | - “%value = %obj.getWindowExtents()” | Retrieves the window extents (x /y / width / height ). NOTE:- These extents relate to the t2dSceneWindow GUI control itself, not the camera. These are in pixel units and relate to the controls position relative to its parent. | |
| getIsWindowPoint() | Checks if world-position is inside GUI window. | (worldX / worldY) “%value = %obj.getIsWorldPoint( “30 20” )” | Retrieves whether the world-position is within the GUI window. NOTE:- The GUI window is the t2dSceneWindow GUI Object, note the canvas window. | |
| getCanvasPoint() | Get Canvas-Point from Window-Point. | (windowX / windowY) “%value = %obj.getCanvasPoint( “250 100” )” | windowX/Y – Window Position (X/Y). NOTE:- We convert the GUI Window position (pixels) into a Canvas-position (pixels). | |
| getWindowPoint() | Get Window-Point from World-Point. | (worldX / worldY) “%value = %obj.getWindowPoint( “25 10” )” | worldX/Y – World Position (X/Y). NOTE:- We convert the world-position into a GUI Window position (pixels). It is important to note that you can specify world-coordinates that result in window coordinates that are both sub-pixel (fractional) and are outside the GUI region. This can be extremely useful in many circumstances. This is the opposite functionality of “getWorldPoint()”. | |
| getWorldPoint() | Get World-Point from Window-Point. | (windowX / windowY) “%value = %obj.getWorldPoint( “100 50” )” | windowX/Y – Window Position (X/Y). NOTE:- We convert the GUI Window position (pixels) into a world-position. It is important to note that you can specify window coordinates that are both sub-pixel (fractional) and are outside the GUI region. This can be extremely useful in many circumstances. This is the opposite functionality of “getWindowPoint()”. | |
| Callbacks | ||||
| Name | Synopsis | Parameter(s) | Detail | |
| onExtentChange() | Window Change Extent Event | (this, newExtent$) | this – Current Object (self). newExtent$ - New Extents (X / Y / W / H) in screen pixels. | |
| onMouseDown() | Left Mouse Button Pressed. | (this, modifier, worldPosition$, mouseClicks) | this – Current Object (self) modifier – Alt/Ctrl/Shift Key modifiers Used. worldPosition$ – Position in world-coordinates. mouseClicks – Number of mouse clicks used. NOTE:- The coordinates returned have been converted to world-coordinates and are automatically adjusted for the camera move/zoom. You can use these coordinates directly with all other T2D objects and also use it for object picking (seeing pickPoint). | |
| onMouseUp() | Left Mouse Button Released. | (this, modifier, worldPosition$, mouseClicks) | (See “onMouseDown()”). | |
| onMouseMove() | Mouse has been moved. | (this, modifier, worldPosition$, mouseClicks) | (See “onMouseDown()”). | |
| onMouseDragged() | Mouse has been dragged (Left Button) | (this, modifier, worldPosition$, mouseClicks) | (See “onMouseDown()”). | |
| onMouseEnter() | Mouse has entered the t2dSceneWindow. | (this, modifier, worldPosition$, mouseClicks) | (See “onMouseDown()”). | |
| onMouseLeave() | Mouse has left the t2dSceneWindow | (this, modifier, worldPosition$, mouseClicks) | (See “onMouseDown()”). | |
| onRightMouseDown() | Right Mouse Button Pressed. | (this, modifier, worldPosition$, mouseClicks) | (See “onMouseDown()”). | |
| onRightMouseUp() | Right Mouse Button Released. | (this, modifier, worldPosition$, mouseClicks) | (See “onMouseDown()”). | |
| onRightMouseDragged() | Mouse has been dragged (Right Button) | (this, modifier, worldPosition$, mouseClicks) | (See “onMouseDown()”). | |
| Fields | ||||
| Name | Synopsis | Type | Detail | |
| lockMouse | Lock mouse to window. | (bool?) | Locks mouse to the window. (See “lockMouse()”). | |
| useWindowMouseEvents | Sets whether mouse-events are monitored by the scene-window. | (bool?) | See “setUseWindowMouseEvents()” for more detail. | |
| useObjectMouseEvents | Sets whether mouse-events are monitored by the scene-object(s). | (bool?) | See “setUseObjectMouseEvents()” for more detail. | |
[edit] t2dShape3D(t2dSceneObject)An object which allows you to display Torque 3D Game-Engine .DTS Shapes. | |||||
| Function | Synopsis | Parameter(s) & Example Format | Detail | ||
| setShape() | Sets the DTS shape-file to render | ( dtsShapeFile$ ) “%obj.setShape("~/client/myshape.dts”)” | DTSShapeFile – DTS Shape File to use. All associated files must be in the same directory. | ||
| setSkin() | Sets the Shape Skin | ( skinSet$, skinName$ ) “%obj.setSkin("highres","blueskin" )” | skinSet – Name of skin-set. skinName – Name of Skin. | ||
| setDetailLevel() | Sets the current Level of Detail | ( int detailLevel, [intraLevel] ) "%obj.setDetailLevel( 3, 0.0 ) | detailLevel – The integer detail level starting at zero. Detail-levels are fixed within the DTS shape, they are not automatically calculated (Default is zero). intraLevel – The inter-detail level from detailLevel to the next level in the range 0.0 to 1.0 (Default is zero). | ||
| setTriggerActive() | Set Trigger Active | ( status? ) "%obj.setTriggerActive( true )" | status? – Specifies whether to check the trigger-channels for events (default is false). NOTE:- When this is enabled and an animation trigger event occurs, the shape will produce an "onAnimationTrigger()" calback (see below). | ||
| playAnimation() | Play Animation | ( animationName$, [startTime], [transitionTime] ) “%obj.playAnimation("idle", 0, 3.0 )" | animationName – Name of animation (as specified in TSShapeConstructor). startTime – Time position to start new animation (default is zero). transitionTime – Time to transition from old animation to new animation (default is zero). NOTE:- This plays the animation alias name specifed in the TSShapeConstructor. | ||
| playAnimationSequence() | Play Animation Sequence | ( sequence, startTime, transitionTime ) “%obj.playAnimationSequence(0, 0, 3.0 )" | sequence – Sequence Number (as specified in TSShapeConstructor). startTime – Time position to start new animation (default is zero). transitionTime – Time to transition from old animation to new animation (default is zero). NOTE:- This plays the animation sequence number specifed in the TSShapeConstructor. | ||
| setTimeScale() | Set Animation Time Scale | ( timeScale ) "%obj.setTimeScale( 1.0 )" | timeScale – Animation Timescale (default is 1.0). NOTE:- This is a time-multiplier. A value of 2.0 results in an animation at twice the speed. | ||
| setShapeOffset() | Set Shape Offset | ( x / y / z ) "%obj.setShapeOffset("-10 20 -15")" | x/y/z – Three-axis angular velocity. NOTE:- X/Y axis identical to standard T2D axis. Z axis goes 'into' the screen. This option is used to offset the center of rotation. | ||
| setShapeScale() | Set Shape Scale | ( x [/ y / z] ) "%obj.setShapescale("1 2 1")" | x/y/z – Three-axis scale. NOTE:- X/Y axis identical to standard T2D axis. Z axis goes 'into' the screen. This option is used to scale the shape. If only a single value is passed, the shape is scaled uniformly. | ||
| setShapeRotation() | Set Shape Rotation | ( x / y / z ) "%obj.setShapeRotation("90 45 30")" | x/y/z – Three-axis absolute rotation. NOTE:- X/Y axis identical to standard T2D axis. Z axis goes 'into' the screen. | ||
| setShapeAngularVelocity() | Set Shape Angular Velocity | ( x / y / z ) "%obj.setShapeAngularVelocity("0 90 0")" | x/y/z – Three-axis angular velocity. NOTE:- X/Y axis identical to standard T2D axis. Z axis goes 'into' the screen. This option is used to auto-rotate the shape. It is important to note that the object window doesn't not rotate, only the shape within it. | ||
| getDetailLevelCount() | Gets the Level of Detail Count | - "%value = %obj.getDetailLevelCount()" | Retrieves the number of available levels of detail. | ||
| getCurrentDetailLevel() | Gets the current Level of Detail | - "%value = %obj.getCurrentDetailLevel()" | Retrieves the current level of detail as specified with "setDetailLevel()". | ||
| getCurrentIntraDetailLevel() | Gets the current Intra Level of Detail | - "%value = %obj.getCurrentIntraDetailLevel()" | Retrieves the current intra level of detail as specified with "setDetailLevel()". | ||
| Callbacks | |||||
| Name | Synopsis | Parameter(s) | Detail | ||
| onAnimationTrigger() | Signals a trigger-event as occurred on one of 32 trigger channels. | (this, triggerChannel) | this – Current Object (self)! triggerChannel – Trigger Channel | ||
[edit] t2dSceneObjectDatablock(t2dBaseDatablock)Datablock Object for Configuring t2dSceneObject-Based Object(s) | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| enabled | bool (flag) | Enabled Status. | setEnabled() |
| lifetime | float | Lifetime | setLifetime() |
| visible | bool (flag) | Visible Status. | setVisible() |
| position | $ “x y” | World Position | setPosition() |
| size | $ (width height) | Local Dimensions | setSize() |
| group | integer (0-31) | Group. | setGraphGroup() |
| layer | integer (0-31) | Rendering Layer. | setLayer() |
| worldLimitMode | $ “mode” | World Limit Mode. | setWorldLimit() |
| worldLimitMin | $ “x y” | World Limit Minimum Point. | setWorldLimit() |
| worldLimitMax | $ “x y” | World Limit Maximum Point. | setWorldLimit() |
| worldLimitCallback | bool (flag) | World Limit Callback Flag. | setWorldLimit() |
| rotation | float (degrees) | Rotation | setRotation() |
| autoRotation | float (degrees/sec) | Automatic Rotation Angular-Velocity | setMountRotation() |
| mountRotation | float (degrees) | Mount-System Absolute Rotation | setMountRotation() |
| autoMountRotation | float (degrees/sec) | Automatic Mount-System Angular-Speed. | setAutoMountRotation() |
| minLinearVelocity | float | Minimum Linear Velocity. | setMinLinearVelocity() |
| maxLinearVelocity | float | Maximum Linear Velocity. | setMaxLinearVelocity() |
| minAngularVelocity | float | Minimum Angular Velocity. | setMinAngularVelocity() |
| maxAngularVelocity | float | Maximum Angular Velocity. | setMaxAngularVelocity() |
| constantForce | $ “x y” | Constant, Continuous Force Vector. | setConstantForce() / setConstantForcePolar() |
| graviticConstantForce | bool (flag) | Constant Gravitic Force Status. | setConstantForce() / setConstantForcePolar() |
| collisionDetectionMode | $ “FULL”, “CIRCLE”, “POLY” & “CUSTOM”. | Collision Detection Mode. | setCollisionDetection() |
| collisionResponseMode | $ “RIGID”, “BOUNCE”, “CLAMP”, “STICKY”, “KILL” & “CUSTOM”. | Collision Detection Mode. | setCollisionDetection() |
| collisionActiveSend | bool (flag) | Collision Active Send Status. | setCollisionActive() |
| collisionActiveReceive | bool (flag) | Collision Active Receive Status. | setCollisionActive () |
| collisionCallback | bool (flag) | Collision Callback Status. | setCollisionCallback() |
| collisionGroupMask | integer-mask (bits 0-31) | Collision Group Mask. | setCollisionMasks() |
| collisionLayerMask | integer-mask (bits 0-31) | Collision Layer Mask. | setCollisionMasks() |
| collisionPhysicsSend | bool (flag) | Collision Physics Send Status. | setCollisionPhysics() |
| collisionPhysicsReceive | bool (flag) | Collision Physics Receive Status. | setCollisionPhysics() |
| collisionPolyScale | $ “width height” | Collision Polygon Scale. | setCollisionPolyScale() |
| collisionCircleScale | $ “width height” | Collision Circle Scale. | setCollisionCircleScale() |
| collisionCircleSuperscribed | bool (flag) | Collision Circle Superscribed Mode. | setCollisionCircleSuperscribed() |
| collisionSuppress | bool (flag) | Collision Suppress Status. | setCollisionSuppress() |
| blending | bool (flag) | Rendering Blending Status. | setBlending() |
| blendColor | $ “r g b a” | Rendering Blend Color. | setBlendColor() or setBlendColour() |
| srcBlendFactor | $ “factor” | Source Blending Factor. | setBlending() |
| dstBlendFactor | $ “factor” | Destination Blending Factor. | setBlending() |
| flipX | bool (flag) | Flip Mounts in the X-Axis | setFlip() |
| flipY | bool (flag) | Flip Mounts in the Y-Axis | setFlip() |
| useMouseEvents | bool (flag) | Use Mouse Events from Scene-Window? | setUseMouseEvents() |
[edit] t2dCollisionMaterialDatablock(t2dBaseDatablock)Datablock Object for Configuring Collision Materials for t2dSceneObject-Based Object(s) | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| immovable | bool | immovable? | t2dSceneObject::setImmovable() |
| automassinertia | bool | auto mass/inertia calculations? | t2dSceneObject::setAutoMassInertia() |
| density | float | density | t2dSceneObject::setDensity() |
| mass | float | density | t2dSceneObject::setMass() |
| inertialmoment | float | density | t2dSceneObject::setInertialMoment() |
| friction | float | friction | t2dSceneObject::setFriction() |
| restitution | float | restitution | t2dSceneObject::setRestitution() |
| damping | float | damping | t2dSceneObject::setDamping() |
| forceScale | float | force scale | t2dSceneObject::setForceScale() |
[edit] t2dScrollerDatablock(t2dBaseDatablock)Datablock Object for Configuring t2dScroller-Based Object(s) | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| imageMap | $ “imageMap Datablock” | Image-Map Datablock used to Render. | setImageMap() |
| repeatX | float | Texture-Repeats in the X-Axis. | setRepeat() |
| repeatY | float | Texture-Repeats in the Y-Axis. | setRepeat() |
| scrollX | float | Scroll-Speed in the X-Axis (texture-width/sec) | setScrollMode() |
| scrollY | float | Scroll-Speed in the Y-Axis (texture-height/sec) | setScrollMode() |
[edit] t2dStaticSpriteDatablock(t2dBaseDatablock)Datablock Object for Configuring t2dStaticSprite-Based Object(s) | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| imageMap | $ “imageMap Datablock” | Image-Map Datablock used to Render. | setImageMap() |
| frame | integer | Image-Map Frame used to Render. | setFrame() |
[edit] t2dImageMapDatablock(t2dBaseDatablock)Datablock Object for Defining Static Imagery. | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| imageMode | $ “image-mode” | Frame Image Mode. | “FULL” – Whole of image is used to capture a single-frame only. “KEY” – Uses the top-left pixel as a color-key which separates frames. Frame capture starts at the top-left and works right/down. Useful when defining different size frames within a single image. “CELL” – Uses the “cellWidth/cellHeight” parameters to define a grid within the graphic. The system will parse the whole width/height of the graphic using the specified “cellWidth/cellHeight”. Additionally, “cellCountX/cellCountY” can be used to specify the required number of cells used in each axis. This can be useful when the graphic isn’t completely filled with cells. This mode is very useful for imagery where the graphics are all packed together with no spaces such as tilemap imagery. “LINK” – Uses the “linkImageMaps” parameters to link together multiple image-maps that can then be referred to using a single image-map. This mode is useful when combining various frames (of potentially different actions) such as player moving left, right or jumping if they’ve been drawn in separate images. Preferrably, these images should be manually combined into a single image but this option allows you to do it automatically. Note that “imageName” is not required in this mode! |
| imageName | $ “path/image” | Image Path/File to Use. | Image File to use for incoming frames. |
| filterMode | $ "mode" | GPU Filter Mode | "NONE" – No Filtering. "SMOOTH" – Bilinear Filtering (DEFAULT). NOTE:- No Filtering can result in highly pixellated imagery but doesn't suffer from filtering artifacts. Bilinear Filtering creates a smoother texturing but can lead to blurry imagery if magnified too much. Unfortunately, bilinear filtering can cause filtering artifacts with adjacent frames 'bleeding' into one another. This 'bleeding' can be corrected by using "filterPad" (see below). |
| filterPad | bool | GPU Filter Texel Padding | When using "bilinear filtering" mode e.g (filterMode = "smooth"), the graphics hardware can cause bleeding artifacts as it samples texels in adjacent frames. To combat this, you can create a border of texels that replicate the edges of each frame in your artwork. To make this easier, you can tell T2D to do this processing internally for you so that you don't need to alter your artwork. It is very important to note that T2D will not touch your artwork! Also, the frames themselves don't expand in size; they are simply surrounded by a border which stops the filter artifacts. NOTE:- If only a single frame is acquired, the filter-padding is automatically disabled. Filter-padding is off by default. |
| cellWidth | integer | Cell-Mode Cell-Width! | “Cell” mode only. Specifies each cells width. |
| cellHeight | integer | Cell-Mode Cell-Height! | “Cell” mode only. Specifies each cells height. |
| cellCountX | integer | Cell-Mode Cell X-Axis Count! | “Cell” mode only. Specifies the expected number of cells in the X-Axis. This field is optional; no specification results in T2D calculating how many cell-widths will fit in the source image, |
| cellCountY | integer | Cell-Mode Cell Y-Axis Count! | “Cell” mode only. Specifies the expected number of cells in the Y-Axis. This field is optional; no specification results in T2D calculating how many cell-heights will fit in the source image, |
| cellOffsetX | integer | Cell-Mode Cell X-Axis Pixel Offset! | “Cell” mode only. Specifies the pixel-offset in the X-Axis from the left to start extracting frames. This field is optional. |
| cellOffsetY | integer | Cell-Mode Cell Y-Axis Pixel Offset! | “Cell” mode only. Specifies the pixel-offset in the Y-Axis from the top to start extracting frames. This field is optional. |
| cellStrideX | integer | Cell-Mode Cell X-Axis Frame Stride! | “Cell” mode only. Specifies the frame-stride in the X-Axis from the left used to move to the next frame. This field is optional. |
| cellStrideY | integer | Cell-Mode Cell Y-Axis Frame Stride! | “Cell” mode only. Specifies the frame-stride in the Y-Axis from the top used to move to the next frame. This field is optional. |
| cellRowOrder | integer | Cell-Mode Cell Row-Order Option. | “Cell” mode only. Specifies whether frame extraction proceeds in a row-major or column-major order. This field is optional. |
| linkImageMaps | $ “image-map list” | List of Image-Maps to link together. | Must be used in “LINK” mode to specify which image-maps to link together. You must specify at least two valid image-maps here. |
| frameCount | integer | Expected Frame-Count Hint. | Can be optionally used in “KEY” or “CELL” modes to specify the number of expected frames. If the frames captured are not equal to this value then the image-map is aborted. This field is optional. |
| preferPerf | bool | Preference for Performance or Least-Waste. | Used to select whether the image-map should prefer performance or least-waste. NOTE:- The default is least waste. This field is optional. |
| Parameter | Type | Synopsis | Field Description / Function Reference |
| setFilterMode | Sets the Filter Mode | (filterMode) “%obj.setFilterMode()” | Sets the Filter Mode (see ‘filterMode’ above). |
| getFilterMode | Gets the Filter Mode | - “%value = %obj.getFilterMode()” | Returns the Filter Mode (see ‘filterMode’ above) - “NONE” or "SMOOTH" |
| getImageMapMode | Gets the ImageMap Mode | - “%value = %obj.getImageMapMode()” | Returns the imageMap Mode (see ‘mode’ above) - “FULL”, “CELL” or “KEY” |
| getSrcBitmapName | Gets the name of the source bitmap used by the imageMap. | - “%values = %obj.getSrcBitmapSize()” | Returns the name of the bitmap used by the imageMap. |
| getSrcBitmapSize | Gets the size of the source bitmap used by the imageMap. | - “%values = %obj.getSrcBitmapSize()” | Returns the size of the bitmap used by the imageMap. (width / height) NOTE:- The bitmap may not be the final dimensions used by the imageMap as the imageMap can pack the frames into multiple textures if required. |
| getFrameCount | Gets the number of frames acquired. | - “%value = %obj.getFrameCount()” | This is the total number frames acquired for the current imageMap mode. |
| getFrameSize | Gets the size of a selected frame. | (int frame) “%value = %obj.getFrameSize(0)” | frame – Selected frame (zero-based). NOTE:- Returns the size (in pixels) of the frame region within the imageMap bitmap (W / H). |
| getFrameTexturePage | Gets the texture page that the frame is located. | (int frame) “%value = %obj.getFrameTexturePage(0)” | frame – Selected frame (zero-based). NOTE:- Returns the texture-page that the frame is located. |
| getTexturePageCount | Gets the number of textures used. | - “%value = %obj.getTexturePageCount()” | This is the total number textures created by the imageMap. NOTE:- T2D will generate the appropriate number of textures needed to pack all frames into hardware-compatible sized textures. |
| getTexturePageSize | Gets the size of a selected texture-page. | (int texturePage) “%value = %obj.getTexturePageSize(0)” | frame – Selected texture-page (zero-based). NOTE:- Returns the size (in pixels) of the specified texture-page (W / H). |
| getTexturePageFrameCount | Gets the number of frames on a specific texture-page. | (int texturePage) “%value = %obj.getTexturePageFrameCount(0)” | frame – Selected texture-page (zero-based). NOTE:- Returns the number of frames on the specified texture-page. |
| CALLBACKS | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| onImageMapPackStart | Frame Packing has started. | (imageMapName$) | imageMapName – Name of ImageMap. NOTE:- This is called prior to the imageMap packing frames. |
| onImageMapPackEnd | Frame Packing has ended. | (imageMapName$,) | imageMapName – Name of ImageMap. NOTE:- This is called after the imageMap has finished packing frames. If an error occurs you will get an additional callback "onError" (see below) which provides more details. |
| onImageMapError | There was an error compiling the imageMap. | (imageMapName$, errorNum, errorDesc$) | imageMapName – Name of ImageMap. errorNum – The numeric error that has occurred. This will errorDesc$ – Textual description of the error that occurred. NOTE:- This error will be automatically echoed to the console if the system variable “$pref::T2D::imageMapEchoErrors” is active. |
| NOTES | |||
| The above t2dImageMapDatablock callbacks are not called via the t2dImageMapDatablock namespace! In other words, you don't define the callbacks as "function t2dDatablock::onImageMapPackStart()" but rather "function onImageMapPackStart()". It is very important to note that this type of callback doesn't pass "%this", rather just the name of the respective datablock. This reason for this is complex but is basically related to the fact that the imageMap is not a registered part of the simulation until the packing is complete. Any failure results in the datablock not being defined! If you can't find your datablock, the chances are that it stopped with an error! Always check. See the following "T2D System Variables" for related options:
| |||
[edit] t2dAnimatedSpriteDatablock(t2dBaseDatablock)Datablock Object for Configuring t2dAnimatedSprite-Based Object(s) | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| startAnimation | $ “Animation Datablock” | Initial Animation Datablock used to Render. | playAnimation() |
[edit] t2dAnimationDatablock(t2dBaseDatablock)Datablock Object for Defining Animated Imagery. | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| imageMap | $ “imageMap Datablock” | Image-Map Datablock used for Animation. | ImageMap Datablock Object Name to use. |
| animationFrames | $ “frame#0 frame#1 frame#2 …” | Animation Frames from Image-Map for Animation. | Animation frames from imageMap to use e.g. “0 3 5 4 2 1 0” etc. NOTE:- If this is left blank then ALL frames from the image-map are used. |
| animationTime | float (all-frames/sec) | Animation Cycle Time. | Time to play all frames for animation (not FPS). |
| animationCycle | bool (flag) | Animation Cycle Status. | Whether the animation plays once or continually repeats. |
| randomStart | bool (flag) | Random Animation Frame Start. | Whether the animation begins at a random logical frame specified within “animationFrames” |
| startFrame | int | Frame Index to start animation. | Specifies which frame-index to start the animation at. The frame-index is NOT the frame numbers. For instance, using the following animation frames "6 3 4 2 7 9", specifying the "startFrame" at "1" starts the sequence at index#1 which is frame number "3". The above animation frames have indexes from 0 to 5 which. Note that if you specify "randomStart" then this field is ignored. |
[edit] t2dChunkedSpriteDatablock(t2dBaseDatablock)Datablock Object for Configuring t2dChunkedSprite-Based Object(s) | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| chunkedImage | $ “chunkedImage Datablock” | Chunked-Image Datablock used to Render. | setChunkedImage() |
| repeatX | int | Texture-Repeats in the X-Axis. | setRepeat() NOTE:- Unlike repeat in t2dScroller, repeating is not specified in floats but ints and is simply the number of times the chunked-images is draw within the objects area. |
| repeatY | int | Texture-Repeats in the Y-Axis. | setRepeat() NOTE:- See above. |
[edit] t2dChunkedImageDatablock(t2dBaseDatablock)Datablock Object for Defining Chunked, Static Imagery. | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| textureName | $ “path/texture” | Texture Path/File to Use. | File Texture to use. |
[edit] t2dTileMapDatablock(t2dBaseDatablock)Datablock Object for Configuring t2dTileMap-Based Object(s) | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| tilemapFile | $ “path/filename” | TileMap File. | loadTileMapDataBlock() |
[edit] t2dSceneGraphDatablock(t2dBaseDatablock)Datablock Object for Configuring t2dAnimatedSprite-Based Object(s) | |||
| Parameter | Type | Synopsis | Field Description / Function Reference |
| containerBinSize | float | Container-System Bin Size! | t2dSceneGraph::initialise() |
| containerBinCount | integer | Container-System Bin Count! | t2dSceneGraph::initialise() |
| useLayerSorting | bool (flag) | Use Sub-Layer Render Sorting Status. | t2dSceneGraph::initialise() |
| lastInFrontSorting | bool (flag) | Last In-Front Sorting Status. | t2dSceneGraph::initialise() |
| scenePhysicsLimitFPS | float | Physics-Simulation FPS Limit. | t2dSceneGraph:: setScenePhysicsLimitFPS() |
| scenePhysicsTargetFPS | float | Physics-Simulation FPS Target. | t2dSceneGraph:: setScenePhysicsTargetFPS() |
| scenePhysicsMaxIterations | integer | Physics-Simulation Maximum Iterations. | t2dSceneGraph:: setScenePhysicsMaxIterations() |
[edit] Particle Effect Time-Graph FieldsFields that control t2dParticleEffect-Based object(s). | |||||
| Graph Name | Synopsis | Max-Time | Min-Value | Max-Value | Default-Value |
| particlelife_scale | Scales Emitter(s) Particle Lifes. | 1000.0 | 0.0 | 100.0 | 1.0 |
| quantity_scale | Scales Emitter(s) Particle Quantities. | 1000.0 | 0.0 | 100.0 | 1.0 |
| sizex_scale | Scales Emitter(s) Particle Size-X Components. (Controls both Axis if particle “Fixed-Aspect” is used) | 1000.0 | 0.0 | 100.0 | 1.0 |
| sizey_scale | Scales Emitter(s) Particle Size-Y Components. (Not used if particle “Fixed-Aspect” is used) | 1000.0 | 0.0 | 100.0 | 1.0 |
| speed_scale | Scales Emitter(s) Particle Speeds. | 1000.0 | 0.0 | 100.0 | 1.0 |
| spin_scale | Scales Emitter(s) Particle Spin. | 1000.0 | -100.0 | 100.0 | 1.0 |
| fixedforce_scale | Scales Emitter(s) Particle Fixed-Force. | 1000.0 | -100.0 | 100.0 | 1.0 |
| randommotion_scale | Scales Emitter(s) Particle Random-Motion. | 1000.0 | 0.0 | 100.0 | 1.0 |
| visibility_scale | Scales Emitter(s) Particle Visibility. | 1000.0 | 0.0 | 100.0 | 1.0 |
| emissionforce_base | Effect Emission Force Base (Only used by emitters if they choose not to use their own). | 1000.0 | -1000.0 | 1000.0 | 5.0 |
| emissionforce_var | Effect Emission Force Variation (Only used by emitters if they choose not to use their own). | 1000.0 | 0.0 | 2000.0 | 0.0 |
| emissionangle_base | Effect Emission Angle Base (Only used by emitters if they choose not to use their own). | 1000.0 | -3600.0 | 3600.0 | 0.0 |
| emissionangle_var | Effect Emission Angle Variation (Only used by emitters if they choose not to use their own). | 1000.0 | 0.0 | 720.0 | 0.0 |
| emissionarc_base | Effect Emission Arc Base (Only used by emitters if they choose not to use their own). | 1000.0 | 0.0 | 360.0 | 0.0 |
| emissionarc_var | Effect Emission Arc Variation (Only used by emitters if they choose not to use their own). | 1000.0 | 0.0 | 720.0 | 0.0 |
[edit] Particle Emitter Time-Graph FieldsFields that control t2dParticleEmitter-Based object(s). | |||||
| Graph Name | Synopsis | Max-Time | Min-Value | Max-Value | Default-Value |
| particlelife_base | Particle Life at Emission Time. | 1000.0 | 0.0 | 1000.0 | 2.0 |
| particlelife_var | Particle Life-Variation at Emission Time. | 1000.0 | 0.0 | 2000.0 | 0.0 |
| quantity_base | Particle Quantity at Emission Time. | 1000.0 | 0.0 | 1000.0 | 10.0 |
| quantity_var | Particle Quantity-Variation at Emission Time. | 1000.0 | 0.0 | 2000.0 | 0.0 |
| sizex_base | Particle Size-X at Emission Time. (Controls both Axis if particle “Fixed-Aspect” is used) | 1000.0 | 0.0 | 1000.0 | 32.0 |
| sizex_var | Particle Size-X-Variation at Emission Time. (Controls both Axis if particle “Fixed-Aspect” is used) | 1000.0 | 0.0 | 2000.0 | 0.0 |
| sizex_life | Particle Size-X Scale in Particle Time. (Controls both Axis if particle “Fixed-Aspect” is used) | 1.0 | -100.0 | 100.0 | 1.0 |
| sizey_base | Particle Size-Y at Emission Time. (Not used if particle “Fixed-Aspect” is used) | 1000.0 | 0.0 | 1000.0 | 32.0 |
| sizey_var | Particle Size-Y-Variation at Emission Time. (Not used if particle “Fixed-Aspect” is used) | 1000.0 | 0.0 | 2000.0 | 0.0 |
| sizey_life | Particle Size-Y Scale in Particle Time. (Not used if particle “Fixed-Aspect” is used) | 1.0 | -100.0 | 100.0 | 1.0 |
| speed_base | Particle Speed at Emission Time. | 1000.0 | 0.0 | 1000.0 | 10.0 |
| speed_var | Particle Speed at Emission Time. | 1000.0 | 0.0 | 2000.0 | 0.0 |
| speed_life | Particle Speed Scale in Particle Time. | 1.0 | -100.0 | 100.0 | 1.0 |
| spin_base | Particle Spin at Emission Time. | 1000.0 | -3600.0 | 3600.0 | 0.0 |
| spin_var | Particle Spin at Emission Time. | 1000.0 | 0.0 | 2000.0 | 0.0 |
| spin_life | Particle Spin Scale in Particle Time. | 1.0 | -100.0 | 100.0 | 1.0 |
| fixedforce_base | Particle Fixed-Force at Emission Time. | 1000.0 | -1000.0 | 1000.0 | 0.0 |
| fixedforce_var | Particle Fixed-Force at Emission Time. | 1000.0 | 0.0 | 2000.0 | 0.0 |
| fixedforce_life | Particle Fixed-Force Scale in Particle Time. | 1.0 | -100.0 | 100.0 | 1.0 |
| randommotion_base | Particle Random-Motion at Emission Time. | 1000.0 | 0.0 | 1000.0 | 0.0 |
| randommotion_var | Particle Random-Motion at Emission Time. | 1000.0 | 0.0 | 2000.0 | 0.0 |
| randommotion_life | Particle Random-Motion Scale in Particle Time. | 1.0 | -100.0 | 100.0 | 1.0 |
| emissionforce_base | Particle Emission-Force at Emission Time (Only used by emitters if they choose not to use their own). | 1000.0 | -1000.0 | 1000.0 | 5.0 |
| emissionforce_var | Particle Emission-Force at Emission Time (Only used by emitters if they choose not to use their own). | 1000.0 | 0.0 | 2000.0 | 0.0 |
| emissionangle_base | Particle Emission-Angle at Emission Time (Only used by emitters if they choose not to use their own). | 1000.0 | -3600.0 | 3600.0 | 0.0 |
| emissionangle_var | Particle Emission-Angle at Emission Time (Only used by emitters if they choose not to use their own). | 1000.0 | 0.0 | 720.0 | 0.0 |
| emissionarc_base | Particle Emission-Arc at Emission Time (Only used by emitters if they choose not to use their own). | 1000.0 | 0.0 | 360.0 | 360.0 |
| emissionarc_var | Particle Emission-Arc at Emission Time (Only used by emitters if they choose not to use their own). | 1000.0 | 0.0 | 720.0 | 0.0 |
| red_life | Particle Red-Channel in Particle Time (Unlike other “_life” graphs; this is absolute and not scaled). | 1.0 | 0.0 | 1.0 | 1.0 |
| green_life | Particle Green-Channel in Particle Time (Unlike other “_life” graphs; this is absolute and not scaled). | 1.0 | 0.0 | 1.0 | 1.0 |
| blue_life | Particle Blue-Channel in Particle Time (Unlike other “_life” graphs; this is absolute and not scaled). | 1.0 | 0.0 | 1.0 | 1.0 |
| visibility_life | Particle Alpha-Channel in Particle Time (Unlike other “_life” graphs; this is absolute and not scaled). | 1.0 | 0.0 | 1.0 | 1.0 |
[edit] Debug Modes | |
| BIT#0 – Statistics Debug Banner. | Shows the debug-banner which shows the following information:- “ScnTme” (Scene Time); “ScnScl” (Scene Time-Scale); “FPS” (Frames Per-Second); “TotObj” (Total Objects in Scene); “BinDen” (Bin Density – Not Active!); “CamQue” (Camera Queue Size); “X-Min” (MinX Position for View); “Y-Min” (MinY Position for View); “Y-Max” (MaxX Position for View); “Y-Max” (MaxY Position for View); “Zoom” (Current Zoom); “PotRen” (Potential Object Renders); “ActRen” (Actual Object Renders); “RenHit” (Render Hit Percentage); “Sorted” (Objects Sorted for Render); “ParAvl” (Particles Available); “ParUse” (Particles Used); “PotCol” (Potential Collisions); “ActCol” (Actual Collisions); “ColHit” (Collision Hit Percentage); **Only shown in update windows** |
| BIT#1 – Object Bounding/Collision/Clipping-Boxes. | Show, in green, the object clipping AABB, collision AABB and trivial clipping rectangles. |
| BIT#2 – Object Mount-Nodes. | Shows, in yellow, all the mount-nodes as crosses. |
| BIT#3 – Object Mount-Links (force tracking paths). | Shows, in red, force-lines for mounted objects. |
| BIT#4 – Object World-Limit. | Shows, in white, world-limit rectangles for objects for all limit-modes. |
| BIT#5 – Object Collision Bounds | Shows the object collision bounds. |
[edit] Miscellaneous Utility FunctionsProvides specific utility functions for T2D. | |||
| Function | Synopsis | Parameter(s) & Example Format | Detail |
| getT2DVersion() | Gets the T2D engine version. | - “%version = getT2DVersion()” | Retrieves the engine version in the following format “v1.0.2”. (with the correct version!). |
| getT2DDatablockSet() | Gets set which all datablocks are added to. | - “%datablock = getT2DDatablockSet()” | Retrieves a SimSet which all datablocks are added to by T2D. You can use this to enumerate all datablocks and their names. NOTE:-'''Do not add/remove objects from this set yourself! Doing so may cause undefined behaviour in T2D and its tools! |
| getT2DMaxTextureSize() | Gets the maximum hardware accelerated texture size. | - “%size = getT2DMaxTextureSize()” | Retrieves the maximum hardware accelerated texture size supported by the current hardware. T2D cannot handle frames that are greater in either dimension than this value. |
| bit | Converts a bit position into its decimal value. | ( bitPosition ) “%value = bit( 0 )" | bitPosition – Bit Position ( 0 to 31 ) Calculates the decimal value from a bit-position. This is used for functions that pass a "mask" value derived from bit values such as "setCollisionMasks()" etc. |
| bits | Converts a list of bit positions into a decimal value. | ( bitPositions$ ) “%value = bits("0 1 2 3 4 5" )" | bitPosition – Bit Positions ( each 0 to 31 ) Calculates the decimal value from a list of bit-positions. This is used for functions that pass a "mask" value derived from bit values such as "setCollisionMasks()" etc. |
| t2dBeginScene | Sets the default scene-graph. | ( t2dSceneGraph ) “t2dBeginScene( myScene );" … <create objects> … “t2dEndScene( );" | t2dSceneGraph – Scene Graph to set to default. This function allows you to specify a default scene-graph. Any object that doesn't explicitly specify a scenegraph when created will be added to this scene-graph. Use this command at the beginning of a section of objects. Use "t2dEndScene();" at the end of the section. Not using "t2dEndScene" will result in all subsequent objects (even those in different packages) being added to the specified scene. |
| t2dEndScene | Resets the default scene-graph. | - “t2dEndScene( );" | This function resets the default scene-graph. It should be used at the end of a section when creating objects. Not using "t2dEndScene" after issuing a "t2dStartScene" will result in all subsequent objects (even those in different packages) being added to the specified scene. |
| t2dAssert | Script Assertion. | ( condition, message ) “t2dAssert ( %count > 0, “invalid count!” );" | condition – True/False (expression in scripts) to assert e.g. check is true. message – Message to display if assertion fails. This function will halt the engine and display the selected message if the “condition” parameter is false. This function only works when used on DEBUG builds of the T2D executable. Release builds do nothing. |
| t2dAssertISV | Script Assertion (In Shipping Version) | ( condition, message ) “t2dAssertISV ( %count > 0, “invalid count!” );" | condition – True/False (expression in scripts) to assert e.g. check is true. message – Message to display if assertion fails. This function works identically to “t2dAssert” with the exception that it also works in Release builds of the T2D executable. You should only use this under the rare conditions where you know that continuing would bring about a crash therefore this call exits gracefully allow the user to report what message occurred. |
| t2dVectorAdd() | Adds two 2D vectors together. | ( t2dVector v1$, t2dVector v2$ ) %vector = “t2dVectorAdd( “20 5”, “10 8” )” | Returns v1 + v2 (vector). |
| t2dVectorSub() | Subtracts two 2D vectors. | ( t2dVector v1$, t2dVector v2$ ) %vector = “t2dVectorSub( “20 5”, “10 8” )” | Returns v1 – v2 (vector). |
| t2dVectorMult() | Multiplies two 2D vectors. | ( t2dVector v1$, t2dVector v2$ ) %vector = “t2dVectorMult( “20 10”, “5 3” )” | Returns v1 mult v2 (vector). **Not the dot product!** |
| t2dVectorDot() | Dot-Product of two 2D vectors. | ( t2dVector v1$, t2dVector v2$ ) %value = “t2dVectorDot( “20 0”, “20 100” )” | Returns Dot-Product of V1 and V2 (scalar). |
| t2dVectorDistance() | Distance between two 2D vectors. | ( t2dVector p1$, t2dVector p2$ ) %value = “t2dVectorDistance( “0 0”, “100 50” )” | Returns Distance between points p1 to p2 (scalar) |
| t2dAngleBetween() | Gets angle between two 2D points. | ( t2dVector v1$, t2dVector v2$ ) %angle = “t2dAngleBetween( “0 0”, “50 10” )” | Returns arctan(v2.x-v1.x,v1.y-v2.y) (scalar). |
| t2dVectorNormalise() | Normalises a 2D vector. | ( t2dVector v1$ ) %vector = “t2dVectorNormalise “20 5” )” | Returns Normalised v1 (vector) |
| t2dVectorScale() | Scales a 2D vector by a scalar. | ( t2dVector v1$, scale ) %vector = “t2dVectorScale( “20 5”, 2.5 )” | Returns v1 * scale (vector) |
| t2dVectorLength() | Length of 2D Vector. | ( t2dVector v1$ ) %value = “t2dVectorLength( “20 30” )” | Returns Length of V1 (scalar). |
| t2dRectNormalise2D() | Normalised Rectangle (two 2D vectors) | ( t2dVector v1$, t2dVector v2$ ) %vectors = “t2dRectNormalise( “20 5”, “10 8” )” | Returns Normalised Rectangle defined by v1 and v2. Returns normV1 and normV2 (two vectors) |
[edit] T2D Profiler Names(C++)(Uncomment “#define T2D_DEBUG_PROFILING” in “t2dUtility.h” and enabled profiler to activate) | |
| t2dSceneWindow_onRender | Window Rendering Time. |
| t2dSceneContainer_findObjects | Time Finding Objects in Container System. |
| t2dSceneContainer_findPotentialCollisions | Time Finding Objects for Potential Collisions (broad-phase). |
| t2dSceneGraph_updateScene | Time doing interval decomposition. |
| t2dSceneGraph_subUpdateScene | Time doing sub-interval scene-updates. |
| t2dSceneGraph_onUpdateSceneScript | Time calling “onUpdateScene” script-callback. |
| t2dSceneGraph_preIntegrate | Time Objects take doing the pre-integrate phase. |
| t2dSceneGraph_Integrate | Time Objects take doing the integrate phase. |
| t2dSceneGraph_layerSorting | Time spent sorting render-layers. |
| t2dSceneGraph_renderObjects | Time spent calling object render routines. |
| t2dSceneGraph_renderView | Time spent rendering the whole scene. |
| t2dSceneObject_processCollisionStatus | Time Processing Found Collisions. |
| t2dSceneObject_updateWorldLimit | Time Checking/Processing the World-Limits. |
| t2dSceneObject_calculateSpatials | Time Updating spatial information for scene objects. |
| t2dSceneObject_checkCollisionSend | Time Checking for send collisions. |
| t2dSceneObject_calculateMountNodes | Time Calculating Mount-Node Positions. |
| t2dSceneObject_updateMount | Time Mounted Objects take updating their mounted positions. |
| t2dSceneObject_updateContainerConfig | Time taken updating both the broad-phase container system and the clipping configuration. |
| t2dSceneContainer_BinRelocation | Time taken relocating objects in the container system. |
| t2dSceneContainer_allocateSceneBinReference | Time Allocating bins for the container system. |
| t2dSceneContainer_freeSceneBinReference | Time Deallocating bins for the container system. |
| t2dSceneContainer_addSceneReferenceBlock | Time adding Bin-Blocks to the container system. |
| t2dPhysics_collide | Time Checking for Collisions (narrow-phase). |
| t2dPhysics_updateNetVelocity | Time updating physics net velocities. |
| t2dPhysics_updateGrossVelocity | Time updating physics gross velocities. |
| t2dPhysics_updateSpatials | Time updating physics position / rotation. |
| t2dPhysics_generateCollisionPoly | Time updating collision-polygons. |
| t2dPhysics_generateCollisionCircle | Time updating collision-circles. |
| t2dPhysics_findContactPoints | Time calculating contact points. |
| t2dPhysics_resolveOverlap | Time resolving overlaps. |
| t2dPhysics_resolveOverlapOnly | Time resolving overlaps only (used for world-limits). |
| t2dPhysics_resolveCollision | Time resolving collisions. |
[edit] T2D System Variables(Scripts)(Controls Internal T2D Engine Features) | ||
| $pref::T2D::warnFileDeprecated | Bool (flag) | Shows warning if deprecated file is loaded/saved. |
| $pref::T2D::warnSceneOccupancy | Bool (flag) | Shows warning if an object is either added to a scene when it's already in one or is removed from a scene and in-fact isn't in one. |
| $pref::T2D::dualCollisionCallbacks | Bool (flag) | Specifies whether bi-directional collision callbacks are processed. During any single collision of object A colliding with object B, T2D will perform two script callbacks of A colliding with B and B colliding with A (assuming both are sending/receiving collisions). This may not be useful in all circumstances and can be reduced to a single callback of A colliding with B by setting this flag to false (off). |
| $pref::T2D::imageMapDumpTextures | Bool (flag) | Dumps all resultant imageMap textures from frame-packing operations to disk to “\imageMapDump”. Images are output as <imageMapName>_Page_<Page> where <imageMapName> is the name of the imageMap datablock and Page is the texture page created. This allows you to visualise exactly what imagery is uploaded to the graphics card. Note that you can get this information in a statistical format by using “$pref::T2D::imageMapShowPacking” below. |
| $pref::T2D::imageMapEchoErrors | Bool (flag) | Shows any imageMap errors in console (additional to the standard "onError()" callback. |
| $pref::T2D::imageMapFixedMaxTextureSize | Integer | Caution! - T2D will automatically use the maximum supported texture size that the graphics hardware reports unless a non-zero/positive value is specified here so it is typically left alone! This is an advanced option. Maximum texture size used when compiling frames into textures. This should be as large as possible but still be small enough that it is compatible with a wide a range of graphics-cards as possible. You cannot specify a value larger than the maximum supported by the graphics hardware, if you do then T2D will simply revert to using the hardware limit. Note that you can force this condition to be an error if you use "$pref::T2D::imageMapFixedMaxTextureError" (see below). Sometimes extremely large, albeit supported, texture sizes perform badly due to driver issues etc therefore this option allows you to specify the maximum size T2D will use for all imageMaps and if done before any imageMaps are processed, can be used to do graphics-card specific initialisation. |
| $pref::T2D::imageMapFixedMaxTextureError | Bool (flag) | Caution! - T2D will automatically use the maximum supported texture size that the graphics hardware reports unless a non-zero/positive value is specified here so it is typically left alone! This is an advanced option. If the fixed maximum texture size is greater than the currently supported maximum hardware size then this option allows you to specify this as a fatal condition. By default, this option is off resulting in T2D automatically using the maximum hardware size. |
| $pref::T2D::imageMapShowPacking | Bool (flag) | Shows all imageMap frame-packing operations/statistics in console (very verbose)! |
| NOTES |
| All script-references to “ON” equate to “true” or “1”. All script-references to “OFF” equate to “false” or “0”. Colored-regions are used to infer logical grouping/related functions. All values are floating-point unless otherwise specified. All angles are in degrees rather than radians and can be negative usually within the range of -360 to +360. All velocity/speed values are in world-units. All parameters with ‘?’ suffix are bool flags. All parameters with “$” suffix are strings. All parameters prefixed with ‘int’ are integer values only within the specified range. All ‘Mask’ parameters refer to a 32-bit unsigned value (bits 0-31) with each bit being a flag. [] Indicate Optional Parameters or Groups of Parameters. , indicates parameters are separated by a comma. / indicates parameters are grouped in a string, space-separated. All retrieved parameters are as a string with each parameter separated with a space. function parameters defined as "1,2,3,4" = func(1,2,3,4) function parameters defined as "1 / 2 / 3 / 4" = func( "1 2 3 4" ) |
Categories: T2D | TGB | TorqueScript | Reference



