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),
73 fNearClip(0), fFarClip(0),
74 fDollyDefault(1.0), fDollyDistance(1.0),
75 fVAxisMinAngle(0.01f),
78 fProjM(), fModVM(), fClipM(),
79 fViewport(0,0,100,100),
112 glGetDoublev(GL_PROJECTION_MATRIX,
fProjM.
Arr());
113 glGetDoublev(GL_MODELVIEW_MATRIX,
fModVM.
Arr());
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;
355 Error(
"TGLCamera::ViewportSize()",
"cache dirty - must call Apply()");
370 vertexCount =
box.FaceVertices(*face).size();
372 vertexCount =
box.NumVertices();
375 for (
UInt_t i = 0; i < vertexCount; i++)
382 &winX, &winY, &winZ);
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());
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, TGLLine3 > Intersection(const TGLPlane &p1, const TGLPlane &p2)
Find 3D line interestion of this plane with 'other'.
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
TGLVector3 Extents() const
Double_t Diagonal() const
void SetEmpty()
Set bounding box empty - all vertices at (0,0,0)
void Scale(Double_t factor)
Isotropically scale bounding box along it's LOCAL axes, preserving center.
Rgl::EOverlap Overlap(const TGLPlane &plane) const
Find overlap (Inside, Outside, Partial) of plane c.f. bounding box.
void Draw(Bool_t solid=kFALSE) const
Draw the bounding box as either wireframe (default) of solid using current GL color.
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Rgl::EOverlap FrustumOverlap(const TGLBoundingBox &box) const
Calculate overlap (kInside, kOutside, kPartial) of box with camera frustum Camera must have valid fru...
static UInt_t fgDollyDeltaSens
TGLVector3 EyeDirection() const
Extract the camera eye direction (vector), running from EyePoint() Camera must have valid frustum cac...
virtual ~TGLCamera()
Base camera destructor.
virtual Bool_t RotateRad(Double_t hRotate, Double_t vRotate)
Rotate camera around center.
TGLVertex3 FrustumCenter() const
Find the center of the camera frustum from intersection of planes This method will work even with par...
TGLCamera()
Default base camera constructor.
void ResetInterest()
Clear out the existing interest box.
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'.
TGLBoundingBox Frustum(Bool_t asBox=kTRUE) const
expansion c.f. aligned current frustum box
virtual Bool_t RotateArcBallRad(Double_t hRotate, Double_t vRotate)
Rotate camera around center.
TGLMatrix fProjM
no-pick projection matrix (cached)
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 Bool_t Truck(Double_t xDelta, Double_t yDelta)
Truck the camera - 'move camera parallel to film plane'.
TGLVertex3 ViewportToWorld(const TGLVertex3 &viewportVertex, TGLMatrix *modviewMat=0) const
Convert a '3D' viewport vertex to 3D world one.
Rgl::EOverlap ViewportOverlap(const TGLBoundingBox &box) const
Calculate overlap (kInside, kOutside, kPartial) of box projection onto viewport (as rect) against the...
TGLBoundingBox fInterestBox
viewport (GL coords - origin bottom left)
TGLBoundingBox fInterestFrustumAsBox
frustum basis of current interest box - NOT a true BB! (DEBUG)
TGLRect ViewportRect(const TGLBoundingBox &box, TGLBoundingBox::EFace face) const
Calculate viewport rectangle which just contains projection of single 'face' of world frame bounding ...
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().
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.
TGLRect fViewport
frustum planes (cached)
TGLVector3 WorldDeltaToViewport(const TGLVertex3 &worldRef, const TGLVector3 &worldDelta) const
Convert a 3D vector worldDelta (shift) about vertex worldRef to a viewport (screen) '3D' vector.
TGLMatrix fModVM
projection matrix (cached)
TGLPlane fFrustumPlanes[kPlanesPerFrustum]
object space clip matrix (cached)
Double_t GetTheta() const
Get angle between camera up axis.
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...
Bool_t UpdateInterest(Bool_t force)
Update the internal interest box (fInterestBox) of the camera.
void DrawDebugAids() const
Draw out some debugging aids for the camera:
TGLBoundingBox fInterestFrustum
previous interest box (DEBUG)
void UpdateCache() const
largest box diagonal seen in OfInterest() - used when bootstrapping interest box
TGLMatrix fClipM
modelView matrix (cached)
TGLVertex3 WorldToViewport(const TGLVertex3 &worldVertex, TGLMatrix *modviewMat=0) const
Convert a 3D world vertex to '3D' viewport (screen) one.
void SetExternalCenter(Bool_t x)
Set camera center diffrent than scene center, if enable is kTRUE.
void SetCenterVec(Double_t x, Double_t y, Double_t z)
Set camera center vector.
void SetViewport(const TGLRect &viewport)
Set viewport extents from passed 'viewport' rect.
TGLBoundingBox fPreviousInterestBox
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().
Double_t fLargestSeen
the interest box - created in UpdateInterest()
static const Double_t fgInterestBoxExpansion
frustum basis (as box) of current interest box (DEBUG)
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.
TGLVertex3 EyePoint() const
Return the camera eye point (vertex) in world space Camera must have valid frustum cache - call Apply...
Double_t AdjustDelta(Double_t screenShift, Double_t deltaFactor, Bool_t mod1, Bool_t mod2) const
Adjust a passed screen value and apply modifiers.
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...
3D space, fixed length, line class, with direction / length 'vector', passing through point 'vertex'.
16 component (4x4) transform matrix - column MAJOR as per GL.
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'.
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame.
Double_t Invert()
Invert the matrix, returns determinant.
void MoveLF(Int_t ai, Double_t amount)
Translate in local frame.
void RotatePF(Int_t i1, Int_t i2, Double_t amount)
Rotate in parent frame. Does optimised version of MultLeft.
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
TGLVector3 GetBaseVec(Int_t b) const
const Double_t * CArr() const
TGLVector3 GetTranslation() const
Return the translation component of matrix.
void RotateIP(TGLVector3 &v) const
Rotate vector in-place. Translation is not applied.
3D plane class - of format Ax + By + Cz + D = 0
void Set(const TGLPlane &other)
Assign from other.
TGLVertex3 NearestOn(const TGLVertex3 &point) const
Return nearest point on plane.
Viewport (pixel base) 2D rectangle class.
const Int_t * CArr() const
Rgl::EOverlap Overlap(const TGLRect &other) const
Return overlap result (kInside, kOutside, kPartial) of this rect with 'other'.
void Expand(Int_t x, Int_t y)
Expand the rect to encompass point (x,y)
void SetCorner(Int_t x, Int_t y)
3 component (x/y/z) vector class.
3 component (x/y/z) vertex class.
void Set(Double_t x, Double_t y, Double_t z)
void Shift(TGLVector3 &shift)
Offset a vertex by vector 'shift'.
const Double_t * CArr() const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
double Pi()
Mathematical constants.
Double_t ATan2(Double_t y, Double_t x)
constexpr Double_t TwoPi()