示例#1
0
        private void MakeEdgeIndicesData()
        {
            //todo work out edge vertices
            uint westCount  = (uint)_GridSize;
            uint southCount = (uint)_GridSize;
            uint eastCount  = (uint)_GridSize;
            uint northCount = (uint)_GridSize;


            MeshEdgeIndices16 = new EdgeIndices16()
            {
                westVertexCount  = westCount,
                westIndices      = new ushort[westCount],
                eastVertexCount  = eastCount,
                eastIndices      = new ushort[eastCount],
                northVertexCount = northCount,
                northIndices     = new ushort[northCount],
                southVertexCount = southCount,
                southIndices     = new ushort[southCount]
            };

            ushort y = 0;

            for (uint i = 0; i < MeshEdgeIndices16.westVertexCount; i++)
            {
                MeshEdgeIndices16.westIndices[i] = y;
                y = (ushort)(y + _GridSize);
            }

            for (uint i = 0; i < MeshEdgeIndices16.southVertexCount; i++)
            {
                MeshEdgeIndices16.southIndices[i] = (ushort)i;
            }

            y = 0;
            for (uint i = 0; i < MeshEdgeIndices16.eastVertexCount; i++)
            {
                MeshEdgeIndices16.eastIndices[i] = (ushort)(y + _GridSize - 1);
                y = (ushort)(y + _GridSize);
            }

            y = (ushort)((_GridSize - 1) * (_GridSize - 1) + _GridSize - 1);
            // y = (ushort) (Math.Pow((_GridSize - 1), 2) + _GridSize - 1);

            for (uint i = 0; i < MeshEdgeIndices16.northVertexCount; i++)
            {
                MeshEdgeIndices16.northIndices[i] = (ushort)(y + i);
            }
        }
示例#2
0
        private void MakeEdgeIndicesData()
        {
            EdgeIndices16 = new EdgeIndices16()
            {
                westVertexCount  = 2,
                westIndices      = new ushort[2],
                eastVertexCount  = 2,
                eastIndices      = new ushort[2],
                northVertexCount = 2,
                northIndices     = new ushort[2],
                southVertexCount = 2,
                southIndices     = new ushort[2]
            };

            /*
             *    westVertexCount = reader.ReadUInt32();
             *    westIndices = new ushort[westVertexCount];
             *
             *    for (int i = 0; i < westVertexCount; i++)
             *        westIndices[i] = reader.ReadUInt16();
             *
             *    southVertexCount = reader.ReadUInt32();
             *    southIndices = new ushort[southVertexCount];
             *
             *    for (int i = 0; i < southVertexCount; i++)
             *        southIndices[i] = reader.ReadUInt16();
             *
             *    eastVertexCount = reader.ReadUInt32();
             *    eastIndices = new ushort[eastVertexCount];
             *
             *    for (int i = 0; i < eastVertexCount; i++)
             *        eastIndices[i] = reader.ReadUInt16();
             *
             *    northVertexCount = reader.ReadUInt32();
             *    northIndices = new ushort[northVertexCount];
             *
             *    for (int i = 0; i < northVertexCount; i++)
             *        northIndices[i] = reader.ReadUInt16();
             *
             */

            // vertexs touching edge
            EdgeIndices16.westIndices[0]  = 0;
            IndexData16.indices[1]        = 1;
            EdgeIndices16.southIndices[0] = 0;
            IndexData16.indices[1]        = 2;
            EdgeIndices16.eastIndices[0]  = 2;
            IndexData16.indices[1]        = 3;
            EdgeIndices16.northIndices[0] = 1;
            IndexData16.indices[1]        = 3;


            /*
             * // now decode deltas and place true value back into array
             * ushort _u = 0;
             * ushort _v = 0;
             * ushort _height = 0;
             *
             * for (int i = 0; i < vertexCount; i++)
             * {
             * _u += (ushort) ZigZag.Decode(u[i]);
             * _v += (ushort) ZigZag.Decode(v[i]);
             * _height += (ushort) ZigZag.Decode(height[i]);
             *
             * u[i] = _u;
             * v[i] = _v;
             * height[i] = _height;
             * }
             *
             */


            // Now encode data in CPP

            /*
             * // # Write mesh vertices (X Y Z components of each vertex):
             * int vertexCount = mMesh.vertices.size();
             * ostream.write(&vertexCount, sizeof(int));
             *
             * for (int c = 0; c < 3; c++) {
             *  double origin = bounds.min[c];
             *  double factor = 0;
             *  if (bounds.max[c] > bounds.min[c]) factor = SHORT_MAX / (bounds.max[c] - bounds.min[c]);
             *
             *  // Move the initial value
             *  int u0 = quantizeIndices(origin, factor, mMesh.vertices[0][c]), u1, ud;
             *  uint16_t sval = zigZagEncode(u0);
             *  ostream.write(&sval, sizeof(uint16_t));
             *
             *  for (size_t i = 1, icount = mMesh.vertices.size(); i < icount; i++) {
             *    u1 = quantizeIndices(origin, factor, mMesh.vertices[i][c]);
             *    ud = u1 - u0;
             *    sval = zigZagEncode(ud);
             *    ostream.write(&sval, sizeof(uint16_t));
             *    u0 = u1;
             *  }
             * }
             */
        }