]> OCCT Git - occt.git/commitdiff
0032188: Visualization, Graphic3d_Aspects - define backface culling using Graphic3d_T...
authorkgv <kgv@opencascade.com>
Mon, 1 Mar 2021 20:25:21 +0000 (23:25 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 4 Mar 2021 16:40:23 +0000 (19:40 +0300)
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.

28 files changed:
src/AIS/AIS_ViewCube.cxx
src/BinMXCAFDoc/BinMXCAFDoc_VisMaterialDriver.cxx
src/Graphic3d/Graphic3d_Aspects.cxx
src/Graphic3d/Graphic3d_Aspects.hxx
src/Graphic3d/Graphic3d_CView.cxx
src/Graphic3d/Graphic3d_CView.hxx
src/Graphic3d/Graphic3d_ClipPlane.cxx
src/Graphic3d/Graphic3d_TypeOfBackfacingModel.hxx
src/OpenGl/OpenGl_View.cxx
src/OpenGl/OpenGl_View.hxx
src/OpenGl/OpenGl_Workspace.cxx
src/RWGltf/RWGltf_GltfJsonParser.cxx
src/RWGltf/RWGltf_GltfMaterialMap.cxx
src/V3d/FILES
src/V3d/V3d_Coordinate.hxx [deleted file]
src/V3d/V3d_PositionLight.hxx
src/V3d/V3d_TypeOfBackfacingModel.hxx
src/V3d/V3d_TypeOfLight.hxx
src/V3d/V3d_TypeOfPickCamera.hxx [deleted file]
src/V3d/V3d_TypeOfPickLight.hxx [deleted file]
src/V3d/V3d_TypeOfRepresentation.hxx [deleted file]
src/V3d/V3d_TypeOfShadingModel.hxx
src/V3d/V3d_View.cxx
src/V3d/V3d_View.hxx
src/XCAFDoc/XCAFDoc_VisMaterial.cxx
src/XCAFDoc/XCAFDoc_VisMaterial.hxx
src/XDEDRAW/XDEDRAW_Colors.cxx
src/XmlMXCAFDoc/XmlMXCAFDoc_VisMaterialDriver.cxx

index fe18f9f4a3c782d397045161155893d493f2aa1c..a1719c6d61512152fe8507afe76e93cff1aab279 100644 (file)
@@ -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);
       }
index 85c756577dab11abe89eb8979deadba8e3fe20d7..7e18a19043189bbdeafe1a01fb9e852a07c9f3c5 100644 (file)
@@ -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());
 
index 8648a7ba4af1f57760e20a89a6ece7c592d01742..e50ea537082662dbfc95a65b7524e1541ec87003 100644 (file)
@@ -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)
 
index 65b9f1a70d60a940d54c12af3ab4cb98f8a9c115..6606d129e044e6cccd4e83f4434323001942b86b 100644 (file)
 #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;
 
index 2219b947e91dfaba7b661fc943ce30a26c23fbd5..6a6fb0821128b8d69ff8118268bd4f34892f5b85 100644 (file)
@@ -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)
 {
index 639f8875dff02f1fb7fc598bec38da123eff28d6..4f87d9b116ad3aa5679129403fcbaa36c947134e 100644 (file)
@@ -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;
index 15911bb02340bc44e06c7b426b4755739667415d..e97a80a3e3f933a1e70f52b9ccbd48ac439f1096 100755 (executable)
@@ -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;
   }
 }
index 0182d945ed0fed19eacf314b13fcae8d8cc7e30e..aae849b5cd8880f410e65f91b39a6d8e5e0f7318 100644 (file)
 #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
index 57af07f5b1c6b968a65f83929af5ce92866174b1..c386352b10760e77c433ea24db92ed3ce67e2f72 100644 (file)
@@ -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
   {
index d041a895ea3961adf7e16f14dc8bc9ecf9759730..8ccda34be8098767fc2f6a5f8e73b47a949a7f27 100644 (file)
@@ -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;
index c39c76c4e84a1a4dc1cc511e6feb0a351123d72d..04cb70d4618fa15b8e77c4765d593c11de7f25e6 100644 (file)
@@ -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)
index 8ef379737d85ac21b551dfe816cedc4ae8fc67ad..26060877a52e31b3a00b938b344e4a111063c2cf 100644 (file)
@@ -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())
     {
index e541e6f15061f41225dda50faab076d826ab89e4..e81d1ae4fbde2f3b28b8ea7d717f4fe8d282788e 100644 (file)
@@ -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);
index a704e23f5660fcf04bb820cc41a7653fdd1a6a08..45e08ec58fa60d335bd0ebeb60919ec02c956a36 100755 (executable)
@@ -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
diff --git a/src/V3d/V3d_Coordinate.hxx b/src/V3d/V3d_Coordinate.hxx
deleted file mode 100644 (file)
index d9dc7e3..0000000
+++ /dev/null
@@ -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
index b0b781f010096b7ef480dd66e0b7ec69df864be5..42c78be6c95c5a51d1c99a1180b3c15da7ed87e2 100644 (file)
@@ -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
index b48ae9b1be75ec276849fa38621abe4e8e7e7084..3d10b9aea09190f5294b1ca14e5c365219b08f23 100644 (file)
 #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
index 4ae6acbcf689847cf7d8df7559e516d9f7eea319..e0412aa815da6c82c8f1d8be66fc9f0f375947a4 100644 (file)
@@ -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
diff --git a/src/V3d/V3d_TypeOfPickCamera.hxx b/src/V3d/V3d_TypeOfPickCamera.hxx
deleted file mode 100644 (file)
index 58eb810..0000000
+++ /dev/null
@@ -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
diff --git a/src/V3d/V3d_TypeOfPickLight.hxx b/src/V3d/V3d_TypeOfPickLight.hxx
deleted file mode 100644 (file)
index 92939a1..0000000
+++ /dev/null
@@ -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
diff --git a/src/V3d/V3d_TypeOfRepresentation.hxx b/src/V3d/V3d_TypeOfRepresentation.hxx
deleted file mode 100644 (file)
index ed954ab..0000000
+++ /dev/null
@@ -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
index 523a8b32f55ff9c801d8f7eef3bc036dddc09d49..24b890805ef4c2bb485ae6ab8fef6b150100198d 100644 (file)
@@ -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
index 8683c77d19c7f4ca58c6b52ddaf1aae8737be905..a5a5c3fe9b0e44606610d3ad1f32e736713fd76b 100644 (file)
@@ -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();
 }
 
 //=============================================================================
index 3b4fb6cce29f2b1822c28ddbcaeb213ea69b1321..3c0ce8ecae9c3c6bb2b0d6470ac731d34220c722 100644 (file)
@@ -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);
-
-  //! Returns current state of the back faces display
-  Standard_EXPORT V3d_TypeOfBackfacingModel BackFacingModel() const;
+  Standard_EXPORT void SetBackFacingModel (const Graphic3d_TypeOfBackfacingModel theModel = Graphic3d_TypeOfBackfacingModel_Auto);
+
+  //! 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
index f3bfac989dd9a7787f27a280d084c955bb351cdf..2be94298b94c25b5aaa2f38b9ce517ed36371f32 100644 (file)
@@ -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)
 }
index 54e53ad637f21a329859a9907d85f7cdac369249..a94a81a5076d9bb1855b719a48c686a51692741b 100644 (file)
@@ -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
 
 };
 
index a74a0d9c34806cef23a5123b98e6e83fecfd204b..83f31c0c3672d0b516f05cf3ff2739cdfc2120c1 100644 (file)
@@ -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"
index cc000c8e9b42a5d4383779d40c69250a1ecf8f49..c63fcd1905487e698e158b46acbab00351104a95 100644 (file)
@@ -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())