Example #1
0
        public static void GenerateCubeGeometry(float radius, CubeGeometry result)
        {
            result.positions     = new Vector3[24];
            result.positions[0]  = MakeV3(-radius, -radius, -radius);
            result.positions[1]  = MakeV3(-radius, -radius, radius);
            result.positions[2]  = MakeV3(radius, -radius, radius);
            result.positions[3]  = MakeV3(radius, -radius, -radius);
            result.positions[4]  = MakeV3(-radius, radius, -radius);
            result.positions[5]  = MakeV3(-radius, radius, radius);
            result.positions[6]  = MakeV3(radius, radius, radius);
            result.positions[7]  = MakeV3(radius, radius, -radius);
            result.positions[8]  = MakeV3(-radius, -radius, -radius);
            result.positions[9]  = MakeV3(-radius, radius, -radius);
            result.positions[10] = MakeV3(radius, radius, -radius);
            result.positions[11] = MakeV3(radius, -radius, -radius);
            result.positions[12] = MakeV3(-radius, -radius, radius);
            result.positions[13] = MakeV3(-radius, radius, radius);
            result.positions[14] = MakeV3(radius, radius, radius);
            result.positions[15] = MakeV3(radius, -radius, radius);
            result.positions[16] = MakeV3(-radius, -radius, -radius);
            result.positions[17] = MakeV3(-radius, -radius, radius);
            result.positions[18] = MakeV3(-radius, radius, radius);
            result.positions[19] = MakeV3(-radius, radius, -radius);
            result.positions[20] = MakeV3(radius, -radius, -radius);
            result.positions[21] = MakeV3(radius, -radius, radius);
            result.positions[22] = MakeV3(radius, radius, radius);
            result.positions[23] = MakeV3(radius, radius, -radius);

            result.normals     = new Vector3[24];
            result.normals[0]  = MakeV3(0.0f, -1.0f, 0.0f);
            result.normals[1]  = MakeV3(0.0f, -1.0f, 0.0f);
            result.normals[2]  = MakeV3(0.0f, -1.0f, 0.0f);
            result.normals[3]  = MakeV3(0.0f, -1.0f, 0.0f);
            result.normals[4]  = MakeV3(0.0f, 1.0f, 0.0f);
            result.normals[5]  = MakeV3(0.0f, 1.0f, 0.0f);
            result.normals[6]  = MakeV3(0.0f, 1.0f, 0.0f);
            result.normals[7]  = MakeV3(0.0f, 1.0f, 0.0f);
            result.normals[8]  = MakeV3(0.0f, 0.0f, -1.0f);
            result.normals[9]  = MakeV3(0.0f, 0.0f, -1.0f);
            result.normals[10] = MakeV3(0.0f, 0.0f, -1.0f);
            result.normals[11] = MakeV3(0.0f, 0.0f, -1.0f);
            result.normals[12] = MakeV3(0.0f, 0.0f, 1.0f);
            result.normals[13] = MakeV3(0.0f, 0.0f, 1.0f);
            result.normals[14] = MakeV3(0.0f, 0.0f, 1.0f);
            result.normals[15] = MakeV3(0.0f, 0.0f, 1.0f);
            result.normals[16] = MakeV3(-1.0f, 0.0f, 0.0f);
            result.normals[17] = MakeV3(-1.0f, 0.0f, 0.0f);
            result.normals[18] = MakeV3(-1.0f, 0.0f, 0.0f);
            result.normals[19] = MakeV3(-1.0f, 0.0f, 0.0f);
            result.normals[20] = MakeV3(1.0f, 0.0f, 0.0f);
            result.normals[21] = MakeV3(1.0f, 0.0f, 0.0f);
            result.normals[22] = MakeV3(1.0f, 0.0f, 0.0f);
            result.normals[23] = MakeV3(1.0f, 0.0f, 0.0f);

            result.texcoords     = new Vector2[24];
            result.texcoords[0]  = MakeV2(0.0f, 0.0f);
            result.texcoords[1]  = MakeV2(0.0f, 1.0f);
            result.texcoords[2]  = MakeV2(1.0f, 1.0f);
            result.texcoords[3]  = MakeV2(1.0f, 0.0f);
            result.texcoords[4]  = MakeV2(1.0f, 0.0f);
            result.texcoords[5]  = MakeV2(1.0f, 1.0f);
            result.texcoords[6]  = MakeV2(0.0f, 1.0f);
            result.texcoords[7]  = MakeV2(0.0f, 0.0f);
            result.texcoords[8]  = MakeV2(0.0f, 0.0f);
            result.texcoords[9]  = MakeV2(0.0f, 1.0f);
            result.texcoords[10] = MakeV2(1.0f, 1.0f);
            result.texcoords[11] = MakeV2(1.0f, 0.0f);
            result.texcoords[12] = MakeV2(0.0f, 0.0f);
            result.texcoords[13] = MakeV2(0.0f, 1.0f);
            result.texcoords[14] = MakeV2(1.0f, 1.0f);
            result.texcoords[15] = MakeV2(1.0f, 0.0f);
            result.texcoords[16] = MakeV2(0.0f, 0.0f);
            result.texcoords[17] = MakeV2(0.0f, 1.0f);
            result.texcoords[18] = MakeV2(1.0f, 1.0f);
            result.texcoords[19] = MakeV2(1.0f, 0.0f);
            result.texcoords[20] = MakeV2(0.0f, 0.0f);
            result.texcoords[21] = MakeV2(0.0f, 1.0f);
            result.texcoords[22] = MakeV2(1.0f, 1.0f);
            result.texcoords[23] = MakeV2(1.0f, 0.0f);

            result.indices     = new ushort[36];
            result.indices[0]  = 0; result.indices[1] = 2; result.indices[2] = 1;
            result.indices[3]  = 0; result.indices[4] = 3; result.indices[5] = 2;
            result.indices[6]  = 4; result.indices[7] = 5; result.indices[8] = 6;
            result.indices[9]  = 4; result.indices[10] = 6; result.indices[11] = 7;
            result.indices[12] = 8; result.indices[13] = 9; result.indices[14] = 10;
            result.indices[15] = 8; result.indices[16] = 10; result.indices[17] = 11;
            result.indices[18] = 12; result.indices[19] = 15; result.indices[20] = 14;
            result.indices[21] = 12; result.indices[22] = 14; result.indices[23] = 13;
            result.indices[24] = 16; result.indices[25] = 17; result.indices[26] = 18;
            result.indices[27] = 16; result.indices[28] = 18; result.indices[29] = 19;
            result.indices[30] = 20; result.indices[31] = 23; result.indices[32] = 22;
            result.indices[33] = 20; result.indices[34] = 22; result.indices[35] = 21;
        }
Example #2
0
 public static void GenerateCubeGeometry(float radius, CubeGeometry result)
 {
     result.positions = new Vector3[24];
     result.positions[0] = MakeV3(-radius, -radius, -radius);
     result.positions[1] = MakeV3(-radius, -radius, radius);
     result.positions[2] = MakeV3(radius, -radius, radius);
     result.positions[3] = MakeV3(radius, -radius, -radius);
     result.positions[4] = MakeV3(-radius, radius, -radius);
     result.positions[5] = MakeV3(-radius, radius, radius);
     result.positions[6] = MakeV3(radius, radius, radius);
     result.positions[7] = MakeV3(radius, radius, -radius);
     result.positions[8] = MakeV3(-radius, -radius, -radius);
     result.positions[9] = MakeV3(-radius, radius, -radius);
     result.positions[10] = MakeV3(radius, radius, -radius);
     result.positions[11] = MakeV3(radius, -radius, -radius);
     result.positions[12] = MakeV3(-radius, -radius, radius);
     result.positions[13] = MakeV3(-radius, radius, radius);
     result.positions[14] = MakeV3(radius, radius, radius);
     result.positions[15] = MakeV3(radius, -radius, radius);
     result.positions[16] = MakeV3(-radius, -radius, -radius);
     result.positions[17] = MakeV3(-radius, -radius, radius);
     result.positions[18] = MakeV3(-radius, radius, radius);
     result.positions[19] = MakeV3(-radius, radius, -radius);
     result.positions[20] = MakeV3(radius, -radius, -radius);
     result.positions[21] = MakeV3(radius, -radius, radius);
     result.positions[22] = MakeV3(radius, radius, radius);
     result.positions[23] = MakeV3(radius, radius, -radius);
     result.normals = new Vector3[24];
     result.normals[0] = MakeV3(0.0f, -1.0f, 0.0f);
     result.normals[1] = MakeV3(0.0f, -1.0f, 0.0f);
     result.normals[2] = MakeV3(0.0f, -1.0f, 0.0f);
     result.normals[3] = MakeV3(0.0f, -1.0f, 0.0f);
     result.normals[4] = MakeV3(0.0f, 1.0f, 0.0f);
     result.normals[5] = MakeV3(0.0f, 1.0f, 0.0f);
     result.normals[6] = MakeV3(0.0f, 1.0f, 0.0f);
     result.normals[7] = MakeV3(0.0f, 1.0f, 0.0f);
     result.normals[8] = MakeV3(0.0f, 0.0f, -1.0f);
     result.normals[9] = MakeV3(0.0f, 0.0f, -1.0f);
     result.normals[10] = MakeV3(0.0f, 0.0f, -1.0f);
     result.normals[11] = MakeV3(0.0f, 0.0f, -1.0f);
     result.normals[12] = MakeV3(0.0f, 0.0f, 1.0f);
     result.normals[13] = MakeV3(0.0f, 0.0f, 1.0f);
     result.normals[14] = MakeV3(0.0f, 0.0f, 1.0f);
     result.normals[15] = MakeV3(0.0f, 0.0f, 1.0f);
     result.normals[16] = MakeV3(-1.0f, 0.0f, 0.0f);
     result.normals[17] = MakeV3(-1.0f, 0.0f, 0.0f);
     result.normals[18] = MakeV3(-1.0f, 0.0f, 0.0f);
     result.normals[19] = MakeV3(-1.0f, 0.0f, 0.0f);
     result.normals[20] = MakeV3(1.0f, 0.0f, 0.0f);
     result.normals[21] = MakeV3(1.0f, 0.0f, 0.0f);
     result.normals[22] = MakeV3(1.0f, 0.0f, 0.0f);
     result.normals[23] = MakeV3(1.0f, 0.0f, 0.0f);
     result.texcoords = new Vector2[24];
     result.texcoords[0] = MakeV2(0.0f, 0.0f);
     result.texcoords[1] = MakeV2(0.0f, 1.0f);
     result.texcoords[2] = MakeV2(1.0f, 1.0f);
     result.texcoords[3] = MakeV2(1.0f, 0.0f);
     result.texcoords[4] = MakeV2(1.0f, 0.0f);
     result.texcoords[5] = MakeV2(1.0f, 1.0f);
     result.texcoords[6] = MakeV2(0.0f, 1.0f);
     result.texcoords[7] = MakeV2(0.0f, 0.0f);
     result.texcoords[8] = MakeV2(0.0f, 0.0f);
     result.texcoords[9] = MakeV2(0.0f, 1.0f);
     result.texcoords[10] = MakeV2(1.0f, 1.0f);
     result.texcoords[11] = MakeV2(1.0f, 0.0f);
     result.texcoords[12] = MakeV2(0.0f, 0.0f);
     result.texcoords[13] = MakeV2(0.0f, 1.0f);
     result.texcoords[14] = MakeV2(1.0f, 1.0f);
     result.texcoords[15] = MakeV2(1.0f, 0.0f);
     result.texcoords[16] = MakeV2(0.0f, 0.0f);
     result.texcoords[17] = MakeV2(0.0f, 1.0f);
     result.texcoords[18] = MakeV2(1.0f, 1.0f);
     result.texcoords[19] = MakeV2(1.0f, 0.0f);
     result.texcoords[20] = MakeV2(0.0f, 0.0f);
     result.texcoords[21] = MakeV2(0.0f, 1.0f);
     result.texcoords[22] = MakeV2(1.0f, 1.0f);
     result.texcoords[23] = MakeV2(1.0f, 0.0f);
     result.indices = new ushort[36];
     result.indices[0] = 0; result.indices[1] = 2; result.indices[2] = 1;
     result.indices[3] = 0; result.indices[4] = 3; result.indices[5] = 2;
     result.indices[6] = 4; result.indices[7] = 5; result.indices[8] = 6;
     result.indices[9] = 4; result.indices[10] = 6; result.indices[11] = 7;
     result.indices[12] = 8; result.indices[13] = 9; result.indices[14] = 10;
     result.indices[15] = 8; result.indices[16] = 10; result.indices[17] = 11;
     result.indices[18] = 12; result.indices[19] = 15; result.indices[20] = 14;
     result.indices[21] = 12; result.indices[22] = 14; result.indices[23] = 13;
     result.indices[24] = 16; result.indices[25] = 17; result.indices[26] = 18;
     result.indices[27] = 16; result.indices[28] = 18; result.indices[29] = 19;
     result.indices[30] = 20; result.indices[31] = 23; result.indices[32] = 22;
     result.indices[33] = 20; result.indices[34] = 22; result.indices[35] = 21;
 }