Camera control / Clipping Planes

unhandled

#1

I feel like I have a good grasp of controlling the camera settings, but I am a little stuck on one thing. I am working out the math to “simulate” depth of field calculations for a given lens; by simulate, I was going to use the near and far frustrum planes as the bounds of the depth of focus. It all seems pretty fine until I get ready to set those planes (after calculating them based on the current aperature, etc.)

I don’t see any relevant set method other than

(in Rhino.Display.RhinoViewPort)

    //
    // Summary:
    //     Sets optimal clipping planes to view objects in a world coordinate 3d bounding
    //     box.
    //
    // Parameters:
    //   box:
    //     The bounding box
    public void SetClippingPlanes(BoundingBox box);

This might be workable, but the fact that it is a world box makes me think its not so easy. If I could give it a box aligned to the camera, great. If its world and the camera is tilted, seems like a lot of extra maths. I have the planes calculated.

Assuming this is the only way…anybody have a tip on the math? Seems you need to make a world aligned bounding box with max diagonal that has endpoints on near/far planes.


#2

slight update to this. Turned out the math for the clipping planes wasn’t so hard. But they don’t seem to have an effect. I am wondering a) do they have to be active somehow, and b)how does my display conduit affect this (my guess is sgnificantly!).

It appears that the
protected override void CalculateBoundingBox(Rhino.Display.CalculateBoundingBoxEventArgs eventArgs) overrides them.
Update:
Currently my solution is to have the display conduit store a list of the cameras I want to control clip planes on, and then update their clipping planes after I calc the bounding box. Seems to work, in that the clipping planes are correctly set. Would be helpful if there is any example of doing this more cleanly.


#3

Still haven’t managed to actually get my clipping planes to work based on camera frustrum. Thought it might help with images.

The upper is the view from the camera shown in the lower. Shouldn’t the objects be clipped according to the two dotted rectangles?