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


C# IntersectionFlags类代码示例

本文整理汇总了C#中IntersectionFlags的典型用法代码示例。如果您正苦于以下问题:C# IntersectionFlags类的具体用法?C# IntersectionFlags怎么用?C# IntersectionFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Start

 public void Start(MyModel model, MyLine line, IntersectionFlags flags = IntersectionFlags.DIRECT_TRIANGLES)
 {
     result = null;
     m_model = model;
     m_line = line;
     m_flags = flags;
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:7,代码来源:MyQuantizedBvhResult.cs

示例2: GetIntersectionWithLine

        //  Calculates intersection of line with any triangleVertexes in this model instance. Closest intersection and intersected triangleVertexes will be returned.
        internal override bool GetIntersectionWithLine(ref LineD line, out MyIntersectionResultLineTriangleEx? t, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            t = null;
            return false;

            //Matrix invWorld = Matrix.Invert(WorldMatrix);
            //Vector3 from = Vector3.Transform(line.From, invWorld);
            //Vector3 to = Vector3.Transform(line.To, invWorld);

            //Line lineLocal = new Line(from, to);

            //bool res = base.GetIntersectionWithLine(ref line, out t, flags);

            //if (res)
            //{
            //    var definition = MyDefinitionManager.Static.GetCubeBlockDefinition(new MyDefinitionId(MyObjectBuilderTypeEnum.Ladder));
            //    if (definition.ExcludedAreaForCamera != null)
            //    {
            //        foreach (var b in definition.ExcludedAreaForCamera)
            //        {
            //            if (b.Contains(t.Value.IntersectionPointInObjectSpace) == ContainmentType.Contains)
            //            {
            //                t = null;
            //                return false;
            //            }
            //        }
            //    }
            //}

            //return res;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:32,代码来源:MyLadder.cs

示例3: GetIntersectionWithLine

        public MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(MyEntity physObject, ref MyLine line, ref Matrix customInvMatrix, IntersectionFlags flags)
        {
            MyLine lineInModelSpace = new MyLine(MyUtils.GetTransform(line.From, ref customInvMatrix), MyUtils.GetTransform(line.To, ref customInvMatrix), true);

            MyIntersectionResultLineTriangleEx? ret = m_rootNode.GetIntersectionWithLine(physObject, m_model, ref lineInModelSpace, null, flags);

            return ret;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:8,代码来源:MyModelOctree.cs

示例4: GetIntersectionWithLine

        public Sandbox.Common.MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(IMyEntity physObject, ref LineD line, ref MatrixD customInvMatrix, IntersectionFlags flags)
        {
            LineD lineInModelSpace = new LineD(Vector3D.Transform(line.From, ref customInvMatrix), Vector3D.Transform(line.To, ref customInvMatrix));

            MyIntersectionResultLineTriangleEx? ret = m_rootNode.GetIntersectionWithLine(physObject, m_model, ref lineInModelSpace, null, flags);

            return ret;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:8,代码来源:MyModelOctree.cs

示例5: GetIntersectionWithLine

        //  Difference between GetIntersectionWithLine and GetIntersectionWithLineRecursive is that the later doesn't calculate
        //  final result, but is better suited for recursive nature of octree. Don't call GetIntersectionWithLineRecursive() from
        //  the outisde of this class, it's private method.
        public MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(MyEntity physObject, MyModel model, ref MyLine line, float? minDistanceUntilNow, IntersectionFlags flags)
        {
            MyIntersectionResultLineTriangle? foundTriangle = GetIntersectionWithLineRecursive(model, ref line, minDistanceUntilNow);

            if (foundTriangle != null)
            {
                return new MyIntersectionResultLineTriangleEx(foundTriangle.Value, physObject, ref line);
            }
            else
            {
                return null;
            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:16,代码来源:MyModelOctreeNode.cs

示例6: GetIntersectionWithLine

        public MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(MyEntity physObject, ref MyLine line, ref Matrix customInvMatrix, IntersectionFlags flags)
        {
            MyLine lineInModelSpace = new MyLine(MyUtils.GetTransform(line.From, ref customInvMatrix), MyUtils.GetTransform(line.To, ref customInvMatrix), true);

            //MyIntersectionResultLineTriangle? result = null;

            m_result.Start(m_model, lineInModelSpace, flags);

            var dir = new IndexedVector3(lineInModelSpace.Direction);
            var from = new IndexedVector3(lineInModelSpace.From);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("m_bvh.RayQueryClosest()");
            m_bvh.RayQueryClosest(ref dir, ref from, m_result.ProcessTriangleHandler);
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            if (m_result.Result.HasValue)
            {
                return new MyIntersectionResultLineTriangleEx(m_result.Result.Value, physObject, ref lineInModelSpace);
            }
            else
            {
                return null;
            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:24,代码来源:MyQuantizedBvhAdapter.cs

示例7: GetIntersectionWithLine

        public override bool GetIntersectionWithLine(ref MyLine line, out Vector3? v, bool useCollisionModel = true, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            v = null;
            Ray ray = new Ray(line.From, line.Direction);
            float? ds = null;
            BoundingBox boundingBox = new BoundingBox(WorldMatrix.Translation - Size / 2f, WorldMatrix.Translation + Size / 2f);
            ds = ray.Intersects(boundingBox);            

            if (ds == null)
                return false;

            v = line.From + line.Direction * ds;
            return true;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:14,代码来源:MyPrefabScanner.cs

示例8: GetIntersectionWithLine

        //  Calculates intersection of line with any triangleVertexes in this model instance. Closest intersection and intersected triangleVertexes will be returned.
        public virtual bool GetIntersectionWithLine(ref LineD line, out VRage.Game.Models.MyIntersectionResultLineTriangleEx? t, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            bool ret = false;

            t = null;
            MyModel collisionModel = Model;

            if (collisionModel != null)
            {
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyEntity.GetIntersectionWithLine on model");
                VRage.Game.Models.MyIntersectionResultLineTriangleEx? result = collisionModel.GetTrianglePruningStructure().GetIntersectionWithLine(this, ref line, flags);
                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                if (result != null)
                {
                    t = result.Value;
                    ret = true;
                }
            }

            return ret;

        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:23,代码来源:MyEntity.cs

示例9: GetIntersectionWithLine

 public override bool GetIntersectionWithLine(ref LineD worldLine, out Vector3D? v, bool useCollisionModel = true, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
 {
     MyIntersectionResultLineTriangleEx? result;
     GetIntersectionWithLine(ref worldLine, out result);
     v = null;
     if (result != null)
     {
         v = result.Value.IntersectionPointInWorldSpace;
         return true;
     }
     return false;
 }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:12,代码来源:MyVoxelBase.cs

示例10: GetIntersectionWithLine

        /// <summary>
        /// Returns closest hit from line start position.
        /// </summary>
        public bool GetIntersectionWithLine(ref LineD line, ref MyCharacterHitInfo info, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            // TODO: This now uses caspule of physics rigid body on the character, it needs to be changed to ragdoll
            //       Currently this approach will be used to support Characters with different skeleton than humanoid
            if (info == null)
                info = new MyCharacterHitInfo();

            info.Reset();

            bool capsulesReady = UpdateCapsuleBones();
            if (!capsulesReady)
                return false;

            double closestDistanceToHit = double.MaxValue;

            Vector3D hitPosition = Vector3D.Zero;
            Vector3D hitPosition2 = Vector3D.Zero;
            Vector3 hitNormal = Vector3.Zero;
            Vector3 hitNormal2 = Vector3.Zero;

            int capsuleIndex = -1;
            for (int i = 0; i < m_bodyCapsules.Length; i++)
            {
                CapsuleD capsule = m_bodyCapsules[i];
                if (capsule.Intersect(line, ref hitPosition, ref hitPosition2, ref hitNormal, ref hitNormal2))
                {
                    double distanceToHit = Vector3.Distance(hitPosition, line.From);
                    if (distanceToHit >= closestDistanceToHit)
                        continue;

                    closestDistanceToHit = distanceToHit;
                    capsuleIndex = i;
                }
            }

            if (capsuleIndex != -1)
            {
                Matrix worldMatrix = PositionComp.WorldMatrix;
                int boneIndex = FindBestBone(capsuleIndex, ref hitPosition, ref worldMatrix);

                // Transform line to model static position and compute accurate collision there
                // 1. Transform line in local coordinates (used later)
                Matrix worldMatrixInv = PositionComp.WorldMatrixNormalizedInv;
                Vector3 fromTrans = Vector3.Transform(line.From, ref worldMatrixInv);
                Vector3 toTrans = Vector3.Transform(line.To, ref worldMatrixInv);
                LineD lineLocal = new LineD(fromTrans, toTrans);

                // 2. Transform line to to bone pose in binding position
                var bone = AnimationController.CharacterBones[boneIndex];
                bone.ComputeAbsoluteTransform();
                Matrix boneAbsTrans = bone.AbsoluteTransform;
                Matrix skinTransform = bone.SkinTransform;
                Matrix boneTrans = skinTransform * boneAbsTrans;
                Matrix invBoneTrans = Matrix.Invert(boneTrans);
                fromTrans = Vector3.Transform(fromTrans, ref invBoneTrans);
                toTrans = Vector3.Transform(toTrans, ref invBoneTrans);

                // 3. Move back line to world coordinates
                LineD lineTransWorld = new LineD(Vector3.Transform(fromTrans, ref worldMatrix), Vector3.Transform(toTrans, ref worldMatrix));
                MyIntersectionResultLineTriangleEx? triangle_;
                bool success = base.GetIntersectionWithLine(ref lineTransWorld, out triangle_, flags);
                if (success)
                {
                    MyIntersectionResultLineTriangleEx triangle = triangle_.Value;

                    info.CapsuleIndex = capsuleIndex;
                    info.BoneIndex = boneIndex;
                    info.Capsule = m_bodyCapsules[info.CapsuleIndex];
                    info.HitHead = info.CapsuleIndex == 0 && m_bodyCapsules.Length > 1;
                    info.HitPositionBindingPose = triangle.IntersectionPointInObjectSpace;
                    info.HitNormalBindingPose = triangle.NormalInObjectSpace;

                    // 4. Move intersection from binding to dynamic pose
                    MyTriangle_Vertexes vertices = new MyTriangle_Vertexes();
                    vertices.Vertex0 = Vector3.Transform(triangle.Triangle.InputTriangle.Vertex0, ref boneTrans);
                    vertices.Vertex1 = Vector3.Transform(triangle.Triangle.InputTriangle.Vertex1, ref boneTrans);
                    vertices.Vertex2 = Vector3.Transform(triangle.Triangle.InputTriangle.Vertex2, ref boneTrans);
                    Vector3 triangleNormal = Vector3.TransformNormal(triangle.Triangle.InputTriangleNormal, boneTrans);
                    MyIntersectionResultLineTriangle triraw = new MyIntersectionResultLineTriangle(ref vertices, ref triangleNormal, triangle.Triangle.Distance);

                    Vector3 intersectionLocal = Vector3.Transform(triangle.IntersectionPointInObjectSpace, ref boneTrans);
                    Vector3 normalLocal = Vector3.TransformNormal(triangle.NormalInObjectSpace, boneTrans);

                    // 5. Store results
                    triangle = new MyIntersectionResultLineTriangleEx();
                    triangle.Triangle = triraw;
                    triangle.IntersectionPointInObjectSpace = intersectionLocal;
                    triangle.NormalInObjectSpace = normalLocal;
                    triangle.IntersectionPointInWorldSpace = Vector3.Transform(intersectionLocal, ref worldMatrix);
                    triangle.NormalInWorldSpace = Vector3.TransformNormal(normalLocal, worldMatrix);
                    triangle.InputLineInObjectSpace = lineLocal;

                    info.Triangle = triangle;

                    if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW)
                    {
                        MyRenderProxy.DebugClearPersistentMessages();
//.........这里部分代码省略.........
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:101,代码来源:MyCharacter.cs

示例11: GetIntersectionWithLine_FullyBuiltProgressModels

        /// <summary>
        /// Calculates intersected block with all models replaced by final models. Useful for construction/deconstruction when models are made from wooden construction.
        /// </summary>
        public bool GetIntersectionWithLine_FullyBuiltProgressModels(ref LineD line, out VRage.Game.Models.MyIntersectionResultLineTriangleEx? t, out ushort blockId, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES, bool checkZFight = false, bool ignoreGenerated = false)
        {
            t = null;
            blockId = 0;

            double distanceSquaredInCompound = double.MaxValue;

            bool foundIntersection = false;

            foreach (var blockPair in m_mapIdToBlock)
            {
                MySlimBlock cmpSlimBlock = blockPair.Value;

                if (ignoreGenerated && cmpSlimBlock.BlockDefinition.IsGeneratedBlock)
                    continue;

                MyModel collisionModel = MyModels.GetModelOnlyData(cmpSlimBlock.BlockDefinition.Model);
                if (collisionModel != null)
                {
                    VRage.Game.Models.MyIntersectionResultLineTriangleEx? intersectionTriResult = collisionModel.GetTrianglePruningStructure().GetIntersectionWithLine(
                        cmpSlimBlock.FatBlock, ref line, flags);

                    if (intersectionTriResult != null)
                    {
                        Vector3D startToIntersection = intersectionTriResult.Value.IntersectionPointInWorldSpace - line.From;
                        double instrDistanceSq = startToIntersection.LengthSquared();
                        if (instrDistanceSq < distanceSquaredInCompound)
                        {
                            if (checkZFight && distanceSquaredInCompound < instrDistanceSq + 0.001f)
                                continue;

                            distanceSquaredInCompound = instrDistanceSq;
                            t = intersectionTriResult;
                            blockId = blockPair.Key;
                            foundIntersection = true;
                        }
                    }
                }
            }

            return foundIntersection;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:45,代码来源:MyCompoundCubeBlock.cs

示例12: GetIntersectionWithLine

        public override bool GetIntersectionWithLine(ref MyLine line, out Vector3? v, bool useCollisionModel = true, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            BoundingSphere boundingSphere = new BoundingSphere(GetPosition(), BoundingSphereRadius);
            Ray ray = new Ray(line.From, line.Direction);

            float? result = ray.Intersects(boundingSphere);
            v = result.HasValue ? ray.Position + ray.Direction * result.Value : (Vector3?)null;

            return result.HasValue;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:10,代码来源:MySpawnPoint.cs

示例13: GetIntersectionWithLine

 public override bool GetIntersectionWithLine(ref MyLine line, out Vector3? v, bool useCollisionModel = true, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
 {
     return m_gun.GetIntersectionWithLine(ref line, out v, useCollisionModel);
 }
开发者ID:ripark,项目名称:Miner-Wars-2081,代码行数:4,代码来源:MyPrefabLargeWeapon.cs

示例14: Explode

                      /*
        protected override void Explode()
        {
            MyExplosion newExplosion = MyExplosions.AddExplosion();
            if (newExplosion != null)
            {
                BoundingSphere explosionSphere = WorldVolumeHr;
                explosionSphere.Radius *= m_config.ExplosionRadiusMultiplier;
                MyVoxelMap voxelMap = MyVoxelMaps.GetOverlappingWithSphere(ref explosionSphere);
                MyExplosionDebrisModel.CreateExplosionDebris(ref explosionSphere, MyGroupMask.Empty, this, voxelMap);
                newExplosion.Start(0, MyPrefabConstants.VOLUME_DAMAGE_MULTIPLIER * m_config.ExplosionDamageMultiplier * WorldVolumeHr.Radius, 0, m_config.ExplosionType, explosionSphere, MyExplosionsConstants.EXPLOSION_LIFESPAN);
            }
        }               */

        public override bool GetIntersectionWithLine(ref MyLine line, out MyIntersectionResultLineTriangleEx? t, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            return m_gun.GetIntersectionWithLine(ref line, out t);
        }
开发者ID:ripark,项目名称:Miner-Wars-2081,代码行数:18,代码来源:MyPrefabLargeWeapon.cs

示例15: GetIntersectionWithLine

        public bool GetIntersectionWithLine(ref LineD line, out MyIntersectionResultLineTriangleEx? t, out ushort blockId, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES, bool checkZFight = false, bool ignoreGenerated = false)
        {
            t = null;
            blockId = 0;

            double distanceSquaredInCompound = double.MaxValue;

            bool foundIntersection = false;

            foreach (var blockPair in m_blocks)
            {
                MySlimBlock cmpSlimBlock = blockPair.Value;

				if (ignoreGenerated && cmpSlimBlock.BlockDefinition.IsGeneratedBlock)
					continue;

                MyIntersectionResultLineTriangleEx? intersectionTriResult;
                if (cmpSlimBlock.FatBlock.GetIntersectionWithLine(ref line, out intersectionTriResult) && intersectionTriResult != null)
                {
                    Vector3D startToIntersection = intersectionTriResult.Value.IntersectionPointInWorldSpace - line.From;
                    double instrDistanceSq = startToIntersection.LengthSquared();
                    if (instrDistanceSq < distanceSquaredInCompound)
                    {
						if (checkZFight && distanceSquaredInCompound < instrDistanceSq + 0.001f)
							continue;

                        distanceSquaredInCompound = instrDistanceSq;
                        t = intersectionTriResult;
                        blockId = blockPair.Key;
                        foundIntersection = true;
                    }
                }
            }

            return foundIntersection;
        }
开发者ID:martejj,项目名称:SpaceEngineers,代码行数:36,代码来源:MyCompoundCubeBlock.cs


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