static GunBulletSmokeComponent()
    {
        VertexPositions.Create(new Vector3[]
        {
            new Vector3(-0.5f, +1, 0),
            new Vector3(+0.5f, +1, 0),
            new Vector3(-0.5f, 0, 0),
            new Vector3(+0.5f, 0, 0),
        }, Accessibility.None);

        VertexTextureCoords.Create(new Vector2[]
        {
            new Vector2(0, 0),
            new Vector2(1, 0),
            new Vector2(0, 1),
            new Vector2(1, 1),
        }, Accessibility.None);

        VertexShader.CreateFromFile("res/shader/GunBulletSmokeVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/GunBulletSmokePixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 1, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);

        Texture.Create("res/texture/water.dds", Accessibility.None);
    }
Пример #2
0
    static FloorComponent()
    {
        VertexShader.CreateFromFile("res/shader/FloorVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/FloorPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("NORMAL", 0, Format.Float3, 1, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 2, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);

        GraphicsModel.CreateBillBoard();
        GraphicsModel.Texture = new Texture2D();
        GraphicsModel.Texture.Create("res/texture/wall.png", Accessibility.None);

        Program.ResourceManager.Register("res/shader/FloorVertexShader.hlsl", (path) => VertexShader);
        Program.ResourceManager.Load("res/shader/FloorVertexShader.hlsl");
        Program.ResourceManager.Register("res/shader/FloorPixelShader.hlsl", (path) => PixelShader);
        Program.ResourceManager.Load("res/shader/FloorPixelShader.hlsl");
        Program.ResourceManager.Register("FloorVertexLayout", (path) => VertexLayout);
        Program.ResourceManager.Load("FloorVertexLayout");
        Program.ResourceManager.Register("FloorGraphicsModel", (path) => GraphicsModel);
        Program.ResourceManager.Load("FloorGraphicsModel");
    }
Пример #3
0
    static BallComponent()
    {
        VertexShader.CreateFromFile("res/shader/BallVertexShader.hlsl");
        PixelShader0.CreateFromFile("res/shader/BallPixelShader.hlsl", "pass0");
        PixelShader1.CreateFromFile("res/shader/BallPixelShader.hlsl", "pass1");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("NORMAL", 0, Format.Float3, 1, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);

        GraphicsModel.CreateSphere(16, 16);

        SamplerState0.Create(TextureAddressMode.Wrap, TextureAddressMode.Wrap, TextureAddressMode.Wrap);
        SamplerState1.CreateComparator();

        Program.ResourceManager.Register("res/shader/BallVertexShader.hlsl", (path) => VertexShader);
        Program.ResourceManager.Load("res/shader/BallVertexShader.hlsl");
        Program.ResourceManager.Register("res/shader/BallPixelShader0.hlsl", (path) => PixelShader0);
        Program.ResourceManager.Load("res/shader/BallPixelShader0.hlsl");
        Program.ResourceManager.Register("res/shader/BallPixelShader1.hlsl", (path) => PixelShader1);
        Program.ResourceManager.Load("res/shader/BallPixelShader1.hlsl");
        Program.ResourceManager.Register("WallVertexLayout", (path) => VertexLayout);
        Program.ResourceManager.Load("WallVertexLayout");
        Program.ResourceManager.Register("WallGraphicsModel", (path) => GraphicsModel);
        Program.ResourceManager.Load("WallGraphicsModel");
        Program.ResourceManager.Register("WallSamplerState0", (path) => SamplerState0);
        Program.ResourceManager.Load("WallSamplerState0");
        Program.ResourceManager.Register("WallSamplerState1", (path) => SamplerState1);
        Program.ResourceManager.Load("WallSamplerState1");
    }
Пример #4
0
    static CloudComponent()
    {
        VertexPositions.Create(new Vector3[]
        {
            new Vector3(-0.5f, +0.5f, 0),
            new Vector3(+0.5f, +0.5f, 0),
            new Vector3(-0.5f, -0.5f, 0),
            new Vector3(+0.5f, -0.5f, 0),
        }, Accessibility.None);

        VertexTextureCoords.Create(new Vector2[]
        {
            new Vector2(0, 0),
            new Vector2(1, 0),
            new Vector2(0, 1),
            new Vector2(1, 1),
        }, Accessibility.None);

        VertexShader.CreateFromFile("res/shader/CloudVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/CloudPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 1, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("WVP", 0, Format.Float4, 2, sizeof(float) * 0, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 1, Format.Float4, 2, sizeof(float) * 4, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 2, Format.Float4, 2, sizeof(float) * 8, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 3, Format.Float4, 2, sizeof(float) * 12, VertexElement.Classification.InstanceData, 1),
        }, VertexShader);

        Texture.Create("res/texture/cloud.dds", Accessibility.None);
    }
Пример #5
0
    static SkyComponent()
    {
        // 円周方向の分割数
        const int Slices = 16;

        // Y方向の分割数
        const int Stacks = 8;

        List <Vector3> positions = new List <Vector3>();

        for (int i = 0; i < Stacks + 1; i++)
        {
            float y = 1.0f - 2.0f * (float)i / Stacks;
            float r = sqrt(1 - y * y);
            for (int j = 0; j < Slices + 1; j++)
            {
                float   t = (float)j / Slices * 3.14159f * 2;
                float   x = r * cos(t);
                float   z = r * sin(t);
                Vector3 v = new Vector3(x / 2, y / 2, z / 2);
                positions.Add(v);
            }
        }
        VertexBuffer.Create(positions.ToArray(), Accessibility.None);

        List <int> indices = new List <int>();

        for (int i = 0; i < Stacks; i++)
        {
            for (int j = 0; j < Slices; j++)
            {
                int i0 = (Slices + 1) * i + j;
                int i1 = i0 + 1;
                int i2 = (Slices + 1) * (i + 1) + j;
                int i3 = i2 + 1;
                indices.Add(i0);
                indices.Add(i2);
                indices.Add(i1);
                indices.Add(i1);
                indices.Add(i2);
                indices.Add(i3);
            }
        }
        IndexBuffer.Create(indices.ToArray(), Accessibility.None);

        Texture.CreateCubeMap("res/texture/skybox.dds", Accessibility.None);

        VertexShader.CreateFromFile("res/shader/SkyVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/SkyPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);
    }
Пример #6
0
    static DebugComponent()
    {
        VertexShader.CreateFromFile("res/shader/DebugVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/DebugPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);

        GraphicsModel.CreateSphere(16, 16);
    }
Пример #7
0
    static GroundComponent()
    {
        VertexShader.CreateFromFile("res/shader/GroundVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/GroundPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("NORMAL", 0, Format.Float3, 1, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 2, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);
    }
Пример #8
0
    static MissileComponent()
    {
        VertexShader.CreateFromFile("res/shader/MissileVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/MissilePixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("NORMAL", 0, Format.Float3, 1, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 2, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);

        GraphicsModel.CreateFromCX("res/mesh/missile/missile.cx");
    }
Пример #9
0
    static GunBulletComponent()
    {
        VertexShader.CreateFromFile("res/shader/GunBulletVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/GunBulletPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("INDEX", 0, Format.SInt1, 0, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);

        VertexPositions.Create(new uint[2] {
            0, 1
        }, Accessibility.None);
    }
Пример #10
0
    static GunFlushComponent()
    {
        VertexShader.CreateFromFile("res/shader/GunFlushVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/GunFlushPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 1, 0),
        }, VertexShader);

        GraphicsModel.CreateBillBoard();
        GraphicsModel.Texture = new Texture2D();
        GraphicsModel.Texture.Create("res/texture/flash.dds", Accessibility.None);
    }
Пример #11
0
    static AircraftFlameComponent()
    {
        VertexShader.CreateFromFile("res/shader/AircraftFlameVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/AircraftFlamePixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 1, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);

        Textures.Create("res/texture/flame.dds", Accessibility.None);

        GraphicsModel.CreateBillBoard();
    }
Пример #12
0
    static DamageViewComponent()
    {
        VertexPositions.Create(new Vector3[]
        {
            new Vector3(-0.5f, +0.5f, 0),
            new Vector3(+0.5f, +0.5f, 0),
            new Vector3(-0.5f, -0.5f, 0),
            new Vector3(+0.5f, -0.5f, 0),
        }, Accessibility.None);

        VertexShader.CreateFromFile("res/shader/DamageViewVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/DamageViewPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0)
        }, VertexShader);
    }
Пример #13
0
    static ExplosionComponent()
    {
        VertexShader.CreateFromFile("res/shader/ExplosionVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/ExplosionPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 1, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);

        for (int i = 0; i < TextureCount; i++)
        {
            Textures[i] = new Texture2D();
            Textures[i].Create(string.Format("res/texture/explos/explos ({0}).png", i + 1), Accessibility.None);
        }

        GraphicsModel.CreateBillBoard();
    }
Пример #14
0
    static StringySmokeComponent()
    {
        VertexPositions.Create(new Vector3[]
        {
            new Vector3(0, 1, 1),
            new Vector3(0, 1, 0),
            new Vector3(0, 0, 1),
            new Vector3(0, 0, 0),
        }, Accessibility.None);

        VertexTextureCoords.Create(new Vector2[]
        {
            new Vector2(0, 0),
            new Vector2(1, 0),
            new Vector2(0, 1),
            new Vector2(1, 1),
        }, Accessibility.None);

        InstanceColors.Create(InstanceCount, Accessibility.DynamicWriteOnly);
        InstanceWVPs.Create(InstanceCount, Accessibility.DynamicWriteOnly);

        VertexShader.CreateFromFile("res/shader/StringySmokeVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/StringySmokePixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 1, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("COLOR", 0, Format.Float4, 2, 0, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 0, Format.Float4, 3, sizeof(float) * 0, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 1, Format.Float4, 3, sizeof(float) * 4, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 2, Format.Float4, 3, sizeof(float) * 8, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 3, Format.Float4, 3, sizeof(float) * 12, VertexElement.Classification.InstanceData, 1),
        }, VertexShader);

        Texture.Create("res/texture/stringy_smoke.dds", Accessibility.None);
    }
Пример #15
0
    static WindComponent()
    {
        VertexPositions.Create(new Vector3[]
        {
            new Vector3(-0.5f, 0, +0.5f),
            new Vector3(+0.5f, 0, +0.5f),
            new Vector3(-0.5f, 0, -0.5f),
            new Vector3(+0.5f, 0, -0.5f),
        }, Accessibility.None);

        VertexTextureCoords.Create(new Vector2[]
        {
            new Vector2(0, 0),
            new Vector2(1, 0),
            new Vector2(0, 1),
            new Vector2(1, 1),
        }, Accessibility.None);

        VertexShader.CreateFromFile("res/shader/WindVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/WindPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 1, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("ALPHA", 0, Format.Float1, 2, 0, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 0, Format.Float4, 3, sizeof(float) * 0, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 1, Format.Float4, 3, sizeof(float) * 4, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 2, Format.Float4, 3, sizeof(float) * 8, VertexElement.Classification.InstanceData, 1),
            new VertexElement("WVP", 3, Format.Float4, 3, sizeof(float) * 12, VertexElement.Classification.InstanceData, 1),
        }, VertexShader);

        Texture.Create("res/texture/wind.dds", Accessibility.None);

        InstanceAlphas.Create(InstanceCount, Accessibility.DynamicWriteOnly);
        InstanceWVPs.Create(InstanceCount, Accessibility.DynamicWriteOnly);
    }
Пример #16
0
    static AircraftComponent()
    {
        VertexShader.CreateFromFile("res/shader/AircraftVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/AircraftPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("NORMAL", 0, Format.Float3, 1, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 2, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TANGENT", 0, Format.Float3, 3, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("BINORMAL", 0, Format.Float3, 4, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);

        //var table = CsvParserExtensions.Parse("res/data/aircrafts.csv", '\t');

        //foreach (var model in table)
        //{
        //    ResourceManager.Register(model["Name"], (name) =>
        //    {
        //        return new AircraftComponent(model);
        //    });
        //}
    }
Пример #17
0
    static JetComponent()
    {
        VertexShader.CreateFromFile("res/shader/JetVertexShader.hlsl");
        PixelShader.CreateFromFile("res/shader/JetPixelShader.hlsl");

        VertexLayout.Create(new VertexElement[]
        {
            new VertexElement("POSITION", 0, Format.Float3, 0, 0, VertexElement.Classification.VertexData, 0),
            new VertexElement("TEXCOORD", 0, Format.Float2, 1, 0, VertexElement.Classification.VertexData, 0),
        }, VertexShader);

        const int DIVISIONS = 24;   // 円の三角形の分割数
        const int LENGTH    = 4;    // 円の数

        // 頂点数
        const int VERTICES = (DIVISIONS + 1 + 1) * LENGTH + DIVISIONS * 4 / 2;

        // インデックス数
        const int INDICES = DIVISIONS * LENGTH * 3 + DIVISIONS * 2 * 3 / 2;

        // 頂点バッファを作成する
        {
            Vector3[] positions = new Vector3[VERTICES];
            Vector2[] texcoords = new Vector2[VERTICES];
            int       idx       = 0;

            for (int l = 0; l < LENGTH; l++)
            {
                // 中心の点
                float u = (float)l / (LENGTH - 1);
                float z = -(float)l / (LENGTH - 1);
                positions[idx] = new Vector3(0, 0, z);
                texcoords[idx] = new Vector2(0, 0.5f);
                idx++;

                // 円周上の点
                for (int d = 0; d < DIVISIONS + 1; d++)
                {
                    const float pi2 = (float)Math.PI * 2.0f;
                    float       r   = 0.5f - 0.25f * l / (LENGTH - 1); // 0.25 -> 0.125
                    float       t   = pi2 * (float)d / DIVISIONS;      // 0 -> pie * 2
                    float       x   = r * cos(t);
                    float       y   = r * sin(t);
                    float       v   = 0;
                    positions[idx] = new Vector3(x, y, z);
                    texcoords[idx] = new Vector2(u, v);
                    idx++;
                }
            }

            // 断面の点
            for (int d = 0; d < DIVISIONS / 2; d++)
            {
                const float pi = (float)Math.PI;
                float       t  = pi * d / DIVISIONS * 2;            // 0 -> pie
                float       x  = 0.5f * cos(t);
                float       y  = -0.5f * sin(t);
                var         p0 = new Vector3(-x, -y, 0);
                var         p1 = new Vector3(x, y, 0);
                var         p2 = new Vector3(-0.5f * x, -0.5f * y, -1);
                var         p3 = new Vector3(0.5f * x, 0.5f * y, -1);
                var         t0 = new Vector2(0, 0);
                var         t1 = new Vector2(0, 1);
                var         t2 = new Vector2(1, 0);
                var         t3 = new Vector2(1, 1);
                positions[idx] = p0;
                texcoords[idx] = t0;
                idx++;
                positions[idx] = p1;
                texcoords[idx] = t1;
                idx++;
                positions[idx] = p2;
                texcoords[idx] = t2;
                idx++;
                positions[idx] = p3;
                texcoords[idx] = t3;
                idx++;
            }
            VertexPositionsBuffer.Create(positions, Accessibility.None);
            VertexTexcoordsBuffer.Create(texcoords, Accessibility.None);
        }

        // インデックスバッファを作成する
        {
            int[] indexBufferSource = new int[INDICES];
            int   idx = 0;
            {
                // 円の描画
                for (int l = 0; l < LENGTH; l++)
                {
                    int offset = l * (DIVISIONS + 2);
                    for (int d = 0; d < DIVISIONS; d++)
                    {
                        indexBufferSource[idx++] = offset + 0;
                        indexBufferSource[idx++] = offset + d + 1;
                        indexBufferSource[idx++] = offset + d + 2;
                    }
                }

                // 円柱の描画
                for (int d = 0; d < DIVISIONS / 2; d++)
                {
                    const int offset = (DIVISIONS + 1 + 1) * LENGTH;
                    int       i0     = offset + d * 4;
                    int       i1     = offset + d * 4 + 1;
                    int       i2     = offset + d * 4 + 2;
                    int       i3     = offset + d * 4 + 3;
                    indexBufferSource[idx++] = i0;
                    indexBufferSource[idx++] = i1;
                    indexBufferSource[idx++] = i2;
                    indexBufferSource[idx++] = i2;
                    indexBufferSource[idx++] = i1;
                    indexBufferSource[idx++] = i3;
                }
            }
            IndexBuffer.Create(indexBufferSource, Accessibility.None);
        }

        // テクスチャを作成する
        Texture.Create("res/texture/jet.dds", Accessibility.None);
    }