当前位置: 首页>>代码示例>>C#>>正文


C# RigidBody.PickShape方法代码示例

本文整理汇总了C#中Duality.Components.Physics.RigidBody.PickShape方法的典型用法代码示例。如果您正苦于以下问题:C# RigidBody.PickShape方法的具体用法?C# RigidBody.PickShape怎么用?C# RigidBody.PickShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Duality.Components.Physics.RigidBody的用法示例。


在下文中一共展示了RigidBody.PickShape方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PickShape

        private ShapeInfo PickShape(RigidBody body, Vector2 worldCoord)
        {
            // Special case for LoopShapes, because they are by definition unpickable
            foreach (LoopShapeInfo loop in body.Shapes.OfType<LoopShapeInfo>())
            {
                for (int i = 0; i < loop.Vertices.Length; i++)
                {
                    Vector2 worldV1 = body.GameObj.Transform.GetWorldPoint(loop.Vertices[i]);
                    Vector2 worldV2 = body.GameObj.Transform.GetWorldPoint(loop.Vertices[(i + 1) % loop.Vertices.Length]);
                    float dist = MathF.PointLineDistance(worldCoord.X, worldCoord.Y, worldV1.X, worldV1.Y, worldV2.X, worldV2.Y);
                    if (dist < 5.0f) return loop;
                }
            }

            // Do a physical picking operation
            return body.PickShape(worldCoord);
        }
开发者ID:qiqisteve,项目名称:duality,代码行数:17,代码来源:RigidBodyEditorCamViewState.cs

示例2: PickShape

        private ShapeInfo PickShape(RigidBody body, Vector2 worldCoord)
        {
            // Special case for Loop- and ChainShapes, because they are by definition unpickable
            Rect worldRect = Rect.Align(Alignment.Center, worldCoord.X, worldCoord.Y, 10.0f, 10.0f);
            foreach (ShapeInfo shape in body.Shapes)
            {
                LoopShapeInfo loop = shape as LoopShapeInfo;
                ChainShapeInfo chain = shape as ChainShapeInfo;

                Vector2[] vertices = null;
                if (loop != null) vertices = loop.Vertices;
                if (chain != null) vertices = chain.Vertices;

                if (vertices != null && IsOutlineBoxIntersection(body.GameObj.Transform, vertices, worldRect))
                    return shape;
            }

            // Do a physical picking operation
            return body.PickShape(worldCoord);
        }
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:20,代码来源:RigidBodyEditorCamViewState.cs


注:本文中的Duality.Components.Physics.RigidBody.PickShape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。