コード例 #1
0
        //returns the vertices for a billboard which has a custom vertex declaration
        public static VertexBillboard[] GetVertexBillboard(int sidelength)
        {
            VertexBillboard[] vertices       = new VertexBillboard[4];
            float             halfSideLength = sidelength / 2.0f;

            Vector2 uvTopLeft     = new Vector2(0, 0);
            Vector2 uvTopRight    = new Vector2(1, 0);
            Vector2 uvBottomLeft  = new Vector2(0, 1);
            Vector2 uvBottomRight = new Vector2(1, 1);

            //quad coplanar with the XY-plane (i.e. forward facing normal along UnitZ)
            vertices[0] = new VertexBillboard(Vector3.Zero, new Vector4(uvTopLeft, -halfSideLength, halfSideLength));
            vertices[1] = new VertexBillboard(Vector3.Zero, new Vector4(uvTopRight, halfSideLength, halfSideLength));
            vertices[2] = new VertexBillboard(Vector3.Zero, new Vector4(uvBottomLeft, -halfSideLength, -halfSideLength));
            vertices[3] = new VertexBillboard(Vector3.Zero, new Vector4(uvBottomRight, halfSideLength, -halfSideLength));

            return(vertices);
        }
コード例 #2
0
        /*************************************************************** Billboard (unlit) ***************************************************************/

        //returns the vertices for a billboard which has a custom vertex declaration
        public static VertexBillboard[] GetBillboard(out PrimitiveType primitiveType, out int primitiveCount)
        {
            primitiveType  = PrimitiveType.TriangleStrip;
            primitiveCount = 2;

            VertexBillboard[] vertices       = new VertexBillboard[4];
            float             halfSideLength = 0.5f;

            Vector2 uvTopLeft     = new Vector2(0, 0);
            Vector2 uvTopRight    = new Vector2(1, 0);
            Vector2 uvBottomLeft  = new Vector2(0, 1);
            Vector2 uvBottomRight = new Vector2(1, 1);

            //quad coplanar with the XY-plane (i.e. forward facing normal along UnitZ)
            vertices[0] = new VertexBillboard(Vector3.Zero, new Vector4(uvTopLeft, -halfSideLength, halfSideLength));
            vertices[1] = new VertexBillboard(Vector3.Zero, new Vector4(uvTopRight, halfSideLength, halfSideLength));
            vertices[2] = new VertexBillboard(Vector3.Zero, new Vector4(uvBottomLeft, -halfSideLength, -halfSideLength));
            vertices[3] = new VertexBillboard(Vector3.Zero, new Vector4(uvBottomRight, halfSideLength, -halfSideLength));

            return(vertices);
        }