public override void Draw(Camera camera, GameTime gameTime)
        {
            Matrix modelWorld = Matrix.CreateScale(Scale) * Matrix.CreateFromQuaternion(Rotation) * /*Matrix.CreateFromYawPitchRoll(Rotation.Y, Rotation.X, Rotation.Z) */ Matrix.CreateTranslation(Position);

            Matrix[] transforms = new Matrix[Model.Bones.Count];
            Animator.CopyAbsoluteTransformsTo(transforms);
            
            int i = 0;
            foreach (ModelMesh mesh in Model.Meshes)
            {
                Matrix meshWorld = transforms[mesh.ParentBone.Index] * modelWorld;

                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    meshPart.Effect = Effect;

                    meshPart.Effect.Parameters["World"].SetValue(meshWorld);
                    meshPart.Effect.Parameters["View"].SetValue(camera.View);
                    meshPart.Effect.Parameters["Projection"].SetValue(camera.Projection);
                    meshPart.Effect.Parameters["Texture"].SetValue(ModelMaterials[i].Texture);

                    if (meshPart.Effect.Parameters.Count(p => p.Name == "SpecularIntensity") == 1)
                        meshPart.Effect.Parameters["SpecularIntensity"].SetValue(ModelMaterials[i].SpecularIntensity);
                    if (meshPart.Effect.Parameters.Count(p => p.Name == "SpecularPower") == 1)
                        meshPart.Effect.Parameters["SpecularPower"].SetValue(ModelMaterials[i].SpecularPower);

                    i++;
                }
            }

            Animator.InitializeEffectParams();
            Animator.Draw(gameTime);
        }
        public override void Draw(Camera camera, GameTime gameTime)
        {
            for (int y = 0; y < 32; y++)
                for (int z = 0; z < 128; z++)
                    for (int x = 0; x < 128; x++)
                    {
                        // Afficher un cube :p
                    }

            // TODO: Afficher seulement les voxels visibles
        }
示例#3
0
        public override void Draw(Camera camera, GameTime gameTime)
        {
            Game.GraphicsDevice.DepthStencilState = DepthStencilState.None;

            model.Position = camera.Position;
            model.Effect = Effect;
            if (Effect.Parameters.Count(p => p.Name == "InfiniteDepth") == 1)
                Effect.Parameters["InfiniteDepth"].SetValue(true);
            model.Draw(camera, gameTime);
            if (Effect.Parameters.Count(p => p.Name == "InfiniteDepth") == 1)
                Effect.Parameters["InfiniteDepth"].SetValue(false);

            Game.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
        }
 public abstract void Draw(Camera camera, GameTime gameTime);
 public override void Draw(Camera camera, GameTime gameTime)
 {
     foreach (DrawableObject o in Objects)
         o.Draw(camera, gameTime);
 }
示例#6
0
        public override void Draw(Camera camera, GameTime gameTime)
        {
            Effect.Parameters["World"].SetValue(Matrix.CreateScale(Scale) * Matrix.CreateTranslation(Position));
            Effect.Parameters["View"].SetValue(camera.View);
            Effect.Parameters["Projection"].SetValue(camera.Projection);

            // FIXME
            if (Effect.Parameters.Count(p => p.Name == "Texture") == 1)
                Effect.Parameters["Texture"].SetValue(Material.Texture);
            if (Effect.Parameters.Count(p => p.Name == "SpecularIntensity") == 1)
                Effect.Parameters["SpecularIntensity"].SetValue(Material.SpecularIntensity);
            if (Effect.Parameters.Count(p => p.Name == "SpecularPower") == 1)
                Effect.Parameters["SpecularPower"].SetValue(Material.SpecularPower);

            Effect.CurrentTechnique.Passes[0].Apply();

            Game.GraphicsDevice.Indices = indexBuffer;
            Game.GraphicsDevice.SetVertexBuffer(vertexBuffer);
            Game.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, 0, 0, vertexBuffer.VertexCount, 0, indexBuffer.IndexCount);
        }