X3DObject.LocalTranslation

X3DObject.LocalTranslation

導入

v3.5.1

説明

オブジェクトのローカル移動を戻したり、設定したりします。これは、Kinematics、ローカルの KinematicState、および SITransformation を介して移動 SIVector3 にアクセスするショートカットとして機能します。

C#構文

// get accessor

Object rtn = X3DObject.LocalTranslation;

// set accessor

X3DObject.LocalTranslation = Object;

1. JScript の例

/*

	This example illustrates how to get/set the local translation using two 

	different approaches

*/

NewScene( null, false );

var oNull1 = Application.ActiveSceneRoot.AddNull();

oNull1.posx.Value = 45;

var oNull2 = Application.ActiveSceneRoot.AddNull();

oNull2.posx.Value = 19;

// ACCESSING

// Access the local translation using the KinematicState

var oTransform = oNull1.Kinematics.Local.Transform;

var oTranslation = oTransform.Translation;

// Access the local translation using X3DObject.LocalTranslation

var oTranslation2 = oNull2.LocalTranslation;

Application.LogMessage( "Null1 pos x - " + oTranslation.X );

Application.LogMessage( "Null2 pos x - " + oTranslation2.X );

// SETTING

// Set the translation using the KinematicState

oTransform.SetTranslationFromValues( 2.0, 1.0, 0.0 );

oNull1.Kinematics.Local.Transform = oTransform;

// Set the translation using X3DObject.LocalTranslation

oTranslation2.Set( 2.0, 1.0, 0.0 );

oNull2.LocalTranslation = oTranslation2;

// Expected results:

//INFO : Null1 pos x - 45

//INFO : Null2 pos x - 19

2. VBScript の例

' 

' This example illustrates how to get/set local translation using

' two different approaches

' 

set oNull1 = Application.ActiveSceneRoot.AddNull()

set oNull2 = Application.ActiveSceneRoot.AddNull()

' ACCESSING

' Access the local translation using the KinematicState

set oTransform = oNull1.Kinematics.Local.Transform

set oTranslation = oTransform.Translation

' Access the local translation using X3DObject.LocalTranslation

set oTranslation2 = oNull2.LocalTranslation

' SETTING

' Set the local translation using the KinematicState

oTransform.SetTranslationFromValues 2.0, 1.0, 0.0

oNull1.Kinematics.Local.Transform = oTransform

' Set the local translation using X3DObject.LocalTranslation

oTranslation2.Set 2.0, 1.0, 0.0

oNull2.LocalTranslation = oTranslation2