00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <graph/TargetCamera.h>
00022 #include <client/ScorchedClient.h>
00023 #include <client/ClientState.h>
00024 #include <actions/CameraPositionAction.h>
00025 #include <weapons/AccessoryStore.h>
00026 #include <weapons/WeaponMoveTank.h>
00027 #include <graph/OptionsDisplay.h>
00028 #include <landscapemap/MovementMap.h>
00029 #include <landscape/Landscape.h>
00030 #include <landscapemap/LandscapeMaps.h>
00031 #include <landscapedef/LandscapeDefinition.h>
00032 #include <landscapedef/LandscapeTex.h>
00033 #include <landscapedef/LandscapeDefn.h>
00034 #include <water/Water.h>
00035 #include <engine/ViewPoints.h>
00036 #include <engine/GameState.h>
00037 #include <tankgraph/TankKeyboardControlUtil.h>
00038 #include <tank/TankContainer.h>
00039 #include <tank/TankState.h>
00040 #include <tank/TankPosition.h>
00041 #include <tank/TankAccessories.h>
00042 #include <target/TargetLife.h>
00043 #include <common/ChannelManager.h>
00044 #include <common/Keyboard.h>
00045 #include <common/Logger.h>
00046 #include <common/LoggerI.h>
00047 #include <common/Defines.h>
00048 #include <lang/LangResource.h>
00049 #include <math.h>
00050
00051 static const char *cameraNames[] =
00052 {
00053 "Top",
00054 "AboveTank",
00055 "Tank",
00056 "Shot",
00057 "Action",
00058 "Left",
00059 "Right",
00060 "LeftFar",
00061 "RightFar",
00062 "Spectator",
00063 "Free"
00064 };
00065 static const int noCameraNames = sizeof(cameraNames) / sizeof(char *);
00066
00067 static ToolTip *cameraToolTips = 0;
00068 static const char *cameraDescriptions[] =
00069 {
00070 "Look directly down on the current tank.\n"
00071 "Tracks the current tanks rotation.",
00072 "Look from above and behind the current tank.\n"
00073 "Tracks the current tanks rotation.",
00074 "Look from directly behind the current tank.\n"
00075 "Tracks the current tanks rotation.",
00076 "Look from the current tanks gun turret.\n"
00077 "Follows any shots the current tank makes.\n"
00078 "Tracks the current tanks rotation.",
00079 "Automaticaly tracks any action around the\n"
00080 "island by moving to view any explosions\n"
00081 "and deaths.",
00082 "Look at the left of the current tank.\n"
00083 "Tracks the current tanks rotation.",
00084 "Look at the right of the current tank.\n"
00085 "Tracks the current tanks rotation.",
00086 "Look at the left of the current tank.\n"
00087 "Tracks the current tanks rotation.",
00088 "Look at the right of the current tank.\n"
00089 "Tracks the current tanks rotation.",
00090 "Look at the island from afar.",
00091 "A custom camera position has been made by the\n"
00092 "user."
00093 };
00094 static const int noCameraDescriptions = sizeof(cameraDescriptions) / sizeof(char *);
00095
00096 TargetCamera::TargetCamera() :
00097 mainCam_(300, 300),
00098 cameraPos_(CamSpectator),
00099 totalTime_(0.0f),
00100 particleEngine_(&mainCam_, 6000),
00101 useHeightFunc_(true),
00102 dragging_(false),
00103 lastLandIntersectValid_(false)
00104 {
00105 resetCam();
00106
00107 mainCam_.setMinHeightFunc(minHeightFunc, this);
00108 mainCam_.setMaxHeightFunc(maxHeightFunc, this);
00109 DIALOG_ASSERT(noCameraDescriptions == noCameraNames);
00110
00111 particleEngine_.setAllowSorting(false);
00112 rainEmitter_.setAttributes(
00113 4.0f, 4.0f,
00114 0.5f, 0.5f,
00115 0.01f, 0.02f,
00116 Vector(0.0f, 0.0f, 0.0f), Vector(0.0f, 0.0f, 0.0f),
00117 Vector(1.0f, 1.0f, 1.0f), 0.6f,
00118 Vector(1.0f, 1.0f, 1.0f), 0.6f,
00119 Vector(1.0f, 1.0f, 1.0f), 0.6f,
00120 Vector(1.0f, 1.0f, 1.0f), 0.6f,
00121 0.2f, 0.2f, 0.2f, 0.2f,
00122 0.2f, 0.2f, 0.2f, 0.2f,
00123 Vector(0.0f, 0.0f, -1600.0f),
00124 false,
00125 true);
00126 snowEmitter_.setAttributes(
00127 16.0f, 16.0f,
00128 0.5f, 0.5f,
00129 0.01f, 0.02f,
00130 Vector(-10.0f, -10.0f, 0.0f), Vector(10.0f, 10.0f, 0.0f),
00131 Vector(1.0f, 1.0f, 1.0f), 0.6f,
00132 Vector(1.0f, 1.0f, 1.0f), 0.6f,
00133 Vector(1.0f, 1.0f, 1.0f), 0.6f,
00134 Vector(1.0f, 1.0f, 1.0f), 0.6f,
00135 0.2f, 0.2f, 0.2f, 0.2f,
00136 0.2f, 0.2f, 0.2f, 0.2f,
00137 Vector(0.0f, 0.0f, -600.0f),
00138 false,
00139 true);
00140 }
00141
00142 TargetCamera::~TargetCamera()
00143 {
00144
00145 }
00146
00147 void TargetCamera::resetCam()
00148 {
00149 Vector at(128.0f, 128.0f, 5.0f);
00150 mainCam_.setLookAt(at, true);
00151 cameraPos_ = CamSpectator;
00152 }
00153
00154 const char **TargetCamera::getCameraNames()
00155 {
00156 return cameraNames;
00157 }
00158
00159 ToolTip *TargetCamera::getCameraToolTips()
00160 {
00161 if (cameraToolTips == 0)
00162 {
00163 cameraToolTips = new ToolTip[noCameraDescriptions];
00164 for (int i=0; i<noCameraDescriptions; i++)
00165 {
00166 cameraToolTips[i].setText(ToolTip::ToolTipHelp,
00167 LANG_RESOURCE(getCameraNames()[i], getCameraNames()[i]),
00168 LANG_RESOURCE(std::string(getCameraNames()[i]) + "_camera", cameraDescriptions[i]));
00169 }
00170 }
00171 return cameraToolTips;
00172 }
00173
00174 int TargetCamera::getNoCameraNames()
00175 {
00176 return noCameraNames;
00177 }
00178
00179 float TargetCamera::minHeightFunc(int x, int y, void *data)
00180 {
00181 TargetCamera *instance = (TargetCamera *) data;
00182 if (instance->cameraPos_ == CamGun)
00183 {
00184 if ((instance->mainCam_.getCurrentPos() -
00185 instance->mainCam_.getLookAt()).Magnitude() < 5.0f) return 0.0f;
00186 }
00187
00188 const float heightMin = (Landscape::instance()->getWater().getWaterOn()?
00189 Landscape::instance()->getWater().getWaterHeight():0.0f);
00190 float addition = 5.0f;
00191
00192 float h = ScorchedClient::instance()->getLandscapeMaps().
00193 getGroundMaps().getHeight(x, y).asFloat() + addition;
00194 return (h>heightMin + addition?h:heightMin + addition);
00195 }
00196
00197 float TargetCamera::maxHeightFunc(int x, int y, void *data)
00198 {
00199 float h =
00200 ScorchedClient::instance()->getLandscapeMaps().
00201 getRoofMaps().getRoofHeight(x, y).asFloat() - 2.0f;
00202 return h;
00203 }
00204
00205 void TargetCamera::simulate(float frameTime, bool playing)
00206 {
00207 totalTime_ += frameTime * ParticleEngine::getFast();
00208 while (totalTime_ > 0.05f)
00209 {
00210 if (!OptionsDisplay::instance()->getNoPrecipitation())
00211 {
00212 LandscapeTex &tex = *ScorchedClient::instance()->getLandscapeMaps().
00213 getDefinitions().getTex();
00214 if (tex.precipitation->getType() == LandscapeTexType::ePrecipitationRain)
00215 {
00216 LandscapeTexPrecipitation *rain = (LandscapeTexPrecipitation *)
00217 tex.precipitation;
00218 rainEmitter_.emitPrecipitation(mainCam_.getCurrentPos(),
00219 particleEngine_,
00220 rain->particles,
00221 true);
00222 }
00223 else if (tex.precipitation->getType() == LandscapeTexType::ePrecipitationSnow)
00224 {
00225 LandscapeTexPrecipitation *snow = (LandscapeTexPrecipitation *)
00226 tex.precipitation;
00227 snowEmitter_.emitPrecipitation(mainCam_.getCurrentPos(),
00228 particleEngine_,
00229 snow->particles,
00230 false);
00231 }
00232 }
00233 totalTime_ -= 0.1f;
00234 }
00235
00236 particleEngine_.simulate(0, frameTime);
00237 if (moveCamera(frameTime, playing))
00238 {
00239 mainCam_.simulate(frameTime);
00240 }
00241 }
00242
00243 void TargetCamera::draw()
00244 {
00245 mainCam_.draw();
00246 }
00247
00248 void TargetCamera::drawPrecipitation()
00249 {
00250 particleEngine_.draw(0);
00251 }
00252
00253 bool TargetCamera::moveCamera(float frameTime, bool playing)
00254 {
00255 float arenaWidth = (float) ScorchedClient::instance()->getLandscapeMaps().
00256 getGroundMaps().getArenaWidth();
00257 float arenaHeight = (float) ScorchedClient::instance()->getLandscapeMaps().
00258 getGroundMaps().getArenaHeight();
00259 float arenaX = (float) ScorchedClient::instance()->getLandscapeMaps().
00260 getGroundMaps().getArenaX();
00261 float arenaY = (float) ScorchedClient::instance()->getLandscapeMaps().
00262 getGroundMaps().getArenaY();
00263
00264 bool simulateCamera = true;
00265 Vector position(arenaX + arenaWidth / 2.0f, arenaY + arenaHeight / 2.0f, 15.0f);
00266 float currentRotation = 0.0f;
00267
00268 Tank *currentTank = ScorchedClient::instance()->getTankContainer().getCurrentTank();
00269 if (currentTank &&
00270 currentTank->getState().getState() == TankState::sNormal)
00271 {
00272 position = currentTank->getPosition().getTankTurretPosition().asVector();
00273 currentRotation = (180.0f - currentTank->getPosition().getRotationGunXY().asFloat()) / 57.32f;
00274 }
00275
00276 bool viewFromBehindTank = false;
00277 switch (cameraPos_)
00278 {
00279 case CamAction:
00280 {
00281 CameraPositionAction *action =
00282 CameraPositionActionRegistry::getCurrentAction();
00283 if (action)
00284 {
00285 mainCam_.setLookAt(action->getShowPosition().asVector());
00286 mainCam_.movePosition(currentRotation + 0.3f, 0.7f, 80.0f);
00287 }
00288 else viewFromBehindTank = true;
00289 }
00290 break;
00291 case CamTop:
00292 mainCam_.setLookAt(position);
00293 mainCam_.movePosition(currentRotation, 0.174f, 50.f);
00294 break;
00295 case CamTank:
00296 {
00297 Vector newPos(
00298 getFastSin(currentRotation) * 8.0f,
00299 getFastCos(currentRotation) * 8.0f,
00300 0.0f);
00301
00302 Vector newPos2 = position - newPos;
00303 mainCam_.setLookAt(newPos2);
00304 mainCam_.movePosition(currentRotation, 1.48f, 15.f);
00305 }
00306 break;
00307 case CamGun:
00308 if (ScorchedClient::instance()->getContext().getViewPoints().getLookAtCount() > 0)
00309 {
00310 FixedVector lookatPos, lookfromPos;
00311 ScorchedClient::instance()->getContext().getViewPoints().
00312 getValues(lookatPos, lookfromPos);
00313
00314 mainCam_.setLookAt(lookatPos.asVector(), true);
00315 mainCam_.setOffSet(lookfromPos.asVector(), true);
00316
00317 }
00318 else viewFromBehindTank = true;
00319 break;
00320 case CamBehind:
00321 {
00322 Vector newPos(
00323 getFastSin(currentRotation) * 25.0f,
00324 getFastCos(currentRotation) * 25.0f,
00325 0.0f);
00326 Vector newPos2 = position - newPos;
00327
00328 mainCam_.setLookAt(newPos2);
00329 mainCam_.movePosition(currentRotation, 1.0f, 60.f);
00330 }
00331 break;
00332 case CamLeftFar:
00333 {
00334 Vector newPos(
00335 getFastSin(currentRotation) * 65.0f,
00336 getFastCos(currentRotation) * 65.0f,
00337 0.0f);
00338 Vector newPos2 = position - newPos;
00339
00340 mainCam_.setLookAt(newPos2);
00341 mainCam_.movePosition(currentRotation + HALFPI, 1.0f, 100.f);
00342 }
00343 break;
00344 case CamRightFar:
00345 {
00346 Vector newPos(
00347 getFastSin(currentRotation) * 65.0f,
00348 getFastCos(currentRotation) * 65.0f,
00349 0.0f);
00350 Vector newPos2 = position - newPos;
00351
00352 mainCam_.setLookAt(newPos2);
00353 mainCam_.movePosition(currentRotation - HALFPI, 1.4f, 100.f);
00354 }
00355 break;
00356 case CamLeft:
00357 {
00358 Vector newPos(
00359 getFastSin(currentRotation) * 10.0f,
00360 getFastCos(currentRotation) * 10.0f,
00361 0.0f);
00362 Vector newPos2 = position - newPos;
00363
00364 mainCam_.setLookAt(newPos2);
00365 mainCam_.movePosition(currentRotation + HALFPI, 1.4f, 20.f);
00366 }
00367 break;
00368 case CamRight:
00369 {
00370 Vector newPos(
00371 getFastSin(currentRotation) * 10.0f,
00372 getFastCos(currentRotation) * 10.0f,
00373 0.0f);
00374 Vector newPos2 = position - newPos;
00375
00376 mainCam_.setLookAt(newPos2);
00377 mainCam_.movePosition(currentRotation - HALFPI, 0.8f, 20.f);
00378 }
00379 break;
00380 case CamSpectator:
00381 {
00382 Vector at(arenaX + arenaWidth / 2.0f, arenaY + arenaHeight / 2.0f, 0.0f);
00383 mainCam_.setLookAt(at);
00384 mainCam_.movePosition(HALFPI, 1.1f, 200.f);
00385 }
00386 break;
00387 default:
00388 break;
00389 }
00390
00391 if (viewFromBehindTank)
00392 {
00393 if (playing &&
00394 currentTank && currentTank->getState().getState() == TankState::sNormal)
00395 {
00396 float currentElevation = (currentTank->getPosition().getRotationGunYZ().asFloat()) / 160.0f;
00397 Vector newPos = currentTank->getPosition().getTankGunPosition().asVector();
00398 Vector diff = newPos - position;
00399 Vector newPos2 = position + (diff);
00400 newPos2[2] += 0.5f;
00401
00402 mainCam_.setLookAt(newPos2);
00403 mainCam_.movePosition(currentRotation, currentElevation + 1.57f, 3.0f);
00404 }
00405 }
00406
00407 return simulateCamera;
00408 }
00409
00410 bool TargetCamera::getLandIntersect(int x, int y, Vector &intersect)
00411 {
00412 mainCam_.draw();
00413 Line direction;
00414 if (!mainCam_.getDirectionFromPt((float) x, (float) y, direction))
00415 {
00416 return false;
00417 }
00418 if (!ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().
00419 getIntersect(direction, intersect))
00420 {
00421 return false;
00422 }
00423 return true;
00424 }
00425
00426 void TargetCamera::mouseDrag(GameState::MouseButton button,
00427 int mx, int my, int x, int y, bool &skipRest)
00428 {
00429 cameraPos_ = CamFree;
00430 if (button == GameState::MouseButtonRight)
00431 {
00432 if (OptionsDisplay::instance()->getInvertMouse())
00433 {
00434 y = -y;
00435 }
00436
00437 const float QPI = 3.14f / 180.0f;
00438 mainCam_.movePositionDelta(
00439 (GLfloat) (x) * QPI,
00440 (GLfloat) (-y) * QPI,
00441 0.0f);
00442 }
00443 else if (button == GameState::MouseButtonLeft)
00444 {
00445 if (mx - dragXStart_ > 4 || mx - dragXStart_ < -4 ||
00446 my - dragYStart_ > 4 || my - dragYStart_ < -4)
00447 {
00448 dragging_ = true;
00449 }
00450
00451 if (dragging_)
00452 {
00453 cameraPos_ = CamFree;
00454 float arenaWidth = (float) ScorchedClient::instance()->getLandscapeMaps().
00455 getGroundMaps().getArenaWidth();
00456 float arenaHeight = (float) ScorchedClient::instance()->getLandscapeMaps().
00457 getGroundMaps().getArenaHeight();
00458 float arenaX = (float) ScorchedClient::instance()->getLandscapeMaps().
00459 getGroundMaps().getArenaX();
00460 float arenaY = (float) ScorchedClient::instance()->getLandscapeMaps().
00461 getGroundMaps().getArenaY();
00462 mainCam_.scroll(float(-x / 2), float(-y / 2),
00463 arenaX, arenaY, arenaX + arenaWidth, arenaY + arenaHeight);
00464 }
00465 }
00466 else
00467 {
00468 mainCam_.movePositionDelta(
00469 0.0f, 0.0f,
00470 (GLfloat) (y));
00471 }
00472 }
00473
00474 void TargetCamera::mouseWheel(int x, int y, int z, bool &skipRest)
00475 {
00476 cameraPos_ = CamFree;
00477 mainCam_.movePositionDelta(
00478 0.0f, 0.0f,
00479 ((GLfloat) z) / 10.0f);
00480 }
00481
00482 void TargetCamera::mouseDown(GameState::MouseButton button,
00483 int x, int y, bool &skipRest)
00484 {
00485 dragXStart_ = x;
00486 dragYStart_ = y;
00487
00488 lastLandIntersectValid_ =
00489 getLandIntersect(x, y, lastLandIntersect_);
00490 }
00491
00492 void TargetCamera::mouseUp(GameState::MouseButton button,
00493 int x, int y, bool &skipRest)
00494 {
00495
00496
00497
00498 if (dragging_)
00499 {
00500 dragging_ = false;
00501 return;
00502 }
00503
00504
00505 if (!lastLandIntersectValid_)
00506 {
00507 return;
00508 }
00509 lastLandIntersectValid_ = false;
00510
00511 skipRest = true;
00512
00513
00514
00515
00516 Accessory *currentWeapon = 0;
00517 Tank *currentTank = 0;
00518 Accessory::PositionSelectType selectType = Accessory::ePositionSelectNone;
00519 if (ScorchedClient::instance()->getGameState().getState() ==
00520 ClientState::StatePlaying)
00521 {
00522 currentTank = ScorchedClient::instance()->
00523 getTankContainer().getCurrentTank();
00524 if (currentTank)
00525 {
00526 currentWeapon = currentTank->getAccessories().getWeapons().getCurrent();
00527 if (currentWeapon)
00528 {
00529 selectType = currentWeapon->getPositionSelect();
00530 }
00531 }
00532 }
00533
00534
00535 int arenaWidth = ScorchedClient::instance()->getLandscapeMaps().
00536 getGroundMaps().getArenaWidth();
00537 int arenaHeight = ScorchedClient::instance()->getLandscapeMaps().
00538 getGroundMaps().getArenaHeight();
00539 int arenaX = ScorchedClient::instance()->getLandscapeMaps().
00540 getGroundMaps().getArenaX();
00541 int arenaY = ScorchedClient::instance()->getLandscapeMaps().
00542 getGroundMaps().getArenaY();
00543 int posX = (int) lastLandIntersect_[0];
00544 int posY = (int) lastLandIntersect_[1];
00545 if (posX > arenaX && posX < arenaX + arenaWidth &&
00546 posY > arenaY && posY < arenaY + arenaHeight)
00547 {
00548
00549 if (selectType == Accessory::ePositionSelectNone)
00550 {
00551 cameraPos_ = CamFree;
00552 mainCam_.setLookAt(lastLandIntersect_);
00553 return;
00554 }
00555
00556 if (selectType == Accessory::ePositionSelectFuel)
00557 {
00558 WeaponMoveTank *moveWeapon = (WeaponMoveTank *)
00559 ScorchedClient::instance()->getAccessoryStore().
00560 findAccessoryPartByAccessoryId(
00561 currentWeapon->getAccessoryId(), "WeaponMoveTank");
00562 if (!moveWeapon) return;
00563
00564 MovementMap mmap(
00565 currentTank,
00566 ScorchedClient::instance()->getContext());
00567
00568 FixedVector pos((int) posX, (int) posY, 0);
00569 mmap.calculatePosition(pos, mmap.getFuel(moveWeapon));
00570
00571 MovementMap::MovementMapEntry &entry = mmap.getEntry(posX, posY);
00572 if (entry.type != MovementMap::eMovement) return;
00573 }
00574 else if (selectType == Accessory::ePositionSelectFuelLimit)
00575 {
00576 int limit = currentWeapon->getPositionSelectLimit();
00577 MovementMap mmap(
00578 currentTank,
00579 ScorchedClient::instance()->getContext());
00580
00581 FixedVector pos((int) posX, (int) posY, 0);
00582 mmap.calculatePosition(pos, fixed(limit));
00583
00584 MovementMap::MovementMapEntry &entry = mmap.getEntry(posX, posY);
00585 if (entry.type != MovementMap::eMovement) return;
00586 }
00587 else if (selectType == Accessory::ePositionSelectLimit)
00588 {
00589 int limit = currentWeapon->getPositionSelectLimit();
00590 FixedVector position(posX, posY, 0);
00591 if ((currentTank->getLife().getTargetPosition() - position).Magnitude() > limit)
00592 {
00593
00594 return;
00595 }
00596 }
00597
00598 currentTank->getPosition().setSelectPosition(posX, posY);
00599 TankKeyboardControlUtil::fireShot(currentTank);
00600 }
00601 }
00602
00603 bool TargetCamera::keyboardCheck(float frameTime,
00604 char *buffer, unsigned int keyState,
00605 KeyboardHistory::HistoryElement *history,
00606 int hisCount,
00607 bool &skipRest)
00608 {
00609 bool keyDown = false;
00610
00611 KEYBOARDKEY("CAMERA_TOP_VIEW", topViewKey);
00612 KEYBOARDKEY("CAMERA_BEHIND_VIEW", behindViewKey);
00613 KEYBOARDKEY("CAMERA_TANK_VIEW", tankViewKey);
00614 KEYBOARDKEY("CAMERA_GUN_VIEW", gunViewKey);
00615 KEYBOARDKEY("CAMERA_ACTION_VIEW", actionViewKey);
00616 KEYBOARDKEY("CAMERA_LEFT_VIEW", leftViewKey);
00617 KEYBOARDKEY("CAMERA_RIGHT_VIEW", rightViewKey);
00618 KEYBOARDKEY("CAMERA_LEFTFAR_VIEW", leftFarViewKey);
00619 KEYBOARDKEY("CAMERA_RIGHTFAR_VIEW", rightFarViewKey);
00620 KEYBOARDKEY("CAMERA_SPECTATOR_VIEW", spectatorViewKey);
00621
00622 if (topViewKey->keyDown(buffer, keyState)) cameraPos_ = CamTop;
00623 else if (behindViewKey->keyDown(buffer, keyState)) cameraPos_ = CamBehind;
00624 else if (tankViewKey->keyDown(buffer, keyState)) cameraPos_ = CamTank;
00625 else if (gunViewKey->keyDown(buffer, keyState)) cameraPos_ = CamGun;
00626 else if (leftViewKey->keyDown(buffer, keyState)) cameraPos_ = CamLeft;
00627 else if (rightViewKey->keyDown(buffer, keyState)) cameraPos_ = CamRight;
00628 else if (leftFarViewKey->keyDown(buffer, keyState)) cameraPos_ = CamLeftFar;
00629 else if (rightFarViewKey->keyDown(buffer, keyState)) cameraPos_ = CamRightFar;
00630 else if (spectatorViewKey->keyDown(buffer, keyState)) cameraPos_ = CamSpectator;
00631 else if (actionViewKey->keyDown(buffer, keyState)) cameraPos_ = CamAction;
00632
00633 const float QPI = 3.14f / 4.0f;
00634 KEYBOARDKEY("CAMERA_ROTATE_LEFT", leftKey);
00635 KEYBOARDKEY("CAMERA_ROTATE_RIGHT", rightKey);
00636 if (leftKey->keyDown(buffer, keyState))
00637 {
00638 keyDown = true;
00639 cameraPos_ = CamFree;
00640 mainCam_.movePositionDelta(QPI * frameTime, 0.0f, 0.0f);
00641 }
00642 else if (rightKey->keyDown(buffer, keyState))
00643 {
00644 keyDown = true;
00645 cameraPos_ = CamFree;
00646 mainCam_.movePositionDelta(-QPI * frameTime, 0.0f, 0.0f);
00647 }
00648
00649 KEYBOARDKEY("CAMERA_ROTATE_DOWN", downKey);
00650 KEYBOARDKEY("CAMERA_ROTATE_UP", upKey);
00651 if (upKey->keyDown(buffer, keyState))
00652 {
00653 keyDown = true;
00654 cameraPos_ = CamFree;
00655 mainCam_.movePositionDelta(0.0f, -QPI * frameTime, 0.0f);
00656 }
00657 else if (downKey->keyDown(buffer, keyState))
00658 {
00659 keyDown = true;
00660 cameraPos_ = CamFree;
00661 mainCam_.movePositionDelta(0.0f, QPI * frameTime, 0.0f);
00662 }
00663
00664 KEYBOARDKEY("CAMERA_ZOOM_IN", inKey);
00665 KEYBOARDKEY("CAMERA_ZOOM_OUT", outKey);
00666 if (inKey->keyDown(buffer, keyState))
00667 {
00668 keyDown = true;
00669 cameraPos_ = CamFree;
00670 mainCam_.movePositionDelta(0.0f, 0.0f, -100.0f * frameTime);
00671 }
00672 else if (outKey->keyDown(buffer, keyState))
00673 {
00674 keyDown = true;
00675 cameraPos_ = CamFree;
00676 mainCam_.movePositionDelta(0.0f, 0.0f, 100.0f * frameTime);
00677 }
00678
00679 KEYBOARDKEY("CAMERA_NOLIMIT", limitKey);
00680 if (limitKey->keyDown(buffer, keyState, false))
00681 {
00682 useHeightFunc_ = !useHeightFunc_;
00683 ChannelManager::showText(
00684 ScorchedClient::instance()->getContext(),
00685 ChannelText("info",
00686 LANG_RESOURCE("RESTRICED_CAMERA_MOVEMENT", "Restricted camera movement : ") +
00687 (useHeightFunc_?LANG_RESOURCE("ON", "On"):LANG_RESOURCE("OFF", "Off"))));
00688 }
00689 mainCam_.setUseHeightFunc(useHeightFunc_);
00690 return keyDown;
00691 }