Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add projection matrix set/get functions to Ogre Depth camera #928

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ogre/include/gz/rendering/ogre/OgreDepthCamera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <memory>
#include <string>

#include <gz/math/Matrix4.hh>

#include "gz/rendering/RenderTypes.hh"
#include "gz/rendering/base/BaseDepthCamera.hh"
#include "gz/rendering/ogre/OgreConversions.hh"
Expand Down Expand Up @@ -83,6 +85,13 @@ namespace gz
/// Note: It's not virtual.
protected: void DestroyDepthTexture();

// Documentation inherited.
public: virtual math::Matrix4d ProjectionMatrix() const override;

// Documentation inherited.
public: virtual void SetProjectionMatrix(
const math::Matrix4d &_matrix) override;

/// \brief Render the camera
public: virtual void PostRender() override;

Expand Down
15 changes: 15 additions & 0 deletions ogre/src/OgreDepthCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
#include <windows.h>
#endif
#include <gz/math/Helpers.hh>
#include <gz/math/Matrix4.hh>

#include "gz/rendering/InstallationDirectories.hh"
#include "gz/rendering/ogre/OgreConversions.hh"
#include "gz/rendering/ogre/OgreDepthCamera.hh"
#include "gz/rendering/ogre/OgreMaterial.hh"

Expand Down Expand Up @@ -312,6 +315,18 @@ void OgreDepthCamera::DestroyDepthTexture()
}
}

/////////////////////////////////////////////////
math::Matrix4d OgreDepthCamera::ProjectionMatrix() const {
return OgreConversions::Convert(this->ogreCamera->getProjectionMatrix());
}

/////////////////////////////////////////////////
void OgreDepthCamera::SetProjectionMatrix(const math::Matrix4d &_matrix) {
BaseDepthCamera::SetProjectionMatrix(_matrix);
this->ogreCamera->setCustomProjectionMatrix(
true, OgreConversions::Convert(this->projectionMatrix));
}

//////////////////////////////////////////////////
void OgreDepthCamera::PreRender()
{
Expand Down
9 changes: 9 additions & 0 deletions ogre2/include/gz/rendering/ogre2/Ogre2DepthCamera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <memory>
#include <string>

#include <gz/math/Matrix4.hh>

#include "gz/rendering/base/BaseDepthCamera.hh"
#include "gz/rendering/ogre2/Ogre2ObjectInterface.hh"
#include "gz/rendering/ogre2/Ogre2Sensor.hh"
Expand Down Expand Up @@ -79,6 +81,13 @@ namespace gz
/// already and the depth texture have already been created
private: void CreateWorkspaceInstance();

// Documentation inherited.
public: virtual math::Matrix4d ProjectionMatrix() const override;

// Documentation inherited.
public: virtual void SetProjectionMatrix(
const math::Matrix4d &_matrix) override;

// Documentation inherited
public: virtual void PreRender() override;

Expand Down
13 changes: 13 additions & 0 deletions ogre2/src/Ogre2DepthCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <math.h>
#include <gz/math/Helpers.hh>
#include <gz/math/Matrix4.hh>

#include "gz/rendering/RenderTypes.hh"
#include "gz/rendering/ogre2/Ogre2Conversions.hh"
Expand Down Expand Up @@ -967,6 +968,18 @@ void Ogre2DepthCamera::CreateWorkspaceInstance()
}
}

/////////////////////////////////////////////////
math::Matrix4d Ogre2DepthCamera::ProjectionMatrix() const {
return Ogre2Conversions::Convert(this->ogreCamera->getProjectionMatrix());
}

/////////////////////////////////////////////////
void Ogre2DepthCamera::SetProjectionMatrix(const math::Matrix4d &_matrix) {
BaseDepthCamera::SetProjectionMatrix(_matrix);
this->ogreCamera->setCustomProjectionMatrix(
true, Ogre2Conversions::Convert(this->projectionMatrix));
}

//////////////////////////////////////////////////
void Ogre2DepthCamera::Render()
{
Expand Down
Loading