Changeset 8660
- Timestamp:
- May 29, 2011, 4:02:07 PM (13 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/data/levels/myTestLevel.oxw
r8643 r8660 33 33 <SpawnPoint team=0 position="0,0,0" direction="1,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /> 34 34 35 <SpaceBoundaries warnDistance="1" maxDistance="200" showDistance="1 00" reactionMode="0" healthDecrease="0.9" position="0,0,0"/>35 <SpaceBoundaries warnDistance="1" maxDistance="200" showDistance="150" reactionMode="0" healthDecrease="0.9" position="0,0,0"/> 36 36 37 37 <Billboard position="0,0,0" colour="1.0,1.0,1.0" material="Flares/backlightflare" scale=1 /> -
code/branches/presentation/src/modules/objects/SpaceBoundaries.cc
r8657 r8660 59 59 this->pawnsIn_.clear(); 60 60 61 for( std::vector< billboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++)61 for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++) 62 62 { 63 63 if( current->billy != NULL) … … 95 95 } 96 96 97 void SpaceBoundaries::positionBillboard(const Vector3 position) 98 { 99 std::vector<billboardAdministration>::iterator current; 100 for( current = this->billboards_.begin(); current != this->billboards_.end(); current++) 101 { 102 if(!current->usedYet) 103 { 97 void SpaceBoundaries::positionBillboard(const Vector3& position, float alpha) 98 { 99 size_t current; 100 for (current = 0; current < this->billboards_.size(); ++current) 101 if (!this->billboards_[current].usedYet) 104 102 break; 105 } 106 } 107 if( current == this->billboards_.end() ) 108 { 109 Billboard *tmp = new Billboard(this); 110 tmp->setPosition(position); 111 this->setBillboardOptions( tmp ); 112 Vector3 normalisedVec = (position - this->getPosition()).normalisedCopy(); /* Vektor von Kugelmitte nach aussen */ 113 tmp->setCommonDirection ( -1.0 * normalisedVec ); 114 Vector3 upVector = Vector3(normalisedVec.z, normalisedVec.z, -(normalisedVec.x+normalisedVec.y)); 115 upVector.normalise(); 116 tmp->setCommonUpVector( upVector ); 117 billboardAdministration tmp2 = { true, tmp }; 118 this->billboards_.push_back( tmp2 ); 119 } else { 120 current->billy->setPosition(position); 121 current->billy->setVisible(true); 122 current->usedYet = true; 123 Vector3 normalisedVec = (position - this->getPosition()).normalisedCopy(); /* Vektor von Kugelmitte nach aussen */ 124 current->billy->setCommonDirection ( -1.0 * normalisedVec ); 125 Vector3 upVector = Vector3(normalisedVec.z, normalisedVec.z, -(normalisedVec.x+normalisedVec.y)); 126 upVector.normalise(); 127 current->billy->setCommonUpVector( upVector ); 128 } 103 104 if (current == this->billboards_.size()) 105 { 106 Billboard* billboard = new Billboard(this); 107 billboard->setPosition(position); 108 this->setBillboardOptions(billboard); 109 BillboardAdministration ba = {true, billboard}; 110 this->billboards_.push_back(ba); 111 } 112 113 this->billboards_[current].billy->setPosition(position); 114 this->billboards_[current].billy->setVisible(true); 115 this->billboards_[current].billy->setColour(ColourValue(1, 1, 1, alpha)); 116 this->billboards_[current].usedYet = true; 117 118 Vector3 directionVector = (this->getPosition() - position).normalisedCopy(); // vector from the position of the billboard to the center of the sphere 119 this->billboards_[current].billy->setCommonDirection(directionVector); 120 121 Vector3 upVector = Vector3(directionVector.z, directionVector.z, -(directionVector.x + directionVector.y)); // vector perpendicular to the direction vector 122 upVector.normalise(); 123 this->billboards_[current].billy->setCommonUpVector(upVector); 129 124 } 130 125 … … 142 137 void SpaceBoundaries::removeAllBillboards() 143 138 { 144 for( std::vector< billboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++ )139 for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++ ) 145 140 { 146 141 current->usedYet = false; … … 229 224 if(/* humanItem &&*/ abs(this->maxDistance_ - distance) < this->showDistance_ ) 230 225 { 231 this->displayBoundaries(currentPawn ); // Show the boundary226 this->displayBoundaries(currentPawn, 1.0f - fabs(this->maxDistance_ - distance) / this->showDistance_); // Show the boundary 232 227 } 233 228 if(distance > this->maxDistance_ && (this->reaction_ == 1) ) … … 268 263 } 269 264 270 void SpaceBoundaries::displayBoundaries(Pawn *item )265 void SpaceBoundaries::displayBoundaries(Pawn *item, float alpha) 271 266 { 272 267 … … 276 271 Vector3 boundaryPosition = this->getPosition() + direction * this->maxDistance_; 277 272 278 this->positionBillboard(boundaryPosition );273 this->positionBillboard(boundaryPosition, alpha); 279 274 } 280 275 -
code/branches/presentation/src/modules/objects/SpaceBoundaries.h
r8645 r8660 100 100 101 101 private: 102 struct billboardAdministration{ bool usedYet; Billboard* billy; };102 struct BillboardAdministration{ bool usedYet; Billboard* billy; }; 103 103 104 104 // Variabeln:: 105 105 std::list<WeakPtr<Pawn> > pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle. 106 106 107 std::vector< billboardAdministration> billboards_;107 std::vector<BillboardAdministration> billboards_; 108 108 109 109 int reaction_; //!< Values: 0, 1, 2. … … 122 122 float computeDistance(WorldEntity *item); //!< Compute distance to center point. 123 123 void displayWarning(const std::string warnText); //!< TODO: Implement. 124 void displayBoundaries(Pawn *item );124 void displayBoundaries(Pawn *item, float alpha); 125 125 void conditionalBounceBack(Pawn *item, float currentDistance, float dt); 126 126 void bounceBack(Pawn *item, Vector3 *normal, Vector3 *velocity); … … 129 129 void checkWhoIsIn(); //!< Update the list 'pawnsIn_'. 130 130 131 void positionBillboard(const Vector3 position); //!< Display a Billboard at the position 'position'.131 void positionBillboard(const Vector3& position, float alpha); //!< Display a Billboard at the position 'position'. 132 132 void setBillboardOptions(Billboard *billy); 133 133 void removeAllBillboards(); //!< Hide all elements of '*billboard_' and set their attribute 'usedYet' to 0.
Note: See TracChangeset
for help on using the changeset viewer.