Exemple #1
0
        public override void Init()
        {
            base.Init();

            var verts = new [] {
                new VertexPositionTexture {
                    Position          = new Vector3(-0.5f, -0.5f, 0.0f),
                    TextureCoordinate = new Vector2(0.0f, 1.0f)
                },
                new VertexPositionTexture {
                    Position          = new Vector3(-0.5f, 0.5f, 0.0f),
                    TextureCoordinate = new Vector2(0.0f, 0.0f)
                },
                new VertexPositionTexture {
                    Position          = new Vector3(0.5f, 0.5f, 0.0f),
                    TextureCoordinate = new Vector2(1.0f, 0.0f)
                },
                new VertexPositionTexture {
                    Position          = new Vector3(0.5f, -0.5f, 0.0f),
                    TextureCoordinate = new Vector2(1.0f, 1.0f)
                },
            };

            var indices = new short[6] {
                0, 2, 1, 0, 3, 2
            };



            var device = Game1.Inst.GraphicsDevice;

            mBillboardVbo = new VertexBuffer(device,
                                             VertexPositionTexture.VertexDeclaration,
                                             verts.Length,
                                             BufferUsage.None);
            mBillboardVbo.SetData <VertexPositionTexture>(verts);

            mBillboardIbo = new IndexBuffer(device,
                                            typeof(short),
                                            indices.Length,
                                            BufferUsage.None);
            mBillboardIbo.SetData <short>(indices);

            mBillboardMat = new BillboardMaterial();
        }
Exemple #2
0
        public Billboard(string filename, float w, float h, Vector4 col)
            : base()
        {
            Name = "Billboard";

            color = col;

            Size = new Vector3(w, h, 0.01f);

            float w2 = w * 0.5f;
            float h2 = h * 0.5f;

            positionVboData = new Vector3[] {
                new Vector3(-w2, -h2, 0),
                new Vector3(w2, -h2, 0),
                new Vector3(w2, h2, 0),
                new Vector3(-w2, h2, 0)
            };

            texCoords = new Vector2[] {
                new Vector2(0, 1),
                new Vector2(1, 1),
                new Vector2(1, 0),
                new Vector2(0, 0)
            };

            indicesVboData = new int[] { 0, 1, 2, 3 };

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

            createVBOs();
            createVAOs();

            ready = true;
        }
Exemple #3
0
        private void CreateBillboardMaterial(string name, Texture2D texture)
        {
            var mat = new BillboardMaterial(this, name);

            mat.Texture = texture;
        }