NodeState Class Reference

The NodeState JavaScript class. Represents the state of a node for a given pose. More...

Public Slots

NodeState interpolate (float a, NodeState b)
 Create a new NodeState, by linearly interpolating the current one with the other one given in argument. More...
 
NodeState interpolate2d (float u, float v, NodeState b, NodeState c, NodeState d)
 Create a new NodeState, by performing a bilinear interpolation of the current one with the 3 other ones given in argument. More...
 
AttrState getAttr (int index)
 Get a copy of the AttrState contained in the current NodeState object at the specified index. More...
 
int getAttrCount ()
 Get the attribute count tracked by this NodeState. More...
 
void applyState (int frameNo)
 Apply the values of the current NodeState snapshot to the scene, at the specified frame. More...
 
int loadFromString (String &sData, int nPos, String &sRelativePath)
 Restore a NodeState from a previously generated NodeState string representation. More...
 
String toString (String &sRelativePath)
 Generate a string representation of the current NodeState data. More...
 

Public Member Functions

virtual ~NodeState ()
 

Properties

String sNodePath
 The qualified name of the node associated with the current NodeState object. More...
 

Detailed Description

The NodeState JavaScript class. Represents the state of a node for a given pose.

A NodeState is a snapshot of the state of a node and of its selected attributes. This snapshot can be stored, blended, and applied to a scene destination frame. It aims at making it easier to manipulate node data by offering a simple, high-level interface to represent the state of a node. Internally, a NodeState object contains a list of attributes with their values for a given pose or frame number.

//Create a snapshot of "Top/Master-P" position, rotation and scale node attributes at frames 1 and 9,
var pegDataA = new NodeState("Top/Master-P", 1, ["POSITION", "SCALE", "ROTATION"]);
var pegDataB = new NodeState("Top/Master-P", 9, ["POSITION", "SCALE", "ROTATION"]);
//Create a new blended NodeState with a ratio of 25% for pegDataA and 75% for pegDataB
var interpolatedData = pegDataA.interpolate(0.75, pegDataB);
//Apply the result to "Top/Master-P" on frame 4
interpolatedData.applyState(4);

Constructor & Destructor Documentation

◆ ~NodeState()

virtual NodeState::~NodeState ( )
virtual

Member Function Documentation

◆ applyState

void NodeState::applyState ( int  frameNo)
slot

Apply the values of the current NodeState snapshot to the scene, at the specified frame.

The example below transfers ["POSITION", "SCALE", "ROTATION"] properties of node "Top/Master-P" from frame 1 to frame 20.

var pegData = new NodeState("Top/Master-P", 1, ["POSITION", "SCALE", "ROTATION"]);
pegData.applyState(20);
Parameters
frameNo: The destination frame number, where the NodeState snapshot values are applied.

◆ getAttr

AttrState NodeState::getAttr ( int  index)
slot

Get a copy of the AttrState contained in the current NodeState object at the specified index.

This example creates a NodeState containing position, scale and rotation attributes of "Top/Master-P" node. It then returns the AttrState for the second attribute (scale)

var pegData = new NodeState("Top/Master-P", 1, ["POSITION", "SCALE", "ROTATION"]);
var scaleAttrState = pegData.getAttr(1);
Parameters
index: The index of the AttrState to retrieve. Must be within [0-getAttrCount[.
Returns
A Copy of the AttrState contained within this NodeState at the specified index.

◆ getAttrCount

int NodeState::getAttrCount ( )
slot

Get the attribute count tracked by this NodeState.

This example creates a RigState from the "Top" group, then gets the first NodeState from it and displays its attribute count.

var rigState = new RigState("Entire rig", 15, "Top");
var nodeState = rigState.getNodeState(0);
var attrCount = nodeState.getAttrCount();
MessageLog.trace("Node state \"Top/Master-P\" tracks "+attrCount+" attributes.");
Returns
The number of attributes tracked by this NodeState.

◆ interpolate

NodeState NodeState::interpolate ( float  a,
NodeState  b 
)
slot

Create a new NodeState, by linearly interpolating the current one with the other one given in argument.

The example below interpolates poseA with poseB, giving a weight of 25% to state A and 75% to state B.

var pegDataA = new NodeState("Top/Master-P", 1, ["POSITION", "SCALE", "ROTATION"]);
var pegDataB = new NodeState("Top/Master-P", 9, ["POSITION", "SCALE", "ROTATION"]);
var interpolatedData = pegDataA.interpolate(0.75, pegDataB);
Parameters
a: The normalized weight given to state b.
b: The state to interpolate the current one with (node and attributes must match)
Returns
A new interpolated NodeState

◆ interpolate2d

NodeState NodeState::interpolate2d ( float  u,
float  v,
NodeState  b,
NodeState  c,
NodeState  d 
)
slot

Create a new NodeState, by performing a bilinear interpolation of the current one with the 3 other ones given in argument.

The example below illustrates the long and short way to perform a bilinear interpolation.

var u = 0.3;
var v = 0.8;
var stateA = new NodeState("Top/Master-P", 1, ["POSITION", "SCALE", "ROTATION"]);
var stateB = new NodeState("Top/Master-P", 2, ["POSITION", "SCALE", "ROTATION"]);
var stateC = new NodeState("Top/Master-P", 3, ["POSITION", "SCALE", "ROTATION"]);
var stateD = new NodeState("Top/Master-P", 4, ["POSITION", "SCALE", "ROTATION"]);
//Long version
var interpolatedStateAB = stateA.interpolate(u, stateB);
var interpolatedStateCD = stateC.interpolate(u, stateD);
var interpolatedStateABCD_long = interpolatedStateAB.interpolate(v, interpolatedStateCD);
//Shorter version
var interpolatedStateABCD_quick = stateA.interpolate2d(u,v,stateB,stateC,stateD);
Parameters
u: First axis interpolation weight
v: Second axis interpolation weight
b: The second NodeState of the bilinear interpolation
c: The third NodeState of the bilinear interpolation
d: The fourth NodeState of the bilinear interpolation
Returns
A new bilinearly interpolated NodeState

◆ loadFromString

int NodeState::loadFromString ( String &  sData,
int  nPos,
String &  sRelativePath 
)
slot

Restore a NodeState from a previously generated NodeState string representation.

This example creates a string representation .

//Create a snapshot of "Top/Master-P" position, rotation and scale node attributes at frames 1 and 9,
var pegDataA = new NodeState("Top/Master-P", 1, ["POSITION", "SCALE", "ROTATION"]);
var dataString = pegDataA.toString("");
var restoredState = new NodeState();
restoredState.loadFromString(dataString, 0, "");
Parameters
sData: The string containing the NodeState data.
nPos: The start index in the string (typicaly zero)
sRelativePath: The qualified name of the root character group (optional). When provided, this argument makes it possible to adjust data generated from a character group that was renamed.
Returns
the index of the last character read in the data string

◆ toString

String NodeState::toString ( String &  sRelativePath)
slot

Generate a string representation of the current NodeState data.

This example creates a new node state, generates the string representation and saves the data to a file.

//Create a snapshot of "Top/Master-P" position, rotation and scale node attributes at frames 1 and 9,
var pegDataA = new NodeState("Top/Master-P", 1, ["POSITION", "SCALE", "ROTATION"]);
var dataString = pegDataA.toString("Top");
MessageLog.trace("dataString="+dataString);
Parameters
sRelativePath(optional) : The qualified name of the root character group (optional). When provided, node paths are stored relative to this group, making it possible to rename or move the character group node without invalidating the data.
Returns
A string containing the pose data.

Property Documentation

◆ sNodePath

String NodeState::sNodePath
readwrite

The qualified name of the node associated with the current NodeState object.