Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed Oct 14, 2024
2 parents ebc7d2f + 57689a6 commit 2efa0f8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
33 changes: 33 additions & 0 deletions include/vsg/app/ProjectionMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ namespace vsg
class VSG_DECLSPEC ProjectionMatrix : public Inherit<Object, ProjectionMatrix>
{
public:
ProjectionMatrix()
{
}

explicit ProjectionMatrix(const ProjectionMatrix& pm, const CopyOp& copyop = {}) :
Inherit(pm, copyop)
{
}

virtual dmat4 transform() const = 0;

virtual dmat4 inverse() const
Expand All @@ -48,6 +57,15 @@ namespace vsg
{
}

explicit Perspective(const Perspective& p, const CopyOp& copyop = {}) :
Inherit(p, copyop),
fieldOfViewY(p.fieldOfViewY),
aspectRatio(p.aspectRatio),
nearDistance(p.nearDistance),
farDistance(p.farDistance)
{
}

Perspective(double fov, double ar, double nd, double fd) :
fieldOfViewY(fov),
aspectRatio(ar),
Expand All @@ -56,6 +74,8 @@ namespace vsg
{
}

ref_ptr<Object> clone(const CopyOp& copyop = {}) const override { return Perspective::create(*this, copyop); }

dmat4 transform() const override { return perspective(radians(fieldOfViewY), aspectRatio, nearDistance, farDistance); }

void changeExtent(const VkExtent2D& prevExtent, const VkExtent2D& newExtent) override
Expand Down Expand Up @@ -91,6 +111,17 @@ namespace vsg
{
}

explicit Orthographic(const Orthographic& o, const CopyOp& copyop = {}) :
Inherit(o, copyop),
left(o.left),
right(o.right),
bottom(o.bottom),
top(o.top),
nearDistance(o.nearDistance),
farDistance(o.farDistance)
{
}

Orthographic(double l, double r, double b, double t, double nd, double fd) :
left(l),
right(r),
Expand All @@ -101,6 +132,8 @@ namespace vsg
{
}

ref_ptr<Object> clone(const CopyOp& copyop = {}) const override { return Orthographic::create(*this, copyop); }

dmat4 transform() const override { return orthographic(left, right, bottom, top, nearDistance, farDistance); }

void changeExtent(const VkExtent2D& prevExtent, const VkExtent2D& newExtent) override
Expand Down
15 changes: 13 additions & 2 deletions include/vsg/app/ViewMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ namespace vsg
class VSG_DECLSPEC ViewMatrix : public Inherit<Object, ViewMatrix>
{
public:
ViewMatrix()
{
}

explicit ViewMatrix(const ViewMatrix& vm, const CopyOp& copyop = {}) :
Inherit(vm, copyop)
{
}

virtual dmat4 transform() const = 0;

virtual dmat4 inverse() const
Expand All @@ -42,8 +51,8 @@ namespace vsg
{
}

LookAt(const LookAt& lookAt) :
Inherit(lookAt),
LookAt(const LookAt& lookAt, const CopyOp& copyop = {}) :
Inherit(lookAt, copyop),
eye(lookAt.eye),
center(lookAt.center),
up(lookAt.up)
Expand All @@ -68,6 +77,8 @@ namespace vsg
return *this;
}

ref_ptr<Object> clone(const CopyOp& copyop = {}) const override { return LookAt::create(*this, copyop); }

void transform(const dmat4& matrix)
{
up = normalize(matrix * (eye + up) - matrix * eye);
Expand Down

0 comments on commit 2efa0f8

Please sign in to comment.