VIDEO: renamed a few methods of the Camera class
parent
28e69f25f5
commit
b032933361
|
@ -93,12 +93,12 @@ void GridRenderer::render(const video::Camera& camera, const math::AABB<float>&
|
|||
const math::Plane planeNear (glm::forward, center + glm::vec3(0.0f, 0.0f, -halfWidth.z));
|
||||
const math::Plane planeFar (glm::backward, center + glm::vec3(0.0f, 0.0f, halfWidth.z));
|
||||
|
||||
_shapeRenderer.hide(_gridMeshIndexXYFar, !planeFar.isBackSide(camera.position()));
|
||||
_shapeRenderer.hide(_gridMeshIndexXYNear, !planeNear.isBackSide(camera.position()));
|
||||
_shapeRenderer.hide(_gridMeshIndexXZFar, !planeTop.isBackSide(camera.position()));
|
||||
_shapeRenderer.hide(_gridMeshIndexXZNear, !planeBottom.isBackSide(camera.position()));
|
||||
_shapeRenderer.hide(_gridMeshIndexYZFar, !planeRight.isBackSide(camera.position()));
|
||||
_shapeRenderer.hide(_gridMeshIndexYZNear, !planeLeft.isBackSide(camera.position()));
|
||||
_shapeRenderer.hide(_gridMeshIndexXYFar, !planeFar.isBackSide(camera.worldPosition()));
|
||||
_shapeRenderer.hide(_gridMeshIndexXYNear, !planeNear.isBackSide(camera.worldPosition()));
|
||||
_shapeRenderer.hide(_gridMeshIndexXZFar, !planeTop.isBackSide(camera.worldPosition()));
|
||||
_shapeRenderer.hide(_gridMeshIndexXZNear, !planeBottom.isBackSide(camera.worldPosition()));
|
||||
_shapeRenderer.hide(_gridMeshIndexYZFar, !planeRight.isBackSide(camera.worldPosition()));
|
||||
_shapeRenderer.hide(_gridMeshIndexYZNear, !planeLeft.isBackSide(camera.worldPosition()));
|
||||
} else {
|
||||
_shapeRenderer.hide(_gridMeshIndexXYFar, true);
|
||||
_shapeRenderer.hide(_gridMeshIndexXYNear, true);
|
||||
|
|
|
@ -84,7 +84,7 @@ app::AppState TestApp::onInit() {
|
|||
|
||||
Log::info("Set window dimensions: %ix%i (aspect: %f)", _frameBufferDimension.x, _frameBufferDimension.y, _aspect);
|
||||
camera().init(glm::ivec2(0), frameBufferDimension(), windowDimension());
|
||||
camera().setPosition(glm::vec3(0.0f, 50.0f, 100.0f));
|
||||
camera().setWorldPosition(glm::vec3(0.0f, 50.0f, 100.0f));
|
||||
camera().lookAt(glm::vec3(0.0f));
|
||||
|
||||
video::clearColor(::core::Color::Black);
|
||||
|
@ -142,9 +142,9 @@ void TestApp::onRenderUI() {
|
|||
ImGui::Checkbox("Render plane", &_renderPlane);
|
||||
ImGui::Checkbox("Camera motion", &_cameraMotion);
|
||||
ImGui::InputFloat("Camera speed", &_cameraSpeed, 0.02f, 0.1f);
|
||||
glm::vec3 cameraPos = camera().position();
|
||||
glm::vec3 cameraPos = camera().worldPosition();
|
||||
if (ImGui::InputFloat3("Camera position", glm::value_ptr(cameraPos))) {
|
||||
camera().setPosition(cameraPos);
|
||||
camera().setWorldPosition(cameraPos);
|
||||
}
|
||||
ImGui::InputVarFloat("Rotation speed", _rotationSpeed, 0.01f, 0.1f);
|
||||
ImGui::Separator();
|
||||
|
|
|
@ -1289,7 +1289,7 @@ int uilua_model(lua_State *s) {
|
|||
model.camera.setTargetDistance(40.0f);
|
||||
model.camera.setRotationType(video::CameraRotationType::Target);
|
||||
model.camera.setTarget(glm::vec3(0.0f));
|
||||
model.camera.setPosition(glm::vec3(0.0f, 200.0f, 200.0f));
|
||||
model.camera.setWorldPosition(glm::vec3(0.0f, 200.0f, 200.0f));
|
||||
|
||||
if (argc == 2) {
|
||||
if (!lua_istable(s, 2)) {
|
||||
|
@ -1304,7 +1304,7 @@ int uilua_model(lua_State *s) {
|
|||
model.omegaY = luaL_checknumber(s, -1);
|
||||
} else if (!SDL_strcmp(field, "cameraPos")) {
|
||||
const glm::vec3& v = clua_tovec<glm::vec3>(s, -1);
|
||||
model.camera.setPosition(v);
|
||||
model.camera.setWorldPosition(v);
|
||||
} else if (!SDL_strcmp(field, "cameraTarget")) {
|
||||
const glm::vec3& v = clua_tovec<glm::vec3>(s, -1);
|
||||
model.camera.setTarget(v);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace video {
|
||||
|
||||
Camera::Camera(CameraType type, CameraMode mode) :
|
||||
_type(type), _mode(mode), _pos(glm::vec3(0.0f)), _omega(0.0f) {
|
||||
_type(type), _mode(mode), _worldPos(glm::vec3(0.0f)), _omega(0.0f) {
|
||||
}
|
||||
|
||||
float Camera::pitch() const {
|
||||
|
@ -73,12 +73,12 @@ glm::vec3 Camera::up() const {
|
|||
return glm::conjugate(_quat) * glm::up;
|
||||
}
|
||||
|
||||
void Camera::setPosition(const glm::vec3& pos) {
|
||||
if (glm::all(glm::epsilonEqual(_pos, pos, 0.0001f))) {
|
||||
void Camera::setWorldPosition(const glm::vec3& worldPos) {
|
||||
if (glm::all(glm::epsilonEqual(_worldPos, worldPos, 0.0001f))) {
|
||||
return;
|
||||
}
|
||||
_dirty |= DIRTY_POSITON;
|
||||
_pos = pos;
|
||||
_worldPos = worldPos;
|
||||
if (_rotationType == CameraRotationType::Target) {
|
||||
lookAt(_target);
|
||||
}
|
||||
|
@ -125,11 +125,11 @@ void Camera::rotate(const glm::quat& rotation) {
|
|||
_dirty |= DIRTY_ORIENTATION;
|
||||
}
|
||||
|
||||
void Camera::init(const glm::ivec2& position, const glm::ivec2& frameBufferSize, const glm::ivec2& windowSize) {
|
||||
if (_position == position && _frameBufferSize == frameBufferSize && _windowSize == windowSize) {
|
||||
void Camera::init(const glm::ivec2& orthoPosition, const glm::ivec2& frameBufferSize, const glm::ivec2& windowSize) {
|
||||
if (_orthoPosition == orthoPosition && _frameBufferSize == frameBufferSize && _windowSize == windowSize) {
|
||||
return;
|
||||
}
|
||||
_position = position;
|
||||
_orthoPosition = orthoPosition;
|
||||
_frameBufferSize = frameBufferSize;
|
||||
_windowSize = windowSize;
|
||||
_frameBufferAspectRatio = (float)_frameBufferSize.x / (float)_frameBufferSize.y;
|
||||
|
@ -141,9 +141,9 @@ void Camera::move(const glm::vec3& delta) {
|
|||
return;
|
||||
}
|
||||
_dirty |= DIRTY_POSITON;
|
||||
_pos += forward() * -delta.z;
|
||||
_pos += right() * delta.x;
|
||||
_pos += up() * delta.y;
|
||||
_worldPos += forward() * -delta.z;
|
||||
_worldPos += right() * delta.x;
|
||||
_worldPos += up() * delta.y;
|
||||
if (_rotationType == CameraRotationType::Target) {
|
||||
lookAt(_target, glm::up);
|
||||
_dirty |= DIRTY_TARGET;
|
||||
|
@ -208,11 +208,11 @@ void Camera::slerp(const glm::vec3& radians, float factor) {
|
|||
}
|
||||
|
||||
bool Camera::lookAt(const glm::vec3& position, const glm::vec3& upDirection) {
|
||||
if (glm::all(glm::epsilonEqual(_pos, position, 0.0001f))) {
|
||||
if (glm::all(glm::epsilonEqual(_worldPos, position, 0.0001f))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
glm::vec3 targetDir = glm::normalize(position - _pos);
|
||||
glm::vec3 targetDir = glm::normalize(position - _worldPos);
|
||||
if (glm::length2(targetDir) == 0) {
|
||||
targetDir = glm::forward;
|
||||
}
|
||||
|
@ -231,12 +231,12 @@ bool Camera::lookAt(const glm::vec3& position, const glm::vec3& upDirection) {
|
|||
}
|
||||
}
|
||||
|
||||
_quat = glm::quat_cast(glm::lookAt(_pos, _pos + targetDir, upDir));
|
||||
_quat = glm::quat_cast(glm::lookAt(_worldPos, _worldPos + targetDir, upDir));
|
||||
_dirty |= DIRTY_ORIENTATION;
|
||||
core_assert_msg(!glm::any(glm::isnan(_quat)), "upDirection(%f:%f:%f), position(%f:%f:%f), _pos(%f:%f:%f)",
|
||||
upDirection.x, upDirection.y, upDirection.z, position.x, position.y, position.z, _pos.x, _pos.y, _pos.z);
|
||||
upDirection.x, upDirection.y, upDirection.z, position.x, position.y, position.z, _worldPos.x, _worldPos.y, _worldPos.z);
|
||||
core_assert_msg(!glm::any(glm::isinf(_quat)), "upDirection(%f:%f:%f), position(%f:%f:%f), _pos(%f:%f:%f)",
|
||||
upDirection.x, upDirection.y, upDirection.z, position.x, position.y, position.z, _pos.x, _pos.y, _pos.z);
|
||||
upDirection.x, upDirection.y, upDirection.z, position.x, position.y, position.z, _worldPos.x, _worldPos.y, _worldPos.z);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -259,10 +259,10 @@ void Camera::updateTarget() {
|
|||
}
|
||||
const glm::vec3& backward = -forward();
|
||||
const glm::vec3& newPosition = _target + backward * _distance;
|
||||
if (glm::all(glm::epsilonEqual(_pos, newPosition, 0.0001f))) {
|
||||
if (glm::all(glm::epsilonEqual(_worldPos, newPosition, 0.0001f))) {
|
||||
return;
|
||||
}
|
||||
_pos = newPosition;
|
||||
_worldPos = newPosition;
|
||||
_dirty |= DIRTY_POSITON;
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ void Camera::updateViewMatrix() {
|
|||
if (!isDirty(DIRTY_ORIENTATION | DIRTY_POSITON)) {
|
||||
return;
|
||||
}
|
||||
_viewMatrix = glm::translate(orientation(), -_pos);
|
||||
_viewMatrix = glm::translate(orientation(), -_worldPos);
|
||||
_invViewMatrix = glm::inverse(_viewMatrix);
|
||||
_eyePosition =_invViewMatrix[3];
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ math::Ray Camera::screenRay(const glm::vec2& screenPos) const {
|
|||
rayEyeSpace.w = 0.0f;
|
||||
|
||||
const glm::vec3& rayDirection = glm::normalize(glm::vec3(inverseViewMatrix() * rayEyeSpace));
|
||||
return math::Ray(position(), rayDirection);
|
||||
return math::Ray(worldPosition(), rayDirection);
|
||||
}
|
||||
|
||||
glm::vec3 Camera::screenToWorld(const glm::vec3& screenPos) const {
|
||||
|
@ -348,8 +348,8 @@ glm::ivec2 Camera::worldToScreen(const glm::vec3& worldPos) const {
|
|||
trans.y = 1.0f - trans.y;
|
||||
trans.x *= (float)_windowSize.x;
|
||||
trans.y *= (float)_windowSize.y;
|
||||
trans.x += (float)_position.x;
|
||||
trans.y += (float)_position.y;
|
||||
trans.x += (float)_orthoPosition.x;
|
||||
trans.y += (float)_orthoPosition.y;
|
||||
return glm::ivec2(trans.x, trans.y);
|
||||
}
|
||||
|
||||
|
@ -461,8 +461,8 @@ void Camera::zoom(float value) {
|
|||
}
|
||||
|
||||
glm::mat4 Camera::orthogonalMatrix(float nplane, float fplane) const {
|
||||
const float left = (float)x();
|
||||
const float top = (float)y();
|
||||
const float left = (float)orthoX();
|
||||
const float top = (float)orthoY();
|
||||
const float right = left + (float)_windowSize.x;
|
||||
const float bottom = top + (float)_windowSize.y;
|
||||
core_assert_msg(right > left, "Invalid dimension given: right must be greater than left but is %f", right);
|
||||
|
@ -471,7 +471,8 @@ glm::mat4 Camera::orthogonalMatrix(float nplane, float fplane) const {
|
|||
}
|
||||
|
||||
glm::mat4 Camera::perspectiveMatrix(float nplane, float fplane) const {
|
||||
return glm::perspectiveFovRH_NO(glm::radians(_fieldOfView), (float)_windowSize.x, (float)_windowSize.y, nplane, fplane);
|
||||
const float fov = glm::radians(_fieldOfView);
|
||||
return glm::perspectiveFovRH_NO(fov, (float)_windowSize.x, (float)_windowSize.y, nplane, fplane);
|
||||
}
|
||||
|
||||
void Camera::setNearPlane(float nearPlane) {
|
||||
|
|
|
@ -72,9 +72,9 @@ protected:
|
|||
// ortho
|
||||
glm::ivec2 _windowSize {0};
|
||||
// the position that is used for ortho projection matrices
|
||||
glm::ivec2 _position {0};
|
||||
glm::ivec2 _orthoPosition {0};
|
||||
// the position of the camera in the world
|
||||
glm::vec3 _pos {0.0f};
|
||||
glm::vec3 _worldPos {0.0f};
|
||||
glm::vec3 _eyePosition { 0.0f };
|
||||
glm::quat _quat = glm::quat(1, 0, 0, 0);
|
||||
uint32_t _dirty = DIRTY_ALL;
|
||||
|
@ -108,7 +108,7 @@ protected:
|
|||
public:
|
||||
Camera(CameraType type = CameraType::FirstPerson, CameraMode mode = CameraMode::Perspective);
|
||||
|
||||
void init(const glm::ivec2& position, const glm::ivec2& frameBufferSize, const glm::ivec2& windowSize);
|
||||
void init(const glm::ivec2& orthoPosition, const glm::ivec2& frameBufferSize, const glm::ivec2& windowSize);
|
||||
int frameBufferWidth() const;
|
||||
int frameBufferHeight() const;
|
||||
|
||||
|
@ -119,11 +119,11 @@ public:
|
|||
/**
|
||||
* @note Not the world position of the camera - but for controlling the viewport
|
||||
*/
|
||||
int x() const;
|
||||
int orthoX() const;
|
||||
/**
|
||||
* @note Not the world position of the camera - but for controlling the viewport
|
||||
*/
|
||||
int y() const;
|
||||
int orthoY() const;
|
||||
|
||||
const glm::vec3& eye() const;
|
||||
|
||||
|
@ -163,8 +163,8 @@ public:
|
|||
|
||||
glm::vec3 direction() const;
|
||||
|
||||
const glm::vec3& position() const;
|
||||
void setPosition(const glm::vec3& pos);
|
||||
const glm::vec3& worldPosition() const;
|
||||
void setWorldPosition(const glm::vec3& worldPos);
|
||||
void move(const glm::vec3& delta);
|
||||
|
||||
glm::mat4 orthogonalMatrix(float nplane, float fplane) const;
|
||||
|
@ -291,12 +291,12 @@ inline int Camera::frameBufferHeight() const {
|
|||
return _frameBufferSize.y;
|
||||
}
|
||||
|
||||
inline int Camera::x() const {
|
||||
return _position.x;
|
||||
inline int Camera::orthoX() const {
|
||||
return _orthoPosition.x;
|
||||
}
|
||||
|
||||
inline int Camera::y() const {
|
||||
return _position.y;
|
||||
inline int Camera::orthoY() const {
|
||||
return _orthoPosition.y;
|
||||
}
|
||||
|
||||
inline void Camera::setType(CameraType type) {
|
||||
|
@ -406,8 +406,8 @@ inline void Camera::setAspectRatio(float aspect) {
|
|||
_frameBufferAspectRatio = aspect;
|
||||
}
|
||||
|
||||
inline const glm::vec3& Camera::position() const {
|
||||
return _pos;
|
||||
inline const glm::vec3& Camera::worldPosition() const {
|
||||
return _worldPos;
|
||||
}
|
||||
|
||||
inline void Camera::setTargetDistance(float distance) {
|
||||
|
@ -426,9 +426,9 @@ inline float Camera::targetDistance() const {
|
|||
return _distance;
|
||||
}
|
||||
|
||||
inline Camera uiCamera(const glm::ivec2& position, const glm::ivec2& frameBufferSize, const glm::ivec2& windowSize) {
|
||||
inline Camera uiCamera(const glm::ivec2& orthoPosition, const glm::ivec2& frameBufferSize, const glm::ivec2& windowSize) {
|
||||
Camera camera(CameraType::FirstPerson, video::CameraMode::Orthogonal);
|
||||
camera.init(position, frameBufferSize, windowSize);
|
||||
camera.init(orthoPosition, frameBufferSize, windowSize);
|
||||
camera.setNearPlane(-1.0f);
|
||||
camera.setFarPlane(1.0f);
|
||||
camera.update(0.0);
|
||||
|
|
|
@ -585,7 +585,7 @@ void ShapeBuilder::frustum(const Camera& camera, int splitFrustum) {
|
|||
|
||||
if (camera.rotationType() == CameraRotationType::Target) {
|
||||
setColor(core::Color::Green);
|
||||
addVertex(camera.position());
|
||||
addVertex(camera.worldPosition());
|
||||
addVertex(camera.target());
|
||||
// TODO: index looks wrong
|
||||
addIndex(startIndex + math::FRUSTUM_VERTICES_MAX + 0);
|
||||
|
|
|
@ -28,7 +28,7 @@ protected:
|
|||
camera.setNearPlane(0.1f);
|
||||
camera.setFarPlane(100.0f);
|
||||
camera.init(glm::ivec2(0), dimension, dimension);
|
||||
camera.setPosition(position);
|
||||
camera.setWorldPosition(position);
|
||||
camera.lookAt(lookAt, lookAlong);
|
||||
camera.update(0.0);
|
||||
return camera;
|
||||
|
@ -67,7 +67,7 @@ TEST_F(CameraTest, testScreenRayStraightDown) {
|
|||
// get the world position from the center of the screen
|
||||
const math::Ray& ray = camera.screenRay(glm::vec2(0.5f));
|
||||
EXPECT_TRUE(glm::all(glm::epsilonEqual(glm::down, ray.direction, 0.00001f))) << ray << " - " << ray.direction.x << ", " << ray.direction.y << ", " << ray.direction.z;
|
||||
EXPECT_TRUE(glm::all(glm::epsilonEqual(camera.position(), ray.origin, 0.00001f))) << ray << " - " << ray.origin.x << ", " << ray.origin.y << ", " << ray.origin.z;
|
||||
EXPECT_TRUE(glm::all(glm::epsilonEqual(camera.worldPosition(), ray.origin, 0.00001f))) << ray << " - " << ray.origin.x << ", " << ray.origin.y << ", " << ray.origin.z;
|
||||
}
|
||||
|
||||
TEST_F(CameraTest, testMotion) {
|
||||
|
@ -116,7 +116,7 @@ TEST_F(CameraTest, testCameraFrustumCullingOrthogonal) {
|
|||
Camera camera;
|
||||
camera.init(glm::ivec2(0), glm::vec2(100.0f, 100.0f), glm::vec2(100.0f, 100.0f));
|
||||
camera.setMode(CameraMode::Orthogonal);
|
||||
camera.setPosition(glm::vec3(0.1, 1.0, 0.1));
|
||||
camera.setWorldPosition(glm::vec3(0.1, 1.0, 0.1));
|
||||
camera.lookAt(glm::vec3(0.0), glm::forward);
|
||||
camera.update(0.0);
|
||||
const math::Frustum& frustum = camera.frustum();
|
||||
|
|
|
@ -46,7 +46,7 @@ bool PlayerCamera::init(const glm::ivec2& position, const glm::ivec2& frameBuffe
|
|||
_camera.setRotationType(video::CameraRotationType::Target);
|
||||
_camera.setFieldOfView(_fieldOfView);
|
||||
_camera.setTargetDistance(_targetDistance);
|
||||
_camera.setPosition(_cameraPosition);
|
||||
_camera.setWorldPosition(_cameraPosition);
|
||||
_camera.setTarget(glm::vec3(0.0f));
|
||||
_camera.setAngles(0.0f, 0.0f, 0.0f);
|
||||
_camera.update(0.0);
|
||||
|
|
|
@ -273,7 +273,7 @@ int WorldRenderer::renderWater(const video::Camera& camera, const glm::vec4& cli
|
|||
_waterShader.markClean();
|
||||
}
|
||||
_waterShader.setFocuspos(_focusPos);
|
||||
_waterShader.setCamerapos(camera.position());
|
||||
_waterShader.setCamerapos(camera.worldPosition());
|
||||
_waterShader.setLightdir(_shadow.sunDirection());
|
||||
_waterShader.setFogrange(_fogRange);
|
||||
_waterShader.setTime(_seconds);
|
||||
|
|
|
@ -174,12 +174,12 @@ void WorldChunkMgr::extractMeshes(const video::Camera& camera) {
|
|||
|
||||
const float farplane = camera.farPlane();
|
||||
|
||||
glm::vec3 mins = camera.position();
|
||||
glm::vec3 mins = camera.worldPosition();
|
||||
mins.x -= farplane;
|
||||
mins.y = 0;
|
||||
mins.z -= farplane;
|
||||
|
||||
glm::vec3 maxs = camera.position();
|
||||
glm::vec3 maxs = camera.worldPosition();
|
||||
maxs.x += farplane;
|
||||
maxs.y = voxel::MAX_HEIGHT;
|
||||
maxs.z += farplane;
|
||||
|
|
|
@ -148,7 +148,7 @@ app::AppState TestAnimation::onInit() {
|
|||
_animations.push_back(animation::toString((animation::Animation)i));
|
||||
}
|
||||
|
||||
camera().setPosition(glm::vec3(10.0f, 5.0f, 10.0f));
|
||||
camera().setWorldPosition(glm::vec3(10.0f, 5.0f, 10.0f));
|
||||
camera().lookAt(glm::zero<glm::vec3>());
|
||||
|
||||
if (!voxel::initDefaultMaterialColors()) {
|
||||
|
|
|
@ -48,7 +48,7 @@ app::AppState TestCamera::onInit() {
|
|||
_renderCamera[i].init(glm::ivec2(0), ortho ? glm::ivec2(100, 50) : frameBufferDimension(), ortho ? glm::ivec2(100, 50) : windowDimension());
|
||||
_renderCamera[i].setOmega(glm::vec3(0.0f, 0.1f, 0.0f));
|
||||
|
||||
_renderCamera[i].setPosition(glm::zero<glm::vec3>());
|
||||
_renderCamera[i].setWorldPosition(glm::zero<glm::vec3>());
|
||||
_renderCamera[i].lookAt(glm::vec3(10.0f, 70.0f, 10.0f));
|
||||
_renderCamera[i].setNearPlane(nearPlane);
|
||||
_renderCamera[i].setFarPlane(40.0f);
|
||||
|
@ -73,7 +73,7 @@ app::AppState TestCamera::onInit() {
|
|||
}
|
||||
|
||||
void TestCamera::resetCameraPosition() {
|
||||
camera().setPosition(glm::vec3(0.0f, 100.0f, 250.0f));
|
||||
camera().setWorldPosition(glm::vec3(0.0f, 100.0f, 250.0f));
|
||||
camera().setAngles(0.0f, 0.0f, 0.0f);
|
||||
camera().lookAt(glm::vec3(0.0f));
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ app::AppState TestCamera::onRunning() {
|
|||
if (mods & KMOD_SHIFT) {
|
||||
c.rotate(glm::vec3(_mouseRelativePos.y, _mouseRelativePos.x, 0.0f) * _rotationSpeed->floatVal());
|
||||
}
|
||||
camera().setTarget(c.position());
|
||||
camera().setTarget(c.worldPosition());
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ app::AppState TestOctree::onInit() {
|
|||
|
||||
_octree.setListener(&_listener);
|
||||
camera().setFarPlane(4000.0f);
|
||||
camera().setPosition(glm::vec3(0.0f, 1250.0f, 2500.0f));
|
||||
camera().setWorldPosition(glm::vec3(0.0f, 1250.0f, 2500.0f));
|
||||
|
||||
insert();
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ void TestOctreeVisit::updateCamera() {
|
|||
_octreeCamera.init(glm::ivec2(0), _ortho ? glm::ivec2(100, 50) : frameBufferDimension(), _ortho ? glm::ivec2(100, 50) : frameBufferDimension());
|
||||
_octreeCamera.setOmega(_omega);
|
||||
|
||||
_octreeCamera.setPosition(_pos);
|
||||
_octreeCamera.setWorldPosition(_pos);
|
||||
_octreeCamera.lookAt(_lookAt);
|
||||
_octreeCamera.setFarPlane(_farPlane);
|
||||
_octreeCamera.setNearPlane(_nearPlane);
|
||||
|
|
|
@ -23,7 +23,7 @@ app::AppState TestSkybox::onInit() {
|
|||
return state;
|
||||
}
|
||||
|
||||
camera().setPosition(glm::backward);
|
||||
camera().setWorldPosition(glm::backward);
|
||||
camera().lookAt(glm::forward);
|
||||
if (!_skybox.init(_skyboxVar->strVal().c_str())) {
|
||||
Log::error("Failed to initialize the skybox");
|
||||
|
@ -49,4 +49,4 @@ void TestSkybox::doRender() {
|
|||
}
|
||||
|
||||
TEST_APP(TestSkybox)
|
||||
#include "io/Filesystem.h"
|
||||
#include "io/Filesystem.h"
|
||||
|
|
|
@ -106,7 +106,7 @@ app::AppState TestTraze::onInit() {
|
|||
return app::AppState::InitFailure;
|
||||
}
|
||||
|
||||
camera().setPosition(glm::vec3(0.0f, 50.0f, 84.0f));
|
||||
camera().setWorldPosition(glm::vec3(0.0f, 50.0f, 84.0f));
|
||||
_logLevelVar->setVal(core::string::toString(SDL_LOG_PRIORITY_INFO));
|
||||
Log::init();
|
||||
|
||||
|
@ -290,7 +290,7 @@ app::AppState TestTraze::onRunning() {
|
|||
_protocol.subscribe(_games[_currentGameIndex]);
|
||||
}
|
||||
_messageQueue.update(_deltaFrameSeconds);
|
||||
_soundMgr.setListenerPosition(camera().position());
|
||||
_soundMgr.setListenerPosition(camera().worldPosition());
|
||||
_soundMgr.update();
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ void MapView::beforeUI() {
|
|||
void MapView::onRenderUI() {
|
||||
if (ImGui::CollapsingHeader("Stats")) {
|
||||
const video::Camera& camera = _camera.camera();
|
||||
const glm::vec3& pos = camera.position();
|
||||
const glm::vec3& pos = camera.worldPosition();
|
||||
const glm::vec3& targetpos = camera.target();
|
||||
const float distance = camera.targetDistance();
|
||||
const float pitch = camera.pitch();
|
||||
|
@ -419,7 +419,7 @@ app::AppState MapView::onRunning() {
|
|||
_camera.rotate(pitch, turn, _rotationSpeed->floatVal());
|
||||
}
|
||||
|
||||
_soundManager->setListenerPosition(_camera.camera().position());
|
||||
_soundManager->setListenerPosition(_camera.camera().worldPosition());
|
||||
_soundManager->update();
|
||||
_axis.render(_camera.camera());
|
||||
compute::finish();
|
||||
|
|
|
@ -117,7 +117,7 @@ app::AppState Thumbnailer::onRunning() {
|
|||
const float distance = glm::length(dim);
|
||||
camera.setTargetDistance(distance * 2.0f);
|
||||
const int height = region.getHeightInCells();
|
||||
camera.setPosition(glm::vec3(-distance, height + distance, -distance));
|
||||
camera.setWorldPosition(glm::vec3(-distance, height + distance, -distance));
|
||||
camera.lookAt(center);
|
||||
camera.setFarPlane(5000.0f);
|
||||
camera.update(1L);
|
||||
|
|
|
@ -18,18 +18,18 @@ void ViewportController::resetCamera(const voxel::Region& region) {
|
|||
if (_renderMode == RenderMode::Animation) {
|
||||
_camera.setTarget(glm::zero<glm::vec3>());
|
||||
const int height = region.getHeightInCells();
|
||||
_camera.setPosition(glm::vec3(-distance, (float)height + distance, -distance));
|
||||
_camera.setWorldPosition(glm::vec3(-distance, (float)height + distance, -distance));
|
||||
} else if (_camMode == SceneCameraMode::Free) {
|
||||
const int height = region.getHeightInCells();
|
||||
_camera.setPosition(glm::vec3(-distance, (float)height + distance, -distance));
|
||||
_camera.setWorldPosition(glm::vec3(-distance, (float)height + distance, -distance));
|
||||
} else if (_camMode == SceneCameraMode::Top) {
|
||||
const int height = region.getHeightInCells();
|
||||
_camera.setPosition(glm::vec3(center.x, height + center.y, center.z));
|
||||
_camera.setWorldPosition(glm::vec3(center.x, height + center.y, center.z));
|
||||
} else if (_camMode == SceneCameraMode::Left) {
|
||||
_camera.setPosition(glm::vec3(-center.x, center.y, center.z));
|
||||
_camera.setWorldPosition(glm::vec3(-center.x, center.y, center.z));
|
||||
} else if (_camMode == SceneCameraMode::Front) {
|
||||
const int depth = region.getDepthInCells();
|
||||
_camera.setPosition(glm::vec3(center.x, center.y, -depth - center.z));
|
||||
_camera.setWorldPosition(glm::vec3(center.x, center.y, -depth - center.z));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue