Exemple #1
0
        public static void DrawCube(VertexBuffer vbo, Color color, float x, float z, float width, float length, float bottom, float height)
        {
            var v1 = new Vector3(x, bottom, z);
            var v2 = new Vector3(x + width, bottom, z);
            var v3 = new Vector3(x + width, bottom, z + length);
            var v4 = new Vector3(x, bottom, z + length);

            var v5 = new Vector3(x, bottom + height, z);
            var v6 = new Vector3(x + width, bottom + height, z);
            var v7 = new Vector3(x + width, bottom + height, z + length);
            var v8 = new Vector3(x, bottom + height, z + length);

            // bottom vertices
            var normal = new Vector3(0, -1, 0);
            vbo.AddVerticies(color, normal, v1, v2, v3, v1, v3, v4);

            // top vertices
            normal = new Vector3(0, 1, 0);
            vbo.AddVerticies(color, normal, v8, v7, v6, v8, v6, v5);

            // -z facing vertices
            normal = new Vector3(0, 0, -1);
            vbo.AddVerticies(color, normal, v5, v6, v2, v5, v2, v1);

            // x facing vertices
            normal = new Vector3(1, 0, 0);
            vbo.AddVerticies(color, normal, v6, v7, v3, v6, v3, v2);

            // z facing vertices
            normal = new Vector3(0, 0, 1);
            vbo.AddVerticies(color, normal, v4, v3, v7, v4, v7, v8);

            // -x facing vertices
            normal = new Vector3(-1, 0, 0);
            vbo.AddVerticies(color, normal, v1, v4, v8, v1, v8, v5);
        }
Exemple #2
0
        private VertexBuffer GetLineVbo(Dictionary<int, VertexBuffer> widthMap, int width)
        {
            VertexBuffer vbo;
            if (!widthMap.TryGetValue(width, out vbo))
            {
                vbo = new VertexBuffer();
                vbo.Init();
                widthMap[width] = vbo;
            }

            return vbo;
        }