Exemple #1
0
        public override void Draw(GameTime gameTime)
        {
            Effect        Effect   = Resource.Effect;
            LightMaterial material = Resources.gMaterials[0];

            foreach (ModelMesh mesh in Resource.model.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    Matrix world = mesh.ParentBone.Transform * finalTransform;
                    part.Effect = Effect;
                    Weather.SetStandardEffect(ref Effect, material, world);
                    if (hasTexture)
                    {
                        Effect.CurrentTechnique = Effect.Techniques["TTexSM2"];
                        Effect.Parameters["xTexture"].SetValue(Resource.texture);
                    }
                    else
                    {
                        Effect.CurrentTechnique = Effect.Techniques["TSM2"];
                    }
                }
                mesh.Draw();
            }
            base.Draw(gameTime);
        }
Exemple #2
0
        public Rectangle(Vector3 pos1, Vector3 pos3, Vector4 col) : base()
        {
            Name = "rect";

            color = col;

            Vector3 pos2 = new Vector3(pos3.X, pos1.Y, pos3.Z);
            Vector3 pos4 = new Vector3(pos1.X, pos3.Y, pos1.Z);

            positionVboData = new Vector3[] { pos1, pos2, pos3, pos4 };

            Vector3 normal = Vector3.Cross(pos2 - pos1, pos4 - pos1).Normalized();

            normalVboData = new Vector3[] { normal, normal, normal, normal };
            //normalVboData = new Vector3[] { new Vector3(0f, 0f, 1f), new Vector3(0f, 0f, 1f), new Vector3(0f, 0f, 1f), new Vector3(0f, 0f, 1f) };
            indicesVboData = new int[] { 0, 1, 2, 3 };

            material = new LightMaterial();
            if (!material.Ready)
            {
                return;
            }

            createVBOs();
            createVAOs();

            ready = true;
        }
Exemple #3
0
        void DrawPart(GraphicsResource Part, Effect Effect, LightMaterial Mat, Vector3 Offset, Color Color)
        {
            Effect.Parameters["customColors"].SetValue(true);
            Effect.Parameters["customColorA"].SetValue(Color.ToVector4());
            if (Part.lightmap != null)
            {
                Effect.Parameters["xLightmap"].SetValue(Part.lightmap);
            }
            foreach (ModelMesh mesh in Part.model.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    Matrix world = mesh.ParentBone.Transform * Matrix.CreateTranslation(Offset) * finalTransform;
                    part.Effect = Effect;
                    Weather.SetStandardEffect(ref Effect, Mat, world);

                    if (Part.texture != null)
                    {
                        Effect.CurrentTechnique = Effect.Techniques["TTexSM2"];
                        Effect.Parameters["xTexture"].SetValue(Part.texture);
                    }
                    else
                    {
                        Effect.CurrentTechnique = Effect.Techniques["TSM2"];
                    }
                }
                mesh.Draw();
            }
            Effect.Parameters["customColors"].SetValue(false);
        }
Exemple #4
0
        public Sphere(string name, float radius, int detail) : base()
        {
            Name   = name;
            Detail = detail;

            Radius = radius;
            color  = new Vector4(0.3f, 0.1f, 0.9f, 1.0f);

            if (setupGeometry())
            {
                Log.WriteLine("Sphere '" + name + "' loaded " +
                              positionVboData.Length + " vertices, " +
                              normalVboData.Length + " normals, " +
                              indicesVboData.Length + " indices");

                material = new LightMaterial();
                if (!material.Ready)
                {
                    return;
                }

                createVBOs();
                createVAOs();

                ready = true;
            }
            else
            {
                Log.WriteLine(Log.LOG_ERROR, "failed setting up environment model '" + Name + "'");
            }
        }
Exemple #5
0
        public SceneData()
        {
            IMaterial lightMaterial = new LightMaterial {
                Color = new Vector(50, 80, 100)
            };                                                                               //небо

            lights.Add(new DirectionLight
            {
                Color      = new Vector(500, 400, 100),
                Direction  = new Vector(.6f, .6f, 1).Normal(),
                Material   = lightMaterial,
                randomCoef = 0.2f
            });
            var roomMaterial = new DifuseMaterial()
            {
                Color = new Vector(0.2f, 0.2f, 0.2f)
            };

            //objects.Add(
            //    new Box3D { LowerLeft = new Vector(-14f, 1f, -4f), UpperRight = new Vector(-6f, 9f, 4f) }
            //    .Substract( new Sphere3D()
            //        {
            //            Radius = 5,
            //            Center = new Vector(-10, 5, 0)
            //        })
            //    .SetMaterial(roomMaterial)//new MirrorMaterial() { Color = new Vector(1, 1, 1) })
            //);

            //objects.Add(new Sphere3D()
            //{
            //    Radius = 3,
            //    Center = new Vector(-10, 5, 0)
            //}.SetMaterial(new MirrorMaterial() { Color = new Vector(1f, 0.1f, 0.1f) }));

            objects.Add(new Text3D("PIXAR").SetMaterial(new MirrorMaterial()));
            //Room
            objects.Add(new InvertOp()
            {
                Objects = new List <IFigure3D> {
                    new Box3D {
                        LowerLeft = new Vector(-30, -.5f, -30), UpperRight = new Vector(30, 18, 30)
                    },                                                                                        //LowerRoom
                    new Box3D {
                        LowerLeft = new Vector(-25, 17, -25), UpperRight = new Vector(25, 20, 25)
                    },                                                                                      //UpperRoom
                }
            }.SetMaterial(roomMaterial));
            objects.Add(new Box3D()
            {
                LowerLeft = new Vector(1.5f, 18.5f, -25), UpperRight = new Vector(6.5f, 20, 25)
            }
                        .RepeatX(8)
                        .SetMaterial(roomMaterial));
            objects.Add(Plane3D.YMinus(19.9).SetMaterial(lightMaterial));
        }
Exemple #6
0
        public Box(float negX, float negY, float negZ, float posX, float posY, float posZ, Vector4 col) : base()
        {
            Name = "Box";

            Color = col;
            Size  = new Vector3(posX - negX, posY - negY, posZ - negZ);

            positionVboData = new Vector3[]
            {
                new Vector3(negX, negY, posZ), new Vector3(negX, posY, posZ), new Vector3(posX, posY, posZ), new Vector3(posX, negY, posZ), // front
                new Vector3(posX, negY, posZ), new Vector3(posX, posY, posZ), new Vector3(posX, posY, negZ), new Vector3(posX, negY, negZ), // right
                new Vector3(posX, negY, negZ), new Vector3(posX, posY, negZ), new Vector3(negX, posY, negZ), new Vector3(negX, negY, negZ), // back
                new Vector3(negX, negY, negZ), new Vector3(negX, posY, negZ), new Vector3(negX, posY, posZ), new Vector3(negX, negY, posZ), // left
                new Vector3(negX, posY, posZ), new Vector3(negX, posY, negZ), new Vector3(posX, posY, negZ), new Vector3(posX, posY, posZ), // top
                new Vector3(negX, negY, negZ), new Vector3(negX, negY, posZ), new Vector3(posX, negY, posZ), new Vector3(posX, negY, negZ)  // bottom
            };

            normalVboData = new Vector3[]
            {
                new Vector3(0f, 0f, 1f), new Vector3(0f, 0f, 1f), new Vector3(0f, 0f, 1f), new Vector3(0f, 0f, 1f),             // front
                new Vector3(1f, 0f, 0f), new Vector3(1f, 0f, 0f), new Vector3(1f, 0f, 0f), new Vector3(1f, 0f, 0f),             // right
                new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f),         // back
                new Vector3(-1f, 0f, 0f), new Vector3(-1f, 0f, 0f), new Vector3(-1f, 0f, 0f), new Vector3(-1f, 0f, 0f),         // left
                new Vector3(0f, 1f, 0f), new Vector3(0f, 1f, 0f), new Vector3(0f, 1f, 0f), new Vector3(0f, 1f, 0f),             // top
                new Vector3(0f, -1f, 0f), new Vector3(0f, -1f, 0f), new Vector3(0f, -1f, 0f), new Vector3(0f, -1f, 0f)          // bottom
            };

            indicesVboData = new int[]
            {
                0, 1, 2, 0, 2, 3,       // front face
                4, 5, 6, 4, 6, 7,       // right face
                8, 9, 10, 8, 10, 11,    // back face
                12, 13, 14, 12, 14, 15, // left face
                16, 17, 18, 16, 18, 19, // top face
                20, 21, 22, 20, 22, 23  // bottom face
            };

            material = new LightMaterial();
            if (!material.Ready)
            {
                return;
            }

            createVBOs();
            createVAOs();

            ready = true;
        }
Exemple #7
0
    public virtual void GenerateQuality(int value)
    {
        if (value > 7)
        {
            value = 7;
        }
        if (material == Material.Metal)
        {
            MetalMaterial randomMaterial = RandomEnum.IndexOf <MetalMaterial>(value);

            name            = randomMaterial.ToString() + " " + name;
            levelMultiplyer = (int)randomMaterial + 1;//starts at zero
        }
        else if (material == Material.Wood)
        {
            WoodMaterial randomMaterial = RandomEnum.IndexOf <WoodMaterial>(value);

            name            = randomMaterial.ToString() + " " + name;
            levelMultiplyer = (int)randomMaterial + 1;//starts at zero
        }
        else if (material == Material.Cloth)
        {
            LightMaterial randomMaterial = RandomEnum.IndexOf <LightMaterial>(value);

            name            = randomMaterial.ToString() + " " + name;
            levelMultiplyer = (int)randomMaterial + 1;//starts at zero
        }
        else if (material == Material.Leather)
        {
            LeatherMaterial randomMaterial = RandomEnum.IndexOf <LeatherMaterial>(value);

            name            = randomMaterial.ToString() + " " + name;
            levelMultiplyer = (int)randomMaterial + 1;//starts at zero
        }
        else if (material == Material.Gem)
        {
            GemMaterial randomMaterial = RandomEnum.IndexOf <GemMaterial>(value);

            name            = randomMaterial.ToString() + " " + name;
            levelMultiplyer = (int)randomMaterial + 1;//starts at zero
        }


        //change values based on material quality;
        defence *= levelMultiplyer;
    }
Exemple #8
0
        public override void Draw()
        {
            var device = MobileFortressClient.Game.GraphicsDevice;

            device.Indices = indexBuffer;
            device.SetVertexBuffer(vertexBuffer);
            Effect        effect   = Resources.gEffects[0];
            LightMaterial material = Resources.gMaterials[1];

            Weather.SetStandardEffect(ref effect, material, Matrix.Identity);

            effect.CurrentTechnique = effect.Techniques["TTexSM2"];
            effect.Parameters["xTexture"].SetValue(Resources.Island.OceanTex);
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);
            }
        }
Exemple #9
0
    public virtual void GenerateQuality()   //if value <0 do random value. testing random material generation.
    {
        if (material == Material.Metal)
        {
            MetalMaterial randomMaterial = RandomEnum.Of <MetalMaterial>();

            name            = randomMaterial.ToString() + " " + name;
            levelMultiplyer = (int)randomMaterial + 1;//starts at zero
        }
        else if (material == Material.Wood)
        {
            WoodMaterial randomMaterial = RandomEnum.Of <WoodMaterial>();

            name            = randomMaterial.ToString() + " " + name;
            levelMultiplyer = (int)randomMaterial + 1;//starts at zero
        }
        else if (material == Material.Cloth)
        {
            LightMaterial randomMaterial = RandomEnum.Of <LightMaterial>();

            name            = randomMaterial.ToString() + " " + name;
            levelMultiplyer = (int)randomMaterial + 1;//starts at zero
        }
        else if (material == Material.Leather)
        {
            LeatherMaterial randomMaterial = RandomEnum.Of <LeatherMaterial>();

            name            = randomMaterial.ToString() + " " + name;
            levelMultiplyer = (int)randomMaterial + 1;//starts at zero
        }
        else if (material == Material.Gem)
        {
            GemMaterial randomMaterial = RandomEnum.Of <GemMaterial>();

            name            = randomMaterial.ToString() + " " + name;
            levelMultiplyer = (int)randomMaterial + 1;//starts at zero
        }


        //change values based on material quality;
        defence *= levelMultiplyer;
        //attackSpeed *= levelMultiplyer;??
    }
Exemple #10
0
        public override void Draw(GameTime gameTime)
        {
            GraphicsResource Nose;
            GraphicsResource Core;
            GraphicsResource Tail;

            Data.SetDrawingResources(out Nose, out Core, out Tail);

            LightMaterial Material = Resources.gMaterials[0];

            DrawPart(Core, Core.Effect, Material, Vector3.Zero, Data.CoreColor);
            DrawPart(Nose, Nose.Effect, Material, Vector3.Forward * 1.5f, Data.NoseColor);
            DrawPart(Tail, Tail.Effect, Material, Vector3.Backward * 1.5f, Data.TailColor);
            foreach (KeyValuePair <Vector3, WeaponData> kvp in Data.Weapons)
            {
                if (kvp.Value != null && kvp.Value.Draw)
                {
                    var res = Resources.GetResource((ushort)(Resources.WeaponIndex + kvp.Value.Index));
                    DrawPart(res, res.Effect, Material, kvp.Key, Data.WeaponColor);
                }
            }
        }
        public void DrawShip()
        {
            GraphicsResource noseRes;
            GraphicsResource coreRes;
            GraphicsResource tailRes;

            Ship.SetDrawingResources(out noseRes, out coreRes, out tailRes);

            LightMaterial Material = Resources.gMaterials[0];

            DrawPart(coreRes, coreRes.Effect, Material, Vector3.Up * 0.001f, Ship.CoreColor);
            DrawPart(noseRes, noseRes.Effect, Material, Vector3.Forward * 1.5f, Ship.NoseColor);
            DrawPart(tailRes, tailRes.Effect, Material, Vector3.Backward * 1.5f, Ship.TailColor);
            foreach (KeyValuePair <Vector3, WeaponData> kvp in Ship.Weapons)
            {
                if (kvp.Value != null)
                {
                    var res = Resources.GetResource((ushort)(Resources.WeaponIndex + kvp.Value.Index));
                    DrawPart(res, res.Effect, Material, kvp.Key, Ship.WeaponColor);
                }
            }
        }
Exemple #12
0
        public override void Draw(GameTime gameTime)
        {
            Effect        effect   = Resources.gEffects[2];
            LightMaterial material = Resources.gMaterials[0];

            Weather.SetStandardEffect(ref effect, material, Matrix.Identity);

            effect.CurrentTechnique = effect.Techniques["Simple"];
            effect.Parameters["xTexture0"].SetValue(Resources.Island.SeafloorTex);
            effect.Parameters["xTexture1"].SetValue(Resources.Island.SandTex);
            effect.Parameters["xTexture2"].SetValue(Resources.Island.PlainTex);
            effect.Parameters["xTexture3"].SetValue(Resources.Island.SnowTex);
            effect.Parameters["mipStart"].SetValue(55f);
            effect.Parameters["mipEnd"].SetValue(150f);

            GraphicsDevice.Indices = indexBuffer;
            GraphicsDevice.SetVertexBuffer(vertexBuffer);
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertexPNTs.Length, 0, indices.Length / 3);
            }
        }
Exemple #13
0
        public override void Draw()
        {
            GraphicsDevice device = MobileFortressClient.Game.GraphicsDevice;

            device.RasterizerState = RasterizerState.CullNone;
            GraphicsResource explosionResource = Resources.GetResource(1);
            Effect           Effect            = explosionResource.Effect;

            LightMaterial material = Resources.gMaterials[2];

            foreach (ModelMesh mesh in explosionResource.model.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    Matrix world = mesh.ParentBone.Transform * Transform * explosionResource.transform;
                    part.Effect = Effect;
                    Weather.SetStandardEffect(ref Effect, material, world);
                    Effect.CurrentTechnique = Effect.Techniques["TTexSM2"];
                    Effect.Parameters["xTexture"].SetValue(explosionResource.texture);
                }
                mesh.Draw();
            }
            device.RasterizerState = RasterizerState.CullCounterClockwise;
        }
 void DrawPart(GraphicsResource Part, Effect Effect, LightMaterial Mat, Vector3 Offset, Color Color)
 {
     if (Part.lightmap != null)
     {
         Effect.Parameters["xLightmap"].SetValue(Part.lightmap);
     }
     foreach (ModelMesh mesh in Part.model.Meshes)
     {
         foreach (ModelMeshPart part in mesh.MeshParts)
         {
             Matrix world = mesh.ParentBone.Transform * Matrix.CreateTranslation(Offset) * Part.transform * shipRotation;
             part.Effect = Effect;
             Weather.SetStandardEffect(ref Effect, Mat, world);
             if (Part.texture != null)
             {
                 Effect.CurrentTechnique = Effect.Techniques["TTexSM2"];
                 Effect.Parameters["xTexture"].SetValue(Part.texture);
             }
             else
                 Effect.CurrentTechnique = Effect.Techniques["TSM2"];
             Effect.Parameters["customColors"].SetValue(true);
             Effect.Parameters["customColorA"].SetValue(Color.ToVector4());
         }
         mesh.Draw();
     }
     Effect.Parameters["customColors"].SetValue(false); //Don't make gray in the entire world change kthx.
 }