XSIMath.MapObjectPositionToObjectSpace

説明

あるObjectSpace で記述されている位置を、異なるObjectSpace での位置に変換します。

スクリプト 構文

oReturn = XSIMath.MapObjectPositionToObjectSpace( ObjectSpace, Space, Position );

戻り値

SIVector3(位置)

パラメータ

パラメータ タイプ 詳細
ObjectSpace SITransformation 位置が記述されているObjectSpace
Space SITransformation 位置を変換する先の ObjectSpace
位置 SIVector3 変換する位置

1. JScript の例

var    oCube = ActiveSceneRoot.AddGeometry("Cube","MeshSurface");
oCube.Kinematics.Global.Parameters("posy").value = 4.0;
oCube.Kinematics.Global.Parameters("posx").value = 2.0;
var     oGrid = ActiveSceneRoot.AddGeometry("Grid", "MeshSurface");
oGrid.Kinematics.Global.Parameters("posy").value = -2.0;
if( Above(oCube, oGrid) )
         Application.LogMessage ( "The Cube is above the Grid" );
else
         Application.LogMessage ( "The Cube is not above the Grid" );
//Function that returns true if in_obj1 is above in_obj2.
//Which means that all " y" values of in_obj1 vertices relative to in_obj2 are bigger
//than in_obj2 "y" values
function  Above(in_obj1, in_obj2)
{
         var l_trans1, l_trans2, l_pos, l_biggesty;
         l_biggesty = 0;
         var oGeometry2 = in_obj2.activeprimitive.geometry;
         var l_nbPoints = oGeometry2.Points.Count;
         //Determine the upper position on in_obj2
         for(var i = 0; i < l_nbPoints; i++) 
         { 
                if (oGeometry2.Points(i).position.y > l_biggesty)
                        l_biggesty = oGeometry2.Points(i).position.y;
         }
         l_trans1 = in_obj1.Kinematics.Global.Transform;
         l_trans2 = in_obj2.Kinematics.Global.Transform;
         var oGeometry1 = in_obj1.activeprimitive.geometry;
         l_nbPoints = oGeometry1.Points.Count;
         //Determine if all vertices of in_obj1 are above in_obj2
         for(var i = 0; i < l_nbPoints; i++) 
         { 
                l_pos = oGeometry1.Points(i).position;
                l_pos = XSIMath.MapObjectPositionToObjectSpace(l_trans1, l_trans2, l_pos);;
                if( l_pos.y < l_biggesty )
                        return false;
         }
        return true;
}
//OUTPUT
//INFO : The Cube is above the Grid

2. VBScript の例

set oRoot = Application.ActiveProject.ActiveScene.Root
        set oCube = oRoot.AddGeometry("Cube","MeshSurface")
        oCube.Kinematics.Global.Parameters("posy").value = 4.0
        oCube.Kinematics.Global.Parameters("posx").value = 2.0
        set oGrid = oRoot.AddGeometry("Grid", "MeshSurface")
        oGrid.Kinematics.Global.Parameters("posy").value = -2.0
        if Above(oCube, oGrid) then
                        Application.LogMessage "The Cube is above the Grid"
        else
                        Application.LogMessage "The Cube is not above the Grid"
        end if
        'Function that returns true if in_obj1 is above in_obj2.
        'Which means that all " y" values of in_obj1 vertices relative to in_obj2 are bigger
        'than in_obj2 "y" values
        Function Above(in_obj1, in_obj2)
                Dim l_trans1, l_trans2, l_pos, l_biggesty
                l_biggesty = 0
                'Determine the upper position on in_obj2
                for each p in in_obj2.activeprimitive.geometry.points
                        if p.position.y > l_biggesty then
                                l_biggesty = p.position.y
                        end if
                next
                set l_trans1 = in_obj1.Kinematics.Global.Transform
                set l_trans2 = in_obj2.Kinematics.Global.Transform
                'Determine if all vertices of in_obj1 are above in_obj2
                for each p in in_obj1.activeprimitive.geometry.points
                        set l_pos = p.position
                        set l_pos = xsimath.MapObjectPositionToObjectSpace(l_trans1, l_trans2, l_pos)
                        if l_pos.y < l_biggesty then
                                Above = False
                                Exit Function
                        end if
                next
                Above = True
        End Function