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