void Awake() { // validate / configure singleton if (singleton != this) { if (singleton != null) throw new Pretty.Exception("Multiple instances of CloudMeshPool are not allowed!"); singleton = this; } PointsPerMesh = System.Math.Min(16128, PointsPerMesh); CloudMeshPool.pointsPerMesh = PointsPerMesh; generator = new CloudMeshConvertor(pointsPerMesh); freeMeshes = new Stack<GameObject>(capacity); }
void Test_ReaderDecode_FracStride() { // fractional stride becomes 1.0 CloudMeshConvertor conv = new CloudMeshConvertor(mockCloud.Length); reader.DecodePoints(conv, mockCloud.Length, 0.5f); for(int i = 0; i<mockCloud.Length; ++i) { Assert_Approximately(mockCloud[i].v, conv.vBuffer[i]); Assert_Approximately(mockCloud[i].c, conv.cBuffer[i], bytePrecision); } }
void Test_ReaderSmallSlicesSequence() { CloudMeshConvertor conv = new CloudMeshConvertor(mockCloud.Length * 2); reader.DecodePoints(conv, mockCloud.Length); Assert_Equal(mockCloud.Length, conv.Offset); reader.SeekPoint(0); reader.DecodePoints(conv, mockCloud.Length); Assert_Equal(mockCloud.Length*2, conv.Offset); for(int i = 0; i<mockCloud.Length; ++i) { Assert_Approximately(mockCloud[i].v, conv.vBuffer[i]); Assert_Approximately(mockCloud[i].c, conv.cBuffer[i], bytePrecision); Assert_Approximately(mockCloud[i].v, conv.vBuffer[mockCloud.Length + i]); Assert_Approximately(mockCloud[i].c, conv.cBuffer[mockCloud.Length + i], bytePrecision); } }
void Test_ReaderDecode_DoubleStride() { CloudMeshConvertor conv = new CloudMeshConvertor(mockCloud.Length / 2); reader.DecodePoints(conv, mockCloud.Length, 2.0f); for(int i = 0; i<mockCloud.Length/2; ++i) { Assert_Approximately(mockCloud[i*2].v, conv.vBuffer[i]); Assert_Approximately(mockCloud[i*2].c, conv.cBuffer[i], bytePrecision); } }
void Test_ReaderDecode_Exact() { // decoding points with stride CloudMeshConvertor conv = new CloudMeshConvertor(mockCloud.Length); reader.DecodePoints(conv, mockCloud.Length, 1); for(int i = 0; i<mockCloud.Length; ++i) { Assert_Approximately(mockCloud[i].v, conv.vBuffer[i]); Assert_Approximately(mockCloud[i].c, conv.cBuffer[i], bytePrecision); } }
public Mesh SampleMinMesh( GameObject go ) { using( CloudStream.Reader reader = new CloudStream.Reader(new FileStream( Prefs.BoxBin( go.name ) , FileMode.Open)) ) { int size = (int)System.Math.Min( (long)Prefs.MinMeshSize, reader.PointCount ); CloudMeshConvertor conv = new CloudMeshConvertor( size ); Mesh mesh = conv.MakeMesh(); reader.ReadPoints(conv.vBuffer, conv.cBuffer); conv.Convert(mesh); // shut up the editor about the "shader wants normals" nonsense mesh.RecalculateNormals(); mesh.name = go.name + "-minMesh"; go.GetComponent<MeshFilter>().sharedMesh = mesh; go.GetComponent<MeshRenderer>().sharedMaterial = AssetDatabaseExt.LoadAssetAtPath<Material>("Assets/Materials/TrillingFastPoint.mat"); return mesh; } }
CloudImporter(Progressor _prog) { prog = _prog; meshConv = new CloudMeshConvertor( Prefs.OrigPreviewSize ); }
public CloudMeshConvertor_Test() { convertor = new CloudMeshConvertor(MeshSize); }
// try to convert no more then pointCount points from this to output public void DecodePoints(CloudMeshConvertor output, int pointCount, float stride = 1f) { if (output.Full) return; output.Offset = DecodePoints(output.vBuffer, output.cBuffer, output.Offset, pointCount, stride); }
public IEnumerator ReadPointsAsync(CloudMeshConvertor buffer, float stride = 1f, int amount = -1) { Vector3[] v = buffer.vBuffer; Color[] c = buffer.cBuffer; int bytesize = PrepareToRead (v, c, buffer.Offset, stride, ref amount); System.IAsyncResult asyncRes = BaseStream.BeginRead (chbuffer, 0, bytesize, null, null); // wait for the read to finish, but let the engine go while (!asyncRes.IsCompleted) yield return null; BaseStream.EndRead(asyncRes); mem.DecodePoints(buffer, bytesize/pointRecSize, stride); }