mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
integrated zooming the camera in and out
This commit is contained in:
@@ -622,4 +622,8 @@ namespace battleship{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ActiveGameState::onRawMouseWheelScroll(bool up){
|
||||
CameraController::getSingleton()->zoomCamera(up);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace battleship{
|
||||
void update();
|
||||
void onAction(int, bool);
|
||||
void onAnalog(int, float);
|
||||
void onRawMouseWheelScroll(bool);
|
||||
inline void addButton(vb01Gui::Button *b){buttons.push_back(b);}
|
||||
inline std::vector<vb01Gui::Button*> getButtons(){return buttons;}
|
||||
inline Player* getPlayer(){return mainPlayer;}
|
||||
|
||||
@@ -51,4 +51,23 @@ namespace battleship{
|
||||
Vector3 dir = rotQuat * cam->getDirection(), up = rotQuat * cam->getUp();
|
||||
cam->lookAt(dir, up);
|
||||
}
|
||||
|
||||
void CameraController::zoomCamera(bool zoomIn){
|
||||
if((zoomIn && numZooms > configData::NUM_MAX_ZOOMS) || (!zoomIn && numZooms < -configData::NUM_MAX_ZOOMS)) return;
|
||||
|
||||
Vector3 newPos;
|
||||
float offset;
|
||||
|
||||
if(zoomIn){
|
||||
numZooms++;
|
||||
offset = configData::CAMERA_ZOOM_INCREMENT;
|
||||
}
|
||||
else{
|
||||
numZooms--;
|
||||
offset = -configData::CAMERA_ZOOM_INCREMENT;
|
||||
}
|
||||
|
||||
Camera *cam = Root::getSingleton()->getCamera();
|
||||
cam->setPosition(cam->getPosition() + cam->getDirection() * offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,14 @@ namespace battleship{
|
||||
static CameraController* getSingleton();
|
||||
void updateCameraPosition();
|
||||
void orientCamera(vb01::Vector3, double);
|
||||
void zoomCamera(bool);
|
||||
inline bool isLookingAround(){return lookingAround;}
|
||||
inline void setLookingAround(bool l){lookingAround = l;}
|
||||
private:
|
||||
CameraController(){}
|
||||
|
||||
bool lookingAround = false;
|
||||
int numZooms = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ namespace battleship{
|
||||
using namespace gameBase;
|
||||
|
||||
const std::string DEFAULT_TEXTURE = "Textures/defaultTexture.jpg";
|
||||
const double camPanSpeed = .1, cellLength = 14, cellWidth = 14, cellDepth = 7;
|
||||
const double camPanSpeed = .1, CAMERA_DISTANCE = 50, CAMERA_ZOOM_INCREMENT = 1, NUM_MAX_ZOOMS = 25, cellLength = 14, cellWidth = 14, cellDepth = 7;
|
||||
const int maxNumGroups = 10;
|
||||
const vb01::u32 IMPASS_NODE_VAL = 65535;
|
||||
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ namespace battleship{
|
||||
}
|
||||
|
||||
Camera *cam = Root::getSingleton()->getCamera();
|
||||
cam->setPosition(Map::getSingleton()->getSpawnPoint(playerId - 1) + Vector3(1, 1, 1) * 40);
|
||||
cam->setPosition(Map::getSingleton()->getSpawnPoint(playerId - 1) + Vector3(1, 1, 1) * configData::CAMERA_DISTANCE);
|
||||
cam->lookAt(Vector3(-1, -1, -1).norm(), Vector3(-1, 1, -1).norm());
|
||||
|
||||
mainPlayer = Game::getSingleton()->getPlayer(playerId);
|
||||
|
||||
@@ -225,7 +225,8 @@ namespace battleship{
|
||||
waterCellMat->addVec4Uniform("diffuseColor", Vector4(0, 0, 1, 1));
|
||||
|
||||
Camera *cam = root->getCamera();
|
||||
cam->setPosition(Vector3(1, 1, 1) * 40);
|
||||
cam->setFarPlane(300);
|
||||
cam->setPosition(Vector3(1, 1, 1) * configData::CAMERA_DISTANCE);
|
||||
cam->lookAt(Vector3(-1, -1, -1).norm(), Vector3(-1, 1, -1).norm());
|
||||
}
|
||||
|
||||
|
||||
@@ -710,4 +710,8 @@ namespace battleship{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MapEditorAppState::onRawMouseWheelScroll(bool up){
|
||||
CameraController::getSingleton()->zoomCamera(up);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ namespace battleship{
|
||||
void onDettached();
|
||||
void onAction(int, bool);
|
||||
void onAnalog(int, float);
|
||||
void onRawMouseWheelScroll(bool);
|
||||
inline MapEditor* getMapEditor(){return mapEditor;}
|
||||
private:
|
||||
MapEditor *mapEditor = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user