extend InventorBuilder

This commit is contained in:
wmayer
2017-10-16 11:03:21 +02:00
parent 930089c6f0
commit fb1fcf3885
2 changed files with 29 additions and 2 deletions

View File

@@ -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<int>& indices)
result << Base::blanks(indent) << "} " << std::endl;
}
void InventorBuilder::addFaceSet(const std::vector<int>& vertices)
{
result << Base::blanks(indent) << "FaceSet { " << std::endl
<< Base::blanks(indent) << " numVertices [ " << std::endl;
indent += 4;
std::vector<int>::const_iterator it_last_f = vertices.end()-1;
int index=0;
for (std::vector<int>::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;

View File

@@ -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<int>& indices);
void addFaceSet(const std::vector<int>& vertices);
//@}
/** @name Surface handling */