HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUI_ViewParameter.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GUI_ViewParameter (Geometry Render Library, C++)
7  *
8  * COMMENTS:
9  * ViewParameter contains information relating to the
10  * viewport's physical characteristics, eg aspect ratio,
11  * position, lookat.
12  *
13  */
14 
15 #ifndef __GUI_ViewParameter__
16 #define __GUI_ViewParameter__
17 
18 #include "GUI_API.h"
19 #include <UT/UT_BoundingBox.h>
20 #include <UT/UT_Matrix3.h>
21 #include <UT/UT_Matrix4.h>
22 #include <UT/UT_Quaternion.h>
23 #include <UT/UT_Rect.h>
24 #include <UT/UT_Vector3.h>
25 #include <UT/UT_Plane.h>
26 
27 class RE_Render;
28 
30 typedef void (*GUI_HomeRotCallback)(UT_Matrix3R &, void *);
31 
33 {
34 public:
36  {
37  ortho = 0;
38  applyAspect = 0;
39  matrixDirty = 1;
40  iMatrixDirty = 1;
41  boxZoom = 0;
42  viewportDirty = 0;
43  rotoTrackWindow = 1;
44  initXform = 0;
45  rxyzDirty = 1;
46  }
47 
48  // ASCII methods to save and load flags
49  void save(std::ostream &os) const;
50  bool load(UT_IStream &is);
51 
52  unsigned ortho:1,
53  applyAspect:1,
54  matrixDirty:1,
55  iMatrixDirty:1,
56  boxZoom:1,
57  viewportDirty:1,
58  rotoTrackWindow:1,
59  initXform:1,
60  rxyzDirty:1;
61 };
62 
64 {
65 public:
68 
69  GUI_ViewParameter(const GUI_ViewParameter &) = delete;
70  enum axis { OBLIQUE, CUSTOM, XAXIS, YAXIS, ZAXIS,
71  FRONT, RIGHT, TOP, BACK, LEFT, BOTTOM, CPLANE };
72 
73  enum orientation { Y_UP, Z_UP };
74 
76  {
77  int w,h;
78  getViewportSize(w,h);
79  area.set(myViewportLeft, myViewportBottom, w,h);
80  }
81  void getViewport(int &l, int &r, int &b, int &t) const;
82  void getViewportSize(int &w, int &h) const
83  {
84  // Note that we have inclusive coordinates.
85  w = myViewportRight - myViewportLeft + 1;
86  h = myViewportTop - myViewportBottom + 1;
87  }
88  int getViewportWidth() const
89  { return myViewportRight - myViewportLeft + 1; }
90  int getViewportHeight() const
91  { return myViewportTop - myViewportBottom + 1; }
92  void setViewport(RE_Render *r, int x, int y, int w, int h);
93  void setViewport(RE_Render *r, const UT_DimRect &viewarea)
94  { setViewport(r, viewarea.x(), viewarea.y(),
95  viewarea.w(), viewarea.h()); }
96 
97  // Utility for converting our viewport into a UT_Rect.
99  { return UT_InclusiveRect(myViewportLeft, myViewportBottom,
100  myViewportRight, myViewportTop); }
101 
102 
103  // Both setViewport and setView must be called before setProjection.
104  // r may be NULL to set the projection matrix without loading it into
105  // RE_Render.
106  void setProjection(RE_Render *r);
107 
108  // Returns the projection matrix. If depth_adjust is false, Z is not
109  // mapped to [0,1], and instead remains as-is.
110  void getProjection(UT_Matrix4D &proj, bool depth_adjust=true);
111 
112  void getUnclippedProjection(UT_Matrix4D &project,
113  fpreal left_crop = 0.0,
114  fpreal right_crop = 1.0,
115  fpreal bottom_crop = 0.0,
116  fpreal top_crop = 1.0);
117 
118  // temporarily use this projection matrix. This class does not take
119  // ownership.
120  void setProjectionOverride(UT_Matrix4D *override);
121 
122  // Get the direction a particular point (px, py) in the camera's
123  // near plane is pointing to in world coordinates. The range of
124  // (px, py) is (0, 0) to (1, 1) with (0, 0) representing the
125  // lower-left corner and the default arguments represent the center of
126  // the screen.
127  UT_Vector3 getCameraDir(fpreal px = 0.5, fpreal py = 0.5);
128 
129  // A utility method to return the world space plane representing our
130  // view plane. The point will be set to the center of the view and
131  // the normal will point towards the camera.
132  UT_PlaneD getViewPlane();
133 
134  // The view is a subregion of the viewport that represents the current
135  // "camera" view. Aspect ratio bars are used to dim the parts of the
136  // viewport not in this view. The window coordinates are relative to
137  // this view, not the viewport.
138  void setView(const UT_DimRect &area)
139  { setView(area.x(), area.y(), area.w(), area.h()); }
140  void setView(int x, int y, int w, int h);
141  void getView(int &l, int &r, int &b, int &t) const;
142  int getViewWidth() const
143  { return myViewRight - myViewLeft + 1; }
144  int getViewHeight() const
145  { return myViewTop - myViewBottom + 1; }
146  // Utility for converting our viewport into a UT_Rect.
148  { return UT_InclusiveRect(myViewLeft, myViewBottom,
149  myViewRight, myViewTop); }
150 
151  // A handy method to compute projection bounds for the viewport such
152  // that the specified bounds map to the view subregion.
153  void viewToViewportProjectionBounds(
154  fpreal &left, fpreal &right,
155  fpreal &bottom, fpreal &top) const;
156 
157  // Convenience methods to query the margins on each side of the view
158  // subregion.
159  int getLeftMargin() const
160  { return myViewLeft - myViewportLeft; }
161  int getRightMargin() const
162  { return myViewportRight - myViewRight; }
163  int getBottomMargin() const
164  { return myViewBottom - myViewportBottom; }
165  int getTopMargin() const
166  { return myViewportTop - myViewTop; }
167 
168  void homeToBox(int width, int height, fpreal minzoom,
169  UT_BoundingBox &box, const UT_Matrix3R *rot = NULL,
170  bool centre_to_origin = false, bool zoom_in = false);
171  void homeRotation(axis a, UT_Matrix3R &rot) const;
172  void homeRotation(axis a);
173 
174  void resetFOV();
175 
176  // Query the rotation that converts the view rotation from the old mode
177  // to the new mode.
178  static void getOrientationChangeRotation(
181  UT_Matrix3R &rot);
182 
183  // Convert a view transform relative to the old_mode to the corresponding
184  // view transform relative to the new mode.
185  void convertTransform(GUI_ViewParameter::axis home_axis,
188 
189  // To perform view operations that are being exported continuously, we
190  // need to cache some data to account for view changes that occur as a
191  // result of the exporting. Generally, you'll want to call the begin
192  // method on a UI_VALUE_START and the end method on a UI_VALUE_CHANGED.
193  void beginContinuouslyExportedOperation();
194  void endContinuouslyExportedOperation();
195  bool continuouslyExportedOperationInProgress() const;
196 
197  void rotate(UT_Axis3::axis axis, fpreal dx);
198  void rotate(const UT_Vector3R &axis, fpreal dx);
199  void rotate(const UT_Quaternion &quat);
200  void trackball(fpreal dx, fpreal dy);
201  void incrementtrackball(fpreal dx, fpreal dy, int finish);
202  void eulertumble(fpreal dx, fpreal dy, int finish, bool lock);
203  void dotumble(fpreal dx, fpreal dy, int finish);
204 
205  void scroll(fpreal dx, fpreal dy);
206  // Scroll using the specified viewport size instead of our settings. Used
207  // for scrolling linked ortho viewports.
208  void scroll(fpreal dx, fpreal dy, const UT_InclusiveRect &viewport);
209  // Scroll to maintain the specified world position under the cursor. This
210  // method is unnecessary when using an orthographic projection.
211  void worldLockedScroll(const UT_Vector3R &locked_pos,
212  fpreal dx, fpreal dy);
213 
214  void dolly(fpreal dx,
215  bool precise_zoom = false,
216  bool smooth_deltas = false);
217 
218  // Dolly using a specified world-space direction (instead of towards the
219  // center of the view as in a regular dolly). The use of world space is
220  // a convenience for the GUI_ViewState wrapper that would otherwise have
221  // to transform this to a view space direction for each instance of this
222  // class.
223  void directedDolly(const UT_Vector3R &unit_worldspace_dir,
224  fpreal dx, bool precise_zoom = false,
225  bool smooth_deltas = false);
226 
228  {
230  GUI_ORTHO_WIDTH
231  };
232  void zoom(fpreal dx, GUI_ZoomItem item, bool precise_zoom = false);
233  // Zoom using the specified viewport size instead of our settings. Used
234  // for zooming linked ortho viewports.
235  void zoom(fpreal dx, GUI_ZoomItem item,
236  const UT_InclusiveRect &viewport,
237  bool precise_zoom = false);
238 
239  // Versions of the zoom() methods that center the zoom around the given
240  // (normalized) screen position (sx, sy). This affects either the window
241  // offset, when GUI_WIN_SIZE is specified, or the view position, when
242  // GUI_ORTHO_WIDTH is specified.
243  void offsetZoom(fpreal sx, fpreal sy, fpreal dx, GUI_ZoomItem item,
244  bool precise_zoom = false);
245  void offsetZoom(fpreal sx, fpreal sy, fpreal dx, GUI_ZoomItem item,
246  const UT_InclusiveRect &viewport,
247  bool precise_zoom = false);
248 
249  // Dolly onto a target located at a specified distance.
250  // Note that the location and size of the "box" must be
251  // normalized to [0, 1]
252  // ** Note : Aspect ratio of the box is assumed to match aspect ratio
253  // of the viewport!
254  void boxZoom(fpreal firstx, fpreal firsty, fpreal lastx,
255  fpreal lasty, fpreal distance);
256 
257  void screenScroll(fpreal dx, fpreal dy);
258 
259  // Returns the width of the frustum cross-section at the distance t.
260  static fpreal getFrustumWidth(fpreal t, fpreal aperture, fpreal focal_length,
261  fpreal orthowidth, bool is_ortho);
262 
263  // Returns the centre of the frustum (cx, cy) and the half-width and
264  // half-height (hw, hh), from these, you can compute the corners of the
265  // frustum.
266  static void getFrustumCenter(fpreal frustum_width, fpreal aspect,
267  fpreal x_offset, fpreal y_offset,
268  fpreal x_window_size, fpreal y_window_size,
269  fpreal &cx, fpreal &cy,
270  fpreal &hw, fpreal &hh);
271 
272 // member data access methods
273 
274  bool isDirty() const { return (myFlag.viewportDirty ||
275  myFlag.matrixDirty ||
276  myFlag.iMatrixDirty); }
277  // bumped whenever the view has changed.
278  int getViewVersion() const { return myVersion + myVersion2D; }
279  void bumpViewVersion() { myVersion++; }
280  void bumpView2DVersion() { myVersion2D++; }
281  int getView3DVersion() const { return myVersion; }
282  int getView2DVersion() const { return myVersion2D; }
283 
284  // projection
285  int initialized() const { return myFlag.initXform; }
286  int getOrthoFlag() const { return myFlag.ortho; }
287  void setOrthoFlag(int o) { myFlag.ortho = o; }
288  void setLimits(fpreal n, fpreal f) { setNearClip(n); setFarClip(f); }
290  {
291  *n = myView.myNearLimit;
292  *f = myView.myFarLimit;
293  }
294  void setNearClip(fpreal near);
295  void setFarClip(fpreal far);
296  fpreal getNearClip() const { return myView.myNearLimit; }
297  fpreal getFarClip() const { return myView.myFarLimit; }
298 
300  {
301  myView.myWinX = x;
302  myView.myWinY = y;
303  myView.myWinW = SYSmax(w, fpreal(0.001));
304  myView.myWinH = SYSmax(h, fpreal(0.001));
305  updateWindowOverridesNominal();
306  }
308  fpreal &w, fpreal &h) const
309  {
310  x = myView.myWinX;
311  y = myView.myWinY;
312  w = myView.myWinW;
313  h = myView.myWinH;
314  }
315 
317  {
318  myNominalWinX = x;
319  myNominalWinY = y;
320  myNominalWinW = SYSmax(w, fpreal(0.001));
321  myNominalWinH = SYSmax(h, fpreal(0.001));
322  updateWindowOverridesNominal();
323  }
325  fpreal &w, fpreal &h) const
326  {
327  x = myNominalWinX;
328  y = myNominalWinY;
329  w = myNominalWinW;
330  h = myNominalWinH;
331  }
333  { return myWindowOverridesNominal; }
334 
335  // A handy method to compute the view region bounds relative to the nominal
336  // window rather than relative to the current window. With bounds relative
337  // to the nominal window, the nominal window is the unit square from (0,0)
338  // to (1,1), in contrast with bounds relative to the current window, which
339  // are themselves always this unit square.
340  void getViewBoundsRelativeToNominalWindow(
341  fpreal &l, fpreal &r, fpreal &b, fpreal &t) const;
342 
343  // The window is stored as an offset from 0, 0 with the scale applied prior
344  // to translation. However, mantra and other renderers expect the window
345  // to be relative to the (0,1) rectangle. getScreenWindow() will translate
346  // the window parameters into a screen window. setScreenWindow() will take
347  // a screen window and set the appropriate parameters.
349  fpreal &b, fpreal &t) const
350  {
351  convertViewToScreenWindow(myView.myWinX, myView.myWinY,
352  myView.myWinW, myView.myWinH,
353  l, r, b, t);
354  }
356  {
357  convertScreenToViewWindow(l, r, b, t,
358  myView.myWinX, myView.myWinY,
359  myView.myWinW, myView.myWinH);
360  }
361 
362  static void convertScreenToViewWindow(
364  fpreal &xoff, fpreal &yoff, fpreal &xsize, fpreal &ysz);
365  static void convertViewToScreenWindow(
366  fpreal xoff, fpreal yoff, fpreal xsize, fpreal ysize,
367  fpreal &l, fpreal &r, fpreal &b, fpreal &t);
368 
369  fpreal getWinSizeX() const { return myView.myWinW; }
370  fpreal getWinSizeY() const { return myView.myWinH; }
371  fpreal getWinX() const { return myView.myWinX; }
372  fpreal getWinY() const { return myView.myWinY; }
373 
375  {
376  GUI_VIEW_ADJUST_NONE = 0,
377  GUI_VIEW_ADJUST_FAR = 1,
378  GUI_VIEW_ADJUST_NEAR = 2,
379  GUI_VIEW_ADJUST_BOTH = 3
380  };
382  { myAdjustLimits = which; }
383  GUI_ViewAdjustLimits getAdjustLimits() const { return myAdjustLimits; }
384 
385  void setWindowAffectRotoscope(int v) { myFlag.rotoTrackWindow = v; }
387  { return myFlag.rotoTrackWindow; }
388 
389  // aspectRatio
390  void setApplyAspectFlag(int a) { myFlag.applyAspect = a; }
391  int getApplyAspectFlag() const { return myFlag.applyAspect; }
392  void setAspectRatio(fpreal a) { myViewAspectRatio = a; }
393  fpreal getAspectRatio() const { return myViewAspectRatio; }
394 
396  {
397  myFrustumWidthScale = xsc;
398  myFrustumHeightScale = ysc;
399  }
400 
401  // position
403  void setT(const UT_Vector3D &t)
404  { myView.myT = t; myFlag.matrixDirty=1; myFlag.iMatrixDirty=1;}
406  const UT_Vector3D & getT() const { return myView.myT; }
407 
408  // pivot
410  const UT_Vector3D & getP() const { return myView.myP; }
412  void setP(const UT_Vector3D &p)
413  { myView.myP = p; myFlag.matrixDirty=1; myFlag.iMatrixDirty=1;}
414 
415  static void setOrientationMode(orientation o);
416  static orientation getOrientationMode();
417  static bool isOrientationYUp()
418  { return getOrientationMode() == Y_UP; }
419  static bool isOrientationZUp()
420  { return getOrientationMode() == Z_UP; }
421 
422  // Rotation style:
423  static void setTumbleStyleFlag(int style)
424  { myTumbleStyle = style; }
425  static int getTumbleStyleFlag() { return myTumbleStyle; }
426  static void setAltKeyViewControlsFlag(int style)
427  { myAltKeyViewControls = style; }
428  static int getAltKeyViewControlsFlag() { return myAltKeyViewControls; }
429  static void setScrollStyleFlag(int style)
430  { myScrollStyle = style; }
431  static int getScrollStyleFlag() { return myScrollStyle; }
432  static void setDefaultHomingStyleFlag(int style)
433  { myDefaultHomingStyle = GUI_ViewParameter::axis(style); }
434  static axis getDefaultHomingStyleFlag() { return myDefaultHomingStyle; }
435 
436  // the resulting matrices
437  void setRotateMatrix(const UT_Matrix3D &mat)
438  { myView.myRotateMatrix = mat;
439  myFlag.matrixDirty = 1;
440  myFlag.iMatrixDirty = 1;
441  myFlag.rxyzDirty = 1; }
442  const UT_Matrix4D &getRotateMatrix() const { return myView.myRotateMatrix; }
443 
445  { return myProjectionOverride ? *myProjectionOverride
446  : myView.myProjectionMatrix; }
447  const UT_Matrix4D &getTransformMatrix() { updateTransformMatrix();
448  return myTransformMatrix; }
449  const UT_Matrix4D &getItransformMatrix() { updateItransformMatrix();
450  return myItransformMatrix; }
451 
452  // This sets the transform matrix to the given value, bypassing the
453  // PX, TX, etc. The purpose of this is to get accurate camera transforms
454  // you can first set all the PX, Rotate, etc, according to the cracked
455  // values, and then do a forceTransformMatrix to ensure the user sees
456  // the most accurate possible matrix.
457  void forceTransformMatrix(const UT_DMatrix4 &mat);
458  void getTransformMatrix(UT_DMatrix4 &mat, fpreal time);
460  void *data)
461  {
462  myTransformCallback = callback;
463  myTransformCallbackData = data;
464  }
465 
466  // Class I/O methods. They return 0 if successful, -1 if not.
467  // `for_view_copy` is only for temporarily transferring one view parms to
468  // another.
469  int save(std::ostream &os,
470  char separator = '\n',
471  bool for_view_copy = false) const;
472  bool load(UT_IStream &is);
473  bool oldLoad(UT_IStream &is, int version);
474 
475  // inline for non-virtual class
476  const char *className() const { return "GUI_ViewParameter"; }
477 
478  fpreal getLastHomeRadius() const { return myLastHomeRadius; }
479 
480  void setHomeAxis(axis homeaxis)
481  { myHomeAxis = homeaxis; myFlag.rxyzDirty = 1; }
482  axis getHomeAxis() const { return myHomeAxis; }
483  void setCustomHomeRot(UT_Matrix3R &rot) { myCustomHomeRot = rot; }
484  const UT_Matrix3R &getCustomHomeRot() const { return myCustomHomeRot; }
485 
486  // Set a callback to get the home rotation for the construction plane
487  // (axis::CPLANE), to which this class does not have direct access.
489  void *data)
490  {
491  myCPlaneHomeRotCallback = callback;
492  myCPlaneHomeRotCallbackData = data;
493  }
494 
495 
496  void setOrthoWidth(fpreal w) { myView.myOrthoWidth = w; }
497  fpreal getOrthoWidth() const { return myView.myOrthoWidth; }
498 
499  void setFocalLength(fpreal f) { myView.myFocalLength = f; }
500  fpreal getFocalLength() const { return myView.myFocalLength; }
501 
502  void setFocalUnitScale(fpreal f) { myView.myFocalScale = f; }
503  fpreal getFocalUnitScale() const { return myView.myFocalScale; }
504 
505  void setFocusDistance(fpreal f) { myView.myFocusDistance = f; }
506  fpreal getFocusDistance() const { return myView.myFocusDistance; }
507 
508  void setAperture(fpreal a) { myView.myAperture = a; }
509  fpreal getAperture() const { return myView.myAperture; }
510 
511  void setFStop(fpreal fs) { myView.myFStop = fs; }
512  fpreal getFStop() const { return myView.myFStop; }
513 
515  {
516  myView.myHApertureOffset = h;
517  myView.myVApertureOffset = v;
518  }
520  {
521  h = myView.myHApertureOffset;
522  v = myView.myVApertureOffset;
523  }
524 
525  fpreal getNearLimit() const { return myView.myNearLimit; }
526  fpreal getFarLimit() const { return myView.myFarLimit; }
527 
528  fpreal getZBufferNear() const { return myZBufferNear; }
529  fpreal getZBufferFar() const { return myZBufferFar; }
530 
531  // viewport clearing
533 
534  // fog
535  int myFog;
537  float myFogNear;
538  float myFogFar;
539  float myFogColor[3];
540  float myFogAlpha;
541 
542  // used for rotoscoping only
544 
545  // container for all view home information
546  class gui_View
547  {
548  public:
550  : myT(0.0, 0.0, 0.1),
551  myP(0.0, 0.0, 0.0),
552  myRotateMatrix(1.0),
553  myProjectionMatrix(1.0),
554  myWinX(0.0),
555  myWinY(0.0),
556  myWinW(1.0),
557  myWinH(1.0),
558  myOrthoWidth(1.0),
559  myFocalLength(50.0),
560  myFocusDistance(5.0),
561  myAperture(41.4214),
562  myFStop(5.6),
563  myFocalScale(1.0),
564  myNearLimit(0.1),
565  myFarLimit(10000.0),
566  myHApertureOffset(0.0),
567  myVApertureOffset(0.0)
568  {}
569 
572 
575 
576  // window (zooming)
581 
582  // projection information
583  // ortho specific
585 
586  // perspective specific sSee diagram below)
590  fpreal myFStop; // for dof.
594 
597  };
598 
599  // methods to quickly stash and recall the view state.
600  void getViewState(gui_View &view_state) const
601  { view_state = myView; }
602  void setViewState(const gui_View &view_state)
603  {
604  myView = view_state;
605  myFlag.matrixDirty=1;
606  myFlag.iMatrixDirty=1;
607  myFlag.rxyzDirty=1;
608  updateWindowOverridesNominal();
609  }
610 
611  // clipping
612 private:
613  fpreal myZBufferNear;
614  fpreal myZBufferFar;
615  GUI_ViewAdjustLimits myAdjustLimits;
616 
617  // aspect ratio
618  fpreal myViewAspectRatio;
619 public:
620  fpreal myPixelAspect; // depends on output device
621 
622 // projection information (see docs below)
633 
635 
636 private:
637  void updateTransformMatrix();
638  void updateItransformMatrix();
639  void updateRXYZValues();
640  fpreal getDistanceToBoxCenter(int clamp = 0) const;
641 
642  void internalScroll(fpreal dx, fpreal dy,
643  const UT_InclusiveRect &viewport,
644  bool decouple_axes,
645  const UT_Vector3R *locked_pos);
646  void internalZoom(fpreal dx, GUI_ZoomItem item, int width);
647  void internalOffsetZoom(fpreal sx, fpreal sy, fpreal dx,
648  GUI_ZoomItem item,
649  const UT_InclusiveRect &viewport);
650  void internalScreenScroll(fpreal dx, fpreal dy,
651  const UT_InclusiveRect &viewport);
652 
653  void getFrustumClip(fpreal &l, fpreal &r, fpreal &t, fpreal &b,
654  fpreal &n, fpreal &f, bool adjust_zrange);
655  bool computeWorldLockedScrollAccel(fpreal dx, fpreal dy,
656  const UT_Vector3R &locked_pos,
657  fpreal &accelerationx,
658  fpreal &accelerationy);
659  fpreal computeZoomDelta(fpreal dx,
660  bool precise_zoom,
661  bool smooth_deltas);
662 
663  void updateWindowOverridesNominal()
664  {
665  myWindowOverridesNominal =
666  (myView.myWinX != myNominalWinX ||
667  myView.myWinY != myNominalWinY ||
668  myView.myWinW != myNominalWinW ||
669  myView.myWinH != myNominalWinH);
670  }
671 
672  GUI_ViewFlag myFlag;
673 
674 // transform information
675 
676  gui_View myView;
677  fpreal myDx, myDy;
678  static orientation myOrientationMode;
679  static int myTumbleStyle;
680  static int myAltKeyViewControls;
681  static int myScrollStyle;
682  static axis myDefaultHomingStyle;
683 
684  fpreal myRx, myRy, myRz; // Used by euler method. In degrees
685 
686  // always call updateTransformMatrix before using myTransformMatrix.
687  UT_Matrix4D myTransformMatrix; // this one is generated from the above
688  UT_Matrix4D myItransformMatrix; // inverse of myTransformMatrix;
689 
690  GUI_TransformCallback myTransformCallback;
691  void *myTransformCallbackData;
692 
693 // home information to be used in scaling of view transformation
694  fpreal myLastHomeDistance;
695  fpreal myLastHomePixelWidthOBSOLETE;
696  fpreal myLastHomeAdjustedBoxWidth;
697  fpreal myLastHomeOrthoWidth;
698  fpreal myLastHomeRadius;
699 
700  // myLastHomeAdjustedBoxWidth supercedes myLastHomePixelWidth, but to load
701  // view transforms from old hip files without screwed up scrolling, we may
702  // need to use the obsolete quantity until the next manual home operation.
703  bool myObsoleteScrollIsActive;
704 
705  axis myHomeAxis;
706  UT_Matrix3R myCustomHomeRot;
707 
708  GUI_HomeRotCallback myCPlaneHomeRotCallback;
709  void *myCPlaneHomeRotCallbackData;
710 
711  // A collection of data needed for calculating the appropriate changes to
712  // the view transform to perform view operations under continuous export
713  // of view changes to a camera.
714  class ContinuousExportCache
715  {
716  public:
717  ContinuousExportCache() {}
718 
719  UT_Matrix4D myRotateMatrix;
720  UT_Matrix4D myTransformMatrix;
721  UT_Matrix4D myItransformMatrix;
722  fpreal myAdjustedNear;
723  fpreal myAdjustedX;
724  fpreal myAdjustedY;
725  fpreal myTotalScrollX;
726  fpreal myTotalScrollY;
727  };
728 
729  typedef ContinuousExportCache ViewOpCache;
730 
731  ViewOpCache myContinuousExportCache;
732  bool myContinuousExportInProgress;
733 
734  // The nominal window (zooming) for this view. The myView.myWin* members
735  // represent the window used for the current view, but when they are used
736  // to override the camera's screen window, we need to know that this is
737  // the case and what nominal window values to use for properly displaying
738  // overlays like the safe area or field guide.
739  bool myWindowOverridesNominal;
740  fpreal myNominalWinX;
741  fpreal myNominalWinY;
742  fpreal myNominalWinW;
743  fpreal myNominalWinH;
744 
745  // These might be needed for other guys.
746  int myViewportLeft, myViewportRight;
747  int myViewportBottom, myViewportTop;
748 
749  // The view is a subregion of the viewport that represents the current
750  // "camera" view. Aspect ratio bars are used to dim the parts of the
751  // viewport not in this view. The window coordinates are relative to
752  // this view, not the viewport.
753  int myViewLeft, myViewRight;
754  int myViewBottom, myViewTop;
755 
756  int myVersion;
757  int myVersion2D;
758 
759  UT_Matrix4D *myProjectionOverride;
760 };
761 
762 
763 #ifdef __DOCUMENTATION__
764 
765 FOV can be computed from aperture and focal length.
766 
767  <--aperture--->
768  | |
769  | |
770  +------+------+-----------
771  \ | / ^
772  \ | / |
773  \_--+--_/ Focal
774 Unzoomed \ | / Length
775  FOV --> \ | / |
776  \|/ v
777  +------------------
778 
779 myFullW and myFullH are the dimensions of the plane onto which the
780 image is projected before any adjustments for zoom or window parms.
781 the plane is located at "myAdjustedNear" along the z axis.
782 After taking the zoom and win channels into account, myAdjustedX and
783 myAdjustedY refer to the center of the view on the same plane, and
784 myAdjustedW and myAdjustedH contain the dimensions of the adjusted view.
785 
786 #endif
787 
788 #endif
#define SYSmax(a, b)
Definition: SYS_Math.h:1526
void setLimits(fpreal n, fpreal f)
fpreal getNearClip() const
int getViewWidth() const
fpreal getNearLimit() const
int rotoscopeTracksWindowVals() const
bool doesWindowOverrideNominal() const
void getViewportSize(int &w, int &h) const
static void setDefaultHomingStyleFlag(int style)
GLint GLint GLint GLint GLint GLint GLsizei width
Definition: glew.h:1252
GT_API const UT_StringHolder time
void setApertureOffsets(fpreal h, fpreal v)
GLint left
Definition: glew.h:8008
void setWindow(fpreal x, fpreal y, fpreal w, fpreal h)
SYS_FORCE_INLINE void setT(const UT_Vector3D &t)
int getView2DVersion() const
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
axis getHomeAxis() const
GA_API const UT_StringHolder rot
fpreal getWinX() const
int getBottomMargin() const
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
Definition: glew.h:1252
int h() const
Get width/height dimensions.
Definition: UT_Rect.h:246
void setAperture(fpreal a)
GLdouble l
Definition: glew.h:9122
const GLdouble * v
Definition: glew.h:1391
void setCPlaneHomeRotCallback(GUI_HomeRotCallback callback, void *data)
GLdouble far
Definition: glcorearb.h:142
int getApplyAspectFlag() const
static void setTumbleStyleFlag(int style)
void getLimits(fpreal *n, fpreal *f)
void setView(const UT_DimRect &area)
GLenum GLsizei GLenum GLenum const void * image
Definition: glew.h:4943
void getApertureOffsets(fpreal &h, fpreal &v) const
int initialized() const
int getView3DVersion() const
void setFocalUnitScale(fpreal f)
void setViewport(RE_Render *r, const UT_DimRect &viewarea)
void(* GUI_HomeRotCallback)(UT_Matrix3R &, void *)
fpreal getFarLimit() const
int getOrthoFlag() const
void setScreenWindow(fpreal l, fpreal r, fpreal b, fpreal t)
fpreal getAperture() const
GLdouble GLdouble z
Definition: glew.h:1559
void setFocalLength(fpreal f)
const char * className() const
void setAdjustLimits(GUI_ViewAdjustLimits which)
GLint GLint bottom
Definition: glew.h:8008
fpreal getFocalLength() const
void getWindow(fpreal &x, fpreal &y, fpreal &w, fpreal &h) const
int getViewportHeight() const
void setApplyAspectFlag(int a)
SYS_FORCE_INLINE void setP(const UT_Vector3D &p)
GLclampf f
Definition: glew.h:3499
bool any(const vbool4 &v)
Definition: simd.h:3372
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
void setWindowAffectRotoscope(int v)
fpreal getFocalUnitScale() const
GLenum clamp
Definition: glew.h:2166
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
#define GUI_API
Definition: GUI_API.h:10
void setHomeAxis(axis homeaxis)
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
void setOrthoFlag(int o)
void getViewport(UT_DimRect &area) const
GLfloat GLfloat GLfloat top
Definition: glew.h:15186
GUI_ViewAdjustLimits getAdjustLimits() const
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
void set(int v1, int v2, int v3, int v4)
Set the native rect type values.
Definition: UT_Rect.h:135
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
void setOrthoWidth(fpreal w)
static bool isOrientationZUp()
void
Definition: png.h:1083
void setRotateMatrix(const UT_Matrix3D &mat)
ImageBuf OIIO_API rotate(const ImageBuf &src, float angle, string_view filtername=string_view(), float filterwidth=0.0f, bool recompute_roi=false, ROI roi={}, int nthreads=0)
GLsizei n
Definition: glew.h:4040
GLuint GLsizei GLsizei * length
Definition: glew.h:1825
GLsizei GLsizei GLfloat distance
Definition: glew.h:13640
int getViewHeight() const
void setNominalWindow(fpreal x, fpreal y, fpreal w, fpreal h)
int getViewportWidth() const
int x() const
Get lower-left corner.
Definition: UT_Rect.h:225
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
int w() const
Get width/height dimensions.
Definition: UT_Rect.h:245
GLfloat right
Definition: glew.h:15186
fpreal getZBufferFar() const
fpreal getLastHomeRadius() const
fpreal getWinSizeX() const
static int getScrollStyleFlag()
int getRightMargin() const
UT_Rect< UT_InclusiveRectImpl > UT_InclusiveRect
Integer rectangle class which stores its data as inclusive lower-left to upper-right (x1...
Definition: UT_Rect.h:53
GT_API const UT_StringHolder version
fpreal getWinY() const
IFDmantra py
Definition: HDK_Image.dox:266
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
GLfloat GLfloat p
Definition: glew.h:16321
fpreal getFStop() const
static axis getDefaultHomingStyleFlag()
static int getTumbleStyleFlag()
static void setScrollStyleFlag(int style)
static int getAltKeyViewControlsFlag()
void setFocusDistance(fpreal f)
const UT_Matrix4D & getTransformMatrix()
fpreal64 fpreal
Definition: SYS_Types.h:277
fpreal getFocusDistance() const
static void setAltKeyViewControlsFlag(int style)
void getViewState(gui_View &view_state) const
fpreal getAspectRatio() const
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
bool isDirty() const
static bool isOrientationYUp()
int y() const
Get lower-left corner.
Definition: UT_Rect.h:226
void setCustomHomeRot(UT_Matrix3R &rot)
int getTopMargin() const
SYS_FORCE_INLINE const UT_Vector3D & getT() const
void setViewState(const gui_View &view_state)
void getNominalWindow(fpreal &x, fpreal &y, fpreal &w, fpreal &h) const
void setFrustumScale(fpreal xsc, fpreal ysc)
void setAspectRatio(fpreal a)
UT_InclusiveRect getView() const
const UT_Matrix4D & getProjectionMatrix() const
const UT_Matrix4D & getRotateMatrix() const
SYS_FORCE_INLINE const UT_Vector3D & getP() const
int getViewVersion() const
void setTransformCallback(GUI_TransformCallback callback, void *data)
fpreal getFarClip() const
fpreal getOrthoWidth() const
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER Vec project(const Vec &s, const Vec &t)
Definition: ImathVecAlgo.h:96
const UT_Matrix3R & getCustomHomeRot() const
fpreal getWinSizeY() const
fpreal getZBufferNear() const
void setFStop(fpreal fs)
GLdouble GLdouble t
Definition: glew.h:1398
void getScreenWindow(fpreal &l, fpreal &r, fpreal &b, fpreal &t) const
void(* GUI_TransformCallback)(UT_DMatrix4 &, fpreal time, void *)
UT_InclusiveRect getViewport() const
GA_API const UT_StringHolder area
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
const UT_Matrix4D & getItransformMatrix()
int getLeftMargin() const