Exemplo n.º 1
0
        private void CreateBuffers(ushort[] indices, short[] vertices)
        {
            var numIndices  = (uint)indices.Length;
            var numVertices = (uint)vertices.Length;

            _vertexDeclaration = HardwareBufferManager.Singleton.CreateVertexDeclaration();
            _vertexDeclaration.AddElement(0, 0, VertexElementType.VET_SHORT2, VertexElementSemantic.VES_POSITION);
            _ib = HardwareBufferManager.Singleton.CreateIndexBuffer(HardwareIndexBuffer.IndexType.IT_16BIT, numIndices, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            _vb = HardwareBufferManager.Singleton.CreateVertexBuffer(_vertexDeclaration.GetVertexSize(0), numVertices, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY, false);

            unsafe
            {
                fixed(ushort *x = indices)
                _ib.WriteData(0, numIndices * sizeof(ushort), x, true);

                fixed(short *x = vertices)
                _vb.WriteData(0, numVertices * sizeof(ushort), x, true);
            }

            var binding = new VertexBufferBinding();

            binding.SetBinding(0, _vb);

            VertexData             = new VertexData(_vertexDeclaration, binding);
            VertexData.vertexCount = numVertices;
            VertexData.vertexStart = 0;

            IndexData             = new IndexData();
            IndexData.indexBuffer = _ib;
            IndexData.indexCount  = numIndices;
            IndexData.indexStart  = 0;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Convert Obj Model File to Ogre Mesh format
        /// </summary>
        /// <param name="fileStream">Obj File Stream</param>
        /// <returns>Ogre Mesh</returns>
        public MeshPtr ConvertObjToMesh(Stream fileStream)
        {
            List <Vector3> vertexObj = new List <Vector3>();
            List <Vector3> faceObj   = new List <Vector3>();

            float[] vertices;
            float[] faces;

            StreamReader reader = new StreamReader(fileStream);
            string       line;

            Regex           floatNumber  = new Regex(@"[\d\-][\d\.]*");
            Regex           ushortNumber = new Regex(@"\d+");
            MatchCollection matchList;

            while ((line = reader.ReadLine()) != null)
            {
                //Read vertices
                if (line.Substring(0, 2) == "v ")
                {
                    matchList = floatNumber.Matches(line);
                    float x = Convert.ToSingle(matchList[0].ToString());
                    float y = Convert.ToSingle(matchList[1].ToString());
                    float z = Convert.ToSingle(matchList[2].ToString());
                    vertexObj.Add(new Vector3(x, y, z));
                }

                //Read faces
                else if (line.Substring(0, 2) == "f ")
                {
                    //Error here where invalid indices were given. This is because the OBJ file started indexing the verts from 1 instead of 0.
                    matchList = ushortNumber.Matches(line);
                    int v1 = -1 + Convert.ToUInt16(matchList[0].ToString());
                    int v2 = -1 + Convert.ToUInt16(matchList[1].ToString());
                    int v3 = -1 + Convert.ToUInt16(matchList[2].ToString());
                    faceObj.Add(new Vector3((ushort)v1, (ushort)v2, (ushort)v3));
                }
            }

            int vertexNum = vertexObj.Count;

            vertices = new float[vertexNum * 3];
            for (int i = 0; i < vertexNum; i++)
            {
                vertices[i * 3 + 0] = vertexObj[i].x;
                vertices[i * 3 + 1] = vertexObj[i].y;
                vertices[i * 3 + 2] = vertexObj[i].z;
            }

            int faceNum = faceObj.Count;

            faces = new float[faceNum * 3];
            for (int i = 0; i < faceNum; i++)
            {
                faces[i * 3 + 0] = faceObj[i].x;
                faces[i * 3 + 1] = faceObj[i].y;
                faces[i * 3 + 2] = faceObj[i].z;
            }

            MeshPtr mesh    = MeshManager.Singleton.CreateManual("mesh1", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            SubMesh subMesh = mesh.CreateSubMesh();

            mesh.sharedVertexData             = new VertexData();
            mesh.sharedVertexData.vertexCount = (uint)vertexObj.Count;

            VertexDeclaration   vdecl = mesh.sharedVertexData.vertexDeclaration;
            VertexBufferBinding vbind = mesh.sharedVertexData.vertexBufferBinding;

            vdecl.AddElement(0, 0, VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_POSITION);
            HardwareVertexBufferSharedPtr vertexBuff =
                HardwareBufferManager.Singleton.CreateVertexBuffer((uint)(3 * System.Runtime.InteropServices.Marshal.SizeOf(typeof(float))), (uint)vertexObj.Count, HardwareBuffer.Usage.HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);

            unsafe
            {
                GCHandle handle  = GCHandle.Alloc(vertices, GCHandleType.Pinned);
                void *   pVertex = (void *)handle.AddrOfPinnedObject();
                vertexBuff.WriteData(0, vertexBuff.SizeInBytes, pVertex, true);
                handle.Free();
                vbind.SetBinding(0, vertexBuff);
            }
            HardwareIndexBufferSharedPtr indexBuff =
                HardwareBufferManager.Singleton.CreateIndexBuffer(HardwareIndexBuffer.IndexType.IT_32BIT, (uint)(3 * faceObj.Count), HardwareBuffer.Usage.HBU_STATIC, true);

            unsafe {
                GCHandle handle = GCHandle.Alloc(faces, GCHandleType.Pinned);
                void *   pFaces = (void *)handle.AddrOfPinnedObject();
                indexBuff.WriteData(0, indexBuff.SizeInBytes, pFaces, true);
                handle.Free();
            }

            subMesh.useSharedVertices     = true;
            subMesh.indexData.indexBuffer = indexBuff;
            subMesh.indexData.indexStart  = 0;
            subMesh.indexData.indexCount  = (uint)(3 * faceObj.Count);

            mesh._setBounds(new AxisAlignedBox(-100, -100, -100, 100, 100, 100));
            mesh.Touch();

            reader.Close();

            return(mesh);
        }
Exemplo n.º 3
0
        private void CreateBuffers(ushort[] indices, short[] vertices)
        {
            var numIndices = (uint)indices.Length;
            var numVertices = (uint)vertices.Length;

            _vertexDeclaration = HardwareBufferManager.Singleton.CreateVertexDeclaration();
            _vertexDeclaration.AddElement(0, 0, VertexElementType.VET_SHORT2, VertexElementSemantic.VES_POSITION);
            _ib = HardwareBufferManager.Singleton.CreateIndexBuffer(HardwareIndexBuffer.IndexType.IT_16BIT, numIndices, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            _vb = HardwareBufferManager.Singleton.CreateVertexBuffer(_vertexDeclaration.GetVertexSize(0), numVertices, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY, false);

            unsafe
            {
                fixed (ushort* x = indices)
                    _ib.WriteData(0, numIndices * sizeof(ushort), x, true);

                fixed (short* x = vertices)
                    _vb.WriteData(0, numVertices * sizeof(ushort), x, true);
            }

            var binding = new VertexBufferBinding();
            binding.SetBinding(0, _vb);

            VertexData = new VertexData(_vertexDeclaration, binding);
            VertexData.vertexCount = numVertices;
            VertexData.vertexStart = 0;

            IndexData = new IndexData();
            IndexData.indexBuffer = _ib;
            IndexData.indexCount = numIndices;
            IndexData.indexStart = 0;
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        private unsafe void CreateGeometry()
        {
            int numVertices = this.Steps * this.Circles + 1;
            int numEule     = 6 * this.Steps * (this.Circles - 1) + 3 * this.Steps;

            // Vertex buffers
            this.SubMesh.vertexData             = new VertexData();
            this.SubMesh.vertexData.vertexStart = 0;
            this.SubMesh.vertexData.vertexCount = (uint)numVertices;

            VertexDeclaration   vdecl = this.SubMesh.vertexData.vertexDeclaration;
            VertexBufferBinding vbind = this.SubMesh.vertexData.vertexBufferBinding;

            uint offset = 0;

            vdecl.AddElement(0, offset, VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_POSITION);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT3);
            vdecl.AddElement(0, offset, VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_TEXTURE_COORDINATES, 0);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT3);
            vdecl.AddElement(0, offset, VertexElementType.VET_FLOAT2, VertexElementSemantic.VES_TEXTURE_COORDINATES, 1);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT2);
            vdecl.AddElement(0, offset, VertexElementType.VET_FLOAT1, VertexElementSemantic.VES_TEXTURE_COORDINATES, 2);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT1);

            _vertexBuffer = HardwareBufferManager.Singleton.CreateVertexBuffer(offset, (uint)numVertices, HardwareBuffer.Usage.HBU_DYNAMIC_WRITE_ONLY);

            vbind.SetBinding(0, _vertexBuffer);

            int[] indexBuffer = new int[numEule];
            for (int k = 0; k < this.Steps; k++)
            {
                indexBuffer[k * 3]     = 0;
                indexBuffer[k * 3 + 1] = k + 1;

                if (k != this.Steps - 1)
                {
                    indexBuffer[k * 3 + 2] = k + 2;
                }
                else
                {
                    indexBuffer[k * 3 + 2] = 1;
                }
            }

            for (int y = 0; y < this.Circles - 1; y++)
            {
                for (int x = 0; x < this.Steps; x++)
                {
                    int twoface = (y * this.Steps + x) * 6 + 3 * this.Steps;

                    int p0 = 1 + y * this.Steps + x;
                    int p1 = 1 + y * this.Steps + x + 1;
                    int p2 = 1 + (y + 1) * this.Steps + x;
                    int p3 = 1 + (y + 1) * this.Steps + x + 1;

                    if (x == this.Steps - 1)
                    {
                        p1 -= x + 1;
                        p3 -= x + 1;
                    }

                    // First triangle
                    indexBuffer[twoface + 2] = p0;
                    indexBuffer[twoface + 1] = p1;
                    indexBuffer[twoface + 0] = p2;

                    // Second triangle
                    indexBuffer[twoface + 5] = p1;
                    indexBuffer[twoface + 4] = p3;
                    indexBuffer[twoface + 3] = p2;
                }
            }
            // Prepare buffer for indices
            _indexBuffer = HardwareBufferManager.Singleton.CreateIndexBuffer(Mogre.HardwareIndexBuffer.IndexType.IT_32BIT, (uint)numEule, HardwareBuffer.Usage.HBU_STATIC, true);
            //for(int z = 0; z < indexBuffer.Length;z++)
            //    LogManager.Singleton.Write("Index " + indexBuffer[z]);
            fixed(int *addr = &indexBuffer[0])
            {
                _indexBuffer.WriteData(0, _indexBuffer.SizeInBytes, addr, true);
            }

            // Set index buffer for this submesh
            this.SubMesh.indexData.indexBuffer = _indexBuffer;
            this.SubMesh.indexData.indexStart  = 0;
            this.SubMesh.indexData.indexCount  = (uint)numEule;

            // Create our internal buffer for manipulations
            _vertices = new PosUVVertex[1 + this.Steps * this.Circles];
        }
Exemplo n.º 5
0
        public unsafe void createMesh()
        {
            /// Create the mesh via the MeshManager
            MeshPtr msh = MeshManager.Singleton.CreateManual("ColourCube", "General");

            /// Create one submesh
            SubMesh sub = msh.CreateSubMesh();

            /// Define the vertices (8 vertices, each consisting of 2 groups of 3 floats
            //const int nVertices = 8;
            //int row = recordno;
            // int col = demcol;
            int  row  = recordno;
            int  col  = 1100;
            int  step = 10;
            int  vbufCount;
            uint nVertices = (uint)(col * row);

            float[] vertices = CreateVertices(row, col, step, out vbufCount);


            /// Define 12 triangles (two triangles per cube face)
            /// The values in this table refer to vertices in the above table
            uint ibufCount;

            ushort[] faces = CreateFaces(row, col, out ibufCount);

            /// Create vertex data structure for 8 vertices shared between submeshes
            msh.sharedVertexData             = new VertexData();
            msh.sharedVertexData.vertexCount = nVertices;

            /// Create declaration (memory format) of vertex data
            VertexDeclaration decl = msh.sharedVertexData.vertexDeclaration;
            uint offset            = 0;

            // 1st buffer
            decl.AddElement(0, offset, VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_POSITION);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT3);
            decl.AddElement(0, offset, VertexElementType.VET_FLOAT2, VertexElementSemantic.VES_TEXTURE_COORDINATES);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT2);
            /// Allocate vertex buffer of the requested number of vertices (vertexCount)
            /// and bytes per vertex (offset)
            HardwareVertexBufferSharedPtr vbuf =
                HardwareBufferManager.Singleton.CreateVertexBuffer(offset, msh.sharedVertexData.vertexCount,
                                                                   HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);


            /// Upload the vertex data to the card
            fixed(void *p = vertices)
            {
                vbuf.WriteData(0, vbuf.SizeInBytes, p, true);// writeData(0, vbuf->getSizeInBytes(), vertices, true);
            }

            /// Set vertex buffer binding so buffer 0 is bound to our vertex buffer
            VertexBufferBinding bind = msh.sharedVertexData.vertexBufferBinding;//  msh->sharedVertexData->vertexBufferBinding;

            bind.SetBinding(0, vbuf);

            /// Allocate index buffer of the requested number of vertices (ibufCount)
            HardwareIndexBufferSharedPtr ibuf =
                HardwareBufferManager.Singleton.CreateIndexBuffer(HardwareIndexBuffer.IndexType.IT_16BIT,
                                                                  ibufCount, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);

            /// Upload the index data to the card
            fixed(void *p = faces)
            {
                ibuf.WriteData(0, ibuf.SizeInBytes, p, true);
            }

            /// Set parameters of the submesh
            sub.useSharedVertices     = true;
            sub.indexData.indexBuffer = ibuf;
            sub.indexData.indexCount  = ibufCount;
            sub.indexData.indexStart  = 0;

            /// Set bounding information (for culling)
            msh._setBounds(new AxisAlignedBox(min, max));
            // msh._setBoundingSphereRadius(Mogre.Math.Sqrt(3 * 100 * 100));

            /// Notify Mesh object that it has been loaded
            msh.Load();
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        private unsafe void CreateGeometry()
        {
            // Vertex buffers
            _subMesh.vertexData             = new VertexData();
            _subMesh.vertexData.vertexStart = 0;
            _subMesh.vertexData.vertexCount = (uint)_vertexCount;

            VertexDeclaration   vdecl = _subMesh.vertexData.vertexDeclaration;
            VertexBufferBinding vbind = _subMesh.vertexData.vertexBufferBinding;

            uint offset = 0;

            // Position
            vdecl.AddElement(0, offset, VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_POSITION);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT3);
            // 3D coords
            vdecl.AddElement(0, offset, VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_TEXTURE_COORDINATES, 0);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT3);
            // Noise coords
            vdecl.AddElement(0, offset, VertexElementType.VET_FLOAT2, VertexElementSemantic.VES_TEXTURE_COORDINATES, 1);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT2);
            // Opacity
            vdecl.AddElement(0, offset, VertexElementType.VET_FLOAT1, VertexElementSemantic.VES_TEXTURE_COORDINATES, 2);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT1);

            _vertexBuffer = HardwareBufferManager.Singleton.CreateVertexBuffer(
                offset, (uint)_vertexCount,
                HardwareBuffer.Usage.HBU_DYNAMIC_WRITE_ONLY);

            vbind.SetBinding(0, _vertexBuffer);

            int[] indexbuffer = new int[_numberOfTriangles * 3];

            int IndexOffset  = 0;
            int VertexOffset = 0;

            // C
            for (int k = 0; k < _nc; k++)
            {
                // First triangle
                indexbuffer[IndexOffset]     = VertexOffset;
                indexbuffer[IndexOffset + 1] = VertexOffset + 1;
                indexbuffer[IndexOffset + 2] = VertexOffset + 3;

                // Second triangle
                indexbuffer[IndexOffset + 3] = VertexOffset;
                indexbuffer[IndexOffset + 4] = VertexOffset + 3;
                indexbuffer[IndexOffset + 5] = VertexOffset + 2;

                IndexOffset  += 6;
                VertexOffset += 4;
            }
            // B
            for (int k = 0; k < _nb; k++)
            {
                // First triangle
                indexbuffer[IndexOffset]     = VertexOffset;
                indexbuffer[IndexOffset + 1] = VertexOffset + 1;
                indexbuffer[IndexOffset + 2] = VertexOffset + 3;

                // Second triangle
                indexbuffer[IndexOffset + 3] = VertexOffset;
                indexbuffer[IndexOffset + 4] = VertexOffset + 3;
                indexbuffer[IndexOffset + 5] = VertexOffset + 2;

                // Third triangle
                indexbuffer[IndexOffset + 6] = VertexOffset + 2;
                indexbuffer[IndexOffset + 7] = VertexOffset + 3;
                indexbuffer[IndexOffset + 8] = VertexOffset + 5;

                // Fourth triangle
                indexbuffer[IndexOffset + 9]  = VertexOffset + 2;
                indexbuffer[IndexOffset + 10] = VertexOffset + 5;
                indexbuffer[IndexOffset + 11] = VertexOffset + 4;

                IndexOffset  += 12;
                VertexOffset += 6;
            }

            // A
            for (int k = 0; k < _na; k++)
            {
                // First triangle
                indexbuffer[IndexOffset]     = VertexOffset;
                indexbuffer[IndexOffset + 1] = VertexOffset + 1;
                indexbuffer[IndexOffset + 2] = VertexOffset + 3;

                // Second triangle
                indexbuffer[IndexOffset + 3] = VertexOffset;
                indexbuffer[IndexOffset + 4] = VertexOffset + 3;
                indexbuffer[IndexOffset + 5] = VertexOffset + 2;

                // Third triangle
                indexbuffer[IndexOffset + 6] = VertexOffset + 2;
                indexbuffer[IndexOffset + 7] = VertexOffset + 3;
                indexbuffer[IndexOffset + 8] = VertexOffset + 5;

                // Fourth triangle
                indexbuffer[IndexOffset + 9]  = VertexOffset + 2;
                indexbuffer[IndexOffset + 10] = VertexOffset + 5;
                indexbuffer[IndexOffset + 11] = VertexOffset + 4;

                // Fifth triangle
                indexbuffer[IndexOffset + 12] = VertexOffset + 4;
                indexbuffer[IndexOffset + 13] = VertexOffset + 5;
                indexbuffer[IndexOffset + 14] = VertexOffset + 6;

                IndexOffset  += 15;
                VertexOffset += 7;
            }
            // Prepare buffer for indices
            _indexBuffer =
                HardwareBufferManager.Singleton.CreateIndexBuffer(Mogre.HardwareIndexBuffer.IndexType.IT_32BIT,
                                                                  (uint)_numberOfTriangles * 3, HardwareBuffer.Usage.HBU_STATIC, true);
            fixed(int *addr = &indexbuffer[0])
            {
                _indexBuffer.WriteData(
                    0, _indexBuffer.SizeInBytes, addr, true);
            }

            //indexbufferArr = null;

            // Set index buffer for this submesh
            _subMesh.indexData.indexBuffer = _indexBuffer;
            _subMesh.indexData.indexStart  = 0;
            _subMesh.indexData.indexCount  = (uint)_numberOfTriangles * 3;

            // Create our internal buffer for manipulations
            _vertices = new Vertex[_vertexCount];
            // Update geometry
            UpdateGeometry();
        }
Exemplo n.º 7
0
        private unsafe void createCube(string name, Mogre.Vector3 gpose, double d)
        {
            MeshPtr msh  = MeshManager.Singleton.CreateManual(name, "General");
            SubMesh sub1 = msh.CreateSubMesh("1");

            const float sqrt13    = 0.577350269f; /* sqrt(1/3) */
            const int   nVertices = 8;
            const int   vbufCount = 3 * 2 * nVertices;

            float[] vertices = new float[vbufCount] {
                (float)(gpose.x - d / 2), (float)(gpose.y + d / 2), (float)(gpose.z - d / 2), //0 position
                -sqrt13, sqrt13, -sqrt13,                                                     //0 normal A
                (float)(gpose.x + d / 2), (float)(gpose.y + d / 2), (float)(gpose.z - d / 2), //1 position
                sqrt13, sqrt13, -sqrt13,                                                      //1 normal B
                (float)(gpose.x + d / 2), (float)(gpose.y - d / 2), (float)(gpose.z - d / 2), //2 position
                sqrt13, -sqrt13, -sqrt13,                                                     //2 normal F
                (float)(gpose.x - d / 2), (float)(gpose.y - d / 2), (float)(gpose.z - d / 2), //3 position
                -sqrt13, -sqrt13, -sqrt13,                                                    //3 normal H
                (float)(gpose.x - d / 2), (float)(gpose.y + d / 2), (float)(gpose.z + d / 2),
                -sqrt13, sqrt13, sqrt13,                                                      //4 normal C
                (float)(gpose.x + d / 2), (float)(gpose.y + d / 2), (float)(gpose.z + d / 2),
                sqrt13, sqrt13, sqrt13,                                                       //5 normal D
                (float)(gpose.x + d / 2), (float)(gpose.y - d / 2), (float)(gpose.z + d / 2),
                sqrt13, -sqrt13, sqrt13,                                                      //6 normal E
                (float)(gpose.x - d / 2), (float)(gpose.y - d / 2), (float)(gpose.z + d / 2),
                -sqrt13, -sqrt13, sqrt13,                                                     //7 normal G
            };

            const int ibufCount = 36;

            ushort[] faces = new ushort[ibufCount] {
                //back
                0, 2, 3,
                0, 1, 2,
                //right
                1, 6, 2,
                1, 5, 6,
                //front
                4, 6, 5,
                4, 7, 6,
                //left
                0, 7, 4,
                0, 3, 7,
                //top
                0, 5, 1,
                0, 4, 5,
                //bottom
                2, 7, 3,
                2, 6, 7
            };

            sub1.vertexData             = new VertexData();
            sub1.vertexData.vertexCount = nVertices;

            VertexDeclaration decl = sub1.vertexData.vertexDeclaration;
            uint offset            = 0;

            //position
            decl.AddElement(0, offset, VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_POSITION);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT3);
            //normal
            decl.AddElement(0, offset, VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_NORMAL);
            offset += VertexElement.GetTypeSize(VertexElementType.VET_FLOAT3);

            HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager.Singleton.CreateVertexBuffer(offset, sub1.vertexData.vertexCount, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            VertexBufferBinding           bind = sub1.vertexData.vertexBufferBinding;

            void *pVertices;

            fixed(float *pFVertice = vertices)
            {
                pVertices = (void *)pFVertice;
            }

            vbuf.WriteData(0, vbuf.SizeInBytes, pVertices, true);
            bind.SetBinding(0, vbuf);

            void *pFaces;

            fixed(ushort *pUFaces = faces)
            {
                pFaces = (void *)pUFaces;
            }

            HardwareIndexBufferSharedPtr ibuf = HardwareBufferManager.Singleton.CreateIndexBuffer(HardwareIndexBuffer.IndexType.IT_16BIT, ibufCount, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);

            ibuf.WriteData(0, ibuf.SizeInBytes, pFaces, true);

            sub1.useSharedVertices     = false;
            sub1.indexData.indexBuffer = ibuf;
            sub1.indexData.indexCount  = ibufCount;
            sub1.indexData.indexStart  = 0;

            sub1.SetMaterialName("Examples/10PointBlock");

            msh._setBounds(new AxisAlignedBox(-100, -100, -100, 100, 100, 100));
            msh._setBoundingSphereRadius(Mogre.Math.Sqrt(3 * 100 * 100));

            msh.Load();
        }