From 9a3211c343590c71936eee93fcc4b6c50a239d38 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 16 Dec 2015 16:09:31 +0100 Subject: [PATCH] + extend Inventor builder to support material nodes --- src/Base/Builder3D.cpp | 21 +++++++++++++++++++++ src/Base/Builder3D.h | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/Base/Builder3D.cpp b/src/Base/Builder3D.cpp index 7ced84820..0bc5e7fde 100644 --- a/src/Base/Builder3D.cpp +++ b/src/Base/Builder3D.cpp @@ -393,6 +393,27 @@ void InventorBuilder::addMaterial(float color_r,float color_g,float color_b) result << Base::blanks(indent) << "} " << std::endl; } +void InventorBuilder::beginMaterial() +{ + result << Base::blanks(indent) << "Material { " << std::endl; + indent +=2; + result << Base::blanks(indent) << "diffuseColor [" << std::endl; + indent +=2; +} + +void InventorBuilder::endMaterial() +{ + indent -=2; + result << Base::blanks(indent) << "]" << std::endl; + indent -=2; + result << Base::blanks(indent) << "}" << std::endl; +} + +void InventorBuilder::addColor(float color_r,float color_g,float color_b) +{ + result << color_r << " " << color_g << " " << color_b << std::endl; +} + void InventorBuilder::addMaterialBinding(const char* bind) { result << Base::blanks(indent) << "MaterialBinding { value " diff --git a/src/Base/Builder3D.h b/src/Base/Builder3D.h index bee4327a7..9a78e1305 100644 --- a/src/Base/Builder3D.h +++ b/src/Base/Builder3D.h @@ -175,6 +175,8 @@ public: * \param str - text set to the label node */ void addLabel(const char* str); + /** @name Appearance handling */ + //@{ /*! * \brief Sets a base color node. The colors are in the range [0, 1]. * \param color_r - red color @@ -189,6 +191,22 @@ public: * \param color_b - blue color */ void addMaterial(float color_r,float color_g,float color_b); + /*! + * \brief Starts a material node. The node must be closed with \ref endMaterial + * and the colors must be added with \ref addColor(). + */ + void beginMaterial(); + /*! + * \brief Closes a material node. + */ + void endMaterial(); + /*! + * \brief Adds a color to a material node. The colors are in the range [0, 1]. + * \param color_r - red color + * \param color_g - green color + * \param color_b - blue color + */ + void addColor(float color_r,float color_g,float color_b); /*! * \brief Sets a material binding node. * \param binding - binding of the material. Allowed values are: @@ -210,6 +228,7 @@ public: * \param crease - the crease angle in radians */ void addShapeHints(float crease=0.0f); + //@} /** @name Add coordinates */ //@{