diff --git a/ColorPlugin.cc b/ColorPlugin.cc index 15682c401704a108026ae74438d96509c1ed661b..06a780312145bbe6dea0e636d8a7eb15957e25bb 100644 --- a/ColorPlugin.cc +++ b/ColorPlugin.cc @@ -310,6 +310,57 @@ void ColorPlugin::setObjectEmissiveColor(int _objectId , Vector4 _color) { //----------------------------------------------------------------------------- +/** Sets the ambient color of an object + * + * @param _objectId Id of an Object + * @param _color Color to be set + */ +void ColorPlugin::setObjectAmbientColor(int _objectId , Vector4 _color) { + BaseObjectData* object; + if ( ! PluginFunctions::getObject(_objectId,object) ) { + return; + } + + OpenMesh::Vec4f tmp = OpenMesh::Vec4f(_color); + object->materialNode()->set_ambient_color(tmp); +} + +//----------------------------------------------------------------------------- + +/** Sets the diffuse color of an object + * + * @param _objectId Id of an Object + * @param _color Color to be set + */ +void ColorPlugin::setObjectDiffuseColor(int _objectId , Vector4 _color) { + BaseObjectData* object; + if ( ! PluginFunctions::getObject(_objectId,object) ) { + return; + } + + OpenMesh::Vec4f tmp = OpenMesh::Vec4f(_color); + object->materialNode()->set_diffuse_color(tmp); +} + +//----------------------------------------------------------------------------- + +/** Sets the specular color of an object + * + * @param _objectId Id of an Object + * @param _color Color to be set + */ +void ColorPlugin::setObjectSpecularColor(int _objectId , Vector4 _color) { + BaseObjectData* object; + if ( ! PluginFunctions::getObject(_objectId,object) ) { + return; + } + + OpenMesh::Vec4f tmp = OpenMesh::Vec4f(_color); + object->materialNode()->set_specular_color(tmp); +} + +//----------------------------------------------------------------------------- + /** \brief Generate an icon with given color * * @param _color a color vector diff --git a/ColorPlugin.hh b/ColorPlugin.hh index d6ef99f233691a0ffe06eda97246ddf42c6f41ac..a6fab8febd1d8690e22d5ab9ddc1b663046f1459 100644 --- a/ColorPlugin.hh +++ b/ColorPlugin.hh @@ -186,6 +186,21 @@ class ColorPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterfac */ void setObjectEmissiveColor(int _objectId , Vector4 _color); + /** + * Sets the ambient color of an object + */ + void setObjectAmbientColor(int _objectId , Vector4 _color); + + /** + * Sets the diffuse color of an object + */ + void setObjectDiffuseColor(int _objectId , Vector4 _color); + + /** + * Sets the specular color of an object + */ + void setObjectSpecularColor(int _objectId , Vector4 _color); + /** @} */ //===========================================================================