# Marching cubes help

I just want to know how it triangulates.
why doesn’t it look like this

How do I go about knowing where to connect the triangles?

Code? I don’t have a clue what the problem is or how you are going about this.

1 Like

I’m just asking about the problem in general ( there is no specific code )

Could you be more specific about your question then? Why doesn’t what look like what?

When using marching cubes from what I understand it uses triangles to make meshes and a triangulation table knows where each point should go and you use the mid points or something of the sorts

and in the video a configuration of one on point is just a triangle in the corner but 2 adjacent makes a rectangle which I don’t understand

It looks like the second one, because that creates a better looking mesh.

Imagine you had occupancies that looked like:

``````o   +
o   +
o   +
o   +
``````

o = empty, + = filled.

If you used you first filling option, it would look like this:

``````o \ +
o / +
o \ +
o / +
``````

Whereas with the second one (the one marching cubes actually uses), it looks much better:

``````o | +
o | +
o | +
o | +
``````

but how does it know to make that better looking mesh?

It doesn’t, that’s the point of marching cubes.

It has no idea what the mesh as a whole will look like. It can just see individual cubes.

Some smart people (apparently Lorensen and Cline) figured out what those cubes should look like so that they all fit together nicely when looked at as a whole.

ok so it does see the individual cubes and it returns where the points should be how would I apply this?

The triangles are based on where the vertices are located. I think the latter would work better, though, since there wouldn’t be awkward triangle sizes since it would be uniform (right angled triangles). You don’t use vertices or polygonisation in Roblox so it doesn’t really apply (other than in importing objects from places like blender).

Hm what do you mean based on where the vertices are located?

What do you mean? Do you want to implement marching cubes? That’s a much more involved question, but there are a lot of resources online.

For example, the first google result gave me an implementation of marching cubes in Roblox. (Also see the post about that project)

Ah ok thanks I will check those out.

I’m just generally confused on how it works still

@DaMajestick This explains it pretty well:
http://paulbourke.net/geometry/polygonise/

@nicemike40 That’s pretty interesting. I didn’t even consider using something like that on Roblox. Although the code you provided doesn’t really use marching cubes in the traditional sense, since it works through cloning wedge parts (which is slightly cheating in my view).

You may want to watch this video to get an overview before you start trying to implement it: