camera stuff
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "bx/math.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <minwindef.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -33,11 +34,8 @@ void Transform::Translate(bx::Vec3 offset)
|
||||
|
||||
void Transform::TranslateLocal(bx::Vec3 offset)
|
||||
{
|
||||
UpdateMatrix();
|
||||
float offsetPtr[4]{offset.x, offset.y, offset.z, 0.0f};
|
||||
float localOffset[4]{0.0f};
|
||||
bx::vec4MulMtx(localOffset, offsetPtr, MI.M);
|
||||
Position = bx::add(Position, {localOffset[0], localOffset[1], localOffset[2]});
|
||||
bx::Vec3 localOffset = GlobalToLocalDirection(offset);
|
||||
Position = bx::add(Position, localOffset);
|
||||
}
|
||||
|
||||
void Transform::Rotate(bx::Vec3 rotation)
|
||||
@@ -122,3 +120,35 @@ namespace Game
|
||||
return reinterpret_cast<void*>(ptrAligned);
|
||||
}
|
||||
} // namespace Game
|
||||
bx::Vec3 Transform::GlobalToLocalDirection(bx::Vec3 global)
|
||||
{
|
||||
UpdateMatrix();
|
||||
float in[4]{global.x, global.y, global.z, 0.0f};
|
||||
float out[4]{0.0f};
|
||||
bx::vec4MulMtx(out, in, MI.M);
|
||||
return {out[0], out[1], out[2]};
|
||||
}
|
||||
bx::Vec3 Transform::GlobalToLocalPoint(bx::Vec3 global)
|
||||
{
|
||||
UpdateMatrix();
|
||||
float in[4]{global.x, global.y, global.z, 1.0f};
|
||||
float out[4]{0.0f};
|
||||
bx::vec4MulMtx(out, in, MI.M);
|
||||
return {out[0], out[1], out[2]};
|
||||
}
|
||||
bx::Vec3 Transform::LocalToGlobalDirection(bx::Vec3 local)
|
||||
{
|
||||
UpdateMatrix();
|
||||
float in[4]{local.x, local.y, local.z, 0.0f};
|
||||
float out[4]{0.0f};
|
||||
bx::vec4MulMtx(out, in, M.M);
|
||||
return {out[0], out[1], out[2]};
|
||||
}
|
||||
bx::Vec3 Transform::LocalToGlobalPoint(bx::Vec3 local)
|
||||
{
|
||||
UpdateMatrix();
|
||||
float in[4]{local.x, local.y, local.z, 1.0f};
|
||||
float out[4]{0.0f};
|
||||
bx::vec4MulMtx(out, in, M.M);
|
||||
return {out[0], out[1], out[2]};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user