public void SetRigidBodyTransform(Matrix m) { if (CharacterRigidBody != null) { CharacterRigidBody.SetRigidBodyTransform(m); } }
public void SetHardSupportDistance(float distance) { if (CharacterRigidBody != null) { CharacterRigidBody.SetHardSupportDistance(distance); } }
public HkCharacterStateType GetState() { if (m_isDynamic) { // TODO: It would be much safer to test convex cast in gravity direction and consider character on ground when ground distance is small (e.g. under 0.1m) var state = CharacterRigidBody.GetState(); if (state != HkCharacterStateType.HK_CHARACTER_ON_GROUND) { m_airFrameCounter++; } if (state == HkCharacterStateType.HK_CHARACTER_ON_GROUND) { m_airFrameCounter = 0; } if (state == HkCharacterStateType.HK_CHARACTER_IN_AIR && m_airFrameCounter < 8) { state = HkCharacterStateType.HK_CHARACTER_ON_GROUND; } return(state); } else { return(CharacterProxy.GetState()); } }
// // Summary: // Applies angular impulse to rigid body. public void ApplyAngularImpulse(Vector3 impulse) { if (CharacterRigidBody != null) { CharacterRigidBody.ApplyAngularImpulse(impulse); } }
public void EnableLadderState(bool enable, float maxCharacterSpeed, float maxAcceleration) { if (CharacterRigidBody != null) { CharacterRigidBody.EnableLadderState(enable, maxCharacterSpeed, maxAcceleration); } }
public Matrix GetRigidBodyTransform() { if (CharacterRigidBody != null) { return(CharacterRigidBody.GetRigidBodyTransform()); } return(Matrix.Identity); }
public HkRigidBody GetHitRigidBody() { if (CharacterRigidBody != null) { return(CharacterRigidBody.GetHitRigidBody()); } return(null); }
public void UpdateSupport(float stepSizeInSeconds) { if (CharacterRigidBody != null) { CharacterRigidBody.UpdateSupport(stepSizeInSeconds); Supported = CharacterRigidBody.Supported; SupportNormal = CharacterRigidBody.SupportNormal; GroundVelocity = CharacterRigidBody.GroundVelocity; } }
public void SetState(HkCharacterStateType state) { if (m_isDynamic) { CharacterRigidBody.SetState(state); } else { CharacterProxy.SetState(state); } }
public void EnableFlyingState(bool enable, float maxCharacterSpeed, float maxFlyingSpeed, float maxAcceleration) { if (m_flyingStateEnabled != enable) { if (CharacterRigidBody != null) { CharacterRigidBody.EnableFlyingState(enable, maxCharacterSpeed, maxFlyingSpeed, maxAcceleration); } // To allow astronaut fly freely in deep space (otherwise he stops in up direction) StepSimulation(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS); m_flyingStateEnabled = enable; } }
public void SetShapeForCrouch(HkWorld world, bool enable) { if (CharacterRigidBody != null && world != null) { world.Lock(); if (enable) { CharacterRigidBody.SetShapeForCrouch(); } else { CharacterRigidBody.SetDefaultShape(); } if (m_physicsBody.IsInWorld) { world.ReintegrateCharacter(CharacterRigidBody); } world.Unlock(); } }
public void StepSimulation(float stepSizeInSeconds) { if (CharacterProxy != null) { CharacterProxy.PosX = m_posX; CharacterProxy.PosY = m_posY; CharacterProxy.Jump = m_jump; m_jump = false; CharacterProxy.Gravity = m_gravity; CharacterProxy.StepSimulation(stepSizeInSeconds); } if (CharacterRigidBody != null) { CharacterRigidBody.PosX = m_posX; CharacterRigidBody.PosY = m_posY; CharacterRigidBody.Jump = m_jump; m_jump = false; CharacterRigidBody.Gravity = m_gravity; CharacterRigidBody.Speed = Speed; CharacterRigidBody.StepSimulation(stepSizeInSeconds); CharacterRigidBody.Elevate = Elevate; Supported = CharacterRigidBody.Supported; GroundVelocity = CharacterRigidBody.GroundVelocity; } }
public void StepSimulation(float stepSizeInSeconds) { if (CharacterProxy != null) { CharacterProxy.PosX = m_posX; CharacterProxy.PosY = m_posY; CharacterProxy.Jump = m_jump; m_jump = false; CharacterProxy.Gravity = m_gravity; CharacterProxy.StepSimulation(stepSizeInSeconds); } if (CharacterRigidBody != null) { CharacterRigidBody.PosX = m_posX; CharacterRigidBody.PosY = m_posY; CharacterRigidBody.Jump = m_jump; m_jump = false; CharacterRigidBody.Gravity = m_gravity; CharacterRigidBody.Speed = Speed; CharacterRigidBody.StepSimulation(stepSizeInSeconds); CharacterRigidBody.Elevate = Elevate; Supported = CharacterRigidBody.Supported; SupportNormal = CharacterRigidBody.SupportNormal; GroundVelocity = CharacterRigidBody.GroundVelocity; if (false) { // Coordinate system Matrix worldMatrix = GetPhysicsBody().GetWorldMatrix(); Vector3 Side = CharacterRigidBody.Up.Cross(CharacterRigidBody.Forward); //MyPhysicsDebugDraw.DebugDrawCoordinateSystem(worldMatrix.Translation, CharacterRigidBody.Forward, Side, CharacterRigidBody.Up); //BoundingBoxD //MyPhysicsDebugDraw.DebugDrawAabb(worldMatrix.Translation,Color.LightBlue); //Velocity and Acceleration MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, CharacterRigidBody.LinearVelocity, Color.Red, 1.0f); //MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, CharacterRigidBody.LinearAcceleration, Color.Blue, 1.0f); // Gravity MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, CharacterRigidBody.Gravity, Color.Yellow, 0.1f); // Controller Up //MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, CharacterRigidBody.GetControllerUp(), Color.Pink, 1.0f); MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, CharacterRigidBody.Up, Color.Pink, 1.0f); Vector3 TestUp = Vector3.Up; MyPhysicsDebugDraw.DebugDrawVector3(worldMatrix.Translation, TestUp, Color.Green, 1.0f); /* * // Capsule Shape draw * float radius = 0.4f; * Vector3 vertexA = Vector3.Zero; * Vector3 vertexB = Vector3.Zero; * CharacterRigidBody.GetPxCapsuleShapeDrawData(ref radius,ref vertexA,ref vertexB); * if ((vertexA != vertexB) && (radius > 0.0f)) * { * HkShape capsuleShape = new HkCapsuleShape(vertexA, vertexB, radius); // only for debug display * * int index = 0; * const float alpha = 0.3f; * MyPhysicsDebugDraw.DrawCollisionShape(capsuleShape, worldMatrix, alpha, ref index); * } */ } } }