Changeset 3004 for code/branches
- Timestamp:
- May 21, 2009, 1:18:46 AM (16 years ago)
- Location:
- code/branches/netp3/src/orxonox/objects/worldentities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.cc
r2990 r3004 66 66 this->mouseLookSpeed_ = 200; 67 67 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;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; 76 76 77 77 … … 326 326 if (!this->isDynamic()) 327 327 { 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 //}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 } 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 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);368 364 369 365 registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); … … 373 369 { 374 370 if (!this->bHasLocalController_) 375 MobileEntity::setPosition(this-> common_position_);371 MobileEntity::setPosition(this->server_position_); 376 372 } 377 373 … … 379 375 { 380 376 if (!this->bHasLocalController_) 381 MobileEntity::setVelocity(this-> common_linear_velocity_);377 MobileEntity::setVelocity(this->server_linear_velocity_); 382 378 } 383 379 … … 385 381 { 386 382 if (!this->bHasLocalController_) 387 MobileEntity::setOrientation(this-> common_orientation_);383 MobileEntity::setOrientation(this->server_orientation_); 388 384 } 389 385 … … 391 387 { 392 388 if (!this->bHasLocalController_) 393 MobileEntity::setAngularVelocity(this-> common_angular_velocity_);389 MobileEntity::setAngularVelocity(this->server_angular_velocity_); 394 390 } 395 391 … … 398 394 if (this->bHasLocalController_) 399 395 { 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_;396 this->setPosition(this->server_position_); 397 this->setOrientation(this->server_orientation_); 398 this->setVelocity(this->server_linear_velocity_); 399 this->setAngularVelocity(this->server_angular_velocity_); 400 401 this->client_overwrite_ = this->server_overwrite_; 406 402 } 407 403 } … … 411 407 if (this->server_overwrite_ == this->client_overwrite_) 412 408 { 413 //MobileEntity::setPosition(this->client_position_);414 //this->server_position_ = this->getPosition();409 MobileEntity::setPosition(this->client_position_); 410 this->server_position_ = this->getPosition(); 415 411 } 416 412 } … … 420 416 if (this->server_overwrite_ == this->client_overwrite_) 421 417 { 422 //MobileEntity::setVelocity(this->client_linear_velocity_);423 //this->server_linear_velocity_ = this->getVelocity();418 MobileEntity::setVelocity(this->client_linear_velocity_); 419 this->server_linear_velocity_ = this->getVelocity(); 424 420 } 425 421 } … … 429 425 if (this->server_overwrite_ == this->client_overwrite_) 430 426 { 431 //MobileEntity::setOrientation(this->client_orientation_);432 //this->server_orientation_ = this->getOrientation();427 MobileEntity::setOrientation(this->client_orientation_); 428 this->server_orientation_ = this->getOrientation(); 433 429 } 434 430 } … … 438 434 if (this->server_overwrite_ == this->client_overwrite_) 439 435 { 440 //MobileEntity::setAngularVelocity(this->client_angular_velocity_);441 //this->server_angular_velocity_ = this->getAngularVelocity();436 MobileEntity::setAngularVelocity(this->client_angular_velocity_); 437 this->server_angular_velocity_ = this->getAngularVelocity(); 442 438 } 443 439 } … … 445 441 void ControllableEntity::setPosition(const Vector3& position) 446 442 { 447 //if (GameMode::isMaster())448 //{443 if (GameMode::isMaster()) 444 { 449 445 MobileEntity::setPosition(position); 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 //}446 this->server_position_ = this->getPosition(); 447 ++this->server_overwrite_; 448 } 449 else if (this->bHasLocalController_) 450 { 451 MobileEntity::setPosition(position); 452 this->client_position_ = this->getPosition(); 453 } 458 454 } 459 455 460 456 void ControllableEntity::setOrientation(const Quaternion& orientation) 461 457 { 462 //if (GameMode::isMaster())463 //{458 if (GameMode::isMaster()) 459 { 464 460 MobileEntity::setOrientation(orientation); 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 //}461 this->server_orientation_ = this->getOrientation(); 462 ++this->server_overwrite_; 463 } 464 else if (this->bHasLocalController_) 465 { 466 MobileEntity::setOrientation(orientation); 467 this->client_orientation_ = this->getOrientation(); 468 } 473 469 } 474 470 475 471 void ControllableEntity::setVelocity(const Vector3& velocity) 476 472 { 477 //if (GameMode::isMaster())478 //{473 if (GameMode::isMaster()) 474 { 479 475 MobileEntity::setVelocity(velocity); 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 //}476 this->server_linear_velocity_ = this->getVelocity(); 477 ++this->server_overwrite_; 478 } 479 else if (this->bHasLocalController_) 480 { 481 MobileEntity::setVelocity(velocity); 482 this->client_linear_velocity_ = this->getVelocity(); 483 } 488 484 } 489 485 490 486 void ControllableEntity::setAngularVelocity(const Vector3& velocity) 491 487 { 492 //if (GameMode::isMaster())493 //{488 if (GameMode::isMaster()) 489 { 494 490 MobileEntity::setAngularVelocity(velocity); 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 //}491 this->server_angular_velocity_ = this->getAngularVelocity(); 492 ++this->server_overwrite_; 493 } 494 else if (this->bHasLocalController_) 495 { 496 MobileEntity::setAngularVelocity(velocity); 497 this->client_angular_velocity_ = this->getAngularVelocity(); 498 } 503 499 } 504 500 … … 506 502 { 507 503 MobileEntity::setWorldTransform(worldTrans); 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 //}504 if (GameMode::isMaster()) 505 { 506 this->server_position_ = this->getPosition(); 507 this->server_orientation_ = this->getOrientation(); 508 this->server_linear_velocity_ = this->getVelocity(); 509 this->server_angular_velocity_ = this->getAngularVelocity(); 510 } 511 else if (this->bHasLocalController_) 512 { 513 this->client_position_ = this->getPosition(); 514 this->client_orientation_ = this->getOrientation(); 515 this->client_linear_velocity_ = this->getVelocity(); 516 this->client_angular_velocity_ = this->getAngularVelocity(); 517 } 522 518 } 523 519 } -
code/branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.h
r2990 r3004 164 164 bool bDestroyWhenPlayerLeft_; 165 165 166 // Vector3 server_position_; 167 Vector3 common_position_; 168 // Vector3 client_position_; 169 // Vector3 server_linear_velocity_; 170 // Vector3 client_linear_velocity_; 171 Vector3 common_linear_velocity_; 172 // Quaternion server_orientation_; 173 // Quaternion client_orientation_; 174 Quaternion common_orientation_; 175 // Vector3 server_angular_velocity_; 176 // Vector3 client_angular_velocity_; 177 Vector3 common_angular_velocity_; 166 Vector3 server_position_; 167 Vector3 client_position_; 168 Vector3 server_linear_velocity_; 169 Vector3 client_linear_velocity_; 170 Quaternion server_orientation_; 171 Quaternion client_orientation_; 172 Vector3 server_angular_velocity_; 173 Vector3 client_angular_velocity_; 178 174 179 175 PlayerInfo* player_;
Note: See TracChangeset
for help on using the changeset viewer.