• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# HkConstraint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AddConstraint

        public void AddConstraint(HkConstraint constraint)
        {
            if (IsWelded)
            {
                WeldInfo.Parent.AddConstraint(constraint);
                return;
            }
            if (HavokWorld == null || RigidBody == null)
                return;
            if (constraint.UserData == 0)
                constraint.UserData = (uint)(WeldedRigidBody == null ? RigidBody.GetGcRoot() : WeldedRigidBody.GetGcRoot());

            Debug.Assert(!m_constraints.Contains(constraint), "Constraint added twice");

            Debug.Assert(HavokWorld.RigidBodies.Contains(constraint.RigidBodyA), "Object must be in the world");
            Debug.Assert(HavokWorld.RigidBodies.Contains(constraint.RigidBodyB), "Object must be in the world");
            Debug.Assert(constraint.RigidBodyA.IsAddedToWorld);
            Debug.Assert(constraint.RigidBodyB.IsAddedToWorld);
            m_constraints.Add(constraint);

            HavokWorld.AddConstraint(constraint);

            if (constraint.InWorld)
                constraint.OnAddedToWorld();
            else
                Debug.Fail("Constraint not added!");
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:27,代码来源:MyPhysicsBody.cs


示例2: CreateConstraint

        private void CreateConstraint(MyCubeGrid other, MyShipMergeBlock block)
        {
            var data = new HkPrismaticConstraintData();
            data.MaximumLinearLimit = 0;
            data.MinimumLinearLimit = 0;
            var posA = ConstraintPositionInGridSpace();
            var posB = block.ConstraintPositionInGridSpace();
            var axisA = PositionComp.LocalMatrix.GetDirectionVector(m_forward);
            var axisAPerp = PositionComp.LocalMatrix.GetDirectionVector(m_right);
            var axisB = -block.PositionComp.LocalMatrix.GetDirectionVector(m_forward);

            Base6Directions.Direction thisRightForOther = block.WorldMatrix.GetClosestDirection(WorldMatrix.GetDirectionVector(m_right));
            Base6Directions.Direction otherRight = WorldMatrix.GetClosestDirection(block.WorldMatrix.GetDirectionVector(block.m_right));

            var axisBPerp = block.PositionComp.LocalMatrix.GetDirectionVector(thisRightForOther);

            data.SetInBodySpace( posA,  posB,  axisA,  axisB,  axisAPerp,  axisBPerp, CubeGrid.Physics, other.Physics);
            var data2 = new HkMalleableConstraintData();
            data2.SetData(data);
            data.ClearHandle();
            data = null;
            data2.Strength = 0.00001f;

            var constraint = new HkConstraint(CubeGrid.Physics.RigidBody, other.Physics.RigidBody, data2);
            AddConstraint(constraint);

            SetConstraint(block, constraint, otherRight);
            m_other.SetConstraint(this, constraint, thisRightForOther);
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:29,代码来源:MyShipMergeBlock.cs


示例3: SetConstraint

        protected void SetConstraint(MyShipMergeBlock otherBlock, HkConstraint constraint, Base6Directions.Direction otherRight)
        {
            Debug.Assert(m_constraint == null && m_other == null);
            if (m_constraint != null || m_other != null) return;

            m_constraint = constraint;
            m_other = otherBlock;
            m_otherRight = otherRight;
            CheckEmissivity();

            NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:12,代码来源:MyShipMergeBlock.cs


示例4: RemoveConstraint

 private void RemoveConstraint(MyShipConnector otherConnector, HkConstraint constraint)
 {
     if (this.HasConstraint)
     {
         CubeGrid.Physics.RemoveConstraint(constraint);
         HasConstraint = false;
     }
     else
     {
         otherConnector.CubeGrid.Physics.RemoveConstraint(constraint);
         otherConnector.HasConstraint = false;
     }
     constraint.Dispose();
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:14,代码来源:MyShipConnector.cs


示例5: AddConstraint

        public void AddConstraint(HkConstraint constraint)
        {
            Debug.Assert(!m_constraints.Contains(constraint), "Constraint added twice");

            Debug.Assert(m_world.RigidBodies.Contains(constraint.RigidBodyA), "Object must be in the world");
            Debug.Assert(m_world.RigidBodies.Contains(constraint.RigidBodyB), "Object must be in the world");
            Debug.Assert(constraint.RigidBodyA.IsAddedToWorld);
            Debug.Assert(constraint.RigidBodyB.IsAddedToWorld);
            m_constraints.Add(constraint);

            m_world.AddConstraint(constraint);

            constraint.OnAddedToWorld();
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:14,代码来源:MyPhysicsBody.cs


示例6: CreateConstraintNosync

        private void CreateConstraintNosync(MyShipConnector otherConnector, ref Vector3 posA, ref Vector3 posB, ref Vector3 axisA, ref Vector3 axisB)
        {
            var data = new HkHingeConstraintData();
            data.SetInBodySpace(ref posA, ref posB, ref axisA, ref axisB);
            var data2 = new HkMalleableConstraintData();
            data2.SetData(data);
            data.ClearHandle();
            data = null;
            data2.Strength = 0.0003f;

            var newConstraint = new HkConstraint(CubeGrid.Physics.RigidBody, otherConnector.CubeGrid.Physics.RigidBody, data2);
            this.Master = true;
            otherConnector.Master = false;
            SetConstraint(otherConnector, newConstraint);
            otherConnector.SetConstraint(this, newConstraint);

            AddConstraint(newConstraint);
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:18,代码来源:MyShipConnector.cs


示例7: ChangeConstraint

        private void ChangeConstraint(MyShipConnector other, HkConstraint newConstraint)
        {
            Debug.Assert(InConstraint);

            m_other = other;
            m_constraint = newConstraint;

            UpdateEmissivity();
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:9,代码来源:MyShipConnector.cs


示例8: Attach

        public void Attach(MyPistonTop topBlock, bool updateSync = false)
        {
            if (m_topBlock != null)
                Detach();
            if (CubeGrid.Physics == null || SafeConstraint != null)
                return;
            UpdateAnimation();
            Debug.Assert(SafeConstraint == null);

            if (CubeGrid.Physics.Enabled && topBlock != null)
            {
                m_topBlock = topBlock;
                m_topBlockId = topBlock.EntityId;

                if (updateSync)
                    SyncObject.AttachTop(m_topBlock);

                m_topGrid = m_topBlock.CubeGrid;
                var rotorBody = m_topGrid.Physics.RigidBody;

                var matAD = MatrixD.CreateWorld(Vector3D.Transform(Vector3D.Transform(m_constraintBasePos, Subpart3.WorldMatrix), CubeGrid.PositionComp.WorldMatrixNormalizedInv), PositionComp.LocalMatrix.Forward, PositionComp.LocalMatrix.Up);
                var matBD = MatrixD.CreateWorld(m_topBlock.Position * m_topBlock.CubeGrid.GridSize, m_topBlock.PositionComp.LocalMatrix.Forward, m_topBlock.PositionComp.LocalMatrix.Up);
                var matA = (Matrix)matAD;
                var matB = (Matrix)matBD;
                m_fixedData = new HkFixedConstraintData();
                m_fixedData.SetInertiaStabilizationFactor(10);
                m_fixedData.SetSolvingMethod(HkSolvingMethod.MethodStabilized);
                m_fixedData.SetInBodySpace(ref matA, ref matB);
                var breakData = new HkBreakableConstraintData(m_fixedData);
                //Dont dispose the fixed data or we wont have access to them

                breakData.Threshold = BreakOffTreshold;
                breakData.ReapplyVelocityOnBreak = true;
                breakData.RemoveFromWorldOnBrake = false;
                m_constraint = new HkConstraint(CubeGrid.Physics.RigidBody, rotorBody, breakData);
                m_constraint.WantRuntime = true;

                CubeGrid.Physics.AddConstraint(m_constraint);
                m_constraint.Enabled = true;

                m_topBlock.Attach(this);

                OnConstraintAdded(GridLinkTypeEnum.Physical, m_topGrid);
                OnConstraintAdded(GridLinkTypeEnum.Logical, m_topGrid);

                m_conveyorEndpoint.Attach(topBlock.ConveyorEndpoint as MyAttachableConveyorEndpoint);

            }
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:49,代码来源:MyPistonBase.cs


示例9: InitSubpartsPhysics

        private void InitSubpartsPhysics()
        {
            var subpart = m_subpart1;
            if (subpart == null || CubeGrid.Physics == null)
                return;
            subpart.Physics = new MyPhysicsBody(subpart, CubeGrid.IsStatic ? RigidBodyFlag.RBF_STATIC : (CubeGrid.GridSizeEnum == MyCubeSize.Large ? RigidBodyFlag.RBF_DOUBLED_KINEMATIC : RigidBodyFlag.RBF_DEFAULT));
            HkCylinderShape shape = new HkCylinderShape(Vector3.Zero, new Vector3(0, 0, 2), CubeGrid.GridSize / 2);
            var mass = HkInertiaTensorComputer.ComputeCylinderVolumeMassProperties(Vector3.Zero, Vector3.One, 1, 40.0f*CubeGrid.GridSize);
            subpart.Physics.CreateFromCollisionObject(shape, Vector3.Zero, subpart.WorldMatrix, mass);
            shape.Base.RemoveReference();
            subpart.Physics.RigidBody.Layer = CubeGrid.Physics.RigidBody.Layer;
            if (subpart.Physics.RigidBody2 != null)
                subpart.Physics.RigidBody2.Layer = MyPhysics.KinematicDoubledCollisionLayer;

            m_subpartsFixedData = new HkFixedConstraintData();
            m_subpartsFixedData.SetSolvingMethod(HkSolvingMethod.MethodStabilized);
            float res;
            var x = m_subpartsFixedData.GetInertiaStabilizationFactor(out res);
            m_subpartsFixedData.SetInertiaStabilizationFactor(1);
            var matAD = MatrixD.CreateWorld(Position * CubeGrid.GridSize + Vector3D.Transform(Vector3D.Transform(m_subpartsConstraintPos, WorldMatrix), CubeGrid.PositionComp.LocalMatrix), PositionComp.LocalMatrix.Forward, PositionComp.LocalMatrix.Up);
            matAD.Translation = CubeGrid.Physics.WorldToCluster(matAD.Translation);
            var matA = (Matrix)matAD;
            var matB = subpart.PositionComp.LocalMatrix;
            m_subpartsFixedData.SetInWorldSpace(ref matA, ref matB, ref matB);
            var breakableData = new HkBreakableConstraintData(m_subpartsFixedData);
            //Dont dispose the fixed data or we wont have access to them
            breakableData.Threshold = BreakOffTreshold;
            m_subpartsConstraint = new HkConstraint(CubeGrid.Physics.RigidBody, subpart.Physics.RigidBody, breakableData);
            m_subpartsConstraint.WantRuntime = true;

            m_posChanged = true;
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:32,代码来源:MyPistonBase.cs


示例10: Attach

        public override bool Attach(MyMotorRotor rotor, bool updateSync = false, bool updateGroup = true)
        {
            if (CubeGrid.Physics == null || SafeConstraint != null)
                return false;

            Debug.Assert(SafeConstraint == null);

            if (CubeGrid.Physics.Enabled && rotor != null)
            {
                m_rotorBlock = rotor;
                m_rotorBlockId = rotor.EntityId;

                if (updateSync)
                    SyncObject.AttachRotor(m_rotorBlock);

                m_rotorGrid = m_rotorBlock.CubeGrid;
                var rotorBody = m_rotorGrid.Physics.RigidBody;
                HkWheelConstraintData data = new HkWheelConstraintData();
                var posA = DummyPosition;
                var posB = rotor.DummyPosLoc;
                var axisA = PositionComp.LocalMatrix.Up;
                var axisAPerp = PositionComp.LocalMatrix.Forward;
                var axisB = rotor.PositionComp.LocalMatrix.Up;
                var suspensionAx = PositionComp.LocalMatrix.Forward;
                //empirical values because who knows what havoc sees behind this 
                //docs say one value should mean same effect for 2 ton or 200 ton vehicle 
                //but we have virtual mass blocks so real mass doesnt corespond to actual "weight" in game and varying gravity
                data.SetSuspensionDamping(Damping);
                data.SetSuspensionStrength(Strength);
                data.SetSuspensionMaxLimit(BlockDefinition.SuspensionLimit);
                data.SetSuspensionMinLimit(-BlockDefinition.SuspensionLimit);
                data.SetInBodySpace(ref posB, ref posA, ref axisB, ref axisA, ref suspensionAx, ref suspensionAx);
                m_constraint = new HkConstraint(rotorBody, CubeGrid.Physics.RigidBody, data);

                m_constraint.WantRuntime = true;
                CubeGrid.Physics.AddConstraint(m_constraint);
                m_constraint.Enabled = true;

                m_rotorBlock.Attach(this);
                UpdateIsWorking();

                if (updateGroup)
                {
                    OnConstraintAdded(GridLinkTypeEnum.Physical, m_rotorGrid);
                    OnConstraintAdded(GridLinkTypeEnum.Logical, m_rotorGrid);
                }

                return true;
            }

            return false;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:52,代码来源:MyMotorSuspension.cs


示例11: Attach

        public override bool Attach(MyMotorRotor rotor, bool updateGroup = true)
        {
            Debug.Assert(rotor != null, "Rotor cannot be null!");
            Debug.Assert(m_constraint == null, "Already attached, call detach first!");
            Debug.Assert(m_rotorBlockId.Value.OtherEntityId == 0 || m_rotorBlockId.Value.OtherEntityId == rotor.EntityId, "m_rotorBlockId must be set prior calling Attach");

            if (rotor == null || MarkedForClose || Closed || rotor.MarkedForClose || rotor.Closed || CubeGrid.MarkedForClose || CubeGrid.Closed)
            {
                return false;
            }

            if (CubeGrid.Physics != null && CubeGrid.Physics.Enabled)
            {
                m_rotorBlock = rotor;
                m_rotorGrid = m_rotorBlock.CubeGrid;
                if (m_rotorGrid.Physics == null)
                    return false;
                if (CubeGrid.Physics.RigidBody == m_rotorGrid.Physics.RigidBody)
                {
                    if (updateGroup && m_welded)
                    {
                        OnConstraintAdded(GridLinkTypeEnum.Physical, m_rotorGrid);
                        OnConstraintAdded(GridLinkTypeEnum.Logical, m_rotorGrid);
                   }
                    m_isAttached = true;
                    return true;
                }
                var rotorBody = m_rotorGrid.Physics.RigidBody;
                var data = new HkLimitedHingeConstraintData();
                m_motor = new HkVelocityConstraintMotor(1.0f, 1000000f);

                data.SetSolvingMethod(HkSolvingMethod.MethodStabilized);
                data.Motor = m_motor;
                data.DisableLimits();

                var posA = DummyPosition;
                var posB = rotor.Position * rotor.CubeGrid.GridSize;
                var axisA = PositionComp.LocalMatrix.Up;
                var axisAPerp = PositionComp.LocalMatrix.Forward;
                var axisB = rotor.PositionComp.LocalMatrix.Up;
                var axisBPerp = rotor.PositionComp.LocalMatrix.Forward;
                data.SetInBodySpace(posA, posB, axisA, axisB, axisAPerp, axisBPerp, CubeGrid.Physics, m_rotorGrid.Physics);
                m_constraint = new HkConstraint(CubeGrid.Physics.RigidBody, rotorBody, data);

                m_constraint.WantRuntime = true;
                CubeGrid.Physics.AddConstraint(m_constraint);
                if(!m_constraint.InWorld)
                {
                    CubeGrid.Physics.RemoveConstraint(m_constraint);
                    m_constraint.Dispose();
                    m_constraint = null;
                    return false;
                }
                m_constraint.Enabled = true;

                SetAngleToPhysics();

                m_rotorBlock.Attach(this);

                if (updateGroup)
                {
                    OnConstraintAdded(GridLinkTypeEnum.Physical, m_rotorGrid);
                    OnConstraintAdded(GridLinkTypeEnum.Logical, m_rotorGrid);
                    m_rotorGrid.OnPhysicsChanged += cubeGrid_OnPhysicsChanged;
                }
                m_isAttached = true;
                UpdateText();
                return true;
            }

            return false;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:72,代码来源:MyMotorStator.cs


示例12: RemoveConstraint

        public void RemoveConstraint(HkConstraint constraint)
        {
            constraint.UserData = 0;

            if(IsWelded)
            {
                WeldInfo.Parent.RemoveConstraint(constraint);
                return;
            }

            m_constraints.Remove(constraint);

            if (HavokWorld != null)
            {
                constraint.OnRemovedFromWorld();
                HavokWorld.RemoveConstraint(constraint);
            }
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:18,代码来源:MyPhysicsBody.cs


示例13: CreateConstraintNosync

        private void CreateConstraintNosync(MyShipConnector otherConnector)
        {
            Debug.Assert(IsMaster, "Constraints should be created only master (entity with higher EntityId)");

            var posA = ConstraintPositionInGridSpace();
            var posB = otherConnector.ConstraintPositionInGridSpace();
            var axisA = ConstraintAxisGridSpace();
            var axisB = -otherConnector.ConstraintAxisGridSpace();

            var data = new HkHingeConstraintData();
            data.SetInBodySpace(posA, posB, axisA, axisB, CubeGrid.Physics, otherConnector.CubeGrid.Physics);
            var data2 = new HkMalleableConstraintData();
            data2.SetData(data);
            data.ClearHandle();
            data = null;
            data2.Strength = GetEffectiveStrength(otherConnector);

            var newConstraint = new HkConstraint(CubeGrid.Physics.RigidBody, otherConnector.CubeGrid.Physics.RigidBody, data2);
            SetConstraint(otherConnector, newConstraint);
            otherConnector.SetConstraint(this, newConstraint);

            AddConstraint(newConstraint);
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:23,代码来源:MyShipConnector.cs


示例14: Attach

        private void Attach(HkRigidBody body, Vector3 gearSpacePivot, Matrix otherBodySpacePivot)
        {
            if (CubeGrid.Physics.Enabled)
            {
                var entity = body.GetEntity();
                Debug.Assert(m_attachedTo == null, "Already attached");
                Debug.Assert(entity != null, "Landing gear is attached to body which has no entity");
                Debug.Assert(m_constraint == null);

                if (m_attachedTo != null || entity == null || m_constraint != null)
                    return;

                body.Activate();
                CubeGrid.Physics.RigidBody.Activate();

                m_attachedTo = entity;

                if (entity != null)
                {
                    entity.OnPhysicsChanged += m_physicsChangedHandler;
                }

                this.OnPhysicsChanged += m_physicsChangedHandler;

                Matrix gearLocalSpacePivot = Matrix.Identity;
                gearLocalSpacePivot.Translation = gearSpacePivot;
                
                var fixedData = new HkFixedConstraintData();
                if (MyFakes.OVERRIDE_LANDING_GEAR_INERTIA)
                {
                    fixedData.SetInertiaStabilizationFactor(MyFakes.LANDING_GEAR_INTERTIA);
                }
                else
                {
                    fixedData.SetInertiaStabilizationFactor(1);
                }

                fixedData.SetSolvingMethod(HkSolvingMethod.MethodStabilized);
                fixedData.SetInBodySpace(ref gearLocalSpacePivot, ref otherBodySpacePivot);

                HkConstraintData data = fixedData;

                if (MyFakes.LANDING_GEAR_BREAKABLE && BreakForce < MaxSolverImpulse)
                {
                    var breakData = new HkBreakableConstraintData(fixedData);
                    fixedData.Dispose();

                    breakData.Threshold = BreakForce;
                    breakData.ReapplyVelocityOnBreak = true;
                    breakData.RemoveFromWorldOnBrake = true;

                    data = breakData;
                }

                if (!m_needsToRetryLock)
                    StartSound(m_lockSound);

                m_constraint = new HkConstraint(CubeGrid.Physics.RigidBody, body, data);
                CubeGrid.Physics.AddConstraint(m_constraint);
                m_constraint.Enabled = true;

                LockMode = LandingGearMode.Locked;
                if (CanAutoLock)
                    ResetAutolock();

                OnConstraintAdded(GridLinkTypeEnum.Physical, entity);
                OnConstraintAdded(GridLinkTypeEnum.NoContactDamage, entity);

                var handle = StateChanged;
                if (handle != null) handle(true);
            }
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:72,代码来源:MyLandingGear.cs


示例15: SetConstraint

 private void SetConstraint(MyShipConnector other, HkConstraint newConstraint)
 {
     m_other = other;
     m_constraint = newConstraint;
     UpdateEmissivity();
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:6,代码来源:MyShipConnector.cs


示例16: ConnectInternal

        private void ConnectInternal(ref Matrix thisMatrix, ref Matrix otherMatrix, MyShipConnector otherConnector, bool constructor)
        {
            Debug.Assert(!m_attachableConveyorEndpoint.AlreadyAttached());
            if (m_attachableConveyorEndpoint.AlreadyAttached()) m_attachableConveyorEndpoint.DetachAll();

            m_attachableConveyorEndpoint.Attach(otherConnector.m_attachableConveyorEndpoint);

            var data = new HkFixedConstraintData();
            data.SetInWorldSpace(ref thisMatrix, ref otherMatrix, ref thisMatrix);
            var newConstraint = new HkConstraint(CubeGrid.Physics.RigidBody, otherConnector.CubeGrid.Physics.RigidBody, data);

            this.Connected = true;
            this.Master = true;
            otherConnector.Connected = true;
            otherConnector.Master = false;
            if (!constructor)
            {
                this.ChangeConstraint(otherConnector, newConstraint);
                otherConnector.ChangeConstraint(this, newConstraint);
            }
            else
            {
                this.SetConstraint(otherConnector, newConstraint);
                otherConnector.SetConstraint(this, newConstraint);
            }

            AddConstraint(newConstraint);

            if (CubeGrid != otherConnector.CubeGrid)
            {
                this.OnConstraintAdded(GridLinkTypeEnum.Logical, otherConnector.CubeGrid);
                this.OnConstraintAdded(GridLinkTypeEnum.Physical, otherConnector.CubeGrid);
            }
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:34,代码来源:MyShipConnector.cs


示例17: CubeGrid_OnPhysicsChanged

        void CubeGrid_OnPhysicsChanged(MyEntity obj)
        {
            if (Sync.IsServer && m_welding == false && InConstraint && m_welded == false)
            {
                if (m_hasConstraint)
                {
                    if (MyPhysicsBody.IsConstraintValid(m_constraint) == false && m_constraint.IsDisposed == false)
                    {
                        RemoveConstraint(m_other, m_constraint);
                        this.m_constraint = null;
                        m_other.m_constraint = null;
                        m_hasConstraint = false;
                        m_other.m_hasConstraint = false;
                        
                        if (m_connectionState.Value.MasterToSlave.HasValue == false && CubeGrid.Physics != null && m_other.CubeGrid.Physics != null)
                        {
                            var posA = ConstraintPositionInGridSpace();
                            var posB = m_other.ConstraintPositionInGridSpace();
                            var axisA = ConstraintAxisGridSpace();
                            var axisB = -m_other.ConstraintAxisGridSpace();

                            var data = new HkHingeConstraintData();
                            data.SetInBodySpace(posA, posB, axisA, axisB, CubeGrid.Physics, m_other.CubeGrid.Physics);
                            var data2 = new HkMalleableConstraintData();
                            data2.SetData(data);
                            data.ClearHandle();
                            data = null;
                            data2.Strength = GetEffectiveStrength(m_other);

                            var newConstraint = new HkConstraint(CubeGrid.Physics.RigidBody, m_other.CubeGrid.Physics.RigidBody, data2);
                            this.SetConstraint(m_other, newConstraint);
                            m_other.SetConstraint(this, newConstraint);

                            AddConstraint(newConstraint);
                        }
                    }
                }
            }
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:39,代码来源:MyShipConnector.cs


示例18: RemoveConstraint

        public void RemoveConstraint(HkConstraint constraint)
        {
            m_constraints.Remove(constraint);

            if (m_world != null)
            {
                constraint.OnRemovedFromWorld();
                m_world.RemoveConstraint(constraint);
            }
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:10,代码来源:MyPhysicsBody.cs


示例19: AddConstraint

 private void AddConstraint(HkConstraint newConstraint)
 {
     m_hasConstraint = true;
     if(newConstraint.RigidBodyA != newConstraint.RigidBodyB)
         CubeGrid.Physics.AddConstraint(newConstraint);
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:6,代码来源:MyShipConnector.cs


示例20: AddConstraint

 private void AddConstraint(HkConstraint newConstraint)
 {
     HasConstraint = true;
     CubeGrid.Physics.AddConstraint(newConstraint);
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyShipMergeBlock.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# HkContactPointEvent类代码示例发布时间:2022-05-24
下一篇:
C# HiveId类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap