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);
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);
{
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);
}
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)
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;
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());
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),
myToDistinguishMaterials (false),
myToDrawEdges (false),
myToDrawSilhouette (false),
- myToSuppressBackFaces (true),
myToMapTexture (false),
myIsTextZoomable (false)
{
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)
#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>
//! 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; }
&& myBackMaterial == theOther.myBackMaterial
&& myInteriorStyle == theOther.myInteriorStyle
&& myShadingModel == theOther.myShadingModel
+ && myFaceCulling == theOther.myFaceCulling
&& myAlphaMode == theOther.myAlphaMode
&& myAlphaCutoff == theOther.myAlphaCutoff
&& myLineType == theOther.myLineType
&& myToDistinguishMaterials == theOther.myToDistinguishMaterials
&& myToDrawEdges == theOther.myToDrawEdges
&& myToDrawSilhouette == theOther.myToDrawSilhouette
- && myToSuppressBackFaces == theOther.myToSuppressBackFaces
&& myToMapTexture == theOther.myToMapTexture
&& myIsTextZoomable == theOther.myIsTextZoomable;
}
//! 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:
Graphic3d_PolygonOffset myPolygonOffset;
Aspect_InteriorStyle myInteriorStyle;
Graphic3d_TypeOfShadingModel myShadingModel;
+ Graphic3d_TypeOfBackfacingModel myFaceCulling;
Graphic3d_AlphaMode myAlphaMode;
Standard_ShortReal myAlphaCutoff;
bool myToDistinguishMaterials;
bool myToDrawEdges;
bool myToDrawSilhouette;
- bool myToSuppressBackFaces;
bool myToMapTexture;
bool myIsTextZoomable;
myIsActive (Standard_False),
myIsRemoved (Standard_False),
myShadingModel (Graphic3d_TOSM_FRAGMENT),
+ myBackfacing (Graphic3d_TypeOfBackfacingModel_Auto),
myVisualization (Graphic3d_TOV_WIREFRAME),
myUnitFactor (1.0)
{
//! 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; }
//! 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;
Standard_Boolean myIsActive;
Standard_Boolean myIsRemoved;
Graphic3d_TypeOfShadingModel myShadingModel;
+ Graphic3d_TypeOfBackfacingModel myBackfacing;
Graphic3d_TypeOfVisualization myVisualization;
Handle(Aspect_XRSession) myXRSession;
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;
}
}
#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
myDriver (theDriver.operator->()),
myCaps (theCaps),
myWasRedrawnGL (Standard_False),
- myBackfacing (Graphic3d_TOBM_AUTOMATIC),
myToShowGradTrihedron (false),
myZLayers (Structure_MAX_PRIORITY - Structure_MIN_PRIORITY + 1),
myStateCounter (theCounter),
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);
// 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
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
{
//! 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; }
Handle(OpenGl_Caps) myCaps;
Standard_Boolean myWasRedrawnGL;
- Graphic3d_TypeOfBackfacingModel myBackfacing;
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
gp_XYZ myLocalOrigin;
Handle(OpenGl_FrameBuffer) myFBO;
#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);
}
// =======================================================================
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
toSuppressBackFaces = false;
}
}
- myGlContext->SetCullBackFaces (toSuppressBackFaces);
}
+ myGlContext->SetCullBackFaces (toSuppressBackFaces);
if (myAspectsSet->Aspect() == myAspectsApplied
&& myHighlightStyle == myAspectFaceAppliedWithHL)
}
}
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())
{
}
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);
V3d_BadValue.hxx
V3d_CircularGrid.cxx
V3d_CircularGrid.hxx
-V3d_Coordinate.hxx
V3d_DirectionalLight.cxx
V3d_DirectionalLight.hxx
V3d_ImageDumpOptions.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
+++ /dev/null
-// 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
#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
#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
#include <Graphic3d_TypeOfLightSource.hxx>
+Standard_DEPRECATED("Deprecated alias - Graphic3d_TypeOfLightSource should be used instead")
typedef Graphic3d_TypeOfLightSource V3d_TypeOfLight;
#endif // _V3d_TypeOfLight_HeaderFile
+++ /dev/null
-// 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
+++ /dev/null
-// 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
+++ /dev/null
-// 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
#include <Graphic3d_TypeOfShadingModel.hxx>
+Standard_DEPRECATED("Deprecated alias - Graphic3d_TypeOfShadingModel should be used instead")
typedef Graphic3d_TypeOfShadingModel V3d_TypeOfShadingModel;
#endif // _V3d_TypeOfShadingModel_HeaderFile
//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();
}
//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();
}
//=============================================================================
}
//! 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
XCAFDoc_VisMaterial::XCAFDoc_VisMaterial()
: myAlphaMode (Graphic3d_AlphaMode_BlendAuto),
myAlphaCutOff (0.5f),
- myIsDoubleSided (Standard_True)
+ myFaceCulling (Graphic3d_TypeOfBackfacingModel_Auto)
{
//
}
}
//=======================================================================
-//function : SetDoubleSided
+//function : SetFaceCulling
//purpose :
//=======================================================================
-void XCAFDoc_VisMaterial::SetDoubleSided (Standard_Boolean theIsDoubleSided)
+void XCAFDoc_VisMaterial::SetFaceCulling (Graphic3d_TypeOfBackfacingModel theFaceCulling)
{
Backup();
- myIsDoubleSided = theIsDoubleSided;
+ myFaceCulling = theFaceCulling;
}
//=======================================================================
myCommonMat = anOther->myCommonMat;
myAlphaMode = anOther->myAlphaMode;
myAlphaCutOff = anOther->myAlphaCutOff;
- myIsDoubleSided = anOther->myIsDoubleSided;
+ myFaceCulling = anOther->myFaceCulling;
}
//=======================================================================
anOther->myCommonMat = myCommonMat;
anOther->myAlphaMode = myAlphaMode;
anOther->myAlphaCutOff = myAlphaCutOff;
- anOther->myIsDoubleSided = myIsDoubleSided;
+ anOther->myFaceCulling = myFaceCulling;
}
// =======================================================================
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;
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)
}
#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>
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; }
{
return true;
}
- return theOther->myIsDoubleSided == myIsDoubleSided
+ return theOther->myFaceCulling == myFaceCulling
&& theOther->myAlphaCutOff == myAlphaCutOff
&& theOther->myAlphaMode == myAlphaMode
&& theOther->myCommonMat.IsEqual (myCommonMat)
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
};
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)
}
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();
++anArgIter;
aMatPbr.IsDefined = true;
}
- else if (anArg == "-alphaMode"
+ else if (anArg == "-alphamode"
&& anArgIter + 2 < theNbArgs
&& parseNormalizedReal (theArgVec[anArgIter + 2], aRealValue))
{
{
++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"
"\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"
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;
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())