コード例 #1
0
 /// <summary>
 /// Generates a square.
 /// </summary>
 void GenerateSquareVBO()
 {
     Renderable.ArrayBuilder builder = new Renderable.ArrayBuilder();
     builder.Prepare(6, 6);
     builder.Tangents = new Vector3[6];
     for (uint n = 0; n < 6; n++)
     {
         builder.Indices[n]  = n;
         builder.Tangents[n] = new Vector3(1, 0, 0);
         builder.Normals[n]  = new Vector3(0, 0, 1);
         builder.Colors[n]   = new Vector4(1, 1, 1, 1);
         builder.ZeroBoneInfo(n);
     }
     builder.Vertices[0]  = new Vector3(1, 0, 0);
     builder.TexCoords[0] = new Vector3(1, 0, 0);
     builder.Vertices[1]  = new Vector3(1, 1, 0);
     builder.TexCoords[1] = new Vector3(1, 1, 0);
     builder.Vertices[2]  = new Vector3(0, 1, 0);
     builder.TexCoords[2] = new Vector3(0, 1, 0);
     builder.Vertices[3]  = new Vector3(1, 0, 0);
     builder.TexCoords[3] = new Vector3(1, 0, 0);
     builder.Vertices[4]  = new Vector3(0, 1, 0);
     builder.TexCoords[4] = new Vector3(0, 1, 0);
     builder.Vertices[5]  = new Vector3(0, 0, 0);
     builder.TexCoords[5] = new Vector3(0, 0, 0);
     Square = builder.Generate();
 }
コード例 #2
0
 void GenerateLineVBO()
 {
     Renderable.ArrayBuilder builder = new Renderable.ArrayBuilder();
     builder.Prepare2D(2, 2);
     for (uint n = 0; n < 2; n++)
     {
         builder.Indices[n] = n;
         builder.Colors[n]  = new Vector4(1, 1, 1, 1);
         builder.Normals[n] = new Vector3(0, 0, 1);
     }
     builder.Vertices[0]  = new Vector3(0, 0, 0);
     builder.TexCoords[0] = new Vector3(0, 0, 0);
     builder.Vertices[1]  = new Vector3(1, 0, 0);
     builder.TexCoords[1] = new Vector3(1, 0, 0);
     Line = builder.Generate();
 }
コード例 #3
0
        /// <summary>
        /// Generates a box.
        /// </summary>
        void GenerateBoxVBO()
        {
            Renderable.ArrayBuilder builder = new Renderable.ArrayBuilder();
            builder.Prepare(24, 24);
            builder.Tangents = new Vector3[24];
            // TODO: Optimize?
            for (uint n = 0; n < 24; n++)
            {
                builder.Indices[n]   = n;
                builder.Tangents[n]  = new Vector3(1f, 0f, 0f);
                builder.TexCoords[n] = new Vector3(0, 0, 0);
                builder.Normals[n]   = new Vector3(0, 0, 1); // TODO: Accurate normals somehow? Do lines even have normals?
                builder.Colors[n]    = new Vector4(1, 1, 1, 1);
                builder.ZeroBoneInfo(n);
            }
            int       i        = 0;
            const int lowValue = -1;

            builder.Vertices[i] = new Vector3(lowValue, lowValue, lowValue); i++;
            builder.Vertices[i] = new Vector3(1, lowValue, lowValue); i++;
            builder.Vertices[i] = new Vector3(1, lowValue, lowValue); i++;
            builder.Vertices[i] = new Vector3(1, 1, lowValue); i++;
            builder.Vertices[i] = new Vector3(1, 1, lowValue); i++;
            builder.Vertices[i] = new Vector3(lowValue, 1, lowValue); i++;
            builder.Vertices[i] = new Vector3(lowValue, 1, lowValue); i++;
            builder.Vertices[i] = new Vector3(lowValue, lowValue, lowValue); i++;
            builder.Vertices[i] = new Vector3(lowValue, lowValue, 1); i++;
            builder.Vertices[i] = new Vector3(1, lowValue, 1); i++;
            builder.Vertices[i] = new Vector3(1, lowValue, 1); i++;
            builder.Vertices[i] = new Vector3(1, 1, 1); i++;
            builder.Vertices[i] = new Vector3(1, 1, 1); i++;
            builder.Vertices[i] = new Vector3(lowValue, 1, 1); i++;
            builder.Vertices[i] = new Vector3(lowValue, 1, 1); i++;
            builder.Vertices[i] = new Vector3(lowValue, lowValue, 1); i++;
            builder.Vertices[i] = new Vector3(lowValue, lowValue, lowValue); i++;
            builder.Vertices[i] = new Vector3(lowValue, lowValue, 1); i++;
            builder.Vertices[i] = new Vector3(1, lowValue, lowValue); i++;
            builder.Vertices[i] = new Vector3(1, lowValue, 1); i++;
            builder.Vertices[i] = new Vector3(1, 1, lowValue); i++;
            builder.Vertices[i] = new Vector3(1, 1, 1); i++;
            builder.Vertices[i] = new Vector3(lowValue, 1, lowValue); i++;
            builder.Vertices[i] = new Vector3(lowValue, 1, 1); i++;
            Box = builder.Generate();
        }
コード例 #4
0
 /// <summary>
 /// Generates a line.
 /// </summary>
 void GenerateLineVBO()
 {
     Renderable.ArrayBuilder builder = new Renderable.ArrayBuilder();
     builder.Prepare(2, 2);
     builder.Tangents = new Vector3[2];
     for (uint n = 0; n < 2; n++)
     {
         builder.Indices[n]  = n;
         builder.Tangents[n] = new Vector3(1f, 0f, 0f);
         builder.Normals[n]  = new Vector3(0, 0, 1);
         builder.Colors[n]   = new Vector4(1, 1, 1, 1);
         builder.ZeroBoneInfo(n);
     }
     builder.Vertices[0]  = new Vector3(0, 0, 0);
     builder.TexCoords[0] = new Vector3(0, 0, 0);
     builder.Vertices[1]  = new Vector3(1, 0, 0);
     builder.TexCoords[1] = new Vector3(1, 0, 0);
     Line = builder.Generate();
 }
コード例 #5
0
 void GenerateSquareOfLinesVBO()
 {
     Renderable.ArrayBuilder builder = new Renderable.ArrayBuilder();
     builder.Prepare2D(5, 5);
     for (uint n = 0; n < 5; n++)
     {
         builder.Indices[n] = n;
         builder.Colors[n]  = new Vector4(1, 1, 1, 1);
         builder.Normals[n] = new Vector3(0, 0, 1);
     }
     builder.Vertices[0]  = new Vector3(1, 0, 0);
     builder.TexCoords[0] = new Vector3(1, 0, 0);
     builder.Vertices[1]  = new Vector3(1, 1, 0);
     builder.TexCoords[1] = new Vector3(1, 1, 0);
     builder.Vertices[2]  = new Vector3(0, 1, 0);
     builder.TexCoords[2] = new Vector3(0, 1, 0);
     builder.Vertices[3]  = new Vector3(0, 0, 0);
     builder.TexCoords[3] = new Vector3(0, 0, 0);
     builder.Vertices[4]  = new Vector3(1, 0, 0);
     builder.TexCoords[4] = new Vector3(1, 0, 0);
     SquareOfLines        = builder.Generate();
 }