Exemple #1
0
        public override void Draw()
        {
            Model model = information.Model;

            // bad, bad code!
            texture = GameContainer.ContentManager.Load <Texture2D>(information.StatueSettings.TextureName);
            for (int i = 0; i < model.Meshes.Count; i++)
            {
                for (int j = 0; j < model.Meshes[i].MeshParts.Count; j++)
                {
                    model.Meshes[i].MeshParts[j].Effect = lambert;
                }
            }

            fxTexture.SetValue(texture);
            fxViewInverted.SetValue(Matrix.Invert(camera.View));

            fxWorldInvertedTranspose.SetValueTranspose(Matrix.Invert(transform.World));
            fxWvp.SetValue(transform.World * camera.View * camera.Projection);
            fxWorld.SetValue(transform.World);

            lambert.Parameters["Lamp0Pos"].SetValue(
                Matrix.Invert(camera.View).Translation + lampOffset);

            lambert.Parameters["Lamp0Color"].SetValue(specular);
            lambert.Parameters["AmbiColor"].SetValue(ambient);

            lambert.CommitChanges();

            foreach (ModelMesh mesh in model.Meshes)
            {
                mesh.Draw();
            }
        }
Exemple #2
0
        public override void Draw()
        {
            GraphicsDevice device = GameContainer.Graphics.GraphicsDevice;

            lambert.CurrentTechnique = lambert.Techniques["Main"];

            fxTexture.SetValue(grassy);
            fxViewInverted.SetValue(Matrix.Invert(camera.View));

            fxWorldInvertedTranspose.SetValueTranspose(Matrix.Invert(transform.World));
            fxWvp.SetValue(transform.World * camera.View * camera.Projection);
            fxWorld.SetValue(transform.World);

            lambert.CommitChanges();

            lambert.Begin();
            foreach (EffectPass pass in lambert.CurrentTechnique.Passes)
            {
                pass.Begin();

                device.VertexDeclaration = vertexDecl;
                device.Indices           = ib;
                device.Vertices[0].SetSource(vb, 0, VertexPositionNormalTexture.SizeInBytes);

                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 8, 0, 12);

                pass.End();
            }
            lambert.End();
        }
 protected internal override void BeginApplyLocalParameters(DrawingContext3D context, MaterialGroup material)
 {
     if (worldParameter != null)
     {
         worldParameter.SetValue(material.world);
     }
     if (worldInverseTransposeParameter != null)
     {
         worldViewProjectionParameter.SetValue(material.world * context.Matrices.ViewProjection);
     }
     if (worldInverseTransposeParameter != null)
     {
         Matrix worldInverse;
         Matrix.Invert(ref material.world, out worldInverse);
         worldInverseTransposeParameter.SetValueTranspose(worldInverse);
     }
 }
Exemple #4
0
        public override void Draw()
        {
            velvety.CurrentTechnique = velvety.Techniques["Textured"];

            foreach (ModelMesh mesh in ball.Meshes)
            {
                Matrix world = transform.World;

                fxTexture.SetValue(rubbery);
                fxViewInverted.SetValue(Matrix.Invert(camera.View));
                fxWorldInvertedTranspose.SetValueTranspose(Matrix.Invert(world));
                fxWorld.SetValue(world);
                fxWvp.SetValue(world * camera.View * camera.Projection);

                fxSubColor.SetValue(Color.Gold.ToVector3());
                fxDiffColor.SetValue(Color.Gold.ToVector3());

                velvety.CommitChanges();

                mesh.Draw();
            }
        }
Exemple #5
0
 public void SetMatrix(ref Matrix wvp)
 {
     worldViewProjection.SetValueTranspose(wvp);
 }
Exemple #6
0
        public override void Draw()
        {
            GameContainer.Graphics.GraphicsDevice.RenderState.CullMode = CullMode.None;

            float scale = 1;

            velvety.CurrentTechnique = velvety.Techniques["Simple"];

            fxViewInverted.SetValue(Matrix.Invert(camera.View));

            fxSubColor.SetValue(
                (controller.PlayerIndex == PlayerIndex.One ?
                 new Vector3(1, 0, 0) :    // red
                 new Vector3(0, 0, 1)));   // blue

            fxDiffColor.SetValue(
                (controller.PlayerIndex == PlayerIndex.One ?
                 new Vector3(0.75f, 0.511f, 0.503f) :
                 new Vector3(0.215f, 0.477f, 0.75f)));
            fxSpecColor.SetValue(new Vector3(0.5f, 0.5f, 0.5f));

            for (int i = 0; i < skeleton.Nodes.Count; i++)
            {
                if (i == skeleton.Nodes.Count - 1)
                {
                    // draw tail
                    foreach (ModelMesh mesh in tail.Meshes)
                    {
                        Matrix world = tailTransforms[mesh.ParentBone.Index] * rotation *Matrix.CreateTranslation(skeleton.Nodes[i].Position);

                        fxWorldInvertedTranspose.SetValueTranspose(Matrix.Invert(world));
                        fxWorld.SetValue(world);
                        fxWvp.SetValue(world * camera.View * camera.Projection);

                        velvety.CommitChanges();

                        mesh.Draw();
                    }
                }
                else
                {
                    // draw part
                    foreach (ModelMesh mesh in part.Meshes)
                    {
                        Matrix world = Matrix.CreateScale(scale) * Matrix.CreateTranslation(skeleton.Nodes[i].Position);

                        fxWorldInvertedTranspose.SetValueTranspose(Matrix.Invert(world));
                        fxWorld.SetValue(world);
                        fxWvp.SetValue(world * camera.View * camera.Projection);

                        velvety.CommitChanges();

                        mesh.Draw();
                    }

                    if (scale > 0.1f)
                    {
                        scale -= 0.1f;
                    }
                }
            }
        }