Beispiel #1
0
        // Called just before the simulation step. Update the vertical position for hoverness.
        private void Hoverer(float timeStep)
        {
            // Don't do hovering while the object is selected.
            if (!isActive)
            {
                return;
            }

            m_hoverMotor.SetCurrent(m_controllingPrim.RawPosition.Z);
            m_hoverMotor.SetTarget(ComputeCurrentHoverHeight());
            float targetHeight = m_hoverMotor.Step(timeStep);

            // 'targetHeight' is where we'd like the Z of the prim to be at this moment.
            // Compute the amount of force to push us there.
            float moveForce = (targetHeight - m_controllingPrim.RawPosition.Z) * m_controllingPrim.RawMass;

            // Undo anything the object thinks it's doing at the moment
            moveForce = -m_controllingPrim.RawVelocity.Z * m_controllingPrim.Mass;

            m_physicsScene.PE.ApplyCentralImpulse(m_controllingPrim.PhysBody, new OMV.Vector3(0f, 0f, moveForce));
            m_physicsScene.DetailLog("{0},BSPrim.Hover,move,targHt={1},moveForce={2},mass={3}",
                                     m_controllingPrim.LocalID, targetHeight, moveForce, m_controllingPrim.RawMass);
        }