public AvatarBoneAnimation(AvatarSkeleton skeleton, AvatarAnimationPreset preset) : base(skeleton, new AvatarAnimationController(skeleton.Renderer, preset)) { Skeleton = skeleton; animationBoneTransforms = new Matrix[AvatarRenderer.BoneCount]; readOnlyAnimationBoneTransforms = new ReadOnlyCollection <Matrix>(animationBoneTransforms); }
/// <summary> /// Constructor. /// </summary> /// <param name="preset">The specified standard animation.</param> public AvatarAnimationWrapper( AvatarAnimationPreset preset ) { customAnimation = null; animation = new AvatarAnimation( preset ); animation.CurrentPosition = TimeSpan.Zero; standardID = preset; }
public override void Update(GameTime gameTime) { if (_avatarPose == null) { if (_avatarRenderer.State == AvatarRendererState.Ready) { _avatarPose = new AvatarPose(_avatarRenderer); // Start the first animation. var wrappedAnimation = WrapAnimation(_currentAvatarAnimationPreset); AnimationService.StartAnimation(wrappedAnimation, _avatarPose).AutoRecycle(); _debugRenderer.Clear(); _debugRenderer.DrawText("\n\nCurrent Animation: " + _currentAvatarAnimationPreset); } } else { if (InputService.IsPressed(Buttons.A, false, LogicalPlayerIndex.One)) { // Switch to next preset. _currentAvatarAnimationPreset++; if (!Enum.IsDefined(typeof(AvatarAnimationPreset), _currentAvatarAnimationPreset)) { _currentAvatarAnimationPreset = 0; } // Cross-fade to new animation. var wrappedAnimation = WrapAnimation(_currentAvatarAnimationPreset); AnimationService.StartAnimation(wrappedAnimation, _avatarPose, AnimationTransitions.Replace(TimeSpan.FromSeconds(0.5)) ).AutoRecycle(); _debugRenderer.Clear(); _debugRenderer.DrawText("\n\nCurrent Animation: " + _currentAvatarAnimationPreset); } if (InputService.IsPressed(Buttons.B, false, LogicalPlayerIndex.One)) { // Switch to previous preset. _currentAvatarAnimationPreset--; if (!Enum.IsDefined(typeof(AvatarAnimationPreset), _currentAvatarAnimationPreset)) { _currentAvatarAnimationPreset = (AvatarAnimationPreset)EnumHelper.GetValues(typeof(AvatarAnimationPreset)).Length - 1; } // Cross-fade to new animation. var wrappedAnimation = WrapAnimation(_currentAvatarAnimationPreset); AnimationService.StartAnimation(wrappedAnimation, _avatarPose, AnimationTransitions.Replace(TimeSpan.FromSeconds(0.5)) ).AutoRecycle(); _debugRenderer.Clear(); _debugRenderer.DrawText("\n\nCurrent Animation: " + _currentAvatarAnimationPreset); } } }
public AvatarAnimationController(AvatarRenderer renderer, AvatarAnimationPreset preset) { if (renderer == null) { throw new ArgumentNullException("renderer"); } Renderer = renderer; Loop = true; avatarAnimation = new AvatarAnimation(preset); }
public ITimeline WrapAnimation(AvatarAnimationPreset preset) { // Return a timeline group that contains one animation for the Expression and one // animation for the SkeletonPose. var avatarAnimation = new AvatarAnimation(_currentAvatarAnimationPreset); var expressionAnimation = new WrappedAvatarExpressionAnimation(avatarAnimation); var skeletonAnimation = new WrappedAvatarSkeletonAnimation(avatarAnimation); return(new TimelineGroup { expressionAnimation, skeletonAnimation, }); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (_avatarPose == null) { if (_avatarRenderer.State == AvatarRendererState.Ready) { _avatarPose = new AvatarPose(_avatarRenderer); // Start the first animation. var wrappedAnimation = WrapAnimation(_currentAvatarAnimationPreset); AnimationService.StartAnimation(wrappedAnimation, _avatarPose).AutoRecycle(); _currentAnimationText = "Current Animation: " + _currentAvatarAnimationPreset; } } else { if (InputService.IsPressed(Buttons.A, false, PlayerIndex.One)) { // Switch to next preset. _currentAvatarAnimationPreset++; if (!Enum.IsDefined(typeof(AvatarAnimationPreset), _currentAvatarAnimationPreset)) _currentAvatarAnimationPreset = 0; // Cross-fade to new animation. var wrappedAnimation = WrapAnimation(_currentAvatarAnimationPreset); AnimationService.StartAnimation(wrappedAnimation, _avatarPose, AnimationTransitions.Replace(TimeSpan.FromSeconds(0.5)) ).AutoRecycle(); _currentAnimationText = "Current Animation: " + _currentAvatarAnimationPreset; } if (InputService.IsPressed(Buttons.B, false, PlayerIndex.One)) { // Switch to previous preset. _currentAvatarAnimationPreset--; if (!Enum.IsDefined(typeof(AvatarAnimationPreset), _currentAvatarAnimationPreset)) _currentAvatarAnimationPreset = (AvatarAnimationPreset)EnumHelper.GetValues(typeof(AvatarAnimationPreset)).Length - 1; // Cross-fade to new animation. var wrappedAnimation = WrapAnimation(_currentAvatarAnimationPreset); AnimationService.StartAnimation(wrappedAnimation, _avatarPose, AnimationTransitions.Replace(TimeSpan.FromSeconds(0.5)) ).AutoRecycle(); _currentAnimationText = "Current Animation: " + _currentAvatarAnimationPreset; } } }
public ITimeline WrapAnimation(AvatarAnimationPreset preset) { // Return a timeline group that contains one animation for the Expression and one // animation for the SkeletonPose. var avatarAnimation = new AvatarAnimation(_currentAvatarAnimationPreset); var expressionAnimation = new WrappedExpressionAnimation(avatarAnimation); var skeletonAnimation = new WrappedSkeletonAnimation(avatarAnimation); return new TimelineGroup { expressionAnimation, skeletonAnimation, }; }
public Avatar( AvatarDescription body, AvatarAnimationPreset anim, float scale, Vector3 dir, Vector3 pos ) : this(body, new AvatarAnimationWrapper( anim ), scale, dir, pos) { }
public void SetAnimation( AvatarAnimationPreset preset ) { if ( !currentAnimation.IsOfType( preset ) && ( targetAnimation == null || !targetAnimation.IsOfType( preset ) ) ) { if ( !presets.ContainsKey( preset ) ) presets.Add( preset, new AvatarAnimationWrapper( preset ) ); targetAnimation = presets[preset]; targetAnimation.CurrentPosition = TimeSpan.Zero; blendTimeCurrent = 0f; } }
public AvatarAnimation(AvatarAnimationPreset animationPreset) { throw new NotImplementedException(); }
/// <summary> /// Checks if the animation matches a preset. /// </summary> /// <param name="preset">The animation preset.</param> /// <returns>True if the preset matches the type of the animation.</returns> public bool IsOfType( AvatarAnimationPreset preset ) { return ( preset == standardID ); }
public Player( GameplayScreen screen, int playerNumber, PlayerIndex playerIndex, Avatar avatar, Vector2 pos, uint id ) : base(screen) { WheelModel = screen.Content.Load<CustomModel>( "Models/hamsterBall" ); foreach ( CustomModelSample.CustomModel.ModelPart part in WheelModel.ModelParts ) { part.Effect.CurrentTechnique = part.Effect.Techniques["Color"]; part.Effect.Parameters["Color"].SetValue( new Vector4( .8f, .7f, 1f, .225f ) ); part.Effect.Parameters["SpecularPower"].SetValue( 400 ); part.Effect.Parameters["Mask"].SetValue( MaskHelper.MotionBlur( 1 ) ); } DrawOrder = 8; WinState = PlayerWinState.None; soundPosition = Vector3.Zero; soundVelocity = Vector3.Zero; float depth = screen.Camera.Position.Z; DeathLine = depth * (float)Math.Tan( screen.Camera.Fov / 2f ); RespawnTime = float.MaxValue; shrinkBegin = 0; Scale = 1f; ScaleSpring = new SpringInterpolater( 1, 200, SpringInterpolater.GetCriticalDamping( 200 ) ); ScaleSpring.Active = true; ScaleSpring.SetSource( Scale ); ScaleSpring.SetDest( Scale ); PlayerIndex = playerIndex; PlayerNumber = playerNumber; BoostBurnRate = 1f; BoostRechargeRate = .25f; Avatar = avatar; BoundingCircle = new PhysCircle( Size / 2f, pos, 10f ); BoundingCircle.Parent = this; BoundingCircle.Elasticity = .4f; BoundingCircle.Friction = .5f; BoundingCircle.Collided += HandleCollision; BoundingCircle.Responded += HandleCollisionResponse; screen.PhysicsSpace.AddBody( BoundingCircle ); walkAnim = CustomAvatarAnimationData.GetAvatarAnimationData( "Walk", Screen.Content ); runAnim = CustomAvatarAnimationData.GetAvatarAnimationData( "Run", Screen.Content ); // pre-load animations for podium screen avatar.SetAnimation( AvatarAnimationPreset.Celebrate ); avatar.SetAnimation( AvatarAnimationPreset.Clap ); avatar.SetAnimation( AvatarAnimationPreset.FemaleAngry ); avatar.SetAnimation( AvatarAnimationPreset.MaleCry ); standAnim = (AvatarAnimationPreset)( (int)AvatarAnimationPreset.Stand0 + random.Next( 8 ) ); avatar.SetAnimation( standAnim ); if ( playerIndex >= PlayerIndex.One ) { HUD = new PlayerHUD( this, SignedInGamer.SignedInGamers[playerIndex] ); } else { HUD = new PlayerHUD( this, null ); playerAI = new PlayerAI( this ); } vertexDeclaration = new VertexDeclaration( screen.ScreenManager.GraphicsDevice, VertexPositionNormalTexture.VertexElements ); boosterSound = GameCore.Instance.AudioManager.Play2DCue( "booster", 1f ); boosterSound.Pause(); glow = new CircularGlow( new Vector3( BoundingCircle.Position, 0 ), Color.OrangeRed, Size ); glow.Player = this; screen.ObjectTable.Add( glow ); glowSpring = new SpringInterpolater( 1, 500, .75f * SpringInterpolater.GetCriticalDamping( 500 ) ); glowSpring.Active = true; glowSpring.SetSource( 0 ); glowSpring.SetDest( 0 ); Tag = new PlayerTag( this, screen.Content.Load<SpriteFont>( "Fonts/playerTagFont" ) ); SetID( id ); }
public AvatarAnimation(AvatarAnimationPreset animationPreset) { throw new NotImplementedException(); }