public void WritePolygonsNet(CurvedPolygonsNet net) { //Debug.Log("On write this.compressionMask:" + this.compressionMask); if (compressionMask == 0) { compressionMask = DEFAULT_COMPRESSION_MASK; /*Debug.Log("Since it was 0 we set it to a new Value this.compressionMask:" + this.compressionMask); * Debug.Log("Where Vertices Compression IS:" + GetVertexCompressionMode()); * Debug.Log("Where UV Compression IS:" + GetUVCompressionMode());*/ } this.numberOfVertices = net.GetNumberOfVertices(); this.vertices = CPVertexArrayData.CompressVertexArray(net.GetVertices(), GetVertexCompressionMode()); this.uvs = CPUVArrayData.compressUVArray(net.GetUv(), GetUVCompressionMode()); //Debug.Log("On Write, UVs:" + ToString(net.GetUv())); this.normals = CPVectorArrayData.compressVectorArray(net.GetNormals(), GetVectorCompressionMode()); this.tangents = new byte[0]; this.edges = CPShortArrayData.CompressShortsArray(net.GetEdges()); this.edgesIndex = CPShortArrayData.CompressShortsArray(net.GetEdgesIndex()); this.edgeHints = CPShortArrayData.CompressShortsArray(net.GetEdgeHints()); //this.edgeRots = CPFloatArrayData.compressFloatsArray(net.GetEdgesRots(), FLOAT_PRECISION); //this.edgeThickness = CPFloatArrayData.compressFloatsArray(net.GetEdgesThickness(), FLOAT_PRECISION); this.edgeWeights = CPFloatArrayData.compressFloatsArray(net.GetEdgeWeights(), FLOAT_PRECISION); this.geometries = new CPGeometryAsset[net.GetGeometriesCount()]; for (int i = 0; i < geometries.Length; i++) { geometries[i] = new CPGeometryAsset { polygons = CPShortArrayData.CompressShortsArray(net.GetGeometries()[i].GetPolygons()), polygonsIndex = CPShortArrayData.CompressShortsArray(net.GetGeometries()[i].GetPolygonsIndex()), polygonsSchema = CPShortArrayData.CompressShortsArray(net.GetGeometries()[i].GetPolygonsSchemas()) }; } }
public void ReadPolygonsNet(CurvedPolygonsNet net) { //Debug.Log("this.precision "+this.compressionMask); net.SetVertices(CPVertexArrayData.GetCompressedVertexArray(vertices, GetVertexCompressionMode())); net.SetUv(CPUVArrayData.getCompressedUVArray(uvs, GetUVCompressionMode())); net.SetNormals(CPVectorArrayData.getCompressedVectorArray(normals, GetVectorCompressionMode())); //net.setTangents(CPVectorArrayData.getCompressedVectorArray(vertices, getVectorCompressionMode())); short[] edges = CPShortArrayData.GetCompressedShortsArray(this.edges); short[] edgesIndex = CPShortArrayData.GetCompressedShortsArray(this.edgesIndex); int edgesSize = edgesIndex.Length - 1; net.SetNumberOfVertices(numberOfVertices); net.SetEdges(edgesIndex.Length - 1, edges, edgesIndex, CPShortArrayData.GetCompressedShortsArray(edgeHints), CPFloatArrayData.getCompressedFloatsArray(edgeWeights, FLOAT_PRECISION)); CPNGeometry[] geometries = new CPNGeometry[this.geometries.Length]; for (int i = 0; i < geometries.Length; i++) { geometries[i] = new CPNGeometry(); short[] polygonsIndex = CPShortArrayData.GetCompressedShortsArray(this.geometries[i].polygonsIndex); short[] polygons = CPShortArrayData.GetCompressedShortsArray(this.geometries[i].polygons); short[] polygonsSchemas = null; if (this.geometries[i].polygonsSchema != null && this.geometries[i].polygonsSchema.Length != 0) { polygonsSchemas = CPShortArrayData.GetCompressedShortsArray(this.geometries[i].polygonsSchema); } else { polygonsSchemas = new short[polygonsIndex.Length - 1]; } int polygonsCount = polygonsIndex.Length - 1; geometries[i].Setup((short)polygonsCount, polygonsIndex, polygons, polygonsSchemas); } net.SetGeometries(geometries.Length, geometries); }