- Timestamp:
- May 19, 2009, 9:35:10 PM (15 years ago)
- Location:
- code/branches/netp3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp3
- Property svn:mergeinfo changed
/code/branches/netp2 (added) merged: 2835-2836,2861,2937-2938,2940-2941,2943-2945,2947-2949,2951,2953,2964-2965,2974-2976
- Property svn:mergeinfo changed
-
code/branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.cc
r2973 r2990 66 66 this->mouseLookSpeed_ = 200; 67 67 68 this-> server_position_ = Vector3::ZERO;69 this->client_position_ = Vector3::ZERO;70 this-> server_linear_velocity_ = Vector3::ZERO;71 this->client_linear_velocity_ = Vector3::ZERO;72 this-> server_orientation_ = Quaternion::IDENTITY;73 this->client_orientation_ = Quaternion::IDENTITY;74 this-> server_angular_velocity_ = Vector3::ZERO;75 this->client_angular_velocity_ = Vector3::ZERO;68 this->common_position_ = Vector3::ZERO; 69 // this->client_position_ = Vector3::ZERO; 70 this->common_linear_velocity_ = Vector3::ZERO; 71 // this->client_linear_velocity_ = Vector3::ZERO; 72 this->common_orientation_ = Quaternion::IDENTITY; 73 // this->client_orientation_ = Quaternion::IDENTITY; 74 this->common_angular_velocity_ = Vector3::ZERO; 75 // this->client_angular_velocity_ = Vector3::ZERO; 76 76 77 77 … … 326 326 if (!this->isDynamic()) 327 327 { 328 if (GameMode::isMaster())329 {330 this-> server_position_ = this->getPosition();331 this-> server_orientation_ = this->getOrientation();332 this-> server_linear_velocity_ = this->getVelocity();333 this-> server_angular_velocity_ = this->getAngularVelocity();334 }335 else if (this->bHasLocalController_)336 {337 this->client_position_ = this->getPosition();338 this->client_orientation_ = this->getOrientation();339 this->client_linear_velocity_ = this->getVelocity();340 this->client_angular_velocity_ = this->getAngularVelocity();341 }328 // if (GameMode::isMaster()) 329 // { 330 this->common_position_ = this->getPosition(); 331 this->common_orientation_ = this->getOrientation(); 332 this->common_linear_velocity_ = this->getVelocity(); 333 this->common_angular_velocity_ = this->getAngularVelocity(); 334 // } 335 // else if (this->bHasLocalController_) 336 // { 337 // this->client_position_ = this->getPosition(); 338 // this->client_orientation_ = this->getOrientation(); 339 // this->client_linear_velocity_ = this->getVelocity(); 340 // this->client_angular_velocity_ = this->getAngularVelocity(); 341 // } 342 342 } 343 343 } … … 349 349 registerVariable(this->hudtemplate_, variableDirection::toclient); 350 350 351 registerVariable(this->server_position_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); 352 registerVariable(this->server_linear_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity)); 353 registerVariable(this->server_orientation_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation)); 354 registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity)); 355 356 registerVariable(this->server_overwrite_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite)); 357 registerVariable(this->client_overwrite_, variableDirection::toserver); 358 359 registerVariable(this->client_position_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition)); 360 registerVariable(this->client_linear_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity)); 361 registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation)); 362 registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity)); 351 // registerVariable(this->server_position_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); 352 // registerVariable(this->server_linear_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity)); 353 // registerVariable(this->server_orientation_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation)); 354 // registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity)); 355 // 356 // registerVariable(this->server_overwrite_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite)); 357 // registerVariable(this->client_overwrite_, variableDirection::toserver); 358 // 359 // registerVariable(this->client_position_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition)); 360 // registerVariable(this->client_linear_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity)); 361 // registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation)); 362 // registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity)); 363 364 registerVariable(this->common_position_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition), true); 365 registerVariable(this->common_linear_velocity_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity), true); 366 registerVariable(this->common_orientation_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation), true); 367 registerVariable(this->common_angular_velocity_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity), true); 363 368 364 369 registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); … … 368 373 { 369 374 if (!this->bHasLocalController_) 370 MobileEntity::setPosition(this-> server_position_);375 MobileEntity::setPosition(this->common_position_); 371 376 } 372 377 … … 374 379 { 375 380 if (!this->bHasLocalController_) 376 MobileEntity::setVelocity(this-> server_linear_velocity_);381 MobileEntity::setVelocity(this->common_linear_velocity_); 377 382 } 378 383 … … 380 385 { 381 386 if (!this->bHasLocalController_) 382 MobileEntity::setOrientation(this-> server_orientation_);387 MobileEntity::setOrientation(this->common_orientation_); 383 388 } 384 389 … … 386 391 { 387 392 if (!this->bHasLocalController_) 388 MobileEntity::setAngularVelocity(this-> server_angular_velocity_);393 MobileEntity::setAngularVelocity(this->common_angular_velocity_); 389 394 } 390 395 … … 393 398 if (this->bHasLocalController_) 394 399 { 395 this->setPosition(this->server_position_);396 this->setOrientation(this->server_orientation_);397 this->setVelocity(this->server_linear_velocity_);398 this->setAngularVelocity(this->server_angular_velocity_);399 400 this->client_overwrite_ = this->server_overwrite_;400 // this->setPosition(this->server_position_); 401 // this->setOrientation(this->server_orientation_); 402 // this->setVelocity(this->server_linear_velocity_); 403 // this->setAngularVelocity(this->server_angular_velocity_); 404 405 // this->client_overwrite_ = this->server_overwrite_; 401 406 } 402 407 } … … 406 411 if (this->server_overwrite_ == this->client_overwrite_) 407 412 { 408 MobileEntity::setPosition(this->client_position_);409 this->server_position_ = this->getPosition();413 // MobileEntity::setPosition(this->client_position_); 414 // this->server_position_ = this->getPosition(); 410 415 } 411 416 } … … 415 420 if (this->server_overwrite_ == this->client_overwrite_) 416 421 { 417 MobileEntity::setVelocity(this->client_linear_velocity_);418 this->server_linear_velocity_ = this->getVelocity();422 // MobileEntity::setVelocity(this->client_linear_velocity_); 423 // this->server_linear_velocity_ = this->getVelocity(); 419 424 } 420 425 } … … 424 429 if (this->server_overwrite_ == this->client_overwrite_) 425 430 { 426 MobileEntity::setOrientation(this->client_orientation_);427 this->server_orientation_ = this->getOrientation();431 // MobileEntity::setOrientation(this->client_orientation_); 432 // this->server_orientation_ = this->getOrientation(); 428 433 } 429 434 } … … 433 438 if (this->server_overwrite_ == this->client_overwrite_) 434 439 { 435 MobileEntity::setAngularVelocity(this->client_angular_velocity_);436 this->server_angular_velocity_ = this->getAngularVelocity();440 // MobileEntity::setAngularVelocity(this->client_angular_velocity_); 441 // this->server_angular_velocity_ = this->getAngularVelocity(); 437 442 } 438 443 } … … 440 445 void ControllableEntity::setPosition(const Vector3& position) 441 446 { 442 if (GameMode::isMaster())443 {447 // if (GameMode::isMaster()) 448 // { 444 449 MobileEntity::setPosition(position); 445 this-> server_position_ = this->getPosition();446 ++this->server_overwrite_;447 }448 else if (this->bHasLocalController_)449 {450 MobileEntity::setPosition(position);451 this->client_position_ = this->getPosition();452 }450 this->common_position_ = this->getPosition(); 451 // ++this->server_overwrite_; 452 // } 453 // else if (this->bHasLocalController_) 454 // { 455 // MobileEntity::setPosition(position); 456 // this->client_position_ = this->getPosition(); 457 // } 453 458 } 454 459 455 460 void ControllableEntity::setOrientation(const Quaternion& orientation) 456 461 { 457 if (GameMode::isMaster())458 {462 // if (GameMode::isMaster()) 463 // { 459 464 MobileEntity::setOrientation(orientation); 460 this-> server_orientation_ = this->getOrientation();461 ++this->server_overwrite_;462 }463 else if (this->bHasLocalController_)464 {465 MobileEntity::setOrientation(orientation);466 this->client_orientation_ = this->getOrientation();467 }465 this->common_orientation_ = this->getOrientation(); 466 // ++this->server_overwrite_; 467 // } 468 // else if (this->bHasLocalController_) 469 // { 470 // MobileEntity::setOrientation(orientation); 471 // this->client_orientation_ = this->getOrientation(); 472 // } 468 473 } 469 474 470 475 void ControllableEntity::setVelocity(const Vector3& velocity) 471 476 { 472 if (GameMode::isMaster())473 {477 // if (GameMode::isMaster()) 478 // { 474 479 MobileEntity::setVelocity(velocity); 475 this-> server_linear_velocity_ = this->getVelocity();476 ++this->server_overwrite_;477 }478 else if (this->bHasLocalController_)479 {480 MobileEntity::setVelocity(velocity);481 this->client_linear_velocity_ = this->getVelocity();482 }480 this->common_linear_velocity_ = this->getVelocity(); 481 // ++this->server_overwrite_; 482 // } 483 // else if (this->bHasLocalController_) 484 // { 485 // MobileEntity::setVelocity(velocity); 486 // this->client_linear_velocity_ = this->getVelocity(); 487 // } 483 488 } 484 489 485 490 void ControllableEntity::setAngularVelocity(const Vector3& velocity) 486 491 { 487 if (GameMode::isMaster())488 {492 // if (GameMode::isMaster()) 493 // { 489 494 MobileEntity::setAngularVelocity(velocity); 490 this-> server_angular_velocity_ = this->getAngularVelocity();491 ++this->server_overwrite_;492 }493 else if (this->bHasLocalController_)494 {495 MobileEntity::setAngularVelocity(velocity);496 this->client_angular_velocity_ = this->getAngularVelocity();497 }495 this->common_angular_velocity_ = this->getAngularVelocity(); 496 // ++this->server_overwrite_; 497 // } 498 // else if (this->bHasLocalController_) 499 // { 500 // MobileEntity::setAngularVelocity(velocity); 501 // this->client_angular_velocity_ = this->getAngularVelocity(); 502 // } 498 503 } 499 504 … … 501 506 { 502 507 MobileEntity::setWorldTransform(worldTrans); 503 if (GameMode::isMaster())504 {505 this-> server_position_ = this->getPosition();506 this-> server_orientation_ = this->getOrientation();507 this-> server_linear_velocity_ = this->getVelocity();508 this-> server_angular_velocity_ = this->getAngularVelocity();509 }510 else if (this->bHasLocalController_)511 {512 this->client_position_ = this->getPosition();513 this->client_orientation_ = this->getOrientation();514 this->client_linear_velocity_ = this->getVelocity();515 this->client_angular_velocity_ = this->getAngularVelocity();516 }508 // if (GameMode::isMaster()) 509 // { 510 this->common_position_ = this->getPosition(); 511 this->common_orientation_ = this->getOrientation(); 512 this->common_linear_velocity_ = this->getVelocity(); 513 this->common_angular_velocity_ = this->getAngularVelocity(); 514 // } 515 // else if (this->bHasLocalController_) 516 // { 517 // this->client_position_ = this->getPosition(); 518 // this->client_orientation_ = this->getOrientation(); 519 // this->client_linear_velocity_ = this->getVelocity(); 520 // this->client_angular_velocity_ = this->getAngularVelocity(); 521 // } 517 522 } 518 523 }
Note: See TracChangeset
for help on using the changeset viewer.