- Home /
Most efficient method to create mesh from array
Hey guys. I was wondering, that what is the most efficient method to generate mesh from array? Because instantiating is damn slow. So I thought that I could just store the cubes data in 3D array like 0 - air, 1 - block, but how can I easily make a mesh from that? And yes I checked the minecraft and after playing minecraft, but I couldn't understand what's going on, because it was really complex, and I would need to get only the roots first to understand.
The code is bit messy but will give the idea.
//initalization //creating cube from many cubes, than if it's in radius/distance*2 it's 0-air, //if it's in radius it's 1-dirt //if it's in radius-5 it's 2-stone //I store it into a 3d array named planet //here should I rebuild the mesh from the array I have. //than if raycast and mouse -- set the block id to 0--air/destroy it
I haven't posted the whole code, because it's just while(x
--David
You should post the code anyway, it makes helping and unerstanding easier
lol no :D I don't know java. I know that Notch made $$anonymous$$inecraft in java, but he just copied the content of infinite$$anonymous$$er or how is it called :D. And I don't wanna make a $$anonymous$$ecraft style game, I wanna make something more science-fiction.
Notch was inspired by infini-$$anonymous$$er, but $$anonymous$$ecraft itself is ten thousand times better and has a lot of better features
Answer by Eric5h5 · Jul 14, 2011 at 08:46 AM
You wouldn't instantiate cubes, you'd use the Mesh class to create meshes.
yeah I know, that's why I'm not instantiating anymore :D, it's in the comment above. Uhm. $$anonymous$$aybe some help? Because first I thought about combining the children, but even the instantiating was slow, so I would never get to the children. So I should just create the mesh from the array like every piece in array is a cube or what?
But how can I export the array? For instance I only want the faces, that are visible/next to air and player can see them, so maximum up to 3 faces, because you can't see more faces of cube. And I forgot, how can I make some cubes look different, like dirt/stone etc? Sorry for asking too much, but I'm new to meshes :).
ok I made it... But I still have a big problem, that Vector3.Distance is really slow, when I wanna make it for many cubes. :(
Your answer
Follow this Question
Related Questions
Does a Mesh Vertices/Triangles/etc Have to be Compact 1 Answer
Generate a mesh from randomly positioned points 0 Answers
Procedural Mesh Generation - Split Arrays into sections 1 Answer
Procedurally generated mesh JS - explain the error please 0 Answers
Generate mesh from raycast positions, independent of rotations 0 Answers