HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_AgentClip Class Reference

#include <GU_AgentClip.h>

+ Inheritance diagram for GU_AgentClip:

Public Types

typedef fpreal32 FloatType
 
typedef UT_Array< FloatTypeFloatArray
 
typedef UT_SharedPtr< FloatArrayFloatArrayPtr
 
typedef GU_AgentXformT< FloatTypeXform
 
typedef UT_Array< XformXformArray
 
typedef UT_Matrix4T< FloatTypeMatrix4
 
typedef UT_Array< Matrix4Matrix4Array
 
typedef UT_SharedPtr
< Matrix4Array
Matrix4ArrayPtr
 
typedef UT_SharedPtr< const
Matrix4Array
Matrix4ArrayConstPtr
 

Public Member Functions

 ~GU_AgentClip ()
 
int64 getMemoryUsage (bool inclusive) const
 
void init (exint num_samples)
 
void load (const CL_Clip &clip)
 Load from clip. More...
 
void load (const GU_AgentClip &clip)
 
int numTransformTracks () const
 
void save (CL_Clip &clip, bool worldspace=false) const
 Save to clip. More...
 
bool isFile () const
 Returns whether the clip references a file on disk. More...
 
const UT_StringHolderfileName () const
 Returns the name of the file referenced by the clip. More...
 
void clearIsFile ()
 
bool isLoaded () const
 Returns whether the clip's contents have been loaded from disk. More...
 
bool hasLoadErrors () const
 Returns whether there were errors when loading the clip from disk. More...
 
bool loadFromFile (UT_StringArray *errors=nullptr) const
 Explicitly loads the clip from disk. More...
 
const GU_AgentRigrig () const
 
exint transformsPerSample () const
 Number of transforms in each sample. More...
 
exint sampleCount () const
 Number of samples in this clip. More...
 
fpreal length () const
 Length of the clip, in seconds. More...
 
void setLocalTransforms (const UT_Array< XformArray > &samples)
 
void setLocalTransforms (exint sample_i, const XformArray &xforms)
 Edit the transforms for a specific sample in the clip. More...
 
const XformArraylocalTransforms (exint sample_i) const
 
Matrix4ArrayConstPtr worldTransforms (exint sample_i) const
 
void sampleTransform (exint i, fpreal seconds, bool worldspace, Matrix4 &xform_sample) const
 Samples a transform in the clip at a specific time. More...
 
void addChannel (const UT_StringHolder &name, const FloatType *samples)
 
exint findChannel (const UT_StringRef &name) const
 Finds a channel by name. Returns -1 if the channel does not exist. More...
 
FloatType sampleChannel (exint channel_index, fpreal seconds) const
 
exint channelCount () const
 
const UT_StringHolderchannelName (exint i) const
 Returns the name of the specified channel. More...
 
UT_StringArray channelNames () const
 
void addScaledLocalTransforms (XformArray &dst, fpreal scale, fpreal seconds) const
 
void addScaledLocalTransforms (XformArray &dst, const UT_BitArray &joints, fpreal scale, const UT_Array< fpreal > &inv_total_weights, fpreal seconds) const
 
void concatLocalTransforms (XformArray &dst, const GU_AgentTransformGroup &xform_grp, fpreal percent, fpreal seconds) const
 Perform an additive blend with the specified percentage. More...
 
void addScaledLocalTransform (Xform &xform, exint i, fpreal scale, fpreal seconds) const
 
void addScaledChannelValues (FloatArray &dst, const UT_BitArray &channels, fpreal scale, const UT_Array< fpreal > &inv_total_weights, fpreal seconds) const
 
fpreal sampleFromSeconds (fpreal seconds) const
 
fpreal secondsFromSample (fpreal sample) const
 
exint nearestSampleFromSeconds (fpreal seconds) const
 
fpreal wrappedSampleFromSeconds (fpreal seconds) const
 
const UT_StringHoldername () const
 
void setName (const UT_StringHolder &name)
 
fpreal start () const
 
void setStart (fpreal t)
 
fpreal sampleRate () const
 
void setSampleRate (fpreal sample_rate)
 
- Public Member Functions inherited from UT_IntrusiveRefCounter< GU_AgentClip >
SYS_FORCE_INLINE UT_IntrusiveRefCounter ()
 Default constructor: Sets counter to 0. More...
 
SYS_FORCE_INLINE UT_IntrusiveRefCounter (const UT_IntrusiveRefCounter &)
 Copy constructor: Sets counter to 0. More...
 
UT_IntrusiveRefCounteroperator= (const UT_IntrusiveRefCounter &)
 Assignment operator: Does not modify counter. More...
 
SYS_FORCE_INLINE uint32 use_count () const
 Return current counter. More...
 

Static Public Member Functions

static GU_AgentClipPtr addClip (const UT_StringHolder &name, const GU_AgentRigConstPtr &rig)
 Create an empty clip. More...
 
static GU_AgentClipPtr addClipFromFile (const UT_StringHolder &name, const UT_StringHolder &filename, const GU_AgentRigConstPtr &rig, bool delay_load, UT_StringArray &errors)
 Create a clip by loading a clip file from disk. More...
 
static GU_AgentClipPtr addClipCopy (const GU_AgentClip &src, const GU_AgentRigConstPtr &rig, bool copy_external_ref)
 
static void computeWorldTransforms (const GU_AgentRig &rig, const XformArray &xforms, Matrix4Array &matrices)
 
static void computeLocalTransforms (const GU_AgentRig &rig, const XformArray &xforms, Matrix4Array &matrices)
 
static void computeWorldTransforms (const GU_AgentRig &rig, const UT_BitArray *in_world_space, Matrix4Array &xforms)
 
static void computeLocalTransforms (const GU_AgentRig &rig, const UT_BitArray *in_world_space, Matrix4Array &xforms)
 
static void forceValidName (UT_String &clipname)
 Replaces whitespace, special characters, etc with underscores. More...
 

Additional Inherited Members

- Protected Member Functions inherited from UT_IntrusiveRefCounter< GU_AgentClip >
SYS_FORCE_INLINE ~UT_IntrusiveRefCounter ()
 Destructor: Only derived classes can destruct this. More...
 

Detailed Description

An agent motion clip

It is represented as array of samples, where each sample has transformsPerSample() number of transforms. These transforms can be "local" (corresponding to the transform hierarchy of rig()), or "world" where they are multiplied all the way up to a root node in the rig.

Definition at line 204 of file GU_AgentClip.h.

Member Typedef Documentation

Definition at line 209 of file GU_AgentClip.h.

Definition at line 208 of file GU_AgentClip.h.

Definition at line 213 of file GU_AgentClip.h.

Definition at line 214 of file GU_AgentClip.h.

Definition at line 211 of file GU_AgentClip.h.

Definition at line 212 of file GU_AgentClip.h.

Constructor & Destructor Documentation

GU_AgentClip::~GU_AgentClip ( )

Member Function Documentation

void GU_AgentClip::addChannel ( const UT_StringHolder name,
const FloatType samples 
)

Add an extra channel into the clip (as an alternative to GU_AgentClip::load()). If a channel with the same name already exists, its data is replaced with the new samples.

Parameters
nameUnique name of the channel.
samplesFloat array with length sampleCount().
static GU_AgentClipPtr GU_AgentClip::addClip ( const UT_StringHolder name,
const GU_AgentRigConstPtr rig 
)
static

Create an empty clip.

Examples:
SOP/SOP_BouncyAgent.C.
static GU_AgentClipPtr GU_AgentClip::addClipCopy ( const GU_AgentClip src,
const GU_AgentRigConstPtr rig,
bool  copy_external_ref 
)
static

Create a clone of a clip, referencing the specified rig. 'copy_external_ref' should be disabled if the new clip will be further modified.

static GU_AgentClipPtr GU_AgentClip::addClipFromFile ( const UT_StringHolder name,
const UT_StringHolder filename,
const GU_AgentRigConstPtr rig,
bool  delay_load,
UT_StringArray errors 
)
static

Create a clip by loading a clip file from disk.

void GU_AgentClip::addScaledChannelValues ( FloatArray dst,
const UT_BitArray channels,
fpreal  scale,
const UT_Array< fpreal > &  inv_total_weights,
fpreal  seconds 
) const

Adds a scaled version of the channel values given a clip time. Only the channels defined on GU_AgentRig are included.

void GU_AgentClip::addScaledLocalTransform ( Xform xform,
exint  i,
fpreal  scale,
fpreal  seconds 
) const
void GU_AgentClip::addScaledLocalTransforms ( XformArray dst,
fpreal  scale,
fpreal  seconds 
) const

Add a scaled version of our local transforms using the given clip time. If the time in seconds exceeds the length of our clip, then it is wrapped around.

void GU_AgentClip::addScaledLocalTransforms ( XformArray dst,
const UT_BitArray joints,
fpreal  scale,
const UT_Array< fpreal > &  inv_total_weights,
fpreal  seconds 
) const

Variant of addScaledLocalTransforms that only affects a subset of the joints.

Parameters
inv_total_weightInverse of the total blend weight at each joint.
exint GU_AgentClip::channelCount ( ) const
inline

Returns the number of non-transform channels in the clip. This value will be >= GU_AgentRig::channelCount().

Definition at line 601 of file GU_AgentClip.h.

const UT_StringHolder & GU_AgentClip::channelName ( exint  i) const
inline

Returns the name of the specified channel.

Definition at line 589 of file GU_AgentClip.h.

UT_StringArray GU_AgentClip::channelNames ( ) const

Builds a list of all channel names in the clip (channels defined by GU_AgentRig, plus any spare channels).

void GU_AgentClip::clearIsFile ( )

Clears the external file reference. The clip's contents will also be loaded from disk if necessary.

static void GU_AgentClip::computeLocalTransforms ( const GU_AgentRig rig,
const XformArray xforms,
Matrix4Array matrices 
)
static

Compute the local transforms 'matrices' from the local 'xforms' corresponding to the transforms in 'rig'.

static void GU_AgentClip::computeLocalTransforms ( const GU_AgentRig rig,
const UT_BitArray in_world_space,
Matrix4Array xforms 
)
static

Given the world transforms 'xforms' corresponding to 'rig', convert them to local transforms in-place. The optional 'in_world_space' array can be used to specify if only some transforms in 'xforms' are currently in world space.

static void GU_AgentClip::computeWorldTransforms ( const GU_AgentRig rig,
const XformArray xforms,
Matrix4Array matrices 
)
static

Compute the world transforms 'matrices' from the local 'xforms' corresponding to the transforms in 'rig'.

static void GU_AgentClip::computeWorldTransforms ( const GU_AgentRig rig,
const UT_BitArray in_world_space,
Matrix4Array xforms 
)
static

Given the local transforms 'xforms' corresponding to 'rig', convert them to world transforms in-place. The optional 'in_world_space' array can be used to specify if some transforms in 'xforms' are already in world space.

void GU_AgentClip::concatLocalTransforms ( XformArray dst,
const GU_AgentTransformGroup xform_grp,
fpreal  percent,
fpreal  seconds 
) const

Perform an additive blend with the specified percentage.

const UT_StringHolder& GU_AgentClip::fileName ( ) const
inline

Returns the name of the file referenced by the clip.

Definition at line 332 of file GU_AgentClip.h.

exint GU_AgentClip::findChannel ( const UT_StringRef name) const
inline

Finds a channel by name. Returns -1 if the channel does not exist.

Definition at line 574 of file GU_AgentClip.h.

static void GU_AgentClip::forceValidName ( UT_String clipname)
inlinestatic

Replaces whitespace, special characters, etc with underscores.

Definition at line 271 of file GU_AgentClip.h.

int64 GU_AgentClip::getMemoryUsage ( bool  inclusive) const
bool GU_AgentClip::hasLoadErrors ( ) const
inline

Returns whether there were errors when loading the clip from disk.

Definition at line 342 of file GU_AgentClip.h.

void GU_AgentClip::init ( exint  num_samples)

Set this clip to have the specified number of samples, filled with identity transforms.

Precondition
num_samples must be larger than 0.
bool GU_AgentClip::isFile ( ) const
inline

Returns whether the clip references a file on disk.

Definition at line 329 of file GU_AgentClip.h.

bool GU_AgentClip::isLoaded ( ) const
inline

Returns whether the clip's contents have been loaded from disk.

Definition at line 339 of file GU_AgentClip.h.

fpreal GU_AgentClip::length ( void  ) const
inline

Length of the clip, in seconds.

Definition at line 376 of file GU_AgentClip.h.

void GU_AgentClip::load ( const CL_Clip clip)

Load from clip.

void GU_AgentClip::load ( const GU_AgentClip clip)

Copy from another agent clip, and inherit the external reference if there is one. If the rigs are different, identity matrices will be used for the additional joints.

bool GU_AgentClip::loadFromFile ( UT_StringArray errors = nullptr) const

Explicitly loads the clip from disk.

const XformArray& GU_AgentClip::localTransforms ( exint  sample_i) const
inline

Definition at line 408 of file GU_AgentClip.h.

const UT_StringHolder& GU_AgentClip::name ( void  ) const
inline

Name of the clip.

Definition at line 322 of file GU_AgentClip.h.

exint GU_AgentClip::nearestSampleFromSeconds ( fpreal  seconds) const
inline

Definition at line 499 of file GU_AgentClip.h.

int GU_AgentClip::numTransformTracks ( ) const
inline

Return the number of transform tracks of the clip that was loaded into this clip.

Definition at line 313 of file GU_AgentClip.h.

const GU_AgentRig& GU_AgentClip::rig ( ) const
inline

Definition at line 348 of file GU_AgentClip.h.

FloatType GU_AgentClip::sampleChannel ( exint  channel_index,
fpreal  seconds 
) const

Samples a channel in the clip at a specific time. The channel indices from GU_AgentRig are valid indices for the clip's channels. For transforms, use GU_AgentClip::sampleTransform().

exint GU_AgentClip::sampleCount ( ) const
inline

Number of samples in this clip.

Definition at line 361 of file GU_AgentClip.h.

fpreal GU_AgentClip::sampleFromSeconds ( fpreal  seconds) const
inline

Definition at line 489 of file GU_AgentClip.h.

fpreal GU_AgentClip::sampleRate ( ) const
inline

Sample rate of this clip

Definition at line 383 of file GU_AgentClip.h.

void GU_AgentClip::sampleTransform ( exint  i,
fpreal  seconds,
bool  worldspace,
Matrix4 xform_sample 
) const

Samples a transform in the clip at a specific time.

void GU_AgentClip::save ( CL_Clip clip,
bool  worldspace = false 
) const

Save to clip.

fpreal GU_AgentClip::secondsFromSample ( fpreal  sample) const
inline

Definition at line 494 of file GU_AgentClip.h.

void GU_AgentClip::setLocalTransforms ( const UT_Array< XformArray > &  samples)

Directly set the local transforms for this clip (as an alternative to using GU_AgentClip::load()).

Parameters
samplesAn array of local transform samples
Precondition
samples (and each sample within) must be at least length 1
Each entry in samples must be the same length
Postcondition
sampleCount() == samples.entries()
transformsPerSample() == samples.last().entries()
void GU_AgentClip::setLocalTransforms ( exint  sample_i,
const XformArray xforms 
)

Edit the transforms for a specific sample in the clip.

void GU_AgentClip::setName ( const UT_StringHolder name)
inline

Name of the clip.

Definition at line 324 of file GU_AgentClip.h.

void GU_AgentClip::setSampleRate ( fpreal  sample_rate)
inline

Sample rate of this clip

Definition at line 385 of file GU_AgentClip.h.

void GU_AgentClip::setStart ( fpreal  t)
inline

Start time of this clip in seconds

Definition at line 371 of file GU_AgentClip.h.

fpreal GU_AgentClip::start ( ) const
inline

Start time of this clip in seconds

Definition at line 369 of file GU_AgentClip.h.

exint GU_AgentClip::transformsPerSample ( ) const
inline

Number of transforms in each sample.

Definition at line 352 of file GU_AgentClip.h.

Matrix4ArrayConstPtr GU_AgentClip::worldTransforms ( exint  sample_i) const
inline

Definition at line 413 of file GU_AgentClip.h.

fpreal GU_AgentClip::wrappedSampleFromSeconds ( fpreal  seconds) const
inline

Definition at line 504 of file GU_AgentClip.h.


The documentation for this class was generated from the following file: