Beispiel #1
0
        public void Initialise()
        {
            if (PhysicsEntity == null)
            {
                if (PhysicsMeshType == PhysicsMeshType.box)
                {
                    GenerateBoxCollider();
                }
                if (PhysicsMeshType == PhysicsMeshType.sphere)
                {
                    GenerateSphereCollider();
                }

                if (!movable)
                {
                    PhysicsEntity.BecomeKinematic();
                }
            }

            PhysicsEntity.Tag = ParentObject;
            PhysicsEntity.CollisionInformation.Tag = ParentObject;

            if (!SystemCore.PhysicsOnBackgroundThread)
            {
                PhysicsEntity.WorldTransform =
                    MonoMathHelper.GenerateBepuMatrixFromMono(ParentObject.Transform.AbsoluteTransform);
                SystemCore.PhysicsSimulation.Add(PhysicsEntity);
            }
            else
            {
                PhysicsEntity.BufferedStates.States.WorldTransform =
                    MonoMathHelper.GenerateBepuMatrixFromMono(ParentObject.Transform.AbsoluteTransform);
                SystemCore.PhysicsSimulation.SpaceObjectBuffer.Add(PhysicsEntity);
            }
        }
Beispiel #2
0
 public PhysicsComponent(Entity physicsEntity, bool movable, bool simulated)
 {
     Enabled            = true;
     Simulated          = simulated;
     this.PhysicsEntity = physicsEntity;
     if (!movable)
     {
         PhysicsEntity.BecomeKinematic();
     }
 }