public void Execute() { CurvedPolygonsNet cpnet = asset.GetCPN(); short[] loqs = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; CPNTessellationProcess tessellationProcess = ProcessesKeeper.GetTessellationProcess(); TessellationOutput output = tessellationProcess.InitProcess(cpnet, loqs); tessellationProcess.BuildProfile(); int[] builtTrianglesCount = output.GetBuiltTrianglesSize(); int builtVerticesCount = output.GetBuiltVerticesSize(); uvs_ = new Vector2[builtVerticesCount]; vertices_ = new Vector3[builtVerticesCount]; normals_ = new Vector3[builtVerticesCount]; indices_ = new int[builtTrianglesCount.Length][]; for (int i = 0; i < builtTrianglesCount.Length; i++) { indices_[i] = new int[builtTrianglesCount[i] * 3]; } OutputMesh mesh = null; mesh = new OutputMesh(vertices_, uvs_, normals_, indices_); tessellationProcess.WriteMesh(mesh); }
public void BuildModel(GameObject gameObject) { CurvedPolygonsNet cpnet = GetPolylinesCPNet(asset.GetCPN()); short[] loqs = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; CPNTessellationProcess tessellationProcess = ProcessesKeeper.GetTessellationProcess(); TessellationOutput output = tessellationProcess.InitProcess(cpnet, loqs, this); //Debug.Log("cpnet.GetGeometriesCount() " + cpnet.GetGeometriesCount()); tessellationProcess.BuildProfile(); int[] builtTrianglesCount = output.GetBuiltTrianglesSize(); int builtVerticesCount = output.GetBuiltVerticesSize(); Vector2[] uvs_ = new Vector2[builtVerticesCount]; Vector3[] vertices_ = new Vector3[builtVerticesCount]; Vector3[] normals_ = new Vector3[builtVerticesCount]; int[][] indices_ = new int[builtTrianglesCount.Length][]; //Debug.Log("indices_ " + indices_.Length); for (int i = 0; i < builtTrianglesCount.Length; i++) { indices_[i] = new int[builtTrianglesCount[i] * 3]; //Debug.Log("indices_[" + i + "] " + indices_[i].Length); } OutputMesh mesh = null; mesh = new OutputMesh(vertices_, uvs_, normals_, indices_); tessellationProcess.WriteMesh(mesh); MeshAssigner.AssignMesh(gameObject, vertices_, normals_, uvs_, indices_); }
public void Execute() { CurvedPolygonsNet cpnet = asset.GetCPN(); CurvedPolyVariants cpnVariants = new CurvedPolyVariants(); cpnVariants.SetCPN(cpnet); short[] loqs = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; CPNTessellationProcess tessellationProcess = ProcessesKeeper.GetTessellationProcess(); TessellationOutput output = tessellationProcess.InitProcess(cpnet, loqs); //Debug.Log("cpnet.GetGeometriesCount() " + cpnet.GetGeometriesCount()); tessellationProcess.BuildProfile(); int[] builtTrianglesCount = output.GetBuiltTrianglesSize(); int builtVerticesCount = output.GetBuiltVerticesSize(); uvs_ = new Vector2[builtVerticesCount]; vertices_ = new Vector3[builtVerticesCount]; normals_ = new Vector3[builtVerticesCount]; indices_ = new int[builtTrianglesCount.Length][]; for (int i = 0; i < builtTrianglesCount.Length; i++) { indices_[i] = new int[builtTrianglesCount[i] * 3]; } OutputMesh mesh = null; mesh = new OutputMesh(vertices_, uvs_, normals_, indices_); tessellationProcess.WriteMesh(mesh); //here int id = cpnVariants.GetFreeTessellationRecordId(); cpnVariants.SetRecord(id, new OutputMesh(vertices_, uvs_, normals_, indices_), output); //this.outMesh = cpnVariants.GetMeshOutput(id).GetNewCloneVariant(); CPNSubset subsSet = new CPNSubset(); TessellationOutput output2 = tessellationProcess.InitProcess(cpnet, loqs, subsSet); this.mesh2 = new OutputMesh(outMesh.GetVertices(), outMesh.GetUVs(), outMesh.GetNormals(), outMesh.GetTriangles()); tessellationProcess.WriteMesh(mesh2); }
public void UpdateTessellationVariant(int id, short[] loqs, CPNSubset cpnSubset = null) { if (id < 0 || id > records.Length || !records[id].used) { return; } CPNTessellationProcess tessellationProcess = ProcessesKeeper.GetTessellationProcess(); OutputMesh mesh = GetMeshOutput(id); if (mesh != null) { tessellationProcess.InitPrebuiltProcess(this.curvedPolygonsNet, GetTessellationOutput(id), cpnSubset, loqs); tessellationProcess.WriteMesh(mesh); } }
public void GenerateTessellationVariant(int id, short[] loqs) { if (id < 0 || id > records.Length || !records[id].used) { return; } CPNTessellationProcess tessellationProcess = ProcessesKeeper.GetTessellationProcess(); TessellationOutput tesellationOutput = tessellationProcess.InitProcess( this.curvedPolygonsNet, loqs); tessellationProcess.BuildProfile(); int[] builtTrianglesCount = tesellationOutput.GetBuiltTrianglesSize(); int builtVerticesCount = tesellationOutput.GetBuiltVerticesSize(); OutputMesh outputMesh = new OutputMesh(); outputMesh.Build(builtVerticesCount, builtTrianglesCount); SetRecord(id, outputMesh, tesellationOutput); }
public void Execute() { CurvedPolygonsNet cpnet = new CurvedPolygonsNet(); cpnet.SetNumberOfVertices(9); Vector3[] vertices = { new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, DemoUtils.ONE_THIRD, 0), new Vector3(DemoUtils.ONE_THIRD, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, DemoUtils.ONE_THIRD, 0), }; cpnet.SetVertices(vertices); Vector3[] uvs = { new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, DemoUtils.ONE_THIRD, 0), new Vector3(DemoUtils.ONE_THIRD, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, DemoUtils.ONE_THIRD, 0), }; cpnet.SetUv(uvs); Vector3[] normals = { Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward }; cpnet.SetNormals(normals); /*short[] edges = { 0, 3, 4, 1, 1, 5, 6, 2, 2, 7, 8, 0 }; * short[] edgesIndex = { 0, 4, 8, 12 }; * short[] edgesHints= { 3, 3, 3, 3, 3, 3 }; * float[] weights = { 1, 1, 1, 1, 1, 1 }; * bool[] updateVertices = new bool[vertices.Length]; * bool[] updateEdges = new bool[3];*/ cpnet.SetEdges(0, new short[0], new short[0], new short[0], new float[0]); short[] polylines = { 0, 3, 4, 1, 1, 5, 6, 2, 2, 7, 8, 0 }; short[] polylinesIndex = { 0, 4, 8, 12 }; cpnet.setPolylines(3, polylines, polylinesIndex); short[] loqs = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; CPNGeometry[] geometries = { new CPNGeometry() }; short[] polygons = { 1, 2, 3 }; short[] polygonsIndex = { 0, 3 }; short[] polygonsSchemas = { SFGouraudSchemaBuilder.GOURAUD_SCHEMA_ID }; geometries[0].Setup(1, polygonsIndex, polygons, polygonsSchemas); cpnet.SetGeometries(1, geometries); CPNTessellationProcess tessellationProcess = ProcessesKeeper.GetTessellationProcess(); TessellationOutput output = tessellationProcess.InitProcess(cpnet, loqs); tessellationProcess.BuildProfile(); int[] builtTrianglesCount = output.GetBuiltTrianglesSize(); int builtVerticesCount = output.GetBuiltVerticesSize(); uvs_ = new Vector2[builtVerticesCount]; vertices_ = new Vector3[builtVerticesCount]; normals_ = new Vector3[builtVerticesCount]; indices_ = new int[builtTrianglesCount.Length][]; for (int i = 0; i < builtTrianglesCount.Length; i++) { indices_[i] = new int[builtTrianglesCount[i] * 3]; } OutputMesh mesh = null; mesh = new OutputMesh(vertices_, uvs_, normals_, indices_); tessellationProcess.WriteMesh(mesh); }
private void Execute() { CurvedPolygonsNet cpnet = new CurvedPolygonsNet(); cpnet.SetNumberOfVertices(3); Vector3[] vertices = { new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, DemoUtils.ONE_THIRD, 0), new Vector3(DemoUtils.ONE_THIRD, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, DemoUtils.ONE_THIRD, 0), }; cpnet.SetVertices(vertices); Vector3[] uvs = { new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, DemoUtils.ONE_THIRD, 0), new Vector3(DemoUtils.ONE_THIRD, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, DemoUtils.ONE_THIRD, 0), }; cpnet.SetUv(uvs); Vector3[] normals = { Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward }; cpnet.SetNormals(normals); short[] edges = { 0, 3, 4, 1, 1, 5, 6, 2, 2, 7, 8, 0 }; short[] edgesIndex = { 0, 4, 8, 12 }; short[] edgesHints = { 3, 3, 3, 3, 3, 3 }; float[] weights = { 1, 1, 1, 1, 1, 1 }; cpnet.SetEdges(3, edges, edgesIndex, edgesHints, weights); short[] loqs = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; CPNGeometry[] geometries = { new CPNGeometry() }; short[] polygons = { 1, 2, 3 }; short[] polygonsIndex = { 0, 3 }; short[] polygonsSchemas = { SFEdgeSurfaceSchemaBuilder.EDGE_SURFACE_SCHEMA_ID }; geometries[0].Setup(1, polygonsIndex, polygons, polygonsSchemas); cpnet.SetGeometries(1, geometries); CPNTessellationProcess tessellationProcess = ProcessesKeeper.GetTessellationProcess(); TessellationOutput output = tessellationProcess.InitProcess(cpnet, loqs); tessellationProcess.BuildProfile(); int[] builtTrianglesCount = output.GetBuiltTrianglesSize(); int builtVerticesCount = output.GetBuiltVerticesSize(); this.mesh = new OutputMesh(); this.mesh.SetupStructure(true, false, false, 0); this.mesh.Build(builtVerticesCount, builtTrianglesCount); tessellationProcess.WriteMesh(mesh); //Debug.Log("Tangents " + DemoUtils.Vector3sToString(mesh.GetTangents())); }
private void Execute() { CurvedPolygonsNet cpnet = new CurvedPolygonsNet(); cpnet.SetNumberOfVertices(3); Vector3[] vertices = { new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, DemoUtils.ONE_THIRD, 0), new Vector3(DemoUtils.ONE_THIRD, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, DemoUtils.ONE_THIRD, 0), }; cpnet.SetVertices(vertices); Vector3[] uvs = { new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, 0, 0), new Vector3(2 * DemoUtils.ONE_THIRD, DemoUtils.ONE_THIRD, 0), new Vector3(DemoUtils.ONE_THIRD, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, 2 * DemoUtils.ONE_THIRD, 0), new Vector3(0, DemoUtils.ONE_THIRD, 0), }; cpnet.SetUv(uvs); Vector3[] normals = { Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward }; cpnet.SetNormals(normals); short[] edges = { 0, 3, 4, 1, 1, 5, 6, 2, 2, 7, 8, 0 }; short[] edgesIndex = { 0, 4, 8, 12 }; short[] edgesHints = { 3, 3, 3, 3, 3, 3 }; float[] weights = { 1, 1, 1, 1, 1, 1 }; cpnet.SetEdges(3, edges, edgesIndex, edgesHints, weights); short[] loqs = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; CPNGeometry[] geometries = { new CPNGeometry() }; short[] polygons = { 1, 2, 3 }; short[] polygonsIndex = { 0, 3 }; short[] polygonsSchemas = { SFEdgeSurfaceSchemaBuilder.EDGE_SURFACE_SCHEMA_ID }; geometries[0].Setup(1, polygonsIndex, polygons, polygonsSchemas); cpnet.SetGeometries(1, geometries); CPNTessellationProcess tessellationProcess = ProcessesKeeper.GetTessellationProcess(); TessellationOutput output = tessellationProcess.InitProcess(cpnet, loqs); tessellationProcess.BuildProfile(); int[] builtTrianglesCount = output.GetBuiltTrianglesSize(); int builtVerticesCount = output.GetBuiltVerticesSize(); this.uvs_ = new Vector2[builtVerticesCount]; this.vertices_ = new Vector3[builtVerticesCount]; this.normals_ = new Vector3[builtVerticesCount]; this.indices_ = new int[builtTrianglesCount.Length][]; for (int i = 0; i < builtTrianglesCount.Length; i++) { this.indices_[i] = new int[builtTrianglesCount[i] * 3]; } OutputMesh mesh = new OutputMesh(vertices_, uvs_, normals_, indices_); tessellationProcess.WriteMesh(mesh); }