1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

0033056: Visualization - add front face culling option

Added Graphic3d_TypeOfBackfacingModel_FrontCulled enumeration value.
OpenGl_Context::SetFaceCulling() now supports GL_FRONT in addition to GL_BACK.

Added -faceCulling option to vaspects Draw command.
This commit is contained in:
kgv
2022-07-06 23:39:14 +03:00
committed by smoskvin
parent e1d576bf31
commit 9db675b3d6
11 changed files with 183 additions and 42 deletions

View File

@@ -1683,6 +1683,9 @@ struct ViewerTest_AspectsChangeSet
Graphic3d_AlphaMode AlphaMode;
Standard_ShortReal AlphaCutoff;
Standard_Integer ToSetFaceCulling;
Graphic3d_TypeOfBackfacingModel FaceCulling;
Standard_Integer ToSetMaterial;
Graphic3d_NameOfMaterial Material;
TCollection_AsciiString MatName;
@@ -1764,6 +1767,8 @@ struct ViewerTest_AspectsChangeSet
ToSetAlphaMode (0),
AlphaMode (Graphic3d_AlphaMode_BlendAuto),
AlphaCutoff (0.5f),
ToSetFaceCulling (0),
FaceCulling (Graphic3d_TypeOfBackfacingModel_Auto),
ToSetMaterial (0),
Material (Graphic3d_NameOfMaterial_DEFAULT),
ToSetShowFreeBoundary (0),
@@ -1811,6 +1816,7 @@ struct ViewerTest_AspectsChangeSet
&& ToSetLineWidth == 0
&& ToSetTransparency == 0
&& ToSetAlphaMode == 0
&& ToSetFaceCulling == 0
&& ToSetColor == 0
&& ToSetBackFaceColor == 0
&& ToSetMaterial == 0
@@ -2064,6 +2070,15 @@ struct ViewerTest_AspectsChangeSet
theDrawer->ShadingAspect()->Aspect()->SetAlphaMode (AlphaMode, AlphaCutoff);
}
}
if (ToSetFaceCulling != 0)
{
if (ToSetFaceCulling != -1
|| theDrawer->HasOwnShadingAspect())
{
toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
theDrawer->ShadingAspect()->Aspect()->SetFaceCulling (FaceCulling);
}
}
if (ToSetHatch != 0)
{
if (ToSetHatch != -1
@@ -2557,6 +2572,47 @@ static Standard_Integer VAspects (Draw_Interpretor& theDI,
}
}
}
else if (anArg == "-setfaceculling"
|| anArg == "-faceculling")
{
if (++anArgIter >= theArgNb)
{
Message::SendFail() << "Error: wrong syntax at " << anArg;
return 1;
}
aChangeSet->ToSetFaceCulling = 1;
{
TCollection_AsciiString aParam (theArgVec[anArgIter]);
aParam.LowerCase();
if (aParam == "auto")
{
aChangeSet->FaceCulling = Graphic3d_TypeOfBackfacingModel_Auto;
}
else if (aParam == "backculled"
|| aParam == "backcull"
|| aParam == "back")
{
aChangeSet->FaceCulling = Graphic3d_TypeOfBackfacingModel_BackCulled;
}
else if (aParam == "frontculled"
|| aParam == "frontcull"
|| aParam == "front")
{
aChangeSet->FaceCulling = Graphic3d_TypeOfBackfacingModel_FrontCulled;
}
else if (aParam == "doublesided"
|| aParam == "off")
{
aChangeSet->FaceCulling = Graphic3d_TypeOfBackfacingModel_DoubleSided;
}
else
{
Message::SendFail() << "Error: wrong syntax at '" << aParam << "'";
return 1;
}
}
}
else if (anArg == "-setvis"
|| anArg == "-setvisibility"
|| anArg == "-visibility")
@@ -3192,6 +3248,8 @@ static Standard_Integer VAspects (Draw_Interpretor& theDI,
aChangeSet->ToSetAlphaMode = -1;
aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
aChangeSet->AlphaCutoff = 0.5f;
aChangeSet->ToSetFaceCulling = -1;
aChangeSet->FaceCulling = Graphic3d_TypeOfBackfacingModel_Auto;
aChangeSet->ToSetColor = -1;
aChangeSet->Color = DEFAULT_COLOR;
//aChangeSet->ToSetBackFaceColor = -1; // should be reset by ToSetColor
@@ -6708,7 +6766,7 @@ vsub 0/1 (off/on) [obj] : Subintensity(on/off) of selected objects
vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults] [-subshapes subname1 [subname2 [...]]]
[-visibility {0|1}]
[-color {ColorName | R G B}] [-unsetColor]
[-backfaceColor Color]
[-backfaceColor Color] [-faceCulling {auto|back|front|doublesided}]
[-material MatName] [-unsetMaterial]
[-transparency Transp] [-unsetTransparency]
[-width LineWidth] [-unsetWidth]