Geometry.GetBoundingCapsule

導入

v5.0

詳細

ジオメトリオブジェクトのバウンディングカプセルのセンターおよび範囲を戻します。入力変換が指定されている場合、バウンディングカプセルが計算される前にこのメソッドが戻されます。

スクリプト 構文

oArray = Geometry.GetBoundingCapsule( [Type], [Type], [Transform] );

戻り値

1D Array には5 つの値が含まれます。最初の 3 つはセンタの x、Y、Z座標値で、その後ろにセントラルシリンダの長さ(半球状のキャップを除く)と半球キャップ/円柱の半径が続きます。

パラメータ

パラメータ タイプ 詳細
タイプ siVolumeCenterMethod バウンディングカプセルのセンタの計算に使用します。

デフォルト値:siVolumeCenterMethodBBoxCenter

siBoundingCapsuleMethod バウンディングカプセルの軸の計算に使用します。

デフォルト値:siBoundingCapsuleMethodBestAxis

変換 SITransformation 変換は、バウンディングカプセルが計算される前にジオメトリに適用されます。

1. JScript の例

/* 
        Example using no input transform and default parameters
*/
// Create and move (rotate and translate) a torus
NewScene( null, false ) ;
var oTorus = ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" ) ;
SelectObj( oTorus ) ;
Rotate(null, 45, 0, 0, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, 0, null) ;
Translate(null, 3, 2, 1, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, null, null, 0, null) ;
// Find the bounding capsule
var vba = new VBArray( oTorus.ActivePrimitive.Geometry.GetBoundingCapsule() ) ;
var jsa = vba.toArray() ;
// Report the (local) center and radius
Application.LogMessage( "center:"  + jsa[0] + ", " + jsa[1] + ", " + jsa[2] ) ;
Application.LogMessage( "length:" + jsa[3] ) ;
Application.LogMessage( "radius:" + jsa[4] ) ;

2. JScript の例

/* 
        Example using an input transform to preserve scaling and non-default parameters
*/
// Create and move (rotate and translate) a torus
NewScene( null, false ) ;
var oTorus = ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" ) ;
SelectObj( oTorus ) ;
Scale(null, 0.5, 0.5, 1, siAbsolute, siGlobal, siObj, siY, null, null, null, null, null, null, null, 0, null) ;
oTransform = oTorus.Kinematics.Local.Transform ;
// Find the bounding capsule
var vba = new VBArray( oTorus.ActivePrimitive.Geometry.GetBoundingCapsule( siVolumeCenterMethodCOG, siBoundingCapsuleMethodXAxis, oTransform) ) ;
var jsa = vba.toArray() ;
// Report the (local) center and radius
Application.LogMessage( "center:" + jsa[0] + ", " + jsa[1] + ", " + jsa[2] ) ;
Application.LogMessage( "height:" + jsa[3] ) ;
Application.LogMessage( "radius:" + jsa[4] ) ;
// Build a capsule that shows the bounding volume
var oSphere = ActiveSceneRoot.AddPrimitive("Sphere" ) ;
oSphere.radius = jsa[4] ;
oSphere.PosX = jsa[0] + 0.5*jsa[3];
oSphere.PosY = jsa[1] ;
oSphere.PosZ = jsa[2] ;
var oSphere2 = ActiveSceneRoot.AddPrimitive("Sphere" ) ;
oSphere2.radius = jsa[4] ;
oSphere2.PosX = jsa[0] - 0.5*jsa[3];
oSphere2.PosY = jsa[1] ;
oSphere2.PosZ = jsa[2] ;
var oCylinder = ActiveSceneRoot.AddPrimitive("Cylinder" ) ;
oCylinder.radius = jsa[4] ;
oCylinder.height = jsa[3] ;
oCylinder.PosX = jsa[0] ;
oCylinder.PosY = jsa[1] ;
oCylinder.PosZ = jsa[2] ;
Rotate(oCylinder, 0, 0, 90.0, siAbsolute, siGlobalCOG, siObj, siXYZ, null, null, null, null, null, null, null, 0, null);
// Rotate them to align graphically
var oColl = new ActiveXObject("XSI.Collection") ;
oColl.Add( oCylinder ) ;
oColl.Add( oSphere ) ;
oColl.Add( oSphere2 ) ;
Rotate( oColl , 0, 90.0, 0, siRelative, siGlobalCOG, siObj, siXYZ, null, null, null, null, null, null, null, 0, null);
// Expected results:
//INFO : center:0, -1.734723475976807e-18, 2.0816681711721685e-16
//INFO : height:8
//INFO : radius:4

関連項目

Geometry.GetBoundingBox Geometry.GetBoundingSphere X3DObject.GetBoundingBox GetBBox