Пример #1
0
 public override void UpdateForce(RigidBody body, float duration)
 {
     Vector3 pointInWorld = body.GetPointInWorldSpace(CenterOfBuoyancy);
     float depth = pointInWorld.Y;
     if (depth >= WaterHeight + MaxDepth) return;
     Vector3 force = new Vector3(0, 0, 0);
     if (depth <= WaterHeight - MaxDepth)
     {
         force.Y = LiquidDensity * Volume;
         body.AddForceAtBodyPoint(force, CenterOfBuoyancy);
         return;
     }
     force.Y = LiquidDensity * Volume * ((depth - MaxDepth - WaterHeight) / 2.0f) * MaxDepth;
     body.AddForceAtBodyPoint(force, CenterOfBuoyancy);
 }
Пример #2
0
 internal void updateforcefromtensor(RigidBody body, float duration, Matrix3 tensor)
 {
     Vector3 velocity = body.GetVelocity();
     velocity += WindSpeed;
     Vector3 bodyVel = body.GetTransform().TransformInverseDirection(velocity);
     Vector3 bodyForce = tensor.Transform(bodyVel);
     Vector3 force = body.GetTransform().TransformDirection(bodyForce);
     body.AddForceAtBodyPoint(force, Position);
 }