void UpdateAnimationTree() { if (EntitySystemWorld.Instance.Simulation && !EntitySystemWorld.Instance.SystemPauseOfSimulation) { AnimationTree tree = GetFirstAnimationTree(); if (tree != null) { bool onGround = GetElapsedTimeSinceLastGroundContact() < .2f; //IsOnGround(); bool move = false; Degree moveAngle = 0; float moveSpeed = 0; if (onGround && GroundRelativeVelocitySmooth.ToVec2().Length() > .05f) { move = true; Vec2 localVec = (Rotation.GetInverse() * GroundRelativeVelocity).ToVec2(); Radian angle = MathFunctions.ATan(localVec.Y, localVec.X); moveAngle = angle.InDegrees(); moveSpeed = GroundRelativeVelocity.ToVec2().Length(); } tree.SetParameterValue("move", move ? 1 : 0); tree.SetParameterValue("run", move && IsNeedRun() ? 1 : 0); tree.SetParameterValue("moveAngle", moveAngle); tree.SetParameterValue("moveSpeed", moveSpeed); tree.SetParameterValue("fly", !onGround ? 1 : 0); } } }
void UpdateAnimationTree() { if (EntitySystemWorld.Instance.Simulation && !EntitySystemWorld.Instance.SystemPauseOfSimulation) { AnimationTree tree = GetFirstAnimationTree(); if (tree != null) { tree.SetParameterValue("weapon", activeWeapon != null ? 1 : 0); Radian horizontalAngle = 0; Radian verticalAngle = 0; PlayerIntellect playerIntellect = Intellect as PlayerIntellect; if (playerIntellect != null) { Vec2 vec = Vec2.Zero; vec.X += playerIntellect.GetControlKeyStrength(GameControlKeys.Forward); vec.X -= playerIntellect.GetControlKeyStrength(GameControlKeys.Backward); vec.Y += playerIntellect.GetControlKeyStrength(GameControlKeys.Left); vec.Y -= playerIntellect.GetControlKeyStrength(GameControlKeys.Right); if (vec.X < 0) { vec = -vec; } horizontalAngle = MathFunctions.ATan(vec.Y, vec.X); verticalAngle = playerIntellect.LookDirection.Vertical; } tree.SetParameterValue("weaponHorizontalAngle", horizontalAngle.InDegrees()); tree.SetParameterValue("weaponVerticalAngle", verticalAngle.InDegrees()); } } }
void UpdateAnimationTree(AnimationTree tree) { bool move = false; //Degree moveAngle = 0; float moveSpeed = 0; if (mainBodyVelocity.ToVec2().Length() > .1f) { move = true; moveSpeed = (Rotation.GetInverse() * mainBodyVelocity).X; } tree.SetParameterValue("move", move ? 1 : 0); //tree.SetParameterValue( "moveAngle", moveAngle ); tree.SetParameterValue("moveSpeed", moveSpeed); }
void UpdateFirstPersonArmsAttachedMesh(MapObjectAttachedMesh armsAttachedMesh, Camera camera) { //update animation tree if (EntitySystemWorld.Instance.Simulation && !EntitySystemWorld.Instance.SystemPauseOfSimulation) { AnimationTree tree = armsAttachedMesh.AnimationTree; if (tree != null) { bool onGround = GetElapsedTimeSinceLastGroundContact() < .2f; //IsOnGround(); bool move = false; float moveSpeed = 0; if (onGround && GroundRelativeVelocitySmooth.ToVec2().Length() > .05f) { move = true; moveSpeed = GroundRelativeVelocity.ToVec2().Length(); } tree.SetParameterValue("move", move ? 1 : 0); tree.SetParameterValue("run", move && IsNeedRun() ? 1 : 0); tree.SetParameterValue("moveSpeed", moveSpeed); float moveSpeedFactor = moveSpeed / Type.RunForwardMaxSpeed; if (moveSpeedFactor > 1) { moveSpeedFactor = 1; } tree.SetParameterValue("moveSpeedFactor", moveSpeedFactor); } } //update scene node armsAttachedMesh.SceneNode.Position = camera.Position + camera.Rotation * armsAttachedMesh.TypeObject.Position; armsAttachedMesh.SceneNode.Rotation = camera.Rotation * armsAttachedMesh.TypeObject.Rotation; //use this code to look arms from another point of view. Useful for calibration position of attached weapon. //armsAttachedMesh.SceneNode.Position = new Vec3( 0, 0, 2 ) + Quat.Identity * armsAttachedMesh.TypeObject.Position; //armsAttachedMesh.SceneNode.Rotation = Quat.Identity * armsAttachedMesh.TypeObject.Rotation; }
public override void UpdateAnimationTree(AnimationTree tree) { bool move = false; //Degree moveAngle = 0; float moveSpeed = 0; if (MainBodyVelocity.ToVec2().Length() > .1f) { move = true; moveSpeed = (Rotation.GetInverse() * MainBodyVelocity).X; } tree.SetParameterValue("idle", move ? 0 : 1); tree.SetParameterValue("move", move ? 1 : 0); tree.SetParameterValue("run", move && IsRunning ? 1 : 0); if (!IsRunning && moveSpeed > 1.5f) { moveSpeed = 1.5f; } tree.SetParameterValue("moveSpeed", moveSpeed); }
void UpdateAnimationTree( AnimationTree tree ) { bool move = false; //Degree moveAngle = 0; float moveSpeed = 0; if( mainBodyVelocity.ToVec2().LengthFast() > .1f ) { move = true; moveSpeed = ( Rotation.GetInverse() * mainBodyVelocity ).X; } tree.SetParameterValue( "move", move ? 1 : 0 ); //tree.SetParameterValue( "moveAngle", moveAngle ); tree.SetParameterValue( "moveSpeed", moveSpeed ); }