Jump to content

Surface height in given point (x,y)


photo

Recommended Posts

Posted

Hello!

I have a mesh with number of surfaces. How can I get height of the given surface in the given point (x,y)?

Posted

You can use engine.world.getIntersection() ray casts. Place start and and end point at your (x,y) with start point z above mesh bounding box z max and end point z below mesh bounding box z min.

  • 8 years later...
Posted

Hello!

how to get all the coordinates of the points of intersection of the surface with a given ray?

Posted

Hello,

Using the GetIntersection function you can get only the first intersection point with an object or a list of all objects. But you can use multiple rays instead of one ray:

void get_intersection_points(Vec3 p1, Vec3 p2, int mask, Vector<vec3> &points)
{
    points.clear();

    WorldIntersectionPtr intersection = WorldIntersection::create();
    Vec3 direction = (p2 - p1).normalize();

    ObjectPtr hitObject = World::getIntersection(p1, p2, mask, intersection);
    while (hitObject)
    {
        points.append(intersection->getPoint());

        p1 = intersection->getPoint() + direction * UNIGINE_EPSILON;
        hitObject = World::getIntersection(p1, p2, mask, intersection);
    }
}

 

×
×
  • Create New...