- Home /
Making Different vertices,triangle,uv maps in the same mesh
Hi friends.
Im working on a big project, where i procedually generate a "minecraft like" terrain, and i've created a building creator in the same way. Heres how it works (code is tooo complex to share here).
Each building is divided into levels which have each their own chunk of boxes. each chunk is a mesh created via vertex, triangle and uv mapping.
Aslong as i keep to just using cube shaped forms in the algoritem, it seems to be working perfectly. BUT, i tried creating a different shape the same way, in a static class, that generates the verts, uvs and tris and return those to the chunk class, and then adding them to the rest of the verts, uvs and triangles.. This resulted in a huge mashup of the shapes, It did not make any sence.
My solution was to create a different mesh all together that works together with the other ones in a complex way, and this way each shape would have its own mesh generator and chunk class. (no problem with 1-5 shapes, buuut i have plans to make 20-30 different shapes, so you see the problem).
So my question is: Is it possible to mix several shapes in the same mesh like im trying to do?
If not, do you have any suggestions ?
ALSO, Why not? and is there anywhere i can read a full guidelines of what the rules for creating meshes manually? Something like "Do's and Dont's".
Thanks for any help.
Answer by MatriXz · Aug 02, 2018 at 10:23 AM
I solved this.
So if anyone has a similar situation, heres what did the difference.
Instead of adding to the list of triangles, uvs and verticies with the List.AddRange() method. I instead passed the lists to the method that calculates the faces, and add the values directly via the reference.
Logically this makes no sence to me, since passing the reference of a list to a method and letting the method add to the list, is exactly the same as returning an object and then AddRange the values into the list. But i guess theres something internally in the AddRange method that screws up the list or something.
Hope this helps
Your answer
Follow this Question
Related Questions
Null Reference Exception Assigning Vertices to Mesh 0 Answers
Lighting up all triangles between two points in a mesh? 1 Answer
How to return from shader the indexes of triangles/vertices that was actually rendered? 1 Answer
Can you apply smoothing to split vertices on a generated mesh? 1 Answer
Get an specific vertices of a mesh 2 Answers