Changeset 2964 for code/branches/netp2/src
- Timestamp:
- May 11, 2009, 1:30:17 PM (16 years ago)
- Location:
- code/branches/netp2/src/orxonox/objects/worldentities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp2/src/orxonox/objects/worldentities/ControllableEntity.cc
r2826 r2964 71 71 this->changedGametype(); 72 72 73 this-> server_position_ = Vector3::ZERO;74 this->client_position_ = Vector3::ZERO;75 this-> server_linear_velocity_ = Vector3::ZERO;76 this->client_linear_velocity_ = Vector3::ZERO;77 this-> server_orientation_ = Quaternion::IDENTITY;78 this->client_orientation_ = Quaternion::IDENTITY;79 this-> server_angular_velocity_ = Vector3::ZERO;80 this->client_angular_velocity_ = Vector3::ZERO;73 this->common_position_ = Vector3::ZERO; 74 // this->client_position_ = Vector3::ZERO; 75 this->common_linear_velocity_ = Vector3::ZERO; 76 // this->client_linear_velocity_ = Vector3::ZERO; 77 this->common_orientation_ = Quaternion::IDENTITY; 78 // this->client_orientation_ = Quaternion::IDENTITY; 79 this->common_angular_velocity_ = Vector3::ZERO; 80 // this->client_angular_velocity_ = Vector3::ZERO; 81 81 82 82 … … 340 340 if (!this->isDynamic()) 341 341 { 342 if (Core::isMaster())343 {344 this-> server_position_ = this->getPosition();345 this-> server_orientation_ = this->getOrientation();346 this-> server_linear_velocity_ = this->getVelocity();347 this-> server_angular_velocity_ = this->getAngularVelocity();348 }349 else if (this->bHasLocalController_)350 {351 this->client_position_ = this->getPosition();352 this->client_orientation_ = this->getOrientation();353 this->client_linear_velocity_ = this->getVelocity();354 this->client_angular_velocity_ = this->getAngularVelocity();355 }342 // if (Core::isMaster()) 343 // { 344 this->common_position_ = this->getPosition(); 345 this->common_orientation_ = this->getOrientation(); 346 this->common_linear_velocity_ = this->getVelocity(); 347 this->common_angular_velocity_ = this->getAngularVelocity(); 348 // } 349 // else if (this->bHasLocalController_) 350 // { 351 // this->client_position_ = this->getPosition(); 352 // this->client_orientation_ = this->getOrientation(); 353 // this->client_linear_velocity_ = this->getVelocity(); 354 // this->client_angular_velocity_ = this->getAngularVelocity(); 355 // } 356 356 } 357 357 } … … 363 363 registerVariable(this->hudtemplate_, variableDirection::toclient); 364 364 365 registerVariable(this->server_position_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); 366 registerVariable(this->server_linear_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity)); 367 registerVariable(this->server_orientation_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation)); 368 registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity)); 369 370 registerVariable(this->server_overwrite_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite)); 371 registerVariable(this->client_overwrite_, variableDirection::toserver); 372 373 registerVariable(this->client_position_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition)); 374 registerVariable(this->client_linear_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity)); 375 registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation)); 376 registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity)); 365 // registerVariable(this->server_position_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); 366 // registerVariable(this->server_linear_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity)); 367 // registerVariable(this->server_orientation_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation)); 368 // registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity)); 369 // 370 // registerVariable(this->server_overwrite_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite)); 371 // registerVariable(this->client_overwrite_, variableDirection::toserver); 372 // 373 // registerVariable(this->client_position_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition)); 374 // registerVariable(this->client_linear_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity)); 375 // registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation)); 376 // registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity)); 377 378 registerVariable(this->common_position_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition), true); 379 registerVariable(this->common_linear_velocity_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity), true); 380 registerVariable(this->common_orientation_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation), true); 381 registerVariable(this->common_angular_velocity_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity), true); 377 382 378 383 registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); … … 383 388 { 384 389 if (!this->bHasLocalController_) 385 MobileEntity::setPosition(this-> server_position_);390 MobileEntity::setPosition(this->common_position_); 386 391 } 387 392 … … 389 394 { 390 395 if (!this->bHasLocalController_) 391 MobileEntity::setVelocity(this-> server_linear_velocity_);396 MobileEntity::setVelocity(this->common_linear_velocity_); 392 397 } 393 398 … … 395 400 { 396 401 if (!this->bHasLocalController_) 397 MobileEntity::setOrientation(this-> server_orientation_);402 MobileEntity::setOrientation(this->common_orientation_); 398 403 } 399 404 … … 401 406 { 402 407 if (!this->bHasLocalController_) 403 MobileEntity::setAngularVelocity(this-> server_angular_velocity_);408 MobileEntity::setAngularVelocity(this->common_angular_velocity_); 404 409 } 405 410 … … 408 413 if (this->bHasLocalController_) 409 414 { 410 this->setPosition(this->server_position_);411 this->setOrientation(this->server_orientation_);412 this->setVelocity(this->server_linear_velocity_);413 this->setAngularVelocity(this->server_angular_velocity_);414 415 this->client_overwrite_ = this->server_overwrite_;415 // this->setPosition(this->server_position_); 416 // this->setOrientation(this->server_orientation_); 417 // this->setVelocity(this->server_linear_velocity_); 418 // this->setAngularVelocity(this->server_angular_velocity_); 419 420 // this->client_overwrite_ = this->server_overwrite_; 416 421 } 417 422 } … … 421 426 if (this->server_overwrite_ == this->client_overwrite_) 422 427 { 423 MobileEntity::setPosition(this->client_position_);424 this->server_position_ = this->getPosition();428 // MobileEntity::setPosition(this->client_position_); 429 // this->server_position_ = this->getPosition(); 425 430 } 426 431 } … … 430 435 if (this->server_overwrite_ == this->client_overwrite_) 431 436 { 432 MobileEntity::setVelocity(this->client_linear_velocity_);433 this->server_linear_velocity_ = this->getVelocity();437 // MobileEntity::setVelocity(this->client_linear_velocity_); 438 // this->server_linear_velocity_ = this->getVelocity(); 434 439 } 435 440 } … … 439 444 if (this->server_overwrite_ == this->client_overwrite_) 440 445 { 441 MobileEntity::setOrientation(this->client_orientation_);442 this->server_orientation_ = this->getOrientation();446 // MobileEntity::setOrientation(this->client_orientation_); 447 // this->server_orientation_ = this->getOrientation(); 443 448 } 444 449 } … … 448 453 if (this->server_overwrite_ == this->client_overwrite_) 449 454 { 450 MobileEntity::setAngularVelocity(this->client_angular_velocity_);451 this->server_angular_velocity_ = this->getAngularVelocity();455 // MobileEntity::setAngularVelocity(this->client_angular_velocity_); 456 // this->server_angular_velocity_ = this->getAngularVelocity(); 452 457 } 453 458 } … … 455 460 void ControllableEntity::setPosition(const Vector3& position) 456 461 { 457 if (Core::isMaster())458 {462 // if (Core::isMaster()) 463 // { 459 464 MobileEntity::setPosition(position); 460 this-> server_position_ = this->getPosition();461 ++this->server_overwrite_;462 }463 else if (this->bHasLocalController_)464 {465 MobileEntity::setPosition(position);466 this->client_position_ = this->getPosition();467 }465 this->common_position_ = this->getPosition(); 466 // ++this->server_overwrite_; 467 // } 468 // else if (this->bHasLocalController_) 469 // { 470 // MobileEntity::setPosition(position); 471 // this->client_position_ = this->getPosition(); 472 // } 468 473 } 469 474 470 475 void ControllableEntity::setOrientation(const Quaternion& orientation) 471 476 { 472 if (Core::isMaster())473 {477 // if (Core::isMaster()) 478 // { 474 479 MobileEntity::setOrientation(orientation); 475 this-> server_orientation_ = this->getOrientation();476 ++this->server_overwrite_;477 }478 else if (this->bHasLocalController_)479 {480 MobileEntity::setOrientation(orientation);481 this->client_orientation_ = this->getOrientation();482 }480 this->common_orientation_ = this->getOrientation(); 481 // ++this->server_overwrite_; 482 // } 483 // else if (this->bHasLocalController_) 484 // { 485 // MobileEntity::setOrientation(orientation); 486 // this->client_orientation_ = this->getOrientation(); 487 // } 483 488 } 484 489 485 490 void ControllableEntity::setVelocity(const Vector3& velocity) 486 491 { 487 if (Core::isMaster())488 {492 // if (Core::isMaster()) 493 // { 489 494 MobileEntity::setVelocity(velocity); 490 this-> server_linear_velocity_ = this->getVelocity();491 ++this->server_overwrite_;492 }493 else if (this->bHasLocalController_)494 {495 MobileEntity::setVelocity(velocity);496 this->client_linear_velocity_ = this->getVelocity();497 }495 this->common_linear_velocity_ = this->getVelocity(); 496 // ++this->server_overwrite_; 497 // } 498 // else if (this->bHasLocalController_) 499 // { 500 // MobileEntity::setVelocity(velocity); 501 // this->client_linear_velocity_ = this->getVelocity(); 502 // } 498 503 } 499 504 500 505 void ControllableEntity::setAngularVelocity(const Vector3& velocity) 501 506 { 502 if (Core::isMaster())503 {507 // if (Core::isMaster()) 508 // { 504 509 MobileEntity::setAngularVelocity(velocity); 505 this-> server_angular_velocity_ = this->getAngularVelocity();506 ++this->server_overwrite_;507 }508 else if (this->bHasLocalController_)509 {510 MobileEntity::setAngularVelocity(velocity);511 this->client_angular_velocity_ = this->getAngularVelocity();512 }510 this->common_angular_velocity_ = this->getAngularVelocity(); 511 // ++this->server_overwrite_; 512 // } 513 // else if (this->bHasLocalController_) 514 // { 515 // MobileEntity::setAngularVelocity(velocity); 516 // this->client_angular_velocity_ = this->getAngularVelocity(); 517 // } 513 518 } 514 519 … … 516 521 { 517 522 MobileEntity::setWorldTransform(worldTrans); 518 if (Core::isMaster())519 {520 this-> server_position_ = this->getPosition();521 this-> server_orientation_ = this->getOrientation();522 this-> server_linear_velocity_ = this->getVelocity();523 this-> server_angular_velocity_ = this->getAngularVelocity();524 }525 else if (this->bHasLocalController_)526 {527 this->client_position_ = this->getPosition();528 this->client_orientation_ = this->getOrientation();529 this->client_linear_velocity_ = this->getVelocity();530 this->client_angular_velocity_ = this->getAngularVelocity();531 }523 // if (Core::isMaster()) 524 // { 525 this->common_position_ = this->getPosition(); 526 this->common_orientation_ = this->getOrientation(); 527 this->common_linear_velocity_ = this->getVelocity(); 528 this->common_angular_velocity_ = this->getAngularVelocity(); 529 // } 530 // else if (this->bHasLocalController_) 531 // { 532 // this->client_position_ = this->getPosition(); 533 // this->client_orientation_ = this->getOrientation(); 534 // this->client_linear_velocity_ = this->getVelocity(); 535 // this->client_angular_velocity_ = this->getAngularVelocity(); 536 // } 532 537 } 533 538 } -
code/branches/netp2/src/orxonox/objects/worldentities/ControllableEntity.h
r2662 r2964 167 167 bool bDestroyWhenPlayerLeft_; 168 168 169 Vector3 server_position_; 170 Vector3 client_position_; 171 Vector3 server_linear_velocity_; 172 Vector3 client_linear_velocity_; 173 Quaternion server_orientation_; 174 Quaternion client_orientation_; 175 Vector3 server_angular_velocity_; 176 Vector3 client_angular_velocity_; 169 // Vector3 server_position_; 170 Vector3 common_position_; 171 // Vector3 client_position_; 172 // Vector3 server_linear_velocity_; 173 // Vector3 client_linear_velocity_; 174 Vector3 common_linear_velocity_; 175 // Quaternion server_orientation_; 176 // Quaternion client_orientation_; 177 Quaternion common_orientation_; 178 // Vector3 server_angular_velocity_; 179 // Vector3 client_angular_velocity_; 180 Vector3 common_angular_velocity_; 177 181 178 182 PlayerInfo* player_;
Note: See TracChangeset
for help on using the changeset viewer.