public ThirdPersonCamera(Game1 game, AnimatedModel target, Vector3 up, Viewport viewPort) : base(game) { cameraPosition = target.CameraOffsetPosition; cameraDirection = target.CameraOffsetPosition - target.position; cameraDirection.Normalize(); cameraUp = up; this.chaseObject = target; projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, viewPort.AspectRatio, 0.5f, 1000f); CreateLookAt(); }
/// <summary> /// Constructor for the animation player. It makes the /// association between a clip and a model and sets up for playing /// </summary> /// <param name="clip"></param> public AnimationPlayer(AnimationClip clip, AnimatedModel model) { this.clip = clip; this.model = model; // Create the bone information classes boneCnt = clip.Bones.Count; boneInfos = new BoneInfo[boneCnt]; for (int b = 0; b < boneInfos.Length; b++) { // Create it boneInfos[b] = new BoneInfo(clip.Bones[b]); // Assign it to a model bone boneInfos[b].SetModel(model); } Rewind(); }
protected override void Initialize() { player = new Player("MainCharacter/model", new Vector3(0, 0, 0), this); currentAnimation = new AnimatedModel("MainCharacter/run_forward", new Vector3(0, 0, 0), this); AnimationClip clip = currentAnimation.Clips[0]; AnimationPlayer animationPlayer = player.PlayClip(clip); animationPlayer.Looping = true; Components.Add(player); terrain = new Terrain(this, 256, 256, 20f, 5f); Components.Add(terrain); //Creates a Third Person Camera and assigns it to follow player camera = new ThirdPersonCamera(this, player, Vector3.Up, new Viewport(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); Components.Add(camera); base.Initialize(); }
/// <summary> /// Assign this bone to the correct bone in the model /// </summary> /// <param name="model"></param> public void SetModel(AnimatedModel model) { // Find this bone assignedBone = model.FindBone(ClipBone.Name); }