- Home /
Procedurally Generated Cube Mesh
Hi there, I'm looking for a way to programmically construct a cube mesh, in C#. Now, what I need to do is be able to do is set a variable determining the amount of sub-divisions/segments on the cubes side. I then need to be able to set up all the UVs etc. I'm troubled because I only know how to setup a cube's mesh in code by manually setting the vert positions, etc. If I had a cube with 64 divisions on each side, that comes to over something like 6000 verts.... Which is way to much to do by hand.
So how would I go about this?
Answer by Dragonlance · Oct 06, 2012 at 03:07 PM
http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html
Check this out. You can create and dynamically change a mesh as you like. Assing it to a MeshFilter mesh attribute and it will be rendered.
But you will need to do all the math for the tesselation by yourself in your script.