1
votes

So I've been working on some code to get the floor from a point-cloud mesh. Untill now, I've achieved to get the triangles that make up this floor mesh, but now I want to create a flat plane to cover those points to represent a flat floor.

Floor mesh

Oke, just to make it a bit more clear. Right now I've got this Mesh. (triangles, vertices and normals). I want to create a plane or something simular to cover this mesh to represent the floor (since this floor is not as flat as an actual floor should be).

It should create 1 or multiple planes to cover the encapsulated area

I do know of a library to use that calculates what an area should be based on some key-points. So if I would be able to get for example these points from the mesh (See below) it would create the following objects (See further below). This would also give me the desired result.

below further below

If someone has done something simular before or has an idea of how to solve this issue, I would be very gratefull :).

(I'm using Unity and C# btw)

One last thing to note about this mesh is sadly that not all triangles connect very well to each other. So there are points in the middle of the mesh that stick out a little bit. This makes it harder to check if a triangle is on a corner.

1
When you say you are trying to "represent the floor" you mean you are trying to fill in the large holes in the mesh with a flat surface?LLSv2.0
Hi @LLSv2.0, Sorry for the confusion. As this is made from a point-cloud mesh from the HoloLens, I want to be able to display 'a new floor' with the HoloLens. I am now able to extract the floor-mesh from the point-cloud, but because of the noise it doesn't really look like a floor. More like an area created by perlin noise I guess? So I want to have indeed something to cover the big holes, but also cover the other parts of this mesh. I hope this explains it a little better?Benji Riegman
So you want to get a perfectly flat plane that approximates the point cloud?LLSv2.0

1 Answers

1
votes

If I understand your problem correctly, you may have actually done too much work in creating your point cloud mesh, but it's cool anyway.

If all you want is a flat plane where the floor is, what you have is an approximation problem; one that can be as simple or as complex as you want really.

The simplest route: You know it's the floor in this case, so you can assume the normal vec is up (i.e. Vector3.up), so step 1 would be to estimate the z coordinate of your plane. The easiest way to do this would be to average all or some of the z coordinates of the points in your point cloud.

Now you need to the find the x and y coordinates for the corners of your plane. The absolute simplest solution, is to assume that most rooms are rectangular and so is the one you're working with. Then you can find the farthest point in any direction (x and y directions) and create a rectangular plane using those points.

This of course does not account for rotation of the floor (you're probably not standing looking perfectly perpendicular to a wall) which requires quite a bit more thinking.