public string ToJson() { // I did think of using a JSON serialiser, // either one of these two provided by the // .NET framework or one of the other libraries: // System.Runtime.Serialization.Json.DataContractJsonSerializer // System.Web.Script.Serialization.JavaScriptSerializer // However, reading this comparison and alternative // implementation, I decided to just write the couple // of lines myself. // http://procbits.com/2011/08/11/fridaythe13th-the-best-json-parser-for-silverlight-and-net string s = string.Format ("\n \"FacetCount\":{0}," + "\n \"VertexCount\":{1}," + "\n \"VertexCoords\":[{2}]," + "\n \"VertexIndices\":[{3}]," + "\n \"Normals\":[{4}]," + "\n \"NormalIndices\":[{5}]," + "\n \"Center\":[{6}]," + "\n \"Color\":[{7}]," + "\n \"Id\":\"{8}\"", FacetCount, VertexCount, string.Join(",", VertexCoords.Select <int, string>(i => (_export_factor * i).ToString("0.#")).ToArray()), string.Join(",", VertexIndices.Select <int, string>(i => i.ToString()).ToArray()), string.Join(",", Normals.Select <double, string>(a => a.ToString("0.####")).ToArray()), string.Join(",", NormalIndices.Select <int, string>(i => i.ToString())), string.Join(",", Center.Select <int, string>(i => (_export_factor * i).ToString("0.#"))), Color, Id); return("\n{" + s + "\n}"); }
public void Skaluj(Vector3D s) { VertexCoords = VertexCoords.Skalowanie(s); VertexNormalsCoords = VertexNormalsCoords.Skalowanie(s); }
public void Obroc(Vector3D phi) { VertexCoords = VertexCoords.Rotacja(phi, VertexCoords.ZnajdzSrodek()); VertexNormalsCoords = VertexNormalsCoords.Rotacja(phi, VertexNormalsCoords.ZnajdzSrodek()); }
public void Obroc(Vector3D phi, Vector3D c) { VertexCoords = VertexCoords.Rotacja(phi, c); VertexNormalsCoords = VertexNormalsCoords.Rotacja(phi, c); }
public void Przesun(Vector3D t) { VertexCoords = VertexCoords.Translacja(t); VertexNormalsCoords = VertexNormalsCoords.Translacja(t); }