edited April 2011 in Help request
Hello everybody,

I'm using the orxObject_IsRendered(...) function and I'm not getting the result I expected. My first guess was that it would return true if the object was in the camera frustum and false otherwise. Is that correct?

In my case if I see the object on the screen, the orxObject_IsRendered returns true, ok. When I move the camera and the object is no longer on the screen, but is near its edge the orxObject_IsRendered still returns true. It returns false only when I move the camera a little more. Is that the correct behavior?



  • edited April 2011
    Well yes and no.

    That was the intent when I first implemented it but it then got deprecated due to rendering changes and I never fixed it/removed it.

    Right now it's completely broken (!) if you have more than one viewport and if you only have one, it'll return true if the object got past the render culling test which is a fast circle (squared distance) one based on the default graphic object (which is again not very precise for animated objects).
    I'll refine it to do an actual OBB intersection if it's not too expensive and make sure it works with more than one viewport.
    I'll try to do that tonight if you need it.
  • edited April 2011
    I just want to check whether an object is off screen or not. Is there another way to do it?
  • edited April 2011
    You can actually get the camera frustum yourself and the object's OBB and call the intersection test yourself.
  • edited April 2011
    Ok. But the frustum is an AABB and the intersection function expects another AABB.
  • edited April 2011
    Sorry, here are all the details:
    - Get the camera frustum
    - Do Size = Frustum.BR - Frustum.TL
    - Sets an orxOBOX with the camera world position, half size as pivot, its size as calculated above and its world rotation as angle
    - Gets the object's orxOBOX
    - Call orxOBox_ZAlignedTestIntersection

    That should do the trick. :)

    [EDIT] Missed some words when writing the first version, sorry.
  • edited April 2011
    It worked pretty well!

    But if you have time, I think it would be better if you refine the IsRendered function as you said.

    Thanks a lot.
  • edited April 2011
    Glad it worked.

    As for doing it this way in the render plugin, I'll probably wait a bit as it adds some complexity to the code as I have to take into account the camera zoom and the object's differential scrolling axes. It'll also have a negative impact on the performances. For now I think I might even remove this "feature" as it's both not precise and has some computation cost.
Sign In or Register to comment.