12 #ifndef ROOT_TGLCamera
13 #define ROOT_TGLCamera
43 class TGLCamera :
public TObject
61 TGLBoundingBox fPreviousInterestBox;
62 TGLBoundingBox fInterestFrustum;
63 TGLBoundingBox fInterestFrustumAsBox;
65 static const Double_t fgInterestBoxExpansion;
68 TGLBoundingBox Frustum(Bool_t asBox = kTRUE)
const;
71 TGLCamera(
const TGLCamera &);
72 TGLCamera & operator=(
const TGLCamera &);
78 Bool_t fExternalCenter;
81 TGLVector3 fExtCenter;
82 TGLVector3 fDefCenter;
86 mutable Double_t fNearClip;
87 mutable Double_t fFarClip;
90 Double_t fDollyDefault;
91 Double_t fDollyDistance;
92 Float_t fVAxisMinAngle;
95 mutable Bool_t fCacheDirty;
96 mutable UInt_t fTimeStamp;
97 mutable TGLMatrix fLastNoPickProjM;
98 mutable TGLMatrix fProjM;
99 mutable TGLMatrix fModVM;
100 mutable TGLMatrix fClipM;
101 mutable TGLPlane fFrustumPlanes[kPlanesPerFrustum];
105 TGLBoundingBox fInterestBox;
106 mutable Double_t fLargestSeen;
110 void UpdateCache()
const;
112 static UInt_t fgDollyDeltaSens;
115 TGLCamera(
const TGLVector3 & hAxis,
const TGLVector3 & vAxis);
116 virtual ~TGLCamera();
118 virtual Bool_t IsOrthographic()
const {
return kFALSE; }
119 virtual Bool_t IsPerspective()
const {
return kFALSE; }
121 const TGLMatrix& RefModelViewMatrix()
const {
return fModVM; }
123 Bool_t IsCacheDirty()
const {
return fCacheDirty; }
124 void IncTimeStamp() { fCacheDirty = kTRUE; ++fTimeStamp; }
125 UInt_t TimeStamp()
const {
return fTimeStamp; }
127 void SetViewport(
const TGLRect & viewport);
128 TGLRect& RefViewport() {
return fViewport; }
129 const TGLRect& RefViewport()
const {
return fViewport; }
132 virtual void Setup(
const TGLBoundingBox & box, Bool_t reset=kTRUE) = 0;
133 virtual void Reset() = 0;
135 virtual Bool_t Dolly(Int_t delta, Bool_t mod1, Bool_t mod2);
136 virtual Bool_t Zoom (Int_t delta, Bool_t mod1, Bool_t mod2) = 0;
137 virtual Bool_t Truck(Double_t xDelta, Double_t yDelta);
138 virtual Bool_t Truck(Int_t xDelta, Int_t yDelta, Bool_t mod1, Bool_t mod2) = 0;
139 virtual Bool_t Rotate(Int_t xDelta, Int_t yDelta, Bool_t mod1, Bool_t mod2);
140 virtual Bool_t RotateRad(Double_t hRotate, Double_t vRotate);
141 virtual Bool_t RotateArcBall(Int_t xDelta, Int_t yDelta, Bool_t mod1, Bool_t mod2);
142 virtual Bool_t RotateArcBallRad(Double_t hRotate, Double_t vRotate);
144 virtual void Apply(
const TGLBoundingBox & sceneBox,
const TGLRect * pickRect = 0)
const = 0;
146 Bool_t AdjustAndClampVal(Double_t & val, Double_t min, Double_t max,
147 Int_t screenShift, Int_t screenShiftRange,
148 Bool_t mod1, Bool_t mod2)
const;
149 Double_t AdjustDelta(Double_t screenShift, Double_t deltaFactor,
150 Bool_t mod1, Bool_t mod2)
const;
152 void SetExternalCenter(Bool_t x);
153 Bool_t GetExternalCenter(){
return fExternalCenter; }
155 void SetCenterVec(Double_t x, Double_t y, Double_t z);
156 void SetCenterVecWarp(Double_t x, Double_t y, Double_t z);
157 Double_t* GetCenterVec() {
return fCenter->Arr(); }
159 void SetFixDefCenter(Bool_t x) { fFixDefCenter = x; }
160 void SetFixDefCenterVec(Double_t x, Double_t y, Double_t z) { fFDCenter.Set(x, y, z); }
161 Double_t* GetFixDefCenterVec() {
return fFDCenter.Arr(); }
163 Double_t GetNearClip()
const {
return fNearClip; }
164 Double_t GetFarClip()
const {
return fFarClip; }
166 const TGLMatrix& GetCamBase()
const {
return fCamBase; }
167 const TGLMatrix& GetCamTrans()
const {
return fCamTrans; }
169 TGLMatrix& RefCamBase() {
return fCamBase; }
170 TGLMatrix& RefCamTrans() {
return fCamTrans; }
172 Double_t GetTheta()
const;
174 TGLMatrix& RefLastNoPickProjM()
const {
return fLastNoPickProjM; }
177 TGLVertex3 EyePoint()
const;
178 TGLVector3 EyeDirection()
const;
179 TGLVertex3 FrustumCenter()
const;
180 const TGLPlane & FrustumPlane(EFrustumPlane plane)
const;
184 Rgl::EOverlap FrustumOverlap (
const TGLBoundingBox & box)
const;
185 Rgl::EOverlap ViewportOverlap(
const TGLBoundingBox & box)
const;
186 TGLRect ViewportRect (
const TGLBoundingBox & box, TGLBoundingBox::EFace face)
const;
187 TGLRect ViewportRect (
const TGLBoundingBox & box,
const TGLBoundingBox::EFace * face = 0)
const;
188 TGLVertex3 WorldToViewport(
const TGLVertex3 & worldVertex, TGLMatrix* modviewMat=0)
const;
189 TGLVector3 WorldDeltaToViewport(
const TGLVertex3 & worldRef,
const TGLVector3 & worldDelta)
const;
190 TGLVertex3 ViewportToWorld(
const TGLVertex3 & viewportVertex, TGLMatrix* modviewMat=0)
const;
191 TGLLine3 ViewportToWorld(Double_t viewportX, Double_t viewportY)
const;
192 TGLLine3 ViewportToWorld(
const TPoint & viewport)
const;
193 TGLVector3 ViewportDeltaToWorld(
const TGLVertex3 & worldRef, Double_t viewportXDelta, Double_t viewportYDelta, TGLMatrix* modviewMat=0)
const;
194 std::pair<Bool_t, TGLVertex3> ViewportPlaneIntersection(Double_t viewportX, Double_t viewportY,
const TGLPlane & worldPlane)
const;
195 std::pair<Bool_t, TGLVertex3> ViewportPlaneIntersection(
const TPoint & viewport,
const TGLPlane & worldPlane)
const;
198 void WindowToViewport(Int_t & , Int_t & y)
const { y = fViewport.Height() - y; }
199 void WindowToViewport(TPoint & point)
const { point.SetY(fViewport.Height() - point.GetY()); }
200 void WindowToViewport(TGLRect & rect)
const { rect.Y() = fViewport.Height() - rect.Y(); }
201 void WindowToViewport(TGLVertex3 & vertex)
const { vertex.Y() = fViewport.Height() - vertex.Y(); }
203 Float_t GetVAxisMinAngle(){
return fVAxisMinAngle;}
204 void SetVAxisMinAngle(Float_t x){fVAxisMinAngle = x;}
206 virtual void Configure(Double_t zoom, Double_t dolly, Double_t center[3],
207 Double_t hRotate, Double_t vRotate) = 0;
209 Bool_t OfInterest(
const TGLBoundingBox & box, Bool_t ignoreSize)
const;
210 Bool_t UpdateInterest(Bool_t force);
211 void ResetInterest();
214 void DrawDebugAids()
const;
216 ClassDef(TGLCamera,1);
219 inline const TGLPlane & TGLCamera::FrustumPlane(EFrustumPlane plane)
const
223 Error(
"TGLCamera::FrustumBox()",
"cache dirty");
225 return fFrustumPlanes[plane];
229 #endif // ROOT_TGLCamera