// If a hover motor has not been created, create one and start the hovering. private void ActivateMoveToTarget() { if (m_targetMotor == null) { // We're taking over after this. m_controllingPrim.ZeroMotion(true); /* Someday use the PID controller * m_targetMotor = new BSPIDVMotor("BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString()); * m_targetMotor.TimeScale = m_controllingPrim.MoveToTargetTau; * m_targetMotor.Efficiency = 1f; */ m_targetMotor = new BSVMotor("BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString(), m_controllingPrim.MoveToTargetTau, // timeScale BSMotor.Infinite, // decay time scale 1f // efficiency ); m_targetMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG so motor will output detail log messages. m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget); m_targetMotor.SetCurrent(m_controllingPrim.RawPosition); // m_physicsScene.BeforeStep += Mover; m_physicsScene.BeforeStep += Mover2; } else { // If already allocated, make sure the target and other paramters are current m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget); m_targetMotor.SetCurrent(m_controllingPrim.RawPosition); } }
public BSActorAvatarMove(BSScene physicsScene, BSPhysObject pObj, string actorName) : base(physicsScene, pObj, actorName) { m_velocityMotor = null; m_walkingUpStairs = 0; m_physicsScene.DetailLog("{0},BSActorAvatarMove,constructor", m_controllingPrim.LocalID); }
public BSActorAvatarMove(BSScene physicsScene, BSPhysObject pObj, string actorName) : base(physicsScene, pObj, actorName) { m_velocityMotor = null; m_walkingUpStairs = 0; m_physicsScene.DetailLog("{0},BSActorAvatarMove,constructor", m_controllingPrim.LocalID); }
private void DeactivateMoveToTarget() { if (m_targetMotor != null) { m_physicsScene.BeforeStep -= Mover; m_targetMotor = null; } }
private void DeactivateAvatarMove() { if (m_velocityMotor != null) { m_physicsScene.BeforeStep -= Mover; m_velocityMotor = null; } }
private void DeactivateAvatarMove() { if (m_velocityMotor != null) { m_controllingPrim.OnPreUpdateProperty -= Process_OnPreUpdateProperty; m_physicsScene.BeforeStep -= Mover; m_velocityMotor = null; } }
// The avatar's movement is controlled by this motor that speeds up and slows down // the avatar seeking to reach the motor's target speed. // This motor runs as a prestep action for the avatar so it will keep the avatar // standing as well as moving. Destruction of the avatar will destroy the pre-step action. private void SetupMovementMotor() { // Someday, use a PID motor for asymmetric speed up and slow down // _velocityMotor = new BSPIDVMotor("BSCharacter.Velocity", 3f, 5f, BSMotor.InfiniteVector, 1f); // Infinite decay and timescale values so motor only changes current to target values. _velocityMotor = new BSVMotor("BSCharacter.Velocity", 0.2f, // time scale BSMotor.Infinite, // decay time scale BSMotor.InfiniteVector, // friction timescale 1f // efficiency ); // _velocityMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG so motor will output detail log messages. RegisterPreStepAction("BSCharactor.Movement", LocalID, delegate(float timeStep) { // TODO: Decide if the step parameters should be changed depending on the avatar's // state (flying, colliding, ...). There is code in ODE to do this. OMV.Vector3 stepVelocity = _velocityMotor.Step(timeStep); // If falling, we keep the world's downward vector no matter what the other axis specify. if (!Flying && !IsColliding) { stepVelocity.Z = _velocity.Z; // DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity); } // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. OMV.Vector3 moveForce = (stepVelocity - _velocity) * Mass / PhysicsScene.LastTimeStep; /* * // If moveForce is very small, zero things so we don't keep sending microscopic updates to the user * float moveForceMagnitudeSquared = moveForce.LengthSquared(); * if (moveForceMagnitudeSquared < 0.0001) * { * DetailLog("{0},BSCharacter.MoveMotor,zeroMovement,stepVel={1},vel={2},mass={3},magSq={4},moveForce={5}", * LocalID, stepVelocity, _velocity, Mass, moveForceMagnitudeSquared, moveForce); * ForceVelocity = OMV.Vector3.Zero; * } * else * { * AddForce(moveForce, false, true); * } */ // DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce); AddForce(moveForce, false, true); }); }
// If a hover motor has not been created, create one and start the hovering. private void ActivateAvatarMove() { if (m_velocityMotor == null) { // Infinite decay and timescale values so motor only changes current to target values. m_velocityMotor = new BSVMotor("BSCharacter.Velocity", 0.2f, // time scale BSMotor.Infinite, // decay time scale BSMotor.InfiniteVector, // friction timescale 1f // efficiency ); // _velocityMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG so motor will output detail log messages. SetVelocityAndTarget(m_controllingPrim.RawVelocity, m_controllingPrim.TargetVelocity, true /* inTaintTime */, 0); m_physicsScene.BeforeStep += Mover; } }
// If a hover motor has not been created, create one and start the hovering. private void ActivateMoveToTarget() { if (m_targetMotor == null) { // We're taking over after this. m_controllingPrim.ZeroMotion(true); m_targetMotor = new BSVMotor("BSActorMoveToTargget.Activate", m_controllingPrim.MoveToTargetTau, // timeScale BSMotor.Infinite, // decay time scale 1f // efficiency ); m_targetMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG so motor will output detail log messages. m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget); m_targetMotor.SetCurrent(m_controllingPrim.RawPosition); m_physicsScene.BeforeStep += Mover; } }
// If a hover motor has not been created, create one and start the hovering. private void ActivateAvatarMove() { if (m_velocityMotor == null) { // Infinite decay and timescale values so motor only changes current to target values. m_velocityMotor = new BSVMotor("BSCharacter.Velocity", 0.2f, // time scale BSMotor.Infinite, // decay time scale 1f // efficiency ); m_velocityMotor.ErrorZeroThreshold = BSParam.AvatarStopZeroThreshold; // _velocityMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG so motor will output detail log messages. SetVelocityAndTarget(m_controllingPrim.RawVelocity, m_controllingPrim.TargetVelocity, true /* inTaintTime */); m_physicsScene.BeforeStep += Mover; m_controllingPrim.OnPreUpdateProperty += Process_OnPreUpdateProperty; m_walkingUpStairs = 0; } }
// If a hover motor has not been created, create one and start the hovering. private void ActivateAvatarMove() { if (m_velocityMotor == null) { // Infinite decay and timescale values so motor only changes current to target values. m_velocityMotor = new BSVMotor("BSCharacter.Velocity", 0.2f, // time scale BSMotor.Infinite, // decay time scale 1f // efficiency ); // _velocityMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG so motor will output detail log messages. SetVelocityAndTarget(m_controllingPrim.RawVelocity, m_controllingPrim.TargetVelocity, true /* inTaintTime */); m_physicsScene.BeforeStep += Mover; m_walkingUpStairs = 0; } }
private void DeactivateMoveToTarget() { if (m_targetMotor != null) { // m_physicsScene.BeforeStep -= Mover; m_physicsScene.BeforeStep -= Mover2; m_targetMotor = null; } }
public void ProcessTypeChange(Vehicle pType) { VDetailLog("{0},ProcessTypeChange,type={1}", ControllingPrim.LocalID, pType); // Set Defaults For Type Type = pType; switch (pType) { case Vehicle.TYPE_NONE: m_linearMotorDirection = Vector3.Zero; m_linearMotorTimescale = 0; m_linearMotorDecayTimescale = 0; m_linearFrictionTimescale = new Vector3(0, 0, 0); m_angularMotorDirection = Vector3.Zero; m_angularMotorDecayTimescale = 0; m_angularMotorTimescale = 0; m_angularFrictionTimescale = new Vector3(0, 0, 0); m_VhoverHeight = 0; m_VhoverEfficiency = 0; m_VhoverTimescale = 0; m_VehicleBuoyancy = 0; m_linearDeflectionEfficiency = 1; m_linearDeflectionTimescale = 1; m_angularDeflectionEfficiency = 0; m_angularDeflectionTimescale = 1000; m_verticalAttractionEfficiency = 0; m_verticalAttractionTimescale = 0; m_bankingEfficiency = 0; m_bankingTimescale = 1000; m_bankingMix = 1; m_referenceFrame = Quaternion.Identity; m_flags = (VehicleFlag)0; break; case Vehicle.TYPE_SLED: m_linearMotorDirection = Vector3.Zero; m_linearMotorTimescale = 1000; m_linearMotorDecayTimescale = 120; m_linearFrictionTimescale = new Vector3(30, 1, 1000); m_angularMotorDirection = Vector3.Zero; m_angularMotorTimescale = 1000; m_angularMotorDecayTimescale = 120; m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); m_VhoverHeight = 0; m_VhoverEfficiency = 10; // TODO: this looks wrong!! m_VhoverTimescale = 10; m_VehicleBuoyancy = 0; m_linearDeflectionEfficiency = 1; m_linearDeflectionTimescale = 1; m_angularDeflectionEfficiency = 1; m_angularDeflectionTimescale = 1000; m_verticalAttractionEfficiency = 0; m_verticalAttractionTimescale = 0; m_bankingEfficiency = 0; m_bankingTimescale = 10; m_bankingMix = 1; m_referenceFrame = Quaternion.Identity; m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); break; case Vehicle.TYPE_CAR: m_linearMotorDirection = Vector3.Zero; m_linearMotorTimescale = 1; m_linearMotorDecayTimescale = 60; m_linearFrictionTimescale = new Vector3(100, 2, 1000); m_angularMotorDirection = Vector3.Zero; m_angularMotorTimescale = 1; m_angularMotorDecayTimescale = 0.8f; m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); m_VhoverHeight = 0; m_VhoverEfficiency = 0; m_VhoverTimescale = 1000; m_VehicleBuoyancy = 0; m_linearDeflectionEfficiency = 1; m_linearDeflectionTimescale = 2; m_angularDeflectionEfficiency = 0; m_angularDeflectionTimescale = 10; m_verticalAttractionEfficiency = 1f; m_verticalAttractionTimescale = 10f; m_bankingEfficiency = -0.2f; m_bankingMix = 1; m_bankingTimescale = 1; m_referenceFrame = Quaternion.Identity; m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP | VehicleFlag.HOVER_UP_ONLY); break; case Vehicle.TYPE_BOAT: m_linearMotorDirection = Vector3.Zero; m_linearMotorTimescale = 5; m_linearMotorDecayTimescale = 60; m_linearFrictionTimescale = new Vector3(10, 3, 2); m_angularMotorDirection = Vector3.Zero; m_angularMotorTimescale = 4; m_angularMotorDecayTimescale = 4; m_angularFrictionTimescale = new Vector3(10,10,10); m_VhoverHeight = 0; m_VhoverEfficiency = 0.5f; m_VhoverTimescale = 2; m_VehicleBuoyancy = 1; m_linearDeflectionEfficiency = 0.5f; m_linearDeflectionTimescale = 3; m_angularDeflectionEfficiency = 0.5f; m_angularDeflectionTimescale = 5; m_verticalAttractionEfficiency = 0.5f; m_verticalAttractionTimescale = 5f; m_bankingEfficiency = -0.3f; m_bankingMix = 0.8f; m_bankingTimescale = 1; m_referenceFrame = Quaternion.Identity; m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_UP_ONLY); m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP | VehicleFlag.HOVER_WATER_ONLY); break; case Vehicle.TYPE_AIRPLANE: m_linearMotorDirection = Vector3.Zero; m_linearMotorTimescale = 2; m_linearMotorDecayTimescale = 60; m_linearFrictionTimescale = new Vector3(200, 10, 5); m_angularMotorDirection = Vector3.Zero; m_angularMotorTimescale = 4; m_angularMotorDecayTimescale = 4; m_angularFrictionTimescale = new Vector3(20, 20, 20); m_VhoverHeight = 0; m_VhoverEfficiency = 0.5f; m_VhoverTimescale = 1000; m_VehicleBuoyancy = 0; m_linearDeflectionEfficiency = 0.5f; m_linearDeflectionTimescale = 3; m_angularDeflectionEfficiency = 1; m_angularDeflectionTimescale = 2; m_verticalAttractionEfficiency = 0.9f; m_verticalAttractionTimescale = 2f; m_bankingEfficiency = 1; m_bankingMix = 0.7f; m_bankingTimescale = 2; m_referenceFrame = Quaternion.Identity; m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY | VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); break; case Vehicle.TYPE_BALLOON: m_linearMotorDirection = Vector3.Zero; m_linearMotorTimescale = 5; m_linearFrictionTimescale = new Vector3(5, 5, 5); m_linearMotorDecayTimescale = 60; m_angularMotorDirection = Vector3.Zero; m_angularMotorTimescale = 6; m_angularFrictionTimescale = new Vector3(10, 10, 10); m_angularMotorDecayTimescale = 10; m_VhoverHeight = 5; m_VhoverEfficiency = 0.8f; m_VhoverTimescale = 10; m_VehicleBuoyancy = 1; m_linearDeflectionEfficiency = 0; m_linearDeflectionTimescale = 5; m_angularDeflectionEfficiency = 0; m_angularDeflectionTimescale = 5; m_verticalAttractionEfficiency = 1f; m_verticalAttractionTimescale = 100f; m_bankingEfficiency = 0; m_bankingMix = 0.7f; m_bankingTimescale = 5; m_referenceFrame = Quaternion.Identity; m_referenceFrame = Quaternion.Identity; m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_UP_ONLY | VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); break; } m_linearMotor = new BSVMotor("LinearMotor", m_linearMotorTimescale, m_linearMotorDecayTimescale, 1f); // m_linearMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG DEBUG (enables detail logging) m_angularMotor = new BSVMotor("AngularMotor", m_angularMotorTimescale, m_angularMotorDecayTimescale, 1f); // m_angularMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG DEBUG (enables detail logging) /* Not implemented m_verticalAttractionMotor = new BSVMotor("VerticalAttraction", m_verticalAttractionTimescale, BSMotor.Infinite, BSMotor.InfiniteVector, m_verticalAttractionEfficiency); // Z goes away and we keep X and Y m_verticalAttractionMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG DEBUG (enables detail logging) */ if (this.Type == Vehicle.TYPE_NONE) { UnregisterForSceneEvents(); } else { RegisterForSceneEvents(); } // Update any physical parameters based on this type. Refresh(); }
// The avatar's movement is controlled by this motor that speeds up and slows down // the avatar seeking to reach the motor's target speed. // This motor runs as a prestep action for the avatar so it will keep the avatar // standing as well as moving. Destruction of the avatar will destroy the pre-step action. private void SetupMovementMotor() { // Someday, use a PID motor for asymmetric speed up and slow down // _velocityMotor = new BSPIDVMotor("BSCharacter.Velocity", 3f, 5f, BSMotor.InfiniteVector, 1f); // Infinite decay and timescale values so motor only changes current to target values. _velocityMotor = new BSVMotor("BSCharacter.Velocity", 0.2f, // time scale BSMotor.Infinite, // decay time scale BSMotor.InfiniteVector, // friction timescale 1f // efficiency ); // _velocityMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG so motor will output detail log messages. RegisterPreStepAction("BSCharactor.Movement", LocalID, delegate(float timeStep) { // TODO: Decide if the step parameters should be changed depending on the avatar's // state (flying, colliding, ...). There is code in ODE to do this. OMV.Vector3 stepVelocity = _velocityMotor.Step(timeStep); // If falling, we keep the world's downward vector no matter what the other axis specify. if (!Flying && !IsColliding) { stepVelocity.Z = _velocity.Z; // DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity); } // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. OMV.Vector3 moveForce = (stepVelocity - _velocity) * Mass / PhysicsScene.LastTimeStep; /* // If moveForce is very small, zero things so we don't keep sending microscopic updates to the user float moveForceMagnitudeSquared = moveForce.LengthSquared(); if (moveForceMagnitudeSquared < 0.0001) { DetailLog("{0},BSCharacter.MoveMotor,zeroMovement,stepVel={1},vel={2},mass={3},magSq={4},moveForce={5}", LocalID, stepVelocity, _velocity, Mass, moveForceMagnitudeSquared, moveForce); ForceVelocity = OMV.Vector3.Zero; } else { AddForce(moveForce, false, true); } */ // DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce); AddForce(moveForce, false, true); }); }
public BSActorMoveToTarget(BSScene physicsScene, BSPhysObject pObj, string actorName) : base(physicsScene, pObj, actorName) { m_targetMotor = null; m_physicsScene.DetailLog("{0},BSActorMoveToTarget,constructor", m_controllingPrim.LocalID); }
// If a hover motor has not been created, create one and start the hovering. private void ActivateMoveToTarget() { if (m_targetMotor == null) { // We're taking over after this. m_controllingPrim.ZeroMotion(true); m_targetMotor = new BSVMotor("BSActorMoveToTargget.Activate", m_controllingPrim.MoveToTargetTau, // timeScale BSMotor.Infinite, // decay time scale 1f // efficiency ); m_targetMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG so motor will output detail log messages. m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget); m_targetMotor.SetCurrent(m_controllingPrim.RawPosition); m_physicsScene.BeforeStep += Mover; } }
private void DeactivateAvatarMove() { if (m_velocityMotor != null) { m_controllingPrim.OnPreUpdateProperty -= Process_OnPreUpdateProperty; m_physicsScene.BeforeStep -= Mover; m_velocityMotor = null; } }
public BSActorMoveToTarget(BSScene physicsScene, BSPhysObject pObj, string actorName) : base(physicsScene, pObj, actorName) { m_targetMotor = null; m_physicsScene.DetailLog("{0},BSActorMoveToTarget,constructor", m_controllingPrim.LocalID); }
private void DeactivateAvatarMove() { if (m_velocityMotor != null) { m_physicsScene.BeforeStep -= Mover; m_velocityMotor = null; } }
// The avatar's movement is controlled by this motor that speeds up and slows down // the avatar seeking to reach the motor's target speed. // This motor runs as a prestep action for the avatar so it will keep the avatar // standing as well as moving. Destruction of the avatar will destroy the pre-step action. private void SetupMovementMotor() { // Infinite decay and timescale values so motor only changes current to target values. _velocityMotor = new BSVMotor("BSCharacter.Velocity", 0.2f, // time scale BSMotor.Infinite, // decay time scale BSMotor.InfiniteVector, // friction timescale 1f // efficiency ); // _velocityMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG so motor will output detail log messages. RegisterPreStepAction("BSCharactor.Movement", LocalID, delegate(float timeStep) { // TODO: Decide if the step parameters should be changed depending on the avatar's // state (flying, colliding, ...). There is code in ODE to do this. // COMMENTARY: when the user is making the avatar walk, except for falling, the velocity // specified for the avatar is the one that should be used. For falling, if the avatar // is not flying and is not colliding then it is presumed to be falling and the Z // component is not fooled with (thus allowing gravity to do its thing). // When the avatar is standing, though, the user has specified a velocity of zero and // the avatar should be standing. But if the avatar is pushed by something in the world // (raising elevator platform, moving vehicle, ...) the avatar should be allowed to // move. Thus, the velocity cannot be forced to zero. The problem is that small velocity // errors can creap in and the avatar will slowly float off in some direction. // So, the problem is that, when an avatar is standing, we cannot tell creaping error // from real pushing. // The code below uses whether the collider is static or moving to decide whether to zero motion. _velocityMotor.Step(timeStep); // If we're not supposed to be moving, make sure things are zero. if (_velocityMotor.ErrorIsZero() && _velocityMotor.TargetValue == OMV.Vector3.Zero) { // The avatar shouldn't be moving _velocityMotor.Zero(); if (IsColliding) { // If we are colliding with a stationary object, presume we're standing and don't move around if (!ColliderIsMoving) { DetailLog("{0},BSCharacter.MoveMotor,collidingWithStationary,zeroingMotion", LocalID); ZeroMotion(true /* inTaintTime */); } // Standing has more friction on the ground if (Friction != BSParam.AvatarStandingFriction) { Friction = BSParam.AvatarStandingFriction; PhysicsScene.PE.SetFriction(PhysBody, Friction); } } else { if (Flying) { // Flying and not collising and velocity nearly zero. ZeroMotion(true /* inTaintTime */); } } DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1},colliding={2}", LocalID, _velocityMotor.TargetValue, IsColliding); } else { // Supposed to be moving. OMV.Vector3 stepVelocity = _velocityMotor.CurrentValue; if (Friction != BSParam.AvatarFriction) { // Probably starting up walking. Set friction to moving friction. Friction = BSParam.AvatarFriction; PhysicsScene.PE.SetFriction(PhysBody, Friction); } // If falling, we keep the world's downward vector no matter what the other axis specify. // The check for _velocity.Z < 0 makes jumping work (temporary upward force). if (!Flying && !IsColliding) { if (_velocity.Z < 0) stepVelocity.Z = _velocity.Z; // DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity); } // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. OMV.Vector3 moveForce = (stepVelocity - _velocity) * Mass; // Should we check for move force being small and forcing velocity to zero? // Add special movement force to allow avatars to walk up stepped surfaces. moveForce += WalkUpStairs(); DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce); PhysicsScene.PE.ApplyCentralImpulse(PhysBody, moveForce); } }); }
// If a hover motor has not been created, create one and start the hovering. private void ActivateMoveToTarget() { if (m_targetMotor == null) { // We're taking over after this. m_controllingPrim.ZeroMotion(true); /* Someday use the PID controller m_targetMotor = new BSPIDVMotor("BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString()); m_targetMotor.TimeScale = m_controllingPrim.MoveToTargetTau; m_targetMotor.Efficiency = 1f; */ m_targetMotor = new BSVMotor("BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString(), m_controllingPrim.MoveToTargetTau, // timeScale BSMotor.Infinite, // decay time scale 1f // efficiency ); m_targetMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG so motor will output detail log messages. m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget); m_targetMotor.SetCurrent(m_controllingPrim.RawPosition); // m_physicsScene.BeforeStep += Mover; m_physicsScene.BeforeStep += Mover2; } else { // If already allocated, make sure the target and other paramters are current m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget); m_targetMotor.SetCurrent(m_controllingPrim.RawPosition); } }