mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-10-04 19:37:55 +00:00
Render bounding box around mesh, centre & scale arcball on bbox
* The arcball lookat position can also be dragged with alt-click or middle click. * Also supports other elements as position not just magically-selected "POSITION" element.
This commit is contained in:
@@ -29,11 +29,12 @@
|
||||
#include "camera.h"
|
||||
#include "matrix.h"
|
||||
|
||||
void Camera::Arcball(float dist, const Vec3f &rot)
|
||||
void Camera::Arcball(const Vec3f &p, float d, const Vec3f &rot)
|
||||
{
|
||||
pos = Vec3f(0.0f, 0.0f, dist);
|
||||
pos = p;
|
||||
dist = d;
|
||||
|
||||
order = ORDER_ROT_TRANS;
|
||||
type = eType_Arcball;
|
||||
|
||||
angles.x = rot.x;
|
||||
angles.y = rot.y;
|
||||
@@ -46,18 +47,26 @@ void Camera::fpsLook(const Vec3f &p, const Vec3f &rot)
|
||||
angles.x = -rot.x;
|
||||
angles.y = -rot.y;
|
||||
|
||||
order = ORDER_TRANS_ROT;
|
||||
type = eType_FPSLook;
|
||||
}
|
||||
|
||||
const Matrix4f Camera::GetMatrix() const
|
||||
{
|
||||
Matrix4f p = Matrix4f::Translation(pos);
|
||||
Matrix4f r = Matrix4f::RotationXYZ(angles);
|
||||
if(type == eType_FPSLook)
|
||||
{
|
||||
Matrix4f p = Matrix4f::Translation(pos);
|
||||
Matrix4f r = Matrix4f::RotationXYZ(angles);
|
||||
|
||||
if(order == ORDER_TRANS_ROT)
|
||||
return r.Mul(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
Matrix4f p = Matrix4f::Translation(-pos);
|
||||
Matrix4f r = Matrix4f::RotationXYZ(angles);
|
||||
Matrix4f d = Matrix4f::Translation(Vec3f(0.0f, 0.0f, dist));
|
||||
|
||||
return p.Mul(r);
|
||||
return d.Mul(r.Mul(p));
|
||||
}
|
||||
}
|
||||
|
||||
const Vec3f Camera::GetPosition() const
|
||||
@@ -74,3 +83,8 @@ const Vec3f Camera::GetRight() const
|
||||
{
|
||||
return Matrix4f::RotationZYX(-angles).GetRight();
|
||||
}
|
||||
|
||||
const Vec3f Camera::GetUp() const
|
||||
{
|
||||
return Matrix4f::RotationZYX(-angles).GetUp();
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ class Camera
|
||||
{
|
||||
public:
|
||||
Camera()
|
||||
: order(ORDER_TRANS_ROT), pos(), angles()
|
||||
: type(eType_FPSLook), pos(), dist(0.0f), angles()
|
||||
{ }
|
||||
|
||||
void Arcball(float dist, const Vec3f &rot);
|
||||
void Arcball(const Vec3f &pos, float dist, const Vec3f &rot);
|
||||
void fpsLook(const Vec3f &pos, const Vec3f &rot);
|
||||
|
||||
void SetPosition(const Vec3f &p) { pos = p; }
|
||||
@@ -49,12 +49,13 @@ class Camera
|
||||
const Matrix4f GetMatrix() const;
|
||||
|
||||
private:
|
||||
enum OperationOrder
|
||||
enum CameraType
|
||||
{
|
||||
ORDER_ROT_TRANS = 0,
|
||||
ORDER_TRANS_ROT,
|
||||
} order;
|
||||
eType_Arcball = 0,
|
||||
eType_FPSLook,
|
||||
} type;
|
||||
|
||||
Vec3f pos;
|
||||
float dist;
|
||||
Vec3f angles;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user