Object Hierarchy | 関連する C++クラス:KinematicState
KinematicState
KinematicState オブジェクトは、X3DObjectオブジェクトの現在のポーズを表します。一方、オブジェクトの基本ポーズは、StaticKinematicStateプロパティによって表されます。
KinematicState オブジェクトの変換状態には、KinematicState.TransformプロパティおよびそのParameterCollectionの両方からアクセスできます。どちらも同じ変換データを表示しますが、KinematicState.Transform
は数学的操作(XSIMathを参照)に使用すると便利なのに対し、ParameterCollection
はKinematicState プロパティページで表示されるように変換を表示します。
/*
Example of using the SITransformation to read the local
and global transforms of an object
*/
NewScene(null,false) ;
var oNull = Application.ActiveSceneRoot.AddNull( "ParentNull" ) ;
//Change the position and rotation of the null
//by providing a new transform
oNewLocalTransform = XSIMath.CreateTransform() ;
// Change posx, posy
oNewLocalTransform.SetTranslationFromValues( 10, 20, 0 ) ;
// set rotx to 90 degrees (pi/2 radians)
oNewLocalTransform.SetRotationFromXYZAnglesValues( XSIMath.pi / 2, 0, 0 ) ;
oNull.Kinematics.Local.Transform = oNewLocalTransform ;
PrintLocalGlobalTransforms( oNull ) ;
var oNullChild = oNull.AddNull( "ChildNull" ) ;
PrintLocalGlobalTransforms( oNullChild ) ;
// Show but the local and global SRT of an object
function PrintLocalGlobalTransforms( in_obj )
{
Application.LogMessage( "--------" + in_obj.Name + "---------" ) ;
var oLocalSITranformation = in_obj.Kinematics.Local.Transform ;
Application.LogMessage( "Local Transform" ) ;
PrintTransformation( oLocalSITranformation ) ;
Application.LogMessage( "" ) ;
Application.LogMessage( "Global Transform" ) ;
var oGlobalSITranformation = in_obj.Kinematics.Global.Transform ;
PrintTransformation( oGlobalSITranformation ) ;
Application.LogMessage( "" ) ;
}
// Show the "SRT: of a SITransformation object
function PrintTransformation( in_oTransform )
{
var oVector = XSIMath.CreateVector3();
in_oTransform.GetScaling( oVector ) ;
PrintVector( "Scaling:", oVector ) ;
// In Radians
in_oTransform.GetRotationXYZAngles( oVector ) ;
PrintVector( "Rotation:", oVector ) ;
in_oTransform.GetTranslation( oVector ) ;
PrintVector( "Translation:", oVector ) ;
}
// Print a vector. Values are rounded to 3 decimal places
function PrintVector( in_Prefix, in_oVec )
{
Application.LogMessage( in_Prefix + " " +
XSIRound(in_oVec.x,3) + ", " +
XSIRound(in_oVec.y,3) + ", " +
XSIRound(in_oVec.z,3) ) ;
}
//Output: (note how the local transform of
//the Child null is relative to the center
//of the parent null)
//
//INFO : --------ParentNull---------
//INFO : Local Transform
//INFO : Scaling: 1, 1, 1
//INFO : Rotation: 1.571, 0, 0
//INFO : Translation: 10, 20, 0
//INFO :
//INFO : Global Transform
//INFO : Scaling: 1, 1, 1
//INFO : Rotation: 1.571, 0, 0
//INFO : Translation: 10, 20, 0
//INFO :
//INFO : --------ChildNull---------
//INFO : Local Transform
//INFO : Scaling: 1, 1, 1
//INFO : Rotation: -1.571, 0, 0
//INFO : Translation: -10, 0, 20
//INFO :
//INFO : Global Transform
//INFO : Scaling: 1, 1, 1
//INFO : Rotation: 0, 0, 0
//INFO : Translation: 0, 0, 0
|
/*
Example of using the ParameterCollection of
a KinematicState object
*/
var oNull = ActiveSceneRoot.AddNull( "Null" ) ;
// The transform can be set through the parameters
// of the kinematicstate object
var oLocalKinematics = oNull.Kinematics.Local ;
oLocalKinematics.Parameters( "posx" ).Value = 10 ;
oLocalKinematics.Parameters( "posy" ).Value = 20 ;
oLocalKinematics.Parameters( "rotx" ).Value = 90 ;
oLocalKinematics.Parameters( "sclz" ).Value = 3 ;
// All the SRT values, plus many more parameters can
// be read via the parameter collection
var oAllParameters = oLocalKinematics.Parameters ;
for ( var i = 0 ; i < oAllParameters.Count ; i++ )
{
Application.LogMessage( oAllParameters(i).ScriptName + ":" +
oAllParameters(i).Value ) ;
}
//Output:
//INFO : blendweight:1
//INFO : active:true
//INFO : posx:10
//INFO : posy:20
//INFO : posz:0
//INFO : rotx:90
//INFO : roty:0
//INFO : rotz:0
//INFO : quatw:0.7071067811865476
//INFO : quatx:0.7071067811865475
//INFO : quaty:0
//INFO : quatz:0
//INFO : sclx:1
//INFO : scly:1
//INFO : sclz:3
//INFO : sclorix:0
//INFO : scloriy:0
//INFO : scloriz:0
//INFO : cnsscl:true
//INFO : cnsori:true
//INFO : cnspos:true
//INFO : affbyscl:true
//INFO : affbyori:true
//INFO : posxmaxactive:false
//INFO : posxminactive:false
//INFO : posymaxactive:false
//INFO : posyminactive:false
//INFO : poszmaxactive:false
//INFO : poszminactive:false
//INFO : rotxmaxactive:false
//INFO : rotxminactive:false
//INFO : rotymaxactive:false
//INFO : rotyminactive:false
//INFO : rotzmaxactive:false
//INFO : rotzminactive:false
//INFO : siscaling:true
//INFO : rotorder:0
//INFO : pivotactive:true
//INFO : pposx:0
//INFO : pposy:0
//INFO : pposz:0
//INFO : protx:0
//INFO : proty:0
//INFO : protz:0
//INFO : psclx:1
//INFO : pscly:1
//INFO : psclz:1
//INFO : pivotcompactive:true
//INFO : pcposx:0
//INFO : pcposy:0
//INFO : pcposz:0
//INFO : pcrotx:0
//INFO : pcroty:0
//INFO : pcrotz:0
//INFO : pcsclx:1
//INFO : pcscly:1
//INFO : pcsclz:1
//INFO : nposx:0
//INFO : nposy:0
//INFO : nposz:0
//INFO : nrotx:0
//INFO : nroty:0
//INFO : nrotz:0
//INFO : nsclx:1
//INFO : nscly:1
//INFO : nsclz:1
//INFO : nsclorix:0
//INFO : nscloriy:0
//INFO : nscloriz:0
|