Beispiel #1
0
        private void WriteMesh(Mesh storedMesh, OutputMesh output /*,bool useUnityNormals*/)
        {
            if (output.GetVertices().Length > CPNTessellationProcess.MAX_VERTICES_SIZE)
            {
                return;
            }

            storedMesh.Clear();
            storedMesh.vertices = output.GetVertices();
            storedMesh.uv       = output.GetUVs();
            storedMesh.normals  = output.GetNormals();

            int[][] triangles = output.GetTriangles();
            if (triangles.Length == 0)
            {
                storedMesh.SetTriangles(new int[0], 0);
            }
            else
            {
                storedMesh.subMeshCount = triangles.Length;
                for (int i = 0; i < triangles.Length; i++)
                {
                    storedMesh.SetTriangles(triangles[i], i);
                }
            }
        }
Beispiel #2
0
 public void Test(ITestAssert testAssert)
 {
     testAssert.CallTest(GetName());
     Execute();
     testAssert.AssertEquals(mesh.GetVertices().Length, 10, "Mesh Vertices");
     testAssert.AssertEquals(mesh.GetNormals().Length, 10, "Mesh Normals");
     //testAssert.AssertEquals(mesh.GetUVs().Length, 0, "Mesh UVs");
     //testAssert.AssertEquals(mesh.GetTangents().Length, 0, "Mesh Tangents");
     testAssert.AssertEquals(mesh.GetTriangles()[0].Length, 27, "Mesh Indices");
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public void BuildModel(GameObject gameObject)
 {
     Execute();
     MeshAssigner.AssignMesh(gameObject, mesh2.GetVertices(), mesh2.GetNormals(),
                             mesh2.GetUVs(), outMesh.GetTriangles());
 }
Beispiel #5
0
 public static void AssignMesh(GameObject gameObject, OutputMesh outputMesh)
 {
     AssignMesh(gameObject, outputMesh.GetVertices(), outputMesh.GetNormals(),
                outputMesh.GetUVs(), outputMesh.GetTriangles());
 }