diff --git a/src/Base/Builder3D.cpp b/src/Base/Builder3D.cpp index 11d5b5af2c..6ace7635ba 100644 --- a/src/Base/Builder3D.cpp +++ b/src/Base/Builder3D.cpp @@ -385,11 +385,13 @@ void InventorBuilder::addBaseColor(float color_r,float color_g,float color_b) result << Base::blanks(indent) << "} " << std::endl; } -void InventorBuilder::addMaterial(float color_r,float color_g,float color_b) +void InventorBuilder::addMaterial(float color_r,float color_g,float color_b,float color_a) { result << Base::blanks(indent) << "Material { " << std::endl; result << Base::blanks(indent) << " diffuseColor " << color_r << " "<< color_g << " "<< color_b << std::endl; + if (color_a > 0) + result << Base::blanks(indent) << " transparency " << color_a << std::endl; result << Base::blanks(indent) << "} " << std::endl; } @@ -688,6 +690,29 @@ void InventorBuilder::addIndexedFaceSet(const std::vector& indices) result << Base::blanks(indent) << "} " << std::endl; } +void InventorBuilder::addFaceSet(const std::vector& vertices) +{ + result << Base::blanks(indent) << "FaceSet { " << std::endl + << Base::blanks(indent) << " numVertices [ " << std::endl; + + indent += 4; + std::vector::const_iterator it_last_f = vertices.end()-1; + int index=0; + for (std::vector::const_iterator it = vertices.begin(); it != vertices.end(); ++it) { + if (index % 8 == 0) + result << Base::blanks(indent); + if (it != it_last_f) + result << *it << ", "; + else + result << *it << " ] " << std::endl; + if (++index % 8 == 0) + result << std::endl; + } + indent -= 4; + + result << Base::blanks(indent) << "} " << std::endl; +} + void InventorBuilder::beginNormal() { result << Base::blanks(indent) << "Normal { " << std::endl; diff --git a/src/Base/Builder3D.h b/src/Base/Builder3D.h index b30665f34b..81454fb845 100644 --- a/src/Base/Builder3D.h +++ b/src/Base/Builder3D.h @@ -189,8 +189,9 @@ public: * \param color_r - red color * \param color_g - green color * \param color_b - blue color + * \param color_a - transparency */ - void addMaterial(float color_r,float color_g,float color_b); + void addMaterial(float color_r,float color_g,float color_b,float color_a=0); /*! * \brief Starts a material node. The node must be closed with \ref endMaterial * and the colors must be added with \ref addColor(). @@ -291,6 +292,7 @@ public: void addSinglePlane(const Vector3f& base, const Vector3f& eX, const Vector3f& eY, float length, float width, bool filled = true, short lineSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0); void addIndexedFaceSet(const std::vector& indices); + void addFaceSet(const std::vector& vertices); //@} /** @name Surface handling */