[Orxonox-commit 2313] r7028 - code/branches/presentation3/src/modules/designtools

rgrieder at orxonox.net rgrieder at orxonox.net
Sun May 30 22:21:41 CEST 2010


Author: rgrieder
Date: 2010-05-30 22:21:41 +0200 (Sun, 30 May 2010)
New Revision: 7028

Modified:
   code/branches/presentation3/src/modules/designtools/CreateStars.cc
   code/branches/presentation3/src/modules/designtools/CreateStars.h
Log:
Fixed M_PI problem (not C++).
Note: For the future, we should define pi in Math.h, but we all don't like recompiles before the presentation...

Modified: code/branches/presentation3/src/modules/designtools/CreateStars.cc
===================================================================
--- code/branches/presentation3/src/modules/designtools/CreateStars.cc	2010-05-30 18:22:19 UTC (rev 7027)
+++ code/branches/presentation3/src/modules/designtools/CreateStars.cc	2010-05-30 20:21:41 UTC (rev 7028)
@@ -28,37 +28,29 @@
 
 #include "CreateStars.h"
 
-#include "core/ConsoleCommand.h"
-#include "core/CoreIncludes.h"
-#include "core/ConfigValueIncludes.h"
-#include "core/ScopedSingletonManager.h"
-#include "core/BaseObject.h"
+#include <OgreVector3.h>
 
-
+#include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-
 #include "graphics/Billboard.h"
-
-#include <OgreVector3.h>
-#include "util/Math.h"
  
 namespace orxonox
 {
-
     CreateFactory(CreateStars);
 
-    CreateStars::CreateStars(BaseObject* creator) : BaseObject(creator)
+    static const float pi = 3.14159265359f;
 
+    CreateStars::CreateStars(BaseObject* creator) : BaseObject(creator)
     {
         RegisterObject(CreateStars);
         this->material_ = "Examples/Flare";
-        this->alpha_ = 0.7;
-        this->alphaDiff_ = 0.5;
-        this->radiusDiff_ = 0.9;
+        this->alpha_ = 0.7f;
+        this->alphaDiff_ = 0.5f;
+        this->radiusDiff_ = 0.9f;
         this->colour_.r = 1;
         this->colour_.g = 1;
         this->colour_.b = 1;
-        this->colourDiff_ = 0.1;
+        this->colourDiff_ = 0.1f;
     }
 
     CreateStars::~CreateStars()
@@ -97,8 +89,8 @@
 
             while(1) 
             {
-                phi = rnd(2*M_PI);
-                teta = rnd(M_PI);
+                phi = rnd(2*pi);
+                teta = rnd(pi);
                 float random = rnd(1);
                 if(sin(teta)>random) break;
             }

Modified: code/branches/presentation3/src/modules/designtools/CreateStars.h
===================================================================
--- code/branches/presentation3/src/modules/designtools/CreateStars.h	2010-05-30 18:22:19 UTC (rev 7027)
+++ code/branches/presentation3/src/modules/designtools/CreateStars.h	2010-05-30 20:21:41 UTC (rev 7028)
@@ -26,11 +26,11 @@
  *
  */
 
+#include "DesignToolsPrereqs.h"
 
+#include <string>
+#include "util/Math.h"
 #include "core/BaseObject.h"
-
-#include "graphics/Billboard.h"
-
  
 namespace orxonox
 {
@@ -48,7 +48,7 @@
                 this->numStars_ = num;
             }
 
-            int getNumStars(){
+            int getNumStars() const {
                 return this->numStars_;
             }
 
@@ -56,7 +56,7 @@
                 this->material_ = material;
             }
 
-            std::string& getMaterial(){
+            const std::string& getMaterial() const {
                 return this->material_;
             }
 
@@ -64,7 +64,7 @@
                 this->colour_ = colour;
             }
 
-            ColourValue& getColour() { 
+            const ColourValue& getColour() const { 
                 return this->colour_;
             }
 
@@ -72,7 +72,7 @@
                 this->alpha_ = alpha;
             }
 
-            float getAlpha() {
+            float getAlpha() const {
                 return this->alpha_;
             }
 
@@ -80,7 +80,7 @@
                 this->colourDiff_ = colourDiff;
             }
 
-            float getColourDiff() {
+            float getColourDiff() const {
                 return this->colourDiff_;
             }
 
@@ -88,7 +88,7 @@
                 this->alphaDiff_ = alphaDiff;
             }
 
-            float getAlphaDiff() {
+            float getAlphaDiff() const {
                 return this->alphaDiff_;
             }
 
@@ -96,7 +96,7 @@
                 this->radiusDiff_ = radiusDiff;
             }
 
-            float getRadiusDiff() {
+            float getRadiusDiff() const {
                 return this->radiusDiff_;
             }
 
@@ -105,7 +105,7 @@
                 this->createBillboards();
             }
 
-            unsigned int getRadius(){
+            unsigned int getRadius()const {
                 return this->radius_;
             }
             
@@ -114,9 +114,9 @@
         private:
             int numStars_;
             std::string material_;
-            orxonox::ColourValue colour_;
+            ColourValue colour_;
             std::vector<Billboard*> billboards_;
-            float radius_;
+            unsigned int radius_;
             float alpha_;
             float colourDiff_; 
             float alphaDiff_;




More information about the Orxonox-commit mailing list