From 50309bfeac0fbda5978c8356fcfb3ca5dfbe780e Mon Sep 17 00:00:00 2001 From: Jasmeet Singh Date: Thu, 16 Mar 2023 15:45:31 +0530 Subject: [PATCH] Updates example lens flare sdf - Adds doxygen comments in LensFlare.hh Signed-off-by: Jasmeet Singh --- examples/worlds/camera_lens_flare.sdf | 307 ++++++++++++++++++++++---- src/systems/lens_flare/LensFlare.cc | 34 +-- src/systems/lens_flare/LensFlare.hh | 20 +- 3 files changed, 300 insertions(+), 61 deletions(-) diff --git a/examples/worlds/camera_lens_flare.sdf b/examples/worlds/camera_lens_flare.sdf index f594d25eb3..e9f46268b6 100644 --- a/examples/worlds/camera_lens_flare.sdf +++ b/examples/worlds/camera_lens_flare.sdf @@ -23,6 +23,209 @@ ogre2 + + + + 3D View + false + docked + + ogre2 + scene + 0.4 0.4 0.4 + 0.8 0.8 0.8 + -6 0 6 0 0.5 0 + + + + + + floating + 5 + 5 + false + + + + + + false + 5 + 5 + floating + false + + + + + + false + 5 + 5 + floating + false + + + + + + false + 5 + 5 + floating + false + + + + + + false + 5 + 5 + floating + false + + + + + + false + 5 + 5 + floating + false + + + + + + false + 5 + 5 + floating + false + + + + + + false + 5 + 5 + floating + false + + + + + + + World control + false + false + 72 + 1 + floating + + + + + + true + true + true + true + + + + + + World stats + false + false + 110 + 290 + 1 + floating + + + + + + true + true + true + true + + + + + + false + 0 + 0 + 250 + 50 + floating + false + #666666 + + + + + + + false + 250 + 0 + 150 + 50 + floating + false + #666666 + + + + + + + false + 0 + 50 + 250 + 50 + floating + false + #777777 + + + + + + + false + docked + + + + + + + false + docked + + + + + + + false + docked + + camera + + + true 0 0 10 0 0 0 @@ -58,45 +261,58 @@ - - - true - 0 0 0.05 0 0 0 - - + + 1.6 2.4 0.5 0 0 0 + + + + 0.16666 + 0 + 0 + 0.16666 + 0 + 0.16666 + + 1 + 0 0 0 0 0 0 + + - 0.1 0.1 0.1 + 1 1 1 + + + + + + + + + + + + 1 1 1 + + + + 0.3 0.3 0.3 1 + 0.7 0.7 0.7 1 + 1 1 1 1 + - - - 0.78539816339744828 - - 320 - 240 - - - 0.1 - 100 - - - 1 - 30 - true - - - + 0 0 0 0 0 0 + false + false + false - - + + true - 0 0 0.05 0 0 0 + 0 2 0.5 0 0 0 @@ -105,9 +321,9 @@ - + - 0.78539816339744828 + 1.047 320 240 @@ -116,23 +332,29 @@ 0.1 100 + + gnomonical + true + 1.5707 + 512 + 1 30 true + wide_angle_camera - 0.1 - + - - + + true - 0 2 0.5 0 0 0 + 0 2 0.3 0 0 0 @@ -141,7 +363,7 @@ - + 1.047 @@ -152,19 +374,16 @@ 0.1 100 - - gnomonical - true - 1.5707 - 512 - 1 30 true + camera + 0.5 + 3 3 3 diff --git a/src/systems/lens_flare/LensFlare.cc b/src/systems/lens_flare/LensFlare.cc index 4d19ade368..e97c1b4500 100644 --- a/src/systems/lens_flare/LensFlare.cc +++ b/src/systems/lens_flare/LensFlare.cc @@ -15,6 +15,8 @@ * */ +#include + #include #include #include @@ -79,7 +81,7 @@ class gz::sim::systems::LensFlarePrivate /// \brief Name of the Light public: std::string lightName; - /// \brief Pointer to the LensFlarePass + /// \brief Pointer to the LensFlarePass public: rendering::LensFlarePassPtr lensFlarePass; /// \brief Scale of the lens flare @@ -88,7 +90,7 @@ class gz::sim::systems::LensFlarePrivate /// \brief Color of the lens flare public: math::Vector3d color = math::Vector3d{1.4, 1.2, 1.0}; - /// \brief Number of occlusion steps to take in each direction. Use 0 to disable + /// \brief Number of occlusion steps to take in each direction. public: uint32_t occlusionSteps = 10; }; @@ -106,9 +108,9 @@ void LensFlare::Configure( EntityComponentManager &_ecm, EventManager &_eventMgr) { this->dataPtr->entity = _entity; - this->dataPtr->eventMgr = &_eventMgr; + this->dataPtr->eventMgr = &_eventMgr; - gzmsg << "Lens flare attached to camera named " + gzmsg << "Lens flare attached to camera named " << this->dataPtr->cameraName << std::endl; if (_sdf->HasElement("scale")) @@ -127,10 +129,12 @@ void LensFlare::Configure( } // Get Camera Name - this->dataPtr->cameraName = scopedName(this->dataPtr->entity, _ecm, "::", false); - + this->dataPtr->cameraName = scopedName(this->dataPtr->entity, + _ecm, "::", false); + // call function that connects to post render event - // using a separate function because unique_ptr (this->dataPtr) is not supported as a argument of std::bind + // using a separate function because unique_ptr (this->dataPtr) + // is not supported as a argument of std::bind this->dataPtr->ConnectToPostRender(); } @@ -162,7 +166,7 @@ void LensFlarePrivate::OnPostRender() if (!this->scene->IsInitialized() || this->scene->SensorCount() == 0) { - gzmsg << "Scene is not initialized or sensor count was found 0" + gzmsg << "Scene is not initialized or sensor count was found 0" << std::endl; } @@ -186,7 +190,7 @@ void LensFlarePrivate::OnPostRender() } return; - } + } // get light if (!this->light) @@ -199,7 +203,8 @@ void LensFlarePrivate::OnPostRender() if (rpSystem) { - rendering::RenderPassPtr flarePass = rpSystem->Create(); + rendering::RenderPassPtr flarePass = + rpSystem->Create(); if (!flarePass) { gzwarn << "Lens Flare is not supported by the " @@ -207,14 +212,15 @@ void LensFlarePrivate::OnPostRender() return; } - this->lensFlarePass = std::dynamic_pointer_cast(flarePass); + this->lensFlarePass = + std::dynamic_pointer_cast(flarePass); this->lensFlarePass->Init(this->scene); this->lensFlarePass->SetEnabled(true); this->lensFlarePass->SetLight(this->light); this->lensFlarePass->SetScale(this->scale); this->lensFlarePass->SetColor(this->color); this->lensFlarePass->SetOcclusionSteps(this->occlusionSteps); - + this->camera->AddRenderPass(lensFlarePass); gzmsg << "LensFlare Render pass added to the camera" << std::endl; } @@ -226,8 +232,8 @@ void LensFlarePrivate::OnPostRender() -GZ_ADD_PLUGIN(LensFlare, - System, +GZ_ADD_PLUGIN(LensFlare, + System, LensFlare::ISystemConfigure) // Add plugin alias so that we can refer to the plugin without the version diff --git a/src/systems/lens_flare/LensFlare.hh b/src/systems/lens_flare/LensFlare.hh index 4463895e96..96e7c0a893 100644 --- a/src/systems/lens_flare/LensFlare.hh +++ b/src/systems/lens_flare/LensFlare.hh @@ -32,6 +32,21 @@ namespace systems /// \brief Private data class for LensFlare Plugin class LensFlarePrivate; + /** \class LensFlare LensFlare.hh \ + * gz/sim/systems/LensFlare.hh + **/ + /// \brief Add lens flare effects to the camera output as a render pass + /// The system takes in the following parameter: + /// Sets the scale of the lens flare. If this is + /// not specified, the value defaults to 1.0 + /// + /// Sets the color of the lens flare. The default + /// is {1.4, 1.2, 1.0} + /// + /// Sets the number of steps to take in + /// each direction to check for occlusions. + /// The default value is set to 10. Use 0 to disable + class LensFlare: public System, public ISystemConfigure @@ -47,7 +62,7 @@ namespace systems const std::shared_ptr &_sdf, EntityComponentManager &_ecm, EventManager &_eventMgr) override; - + /// \brief Private data pointer private: std::unique_ptr dataPtr; }; @@ -55,5 +70,4 @@ namespace systems } } } - -#endif \ No newline at end of file +#endif