Using an object to render to the stencil buffer

Started by rhadamanthus, May 05, 2013, 02:33:01 AM

Previous topic - Next topic

rhadamanthus

Hello,
I am developing an augmented reality application. I successfully aligned a 3D box with an actual box that I see through the camera. The next thing I want to do is to use the 3D box to hide other 3D objects around it, so it would appear as if the other 3D objects were behind the real box in the image. (They should be occluded by the real box if they are behind it)

I think this can be done using the stencil buffer, however, I am not experienced enough to deduct what I need to do, neither in OpenGL nor in JPCT. Anybody has any hints about that?
I saw that IRenderHook can be used to inject code into the rendering pipeline, but I'm not exactly sure how this works or how to set different stencil modes. Is it that every time repeatRendering() returns true, the method afterRendering() is called?

Any help would be appreciated. thank you

EgonOlsen


rhadamanthus

Yup! That's exactly what I ended up doing. Thank you for the reply.
I put the box in a separate world instance in order to render them independently. Is that how it is supposed to be used?

EgonOlsen

Quote from: rhadamanthus on May 06, 2013, 09:13:42 PM
I put the box in a separate world instance in order to render them independently. Is that how it is supposed to be used?
Yes, that's just fine.