myAxialScale (1.0, 1.0, 1.0),
myProjType (Projection_Orthographic),
myFOVy (45.0),
+ myFOVyTan (Tan (DTR_HALF * 45.0)),
myZNear (DEFAULT_ZNEAR),
myZFar (DEFAULT_ZFAR),
myAspect (1.0),
SetZFocus (theOtherCamera->ZFocusType(), theOtherCamera->ZFocus());
SetIOD (theOtherCamera->GetIODType(), theOtherCamera->IOD());
SetProjectionType (theOtherCamera->ProjectionType());
+ SetTile (theOtherCamera->myTile);
}
// =======================================================================
case Projection_MonoLeftEye :
case Projection_MonoRightEye :
{
- Standard_Real aDistance = theScale * 0.5 / Tan(myFOVy * M_PI / 360.0);
+ Standard_Real aDistance = theScale * 0.5 / myFOVyTan;
SetDistance (aDistance);
}
// case Projection_MonoLeftEye :
// case Projection_MonoRightEye :
default :
- return Distance() * 2.0 * Tan (myFOVy * M_PI / 360.0);
+ return Distance() * 2.0 * myFOVyTan;
}
}
}
myFOVy = theFOVy;
+ myFOVyTan = Tan(DTR_HALF * myFOVy);
InvalidateProjection();
}
InvalidateProjection();
}
+// =======================================================================
+// function : SetTile
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetTile (const Graphic3d_CameraTile& theTile)
+{
+ if (myTile == theTile)
+ {
+ return;
+ }
+
+ myTile = theTile;
+ InvalidateProjection();
+}
+
// =======================================================================
// function : OrthogonalizeUp
// purpose :
// function : ViewDimensions
// purpose :
// =======================================================================
-gp_XYZ Graphic3d_Camera::ViewDimensions() const
+gp_XYZ Graphic3d_Camera::ViewDimensions (const Standard_Real theZValue) const
{
// view plane dimensions
- Standard_Real aSize = IsOrthographic() ? myScale : (2.0 * Distance() * Tan (DTR_HALF * myFOVy));
+ Standard_Real aSize = IsOrthographic() ? myScale : (2.0 * theZValue * myFOVyTan);
Standard_Real aSizeX, aSizeY;
if (myAspect > 1.0)
{
// =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::OrientationMatrix() const
{
- return *UpdateOrientation (myMatricesD).Orientation;
+ return UpdateOrientation (myMatricesD).Orientation;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::OrientationMatrixF() const
{
- return *UpdateOrientation (myMatricesF).Orientation;
+ return UpdateOrientation (myMatricesF).Orientation;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionMatrix() const
{
- return *UpdateProjection (myMatricesD).MProjection;
+ return UpdateProjection (myMatricesD).MProjection;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::ProjectionMatrixF() const
{
- return *UpdateProjection (myMatricesF).MProjection;
+ return UpdateProjection (myMatricesF).MProjection;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionStereoLeft() const
{
- return *UpdateProjection (myMatricesD).LProjection;
+ return UpdateProjection (myMatricesD).LProjection;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::ProjectionStereoLeftF() const
{
- return *UpdateProjection (myMatricesF).LProjection;
+ return UpdateProjection (myMatricesF).LProjection;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionStereoRight() const
{
- return *UpdateProjection (myMatricesD).RProjection;
+ return UpdateProjection (myMatricesD).RProjection;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::ProjectionStereoRightF() const
{
- return *UpdateProjection (myMatricesF).RProjection;
+ return UpdateProjection (myMatricesF).RProjection;
}
// =======================================================================
}
else
{
- aDXHalf = aZNear * Elem_t (Tan (DTR_HALF * myFOVy));
- aDYHalf = aZNear * Elem_t (Tan (DTR_HALF * myFOVy));
+ aDXHalf = aZNear * Elem_t (myFOVyTan);
+ aDYHalf = aZNear * Elem_t (myFOVyTan);
}
if (anAspect > 1.0)
? static_cast<Elem_t> (myZFocus * Distance())
: static_cast<Elem_t> (myZFocus);
+ if (myTile.IsValid())
+ {
+ const Elem_t aDXFull = Elem_t(2) * aDXHalf;
+ const Elem_t aDYFull = Elem_t(2) * aDYHalf;
+ const Graphic3d_Vec2i anOffset = myTile.OffsetLowerLeft();
+ aLeft = -aDXHalf + aDXFull * static_cast<Elem_t> (anOffset.x()) / static_cast<Elem_t> (myTile.TotalSize.x());
+ aRight = -aDXHalf + aDXFull * static_cast<Elem_t> (anOffset.x() + myTile.TileSize.x()) / static_cast<Elem_t> (myTile.TotalSize.x());
+ aBot = -aDYHalf + aDYFull * static_cast<Elem_t> (anOffset.y()) / static_cast<Elem_t> (myTile.TotalSize.y());
+ aTop = -aDYHalf + aDYFull * static_cast<Elem_t> (anOffset.y() + myTile.TileSize.y()) / static_cast<Elem_t> (myTile.TotalSize.y());
+ }
+
switch (myProjType)
{
case Projection_Orthographic :
- OrthoProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, *theMatrices.MProjection);
+ OrthoProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, theMatrices.MProjection);
break;
case Projection_Perspective :
- PerspectiveProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, *theMatrices.MProjection);
+ PerspectiveProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, theMatrices.MProjection);
break;
case Projection_MonoLeftEye :
{
StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus,
- Standard_True, *theMatrices.MProjection);
- *theMatrices.LProjection = *theMatrices.MProjection;
+ Standard_True, theMatrices.MProjection);
+ theMatrices.LProjection = theMatrices.MProjection;
break;
}
{
StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus,
- Standard_False, *theMatrices.MProjection);
- *theMatrices.RProjection = *theMatrices.MProjection;
+ Standard_False, theMatrices.MProjection);
+ theMatrices.RProjection = theMatrices.MProjection;
break;
}
case Projection_Stereo :
{
- PerspectiveProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, *theMatrices.MProjection);
+ PerspectiveProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, theMatrices.MProjection);
StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus,
Standard_True,
- *theMatrices.LProjection);
+ theMatrices.LProjection);
StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus,
Standard_False,
- *theMatrices.RProjection);
+ theMatrices.RProjection);
break;
}
}
static_cast<Elem_t> (myAxialScale.Y()),
static_cast<Elem_t> (myAxialScale.Z()));
- LookOrientation (anEye, aCenter, anUp, anAxialScale, *theMatrices.Orientation);
+ LookOrientation (anEye, aCenter, anUp, anAxialScale, theMatrices.Orientation);
return theMatrices; // for inline accessors
}