问题
The plane fitting example fits a cube on a plane that it created from the point cloud that it retrieves based on the point selected by user. I want to determine if that point is a floor, a wall or a roof. What I am trying to achieve is to change the example so that it only renders the cube on the floor and not on wall or roof.
回答1:
The simplest solution is to check the plane normal. Usually, wall's normal is perpendicular to the gravity, and floor is parallel to gravity.
回答2:
Something like this:
You got the normal of the plane hit right?
float surfaceAngle = Vector3.Angle(normal, new Vector3(0,1,0));
float floorLimitAngle = 20;
float ceilingLimitAngle = 180 - 20;
if (surfaceAngle < floorLimitAngle )
// It's a floor
else if (surfaceAngle > ceilingLimitAngle)
// It's a ceiling
else
// It's a wall
来源:https://stackoverflow.com/questions/38776664/project-tango-how-to-tell-if-the-plane-created-in-the-plane-fitting-example-is