Changeset 1502 for code/trunk/src/orxonox/objects
- Timestamp:
- Jun 1, 2008, 3:54:20 PM (17 years ago)
- Location:
- code/trunk/src/orxonox/objects
- Files:
-
- 21 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/Ambient.cc
r1293 r1502 47 47 namespace orxonox 48 48 { 49 ConsoleCommand(Ambient, setAmbientLightTest, AccessLevel::Offline, false).setDefaultValues(ColourValue(1, 1, 1, 1));49 SetConsoleCommand(Ambient, setAmbientLightTest, false).setDefaultValues(ColourValue(1, 1, 1, 1)).setAccessLevel(AccessLevel::Offline); 50 50 51 51 CreateFactory(Ambient); … … 66 66 bool Ambient::create(){ 67 67 GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_); 68 return true;68 return Synchronisable::create(); 69 69 } 70 70 -
code/trunk/src/orxonox/objects/Ambient.h
r1293 r1502 47 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 48 void setAmbientLight(const ColourValue& colour); 49 bool create();49 virtual bool create(); 50 50 void registerAllVariables(); 51 51 -
code/trunk/src/orxonox/objects/Camera.cc
r1293 r1502 60 60 { 61 61 CameraHandler::getInstance()->releaseFocus(this); 62 GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName()); 62 63 } 63 64 … … 75 76 void Camera::tick(float dt) 76 77 { 77 if(this->positionNode_ != NULL) { 78 if (this->positionNode_ != NULL) 79 { 78 80 // this stuff here may need some adjustments 79 Vector3 offset = this->positionNode_->getWorldPosition() - this->cameraNode_->getPosition(); 80 this->cameraNode_->translate(15*dt*offset); 81 Vector3 offset = this->positionNode_->getWorldPosition() - this->cameraNode_->getWorldPosition(); 82 float coeff = 15.0f * dt; 83 if (coeff > 1.0f) 84 coeff = 1.0f; 81 85 82 this->cameraNode_->setOrientation(Quaternion::Slerp(0.7, this->positionNode_->getWorldOrientation(), this->cameraNode_->getWorldOrientation(), false)); 86 this->cameraNode_->translate(coeff * offset); 87 88 this->cameraNode_->setOrientation(Quaternion::Slerp(7.0f * dt, this->positionNode_->getWorldOrientation(), this->cameraNode_->getWorldOrientation(), false)); 83 89 } 84 90 } -
code/trunk/src/orxonox/objects/Camera.h
r1407 r1502 50 50 void setTargetNode(Ogre::SceneNode* obj); 51 51 52 Ogre::Camera* cam_; 53 52 54 void tick(float dt); 53 55 void update(); … … 63 65 Ogre::SceneNode* cameraNode_; 64 66 Ogre::Vector3 oldPos; 65 Ogre::Camera* cam_;66 67 bool bHasFocus_; 67 68 }; -
code/trunk/src/orxonox/objects/CameraHandler.cc
r1293 r1502 26 26 * 27 27 */ 28 #include "OrxonoxStableHeaders.h" 29 #include "CameraHandler.h" 30 28 31 #include <OgreSceneManager.h> 29 32 #include <OgreRenderWindow.h> 30 33 31 #include "OrxonoxStableHeaders.h"32 34 #include "core/ObjectList.h" 33 #include "CameraHandler.h"34 35 #include "Camera.h" 35 36 #include "GraphicsEngine.h" -
code/trunk/src/orxonox/objects/Explosion.cc
r1293 r1502 79 79 } 80 80 }; 81 82 /*bool Explosion::create(){ 83 if(!WorldEntity::create()) 84 return false; 85 classID=this->getIdentifier()->getNetworkID(); 86 }*/ 81 87 82 88 void Explosion::destroyObject() -
code/trunk/src/orxonox/objects/Explosion.h
r1056 r1502 43 43 virtual ~Explosion(); 44 44 void destroyObject(); 45 virtual bool create(){return WorldEntity::create();} 45 46 46 47 private: -
code/trunk/src/orxonox/objects/Model.cc
r1293 r1502 34 34 #include "GraphicsEngine.h" 35 35 #include "core/XMLPort.h" 36 37 #include <OgreEntity.h> 38 #include <OgreMesh.h> 39 #include <OgreHardwareVertexBuffer.h> 40 #include <OgreMeshManager.h> 41 36 42 37 43 namespace orxonox … … 77 83 this->mesh_.setMesh(meshSrc_); 78 84 this->attachObject(this->mesh_.getEntity()); 85 86 //HACK!! 87 /*if ((this->meshSrc_ == "assff.mesh") || (this->meshSrc_ == "ast1.mesh") || (this->meshSrc_ == "ast2.mesh") || (this->meshSrc_ == "ast3.mesh") || (this->meshSrc_ == "ast4.mesh") ||(this->meshSrc_ == "ast5.mesh") || (this->meshSrc_ == "ast6.mesh")) 88 { 89 Ogre::MeshPtr pMesh = this->mesh_.getEntity()->getMesh(); 90 //set Mesh to tangentspace 91 unsigned short src, dest; 92 if (!pMesh->suggestTangentVectorBuildParams(Ogre::VES_TANGENT, src, dest)) 93 { 94 pMesh->buildTangentVectors(Ogre::VES_TANGENT, src, dest); 95 } 96 if ((this->meshSrc_ == "assff.mesh")) 97 { 98 (this->mesh_.getEntity())->setMaterialName("Assff/BumpMap"); 99 } 100 else 101 { 102 (this->mesh_.getEntity())->setMaterialName("Asteroid/BumpMap"); 103 } 104 105 106 }*/ 79 107 COUT(4) << "Loader (Model.cc): Created model" << std::endl; 80 108 } -
code/trunk/src/orxonox/objects/Model.h
r1293 r1502 45 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 46 void setMesh(const std::string& meshname); 47 bool create();47 virtual bool create(); 48 48 49 49 protected: -
code/trunk/src/orxonox/objects/NPC.cc
r1293 r1502 67 67 } 68 68 69 bool NPC::create(){70 Model::create();71 return true;72 }73 69 74 70 /** -
code/trunk/src/orxonox/objects/NPC.h
r1293 r1502 53 53 void setValues(Vector3 location, Vector3 speed, Vector3 acceleration, bool movable); 54 54 void registerAllVariables(); 55 bool create();55 virtual bool create(){return Model::create();} 56 56 57 57 private: -
code/trunk/src/orxonox/objects/Projectile.cc
r1360 r1502 30 30 #include "Projectile.h" 31 31 32 #include <OgreBillboard.h> 33 32 34 #include "core/CoreIncludes.h" 33 35 #include "core/Executor.h" … … 41 43 { 42 44 CreateFactory(Projectile); 45 46 float Projectile::speed_ = 0; 43 47 44 48 Projectile::Projectile(SpaceShip* owner) : … … 63 67 64 68 this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject))); 65 this->classID = this->getIdentifier()->getNetworkID(); // TODO: remove this hack66 69 // COUT(3) << this->classID << std::endl; 67 70 } … … 92 95 if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius)) 93 96 { 94 new Explosion(this); 97 Explosion *exp = new Explosion(this); 98 exp->create(); 95 99 delete this; 96 100 return; … … 104 108 delete this; 105 109 } 110 111 void Projectile::setColour(const ColourValue& colour) 112 { 113 this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour); 114 } 106 115 } -
code/trunk/src/orxonox/objects/Projectile.h
r1056 r1502 35 35 #include "../tools/BillboardSet.h" 36 36 #include "../tools/Timer.h" 37 #include "util/Math.h" 37 38 38 39 namespace orxonox … … 46 47 void destroyObject(); 47 48 virtual void tick(float dt); 49 virtual bool create(){return WorldEntity::create();} 50 void setColour(const ColourValue& colour); 51 52 static float getSpeed() 53 { return Projectile::speed_; } 54 55 protected: 56 SpaceShip* owner_; 48 57 49 58 private: 50 SpaceShip* owner_;51 59 BillboardSet billboard_; 52 float speed_;60 static float speed_; 53 61 float lifetime_; 54 62 Timer<Projectile> destroyTimer_; -
code/trunk/src/orxonox/objects/Skybox.cc
r1293 r1502 90 90 bool Skybox::create(){ 91 91 this->setSkybox(skyboxSrc_); 92 return true;92 return Synchronisable::create(); 93 93 } 94 94 -
code/trunk/src/orxonox/objects/Skybox.h
r1293 r1502 47 47 void setSkybox(const std::string& skyboxname); 48 48 49 bool create();49 virtual bool create(); 50 50 void registerAllVariables(); 51 51 void setSkyboxSrc(const std::string &src); -
code/trunk/src/orxonox/objects/SpaceShip.cc
r1407 r1502 45 45 #include "particle/ParticleInterface.h" 46 46 #include "Projectile.h" 47 #include "RotatingProjectile.h" 47 48 #include "core/XMLPort.h" 48 49 #include "core/ConsoleCommand.h" 49 50 #include "network/Client.h" 51 #include "hud/HUD.h" 50 52 51 53 namespace orxonox 52 54 { 53 ConsoleCommand(SpaceShip, setMaxSpeedTest, AccessLevel::Debug, false); 54 ConsoleCommand(SpaceShip, whereAmI, AccessLevel::User, true); 55 ConsoleCommandGeneric(test1, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed", AccessLevel::Debug), false); 56 ConsoleCommandGeneric(test2, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber", AccessLevel::Debug), false); 57 ConsoleCommandGeneric(test3, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl", AccessLevel::Debug), false); 55 SetConsoleCommand(SpaceShip, setMaxSpeedTest, false).setAccessLevel(AccessLevel::Debug); 56 SetConsoleCommand(SpaceShip, whereAmI, true).setAccessLevel(AccessLevel::User); 57 SetConsoleCommand(SpaceShip, moveLongitudinal, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold); 58 SetConsoleCommand(SpaceShip, moveLateral, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold); 59 SetConsoleCommand(SpaceShip, moveYaw, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold); 60 SetConsoleCommand(SpaceShip, movePitch, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold); 61 SetConsoleCommand(SpaceShip, moveRoll, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold); 62 SetConsoleCommand(SpaceShip, fire, true).setAccessLevel(AccessLevel::User).setKeybindMode(KeybindMode::OnHold); 63 SetConsoleCommandGeneric(test1, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed"), false).setAccessLevel(AccessLevel::Debug); 64 SetConsoleCommandGeneric(test2, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber"), false).setAccessLevel(AccessLevel::Debug); 65 SetConsoleCommandGeneric(test3, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl"), false).setAccessLevel(AccessLevel::Debug); 58 66 59 67 CreateFactory(SpaceShip); … … 64 72 Iterator<SpaceShip> it; 65 73 for(it = ObjectList<SpaceShip>::start(); it; ++it){ 66 if( (it)->server_ || ( network::Client::getSingleton() && network::Client::getSingleton()->getShipID()==it->objectID ))74 if( (it)->myShip_ ) 67 75 return *it; 68 76 } 69 77 return NULL; 70 78 } 71 79 72 80 SpaceShip::SpaceShip() : 73 81 //testvector_(0,0,0), … … 103 111 mouseY_(0.0f), 104 112 emitterRate_(0.0f), 105 server_(false) 113 myShip_(false), 114 teamNr_(0), 115 health_(100) 106 116 { 107 117 RegisterObject(SpaceShip); … … 112 122 this->setConfigValues(); 113 123 124 initialDir_ = Vector3(1.0, 0.0, 0.0); 125 currentDir_ = initialDir_; 126 initialOrth_ = Vector3(0.0, 0.0, 1.0); 127 currentOrth_ = initialOrth_; 128 129 this->camName_ = this->getName() + "CamNode"; 114 130 115 131 this->setRotationAxis(1, 0, 0); … … 127 143 if (this->cam_) 128 144 delete this->cam_; 145 if (!Identifier::isCreatingHierarchy() && !myShip_ && &HUD::getSingleton()!=NULL) 146 //remove the radar object 147 HUD::getSingleton().removeRadarObject(this->getNode()); 129 148 } 130 149 131 150 bool SpaceShip::create(){ 151 if(!myShip_){ 152 if(network::Client::getSingleton() && objectID == network::Client::getSingleton()->getShipID()) 153 myShip_=true; 154 else 155 HUD::getSingleton().addRadarObject(this->getNode(), 3); 156 } 132 157 if(Model::create()) 133 158 this->init(); … … 153 178 void SpaceShip::init() 154 179 { 155 if ((server_ || ( network::Client::getSingleton() && network::Client::getSingleton()->getShipID()==objectID ) ))156 {157 if (!setMouseEventCallback_)158 {159 InputManager::addMouseHandler(this, "SpaceShip");160 //InputManager::enableMouseHandler("SpaceShip");161 setMouseEventCallback_ = true;162 }163 }164 165 180 // START CREATING THRUSTER 166 181 this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow"); … … 200 215 // END CREATING BLINKING LIGHTS 201 216 202 // START of testing crosshair 203 this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1); 204 this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1); 205 206 this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0)); 207 this->chNearNode_->setInheritScale(false); 208 this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0)); 209 this->chFarNode_->setInheritScale(false); 210 211 this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet()); 212 this->chNearNode_->setScale(0.2, 0.2, 0.2); 213 214 this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet()); 215 this->chFarNode_->setScale(0.4, 0.4, 0.4); 217 if (this->isExactlyA(Class(SpaceShip))) 218 { 219 // START of testing crosshair 220 this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1); 221 this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1); 222 223 this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0)); 224 this->chNearNode_->setInheritScale(false); 225 this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0)); 226 this->chFarNode_->setInheritScale(false); 227 228 this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet()); 229 this->chNearNode_->setScale(0.2, 0.2, 0.2); 230 231 this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet()); 232 this->chFarNode_->setScale(0.4, 0.4, 0.4); 233 } 216 234 217 235 createCamera(); … … 237 255 CameraHandler::getInstance()->requestFocus(cam_); 238 256 257 } 258 259 Camera* SpaceShip::getCamera(){ 260 return cam_; 239 261 } 240 262 … … 295 317 XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode); 296 318 XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode); 297 server_=true; // TODO: this is only a hack 319 myShip_=true; // TODO: this is only a hack 320 298 321 SpaceShip::create(); 299 getFocus(); 322 if (this->isExactlyA(Class(SpaceShip))) 323 getFocus(); 300 324 } 301 325 … … 308 332 } 309 333 310 void SpaceShip::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)311 {312 /*313 this->mouseX += e.state.X.rel;314 if (this->bInvertMouse_)315 this->mouseY += e.state.Y.rel;316 else317 this->mouseY -= e.state.Y.rel;318 319 // if(mouseX>maxMouseX) maxMouseX = mouseX;320 // if(mouseX<minMouseX) minMouseX = mouseX;321 // cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;322 323 this->moved = true;324 */325 if (this->bRMousePressed_)326 {327 this->camNode_->roll(Degree(-rel.x * 0.10));328 this->camNode_->yaw(Degree(rel.y * 0.10));329 }330 else331 {332 float minDimension = clippingSize.y;333 if (clippingSize.x < minDimension)334 minDimension = clippingSize.x;335 336 this->mouseX_ += rel.x;337 if (this->mouseX_ < -minDimension)338 this->mouseX_ = -minDimension;339 if (this->mouseX_ > minDimension)340 this->mouseX_ = minDimension;341 342 this->mouseY_ += rel.y;343 if (this->mouseY_ < -minDimension)344 this->mouseY_ = -minDimension;345 if (this->mouseY_ > minDimension)346 this->mouseY_ = minDimension;347 348 float xRotation = this->mouseX_ / minDimension;349 xRotation = xRotation*xRotation * sgn(xRotation);350 xRotation *= -this->rotationAcceleration_;351 if (xRotation > this->maxRotation_)352 xRotation = this->maxRotation_;353 if (xRotation < -this->maxRotation_)354 xRotation = -this->maxRotation_;355 this->mouseXRotation_ = Radian(xRotation);356 357 float yRotation = this->mouseY_ / minDimension;358 yRotation = yRotation*yRotation * sgn(yRotation);359 yRotation *= this->rotationAcceleration_;360 if (yRotation > this->maxRotation_)361 yRotation = this->maxRotation_;362 if (yRotation < -this->maxRotation_)363 yRotation = -this->maxRotation_;364 this->mouseYRotation_ = Radian(yRotation);365 }366 }367 368 void SpaceShip::mouseButtonPressed(MouseButton::Enum id)369 {370 if (id == MouseButton::Left)371 this->bLMousePressed_ = true;372 else if (id == MouseButton::Right)373 this->bRMousePressed_ = true;374 }375 376 void SpaceShip::mouseButtonReleased(MouseButton::Enum id)377 {378 if (id == MouseButton::Left)379 this->bLMousePressed_ = false;380 else if (id == MouseButton::Right)381 {382 this->bRMousePressed_ = false;383 this->camNode_->resetOrientation();384 }385 }386 387 334 std::string SpaceShip::whereAmI() { 388 335 return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x) … … 391 338 } 392 339 393 Vector3 SpaceShip::get SPosition() {394 return SpaceShip::getLocalShip()->getPosition();395 } 396 397 Quaternion SpaceShip::getSOrientation(){398 return SpaceShip::getLocalShip()->getOrientation();340 Vector3 SpaceShip::getDir() { 341 return currentDir_; 342 } 343 344 Vector3 SpaceShip::getOrth(){ 345 return currentOrth_; 399 346 } 400 347 … … 403 350 void SpaceShip::tick(float dt) 404 351 { 352 currentDir_ = getOrientation()*initialDir_; 353 currentOrth_ = getOrientation()*initialOrth_; 354 405 355 if (this->cam_) 406 356 this->cam_->tick(dt); … … 422 372 if (this->bLMousePressed_ && this->timeToReload_ <= 0) 423 373 { 424 425 Projectile *p = new Projectile(this); 426 374 375 Projectile *p; 376 if (this->isExactlyA(Class(SpaceShip))) 377 p = new RotatingProjectile(this); 378 else 379 p = new Projectile(this); 380 p->setColour(this->getProjectileColour()); 381 p->create(); 382 if(p->classID==0) 383 COUT(3) << "generated projectile with classid 0" << std::endl; // TODO: remove this output 384 427 385 p->setBacksync(true); 428 386 this->timeToReload_ = this->reloadTime_; … … 495 453 } 496 454 497 if( (network::Client::getSingleton() && network::Client::getSingleton()->getShipID() == objectID) || server_ )498 {499 COUT(4) << "steering our ship: " << objectID << std::endl;500 if (InputManager::isKeyDown(KeyCode::Up) || InputManager::isKeyDown(KeyCode::W))501 this->acceleration_.x = this->translationAcceleration_;502 else if(InputManager::isKeyDown(KeyCode::Down) || InputManager::isKeyDown(KeyCode::S))503 this->acceleration_.x = -this->translationAcceleration_;504 else505 this->acceleration_.x = 0;506 507 if (InputManager::isKeyDown(KeyCode::Right) || InputManager::isKeyDown(KeyCode::D))508 this->acceleration_.y = -this->translationAcceleration_;509 else if (InputManager::isKeyDown(KeyCode::Left) || InputManager::isKeyDown(KeyCode::A))510 this->acceleration_.y = this->translationAcceleration_;511 else512 this->acceleration_.y = 0;513 514 if (InputManager::isKeyDown(KeyCode::Delete) || InputManager::isKeyDown(KeyCode::Q))515 this->momentum_ = Radian(-this->rotationAccelerationRadian_);516 else if (InputManager::isKeyDown(KeyCode::PageDown) || InputManager::isKeyDown(KeyCode::E))517 this->momentum_ = Radian(this->rotationAccelerationRadian_);518 else519 this->momentum_ = 0;520 }/*else521 COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/522 455 523 456 WorldEntity::tick(dt); … … 533 466 else 534 467 this->tt_->setRate(0); 535 } 536 468 469 if( myShip_ ) 470 { 471 COUT(4) << "steering our ship: " << objectID << std::endl; 472 this->acceleration_.x = 0; 473 this->acceleration_.y = 0; 474 this->momentum_ = 0; 475 this->mouseXRotation_ = Radian(0); 476 this->mouseYRotation_ = Radian(0); 477 this->bLMousePressed_ = false; 478 }/*else 479 COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/ 480 } 481 482 void SpaceShip::movePitch(float val) 483 { getLocalShip()->setMovePitch(val); } 484 void SpaceShip::moveYaw(float val) 485 { getLocalShip()->setMoveYaw(val); } 486 void SpaceShip::moveRoll(float val) 487 { getLocalShip()->setMoveRoll(val); } 488 void SpaceShip::moveLongitudinal(float val) 489 { getLocalShip()->setMoveLongitudinal(val); } 490 void SpaceShip::moveLateral(float val) 491 { getLocalShip()->setMoveLateral(val); } 492 void SpaceShip::fire() 493 { getLocalShip()->doFire(); } 494 495 void SpaceShip::setMovePitch(float val) 496 { 497 val = -val * val * sgn(val) * this->rotationAcceleration_; 498 if (val > this->maxRotation_) 499 val = this->maxRotation_; 500 if (val < -this->maxRotation_) 501 val = -this->maxRotation_; 502 this->mouseYRotation_ = Radian(val); 503 } 504 505 void SpaceShip::setMoveYaw(float val) 506 { 507 val = -val * val * sgn(val) * this->rotationAcceleration_; 508 if (val > this->maxRotation_) 509 val = this->maxRotation_; 510 if (val < -this->maxRotation_) 511 val = -this->maxRotation_; 512 this->mouseXRotation_ = Radian(val); 513 } 514 515 void SpaceShip::setMoveRoll(float val) 516 { 517 this->momentum_ = Radian(-this->rotationAccelerationRadian_ * val); 518 //COUT(3) << "rotating val: " << val << " acceleration: " << this->rotationAccelerationRadian_.valueDegrees() << std::endl; 519 } 520 521 void SpaceShip::setMoveLongitudinal(float val) 522 { 523 this->acceleration_.x = this->translationAcceleration_ * val; 524 } 525 526 void SpaceShip::setMoveLateral(float val) 527 { 528 this->acceleration_.y = -this->translationAcceleration_ * val; 529 } 530 531 void SpaceShip::doFire() 532 { 533 this->bLMousePressed_ = true; 534 } 537 535 } -
code/trunk/src/orxonox/objects/SpaceShip.h
r1407 r1502 41 41 namespace orxonox 42 42 { 43 class _OrxonoxExport SpaceShip : public Model , public MouseHandler43 class _OrxonoxExport SpaceShip : public Model 44 44 { 45 45 public: 46 46 47 47 static SpaceShip *getLocalShip(); 48 48 49 49 SpaceShip(); 50 50 ~SpaceShip(); 51 bool create();51 virtual bool create(); 52 52 void registerAllVariables(); 53 53 void init(); … … 64 64 void setTransDamp(float value); 65 65 void setRotDamp(float value); 66 void getFocus(); 66 67 67 void getFocus();68 static SpaceShip* instance_s;69 static Vector3 getSPosition();70 static Quaternion getSOrientation();71 68 static std::string whereAmI(); 72 69 static void setMaxSpeedTest(float value) 73 70 { SpaceShip::instance_s->setMaxSpeed(value); } 74 71 75 void mouseButtonPressed (MouseButton::Enum id); 76 void mouseButtonReleased(MouseButton::Enum id); 77 void mouseButtonHeld (MouseButton::Enum id) { } 78 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize); 79 void mouseScrolled (int abs, int rel) { } 72 static void movePitch(float value); 73 static void moveYaw(float value); 74 static void moveRoll(float value); 75 static void moveLongitudinal(float value); 76 static void moveLateral(float value); 77 static void fire(); 78 void setMovePitch(float value); 79 void setMoveYaw(float value); 80 void setMoveRoll(float value); 81 void setMoveLongitudinal(float value); 82 void setMoveLateral(float value); 83 void doFire(); 80 84 81 85 float getMaxSpeed(); 86 Vector3 getDir(); 87 Vector3 getOrth(); 88 Camera* getCamera(); 89 90 int getTeamNr() const 91 { return this->teamNr_; } 92 int getHealth() const 93 { return this->health_; } 94 95 bool getMyShip(){return myShip_;} 96 97 protected: 98 void setTeamNr(int teamNr) 99 { this->teamNr_ = teamNr; } 82 100 83 101 private: 84 102 void createCamera(); 103 virtual ColourValue getProjectileColour() const 104 { return ColourValue(1.0, 1.0, 0.5); } 85 105 86 106 Vector3 testvector_; 107 Vector3 initialDir_; 108 Vector3 currentDir_; 109 Vector3 initialOrth_; 110 Vector3 currentOrth_; 87 111 bool bInvertYAxis_; 88 112 bool setMouseEventCallback_; … … 130 154 131 155 float emitterRate_; 132 bool server_; 156 157 protected: 158 bool myShip_; 159 160 int teamNr_; 161 int health_; 162 163 static SpaceShip* instance_s; 133 164 }; 134 165 } -
code/trunk/src/orxonox/objects/WorldEntity.cc
r1360 r1502 85 85 this->rotationRate_ += (dt * this->momentum_); 86 86 this->rotate(this->rotationAxis_, dt * this->rotationRate_); 87 //COUT(3) << "rotationrate: " << this->rotationRate_.valueDegrees() << " momentum: " << this->momentum_.valueDegrees() << std::endl; 87 88 } 88 89 } … … 153 154 registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3); 154 155 //register acceleration & momentum 155 registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);156 registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);157 registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);158 registerVar( (void*) &(this->getMomentum()), sizeof(this->getMomentum()), network::DATA); 156 // registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x2); 157 // registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x2); 158 // registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x2); 159 // registerVar( (void*) &(this->getMomentum()), sizeof(this->getMomentum()), network::DATA, 0x2); // only backsync 159 160 } 160 161 -
code/trunk/src/orxonox/objects/WorldEntity.h
r1227 r1502 53 53 virtual void loadParams(TiXmlElement* xmlElem); 54 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 inline bool create(){ return true; }55 virtual inline bool create(){ return Synchronisable::create(); } 56 56 57 57 void attachWorldEntity(WorldEntity* entity); -
code/trunk/src/orxonox/objects/weapon/AmmunitionDump.h
r1056 r1502 60 60 61 61 protected: 62 inline bool create() { return true; }62 inline bool create() { return Synchronisable::create(); } 63 63 void registerAllVariables(); 64 64 -
code/trunk/src/orxonox/objects/weapon/BulletManager.h
r1209 r1502 60 60 61 61 protected: 62 inline bool create() { return true; }62 inline bool create() { return Synchronisable::create(); } 63 63 void registerAllVariables(); 64 64
Note: See TracChangeset
for help on using the changeset viewer.