Torque3D Documentation / _generateds / TSShapeConstructor

TSShapeConstructor

consoledoc.h

An object used to modify a DTS or COLLADA shape model after it has been loaded by Torque.

More...

Media

filename

Specifies the path to the DTS or DAE file to be operated on by this object.

Collada

Override the element in the COLLADA (.dae) file. No effect for DTS files.

float

Override the element in the COLLADA (.dae) file. No effect for DTS files.

Control how the COLLADA (.dae) importer interprets LOD in the model. No effect for DTS files.

int

Sets the detail size when lodType is set to SingleSize. No effect otherwise, and no effect for DTS files.

string

Prefix to apply to all material map names in the COLLADA (.dae) file. No effect for DTS files.

string

TAB separated patterns of nodes to import even if in neverImport list. No effect for DTS files.

string

TAB separated patterns of nodes to ignore on loading. No effect for DTS files.

string

TAB separated patterns of meshes to import even if in neverImportMesh list. No effect for DTS files.

string

TAB separated patterns of meshes to ignore on loading. No effect for DTS files.

string

TAB separated patterns of materials to ignore on loading. No effect for DTS files.

bool

Ignore elements inside COLLADA s. No effect for DTS files.

bool

Translate COLLADA model on import so the origin is at the center. No effect for DTS files.

bool

Translate COLLADA model on import so origin is at the (Z axis) bottom of the model. No effect for DTS files.

bool

Forces update of the materials.cs file in the same folder as the COLLADA (.dae) file, even if Materials already exist. No effect for DTS files.

bool

Convert to left handed coordinate system.

bool

Calculate tangents and bitangents, if possible.

bool

Convert spherical, cylindrical, box and planar mapping to proper UVs.

bool

Preprocess UV transformations (scaling, translation ...).

bool

This step flips all UV coordinates along the y-axis and adjusts material settings and bitangents accordingly.

bool

Search for instanced meshes and remove them by references to one master.

bool

Limit bone weights to 4 per vertex.

bool

Identifies and joins identical vertex data sets within all imported meshes.

bool

This step adjusts the output face winding order to be clockwise. The default assimp face winding order is counter clockwise.

bool

Reverse the normal vector direction for all normals.

bool

Removes redundant materials.

How to import timing data as frames, seconds or milliseconds.

int

FPS value to use if timing is set in frames and the animations does not have an fps set.

Sequences

filename

Legacy method of adding sequences to a DTS or DAE shape after loading.

Callbacks

void

Called immediately after the DTS or DAE file has been loaded; before the shape data is available to any other object (StaticShape, Player etc). This is where you should put any post-load commands to modify the shape in-memory such as addNode, renameSequence etc.

void

Called when the DTS or DAE resource is flushed from memory. Not normally required, but may be useful to perform cleanup.

Public Functions

bool
addCollisionDetail(int size, string type, string target, int depth, float merge, float concavity, int maxVerts, float boxMaxError, float sphereMaxError, float capsuleMaxError)

Autofit a mesh primitive or set of convex hulls to the shape geometry. Hulls may optionally be converted to boxes, spheres and/or capsules based on their volume.

int
addImposter(int size, int equatorSteps, int polarSteps, int dl, int dim, bool includePoles, float polarAngle)

Add (or edit) an imposter detail level to the shape.

bool
addMesh(string meshName, string srcShape, string srcMesh)

Add geometry from another DTS or DAE shape file into this shape.

bool
addNode(string name, string parentName, TransformF txfm, bool isWorld)

Add a new node.

bool
addPrimitive(string meshName, string type, string params, TransformF txfm, string nodeName)

Add a new mesh primitive to the shape.

bool
addSequence(string source, string name, int start, int end, bool padRot, bool padTrans)

Add a new sequence to the shape.

bool
addTrigger(string name, int keyframe, int state)

Add a new trigger to the sequence.

void
dumpShape(string filename)

Dump the shape hierarchy to the console or to a file. Useful for reviewing the result of a series of construction commands.

Box3F

Get the bounding box for the shape.

int

Get the total number of detail levels in the shape.

int

Get the index of the detail level with a given size.

string
getDetailLevelName(int index)

Get the name of the indexed detail level.

int
getDetailLevelSize(int index)

Get the size of the indexed detail level.

int

Get the index of the imposter (auto-billboard) detail level (if any).

string

Get the settings used to generate imposters for the indexed detail level.

int
getMeshCount(string name)

Get the number of meshes (detail levels) for the specified object.

string
getMeshMaterial(string name)

Get the name of the material attached to a mesh. Note that only the first material used by the mesh is returned.

string
getMeshName(string name, int index)

Get the name of the indexed mesh (detail level) for the specified object.

int
getMeshSize(string name, int index)

Get the detail level size of the indexed mesh for the specified object.

string
getMeshType(string name)

Get the display type of the mesh.

int
getNodeChildCount(string name)

Get the number of children of this node.

string
getNodeChildName(string name, int index)

Get the name of the indexed child node.

int

Get the total number of nodes in the shape.

int
getNodeIndex(string name)

Get the index of the node.

string
getNodeName(int index)

Get the name of the indexed node.

int
getNodeObjectCount(string name)

Get the number of geometry objects attached to this node.

string
getNodeObjectName(string name, int index)

Get the name of the indexed object.

string
getNodeParentName(string name)

Get the name of the node's parent. If the node has no parent (ie. it is at the root level), return an empty string.

TransformF
getNodeTransform(string name, bool isWorld)

Get the base (ie. not animated) transform of a node.

int

Get the total number of objects in the shape.

int
getObjectIndex(string name)

Get the index of the first object with the given name.

string
getObjectName(int index)

Get the name of the indexed object.

string
getObjectNode(string name)

Get the name of the node this object is attached to.

string
getSequenceBlend(string name)

Get information about blended sequences.

int

Get the total number of sequences in the shape.

bool
getSequenceCyclic(string name)

Check if this sequence is cyclic (looping).

int
getSequenceFrameCount(string name)

Get the number of keyframes in the sequence.

string

Get the ground speed of the sequence.

int
getSequenceIndex(string name)

Find the index of the sequence with the given name.

string
getSequenceName(int index)

Get the name of the indexed sequence.

float
getSequencePriority(string name)

Get the priority setting of the sequence.

string
getSequenceSource(string name)

Get information about where the sequence data came from.

int

Get the number of materials in the shape.

string
getTargetName(int index)

Get the name of the indexed shape material.

string
getTrigger(string name, int index)

Get information about the indexed trigger.

int
getTriggerCount(string name)

Get the number of triggers in the specified sequence.

void

Notify game objects that this shape file has changed, allowing them to update internal data if needed.

bool
removeDetailLevel(int index)

Remove the detail level (including all meshes in the detail level)

bool

Remove the imposter detail level (if any) from the shape.

bool
removeMesh(string name)

Remove a mesh from the shape.

bool
removeNode(string name)

Remove a node from the shape.

bool
removeObject(string name)

Remove an object (including all meshes for that object) from the shape.

bool
removeSequence(string name)

Remove the sequence from the shape.

bool
removeTrigger(string name, int keyframe, int state)

Remove a trigger from the sequence.

bool
renameDetailLevel(string oldName, string newName)

Rename a detail level.

bool
renameNode(string oldName, string newName)

Rename a node.

bool
renameObject(string oldName, string newName)

Rename an object.

bool
renameSequence(string oldName, string newName)

Rename a sequence.

void
saveShape(string filename)

Save the shape (with all current changes) to a new DTS file.

bool
setBounds(Box3F bbox)

Set the shape bounds to the given bounding box.

int
setDetailLevelSize(int index, int newSize)

Change the size of a detail level.

bool
setMeshMaterial(string meshName, string matName)

Set the name of the material attached to the mesh.

bool
setMeshSize(string name, int size)

Change the detail level size of the named mesh.

bool
setMeshType(string name, string type)

Set the display type for the mesh.

bool
setNodeParent(string name, string parentName)

Set the parent of a node.

bool
setNodeTransform(string name, TransformF txfm, bool isWorld)

Set the base transform of a node. That is, the transform of the node when in the root (not-animated) pose.

bool
setObjectNode(string objName, string nodeName)

Set the node an object is attached to.

bool
setSequenceBlend(string name, bool blend, string blendSeq, int blendFrame)

Mark a sequence as a blend or non-blend.

bool
setSequenceCyclic(string name, bool cyclic)

Mark a sequence as cyclic or non-cyclic.

bool
setSequenceGroundSpeed(string name, Point3F transSpeed, Point3F rotSpeed)

Set the translation and rotation ground speed of the sequence.

bool
setSequencePriority(string name, float priority)

Set the sequence priority.

void

Write the current change set to a TSShapeConstructor script file. The name of the script file is the same as the model, but with .cs extension. eg. myShape.cs for myShape.dts or myShape.dae.

Detailed Description

An object used to modify a DTS or COLLADA shape model after it has been loaded by Torque.

Media

filename baseShape 

Specifies the path to the DTS or DAE file to be operated on by this object.

Since the TSShapeConstructor script must be in the same folder as the DTS or DAE file, it is recommended to use a relative path so that the shape and script files can be copied to another location without having to modify the path.

Collada

TSShapeConstructorUpAxis upAxis 

Override the element in the COLLADA (.dae) file. No effect for DTS files.

Set to one of the following values:

X_AXIS

Positive X points up. Model will be rotated into Torque's coordinate system (Z up).

Y_AXIS

Positive Y points up. Model will be rotated into Torque's coordinate system (Z up).

Z_AXIS

Positive Z points up. No rotation will be applied to the model.

DEFAULT

The default value. Use the value in the .dae file (defaults to Z_AXIS if the element is not present).

float unit 

Override the element in the COLLADA (.dae) file. No effect for DTS files.

COLLADA (.dae) files usually contain a element that indicates the 'real world' units that the model is described in. It means you can work in sensible and meaningful units in your modeling app.
For example, if you were modeling a small object like a cup, it might make sense to work in inches (1 MAX unit = 1 inch), but if you were modeling a building, it might make more sense to work in feet (1 MAX unit = 1 foot). If you export both models to COLLADA, T3D will automatically scale them appropriately. 1 T3D unit = 1 meter, so the cup would be scaled down by 0.0254, and the building scaled down by 0.3048, given them both the correct scale relative to each other.
Omit the field or set to -1 to use the value in the .dae file (1.0 if the element is not present)

TSShapeConstructorLodType LODType 

Control how the COLLADA (.dae) importer interprets LOD in the model. No effect for DTS files.

Set to one of the following values:

DetectDTS

The default value. Instructs the importer to search for a 'baseXXX->startXXX' node hierarchy at the root level. If found, the importer acts as if ''TrailingNumber'' was set. Otherwise, all geometry is imported at a single detail size.

SingleSize

All geometry is imported at a fixed detail size. Numbers at the end of geometry node's are ignored.

TrailingNumber

Numbers at the end of geometry node's name are interpreted as the detail size (similar to DTS exporting). Geometry instances with the same base name but different trailing number are grouped into the same object.

DEFAULT

The default value. Use the value in the .dae file (defaults to Z_AXIS if the element is not present).

int singleDetailSize 

Sets the detail size when lodType is set to SingleSize. No effect otherwise, and no effect for DTS files.

see:

lodType

string matNamePrefix 

Prefix to apply to all material map names in the COLLADA (.dae) file. No effect for DTS files.

This field is useful to avoid material name clashes for exporters that generate generic material names like "texture0" or "material1".

string alwaysImport 

TAB separated patterns of nodes to import even if in neverImport list. No effect for DTS files.

Torque allows unwanted nodes in COLLADA (.dae) files to to be ignored during import. This field contains a TAB separated list of patterns to match node names. Any node that matches one of the patterns in the list will always be imported, even if it also matches the neverImport list

singleton TSShapeConstructor(MyShapeDae)
{
   baseShape = "./myShape.dae";
   alwaysImport = "mount*" TAB "eye";
   neverImport = "*-PIVOT";
}

string neverImport 

TAB separated patterns of nodes to ignore on loading. No effect for DTS files.

Torque allows unwanted nodes in COLLADA (.dae) files to to be ignored during import. This field contains a TAB separated list of patterns to match node names. Any node that matches one of the patterns in the list will not be imported (unless it matches the alwaysImport list.

string alwaysImportMesh 

TAB separated patterns of meshes to import even if in neverImportMesh list. No effect for DTS files.

Torque allows unwanted meshes in COLLADA (.dae) files to to be ignored during import. This field contains a TAB separated list of patterns to match mesh names. Any mesh that matches one of the patterns in the list will always be imported, even if it also matches the neverImportMesh list

singleton TSShapeConstructor(MyShapeDae)
{
   baseShape = "./myShape.dae";
   alwaysImportMesh = "body*" TAB "armor" TAB "bounds";
   neverImportMesh = "*-dummy";
}

string neverImportMesh 

TAB separated patterns of meshes to ignore on loading. No effect for DTS files.

Torque allows unwanted meshes in COLLADA (.dae) files to to be ignored during import. This field contains a TAB separated list of patterns to match mesh names. Any mesh that matches one of the patterns in the list will not be imported (unless it matches the alwaysImportMesh list.

string neverImportMat 

TAB separated patterns of materials to ignore on loading. No effect for DTS files.

Torque allows unwanted materials in COLLADA (.dae) files to to be ignored during import. This field contains a TAB separated list of patterns to match material names. Any material that matches one of the patterns in the list will not be imported

bool IgnoreNodeScale 

Ignore elements inside COLLADA s. No effect for DTS files.

This field is a workaround for certain exporters that generate bad node scaling, and is not usually required.

bool AdjustCenter 

Translate COLLADA model on import so the origin is at the center. No effect for DTS files.

bool AdjustFloor 

Translate COLLADA model on import so origin is at the (Z axis) bottom of the model. No effect for DTS files.

This can be used along with adjustCenter to have the origin at the center of the bottom of the model.

see:

adjustCenter

bool forceUpdateMaterials 

Forces update of the materials.cs file in the same folder as the COLLADA (.dae) file, even if Materials already exist. No effect for DTS files.

Normally only Materials that are not already defined are written to materials.cs.

bool convertLeftHanded 

Convert to left handed coordinate system.

bool calcTangentSpace 

Calculate tangents and bitangents, if possible.

bool genUVCoords 

Convert spherical, cylindrical, box and planar mapping to proper UVs.

bool transformUVCoords 

Preprocess UV transformations (scaling, translation ...).

bool flipUVCoords 

This step flips all UV coordinates along the y-axis and adjusts material settings and bitangents accordingly.

Assimp uses TL(0,0):BR(1,1). T3D uses TL(0,1):BR(1,0). This will be needed for most textured models.

bool findInstances 

Search for instanced meshes and remove them by references to one master.

bool limitBoneWeights 

Limit bone weights to 4 per vertex.

bool JoinIdenticalVerts 

Identifies and joins identical vertex data sets within all imported meshes.

bool reverseWindingOrder 

This step adjusts the output face winding order to be clockwise. The default assimp face winding order is counter clockwise.

bool invertNormals 

Reverse the normal vector direction for all normals.

bool removeRedundantMats 

Removes redundant materials.

TSShapeConstructorAnimType animTiming 

How to import timing data as frames, seconds or milliseconds.

int animFPS 

FPS value to use if timing is set in frames and the animations does not have an fps set.

Sequences

filename sequence 

Legacy method of adding sequences to a DTS or DAE shape after loading.

singleton TSShapeConstructor(MyShapeDae)
{
   baseShape = "./myShape.dae";
   sequence = "../anims/root.dae root";
   sequence = "../anims/walk.dae walk";
   sequence = "../anims/jump.dsq jump";
}

Callbacks

onLoad()

Called immediately after the DTS or DAE file has been loaded; before the shape data is available to any other object (StaticShape, Player etc). This is where you should put any post-load commands to modify the shape in-memory such as addNode, renameSequence etc.

onUnload()

Called when the DTS or DAE resource is flushed from memory. Not normally required, but may be useful to perform cleanup.

Public Functions

addCollisionDetail(int size, string type, string target, int depth, float merge, float concavity, int maxVerts, float boxMaxError, float sphereMaxError, float capsuleMaxError)

Autofit a mesh primitive or set of convex hulls to the shape geometry. Hulls may optionally be converted to boxes, spheres and/or capsules based on their volume.

Parameters:

size

size for this detail level

type

one of: box, sphere, capsule, 10-dop x, 10-dop y, 10-dop z, 18-dop, 26-dop, convex hulls. See the Shape Editor documentation for more details about these types.

target

geometry to fit collision mesh(es) to; either "bounds" (for the whole shape), or the name of an object in the shape

depth

maximum split recursion depth (hulls only)

merge

volume % threshold used to merge hulls together (hulls only)

concavity

volume % threshold used to detect concavity (hulls only)

maxVerts

maximum number of vertices per hull (hulls only)

boxMaxError

max % volume difference for a hull to be converted to a box (hulls only)

sphereMaxError

max % volume difference for a hull to be converted to a sphere (hulls only)

capsuleMaxError

max % volume difference for a hull to be converted to a capsule (hulls only)

return:

true if successful, false otherwise

%this.addCollisionDetail( -1, "box", "bounds" );
%this.addCollisionDetail( -1, "convex hulls", "bounds", 4, 30, 30, 32, 0, 0, 0 );
%this.addCollisionDetail( -1, "convex hulls", "bounds", 4, 30, 30, 32, 50, 50, 50 );

addImposter(int size, int equatorSteps, int polarSteps, int dl, int dim, bool includePoles, float polarAngle)

Add (or edit) an imposter detail level to the shape.

If the shape already contains an imposter detail level, this command will simply change the imposter settings Parameters:

size

size of the imposter detail level

equatorSteps

defines the number of snapshots to take around the equator. Imagine the object being rotated around the vertical axis, then a snapshot taken at regularly spaced intervals.

polarSteps

defines the number of snapshots taken between the poles (top and bottom), at each equator step. eg. At each equator snapshot, snapshots are taken at regular intervals between the poles.

dl

the detail level to use when generating the snapshots. Note that this is an array index rather than a detail size. So if an object has detail sizes of: 200, 150, and 40, then setting dl to 1 will generate the snapshots using detail size 150.

dim

defines the size of the imposter images in pixels. The larger the number, the more detailed the billboard will be.

includePoles

flag indicating whether to include the "pole" snapshots. ie. the views from the top and bottom of the object.

polar_angle

if pole snapshots are active (includePoles is true), this parameter defines the camera angle (in degrees) within which to render the pole snapshot. eg. if polar_angle is set to 25 degrees, then the snapshot taken at the pole (looking directly down or up at the object) will be rendered when the camera is within 25 degrees of the pole.

return:

true if successful, false otherwise

%this.addImposter( 2, 4, 0, 0, 64, false, 0 );
%this.addImposter( 2, 4, 2, 0, 64, true, 10 );   // this command would edit the existing imposter detail level

addMesh(string meshName, string srcShape, string srcMesh)

Add geometry from another DTS or DAE shape file into this shape.

Any materials required by the source mesh are also copied into this shape.
Parameters:

meshName

full name (object name + detail size) of the new mesh. If no detail size is present at the end of the name, a value of 2 is used.
An underscore before the number at the end of the name will be interpreted as a negative sign. eg. "MyMesh_4" will be interpreted as "MyMesh-4".

srcShape

name of a shape file (DTS or DAE) that contains the mesh

srcMesh

the full name (object name + detail size) of the mesh to copy from the DTS/DAE file into this shape

return:

true if successful, false otherwise

%this.addMesh( "ColMesh-1", "./collision.dts", "ColMesh", "Col-1" );
%this.addMesh( "SimpleShape10", "./testShape.dae", "MyMesh2",  );

addNode(string name, string parentName, TransformF txfm, bool isWorld)

Add a new node.

Parameters:

name

name for the new node (must not already exist)

parentName

name of an existing node to be the parent of the new node. If empty (""), the new node will be at the root level of the node hierarchy.

txfm

(optional) transform string of the form: "pos.x pos.y pos.z rot.x rot.y rot.z rot.angle"

isworld

(optional) flag to set the local-to-parent or the global transform. If false, or not specified, the position and orientation are treated as relative to the node's parent.

return:

true if successful, false otherwise

%this.addNode( "Nose", "Bip01 Head", "0 2 2 0 0 1 0" );
%this.addNode( "myRoot", "", "0 0 4 0 0 1 1.57" );
%this.addNode( "Nodes", "Bip01 Head", "0 2 0 0 0 1 0", true );

addPrimitive(string meshName, string type, string params, TransformF txfm, string nodeName)

Add a new mesh primitive to the shape.

Parameters:

meshName

full name (object name + detail size) of the new mesh. If no detail size is present at the end of the name, a value of 2 is used.
An underscore before the number at the end of the name will be interpreted as a negative sign. eg. "MyMesh_4" will be interpreted as "MyMesh-4".

type

one of: "box", "sphere", "capsule"

params

mesh primitive parameters:

  • for box: "size_x size_y size_z"

  • for sphere: "radius"

  • for capsule: "height radius"

txfm

local transform offset from the node for this mesh

nodeName

name of the node to attach the new mesh to (will change the object's node if adding a new mesh to an existing object)

return:

true if successful, false otherwise

%this.addMesh( "Box4", "box", "2 4 2", "0 2 0 0 0 1 0", "eye" );
%this.addMesh( "Sphere256", "sphere", "2", "0 0 0 0 0 1 0", "root" );
%this.addMesh( "MyCapsule-1", "capsule", "2 5", "0 0 2 0 0 1 0", "base01" );

addSequence(string source, string name, int start, int end, bool padRot, bool padTrans)

Add a new sequence to the shape.

Parameters:

source

the name of an existing sequence, or the name of a DTS or DAE shape or DSQ sequence file. When the shape file contains more than one sequence, the desired sequence can be specified by appending the name to the end of the shape file. eg. "myShape.dts run" would select the "run" sequence from the "myShape.dts" file.

name

name of the new sequence

start

(optional) first frame to copy. Defaults to 0, the first frame in the sequence.

end

(optional) last frame to copy. Defaults to -1, the last frame in the sequence.

padRot

(optional) copy root-pose rotation keys for non-animated nodes. This is useful if the source sequence data has a different root-pose to the target shape, such as if one character was in the T pose, and the other had arms at the side. Normally only nodes that are actually rotated by the source sequence have keyframes added, but setting this flag will also add keyframes for nodes that are not animated, but have a different root-pose rotation to the target shape root pose.

padTrans

(optional) copy root-pose translation keys for non-animated nodes. This is useful if the source sequence data has a different root-pose to the target shape, such as if one character was in the T pose, and the other had arms at the side. Normally only nodes that are actually moved by the source sequence have keyframes added, but setting this flag will also add keyframes for nodes that are not animated, but have a different root-pose position to the target shape root pose.

return:

true if successful, false otherwise

%this.addSequence( "./testShape.dts ambient", "ambient" );
%this.addSequence( "./myPlayer.dae run", "run" );
%this.addSequence( "./player_look.dsq", "look", 0, -1 );     // start to end
%this.addSequence( "walk", "walk_shortA", 0, 4 );            // start to frame 4
%this.addSequence( "walk", "walk_shortB", 4, -1 );           // frame 4 to end

addTrigger(string name, int keyframe, int state)

Add a new trigger to the sequence.

Parameters:

name

name of the sequence to modify

keyframe

keyframe of the new trigger

state

of the new trigger

return:

true if successful, false otherwise

%this.addTrigger( "walk", 3, 1 );
%this.addTrigger( "walk", 5, -1 );

dumpShape(string filename)

Dump the shape hierarchy to the console or to a file. Useful for reviewing the result of a series of construction commands.

Parameters:

filename

Destination filename. If not specified, dump to console.

%this.dumpShape();               // dump to console
%this.dumpShape( "./dump.txt" ); // dump to file

getBounds()

Get the bounding box for the shape.

return:

Bounding box "minX minY minZ maxX maxY maxZ"

getDetailLevelCount()

Get the total number of detail levels in the shape.

return:

the number of detail levels in the shape

getDetailLevelIndex(int size)

Get the index of the detail level with a given size.

Parameters:

size

size of the detail level to lookup

return:

index of the detail level with the desired size, or -1 if no such detail exists

if ( %this.getDetailLevelSize( 32 ) == -1 )
   echo( "Error: This shape does not have a detail level at size 32" );

getDetailLevelName(int index)

Get the name of the indexed detail level.

Parameters:

index

detail level index (valid range is 0 - getDetailLevelCount()-1)

return:

the detail level name

// print the names of all detail levels in the shape
%count = %this.getDetailLevelCount();
for ( %i = 0; %i < %count; %i++ )
   echo( %i SPC %this.getDetailLevelName( %i ) );

getDetailLevelSize(int index)

Get the size of the indexed detail level.

Parameters:

index

detail level index (valid range is 0 - getDetailLevelCount()-1)

return:

the detail level size

// print the sizes of all detail levels in the shape
%count = %this.getDetailLevelCount();
for ( %i = 0; %i < %count; %i++ )
   echo( "Detail" @ %i @ " has size " @ %this.getDetailLevelSize( %i ) );

getImposterDetailLevel()

Get the index of the imposter (auto-billboard) detail level (if any).

return:

imposter detail level index, or -1 if the shape does not use imposters.

getImposterSettings(int index)

Get the settings used to generate imposters for the indexed detail level.

Parameters:

index

index of the detail level to query (does not need to be an imposter detail level

return:

string of the form: "valid eqSteps pSteps dl dim poles angle", where:

valid

1 if this detail level generates imposters, 0 otherwise

eqSteps

number of steps around the equator

pSteps

number of steps between the poles

dl

index of the detail level used to generate imposters

dim

size (in pixels) of each imposter image

poles

1 to include pole images, 0 otherwise

angle

angle at which to display pole images

// print the imposter detail level settings
%index = %this.getImposterDetailLevel();
if ( %index != -1 )
   echo( "Imposter settings: " @ %this.getImposterSettings( %index ) );

getMeshCount(string name)

Get the number of meshes (detail levels) for the specified object.

Parameters:

name

name of the object to query

return:

the number of meshes for this object.

%count = %this.getMeshCount( "SimpleShape" );

getMeshMaterial(string name)

Get the name of the material attached to a mesh. Note that only the first material used by the mesh is returned.

Parameters:

name

full name (object name + detail size) of the mesh to query

return:

name of the material attached to the mesh (suitable for use with the Material mapTo field)

echo( "Mesh material is " @ %this.sgetMeshMaterial( "SimpleShape128" ) );

getMeshName(string name, int index)

Get the name of the indexed mesh (detail level) for the specified object.

Parameters:

name

name of the object to query

index

index of the mesh (valid range is 0 - getMeshCount()-1)

return:

the mesh name.

// print the names of all meshes in the shape
%objCount = %this.getObjectCount();
for ( %i = 0; %i < %objCount; %i++ )
{
   %objName = %this.getObjectName( %i );
   %meshCount = %this.getMeshCount( %objName );
   for ( %j = 0; %j < %meshCount; %j++ )
      echo( %this.getMeshName( %objName, %j ) );
}

getMeshSize(string name, int index)

Get the detail level size of the indexed mesh for the specified object.

Parameters:

name

name of the object to query

index

index of the mesh (valid range is 0 - getMeshCount()-1)

return:

the mesh detail level size.

// print sizes for all detail levels of this object
%objName = "trunk";
%count = %this.getMeshCount( %objName );
for ( %i = 0; %i < %count; %i++ )
   echo( %this.getMeshSize( %objName, %i ) );

getMeshType(string name)

Get the display type of the mesh.

Parameters:

name

name of the mesh to query

return:

the string returned is one of:

normal

a normal 3D mesh

billboard

a mesh that always faces the camera

billboardzaxis

a mesh that always faces the camera in the Z-axis

echo( "Mesh type is " @ %this.getMeshType( "SimpleShape128" ) );

getNodeChildCount(string name)

Get the number of children of this node.

Parameters:

name

name of the node to query.

return:

the number of child nodes.

%count = %this.getNodeChildCount( "Bip01 Pelvis" );

getNodeChildName(string name, int index)

Get the name of the indexed child node.

Parameters:

name

name of the parent node to query.

index

index of the child node (valid range is 0 - getNodeChildName()-1).

return:

the name of the indexed child node.

function dumpNode( %shape, %name, %indent )
{
   echo( %indent @ %name );
   %count = %shape.getNodeChildCount( %name );
   for ( %i = 0; %i < %count; %i++ )
      dumpNode( %shape, %shape.getNodeChildName( %name, %i ), %indent @ "   " );
}

function dumpShape( %shape )
{
   // recursively dump node hierarchy
   %count = %shape.getNodeCount();
   for ( %i = 0; %i < %count; %i++ )
   {
      // dump top level nodes
      %name = %shape.getNodeName( %i );
      if ( %shape.getNodeParentName( %name ) $=  )
         dumpNode( %shape, %name, "" );
   }
}

getNodeCount()

Get the total number of nodes in the shape.

return:

the number of nodes in the shape.

%count = %this.getNodeCount();

getNodeIndex(string name)

Get the index of the node.

Parameters:

name

name of the node to lookup.

return:

the index of the named node, or -1 if no such node exists.

// get the index of Bip01 Pelvis node in the shape
%index = %this.getNodeIndex( "Bip01 Pelvis" );

getNodeName(int index)

Get the name of the indexed node.

Parameters:

index

index of the node to lookup (valid range is 0 - getNodeCount()-1).

return:

the name of the indexed node, or "" if no such node exists.

// print the names of all the nodes in the shape
%count = %this.getNodeCount();
for (%i = 0; %i < %count; %i++)
   echo(%i SPC %this.getNodeName(%i));

getNodeObjectCount(string name)

Get the number of geometry objects attached to this node.

Parameters:

name

name of the node to query.

return:

the number of attached objects.

%count = %this.getNodeObjectCount( "Bip01 Head" );

getNodeObjectName(string name, int index)

Get the name of the indexed object.

Parameters:

name

name of the node to query.

index

index of the object (valid range is 0 - getNodeObjectCount()-1).

return:

the name of the indexed object.

// print the names of all objects attached to the node
%count = %this.getNodeObjectCount( "Bip01 Head" );
for ( %i = 0; %i < %count; %i++ )
   echo( %this.getNodeObjectName( "Bip01 Head", %i ) );

getNodeParentName(string name)

Get the name of the node's parent. If the node has no parent (ie. it is at the root level), return an empty string.

Parameters:

name

name of the node to query.

return:

the name of the node's parent, or "" if the node is at the root level

echo( "Bip01 Pelvis parent = " @ %this.getNodeParentName( "Bip01 Pelvis ") );

getNodeTransform(string name, bool isWorld)

Get the base (ie. not animated) transform of a node.

Parameters:

name

name of the node to query.

isWorld

true to get the global transform, false (or omitted) to get the local-to-parent transform.

return:

the node transform in the form "pos.x pos.y pos.z rot.x rot.y rot.z rot.angle".

%ret = %this.getNodeTransform( "mount0" );
%this.setNodeTransform( "mount4", %ret );

getObjectCount()

Get the total number of objects in the shape.

return:

the number of objects in the shape.

%count = %this.getObjectCount();

getObjectIndex(string name)

Get the index of the first object with the given name.

Parameters:

name

name of the object to get.

return:

the index of the named object.

%index = %this.getObjectIndex( "Head" );

getObjectName(int index)

Get the name of the indexed object.

Parameters:

index

index of the object to get (valid range is 0 - getObjectCount()-1).

return:

the name of the indexed object.

// print the names of all objects in the shape
%count = %this.getObjectCount();
for ( %i = 0; %i < %count; %i++ )
   echo( %i SPC %this.getObjectName( %i ) );

getObjectNode(string name)

Get the name of the node this object is attached to.

Parameters:

name

name of the object to get.

return:

the name of the attached node, or an empty string if this object is not attached to a node (usually the case for skinned meshes).

echo( "Hand is attached to " @ %this.getObjectNode( "Hand" ) );

getSequenceBlend(string name)

Get information about blended sequences.

Parameters:

name

name of the sequence to query

return:

TAB delimited string of the form: "isBlend blendSeq blendFrame", where:

blend_flag

a boolean flag indicating whether this sequence is a blend

blend_seq_name

the name of the sequence that contains the reference frame (empty for blend sequences embedded in DTS files)

blend_seq_frame

the blend reference frame (empty for blend sequences embedded in DTS files)

note:

Note that only sequences set to be blends using the setSequenceBlend command will contain the blendSeq and blendFrame information.

%blendData = %this.getSequenceBlend( "look" );
if ( getField( %blendData, 0 ) )
   echo( "look is a blend, reference: " @ getField( %blendData, 1 ) );

getSequenceCount()

Get the total number of sequences in the shape.

return:

the number of sequences in the shape

getSequenceCyclic(string name)

Check if this sequence is cyclic (looping).

Parameters:

name

name of the sequence to query

return:

true if this sequence is cyclic, false if not

if ( !%this.getSequenceCyclic( "ambient" ) )
   error( "ambient sequence is not cyclic!" );

getSequenceFrameCount(string name)

Get the number of keyframes in the sequence.

Parameters:

name

name of the sequence to query

return:

number of keyframes in the sequence

echo( "Run has " @ %this.getSequenceFrameCount( "run" ) @ " keyframes" );

getSequenceGroundSpeed(string name)

Get the ground speed of the sequence.

note:

Note that only the first 2 ground frames of the sequence are examined; the speed is assumed to be constant throughout the sequence.

Parameters:
name

name of the sequence to query

return:

string of the form: "trans.x trans.y trans.z rot.x rot.y rot.z"

%speed = VectorLen( getWords( %this.getSequenceGroundSpeed( "run" ), 0, 2 ) );
   echo( "Run moves at " @ %speed @ " units per frame" );

getSequenceIndex(string name)

Find the index of the sequence with the given name.

Parameters:

name

name of the sequence to lookup

return:

index of the sequence with matching name, or -1 if not found

// Check if a given sequence exists in the shape
if ( %this.getSequenceIndex( "walk" ) == -1 )
   echo( "Could not find 'walk' sequence" );

getSequenceName(int index)

Get the name of the indexed sequence.

Parameters:

index

index of the sequence to query (valid range is 0 - getSequenceCount()-1)

return:

the name of the sequence

// print the name of all sequences in the shape
%count = %this.getSequenceCount();
for ( %i = 0; %i < %count; %i++ )
   echo( %i SPC %this.getSequenceName( %i ) );

getSequencePriority(string name)

Get the priority setting of the sequence.

Parameters:

name

name of the sequence to query

return:

priority value of the sequence

getSequenceSource(string name)

Get information about where the sequence data came from.

For example, whether it was loaded from an external DSQ file. Parameters:

name

name of the sequence to query

return:

TAB delimited string of the form: "from reserved start end total", where:

from

the source of the animation data, such as the path to a DSQ file, or the name of an existing sequence in the shape. This field will be empty for sequences already embedded in the DTS or DAE file.

reserved

reserved value

start

the first frame in the source sequence used to create this sequence

end

the last frame in the source sequence used to create this sequence

total

the total number of frames in the source sequence

// print the source for the walk animation
echo( "walk source:" SPC getField( %this.getSequenceSource( "walk" ), 0 ) );

getTargetCount()

Get the number of materials in the shape.

return:

the number of materials in the shape.

%count = %this.getTargetCount();

getTargetName(int index)

Get the name of the indexed shape material.

Parameters:

index

index of the material to get (valid range is 0 - getTargetCount()-1).

return:

the name of the indexed material.

%count = %this.getTargetCount();
for ( %i = 0; %i < %count; %i++ )
   echo( "Target " @ %i @ ": " @ %this.getTargetName( %i ) );

getTrigger(string name, int index)

Get information about the indexed trigger.

Parameters:

name

name of the sequence to query

index

index of the trigger (valid range is 0 - getTriggerCount()-1)

return:

string of the form "frame state"

// print all triggers in the sequence
%count = %this.getTriggerCount( "back" );
for ( %i = 0; %i < %count; %i++ )
   echo( %i SPC %this.getTrigger( "back", %i ) );

getTriggerCount(string name)

Get the number of triggers in the specified sequence.

Parameters:

name

name of the sequence to query

return:

number of triggers in the sequence

notifyShapeChanged()

Notify game objects that this shape file has changed, allowing them to update internal data if needed.

removeDetailLevel(int index)

Remove the detail level (including all meshes in the detail level)

Parameters:

size

size of the detail level to remove

return:

true if successful, false otherwise

%this.removeDetailLevel( 2 );

removeImposter()

Remove the imposter detail level (if any) from the shape.

return:

true if successful, false otherwise

removeMesh(string name)

Remove a mesh from the shape.

If all geometry is removed from an object, the object is also removed. Parameters:

name

full name (object name + detail size) of the mesh to remove

return:

true if successful, false otherwise

%this.removeMesh( "SimpleShape128" );

removeNode(string name)

Remove a node from the shape.

The named node is removed from the shape, including from any sequences that use the node. Child nodes and objects attached to the node are re-assigned to the node's parent. Parameters:

name

name of the node to remove.

return:

true if successful, false otherwise.

%this.removeNode( "Nose" );

removeObject(string name)

Remove an object (including all meshes for that object) from the shape.

Parameters:

name

name of the object to remove.

return:

true if successful, false otherwise.

// clear all objects in the shape
%count = %this.getObjectCount();
for ( %i = %count-1; %i >= 0; %i-- )
   %this.removeObject( %this.getObjectName(%i) );

removeSequence(string name)

Remove the sequence from the shape.

Parameters:

name

name of the sequence to remove

return:

true if successful, false otherwise

removeTrigger(string name, int keyframe, int state)

Remove a trigger from the sequence.

Parameters:

name

name of the sequence to modify

keyframe

keyframe of the trigger to remove

state

of the trigger to remove

return:

true if successful, false otherwise

%this.removeTrigger( "walk", 3, 1 );

renameDetailLevel(string oldName, string newName)

Rename a detail level.

note:

Note that detail level names must be unique, so this command will fail if there is already a detail level with the desired name

Parameters:
oldName

current name of the detail level

newName

new name of the detail level

return:

true if successful, false otherwise

%this.renameDetailLevel( "detail-1", "collision-1" );

renameNode(string oldName, string newName)

Rename a node.

note:

Note that node names must be unique, so this command will fail if there is already a node with the desired name

Parameters:
oldName

current name of the node

newName

new name of the node

return:

true if successful, false otherwise

%this.renameNode( "Bip01 L Hand", "mount5" );

renameObject(string oldName, string newName)

Rename an object.

note:

Note that object names must be unique, so this command will fail if there is already an object with the desired name

Parameters:
oldName

current name of the object

newName

new name of the object

return:

true if successful, false otherwise

%this.renameObject( "MyBox", "Box" );

renameSequence(string oldName, string newName)

Rename a sequence.

note:

Note that sequence names must be unique, so this command will fail if there is already a sequence with the desired name

Parameters:
oldName

current name of the sequence

newName

new name of the sequence

return:

true if successful, false otherwise

%this.renameSequence( "walking", "walk" );

saveShape(string filename)

Save the shape (with all current changes) to a new DTS file.

Parameters:

filename

Destination filename.

%this.saveShape( "./myShape.dts" );

setBounds(Box3F bbox)

Set the shape bounds to the given bounding box.

Parameters:

Bounding

box "minX minY minZ maxX maxY maxZ"

return:

true if successful, false otherwise

setDetailLevelSize(int index, int newSize)

Change the size of a detail level.

note:

Note that detail levels are always sorted in decreasing size order, so this command may cause detail level indices to change.

Parameters:
index

index of the detail level to modify

newSize

new size for the detail level

return:

new index for this detail level

%this.setDetailLevelSize( 2, 256 );

setMeshMaterial(string meshName, string matName)

Set the name of the material attached to the mesh.

Parameters:

meshName

full name (object name + detail size) of the mesh to modify

matName

name of the material to attach. This could be the base name of the diffuse texture (eg. "test_mat" for "test_mat.jpg"), or the name of a Material object already defined in script.

return:

true if successful, false otherwise

// set the mesh material
%this.setMeshMaterial( "SimpleShape128", "test_mat" );

setMeshSize(string name, int size)

Change the detail level size of the named mesh.

Parameters:

name

full name (object name + current size ) of the mesh to modify

size

new detail level size

return:

true if successful, false otherwise.

%this.setMeshSize( "SimpleShape128", 64 );

setMeshType(string name, string type)

Set the display type for the mesh.

Parameters:

name

full name (object name + detail size) of the mesh to modify

type

the new type for the mesh: "normal", "billboard" or "billboardzaxis"

return:

true if successful, false otherwise

// set the mesh to be a billboard
%this.setMeshType( "SimpleShape64", "billboard" );

setNodeParent(string name, string parentName)

Set the parent of a node.

Parameters:

name

name of the node to modify

parentName

name of the parent node to set (use "" to move the node to the root level)

return:

true if successful, false if failed

%this.setNodeParent( "Bip01 Pelvis", "start01" );

setNodeTransform(string name, TransformF txfm, bool isWorld)

Set the base transform of a node. That is, the transform of the node when in the root (not-animated) pose.

Parameters:

name

name of the node to modify

txfm

transform string of the form: "pos.x pos.y pos.z rot.x rot.y rot.z rot.angle"

isworld

(optional) flag to set the local-to-parent or the global transform. If false, or not specified, the position and orientation are treated as relative to the node's parent.

return:

true if successful, false otherwise

%this.setNodeTransform( "mount0", "0 0 1 0 0 1 0" );
%this.setNodeTransform( "mount0", "0 0 0 0 0 1 1.57" );
%this.setNodeTransform( "mount0", "1 0 0 0 0 1 0", true );

setObjectNode(string objName, string nodeName)

Set the node an object is attached to.

When the shape is rendered, the object geometry is rendered at the node's current transform. Parameters:

objName

name of the object to modify

nodeName

name of the node to attach the object to

return:

true if successful, false otherwise

%this.setObjectNode( "Hand", "Bip01 LeftHand" );

setSequenceBlend(string name, bool blend, string blendSeq, int blendFrame)

Mark a sequence as a blend or non-blend.

A blend sequence is one that will be added on top of any other playing sequences. This is done by storing the animated node transforms relative to a reference frame, rather than as absolute transforms. Parameters:

name

name of the sequence to modify

blend

true to make the sequence a blend, false for a non-blend

blendSeq

the name of the sequence that contains the blend reference frame

blendFrame

the reference frame in the blendSeq sequence

return:

true if successful, false otherwise

%this.setSequenceBlend( "look", true, "root", 0 );

setSequenceCyclic(string name, bool cyclic)

Mark a sequence as cyclic or non-cyclic.

Parameters:

name

name of the sequence to modify

cyclic

true to make the sequence cyclic, false for non-cyclic

return:

true if successful, false otherwise

%this.setSequenceCyclic( "ambient", true );
%this.setSequenceCyclic( "shoot", false );

setSequenceGroundSpeed(string name, Point3F transSpeed, Point3F rotSpeed)

Set the translation and rotation ground speed of the sequence.

The ground speed of the sequence is set by generating ground transform keyframes. The ground translational and rotational speed is assumed to be constant for the duration of the sequence. Existing ground frames for the sequence (if any) will be replaced. Parameters:

name

name of the sequence to modify

transSpeed

translational speed (trans.x trans.y trans.z) in Torque units per frame

rotSpeed

(optional) rotational speed (rot.x rot.y rot.z) in radians per frame. Default is "0 0 0"

return:

true if successful, false otherwise

%this.setSequenceGroundSpeed( "run", "5 0 0" );
%this.setSequenceGroundSpeed( "spin", "0 0 0", "4 0 0" );

setSequencePriority(string name, float priority)

Set the sequence priority.

Parameters:

name

name of the sequence to modify

priority

new priority value

return:

true if successful, false otherwise

writeChangeSet()

Write the current change set to a TSShapeConstructor script file. The name of the script file is the same as the model, but with .cs extension. eg. myShape.cs for myShape.dts or myShape.dae.