SpaceFace
SpaceFace

Reputation: 1552

3D voxel angled plane

I'm trying to draw a flat surface out of voxels, the goal is to draw it filled and I'm having a lot of trouble. Everything I try results in holes on the surface. The surface has 4 corners, but I'd like to be able to use the same method for triangles too.

Here's what I've tried:

I've had the most success with 2 but it fails when I add any pitch or roll to the plane (any elevation present).

Any tips? There's no code because I'm sure my implementations are all correct, it's just the choice of algorithm that's wrong.

EDIT:

On a side note, though number 2 had less holes, the planes were distorted and didn't appear flat.

EDIT2:

I'm sticking with my first decision, but now the question is, how do I detect when there will be a hole? By observation I notice there's the same amount of holes per plane regardless of pitch and roll. Yaw is the culprit here.

EDIT3:

I'm leaving this question up but I decided to just test a nearby block to see if it's empty. I didn't want to do it, but yeah. If you have a more elegant solution I'm all ears.

Upvotes: 1

Views: 616

Answers (1)

smocking
smocking

Reputation: 3709

A plane, being infinite, does not have corners. Are you talking about a four-sided polygon? Does it have square corners?

For a polygon, I would certainly start off with a triangle, since you can construct any other polygon out of triangles, not the other way around.

Then, a good start for filling a triangle would probably be to come up with an accurate test of whether a given voxel should be filled or not. Here's an example of two different point-in-triangle tests.

After you have that you can proceed in different ways. For example, although not the most efficient, you could region-grow from the center, testing each neighboring voxel and recursing with a stack.

Upvotes: 1

Related Questions