Changeset 9792 for code/branches/radarDreiD
- Timestamp:
- Nov 18, 2013, 4:22:09 PM (11 years ago)
- Location:
- code/branches/radarDreiD
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/radarDreiD/data/levels/radar3D_test.oxw
r9779 r9792 32 32 33 33 <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"/> 34 <SpawnPoint team=0 position="-500,0,0" lookat=" -500,0,1" spawnclass=SpaceShip pawndesign=spaceshipescort />34 <SpawnPoint team=0 position="-500,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort /> 35 35 36 36 -
code/branches/radarDreiD/src/libraries/util/Math.cc
r9787 r9792 204 204 Examples: 205 205 - 206 206 */ 207 207 orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit) 208 208 { … … 222 222 } 223 223 224 224 // perform a coordinate transformation to get distance in relation of the position of the ship 225 orxonox::Vector3 distanceShip = getTransformedVector(distance, mydirection, myorthonormal, myside); 226 227 // calculate 2D vector on the map (with angle between x/z - plain and line of sight) 228 float xcoordinate = distanceShip.z; // z; cause x direction on screen is to the right side 229 float ycoordinate = distanceShip.x*sin(mapangle)+distanceShip.y*cos(mapangle); 230 return orxonox::Vector2(xcoordinate , ycoordinate); 231 } 232 233 /** 234 @brief Gets if a object is over the x/z - plain on map 235 @param myposition My position 236 @param mydirection My viewing direction 237 @param myorthonormal My orthonormalvector (pointing upwards through my head) 238 @param otherposition The position of the other object 239 @param mapangle The angle you look on the 3Dmap 240 @return If distancevector to the other object has a positive y-coordinate 241 242 Examples: 243 Returns true if object is over x/z - plain 244 Returns false if object is below x/z -plain 245 */ 246 bool isObjectHigherThanShipOnMap(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle) 247 { 248 // Orxonox Vectors: x_direction you are looking, y_direction points up, z_direction points to the right 249 orxonox::Vector3 distance = otherposition - myposition; 250 251 // new coordinate system: x_axsis: mydirection (points front) 252 // y_axsis: myorthonormal (points up) 253 // z_axsis: myside (points right) 254 255 orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); // get vector from Ship to object 256 257 258 // perform a coordinate transformation to get distance in relation of the position of the ship 259 orxonox::Vector3 distanceShip = getTransformedVector(distance, mydirection, myorthonormal, myside); 260 261 if(distanceShip.y >= 0) 262 return true; 263 else 264 return false; 265 } 266 267 268 /** 269 @brief Gets the new vector after a coordinate transformation 270 @param distance Vector which will be transformed 271 @param mydirection New x basevector 272 @param myorthonormal New y basevector 273 @param otherposition New z basevector 274 @return direction in the new coordinates 275 276 x is vector in old coordinates 277 y is vector in old coordinates 278 T is transform matrix with: 279 T = (t1 , t2 , t3) 280 t1 = mydirection 281 t2 = myorthonormal 282 t3 = myside 283 284 y = T^(-1)*x 285 */ 286 orxonox::Vector3 getTransformedVector(const orxonox::Vector3& distance, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& myside) 287 { 225 288 // inverse of the transform matrix 226 289 float determinant = +mydirection.x * (myorthonormal.y*myside.z - myside.y*myorthonormal.z) … … 250 313 distanceShip.z = xinvtransform.z * distance.x + yinvtransform.z * distance.y + zinvtransform.z * distance.z; 251 314 252 // cap vector for map if its to long 253 //distance.x = clamp<float>(distance.x, -detectionlimit/5, detectionlimit/5); 254 //distance.y = clamp<float>(distance.y, -detectionlimit/5, detectionlimit/5); 255 //distance.z = clamp<float>(distance.z, -detectionlimit/5, detectionlimit/5); 256 //float distancelength = distance.length(); 257 258 259 // project vector for the rotated 3DMap on screen 260 //float xcoordinate = distance.z; 261 //float ycoordinate = distance.y; 262 263 float xcoordinate = distanceShip.z; // z; cause z direction is to the side 264 float ycoordinate = distanceShip.x*sin(mapangle)+distanceShip.y*cos(mapangle);// -; cause on screen y coordinate points down 265 return orxonox::Vector2(xcoordinate , ycoordinate); 266 } 267 315 return distanceShip; 316 } 268 317 269 318 /** -
code/branches/radarDreiD/src/libraries/util/Math.h
r9740 r9792 93 93 _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition); 94 94 _UtilExport orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit); 95 _UtilExport bool isObjectHigherThanShipOnMap(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle); 96 _UtilExport orxonox::Vector3 getTransformedVector(const orxonox::Vector3& distance, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& myside); 95 97 _UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity); 96 98 -
code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc
r9787 r9792 166 166 // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda) 167 167 float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale(); 168 169 168 170 it->second->setDimensions(size, size); 169 171 … … 171 173 //Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 172 174 Vector2 coord = get3DProjection(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011, detectionLimit_); 173 if(coord.y < 0) 174 { 175 orxonox::ColourValue color = it->second->getColour(); 176 color.a = 0.5f; 177 it->second->setColour(color); 178 } 175 176 // set zOrder on screen 177 bool overXZPlain = isObjectHigherThanShipOnMap(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011); 178 179 if(overXZPlain == false && (it->second->getZOrder() > 100 * this->overlay_->getZOrder())) // it appears that zOrder of attached Overlayelements is 100 times the zOrder of the Overlay 180 it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 1); 181 if(overXZPlain == true && (it->second->getZOrder() <= 100 * this->overlay_->getZOrder())) 182 it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 1); 183 184 179 185 180 186 coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
Note: See TracChangeset
for help on using the changeset viewer.