- Timestamp:
- Nov 28, 2008, 1:25:16 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.cc
r2201 r2292 229 229 if (this->isActive()) 230 230 { 231 this->velocity_ += (dt * this->acceleration_); 232 this->node_->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL); 231 if (!this->isDynamic()) 232 { 233 this->velocity_ += (dt * this->acceleration_); 234 this->node_->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL); 235 } 233 236 234 237 if (Core::isMaster()) … … 325 328 } 326 329 327 328 // virtual void PositionChanged() { } 329 void ControllableEntity::positionChanged(const Vector3& position) 330 void ControllableEntity::positionChanged() 330 331 { 331 332 if (Core::isMaster()) 332 333 { 333 this->server_position_ = this->getPosition();334 ++this->server_overwrite_;335 }336 else if (this->bControlled_)337 {338 this->client_position_ = position;339 }340 }341 342 void ControllableEntity::setVelocity(const Vector3& velocity)343 {344 if (Core::isMaster())345 {346 this->velocity_ = velocity;347 this->server_velocity_ = velocity;348 ++this->server_overwrite_;349 }350 else if (this->bControlled_)351 {352 this->velocity_ = velocity;353 this->client_velocity_ = velocity;354 }355 }356 // virtual void translateChanged() { }357 void ControllableEntity::translateChanged(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)358 {359 if (Core::isMaster())360 {361 this->node_->translate(distance, relativeTo);362 334 this->server_position_ = this->node_->getPosition(); 363 335 ++this->server_overwrite_; … … 365 337 else if (this->bControlled_) 366 338 { 367 this->node_->translate(distance, relativeTo);368 339 this->client_position_ = this->node_->getPosition(); 369 340 } 370 341 } 371 // virtual void orientationChanged() { } 372 void ControllableEntity::orientationChanged( const Quaternion& orientation)342 343 void ControllableEntity::orientationChanged() 373 344 { 374 345 if (Core::isMaster()) 375 346 { 376 this->node_->setOrientation(orientation);377 this->server_orientation_ = orientation;378 ++this->server_overwrite_;379 }380 else if (this->bControlled_)381 {382 this->node_->setOrientation(orientation);383 this->client_orientation_ = orientation;384 }385 }386 // virtual void rotateChanged() { }387 void ControllableEntity::rotateChanged(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)388 {389 if (Core::isMaster())390 {391 this->node_->rotate(rotation, relativeTo);392 347 this->server_orientation_ = this->node_->getOrientation(); 393 348 ++this->server_overwrite_; … … 395 350 else if (this->bControlled_) 396 351 { 397 this->node_->rotate(rotation, relativeTo);398 352 this->client_orientation_ = this->node_->getOrientation(); 399 353 } 400 354 } 401 // virtual void yawChanged() { } 402 void ControllableEntity:: yawChanged(const Degree& angle, Ogre::Node::TransformSpace relativeTo)355 356 void ControllableEntity::velocityChanged() 403 357 { 404 358 if (Core::isMaster()) 405 359 { 406 this->node_->yaw(angle, relativeTo); 407 this->server_orientation_ = this->node_->getOrientation(); 360 this->server_velocity_ = this->velocity_; 408 361 ++this->server_overwrite_; 409 362 } 410 363 else if (this->bControlled_) 411 364 { 412 this->node_->yaw(angle, relativeTo); 413 this->client_orientation_ = this->node_->getOrientation(); 414 } 415 } 416 // virtual void pitchChanged() { } 417 void ControllableEntity::pitchChanged(const Degree& angle, Ogre::Node::TransformSpace relativeTo) 418 { 419 if (Core::isMaster()) 420 { 421 this->node_->pitch(angle, relativeTo); 422 this->server_orientation_ = this->node_->getOrientation(); 423 ++this->server_overwrite_; 424 } 425 else if (this->bControlled_) 426 { 427 this->node_->pitch(angle, relativeTo); 428 this->client_orientation_ = this->node_->getOrientation(); 429 } 430 } 431 // virtual void rollChanged() { } 432 void ControllableEntity::rollChanged(const Degree& angle, Ogre::Node::TransformSpace relativeTo) 433 { 434 if (Core::isMaster()) 435 { 436 this->node_->roll(angle, relativeTo); 437 this->server_orientation_ = this->node_->getOrientation(); 438 ++this->server_overwrite_; 439 } 440 else if (this->bControlled_) 441 { 442 this->node_->roll(angle, relativeTo); 443 this->client_orientation_ = this->node_->getOrientation(); 444 } 445 } 446 //virtual void lookAtChanged() { } 447 void ControllableEntity::lookAtChanged(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector) 448 { 449 if (Core::isMaster()) 450 { 451 this->node_->lookAt(target, relativeTo, localDirectionVector); 452 this->server_orientation_ = this->node_->getOrientation(); 453 ++this->server_overwrite_; 454 } 455 else if (this->bControlled_) 456 { 457 this->node_->lookAt(target, relativeTo, localDirectionVector); 458 this->client_orientation_ = this->node_->getOrientation(); 459 } 460 } 461 // virtual void directionChanged( ) { } 462 void ControllableEntity::directionChanged(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector) 463 { 464 if (Core::isMaster()) 465 { 466 this->node_->setDirection(direction, relativeTo, localDirectionVector); 467 this->server_orientation_ = this->node_->getOrientation(); 468 ++this->server_overwrite_; 469 } 470 else if (this->bControlled_) 471 { 472 this->node_->setDirection(direction, relativeTo, localDirectionVector); 473 this->client_orientation_ = this->node_->getOrientation(); 365 this->client_velocity_ = this->velocity_; 366 } 367 } 368 369 void ControllableEntity::setVelocity(const Vector3& velocity) 370 { 371 if (this->bControlled_ || Core::isMaster()) 372 { 373 if (!this->isDynamic()) 374 { 375 // no physics, we do it ourselves 376 internalSetVelocity(velocity); 377 } 378 else 379 { 380 this->physicalBody_->setLinearVelocity(btVector3(velocity.x, velocity.y, velocity.z)); 381 } 382 velocityChanged(); 474 383 } 475 384 }
Note: See TracChangeset
for help on using the changeset viewer.