49 fNearClip(0), fFarClip(0),
50 fDollyDefault(1.0), fDollyDistance(1.0),
51 fVAxisMinAngle(0.01f),
54 fProjM(), fModVM(), fClipM(),
55 fViewport(0,0,100,100),
112 glGetDoublev(GL_PROJECTION_MATRIX,
fProjM.
Arr());
113 glGetDoublev(GL_MODELVIEW_MATRIX,
fModVM.
Arr());
122 fClipM[ 7] - fClipM[ 4],
123 fClipM[11] - fClipM[ 8],
124 fClipM[15] - fClipM[12]);
128 fClipM[ 7] + fClipM[ 4],
129 fClipM[11] + fClipM[ 8],
130 fClipM[15] + fClipM[12]);
134 fClipM[ 7] + fClipM[ 5],
135 fClipM[11] + fClipM[ 9],
136 fClipM[15] + fClipM[13]);
141 fClipM[ 7] - fClipM[ 5],
142 fClipM[11] - fClipM[ 9],
143 fClipM[15] - fClipM[13]);
147 fClipM[ 7] - fClipM[ 6],
148 fClipM[11] - fClipM[10],
149 fClipM[15] - fClipM[14]);
153 fClipM[ 7] + fClipM[ 6],
154 fClipM[11] + fClipM[10],
155 fClipM[15] + fClipM[14]);
176 Error(
"TGLCamera::FrustumBox()",
"cache dirty - must call Apply()");
222 Error(
"TGLPerspectiveCamera::FrustumBox()",
"cache dirty - must call Apply()");
239 Error(
"TGLCamera::FrustumBox()",
"cache dirty - must call Apply()");
254 Error(
"TGLCamera::FrustumCenter()",
"cache dirty - must call Apply()");
263 if (!nearBottomLeft.first || !farTopRight.first) {
264 Error(
"TGLCamera::FrustumCenter()",
"frustum planes invalid");
267 return nearBottomLeft.second + (farTopRight.second - nearBottomLeft.second)/2.0;
278 Error(
"TGLCamera::FrustumOverlap()",
"cache dirty - must call Apply()");
287 Int_t planesInside = 0;
307 if (planesInside == kPlanesPerFrustum) {
355 Error(
"TGLCamera::ViewportSize()",
"cache dirty - must call Apply()");
375 for (
UInt_t i = 0; i < vertexCount; i++)
380 gluProject(vertex.
X(), vertex.
Y(), vertex.
Z(),
382 &winX, &winY, &winZ);
385 screenRect.
SetCorner(static_cast<Int_t>(winX),static_cast<Int_t>(winY));
387 screenRect.
Expand(static_cast<Int_t>(winX), static_cast<Int_t>(winY));
407 Error(
"TGLCamera::WorldToViewport()",
"cache dirty - must call Apply()");
410 gluProject(worldVertex[0], worldVertex[1], worldVertex[2],
413 &viewportVertex[0], &viewportVertex[1], &viewportVertex[2]);
414 return viewportVertex;
430 Error(
"TGLCamera::WorldToViewport()",
"cache dirty - must call Apply()");
457 Error(
"TGLCamera::ViewportToWorld()",
"cache dirty - must call Apply()");
460 gluUnProject(viewportVertex[0], viewportVertex[1], viewportVertex[2],
463 &worldVertex[0], &worldVertex[1], &worldVertex[2]);
480 Error(
"TGLCamera::Viewport2DToWorldLine()",
"cache dirty - must call Apply()");
485 return TGLLine3(nearClipWorld, farClipWorld - nearClipWorld);
550 Error(
"TGLCamera::ViewportDeltaToWorld()",
"cache dirty - must call Apply()");
553 winVertex.
Shift(viewportXDelta, viewportYDelta, 0.0);
656 newInterestBox.
Scale(minBoxLength/frustumExtents[0], minBoxLength/frustumExtents[1], minBoxLength/frustumExtents[2]);
679 Error(
"TGLCamera::UpdateInterest",
"update interest box does not contain frustum");
682 exposedUpdate =
kTRUE;
689 Info(
"TGLCamera::UpdateInterest",
"changed - volume ratio %f", volRatio );
693 return exposedUpdate;
726 if (screenShift == 0) {
751 else if (val > max) {
755 return val != oldVal;
765 if (screenShift == 0)
782 return sens * deltaFactor * screenShift;
796 glColor3d(1.0,0.0,0.0);
800 glColor3d(1.0,0.65,0.15);
804 glColor3d(0.0,0.0,1.0);
815 glColor3d(1.0,1.0,1.0);
817 glVertex3dv(start.
CArr());
818 glVertex3dv(end.
CArr());
839 fCamTrans = binv * bt;
857 fCamTrans = binv * bt;
896 if (xDelta != 0 || yDelta != 0)
929 using namespace TMath;
936 else if (d < -1) d = -1;
941 M[0] = M[5] = M[10] = 1;
942 M[1] = M[2] = M[4] = M[6] = M[8] = M[9] = 0;
1003 using namespace TMath;
std::pair< Bool_t, TGLVertex3 > ViewportPlaneIntersection(Double_t viewportX, Double_t viewportY, const TGLPlane &worldPlane) const
Find the intersection of projection of supplied viewport point (a 3D world line - see ViewportToWorld...
TGLBoundingBox fInterestFrustum
previous interest box (DEBUG)
TGLMatrix fModVM
projection matrix (cached)
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
TGLVector3 Extents() const
TGLBoundingBox fInterestFrustumAsBox
frustum basis of current interest box - NOT a true BB! (DEBUG)
const TGLVertex3 & Vertex(UInt_t index) const
Double_t Invert()
Invert the matrix, returns determinant.
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
constexpr Double_t TwoPi()
16 component (4x4) transform matrix - column MAJOR as per GL.
void Expand(Int_t x, Int_t y)
Expand the rect to encompass point (x,y)
Int_t NumVertices() const
Double_t fFarClip
last applied near-clip
TGLVertex3 NearestOn(const TGLVertex3 &point) const
Return nearest point on plane.
virtual Bool_t RotateRad(Double_t hRotate, Double_t vRotate)
Rotate camera around center.
void UpdateCache() const
largest box diagonal seen in OfInterest() - used when bootstrapping interest box
Bool_t OfInterest(const TGLBoundingBox &box, Bool_t ignoreSize) const
Calculate if the an object defined by world frame bounding box is 'of interest' to the camera...
virtual Bool_t RotateArcBall(Int_t xDelta, Int_t yDelta, Bool_t mod1, Bool_t mod2)
Rotate the camera round view volume center established in Setup().
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Double_t fLargestSeen
the interest box - created in UpdateInterest()
Double_t fDollyDefault
last applied far-clip
void Set(Double_t x, Double_t y, Double_t z)
TGLCamera()
Default base camera constructor.
TGLVertex3 ViewportToWorld(const TGLVertex3 &viewportVertex, TGLMatrix *modviewMat=0) const
Convert a '3D' viewport vertex to 3D world one.
void RotateIP(TGLVector3 &v) const
Rotate vector in-place. Translation is not applied.
TGLRect ViewportRect(const TGLBoundingBox &box, TGLBoundingBox::EFace face) const
Calculate viewport rectangle which just contains projection of single 'face' of world frame bounding ...
void Set(const TGLVertex3 &origin, const TGLVector3 &zAxis, const TGLVector3 &xAxis=0)
Set matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'...
TGLBoundingBox fInterestBox
viewport (GL coords - origin bottom left)
3 component (x/y/z) vertex class.
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame.
TGLRect fViewport
frustum planes (cached)
Rgl::EOverlap Overlap(const TGLRect &other) const
Return overlap result (kInside, kOutside, kPartial) of this rect with 'other'.
void RotatePF(Int_t i1, Int_t i2, Double_t amount)
Rotate in parent frame. Does optimised version of MultLeft.
Viewport (pixel base) 2D rectangle class.
virtual Bool_t Rotate(Int_t xDelta, Int_t yDelta, Bool_t mod1, Bool_t mod2)
Rotate the camera round view volume center established in Setup().
3 component (x/y/z) vector class.
Double_t ATan2(Double_t, Double_t)
TGLBoundingBox Frustum(Bool_t asBox=kTRUE) const
expansion c.f. aligned current frustum box
void SetCenterVecWarp(Double_t x, Double_t y, Double_t z)
Set camera center vector and do not keep the same combined camera transformation matrix.
Double_t Diagonal() const
TGLVector3 ViewportDeltaToWorld(const TGLVertex3 &worldRef, Double_t viewportXDelta, Double_t viewportYDelta, TGLMatrix *modviewMat=0) const
Apply a 2D viewport delta (shift) to the projection of worldRef onto viewport, returning the resultan...
TGLPlane fFrustumPlanes[kPlanesPerFrustum]
object space clip matrix (cached)
TGLVector3 GetTranslation() const
Return the translation component of matrix.
TGLMatrix fClipM
modelView matrix (cached)
double Pi()
Mathematical constants.
TGLVertex3 WorldToViewport(const TGLVertex3 &worldVertex, TGLMatrix *modviewMat=0) const
Convert a 3D world vertex to '3D' viewport (screen) one.
const Double_t * CArr() const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void SetExternalCenter(Bool_t x)
Set camera center diffrent than scene center, if enable is kTRUE.
virtual Bool_t Truck(Double_t xDelta, Double_t yDelta)
Truck the camera - 'move camera parallel to film plane'.
3D space, fixed length, line class, with direction / length 'vector', passing through point 'vertex'...
Bool_t AdjustAndClampVal(Double_t &val, Double_t min, Double_t max, Int_t screenShift, Int_t screenShiftRange, Bool_t mod1, Bool_t mod2) const
Adjust a passed REFERENCE value 'val', based on screenShift delta.
virtual ~TGLCamera()
Base camera destructor.
Double_t AdjustDelta(Double_t screenShift, Double_t deltaFactor, Bool_t mod1, Bool_t mod2) const
Adjust a passed screen value and apply modifiers.
void Scale(Double_t factor)
Isotropically scale bounding box along it's LOCAL axes, preserving center.
void SetCenterVec(Double_t x, Double_t y, Double_t z)
Set camera center vector.
Double_t fNearClip
current camera center
TGLBoundingBox fPreviousInterestBox
void SetCorner(Int_t x, Int_t y)
void ResetInterest()
Clear out the existing interest box.
TGLVector3 WorldDeltaToViewport(const TGLVertex3 &worldRef, const TGLVector3 &worldDelta) const
Convert a 3D vector worldDelta (shift) about vertex worldRef to a viewport (screen) '3D' vector...
void Draw(Bool_t solid=kFALSE) const
Draw the bounding box as either wireframe (default) of solid using current GL color.
void SetEmpty()
Set bounding box empty - all vertices at (0,0,0)
static UInt_t fgDollyDeltaSens
TGLVertex3 FrustumCenter() const
Find the center of the camera frustum from intersection of planes This method will work even with par...
Bool_t UpdateInterest(Bool_t force)
Update the internal interest box (fInterestBox) of the camera.
virtual Bool_t Dolly(Int_t delta, Bool_t mod1, Bool_t mod2)
Dolly the camera - 'move camera along eye line, retaining lens focal length'.
TGLVertex3 EyePoint() const
Return the camera eye point (vertex) in world space Camera must have valid frustum cache - call Apply...
Rgl::EOverlap FrustumOverlap(const TGLBoundingBox &box) const
Calculate overlap (kInside, kOutside, kPartial) of box with camera frustum Camera must have valid fru...
Concrete class describing an orientated (free) or axis aligned box of 8 vertices. ...
you should not use this method at all Int_t Int_t z
const std::vector< UInt_t > & FaceVertices(EFace face) const
return a vector of face vertices y | | |________x / 3----—2 / /| /| z 7----—6 | | 0--—|-1 |/ |/ 4-...
const Double_t * CArr() const
TGLMatrix fProjM
no-pick projection matrix (cached)
Double_t GetTheta() const
Get angle between camera up axis.
UInt_t fTimeStamp
cached items dirty?
Rgl::EOverlap Overlap(const TGLPlane &plane) const
Find overlap (Inside, Outside, Partial) of plane c.f. bounding box.
void Shift(TGLVector3 &shift)
Offset a vertex by vector 'shift'.
void SetViewport(const TGLRect &viewport)
Set viewport extents from passed 'viewport' rect.
3D plane class - of format Ax + By + Cz + D = 0
Rgl::EOverlap ViewportOverlap(const TGLBoundingBox &box) const
Calculate overlap (kInside, kOutside, kPartial) of box projection onto viewport (as rect) against the...
static const Double_t fgInterestBoxExpansion
frustum basis (as box) of current interest box (DEBUG)
void MoveLF(Int_t ai, Double_t amount)
Translate in local frame.
TGLVector3 GetBaseVec(Int_t b) const
void Set(const TGLPlane &other)
Assign from other.
const Int_t * CArr() const
virtual Bool_t RotateArcBallRad(Double_t hRotate, Double_t vRotate)
Rotate camera around center.
TGLVector3 EyeDirection() const
Extract the camera eye direction (vector), running from EyePoint() Camera must have valid frustum cac...
void DrawDebugAids() const
Draw out some debugging aids for the camera:
std::pair< Bool_t, TGLLine3 > Intersection(const TGLPlane &p1, const TGLPlane &p2)
Find 3D line interestion of this plane with 'other'.