Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Although varying the camera distance and focal length will change the object's visual size, it has the drawback of also changing the perspective, thus leading to a somewhat distorted view. I suggest to use the camera's <code>SceneScale</code> property instead.</p> <p>Alas, I have no valid steps to calculate the correct value for that. In my case I have to scale to a cube with varying size, while the window size of the viewer is constant. So I placed two dummycubes at the position of the target cube, each sized to fit either the width or the height of the viewer with appropriate values for <code>SceneScale</code>, camera distance and <code>FocalLength</code>. During runtime I calculate the new <code>SceneScale</code> by the ratio of the target cube size in respect to the dummycube sizes. This works quite well in my case.</p> <p><strong>Edit</strong>: Here is some code I make for the calculations.</p> <ul> <li><code>ZoomRefX</code> and <code>ZoomRefY</code> are those DummyCubes</li> <li><code>TargetDimX</code> and <code>TargetDimY</code> give the size of the current object</li> <li><code>DesignWidth</code> and <code>DesignHeight</code> are the size of <code>MyGLView</code> at design time</li> <li><code>DesignSceneScale</code> is the camera's <code>SceneScale</code> at design time</li> </ul> <p>The calculation code:</p> <pre><code>ScaleX := (ZoomRefX.CubeSize*MyGLView.Width)/(DesignWidth*TargetDimX); ScaleY := (ZoomRefY.CubeSize*MyGLView.Height)/(DesignHeight*TargetDimY); NewSceneScale := Min(ScaleX, ScaleY)*DesignSceneScale; </code></pre> <p>The DummyCubes <code>ZoomRefX</code> and <code>ZoomRefY</code> are sized so that they have a small margin to either the left-right or top-bottom edges of the viewing window. The are both positioned so that the front faces match. Also the target object is positioned to match its front face with those of these DummyCubes.</p> <p>The formulas above allow the window size to be different from design time, but I actually didn't test this feature.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload