mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0032188: Visualization, Graphic3d_Aspects - define backface culling using Graphic3d_TypeOfBackfacingModel
Graphic3d_Aspects::ToSuppressBackFaces() bool flag has been replaced by Graphic3d_Aspects::FaceCulling() property defined by Graphic3d_TypeOfBackfacingModel enumeration. Graphic3d_TypeOfBackfacingModel_Auto corresponds to old ToSuppressBackFaces()==TRUE; Graphic3d_TypeOfBackfacingModel_DoubleSided corresponds to old ToSuppressBackFaces()==FALSE; Graphic3d_TypeOfBackfacingModel_BackCulled allows enabling back face culling regardless of Graphic3d_Group::IsClosed() flag. XCAFDoc_VisMaterial::IsDoubleSided() bool flag has been replaced by XCAFDoc_VisMaterial::FaceCulling() property defined by Graphic3d_TypeOfBackfacingModel enumeration. glTF reader now maps "doubleSided" material flag into Graphic3d_TypeOfBackfacingModel_BackCulled (forced back face culling) and Graphic3d_TypeOfBackfacingModel_Auto (e.g. practically doubleSided as there is no closed/open info in glTF). glTF writer by default writes materials as "doubleSided" save the Graphic3d_TypeOfBackfacingModel_BackCulled property set (in future, extra logic might written for automatically defining singleSided materials for Solid B-Rep objects). Removed obsolete unused types V3d_TypeOfPickCamera, V3d_TypeOfPickLight, V3d_TypeOfRepresentation, and V3d_Coordinate. Deprecated types V3d_TypeOfBackfacingModel, V3d_TypeOfLight, and V3d_TypeOfShadingModel.
This commit is contained in:
parent
42ddd0028c
commit
7fd4958d45
@ -198,7 +198,7 @@ void AIS_ViewCube::setDefaultAttributes()
|
||||
myDrawer->TextAspect()->SetHeight (16.0);
|
||||
myDrawer->TextAspect()->Aspect()->SetTextZoomable (true); // the whole object is drawn within transformation-persistence
|
||||
// this should be forced back-face culling regardless Closed flag
|
||||
myDrawer->TextAspect()->Aspect()->SetSuppressBackFaces (true);
|
||||
myDrawer->TextAspect()->Aspect()->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_BackCulled);
|
||||
|
||||
Graphic3d_MaterialAspect aMat (Graphic3d_NameOfMaterial_UserDefined);
|
||||
aMat.SetColor (Quantity_NOC_WHITE);
|
||||
@ -207,7 +207,7 @@ void AIS_ViewCube::setDefaultAttributes()
|
||||
const Handle(Graphic3d_AspectFillArea3d)& aShading = myDrawer->ShadingAspect()->Aspect();
|
||||
aShading->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
// this should be forced back-face culling regardless Closed flag
|
||||
aShading->SetSuppressBackFaces (true);
|
||||
aShading->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_BackCulled);
|
||||
aShading->SetInteriorColor (aMat.Color());
|
||||
aShading->SetFrontMaterial (aMat);
|
||||
myDrawer->SetFaceBoundaryDraw (false);
|
||||
@ -671,7 +671,7 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroupSides = thePrs->NewGroup();
|
||||
aGroupSides->SetClosed (true); // should be replaced by forced back-face culling aspect
|
||||
aGroupSides->SetClosed (true);
|
||||
aGroupSides->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
|
||||
aGroupSides->AddPrimitiveArray (aTris);
|
||||
}
|
||||
|
@ -47,6 +47,30 @@ static Graphic3d_AlphaMode alphaModeFromChar (Standard_Byte theMode)
|
||||
return Graphic3d_AlphaMode_BlendAuto;
|
||||
}
|
||||
|
||||
//! Encode face culling mode into character.
|
||||
static Standard_Byte faceCullToChar (Graphic3d_TypeOfBackfacingModel theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case Graphic3d_TypeOfBackfacingModel_Auto: return '0';
|
||||
case Graphic3d_TypeOfBackfacingModel_BackCulled: return 'B';
|
||||
case Graphic3d_TypeOfBackfacingModel_DoubleSided: return '1';
|
||||
}
|
||||
return '0';
|
||||
}
|
||||
|
||||
//! Decode face culling mode from character.
|
||||
static Graphic3d_TypeOfBackfacingModel faceCullFromChar (Standard_Byte theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case '0': return Graphic3d_TypeOfBackfacingModel_Auto;
|
||||
case 'B': return Graphic3d_TypeOfBackfacingModel_BackCulled;
|
||||
case '1': return Graphic3d_TypeOfBackfacingModel_DoubleSided;
|
||||
}
|
||||
return Graphic3d_TypeOfBackfacingModel_Auto;
|
||||
}
|
||||
|
||||
//! Encode vec3.
|
||||
static void writeVec3 (BinObjMgt_Persistent& theTarget,
|
||||
const Graphic3d_Vec3& theVec3)
|
||||
@ -162,7 +186,7 @@ Standard_Boolean BinMXCAFDoc_VisMaterialDriver::Paste (const BinObjMgt_Persisten
|
||||
theSource.GetByte (isDoubleSided);
|
||||
theSource.GetByte (anAlphaMode);
|
||||
theSource.GetShortReal (anAlphaCutOff);
|
||||
aMat->SetDoubleSided (isDoubleSided == '1');
|
||||
aMat->SetFaceCulling (faceCullFromChar (isDoubleSided));
|
||||
aMat->SetAlphaMode (alphaModeFromChar (anAlphaMode), anAlphaCutOff);
|
||||
|
||||
XCAFDoc_VisMaterialPBR aPbrMat;
|
||||
@ -227,7 +251,7 @@ void BinMXCAFDoc_VisMaterialDriver::Paste (const Handle(TDF_Attribute)& theSourc
|
||||
theTarget.PutByte (MaterialVersionMajor);
|
||||
theTarget.PutByte (MaterialVersionMinor);
|
||||
|
||||
theTarget.PutByte (aMat->IsDoubleSided() ? '1' : '0');
|
||||
theTarget.PutByte (faceCullToChar (aMat->FaceCulling()));
|
||||
theTarget.PutByte (alphaModeToChar (aMat->AlphaMode()));
|
||||
theTarget.PutShortReal (aMat->AlphaCutOff());
|
||||
|
||||
|
@ -26,6 +26,7 @@ Graphic3d_Aspects::Graphic3d_Aspects()
|
||||
myEdgeColor (Quantity_NOC_WHITE),
|
||||
myInteriorStyle (Aspect_IS_SOLID),
|
||||
myShadingModel (Graphic3d_TOSM_DEFAULT),
|
||||
myFaceCulling (Graphic3d_TypeOfBackfacingModel_Auto),
|
||||
myAlphaMode (Graphic3d_AlphaMode_BlendAuto),
|
||||
myAlphaCutoff (0.5f),
|
||||
myLineType (Aspect_TOL_SOLID),
|
||||
@ -42,7 +43,6 @@ Graphic3d_Aspects::Graphic3d_Aspects()
|
||||
myToDistinguishMaterials (false),
|
||||
myToDrawEdges (false),
|
||||
myToDrawSilhouette (false),
|
||||
myToSuppressBackFaces (true),
|
||||
myToMapTexture (false),
|
||||
myIsTextZoomable (false)
|
||||
{
|
||||
@ -81,7 +81,7 @@ void Graphic3d_Aspects::DumpJson (Standard_OStream& theOStream, Standard_Integer
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDistinguishMaterials)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawEdges)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawSilhouette)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToSuppressBackFaces)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFaceCulling)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToMapTexture)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsTextZoomable)
|
||||
|
||||
|
@ -24,12 +24,13 @@
|
||||
#include <Font_NameOfFont.hxx>
|
||||
#include <Graphic3d_AlphaMode.hxx>
|
||||
#include <Graphic3d_MarkerImage.hxx>
|
||||
#include <Graphic3d_HatchStyle.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <Graphic3d_HatchStyle.hxx>
|
||||
#include <Graphic3d_PolygonOffset.hxx>
|
||||
#include <Graphic3d_ShaderProgram.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <Graphic3d_TextureSet.hxx>
|
||||
#include <Graphic3d_TypeOfBackfacingModel.hxx>
|
||||
#include <Graphic3d_TypeOfShadingModel.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
|
||||
@ -120,22 +121,13 @@ public:
|
||||
//! Modifies the surface material of internal faces
|
||||
void SetBackMaterial (const Graphic3d_MaterialAspect& theMaterial) { myBackMaterial = theMaterial; }
|
||||
|
||||
//! Returns true if back faces should be suppressed (true by default).
|
||||
bool ToSuppressBackFaces() const { return myToSuppressBackFaces; }
|
||||
|
||||
//! Assign back faces culling flag.
|
||||
void SetSuppressBackFaces (bool theToSuppress) { myToSuppressBackFaces = theToSuppress; }
|
||||
|
||||
//! Returns true if back faces should be suppressed (true by default).
|
||||
bool BackFace() const { return myToSuppressBackFaces; }
|
||||
|
||||
//! Allows the display of back-facing filled polygons.
|
||||
void AllowBackFace() { myToSuppressBackFaces = false; }
|
||||
|
||||
//! Suppress the display of back-facing filled polygons.
|
||||
//! Return face culling mode; Graphic3d_FaceCulling_BackClosed by default.
|
||||
//! A back-facing polygon is defined as a polygon whose
|
||||
//! vertices are in a clockwise order with respect to screen coordinates.
|
||||
void SuppressBackFace() { myToSuppressBackFaces = true; }
|
||||
Graphic3d_TypeOfBackfacingModel FaceCulling() const { return myFaceCulling; }
|
||||
|
||||
//! Set face culling mode.
|
||||
void SetFaceCulling (Graphic3d_TypeOfBackfacingModel theCulling) { myFaceCulling = theCulling; }
|
||||
|
||||
//! Returns true if material properties should be distinguished for back and front faces (false by default).
|
||||
bool Distinguish() const { return myToDistinguishMaterials; }
|
||||
@ -511,6 +503,7 @@ public:
|
||||
&& myBackMaterial == theOther.myBackMaterial
|
||||
&& myInteriorStyle == theOther.myInteriorStyle
|
||||
&& myShadingModel == theOther.myShadingModel
|
||||
&& myFaceCulling == theOther.myFaceCulling
|
||||
&& myAlphaMode == theOther.myAlphaMode
|
||||
&& myAlphaCutoff == theOther.myAlphaCutoff
|
||||
&& myLineType == theOther.myLineType
|
||||
@ -531,7 +524,6 @@ public:
|
||||
&& myToDistinguishMaterials == theOther.myToDistinguishMaterials
|
||||
&& myToDrawEdges == theOther.myToDrawEdges
|
||||
&& myToDrawSilhouette == theOther.myToDrawSilhouette
|
||||
&& myToSuppressBackFaces == theOther.myToSuppressBackFaces
|
||||
&& myToMapTexture == theOther.myToMapTexture
|
||||
&& myIsTextZoomable == theOther.myIsTextZoomable;
|
||||
}
|
||||
@ -539,6 +531,30 @@ public:
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
|
||||
|
||||
public:
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, FaceCulling() should be used instead")
|
||||
bool ToSuppressBackFaces() const
|
||||
{
|
||||
return myFaceCulling == Graphic3d_TypeOfBackfacingModel_BackCulled
|
||||
|| myFaceCulling == Graphic3d_TypeOfBackfacingModel_Auto;
|
||||
}
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used instead")
|
||||
void SetSuppressBackFaces (bool theToSuppress) { myFaceCulling = theToSuppress ? Graphic3d_TypeOfBackfacingModel_Auto : Graphic3d_TypeOfBackfacingModel_DoubleSided; }
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, FaceCulling() should be used instead")
|
||||
bool BackFace() const
|
||||
{
|
||||
return myFaceCulling == Graphic3d_TypeOfBackfacingModel_BackCulled
|
||||
|| myFaceCulling == Graphic3d_TypeOfBackfacingModel_Auto;
|
||||
}
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used instead")
|
||||
void AllowBackFace() { myFaceCulling = Graphic3d_TypeOfBackfacingModel_DoubleSided; }
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used instead")
|
||||
void SuppressBackFace() { myFaceCulling = Graphic3d_TypeOfBackfacingModel_Auto; }
|
||||
|
||||
protected:
|
||||
|
||||
@ -557,6 +573,7 @@ protected:
|
||||
Graphic3d_PolygonOffset myPolygonOffset;
|
||||
Aspect_InteriorStyle myInteriorStyle;
|
||||
Graphic3d_TypeOfShadingModel myShadingModel;
|
||||
Graphic3d_TypeOfBackfacingModel myFaceCulling;
|
||||
Graphic3d_AlphaMode myAlphaMode;
|
||||
Standard_ShortReal myAlphaCutoff;
|
||||
|
||||
@ -577,7 +594,6 @@ protected:
|
||||
bool myToDistinguishMaterials;
|
||||
bool myToDrawEdges;
|
||||
bool myToDrawSilhouette;
|
||||
bool myToSuppressBackFaces;
|
||||
bool myToMapTexture;
|
||||
bool myIsTextZoomable;
|
||||
|
||||
|
@ -33,6 +33,7 @@ Graphic3d_CView::Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theM
|
||||
myIsActive (Standard_False),
|
||||
myIsRemoved (Standard_False),
|
||||
myShadingModel (Graphic3d_TOSM_FRAGMENT),
|
||||
myBackfacing (Graphic3d_TypeOfBackfacingModel_Auto),
|
||||
myVisualization (Graphic3d_TOV_WIREFRAME),
|
||||
myUnitFactor (1.0)
|
||||
{
|
||||
|
@ -106,6 +106,13 @@ public:
|
||||
//! Will throw an exception on attempt to set Graphic3d_TOSM_DEFAULT.
|
||||
Standard_EXPORT void SetShadingModel (Graphic3d_TypeOfShadingModel theModel);
|
||||
|
||||
//! Return backfacing model used for the view; Graphic3d_TypeOfBackfacingModel_Auto by default,
|
||||
//! which means that backface culling is defined by each presentation.
|
||||
Graphic3d_TypeOfBackfacingModel BackfacingModel() const { return myBackfacing; }
|
||||
|
||||
//! Sets backfacing model for the view.
|
||||
void SetBackfacingModel (const Graphic3d_TypeOfBackfacingModel theModel) { myBackfacing = theModel; }
|
||||
|
||||
//! Returns visualization type of the view.
|
||||
Graphic3d_TypeOfVisualization VisualizationType() const { return myVisualization; }
|
||||
|
||||
@ -403,12 +410,6 @@ public:
|
||||
//! Sets environment texture for the view.
|
||||
virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) = 0;
|
||||
|
||||
//! Return backfacing model used for the view.
|
||||
virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const = 0;
|
||||
|
||||
//! Sets backfacing model for the view.
|
||||
virtual void SetBackfacingModel (const Graphic3d_TypeOfBackfacingModel theModel) = 0;
|
||||
|
||||
//! Returns list of lights of the view.
|
||||
virtual const Handle(Graphic3d_LightSet)& Lights() const = 0;
|
||||
|
||||
@ -570,6 +571,7 @@ protected:
|
||||
Standard_Boolean myIsActive;
|
||||
Standard_Boolean myIsRemoved;
|
||||
Graphic3d_TypeOfShadingModel myShadingModel;
|
||||
Graphic3d_TypeOfBackfacingModel myBackfacing;
|
||||
Graphic3d_TypeOfVisualization myVisualization;
|
||||
|
||||
Handle(Aspect_XRSession) myXRSession;
|
||||
|
@ -34,7 +34,7 @@ namespace
|
||||
anAspect->SetHatchStyle (Aspect_HS_HORIZONTAL);
|
||||
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
anAspect->SetInteriorColor (Quantity_NOC_GRAY20);
|
||||
anAspect->SetSuppressBackFaces (false);
|
||||
anAspect->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_DoubleSided);
|
||||
return anAspect;
|
||||
}
|
||||
}
|
||||
|
@ -17,16 +17,20 @@
|
||||
#ifndef _Graphic3d_TypeOfBackfacingModel_HeaderFile
|
||||
#define _Graphic3d_TypeOfBackfacingModel_HeaderFile
|
||||
|
||||
//! Modes of display of back faces in the view
|
||||
//!
|
||||
//! TOBM_AUTOMATIC graphic's structure setting is in use
|
||||
//! TOBM_FORCE force display of back faces
|
||||
//! TOBM_DISABLE disable display of back faces
|
||||
//! Modes of display of back faces in the view.
|
||||
enum Graphic3d_TypeOfBackfacingModel
|
||||
{
|
||||
Graphic3d_TOBM_AUTOMATIC,
|
||||
Graphic3d_TOBM_FORCE,
|
||||
Graphic3d_TOBM_DISABLE
|
||||
Graphic3d_TypeOfBackfacingModel_Auto, //!< automatic back face culling enabled for opaque groups with closed flag
|
||||
//! (e.g. solids, see Graphic3d_Group::IsClosed())
|
||||
Graphic3d_TypeOfBackfacingModel_DoubleSided, //!< no culling (double-sided shading)
|
||||
Graphic3d_TypeOfBackfacingModel_BackCulled, //!< back face culling
|
||||
// old aliases
|
||||
Graphic3d_TOBM_AUTOMATIC = Graphic3d_TypeOfBackfacingModel_Auto,
|
||||
Graphic3d_TOBM_FORCE = Graphic3d_TypeOfBackfacingModel_DoubleSided,
|
||||
Graphic3d_TOBM_DISABLE = Graphic3d_TypeOfBackfacingModel_BackCulled,
|
||||
V3d_TOBM_AUTOMATIC = Graphic3d_TypeOfBackfacingModel_Auto,
|
||||
V3d_TOBM_ALWAYS_DISPLAYED = Graphic3d_TypeOfBackfacingModel_DoubleSided,
|
||||
V3d_TOBM_NEVER_DISPLAYED = Graphic3d_TypeOfBackfacingModel_BackCulled
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_TypeOfBackfacingModel_HeaderFile
|
||||
|
@ -83,7 +83,6 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
|
||||
myDriver (theDriver.operator->()),
|
||||
myCaps (theCaps),
|
||||
myWasRedrawnGL (Standard_False),
|
||||
myBackfacing (Graphic3d_TOBM_AUTOMATIC),
|
||||
myToShowGradTrihedron (false),
|
||||
myZLayers (Structure_MAX_PRIORITY - Structure_MIN_PRIORITY + 1),
|
||||
myStateCounter (theCounter),
|
||||
@ -540,7 +539,7 @@ void OpenGl_View::SetBackgroundImage (const Handle(Graphic3d_TextureMap)& theTex
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
|
||||
Handle(Graphic3d_TextureSet) aTextureSet = new Graphic3d_TextureSet (theTextureMap);
|
||||
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
anAspect->SetSuppressBackFaces (false);
|
||||
anAspect->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_DoubleSided);
|
||||
anAspect->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||
anAspect->SetTextureSet (aTextureSet);
|
||||
anAspect->SetTextureMapOn (true);
|
||||
@ -2188,20 +2187,6 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
|
||||
// Step 3: Redraw main plane
|
||||
// =================================
|
||||
|
||||
// Setup face culling
|
||||
GLboolean isCullFace = GL_FALSE;
|
||||
if (myBackfacing != Graphic3d_TOBM_AUTOMATIC)
|
||||
{
|
||||
isCullFace = glIsEnabled (GL_CULL_FACE);
|
||||
if (myBackfacing == Graphic3d_TOBM_DISABLE)
|
||||
{
|
||||
glEnable (GL_CULL_FACE);
|
||||
glCullFace (GL_BACK);
|
||||
}
|
||||
else
|
||||
glDisable (GL_CULL_FACE);
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
// if the view is scaled normal vectors are scaled to unit
|
||||
// length for correct displaying of shaded objects
|
||||
@ -2274,18 +2259,6 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
|
||||
if (!theToDrawImmediate)
|
||||
{
|
||||
renderTrihedron (myWorkspace);
|
||||
|
||||
// Restore face culling
|
||||
if (myBackfacing != Graphic3d_TOBM_AUTOMATIC)
|
||||
{
|
||||
if (isCullFace)
|
||||
{
|
||||
glEnable (GL_CULL_FACE);
|
||||
glCullFace (GL_BACK);
|
||||
}
|
||||
else
|
||||
glDisable (GL_CULL_FACE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -261,12 +261,6 @@ public:
|
||||
//! Sets environment texture for the view.
|
||||
Standard_EXPORT virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) Standard_OVERRIDE;
|
||||
|
||||
//! Return backfacing model used for the view.
|
||||
virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const Standard_OVERRIDE { return myBackfacing; }
|
||||
|
||||
//! Sets backfacing model for the view.
|
||||
virtual void SetBackfacingModel (const Graphic3d_TypeOfBackfacingModel theModel) Standard_OVERRIDE { myBackfacing = theModel; }
|
||||
|
||||
//! Returns local camera origin currently set for rendering, might be modified during rendering.
|
||||
const gp_XYZ& LocalOrigin() const { return myLocalOrigin; }
|
||||
|
||||
@ -489,7 +483,6 @@ protected:
|
||||
Handle(OpenGl_Caps) myCaps;
|
||||
Standard_Boolean myWasRedrawnGL;
|
||||
|
||||
Graphic3d_TypeOfBackfacingModel myBackfacing;
|
||||
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
|
||||
gp_XYZ myLocalOrigin;
|
||||
Handle(OpenGl_FrameBuffer) myFBO;
|
||||
|
@ -144,11 +144,11 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
|
||||
#endif
|
||||
}
|
||||
|
||||
myNoneCulling .Aspect()->SetSuppressBackFaces (false);
|
||||
myNoneCulling .Aspect()->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_DoubleSided);
|
||||
myNoneCulling .Aspect()->SetDrawEdges (false);
|
||||
myNoneCulling .Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
||||
|
||||
myFrontCulling.Aspect()->SetSuppressBackFaces (true);
|
||||
myFrontCulling.Aspect()->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_BackCulled);
|
||||
myFrontCulling.Aspect()->SetDrawEdges (false);
|
||||
myFrontCulling.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
||||
}
|
||||
@ -252,12 +252,14 @@ const OpenGl_Aspects* OpenGl_Workspace::SetAspects (const OpenGl_Aspects* theAsp
|
||||
// =======================================================================
|
||||
const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects (bool theToBindTextures)
|
||||
{
|
||||
if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC)
|
||||
bool toSuppressBackFaces = myView->BackfacingModel() == Graphic3d_TypeOfBackfacingModel_BackCulled;
|
||||
if (myView->BackfacingModel() == Graphic3d_TypeOfBackfacingModel_Auto)
|
||||
{
|
||||
bool toSuppressBackFaces = myToAllowFaceCulling
|
||||
&& myAspectsSet->Aspect()->ToSuppressBackFaces();
|
||||
if (toSuppressBackFaces)
|
||||
toSuppressBackFaces = myAspectsSet->Aspect()->FaceCulling() == Graphic3d_TypeOfBackfacingModel_BackCulled;
|
||||
if (myAspectsSet->Aspect()->FaceCulling() == Graphic3d_TypeOfBackfacingModel_Auto
|
||||
&& myToAllowFaceCulling)
|
||||
{
|
||||
toSuppressBackFaces = true;
|
||||
if (myAspectsSet->Aspect()->InteriorStyle() == Aspect_IS_HATCH
|
||||
|| myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Blend
|
||||
|| myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Mask
|
||||
@ -269,8 +271,8 @@ const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects (bool theToBindTextures)
|
||||
toSuppressBackFaces = false;
|
||||
}
|
||||
}
|
||||
myGlContext->SetCullBackFaces (toSuppressBackFaces);
|
||||
}
|
||||
myGlContext->SetCullBackFaces (toSuppressBackFaces);
|
||||
|
||||
if (myAspectsSet->Aspect() == myAspectsApplied
|
||||
&& myHighlightStyle == myAspectFaceAppliedWithHL)
|
||||
|
@ -438,7 +438,9 @@ void RWGltf_GltfJsonParser::gltfBindMaterial (const Handle(RWGltf_MaterialMetall
|
||||
}
|
||||
}
|
||||
aMat->SetAlphaMode (anAlphaMode, theMatPbr->AlphaCutOff);
|
||||
aMat->SetDoubleSided (theMatPbr->IsDoubleSided);
|
||||
// consider "doubleSided" material flag as indication of automatically culled material
|
||||
// as glTF doesn't define closed/open flag and culling will be practically disabled
|
||||
aMat->SetFaceCulling (theMatPbr->IsDoubleSided ? Graphic3d_TypeOfBackfacingModel_Auto : Graphic3d_TypeOfBackfacingModel_BackCulled);
|
||||
|
||||
if (!theMatPbr->Name.IsEmpty())
|
||||
{
|
||||
|
@ -486,8 +486,13 @@ void RWGltf_GltfMaterialMap::DefineMaterial (const XCAFPrs_Style& theStyle,
|
||||
}
|
||||
myWriter->EndObject();
|
||||
|
||||
// export automatic culling as doubleSided material;
|
||||
// extra preprocessing is necessary to automatically export
|
||||
// Solids with singleSided material and Shells with doubleSided material,
|
||||
// as both may share the same material having "auto" flag
|
||||
if (theStyle.Material().IsNull()
|
||||
|| theStyle.Material()->IsDoubleSided())
|
||||
|| theStyle.Material()->FaceCulling() == Graphic3d_TypeOfBackfacingModel_Auto
|
||||
|| theStyle.Material()->FaceCulling() == Graphic3d_TypeOfBackfacingModel_DoubleSided)
|
||||
{
|
||||
myWriter->Key ("doubleSided");
|
||||
myWriter->Bool (true);
|
||||
|
@ -5,7 +5,6 @@ V3d_AmbientLight.hxx
|
||||
V3d_BadValue.hxx
|
||||
V3d_CircularGrid.cxx
|
||||
V3d_CircularGrid.hxx
|
||||
V3d_Coordinate.hxx
|
||||
V3d_DirectionalLight.cxx
|
||||
V3d_DirectionalLight.hxx
|
||||
V3d_ImageDumpOptions.hxx
|
||||
@ -30,9 +29,6 @@ V3d_TypeOfAxe.hxx
|
||||
V3d_TypeOfBackfacingModel.hxx
|
||||
V3d_TypeOfLight.hxx
|
||||
V3d_TypeOfOrientation.hxx
|
||||
V3d_TypeOfPickCamera.hxx
|
||||
V3d_TypeOfPickLight.hxx
|
||||
V3d_TypeOfRepresentation.hxx
|
||||
V3d_TypeOfShadingModel.hxx
|
||||
V3d_TypeOfView.hxx
|
||||
V3d_TypeOfVisualization.hxx
|
||||
|
@ -1,26 +0,0 @@
|
||||
// Created on: 1992-11-13
|
||||
// Created by: GG
|
||||
// Copyright (c) 1992-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _V3d_Coordinate_HeaderFile
|
||||
#define _V3d_Coordinate_HeaderFile
|
||||
|
||||
#include <Standard_Real.hxx>
|
||||
|
||||
//! User-defined coordinate in the reference plane of
|
||||
//! view (Projection or Mapping).
|
||||
typedef Standard_Real V3d_Coordinate;
|
||||
|
||||
#endif // _V3d_Coordinate_HeaderFile
|
@ -19,8 +19,6 @@
|
||||
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <V3d_Light.hxx>
|
||||
#include <V3d_TypeOfPickLight.hxx>
|
||||
#include <V3d_TypeOfRepresentation.hxx>
|
||||
|
||||
//! Base class for Positional, Spot and Directional Light classes.
|
||||
class V3d_PositionLight : public Graphic3d_CLight
|
||||
|
@ -17,16 +17,9 @@
|
||||
#ifndef _V3d_TypeOfBackfacingModel_HeaderFile
|
||||
#define _V3d_TypeOfBackfacingModel_HeaderFile
|
||||
|
||||
//! Modes of display of back faces in the view
|
||||
//!
|
||||
//! TOBM_AUTOMATIC graphic's structure setting is in use
|
||||
//! TOBM_ALWAYS_DISPLAYED force display of back faces
|
||||
//! TOBM_NEVER_DISPLAYED disable display of back faces
|
||||
enum V3d_TypeOfBackfacingModel
|
||||
{
|
||||
V3d_TOBM_AUTOMATIC,
|
||||
V3d_TOBM_ALWAYS_DISPLAYED,
|
||||
V3d_TOBM_NEVER_DISPLAYED
|
||||
};
|
||||
#include <Graphic3d_TypeOfBackfacingModel.hxx>
|
||||
|
||||
Standard_DEPRECATED("Deprecated alias - Graphic3d_TypeOfBackfacingModel should be used instead")
|
||||
typedef Graphic3d_TypeOfBackfacingModel V3d_TypeOfBackfacingModel;
|
||||
|
||||
#endif // _V3d_TypeOfBackfacingModel_HeaderFile
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <Graphic3d_TypeOfLightSource.hxx>
|
||||
|
||||
Standard_DEPRECATED("Deprecated alias - Graphic3d_TypeOfLightSource should be used instead")
|
||||
typedef Graphic3d_TypeOfLightSource V3d_TypeOfLight;
|
||||
|
||||
#endif // _V3d_TypeOfLight_HeaderFile
|
||||
|
@ -1,31 +0,0 @@
|
||||
// Created on: 1992-11-13
|
||||
// Created by: GG
|
||||
// Copyright (c) 1992-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _V3d_TypeOfPickCamera_HeaderFile
|
||||
#define _V3d_TypeOfPickCamera_HeaderFile
|
||||
|
||||
|
||||
enum V3d_TypeOfPickCamera
|
||||
{
|
||||
V3d_POSITIONCAMERA,
|
||||
V3d_SPACECAMERA,
|
||||
V3d_RADIUSTEXTCAMERA,
|
||||
V3d_ExtRADIUSCAMERA,
|
||||
V3d_IntRADIUSCAMERA,
|
||||
V3d_NOTHINGCAMERA
|
||||
};
|
||||
|
||||
#endif // _V3d_TypeOfPickCamera_HeaderFile
|
@ -1,31 +0,0 @@
|
||||
// Created on: 1992-11-13
|
||||
// Created by: GG
|
||||
// Copyright (c) 1992-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _V3d_TypeOfPickLight_HeaderFile
|
||||
#define _V3d_TypeOfPickLight_HeaderFile
|
||||
|
||||
|
||||
enum V3d_TypeOfPickLight
|
||||
{
|
||||
V3d_POSITIONLIGHT,
|
||||
V3d_SPACELIGHT,
|
||||
V3d_RADIUSTEXTLIGHT,
|
||||
V3d_ExtRADIUSLIGHT,
|
||||
V3d_IntRADIUSLIGHT,
|
||||
V3d_NOTHING
|
||||
};
|
||||
|
||||
#endif // _V3d_TypeOfPickLight_HeaderFile
|
@ -1,29 +0,0 @@
|
||||
// Created on: 1992-11-13
|
||||
// Created by: GG
|
||||
// Copyright (c) 1992-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _V3d_TypeOfRepresentation_HeaderFile
|
||||
#define _V3d_TypeOfRepresentation_HeaderFile
|
||||
|
||||
|
||||
enum V3d_TypeOfRepresentation
|
||||
{
|
||||
V3d_SIMPLE,
|
||||
V3d_COMPLETE,
|
||||
V3d_PARTIAL,
|
||||
V3d_SAMELAST
|
||||
};
|
||||
|
||||
#endif // _V3d_TypeOfRepresentation_HeaderFile
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <Graphic3d_TypeOfShadingModel.hxx>
|
||||
|
||||
Standard_DEPRECATED("Deprecated alias - Graphic3d_TypeOfShadingModel should be used instead")
|
||||
typedef Graphic3d_TypeOfShadingModel V3d_TypeOfShadingModel;
|
||||
|
||||
#endif // _V3d_TypeOfShadingModel_HeaderFile
|
||||
|
@ -2603,9 +2603,9 @@ Standard_Boolean V3d_View::ComputedMode() const
|
||||
//function : SetBackFacingModel
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void V3d_View::SetBackFacingModel (const V3d_TypeOfBackfacingModel theModel)
|
||||
void V3d_View::SetBackFacingModel (const Graphic3d_TypeOfBackfacingModel theModel)
|
||||
{
|
||||
myView->SetBackfacingModel (static_cast<Graphic3d_TypeOfBackfacingModel> (theModel));
|
||||
myView->SetBackfacingModel (theModel);
|
||||
Redraw();
|
||||
}
|
||||
|
||||
@ -2613,9 +2613,9 @@ void V3d_View::SetBackFacingModel (const V3d_TypeOfBackfacingModel theModel)
|
||||
//function : BackFacingModel
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
V3d_TypeOfBackfacingModel V3d_View::BackFacingModel() const
|
||||
Graphic3d_TypeOfBackfacingModel V3d_View::BackFacingModel() const
|
||||
{
|
||||
return static_cast<V3d_TypeOfBackfacingModel> (myView->BackfacingModel());
|
||||
return myView->BackfacingModel();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -876,18 +876,11 @@ public:
|
||||
}
|
||||
|
||||
//! Manages display of the back faces
|
||||
//! When <aModel> is TOBM_AUTOMATIC the object backfaces
|
||||
//! are displayed only for surface objects and
|
||||
//! never displayed for solid objects.
|
||||
//! this was the previous mode.
|
||||
//! <aModel> is TOBM_ALWAYS_DISPLAYED the object backfaces
|
||||
//! are always displayed both for surfaces or solids.
|
||||
//! <aModel> is TOBM_NEVER_DISPLAYED the object backfaces
|
||||
//! are never displayed.
|
||||
Standard_EXPORT void SetBackFacingModel (const V3d_TypeOfBackfacingModel theModel = V3d_TOBM_AUTOMATIC);
|
||||
Standard_EXPORT void SetBackFacingModel (const Graphic3d_TypeOfBackfacingModel theModel = Graphic3d_TypeOfBackfacingModel_Auto);
|
||||
|
||||
//! Returns current state of the back faces display
|
||||
Standard_EXPORT V3d_TypeOfBackfacingModel BackFacingModel() const;
|
||||
//! Returns current state of the back faces display; Graphic3d_TypeOfBackfacingModel_Auto by default,
|
||||
//! which means that backface culling is defined by each presentation.
|
||||
Standard_EXPORT Graphic3d_TypeOfBackfacingModel BackFacingModel() const;
|
||||
|
||||
//! Adds clip plane to the view. The composition of clip planes truncates the
|
||||
//! rendering space to convex volume. Number of supported clip planes can be consulted
|
||||
|
@ -38,7 +38,7 @@ const Standard_GUID& XCAFDoc_VisMaterial::GetID()
|
||||
XCAFDoc_VisMaterial::XCAFDoc_VisMaterial()
|
||||
: myAlphaMode (Graphic3d_AlphaMode_BlendAuto),
|
||||
myAlphaCutOff (0.5f),
|
||||
myIsDoubleSided (Standard_True)
|
||||
myFaceCulling (Graphic3d_TypeOfBackfacingModel_Auto)
|
||||
{
|
||||
//
|
||||
}
|
||||
@ -76,13 +76,13 @@ void XCAFDoc_VisMaterial::SetAlphaMode (Graphic3d_AlphaMode theMode,
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDoubleSided
|
||||
//function : SetFaceCulling
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::SetDoubleSided (Standard_Boolean theIsDoubleSided)
|
||||
void XCAFDoc_VisMaterial::SetFaceCulling (Graphic3d_TypeOfBackfacingModel theFaceCulling)
|
||||
{
|
||||
Backup();
|
||||
myIsDoubleSided = theIsDoubleSided;
|
||||
myFaceCulling = theFaceCulling;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -96,7 +96,7 @@ void XCAFDoc_VisMaterial::Restore (const Handle(TDF_Attribute)& theWith)
|
||||
myCommonMat = anOther->myCommonMat;
|
||||
myAlphaMode = anOther->myAlphaMode;
|
||||
myAlphaCutOff = anOther->myAlphaCutOff;
|
||||
myIsDoubleSided = anOther->myIsDoubleSided;
|
||||
myFaceCulling = anOther->myFaceCulling;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -121,7 +121,7 @@ void XCAFDoc_VisMaterial::Paste (const Handle(TDF_Attribute)& theInto,
|
||||
anOther->myCommonMat = myCommonMat;
|
||||
anOther->myAlphaMode = myAlphaMode;
|
||||
anOther->myAlphaCutOff = myAlphaCutOff;
|
||||
anOther->myIsDoubleSided = myIsDoubleSided;
|
||||
anOther->myFaceCulling = myFaceCulling;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -259,7 +259,7 @@ void XCAFDoc_VisMaterial::FillAspect (const Handle(Graphic3d_Aspects)& theAspect
|
||||
FillMaterialAspect (aMaterial);
|
||||
theAspect->SetFrontMaterial (aMaterial);
|
||||
theAspect->SetAlphaMode (myAlphaMode , myAlphaCutOff);
|
||||
theAspect->SetSuppressBackFaces (!myIsDoubleSided);
|
||||
theAspect->SetFaceCulling (myFaceCulling);
|
||||
|
||||
const Handle(Image_Texture)& aColorTexture = !myPbrMat.BaseColorTexture.IsNull() ? myPbrMat.BaseColorTexture : myCommonMat.DiffuseTexture;
|
||||
Standard_Integer aNbTexUnits = 0;
|
||||
@ -317,5 +317,5 @@ void XCAFDoc_VisMaterial::DumpJson (Standard_OStream& theOStream, Standard_Integ
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAlphaMode)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAlphaCutOff)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsDoubleSided)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFaceCulling)
|
||||
}
|
||||
|
@ -14,6 +14,8 @@
|
||||
#ifndef _XCAFDoc_VisMaterial_HeaderFile
|
||||
#define _XCAFDoc_VisMaterial_HeaderFile
|
||||
|
||||
#include <Graphic3d_AlphaMode.hxx>
|
||||
#include <Graphic3d_TypeOfBackfacingModel.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <XCAFDoc_VisMaterialCommon.hxx>
|
||||
#include <XCAFDoc_VisMaterialPBR.hxx>
|
||||
@ -104,11 +106,20 @@ public:
|
||||
Standard_EXPORT void SetAlphaMode (Graphic3d_AlphaMode theMode,
|
||||
Standard_ShortReal theCutOff = 0.5f);
|
||||
|
||||
//! Specifies whether the material is double sided; TRUE by default.
|
||||
Standard_Boolean IsDoubleSided() const { return myIsDoubleSided; }
|
||||
//! Returns if the material is double or single sided; Graphic3d_TypeOfBackfacingModel_Auto by default.
|
||||
Graphic3d_TypeOfBackfacingModel FaceCulling() const { return myFaceCulling; }
|
||||
|
||||
//! Specifies whether the material is double sided.
|
||||
Standard_EXPORT void SetDoubleSided (Standard_Boolean theIsDoubleSided);
|
||||
//! Specifies whether the material is double or single sided.
|
||||
Standard_EXPORT void SetFaceCulling (Graphic3d_TypeOfBackfacingModel theFaceCulling);
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, FaceCulling() should be used instead")
|
||||
Standard_Boolean IsDoubleSided() const { return myFaceCulling == Graphic3d_TypeOfBackfacingModel_DoubleSided; }
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used instead")
|
||||
void SetDoubleSided (Standard_Boolean theIsDoubleSided)
|
||||
{
|
||||
SetFaceCulling (theIsDoubleSided ? Graphic3d_TypeOfBackfacingModel_DoubleSided : Graphic3d_TypeOfBackfacingModel_Auto);
|
||||
}
|
||||
|
||||
//! Return material name / tag (transient data, not stored in the document).
|
||||
const Handle(TCollection_HAsciiString)& RawName() const { return myRawName; }
|
||||
@ -124,7 +135,7 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return theOther->myIsDoubleSided == myIsDoubleSided
|
||||
return theOther->myFaceCulling == myFaceCulling
|
||||
&& theOther->myAlphaCutOff == myAlphaCutOff
|
||||
&& theOther->myAlphaMode == myAlphaMode
|
||||
&& theOther->myCommonMat.IsEqual (myCommonMat)
|
||||
@ -165,7 +176,7 @@ private:
|
||||
XCAFDoc_VisMaterialCommon myCommonMat; //!< common material definition
|
||||
Graphic3d_AlphaMode myAlphaMode; //!< alpha mode; Graphic3d_AlphaMode_BlendAuto by default
|
||||
Standard_ShortReal myAlphaCutOff; //!< alpha cutoff value; 0.5 by default
|
||||
Standard_Boolean myIsDoubleSided; //!< specifies whether the material is double sided; TRUE by default
|
||||
Graphic3d_TypeOfBackfacingModel myFaceCulling; //!< specifies whether the material is double/single sided
|
||||
|
||||
};
|
||||
|
||||
|
@ -93,6 +93,18 @@ static const char* alphaModeToString (Graphic3d_AlphaMode theMode)
|
||||
return "";
|
||||
}
|
||||
|
||||
//! Convert back face culling mode into string.
|
||||
static const char* faceCullToString (Graphic3d_TypeOfBackfacingModel theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case Graphic3d_TypeOfBackfacingModel_Auto: return "Auto";
|
||||
case Graphic3d_TypeOfBackfacingModel_BackCulled: return "BackCulled";
|
||||
case Graphic3d_TypeOfBackfacingModel_DoubleSided: return "DoubleSided";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//! Find existing visualization material in the document.
|
||||
static TDF_Label findVisMaterial (const Handle(TDocStd_Document)& theDoc,
|
||||
const TCollection_AsciiString& theKey)
|
||||
@ -860,7 +872,7 @@ static Standard_Integer XGetVisMaterial (Draw_Interpretor& theDI, Standard_Integ
|
||||
}
|
||||
theDI << "AlphaMode: " << alphaModeToString (aMat->AlphaMode()) << "\n";
|
||||
theDI << "AlphaCutOff: " << aMat->AlphaCutOff() << "\n";
|
||||
theDI << "IsDoubleSided: " << aMat->IsDoubleSided() << "\n";
|
||||
theDI << "IsDoubleSided: " << faceCullToString (aMat->FaceCulling()) << "\n";
|
||||
if (aMat->HasCommonMaterial())
|
||||
{
|
||||
const XCAFDoc_VisMaterialCommon& aMatCom = aMat->CommonMaterial();
|
||||
@ -968,7 +980,7 @@ static Standard_Integer XAddVisMaterial (Draw_Interpretor& , Standard_Integer th
|
||||
++anArgIter;
|
||||
aMatPbr.IsDefined = true;
|
||||
}
|
||||
else if (anArg == "-alphaMode"
|
||||
else if (anArg == "-alphamode"
|
||||
&& anArgIter + 2 < theNbArgs
|
||||
&& parseNormalizedReal (theArgVec[anArgIter + 2], aRealValue))
|
||||
{
|
||||
@ -1130,7 +1142,36 @@ static Standard_Integer XAddVisMaterial (Draw_Interpretor& , Standard_Integer th
|
||||
{
|
||||
++anArgIter;
|
||||
}
|
||||
aMat->SetDoubleSided (isDoubleSided);
|
||||
aMat->SetFaceCulling (isDoubleSided ? Graphic3d_TypeOfBackfacingModel_Auto : Graphic3d_TypeOfBackfacingModel_BackCulled);
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& (anArg == "-faceculling"
|
||||
|| anArg == "-facecull"))
|
||||
{
|
||||
aMatPbr.IsDefined = true;
|
||||
TCollection_AsciiString aCullStr (theArgVec[++anArgIter]);
|
||||
Graphic3d_TypeOfBackfacingModel aMode = Graphic3d_TypeOfBackfacingModel_Auto;
|
||||
aCullStr.LowerCase();
|
||||
if (aCullStr == "auto")
|
||||
{
|
||||
aMode = Graphic3d_TypeOfBackfacingModel_Auto;
|
||||
}
|
||||
else if (aCullStr == "backculled"
|
||||
|| aCullStr == "backcull"
|
||||
|| aCullStr == "back")
|
||||
{
|
||||
aMode = Graphic3d_TypeOfBackfacingModel_BackCulled;
|
||||
}
|
||||
else if (aCullStr == "doublesided")
|
||||
{
|
||||
aMode = Graphic3d_TypeOfBackfacingModel_DoubleSided;
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::SendFail() << "Syntax error at '" << anArg << "'";
|
||||
return 1;
|
||||
}
|
||||
aMat->SetFaceCulling (aMode);
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-metallic"
|
||||
@ -1329,7 +1370,7 @@ void XDEDRAW_Colors::InitCommands(Draw_Interpretor& di)
|
||||
"\n\t\t: [-emissiveFactor RGB] [-emissiveTexture ImagePath]"
|
||||
"\n\t\t: [-metallic 0..1] [-roughness 0..1] [-metallicRoughnessTexture ImagePath]"
|
||||
"\n\t\t: [-occlusionTexture ImagePath] [-normalTexture ImagePath]"
|
||||
"\n\t\t: [-doubleSided {0|1}]"
|
||||
"\n\t\t: [-faceCulling {auto|backCulled|doubleSided}] [-doubleSided {0|1}]"
|
||||
"\n\t\t: Add material into Document's material table.",
|
||||
__FILE__, XAddVisMaterial, g);
|
||||
di.Add ("XRemoveVisMaterial","Doc Material"
|
||||
|
@ -252,11 +252,15 @@ Standard_Boolean XmlMXCAFDoc_VisMaterialDriver::Paste (const XmlObjMgt_Persisten
|
||||
Handle(XCAFDoc_VisMaterial) aMat = Handle(XCAFDoc_VisMaterial)::DownCast(theTarget);
|
||||
|
||||
const XmlObjMgt_DOMString aDoubleSidedStr = theSource.Element().getAttribute (::IsDoubleSided());
|
||||
Standard_Integer isDoubleSided = 1;
|
||||
aDoubleSidedStr.GetInteger (isDoubleSided);
|
||||
Standard_Integer aDoubleSidedInt = 1;
|
||||
aDoubleSidedStr.GetInteger (aDoubleSidedInt);
|
||||
Standard_ShortReal anAlphaCutOff = 0.5f;
|
||||
readReal (theSource, ::AlphaCutOff(), anAlphaCutOff);
|
||||
aMat->SetDoubleSided (isDoubleSided != 0);
|
||||
aMat->SetFaceCulling (aDoubleSidedInt == 1
|
||||
? Graphic3d_TypeOfBackfacingModel_DoubleSided
|
||||
: (aDoubleSidedInt == 2
|
||||
? Graphic3d_TypeOfBackfacingModel_BackCulled
|
||||
: Graphic3d_TypeOfBackfacingModel_Auto));
|
||||
aMat->SetAlphaMode (alphaModeFromString (theSource.Element().getAttribute (::AlphaMode()).GetString()), anAlphaCutOff);
|
||||
|
||||
Quantity_ColorRGBA aBaseColor;
|
||||
@ -303,8 +307,12 @@ void XmlMXCAFDoc_VisMaterialDriver::Paste (const Handle(TDF_Attribute)& theSourc
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aMat = Handle(XCAFDoc_VisMaterial)::DownCast(theSource);
|
||||
|
||||
theTarget.Element().setAttribute (::IsDoubleSided(), aMat->IsDoubleSided() ? 1 : 0);
|
||||
Standard_Integer aDoubleSidedInt = aMat->FaceCulling() == Graphic3d_TypeOfBackfacingModel_DoubleSided
|
||||
? 1
|
||||
: (aMat->FaceCulling() == Graphic3d_TypeOfBackfacingModel_BackCulled
|
||||
? 2
|
||||
: 0);
|
||||
theTarget.Element().setAttribute (::IsDoubleSided(), aDoubleSidedInt);
|
||||
theTarget.Element().setAttribute (::AlphaMode(), alphaModeToString (aMat->AlphaMode()));
|
||||
writeReal (theTarget, ::AlphaCutOff(), aMat->AlphaCutOff());
|
||||
if (aMat->HasPbrMaterial())
|
||||
|
Loading…
x
Reference in New Issue
Block a user