Hi all,
I’d like to check if a point is visible to the camera associated with a displayRegion. Trying this:
displayRegionCamera.node().isInView(point)
yields incorrect results, since it keeps returning False for any point I pass to it, including a point where the x and z coordinates are the camera’s and the y coordinate is greater than the camera’s.
Also, doing this:
point2d=LPoint2()
rezult=displayRegionCamera.node().getLens().project(point,point2d)
just gives me similar results: False for any point I pass to it. What could I be doing wrong? Is there another way to check assuredly if a point is visible to a displayRegion’s camera?
Thanks in advance.
I think that both “isInView” and “project” expect the given point to be in the space of the camera (i.e. relative to the camera)–is that true of the points that you’re passing to them? Or are the points in world-space? (Or some other space.)
For example, here’s a brief few lines of code for the use of the “project” method:
# Given a point in world-space, held in a variable named "myPoint",
# and a camera held in a variable named "camera":
lens = camera.node().getLens()
resultPoint = LPoint2f()
relativePoint = camera.getRelativePoint(render, myPoint) # <--Note!
success = lens.project(relativePoint, resultPoint)
Thanks, that solved it. I had to convert the point to the camera’s space.
1 Like