mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-11 18:17:16 +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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user