Is there any scriptcontext method that could be used to set the active viewport’s visible area precisely say using 4 3d points of a rectangle. I’m looking for something similar to rhinoscriptsyntax’s ViewCorners except that I want to set the corners. SetFrustum does not seem to be useful in this regard. Any thoughts?
see what rhinoscriptsyntax.ZoomBoundingBox() can do for you.
It’s not really useful/obvious for perspective views but for parallel views it’s rather straightforward.
Thanks, Willem. I did try ZoomBoundingBox and it seems like the most useful as of now. The only trouble with ZoomBoundingBox is that it does not set the active viewport precisely at the 4 corners; rather it works like ZoomExtents or ZoomSelected.
Is that not due to the aspect ratio of the viewport not being equal to that of the boundingbox?
In the past I have found that when working with viewports and setting exact scale, it’s best to work with the pixel dimensions as a start and calculate towards model units. If you do the reverse; the rounding to pixels will cause fairly large differences in aspect ratio.
Can you explain this a little more? Not sure I understand what you mean by working with pixel dimensions.
Is this (basically) running the Zoom command and dragging the rectangle to zoom?
Can you provide an ecample of where zoomboundingbox is not working as expected that might be easier to work with than an abstract conversation?
Okay, I will have it up when I get back on my office computer.
@dale Yes! Actually, what I am trying to do is tile render. Below: the black rectangle represents active viewport and it’s approx at (694,494) pixel size. The red dots represent bounding box points. I want to calculate the blue rectangle and then zoom my camera in just enough for that portion to be visible in the render; in other words, make that blue rectangle the active viewport size. Makes sense?
Like as been mentioned here already, if you want to “zoom” the viewport based on some calculated rectangle, then using
ZoomBoundingBox is the way to go. If this isn’t zooming like you expect, then there are two possibilities (maybe more):
1.) The aspect ratio of the bounding box does not match the aspect ratio of the viewport. Thus, you end up seeing more or less than you want.
2.) The zoom border (or padding" is preventing an accurate zoom. Zoom borders are controlled
Just to be sure: if this is a perspective projection, there is no way in Rhino to make tile-able views as the frustrum is centered around the view center so making tiles this way will not line up seamless.
Thanks, @Dale. That could be quite useful. I’m going to try the
ZoomBoundingBox logic out. And if that doesn’t work out, I might try this: use
ViewCameraTarget to zoom to the required extent, then keep moving the target location and rendering, and stop when
ViewCorners exceeds the bounding box. The should ensure I have tile rendered all the areas where the object is present? Yes, this is parallel projection of course.