Exemple #1
0
 public Avatar()
 {
     // We pick a random animation and description for each avatar we create
     Animation   = new AvatarAnimation((AvatarAnimationPreset)random.Next(30));
     Description = AvatarDescription.CreateRandom();
     Renderer    = new AvatarRenderer(Description, false);
 }
Exemple #2
0
    private IEnumerator loadRenderGameObjects(DCustomEquipment[] outfit, AvatarAnimationFrame avatarFrame)
    {
        if (avatarInstance != null)
        {
            continueAvatarRender = false;
            cleanupRenderObjects();
            yield return(null);
        }
        while (lightingRig != null && !lightingRig.IsReady)
        {
            yield return(null);
        }
        AssetRequest <GameObject> assetRequest = null;

        try
        {
            assetRequest = Content.LoadAsync(uiAvatarPrefabContentKey);
        }
        catch (Exception ex)
        {
            Log.LogError(this, $"Could not load UI Avatar penguin asset {uiAvatarPrefabContentKey.Key}. Message: {ex.Message}");
        }
        if (assetRequest != null)
        {
            yield return(assetRequest);

            avatarInstance = UnityEngine.Object.Instantiate(assetRequest.Asset);
            DCustomOutfit avatarOutfit = default(DCustomOutfit);
            avatarOutfit.Equipment = outfit;
            avatarImageSet         = false;
            continueAvatarRender   = true;
            AvatarModel avatarModel = avatarInstance.GetComponent <AvatarModel>();
            yield return(AvatarRenderer.RenderOutfit(beakColor: avatarModel.BeakColor, bellyColor: avatarModel.BellyColor, bodyColor: useBodyColor ? bodyColor : avatarModel.BodyColor, outfit: avatarOutfit, cameraData: imageBuilderCameraData, avatarGO: avatarInstance, onProcessModel: onProcessAnimationFrame, animationFrame: avatarFrame));
        }
    }
        /// <summary>
        /// Handles input for quitting the game.
        /// </summary>
        void HandleInput()
        {
            lastGamePadState    = currentGamePadState;
            currentGamePadState = GamePad.GetState(PlayerIndex.One);

            // Check for exit.
            if (currentGamePadState.Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            // Check to see if we need to change play modes
            if (currentGamePadState.Buttons.LeftShoulder == ButtonState.Pressed &&
                lastGamePadState.Buttons.LeftShoulder != ButtonState.Pressed)
            {
                animationPlaybackMode += 1;
                if (animationPlaybackMode > AnimationPlaybackMode.Wave)
                {
                    animationPlaybackMode = AnimationPlaybackMode.All;
                }
            }

            // Check to see if we should load another random avatar
            if (currentGamePadState.Buttons.RightShoulder == ButtonState.Pressed &&
                lastGamePadState.Buttons.RightShoulder != ButtonState.Pressed)
            {
                avatarDescription = AvatarDescription.CreateRandom();
                avatarRenderer    = new AvatarRenderer(avatarDescription);
            }
        }
Exemple #4
0
        public AvatarRagdollSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // This sample uses for a DebugRenderer for the rendering rigid bodies.
            _debugRenderer = new DebugRenderer(GraphicsService, SpriteFont);

            // Add a custom game object which controls the camera.
            _cameraObject = new CameraObject(Services);
            _cameraObject.ResetPose(new Vector3F(0, 1, -3), ConstantsF.Pi, 0);
            GameObjectService.Objects.Add(_cameraObject);

            // Add some objects which allow the user to interact with the rigid bodies.
            _grabObject        = new GrabObject(Services);
            _ballShooterObject = new BallShooterObject(Services)
            {
                Speed = 20
            };
            GameObjectService.Objects.Add(_grabObject);
            GameObjectService.Objects.Add(_ballShooterObject);

            // Add some default force effects.
            Simulation.ForceEffects.Add(new Gravity());
            Simulation.ForceEffects.Add(new Damping());

            // Add a ground plane in the simulation.
            Simulation.RigidBodies.Add(new RigidBody(new PlaneShape(Vector3F.UnitY, 0))
            {
                MotionType = MotionType.Static
            });

            // Create a random avatar.
            _avatarDescription = AvatarDescription.CreateRandom();
            _avatarRenderer    = new AvatarRenderer(_avatarDescription);
        }
Exemple #5
0
        /// <summary>
        /// Load the avatar and initialize the avatar IK chain.
        /// </summary>
        private void LoadAvatar()
        {
            // Create a new avatar renderer.
            avatarRenderer = new AvatarRenderer(AvatarDescription.CreateRandom(), true);

            // Create the avatar IK chain.
            avatarBoneChain.Clear();
            avatarBoneChain.Add((int)AvatarBone.FingerMiddle3Left);
            avatarBoneChain.Add((int)AvatarBone.WristLeft);
            avatarBoneChain.Add((int)AvatarBone.ElbowLeft);
            avatarBoneChain.Add((int)AvatarBone.ShoulderLeft);

            // Initialize the avatar transform lists to the identity.
            int boneCount = AvatarRenderer.BoneCount;

            avatarBoneTransforms =
                Enumerable.Repeat(Matrix.Identity, boneCount).ToList();
            avatarWorldTransforms = avatarBoneTransforms.ToList();
            avatarLocalTransforms = avatarBoneTransforms.ToList();

            // Rotate the right arm down so it's idle at the avatar's hip.
            avatarBoneTransforms[(int)AvatarBone.ShoulderRight] =
                Matrix.CreateRotationZ(MathHelper.ToRadians(80));

            // Position the avatar.
            avatarRenderer.World = Matrix.CreateTranslation(1, 0, 0);
        }
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font        = Content.Load <SpriteFont>("Font");

            // Create random avatar description and load the renderer and animation
            avatarDescription = AvatarDescription.CreateRandom();
            avatarRenderer    = new AvatarRenderer(avatarDescription);

            // Load the preset animations
            waveAnimation      = new AvatarAnimation(AvatarAnimationPreset.Wave);
            celebrateAnimation = new AvatarAnimation(AvatarAnimationPreset.Celebrate);

            // Find the bone index values for the right arm and its children
            rightArmBones = FindInfluencedBones(AvatarBone.ShoulderRight,
                                                avatarRenderer.ParentBones);

            for (int i = 0; i < AvatarRenderer.BoneCount; ++i)
            {
                finalBoneTransforms.Add(Matrix.Identity);
            }

            // Initialize the rendering matrices
            world      = Matrix.CreateRotationY(MathHelper.Pi);
            projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
                                                             GraphicsDevice.Viewport.AspectRatio,
                                                             .01f, 200.0f);
        }
Exemple #7
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create random avatar description and load the renderer and animation
            avatarDescription = AvatarDescription.CreateRandom();
            avatarRenderer    = new AvatarRenderer(avatarDescription);

            // Load 4 of the preset animations
            avatarAnimations[0] = new AvatarAnimation(AvatarAnimationPreset.Stand0);
            avatarAnimations[1] = new AvatarAnimation(AvatarAnimationPreset.Celebrate);
            avatarAnimations[2] = new AvatarAnimation(AvatarAnimationPreset.Clap);
            avatarAnimations[3] = new AvatarAnimation(AvatarAnimationPreset.Stand5);

            // Current animation to play and update
            currentAvatarAnimation = avatarAnimations[0];

            // Load the baseball bat model
            baseballBat = Content.Load <Model>("baseballbat");

            // Initialize the rendering matrices
            world      = Matrix.CreateRotationY(MathHelper.Pi);
            projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
                                                             GraphicsDevice.Viewport.AspectRatio,
                                                             .01f, 200.0f);

            // Initialize the list of bones in world space
            bonesWorldSpace = new List <Matrix>(AvatarRenderer.BoneCount);
            for (int i = 0; i < AvatarRenderer.BoneCount; i++)
            {
                bonesWorldSpace.Add(Matrix.Identity);
            }
        }
Exemple #8
0
        /// <summary>
        /// Updates a list of matrices to represent the location of the
        /// avatar bones in world space with the avatar animation applied.
        /// </summary>
        private static void BonesToWorldSpace(AvatarRenderer renderer, AvatarAnimation animation,
                                              List <Matrix> boneToUpdate)
        {
            // Bind pose of the avatar.
            // These positions are in local space, and are relative to the parent bone.
            IList <Matrix> bindPose = renderer.BindPose;
            // The current animation pose.
            // These positions are in local space, and are relative to the parent bone.
            IList <Matrix> animationPose = animation.BoneTransforms;
            // List of parent bones for each bone in the hierarchy
            IList <int> parentIndex = renderer.ParentBones;

            // Loop all of the bones.
            // Since the bone hierarchy is sorted by depth
            // we will transform the parent before any child.
            for (int i = 0; i < AvatarRenderer.BoneCount; i++)
            {
                // Find the transform of this bones parent.
                // If this is the first bone use the world matrix used on the avatar
                Matrix parentMatrix = (parentIndex[i] != -1)
                                       ? boneToUpdate[parentIndex[i]]
                                       : renderer.World;
                // Calculate this bones world space position
                boneToUpdate[i] = Matrix.Multiply(Matrix.Multiply(animationPose[i],
                                                                  bindPose[i]),
                                                  parentMatrix);
            }
        }
Exemple #9
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font        = Content.Load <SpriteFont>("Font");

            // Create random avatar description and load the renderer and animation
            avatarDescription = AvatarDescription.CreateRandom();
            avatarRenderer    = new AvatarRenderer(avatarDescription);

            // Load 4 of the preset animations
            avatarAnimations    = new AvatarAnimation[4];
            avatarAnimations[0] = new AvatarAnimation(AvatarAnimationPreset.Stand0);
            avatarAnimations[1] = new AvatarAnimation(AvatarAnimationPreset.Celebrate);
            avatarAnimations[2] = new AvatarAnimation(AvatarAnimationPreset.Clap);
            avatarAnimations[3] = new AvatarAnimation(AvatarAnimationPreset.Wave);

            // Create new blended animation
            blendedAnimation = new AvatarBlendedAnimation(avatarAnimations[0]);

            noBlendingAnimation = avatarAnimations[0];

            // Initialize the rendering matrices
            world      = Matrix.CreateRotationY(MathHelper.Pi);
            projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
                                                             GraphicsDevice.Viewport.AspectRatio,
                                                             .01f, 200.0f);
        }
        protected override IEnumerator SetUp()
        {
            yield return(base.SetUp());

            avatarModel = new AvatarModel()
            {
                name      = " test",
                hairColor = Color.white,
                eyeColor  = Color.white,
                skinColor = Color.white,
                bodyShape = WearableLiterals.BodyShapes.FEMALE,
                wearables = new List <string>()
                {
                }
            };

            AvatarTestHelpers.CreateTestCatalog();

            var avatarShape = AvatarTestHelpers.CreateAvatarShape(scene, avatarModel);

            yield return(new DCL.WaitUntil(() => avatarShape.everythingIsLoaded, 20));

            avatarRenderer = avatarShape.avatarRenderer;
            animator       = avatarRenderer.animator;
        }
Exemple #11
0
        /// <summary>
        /// Load a random avatar
        /// </summary>
        private void LoadRandomAvatar()
        {
            UnloadAvatar();

            avatarDescription         = AvatarDescription.CreateRandom();
            avatarRenderer            = new AvatarRenderer(avatarDescription);
            avatarRenderer.Projection = projection;
        }
Exemple #12
0
 /// <summary>
 /// Unloads the current avatar
 /// </summary>
 private void UnloadAvatar()
 {
     // Dispose the current Avatar
     if (avatarRenderer != null)
     {
         avatarRenderer.Dispose();
         avatarRenderer = null;
     }
 }
        public static WearableController_Mock GetWearableController(AvatarRenderer renderer, string id)
        {
            var wearableControllers = GetWearableControllers(renderer);

            if (!wearableControllers.ContainsKey(id))
            {
                return(null);
            }

            return(new WearableController_Mock(wearableControllers[id]));
        }
        public static BodyShapeController_Mock GetBodyShapeController(AvatarRenderer renderer)
        {
            var bodyShapeController = GetBodyShape(renderer);

            if (bodyShapeController == null)
            {
                return(null);
            }

            return(new BodyShapeController_Mock(bodyShapeController));
        }
Exemple #15
0
        //--------------------------------------------------------------
        #region Methods
        //--------------------------------------------------------------

        /// <summary>
        /// Creates a skeleton for the given avatar renderer.
        /// </summary>
        /// <param name="avatarRenderer">The avatar renderer.</param>
        /// <returns>The skeleton.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="avatarRenderer"/> is <see langword="null"/>.
        /// </exception>
        private static Skeleton CreateSkeleton(AvatarRenderer avatarRenderer)
        {
            if (avatarRenderer == null)
            {
                throw new ArgumentNullException("avatarRenderer");
            }

            var skeleton = new Skeleton(avatarRenderer.ParentBones, BoneNames, ConvertToSrt(avatarRenderer.BindPose));

            return(skeleton);
        }
Exemple #16
0
        public AvatarAnimationController(AvatarRenderer renderer, AvatarAnimationPreset preset)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            Renderer        = renderer;
            Loop            = true;
            avatarAnimation = new AvatarAnimation(preset);
        }
        public static Dictionary <string, WearableController> GetWearableControllers(AvatarRenderer renderer)
        {
            var avatarRendererMock = new GameObject("Temp").AddComponent <AvatarRenderer_Mock>();

            avatarRendererMock.CopyFrom(renderer);

            var toReturn = avatarRendererMock.wearablesController;

            Destroy(avatarRendererMock.gameObject);

            return(toReturn);
        }
        public static BodyShapeController GetBodyShape(AvatarRenderer renderer)
        {
            var avatarRendererMock = new GameObject("Temp").AddComponent <AvatarRenderer_Mock>();

            avatarRendererMock.CopyFrom(renderer);

            var toReturn = avatarRendererMock.bodyShapeController;

            Destroy(avatarRendererMock.gameObject);

            return(toReturn);
        }
Exemple #19
0
        /// <summary>
        /// Handles input for quitting the game.
        /// </summary>
        void HandleInput()
        {
            lastGamePadState    = currentGamePadState;
            currentGamePadState = GamePad.GetState(PlayerIndex.One);

            // Check for exit.
            if (currentGamePadState.Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            // Check to see if we need to change blending bool
            if (currentGamePadState.Buttons.LeftShoulder == ButtonState.Pressed &&
                lastGamePadState.Buttons.LeftShoulder != ButtonState.Pressed)
            {
                useAnimationBlending = !useAnimationBlending;
            }

            // Check to see if we should load another random avatar
            if (currentGamePadState.Buttons.RightShoulder == ButtonState.Pressed &&
                lastGamePadState.Buttons.RightShoulder != ButtonState.Pressed)
            {
                avatarDescription = AvatarDescription.CreateRandom();
                avatarRenderer    = new AvatarRenderer(avatarDescription);
            }

            // Check to see if we need to play another animation
            if (currentGamePadState.Buttons.A == ButtonState.Pressed &&
                lastGamePadState.Buttons.A != ButtonState.Pressed)
            {
                blendedAnimation.Play(avatarAnimations[1]);
                noBlendingAnimation = avatarAnimations[1];
            }
            else if (currentGamePadState.Buttons.B == ButtonState.Pressed &&
                     lastGamePadState.Buttons.B != ButtonState.Pressed)
            {
                blendedAnimation.Play(avatarAnimations[2]);
                noBlendingAnimation = avatarAnimations[2];
            }
            else if (currentGamePadState.Buttons.X == ButtonState.Pressed &&
                     lastGamePadState.Buttons.X != ButtonState.Pressed)
            {
                blendedAnimation.Play(avatarAnimations[0]);
                noBlendingAnimation = avatarAnimations[0];
            }
            else if (currentGamePadState.Buttons.Y == ButtonState.Pressed &&
                     lastGamePadState.Buttons.Y != ButtonState.Pressed)
            {
                blendedAnimation.Play(avatarAnimations[3]);
                noBlendingAnimation = avatarAnimations[3];
            }
        }
Exemple #20
0
        public AvatarSkeleton(AvatarRenderer renderer)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            this.Renderer       = renderer;
            this.boneTransforms = new Matrix[AvatarRenderer.BoneCount];
            this.BoneNames      = new ReadOnlyCollection <string>(
                Enumerable.Range(0, AvatarRenderer.BoneCount)
                .Select(i => ((AvatarBone)i).ToString()).ToArray());
        }
Exemple #21
0
        public AvatarAnimationController(AvatarRenderer renderer, BoneAnimationClip clip)
        {
            if (clip.Transforms.Length != AvatarRenderer.BoneCount)
            {
                throw new ArgumentException("The input animation clip is not a valid avatar animation.");
            }

            Renderer = renderer;
            Loop     = true;
            boneAnimationController            = new BoneAnimationController(clip);
            boneAnimationController.Completed += (sender, e) => { OnCompleted(); Stop(); };
            boneAnimationController.Play();
        }
        public static Dictionary <string, WearableController> GetWearableControllers(AvatarRenderer renderer)
        {
            var avatarRendererMock = new GameObject("Temp").AddComponent <AvatarRenderer_Mock>();

            avatarRendererMock.CopyFrom(renderer);

            var result =
                avatarRendererMock.wearableControllers.ToDictionary(x => x.Value.id, y => y.Value);

            Destroy(avatarRendererMock.gameObject);

            return(result);
        }
        public BakedAnimationSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Add a custom game object which controls the camera.
            _cameraObject = new CameraObject(Services);
            _cameraObject.ResetPose(new Vector3F(0, 1, -3), ConstantsF.Pi, 0);
            GameObjectService.Objects.Add(_cameraObject);

            // Create a random avatar.
            _avatarDescription = AvatarDescription.CreateRandom();
            _avatarRenderer    = new AvatarRenderer(_avatarDescription);

            // Convert animation.
            _waveAnimation = BakeAnimation(new AvatarAnimation(AvatarAnimationPreset.Clap));
        }
Exemple #24
0
        /// <summary>
        /// AsyncCallback for loading the AvatarDescription
        /// </summary>
        private void LoadAvatarDescription(IAsyncResult result)
        {
            // Get the AvatarDescription for the gamer
            avatarDescription = AvatarDescription.EndGetFromGamer(result);

            // Load the AvatarRenderer if description is valid
            if (avatarDescription.IsValid)
            {
                avatarRenderer            = new AvatarRenderer(avatarDescription);
                avatarRenderer.Projection = projection;
            }
            // Load random for an invalid description
            else
            {
                LoadRandomAvatar();
            }
        }
        private IEnumerator loadRenderGameObjects(DCustomEquipment[] outfit, Color bodyColor, AvatarAnimationFrame avatarFrame, RenderRequest renderRequest)
        {
            if (avatarPrefab == null && isLoadingAvatarPrefab)
            {
                yield return(null);
            }
            if (avatarPrefab == null)
            {
                isLoadingAvatarPrefab = true;
                AssetRequest <GameObject> assetRequest = null;
                try
                {
                    assetRequest = Content.LoadAsync(uiAvatarPrefabContentKey);
                }
                catch (Exception ex)
                {
                    Log.LogError(this, $"Could not load UI Avatar penguin asset {uiAvatarPrefabContentKey.Key}. Message: {ex.Message}");
                }
                if (assetRequest != null)
                {
                    yield return(assetRequest);

                    avatarPrefab          = assetRequest.Asset;
                    isLoadingAvatarPrefab = false;
                }
            }
            if (avatarPrefab != null)
            {
                GameObject            avatarInstance = UnityEngine.Object.Instantiate(avatarPrefab);
                IconRenderLightingRig lightingRig    = IconRenderLightingRig.Acquire();
                while (!lightingRig.IsReady)
                {
                    yield return(null);
                }
                DCustomOutfit avatarOutfit = default(DCustomOutfit);
                avatarOutfit.Equipment = outfit;
                AvatarModel avatarModel = avatarInstance.GetComponent <AvatarModel>();
                yield return(AvatarRenderer.RenderOutfit(avatarOutfit, avatarModel.BeakColor, bodyColor, avatarModel.BellyColor, imageBuilderCameraData, avatarInstance, (ModelRenderer modelRenderer) => onProcessAnimationFrame(modelRenderer, renderRequest.Handle, avatarInstance), avatarFrame));

                IconRenderLightingRig.Release();
            }
            else
            {
                Log.LogErrorFormatted(this, "Unabe to load the UI Avatar Prefab at path {0}", uiAvatarPrefabContentKey.Key);
            }
        }
Exemple #26
0
        /// <summary>
        /// Handles input for quitting the game.
        /// </summary>
        void HandleInput()
        {
            lastGamePadState    = currentGamePadState;
            currentGamePadState = GamePad.GetState(PlayerIndex.One);

            // Check for exit.
            if (currentGamePadState.Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            // Check to see if we should load another random avatar
            if (currentGamePadState.Buttons.RightShoulder == ButtonState.Pressed &&
                lastGamePadState.Buttons.RightShoulder != ButtonState.Pressed)
            {
                avatarDescription = AvatarDescription.CreateRandom();
                avatarRenderer    = new AvatarRenderer(avatarDescription);
            }

            // Check to see if we need to play another animation
            if (currentGamePadState.Buttons.A == ButtonState.Pressed &&
                lastGamePadState.Buttons.A != ButtonState.Pressed)
            {
                currentAvatarAnimation = avatarAnimations[1];
                currentAvatarAnimation.CurrentPosition = TimeSpan.Zero;
            }
            else if (currentGamePadState.Buttons.B == ButtonState.Pressed &&
                     lastGamePadState.Buttons.B != ButtonState.Pressed)
            {
                currentAvatarAnimation = avatarAnimations[2];
                currentAvatarAnimation.CurrentPosition = TimeSpan.Zero;
            }
            else if (currentGamePadState.Buttons.X == ButtonState.Pressed &&
                     lastGamePadState.Buttons.X != ButtonState.Pressed)
            {
                currentAvatarAnimation = avatarAnimations[3];
                currentAvatarAnimation.CurrentPosition = TimeSpan.Zero;
            }
            else if (currentGamePadState.Buttons.Y == ButtonState.Pressed &&
                     lastGamePadState.Buttons.Y != ButtonState.Pressed)
            {
                currentAvatarAnimation = avatarAnimations[0];
                currentAvatarAnimation.CurrentPosition = TimeSpan.Zero;
            }
        }
        public CustomAvatarAnimationSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            SampleFramework.IsMouseVisible = false;

            // Add a custom game object which controls the camera.
            _cameraObject = new CameraObject(Services);
            _cameraObject.ResetPose(new Vector3(0, 1, -3), ConstantsF.Pi, 0);
            GameObjectService.Objects.Add(_cameraObject);

            // Create a random avatar.
            _avatarDescription = AvatarDescription.CreateRandom();
            _avatarRenderer    = new AvatarRenderer(_avatarDescription);

            // Wrap the Stand0 AvatarAnimationPreset (see WrappedAnimationSample) to create an
            // infinitely looping stand animation.
            AvatarAnimation standAnimationPreset = new AvatarAnimation(AvatarAnimationPreset.Stand0);
            TimelineGroup   standAnimation       = new TimelineGroup
            {
                new WrappedAvatarExpressionAnimation(standAnimationPreset),
                new WrappedAvatarSkeletonAnimation(standAnimationPreset),
            };

            _standAnimation = new TimelineClip(standAnimation)
            {
                LoopBehavior = LoopBehavior.Cycle, // Cycle the Stand animation...
                Duration     = TimeSpan.MaxValue,  // ...forever.
            };

            // Load animations from content pipeline.
            _faintAnimation = ContentManager.Load <TimelineGroup>("XboxAvatars/Faint");
            _jumpAnimation  = ContentManager.Load <TimelineGroup>("XboxAvatars/Jump");
            _kickAnimation  = ContentManager.Load <TimelineGroup>("XboxAvatars/Kick");
            _punchAnimation = ContentManager.Load <TimelineGroup>("XboxAvatars/Punch");

            // The walk cycle should loop: Put it into a timeline clip and set a
            // loop-behavior.
            TimelineGroup walkAnimation = ContentManager.Load <TimelineGroup>("XboxAvatars/Walk");

            _walkAnimation = new TimelineClip(walkAnimation)
            {
                LoopBehavior = LoopBehavior.Cycle, // Cycle the Walk animation...
                Duration     = TimeSpan.MaxValue,  // ...forever.
            };
        }
        public WrappedAvatarAnimationSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // This sample uses for a DebugRenderer for rendering text.
            _debugRenderer = new DebugRenderer(GraphicsService, SpriteFont)
            {
                DefaultColor        = Color.Black,
                DefaultTextPosition = new Vector2F(10),
            };

            // Add a custom game object which controls the camera.
            _cameraObject = new CameraObject(Services);
            _cameraObject.ResetPose(new Vector3F(0, 1, -3), ConstantsF.Pi, 0);
            GameObjectService.Objects.Add(_cameraObject);

            // Create a random avatar.
            _avatarDescription = AvatarDescription.CreateRandom();
            _avatarRenderer    = new AvatarRenderer(_avatarDescription);
        }
        public AvatarAttachmentSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            SampleFramework.IsMouseVisible = false;

            // This sample uses Scene and MeshRenderer for rendering the attached models.
            _scene        = new Scene();
            _meshRenderer = new MeshRenderer();

            // Add a custom game object which controls the camera.
            _cameraObject = new CameraObject(Services);
            _cameraObject.ResetPose(new Vector3F(0, 1, -3), ConstantsF.Pi, 0);
            GameObjectService.Objects.Add(_cameraObject);

            // Create a random avatar.
            _avatarDescription = AvatarDescription.CreateRandom();
            _avatarRenderer    = new AvatarRenderer(_avatarDescription);

            // Load walk animation using the content pipeline.
            TimelineGroup animation = ContentManager.Load <TimelineGroup>("XboxAvatars/Walk");

            // Create a looping walk animation.
            _walkAnimation = new TimelineClip(animation)
            {
                LoopBehavior = LoopBehavior.Cycle, // Cycle Walk animation...
                Duration     = TimeSpan.MaxValue,  // ...forever.
            };

            var baseballBatModelNode = ContentManager.Load <ModelNode>("XboxAvatars/BaseballBat").Clone();

            _baseballBatMeshNode = baseballBatModelNode.GetChildren().OfType <MeshNode>().First();

            // If we only render the baseball bat, it appears black. We need to add it to
            // a scene with some lights. (The lights do not affect the avatar.)
            SceneSample.InitializeDefaultXnaLights(_scene);

            // We must detach the mesh node from its current parent (the model node) before
            // we can add it to the scene.
            _baseballBatMeshNode.Parent.Children.Remove(_baseballBatMeshNode);
            _scene.Children.Add(_baseballBatMeshNode);
        }
        public static Dictionary <string, WearableController_Mock> GetWearableMockControllers(AvatarRenderer renderer)
        {
            var controllers = GetWearableControllers(renderer);

            return(controllers.ToDictionary(x => x.Key, x => new WearableController_Mock(x.Value)));
        }