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 = 0;
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 
427  { myOrientationMode = o; }
428  static orientation getOrientationMode() { return myOrientationMode; }
429  static bool isOrientationYUp()
430  { return myOrientationMode == Y_UP; }
431  static bool isOrientationZUp()
432  { return myOrientationMode == Z_UP; }
433 
434  // Rotation style:
435  static void setTumbleStyleFlag(int style)
436  { myTumbleStyle = style; }
437  static int getTumbleStyleFlag() { return myTumbleStyle; }
438  static void setAltKeyViewControlsFlag(int style)
439  { myAltKeyViewControls = style; }
440  static int getAltKeyViewControlsFlag() { return myAltKeyViewControls; }
441  static void setScrollStyleFlag(int style)
442  { myScrollStyle = style; }
443  static int getScrollStyleFlag() { return myScrollStyle; }
444  static void setDefaultHomingStyleFlag(int style)
445  { myDefaultHomingStyle = GUI_ViewParameter::axis(style); }
446  static axis getDefaultHomingStyleFlag() { return myDefaultHomingStyle; }
447 
448  // the resulting matrices
449  void setRotateMatrix(const UT_Matrix3D &mat)
450  { myView.myRotateMatrix = mat;
451  myFlag.matrixDirty = 1;
452  myFlag.iMatrixDirty = 1;
453  myFlag.rxyzDirty = 1; }
454  const UT_Matrix4D &getRotateMatrix() const { return myView.myRotateMatrix; }
455 
457  { return myProjectionOverride ? *myProjectionOverride
458  : myView.myProjectionMatrix; }
459  const UT_Matrix4D &getTransformMatrix() { updateTransformMatrix();
460  return myTransformMatrix; }
461  const UT_Matrix4D &getItransformMatrix() { updateItransformMatrix();
462  return myItransformMatrix; }
463 
464  // This sets the transform matrix to the given value, bypassing the
465  // PX, TX, etc. The purpose of this is to get accurate camera transforms
466  // you can first set all the PX, Rotate, etc, according to the cracked
467  // values, and then do a forceTransformMatrix to ensure the user sees
468  // the most accurate possible matrix.
469  void forceTransformMatrix(const UT_DMatrix4 &mat);
470  void getTransformMatrix(UT_DMatrix4 &mat, fpreal time);
472  void *data)
473  {
474  myTransformCallback = callback;
475  myTransformCallbackData = data;
476  }
477 
478  // Class I/O methods. They return 0 if successful, -1 if not.
479  // `for_view_copy` is only for temporarily transferring one view parms to
480  // another.
481  int save(std::ostream &os,
482  char separator = '\n',
483  bool for_view_copy = false) const;
484  bool load(UT_IStream &is);
485  bool oldLoad(UT_IStream &is, int version);
486 
487  // inline for non-virtual class
488  const char *className() const { return "GUI_ViewParameter"; }
489 
490  fpreal getLastHomeRadius() const { return myLastHomeRadius; }
491 
492  void setHomeAxis(axis homeaxis)
493  { myHomeAxis = homeaxis; myFlag.rxyzDirty = 1; }
494  axis getHomeAxis() const { return myHomeAxis; }
495  void setCustomHomeRot(UT_Matrix3R &rot) { myCustomHomeRot = rot; }
496  const UT_Matrix3R &getCustomHomeRot() const { return myCustomHomeRot; }
497 
498  // Set a callback to get the home rotation for the construction plane
499  // (axis::CPLANE), to which this class does not have direct access.
501  void *data)
502  {
503  myCPlaneHomeRotCallback = callback;
504  myCPlaneHomeRotCallbackData = data;
505  }
506 
507 
508  void setOrthoWidth(fpreal w) { myView.myOrthoWidth = w; }
509  fpreal getOrthoWidth() const { return myView.myOrthoWidth; }
510 
511  void setFocalLength(fpreal f) { myView.myFocalLength = f; }
512  fpreal getFocalLength() const { return myView.myFocalLength; }
513 
514  void setFocusDistance(fpreal f) { myView.myFocusDistance = f; }
515  fpreal getFocusDistance() const { return myView.myFocusDistance; }
516 
517  void setAperture(fpreal a) { myView.myAperture = a; }
518  fpreal getAperture() const { return myView.myAperture; }
519 
520  void setFStop(fpreal fs) { myView.myFStop = fs; }
521  fpreal getFStop() const { return myView.myFStop; }
522 
523  fpreal getNearLimit() const { return myView.myNearLimit; }
524  fpreal getFarLimit() const { return myView.myFarLimit; }
525 
526  fpreal getZBufferNear() const { return myZBufferNear; }
527  fpreal getZBufferFar() const { return myZBufferFar; }
528 
529  // viewport clearing
531 
532  // fog
533  int myFog;
535  float myFogNear;
536  float myFogFar;
537  float myFogColor[3];
538  float myFogAlpha;
539 
540  // used for rotoscoping only
542 
543  // container for all view home information
544  class gui_View
545  {
546  public:
548  : myT(0.0, 0.0, 0.1),
549  myP(0.0, 0.0, 0.0),
550  myRotateMatrix(1.0),
551  myProjectionMatrix(1.0),
552  myWinX(0.0),
553  myWinY(0.0),
554  myWinW(1.0),
555  myWinH(1.0),
556  myOrthoWidth(1.0),
557  myFocalLength(50.0),
558  myFocusDistance(5.0),
559  myAperture(41.4214),
560  myFStop(5.6),
561  myNearLimit(0.1),
562  myFarLimit(10000.0)
563  {}
564 
567 
570 
571  // window (zooming)
576 
577  // projection information
578  // ortho specific
580 
581  // perspective specific sSee diagram below)
585  fpreal myFStop; // for dof.
586 
589  };
590 
591  // methods to quickly stash and recall the view state.
592  void getViewState(gui_View &view_state) const
593  { view_state = myView; }
594  void setViewState(const gui_View &view_state)
595  {
596  myView = view_state;
597  myFlag.matrixDirty=1;
598  myFlag.iMatrixDirty=1;
599  myFlag.rxyzDirty=1;
600  updateWindowOverridesNominal();
601  }
602 
603  // clipping
604 private:
605  fpreal myZBufferNear;
606  fpreal myZBufferFar;
607  GUI_ViewAdjustLimits myAdjustLimits;
608 
609  // aspect ratio
610  fpreal myViewAspectRatio;
611 public:
612  fpreal myPixelAspect; // depends on output device
613 
614 // projection information (see docs below)
625 
627 
628 private:
629  void updateTransformMatrix();
630  void updateItransformMatrix();
631  void updateRXYZValues();
632  fpreal getDistanceToBoxCenter(int clamp = 0) const;
633 
634  void internalScroll(fpreal dx, fpreal dy,
635  const UT_InclusiveRect &viewport,
636  bool decouple_axes,
637  const UT_Vector3R *locked_pos);
638  void internalZoom(fpreal dx, GUI_ZoomItem item, int width);
639  void internalOffsetZoom(fpreal sx, fpreal sy, fpreal dx,
640  GUI_ZoomItem item,
641  const UT_InclusiveRect &viewport);
642  void internalScreenScroll(fpreal dx, fpreal dy,
643  const UT_InclusiveRect &viewport);
644 
645  void getFrustumClip(fpreal &l, fpreal &r, fpreal &t, fpreal &b,
646  fpreal &n, fpreal &f, bool adjust_zrange);
647  bool computeWorldLockedScrollAccel(fpreal dx, fpreal dy,
648  const UT_Vector3R &locked_pos,
649  fpreal &accelerationx,
650  fpreal &accelerationy);
651  fpreal computeZoomDelta(fpreal dx,
652  bool precise_zoom,
653  bool smooth_deltas);
654 
655  void updateWindowOverridesNominal()
656  {
657  myWindowOverridesNominal =
658  (myView.myWinX != myNominalWinX ||
659  myView.myWinY != myNominalWinY ||
660  myView.myWinW != myNominalWinW ||
661  myView.myWinH != myNominalWinH);
662  }
663 
664  GUI_ViewFlag myFlag;
665 
666 // transform information
667 
668  gui_View myView;
669  fpreal myDx, myDy;
670  static orientation myOrientationMode;
671  static int myTumbleStyle;
672  static int myAltKeyViewControls;
673  static int myScrollStyle;
674  static axis myDefaultHomingStyle;
675 
676  fpreal myRx, myRy, myRz; // Used by euler method. In degrees
677 
678  // always call updateTransformMatrix before using myTransformMatrix.
679  UT_Matrix4D myTransformMatrix; // this one is generated from the above
680  UT_Matrix4D myItransformMatrix; // inverse of myTransformMatrix;
681 
682  GUI_TransformCallback myTransformCallback;
683  void *myTransformCallbackData;
684 
685 // home information to be used in scaling of view transformation
686  fpreal myLastHomeDistance;
687  fpreal myLastHomePixelWidthOBSOLETE;
688  fpreal myLastHomeAdjustedBoxWidth;
689  fpreal myLastHomeOrthoWidth;
690  fpreal myLastHomeRadius;
691 
692  // myLastHomeAdjustedBoxWidth supercedes myLastHomePixelWidth, but to load
693  // view transforms from old hip files without screwed up scrolling, we may
694  // need to use the obsolete quantity until the next manual home operation.
695  bool myObsoleteScrollIsActive;
696 
697  axis myHomeAxis;
698  UT_Matrix3R myCustomHomeRot;
699 
700  GUI_HomeRotCallback myCPlaneHomeRotCallback;
701  void *myCPlaneHomeRotCallbackData;
702 
703  // A collection of data needed for calculating the appropriate changes to
704  // the view transform to perform view operations under continuous export
705  // of view changes to a camera.
706  class ContinuousExportCache
707  {
708  public:
709  ContinuousExportCache() {}
710 
711  UT_Matrix4D myRotateMatrix;
712  UT_Matrix4D myTransformMatrix;
713  UT_Matrix4D myItransformMatrix;
714  fpreal myAdjustedNear;
715  fpreal myAdjustedX;
716  fpreal myAdjustedY;
717  fpreal myTotalScrollX;
718  fpreal myTotalScrollY;
719  };
720 
721  typedef ContinuousExportCache ViewOpCache;
722 
723  ViewOpCache myContinuousExportCache;
724  bool myContinuousExportInProgress;
725 
726  // The nominal window (zooming) for this view. The myView.myWin* members
727  // represent the window used for the current view, but when they are used
728  // to override the camera's screen window, we need to know that this is
729  // the case and what nominal window values to use for properly displaying
730  // overlays like the safe area or field guide.
731  bool myWindowOverridesNominal;
732  fpreal myNominalWinX;
733  fpreal myNominalWinY;
734  fpreal myNominalWinW;
735  fpreal myNominalWinH;
736 
737  // These might be needed for other guys.
738  int myViewportLeft, myViewportRight;
739  int myViewportBottom, myViewportTop;
740 
741  // The view is a subregion of the viewport that represents the current
742  // "camera" view. Aspect ratio bars are used to dim the parts of the
743  // viewport not in this view. The window coordinates are relative to
744  // this view, not the viewport.
745  int myViewLeft, myViewRight;
746  int myViewBottom, myViewTop;
747 
748  int myVersion;
749 
750  UT_Matrix4D *myProjectionOverride;
751 };
752 
753 
754 #ifdef __DOCUMENTATION__
755 
756 FOV can be computed from aperture and focal length.
757 
758  <--aperture--->
759  | |
760  | |
761  +------+------+-----------
762  \ | / ^
763  \ | / |
764  \_--+--_/ Focal
765 Unzoomed \ | / Length
766  FOV --> \ | / |
767  \|/ v
768  +------------------
769 
770 myFullW and myFullH are the dimensions of the plane onto which the
771 image is projected before any adjustments for zoom or window parms.
772 the plane is located at "myAdjustedNear" along the z axis.
773 After taking the zoom and win channels into account, myAdjustedX and
774 myAdjustedY refer to the center of the view on the same plane, and
775 myAdjustedW and myAdjustedH contain the dimensions of the adjusted view.
776 
777 #endif
778 
779 #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
static void setOrientationMode(orientation o)
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
static orientation getOrientationMode()
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