Пример #1
0
        // If a hover motor has not been created, create one and start the hovering.
        private void ActivateHover()
        {
            if (m_hoverMotor == null)
            {
                // Turning the target on
                m_hoverMotor = new BSFMotor("BSActorHover",
                                            m_controllingPrim.HoverTau, // timeScale
                                            BSMotor.Infinite,           // decay time scale
                                            1f                          // efficiency
                                            );
                m_hoverMotor.SetTarget(ComputeCurrentHoverHeight());
                m_hoverMotor.SetCurrent(m_controllingPrim.RawPosition.Z);
                m_hoverMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG so motor will output detail log messages.

                m_physicsScene.BeforeStep += Hoverer;
            }
        }
Пример #2
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);
        }
Пример #3
0
    // If a hover motor has not been created, create one and start the hovering.
    private void ActivateHover()
    {
        if (m_hoverMotor == null)
        {
            // Turning the target on
            m_hoverMotor = new BSFMotor("BSActorHover",
                                        m_controllingPrim.HoverTau,               // timeScale
                                        BSMotor.Infinite,           // decay time scale
                                        1f                          // efficiency
            );
            m_hoverMotor.SetTarget(ComputeCurrentHoverHeight());
            m_hoverMotor.SetCurrent(m_controllingPrim.RawPosition.Z);
            m_hoverMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG so motor will output detail log messages.

            m_physicsScene.BeforeStep += Hoverer;
        }
    }