//=================================================================================================
+void RWGltf_CafWriter::writeMaterial(RWMesh_ShapeIterator& theShapeIter,
+ Standard_Boolean& theIsStarted,
+ Standard_Integer& theAddedMaterialsNb)
+{
+ for (; theShapeIter.More(); theShapeIter.Next())
+ {
+ myMaterialMap->AddMaterial(myWriter.get(), theShapeIter.Style(), theIsStarted);
+ theAddedMaterialsNb++;
+ }
+}
+
+//=================================================================================================
+
void RWGltf_CafWriter::writeMaterials(const RWGltf_GltfSceneNodeMap& theSceneNodeMap)
{
#ifdef HAVE_RAPIDJSON
for (RWGltf_GltfSceneNodeMap::Iterator aSceneNodeIter(theSceneNodeMap); aSceneNodeIter.More();
aSceneNodeIter.Next())
{
- const XCAFPrs_DocumentNode& aDocNode = aSceneNodeIter.Value();
- for (RWMesh_FaceIterator aFaceIter(aDocNode.RefLabel, TopLoc_Location(), true, aDocNode.Style);
- aFaceIter.More();
- aFaceIter.Next())
+ const XCAFPrs_DocumentNode& aDocNode = aSceneNodeIter.Value();
+ Standard_Integer anAddedMaterialsNb = 0;
+ {
+ RWMesh_FaceIterator aFaceIter(aDocNode.RefLabel, TopLoc_Location(), true, aDocNode.Style);
+ writeMaterial(aFaceIter, anIsStarted, anAddedMaterialsNb);
+ }
+ if (anAddedMaterialsNb == 0)
+ {
+ RWMesh_EdgeIterator anEdgeIter(aDocNode.RefLabel, TopLoc_Location(), true, aDocNode.Style);
+ writeMaterial(anEdgeIter, anIsStarted, anAddedMaterialsNb);
+ }
+ if (anAddedMaterialsNb == 0)
{
- myMaterialMap->AddMaterial(myWriter.get(), aFaceIter.Style(), anIsStarted);
+ RWMesh_VertexIterator VertexIter(aDocNode.RefLabel, TopLoc_Location(), true, aDocNode.Style);
+ writeMaterial(VertexIter, anIsStarted, anAddedMaterialsNb);
}
}
if (anIsStarted)
//! @param[out] theMaterialMap map of materials, filled with materials
Standard_EXPORT virtual void writeMaterials(const RWGltf_GltfSceneNodeMap& theSceneNodeMap);
+ //! Write RWGltf_GltfRootElement_Materials section.
+ //! @param[in] theShapeIter Shape iterator to traverse shapes
+ //! @param[out] theIsStarted Flag indicating that writing material has been started
+ //! @param[out] theAddedMaterialsNb Number of added materials
+ Standard_EXPORT virtual void writeMaterial(RWMesh_ShapeIterator& theShapeIter,
+ Standard_Boolean& theIsStarted,
+ Standard_Integer& theAddedMaterialsNb);
+
//! Write RWGltf_GltfRootElement_Meshes section.
//! @param[in] theSceneNodeMap ordered map of scene nodes
//! @param[in] theMaterialMap map of materials
#ifdef HAVE_RAPIDJSON
if (theWriter == NULL
|| ((theStyle.Material().IsNull() || theStyle.Material()->IsEmpty())
- && !theStyle.IsSetColorSurf()))
+ && !theStyle.IsSetColorSurf() && !theStyle.IsSetColorCurv()))
{
return;
}
aPbrMat.BaseColor.SetAlpha(theStyle.GetColorSurfRGBA().Alpha());
}
}
+ else if (theStyle.IsSetColorCurv())
+ {
+ aPbrMat.BaseColor.SetRGB(theStyle.GetColorCurv());
+ }
myWriter->StartObject();
{
myWriter->Key("name");