public AvatarRagdollSample(Microsoft.Xna.Framework.Game game) : base(game) { SampleFramework.IsMouseVisible = false; // 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); }
private Avatar( AvatarDescription body, AvatarAnimationWrapper anim, float scale, Vector3 dir, Vector3 pos ) { Scale = scale; Direction = dir; Position = pos; BlendTime = .25f; Description = body; Renderer = new AvatarRenderer( body ); currentAnimation = anim; BoneTransforms = new ReadOnlyCollection<Matrix>( avatarBones ); }
public BakedAnimationSample(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 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)); }
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 Vector3F(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 BasicAvatarSample(Microsoft.Xna.Framework.Game game) : base(game) { SampleFramework.IsMouseVisible = false; // This sample uses for a DebugRenderer for the rendering Avatar skeleton. _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); }
/// <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 = projectionMatrix; } // Load random for an invalid description else { LoadRandomAvatar(); } //List<Matrix> BONES = new List<Matrix>(71); ////head //// == matrix from head bone in local space //BONES[19] = new Matrix(); ////back 0 , 1 , 5 //// == matrix from chest bone in world space //BONES[0] = new Matrix(); //avatarRenderer.Draw(BONES, new AvatarExpression()); if (avatarDescription.IsValid) { Console.WriteLine(" VALID AVATAR "); } }
public Avatar( AvatarDescription body, AvatarAnimationPreset anim, float scale, Vector3 dir, Vector3 pos ) : this(body, new AvatarAnimationWrapper( anim ), scale, dir, pos) { }
protected override void LoadContent() { _avatarDescription = AvatarDescription.CreateRandom(); _avatarRenderer = new AvatarRenderer(_avatarDescription); // Use the "Wave" animation preset. var avatarAnimation = new AvatarAnimation(AvatarAnimationPreset.Wave); _expressionAnimation = new AnimationClip<AvatarExpression>(new WrappedExpressionAnimation(avatarAnimation)) { LoopBehavior = LoopBehavior.Cycle, Duration = TimeSpan.MaxValue, }; _skeletonAnimation = new AnimationClip<SkeletonPose>(new WrappedSkeletonAnimation(avatarAnimation)) { LoopBehavior = LoopBehavior.Cycle, Duration = TimeSpan.MaxValue, }; // Add a ground plane in the simulation. Simulation.RigidBodies.Add(new RigidBody(new PlaneShape(Vector3F.UnitY, 0)) { MotionType = MotionType.Static }); // Distribute a few dynamic spheres and boxes across the landscape. SphereShape sphereShape = new SphereShape(0.3f); for (int i = 0; i < 10; i++) { Vector3F position = RandomHelper.Random.NextVector3F(-10, 10); position.Y = 1; Simulation.RigidBodies.Add(new RigidBody(sphereShape) { Pose = new Pose(position) }); } BoxShape boxShape = new BoxShape(0.6f, 0.6f, 0.6f); for (int i = 0; i < 10; i++) { Vector3F position = RandomHelper.Random.NextVector3F(-10, 10); position.Y = 1; Simulation.RigidBodies.Add(new RigidBody(boxShape) { Pose = new Pose(position) }); } base.LoadContent(); }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { if (content == null) content = new ContentManager(ScreenManager.Game.Services, "Content"); gameFont = content.Load<SpriteFont>("menufont"); square = content.Load<Texture2D>("square"); disc = content.Load<Texture2D>("disc"); gameplaybackground = content.Load<Texture2D>("gameplaybackground"); guy = content.Load<Texture2D>("guy"); blueguy = content.Load<Texture2D>("blueguy"); girl = content.Load<Texture2D>("girl"); pinkgirl = content.Load<Texture2D>("pinkgirl"); p0 = content.Load<Texture2D>("images/0"); p1 = content.Load<Texture2D>("images/1"); p2 = content.Load<Texture2D>("images/2"); p3 = content.Load<Texture2D>("images/3"); p4 = content.Load<Texture2D>("images/4"); p5 = content.Load<Texture2D>("images/5"); p6 = content.Load<Texture2D>("images/6"); p7 = content.Load<Texture2D>("images/7"); p8 = content.Load<Texture2D>("images/8"); p9 = content.Load<Texture2D>("images/9"); p10 = content.Load<Texture2D>("images/10"); p11 = content.Load<Texture2D>("images/11"); p12 = content.Load<Texture2D>("images/12"); p13 = content.Load<Texture2D>("images/13"); p14 = content.Load<Texture2D>("images/14"); p15 = content.Load<Texture2D>("images/15"); p16 = content.Load<Texture2D>("images/16"); p17 = content.Load<Texture2D>("images/17"); p18 = content.Load<Texture2D>("images/18"); p19 = content.Load<Texture2D>("images/19"); p20 = content.Load<Texture2D>("images/20"); p21 = content.Load<Texture2D>("images/21"); p22 = content.Load<Texture2D>("images/22"); p23 = content.Load<Texture2D>("images/23"); p24 = content.Load<Texture2D>("images/24"); p25 = content.Load<Texture2D>("images/25"); p26 = content.Load<Texture2D>("images/26"); p27 = content.Load<Texture2D>("images/27"); // A real game would probably have more content than this sample, so // it would take longer to load. We simulate that by delaying for a // while, giving you a chance to admire the beautiful loading screen. Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); //MediaPlayer.Stop(); // stop current audio playback // generate a random valid index into Albums //int i = rand.Next(0, sampleMediaLibrary.Albums.Count - 1); spriteBatch = new SpriteBatch(ScreenManager.GraphicsDevice); //video = content.Load<Video>("xblcg"); //videoDimensions = new Vector2(video.Width, video.Height); //Avatar Stuff try { avatarDescription = Gamer.SignedInGamers[ControllingPlayer.Value].Avatar; } catch { avatarDescription = AvatarDescription.CreateRandom(); } if (content == null) content = new ContentManager(ScreenManager.Game.Services, "Content"); //avatar stuff // 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.Clap); celebrateAnimation = new AvatarAnimation(AvatarAnimationPreset.Celebrate); standAnimation0 = new AvatarAnimation(AvatarAnimationPreset.MaleIdleShiftWeight); // 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, ScreenManager.GraphicsDevice.Viewport.AspectRatio, .01f, 200.0f); }
protected override void LoadContent() { // Create a random avatar. _avatarDescription = AvatarDescription.CreateRandom(); _avatarRenderer = new AvatarRenderer(_avatarDescription); // Load walk animation using the content pipeline. TimelineGroup animation = Game.Content.Load<TimelineGroup>("Walk"); // Create a looping walk animation. _walkAnimation = new TimelineClip(animation) { LoopBehavior = LoopBehavior.Cycle, // Cycle Walk animation... Duration = TimeSpan.MaxValue, // ...forever. }; _baseballBat = Game.Content.Load<Model>("BaseballBat"); base.LoadContent(); }
protected override void LoadContent() { _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 WrappedExpressionAnimation(standAnimationPreset), new WrappedSkeletonAnimation(standAnimationPreset), }; _standAnimation = new TimelineClip(standAnimation) { LoopBehavior = LoopBehavior.Cycle, // Cycle the Stand animation... Duration = TimeSpan.MaxValue, // ...forever. }; // Load animations from content pipeline. _faintAnimation = Game.Content.Load<TimelineGroup>("Faint"); _jumpAnimation = Game.Content.Load<TimelineGroup>("Jump"); _kickAnimation = Game.Content.Load<TimelineGroup>("Kick"); _punchAnimation = Game.Content.Load<TimelineGroup>("Punch"); // The walk cycle should loop: Put it into a timeline clip and set a // loop-behavior. TimelineGroup walkAnimation = Game.Content.Load<TimelineGroup>("Walk"); _walkAnimation = new TimelineClip(walkAnimation) { LoopBehavior = LoopBehavior.Cycle, // Cycle the Walk animation... Duration = TimeSpan.MaxValue, // ...forever. }; base.LoadContent(); }
private void LoadGamerAvatar(IAsyncResult result) { avatarDescription = AvatarDescription.EndGetFromGamer(result); AvatarRenderer = new AvatarRenderer(avatarDescription); }
public AdvancedAvatarRagdollSample(Microsoft.Xna.Framework.Game game) : base(game) { SampleFramework.IsMouseVisible = false; // This sample uses for a DebugRenderer to draw text and rigid bodies. _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); // 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()); // Create a random avatar. _avatarDescription = AvatarDescription.CreateRandom(); _avatarRenderer = new AvatarRenderer(_avatarDescription); // Use the "Wave" animation preset. var avatarAnimation = new AvatarAnimation(AvatarAnimationPreset.Wave); _expressionAnimation = new AnimationClip<AvatarExpression>(new WrappedAvatarExpressionAnimation(avatarAnimation)) { LoopBehavior = LoopBehavior.Cycle, Duration = TimeSpan.MaxValue, }; _skeletonAnimation = new AnimationClip<SkeletonPose>(new WrappedAvatarSkeletonAnimation(avatarAnimation)) { LoopBehavior = LoopBehavior.Cycle, Duration = TimeSpan.MaxValue, }; // Add a ground plane in the simulation. Simulation.RigidBodies.Add(new RigidBody(new PlaneShape(Vector3F.UnitY, 0)) { MotionType = MotionType.Static }); // Distribute a few dynamic spheres and boxes across the landscape. SphereShape sphereShape = new SphereShape(0.3f); for (int i = 0; i < 10; i++) { Vector3F position = RandomHelper.Random.NextVector3F(-10, 10); position.Y = 1; Simulation.RigidBodies.Add(new RigidBody(sphereShape) { Pose = new Pose(position) }); } BoxShape boxShape = new BoxShape(0.6f, 0.6f, 0.6f); for (int i = 0; i < 10; i++) { Vector3F position = RandomHelper.Random.NextVector3F(-10, 10); position.Y = 1; Simulation.RigidBodies.Add(new RigidBody(boxShape) { Pose = new Pose(position) }); } }
public AvatarRenderer(AvatarDescription avatarDescription) : this(avatarDescription, true) { }
protected override void LoadContent() { _basicEffect = new BasicEffect(GraphicsDevice); // Create a random avatar. _avatarDescription = AvatarDescription.CreateRandom(); _avatarRenderer = new AvatarRenderer(_avatarDescription); base.LoadContent(); }
protected override void LoadContent() { _avatarDescription = AvatarDescription.CreateRandom(); _avatarRenderer = new AvatarRenderer(_avatarDescription); // Convert animation. _waveAnimation = BakeAnimation(new AvatarAnimation(AvatarAnimationPreset.Clap)); base.LoadContent(); }
void TryLoadAvatar() { if (!Shorewood.presetAvatarAnimations.Keys.Contains<AvatarAnimationPreset>(AvatarAnimationPreset.Celebrate)) { Shorewood.presetAvatarAnimations.Add(AvatarAnimationPreset.Celebrate, new AvatarAnimation(AvatarAnimationPreset.Celebrate)); Shorewood.presetAvatarAnimations.Add(AvatarAnimationPreset.Clap, new AvatarAnimation(AvatarAnimationPreset.Clap)); } avatarDescription = AvatarDescription.CreateRandom(); // Load avatar animation information avatarAnimation = Shorewood.presetAvatarAnimations[AvatarAnimationPreset.Celebrate]; // Create new avatar Renderer avatarAnimation.CurrentPosition = TimeSpan.Zero; avatarRenderer = new AvatarRenderer(avatarDescription, false); }
public AvatarRenderer(AvatarDescription avatarDescription, bool useLoadingEffect) { }
/// <summary> /// Load a random avatar /// </summary> private void LoadRandomAvatar() { UnloadAvatar(); avatarDescription = AvatarDescription.CreateRandom(); avatarRenderer = new AvatarRenderer(avatarDescription); avatarRenderer.Projection = projectionMatrix; }
protected override void LoadContent() { _avatarDescription = AvatarDescription.CreateRandom(); _avatarRenderer = new AvatarRenderer(_avatarDescription); // Add a ground plane in the simulation. Simulation.RigidBodies.Add( new RigidBody(new PlaneShape(Vector3F.UnitY, 0)) { MotionType = MotionType.Static }); base.LoadContent(); }
protected override void LoadContent() { _avatarDescription = AvatarDescription.CreateRandom(); _avatarRenderer = new AvatarRenderer(_avatarDescription); base.LoadContent(); }
/// <summary> /// Loads graphics content for this screen. The background texture is quite /// big, so we use our own local ContentManager to load it. This allows us /// to unload before going from the menus into the game itself, wheras if we /// used the shared ContentManager provided by the Game class, the content /// would remain loaded forever. /// </summary> public override void LoadContent() { try { avatarDescription = Gamer.SignedInGamers[ControllingPlayer.Value].Avatar; } catch { avatarDescription = AvatarDescription.CreateRandom(); } if (content == null) content = new ContentManager(ScreenManager.Game.Services, "Content"); //avatar stuff // 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); standAnimation0 = new AvatarAnimation(AvatarAnimationPreset.MaleIdleShiftWeight); // 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, ScreenManager.GraphicsDevice.Viewport.AspectRatio, .01f, 200.0f); }