public static MeshPtr makeTetra(string name, string matname)
        {
            MeshBuilderHelper mbh    = new MeshBuilderHelper(name, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, false, 0, 4);
            UInt32            offPos = mbh.AddElement(VertexElementType.VET_FLOAT3,
                                                      VertexElementSemantic.VES_POSITION).Offset;
            UInt32 offNorm = mbh.AddElement(VertexElementType.VET_FLOAT3,
                                            VertexElementSemantic.VES_NORMAL).Offset;
            UInt32 offUV = mbh.AddElement(VertexElementType.VET_FLOAT2,
                                          VertexElementSemantic.VES_TEXTURE_COORDINATES).Offset;

            mbh.CreateVertexBuffer(4, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            int scale = 10;
            // calculate corners of tetrahedron (with point of origin in middle of volume)
            Single mbot = scale * 0.2f;                      // distance middle to bottom
            Single mtop = scale * 0.62f;                     // distance middle to top
            Single mf   = scale * 0.289f;                    // distance middle to front
            Single mb   = scale * 0.577f;                    // distance middle to back
            Single mlr  = scale * 0.5f;                      // distance middle to left right

            Mogre.Vector3[] corners = new Mogre.Vector3[4];  // corners
            //               width / height / depth
            corners[0] = new Mogre.Vector3(-mlr, -mbot, mf); // left bottom front
            corners[1] = new Mogre.Vector3(mlr, -mbot, mf);  // right bottom front
            corners[2] = new Mogre.Vector3(0, -mbot, -mb);   // (middle) bottom back
            corners[3] = new Mogre.Vector3(0, mtop, 0);      // (middle) top (middle)

            for (int i = 0; i < 4; i++)
            {
                mbh.SetVertFloat((uint)i, offPos, corners[i].x, corners[i].y, corners[i].z);
                mbh.SetVertFloat((uint)i, offNorm, corners[i].NormalisedCopy.x, corners[i].NormalisedCopy.y, corners[i].NormalisedCopy.z);
                mbh.SetVertFloat((uint)i, offUV, 0f, 0f);
            }
            mbh.CreateIndexBuffer(4, HardwareIndexBuffer.IndexType.IT_16BIT,
                                  HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);

            mbh.SetIndex16bit(0, (UInt16)0, (UInt16)1, (UInt16)2);
            mbh.SetIndex16bit(1, (UInt16)0, (UInt16)1, (UInt16)3);
            mbh.SetIndex16bit(2, (UInt16)0, (UInt16)2, (UInt16)3);
            mbh.SetIndex16bit(3, (UInt16)1, (UInt16)2, (UInt16)3);

            MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourTest",
                                                                    ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            material.GetTechnique(0).GetPass(0).VertexColourTracking =
                (int)TrackVertexColourEnum.TVC_AMBIENT;
            material.SetCullingMode(CullingMode.CULL_NONE);
            MeshPtr m = mbh.Load("Test/ColourTest");

            // MeshPtr m = mbh.Load();
            m._setBounds(new AxisAlignedBox(0.0f, 0.0f, 0.0f, scale, scale, scale), false);
            m._setBoundingSphereRadius((float)System.Math.Sqrt(scale * scale + scale * scale));

            // the original code was missing this line:
            m._setBounds(new AxisAlignedBox(new Mogre.Vector3(-scale, -scale, -scale), new Mogre.Vector3(scale, scale, scale)), false);
            m._setBoundingSphereRadius(scale);
            return(m);
        }
        public static MeshPtr makeTetra(string name, string matname)
        {
            MeshBuilderHelper mbh = new MeshBuilderHelper(name, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, false, 0, 4);
            UInt32 offPos = mbh.AddElement(VertexElementType.VET_FLOAT3,
                VertexElementSemantic.VES_POSITION).Offset;
            UInt32 offNorm = mbh.AddElement(VertexElementType.VET_FLOAT3,
                VertexElementSemantic.VES_NORMAL).Offset;
            UInt32 offUV = mbh.AddElement(VertexElementType.VET_FLOAT2,
                VertexElementSemantic.VES_TEXTURE_COORDINATES).Offset;
            mbh.CreateVertexBuffer(4, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            int scale = 10;
            // calculate corners of tetrahedron (with point of origin in middle of volume)
            Single mbot = scale * 0.2f;      // distance middle to bottom
            Single mtop = scale * 0.62f;     // distance middle to top    
            Single mf = scale * 0.289f;    // distance middle to front
            Single mb = scale * 0.577f;    // distance middle to back
            Single mlr = scale * 0.5f;      // distance middle to left right 
            Mogre.Vector3[] corners = new Mogre.Vector3[4]; // corners
            //               width / height / depth
            corners[0] = new Mogre.Vector3(-mlr, -mbot, mf);  // left bottom front
            corners[1] = new Mogre.Vector3(mlr, -mbot, mf);  // right bottom front
            corners[2] = new Mogre.Vector3(0, -mbot, -mb);  // (middle) bottom back
            corners[3] = new Mogre.Vector3(0, mtop, 0);  // (middle) top (middle)

            for (int i = 0; i < 4; i++)
            {
                mbh.SetVertFloat((uint)i, offPos, corners[i].x, corners[i].y, corners[i].z);
                mbh.SetVertFloat((uint)i, offNorm, corners[i].NormalisedCopy.x, corners[i].NormalisedCopy.y, corners[i].NormalisedCopy.z);
                mbh.SetVertFloat((uint)i, offUV, 0f, 0f);
            }
            mbh.CreateIndexBuffer(4, HardwareIndexBuffer.IndexType.IT_16BIT,
                                 HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);

            mbh.SetIndex16bit(0, (UInt16)0, (UInt16)1, (UInt16)2);
            mbh.SetIndex16bit(1, (UInt16)0, (UInt16)1, (UInt16)3);
            mbh.SetIndex16bit(2, (UInt16)0, (UInt16)2, (UInt16)3);
            mbh.SetIndex16bit(3, (UInt16)1, (UInt16)2, (UInt16)3);

            MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourTest",
                             ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            material.GetTechnique(0).GetPass(0).VertexColourTracking =
                           (int)TrackVertexColourEnum.TVC_AMBIENT;
            material.SetCullingMode(CullingMode.CULL_NONE);
            MeshPtr m = mbh.Load("Test/ColourTest");
            // MeshPtr m = mbh.Load();
            m._setBounds(new AxisAlignedBox(0.0f, 0.0f, 0.0f, scale, scale, scale), false);
            m._setBoundingSphereRadius((float)System.Math.Sqrt(scale * scale + scale * scale));
            
            // the original code was missing this line:
            m._setBounds(new AxisAlignedBox(new Mogre.Vector3(-scale, -scale, -scale), new Mogre.Vector3(scale, scale, scale)), false);
            m._setBoundingSphereRadius(scale);
            return m;
        }
        public static MeshPtr makeTetra2(string name)
        {
            MeshBuilderHelper mbh    = new MeshBuilderHelper(name, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, false, 0, 12);
            UInt32            offPos = mbh.AddElement(VertexElementType.VET_FLOAT3,
                                                      VertexElementSemantic.VES_POSITION).Offset;
            UInt32 offNorm = mbh.AddElement(VertexElementType.VET_FLOAT3,
                                            VertexElementSemantic.VES_NORMAL).Offset;
            UInt32 offUV = mbh.AddElement(VertexElementType.VET_FLOAT2,
                                          VertexElementSemantic.VES_TEXTURE_COORDINATES).Offset;

            mbh.CreateVertexBuffer(12, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            int scale = 10;
            // calculate corners of tetrahedron (with point of origin in middle of volume)
            Single mbot = scale * 0.2f;                      // distance middle to bottom
            Single mtop = scale * 0.62f;                     // distance middle to top
            Single mf   = scale * 0.289f;                    // distance middle to front
            Single mb   = scale * 0.577f;                    // distance middle to back
            Single mlr  = scale * 0.5f;                      // distance middle to left right

            Mogre.Vector3[] corners = new Mogre.Vector3[4];  // corners
            //               width / height / depth
            corners[0] = new Mogre.Vector3(-mlr, -mbot, mf); // left bottom front
            corners[1] = new Mogre.Vector3(mlr, -mbot, mf);  // right bottom front
            corners[2] = new Mogre.Vector3(0, -mbot, -mb);   // (middle) bottom back
            corners[3] = new Mogre.Vector3(0, mtop, 0);      // (middle) top (middle)

            int[,] triangles = new int[4, 3] {
                { 0, 1, 2 }, { 0, 1, 3 }, { 0, 2, 3 }, { 1, 2, 3 }
            };
            uint i = 0;

            for (int f = 0; f < 4; f++)
            {
                for (int g = 0; g < 3; g++)
                {
                    Mogre.Vector3 pos  = new Mogre.Vector3(corners[triangles[f, g]].x, corners[triangles[f, g]].y, corners[triangles[f, g]].z);
                    Mogre.Vector3 norm = pos.NormalisedCopy;
                    mbh.SetVertFloat(i, offPos, pos.x, pos.y, pos.z);
                    mbh.SetVertFloat(i, offNorm, norm.x, norm.y, norm.z);
                    mbh.SetVertFloat(i, offUV, 0f, 0f);
                    i++;
                }
            }
            mbh.CreateIndexBuffer(4, HardwareIndexBuffer.IndexType.IT_16BIT,
                                  HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            mbh.SetIndex16bit(0, (UInt16)0, (UInt16)1, (UInt16)2);
            mbh.SetIndex16bit(1, (UInt16)3, (UInt16)4, (UInt16)5);
            mbh.SetIndex16bit(2, (UInt16)6, (UInt16)7, (UInt16)8);
            mbh.SetIndex16bit(3, (UInt16)9, (UInt16)10, (UInt16)11);
            MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourTest",
                                                                    ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            material.GetTechnique(0).GetPass(0).VertexColourTracking =
                (int)TrackVertexColourEnum.TVC_AMBIENT;
            MeshPtr m = mbh.Load("Test/ColourTest");

            // MeshPtr m = mbh.Load();
            m._setBounds(new AxisAlignedBox(0.0f, 0.0f, 0.0f, mtop, mtop, mtop), false);
            m._setBoundingSphereRadius((float)System.Math.Sqrt(mbot * mtop + mf * mb));
            return(m);
        }
        public static MeshPtr makeTetra2(string name)
        {
            MeshBuilderHelper mbh = new MeshBuilderHelper(name, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, false, 0, 12);
            UInt32 offPos = mbh.AddElement(VertexElementType.VET_FLOAT3,
                VertexElementSemantic.VES_POSITION).Offset;
            UInt32 offNorm = mbh.AddElement(VertexElementType.VET_FLOAT3,
                VertexElementSemantic.VES_NORMAL).Offset;
            UInt32 offUV = mbh.AddElement(VertexElementType.VET_FLOAT2,
                VertexElementSemantic.VES_TEXTURE_COORDINATES).Offset;
            mbh.CreateVertexBuffer(12, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            int scale = 10;
            // calculate corners of tetrahedron (with point of origin in middle of volume)
            Single mbot = scale * 0.2f;      // distance middle to bottom
            Single mtop = scale * 0.62f;     // distance middle to top    
            Single mf = scale * 0.289f;    // distance middle to front
            Single mb = scale * 0.577f;    // distance middle to back
            Single mlr = scale * 0.5f;      // distance middle to left right 
            Mogre.Vector3[] corners = new Mogre.Vector3[4]; // corners
            //               width / height / depth
            corners[0] = new Mogre.Vector3(-mlr, -mbot, mf);  // left bottom front
            corners[1] = new Mogre.Vector3(mlr, -mbot, mf);  // right bottom front
            corners[2] = new Mogre.Vector3(0, -mbot, -mb);  // (middle) bottom back
            corners[3] = new Mogre.Vector3(0, mtop, 0);  // (middle) top (middle)

            int[,] triangles = new int[4, 3] { { 0, 1, 2 }, { 0, 1, 3 }, { 0, 2, 3 }, { 1, 2, 3 } };
            uint i = 0;
            for (int f = 0; f < 4; f++)
            {
                for (int g = 0; g < 3; g++)
                {
                    Mogre.Vector3 pos = new Mogre.Vector3(corners[triangles[f, g]].x, corners[triangles[f, g]].y, corners[triangles[f, g]].z);
                    Mogre.Vector3 norm = pos.NormalisedCopy;
                    mbh.SetVertFloat(i, offPos, pos.x, pos.y, pos.z);
                    mbh.SetVertFloat(i, offNorm, norm.x, norm.y, norm.z);
                    mbh.SetVertFloat(i, offUV, 0f, 0f);
                    i++;
                }
            }
            mbh.CreateIndexBuffer(4, HardwareIndexBuffer.IndexType.IT_16BIT,
                                  HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            mbh.SetIndex16bit(0, (UInt16)0, (UInt16)1, (UInt16)2);
            mbh.SetIndex16bit(1, (UInt16)3, (UInt16)4, (UInt16)5);
            mbh.SetIndex16bit(2, (UInt16)6, (UInt16)7, (UInt16)8);
            mbh.SetIndex16bit(3, (UInt16)9, (UInt16)10, (UInt16)11);
            MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourTest",
                             ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            material.GetTechnique(0).GetPass(0).VertexColourTracking =
                           (int)TrackVertexColourEnum.TVC_AMBIENT;
            MeshPtr m = mbh.Load("Test/ColourTest");
            // MeshPtr m = mbh.Load();
            m._setBounds(new AxisAlignedBox(0.0f, 0.0f, 0.0f, mtop, mtop, mtop), false);
            m._setBoundingSphereRadius((float)System.Math.Sqrt(mbot * mtop + mf * mb));
            return m;
        }