Clipping in render2d

How do we explicitly clip a portion of the scenegraph in render2d?

I looked at the code for the scrolled frame but i wasn’t able understand how it does this.

This sort of clipping is achieved using clip planes. If you want to see the actual setup for the scrolled frame, see the function set_clip_frame() in panda/src/pgui/pgVirtualFrame.cxx. Panda actually provides some helper functions at the python level, though.

np = NodePath('someModel')
clipPlane = np.attachNewNode(PlaneNode('clip'))

This will cause everything above 10 units in the z-direction (in np’s coordinate system) to be culled out at render time. Polygons that intersect this boundary are clipped (cut) such that they render right up to the plane. I’ve heard that there are limits on how many clip planes you can have active at any given time, depending on your hardware, though I’m not sure what those limits are.