Deleted adding background quad into depth range. Background is drawn in 2D coordinates. Fixed problem with using gradient background in tiles.
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
Standard_Integer aViewSizeX = aCtx->Viewport()[2];
Standard_Integer aViewSizeY = aCtx->Viewport()[3];
+ Graphic3d_Vec2i aTileOffset, aTileSize;
+
if (theWorkspace->View()->Camera()->Tile().IsValid())
{
aViewSizeX = theWorkspace->View()->Camera()->Tile().TotalSize.x();
aViewSizeY = theWorkspace->View()->Camera()->Tile().TotalSize.y();
+
+ aTileOffset = theWorkspace->View()->Camera()->Tile().OffsetLowerLeft();
+ aTileSize = theWorkspace->View()->Camera()->Tile().TileSize;
}
if (myToUpdate
|| myViewWidth != aViewSizeX
if (myType != Graphic3d_TOB_CUBEMAP)
{
- myTrsfPers.Apply(theWorkspace->View()->Camera(), aProjection, aWorldView,
- aCtx->Viewport()[2], aCtx->Viewport()[3]);
+ aProjection.InitIdentity();
+ aWorldView.InitIdentity();
+ if (theWorkspace->View()->Camera()->Tile().IsValid())
+ {
+ aWorldView.SetDiagonal (OpenGl_Vec4 (2.0f / aTileSize.x(), 2.0f / aTileSize.y(), 1.0f, 1.0f));
+ if (myType == Graphic3d_TOB_GRADIENT)
+ {
+ aWorldView.SetColumn (3, OpenGl_Vec4 (-1.0f - 2.0f * aTileOffset.x() / aTileSize.x(),
+ -1.0f - 2.0f * aTileOffset.y() / aTileSize.y(), 0.0f, 1.0f));
+ }
+ else
+ {
+ aWorldView.SetColumn (3, OpenGl_Vec4 (-1.0f + (float) aViewSizeX / aTileSize.x() - 2.0f * aTileOffset.x() / aTileSize.x(),
+ -1.0f + (float) aViewSizeY / aTileSize.y() - 2.0f * aTileOffset.y() / aTileSize.y(), 0.0f, 1.0f));
+ }
+ }
+ else
+ {
+ aWorldView.SetDiagonal (OpenGl_Vec4 (2.0f / myViewWidth, 2.0f / myViewHeight, 1.0f, 1.0f));
+ if (myType == Graphic3d_TOB_GRADIENT)
+ {
+ aWorldView.SetColumn (3, OpenGl_Vec4 (-1.0f, -1.0f, 0.0f, 1.0f));
+ }
+ }
}
aCtx->ProjectionState.Push();
Bnd_Box aBox = base_type::MinMaxValues (theToIncludeAuxiliary);
- // add bounding box of gradient/texture background for proper Z-fit
- if (theToIncludeAuxiliary
- && (myBackgrounds[Graphic3d_TOB_TEXTURE]->IsDefined()
- || myBackgrounds[Graphic3d_TOB_GRADIENT]->IsDefined()))
- {
- const Handle(Graphic3d_Camera)& aCamera = Camera();
- Graphic3d_Vec2i aWinSize;
- Window()->Size (aWinSize.x(), aWinSize.y());
-
- // Background is drawn using 2D transformation persistence
- // (e.g. it is actually placed in 3D coordinates within active camera position).
- // We add here full-screen plane with 2D transformation persistence
- // for simplicity (myBgTextureArray might define a little bit different options
- // but it is updated within ::Render())
- const Graphic3d_Mat4d& aProjectionMat = aCamera->ProjectionMatrix();
- const Graphic3d_Mat4d& aWorldViewMat = aCamera->OrientationMatrix();
- Graphic3d_BndBox3d aBox2d (Graphic3d_Vec3d (0.0, 0.0, 0.0),
- Graphic3d_Vec3d (double(aWinSize.x()), double(aWinSize.y()), 0.0));
-
- Graphic3d_TransformPers aTrsfPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER);
- aTrsfPers.Apply (aCamera,
- aProjectionMat,
- aWorldViewMat,
- aWinSize.x(),
- aWinSize.y(),
- aBox2d);
- aBox.Add (gp_Pnt (aBox2d.CornerMin().x(), aBox2d.CornerMin().y(), aBox2d.CornerMin().z()));
- aBox.Add (gp_Pnt (aBox2d.CornerMax().x(), aBox2d.CornerMax().y(), aBox2d.CornerMax().z()));
- }
-
return aBox;
}
{
aBackColorTop = myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (0);
aBackColorBot = myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (1);
+
+ if (myCamera->Tile().IsValid())
+ {
+ Standard_Integer aTileOffset = myCamera->Tile().OffsetLowerLeft().y();
+ Standard_Integer aTileSize = myCamera->Tile().TileSize.y();
+ Standard_Integer aViewSize = myCamera->Tile().TotalSize.y();
+ OpenGl_Vec4 aColorRange = aBackColorTop - aBackColorBot;
+ aBackColorBot = aBackColorBot + aColorRange * ((float) aTileOffset / aViewSize);
+ aBackColorTop = aBackColorBot + aColorRange * ((float) aTileSize / aViewSize);
+ }
}
aBackColorTop = theGlContext->Vec4FromQuantityColor (aBackColorTop);
aBackColorBot = theGlContext->Vec4FromQuantityColor (aBackColorBot);