lgdnpt Posted August 7, 2022 Share Posted August 7, 2022 I try to create a mesh manually, and saved the mesh, but it can't be display in the scene. I can only see the outline of the mesh which I create. this my c# code: Mesh mesh = new Mesh(); mesh.AddSurface("0"); mesh.AddVertex(new vec3(0.0f, 0.0f, 0.0f), 0); mesh.AddVertex(new vec3(0.0f, 0.0f, 1.0f), 0); mesh.AddVertex(new vec3(0.0f, 1.0f, 0.0f), 0); mesh.AddVertex(new vec3(0.0f, 1.0f, 1.0f), 0); mesh.AddVertex(new vec3(-1.0f, 0.0f, 0.0f), 0); mesh.AddVertex(new vec3(-1.0f, 0.0f, 1.0f), 0); mesh.AddVertex(new vec3(-1.0f, 1.0f, 0.0f), 0); mesh.AddVertex(new vec3(-1.0f, 1.0f, 1.0f), 0); mesh.AddIndex(0, 0); mesh.AddIndex(1, 0); mesh.AddIndex(2, 0); mesh.AddIndex(3, 0); mesh.AddIndex(2, 0); mesh.AddIndex(1, 0); mesh.AddIndex(4, 0); mesh.AddIndex(5, 0); mesh.AddIndex(6, 0); mesh.AddIndex(7, 0); mesh.AddIndex(6, 0); mesh.AddIndex(5, 0); mesh.AddIndex(7, 0); mesh.AddIndex(3, 0); mesh.AddIndex(6, 0); mesh.AddIndex(2, 0); mesh.AddIndex(6, 0); mesh.AddIndex(3, 0); mesh.AddIndex(5, 0); mesh.AddIndex(1, 0); mesh.AddIndex(7, 0); mesh.AddIndex(3, 0); mesh.AddIndex(7, 0); mesh.AddIndex(1, 0); mesh.AddIndex(0, 0); mesh.AddIndex(1, 0); mesh.AddIndex(4, 0); mesh.AddIndex(5, 0); mesh.AddIndex(4, 0); mesh.AddIndex(1, 0); mesh.AddIndex(4, 0); mesh.AddIndex(6, 0); mesh.AddIndex(0, 0); mesh.AddIndex(2, 0); mesh.AddIndex(0, 0); mesh.AddIndex(6, 0); mesh.CreateNormals(0); mesh.CreateTangents(); ObjectMeshStatic om = new ObjectMeshStatic(mesh); om.WorldPosition = new vec3(0, 0, 1); om.SetMaterial(mat, 0); om.SaveMesh("test.mesh"); mesh.Clear(); It's so strange that I can see it in the editor preview panel, but in the scene I can't see it except the outline. please point out of the mistake of my code, thanks! Link to comment
silent Posted August 8, 2022 Share Posted August 8, 2022 lgdnpt Please make sure that you also called createBounds() for mesh, here is the minimal C# example: https://developer.unigine.com/en/docs/latest/code/usage/mesh_class/index?rlang=cs#add_new_surface How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
lgdnpt Posted August 8, 2022 Author Share Posted August 8, 2022 1 hour ago, silent said: lgdnpt Please make sure that you also called createBounds() for mesh, here is the minimal C# example: https://developer.unigine.com/en/docs/latest/code/usage/mesh_class/index?rlang=cs#add_new_surface thank you! Link to comment
leon.dong Posted December 6, 2023 Share Posted December 6, 2023 @silent is that possible to have a algorithm to generate the data for AddIndex method instead of manually write many lines. Link to comment
werner.poetzelberger Posted December 7, 2023 Share Posted December 7, 2023 Iam not a programmer so anyone correct me ;). But wouldnt you do that in some sort of loop and write it into an Array or so ;) Best. WErner Link to comment
Recommended Posts