Changeset 8710
- Timestamp:
- Jun 18, 2011, 1:11:04 PM (13 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/data/levels/myTestLevel.oxw
r8660 r8710 30 30 > 31 31 32 <Light type=directional position="0,0,0" direction="0.253, 0. 593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>33 <SpawnPoint team=0 position="0 ,0,0" direction="1,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />32 <Light type=directional position="0,0,0" direction="0.253, 0.193, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/> 33 <SpawnPoint team=0 position="0.1,0.1,0" yaw="-90" roll="-90" spawnclass=SpaceShip pawndesign=spaceshipassff /> 34 34 35 35 <SpaceBoundaries warnDistance="1" maxDistance="200" showDistance="150" reactionMode="0" healthDecrease="0.9" position="0,0,0"/> 36 36 37 <Billboard position="0,0,0" colour="1.0,1.0,1.0" material="Flares/backlightflare" scale=1 /> 37 <Billboard position=" 0, 0, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 38 <Billboard position=" 0, 0,200" colour="0.0,0.0,1.0" material="Flares/backlightflare" scale=0.2 /> 39 40 <Billboard position=" 142, 142, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 41 <Billboard position=" 142,-142, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 42 <Billboard position="-142,-142, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 43 <Billboard position="-142, 142, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 44 45 <Billboard position=" 200, 0, 0" colour="1.0,0.0,0.0" material="Flares/backlightflare" scale=0.2 /> 46 <Billboard position="-200, 0, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 47 <Billboard position=" 0, 200, 0" colour="0.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 48 <Billboard position=" 0,-200, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 49 50 <Billboard position=" 184, 76, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 51 <Billboard position=" 76, 184, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 52 <Billboard position=" -76, 184, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 53 <Billboard position="-184, 76, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 54 <Billboard position="-184, -76, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 55 <Billboard position=" -76,-184, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 56 <Billboard position=" 76,-184, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 57 <Billboard position=" 184, -76, 0" colour="1.0,1.0,0.0" material="Flares/backlightflare" scale=0.2 /> 38 58 39 59 </Scene> -
code/branches/presentation/src/modules/objects/SpaceBoundaries.cc
r8694 r8710 35 35 #include "core/XMLPort.h" 36 36 37 #include "util/Math.h" 38 37 39 #include "graphics/Billboard.h" 38 40 #include "infos/PlayerInfo.h" 39 41 #include "worldentities/WorldEntity.h" 40 42 #include "worldentities/pawns/Pawn.h" 43 44 #ifndef PI2 45 #define PI2 1.570796327 46 #endif 47 #ifndef PI 48 #define PI 3.141592654 49 #endif 41 50 42 51 namespace orxonox … … 117 126 this->billboards_[current].usedYet = true; 118 127 119 Vector3 directionVector = (this->getPosition() - position).normalisedCopy(); // vector from the position of the billboard to the center of the sphere 120 this->billboards_[current].billy->setCommonDirection(directionVector); 121 122 Vector3 upVector = Vector3(directionVector.z, directionVector.z, -(directionVector.x + directionVector.y)); // vector perpendicular to the direction vector 123 upVector.normalise(); 124 this->billboards_[current].billy->setCommonUpVector(upVector); 128 // in order to animate the billboard, we use a 129 // transform to spherical coordinates according to 130 // http://de.wikipedia.org/wiki/Kugelkoordinaten convention 131 132 Vector3 dirVect = position - this->getPosition(); 133 134 float phi; // this is the longitude on the sphere (-pi, pi) 135 if (dirVect.x > 0) phi = atan(dirVect.y/dirVect.x); 136 else if (dirVect.x == 0) phi = sgn(dirVect.y) * PI2; 137 else if (dirVect.y >= 0) phi = atan(dirVect.y/dirVect.x) + PI; 138 else if (dirVect.y < 0) phi = atan(dirVect.y/dirVect.x) - PI; 139 140 float theta; // this is the latitude measured from z axis (0, pi) 141 theta = acos(dirVect.z / dirVect.length()); 142 143 Vector3 e_r = dirVect.normalisedCopy(); 144 //Vector3 e_phi = Vector3(-sin(phi), cos(phi), 0); 145 Vector3 e_theta = Vector3(cos(theta)*cos(phi), cos(theta)*sin(phi), -sin(theta)); 146 147 // set billboard orientation 148 this->billboards_[current].billy->setCommonDirection(e_r); 149 this->billboards_[current].billy->setCommonUpVector(e_theta); 150 151 // set billboard texture coordinates 152 float u = (phi - floor(phi)) * this->maxDistance_ / 200; 153 float v = (theta -floor(theta)) * this->maxDistance_ / 200; 154 Ogre::FloatRect textureCoords = Ogre::FloatRect(0.5-u, 0.5-v, 1.0-u, 1.0-v); 155 this->billboards_[current].billy->setTextureCoords(&textureCoords, 1); 156 157 // debug output 158 //COUT(0) << "dirVect: " << dirVect << " len: " << dirVect.length() << std::endl; 159 //COUT(0) << "phi: " << phi << std::endl; 160 //COUT(0) << "theta: " << theta << std::endl; 161 //COUT(0) << "e_r: " << e_r << " len: " << e_r.length() << std::endl; 162 //COUT(0) << "e_phi: " << e_phi << " len: " << e_phi.length() << std::endl; 163 //COUT(0) << "e_theta: " << e_theta << " len: " << e_theta.length() << std::endl; 125 164 } 126 165 127 166 void SpaceBoundaries::setBillboardOptions(Billboard *billy) 128 167 { 129 if(billy != NULL)130 { 131 billy->setMaterial("Grid ");168 if(billy) 169 { 170 billy->setMaterial("Grid02"); 132 171 billy->setBillboardType(Ogre::BBT_PERPENDICULAR_COMMON); 133 billy->setDefaultDimensions(1 50, 150);172 billy->setDefaultDimensions(100, 100); 134 173 billy->setVisible(true); 135 174 } -
code/branches/presentation/src/modules/objects/SpaceBoundaries.h
r8660 r8710 46 46 47 47 /** 48 @brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area (until now this area is a ball).48 @brief SpaceBoundaries gives level creators the possibility to keep Pawns from leaving a defined area (until now this area is spherical). 49 49 50 50 Some attributes can/should be defined in the XML-File: -
code/branches/presentation/src/orxonox/graphics/Billboard.cc
r8614 r8710 145 145 } 146 146 } 147 148 void Billboard::setCommonDirection(Vector3 vec)149 {150 Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();151 if( bSet != NULL )152 {153 bSet->setCommonDirection( vec );154 }155 }156 157 void Billboard::setCommonUpVector(Vector3 vec)158 {159 Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();160 if( bSet != NULL )161 {162 bSet->setCommonUpVector( vec );163 }164 }165 166 void Billboard::setDefaultDimensions(float width, float height)167 {168 Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();169 if( bSet != NULL )170 {171 bSet->setDefaultDimensions(width, height);172 }173 }174 147 } -
code/branches/presentation/src/orxonox/graphics/Billboard.h
r8614 r8710 65 65 { return this->colour_; } 66 66 67 68 67 inline void setRotation(const Radian& rotation) 69 68 { this->rotation_ = rotation; this->changedRotation(); } … … 71 70 { return this->rotation_; } 72 71 72 /// use normalised vector as argument 73 inline void setCommonDirection(const Vector3 vec) 74 { if(this->billboard_.getBillboardSet()) 75 this->billboard_.getBillboardSet()->setCommonDirection(vec); } 76 inline const Vector3 getCommonDirection() 77 { if(this->billboard_.getBillboardSet()) 78 return this->billboard_.getBillboardSet()->getCommonDirection(); } 79 80 /// use normalised vector as argument 81 inline void setCommonUpVector(const Vector3 vec) 82 { if(this->billboard_.getBillboardSet()) 83 this->billboard_.getBillboardSet()->setCommonUpVector( vec ); } 84 inline const Vector3 getCommonUpVector() 85 { if(this->billboard_.getBillboardSet()) 86 return this->billboard_.getBillboardSet()->getCommonUpVector(); } 73 87 74 88 virtual void setTeamColour(const ColourValue& colour) … … 77 91 void setBillboardType(Ogre::BillboardType bbt); 78 92 79 void setCommonDirection(Vector3 vec); //!< normalised Vector vec as argument 80 81 void setCommonUpVector(Vector3 vec); //!< normalised Vector vec as argument 82 83 void setDefaultDimensions(float width, float height); 93 inline void setDefaultDimensions(float width, float height) 94 { if(this->billboard_.getBillboardSet()) 95 this->billboard_.getBillboardSet()->setDefaultDimensions(width, height); } 84 96 97 inline void setTextureCoords(const Ogre::FloatRect* coords, unsigned int numCoords) 98 { if(this->billboard_.getBillboardSet()) 99 this->billboard_.getBillboardSet()->setTextureCoords(coords, numCoords); } 85 100 86 101 protected:
Note: See TracChangeset
for help on using the changeset viewer.