Esempio n. 1
0
        public override void Init()
        {
            camera = new Libraries.Camera(TurkeySmashGame.manager);

            #region player1
            model = new Joueur(PlayerIndex.One, MathHelper.ToRadians(-90), MathHelper.ToRadians(180));
            model.Load("Models\\dude", TurkeySmashGame.content);
            walk = new AnimatedModel();
            walk.Load("Models\\dude-walk", TurkeySmashGame.content);
            AnimationClip clip = walk.Clips[0];
            AnimationPlayer player = model.PlayClip(clip);
            player.Looping = true;
            model.Size = new Vector2(50, 350);

            elements.Add(model);
            #endregion

            if (SelectionNiveau.niveauSelect == "spacefarm")
                level = new Level("Jeu\\space", "Models\\farm", elements, TurkeySmashGame.content);
            else
                level = new Level("Jeu\\citybackground", "Models\\MapCity2", elements, TurkeySmashGame.content);

            hud.Load(elements);
            camera.Initialize();

            sonInstance.Volume = 0.5f;
            sonInstance.IsLooped = true;
            sonInstance.Resume();
        }
Esempio n. 2
0
        public override void Init()
        {
            camera = new Camera(TurkeySmashGame.manager);
            background = new Sprite();
            //players.Add(new Joueur(PlayerIndex.One));
            //players.Add(new IA(PlayerIndex.Two));
            background.Load(TurkeySmashGame.content, "Jeu\\space");
            //players[0].Load(TurkeySmashGame.content, "Models\\dude", elements);
            //players[0].Size = new Vector2(50, 375);
            //players[1].Load(TurkeySmashGame.content, "Models\\dude", elements);
            //players[1].Size = new Vector2(80, 400);
            //level.Load(TurkeySmashGame.content, "Models\\farm");
            hud.Load(elements);
            camera.Initialize();

            sonInstance.Volume = 0.5f;
            sonInstance.IsLooped = true;
            sonInstance.Resume();
        }
Esempio n. 3
0
        // Meme methode que Element3D sans rotation ni translation
        public void Draw(SpriteBatch spriteBatch, GraphicsDevice device, Camera camera)
        {
            spriteBatch.Begin();

            background.Draw(spriteBatch);

            spriteBatch.End();

            device.BlendState = BlendState.Opaque; //rendre les textures opaques
            device.DepthStencilState = DepthStencilState.Default;

            foreach (ModelMesh mesh in model.Meshes)
            {
                Matrix localWorld = transforms[mesh.ParentBone.Index];
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.View = camera.View;
                    effect.Projection = camera.Projection;
                    effect.World = localWorld;
                }
                mesh.Draw();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Draw the model
        /// </summary>
        /// <param name="graphics">The graphics device to draw on</param>
        /// <param name="camera">A camera to determine the view</param>
        public void Draw(GraphicsDevice graphics, Camera camera)
        {
            if (model == null)
                return;

            world = Matrix.CreateScale(scale) * Matrix.CreateRotationX(modelRotationX) *
                Matrix.CreateRotationY(modelRotationY) * Matrix.CreateRotationZ(modelRotationZ)
                        * Matrix.CreateTranslation(modelPosition);

            //
            // Compute all of the bone absolute transforms
            //

            Matrix[] boneTransforms = new Matrix[bones.Count];

            for (int i = 0; i < bones.Count; i++)
            {
                Bone bone = bones[i];
                bone.ComputeAbsoluteTransform();

                boneTransforms[i] = bone.AbsoluteTransform;
            }

            //
            // Determine the skin transforms from the skeleton
            //

            Matrix[] skeleton = new Matrix[modelExtra.Skeleton.Count];
            for (int s = 0; s < modelExtra.Skeleton.Count; s++)
            {
                Bone bone = bones[modelExtra.Skeleton[s]];
                skeleton[s] = bone.SkinTransform * bone.AbsoluteTransform;
            }

            // Draw the model.
            foreach (ModelMesh modelMesh in model.Meshes)
            {
                foreach (Effect effect in modelMesh.Effects)
                {
                    if (effect is BasicEffect)
                    {
                        BasicEffect beffect = effect as BasicEffect;
                        beffect.World = boneTransforms[modelMesh.ParentBone.Index] * world;
                        beffect.View = camera.View;
                        beffect.Projection = camera.Projection;
                        beffect.EnableDefaultLighting();
                        beffect.PreferPerPixelLighting = true;
                    }

                    if (effect is SkinnedEffect)
                    {
                        SkinnedEffect seffect = effect as SkinnedEffect;
                        seffect.World = boneTransforms[modelMesh.ParentBone.Index] * world;
                        seffect.View = camera.View;
                        seffect.Projection = camera.Projection;
                        seffect.EnableDefaultLighting();
                        seffect.PreferPerPixelLighting = true;
                        seffect.SetBoneTransforms(skeleton);
                    }
                }

                modelMesh.Draw();
            }
        }