Пример #1
0
        /// <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();
        }
        public void LoadContents(SpriteBatch s, ContentManager C,float windX, float windZ)
        {
            // load everything

            image = C.Load<Texture2D>("Images\\jimmy");        //  red square for joints
            confirmScreen.image = C.Load<Texture2D>("Images\\ConfirmOverlay");

            leftWrist = C.Load<Texture2D>("Images\\handLeft");
            wrist = C.Load<Texture2D>("Images\\handRight");
            yellowBall = C.Load<Texture2D>("Images\\yellowBall");
            yellowTarget = C.Load<Texture2D>("Images\\yellowTarget");
            windArrow = C.Load<Texture2D>("Images\\WindArrow");
            overLay = C.Load<Texture2D>("Images\\OverlayNew");
            scoreText = C.Load<Texture2D>("Images\\Score");
            wideText = C.Load<Texture2D>("Images\\Wide");

            instructText = C.Load<SpriteFont>("Text\\instructions");
            spritefont = C.Load<SpriteFont>("Text\\priteFont");

            Stadium = C.Load<Model>("Models\\Stadium2");
            GoalPosts = C.Load<Model>("Models\\GoalPosts2");
            Sliothar = C.Load<Model>("Models\\Sliothar");

            model = new AnimatedModel("HurlerSimpleRigUV",this.graphics,s);  // standing model
            animation = new AnimatedModel("HurlerFullAnim", this.graphics, s); // model with movements
            model.LoadContent(C);
            animation.LoadContent(C);

            aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
            puck = C.Load<SoundEffect>("Audio\\slit1");
            puckInstance = puck.CreateInstance();
            crowd = C.Load<SoundEffect>("Audio\\Sports_Crowd");
            crowdInstance = crowd.CreateInstance();
            crowdInstance.IsLooped = true;

            stadium = new BoxObject(new Vector3(0,-.1f,0), Stadium, 1000, 0.1f, 1000);
            Goals = new GoalPostObject(goalPosition, GoalPosts, 80, 0.1f);
            ball = new BallObject(sliotharPosition, Sliothar, 0.05f);

            space.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
            Box behindGoals = new Box(new Vector3(90, 40, -5), 150, 100, 2);
            ball.sphere.LinearDamping = 0.1f;
            ball.sphere.Material.KineticFriction = 1f;
            ball.sphere.Material.StaticFriction = 3f;     // ball doesn't really roll or bounce,  go straight over the bar lads!!!
            stadium.box.Material.KineticFriction = 3f;
            stadium.box.Material.StaticFriction = 3f;

            space.Add(stadium.box);
            space.Add(Goals.post1);   // add parts to our space
            space.Add(Goals.post2);
            space.Add(ball.sphere);
            space.Add(behindGoals);   // just to stop the ball going into the stadium and drawing some quare stuff

            rotation = MathHelper.ToDegrees((float)Math.Atan((modulus(ball.sphere.Position.X - camSpot.X)) / (ball.sphere.Position.Z)));

            if (ball.sphere.Position.X > camSpot.X)
            {
                camPosition.X = (float)(((camOrigin.Z - sliotharPosition.Z) * Math.Sin(MathHelper.ToRadians(rotation))) + ((camOrigin.X - sliotharPosition.X) * Math.Cos(MathHelper.ToRadians(rotation)))) + sliotharPosition.X;
                camPosition.Z = (float)(((camOrigin.Z - sliotharPosition.Z) * Math.Cos(MathHelper.ToRadians(rotation))) - ((camOrigin.X - sliotharPosition.X) * Math.Sin(MathHelper.ToRadians(rotation)))) + sliotharPosition.Z;
                // rotate the camera behind the player in line with where we are looking at
            }

            else
            {
                camPosition.X = (float)(((camOrigin.Z - sliotharPosition.Z) * Math.Sin(MathHelper.ToRadians(-rotation))) + ((camOrigin.X - sliotharPosition.X) * Math.Cos(MathHelper.ToRadians(-rotation)))) + sliotharPosition.X;
                camPosition.Z = (float)(((camOrigin.Z - sliotharPosition.Z) * Math.Cos(MathHelper.ToRadians(-rotation))) - ((camOrigin.X - sliotharPosition.X) * Math.Sin(MathHelper.ToRadians(-rotation)))) + sliotharPosition.Z;

            }

            calcWindRotate();
            // TODO: use this.Content to load your game content here
        }
Пример #3
0
 /// <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);
 }
Пример #4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Load the model we will display
            //model = new AnimatedModel("Victoria-hat-tpose");
            //model.LoadContent(Content);

            // Load the model that has an animation clip it in
            dance = new AnimatedModel("test_FBX_Y");
            dance.LoadContent(Content);

            // Obtain the clip we want to play. I'm using an absolute index,
            // because XNA 4.0 won't allow you to have more than one animation
            // associated with a model, anyway. It would be easy to add code
            // to look up the clip by name and to index it by name in the model.
            AnimationClip clip = dance.Clips["Run"];
            //dance.Clips["Walk"].Duration = 8;

            // And play the clip
            AnimationPlayer player = dance.PlayClip(clip);
            player.Looping = true;
        }