Changeset 6936
- Timestamp:
- May 20, 2010, 4:10:54 PM (15 years ago)
- Location:
- code/branches/skybox2/src/modules/designtools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/skybox2/src/modules/designtools/CreateStars.cc
r6861 r6936 52 52 { 53 53 RegisterObject(CreateStars); 54 this->material_ = "Examples/Flare"; 55 this->alpha_ = 0.7; 56 this->alphaDiff_ = 0.5; 57 this->radiusDiff_ = 0.9; 58 this->colour_.r = 1; 59 this->colour_.g = 1; 60 this->colour_.b = 1; 61 this->colourDiff_ = 0.1; 54 62 } 55 63 … … 71 79 for(int i=0; i < numStars_; i++) 72 80 { 73 Billboard* b = new Billboard(this); 74 b->setMaterial(material_); 81 Billboard* bb = new Billboard(this); 75 82 76 float alpha = rnd(-90,90); 77 float beta = rnd(0,360); 78 79 b->setPosition( PolarToCartesian(alpha, beta, radius_) ); 80 billboards_.push_back(b); 83 float r = rnd(-colourDiff_,colourDiff_); 84 float g = rnd(-colourDiff_,colourDiff_); 85 float b = rnd(-colourDiff_,colourDiff_); 86 orxonox::ColourValue thisColour = colour_; 87 float alpha = alpha_+rnd(-alphaDiff_,alphaDiff_); 88 thisColour.r=clamp(thisColour.r*alpha+r, 0.0f, 1.0f); 89 thisColour.g=clamp(thisColour.g*alpha+g, 0.0f, 1.0f); 90 thisColour.b=clamp(thisColour.b*alpha+b, 0.0f, 1.0f); 91 92 bb->setMaterial(material_); 93 bb->setColour(thisColour); 94 95 float phi; 96 float teta; 97 98 while(1) 99 { 100 phi = rnd(2*M_PI); 101 teta = rnd(M_PI); 102 float random = rnd(1); 103 if(sin(teta)>random) break; 104 } 105 float radius = rnd(radiusDiff_,1)*radius_; 106 bb->setPosition( PolarToCartesian(phi, teta, radius) ); 107 billboards_.push_back(bb); 81 108 } 82 109 } 83 110 84 Vector3 PolarToCartesian(float alpha, float beta, float radius)111 Vector3 CreateStars::PolarToCartesian(float phi, float teta, float radius) 85 112 { 86 int x = radius * cos(alpha) * sin(beta);87 int y = radius * sin(alpha) * cos(beta);88 int z = radius * cos(beta);113 float x = radius * cos(phi) * sin(teta); 114 float y = radius * sin(phi) * sin(teta); 115 float z = radius * cos(teta); 89 116 return Vector3(x,y,z); 90 117 } … … 92 119 void CreateStars::XMLPort(Element& xmlelement, XMLPort::Mode mode) 93 120 { 121 SUPER(CreateStars, XMLPort, xmlelement, mode); 122 94 123 XMLPortParam(CreateStars, "numStars", setNumStars, getNumStars, xmlelement, mode); 95 124 XMLPortParam(CreateStars, "material", setMaterial, getMaterial, xmlelement, mode); 125 XMLPortParam(CreateStars, "colour", setColour, getColour, xmlelement, mode); 126 XMLPortParam(CreateStars, "alpha", setAlpha, getAlpha, xmlelement, mode); 127 XMLPortParam(CreateStars, "colourDiff", setColourDiff, getColourDiff, xmlelement, mode); 128 XMLPortParam(CreateStars, "alphaDiff", setAlphaDiff, getAlphaDiff, xmlelement, mode); 129 XMLPortParam(CreateStars, "radiusDiff", setRadiusDiff, getRadiusDiff, xmlelement, mode); 96 130 XMLPortParam(CreateStars, "radius", setRadius, getRadius, xmlelement, mode); 97 131 } -
code/branches/skybox2/src/modules/designtools/CreateStars.h
r6861 r6936 31 31 32 32 #include "graphics/Billboard.h" 33 33 34 34 35 35 namespace orxonox … … 61 61 } 62 62 63 void setColour(const orxonox::ColourValue& colour) { 64 this->colour_ = colour; 65 } 66 67 ColourValue& getColour() { 68 return this->colour_; 69 } 70 71 void setAlpha(float alpha) { 72 this->alpha_ = alpha; 73 } 74 75 float getAlpha() { 76 return this->alpha_; 77 } 78 79 void setColourDiff(float colourDiff) { 80 this->colourDiff_ = colourDiff; 81 } 82 83 float getColourDiff() { 84 return this->colourDiff_; 85 } 86 87 void setAlphaDiff(float alphaDiff) { 88 this->alphaDiff_ = alphaDiff; 89 } 90 91 float getAlphaDiff() { 92 return this->alphaDiff_; 93 } 94 95 void setRadiusDiff(float radiusDiff) { 96 this->radiusDiff_ = radiusDiff; 97 } 98 99 float getRadiusDiff() { 100 return this->radiusDiff_; 101 } 102 63 103 void setRadius(unsigned int dist) { 64 104 this->radius_ = dist; … … 75 115 int numStars_; 76 116 std::string material_; 117 orxonox::ColourValue colour_; 77 118 std::vector<Billboard*> billboards_; 78 unsigned int radius_; 119 float radius_; 120 float alpha_; 121 float colourDiff_; 122 float alphaDiff_; 123 float radiusDiff_; 79 124 80 125 };
Note: See TracChangeset
for help on using the changeset viewer.