[Orxonox-commit 4732] r9401 - code/branches/shaders/src/libraries/tools

davidsa at orxonox.net davidsa at orxonox.net
Tue Oct 16 15:30:20 CEST 2012


Author: davidsa
Date: 2012-10-16 15:30:20 +0200 (Tue, 16 Oct 2012)
New Revision: 9401

Modified:
   code/branches/shaders/src/libraries/tools/Mesh.cc
   code/branches/shaders/src/libraries/tools/Mesh.h
Log:
Orxonox::Mesh: Added functions setMaterial() and getMaterial() to easily attach a material/shader to a Mesh via the provided functions in Ogre::Entity and Ogre::SubEntity

Modified: code/branches/shaders/src/libraries/tools/Mesh.cc
===================================================================
--- code/branches/shaders/src/libraries/tools/Mesh.cc	2012-10-15 14:33:52 UTC (rev 9400)
+++ code/branches/shaders/src/libraries/tools/Mesh.cc	2012-10-16 13:30:20 UTC (rev 9401)
@@ -32,6 +32,7 @@
 #include <sstream>
 #include <string>
 #include <OgreEntity.h>
+#include <OgreSubEntity.h>
 #include <OgreSceneManager.h>
 
 #include "util/Convert.h"
@@ -92,6 +93,25 @@
             return BLANKSTRING;
     }
 
+    void Mesh::setMaterial(const std::string& name)
+    {
+        if (this->entity_)
+            this->entity_->setMaterialName(name);
+    }
+
+    const std::string& Mesh::getMaterial() const
+    {
+        if (this->entity_)
+        {
+            if(this->entity_->getSubEntity(0))
+                return this->entity_->getSubEntity(0)->getMaterialName(); //return the Material of the first SubEntity, should be enough for now
+            else
+                return BLANKSTRING;
+        }
+        else
+            return BLANKSTRING;
+    }
+
     void Mesh::setVisible(bool bVisible)
     {
         if (this->entity_)

Modified: code/branches/shaders/src/libraries/tools/Mesh.h
===================================================================
--- code/branches/shaders/src/libraries/tools/Mesh.h	2012-10-15 14:33:52 UTC (rev 9400)
+++ code/branches/shaders/src/libraries/tools/Mesh.h	2012-10-16 13:30:20 UTC (rev 9401)
@@ -47,6 +47,9 @@
 
             const std::string& getName() const;
 
+            void setMaterial(const std::string& name);
+            const std::string& getMaterial() const;
+
             void setVisible(bool bVisible);
             bool isVisible() const;
 




More information about the Orxonox-commit mailing list