Skip to content

Commit

Permalink
Add projection matrix set/get functions to Ogre Depth camera
Browse files Browse the repository at this point in the history
Signed-off-by: Shameek Ganguly <[email protected]>
  • Loading branch information
shameekganguly committed Sep 30, 2023
1 parent 09022e4 commit d83a1c4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
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

0 comments on commit d83a1c4

Please sign in to comment.