diff --git a/CMakeLists.txt b/CMakeLists.txt index 994817273..a0e282b0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,10 @@ set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR}) #============================================================================ # Set up the project #============================================================================ -ign_configure_project(VERSION_SUFFIX) +ign_configure_project( + REPLACE_IGNITION_INCLUDE_PATH gz/rendering + VERSION_SUFFIX +) #============================================================================ # Set project-specific options diff --git a/Changelog.md b/Changelog.md index da5cf6486..62db906ac 100644 --- a/Changelog.md +++ b/Changelog.md @@ -860,6 +860,67 @@ 1. Add support for transparency based on textures alpha channel for ogre1 and ogre2 * [BitBucket pull request 229](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-rendering/pull-requests/229) + +### Ignition Rendering 3.7.0 (2022-11-29) + +1. Migrate ignition to gazebo headers. + * [Pull request #705](https://github.com/gazebosim/gz-rendering/pull/705) + +### Ignition Rendering 3.6.1 (2022-11-08) + +1. Improved coverage: MeshDescriptor, Mesh, MoveToHelper, OrbitViewController, PixelFormat and ShadersParams + * [Pull request #748](https://github.com/gazebosim/gz-rendering/pull/748) + +1. Suppress Windows warnings + * [Pull request #749](https://github.com/gazebosim/gz-rendering/pull/749) + +1. Improved RenderEngine and Mesh coverage + * [Pull request #739](https://github.com/gazebosim/gz-rendering/pull/739) + +1. Increase TransformControl test converage (#668) + * [Pull request #741](https://github.com/gazebosim/gz-rendering/pull/741) + +1. Increased Marker coverage + * [Pull request #738](https://github.com/gazebosim/gz-rendering/pull/738) + +1. Added shaderType converage + * [Pull request #740](https://github.com/gazebosim/gz-rendering/pull/740) + +1. Improved grid coverage + * [Pull request #737](https://github.com/gazebosim/gz-rendering/pull/737) + +1. Improved coverage Arrow and Axis visuals and fixed some warnings + * [Pull request #736](https://github.com/gazebosim/gz-rendering/pull/736) + +1. Backport from 6 to 3. Disable C4275 warnings on Windows from OgreUTFString (#621) + * [Pull request #707](https://github.com/gazebosim/gz-rendering/pull/707) + +1. Remove redundant namespace references + * [Pull request #701](https://github.com/gazebosim/gz-rendering/pull/701) + +1. Disabling flaky depth and thermal camera tests on mac (#405) + * [Pull request #696](https://github.com/gazebosim/gz-rendering/pull/696) + +1. Change IGN_DESIGNATION to GZ_DESIGNATION (#677) + * [Pull request #691](https://github.com/gazebosim/gz-rendering/pull/691) + +1. Add coverage ignore file + * [Pull request #689](https://github.com/gazebosim/gz-rendering/pull/689) + +1. Ignition -> Gazebo + * [Pull request #674](https://github.com/gazebosim/gz-rendering/pull/674) + +1. fix checking unofficial ogre version when ogre 1.x is not installed + * [Pull request #648](https://github.com/gazebosim/gz-rendering/pull/648) + +1. Updated CODEOWNERS + * [Pull request #612](https://github.com/gazebosim/gz-rendering/pull/612) + * [Pull request #613](https://github.com/gazebosim/gz-rendering/pull/613) + * [Pull request #634](https://github.com/gazebosim/gz-rendering/pull/634) + +1. Silence CMake policy CMP0072 + * [Pull request #528](https://github.com/gazebosim/gz-rendering/pull/528) + ### Ignition Rendering 3.6.0 (2021-10-15) 1. Avoid symbol redefition to fix armel builds diff --git a/examples/actor_animation/GlutWindow.cc b/examples/actor_animation/GlutWindow.cc index 6f8d49ce4..06e852d51 100644 --- a/examples/actor_animation/GlutWindow.cc +++ b/examples/actor_animation/GlutWindow.cc @@ -34,16 +34,16 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" #include "example_config.hh" @@ -171,7 +171,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -201,7 +201,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) diff --git a/examples/actor_animation/GlutWindow.hh b/examples/actor_animation/GlutWindow.hh index a96929771..c0756de12 100644 --- a/examples/actor_animation/GlutWindow.hh +++ b/examples/actor_animation/GlutWindow.hh @@ -14,15 +14,15 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/common/graphics/Types.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/common/graphics/Types.hh" -namespace ir = ignition::rendering; -namespace ic = ignition::common; +namespace ir = gz::rendering; +namespace ic = gz::common; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/actor_animation/Main.cc b/examples/actor_animation/Main.cc index c204dc88e..a41e3f315 100644 --- a/examples/actor_animation/Main.cc +++ b/examples/actor_animation/Main.cc @@ -27,17 +27,17 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; const std::string RESOURCE_PATH = diff --git a/examples/camera_tracking/GlutWindow.cc b/examples/camera_tracking/GlutWindow.cc index 3ed256c0c..b097562ed 100644 --- a/examples/camera_tracking/GlutWindow.cc +++ b/examples/camera_tracking/GlutWindow.cc @@ -31,12 +31,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -92,8 +92,8 @@ struct mouseButton struct mouseButton g_mouse; std::mutex g_mouseMutex; -ignition::math::Vector3d g_trackOffset(1.0, 0, 0); -ignition::math::Vector3d g_followOffset(-3, 0, 3); +gz::math::Vector3d g_trackOffset(1.0, 0, 0); +gz::math::Vector3d g_followOffset(-3, 0, 3); ////////////////////////////////////////////////// @@ -158,7 +158,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -188,7 +188,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) @@ -296,21 +296,21 @@ void keyboardCB(unsigned char _key, int, int) if (_key == 'w' || _key == 'W') { node->SetWorldPosition(node->WorldPosition() + - node->WorldRotation() * ignition::math::Vector3d(posIncr, 0, 0)); + node->WorldRotation() * gz::math::Vector3d(posIncr, 0, 0)); } else if (_key == 's' || _key == 'S') { node->SetWorldPosition(node->WorldPosition() + - node->WorldRotation() * ignition::math::Vector3d(-posIncr, 0, 0)); + node->WorldRotation() * gz::math::Vector3d(-posIncr, 0, 0)); } else if (_key == 'a' || _key == 'A') { - node->SetWorldRotation(ignition::math::Quaterniond(0, 0, + node->SetWorldRotation(gz::math::Quaterniond(0, 0, node->WorldRotation().Yaw() + yawIncr)); } else if (_key == 'd' || _key == 'D') { - node->SetWorldRotation(ignition::math::Quaterniond(0, 0, + node->SetWorldRotation(gz::math::Quaterniond(0, 0, node->WorldRotation().Yaw() - yawIncr)); } } @@ -399,14 +399,14 @@ void keyboardCB(unsigned char _key, int, int) if (_key == 't' || _key == 'T') { double trackPGain = 0.005; - double p = ignition::math::equal(cam->TrackPGain(), 1.0) ? + double p = gz::math::equal(cam->TrackPGain(), 1.0) ? trackPGain : 1.0; cam->SetTrackPGain(p); } else if (_key == 'f' || _key == 'F') { double followPGain = 0.01; - double p = ignition::math::equal(cam->FollowPGain(), 1.0) ? + double p = gz::math::equal(cam->FollowPGain(), 1.0) ? followPGain : 1.0; cam->SetFollowPGain(p); } diff --git a/examples/camera_tracking/GlutWindow.hh b/examples/camera_tracking/GlutWindow.hh index 6396104d8..8670a65b8 100644 --- a/examples/camera_tracking/GlutWindow.hh +++ b/examples/camera_tracking/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ #include -#include +#include -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/camera_tracking/Main.cc b/examples/camera_tracking/Main.cc index 6aee947af..cf691f607 100644 --- a/examples/camera_tracking/Main.cc +++ b/examples/camera_tracking/Main.cc @@ -27,11 +27,11 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/custom_scene_viewer/DemoWindow.cc b/examples/custom_scene_viewer/DemoWindow.cc index 95907ccd3..0ce5850bb 100644 --- a/examples/custom_scene_viewer/DemoWindow.cc +++ b/examples/custom_scene_viewer/DemoWindow.cc @@ -33,7 +33,7 @@ #include #include -#include +#include #include "ManualSceneDemo.hh" #include "DemoWindow.hh" @@ -41,7 +41,7 @@ #define KEY_ESC 27 #define KEY_TAB 9 -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/custom_scene_viewer/DemoWindow.hh b/examples/custom_scene_viewer/DemoWindow.hh index 46ddacf82..2c9696032 100644 --- a/examples/custom_scene_viewer/DemoWindow.hh +++ b/examples/custom_scene_viewer/DemoWindow.hh @@ -14,12 +14,12 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ #include "TestTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo /// \param[in] _Pointer to demo diff --git a/examples/custom_scene_viewer/ManualSceneDemo.cc b/examples/custom_scene_viewer/ManualSceneDemo.cc index 2f2bdeb57..97771552d 100644 --- a/examples/custom_scene_viewer/ManualSceneDemo.cc +++ b/examples/custom_scene_viewer/ManualSceneDemo.cc @@ -25,12 +25,12 @@ #endif #include -#include +#include #include "ManualSceneDemo.hh" #include "SceneBuilder.hh" #include "DemoWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/custom_scene_viewer/ManualSceneDemo.hh b/examples/custom_scene_viewer/ManualSceneDemo.hh index 99a316864..7dbc6ddf5 100644 --- a/examples/custom_scene_viewer/ManualSceneDemo.hh +++ b/examples/custom_scene_viewer/ManualSceneDemo.hh @@ -14,12 +14,12 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ -#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ +#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ #include #include -#include +#include #include "TestTypes.hh" namespace ignition diff --git a/examples/custom_scene_viewer/SceneBuilder.cc b/examples/custom_scene_viewer/SceneBuilder.cc index 10b51cad9..1ddd9e174 100644 --- a/examples/custom_scene_viewer/SceneBuilder.cc +++ b/examples/custom_scene_viewer/SceneBuilder.cc @@ -18,7 +18,7 @@ #include "example_config.hh" #include "SceneBuilder.hh" -using namespace ignition; +using namespace gz; using namespace rendering; const std::string RESOURCE_PATH = std::string(PROJECT_BINARY_PATH) + "/media"; diff --git a/examples/custom_scene_viewer/SceneBuilder.hh b/examples/custom_scene_viewer/SceneBuilder.hh index 9901b9c1e..42362ccd9 100644 --- a/examples/custom_scene_viewer/SceneBuilder.hh +++ b/examples/custom_scene_viewer/SceneBuilder.hh @@ -14,8 +14,8 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ -#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ +#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ #include #include "TestTypes.hh" diff --git a/examples/custom_scene_viewer/TestTypes.hh b/examples/custom_scene_viewer/TestTypes.hh index 92c62a468..41e1dd3ed 100644 --- a/examples/custom_scene_viewer/TestTypes.hh +++ b/examples/custom_scene_viewer/TestTypes.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ -#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ +#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ #include -#include +#include namespace ignition { diff --git a/examples/custom_shaders/custom_shaders.cc b/examples/custom_shaders/custom_shaders.cc index d9b359feb..b303f01fa 100644 --- a/examples/custom_shaders/custom_shaders.cc +++ b/examples/custom_shaders/custom_shaders.cc @@ -14,15 +14,15 @@ * limitations under the License. * */ -#include -#include -#include +#include +#include +#include #include "example_config.hh" -void BuildScene(ignition::rendering::ScenePtr _scene); +void BuildScene(gz::rendering::ScenePtr _scene); -void PresentImage(ignition::rendering::ImagePtr _image, +void PresentImage(gz::rendering::ImagePtr _image, const std::string &_name); @@ -47,15 +47,15 @@ const std::string RESOURCE_PATH = ////////////////////////////////////////////////// int main() { - // Initialize ignition::rendering - auto *engine = ignition::rendering::engine("ogre"); + // Initialize gz::rendering + auto *engine = gz::rendering::engine("ogre"); if (!engine) { std::cerr << "Failed to load ogre\n"; return 1; } // Create a scene and add stuff to it - ignition::rendering::ScenePtr scene = engine->CreateScene("scene"); + gz::rendering::ScenePtr scene = engine->CreateScene("scene"); if (!scene) { std::cerr << "Failed to create scene." << std::endl; @@ -63,42 +63,42 @@ int main() } BuildScene(scene); - ignition::rendering::VisualPtr root = scene->RootVisual(); + gz::rendering::VisualPtr root = scene->RootVisual(); // Create a camera - ignition::rendering::CameraPtr camera; + gz::rendering::CameraPtr camera; camera = scene->CreateCamera("example_custom_shaders"); camera->SetImageWidth(width); camera->SetImageHeight(height); camera->SetHFOV(1.05); camera->SetAntiAliasing(2); camera->SetAspectRatio(width / height); - camera->SetImageFormat(ignition::rendering::PF_R8G8B8); + camera->SetImageFormat(gz::rendering::PF_R8G8B8); root->AddChild(camera); // Create a camera for depth image - ignition::rendering::CameraPtr depthCamera; + gz::rendering::CameraPtr depthCamera; depthCamera = scene->CreateCamera("example_custom_shaders_depth"); depthCamera->SetImageWidth(width); depthCamera->SetImageHeight(height); depthCamera->SetHFOV(1.05); depthCamera->SetAntiAliasing(2); depthCamera->SetAspectRatio(width / height); - depthCamera->SetImageFormat(ignition::rendering::PF_R8G8B8); + depthCamera->SetImageFormat(gz::rendering::PF_R8G8B8); root->AddChild(depthCamera); //! [Get shader path] // path to look for vertex and fragment shaders - std::string depth_vertex_shader_path = ignition::common::joinPaths( + std::string depth_vertex_shader_path = gz::common::joinPaths( RESOURCE_PATH, depth_vertex_shader_file); - std::string depth_fragment_shader_path = ignition::common::joinPaths( + std::string depth_fragment_shader_path = gz::common::joinPaths( RESOURCE_PATH, depth_fragment_shader_file); //! [Get shader path] //! [add shader to camera] // create shader material - ignition::rendering::MaterialPtr depthMat = scene->CreateMaterial(); + gz::rendering::MaterialPtr depthMat = scene->CreateMaterial(); depthMat->SetVertexShader(depth_vertex_shader_path); depthMat->SetFragmentShader(depth_fragment_shader_path); @@ -106,10 +106,10 @@ int main() depthCamera->SetMaterial(depthMat); //! [add shader to camera] - ignition::rendering::ImagePtr image = - std::make_shared(camera->CreateImage()); - ignition::rendering::ImagePtr depthImage = - std::make_shared(depthCamera->CreateImage()); + gz::rendering::ImagePtr image = + std::make_shared(camera->CreateImage()); + gz::rendering::ImagePtr depthImage = + std::make_shared(depthCamera->CreateImage()); depthCamera->Capture(*depthImage); PresentImage(depthImage, "depth.png"); @@ -120,14 +120,14 @@ int main() } ////////////////////////////////////////////////// -void PresentImage(ignition::rendering::ImagePtr _image, +void PresentImage(gz::rendering::ImagePtr _image, const std::string &_name) { // Present the data unsigned char *data = _image->Data(); - ignition::common::Image image; - image.SetFromData(data, width, height, ignition::common::Image::RGB_INT8); + gz::common::Image image; + image.SetFromData(data, width, height, gz::common::Image::RGB_INT8); image.SavePNG(_name); @@ -135,14 +135,14 @@ void PresentImage(ignition::rendering::ImagePtr _image, } ////////////////////////////////////////////////// -void BuildScene(ignition::rendering::ScenePtr _scene) +void BuildScene(gz::rendering::ScenePtr _scene) { // initialize _scene _scene->SetAmbientLight(0.3, 0.3, 0.3); - ignition::rendering::VisualPtr root = _scene->RootVisual(); + gz::rendering::VisualPtr root = _scene->RootVisual(); // create directional light - ignition::rendering::DirectionalLightPtr light0 = + gz::rendering::DirectionalLightPtr light0 = _scene->CreateDirectionalLight(); light0->SetDirection(-0.5, 0.5, -1); light0->SetDiffuseColor(0.5, 0.5, 0.5); @@ -150,14 +150,14 @@ void BuildScene(ignition::rendering::ScenePtr _scene) root->AddChild(light0); // create white material - ignition::rendering::MaterialPtr grey = _scene->CreateMaterial(); + gz::rendering::MaterialPtr grey = _scene->CreateMaterial(); grey->SetAmbient(0.5, 0.5, 0.5); grey->SetDiffuse(0.8, 0.8, 0.8); grey->SetReceiveShadows(true); grey->SetReflectivity(0); // create plane visual - ignition::rendering::VisualPtr plane = _scene->CreateVisual(); + gz::rendering::VisualPtr plane = _scene->CreateVisual(); auto geom = _scene->CreatePlane(); plane->AddGeometry(geom); plane->SetLocalScale(5, 8, 1); @@ -167,20 +167,20 @@ void BuildScene(ignition::rendering::ScenePtr _scene) // create shader materials // path to look for vertex and fragment shader parameters - std::string vertex_shader_path = ignition::common::joinPaths( + std::string vertex_shader_path = gz::common::joinPaths( RESOURCE_PATH, vertex_shader_file); - std::string fragment_shader_path = ignition::common::joinPaths( + std::string fragment_shader_path = gz::common::joinPaths( RESOURCE_PATH, fragment_shader_file); //! [add shader to visual] // create shader material - ignition::rendering::MaterialPtr shader = _scene->CreateMaterial(); + gz::rendering::MaterialPtr shader = _scene->CreateMaterial(); shader->SetVertexShader(vertex_shader_path); shader->SetFragmentShader(fragment_shader_path); // create box visual and apply shader - ignition::rendering::VisualPtr box = _scene->CreateVisual(); + gz::rendering::VisualPtr box = _scene->CreateVisual(); box->AddGeometry(_scene->CreateBox()); box->SetOrigin(0.0, 0.5, 0.0); box->SetLocalPosition(3, 0, 0); diff --git a/examples/gazebo_scene_viewer/CameraWindow.cc b/examples/gazebo_scene_viewer/CameraWindow.cc index f1c3004f4..96e37f437 100644 --- a/examples/gazebo_scene_viewer/CameraWindow.cc +++ b/examples/gazebo_scene_viewer/CameraWindow.cc @@ -14,7 +14,6 @@ * limitations under the License. * */ - #if __APPLE__ #include #include @@ -33,9 +32,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "CameraWindow.hh" #include "SceneManager.hh" @@ -47,9 +46,9 @@ unsigned int imgw = 0; unsigned int imgh = 0; -std::vector g_cameras; -gz::CameraPtr g_camera; -gz::CameraPtr g_currCamera; +std::vector g_cameras; +gz::rendering::CameraPtr g_camera; +gz::rendering::CameraPtr g_currCamera; unsigned int g_cameraIndex = 0; gz::ImagePtr g_image; @@ -71,7 +70,7 @@ bool g_initContext = false; double g_offset = 0.0; ////////////////////////////////////////////////// -void GlutRun(std::vector _cameras) +void GlutRun(std::vector _cameras) { #if __APPLE__ g_context = CGLGetCurrentContext(); @@ -145,8 +144,8 @@ void GlutIdle() } #endif - ignition::rendering::SceneManager* manager = - ignition::rendering::SceneManager::Instance(); + gz::rendering::SceneManager* manager = + gz::rendering::SceneManager::Instance(); manager->UpdateScenes(); @@ -182,13 +181,13 @@ void GlutReshape(int, int) } ////////////////////////////////////////////////// -void GlutInitCamera(gz::CameraPtr _camera) +void GlutInitCamera(gz::rendering::CameraPtr _camera) { g_camera = _camera; imgw = g_camera->ImageWidth(); imgh = g_camera->ImageHeight(); - gz::Image image = g_camera->CreateImage(); - g_image = std::make_shared(image); + gz::rendering::Image image = g_camera->CreateImage(); + g_image = std::make_shared(image); g_camera->Capture(*g_image); } diff --git a/examples/gazebo_scene_viewer/CameraWindow.hh b/examples/gazebo_scene_viewer/CameraWindow.hh index e751aad19..e5ad4dfb4 100644 --- a/examples/gazebo_scene_viewer/CameraWindow.hh +++ b/examples/gazebo_scene_viewer/CameraWindow.hh @@ -14,15 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace gz = ignition::rendering; - -void GlutRun(std::vector _cameras); +void GlutRun(std::vector _cameras); void GlutDisplay(); @@ -32,7 +30,7 @@ void GlutKeyboard(unsigned char _key, int _x, int _y); void GlutReshape(int _width, int _height); -void GlutInitCamera(gz::CameraPtr _camera); +void GlutInitCamera(gz::rendering::CameraPtr _camera); void GlutInitContext(); diff --git a/examples/gazebo_scene_viewer/GazeboDemo.cc b/examples/gazebo_scene_viewer/GazeboDemo.cc index 2d7217f0b..3b9a662f4 100644 --- a/examples/gazebo_scene_viewer/GazeboDemo.cc +++ b/examples/gazebo_scene_viewer/GazeboDemo.cc @@ -28,16 +28,16 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "CameraWindow.hh" #include "SceneManager.hh" -using namespace ignition; +using namespace gz; using namespace rendering; void Connect() @@ -46,7 +46,7 @@ void Connect() gazebo::transport::init(); gazebo::transport::run(); - SceneManager* manager = SceneManager::Instance(); + SceneManager *manager = SceneManager::Instance(); manager->Load(); manager->Init(); } diff --git a/examples/gazebo_scene_viewer/GazeboWorldDemo.cc b/examples/gazebo_scene_viewer/GazeboWorldDemo.cc index 33b32df1f..9b3860ce6 100644 --- a/examples/gazebo_scene_viewer/GazeboWorldDemo.cc +++ b/examples/gazebo_scene_viewer/GazeboWorldDemo.cc @@ -25,19 +25,19 @@ #endif #include -#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "CameraWindow.hh" #include "SceneManager.hh" -using namespace ignition; +using namespace gz; using namespace rendering; void Connect() diff --git a/examples/gazebo_scene_viewer/SceneManager.cc b/examples/gazebo_scene_viewer/SceneManager.cc index b8e401e74..18f1b9547 100644 --- a/examples/gazebo_scene_viewer/SceneManager.cc +++ b/examples/gazebo_scene_viewer/SceneManager.cc @@ -17,19 +17,19 @@ #include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #include "SceneManager.hh" #include "SceneManagerPrivate.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// @@ -994,7 +994,7 @@ DirectionalLightPtr SubSceneManager::DirectionalLight( LightPtr light = this->activeScene->LightByName(name); DirectionalLightPtr dirLight = - std::dynamic_pointer_cast(light); + std::dynamic_pointer_cast(light); // check if not found if (!dirLight) @@ -1038,7 +1038,7 @@ PointLightPtr SubSceneManager::PointLight( std::string name = _lightMsg.name(); LightPtr light = this->activeScene->LightByName(name); PointLightPtr pointLight = - std::dynamic_pointer_cast(light); + std::dynamic_pointer_cast(light); // check if not found if (!pointLight) @@ -1110,7 +1110,7 @@ SpotLightPtr SubSceneManager::SpotLight(const gazebo::msgs::Light &_lightMsg, std::string name = _lightMsg.name(); LightPtr light = this->activeScene->LightByName(name); SpotLightPtr spotLight = - std::dynamic_pointer_cast(light); + std::dynamic_pointer_cast(light); // check if not found if (!spotLight) @@ -1225,7 +1225,7 @@ CameraPtr SubSceneManager::Camera(const gazebo::msgs::Sensor &_sensorMsg, // find existing camera with name std::string name = _sensorMsg.name(); SensorPtr sensor = this->activeScene->SensorByName(name); - CameraPtr camera = std::dynamic_pointer_cast(sensor); + CameraPtr camera = std::dynamic_pointer_cast(sensor); // check if not found if (!camera) diff --git a/examples/gazebo_scene_viewer/SceneManager.hh b/examples/gazebo_scene_viewer/SceneManager.hh index d0aa33e33..288ff0749 100644 --- a/examples/gazebo_scene_viewer/SceneManager.hh +++ b/examples/gazebo_scene_viewer/SceneManager.hh @@ -27,8 +27,8 @@ #endif #include -#include -#include "ignition/rendering/RenderTypes.hh" +#include +#include "gz/rendering/RenderTypes.hh" namespace ignition { diff --git a/examples/gazebo_scene_viewer/SceneManagerPrivate.hh b/examples/gazebo_scene_viewer/SceneManagerPrivate.hh index f98d1db5f..c82d4d701 100644 --- a/examples/gazebo_scene_viewer/SceneManagerPrivate.hh +++ b/examples/gazebo_scene_viewer/SceneManagerPrivate.hh @@ -22,13 +22,13 @@ #include #include -#include +#include -#include -#include +#include +#include -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ShaderType.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ShaderType.hh" #include "gazebo/transport/Node.hh" namespace ignition diff --git a/examples/hello_world_plugin/HelloWorldPlugin.cc b/examples/hello_world_plugin/HelloWorldPlugin.cc index 361b43e3f..e3348b912 100644 --- a/examples/hello_world_plugin/HelloWorldPlugin.cc +++ b/examples/hello_world_plugin/HelloWorldPlugin.cc @@ -15,20 +15,20 @@ * */ -#include +#include -#include +#include -#include "ignition/rendering/RenderEnginePlugin.hh" -#include "ignition/rendering/base/BaseRenderEngine.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" +#include "gz/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/base/BaseRenderEngine.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" namespace mock { /// \brief The render engine class which implements a render engine. class HelloWorldRenderEngine : - public virtual ignition::rendering::BaseRenderEngine, - public ignition::common::SingletonT + public virtual gz::rendering::BaseRenderEngine, + public gz::common::SingletonT { // Documentation Inherited. public: virtual bool IsEnabled() const override @@ -59,7 +59,7 @@ namespace mock /// \brief Get a pointer to the list of scenes managed by the render /// engine. /// \return list of scenes - protected: virtual ignition::rendering::SceneStorePtr Scenes() + protected: virtual gz::rendering::SceneStorePtr Scenes() const override { return nullptr; @@ -68,7 +68,7 @@ namespace mock /// \brief Create a scene. /// \param[in] _id Unique scene Id /// \parampin] _name Name of scene - protected: virtual ignition::rendering::ScenePtr + protected: virtual gz::rendering::ScenePtr CreateSceneImpl(unsigned int _id, const std::string &_name) override { @@ -76,12 +76,12 @@ namespace mock } /// \brief Singelton setup. - private: friend class ignition::common::SingletonT; + private: friend class gz::common::SingletonT; }; /// \brief Plugin for loading the HelloWorld render engine. class HelloWorldPlugin : - public ignition::rendering::RenderEnginePlugin + public gz::rendering::RenderEnginePlugin { /// \brief Get the name of the render engine loaded by this plugin. /// \return Name of render engine @@ -92,7 +92,7 @@ namespace mock /// \brief Get a pointer to the render engine loaded by this plugin. /// \return Render engine instance - public: ignition::rendering::RenderEngine *Engine() const override + public: gz::rendering::RenderEngine *Engine() const override { return HelloWorldRenderEngine::Instance(); } @@ -101,4 +101,4 @@ namespace mock // Register this plugin IGNITION_ADD_PLUGIN(mock::HelloWorldPlugin, - ignition::rendering::RenderEnginePlugin) + gz::rendering::RenderEnginePlugin) diff --git a/examples/mesh_viewer/GlutWindow.cc b/examples/mesh_viewer/GlutWindow.cc index d6eccb28d..02413dffd 100644 --- a/examples/mesh_viewer/GlutWindow.cc +++ b/examples/mesh_viewer/GlutWindow.cc @@ -31,12 +31,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -151,7 +151,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -181,7 +181,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) diff --git a/examples/mesh_viewer/GlutWindow.hh b/examples/mesh_viewer/GlutWindow.hh index 6f410018a..7674df2c3 100644 --- a/examples/mesh_viewer/GlutWindow.hh +++ b/examples/mesh_viewer/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/mesh_viewer/Main.cc b/examples/mesh_viewer/Main.cc index f940298d2..a496ac1f9 100644 --- a/examples/mesh_viewer/Main.cc +++ b/examples/mesh_viewer/Main.cc @@ -27,14 +27,14 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; const std::string RESOURCE_PATH = diff --git a/examples/mouse_picking/GlutWindow.cc b/examples/mouse_picking/GlutWindow.cc index 1cb83339e..43a6dcac6 100644 --- a/examples/mouse_picking/GlutWindow.cc +++ b/examples/mouse_picking/GlutWindow.cc @@ -31,14 +31,14 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -118,7 +118,7 @@ void handleMouse() { // Get visual using Selection Buffer from Camera ir::VisualPtr visual1; - ignition::math::Vector2i mousePosI(g_mouse.x, g_mouse.y); + gz::math::Vector2i mousePosI(g_mouse.x, g_mouse.y); visual1 = rayCamera->VisualAt(mousePosI); if (visual1) { diff --git a/examples/mouse_picking/GlutWindow.hh b/examples/mouse_picking/GlutWindow.hh index e81c7d1b1..5cb582744 100644 --- a/examples/mouse_picking/GlutWindow.hh +++ b/examples/mouse_picking/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; void run(std::vector _cameras); diff --git a/examples/mouse_picking/Main.cc b/examples/mouse_picking/Main.cc index b5fc9c192..96144ec0c 100644 --- a/examples/mouse_picking/Main.cc +++ b/examples/mouse_picking/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/ogre2_demo/GlutWindow.cc b/examples/ogre2_demo/GlutWindow.cc index 44aab4f68..c4a1b3441 100644 --- a/examples/ogre2_demo/GlutWindow.cc +++ b/examples/ogre2_demo/GlutWindow.cc @@ -31,13 +31,13 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -154,7 +154,7 @@ void handleMouse() { // Get visual using Selection Buffer from Camera ir::VisualPtr visual; - ignition::math::Vector2i mousePos(g_mouse.x, g_mouse.y); + gz::math::Vector2i mousePos(g_mouse.x, g_mouse.y); visual = rayCamera->VisualAt(mousePos); if (visual) { @@ -174,7 +174,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -204,7 +204,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) diff --git a/examples/ogre2_demo/GlutWindow.hh b/examples/ogre2_demo/GlutWindow.hh index 1942a287e..55f47a778 100644 --- a/examples/ogre2_demo/GlutWindow.hh +++ b/examples/ogre2_demo/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/ogre2_demo/Main.cc b/examples/ogre2_demo/Main.cc index 8f942dc2a..c8f2b290a 100644 --- a/examples/ogre2_demo/Main.cc +++ b/examples/ogre2_demo/Main.cc @@ -27,14 +27,14 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; diff --git a/examples/render_pass/GlutWindow.cc b/examples/render_pass/GlutWindow.cc index 9887c8c92..c39c183d9 100644 --- a/examples/render_pass/GlutWindow.cc +++ b/examples/render_pass/GlutWindow.cc @@ -31,11 +31,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/render_pass/GlutWindow.hh b/examples/render_pass/GlutWindow.hh index b1610206c..ef9893513 100644 --- a/examples/render_pass/GlutWindow.hh +++ b/examples/render_pass/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/render_pass/Main.cc b/examples/render_pass/Main.cc index 76498e7ad..94877fa45 100644 --- a/examples/render_pass/Main.cc +++ b/examples/render_pass/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/simple_demo/GlutWindow.cc b/examples/simple_demo/GlutWindow.cc index 4d0c9a27d..bb13dcba8 100644 --- a/examples/simple_demo/GlutWindow.cc +++ b/examples/simple_demo/GlutWindow.cc @@ -31,10 +31,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/simple_demo/GlutWindow.hh b/examples/simple_demo/GlutWindow.hh index 9dc770201..3b757b280 100644 --- a/examples/simple_demo/GlutWindow.hh +++ b/examples/simple_demo/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/simple_demo/Main.cc b/examples/simple_demo/Main.cc index 489d9533e..af38d901c 100644 --- a/examples/simple_demo/Main.cc +++ b/examples/simple_demo/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/text_geom/GlutWindow.cc b/examples/text_geom/GlutWindow.cc index 9dc6648ef..df485dc9b 100644 --- a/examples/text_geom/GlutWindow.cc +++ b/examples/text_geom/GlutWindow.cc @@ -31,10 +31,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/text_geom/GlutWindow.hh b/examples/text_geom/GlutWindow.hh index 070bdfdbd..2aaf4f11e 100644 --- a/examples/text_geom/GlutWindow.hh +++ b/examples/text_geom/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/text_geom/Main.cc b/examples/text_geom/Main.cc index d9c0eb408..04b083498 100644 --- a/examples/text_geom/Main.cc +++ b/examples/text_geom/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/thermal_camera/GlutWindow.cc b/examples/thermal_camera/GlutWindow.cc index cee056897..51b547ef5 100644 --- a/examples/thermal_camera/GlutWindow.cc +++ b/examples/thermal_camera/GlutWindow.cc @@ -31,11 +31,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -50,7 +50,7 @@ std::vector g_cameras; ir::CameraPtr g_camera; unsigned int g_cameraIndex = 0; ir::ImagePtr g_image; -ignition::common::ConnectionPtr g_connection; +gz::common::ConnectionPtr g_connection; bool g_initContext = false; @@ -88,7 +88,7 @@ void OnNewThermalFrame(const uint16_t *_scan, // convert temperature to grayscale image double range = static_cast(max - min); - if (ignition::math::equal(range, 0.0)) + if (gz::math::equal(range, 0.0)) range = 1.0; unsigned char *data = g_image->Data(); for (unsigned int i = 0; i < _height; ++i) diff --git a/examples/thermal_camera/GlutWindow.hh b/examples/thermal_camera/GlutWindow.hh index ad5fb3bb1..d16b9b537 100644 --- a/examples/thermal_camera/GlutWindow.hh +++ b/examples/thermal_camera/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/thermal_camera/Main.cc b/examples/thermal_camera/Main.cc index aee8e61d1..3e04c381e 100644 --- a/examples/thermal_camera/Main.cc +++ b/examples/thermal_camera/Main.cc @@ -27,14 +27,14 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; const std::string RESOURCE_PATH = diff --git a/examples/transform_control/GlutWindow.cc b/examples/transform_control/GlutWindow.cc index 3331cf226..23466b249 100644 --- a/examples/transform_control/GlutWindow.cc +++ b/examples/transform_control/GlutWindow.cc @@ -31,13 +31,13 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -168,14 +168,14 @@ void handleTransform() if (g_mouse.state == GLUT_DOWN) { // get the visual at mouse position - ignition::math::Vector2i mousePos(g_mouse.x, g_mouse.y); + gz::math::Vector2i mousePos(g_mouse.x, g_mouse.y); ir::VisualPtr visual = rayCamera->VisualAt(mousePos); if (visual) { // check if the visual is an axis in the gizmo visual - ignition::math::Vector3d axis = + gz::math::Vector3d axis = g_transformControl.AxisById(visual->Id()); - if (axis != ignition::math::Vector3d::Zero) + if (axis != gz::math::Vector3d::Zero) { // start the transform process g_transformControl.SetActiveAxis(axis); @@ -207,23 +207,23 @@ void handleTransform() double ny = 1.0 - 2.0 * g_mouse.y / imageHeight; double nxEnd = 2.0 * g_mouse.motionX / imageWidth - 1.0; double nyEnd = 1.0 - 2.0 * g_mouse.motionY / imageHeight; - ignition::math::Vector2d start(nx, ny); - ignition::math::Vector2d end(nxEnd, nyEnd); + gz::math::Vector2d start(nx, ny); + gz::math::Vector2d end(nxEnd, nyEnd); // get the currect active axis - ignition::math::Vector3d axis = g_transformControl.ActiveAxis(); + gz::math::Vector3d axis = g_transformControl.ActiveAxis(); // compute 3d transformation from 2d mouse movement if (g_transformControl.Mode() == ir::TransformMode::TM_TRANSLATION) { - ignition::math::Vector3d distance = + gz::math::Vector3d distance = g_transformControl.TranslationFrom2d(axis, start, end); g_transformControl.Translate(distance); g_mouse.motionDirty = false; } else if (g_transformControl.Mode() == ir::TransformMode::TM_ROTATION) { - ignition::math::Quaterniond rotation = + gz::math::Quaterniond rotation = g_transformControl.RotationFrom2d(axis, start, end); g_transformControl.Rotate(rotation); g_mouse.motionDirty = false; @@ -231,7 +231,7 @@ void handleTransform() else if (g_transformControl.Mode() == ir::TransformMode::TM_SCALE) { // note: scaling is limited to local space - ignition::math::Vector3d scale = + gz::math::Vector3d scale = g_transformControl.ScaleFrom2d(axis, start, end); g_transformControl.Scale(scale); g_mouse.motionDirty = false; @@ -263,7 +263,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -293,7 +293,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) diff --git a/examples/transform_control/GlutWindow.hh b/examples/transform_control/GlutWindow.hh index b55523c6b..f162a70e6 100644 --- a/examples/transform_control/GlutWindow.hh +++ b/examples/transform_control/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/transform_control/Main.cc b/examples/transform_control/Main.cc index aef627d4d..c247f410c 100644 --- a/examples/transform_control/Main.cc +++ b/examples/transform_control/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/view_control/GlutWindow.cc b/examples/view_control/GlutWindow.cc index 75724e49c..1d6bc6f06 100644 --- a/examples/view_control/GlutWindow.cc +++ b/examples/view_control/GlutWindow.cc @@ -31,13 +31,13 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -154,7 +154,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -185,7 +185,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) diff --git a/examples/view_control/GlutWindow.hh b/examples/view_control/GlutWindow.hh index 9bb9c368c..8451263aa 100644 --- a/examples/view_control/GlutWindow.hh +++ b/examples/view_control/GlutWindow.hh @@ -14,16 +14,16 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene -void run(std::vector _cameras); +void run(std::vector _cameras); #endif diff --git a/examples/view_control/Main.cc b/examples/view_control/Main.cc index 478e7ceb4..fd4fe10e8 100644 --- a/examples/view_control/Main.cc +++ b/examples/view_control/Main.cc @@ -27,11 +27,11 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 25ec89762..4b2bdd7bb 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(ignition) +add_subdirectory(gz) +install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) diff --git a/include/ignition/CMakeLists.txt b/include/gz/CMakeLists.txt similarity index 100% rename from include/ignition/CMakeLists.txt rename to include/gz/CMakeLists.txt diff --git a/include/gz/rendering/ArrowVisual.hh b/include/gz/rendering/ArrowVisual.hh new file mode 100644 index 000000000..28ae20ee8 --- /dev/null +++ b/include/gz/rendering/ArrowVisual.hh @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_ARROWVISUAL_HH_ +#define GZ_RENDERING_ARROWVISUAL_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/CompositeVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class ArrowVisual ArrowVisual.hh ignition/rendering/ArrowVisual.hh + /// \brief Represents a arrow composite visual + class IGNITION_RENDERING_VISIBLE ArrowVisual : + public virtual CompositeVisual + { + /// \brief Deconstructor + public: virtual ~ArrowVisual() { } + + /// \brief Get arrow-head visual + /// \return The arrow-head visual + public: virtual VisualPtr Head() const = 0; + + /// \brief Get arrow-shaft visual + /// \return The arrow-shaft visual + public: virtual VisualPtr Shaft() const = 0; + + /// \brief Get arrow-rotation visual + /// \return The arrow-rotation visual + public: virtual VisualPtr Rotation() const = 0; + + /// \brief set true to show the arrow head, false otherwise + /// \param[in] _b true to show the arrow head, false otherwise + public: virtual void ShowArrowHead(bool _b) = 0; + + /// \brief set true to show the arrow shaft, false otherwise + /// \param[in] _b true to show the arrow shaft, false otherwise + public: virtual void ShowArrowShaft(bool _b) = 0; + + /// \brief Set true to show the rotation of the arrow, false otherwise + /// \param[in] _b True to show the arrow rotation. + public: virtual void ShowArrowRotation(bool _b) = 0; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/AxisVisual.hh b/include/gz/rendering/AxisVisual.hh new file mode 100644 index 000000000..74926412d --- /dev/null +++ b/include/gz/rendering/AxisVisual.hh @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_AXISVISUAL_HH_ +#define GZ_RENDERING_AXISVISUAL_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/CompositeVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class AxisVisual AxisVisual.hh ignition/rendering/AxisVisual.hh + /// \brief Represents a axis composite visual + class IGNITION_RENDERING_VISIBLE AxisVisual : + public virtual CompositeVisual + { + /// \brief Deconstructor + public: virtual ~AxisVisual() { } + + /// \brief set true to show the axis heads, false otherwise + /// \param[in] _b true to show the axis heads, false otherwise + public: virtual void ShowAxisHead(bool _b) = 0; + + /// \brief set true to show the specified axis head, false otherwise + /// \param[in] _axis Axis index. 0: x, 1: y, 2: z + /// \param[in] _b true to show the specified axis head, false otherwise + public: virtual void ShowAxisHead(unsigned int _axis, bool _b) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/BoundingBox.hh b/include/gz/rendering/BoundingBox.hh new file mode 100644 index 000000000..1337dc96e --- /dev/null +++ b/include/gz/rendering/BoundingBox.hh @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BOUNDINGBOX_HH_ +#define IGNITION_RENDERING_BOUNDINGBOX_HH_ + +#include +#include +#include +#include + +#include +#include +#include + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Export.hh" + +namespace ignition +{ +namespace rendering +{ +inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + class BoundingBoxPrivate; + + /// \brief 2D or 3D Bounding box. It stores the + /// position / orientation / size info of the box and its label + class IGNITION_RENDERING_VISIBLE BoundingBox + { + /// \brief Constructor + public: BoundingBox(); + + /// \brief Copy constructor + /// \param[in] _box BoundingBox to copy. + public: BoundingBox(const BoundingBox &_box); + + /// \brief Move constructor + /// \param[in] _box BoundingBox to move. + public: BoundingBox(BoundingBox &&_box) noexcept; + + /// \brief Destructor + public: virtual ~BoundingBox(); + + /// \brief Move assignment operator. + /// \param[in] _box Heightmap box to move. + /// \return Reference to this. + public: BoundingBox &operator=(BoundingBox &&_box); + + /// \brief Copy Assignment operator. + /// \param[in] _box The heightmap box to set values from. + /// \return *this + public: BoundingBox &operator=(const BoundingBox &_box); + + /// \brief Get the center of the bounding box. + /// \return The center of the bounding box, in (x,y,z) representation. + /// If this is a 2D bounding box, the z component should be ignored. + public: const math::Vector3d &Center() const; + + /// \brief Set the center of the bounding box. + /// \param[in] _center The center of the bounding box, in (x,y,z) + /// representation. If this is a 2D bounding box, the z component should be + /// ignored. + public: void SetCenter(const math::Vector3d &_center); + + /// \brief Get the size of the bounding box. + /// \return The size of the box (width, height, depth). If this is a 2D + /// bounding box, the depth should be ignored. + public: const math::Vector3d &Size() const; + + /// \brief Set the size of the bounding box. + /// \param[in] _size The size of the box (width, height, depth). If this is + /// a 2D bounding box, the depth should be ignored. + public: void SetSize(const math::Vector3d &_size); + + /// \brief Get the orientation of the bounding box. + /// \return The orientation of the bounding box, in camera coordinates. + public: const math::Quaterniond &Orientation() const; + + /// \brief Set the orientation of the bounding box. + /// \param[in] _orientation The orientation of the bounding box, in camera + /// coordinates. + public: void SetOrientation(const math::Quaterniond &_orientation); + + /// \brief Get the vertices of the 3D bounding box representation. + /// \return The vertices, in the following order: + /// + /// 1 -------- 0 + /// /| /| + /// 2 -------- 3 . + /// | | | | + /// . 5 -------- 4 + /// |/ |/ + /// 6 -------- 7 + public: const std::vector &Vertices3D() const; + + /// \brief Get the label of the bounding box. + /// \return The label of the bounding box. + public: uint32_t Label() const; + + /// \brief Set the label of the bounding box. + /// \param[in] _label The label of the bounding box. + public: void SetLabel(uint32_t _label); + + /// \internal + /// \brief Private data + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; +} +} +} +#endif diff --git a/include/gz/rendering/BoundingBoxCamera.hh b/include/gz/rendering/BoundingBoxCamera.hh new file mode 100644 index 000000000..e0f88808e --- /dev/null +++ b/include/gz/rendering/BoundingBoxCamera.hh @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BOUNDINGBOXCAMERA_HH_ +#define IGNITION_RENDERING_BOUNDINGBOXCAMERA_HH_ + +#include +#include + +#include +#include +#include + +#include "ignition/rendering/BoundingBox.hh" +#include "ignition/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief BoundingBox types for Visible / Full 2D Boxes / 3D Boxes + enum class BoundingBoxType + { + /// 2D box that shows the full box of occluded objects + BBT_FULLBOX2D = 0, + + /// 2D box that shows the visible part of the + /// occluded object + BBT_VISIBLEBOX2D = 1, + + /// 3D oriented box + BBT_BOX3D = 2 + }; + + /// \class BoundingBoxCamera BoundingBoxCamera.hh + /// ignition/rendering/BoundingBoxCamera.hh + /// \brief Poseable BoundingBox camera used for rendering bounding boxes of + /// objects in the scene. + class IGNITION_RENDERING_VISIBLE BoundingBoxCamera : + public virtual Camera + { + /// \brief Destructor + public: virtual ~BoundingBoxCamera() { } + + /// \brief Get the BoundingBox data + /// \return Buffer of bounding boxes info (label, minX, minY, maxX, maxY). + /// If the camera's bounding box type is 3D, minZ and maxZ are also + /// defined) + public: virtual const std::vector &BoundingBoxData() + const = 0; + + /// \brief Connect to the new BoundingBox info + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual ignition::common::ConnectionPtr ConnectNewBoundingBoxes( + std::function &)> _subscriber) = 0; + + /// \brief Set BoundingBox Type (Visible / Full) + /// \param[in] _type BoundingBox Type (Visible / Full) + public: virtual void SetBoundingBoxType(BoundingBoxType _type) = 0; + + /// \brief Get the BoundingBox Type (Visible / Full) + /// \return BoundingBox Type (Visible / Full) + public: virtual BoundingBoxType Type() const = 0; + + /// \brief Draw a bounding box on the given image + /// \param[in] _data buffer containing the image data + /// \param[in] _color Color of the bounding box to be drawn + /// \param[in] _box bounding box to be drawn + public: virtual void DrawBoundingBox(unsigned char *_data, + const math::Color &_color, const BoundingBox &_box) const = 0; + }; + } + } +} +#endif diff --git a/include/ignition/rendering/CMakeLists.txt b/include/gz/rendering/CMakeLists.txt similarity index 100% rename from include/ignition/rendering/CMakeLists.txt rename to include/gz/rendering/CMakeLists.txt diff --git a/include/gz/rendering/COMVisual.hh b/include/gz/rendering/COMVisual.hh new file mode 100644 index 000000000..a0f811cba --- /dev/null +++ b/include/gz/rendering/COMVisual.hh @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_COMVISUAL_HH_ +#define IGNITION_RENDERING_COMVISUAL_HH_ + +#include +#include +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Object.hh" +#include "ignition/rendering/RenderTypes.hh" +#include "ignition/rendering/Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + /// \class COMVisual COMVisual.hh + /// ignition/rendering/COMVisual.hh + /// \brief Represents a center of mass visual + class IGNITION_RENDERING_VISIBLE COMVisual : + public virtual Visual + { + /// \brief Destructor + public: virtual ~COMVisual() {} + + /// \brief Set the inertial component of the visual + /// \param[in] _inertial Inertial component of the visual + public: virtual void SetInertial( + const ignition::math::Inertiald &_inertial) = 0; + + /// \brief Set the mass of the parent + /// \param[in] _mass Parent mass + public: virtual void SetMass(double _mass) = 0; + + /// \brief Get the mass of the parent + /// \return Parent mass + public: virtual double Mass() const = 0; + + /// \brief Get the inertia pose + /// \return Inertia pose in parent frame. + public: virtual ignition::math::Pose3d InertiaPose() const = 0; + + /// \brief Get the sphere visual + /// \return Pointer to the sphere visual + public: virtual VisualPtr SphereVisual() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Camera.hh b/include/gz/rendering/Camera.hh new file mode 100644 index 000000000..56c53fda5 --- /dev/null +++ b/include/gz/rendering/Camera.hh @@ -0,0 +1,344 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_CAMERA_HH_ +#define GZ_RENDERING_CAMERA_HH_ + +#include + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/Sensor.hh" +#include "gz/rendering/Scene.hh" + + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Enum for projection types + enum IGNITION_RENDERING_VISIBLE CameraProjectionType + { + /// \brief Perspective projection + CPT_PERSPECTIVE, + /// \brief Orthographic projection + CPT_ORTHOGRAPHIC + }; + + /// \class Camera Camera.hh ignition/rendering/Camera.hh + /// \brief Posable camera used for rendering the scene graph + class IGNITION_RENDERING_VISIBLE Camera : + public virtual Sensor + { + /// \brief Callback function for new frame render event listeners + public: typedef std::function NewFrameListener; + + /// \brief Deconstructor + public: virtual ~Camera() { } + + /// \brief Get the image width in pixels + /// \return The image width in pixels + public: virtual unsigned int ImageWidth() const = 0; + + /// \brief Set the image width in pixels + /// \param[in] _width New image width in pixels + public: virtual void SetImageWidth(unsigned int _width) = 0; + + /// \brief Get the image height in pixels + /// \return The image height in pixels + public: virtual unsigned int ImageHeight() const = 0; + + /// \brief Set the image height in pixels + /// \param[in] _height New image height in pixels + public: virtual void SetImageHeight(unsigned int _height) = 0; + + /// \brief Get the image pixel format. If the image pixel format has not + /// been set with a valid value, PF_UNKNOWN will be returned. + /// \return The image pixel format + public: virtual PixelFormat ImageFormat() const = 0; + + /// \brief Set the image pixel format + /// \param[in] _format New image pixel format + public: virtual void SetImageFormat(PixelFormat _format) = 0; + + /// \brief Get the total image memory size in bytes + /// \return The image memory size in bytes + public: virtual unsigned int ImageMemorySize() const = 0; + + /// \brief Get the camera's horizontal field-of-view + /// \return Angle containing the camera's horizontal field-of-view + public: virtual math::Angle HFOV() const = 0; + + /// \brief Set the camera's horizontal field-of-view + /// \param[in] _hfov Desired horizontal field-of-view + public: virtual void SetHFOV(const math::Angle &_hfov) = 0; + + /// \brief Get the camera's aspect ratio + /// \return The camera's aspect ratio + public: virtual double AspectRatio() const = 0; + + /// \brief Set the camera's aspect ratio. This value determines the + /// cameras vertical field-of-view. It is often the \code image_height / + /// image_width \endcode but this is not necessarily true. + /// \return The camera's aspect ratio + public: virtual void SetAspectRatio(const double _ratio) = 0; + + // TODO(anyone): add auto-aspect ratio + + /// \brief Get the level of anti-aliasing used during rendering + /// \return The level of anti-aliasing used during rendering + public: virtual unsigned int AntiAliasing() const = 0; + + /// \brief Set the level of anti-aliasing used during rendering. If a + /// value of 0 is given, no anti-aliasing will be performed. Higher values + /// can significantly slow-down rendering times, depending on the + /// underlying render engine. + /// \param[in] _aa Level of anti-aliasing used during rendering + public: virtual void SetAntiAliasing(const unsigned int _aa) = 0; + + /// \brief Get the camera's far clipping plane distance + /// \return Far clipping plane distance + public: virtual double FarClipPlane() const = 0; + + /// \brief Set the camera's far clipping plane distance + /// \param[in] _far Far clipping plane distance + public: virtual void SetFarClipPlane(const double _far) = 0; + + /// \brief Get the camera's near clipping plane distance + /// \return Near clipping plane distance + public: virtual double NearClipPlane() const = 0; + + /// \brief Set the camera's near clipping plane distance + /// \param[in] _near Near clipping plane distance + public: virtual void SetNearClipPlane(const double _near) = 0; + + /// \brief Renders the current scene using this camera. This function + /// assumes PreRender() has already been called on the parent Scene, + /// allowing the camera and the scene itself to prepare for rendering. + public: virtual void Render() = 0; + + /// \brief Preforms any necessary final rendering work. Once rendering is + /// complete the camera will alert any listeners of the new frame event. + /// This function should only be called after a call to Render has + /// successfully been executed. + public: virtual void PostRender() = 0; + + /// \brief Get the visual for a given mouse position + /// param[in] _mousePos mouse position + // \return visual for that position, null if no visual was found + public: virtual VisualPtr VisualAt(const gz::math::Vector2i + &_mousePos) = 0; + + /// \brief Renders a new frame. + /// This is a convenience function for single-camera scenes. It wraps the + /// pre-render, render, and post-render into a single + /// function. This should be used in applications with multiple cameras + /// or multiple consumers of a single camera's images. + public: virtual void Update() = 0; + + /// \brief Created an empty image buffer for capturing images. The + /// resulting image will have sufficient memory allocated for subsequent + /// calls to this camera's Capture function. However, any changes to this + /// cameras properties may invalidate the condition. + /// \return A newly allocated Image for storing this cameras images + public: virtual Image CreateImage() const = 0; + + /// \brief Renders a new frame and writes the results to the given image. + /// This is a convenience function for single-camera scenes. It wraps the + /// pre-render, render, post-render, and get-image calls into a single + /// function. This should be used in applications with multiple cameras + /// or multiple consumers of a single camera's images. + /// \param[out] _image Output image buffer + public: virtual void Capture(Image &_image) = 0; + + /// \brief Writes the last rendered image to the given image buffer. This + /// function can be called multiple times after PostRender has been + /// called, without rendering the scene again. Calling this function + /// before a single image has been rendered will have undefined behavior. + /// \param[out] _image Output image buffer + public: virtual void Copy(Image &_image) const = 0; + + /// \brief Writes the previously rendered frame to a file. This function + /// can be called multiple times after PostRender has been called, + /// without rendering the scene again. Calling this function before a + /// single image has been rendered will have undefined behavior. + /// \param[in] _name Name of the output file + public: virtual bool SaveFrame(const std::string &_name) = 0; + + /// \brief Subscribes a new listener to this camera's new frame event + /// \param[in] _listener New camera listener callback + public: virtual common::ConnectionPtr ConnectNewImageFrame( + NewFrameListener _listener) = 0; + + /// \brief Create a render window. + /// \return A pointer to the render window. + public: virtual RenderWindowPtr CreateRenderWindow() = 0; + + /// \brief Get the projection matrix for this camera + /// \return Camera projection matrix + public: virtual math::Matrix4d ProjectionMatrix() const = 0; + + /// \brief Get the view matrix for this camera + /// \return Camera view matrix + public: virtual math::Matrix4d ViewMatrix() const = 0; + + /// \brief Set the projection matrix for this camera. This overrides + /// the standard projection matrix computed based on camera parameters. + /// \param[in] _matrix Camera projection matrix + public: virtual void SetProjectionMatrix(const math::Matrix4d &_matrix) + = 0; + + /// \brief Get the projection type for this camera + /// \return Camera projection type + public: virtual CameraProjectionType ProjectionType() const = 0; + + /// \brief Set the projection type for this camera + /// This changes the projection matrix of the camera based on the camera + /// projection type. A custom projection matrix can be specified via + /// `SetProjectionMatrix` to override the provided one. To disable the + /// custom projection matrix, just call this function again with the + /// desired projection type. + /// \param[in] _type Camera projection type + /// \sa SetProjectionMatrix + public: virtual void SetProjectionType(CameraProjectionType _type) = 0; + + /// \brief Project point in 3d world space to 2d screen space + /// \param[in] _pt Point in 3d world space + /// \return Point in 2d screen space + public: virtual math::Vector2i Project(const math::Vector3d &_pt) const + = 0; + + /// \brief Set a node for camera to track. The camera will automatically + /// change its orientation to face the target being tracked. If null is + /// specified, tracking is disabled. In contrast to SetFollowTarget + /// the camera does not change its position when tracking is enabled. + /// \param[in] _target Target node to track + /// \param[in] _offset Track a point that is at an offset relative + /// to target. + /// \param[in] _worldFrame If true, the offset point to track will be + /// treated in world frame and its position relative to the target + /// node remains fixed regardless of the target node's rotation. Default + /// is false, which means the camera tracks the point in target node's + /// local frame. + public: virtual void SetTrackTarget(const NodePtr &_target, + const math::Vector3d &_offset = math::Vector3d::Zero, + const bool _worldFrame = false) = 0; + + /// \brief Get the target node being tracked + /// \return Target node being tracked. + public: virtual NodePtr TrackTarget() const = 0; + + /// \brief Set track offset. Camera will track a point that's at an + /// offset from the target node. The offset will be in the frame + /// that is specified at the time the track target is set. + /// \param[in] _offset Point offset to track + public: virtual void SetTrackOffset(const math::Vector3d &_offset) = 0; + + /// \brief Get the track offset vector in the frame specified at the time + /// the track target is set. + /// \return Point offset from target. + public: virtual math::Vector3d TrackOffset() const = 0; + + /// \brief Set track P Gain. Determines how fast the camera rotates + /// to look at the target node. Valid range: [0-1] + /// \param[in] _pGain P gain for camera tracking + public: virtual void SetTrackPGain(const double _pGain) = 0; + + /// \brief Get the camera track rotation P gain. + /// \return P gain for camera tracking + public: virtual double TrackPGain() const = 0; + + /// \brief Set a node for camera to follow. The camera will automatically + /// update its position to keep itself at the specified offset distance + /// from the target being followed. If null is specified, camera follow is + /// disabled. In contrast to SetTrackTarget, the camera does not change + /// its orientation when following is enabled. + /// \param[in] _target Target node to follow + /// \param[in] _offset Tether the camera at an offset distance from the + /// target node. + /// \param[in] _worldFrame True to follow the target node at a + /// distance that's fixed in world frame. Default is false which means + /// the camera follows at fixed distance in target node's local frame. + public: virtual void SetFollowTarget(const NodePtr &_target, + const math::Vector3d &_offset = math::Vector3d::Zero, + const bool _worldFrame = false) = 0; + + /// \brief Get the target node being followed + /// \return Target node being tracked. + public: virtual NodePtr FollowTarget() const = 0; + + /// \brief Set offset of camera from target node being followed. The + /// offset will be in the frame that is specified at the time the follow + /// target is set. + /// \param[in] _offset Offset distance from target node. + public: virtual void SetFollowOffset(const math::Vector3d &_offset) = 0; + + /// \brief Get the follow offset vector in the frame specified at the + /// time the follow target is set. + /// \return Offset of camera from target. + public: virtual math::Vector3d FollowOffset() const = 0; + + /// \brief Set follow P Gain. Determines how fast the camera moves + /// to follow the target node. Valid range: [0-1] + /// \param[in] _pGain P gain for camera following + public: virtual void SetFollowPGain(const double _pGain) = 0; + + /// \brief Get the camera follow movement P gain. + /// \return P gain for camera following + public: virtual double FollowPGain() const = 0; + + /// \brief Set a material that the camera should see on all objects + /// \param[in] _material a material instance + public: virtual void SetMaterial(const MaterialPtr &_material) = 0; + + /// \brief Get the OpenGL texture id associated with the render texture + /// used by this camera. A valid id is returned only if the underlying + /// render engine is OpenGL based. + /// \return Texture Id of type GLuint. + public: virtual unsigned int RenderTextureGLId() const = 0; + + /// \brief Add a render pass to the camera + /// \param[in] _pass New render pass to add + public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0; + + /// \brief Remove a render pass from the camera + /// \param[in] _pass render pass to remove + public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) = 0; + + /// \brief Get the number of render passes applied to the camera + /// \return Number of render passes applied + public: virtual unsigned int RenderPassCount() const = 0; + + /// \brief Get a render passes by index + /// \return Render pass at the specified index + public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) + const = 0; + + /// \internal + /// \brief Notify that shadows are dirty and need to be regenerated + public: virtual void SetShadowsDirty() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Capsule.hh b/include/gz/rendering/Capsule.hh new file mode 100644 index 000000000..7423be1d7 --- /dev/null +++ b/include/gz/rendering/Capsule.hh @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef IGNITION_RENDERING_CAPSULE_HH_ +#define IGNITION_RENDERING_CAPSULE_HH_ + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Geometry.hh" +#include "ignition/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \class Capsule Capsule.hh ignition/rendering/Capsule + /// \brief Geometry for a capsule shape. + class IGNITION_RENDERING_VISIBLE Capsule : + public virtual Geometry + { + /// \brief Destructor + public: virtual ~Capsule() { } + + /// \brief Set the radius of the capsule + public: virtual void SetRadius(double _radius) = 0; + + /// \brief Set the length of the capsule + public: virtual void SetLength(double _length) = 0; + + /// \brief Get the radius of the capsule + public: virtual double Radius() const = 0; + + /// \brief Get the length of the capsule + public: virtual double Length() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/CompositeVisual.hh b/include/gz/rendering/CompositeVisual.hh new file mode 100644 index 000000000..05c307337 --- /dev/null +++ b/include/gz/rendering/CompositeVisual.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_COMPOSITEVISUAL_HH_ +#define GZ_RENDERING_COMPOSITEVISUAL_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class CompositeVisual CompositeVisual.hh + /// ignition/rendering/CompositeVisual.hh + /// \brief Represents a predefined collection of geometries and visuals + class IGNITION_RENDERING_VISIBLE CompositeVisual : + public virtual Visual + { + /// \brief Deconstructor + public: virtual ~CompositeVisual() { } + }; + } + } +} +#endif diff --git a/include/gz/rendering/DepthCamera.hh b/include/gz/rendering/DepthCamera.hh new file mode 100644 index 000000000..f86c935c6 --- /dev/null +++ b/include/gz/rendering/DepthCamera.hh @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_DEPTHCAMERA_HH_ +#define GZ_RENDERING_DEPTHCAMERA_HH_ + +#include + +#include +#include "gz/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \class Camera Camera.hh ignition/rendering/Camera.hh + /// \brief Poseable depth camera used for rendering the scene graph. + /// This camera is designed to produced depth data, instead of a 2D + /// image. + class IGNITION_RENDERING_VISIBLE DepthCamera : + public virtual Camera + { + /// \brief Callback function for new frame render event listeners + public: typedef std::function NewFrameListener; + + /// \brief Destructor + public: virtual ~DepthCamera() { } + + /// \brief Create a texture which will hold the depth data + public: virtual void CreateDepthTexture() = 0; + + /// \brief All things needed to get back z buffer for depth data + /// \return The z-buffer as a float array + public: virtual const float *DepthData() const = 0; + + /// \brief Connect to the new depth image signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewDepthFrame( + std::function _subscriber) = 0; + + /// \brief Connect to the new rgb point cloud signal. + /// \param[in] _subscriber Subscriber callback function + /// The arguments of the callback function are: + /// _pointCloud Point cloud data. Each point is represented by four + /// 32 bit floating point values [X, Y, Z, RGBA]. The last + /// field can be decoded into 4 unsigned 8 bit color values: + /// uint32_t *rgba = reinterpret_cast(&_rgba) + /// r = static_cast(*rgba >> 24 & 0xFF); + /// g = static_cast(*rgba >> 16 & 0xFF); + /// b = static_cast(*rgba >> 8 & 0xFF); + /// a = static_cast(*rgba >> 0 & 0xFF); + /// _width Point cloud image width + /// _height Point cloud image height + /// _depth Point cloud image depth + /// _format Point cloud image format + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewRgbPointCloud( + std::function _subscriber) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/DistortionPass.hh b/include/gz/rendering/DistortionPass.hh new file mode 100644 index 000000000..c4d02221d --- /dev/null +++ b/include/gz/rendering/DistortionPass.hh @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_DISTORTIONPASS_HH_ +#define IGNITION_RENDERING_DISTORTIONPASS_HH_ + +#include +#include + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Export.hh" +#include "ignition/rendering/RenderPass.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class DistortionPass DistortionPass.hh \ + * ignition/rendering/DistortionPass.hh + */ + /// \brief A render pass that applies distortion to the render target + class IGNITION_RENDERING_VISIBLE DistortionPass + : public virtual RenderPass + { + /// \brief Constructor + public: DistortionPass(); + + /// \brief Destructor + public: virtual ~DistortionPass(); + + /// \brief Get the radial distortion coefficient k1. + /// \return Distortion coefficient k1. + public: virtual double K1() const = 0; + + /// \brief Get the radial distortion coefficient k2. + /// \return Distortion coefficient k2. + public: virtual double K2() const = 0; + + /// \brief Get the radial distortion coefficient k3. + /// \return Distortion coefficient k3. + public: virtual double K3() const = 0; + + /// \brief Get the tangential distortion coefficient p1. + /// \return Distortion coefficient p1. + public: virtual double P1() const = 0; + + /// \brief Get the tangential distortion coefficient p2. + /// \return Distortion coefficient p2. + public: virtual double P2() const = 0; + + /// \brief Get the distortion center. + /// \return Distortion center. + public: virtual math::Vector2d Center() const = 0; + + /// \brief Set the radial distortion coefficient k1. + /// \param[in] _k1 Distortion coefficient k1. + public: virtual void SetK1(double _k1) = 0; + + /// \brief Set the radial distortion coefficient k2. + /// \param[in] _k2 Distortion coefficient k1. + public: virtual void SetK2(double _k2) = 0; + + /// \brief Set the radial distortion coefficient k3. + /// \param[in] _k3 Distortion coefficient k1. + public: virtual void SetK3(double _k3) = 0; + + /// \brief Set the tangential distortion coefficient p1. + /// \param[in] _p1 Distortion coefficient k1. + public: virtual void SetP1(double _p1) = 0; + + /// \brief Set the tangential distortion coefficient p2. + /// \param[in] _p2 Distortion coefficient k1. + public: virtual void SetP2(double _p2) = 0; + + /// \brief Set the distortion center. + /// \param[in] _center Distortion center. + public: virtual void SetCenter(const math::Vector2d &_center) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/GaussianNoisePass.hh b/include/gz/rendering/GaussianNoisePass.hh new file mode 100644 index 000000000..4abaf9b7a --- /dev/null +++ b/include/gz/rendering/GaussianNoisePass.hh @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_GAUSSIANNOISEPASS_HH_ +#define GZ_RENDERING_GAUSSIANNOISEPASS_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" +#include "gz/rendering/RenderPass.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class GaussianNoisePass GaussianNoisePass.hh \ + * ignition/rendering/GaussianNoisePass.hh + */ + /// \brief A render pass that applies Gaussian noise to the render target + class IGNITION_RENDERING_VISIBLE GaussianNoisePass + : public virtual RenderPass + { + /// \brief Constructor + public: GaussianNoisePass(); + + /// \brief Destructor + public: virtual ~GaussianNoisePass(); + + /// \brief Accessor for mean. + /// \return Mean of Gaussian noise. + public: virtual double Mean() const = 0; + + /// \brief Accessor for stddev. + /// \return Standard deviation of Gaussian noise. + public: virtual double StdDev() const = 0; + + /// \brief Accessor for bias. + /// \return Bias on output. + public: virtual double Bias() const = 0; + + /// \brief Set mean. + /// \param[in] _mean Mean of Gaussian noise. + public: virtual void SetMean(double _mean) = 0; + + /// \brief Set stddev. + /// \param[in] _stdDev Standard deviation of Gaussian noise. + public: virtual void SetStdDev(double _stdDev) = 0; + + /// \brief Set the mean of the bias value. Bias is computed based on + /// the bias mean and bias standard deviation. + /// \sa SetBiasStdDev + public: virtual void SetBiasMean(double _biasMean) = 0; + + /// \brief Set the standard deviation of the bias value. Bias is computed + /// based on the bias mean and bias standard deviation. + /// \sa SetBiasMean + public: virtual void SetBiasStdDev(double _biasStdDev) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Geometry.hh b/include/gz/rendering/Geometry.hh new file mode 100644 index 000000000..a65b2a8aa --- /dev/null +++ b/include/gz/rendering/Geometry.hh @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_GEOMETRY_HH_ +#define GZ_RENDERING_GEOMETRY_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Object.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Geometry Geometry.hh ignition/rendering/Geometry.hh + /// \brief Represents a geometric shape to be rendered + class IGNITION_RENDERING_VISIBLE Geometry : + public virtual Object + { + /// \brief Deconstructor + public: virtual ~Geometry() { } + + /// \brief Determine if this Geometry is attached to a Visual + /// \return True if this Geometry has a parent Visual + public: virtual bool HasParent() const = 0; + + /// \brief Get the parent Visual + /// \return the parent Visual + public: virtual VisualPtr Parent() const = 0; + + /// \brief Detach this Geometry from its parent Visual. If this + /// Geometry does not have a parent, no work will be done. + public: virtual void RemoveParent() = 0; + + /// \brief Set the materials of this Geometry. The specified material + /// will be retrieved from the parent Scene. If no material is registered + /// by the given name, no work will be done. + /// \param[in] _name Name of registered Material + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetMaterial(const std::string &_name, + bool _unique = true) = 0; + + /// \brief Set the materials of this Geometry + /// \param[in] _material New Material to be assigned + /// \param[in] _unique True if the given material should be cloned + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true) = 0; + + /// \brief Get the material of this geometry + /// \return Material used by this geometry + public: virtual MaterialPtr Material() const = 0; + + /// \brief Clone the geometry. + /// \return The cloned geometry. + public: virtual GeometryPtr Clone() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/GizmoVisual.hh b/include/gz/rendering/GizmoVisual.hh new file mode 100644 index 000000000..bc7bba0c6 --- /dev/null +++ b/include/gz/rendering/GizmoVisual.hh @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_GIZMOVISUAL_HH_ +#define GZ_RENDERING_GIZMOVISUAL_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/CompositeVisual.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Export.hh" +#include "gz/rendering/TransformType.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class GizmoVisual GizmoVisual.hh ignition/rendering/GizmoVisual.hh + /// \brief A gizmo that contains rotate, translate, and scale visuals + class IGNITION_RENDERING_VISIBLE GizmoVisual : + public virtual CompositeVisual + { + /// \brief Destructor + public: virtual ~GizmoVisual() { } + + /// \brief Set the transform mode of the gizmo. This controls the visual + /// appearance of the gizmo. Only the visuals in the specified mode will + /// be visible, e.g. if set to TM_TRANSLATION mode, then only the + /// translation axis visuals will be visible. + /// \param[in] _mode Transform mode to set the gizmo to + /// \sa GizmoMode + public: virtual void SetTransformMode(TransformMode _mode) = 0; + + /// \brief Get the current transform mode. + /// \return Transform mode + /// \sa SetTransformMode + public: virtual TransformMode Mode() const = 0; + + /// \brief Set the active axis in the gizmo visual + /// \param[in] _axis Axis to be set active + public: virtual void SetActiveAxis(const math::Vector3d &_axis) = 0; + + /// \brief Get the current active axis. + /// \return Active axis + /// \sa SetActiveAxis + public: virtual math::Vector3d ActiveAxis() const = 0; + + /// \brief Get the Transform axis associated with the given id. + /// \param[in] _id Id of the visual associated with a transform axis + /// \return Transform axis with the given id + public: virtual TransformAxis AxisById(unsigned int _id) const = 0; + + /// \brief Get the child visual by axis + /// \return Visual representing the specified transform axis or transform + /// mode + /// \sa TransformAxis, TransformMode + public: virtual VisualPtr ChildByAxis(unsigned int _axis) const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/GpuRays.hh b/include/gz/rendering/GpuRays.hh new file mode 100644 index 000000000..a1f92556a --- /dev/null +++ b/include/gz/rendering/GpuRays.hh @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_GPURAYS_HH_ +#define GZ_RENDERING_GPURAYS_HH_ + +#include + +#include + +#include "gz/rendering/Image.hh" +#include "gz/rendering/Sensor.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class GpuRays GpuRays.hh ignition/rendering/GpuRays.hh + /// \brief Generate depth ray data. + class IGNITION_RENDERING_VISIBLE GpuRays : + public virtual Camera + { + /// \brief Callback function for new frame render event listeners + public: typedef std::function NewFrameListener; + + /// \brief Destructor + public: virtual ~GpuRays() { } + + /// \brief All things needed to get back z buffer for gpu rays data. + /// \return Array of gpu rays data. + public: virtual const float *Data() const = 0; + + /// \brief Copy to the specified memory direction the gpu rays data. + public: virtual void Copy(float *_data) = 0; + + /// \brief Configure behaviour for data values outside of camera range + /// \param[in] _clamp True to clamp data to camera clip distances, + // false to leave data values as +/-inf when out of camera range + public: virtual void SetClamp(const bool _clamp) = 0; + + /// \brief Get behaviour for data values outside of camera range + /// \return True if data values are clampped to camera clip distances, + // false if data values outside of camera range are returned as +/-inf + public: virtual bool Clamp() const = 0; + + /// \brief Connect to a gpu rays frame signal + /// \param[in] _subscriber Callback that is called when a new image is + /// generated. The callback function parameters are: + /// _frame: Image frame is an array of floats. Size is equal + /// to width * height * channels + /// Each gpu rays reading occupies 3 floats + /// Index 0: depth value + /// Index 1: retro value + /// Index 2: 0. Not used + /// _width: Width of image, i.e. number of data in the horizonal scan + /// _height: Height o image, i.e. number of scans in vertical direction + /// _channels: Number of channels, i.e. 3 floats per gpu rays reading + /// _format: Pixel format of the image frame. + /// \return A pointer to the connection. This must be kept in scope. + public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( + std::function _subscriber) = 0; + + /// \brief Set sensor horizontal or vertical + /// \param[in] _horizontal True if horizontal, false if not + public: virtual void SetIsHorizontal(const bool _horizontal) = 0; + + /// \brief Gets if sensor is horizontal + /// \return True if horizontal, false if not + public: virtual bool IsHorizontal() const = 0; + + /// \brief Get the vertical field-of-view. + /// \return The vertical field of view of the gpu rays. + public: virtual math::Angle VFOV() const = 0; + + /// \brief Get the ray count ratio (equivalent to aspect ratio) + /// \return The ray count ratio (equivalent to aspect ratio) + public: virtual double RayCountRatio() const = 0; + + /// \brief Get the ray count ratio (equivalent to aspect ratio) + /// \return The ray count ratio (equivalent to aspect ratio) + public: virtual double RangeCountRatio() const = 0; + + /// \brief Sets the ray count ratio (equivalent to aspect ratio) + /// \param[in] _rayCountRatio ray count ratio (equivalent to aspect ratio) + public: virtual void SetRayCountRatio(const double _rayCountRatio) = 0; + + /// \brief Get minimal horizontal angle value + // \return minimal horizontal angle value + public: virtual gz::math::Angle AngleMin() const = 0; + + /// \brief Set minimal horizontal angle value + public: virtual void SetAngleMin(double _angle) = 0; + + /// \brief Get maximal horizontal angle value + // \return maximal horizontal angle value + public: virtual gz::math::Angle AngleMax() const = 0; + + /// \brief Set maximal horizontal angle value + public: virtual void SetAngleMax(double _angle) = 0; + + /// \brief Get horizontal quantity of rays + // \return horizontal quantity of rays + public: virtual int RayCount() const = 0; + + /// \brief Set horizontal quantity of rays + public: virtual void SetRayCount(int _samples) = 0; + + /// \brief Get hoizontal range count, i.e. ray count * horz resolution + // \return horizontal range count + public: virtual int RangeCount() const = 0; + + /// \brief Get vertical quantity of rays + // \return vertical quantity of rays + public: virtual int VerticalRayCount() const = 0; + + /// \brief Set vertical quantity of rays + public: virtual void SetVerticalRayCount(int _samples) = 0; + + /// \brief Get vertical range count, i.e. ray count * vert resolution + // \return Vertical range count + public: virtual int VerticalRangeCount() const = 0; + + /// \brief Get minimal vertical angle value + // \return minimal vertical angle value + public: virtual gz::math::Angle VerticalAngleMin() const = 0; + + /// \brief Set minimal vertical angle value + public: virtual void SetVerticalAngleMin(const double _angle) = 0; + + /// \brief Get maximal vertical angle value + // \return maximal vertical angle value + public: virtual gz::math::Angle VerticalAngleMax() const = 0; + + /// \brief Set maximal vertical angle value + // \return minimal vertical angle value + public: virtual void SetVerticalAngleMax(const double _angle) = 0; + + /// \brief Get the number of channels used to store the ray data. + /// \return Channel count. + public: virtual unsigned int Channels() const = 0; + + /// \brief Set the horizontal resolution. This number is multiplied by + /// RayCount to calculate RangeCount, which is the the number range data + /// points. + /// \sa RayCount() + /// \param[in] _resolution The new horizontal resolution. The + /// absolute value of this parameter is used to prevent a + /// negative resolution value. + public: virtual void SetHorizontalResolution(double _resolution) = 0; + + /// \brief Get the horizontal resolution. This number is multiplied by + /// RayCount to calculate RangeCount, which is the the number range data + /// points. + /// \sa RayCount() + /// \return The horizontal resolution + public: virtual double HorizontalResolution() const = 0; + + /// \brief Set the vertical resolution. This number is multiplied by + /// VerticalRayCount to calculate VerticalRangeCount, which is the the + /// number vertical range data points. + /// \param[in] _resolution The new vertical resolution. The + /// absolute value of this parameter is used to prevent a + /// negative resolution value. + /// \sa VerticalRayCount() + public: virtual void SetVerticalResolution(double _resolution) = 0; + + /// \brief Get the vertical resolution. This number is multiplied by + /// VerticalRayCount to calculate VerticalRangeCount, which is the the + /// number vertical range data points. + /// \return The vertical resolution. + /// \sa VerticalRayCount() + public: virtual double VerticalResolution() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/GraphicsAPI.hh b/include/gz/rendering/GraphicsAPI.hh new file mode 100644 index 000000000..505e4019d --- /dev/null +++ b/include/gz/rendering/GraphicsAPI.hh @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_GRAPHICSAPI_HH_ +#define IGNITION_RENDERING_GRAPHICSAPI_HH_ + +#include +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + /// \brief The graphics API used by the render engine + enum class IGNITION_RENDERING_VISIBLE GraphicsAPI : uint16_t + { + /// \internal + /// \brief Indicator used to create an iterator over the + /// enum. Do not use this. + GRAPHICS_API_BEGIN = 0, + + /// \brief Unknown graphics interface + UNKNOWN = GRAPHICS_API_BEGIN, + + /// \brief OpenGL graphics interface + OPENGL = 1, + + /// \brief Direct3D11 graphics interface + DIRECT3D11 = 2, + + /// \brief Vulkan graphics interface + VULKAN = 3, + + /// \brief Metal graphics interface + METAL = 4, + + /// \internal + /// \brief Indicator used to create an iterator over the + /// enum. Do not use this. + GRAPHICS_API_END + }; + + /// \brief Utils to convert GraphicsAPI to and from strings + class IGNITION_RENDERING_VISIBLE GraphicsAPIUtils + { + /// \brief Convert enum value to string. + /// \param[in] _e Enum value to convert. + /// \return String representation of the enum. An empty string is + /// returned if _e is invalid, or the names for the enum have not been + /// set. + public: static std::string Str(GraphicsAPI _e); + + /// \brief Set an enum from a string. This function requires a valid + /// string, and an array of names for the enum must exist. + /// The string is not case sensitive. + /// \param[in] _str String value to convert to enum value. + /// \return GraphicsAPI enum + public: static GraphicsAPI Set(const std::string &_str); + }; + } + } +} +#endif diff --git a/include/gz/rendering/Grid.hh b/include/gz/rendering/Grid.hh new file mode 100644 index 000000000..70fa66019 --- /dev/null +++ b/include/gz/rendering/Grid.hh @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_GRID_HH_ +#define GZ_RENDERING_GRID_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Grid Grid.hh ignition/rendering/Grid + /// \brief Represents a grid geometry drawn along the XY plane. + /// If vertical cell count is specified then the grid becomes 3D. + class IGNITION_RENDERING_VISIBLE Grid : + public virtual Geometry + { + /// \brief Destructor + public: virtual ~Grid() { } + + /// \brief Set the number of cells on a planar grid + /// \param[in] _count The number of cells + public: virtual void SetCellCount(const unsigned int _count) = 0; + + /// \brief Get the number of cells on a planar grid + /// \return Number of cells + public: virtual unsigned int CellCount() const = 0; + + /// \brief Set the cell length in one direction. + /// The cells are assumed to be square. + /// \param[in] _len The cell length + public: virtual void SetCellLength(const double _len) = 0; + + /// \brief Get the cell length + /// \return The cell length + public: virtual double CellLength() const = 0; + + /// \brief Set the vertical cell count of the grid. This makes the grid 3D + /// \param[in] _count Number of cells in vertical direction. + public: virtual void SetVerticalCellCount(const unsigned int _count) = 0; + + /// \brief Get the vertical cell count + /// \return The vertical cell count. + public: virtual unsigned int VerticalCellCount() const = 0; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/Heightmap.hh b/include/gz/rendering/Heightmap.hh new file mode 100644 index 000000000..dbd818b68 --- /dev/null +++ b/include/gz/rendering/Heightmap.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_HEIGHTMAP_HH_ +#define IGNITION_RENDERING_HEIGHTMAP_HH_ + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Geometry.hh" +#include "ignition/rendering/HeightmapDescriptor.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Heightmap Heightmap.hh ignition/rendering/Heightmap + /// \brief A terrain defined by a heightfield. + class Heightmap : + public virtual Geometry + { + /// \brief Get the immutable heightmap descriptor. + /// \return Descriptor with heightmap information. + public: virtual const HeightmapDescriptor &Descriptor() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/HeightmapDescriptor.hh b/include/gz/rendering/HeightmapDescriptor.hh new file mode 100644 index 000000000..2717554c2 --- /dev/null +++ b/include/gz/rendering/HeightmapDescriptor.hh @@ -0,0 +1,262 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_HEIGHTMAPDESCRIPTOR_HH_ +#define IGNITION_RENDERING_HEIGHTMAPDESCRIPTOR_HH_ + +#include +#include +#include +#include + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Export.hh" + +namespace ignition +{ +namespace rendering +{ +inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + class HeightmapDescriptorPrivate; + class HeightmapTexturePrivate; + class HeightmapBlendPrivate; + + /// \brief Texture to be used on heightmaps. + class IGNITION_RENDERING_VISIBLE HeightmapTexture + { + /// \brief Constructor + public: HeightmapTexture(); + + /// \brief Copy constructor + /// \param[in] _texture HeightmapTexture to copy. + public: HeightmapTexture(const HeightmapTexture &_texture); + + /// \brief Move constructor + /// \param[in] _texture HeightmapTexture to move. + public: HeightmapTexture(HeightmapTexture &&_texture) noexcept; + + /// \brief Destructor + public: virtual ~HeightmapTexture(); + + /// \brief Move assignment operator. + /// \param[in] _texture Heightmap texture to move. + /// \return Reference to this. + public: HeightmapTexture &operator=(HeightmapTexture &&_texture); + + /// \brief Copy Assignment operator. + /// \param[in] _texture The heightmap texture to set values from. + /// \return *this + public: HeightmapTexture &operator=(const HeightmapTexture &_texture); + + /// \brief Get the heightmap texture's size. + /// \return The size of the heightmap texture in meters. + public: double Size() const; + + /// \brief Set the size of the texture in meters. + /// \param[in] _size The size of the texture in meters. + public: void SetSize(double _size); + + /// \brief Get the heightmap texture's diffuse map. + /// \return The diffuse map of the heightmap texture. + public: std::string Diffuse() const; + + /// \brief Set the filename of the diffuse map. + /// \param[in] _diffuse The diffuse map of the heightmap texture. + public: void SetDiffuse(const std::string &_diffuse); + + /// \brief Get the heightmap texture's normal map. + /// \return The normal map of the heightmap texture. + public: std::string Normal() const; + + /// \brief Set the filename of the normal map. + /// \param[in] _normal The normal map of the heightmap texture. + public: void SetNormal(const std::string &_normal); + + /// \brief Private data pointer. + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + + /// \brief Blend information to be used between textures on heightmaps. + class IGNITION_RENDERING_VISIBLE HeightmapBlend + { + /// \brief Constructor + public: HeightmapBlend(); + + /// \brief Copy constructor + /// \param[in] _blend HeightmapBlend to copy. + public: HeightmapBlend(const HeightmapBlend &_blend); + + /// \brief Move constructor + /// \param[in] _blend HeightmapBlend to move. + public: HeightmapBlend(HeightmapBlend &&_blend) noexcept; + + /// \brief Destructor + public: virtual ~HeightmapBlend(); + + /// \brief Move assignment operator. + /// \param[in] _blend Heightmap blend to move. + /// \return Reference to this. + public: HeightmapBlend &operator=(HeightmapBlend &&_blend); + + /// \brief Copy Assignment operator. + /// \param[in] _blend The heightmap blend to set values from. + /// \return *this + public: HeightmapBlend &operator=(const HeightmapBlend &_blend); + + /// \brief Get the heightmap blend's minimum height. + /// \return The minimum height of the blend layer. + public: double MinHeight() const; + + /// \brief Set the minimum height of the blend in meters. + /// \param[in] _minHeight The minimum height of the blend in meters. + public: void SetMinHeight(double _minHeight); + + /// \brief Get the heightmap blend's fade distance. + /// \return The fade distance of the heightmap blend in meters. + public: double FadeDistance() const; + + /// \brief Set the distance over which the blend occurs. + /// \param[in] _fadeDistance The distance in meters. + public: void SetFadeDistance(double _fadeDistance); + + /// \brief Private data pointer. + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + + /// \class HeightmapDescriptor HeightmapDescriptor.hh + /// ignition/rendering/HeightmapDescriptor.hh + /// \brief Describes how a Heightmap should be loaded + class IGNITION_RENDERING_VISIBLE HeightmapDescriptor + { + /// \brief Constructor + public: HeightmapDescriptor(); + + /// \brief Copy constructor + /// \param[in] _desc HeightmapDescriptor to copy. + public: HeightmapDescriptor(const HeightmapDescriptor &_desc); + + /// \brief Move constructor + /// \param[in] _desc HeightmapDescriptor to move. + public: HeightmapDescriptor(HeightmapDescriptor &&_desc) noexcept; + + /// \brief Destructor + public: virtual ~HeightmapDescriptor(); + + /// \brief Move assignment operator. + /// \param[in] _desc HeightmapDescriptor to move. + /// \return Reference to this. + public: HeightmapDescriptor &operator=(HeightmapDescriptor &&_desc); + + /// \brief Copy Assignment operator. + /// \param[in] _desc The heightmap to set values from. + /// \return *this + public: HeightmapDescriptor &operator=(const HeightmapDescriptor &_desc); + + /// \brief Get the heightmap's name used for caching. + /// This is different from its unique `Heightmap::Name()`. + /// \return Heightmap's given name. Defaults to `Heightmap::Name()`. + public: const std::string &Name() const; + + /// \brief Set the heightmap's name. + /// \param[in] _name Heightmap's name. + public: void SetName(const std::string &_name); + + /// \brief Get the heightfield data. + /// \return Heightmap data. + public: std::shared_ptr Data() const; + + /// \brief Set the heightfield data. + /// \param[in] _data New data. + public: void SetData(const std::shared_ptr &_data); + + /// \brief Get the heightmap's scaling factor. + /// \return The heightmap's size. + public: ignition::math::Vector3d Size() const; + + /// \brief Set the heightmap's scaling factor. Defaults to 1x1x1. + /// \return The heightmap's size factor. + public: void SetSize(const ignition::math::Vector3d &_size); + + /// \brief Get the heightmap's position offset. + /// \return The heightmap's position offset. + public: ignition::math::Vector3d Position() const; + + /// \brief Set the heightmap's position offset. + /// \return The heightmap's position offset. + public: void SetPosition(const ignition::math::Vector3d &_position); + + /// \brief Get whether the heightmap uses terrain paging. + /// \return True if the heightmap uses terrain paging. + public: bool UseTerrainPaging() const; + + /// \brief Set whether the heightmap uses terrain paging. Defaults to false. + /// \param[in] _use True to use. + public: void SetUseTerrainPaging(bool _use); + + /// \brief Get the heightmap's sampling per datum. + /// \return The heightmap's sampling. + public: unsigned int Sampling() const; + + /// \brief Set the heightmap's sampling. Defaults to 1. + /// \param[in] _sampling The heightmap's sampling per datum. + public: void SetSampling(unsigned int _sampling); + + /// \brief Get the number of heightmap textures. + /// \return Number of heightmap textures contained in this Heightmap object. + public: uint64_t TextureCount() const; + + /// \brief Get a heightmap texture based on an index. + /// \param[in] _index Index of the heightmap texture. The index should be in + /// the range [0..TextureCount()). + /// \return Pointer to the heightmap texture. Nullptr if the index does not + /// exist. + /// \sa uint64_t TextureCount() const + public: const HeightmapTexture *TextureByIndex(uint64_t _index) const; + + /// \brief Add a heightmap texture. + /// \param[in] _texture Texture to add. + public: void AddTexture(const HeightmapTexture &_texture); + + /// \brief Get the number of heightmap blends. + /// \return Number of heightmap blends contained in this Heightmap object. + public: uint64_t BlendCount() const; + + /// \brief Get a heightmap blend based on an index. + /// \param[in] _index Index of the heightmap blend. The index should be in + /// the range [0..BlendCount()). + /// \return Pointer to the heightmap blend. Nullptr if the index does not + /// exist. + /// \sa uint64_t BlendCount() const + public: const HeightmapBlend *BlendByIndex(uint64_t _index) const; + + /// \brief Add a heightmap blend. + /// \param[in] _blend Blend to add. + public: void AddBlend(const HeightmapBlend &_blend); + + /// \internal + /// \brief Private data + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; +} +} +} +#endif diff --git a/include/gz/rendering/Image.hh b/include/gz/rendering/Image.hh new file mode 100644 index 000000000..249c34b0c --- /dev/null +++ b/include/gz/rendering/Image.hh @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_IMAGE_HH_ +#define GZ_RENDERING_IMAGE_HH_ + +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Image Image.hh ignition/rendering/Image.hh + /// \brief Encapsulates a raw image buffer and relevant properties + class IGNITION_RENDERING_VISIBLE Image + { + /// \brief Shared pointer to raw image buffer + typedef std::shared_ptr DataPtr; + + /// \brief Default constructor + public: Image() = default; + + /// \brief Constructor + /// \param[in] _width Image width in pixels + /// \param[in] _height Image height in pixels + /// \param[in] _format Image pixel format + public: Image(unsigned int _width, unsigned int _height, + PixelFormat _format); + + /// \brief Deconstructor + public: ~Image(); + + /// \brief Get image width in pixels + /// \return The image width in pixels + public: unsigned int Width() const; + + /// \brief Get image height in pixels + /// \return The image height in pixels + public: unsigned int Height() const; + + /// \brief Get image pixel format + /// \return The image pixel format + public: PixelFormat Format() const; + + /// \brief Get image channel depth + /// \return The image channel depth + public: unsigned int Depth() const; + + /// \brief Get image channel depth + /// \return The image channel depth + public: unsigned int MemorySize() const; + + /// \brief Get a const pointer to image data + /// \return The const pointer to image data + public: const void *Data() const; + + /// \brief Get a pointer to image data + /// \return The pointer to image data + public: void *Data(); + + /// \brief Get a const pointer to image data. The returned image buffer + /// will be statically cast to the given template type T. + /// \return The const pointer to image data + public: template + const T *Data() const; + + /// \brief Get a pointer to image data. The returned image buffer will be + /// statically cast to the given template type T. + /// \return The pointer to image data + public: template + T *Data(); + + /// \brief Image width in pixels + private: unsigned int width = 0; + + /// \brief Image height in pixels + private: unsigned int height = 0; + + /// \brief Image pixel format + private: PixelFormat format = PF_UNKNOWN; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Pointer to the image data + private: DataPtr data = nullptr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + + ////////////////////////////////////////////////// + template + const T *Image::Data() const + { + return static_cast(this->data.get()); + } + + ////////////////////////////////////////////////// + template + T *Image::Data() + { + return static_cast(this->data.get()); + } + } + } +} +#endif diff --git a/include/gz/rendering/InertiaVisual.hh b/include/gz/rendering/InertiaVisual.hh new file mode 100644 index 000000000..2b233aef0 --- /dev/null +++ b/include/gz/rendering/InertiaVisual.hh @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_INERTIAVISUAL_HH_ +#define IGNITION_RENDERING_INERTIAVISUAL_HH_ + +#include +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Object.hh" +#include "ignition/rendering/RenderTypes.hh" +#include "ignition/rendering/Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + /// \class InertiaVisual InertiaVisual.hh + /// ignition/rendering/InertiaVisual.hh + /// \brief Represents a inertia visual + class IGNITION_RENDERING_VISIBLE InertiaVisual : + public virtual Visual + { + /// \brief Destructor + public: virtual ~InertiaVisual() {} + + /// \brief Set the inertial component of the visual + /// \param[in] _inertial Inertial component of the visual + public: virtual void SetInertial( + const ignition::math::Inertiald &_inertial) = 0; + + /// \brief Load the Inertia visual from its pose and scale + /// \param[in] _pose Pose of the Inertia visual + /// \param[in] _scale Scale factor of the box visual + public: virtual void Load(const ignition::math::Pose3d &_pose, + const ignition::math::Vector3d &_scale) = 0; + + /// \brief Get the box visual + /// \return Pointer to the box visual + public: virtual VisualPtr BoxVisual() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/JointVisual.hh b/include/gz/rendering/JointVisual.hh new file mode 100644 index 000000000..d0cb89664 --- /dev/null +++ b/include/gz/rendering/JointVisual.hh @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_JOINTVISUAL_HH_ +#define IGNITION_RENDERING_JOINTVISUAL_HH_ + +#include + +#include + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Object.hh" +#include "ignition/rendering/RenderTypes.hh" +#include "ignition/rendering/Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Enum for JointVisual types + enum IGNITION_RENDERING_VISIBLE JointVisualType + { + /// \brief No type + JVT_NONE = 0, + + /// \brief Revolute joint type + JVT_REVOLUTE = 1, + + /// \brief Revolute2 joint type + JVT_REVOLUTE2 = 2, + + /// \brief Prismatic joint type + JVT_PRISMATIC = 3, + + /// \brief Universal joint type + JVT_UNIVERSAL = 4, + + /// \brief Ball joint type + JVT_BALL = 5, + + /// \brief Screw joint type + JVT_SCREW = 6, + + /// \brief Gearbox joint type + JVT_GEARBOX = 7, + + /// \brief Fixed joint type + JVT_FIXED = 8 + }; + + /// \class JointVisual JointVisual.hh + /// ignition/rendering/JointVisual.hh + /// \brief Represents a joint visual + class IGNITION_RENDERING_VISIBLE JointVisual : + public virtual Visual + { + /// \brief Destructor + public: virtual ~JointVisual() {} + + /// \brief Create an axis and attach it to the joint visual. + /// \param[in] _axis Axis vector. + /// \param[in] _useParentFrame True if axis vector is expressed in + /// parent frame. + public: virtual void SetAxis(const ignition::math::Vector3d &_axis, + bool _useParentFrame = false) = 0; + + /// \brief Get axis vector. + /// \return The axis vector. + public: virtual ignition::math::Vector3d Axis() const = 0; + + /// \brief Create a parent axis for hinge2 and universal joint types + /// and attach it to the joint visual. + /// \param[in] _axis Axis vector. + /// \param[in] _parentName Joint parent name. + /// \param[in] _useParentFrame True if axis vector is expressed in + /// parent frame. + public: virtual void SetParentAxis( + const ignition::math::Vector3d &_axis, + const std::string &_parentName, + bool _useParentFrame = false) = 0; + + /// \brief Get parent axis vector. + /// \return The parent axis vector. + public: virtual ignition::math::Vector3d ParentAxis() const = 0; + + /// \brief Update an axis' arrow visual. + /// \param[in] _axis Axis vector. + /// \param[in] _useParentFrame True if axis vector is expressed in + /// parent frame. + /// \return True if axis was updated else false. + public: virtual bool UpdateAxis(const ignition::math::Vector3d &_axis, + bool _useParentFrame = false) = 0; + + /// \brief Update the parent axis' arrow visual if it exists. + /// \param[in] _axis Axis vector. + /// \param[in] _useParentFrame True if axis vector is expressed in + /// parent frame. + /// \return True if parent axis was updated else false. + public: virtual bool UpdateParentAxis( + const ignition::math::Vector3d &_axis, + bool _useParentFrame = false) = 0; + + /// \brief Set type for joint visual. + /// \param[in] _type The type of visualisation for joint. + public: virtual void SetType(const JointVisualType _type) = 0; + + /// \brief Get joint visual type. + /// \return The joint visual type. + public: virtual JointVisualType Type() const = 0; + + /// \brief Get the JointVisual which is attached to the parent. + /// \return Parent axis visual. + public: virtual JointVisualPtr ParentAxisVisual() const = 0; + + /// \brief Get the arrow visual which represents the axis attached to the + /// child. + /// \return Arrow visual. + public: virtual ArrowVisualPtr ArrowVisual() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/LidarVisual.hh b/include/gz/rendering/LidarVisual.hh new file mode 100644 index 000000000..1d2314f30 --- /dev/null +++ b/include/gz/rendering/LidarVisual.hh @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_LIDARVISUAL_HH_ +#define IGNITION_RENDERING_LIDARVISUAL_HH_ + +#include +#include +#include +#include +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Visual.hh" +#include "ignition/rendering/Object.hh" +#include "ignition/rendering/RenderTypes.hh" +#include "ignition/rendering/Marker.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Enum for LidarVisual types + enum IGNITION_RENDERING_VISIBLE LidarVisualType + { + /// \brief No type + LVT_NONE = 0, + + /// \brief Ray line visual + LVT_RAY_LINES = 1, + + /// \brief Points visual + LVT_POINTS = 2, + + /// \brief Triangle strips visual + LVT_TRIANGLE_STRIPS = 3 + }; + + /// \class LidarVisual LidarVisual.hh ignition/rendering/LidarVisual + /// \brief A LidarVisual geometry class. The visual appearance is based + /// on the type specified. + class IGNITION_RENDERING_VISIBLE LidarVisual : + public virtual Visual + { + protected: LidarVisual(); + + /// \brief Destructor + public: virtual ~LidarVisual(); + + /// \brief Clear the points of the lidar visual + public: virtual void ClearPoints() = 0; + + /// \brief Update the Visual + public: virtual void Update() = 0; + + /// \brief Set lidar points to be visualised + /// \param[in] _points Vector of points representing distance of the ray + public: virtual void SetPoints(const std::vector &_points) = 0; + + /// \brief Set lidar points to be visualised + /// \param[in] _points Vector of points representing distance of the ray + /// \param[in] _colors Vector of colors for the rendered points + public: virtual void SetPoints(const std::vector &_points, + const std::vector &_colors) = 0; + + /// \brief Set minimum vertical angle + /// \param[in] _minVerticalAngle Minimum vertical angle + public: virtual void SetMinVerticalAngle( + double _minVerticalAngle) = 0; + + /// \brief Get minimum vertical angle + /// \return The minimum vertical angle value of the lidar visual + public: virtual double MinVerticalAngle() const = 0; + + /// \brief Set maximum vertical angle + /// \param[in] _maxVerticalAngle Maximum vertical angle value + public: virtual void SetMaxVerticalAngle( + double _maxVerticalAngle) = 0; + + /// \brief Get minimum vertical angle + /// \return The maximum vertical angle value of the lidar visual + public: virtual double MaxVerticalAngle() const = 0; + + /// \brief Set minimum horizontal angle + /// \param[in] _minHorizontalAngle Minimum horizontal angle value + public: virtual void SetMinHorizontalAngle( + double _minHorizontalAngle) = 0; + + /// \brief Get minimum horizontal angle + /// \return The minimum horizontal angle value of the lidar visual + public: virtual double MinHorizontalAngle() const = 0; + + /// \brief Set maximum horizontal angle + /// \param[in] _maxHorizontalAngle Maximum horizontal angle value + public: virtual void SetMaxHorizontalAngle( + double _maxHorizontalAngle) = 0; + + /// \brief Get maximum horizontal angle + /// \return The maximum horizontal angle value of the lidar visual + public: virtual double MaxHorizontalAngle() const = 0; + + /// \brief Set number of vertical rays + /// \param[in] _verticalRayCount Number of vertical rays + public: virtual void SetVerticalRayCount( + unsigned int _verticalRayCount) = 0; + + /// \brief Get number of vertical rays + /// \return The number of vertical rays + public: virtual unsigned int VerticalRayCount() const = 0; + + /// \brief Set number of horizontal rays + /// \return _horizontalRayCount Number of vertical rays + public: virtual void SetHorizontalRayCount( + unsigned int _horizontalRayCount) = 0; + + /// \brief Get number of horizontal rays + /// \return The number of horizontal rays + public: virtual unsigned int HorizontalRayCount() const = 0; + + /// \brief Set minimum range of lidar rays + /// \param[in] _minRange The minimum range for lidar rays + public: virtual void SetMinRange(double _minRange) = 0; + + /// \brief Get minimum range of lidar rays + /// \return The minimum range for lidar rays + public: virtual double MinRange() const = 0; + + /// \brief Set maximum range of lidar rays + /// \param[in] _maxRange The maximum range for lidar rays + public: virtual void SetMaxRange(double _maxRange) = 0; + + /// \brief Get maximum range of lidar rays + /// \return The maximum range for lidar rays + public: virtual double MaxRange() const = 0; + + /// \brief Set offset of visual + /// \param[in] _offset The offset of the lidar rays from visual origin + public: virtual void SetOffset( + const ignition::math::Pose3d _offset) = 0; + + /// \brief Get offset of visual + /// \return The offset of the lidar rays from visual origin + public: virtual ignition::math::Pose3d Offset() const = 0; + + /// \brief Get number of points in laser data + /// \return The number of points in the laser data + public: virtual unsigned int PointCount() const = 0; + + /// \brief Get the points in laser data + /// \return The points in the laser data + public: virtual std::vector Points() const = 0; + + /// \brief Set type for lidar visual + /// \param[in] _type The type of visualisation for lidar data + public: virtual void SetType(const LidarVisualType _type) = 0; + + /// \brief Get the type for lidar visual + /// \return The type for lidar visual + public: virtual LidarVisualType Type() const = 0; + + /// \brief Set size of the lidar visualization, + /// e.g. size of rasterized lidar points in pixels + /// \param[in] _size Size of the lidar visualization. + public: virtual void SetSize(double _size) = 0; + + /// \brief Get size of the lidar visualization + /// \return Size of the lidar visualization. + /// \sa SetSize + public: virtual double Size() const = 0; + + /// \brief Set if non-hitting rays will be displayed + /// (this does not work for TRIANGLE_STRIPS visual) + /// \param[in] _display Boolean value to display non hitting visuals + public: virtual void SetDisplayNonHitting(bool _display) = 0; + + /// \brief Get if non-hitting rays will be displayed + /// \return Boolean value if non-hitting rays will be displayed + public: virtual bool DisplayNonHitting() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Light.hh b/include/gz/rendering/Light.hh new file mode 100644 index 000000000..bb7dff151 --- /dev/null +++ b/include/gz/rendering/Light.hh @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_LIGHT_HH_ +#define GZ_RENDERING_LIGHT_HH_ + +#include "gz/math/Color.hh" +#include "gz/rendering/config.hh" +#include "gz/rendering/Node.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Light Light.hh ignition/rendering/Light.hh + /// \brief Represents a light source in the scene graph + class IGNITION_RENDERING_VISIBLE Light : + public virtual Node + { + /// \brief Deconstructor + public: virtual ~Light() { } + + /// \brief Get the diffuse color + /// \return The diffuse color + public: virtual math::Color DiffuseColor() const = 0; + + /// \brief Set the diffuse color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetDiffuseColor(double _r, double _g, double _b, + double _a = 1.0) = 0; + + /// \brief Set the diffuse color + /// \param[in] _color New diffuse color + public: virtual void SetDiffuseColor(const math::Color &_color) = 0; + + /// \brief Get the specular color + /// \return The specular color + public: virtual math::Color SpecularColor() const = 0; + + /// \brief Set the specular color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetSpecularColor(double _r, double _g, double _b, + double _a = 1.0) = 0; + + /// \brief Set the specular color + /// \param[in] _color New specular color + public: virtual void SetSpecularColor(const math::Color &_color) = 0; + + /// \brief Get the attenuation constant value + /// \return The attenuation constant value + public: virtual double AttenuationConstant() const = 0; + + /// \brief Set the attenuation constant value + /// \param[in] _value New attenuation constant value + public: virtual void SetAttenuationConstant(double _value) = 0; + + /// \brief Get the attenuation linear value + /// \return The attenuation linear value + public: virtual double AttenuationLinear() const = 0; + + /// \brief Set the attenuation linear value + /// \param[in] _value New attenuation linear value + public: virtual void SetAttenuationLinear(double _value) = 0; + + /// \brief Get the attenuation quadratic value + /// \return The attenuation quadratic value + public: virtual double AttenuationQuadratic() const = 0; + + /// \brief Set the attenuation quadratic value + /// \param[in] _value New attenuation quadratic value + public: virtual void SetAttenuationQuadratic(double _value) = 0; + + /// \brief Get the attenuation range + /// \return The attenuation range + public: virtual double AttenuationRange() const = 0; + + /// \brief Set the attenuation range + /// \param[in] _range New attenuation range + public: virtual void SetAttenuationRange(double _range) = 0; + + /// \brief Determine if this light cast shadows + /// \return True if this light cast shadows + public: virtual bool CastShadows() const = 0; + + /// \brief Specify if this light should cast shadows + /// \param[in] _castShadows True if this light cast shadows + public: virtual void SetCastShadows(bool _castShadows) = 0; + + /// \brief Get the light intensity + /// \return The light intensity + public: virtual double Intensity() const = 0; + + /// \brief Set the light intensity + /// \param[in] _intensity New light intensity + public: virtual void SetIntensity(double _intensity) = 0; + }; + + /// \class DirectionalLight Light.hh ignition/rendering/Light.hh + /// \brief Represents a infinite directional light + class IGNITION_RENDERING_VISIBLE DirectionalLight : + public virtual Light + { + /// \brief Destructor + public: virtual ~DirectionalLight() { } + + /// \brief Get the direction of the light + /// \return The direction of the light + public: virtual math::Vector3d Direction() const = 0; + + /// \brief Set the direction of the light + /// \param[in] _x X-component of direction vector + /// \param[in] _y Y-component of direction vector + /// \param[in] _z Z-component of direction vector + public: virtual void SetDirection(double _x, double _y, double _z) = 0; + + /// \brief Set the direction of the light + /// \param[in] _dir New direction vector + public: virtual void SetDirection(const math::Vector3d &_dir) = 0; + }; + + /// \class PointLight Light.hh ignition/rendering/Light.hh + /// \brief Represents a point light + class IGNITION_RENDERING_VISIBLE PointLight : + public virtual Light + { + /// \brief Deconstructor + public: virtual ~PointLight() { } + }; + + /// \class SpotLight Light.hh ignition/rendering/Light.hh + /// \brief Represents a spotlight + class IGNITION_RENDERING_VISIBLE SpotLight : + public virtual Light + { + /// \brief Deconstructor + public: virtual ~SpotLight() { } + + /// \brief Get direction of the light + /// \return The direction of the light + public: virtual math::Vector3d Direction() const = 0; + + /// \brief Set the direction of the light + /// \param[in] _x X-component of direction vector + /// \param[in] _y Y-component of direction vector + /// \param[in] _z Z-component of direction vector + public: virtual void SetDirection(double _x, double _y, double _z) = 0; + + /// \brief Set the direction of the light + /// \param[in] _dir New direction vector + public: virtual void SetDirection(const math::Vector3d &_dir) = 0; + + /// \brief Get the inner angle of the spotlight + /// \return The inner angle of the spotlight + public: virtual math::Angle InnerAngle() const = 0; + + /// \brief Set the inner angle of the spotlight + /// \param[in] _radians New inner angle of the spotlight in radians + public: virtual void SetInnerAngle(double _radians) = 0; + + /// \brief Set the inner angle of the spotlight + /// \param[in] _angle New inner angle of the spotlight + public: virtual void SetInnerAngle(const math::Angle &_angle) = 0; + + /// \brief Get the outer angle of the spotlight + /// \return The outer angle of the spotlight + public: virtual math::Angle OuterAngle() const = 0; + + /// \brief Set the outer angle of the spotlight + /// \param[in] _radians New outer angle of the spotlight in radians + public: virtual void SetOuterAngle(double _radians) = 0; + + /// \brief Set the outer angle of the spotlight + /// \param[in] _angle New outer angle of the spotlight + public: virtual void SetOuterAngle(const math::Angle &_angle) = 0; + + /// \brief Get the falloff of the spotlight + /// \return The falloff of the spotlight + public: virtual double Falloff() const = 0; + + /// \brief Set the falloff of the spotlight + /// \param[in] _falloff New falloff of the spotlight + public: virtual void SetFalloff(double _falloff) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/LightVisual.hh b/include/gz/rendering/LightVisual.hh new file mode 100644 index 000000000..cc8c6090f --- /dev/null +++ b/include/gz/rendering/LightVisual.hh @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_LIGHTVISUAL_HH_ +#define IGNITION_RENDERING_LIGHTVISUAL_HH_ + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Object.hh" +#include "ignition/rendering/RenderTypes.hh" +#include "ignition/rendering/Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + /// \brief Enum for LightVisual types + enum IGNITION_RENDERING_VISIBLE LightVisualType + { + /// \brief No type + LVT_EMPTY = 0, + + /// \brief Point light + LVT_POINT = 1, + + /// \brief Directional light + LVT_DIRECTIONAL = 2, + + /// \brief Spot light + LVT_SPOT = 3 + }; + + /// \class LightVisual LightVisual.hh ignition/rendering/LightVisual.hh + /// \brief Represents a light visual + class IGNITION_RENDERING_VISIBLE LightVisual : + public virtual Visual + { + /// \brief Descructor + public: virtual ~LightVisual() {} + + /// \brief set type of the light + /// \param[in] _type type of the light + public: virtual void SetType(LightVisualType _type) = 0; + + /// \brief Get light visual type + /// \return The light visual type + public: virtual LightVisualType Type() = 0; + + /// \brief Set inner angle for spot lights + /// \param[in] _innerAngle Inner angle + public: virtual void SetInnerAngle(double _innerAngle) = 0; + + /// \brief Get inner angle + /// \return The light inner angle + public: virtual double InnerAngle() = 0; + + /// \brief Set outer angle for spot lights + /// \param[in] _outerAngle Outer angle + public: virtual void SetOuterAngle(double _outerAngle) = 0; + + /// \brief Get outer angle + /// \return The light outer angle + public: virtual double OuterAngle() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Marker.hh b/include/gz/rendering/Marker.hh new file mode 100644 index 000000000..401b05892 --- /dev/null +++ b/include/gz/rendering/Marker.hh @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_MARKER_HH_ +#define GZ_RENDERING_MARKER_HH_ + +#include +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/Object.hh" +#include "gz/rendering/RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Enum for marker types + enum IGNITION_RENDERING_VISIBLE MarkerType + { + /// \brief No type + MT_NONE = 0, + + /// \brief Box geometry + MT_BOX = 1, + + /// \brief Cylinder geometry + MT_CYLINDER = 2, + + /// \brief Line strip primitive + MT_LINE_STRIP = 3, + + /// \brief Line list primitive + MT_LINE_LIST = 4, + + /// \brief Points primitive + MT_POINTS = 5, + + /// \brief Sphere geometry + MT_SPHERE = 6, + + /// \brief Text geometry + MT_TEXT = 7, + + /// \brief Triangle fan primitive + MT_TRIANGLE_FAN = 8, + + /// \brief Triangle list primitive + MT_TRIANGLE_LIST = 9, + + /// \brief Triangle strip primitive + MT_TRIANGLE_STRIP = 10, + + /// \brief Capsule geometry + MT_CAPSULE = 11, + }; + + /// \class Marker Marker.hh ignition/rendering/Marker + /// \brief A marker geometry class. The marker's visual appearance is based + /// on the marker type specified. + class IGNITION_RENDERING_VISIBLE Marker : + public virtual Geometry + { + protected: Marker(); + + /// \brief Destructor + public: virtual ~Marker(); + + /// \brief Set the lifetime of this Marker + /// \param[in] _lifetime The time at which the marker will be removed + public: virtual void SetLifetime( + const std::chrono::steady_clock::duration &_lifetime) = 0; + + /// \brief Get the lifetime of this Marker + /// \return The time at which the marker will be removed + public: virtual std::chrono::steady_clock::duration Lifetime() const = 0; + + /// \brief Set the layer of this Marker + /// \param[in] _layer Layer at which the marker will reside + public: virtual void SetLayer(int32_t _layer) = 0; + + /// \brief Get the layer of this Marker + /// \return The layer of the marker + public: virtual int32_t Layer() const = 0; + + /// \brief Set the render type of this Marker + /// \param[in] _markerType The desired render type + public: virtual void SetType( + const gz::rendering::MarkerType _markerType) = 0; + + /// \brief Get the render type of this Marker + /// \return The render type of the marker + public: virtual gz::rendering::MarkerType Type() const = 0; + + /// \brief Set size of the marker. Only affects MT_POINTS. + /// e.g. size of rasterized points in pixels + /// \param[in] _size Size of the marker + public: virtual void SetSize(double _size) = 0; + + /// \brief Get the size of the marker. + /// \return The size of the marker + /// \sa SetSize + public: virtual double Size() const = 0; + + /// \brief Clear the points of the marker, if applicable + public: virtual void ClearPoints() = 0; + + /// \brief Add a point with its respective color to the marker + /// \param[in] _x X coordinate + /// \param[in] _y Y coordinate + /// \param[in] _z Z coordinate + /// \param[in] _color The color the point is set to + public: virtual void AddPoint(double _x, + double _y, double _z, + const gz::math::Color &_color) = 0; + + /// \brief Add a point with its respective color to the marker + /// \param[in] _pt A vector containing the position of the point + /// \param[in] _color The color the point is set to + public: virtual void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color) = 0; + + /// \brief Set an existing point's vector + /// \param[in] _index The index of the point + /// \param[in] _value The new positional vector of the point + public: virtual void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value) = 0; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/Material.hh b/include/gz/rendering/Material.hh new file mode 100644 index 000000000..23931f456 --- /dev/null +++ b/include/gz/rendering/Material.hh @@ -0,0 +1,407 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_MATERIAL_HH_ +#define GZ_RENDERING_MATERIAL_HH_ + +#include +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Object.hh" +#include "gz/rendering/ShaderType.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief An enum for the type of material + enum IGNITION_RENDERING_VISIBLE MaterialType + { + /// \brief Classic shading, i.e. variants of Phong + MT_CLASSIC = 0, + + /// \brief Physically Based Shading + MT_PBS = 1 + }; + + /// \class Material Material.hh ignition/rendering/Material.hh + /// \brief Represents a surface material of a Geometry + class IGNITION_RENDERING_VISIBLE Material : + public virtual Object + { + /// \brief Deconstructor + public: virtual ~Material() { } + + /// \brief Determine if lighting affects this material + /// \return True if lighting affects this material + public: virtual bool LightingEnabled() const = 0; + + /// \brief Specify if lighting affects this material + /// \param[in] _enabled True if lighting affects this material + public: virtual void SetLightingEnabled(const bool _enabled) = 0; + + /// \brief Specify if depth buffer checking is enabled + /// \param[in] _enabled True if depth check is enabled + public: virtual void SetDepthCheckEnabled(bool _enabled) = 0; + + /// \brief Determine if depth buffer checking is enabled + /// \return True if depth check is enabled + public: virtual bool DepthCheckEnabled() const = 0; + + /// \brief Specify if depth buffer writing is enabled + /// \param[in] _enabled True if depth buffer writing is enabled + public: virtual void SetDepthWriteEnabled(bool _enabled) = 0; + + /// \brief Determine if depth buffer writing is enabled + /// \return True if depth buffer writing is enabled + public: virtual bool DepthWriteEnabled() const = 0; + + /// \brief Get the ambient color + /// \return The ambient color + public: virtual math::Color Ambient() const = 0; + + /// \brief Set the ambient color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetAmbient(const double _r, const double _g, + const double _b, const double _a = 1.0) = 0; + + /// \brief Set the ambient color + /// \param[in] _color New ambient color + public: virtual void SetAmbient(const math::Color &_color) = 0; + + /// \brief Get the diffuse color + /// \return The diffuse color + public: virtual math::Color Diffuse() const = 0; + + /// \brief Set the diffuse color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetDiffuse(const double _r, const double _g, + const double _b, const double _a = 1.0) = 0; + + /// \brief Set the diffuse color + /// \param[in] _color New diffuse color + public: virtual void SetDiffuse(const math::Color &_color) = 0; + + /// \brief Get the specular color + /// \return The specular color + public: virtual math::Color Specular() const = 0; + + /// \brief Set the specular color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetSpecular(const double _r, const double _g, + const double _b, const double _a = 1.0) = 0; + + /// \brief Set the specular color + /// \param[in] _color New specular color + public: virtual void SetSpecular(const math::Color &_color) = 0; + + /// \brief Get the emissive color + /// \return The emissive color + public: virtual math::Color Emissive() const = 0; + + /// \brief Set the emissive color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetEmissive(const double _r, const double _g, + const double _b, const double _a = 1.0) = 0; + + /// \brief Set the emissive color + /// \param[in] _color New emissive color + public: virtual void SetEmissive(const math::Color &_color) = 0; + + /// \brief Get the shininess value + /// \return The shininess value + public: virtual double Shininess() const = 0; + + /// \brief Set the shininess value + /// \param[in] _shininess New shininess value + public: virtual void SetShininess(const double _shininess) = 0; + + /// \brief Get the transparency value + /// \return The transparency value + public: virtual double Transparency() const = 0; + + /// \brief Configuration for Depth Material + /// \param[in] far Far distance for normalized output + /// \param[in] near Near distance for normalized output + public: virtual void SetDepthMaterial(const double far, + const double near) = 0; + + /// \brief Set the transparency value + /// \param[in] _transparency New transparency value + public: virtual void SetTransparency(const double _transparency) = 0; + + /// \brief Set the material to use the alpha channel from the textures + /// \param[in] _enabled Enable alpha channel based rendering + /// \param[in] _alpha Set the alpha threshold value + /// \param[in] _twoSided Enable two sided rendering + public: virtual void SetAlphaFromTexture(bool _enabled, + double _alpha = 0.5, bool _twoSided = true) = 0; + + /// \brief Get the enable alpha from textures + /// \return The enable alpha value + public: virtual bool TextureAlphaEnabled() const = 0; + + /// \brief Get the alpha threshold + /// \return The alpha threshold value + public: virtual double AlphaThreshold() const = 0; + + /// \brief Get the enable two sided rendering value + /// \return The enable two sided rendering value + public: virtual bool TwoSidedEnabled() const = 0; + + /// \brief Get the reflectivity value + /// \return The reflectivity value + public: virtual double Reflectivity() const = 0; + + /// \brief Set the reflectivity value + /// \param[in] _reflectivity New reflectivity value + public: virtual void SetReflectivity(const double _reflectivity) = 0; + + /// \brief Determine if this material casts shadows + /// \return True if this material casts shadows + public: virtual bool CastShadows() const = 0; + + /// \brief Specify if this material casts shadows + /// \param[in] _castShadows True if this material casts shadows + public: virtual void SetCastShadows(const bool _castShadows) = 0; + + /// \brief Determine if this material receives shadows + /// \return True if this material receives shadows + public: virtual bool ReceiveShadows() const = 0; + + /// \brief Specify if this material receives shadows + /// \param[in] _receiveShadows True if this material receives shadows + public: virtual void SetReceiveShadows(const bool _receiveShadows) = 0; + + /// \brief Determine if this material has a reflection + /// \return True if this material has a reflection + public: virtual bool ReflectionEnabled() const = 0; + + /// \brief Specify if this material has a reflection + /// \param[in] _enabled True if this material has a reflection + public: virtual void SetReflectionEnabled(const bool _enabled) = 0; + + /// \brief Determine if this material has a texture + /// \return True if this material has a texture + public: virtual bool HasTexture() const = 0; + + /// \brief Get the URI of the texture file + /// \return URI of the texture file + public: virtual std::string Texture() const = 0; + + /// \brief Set the material texture + /// \param[in] _texture URI of the new texture file + public: virtual void SetTexture(const std::string &_texture) = 0; + + /// \brief Removes any texture mapped to this material + public: virtual void ClearTexture() = 0; + + /// \brief Determine if this material has a normal map + /// \return True if this material has a normal map + public: virtual bool HasNormalMap() const = 0; + + /// \brief Get the URI of the normal map file + /// \return URI of the normal map file + public: virtual std::string NormalMap() const = 0; + + /// \brief Set the material normal map + /// \param[in] _normalMap URI of the new normal map file + public: virtual void SetNormalMap(const std::string &_normalMap) = 0; + + /// \brief Removes any normal map mapped to this material + public: virtual void ClearNormalMap() = 0; + + /// \brief Determine if this material has a roughness map + /// \return True if this material has a roughness map + public: virtual bool HasRoughnessMap() const = 0; + + /// \brief Get the URI of the roughness map file + /// \return URI of the roughness map file + public: virtual std::string RoughnessMap() const = 0; + + /// \brief Set the material roughness map + /// \param[in] _roughnessMap URI of the new roughness map file + public: virtual void SetRoughnessMap( + const std::string &_roughnessMap) = 0; + + /// \brief Removes any roughness map mapped to this material + public: virtual void ClearRoughnessMap() = 0; + + /// \brief Determine if this material has a metalness map + /// \return True if this material has a metalness map + public: virtual bool HasMetalnessMap() const = 0; + + /// \brief Get the URI of the metalness map file + /// \return URI of the metalness map file + public: virtual std::string MetalnessMap() const = 0; + + /// \brief Set the material metalness map + /// \param[in] _metalnessMap URI of the new metalness map file + public: virtual void SetMetalnessMap( + const std::string &_metalnessMap) = 0; + + /// \brief Removes any metalness map mapped to this material + public: virtual void ClearMetalnessMap() = 0; + + /// \brief Determine if this material has a environment map + /// \return True if this material has a environment map + public: virtual bool HasEnvironmentMap() const = 0; + + /// \brief Get the URI of the environment map file + /// \return URI of the environment map file + public: virtual std::string EnvironmentMap() const = 0; + + /// \brief Set the material environment map + /// \param[in] _metalnessMap URI of the new environment map file + public: virtual void SetEnvironmentMap( + const std::string &_metalnessMap) = 0; + + /// \brief Removes any environment map mapped to this material + public: virtual void ClearEnvironmentMap() = 0; + + /// \brief Determine if this material has an emissive map + /// \return True if this material has an emissive map + public: virtual bool HasEmissiveMap() const = 0; + + /// \brief Get the URI of the emissive map file + /// \return URI of the emissive map file + public: virtual std::string EmissiveMap() const = 0; + + /// \brief Set the material emissive map + /// \param[in] _emissiveMap URI of the new emissive map file + public: virtual void SetEmissiveMap( + const std::string &_emissiveMap) = 0; + + /// \brief Removes any emissive map mapped to this material + public: virtual void ClearEmissiveMap() = 0; + + /// \brief Determine if this material has a light map + /// \return True if this material has a light map + public: virtual bool HasLightMap() const = 0; + + /// \brief Get the URI of the light map file + /// \return URI of the light map file + public: virtual std::string LightMap() const = 0; + + /// \brief Get the texture coordinate set used by lightmap + /// \return texture coordinate set of the light map + public: virtual unsigned int LightMapTexCoordSet() const = 0; + + /// \brief Set the material light map + /// \param[in] _lightMap URI of the new light map file + /// \param[in] _uvSet Texture coordinate set to use + public: virtual void SetLightMap(const std::string &_lightMap, + unsigned int _uvSet = 0u) = 0; + + /// \brief Removes any light map mapped to this material + public: virtual void ClearLightMap() = 0; + + /// \brief Set the render order. When polygons are coplanar, you can get + /// problems with 'depth fighting' where the pixels from the two polys + /// compete for the same screen pixel. This param help to avoid this + /// problem. + /// \param[in] _renderOrder Render order to set to + public: virtual void SetRenderOrder(const float _renderOrder) = 0; + + /// \brief Get the render order value of this material. + /// \return Material render order + public: virtual float RenderOrder() const = 0; + + /// \brief Set the roughness value. Only affects material of type MT_PBS + /// \param[in] _roughness Roughness to set to + public: virtual void SetRoughness(const float _roughness) = 0; + + /// \brief Get the roughness value of this material. + /// \return Material roughness + public: virtual float Roughness() const = 0; + + /// \brief Set the metalness value. Only affects material of type MT_PBS + /// \param[in] _metalness Metalness to set to + public: virtual void SetMetalness(const float _metalness) = 0; + + /// \brief Get the metalness value of this material + /// \return Material metalness + public: virtual float Metalness() const = 0; + + /// \brief Removes any metalness map mapped to this material + public: virtual enum MaterialType Type() const = 0; + + /// \brief Get the ShaderType value + /// \return The ShaderType value + public: virtual enum ShaderType ShaderType() const = 0; + + /// \brief Set the ShaderType value + /// \param[in] _type New ShaderType value + public: virtual void SetShaderType(enum ShaderType _type) = 0; + + /// \brief Clone this material + /// \return New cloned material + public: virtual MaterialPtr Clone(const std::string &_name = "") + const = 0; + + /// \brief Copy properties from given Material + /// \param[in] _material Source Material to be copied from + public: virtual void CopyFrom(ConstMaterialPtr _material) = 0; + + /// \brief Copy properties from given Material + /// \param[in] _material Source Material to be copied from + public: virtual void CopyFrom(const common::Material &_material) = 0; + + /// \brief Get path to the vertex shader + /// \return Path to vertex shader + public: virtual std::string VertexShader() const = 0; + + /// \brief Get params for the vertex shader + /// \return editable parameters + public: virtual ShaderParamsPtr VertexShaderParams() = 0; + + /// \brief Set the vertex shader + /// \param[in] _path path to a file containing a glsl shader + public: virtual void SetVertexShader(const std::string &_path) = 0; + + /// \brief Get path to the fragment shader + /// \return Path to fragment shader + public: virtual std::string FragmentShader() const = 0; + + /// \brief Get params for the fragment shader + /// \return editable parameters + public: virtual ShaderParamsPtr FragmentShaderParams() = 0; + + /// \brief Set the fragment shader + /// \param[in] _path path to a file containing a glsl shader + public: virtual void SetFragmentShader(const std::string &_path) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Mesh.hh b/include/gz/rendering/Mesh.hh new file mode 100644 index 000000000..9cb0ae2f3 --- /dev/null +++ b/include/gz/rendering/Mesh.hh @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_MESH_HH_ +#define GZ_RENDERING_MESH_HH_ + +#include +#include +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/MeshDescriptor.hh" +#include "gz/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Mesh Mesh.hh ignition/rendering/Mesh + /// \brief Represents a collection of mesh geometries + class IGNITION_RENDERING_VISIBLE Mesh : + public virtual Geometry + { + /// \brief Destructor + public: virtual ~Mesh() { } + + /// \brief Check whether the mesh has skeleton + /// \return True if the mesh has skeleton + public: virtual bool HasSkeleton() const = 0; + + /// \brief Get the skeleton local transforms + /// \return Map of skeleton local transformations + /// * Map holding: + /// * Skeleton node names + /// * Local transformations of the skeleton nodes + public: virtual std::map + SkeletonLocalTransforms() const = 0; + + /// \brief Set transforms for the skeleton + /// \param[in] _tfs Map of skeleton local transformations + /// * Map holding: + /// * Skeleton node names + /// * Local transformations of the skeleton nodes + /// \return True if all the transformations are set to the skeleton + public: virtual void SetSkeletonLocalTransforms( + const std::map &_tfs) = 0; + + /// \brief Get skeleton node weight + /// \return Map of skeleton node name to its weight + /// * Map holding: + /// * Skeleton node names + /// * Weight the skeleton nodes + public: virtual std::unordered_map SkeletonWeights() + const = 0; + + /// \brief Set skeleton node weight + /// \param[in] _weights Map of skeleton node's name to its weight + /// * Map holding: + /// * Skeleton node names + /// * Weight the skeleton nodes + public: virtual void SetSkeletonWeights( + const std::unordered_map &_weights) = 0; + + /// \brief Set whether a skeleton animation should be enabled or not + /// \param[in] _name Name of animation + /// \param[in] _enabled True to enable animation, false to disable + /// \param[in] _loop True to loop animation + /// \param[in] _weight Weight of animation + public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, + bool _enabled, bool _loop = true, float _weight = 1.0) = 0; + + /// \brief Get whether a skeleton animation is enabled or not + /// \param[in] _name Name of animation + /// \return True is the skeleton animation is enabled, false otherwise + public: virtual bool SkeletonAnimationEnabled(const std::string &_name) + const = 0; + + /// \brief Play the active skeleton animation to the specified time + /// \param[in] _time Time to set the skeleton animation to + public: virtual void UpdateSkeletonAnimation( + std::chrono::steady_clock::duration _time) = 0; + + /// \brief Get the sub-mesh count + /// \return The sub-mesh count + public: virtual unsigned int SubMeshCount() const = 0; + + /// \brief Determine if has given sub-mesh + /// \param[in] _subMesh Sub-mesh in question + /// \return True if has given sub-mesh + public: virtual bool HasSubMesh(ConstSubMeshPtr _subMesh) const = 0; + + /// \brief Determine if has sub-mesh with given name + /// \param[in] _name Name of sub-mesh in question + /// \return True if has sub-mesh with given name + public: virtual bool HasSubMeshName(const std::string &_name) const = 0; + + /// \brief Get sub-mesh with given name + /// \param[in] _name Name of sub-mesh + /// \return The sub-mesh with the given name + public: virtual SubMeshPtr SubMeshByName( + const std::string &_name) const = 0; + + /// \brief Get sub-mesh at given index + /// \param[in] _index Index of sub-mesh + /// \return The sub-mesh at the given index + public: virtual SubMeshPtr SubMeshByIndex( + unsigned int _index) const = 0; + + /// \brief Set the mesh's mesh descriptor + /// \return The mesh's mesh descriptor + public: virtual void SetDescriptor(const MeshDescriptor &_desc) = 0; + + /// \brief Get the mesh's mesh descriptor + /// \return The mesh's mesh descriptor + public: virtual const MeshDescriptor &Descriptor() const = 0; + }; + + /// \class SubMesh Mesh.hh ignition/rendering/Mesh.hh + /// \brief Represents a single mesh geometry + class IGNITION_RENDERING_VISIBLE SubMesh : + public virtual Object + { + /// \brief Deconstructor + public: virtual ~SubMesh() { } + + /// \brief Get the currently assigned material + /// \return The currently assigned material + public: virtual MaterialPtr Material() const = 0; + + /// \brief Set the materials of this SubMesh. The specified material + /// will be retrieved from the parent Scene. If no material is registered + /// by the given name, no work will be done. + /// \param[in] _name Name of registered Material + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetMaterial(const std::string &_name, + bool _unique = true) = 0; + + /// \brief Set the materials of this SubMesh + /// \param[in] _material New Material to be assigned + /// \param[in] _unique True if the given material should be cloned + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/MeshDescriptor.hh b/include/gz/rendering/MeshDescriptor.hh new file mode 100644 index 000000000..5012165e8 --- /dev/null +++ b/include/gz/rendering/MeshDescriptor.hh @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_MESHDESCRIPTOR_HH_ +#define GZ_RENDERING_MESHDESCRIPTOR_HH_ + +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace common + { + class Mesh; + } +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \struct MeshDescriptor MeshDescriptor.hh + /// ignition/rendering/MeshDescriptor.hh + /// \brief Describes how a Mesh should be loaded + struct IGNITION_RENDERING_VISIBLE MeshDescriptor + { + /// \brief Constructor + public: MeshDescriptor(); + + /// \brief Constructor. A common::Mesh will be retrieved from the + /// MeshManager by the given name upon a call to Normalize. + /// \param[in] _meshName Name of the mesh to load + public: explicit MeshDescriptor(const std::string &_meshName); + + /// \brief Constructor + /// \param[in] _mesh Mesh to load + public: explicit MeshDescriptor(const common::Mesh *_mesh); + + /// \brief Ensures both the meshName and mesh member variables have been + /// assigned. If mesh is not null, it will be used to override the value + /// of meshName. + public: void Load(); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief common::Mesh object + public: const common::Mesh *mesh = nullptr; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Name of the registered Mesh + public: std::string meshName; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Name of the sub-mesh to be loaded. An empty string signifies + /// all sub-meshes should be loaded. + public: std::string subMeshName; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Denotes if the loaded sub-mesh vertices should be centered + public: bool centerSubMesh = false; + }; + } + } +} +#endif diff --git a/include/gz/rendering/MoveToHelper.hh b/include/gz/rendering/MoveToHelper.hh new file mode 100644 index 000000000..d6ca753eb --- /dev/null +++ b/include/gz/rendering/MoveToHelper.hh @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_MOVETOHELPER_HH_ +#define GZ_RENDERING_MOVETOHELPER_HH_ + +#include + +#include +#include + +#include +#include + +#include "gz/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + // Inline bracket to help doxygen filtering. + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // forward declaration + class MoveToHelperPrivate; + + /// \brief Helper class for animating a user camera to move to a target + /// entity + class IGNITION_RENDERING_VISIBLE MoveToHelper + { + public: MoveToHelper(); + + public: ~MoveToHelper(); + + /// \brief Move the camera to look at the specified target + /// param[in] _camera Camera to be moved + /// param[in] _target Target to look at + /// param[in] _duration Duration of the move to animation, in seconds. + /// param[in] _onAnimationComplete Callback function when animation is + /// complete + public: void MoveTo(const rendering::CameraPtr &_camera, + const rendering::NodePtr &_target, double _duration, + std::function _onAnimationComplete); + + /// \brief Move the camera to the specified pose. + /// param[in] _camera Camera to be moved + /// param[in] _target Pose to move to + /// param[in] _duration Duration of the move to animation, in seconds. + /// param[in] _onAnimationComplete Callback function when animation is + /// complete + public: void MoveTo(const rendering::CameraPtr &_camera, + const math::Pose3d &_target, double _duration, + std::function _onAnimationComplete); + + /// \brief Move the camera to look at the specified target + /// param[in] _camera Camera to be moved + /// param[in] _direction The pose to assume relative to the + /// entit(y/ies), (0, 0, 0) indicates to return the camera back to the + /// home pose originally loaded in from the sdf. + /// param[in] _duration Duration of the move to animation, in seconds. + /// param[in] _onAnimationComplete Callback function when animation is + /// complete + public: void LookDirection(const rendering::CameraPtr &_camera, + const math::Vector3d &_direction, const math::Vector3d &_lookAt, + double _duration, std::function _onAnimationComplete); + + /// \brief Add time to the animation. + /// \param[in] _time Time to add in seconds + public: void AddTime(double _time); + + /// \brief Get whether the move to helper is idle, i.e. no animation + /// is being executed. + /// \return True if idle, false otherwise + public: bool Idle() const; + + /// \brief Set the initial camera pose + /// param[in] _pose The init pose of the camera + public: void SetInitCameraPose(const math::Pose3d &_pose); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/Node.hh b/include/gz/rendering/Node.hh new file mode 100644 index 000000000..dee0f21bb --- /dev/null +++ b/include/gz/rendering/Node.hh @@ -0,0 +1,344 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_NODE_HH_ +#define GZ_RENDERING_NODE_HH_ + +#include +#include +#include + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Object.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Alias for a variant that can hold various types of data. + /// The first type of the variant is std::monostate in order to prevent + /// default-constructed variants from holding a type (a default-constructed + /// variant is returned when a user calls Node::UserData with a key that + /// doesn't exist for the node. In this case, since the key doesn't + /// exist, the variant that is returned shouldn't hold any types - an + /// "empty variant" should be returned for keys that don't exist) + using Variant = + std::variant; + + /// \class Node Node.hh ignition/rendering/Node.hh + /// \brief Represents a single posable node in the scene graph + class IGNITION_RENDERING_VISIBLE Node : + public virtual Object + { + /// \brief Deconstructor + public: virtual ~Node() { } + + /// \brief Determine if this Node is attached to another Node. + /// \return True if this Node has a parent Node + public: virtual bool HasParent() const = 0; + + /// \brief Get the parent Node + /// \return the parent Node + public: virtual NodePtr Parent() const = 0; + + /// \brief Detach this Node from its parent. If this + /// Node does not have a parent, no work will be done. + public: virtual void RemoveParent() = 0; + + /// \brief Get the local pose + /// \return The local pose + public: virtual math::Pose3d LocalPose() const = 0; + + /// \brief Get the initial local pose + /// \return The initial local pose + public: virtual math::Pose3d InitialLocalPose() const = 0; + + /// \brief Set the local pose + /// \param[in] _pose New local pose + public: virtual void SetLocalPose(const math::Pose3d &_pose) = 0; + + /// \brief Get the local position + /// \return The local position + public: virtual math::Vector3d LocalPosition() const = 0; + + /// \brief Set the local position + /// \param[in] _x X-coordinate + /// \param[in] _y Y-coordinate + /// \param[in] _z Z-coordinate + public: virtual void SetLocalPosition(double _x, double _y, + double _z) = 0; + + /// \brief Set the local position + /// \param[in] _position New local position + public: virtual void SetLocalPosition( + const math::Vector3d &_position) = 0; + + /// \brief Get the local rotation + /// \return The local rotation + public: virtual math::Quaterniond LocalRotation() const = 0; + + /// \brief Set the local rotation + /// \param[in] _r roll + /// \param[in] _p pitch + /// \param[in] _y yaw + public: virtual void SetLocalRotation(double _r, double _p, + double _y) = 0; + + /// \brief Set the local rotation + /// \param[in] _w W-coordinate + /// \param[in] _x X-coordinate + /// \param[in] _y Y-coordinate + /// \param[in] _z Z-coordinate + public: virtual void SetLocalRotation(double _w, double _x, double _y, + double _z) = 0; + + /// \brief Set the local rotation + /// \param[in] _rotation New local rotation + public: virtual void SetLocalRotation( + const math::Quaterniond &_rotation) = 0; + + /// \brief Get the world pose + /// \return The world pose + public: virtual math::Pose3d WorldPose() const = 0; + + /// \brief Set the world pose + /// \param[in] _pose New world pose + public: virtual void SetWorldPose(const math::Pose3d &_pose) = 0; + + /// \brief Get the world position + /// \return The world position + public: virtual math::Vector3d WorldPosition() const = 0; + + /// \brief Set the world position + /// \param[in] _x X-coordinate + /// \param[in] _y Y-coordinate + /// \param[in] _z Z-coordinate + public: virtual void SetWorldPosition(double _x, double _y, + double _z) = 0; + + /// \brief Set the world position + /// \param[in] _position New world position + public: virtual void SetWorldPosition( + const math::Vector3d &_position) = 0; + + /// \brief Get the world rotation + /// \return The world rotation + public: virtual math::Quaterniond WorldRotation() const = 0; + + /// \brief Set the world rotation + /// \param[in] _r roll + /// \param[in] _p pitch + /// \param[in] _y yaw + public: virtual void SetWorldRotation(double _r, double _p, + double _y) = 0; + + /// \brief Set the world rotation + /// \param[in] _w W-coordinate + /// \param[in] _x X-coordinate + /// \param[in] _y Y-coordinate + /// \param[in] _z Z-coordinate + public: virtual void SetWorldRotation(double _w, double _x, double _y, + double _z) = 0; + + /// \brief Set the world rotation + /// \param[in] _rotation New world rotation + public: virtual void SetWorldRotation( + const math::Quaterniond &_rotation) = 0; + + /// \brief Convert given world pose to local pose + /// \param[in] _pose World pose to be converted + public: virtual math::Pose3d WorldToLocal( + const math::Pose3d &_pose) const = 0; + + /// \brief Get position of origin + /// \return The position of the origin + public: virtual math::Vector3d Origin() const = 0; + + /// \brief Set position of origin. The position should be relative to the + /// original origin of the geometry. + /// \param[in] _x X-coordinate + /// \param[in] _y Y-coordinate + /// \param[in] _z Z-coordinate + public: virtual void SetOrigin(double _x, double _y, double _z) = 0; + + /// \brief Set position of origin. The position should be relative to the + /// original origin of the geometry. + /// \param[in] _origin New origin position + public: virtual void SetOrigin(const math::Vector3d &_origin) = 0; + + /// \brief Get the local scale + /// \return The local scale + public: virtual math::Vector3d LocalScale() const = 0; + + /// \brief Set the local scale. The given scale will be assigned to the + /// x, y, and z coordinates. + /// \param[in] _scale New local scale + public: virtual void SetLocalScale(double _scale) = 0; + + /// \brief Set the local scale + /// \param[in] _x New x-coordinate scale + /// \param[in] _y New y-coordinate scale + /// \param[in] _z New z-coordinate scale + public: virtual void SetLocalScale(double _x, double _y, double _z) = 0; + + /// \brief Set the local scale + /// \param[in] _scale New local scale + public: virtual void SetLocalScale(const math::Vector3d &_scale) = 0; + + /// \brief Get the world scale + /// \return The world scale + public: virtual math::Vector3d WorldScale() const = 0; + + /// \brief Set the world scale. The given scale will be assigned to the + /// x, y, and z coordinates. + /// \param[in] _scale New world scale + public: virtual void SetWorldScale(double _scale) = 0; + + /// \brief Set the world scale + /// \param[in] _x New x-coordinate scale + /// \param[in] _y New y-coordinate scale + /// \param[in] _z New z-coordinate scale + public: virtual void SetWorldScale(double _x, double _y, double _z) = 0; + + /// \brief Set the world scale + /// \param[in] _scale New world scale + public: virtual void SetWorldScale(const math::Vector3d &_scale) = 0; + + /// \brief Scale the current scale by the given scalar. The given scalar + /// will be assigned to the x, y, and z coordinates. + /// \param[in] _scale Scalar to alter the current scale + public: virtual void Scale(double _scale) = 0; + + /// \brief Scale the current scale by the given scalars + /// \param[in] _x Scalar to alter the current x-coordinate scale + /// \param[in] _y Scalar to alter the current y-coordinate scale + /// \param[in] _z Scalar to alter the current z-coordinate scale + public: virtual void Scale(double _x, double _y, double _z) = 0; + + /// \brief Scale the current scale by the given scalars + /// \param[in] _scale Scalars to alter the current scale + public: virtual void Scale(const math::Vector3d &_scale) = 0; + + /// \brief Determine if this visual inherits scale from this parent + /// \return True if this visual inherits scale from this parent + public: virtual bool InheritScale() const = 0; + + /// \brief Specify if this visual inherits scale from its parent + /// \param[in] _inherit True if this visual inherits scale from its parent + public: virtual void SetInheritScale(bool _inherit) = 0; + + /// \brief Get number of child nodes + /// \return The number of child nodes + public: virtual unsigned int ChildCount() const = 0; + + /// \brief Determine if given node is an attached child + /// \return True if given node is an attached child + public: virtual bool HasChild(ConstNodePtr _child) const = 0; + + /// \brief Determine if node with given ID is an attached child + /// \param[in] _id ID of the node in question + /// \return True if node with given ID is an attached child + public: virtual bool HasChildId(unsigned int _id) const = 0; + + /// \brief Determine if node with given name is an attached child + /// \param[in] _name Name of the node in question + /// \return True if node with given name is an attached child + public: virtual bool HasChildName(const std::string &_name) const = 0; + + /// \brief Get node with given ID. If no child exists with given ID, NULL + /// will be returned. + /// \param[in] _id ID of the desired node + /// \return The specified node + public: virtual NodePtr ChildById(unsigned int _id) const = 0; + + /// \brief Get node with given name. If no child exists with given name, + /// NULL will be returned. + /// \param[in] _name Name of the desired node + /// \return The specified node + public: virtual NodePtr ChildByName( + const std::string &_name) const = 0; + + /// \brief Get node at given index. If no child exists at given index, + /// NULL will be returned. + /// \param[in] _index Index of the desired node + /// \return The specified node + public: virtual NodePtr ChildByIndex(unsigned int _index) const = 0; + + /// \brief Add the given node to this node. If the given node is + /// already a child, no work will be done. + /// \param[in] _child Child node to be added + public: virtual void AddChild(NodePtr _child) = 0; + + /// \brief Remove (detach) the given node from this node. If the given + /// node is not a child of this node, no work will be done. + /// \param[in] _child Child node to be removed + /// \return The removed child node + public: virtual NodePtr RemoveChild(NodePtr _child) = 0; + + /// \brief Remove (detach) the node with the given ID from this node. + /// If the specified node is not a child of this node, no work will be + /// done. + /// \param[in] _id ID of the child node to be removed + /// \return The removed child node + public: virtual NodePtr RemoveChildById(unsigned int _id) = 0; + + /// \brief Remove (detach) the node with the given name from this node. + /// If the specified node is not a child of this node, no work will be + /// done. + /// \param[in] _name Name of the child node to be removed + /// \return The removed child node + public: virtual NodePtr RemoveChildByName(const std::string &_name) = 0; + + /// \brief Remove (detach) the node at the given index from this node. + /// If the specified node is not a child of this node, no work will be + /// done. + /// \param[in] _index Index of the child node to be removed + /// \return The removed child node + public: virtual NodePtr RemoveChildByIndex(unsigned int _index) = 0; + + /// \brief Remove all child nodes from this node + /// This detaches all the child nodes but does not destroy them + public: virtual void RemoveChildren() = 0; + + /// \brief Store any custom data associated with this node + /// \param[in] _key Unique key + /// \param[in] _value Value in any type + public: virtual void SetUserData( + const std::string &_key, Variant _value) = 0; + + /// \brief Get custom data stored in this node + /// \param[in] _key Unique key + /// \return Value in any type. If _key does not exist for the node, an + /// empty variant is returned (i.e., no data). + public: virtual Variant UserData(const std::string &_key) const = 0; + + /// \brief Check if node has custom data + /// \param[in] _key Unique key + /// \return True if node has custom data with the specified key + public: virtual bool HasUserData(const std::string &_key) const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Object.hh b/include/gz/rendering/Object.hh new file mode 100644 index 000000000..1d33a29b5 --- /dev/null +++ b/include/gz/rendering/Object.hh @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OBJECT_HH_ +#define GZ_RENDERING_OBJECT_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Object Object.hh ignition/rendering/Object.hh + /// \brief Represents an object present in the scene graph. This includes + /// sub-meshes, materials, render targets, as well as posable nodes. + class IGNITION_RENDERING_VISIBLE Object + { + /// \brief Destructor + public: virtual ~Object() { } + + /// \brief Get the object ID. This ID will be unique across all objects + /// inside a given scene, but necessarily true for objects across + /// different scenes. + /// \return The object ID + public: virtual unsigned int Id() const = 0; + + /// \brief Get the object name. This name will be unique across all + /// objects inside a given scene, but necessarily true for objects across + /// different scenes. + /// \return The object name + public: virtual std::string Name() const = 0; + + /// \brief Get the Scene that created this object. + /// \return The parent scene + public: virtual ScenePtr Scene() const = 0; + + /// \brief Prepare this object and any of its children for rendering. + /// This should be called for each object in a scene just before + /// rendering, which can be achieved by a single call to Scene::PreRender + public: virtual void PreRender() = 0; + + /// \brief Post process this object and any of its children after + /// rendering. + public: virtual void PostRender() = 0; + + /// \brief Destroy any resources associated with this object. Invoking + /// any other functions after destroying an object will result in + /// undefined behavior. + public: virtual void Destroy() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/OrbitViewController.hh b/include/gz/rendering/OrbitViewController.hh new file mode 100644 index 000000000..5ca370256 --- /dev/null +++ b/include/gz/rendering/OrbitViewController.hh @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_ORBITVIEWCONTROLLER_HH_ +#define GZ_RENDERING_ORBITVIEWCONTROLLER_HH_ + +#include + +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/ViewController.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations + class OrbitViewControllerPrivate; + + /// \class OrbitViewController OrbitViewController.hh + /// ignition/rendering/OrbitViewController.hh + /// \brief A camera view controller + class IGNITION_RENDERING_VISIBLE OrbitViewController + : public virtual ViewController + { + /// \brief Deconstructor + public: OrbitViewController(); + + /// \brief Deconstructor + public: explicit OrbitViewController(const CameraPtr &_camera); + + /// \brief Deconstructor + public: virtual ~OrbitViewController(); + + /// \brief Set the camera that will be controlled by this view controller. + /// \param[in] _camera Camera to control + public: virtual void SetCamera(const CameraPtr &_camera); + + /// \brief Get the camera that is controlled by this view controller. + /// \return Camera being controlled + public: virtual CameraPtr Camera() const; + + /// \brief Set target point for pan, zoom, oribit + /// \param[in] _target Target point in world coordinates + public: virtual void SetTarget(const math::Vector3d &_target); + + /// \brief Get target point for pan, zoom, oribit + /// \return target point in world coordinates + public: virtual math::Vector3d &Target() const; + + /// \brief Set zoom amount + /// \param[in] _value Camera zoon value, e.g. mouse scroll delta + public: virtual void Zoom(const double _value); + + /// \brief Set camera pan (translational movement) around target point. + /// \param[in] _value Pan amount in image plane, e.g. mouse drag delta. + public: virtual void Pan(const math::Vector2d &_value); + + /// \brief Set camera orbit (rotational movement) around target point. + /// \param[in] _value robit amount in image plane, e.g. mouse drag delta + public: virtual void Orbit(const math::Vector2d &_value); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Private data pointer + public: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/OrthoViewController.hh b/include/gz/rendering/OrthoViewController.hh new file mode 100644 index 000000000..59d7b05f9 --- /dev/null +++ b/include/gz/rendering/OrthoViewController.hh @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef IGNITION_RENDERING_ORTHOVIEWCONTROLLER_HH_ +#define IGNITION_RENDERING_ORTHOVIEWCONTROLLER_HH_ + +#include +#include +#include + +#include "ignition/rendering/ViewController.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declare private data pointer. + class OrthoViewControllerPrivate; + + /// \class OrthoViewController OrthoViewController.hh + /// \brief Orthographic view controller + class IGNITION_RENDERING_VISIBLE OrthoViewController + : public virtual ViewController + { + /// \brief Constructor + public: OrthoViewController(); + + /// \brief Constructor. + /// \param[in] _camera Pointer to the camera to control. + public: explicit OrthoViewController(const CameraPtr &_camera); + + /// \brief Destructor. + public: virtual ~OrthoViewController(); + + /// \brief Set the camera that will be controlled by this view controller. + /// \param[in] _camera Camera to control + public: virtual void SetCamera(const CameraPtr &_camera); + + /// \brief Get the camera that is controlled by this view controller. + /// \return Camera being controlled + public: virtual CameraPtr Camera() const; + + /// \brief Set target point for pan, zoom, oribit + /// \param[in] _target Target point in world coordinates + public: virtual void SetTarget(const math::Vector3d &_target); + + /// \brief Get target point for pan, zoom, oribit + /// \return target point in world coordinates + public: virtual const math::Vector3d &Target() const; + + /// \brief Set zoom amount + /// \param[in] _value Camera zoon value, e.g. mouse scroll delta + public: virtual void Zoom(const double _value); + + /// \brief Set camera pan (translational movement) around target point. + /// \param[in] _value Pan amount in image plane, e.g. mouse drag delta. + public: virtual void Pan(const math::Vector2d &_value); + + /// \brief Set camera orbit (rotational movement) around target point. + /// \param[in] _value robit amount in image plane, e.g. mouse drag delta + public: virtual void Orbit(const math::Vector2d &_value); + + /// \brief Resize and update the camera projection matrix + /// \param[in] _width Image width + /// \param[in] _height Image height + private: virtual void Resize(const unsigned int _width, + const unsigned int _height); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Private data pointer + public: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/ParticleEmitter.hh b/include/gz/rendering/ParticleEmitter.hh new file mode 100644 index 000000000..3cd481b01 --- /dev/null +++ b/include/gz/rendering/ParticleEmitter.hh @@ -0,0 +1,263 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_PARTICLEEMITTER_HH_ +#define IGNITION_RENDERING_PARTICLEEMITTER_HH_ + +#include +#include "ignition/math/Color.hh" +#include "ignition/math/Pose3.hh" +#include "ignition/math/Vector3.hh" +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Export.hh" +#include "ignition/rendering/RenderTypes.hh" +#include "ignition/rendering/Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Enum for emitter types. + enum IGNITION_RENDERING_VISIBLE EmitterType + { + /// \brief Point emitter. + EM_POINT = 0, + + /// \brief Box emitter. + EM_BOX = 1, + + /// \brief Cylinder emitter. + EM_CYLINDER = 2, + + /// \brief Ellipsoid emitter. + EM_ELLIPSOID = 3, + + /// \brief Total number of emitters (keep always at the end). + EM_NUM_EMITTERS = 4, + }; + + /// \class ParticleEmitter ParticleEmitter.hh + /// ignition/rendering/ParticleEmitter.hh + // + /// \brief Class to manage a particle emitter. + class IGNITION_RENDERING_VISIBLE ParticleEmitter : + public virtual Visual + { + /// \brief Destructor + public: virtual ~ParticleEmitter() {} + + /// \brief \brief Get the emitter type. + /// \return Emitter type. + /// \sa EmitterType. + /// \sa SetType. + public: virtual EmitterType Type() const = 0; + + /// \brief \brief Set the emitter type. + /// Default value is EM_POINT. + /// \param[in] _type Emitter type. + /// \sa EmitterType. + /// \sa Type. + public: virtual void SetType(const EmitterType _type) = 0; + + /// \brief Get the size of the emitter where the particles are sampled. + /// \return The emitter size. See SetEmitterSize() for the interpretation + /// of the dimensions depending on the emitter type. + /// \sa SetEmitterSize + public: virtual ignition::math::Vector3d EmitterSize() const = 0; + + /// \brief Set the size of the emitter where the particles are sampled. + /// Default value is (1, 1, 1). + /// Note that the interpretation of the emitter area varies depending on + /// the emmiter type: + /// - EM_POINT: The area is ignored. + /// - EM_BOX: The area is interpreted as width X height X depth. + /// - EM_CYLINDER: The area is interpreted as the bounding box of the + /// cilinder. The cylinder is oriented along the Z-axis. + /// - EM_ELLIPSOID: The area is interpreted as the bounding box of an + /// ellipsoid shaped area, i.e. a sphere or + /// squashed-sphere area. The parameters are again + /// identical to EM_BOX, except that the dimensions + /// describe the widest points along each of the axes. + /// \param[in] _size Size of the emitter (width, height, depth). + /// \sa EmitterSize + public: virtual void SetEmitterSize( + const ignition::math::Vector3d &_size) = 0; + + /// \brief Get how many particles per second should be emitted. + /// \return Particles per second. + /// \sa SetRate + public: virtual double Rate() const = 0; + + /// \brief Set how many particles per second should be emitted. + /// Default value is 10. + /// \param[in] _rate Particles per second. + /// \sa Rate + public: virtual void SetRate(double _rate) = 0; + + /// \brief Get the number of seconds the emitter is active. + /// A value of 0 means infinite duration. + /// \return Total duration of the emitter (seconds). + /// \sa SetDuration + public: virtual double Duration() const = 0; + + /// \brief Set the number of seconds the emitter is active. + /// A value of 0 means infinite duration. + /// Default value is 0. + /// \param[in] _duration Total duration of the emitter (seconds). + /// \sa Duration + public: virtual void SetDuration(double _duration) = 0; + + /// \brief Is the particle emitter enabled? + /// \return True when enabled or false otherwise. + /// \sa SetEmitting + public: virtual bool Emitting() const = 0; + + /// \brief This is used to turn on or off particle emission. + /// Default value is false. + /// \param[in] _enable True for enabling the emission or false otherwise. + /// \sa Emitting + public: virtual void SetEmitting(bool _enable) = 0; + + /// \brief Get the particle dimensions (width, height, depth). + /// \return Particle dimensions. + /// \sa SetParticleSize + public: virtual ignition::math::Vector3d ParticleSize() const = 0; + + /// \brief Set the particle dimensions (width, height, depth). + /// Default value is {1, 1, 1}. + /// \param[in] _size Particle dimensions. + /// \sa ParticleSize + public: virtual void SetParticleSize( + const ignition::math::Vector3d &_size) = 0; + + /// \brief Get the number of seconds each particle will ’live’ for before + /// being destroyed. + /// \return Lifetime of each particle (seconds). + /// \sa SetLifetime + public: virtual double Lifetime() const = 0; + + /// \brief Set the number of seconds each particle will ’live’ for before + /// being destroyed. + /// Default value is 5. + /// \param[in] _lifetime Lifetime of each particle (seconds). + /// \sa Lifetime + public: virtual void SetLifetime(double _lifetime) = 0; + + /// \brief Get the material which all particles in the emitter will use. + /// \return The material pointer. + /// \sa SetMaterial + public: virtual MaterialPtr Material() const = 0; + + /// \brief Sets the material which all particles in the emitter will use. + /// \param[in] _material The material pointer. + /// \sa Material + public: virtual void SetMaterial(const MaterialPtr &_material) = 0; + + /// \brief Get the minimum velocity each particle is emitted (m/s). + /// \return Minimum velocity. + /// \sa MaxVelocity + /// \sa SetVelocityRange + public: virtual double MinVelocity() const = 0; + + /// \brief Get the maximum velocity each particle is emitted (m/s). + /// \return Maximum velocity. + /// \sa MinVelocity + /// \sa SetVelocityRange + public: virtual double MaxVelocity() const = 0; + + /// \brief Set a velocity range and each particle is emitted with a + /// random velocity within this range (m/s). + /// Default value is 1 for both velocities. + /// \param[in] _minVelocity Minimum velocity. + /// \param[in] _maxVelocity Maximum velocity. + /// \sa MinVelocity + /// \sa MaxVelocity + public: virtual void SetVelocityRange(double _minVelocity, + double _maxVelocity) = 0; + + /// \brief Get the starting color of the particles. + /// \return Start color. + /// \sa ColorEnd + /// \sa SetColorRange + public: virtual ignition::math::Color ColorStart() const = 0; + + /// \brief Get the end color of the particles. + /// \return End color. + /// \sa ColorStart + /// \sa SetColorRange + public: virtual ignition::math::Color ColorEnd() const = 0; + + /// \brief Sets a color for all particle emitted. + /// The actual color will be interpolated between these two colors + /// Color::White is the default color for the particles unless a specific + /// function is used. + /// Note that this function overrides the particle colors set with + /// SetColorRangeImage(). + /// \param[in] _colorStart Start color. + /// \param[in] _colorEnd End color. + /// \sa ColorStart + /// \sa ColorEnd + public: virtual void SetColorRange( + const ignition::math::Color &_colorStart, + const ignition::math::Color &_colorEnd) = 0; + + /// \brief Get the amount by which to scale the particles in both x and y + /// direction per second. + /// Default value is 1. + /// \return The scale rate. + /// \sa SetScaleRate + public: virtual double ScaleRate() const = 0; + + /// \brief Set the amount by which to scale the particles in both x and y + /// direction per second. + /// \param[in] _scaleRate The scale rate. + /// \sa ScaleRate + public: virtual void SetScaleRate(double _scaleRate) = 0; + + /// \brief Get the path to the color image used as an affector. + /// \return The color image name or empty string if the image is not set. + /// \sa SetColorRangeImage + public: virtual std::string ColorRangeImage() const = 0; + + /// \brief Set the path to the color image used as an affector. This + /// affector modifies the color of particles in flight. The colors are + /// taken from a specified image file. The range of color values begins + /// from the left side of the image and move to the right over the + /// lifetime of the particle, therefore only the horizontal dimension of + /// the image is used. + /// Note that this function overrides the particle colors set with + /// SetColorRange(). + /// \param[in] _image The color image name. + /// \sa ColorRangeImage + public: virtual void SetColorRangeImage(const std::string &_image) = 0; + + /// \brief Get the particle scatter ratio. + /// \return The particle scatter ratio. + /// \sa SetParticleScatterRatio + public: virtual float ParticleScatterRatio() const = 0; + + /// \brief Set the particle scatter ratio. + /// \param[in] _ratio The scatter ratio. The particle emitter's scatter + /// ratio will only be set to _ratio if _ratio > 0. + /// \sa ParticleScatterRatio + public: virtual void SetParticleScatterRatio(float _ratio) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/PixelFormat.hh b/include/gz/rendering/PixelFormat.hh new file mode 100644 index 000000000..dfd20b371 --- /dev/null +++ b/include/gz/rendering/PixelFormat.hh @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_PIXELFORMAT_HH_ +#define GZ_RENDERING_PIXELFORMAT_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \enum PixelFormat PixelFormat.hh ignition/rendering/PixelFormat.hh + /// \brief Image pixel format types + enum IGNITION_RENDERING_VISIBLE PixelFormat + { + /// < Unknown or errant type + PF_UNKNOWN = 0, + /// < Grayscale, 1-byte per channel + PF_L8 = 1, + /// < RGB, 1-byte per channel + PF_R8G8B8 = 2, + /// < BGR, 1-byte per channel + PF_B8G8R8 = 3, + /// < Bayer RGGB, 1-byte per channel + PF_BAYER_RGGB8 = 4, + /// < Bayer BGGR, 1-byte per channel + PF_BAYER_BGGR8 = 5, + /// < Bayer GBGR, 1-byte per channel + PF_BAYER_GBGR8 = 6, + /// < Bayer GRGB, 1-byte per channel + PF_BAYER_GRGB8 = 7, + // Float32 format one channel + PF_FLOAT32_R = 8, + // Float32 format and RGB + PF_FLOAT32_RGBA = 9, + // Float32 format and RGB + PF_FLOAT32_RGB = 10, + // 16 bit single channel + PF_L16 = 11, + /// < RGBA, 1-byte per channel + PF_R8G8B8A8 = 12, + /// < Number of pixel format types + PF_COUNT = 13 + }; + + /// \class PixelUtil PixelFormat.hh ignition/rendering/PixelFormat.hh + /// \brief Provides supporting functions for PixelFormat enum + class IGNITION_RENDERING_VISIBLE PixelUtil + { + /// \brief Determine if given format is valid PixelFormat enum + /// \param[in] _format Enum value to be evaluated + public: static bool IsValid(PixelFormat _format); + + /// \brief Sanitize given format. If the given value is invalid, + /// PF_UNKNOWN will be returned, otherwise input will be returned + /// unchanged. + /// \param[in] _format Image pixel format to be sanitized + /// \return The sanitized pixel format + public: static PixelFormat Sanitize(PixelFormat _format); + + /// \brief Get human-readable name for pixel format value. + /// \param[in] _format Image pixel format + /// \return The format name + public: static std::string Name(PixelFormat _format); + + /// \brief Get number of channels for given format. If an invalid format + /// is given, 0 will be returned. + /// \param[in] _format Image pixel format + /// \return The channel count + public: static unsigned int ChannelCount(PixelFormat _format); + + /// \brief Get number of bytes per channel for given format. If an invalid + /// format is given, 0 will be returned. + /// \param[in] _format Image pixel format + /// \return The number of bytes per channel + public: static unsigned int BytesPerChannel(PixelFormat _format); + + /// \brief Get number of bytes per pixel for given format. If an invalid + /// format is given, 0 will be returned. This is simply the product of + /// GetChannelCount and GetBytesPerChannel. + /// \return The number of bytes per pixel + public: static unsigned int BytesPerPixel(PixelFormat _format); + + /// \brief Get total memory size in bytes for an image with the given + /// format and dimensions. If an invalid format is given, 0 will be + /// returned. This is simply the product of GetBytesPerPixel, _width, + /// and, _height. + /// \param[in] _format Image pixel format + /// \param[in] _width Image width in pixels + /// \param[in] _height Image height in pixels + /// \return The number of bytes per pixel + public: static unsigned int MemorySize(PixelFormat _format, + unsigned int _width, unsigned int _height); + + /// \brief Get enum value by human-readable name. The given string should + /// match watch is returned by GetName. If an invalid name is given, + /// PF_UNKNOWN will be returned. + /// \param[in] _name Name of the pixel format to be retrieved + /// \return The specified PixelFormat enum value + public: static PixelFormat Enum(const std::string &_name); + + /// \brief Array of human-readable names for each PixelFormat + private: static const char *names[PF_COUNT]; + + /// \brief Array of channel counts for each PixelFormat + private: static const unsigned char channelCounts[PF_COUNT]; + + /// \brief Array of bytes per channel for each PixelFormat + private: static const unsigned char channelByteCounts[PF_COUNT]; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RayQuery.hh b/include/gz/rendering/RayQuery.hh new file mode 100644 index 000000000..4beca9b6c --- /dev/null +++ b/include/gz/rendering/RayQuery.hh @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RAYQUERY_HH_ +#define GZ_RENDERING_RAYQUERY_HH_ + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief A class that stores ray query intersection results. + class IGNITION_RENDERING_VISIBLE RayQueryResult + { + /// \brief Intersection distance + public: double distance = -1; + + /// \brief Intersection point in 3d space + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public: math::Vector3d point; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Intersected object id + public: unsigned int objectId = 0; + + /// \brief Returns false if result is not valid + public: operator bool() const + { + return distance > 0; + } + + /// \brief Returns false if result is not valid + public: operator bool() + { + return distance > 0; + } + }; + + /// \class RayQuery RayQuery.hh ignition/rendering/RayQuery.hh + /// \brief A Ray Query class used for computing ray object intersections + class IGNITION_RENDERING_VISIBLE RayQuery + : public virtual Object + { + /// \brief Destructor + public: virtual ~RayQuery() { } + + /// \brief Set ray origin + /// \param[in] _origin Ray origin + public: virtual void SetOrigin(const math::Vector3d &_origin) = 0; + + /// \brief Get ray origin + /// \return Ray origin + public: virtual math::Vector3d Origin() const = 0; + + /// \brief Set ray direction + /// \param[in] _dir Ray origin + public: virtual void SetDirection(const math::Vector3d &_dir) = 0; + + /// \brief Get ray direction + /// \return Ray direction. + public: virtual math::Vector3d Direction() const = 0; + + /// \brief Create the ray query from camera + /// \param[in] _camera Camera to construct ray + /// \param[in] _coord normalized device coords [-1, +1] + public: virtual void SetFromCamera(const CameraPtr &_camera, + const math::Vector2d &_coord) = 0; + + /// \brief Compute intersections + /// \return A vector of intersection results + public: virtual RayQueryResult ClosestPoint() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderEngine.hh b/include/gz/rendering/RenderEngine.hh new file mode 100644 index 000000000..54f24dd92 --- /dev/null +++ b/include/gz/rendering/RenderEngine.hh @@ -0,0 +1,185 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERENGINE_HH_ +#define GZ_RENDERING_RENDERENGINE_HH_ + +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class RenderEngine RenderEngine.hh ignition/rendering/RenderEngine.hh + /// \brief An abstract interface to a concrete render-engine. A + /// RenderEngine is responsible for initializing a render-engine as well as + /// creating, storing, and destroying scenes. + class IGNITION_RENDERING_VISIBLE RenderEngine + { + /// \brief Deconstructor + public: virtual ~RenderEngine() { } + + /// \brief Load any necessary resources to set up render-engine. This + /// should called before any other function. + /// \param[in] _params Parameters to be passed to the underlying + /// rendering engine. + /// \return True if the render-engine was successfully loaded + public: virtual bool Load( + const std::map &_params = {}) = 0; + + /// \brief Initialize the render-engine. This should be called immediately + /// after a successful call to Load. + /// \return True if the render-engine was successfully initialized + public: virtual bool Init() = 0; + + /// \brief Destroys all scenes created by render-engine and releases all + /// loaded resources. This should be called when the given render-engine + /// will no longer be used during runtime. + /// \return True if the render-engine was successfully destroyed + public: virtual void Destroy() = 0; + + // TODO(anyone): merge with Destroy + public: virtual bool Fini() = 0; + + /// \brief Determines if the render-engine has been loaded. + /// \return True if the render-engine is loaded + public: virtual bool IsLoaded() const = 0; + + /// \brief Determines if the render-engine has been initialized. + /// \return True if the render-engine is initialized + public: virtual bool IsInitialized() const = 0; + + /// \brief Determines if the render-engine can be used. Despite loading + /// and initializing the render-engine, it may not be possible to use due + /// to hardware capabilities of the runtime system. + /// \return True if the render-engine can be used + public: virtual bool IsEnabled() const = 0; + + /// \brief Get name of the render-engine. + /// \return The render-engine name + public: virtual std::string Name() const = 0; + + /// \brief Get the number of scenes actively managed by this + /// render-engine + /// \return The number of active scenes + public: virtual unsigned int SceneCount() const = 0; + + /// \brief Determine if the given scene is actively managed by this + /// render-engine + /// \param[in] _scene Scene in question + /// \return True if the scene is managed by this render-engine + public: virtual bool HasScene(ConstScenePtr _scene) const = 0; + + /// \brief Determine if this render-engine manages a scene with the + /// given ID. + /// \param[in] _id ID of scene in question + /// \return True if this render-engine manages the specified scene + public: virtual bool HasSceneId(unsigned int _id) const = 0; + + /// \brief Determine if this render-engine manages a scene with the + /// given name. + /// \param[in] _name Name of scene in question + /// \return True if this render-engine manages the specified scene + public: virtual bool HasSceneName(const std::string &_name) const = 0; + + /// \brief Get the scene with the given ID. If no scenes exist with the + /// given ID, NULL will be returned. + /// \param[in] _id ID of scene to be retrieved + /// \return The specified scene + public: virtual ScenePtr SceneById(unsigned int _id) const = 0; + + /// \brief Get the scene with the given name. If no scenes exist with the + /// given name, NULL will be returned. + /// \param[in] _name Name of scene to be retrieved + /// \return The specified scene + public: virtual ScenePtr SceneByName( + const std::string &_name) const = 0; + + /// \brief Get the scene at the given index. If no scenes exist at the + /// given index, NULL will be returned. + /// \param[in] _index Index of scene, which is a number from 0 to + /// SceneCount() - 1. Note that the index for a specific scene might + /// change as other scenes are destroyed. + /// \return The specified scene + public: virtual ScenePtr SceneByIndex(unsigned int _index) const = 0; + + /// \brief Destroy the given scene. If the given scene is not managed by + /// this render-engine, no work will be done. + /// \param[in] _scene Scene to be destroyed + public: virtual void DestroyScene(ScenePtr _scene) = 0; + + /// \brief Destroy the scene with the given ID. If no scenes exist with + /// the given ID, no work will be done. + /// \param[in] _id ID of the scene to destroy + public: virtual void DestroySceneById(unsigned int _id) = 0; + + /// \brief Destroy the scene with the given name. If no scenes exist with + /// the given name, no work will be done. + /// \param[in] _name Name of the scene to destroy + public: virtual void DestroySceneByName(const std::string &_name) = 0; + + /// \brief Destroy the scene at the given index. If no scenes exist at the + /// given index, no work will be done. + /// \param[in] _index Index of the scene to destroy + public: virtual void DestroySceneByIndex(unsigned int _index) = 0; + + /// \brief Destroy all scenes managed by this render-engine + public: virtual void DestroyScenes() = 0; + + /// \brief Create a new scene with the given name. The given name should + /// be unique across all scenes managed by this render-engine. If a + /// duplicate name is given, NULL will be returned. An unique ID will + /// automatically be assigned to the created scene. + /// \param[in] _name Name of the new scene + /// \return The created scene + public: virtual ScenePtr CreateScene(const std::string &_name) = 0; + + /// \brief Create a new scene with the given ID. The given ID should + /// be unique across all scenes managed by this render-engine. If a + /// duplicate ID is given, NULL will be returned. An unique name will + /// automatically be assigned to the created scene. + /// \param[in] _id ID of the new scene + /// \param[in] _name Name of the new scene + /// \return The created scene + public: virtual ScenePtr CreateScene(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Set headless mode + /// Only available in OGRE 2.2, which makes use of EGL + /// \param[in] _headless Set to true to enable headless mode. + public: virtual void SetHeadless(bool _headless) = 0; + + /// \brief Get headless mode + /// \return True if headless mode is enable, false otherwise. + public: virtual bool Headless() const = 0; + + /// \brief Add path to media resource location + /// \param[in] _path Absolute path to resource location + public: virtual void AddResourcePath(const std::string &_path) = 0; + + /// \brief Get the render pass system for this engine. + public: virtual RenderPassSystemPtr RenderPassSystem() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderEngineManager.hh b/include/gz/rendering/RenderEngineManager.hh new file mode 100644 index 000000000..d7391338b --- /dev/null +++ b/include/gz/rendering/RenderEngineManager.hh @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERENGINEMANAGER_HH_ +#define GZ_RENDERING_RENDERENGINEMANAGER_HH_ + +#include +#include +#include +#include +#include +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations. + class RenderEngine; + class RenderEngineManagerPrivate; + + /// \class RenderEngineManager RenderEngineManager.hh + /// ignition/rendering/RenderEngineManager.hh + /// \brief Collection of render-engines. This provides access to all the + /// render-engines available at runtime. RenderEngine objects should not + /// be access directly, but instead via the RenderEngineManager to maintain + /// a flexible render-engine agnostic design. + class IGNITION_RENDERING_VISIBLE RenderEngineManager : + public virtual common::SingletonT + { + /// \brief Constructor + public: RenderEngineManager(); + + /// \brief Deconstructor + public: ~RenderEngineManager(); + + /// \brief Get the number of available render-engines + /// \return the number of available render-engines + public: unsigned int EngineCount() const; + + /// \brief Determine if a render-engine with the given name is avaiable. + /// It also checks the list of default engines supplied by ign-rendering. + /// \param[in] _name Name of the desired render-engine + /// \return True if the specified render-engine is available + public: bool HasEngine(const std::string &_name) const; + + /// \brief Determine if a render-engine with the given name is already + /// loaded. + /// \param[in] _name Name of the desired render-engine + /// \return True if the specified render-engine is loaded. + public: bool IsEngineLoaded(const std::string &_name) const; + + /// \brief Get the list of all engines already loaded. + /// \return Names of all loaded engines. + public: std::vector LoadedEngines() const; + + /// \brief Get the render-engine with the given name. If the no + /// render-engine is registered under the given name, NULL will be + /// returned. + /// \param[in] _name Name of the desired render-engine + /// \param[in] _params Parameters to be passed to the render engine. + /// \param[in] _path Another search path for rendering engine plugin. + /// \return The specified render-engine + public: RenderEngine *Engine(const std::string &_name, + const std::map &_params = {}, + const std::string &_path = ""); + + /// \brief Get the render-engine at the given index. If no + /// render-engine is exists at the given index, NULL will be returned. + /// \param[in] _index Index of the desired render-engine + /// \param[in] _params Parameters to be passed to the render engine. + /// \param[in] _path Another search path for rendering engine plugin. + /// \return The specified render-engine + public: RenderEngine *EngineAt(unsigned int _index, + const std::map &_params = {}, + const std::string &_path = ""); + + /// \brief Unload the render-engine with the given name. If the no + /// render-engine is registered under the given name, false will be + /// returned. + /// \param[in] _name Name of the desired render-engine + /// \return True if the engine is unloaded + public: bool UnloadEngine(const std::string &_name); + + /// \brief Unload the render-engine at the given index. If the no + /// render-engine is registered under the given name, false will be + /// returned. + /// \param[in] _index Index of the desired render-engine + /// \return True if the engine is unloaded + public: bool UnloadEngineAt(unsigned int _index); + + /// \brief Register a new render-engine under the given name. If the + /// given name is already in use, the render-engine will not be + /// registered. + /// \param[in] _name Name the render-engine will be registered under + /// \param[in] _engine Render-engine to be registered + public: void RegisterEngine(const std::string &_name, + RenderEngine *_engine); + + /// \brief Unregister a render-engine registered under the given name. + /// If no render-engine is registered under the given name no work + /// will be done. + /// \param[in] _name Name of the render-engine to unregister + public: void UnregisterEngine(const std::string &_name); + + /// \brief Unregister the given render-engine. If the given render-engine + /// is not currently registered, no work will be done. + /// \param[in] _engine Render-engine to unregister + public: void UnregisterEngine(RenderEngine *_engine); + + /// \brief Unregister a render-engine at the given index. If the no + /// render-engine is registered at the given index, no work will be done. + /// \param[in] _index Index of the render-engine to unregister + public: void UnregisterEngineAt(unsigned int _index); + + /// \brief Set the plugin paths from which render engines can be loaded. + /// \param[in] _paths The list of the plugin paths + public: void SetPluginPaths(const std::list &_paths); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief private implementation details + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief required SingletonT friendship + private: friend class gz::common::SingletonT; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderEnginePlugin.hh b/include/gz/rendering/RenderEnginePlugin.hh new file mode 100644 index 000000000..7afe29ed4 --- /dev/null +++ b/include/gz/rendering/RenderEnginePlugin.hh @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GZ_RENDERING_RENDERENGINEPLUGIN_HH_ +#define GZ_RENDERING_RENDERENGINEPLUGIN_HH_ + +#include +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declarations + class RenderEngine; + class RenderEnginePluginPrivate; + + /// \brief Base plugin class for render engines + class IGNITION_RENDERING_VISIBLE RenderEnginePlugin + { + /// \brief Constructor + public: RenderEnginePlugin(); + + /// \brief Destructor + public: virtual ~RenderEnginePlugin(); + + /// \brief Get the name of render engine + /// \return Name of render engine + public: virtual std::string Name() const = 0; + + /// \brief Get a pointer to the render engine + /// \return Render engine instance + public: virtual RenderEngine *Engine() const = 0; + + /// \brief Pointer to private data class + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderPass.hh b/include/gz/rendering/RenderPass.hh new file mode 100644 index 000000000..e012285b0 --- /dev/null +++ b/include/gz/rendering/RenderPass.hh @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERPASS_HH_ +#define GZ_RENDERING_RENDERPASS_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/Object.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class RenderPass RenderPass.hh ignition/rendering/RenderPass.hh + /// \brief A render pass can be added to a camera to affect how the scene + /// is rendered. It can be used to add post-processing effects. Multiple + /// passes can be chained together. + class IGNITION_RENDERING_VISIBLE RenderPass + : public virtual Object + { + /// \brief Destructor + public: virtual ~RenderPass() { } + + /// \brief Set to enable or disable the render pass + /// \param[in] _enabled True to enable the render pass, false to disable. + public: virtual void SetEnabled(bool _enabled) = 0; + + /// \brief Get whether or not the render pass is enabled + /// \return True if the render pass is enabled, false otherwise. + public: virtual bool IsEnabled() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderPassSystem.hh b/include/gz/rendering/RenderPassSystem.hh new file mode 100644 index 000000000..271d76f2e --- /dev/null +++ b/include/gz/rendering/RenderPassSystem.hh @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERPASSSYSTEM_HH_ +#define GZ_RENDERING_RENDERPASSSYSTEM_HH_ + +#include +#include +#include +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" +#include "gz/rendering/RenderPass.hh" +#include "gz/rendering/RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class RenderPassSystemPrivate; + + /* \class RenderPassFactory RenderPassSystem.hh \ + * ignition/rendering/RenderPassSystem.hh + */ + /// \brief A factory interface for creating render passes + class IGNITION_RENDERING_VISIBLE RenderPassFactory + { + /// \brief Instantiate new render pass + /// \return New render pass + public: virtual RenderPass *New() const = 0; + }; + + /* \class RenderPassSystem RenderPassSystem.hh \ + * ignition/rendering/RenderPassSystem.hh + */ + /// \brief A class for creating and managing render passes + class IGNITION_RENDERING_VISIBLE RenderPassSystem + { + /// \brief Constructor + public: RenderPassSystem(); + + /// \brief Destructor + public: virtual ~RenderPassSystem(); + + /// \brief Templated function for creating render passes + /// \return Pointer to the render pass created + public: template RenderPassPtr Create() + { + return this->CreateImpl(typeid(T).name()); + } + + /// \brief Register a render pass factory to the system + /// \param[in] _type Render pass type, i.e. type id of render pass class + /// \param[in] _factory Factory used to create the render pass + public: static void Register(const std::string &_type, + RenderPassFactory *_factory); + + /// \brief Implementation for creating render passes + /// \param[in] _type Render pass type, i.e. type id of render pass class + /// \return Pointer to the render pass created + private: RenderPassPtr CreateImpl(const std::string &_type); + + /// \brief A map of render pass type id name to its factory class + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: static std::map renderPassMap; + + /// \internal + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + + /// \brief Render pass registration macro + /// + /// Use this macro to register render pass with the render pass factory. + #define IGN_RENDERING_REGISTER_RENDER_PASS(classname, interface) \ + class classname##Factory : public gz::rendering::RenderPassFactory \ + { \ + public: classname##Factory() \ + { \ + gz::rendering::RenderPassSystem::Register( \ + typeid(interface).name(), this); \ + } \ + public: RenderPass *New() const override \ + { \ + return new classname(); \ + } \ + }; \ + static classname##Factory global_##classname##Factory; + } + } +} +#endif diff --git a/include/gz/rendering/RenderTarget.hh b/include/gz/rendering/RenderTarget.hh new file mode 100644 index 000000000..1a30a7786 --- /dev/null +++ b/include/gz/rendering/RenderTarget.hh @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License") = 0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERTARGET_HH_ +#define GZ_RENDERING_RENDERTARGET_HH_ + +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class RenderTarget RenderTarget.hh ignition/rendering/RenderTarget.hh + /// \brief Represents a render-target to which cameras can render images. + class IGNITION_RENDERING_VISIBLE RenderTarget : + public virtual Object + { + /// \brief Destructor + public: virtual ~RenderTarget() { } + + /// \brief Get render target width in pixels + /// \return The render target width in pixels + public: virtual unsigned int Width() const = 0; + + /// \brief Get render target height in pixels + /// \return The Render target height in pixels + public: virtual unsigned int Height() const = 0; + + /// \brief Set the render target width in pixels + /// \param[in] _width New render target width in pixels + public: virtual void SetWidth(const unsigned int _width) = 0; + + /// \brief Set the render target height in pixels + /// \param[in] _height New render target height in pixels + public: virtual void SetHeight(const unsigned int _height) = 0; + + /// \brief Set the render target image format + /// \return Render target format + public: virtual PixelFormat Format() const = 0; + + /// \brief Set the render target image format + /// \param[in] _format New target format + public: virtual void SetFormat(PixelFormat _format) = 0; + + /// \brief Write rendered image to given Image. The RenderTarget will + /// convert the underlying image to the specified format listed in the + /// given Image. However if the given image is not of the correct size no + /// work will be done. Calling this function before an image has been + /// rendered will result in undefined behavior. + /// \param[out] _image Image to which output will be written + public: virtual void Copy(Image &_image) const = 0; + + /// \brief Get the background color of the render target. + /// This should be the same as the scene background color. + /// \return Render target background color. + public: virtual math::Color BackgroundColor() const = 0; + + /// \brief Add a render pass to the render target + /// \param[in] _pass New render pass to add + public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0; + + /// \brief Remove a render pass from the render target + /// \param[in] _pass render pass to remove + public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) = 0; + + /// \brief Get the number of render passes applied to the render target + /// \return Number of render passes applied + public: virtual unsigned int RenderPassCount() const = 0; + + /// \brief Get a render pass by index + /// \return Render pass at the specified index + public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) + const = 0; + }; + + /* \class RenderTexture RenderTexture.hh \ + * ignition/rendering/RenderTexture.hh + */ + /// \brief Represents a off-screen render-texture to which cameras can + /// render images. + class IGNITION_RENDERING_VISIBLE RenderTexture : + public virtual RenderTarget + { + /// \brief Deconstructor + public: virtual ~RenderTexture() { } + + /// \brief Returns the OpenGL texture Id. A valid Id is returned only + // if this is an OpenGL render texture + public: virtual unsigned int GLId() const = 0; + }; + + /* \class RenderWindow RenderWindow.hh \ + * ignition/rendering/RenderWindow.hh + */ + /// \brief Represents a on-screen render-window to which cameras can + /// render images. + class IGNITION_RENDERING_VISIBLE RenderWindow : + public virtual RenderTarget + { + /// \brief Deconstructor + public: virtual ~RenderWindow() { } + + /// \brief Get the window handle that the render window is attached to. + /// \return Window handle + public: virtual std::string Handle() const = 0; + + /// \brief Set the window handle to attach the render window to + /// \param[in] _handle Window handle + public: virtual void SetHandle(const std::string &_handle) = 0; + + /// \brief Get the device to pixel ratio + /// \return Device to pixel ratio + public: virtual double DevicePixelRatio() const = 0; + + /// \brief Set the device to pixel ratio + /// \param[in] _ratio Device to pixel ratio + public: virtual void SetDevicePixelRatio(const double _ratio) = 0; + + /// \brief Alert the window of a window resize event + /// \param[in] _width New window width in pixels + /// \param[in] _height New window height in pixels + public: virtual void OnResize(unsigned int _width, + unsigned int _height) = 0; + + /// \brief Alert the window of a window move event + public: virtual void OnMove() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderTypes.hh b/include/gz/rendering/RenderTypes.hh new file mode 100644 index 000000000..7d5fdae2e --- /dev/null +++ b/include/gz/rendering/RenderTypes.hh @@ -0,0 +1,424 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERTYPES_HH_ +#define GZ_RENDERING_RENDERTYPES_HH_ + +#include +#include + + +/// \typedef IGN_VISIBILITY_ALL +/// \brief Render everything visibility mask. +#define IGN_VISIBILITY_ALL 0x0FFFFFFF + +/// \typedef IGN_VISIBILITY_SELECTION +/// \brief Renders only objects that can be selected. +#define IGN_VISIBILITY_SELECTION 0x10000000 + +/// \typedef IGN_VISIBILITY_GUI +/// \brief Render GUI visuals mask. +#define IGN_VISIBILITY_GUI 0x00000001 + +/// \typedef IGN_VISIBILITY_SELECTABLE +/// \brief Render visuals that are selectable mask. +#define IGN_VISIBILITY_SELECTABLE 0x00000002 + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + using shared_ptr = std::shared_ptr; + + class ArrowVisual; + class AxisVisual; + class BoundingBoxCamera; + class Camera; + class Capsule; + class COMVisual; + class DepthCamera; + class DirectionalLight; + class DistortionPass; + class GaussianNoisePass; + class Geometry; + class GizmoVisual; + class GpuRays; + class Grid; + class Heightmap; + class Image; + class InertiaVisual; + class Light; + class LightVisual; + class JointVisual; + class LidarVisual; + class Light; + class Marker; + class Material; + class Mesh; + class Node; + class Object; + class ObjectFactory; + class ParticleEmitter; + class PointLight; + class RayQuery; + class RenderEngine; + class RenderPass; + class RenderPassSystem; + class RenderTarget; + class RenderTexture; + class RenderWindow; + class Scene; + class SegmentationCamera; + class Sensor; + class ShaderParams; + class SpotLight; + class SubMesh; + class Text; + class ThermalCamera; + class Visual; + class WireBox; + + /// \typedef ArrowVisualPtr + /// \brief Shared pointer to ArrowVisual + typedef shared_ptr ArrowVisualPtr; + + /// \typedef AxisVisualPtr + /// \brief Shared pointer to AxisVisual + typedef shared_ptr AxisVisualPtr; + + /// \typedef CameraPtr + /// \brief Shared pointer to Camera + typedef shared_ptr CameraPtr; + + /// \typedef DepthCameraPtr + /// \brief Shared pointer to DepthCamera + typedef shared_ptr DepthCameraPtr; + + /// \typedef ThermalCameraPtr + /// \brief Shared pointer to ThermalCamera + typedef shared_ptr ThermalCameraPtr; + + /// \typedef BoundingBoxCameraPtr + /// \brief Shared pointer to BoundingBoxCamera + typedef shared_ptr BoundingBoxCameraPtr; + + /// \typedef SegmentationCameraPtr + /// \brief Shared pointer to Segmentation Camera + typedef shared_ptr SegmentationCameraPtr; + + /// \typedef GpuRaysPtr + /// \brief Shared pointer to GpuRays + typedef shared_ptr GpuRaysPtr; + + /// \typedef DirectionalLightPtr + /// \brief Shared pointer to DirectionalLight + typedef shared_ptr DirectionalLightPtr; + + /// \typedef DistortionPassPtr + /// \brief Shared pointer to DistortionPass + typedef shared_ptr DistortionPassPtr; + + /// \typedef GaussianNoisePassPtr + /// \brief Shared pointer to GaussianNoisePass + typedef shared_ptr GaussianNoisePassPtr; + + /// \typedef GeometryPtr + /// \brief Shared pointer to Geometry + typedef shared_ptr GeometryPtr; + + /// \typedef GizmoVisualPtr + /// \brief Shared pointer to GizmoVisual + typedef shared_ptr GizmoVisualPtr; + + /// \typedef CapsulePtr + /// \brief Shared pointer to Capsule + typedef shared_ptr CapsulePtr; + + /// \typedef GridPtr + /// \brief Shared pointer to Grid + typedef shared_ptr GridPtr; + + /// \typedef JointVisualPtr + /// \brief Shared pointer to JointVisual + typedef shared_ptr JointVisualPtr; + + /// \typedef HeightmapPtr + /// \brief Shared pointer to Heightmap + typedef shared_ptr HeightmapPtr; + + /// \typedef ImagePtr + /// \brief Shared pointer to Image + typedef shared_ptr ImagePtr; + + /// \typedef InertiaVisualPtr + /// \def Shared pointer to InertiaVisual + typedef shared_ptr InertiaVisualPtr; + + /// \typedef LightPtr + /// \brief Shared pointer to Light + typedef shared_ptr LightPtr; + + /// \typedef COMVisualPtr + /// \brief Shared pointer to COMVisual + typedef shared_ptr COMVisualPtr; + + /// \typedef LightVisualPtr + /// \brief Shared pointer to Light + typedef shared_ptr LightVisualPtr; + + /// \typedef LidarVisualPtr + /// \brief Shared pointer to LidarVisual + typedef shared_ptr LidarVisualPtr; + + /// \typedef MaterialPtr + /// \brief Shared pointer to Material + typedef shared_ptr MaterialPtr; + + /// \typedef MarkerPtr + /// \brief Shared pointer to Marker + typedef shared_ptr MarkerPtr; + + /// \typedef MeshPtr + /// \brief Shared pointer to Mesh + typedef shared_ptr MeshPtr; + + /// \typedef NodePtr + /// \brief Shared pointer to Node + typedef shared_ptr NodePtr; + + /// \typedef ObjectPtr + /// \brief Shared pointer to Object + typedef shared_ptr ObjectPtr; + + /// \typedef ObjectFactoryPtr + /// \brief Shared pointer to ObjectFactory + typedef shared_ptr ObjectFactoryPtr; + + /// \typedef ParticleEmitterPtr + /// \brief Shared pointer to ParticleEmitter + typedef shared_ptr ParticleEmitterPtr; + + /// \typedef PointLightPtr + /// \brief Shared pointer to PointLight + typedef shared_ptr PointLightPtr; + + /// \typedef RayQueryPtr + /// \brief Shared pointer to RayQuery + typedef shared_ptr RayQueryPtr; + + /// \typedef RenderPassPtr + /// \brief Shared pointer to RenderPass + typedef shared_ptr RenderPassPtr; + + /// \typedef RenderPassSystemPtr + /// \brief Shared pointer to RenderPassSystem + typedef shared_ptr RenderPassSystemPtr; + + /// \typedef RenderTargetPtr + /// \brief Shared pointer to RenderTarget + typedef shared_ptr RenderTargetPtr; + + /// \typedef RenderTexturePtr + /// \brief Shared pointer to RenderTexture + typedef shared_ptr RenderTexturePtr; + + /// \typedef RenderWindowPtr + /// \brief Shared pointer to RenderWindow + typedef shared_ptr RenderWindowPtr; + /// \typedef ScenePtr + /// \brief Shared pointer to Scene + typedef shared_ptr ScenePtr; + + /// \typedef SensorPtr + /// \brief Shared pointer to Sensor + typedef shared_ptr SensorPtr; + + /// \brief Shared pointer to ShaderParams + typedef shared_ptr ShaderParamsPtr; + + /// \typedef SpotLightPtr + /// \brief Shared pointer to SpotLight + typedef shared_ptr SpotLightPtr; + + /// \typedef SubMeshPtr + /// \brief Shared pointer to SubMesh + typedef shared_ptr SubMeshPtr; + + /// \typedef TextPtr + /// \brief Shared pointer to Text + typedef shared_ptr TextPtr; + + /// \typedef VisualPtr + /// \brief Shared pointer to Visual + typedef shared_ptr VisualPtr; + + /// \typedef WireBoxPtr + /// \brief Shared pointer to WireBox + typedef shared_ptr WireBoxPtr; + + /// \typedef const ArrowVisualPtr + /// \brief Shared pointer to const ArrowVisual + typedef shared_ptr ConstArrowVisualPtr; + + /// \typedef const AxisVisualPtr + /// \brief Shared pointer to const AxisVisual + typedef shared_ptr ConstAxisVisualPtr; + + /// \typedef const CameraPtr + /// \brief Shared pointer to const Camera + typedef shared_ptr ConstCameraPtr; + + /// \typedef const DepthCameraPtr + /// \brief Shared pointer to const DepthCamera + typedef shared_ptr ConstDepthCameraPtr; + + /// \typedef const ThermalCameraPtr + /// \brief Shared pointer to const ThermalCamera + typedef shared_ptr ConstThermalCameraPtr; + + /// \typedef const BoundingBoxCameraPtr + /// \brief Shared pointer to const BoundingBox Camera + typedef shared_ptr ConstBoundingBoxCameraPtr; + + /// \typedef const SegmentationCameraPtr + /// \brief Shared pointer to const Segmentation Camera + typedef shared_ptr ConstSegmentationCameraPtr; + + /// \typedef const GpuRaysPtr + /// \brief Shared pointer to const GpuRays + typedef shared_ptr ConstGpuRaysPtr; + + /// \typedef const DirectionalLightPtr + /// \brief Shared pointer to const DirectionalLight + typedef shared_ptr ConstDirectionalLightPtr; + + /// \typedef const ConstGaussianNoisePass + /// \brief Shared pointer to const GaussianNoisePass + typedef shared_ptr ConstGaussianNoisePass; + + /// \typedef const GeometryPtr + /// \brief Shared pointer to const Geometry + typedef shared_ptr ConstGeometryPtr; + + /// \typedef const GizmoVisualPtr + /// \brief Shared pointer to const GizmoVisual + typedef shared_ptr ConstGizmoVisualPtr; + + /// \typedef const JointVisualPtr + /// \brief Shared pointer to const JointVisual + typedef shared_ptr ConstJointVisualPtr; + + /// \typedef const HeightmapPtr + /// \brief Shared pointer to const Heightmap + typedef shared_ptr ConstHeightmapPtr; + + /// \typedef const ImagePtr + /// \brief Shared pointer to const Image + typedef shared_ptr ConstImagePtr; + + /// \typedef const LightPtr + /// \brief Shared pointer to const Light + typedef shared_ptr ConstLightPtr; + + /// \typedef const LidarVisualPtr + /// \brief Shared pointer to const LidarVisual + typedef shared_ptr ConstLidarVisualPtr; + + /// \typedef const MaterialPtr + /// \brief Shared pointer to const Material + typedef shared_ptr ConstMaterialPtr; + + /// \typedef const MeshPtr + /// \brief Shared pointer to const Mesh + typedef shared_ptr ConstMeshPtr; + + /// \typedef const NodePtr + /// \brief Shared pointer to const Node + typedef shared_ptr ConstNodePtr; + + /// \typedef const ObjectPtr + /// \brief Shared pointer to const Object + typedef shared_ptr ConstObjectPtr; + + /// \typedef const ObjectFactoryPtr + /// \brief Shared pointer to const ObjectFactory + typedef shared_ptr ConstObjectFactoryPtr; + + /// \typedef const ParticleEmitterPtr + /// \brief Shared pointer to const ParticleEmitter + typedef shared_ptr ConstParticleEmitterPtr; + + /// \typedef const PointLightPtr + /// \brief Shared pointer to const PointLight + typedef shared_ptr ConstPointLightPtr; + + /// \typedef RayQueryPtr + /// \brief Shared pointer to RayQuery + typedef shared_ptr ConstRayQueryPtr; + + /// \typedef const RenderPassPtr + /// \brief Shared pointer to const RenderPass + typedef shared_ptr ConstRenderPassPtr; + + /// \typedef const RenderPassSystemPtr + /// \brief Shared pointer to const RenderPassSystem + typedef shared_ptr ConstRenderPassSystemPtr; + + /// \typedef const RenderTargetPtr + /// \brief Shared pointer to const RenderTarget + typedef shared_ptr ConstRenderTargetPtr; + + /// \typedef const RenderTexturePtr + /// \brief Shared pointer to const RenderTexture + typedef shared_ptr ConstRenderTexturePtr; + + /// \typedef const RenderWindowPtr + /// \brief Shared pointer to const RenderWindow + typedef shared_ptr ConstRenderWindowPtr; + + /// \typedef const ScenePtr + /// \brief Shared pointer to const Scene + typedef shared_ptr ConstScenePtr; + + /// \typedef const SensorPtr + /// \brief Shared pointer to const Sensor + typedef shared_ptr ConstSensorPtr; + + /// \brief Shared pointer to const ShaderParams + typedef shared_ptr ConstShaderParamsPtr; + + /// \typedef const SpotLightPtr + /// \brief Shared pointer to const SpotLight + typedef shared_ptr ConstSpotLightPtr; + + /// \typedef const SubMeshPtr + /// \brief Shared pointer to const SubMesh + typedef shared_ptr ConstSubMeshPtr; + + /// \typedef const SubMeshPtr + /// \brief Shared pointer to const SubMesh + typedef shared_ptr ConstTextPtr; + + /// \typedef const VisualPtr + /// \brief Shared pointer to const Visual + typedef shared_ptr ConstVisualPtr; + } + } +} +#endif diff --git a/include/gz/rendering/RenderingIface.hh b/include/gz/rendering/RenderingIface.hh new file mode 100644 index 000000000..13825ee77 --- /dev/null +++ b/include/gz/rendering/RenderingIface.hh @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERINGIFACE_HH_ +#define GZ_RENDERING_RENDERINGIFACE_HH_ + +#include +#include +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" +#include "gz/rendering/RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class RenderEngine; + + /// \brief Load shared render-engine resources + /// \return True if successful + IGNITION_RENDERING_VISIBLE + bool load(); + + /// \brief Initialized shared render-engine features + /// \return True if successful + IGNITION_RENDERING_VISIBLE + bool init(); + + /// \brief Destroy all render-engines and related resources + /// \return True if successful + IGNITION_RENDERING_VISIBLE + bool fini(); + + /// \brief Get the number of available render-engines. + /// \return The number of available render-engines + IGNITION_RENDERING_VISIBLE + unsigned int engineCount(); + + /// \brief Determine if a render-engine is registered under the given name + /// \param[in] _name Name of the desired render-engine + /// \return True if a render-engine is registered under the given name + IGNITION_RENDERING_VISIBLE + bool hasEngine(const std::string &_name); + + /// \brief Determine if a render-engine is already loaded. + /// \param[in] _name Name of the desired render-engine + /// \return True if a render-engine is loaded under the given name + IGNITION_RENDERING_VISIBLE + bool isEngineLoaded(const std::string &_name); + + /// \brief Get the names of all engines currently loaded. + /// \return All the engines currently loaded. + IGNITION_RENDERING_VISIBLE + std::vector loadedEngines(); + + /// \brief Get the render-engine registered under the given name. If no + /// render-engine is registered under the given name, NULL will be + /// returned. + /// If the engine is registered, but not loaded, this function will load it. + /// \param[in] _name Name of the desired render-engine + /// \param[in] _params Parameters to be passed to the render engine. + /// \param[in] _path Another search path for rendering engine plugin. + /// \return The specified render-engine + IGNITION_RENDERING_VISIBLE + RenderEngine *engine(const std::string &_name, + const std::map &_params = {}, + const std::string &_path = ""); + + /// \brief Get the render-engine registered at the given index. If no + /// render-engine is registered at the given index, NULL will be returned. + /// If the engine is registered, but not loaded, this function will load it. + /// \param[in] _index Index of the desired render-engine + /// \param[in] _params Parameters to be passed to the render engine. + /// \param[in] _path Another search path for rendering engine plugin. + /// \return The specified render-engine + IGNITION_RENDERING_VISIBLE + RenderEngine *engine(const unsigned int _index, + const std::map &_params = {}, + const std::string &_path = ""); + + /// \brief Unload the render-engine registered under the given name. + /// \param[in] _name Name of the desired render-engine + /// \return True if the engine is unloaded + IGNITION_RENDERING_VISIBLE + bool unloadEngine(const std::string &_name); + + /// \brief Register a new render-engine under the given name. If the given + /// name is already in use, the render-engine will not be registered. + /// \param[in] _name Name the render-engine will be registered under + /// \param[in] _engine Render-engine to be registered + IGNITION_RENDERING_VISIBLE + void registerEngine(const std::string &_name, RenderEngine *_engine); + + /// \brief Unregister a render-engine registered under the given name. + /// If the no render-engine is registered under the given name no work + /// will be done. + /// \param[in] _name Name of the render-engine to unregister + IGNITION_RENDERING_VISIBLE + void unregisterEngine(const std::string &_name); + + /// \brief Unregister the given render-engine. If the given render-engine + /// is not currently registered, no work will be done. + /// \param[in] _engine Render-engine to unregister + IGNITION_RENDERING_VISIBLE + void unregisterEngine(RenderEngine *_engine); + + /// \brief Unregister a render-engine at the given index. If the no + /// render-engine is registered at the given index, no work will be done. + /// \param[in] _index Index of the render-engine to unregister + IGNITION_RENDERING_VISIBLE + void unregisterEngine(const unsigned int _index); + + /// \brief Set the plugin paths from which render engines can be loaded. + /// \param[in] _paths The list of the plugin paths + IGNITION_RENDERING_VISIBLE + void setPluginPaths(const std::list &_paths); + + /// \brief Most applications will only have one rendering engine loaded + /// at a time, and only one scene within that. This helper function gets + /// the first scene that can be found in the first loaded rendering engine. + /// + /// It's not recommended to call this function when there's more than one + /// engine or scene. + /// + /// \return Pointer to a scene that was found, null if no scene is loaded. + IGNITION_RENDERING_VISIBLE + ScenePtr sceneFromFirstRenderEngine(); + } + } +} +#endif diff --git a/include/gz/rendering/Scene.hh b/include/gz/rendering/Scene.hh new file mode 100644 index 000000000..3215cdb2d --- /dev/null +++ b/include/gz/rendering/Scene.hh @@ -0,0 +1,1294 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_SCENE_HH_ +#define GZ_RENDERING_SCENE_HH_ + +#include +#include +#include + +#include +#include +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/HeightmapDescriptor.hh" +#include "gz/rendering/MeshDescriptor.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Storage.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class RenderEngine; + + /// \class Scene Scene.hh ignition/rendering/Scene.hh + /// \brief Manages a single scene-graph. This class updates scene-wide + /// properties and holds the root scene node. A Scene also serves as a + /// factory for all scene objects. + class IGNITION_RENDERING_VISIBLE Scene + { + /// \brief Deconstructor + public: virtual ~Scene() { } + + /// \brief Load scene-specific resources + public: virtual void Load() = 0; + + /// \brief Initialize the scene + public: virtual void Init() = 0; + + // TODO(anyone): merge with Destroy + public: virtual void Fini() = 0; + + /// \brief Determine if the scene is initialized + /// \return True if the scene is initialized + public: virtual bool IsInitialized() const = 0; + + /// \brief Get the ID of the scene + /// \return The scene ID + public: virtual unsigned int Id() const = 0; + + /// \brief Get the name of the scene + /// \return The scene name + public: virtual std::string Name() const = 0; + + /// \brief Get the creating render-engine of the scene + /// \return The creating render-engine + public: virtual RenderEngine *Engine() const = 0; + + /// \brief Get the last simulation update time + /// \return The last simulation update time + public: virtual common::Time IGN_DEPRECATED(4) SimTime() const = 0; + + /// \brief Get the last simulation update time + /// \return The last simulation update time + public: virtual std::chrono::steady_clock::duration + Time() const = 0; + + /// \brief Set the last simulation update time + /// \param[in] _time Latest simulation update time + public: virtual void IGN_DEPRECATED(4) + SetSimTime(const common::Time &_time) = 0; + + /// \brief Set the last simulation update time + /// \param[in] _time Latest simulation update time + public: virtual void SetTime( + const std::chrono::steady_clock::duration &_time) = 0; + + /// \brief Get root Visual node. All nodes that are desired to be + /// rendered in a scene should be added to this Visual or one of its + /// ancestors in the scene-graph. Nodes created by this Scene will not be + /// added to the scene by default. + /// \return The root Visual node + public: virtual VisualPtr RootVisual() const = 0; + + /// \brief Get a visual at a mouse position. + /// \param[in] _camera Camera pointer being used + /// \param[in] _mousePos position of the mouse in pixels + /// \return Pointer to the visual, NULL if none found. + public: virtual VisualPtr VisualAt(const CameraPtr &_camera, + const math::Vector2i &_mousePos) = 0; + + /// \brief Get the scene ambient light color + /// \return The scene ambient light color + public: virtual math::Color AmbientLight() const = 0; + + /// \brief Set the scene ambient light color + /// \param[in] _r Red color + /// \param[in] _g Green color + /// \param[in] _b Blue color + /// \param[in] _a Alpha color + public: virtual void SetAmbientLight(double _r, double _g, double _b, + double _a = 1.0) = 0; + + /// \brief Set the scene ambient light color + /// \param[in] _color The scene ambient light color + public: virtual void SetAmbientLight(const math::Color &_color) = 0; + + /// \brief Get the scene background color + /// \return The scene background color + public: virtual math::Color BackgroundColor() const = 0; + + /// \brief Set the scene background color + /// \param[in] _r Red color + /// \param[in] _g Green color + /// \param[in] _b Blue color + /// \param[in] _a Alpha color + public: virtual void SetBackgroundColor(double _r, double _g, double _b, + double _a = 1.0) = 0; + + /// \brief Set the scene background color + /// \param[in] _color The scene background color + public: virtual void SetBackgroundColor(const math::Color &_color) = 0; + + /// \brief Whether the scene has a gradient background or not (solid) + /// \return True if the scene has a gradient background or false otherwise + public: virtual bool IsGradientBackgroundColor() const = 0; + + /// \brief Get the scene gradient background color + /// \return The scene gradient background color + /// \sa bool IsGradientBackgroundColor() const + public: virtual std::array + GradientBackgroundColor() const = 0; + + /// \brief Set a custom gradient background color on top of the regular + /// background. Default should be black. + /// + /// Important note: Keep in mind that this object will always be rendered + /// on top of any existing scene or camera background. + /// + /// \param[in] _colors The scene gradient background color. + /// Next is the description of how to interpret each value of the array: + /// 0: Top left corner color. + /// 1: Bottom left corner color. + /// 2: Top right corner color. + /// 3: Bottom right corner color. + /// \sa void RemoveGradientBackgroundColor() + public: virtual void SetGradientBackgroundColor( + const std::array &_colors) = 0; + + /// \brief Remove the scene gradient background color + /// \sa void SetGradientBackgroundColor( + /// const std::array &_colors) + public: virtual void RemoveGradientBackgroundColor() = 0; + + /// \brief Get the scene background material + /// e.g. a material with skybox cubemap texture + /// \return Material of the background + public: virtual MaterialPtr BackgroundMaterial() const = 0; + + /// \brief Set the scene background material + /// e.g. a material with skybox cubemap texture + /// \param[in] _material Material to set the background to + public: virtual void SetBackgroundMaterial(MaterialPtr _material) = 0; + + /// \brief Get the number of nodes managed by this scene. Note these + /// nodes may not be directly or indirectly attached to the root node. + /// \return The number of nodes managed by this scene + public: virtual unsigned int NodeCount() const = 0; + + /// \brief Determine if the given node is managed by this Scene + /// \param[in] _node Node in question + /// \return True if a node is managed by this scene + public: virtual bool HasNode(ConstNodePtr _node) const = 0; + + /// \brief Determine if a given node with the given id is managed by + /// this Scene + /// \param[in] _id ID of the node in question + /// \return True if a node is managed by this scene + public: virtual bool HasNodeId(unsigned int _id) const = 0; + + /// \brief Determine if a given node with the given name is managed by + /// this Scene + /// \param[in] _name Name of the node in question + /// \return True if a node is managed by this scene + public: virtual bool HasNodeName(const std::string &_name) const = 0; + + /// \brief Get node with the given id. If no node exists with the given + /// id, NULL will be returned. + /// \param[in] _id ID of the desired node + /// \return The desired node + public: virtual NodePtr NodeById(unsigned int _id) const = 0; + + /// \brief Get node with the given name. If no node exists with the given + /// name, NULL will be returned. + /// \param[in] _name Name of the desired node + /// \return The desired node + public: virtual NodePtr NodeByName(const std::string &_name) const = 0; + + /// \brief Get node at the given index. If no node exists at the given + /// index, NULL will be returned. + /// \param[in] _index Index of the desired node + /// \return The desired node + public: virtual NodePtr NodeByIndex(unsigned int _index) const = 0; + + /// \brief Destroy given node. If the given node is not managed by this + /// scene, no work will be done. Depending on the _recursive argument, + /// this function will either detach all child nodes from the scene graph + /// or recursively destroy them. + /// \param[in] _node Node pointer to destroy + /// \param[in] _recursive True to recursively destroy the node and its + /// children, false to destroy only this node and detach the children + public: virtual void DestroyNode(NodePtr _node, + bool _recursive = false) = 0; + + /// \brief Destroy node with the given id. If no node exists with the + /// given id, no work will be done. All children of the node will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _id ID of the node to destroy + public: virtual void DestroyNodeById(unsigned int _id) = 0; + + /// \brief Destroy node with the given name. If no node exists with the + /// given name, no work will be done. All children of the node will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _name Name of the node to destroy + public: virtual void DestroyNodeByName(const std::string &_name) = 0; + + /// \brief Destroy node at the given index. If no node exists at the + /// given index, no work will be done. All children of the node will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _index Index of the node to destroy + public: virtual void DestroyNodeByIndex(unsigned int _index) = 0; + + /// \brief Destroy all nodes manages by this scene. + public: virtual void DestroyNodes() = 0; + + /// \brief Get the number of lights managed by this scene. Note these + /// lights may not be directly or indirectly attached to the root light. + /// \return The number of lights managed by this scene + public: virtual unsigned int LightCount() const = 0; + + /// \brief Determine if the given light is managed by this Scene + /// \param[in] _light Light in question + /// \return True if a light is managed by this scene + public: virtual bool HasLight(ConstLightPtr _light) const = 0; + + /// \brief Determine if a given light with the given id is managed by + /// this Scene + /// \param[in] _id ID of the light in question + /// \return True if a light is managed by this scene + public: virtual bool HasLightId(unsigned int _id) const = 0; + + /// \brief Determine if a given light with the given name is managed by + /// this Scene + /// \param[in] _name Name of the light in question + /// \return True if a light is managed by this scene + public: virtual bool HasLightName(const std::string &_name) const = 0; + + /// \brief Get light with the given id. If no light exists with the given + /// id, NULL will be returned. + /// \param[in] _id ID of the desired light + /// \return The desired light + public: virtual LightPtr LightById(unsigned int _id) const = 0; + + /// \brief Get light with the given name. If no light exists with the + /// given name, NULL will be returned. + /// \param[in] _name Name of the desired light + /// \return The desired light + public: virtual LightPtr LightByName( + const std::string &_name) const = 0; + + /// \brief Get light at the given index. If no light exists at the given + /// index, NULL will be returned. + /// \param[in] _index Index of the desired light + /// \return The desired light + public: virtual LightPtr LightByIndex(unsigned int _index) const = 0; + + /// \brief Destroy given light. If the given light is not managed by this + /// scene, no work will be done. Depending on the _recursive argument, + /// this function will either detach all child nodes from the scene graph + /// or recursively destroy them. + /// \param[in] _light Light pointer to destroy + /// \param[in] _recursive True to recursively destroy the node and its + /// children, false to destroy only this node and detach the children + public: virtual void DestroyLight(LightPtr _light, + bool _recursive = false) = 0; + + /// \brief Destroy light with the given id. If no light exists with the + /// given id, no work will be done. All children of the light will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _id ID of the light to destroy + public: virtual void DestroyLightById(unsigned int _id) = 0; + + /// \brief Destroy light with the given name. If no light exists with the + /// given name, no work will be done. All children of the light will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _name Name of the light to destroy + public: virtual void DestroyLightByName(const std::string &_name) = 0; + + /// \brief Destroy light at the given index. If no light exists at the + /// given index, no work will be done. All children of the light will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _index Index of the light to destroy + public: virtual void DestroyLightByIndex(unsigned int _index) = 0; + + /// \brief Destroy all lights manages by this scene. + public: virtual void DestroyLights() = 0; + + /// \brief Get the number of sensors managed by this scene. Note these + /// sensors may not be directly or indirectly attached to the root sensor. + /// \return The number of sensors managed by this scene + public: virtual unsigned int SensorCount() const = 0; + + /// \brief Determine if the given sensor is managed by this Scene + /// \param[in] _sensor Sensor in question + /// \return True if a sensor is managed by this scene + public: virtual bool HasSensor(ConstSensorPtr _sensor) const = 0; + + /// \brief Determine if a given sensor with the given id is managed by + /// this Scene + /// \param[in] _id ID of the sensor in question + /// \return True if a sensor is managed by this scene + public: virtual bool HasSensorId(unsigned int _id) const = 0; + + /// \brief Determine if a given sensor with the given name is managed by + /// this Scene + /// \param[in] _name Name of the sensor in question + /// \return True if a sensor is managed by this scene + public: virtual bool HasSensorName(const std::string &_name) const = 0; + + /// \brief Get sensor with the given id. If no sensor exists with the + /// given id, NULL will be returned. + /// \param[in] _id ID of the desired sensor + /// \return The desired sensor + public: virtual SensorPtr SensorById(unsigned int _id) const = 0; + + /// \brief Get sensor with the given name. If no sensor exists with the + /// given name, NULL will be returned. + /// \param[in] _name Name of the desired sensor + /// \return The desired sensor + public: virtual SensorPtr SensorByName( + const std::string &_name) const = 0; + + /// \brief Get sensor at the given index. If no sensor exists at the given + /// index, NULL will be returned. + /// \param[in] _index Index of the desired sensor + /// \return The desired sensor + public: virtual SensorPtr SensorByIndex(unsigned int _index) const = 0; + + /// \brief Destroy given sensor. If the given sensor is not managed by + /// this scene, no work will be done. Depending on the _recursive + /// argument, this function will either detach all child nodes from the + /// scene graph or recursively destroy them. + /// \param[in] _sensor Sensor pointer to destroy + /// \param[in] _recursive True to recursively destroy the node and its + /// children, false to destroy only this node and detach the children + public: virtual void DestroySensor(SensorPtr _sensor, + bool _recursive = false) = 0; + + /// \brief Destroy sensor with the given id. If no sensor exists with the + /// given id, no work will be done. All children of the sensor will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _id ID of the sensor to destroy + public: virtual void DestroySensorById(unsigned int _id) = 0; + + /// \brief Destroy sensor with the given name. If no sensor exists with + /// the given name, no work will be done. All children of the sensor will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _name Name of the sensor to destroy + public: virtual void DestroySensorByName(const std::string &_name) = 0; + + /// \brief Destroy sensor at the given index. If no sensor exists at the + /// given index, no work will be done. All children of the sensor will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _index Index of the sensor to destroy + public: virtual void DestroySensorByIndex(unsigned int _index) = 0; + + /// \brief Destroy all sensors manages by this scene. + public: virtual void DestroySensors() = 0; + + /// \brief Get the number of nodes managed by this scene. Note these + /// nodes may not be directly or indirectly attached to the root node. + /// \return The number of nodes managed by this scene + public: virtual unsigned int VisualCount() const = 0; + + /// \brief Determine if the given node is managed by this Scene + /// \param[in] _node Visual in question + /// \return True if a node is managed by this scene + public: virtual bool HasVisual(ConstVisualPtr _node) const = 0; + + /// \brief Determine if a given node with the given id is managed by + /// this Scene + /// \param[in] _id ID of the node in question + /// \return True if a node is managed by this scene + public: virtual bool HasVisualId(unsigned int _id) const = 0; + + /// \brief Determine if a given node with the given name is managed by + /// this Scene + /// \param[in] _name Name of the node in question + /// \return True if a node is managed by this scene + public: virtual bool HasVisualName(const std::string &_name) const = 0; + + /// \brief Get node with the given id. If no node exists with the given + /// id, NULL will be returned. + /// \param[in] _id ID of the desired node + /// \return The desired node + public: virtual VisualPtr VisualById(unsigned int _id) const = 0; + + /// \brief Get node with the given name. If no node exists with the given + /// name, NULL will be returned. + /// \param[in] _name Name of the desired node + /// \return The desired node + public: virtual VisualPtr VisualByName( + const std::string &_name) const = 0; + + /// \brief Get node at the given index. If no node exists at the given + /// index, NULL will be returned. + /// \param[in] _index Index of the desired node + /// \return The desired node + public: virtual VisualPtr VisualByIndex(unsigned int _index) const = 0; + + /// \brief Destroy given node. If the given node is not managed by this + /// scene, no work will be done. Depending on the _recursive argument, + /// this function will either detach all child nodes from the scene graph + /// or recursively destroy them. + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _node Visual pointer to destroy + /// \param[in] _recursive True to recursively destroy the node and its + /// children, false to destroy only this node and detach the children + public: virtual void DestroyVisual(VisualPtr _node, + bool _recursive = false) = 0; + + /// \brief Destroy node with the given id. If no node exists with the + /// given id, no work will be done. All children of the node will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _id ID of the node to destroy + public: virtual void DestroyVisualById(unsigned int _id) = 0; + + /// \brief Destroy node with the given name. If no node exists with the + /// given name, no work will be done. All children of the node will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _name Name of the node to destroy + public: virtual void DestroyVisualByName(const std::string &_name) = 0; + + /// \brief Destroy node at the given index. If no node exists at the + /// given index, no work will be done. All children of the node will + /// consequently be detached from the scene graph, but not destroyed. + /// \param[in] _index Index of the node to destroy + public: virtual void DestroyVisualByIndex(unsigned int _index) = 0; + + /// \brief Destroy all nodes manages by this scene. + public: virtual void DestroyVisuals() = 0; + + /// \brief Determine if a material is registered under the given name + /// \param[in] _name Name of the material in question + /// \return True if a material is registered under the given name + public: virtual bool MaterialRegistered( + const std::string &_name) const = 0; + + /// \brief Get material registered under the given name. If no material + /// is registered under the given name, NULL will be returned. + /// \param[in] _name Name of the desired material + /// \return The specified material + public: virtual MaterialPtr Material( + const std::string &_name) const = 0; + + /// \brief Register a new material under the given name. If the name is + /// already in use, no work will be done. + /// \param[in] _name Name which the material will be registered under + /// \param[in] _material Material to register + public: virtual void RegisterMaterial(const std::string &_name, + MaterialPtr _material) = 0; + + /// \brief Unregister material registered under the given name. If no + /// material is registered under this name, no work will be done. + /// \param[in] _name Name of the material to unregistered + public: virtual void UnregisterMaterial(const std::string &_name) = 0; + + /// \brief Unregister all registered materials + public: virtual void UnregisterMaterials() = 0; + + /// \brief Unregister and destroy a material + /// \param[in] _material Material to be unregistered and destroyed + public: virtual void DestroyMaterial(MaterialPtr _material) = 0; + + /// \brief Unregister and destroys all registered materials + public: virtual void DestroyMaterials() = 0; + + /// \brief Create new directional light. A unique ID and name will + /// automatically be assigned to the light. + /// \return The created light + public: virtual DirectionalLightPtr CreateDirectionalLight() = 0; + + /// \brief Create new directional light with the given ID. A unique name + /// will automatically be assigned to the light. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new light + /// \return The created light + public: virtual DirectionalLightPtr CreateDirectionalLight( + unsigned int _id) = 0; + + /// \brief Create new directional light with the given name. A unique ID + /// will automatically be assigned to the light. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new light + /// \return The created light + public: virtual DirectionalLightPtr CreateDirectionalLight( + const std::string &_name) = 0; + + /// \brief Create new directional light with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new light + /// \param[in] _name Name of the new light + /// \return The created light + public: virtual DirectionalLightPtr CreateDirectionalLight( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new point light. A unique ID and name will + /// automatically be assigned to the light. + /// \return The created light + public: virtual PointLightPtr CreatePointLight() = 0; + + /// \brief Create new point light with the given ID. A unique name + /// will automatically be assigned to the light. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new light + /// \return The created light + public: virtual PointLightPtr CreatePointLight( + unsigned int _id) = 0; + + /// \brief Create new point light with the given name. A unique ID + /// will automatically be assigned to the light. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new light + /// \return The created light + public: virtual PointLightPtr CreatePointLight( + const std::string &_name) = 0; + + /// \brief Create new point light with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new light + /// \param[in] _name Name of the new light + /// \return The created light + public: virtual PointLightPtr CreatePointLight( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new spotlight. A unique ID and name will + /// automatically be assigned to the light. + /// \return The created light + public: virtual SpotLightPtr CreateSpotLight() = 0; + + /// \brief Create new spotlight with the given ID. A unique name + /// will automatically be assigned to the light. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new light + /// \return The created light + public: virtual SpotLightPtr CreateSpotLight( + unsigned int _id) = 0; + + /// \brief Create new spotlight with the given name. A unique ID + /// will automatically be assigned to the light. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new light + /// \return The created light + public: virtual SpotLightPtr CreateSpotLight( + const std::string &_name) = 0; + + /// \brief Create new spotlight with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new light + /// \param[in] _name Name of the new light + /// \return The created light + public: virtual SpotLightPtr CreateSpotLight( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new camera. A unique ID and name will + /// automatically be assigned to the camera. + /// \return The created camera + public: virtual CameraPtr CreateCamera() = 0; + + /// \brief Create new camera with the given ID. A unique name + /// will automatically be assigned to the camera. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new camera + /// \return The created camera + public: virtual CameraPtr CreateCamera( + unsigned int _id) = 0; + + /// \brief Create new camera with the given name. A unique ID + /// will automatically be assigned to the camera. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new camera + /// \return The created camera + public: virtual CameraPtr CreateCamera( + const std::string &_name) = 0; + + /// \brief Create new camera with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new camera + /// \param[in] _name Name of the new camera + /// \return The created camera + public: virtual CameraPtr CreateCamera( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new depth camera. A unique ID and name will + /// automatically be assigned to the camera. + /// \return The created camera + public: virtual DepthCameraPtr CreateDepthCamera() = 0; + + /// \brief Create new depth camera with the given ID. A unique name + /// will automatically be assigned to the camera. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new camera + /// \return The created camera + public: virtual DepthCameraPtr CreateDepthCamera( + unsigned int _id) = 0; + + /// \brief Create new depth camera with the given name. A unique ID + /// will automatically be assigned to the camera. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new camera + /// \return The created camera + public: virtual DepthCameraPtr CreateDepthCamera( + const std::string &_name) = 0; + + /// \brief Create new depth camera with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new camera + /// \param[in] _name Name of the new camera + /// \return The created camera + public: virtual DepthCameraPtr CreateDepthCamera( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new thermal camera. A unique ID and name will + /// automatically be assigned to the camera. + /// \return The created camera + public: virtual ThermalCameraPtr CreateThermalCamera() = 0; + + /// \brief Create new thermal camera with the given ID. A unique name + /// will automatically be assigned to the camera. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new camera + /// \return The created camera + public: virtual ThermalCameraPtr CreateThermalCamera( + unsigned int _id) = 0; + + /// \brief Create new thermal camera with the given name. A unique ID + /// will automatically be assigned to the camera. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new camera + /// \return The created camera + public: virtual ThermalCameraPtr CreateThermalCamera( + const std::string &_name) = 0; + + /// \brief Create new thermal camera with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new camera + /// \param[in] _name Name of the new camera + /// \return The created camera + public: virtual ThermalCameraPtr CreateThermalCamera( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new BoundingBox camera. A unique ID and name will + /// automatically be assigned to the camera. + /// \return The created camera + public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera() = 0; + + /// \brief Create new BoundingBox camera with the given ID. + /// A unique name will automatically be assigned to the camera. + /// If the given ID is already in use, NULL will be returned. + /// \param[in] _id ID of the new camera + /// \return The created camera + public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( + unsigned int _id) = 0; + + /// \brief Create new BoundingBox camera with the given name. + /// A unique ID will automatically be assigned to the camera. + /// If the given name is already in use, NULL will be returned. + /// \param[in] _name Name of the new camera + /// \return The created camera + public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( + const std::string &_name) = 0; + + /// \brief Create new BoundingBox camera with the given ID & name. If + /// either the given ID or name is already in use, will return NULL. + /// \param[in] _id ID of the new camera + /// \param[in] _name Name of the new camera + /// \return The created camera + public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new segmentation camera. A unique ID and name will + /// automatically be assigned to the camera. + /// \return The created camera + public: virtual SegmentationCameraPtr CreateSegmentationCamera() = 0; + + /// \brief Create new segmentation camera with the given ID. + /// A unique name will automatically be assigned to the camera. + /// If the given ID is already in use, NULL will be returned. + /// \param[in] _id ID of the new camera + /// \return The created camera + public: virtual SegmentationCameraPtr CreateSegmentationCamera( + unsigned int _id) = 0; + + /// \brief Create new segmentation camera with the given name. + /// A unique ID will automatically be assigned to the camera. + /// If the given name is already in use, NULL will be returned. + /// \param[in] _name Name of the new camera + /// \return The created camera + public: virtual SegmentationCameraPtr CreateSegmentationCamera( + const std::string &_name) = 0; + + /// \brief Create new segmentation camera with the given name and ID. If + /// either the given ID or name is already in use, will return NULL. + /// \param[in] _id ID of the new camera + /// \param[in] _name Name of the new camera + /// \return The created camera + public: virtual SegmentationCameraPtr CreateSegmentationCamera( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new gpu rays caster. A unique ID and name will + /// automatically be assigned to the gpu rays caster. + /// \return The created gpu rays caster + public: virtual GpuRaysPtr CreateGpuRays() = 0; + + /// \brief Create new gpu rays caster with the given ID. A unique name + /// will automatically be assigned to the gpu rays caster. If the given + /// ID is already in use, NULL will be returned. + /// \param[in] _id ID of the new gpu rays caster + /// \return The created gpu rays caster + public: virtual GpuRaysPtr CreateGpuRays(unsigned int _id) = 0; + + /// \brief Create new gpu rays caster with the given name. A unique ID + /// will automatically be assigned to the gpu rays caster. If the given + /// name is already in use, NULL will be returned. + /// \param[in] _name Name of the new gpu rays caster + /// \return The created gpu ray caster + public: virtual GpuRaysPtr CreateGpuRays( + const std::string &_name) = 0; + + /// \brief Create new gpu rays caster with the given name. If either + /// the given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the gpu ray caster + /// \param[in] _name Name of the new gpu ray caster + /// \return The created Gpu ray caster + public: virtual GpuRaysPtr CreateGpuRays( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new visual. A unique ID and name will + /// automatically be assigned to the visual. + /// \return The created visual + public: virtual VisualPtr CreateVisual() = 0; + + /// \brief Create new visual with the given ID. A unique name + /// will automatically be assigned to the visual. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new visual + /// \return The created visual + public: virtual VisualPtr CreateVisual( + unsigned int _id) = 0; + + /// \brief Create new visual with the given name. A unique ID + /// will automatically be assigned to the visual. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new visual + /// \return The created visual + public: virtual VisualPtr CreateVisual( + const std::string &_name) = 0; + + /// \brief Create new visual with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new visual + /// \param[in] _name Name of the new visual + /// \return The created visual + public: virtual VisualPtr CreateVisual( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new arrow visual. A unique ID and name will + /// automatically be assigned to the visual. + /// \return The created arrow visual + public: virtual ArrowVisualPtr CreateArrowVisual() = 0; + + /// \brief Create new arrow visual with the given ID. A unique name + /// will automatically be assigned to the visual. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new arrow visual + /// \return The created arrow visual + public: virtual ArrowVisualPtr CreateArrowVisual( + unsigned int _id) = 0; + + /// \brief Create new arrow visual with the given name. A unique ID + /// will automatically be assigned to the visual. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new arrow visual + /// \return The created arrow visual + public: virtual ArrowVisualPtr CreateArrowVisual( + const std::string &_name) = 0; + + /// \brief Create new arrow visual with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new arrow visual + /// \param[in] _name Name of the new arrow visual + /// \return The created arrow visual + public: virtual ArrowVisualPtr CreateArrowVisual( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new axis visual. A unique ID and name will + /// automatically be assigned to the visual. + /// \return The created axis visual + public: virtual AxisVisualPtr CreateAxisVisual() = 0; + + /// \brief Create new axis visual with the given ID. A unique name + /// will automatically be assigned to the visual. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new axis visual + /// \return The created axis visual + public: virtual AxisVisualPtr CreateAxisVisual( + unsigned int _id) = 0; + + /// \brief Create new axis visual with the given name. A unique ID + /// will automatically be assigned to the visual. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new axis visual + /// \return The created axis visual + public: virtual AxisVisualPtr CreateAxisVisual( + const std::string &_name) = 0; + + /// \brief Create new axis visual with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new axis visual + /// \param[in] _name Name of the new axis visual + /// \return The created axis visual + public: virtual AxisVisualPtr CreateAxisVisual( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new gizmo visual. A unique ID and name will + /// automatically be assigned to the visual. + /// \return The created gizmo visual + public: virtual GizmoVisualPtr CreateGizmoVisual() = 0; + + /// \brief Create new gizmo visual with the given ID. A unique name + /// will automatically be assigned to the visual. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new gizmo visual + /// \return The created gizmo visual + public: virtual GizmoVisualPtr CreateGizmoVisual( + unsigned int _id) = 0; + + /// \brief Create new gizmo visual with the given name. A unique ID + /// will automatically be assigned to the visual. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new gizmo visual + /// \return The created gizmo visual + public: virtual GizmoVisualPtr CreateGizmoVisual( + const std::string &_name) = 0; + + /// \brief Create new gizmo visual with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new gizmo visual + /// \param[in] _name Name of the new gizmo visual + /// \return The created gizmo visual + public: virtual GizmoVisualPtr CreateGizmoVisual( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new CoM visual. A unique ID and name will + /// automatically be assigned to the CoM visual. + /// \return The created CoM visual + public: virtual COMVisualPtr CreateCOMVisual() = 0; + + /// \brief Create new CoM visual with the given ID. A unique name + /// will automatically be assigned to the visual. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new CoM visual + /// \return The created CoM visual + public: virtual COMVisualPtr CreateCOMVisual( + unsigned int _id) = 0; + + /// \brief Create new CoM visual with the given name. A unique ID + /// will automatically be assigned to the visual. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new CoM visual + /// \return The created CoM visual + public: virtual COMVisualPtr CreateCOMVisual( + const std::string &_name) = 0; + + /// \brief Create new CoM visual with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new CoM visual + /// \param[in] _name Name of the new CoM visual + /// \return The created CoM visual + public: virtual COMVisualPtr CreateCOMVisual( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new inertia visual. A unique ID and name will + /// automatically be assigned to the inertia visual. + /// \return The created inertia visual + public: virtual InertiaVisualPtr CreateInertiaVisual() = 0; + + /// \brief Create new inertia visual with the given ID. A unique name + /// will automatically be assigned to the visual. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new inertia visual + /// \return The created light visual + public: virtual InertiaVisualPtr CreateInertiaVisual( + unsigned int _id) = 0; + + /// \brief Create new inertia visual with the given name. A unique ID + /// will automatically be assigned to the visual. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new inertia visual + /// \return The created light visual + public: virtual InertiaVisualPtr CreateInertiaVisual( + const std::string &_name) = 0; + + /// \brief Create new inertia visual with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new inertia visual + /// \param[in] _name Name of the new inertia visual + /// \return The created inertia visual + public: virtual InertiaVisualPtr CreateInertiaVisual( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new joint visual. A unique ID and name will + /// automatically be assigned to the Joint visual. + /// \return The created Joint visual + public: virtual JointVisualPtr CreateJointVisual() = 0; + + /// \brief Create new joint visual with the given ID. A unique name + /// will automatically be assigned to the visual. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new Joint visual + /// \return The created Joint visual + public: virtual JointVisualPtr CreateJointVisual( + unsigned int _id) = 0; + + /// \brief Create new joint visual with the given name. A unique ID + /// will automatically be assigned to the visual. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new Joint visual + /// \return The created Joint visual + public: virtual JointVisualPtr CreateJointVisual( + const std::string &_name) = 0; + + /// \brief Create new joint visual with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new Joint visual + /// \param[in] _name Name of the new Joint visual + /// \return The created Joint visual + public: virtual JointVisualPtr CreateJointVisual( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new light visual. A unique ID and name will + /// automatically be assigned to the light visual. + /// \return The created light visual + public: virtual LightVisualPtr CreateLightVisual() = 0; + + /// \brief Create new light visual with the given ID. A unique name + /// will automatically be assigned to the visual. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new light visual + /// \return The created light visual + public: virtual LightVisualPtr CreateLightVisual( + unsigned int _id) = 0; + + /// \brief Create new light visual with the given name. A unique ID + /// will automatically be assigned to the visual. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new light visual + /// \return The created light visual + public: virtual LightVisualPtr CreateLightVisual( + const std::string &_name) = 0; + + /// \brief Create new light visual with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new light visual + /// \param[in] _name Name of the new light visual + /// \return The created light visual + public: virtual LightVisualPtr CreateLightVisual( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new box geometry + /// \return The created box + public: virtual GeometryPtr CreateBox() = 0; + + /// \brief Create new capsule geometry + /// \return The created capsule + public: virtual CapsulePtr CreateCapsule() = 0; + + /// \brief Create new cone geometry + /// \return The created cone + public: virtual GeometryPtr CreateCone() = 0; + + /// \brief Create new cylinder geometry + /// \return The created cylinder + public: virtual GeometryPtr CreateCylinder() = 0; + + /// \brief Create new plane geometry + /// \return The created plane + public: virtual GeometryPtr CreatePlane() = 0; + + /// \brief Create new sphere or ellipsoid geometry + /// This method allow to create ellipsoid too, because it can be scaled + /// in 3 dimensions. + /// \return The created sphere + public: virtual GeometryPtr CreateSphere() = 0; + + /// \brief Create new mesh geomerty. The rendering::Mesh will be created + /// from a common::Mesh retrieved from common::MeshManager using the given + /// mesh name. If no mesh exists by this name, NULL will be returned. All + /// sub-meshes will be loaded into the created mesh, uncentered. + /// \param[in] _meshName Name of the reference mesh + /// \return The created mesh + public: virtual MeshPtr CreateMesh(const std::string &_meshName) = 0; + + /// \brief Create new mesh geomerty. The rendering::Mesh will be created + /// from the given common::Mesh. All sub-meshes will be loaded into this + /// created mesh, uncentered. + /// \param[in] _mesh Reference mesh + /// \return The created mesh + public: virtual MeshPtr CreateMesh(const common::Mesh *_mesh) = 0; + + /// \brief Create new mesh geometry. The rendering::Mesh will be created + /// from the given common::Mesh specified in the MeshDescriptor. + /// Sub-meshes will be loaded and centered according to the descriptor. + /// \param[in] _desc Descriptor of the mesh to load + /// \return The created mesh + public: virtual MeshPtr CreateMesh(const MeshDescriptor &_desc) = 0; + + /// \brief Create new grid geometry. + /// \return The created grid + public: virtual GridPtr CreateGrid() = 0; + + /// \brief Create new wire box geometry. + /// \return The created wire box + public: virtual WireBoxPtr CreateWireBox() = 0; + + /// \brief Create new marker geometry. + /// \return The created marker + public: virtual MarkerPtr CreateMarker() = 0; + + /// \brief Create new lidar visual. A unique ID and name will + /// automatically be assigned to the lidar visual. + /// \return The created lidar visual + public: virtual LidarVisualPtr CreateLidarVisual() = 0; + + /// \brief Create new lidar visual with the given ID. A unique name + /// will automatically be assigned to the lidar visual. If the given + /// ID is already in use, NULL will be returned. + /// \param[in] _id ID of the new lidar visual + /// \return The created lidar visual + public: virtual LidarVisualPtr CreateLidarVisual(unsigned int _id) = 0; + + /// \brief Create new lidar visual with the given name. A unique ID + /// will automatically be assigned to the lidar visual. If the given + /// name is already in use, NULL will be returned. + /// \param[in] _name Name of the new lidar visual + /// \return The created lidar visual + public: virtual LidarVisualPtr CreateLidarVisual( + const std::string &_name) = 0; + + /// \brief Create new lidar visual with the given name. If either + /// the given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the lidar visual. + /// \param[in] _name Name of the new lidar visual. + /// \return The created lidar visual + public: virtual LidarVisualPtr CreateLidarVisual( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Create new heightmap geomerty. The rendering::Heightmap will be + /// created from the given HeightmapDescriptor. + /// \param[in] _desc Data about the heightmap + /// \return The created heightmap + public: virtual HeightmapPtr CreateHeightmap( + const HeightmapDescriptor &_desc) = 0; + + /// \brief Create new text geometry. + /// \return The created text + public: virtual TextPtr CreateText() = 0; + + /// \brief Create new material with the given name. Created material will + /// have default properties. + /// \param[in] _name Name for the new material. + /// \return The created material + public: virtual MaterialPtr CreateMaterial(const std::string &_name = "") + = 0; + + /// \brief Create new material from the reference common::Material + /// \param[in] _material Reference material + /// \return The created material + public: virtual MaterialPtr CreateMaterial( + const common::Material &_material) = 0; + + /// \brief Create new render texture + /// \return The created render texture + public: virtual RenderTexturePtr CreateRenderTexture() = 0; + + /// \brief Create new render window. This feature is render engine + /// dependent. If the engine does not support attaching to a windowing + /// system then it should behave as a a render texture. + /// \return The created render window + public: virtual RenderWindowPtr CreateRenderWindow() = 0; + + /// \brief Create new ray query + /// \return The created ray query + public: virtual RayQueryPtr CreateRayQuery() = 0; + + /// \brief Create new particle emitter. A unique ID and name will + /// automatically be assigned to the visual. + /// \return The created particle emitter + public: virtual ParticleEmitterPtr CreateParticleEmitter() = 0; + + /// \brief Create new particle emitter with the given ID. A unique name + /// will automatically be assigned to the visual. If the given ID is + /// already in use, NULL will be returned. + /// \param[in] _id ID of the new particle emitter + /// \return The created particle emitter + public: virtual ParticleEmitterPtr CreateParticleEmitter( + unsigned int _id) = 0; + + /// \brief Create new particle emitter with the given name. A unique ID + /// will automatically be assigned to the visual. If the given name is + /// already in use, NULL will be returned. + /// \param[in] _name Name of the new particle emitter + /// \return The created particle emitter + public: virtual ParticleEmitterPtr CreateParticleEmitter( + const std::string &_name) = 0; + + /// \brief Create new particle emitter with the given name. If either the + /// given ID or name is already in use, NULL will be returned. + /// \param[in] _id ID of the new particle emitter + /// \param[in] _name Name of the new particle emitter + /// \return The created particle emitter + public: virtual ParticleEmitterPtr CreateParticleEmitter( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Enable sky in the scene. + /// \param[in] _enabled True to enable sky + public: virtual void SetSkyEnabled(bool _enabled) = 0; + + /// \brief Get whether the sky is enabled in the scene. + /// \return true to sky is enabled, false otherwise + public: virtual bool SkyEnabled() const = 0; + + /// \brief Prepare scene for rendering. The scene will flushing any scene + /// changes by traversing scene-graph, calling PreRender on all objects + public: virtual void PreRender() = 0; + + /// \brief Call this function after you're done updating ALL cameras + /// \remark Each PreRender must have a correspondent PostRender + /// \remark Particle FX simulation is moved forward after this call + /// + /// \see Scene::SetCameraPassCountPerGpuFlush + public: virtual void PostRender() = 0; + + /// \brief + /// The ideal render loop is as follows: + /// + /// \code + /// scene->PreRender(); + /// for (auto &camera in cameras) + /// camera->Render(); + /// for (auto &camera in cameras) + /// camera->PostRender(); + /// scene->PostRender(); + /// \endcode + /// + /// Now... Camera Render calls MUST happen between Scene::PreRender and + /// Scene::PostRender. + /// + /// The scene must not be modified (e.g. add/remove objects, lights, etc) + /// while inside Scene PreRender/PostRender + /// + /// # Legacy mode: Set this value to 0. + /// + /// Old projects migrating to newer ign versions may break + /// these rules (e.g. not calling Render between Scene's + /// Pre/PostRender). + /// + /// Setting this value to 0 forces Gazebo to flush commands for + /// every camera; thus avoiding the need to call PostRender at all + /// + /// This is much slower but will ease porting, specially + /// if it's not easy to adapt your code to call PostRender for some + /// reason (in non-legacy mode each call *must* correspond to a + /// previous PreRender call) + /// + /// Legacy mode forces Particle FX simulations to move forward + /// after each camera render, which can cause inconsistencies + /// when Cameras are supposed to be rendering the same frame from + /// different angles + /// + /// # New mode i.e. values greater than 0: + /// + /// The CPU normally queues up of rendering commands from each Camera and + /// then waits for the GPU to finish up. + /// + /// 1. If we flush too often, the CPU will often have to wait for + /// the GPU to finish. + /// 2. If we flush infrequently, RAM consumption will rise due to + /// queueing up too much unsubmitted work. + /// + /// Larger values values queue up more work; lower values flush more + /// frequently. + /// + /// Note that work may be submitted earlier if required by a specific + /// operation (e.g. reading GPU -> CPU) + /// + /// A sensible value in the range of [2; 6] is probably the best + /// ratio between parallel performance / RAM cost. + /// + /// Actual value depends on scene complexity and number of shadow + /// casting lights + /// + /// If you're too tight on RAM consumption, try setting this value to 1. + /// + /// ## Example: + /// + /// Cubemap rendering w/ 3 probes and 5 shadowmaps can cause + /// a blow up of passes: + /// + /// (5 shadow maps per face + 1 regular render) x 6 faces x 3 probes = + /// 108 render_scene passes. + /// 108 is way too much, causing out of memory situations; + /// + /// so setting the value to 6 (1 cubemap face = 1 pass) will + /// force one flush per cubemap face, flushing a total of 3 times + /// (one per cubemap). + /// + /// ## Upper bound + /// + /// Once Scene::PostRender is called, a flush is always forced. + /// + /// If you set a value of e.g. 6, but you have a single camera, it + /// will be flushed after Scene::PostRender, thus having a value of 1 or + /// 6 won't matter as the result will be exactly the same (in every term: + /// performance, memory consumption) + /// + /// A value of 6 is like an upper bound. + /// We may queue _up to_ 6 render passes or less; but never more. + /// + /// \remarks Not all rendering engines care about this. + /// ogre2 plugin does. + /// + /// \param[in] _numPass 0 for old projects who can't or don't know + /// when to call PostRender and prefer to penalize rendering + /// performance + /// Value in range [1; 255] + public: virtual void SetCameraPassCountPerGpuFlush(uint8_t _numPass) = 0; + + /// \brief Returns the value set in SetCameraPassCountPerGpuFlush + /// \return Value in range [0; 255]. + /// ALWAYS returns 0 for plugins that ignore + /// SetCameraPassCountPerGpuFlush + public: virtual uint8_t CameraPassCountPerGpuFlush() const = 0; + + /// \brief Checks if SetCameraPassCountPerGpuFlush is 0 + /// \return True if Gazebo is using the old method (i.e. 0). + /// ALWAYS returns true for plugins that ignore + /// SetCameraPassCountPerGpuFlush + public: virtual bool LegacyAutoGpuFlush() const = 0; + + /// \brief Remove and destroy all objects from the scene graph. This does + /// not completely destroy scene resources, so new objects can be created + /// and added to the scene afterwards. + public: virtual void Clear() = 0; + + /// \brief Completely destroy the scene an all its resources. Continued + /// use of this scene after its destruction will result in undefined + /// behavior. + public: virtual void Destroy() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/SegmentationCamera.hh b/include/gz/rendering/SegmentationCamera.hh new file mode 100644 index 000000000..afc69079d --- /dev/null +++ b/include/gz/rendering/SegmentationCamera.hh @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_SEGMENTATIONCAMERA_HH_ +#define IGNITION_RENDERING_SEGMENTATIONCAMERA_HH_ + +#include +#include + +#include +#include + +#include "ignition/rendering/Camera.hh" + + +namespace ignition +{ + namespace rendering + { + /// \brief Segmentation types for Semantic / Panpoptic segmentation + enum class SegmentationType + { + /// \brief Pixels of same label from different items + /// have the same color & id. + ST_SEMANTIC = 0, + + /// \brief Pixels of same label from different items, have different + /// color & id. 1 channel for label id & 2 channels for instance id + ST_PANOPTIC = 1 + }; + + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \class SegmentationCamera SegmentationCamera.hh + /// ignition/rendering/SegmentationCamera.hh + /// \brief Poseable Segmentation camera used for rendering the scene graph. + /// This camera is designed to produce segmentation data, instead of a 2D + /// image. + class IGNITION_RENDERING_VISIBLE SegmentationCamera : + public virtual Camera + { + /// \brief Destructor + public: virtual ~SegmentationCamera() { } + + /// \brief Create a texture which will hold the segmentation data + public: virtual void CreateSegmentationTexture() = 0; + + /// \brief Get the segmentation image data. + /// If the segmentation type is panoptic, the first two channels are the + /// instance count, and the last channel is the label. + /// \return The labels-buffer as an array of unsigned ints + public: virtual uint8_t *SegmentationData() const = 0; + + /// \brief Connect to the new Segmentation image event + /// \param[in] _subscriber Subscriber callback function. + /// The callback function arguments are: + /// + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual ignition::common::ConnectionPtr + ConnectNewSegmentationFrame( + std::function _subscriber) = 0; + + /// \brief Set Segmentation Type + /// \param[in] _type Segmentation Type + public: virtual void SetSegmentationType(SegmentationType _type) = 0; + + /// \brief Get Segmentation Type + /// \return Segmentation Type + public: virtual SegmentationType Type() const = 0; + + /// \brief Enable Color map mode to generate colored semantics + /// \param[in] _enable True to generate colored map, False to generate + /// label id map + public: virtual void EnableColoredMap(bool _enable) = 0; + + /// \brief Check if color map mode is enabled + /// \return True if colored map, False if label id map + public: virtual bool IsColoredMap() const = 0; + + /// \brief Set color for background & unlabeled items in the colored map + /// \param[in] _color Color of background & unlabeled items + public: virtual void SetBackgroundColor(const math::Color &_color) = 0; + + /// \brief Set label for background & unlabeled items in the semantic map + /// \param[in] _label label of background & unlabeled items + public: virtual void SetBackgroundLabel(int _label) = 0; + + /// \brief Get color for background & unlabeled items in the colored map + /// \return Color of background & unlabeled items + public: virtual const math::Color &BackgroundColor() const = 0; + + /// \brief Get label for background & unlabeled items in the semantic map + /// \return label of background & unlabeled items + public: virtual int BackgroundLabel() const = 0; + + /// \brief Convert the colored map stored in the internal buffer to label + /// IDs map, so users get both the colored map and the corresponding IDs + /// map. This function must be called before the next render loop and + /// the colored map mode must be enabeled + /// \param[out] _labelBuffer A buffer that is populated with the label + /// IDs map data. This output buffer must be allocated with the same size + /// before calling + public: virtual void LabelMapFromColoredBuffer( + uint8_t *_labelBuffer) const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Sensor.hh b/include/gz/rendering/Sensor.hh new file mode 100644 index 000000000..2a4b36819 --- /dev/null +++ b/include/gz/rendering/Sensor.hh @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_SENSOR_HH_ +#define GZ_RENDERING_SENSOR_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/Node.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Sensor Sensor.hh ignition/rendering/Sensor.hh + /// \brief Represents a scene sensor. The most obvious example is a camera, + /// but it can be anything that generates output from the scene. + class IGNITION_RENDERING_VISIBLE Sensor : + public virtual Node + { + /// \brief Sensor + public: virtual ~Sensor() { } + + /// \brief Set visibility mask + /// \param[in] _mask Visibility mask + public: virtual void SetVisibilityMask(uint32_t _mask) = 0; + + /// \brief Get visibility mask + /// \return visibility mask + public: virtual uint32_t VisibilityMask() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/ShaderParam.hh b/include/gz/rendering/ShaderParam.hh new file mode 100644 index 000000000..211f2bfa9 --- /dev/null +++ b/include/gz/rendering/ShaderParam.hh @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GZ_RENDERING_SHADERPARAM_HH_ +#define GZ_RENDERING_SHADERPARAM_HH_ + +#include +#include +#include +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief forward declaration + class ShaderParamPrivate; + + /// \brief a variant type that holds params that can be passed to a shader + class IGNITION_RENDERING_VISIBLE ShaderParam + { + public: enum ParamType : uint16_t + { + /// \brief Type none + PARAM_NONE = 0, + + /// \brief Float type parameter + PARAM_FLOAT = 1, + + /// \brief Integer type parameter + PARAM_INT = 2, + + /// \brief Float Buffer type parameter + PARAM_FLOAT_BUFFER = 3, + + /// \brief Int Buffer type parameter + PARAM_INT_BUFFER = 4, + + /// \brief texture type parameter + PARAM_TEXTURE = 5, + + /// \brief cube map type parameter + PARAM_TEXTURE_CUBE = 6, + }; + + /// \brief constructor + public: ShaderParam(); + + /// \brief copy constructor + /// \param[in] _other Another ShaderParam + public: ShaderParam(const ShaderParam &_other); + + /// \brief destructor + public: ~ShaderParam(); + + /// \brief Get the type of this parameter + /// \return Type of this parameter + public: ParamType Type() const; + + /// \brief Get the element count of this parameter's buffer + /// \return Count of elements in this parameter's buffer + public: uint32_t Count() const; + + /// \brief Set from another ShaderParam + /// \param[in] _other Another ShaderParam + /// \return Reference to this ShaderParam + public: ShaderParam &operator=(const ShaderParam &_other); + + /// \brief Set this to be a float parameter + /// \param[in] _value Value to set this parameter to + public: void operator=(const float _value); + + /// \brief Set this to be an integer parameter + /// \param[in] _value Value to set this parameter to + public: void operator=(const int _value); + + /// \brief Set this to be a texture parameter + /// \param[in] _value Value to set this parameter to + /// \param[in] _type Type of texture + /// \param[in] _uvSetIndex Texture coordinate set index + public: void SetTexture(const std::string &_value, + ShaderParam::ParamType _type = ShaderParam::ParamType::PARAM_TEXTURE, + uint32_t _uvSetIndex = 0u); + + /// \brief Set this to be a buffer parameter + /// \param[in] _count Number of 32-bit elements in the buffer + public: void InitializeBuffer(uint32_t _count); + + /// \brief Copy a buffer to this parameter + /// \param[in] _floatBuffer Source buffer to copy from + public: void UpdateBuffer(float *_floatBuffer); + + /// \brief Copy a buffer to this parameter + /// \param[in] _intBuffer Source buffer to copy from + public: void UpdateBuffer(int *_intBuffer); + + /// \brief Get the value of this parameter if it is a float + /// \param[out] _value variable the value will be copied to + /// \return true if the parameter is the expected type + public: bool Value(float *_value) const; + + /// \brief Get the value of this parameter if it is an int + /// \param[out] _value variable the value will be copied to + /// \return true if the parameter is the expected type + public: bool Value(int *_value) const; + + /// \brief Get the value of this parameter if it is a texture + /// \param[out] _value variable the value will be copied to + /// \param[out] _uvSetIndex Texture coordinate set index + /// \return true if the parameter filled + public: bool Value(std::string &_value, uint32_t &_uvSetIndex) const; + + /// \brief Get the value of this parameter if it is a buffer + /// \param[out] _buffer variable the value will be copied to + /// \return true if the parameter is the expected type + public: bool Buffer(std::shared_ptr &_buffer) const; + + /// \brief private implementation + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} + +#endif diff --git a/include/gz/rendering/ShaderParams.hh b/include/gz/rendering/ShaderParams.hh new file mode 100644 index 000000000..b575d081f --- /dev/null +++ b/include/gz/rendering/ShaderParams.hh @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GZ_RENDERING_SHADERPARAMS_HH_ +#define GZ_RENDERING_SHADERPARAMS_HH_ + +#include +#include +#include + +#include "gz/rendering/Export.hh" +#include "gz/rendering/ShaderParam.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief forward declaration + class ShaderParamsPrivate; + + /// \brief a map that holds params to be passed to a shader + class IGNITION_RENDERING_VISIBLE ShaderParams + { + /// \brief forward declaration + class IteratorPrivate; + + /// \brief Iterator for looping through params + /// \remarks implements a forward-iterator + class IGNITION_RENDERING_VISIBLE Iterator + { + /// \brief Default constructor + public: Iterator(); + + /// \brief Special constructor used by ShaderParams implementation + /// \param[in] _dataPtr Pointer to private data. + public: explicit Iterator(std::unique_ptr _dataPtr); + + /// \brief Copy constructor + /// \param[in] _iter Another iterator + public: Iterator(const Iterator &_iter); + + /// \brief Copy assignment + /// \param[in] _iter Another iterator + /// \return this + Iterator& operator=(const Iterator &_iter); + + /// \brief Destructor + public: ~Iterator(); + + /// \brief Equality operator + /// \param[in] _iter Another iterator + /// \return True if input interator equal to this one, false otherwise. + public: bool operator==(const Iterator &_iter); + + /// \brief Inequality operator + /// \param[in] _iter Another iterator + /// \return True if input interator is equal to this one, + /// false otherwise + public: bool operator!=(const Iterator &_iter); + + /// \brief Dereference operator + public: const std::pair &operator*(); + + /// \brief Arrow dereference operator + public: const std::pair *operator->(); + + /// \brief prefix increment + public: Iterator &operator++(); + + /// \brief postfix increment + public: Iterator operator++(int); + + private: std::unique_ptr dataPtr; + }; + + /// \brief constructor + public: ShaderParams(); + + /// \brief destructor + public: ~ShaderParams(); + + /// \brief Access a param with a given name + /// \param[in] _name Identifier for the parameter + /// \returns parameter reference + public: ShaderParam &operator[](const std::string &_name); + + /// \brief Access a param with a given name + /// \param[in] _name Identifier for the parameter + /// \returns const parameter reference + public: const ShaderParam &operator[](const std::string &_name) const; + + /// \brief Iterator to first parameter + /// \remarks Necessary for range-base for loop support + /// \return Iterator pointing to first parameter. + public: Iterator begin() const; + + /// \brief Iterator to one past last param + /// \remarks Necessary for range-base for loop support + /// \return Iterator pointing to one past last parameter. + public: Iterator end() const; + + /// \brief Have the params changed? + /// \internal + /// \returns true if the parameters have changed + public: bool IsDirty() const; + + /// \brief Resets the dirty flag + /// \internal + public: void ClearDirty(); + + /// \brief private implementation + private: std::unique_ptr dataPtr; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/ShaderType.hh b/include/gz/rendering/ShaderType.hh new file mode 100644 index 000000000..f4d87ccc4 --- /dev/null +++ b/include/gz/rendering/ShaderType.hh @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_SHADERTYPE_HH_ +#define GZ_RENDERING_SHADERTYPE_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \enum ShaderType ShaderType.hh ignition/rendering/ShaderType.hh + /// \brief Available types of shaders. Note that not all rendering-engines + /// will be able to use each type. They will instead default to the closest + /// alternative. + enum IGNITION_RENDERING_VISIBLE ShaderType + { + /// \brief Unknown or errant type + ST_UNKNOWN = 0, + + /// \brief Per pixel lighting shader + ST_PIXEL = 1, + + /// \brief Per vertex lighting shader + ST_VERTEX = 2, + + /// \brief Object-space normal map shader + ST_NORM_OBJ = 3, + + /// \brief Tangent-space normal map shader + ST_NORM_TAN = 4, + + /// \brief Total number of shader types + ST_COUNT = 5, + }; + + /// \class ShaderUtil ShaderType.hh ignition/rendering/ShaderType.hh + /// \brief Provides supporting functions for ShaderType enum + class IGNITION_RENDERING_VISIBLE ShaderUtil + { + /// \brief Determine if given type is valid ShaderType enum + /// \param[in] _type Enum value to be evaluated + /// \return True if the given type is valid + public: static bool IsValid(ShaderType _type); + + /// \brief Sanitize given type. If the given value is invalid, + /// ST_UNKNOWN will be returned, otherwise input will be returned + /// unchanged. + /// \param[in] _type Shader type to be sanitized + /// \return The santized shader type + public: static ShaderType Sanitize(ShaderType _type); + + /// \brief Get human-readable name for shader type value. + /// \param[in] _type Shader type enum value + /// \return The type name + public: static std::string Name(ShaderType _type); + + /// \brief Get enum value by human-readable name. The given string should + /// match watch is returned by GetName. If an invalid name is given, + /// ST_UNKNOWN will be returned. + /// \param[in] _name Name of the shader type to be retrieved + /// \return The specified ShaderType enum value + public: static ShaderType Enum(const std::string &_name); + + /// \brief Array of human-readable names for each ShaderType + private: static const char *names[ST_COUNT]; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Storage.hh b/include/gz/rendering/Storage.hh new file mode 100644 index 000000000..8a94e1f3f --- /dev/null +++ b/include/gz/rendering/Storage.hh @@ -0,0 +1,386 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_STORAGE_HH_ +#define GZ_RENDERING_STORAGE_HH_ + +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Node.hh" +#include "gz/rendering/Light.hh" +#include "gz/rendering/Sensor.hh" +#include "gz/rendering/Visual.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/Material.hh" +#include "gz/rendering/Mesh.hh" +#include "gz/rendering/Export.hh" + +// An X11 header file defines a macro that conflicts with our function name, +// so undefine it here +#ifdef DestroyAll +#undef DestroyAll +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Map Storage.hh ignition/rendering/Storage.hh + /// \brief Storage map from std::string to template class T + /// \tparam T The storage element type + template + class IGNITION_RENDERING_VISIBLE Map + { + /// \typedef TPtr + /// \brief Shared pointer to T + typedef std::shared_ptr TPtr; + + /// \typedef const TPtr + /// \brief Shared pointer to const T + typedef std::shared_ptr ConstTPtr; + + /// \brief Deconstructor + public: virtual ~Map() { } + + /// \brief Get the number of elements in this map + /// \return The number of elements in this map + public: virtual unsigned int Size() const = 0; + + /// \brief Determine if an elements is mapped to the given key + /// \param[in] _key Key of the element in question + /// \return True if an elements is mapped to the given key + public: virtual bool ContainsKey(const std::string &_key) const = 0; + + /// \brief Determine if the given element exists in this map + /// \param[in] _value Element in question + /// \return True if the given element exists in this map + public: virtual bool ContainsValue(ConstTPtr _value) const = 0; + + /// \brief Get the element mapped to the given key + /// \param[in] _key Key of the element in question + /// \return The element mapped to the given key + public: virtual TPtr Get(const std::string &_key) const = 0; + + /// \brief Get the element at the given index + /// \param[in] _index Index of the element in question + /// \return The element at the given index + public: virtual TPtr GetByIndex(unsigned int _index) const = 0; + + /// \brief Map to given element to the given key. If the given key is + /// already in use, no work will be done. + /// \param[in] _key Key of the new element + /// \param[in] _value Element to be mapped + /// \return True if successful + public: virtual bool Put(const std::string &_key, TPtr _value) = 0; + + /// \brief Remove the element mapped to the given key. If the specified + /// element does not exists, no work will be done. + /// \param[in] _key Key of the element in question + public: virtual void Remove(const std::string &_key) = 0; + + /// \brief Remove the given element. If the given element does not exist + /// no work will be done. + /// \param[in] _value Key of the element in question + public: virtual void Remove(TPtr _value) = 0; + + /// \brief Remove all elements from this map + public: virtual void RemoveAll() = 0; + }; + + /// \class Store Storage.hh ignition/rendering/Storage.hh + /// \brief Multi-access storage structure of template class T. Template + /// class T is expected to have functions GetId, GetName(), Destroy() which + /// return unsigned int, std::string, and void respectively. This store + /// will ensure that each element's name and ID are unique. + /// \tparam T The storage element type + template + class IGNITION_RENDERING_VISIBLE Store + { + /// \typedef TPtr + /// \brief Shared pointer to T + typedef std::shared_ptr TPtr; + + /// \typedef const TPtr + /// \brief Shared pointer to const T + typedef std::shared_ptr ConstTPtr; + + /// \brief Deconstructor + public: virtual ~Store() { } + + /// \brief Get number of elements in this store + /// \return The number of elements in this store + public: virtual unsigned int Size() const = 0; + + /// \brief Determine if store contains the given element + /// \param[in] _object The element in question + /// \return True if this store contains the given element + public: virtual bool Contains(ConstTPtr _object) const = 0; + + /// \brief Determine if store contains the element with the given ID + /// \param[in] _id ID of the element in question + /// \return True if this store contains the specified element + public: virtual bool ContainsId(unsigned int _id) const = 0; + + /// \brief Determine if store contains the element with the given name + /// \param[in] _name Name of the element in question + /// \return True if this store contains the specified element + public: virtual bool ContainsName(const std::string &_name) const = 0; + + /// \brief Get element with the given ID + /// \param[in] _id ID of the desired element + /// \return The specified element + public: virtual TPtr GetById(unsigned int _id) const = 0; + + /// \brief Get element with the given name + /// \param[in] _name Name of the desired element + /// \return The specified element + public: virtual TPtr GetByName(const std::string &_name) const = 0; + + /// \brief Get element at the given index + /// \param[in] _index Index of the desired element + /// \return The specified element + public: virtual TPtr GetByIndex(unsigned int _index) const = 0; + + /// \brief Add given element. If the element has already been added + /// or its name or ID conflict with other existing elements, then no + /// work will be done. + /// \param[in] _object Element to be added + /// \return True if successful + public: virtual bool Add(TPtr _object) = 0; + + /// \brief Remove given element. If the given element does not exists + /// in this store, then no work will be done. + /// \param[in] _object Element to be removed + /// \return The removed element + public: virtual TPtr Remove(TPtr _object) = 0; + + /// \brief Remove element with the given ID. If the specified element + /// does not exists in this store, then no work will be done. + /// \param[in] _id ID of the element to be removed + /// \return The removed element + public: virtual TPtr RemoveById(unsigned int _id) = 0; + + /// \brief Remove element with the given name. If the specified element + /// does not exists in this store, then no work will be done. + /// \param[in] _name Name of the element to be removed + /// \return The removed element + public: virtual TPtr RemoveByName(const std::string &_name) = 0; + + /// \brief Remove element at the given index. If the specified element + /// does not exists in this store, then no work will be done. + /// \param[in] _index Index of the element to be removed + /// \return The removed element + public: virtual TPtr RemoveByIndex(unsigned int _index) = 0; + + /// \brief Remove all elements from store + public: virtual void RemoveAll() = 0; + + /// \brief Remove and destroy given element. If the given element does + /// not exists, in this store, then no work will be done. + /// \param[in] _object Element to be removed + public: virtual void Destroy(TPtr _object) = 0; + + /// \brief Remove and destroy element with the given ID. If the specified + /// element does not exists in this store, then no work will be done. + /// \param[in] _id ID of the element to be removed + public: virtual void DestroyById(unsigned int _id) = 0; + + /// \brief Remove and destroy element with the given name. If the + /// specified element does not exists in this store, then no work + /// will be done. + /// \param[in] _name Name of the element to be removed + public: virtual void DestroyByName(const std::string &_name) = 0; + + /// \brief Remove and destroy element at the given index. If the + /// specified element does not exists in this store, then no work + /// will be done. + /// \param[in] _index Index of the element to be removed + public: virtual void DestroyByIndex(unsigned int _index) = 0; + + /// \brief Remove and destroy all elements in store + public: virtual void DestroyAll() = 0; + }; + + /// \class CompositeStore Storage.hh ignition/rendering/Storage.hh + /// ignition/rendering/CompositeStore.hh + /// \brief Represents a collection of Store objects, collectively working as + /// a single composite store. + /// \tparam T The storage element type + template + class IGNITION_RENDERING_VISIBLE CompositeStore : + public Store + { + /// \typedef TPtr + /// \brief Shared pointer to T + typedef std::shared_ptr TPtr; + + /// \typedef TPtr + /// \brief Store of T + typedef Store TStore; + + /// \typedef TStorePtr + /// \brief Shared pointer to TStore + typedef std::shared_ptr TStorePtr; + + /// \typedef const TStorePtr + /// \brief Shared pointer to const TStore + typedef std::shared_ptr ConstTStorePtr; + + /// \brief Deconstructor + public: virtual ~CompositeStore() { } + + /// \brief Get number of Stores + /// \return The number of Stores + public: virtual unsigned int GetStoreCount() const = 0; + + /// \brief Determine if given store exists + /// \param[in] _store Store in question + /// \return True if given store exists + public: virtual bool ContainsStore(ConstTStorePtr _store) const = 0; + + /// \brief Add the given store. If the given store already exists, then + /// no work will be done. + /// \param[in] _store Store to be added + /// \return True if successful + public: virtual bool AddStore(TStorePtr _store) = 0; + + /// \brief Get store at the given index. If no such store exists NULL + /// will be returned. + /// \param[in] _index Index of the desired store + /// \return The specified store + public: virtual TStorePtr GetStore(unsigned int _index) const = 0; + + /// \brief Remove given store. If no such store exists no + /// work will be done and NULL will be returned. + /// \param[in] _store Store to be removed + /// \return The removed store + public: virtual TStorePtr RemoveStore(TStorePtr _store) = 0; + + /// \brief Remove store at the given index. If no such store exists no + /// work will be done and NULL will be returned. + /// \param[in] _index Index of the store to be removed + /// \return The removed store + public: virtual TStorePtr RemoveStore(unsigned int _index) = 0; + }; + + /// \class StoreWrapper Storage.hh ignition/rendering/StoreWrapper.hh + /// \brief Simple wrapper class that allows a Store of type Derived to be + /// treated as a Store of type Base, where Derived is some class derived + /// from Base. This is useful in storing Stores of different derived types + /// in a single CompositeStore instance. + /// \tparam T New storage type + /// \tparam U Some derived class of T + template + class IGNITION_RENDERING_VISIBLE StoreWrapper : + public Store + { + public: virtual ~StoreWrapper() { } + }; + +// armhf failed to build with this code. It can not be removed for the rest +// of arches to keep ABI but should be removed in major versions unreleased +// see https://github.com/ignitionrobotics/ign-rendering/pull/457 +#ifndef __ARM_PCS_VFP + template class Store; + template class Store; + template class Store; + template class Store; + template class Store; + template class Store; + template class Store; + template class Map; + template class CompositeStore; +#endif + + /// \def SceneStore + /// \brief Store of Scene + typedef Store SceneStore; + + /// \def NodeStore + /// \brief Store of Node + typedef Store NodeStore; + + /// \def LightStore + /// \brief Store of Light + typedef Store LightStore; + + /// \def SensorStore + /// \brief Store of Sensor + typedef Store SensorStore; + + /// \def VisualStore + /// \brief Store of Visual + typedef Store VisualStore; + + /// \def GeometryStore + /// \brief Store of Geometry + typedef Store GeometryStore; + + /// \def SubMeshStore + /// \brief Store of SubMesh + typedef Store SubMeshStore; + + /// \def MaterialMap + /// \brief Material Map + typedef Map MaterialMap; + + /// \def NodeCompositeStore + /// \brief Node Composite Store + typedef CompositeStore NodeCompositeStore; + + /// \def SceneStorePtr + /// \brief Shared pointer to SceneStore + typedef std::shared_ptr SceneStorePtr; + + /// \def NodeStorePtr + /// \brief Shared pointer to NodeStore + typedef std::shared_ptr NodeStorePtr; + + /// \def LightStorePtr + /// \brief Shared pointer to LightStore + typedef std::shared_ptr LightStorePtr; + + /// \def SensorStorePtr + /// \brief Shared pointer to SensorStore + typedef std::shared_ptr SensorStorePtr; + + /// \def VisualStorePtr + /// \brief Shared pointer to VisualStore + typedef std::shared_ptr VisualStorePtr; + + /// \def GeometryStorePtr + /// \brief Shared pointer to GeometryStore + typedef std::shared_ptr GeometryStorePtr; + + /// \def SubMeshStorePtr + /// \brief Shared pointer to SubMeshStore + typedef std::shared_ptr SubMeshStorePtr; + + /// \def MaterialMapPtr + /// \brief Shared pointer to MaterialMap + typedef std::shared_ptr MaterialMapPtr; + + /// \def NodeCompositeStorePtr + /// \brief Shared pointer to NodeCompositeStore + typedef std::shared_ptr NodeCompositeStorePtr; + } + } +} +#endif diff --git a/include/gz/rendering/Text.hh b/include/gz/rendering/Text.hh new file mode 100644 index 000000000..96e8bc228 --- /dev/null +++ b/include/gz/rendering/Text.hh @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_TEXT_HH_ +#define GZ_RENDERING_TEXT_HH_ + +#include + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \enum TextHorizontalAlign + /// \brief Text Horizontal alignment + enum class TextHorizontalAlign + { + /// \brief Left alignment + LEFT = 0, + /// \brief Center alignment + CENTER = 1, + /// \brief Right alignment + RIGHT = 2 + }; + + /// \enum TextVerticalAlign + /// \brief Text vertical alignment + enum class TextVerticalAlign + { + /// \brief Align bottom + BOTTOM = 0, + /// \brief Align center + CENTER = 1, + /// \brief Align top + TOP = 2 + }; + + /// \class Text Text.hh ignition/rendering/Text + /// \brief Represents a billboard text geometry that is always facing the + /// camera. + class IGNITION_RENDERING_VISIBLE Text : + public virtual Geometry + { + /// \brief Constructor + public: Text() = default; + + /// \brief Destructor + public: virtual ~Text() = default; + + /// \brief Set the font. + /// \param[in] _font Name of the font + /// \sa FontName() + public: virtual void SetFontName(const std::string &_font) = 0; + + /// \brief Get the font name. + /// \return The font name. + /// \sa SetFontName() + public: virtual std::string FontName() const = 0; + + /// \brief Set the text to display. + /// \param[in] _text The text to display. + /// \sa Text() + public: virtual void SetTextString(const std::string &_text) = 0; + + /// \brief Get the displayed text. + /// \return The displayed text. + /// \sa SetText() + public: virtual std::string TextString() const = 0; + + /// \brief Set the text color. + /// \param[in] _color Text color. + /// \sa Color() + public: virtual void SetColor(const gz::math::Color &_color) = 0; + + /// \brief Get the text color. + /// \return Text color. + /// \sa SetColor() + public: virtual gz::math::Color Color() const = 0; + + /// \brief Set the height of the character in meters. + /// \param[in] _height Height of the characters. + /// \sa CharHeight() + public: virtual void SetCharHeight(const float _height) = 0; + + /// \brief Get the height of the characters in meters + /// return Height of the characters. + /// \sa SetCharHeight() + public: virtual float CharHeight() const = 0; + + /// \brief Set the width of spaces between words. + /// \param[in] _width Space width + /// \sa SpaceWidth() + public: virtual void SetSpaceWidth(const float _width) = 0; + + /// \brief Get the width of spaces between words. + /// \return Space width + /// \sa SetSpaceWidth() + public: virtual float SpaceWidth() const = 0; + + /// \brief Set the alignment of the text + /// \param[in] _hAlign Horizontal alignment + /// \param[in] _vAlign Vertical alignment + public: virtual void SetTextAlignment(const TextHorizontalAlign &_hAlign, + const TextVerticalAlign &_vAlign) = 0; + + /// \brief Get the horizontal alignment of the text + /// \return Text horizontal alignment + public: virtual TextHorizontalAlign HorizontalAlignment() const = 0; + + /// \brief Get the vertical alignment of the text + /// \return Text verical alignment + public: virtual TextVerticalAlign VerticalAlignment() const = 0; + + /// \brief Set the baseline height of the text + /// \param[in] _baseline Baseline height + /// \sa Baseline() + public: virtual void SetBaseline(const float _baseline) = 0; + + /// \brief Get the baseline height in meters. + /// \return Baseline height + /// \sa SetBaseline() + public: virtual float Baseline() const = 0; + + /// \brief True = text always is displayed ontop. + /// \param[in] _onTop Set to true to render the text on top of + /// all other drawables. + /// \sa ShowOnTop() + public: virtual void SetShowOnTop(const bool _onTop) = 0; + + /// \brief Get whether the is displayed above other objects. + /// \return True if it is on top. + /// \sa SetShowOnTop() + public: virtual bool ShowOnTop() const = 0; + + /// \brief Get the axis aligned bounding box of the text. + /// \return The axis aligned bounding box. + public: virtual gz::math::AxisAlignedBox AABB() const = 0; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/ThermalCamera.hh b/include/gz/rendering/ThermalCamera.hh new file mode 100644 index 000000000..077c9a3a9 --- /dev/null +++ b/include/gz/rendering/ThermalCamera.hh @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_THERMALCAMERA_HH_ +#define GZ_RENDERING_THERMALCAMERA_HH_ + +#include +#include "gz/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /* \class ThermalCamera ThermalCamera.hh \ + * ignition/rendering/ThermalCamera.hh + */ + /// \brief Thermal camera that produces temperature data. + /// An object's temperature can be set through the Visual class + /// using SetUserData with the key "temperature". Ambient temperature + /// is returned for object that do not have this property set. Note that + /// temperature variations for the environment and objects can be set using + /// the Set*Range functions in this class. For simplicity, the variations + /// are modeled as a function of depth (which is not how a real thermal + /// sensor works). Ideally we support heatmaps for visuals in order to + /// produce more realistic temperature output. + class IGNITION_RENDERING_VISIBLE ThermalCamera : + public virtual Camera + { + /// \brief Destructor + public: virtual ~ThermalCamera() { } + + /// \brief Set the ambient temperature of the environment + /// \param[in] _ambient Ambient temperature in kelvin + /// \sa AmbientTemperature + public: virtual void SetAmbientTemperature(float _ambient) = 0; + + /// \brief Get the ambient temperature of the environment + /// \return Ambient temperature in kelvin + /// \sa SetAmbientTemperature + public: virtual float AmbientTemperature() const = 0; + + /// \brief Set the range of ambient temperature + /// \param[in] _range The ambient temperature ranges from + /// (ambient - range/2) to (ambient + range/2). + /// \sa AmbientTemperatureRange + public: virtual void SetAmbientTemperatureRange(float _range) = 0; + + /// \brief Get the range of ambient temperature + /// \return The ambient temperature range. Ambient temperature ranges + /// from (ambient - range/2) to (ambient - range/2) + /// \sa SetAmbientTemperatureRange + public: virtual float AmbientTemperatureRange() const = 0; + + /// \brief Set the minimum temperature the sensor can detect + /// \param[in] _min Min temperature in kelvin + /// \sa MinTemperature + public: virtual void SetMinTemperature(float _min) = 0; + + /// \brief Get the minimum temperature the sensor can detect + /// \return Min temperature in kelvin + /// \sa SetMinTemperature + public: virtual float MinTemperature() const = 0; + + /// \brief Set the maximum temperature the sensor can detect + /// \param[in] _max Max temperature in kelvin + /// \sa MaxTemperature + public: virtual void SetMaxTemperature(float _max) = 0; + + /// \brief Get the maximum temperature the sensor can detect + /// \return Max temperature in kelvin + /// \sa SetMaxTemperature + public: virtual float MaxTemperature() const = 0; + + /// \brief Set the temperature linear resolution. The thermal image data + /// returned will be temperature in kelvin / resolution. + /// Typical values are 0.01 (10mK), 0.1 (100mK), or 0.04 to simulate + /// 14 bit format. + /// \param[in] _resolution Temperature linear resolution + /// \sa LinearResolution + public: virtual void SetLinearResolution(float _resolution) = 0; + + /// \brief Get the temperature linear resolution + /// \return Temperature linear resolution + /// \sa SetLinearResolution + public: virtual float LinearResolution() const = 0; + + /// \brief Get the range of temperature variation for all heat sources. + /// \return Temperature variation range + /// \sa SetHeatSourceTemperatureRange + public: virtual float HeatSourceTemperatureRange() const = 0; + + /// \brief Set the range of temperature variation for all heat sources. + /// If set, the temperature reading of heat sources will vary within + /// a temperature of +/- range/2 instead of returning a fixed uniform + /// temperature for the entire heat source + /// \param[in] _range Temperature variation range + /// \sa HeatSourceTemperatureRange + public: virtual void SetHeatSourceTemperatureRange(float _range) = 0; + + /// \brief Connect to the new thermal image event + /// \param[in] _subscriber Subscriber callback function. The callback + /// function arguments are: + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewThermalFrame( + std::function _subscriber) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/TransformController.hh b/include/gz/rendering/TransformController.hh new file mode 100644 index 000000000..9e35d6cef --- /dev/null +++ b/include/gz/rendering/TransformController.hh @@ -0,0 +1,223 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_TRANSFORMCONTROLLER_HH_ +#define GZ_RENDERING_TRANSFORMCONTROLLER_HH_ + +#include + +#include + +#include +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GizmoVisual.hh" +#include "gz/rendering/TransformType.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations + class TransformControllerPrivate; + + /* \class TransformController TransformController.hh \ + * ignition/rendering/TransformController.hh + */ + /// \brief An transform tool for translating, rotating, and scaling objects. + class IGNITION_RENDERING_VISIBLE TransformController + { + /// \brief Constructor + public: TransformController(); + + /// \brief Destructor + public: virtual ~TransformController(); + + /// \brief Update the transform controller. Its visual is updated based + /// on the current transform mode, space, and axis. + public: virtual void Update(); + + /// \brief Set the camera. + /// \param[in] _camera Camera + public: virtual void SetCamera(const CameraPtr &_camera); + + /// \brief get the camera that is controlled by this view controller. + /// \return camera being controlled + public: virtual CameraPtr Camera() const; + + /// \brief Get the attached node + /// \return The node which is being transformed, nullptr if there is no + /// node attached. + public: virtual NodePtr Node() const; + + /// \brief Attach the transform controller to the specified node + /// \param[in] _node Node that will be transformed + public: virtual void Attach(NodePtr _node); + + /// \brief Detach the transform controller from the currently attached + /// node + public: virtual void Detach(); + + /// \brief Set the transform mode + /// \param[in] _mode Transform mode to set to + public: virtual void SetTransformMode(TransformMode _mode); + + /// \brief Get the current transform mode + /// \return Transform mode + public: virtual TransformMode Mode() const; + + /// \brief Set the transform space + /// \param[in] _space Transform space to set to + public: virtual void SetTransformSpace(TransformSpace _space); + + /// \brief Get the transform space + /// \return Transform space + public: virtual TransformSpace Space() const; + + /// \brief Set the active transform axis. This highlights the axis visual + /// \param[in] _axis Transform axis vector + public: virtual void SetActiveAxis(const math::Vector3d &_axis); + + /// \brief Get the current highlighted active axis of transform + /// \return Active axis of transform + public: virtual math::Vector3d ActiveAxis() const; + + /// \brief Get the axis of transform represented by the given node id + /// \param[in] _id Id of the node to check + /// \return Transform axis + public: virtual math::Vector3d AxisById(unsigned int _id) const; + + /// \brief Translate the attached node + /// \param[in] _translation Translation in the current transform space + /// \param[in] _snap True to snap the final position to fixed increments + /// \sa SetTransformSpace + public: virtual void Translate(const math::Vector3d &_translation, + bool _snap = false); + + /// \brief Rotate the attached node + /// \param[in] _rotation Rotation in the current transform space + /// \param[in] _snap True to snap rotation angle to fixed increments + /// \sa SetTransformSpace + public: virtual void Rotate(const math::Quaterniond &_rotation, + bool _snap = false); + + /// \brief Scale the attached node. + /// \param[in] _scale Scale in the current transform space + /// \param[in] _snap True to snap scale to fixed increments + /// \sa SetTransformSpace + public: virtual void Scale(const math::Vector3d &_scale, + bool _snap = false); + + /// \brief Snap a point at intervals of a fixed distance. Currently used + /// to give a snapping behavior when transforming objects + /// \param[in] _point Input point. + /// \param[in] _interval Fixed distance interval at which the point + /// is snapped. + /// \param[in] _sensitivity Sensitivity of point snapping, in terms of a + /// percentage of the interval. + /// \return Snapped 3D point. + public: static gz::math::Vector3d SnapPoint( + const gz::math::Vector3d &_point, const double _interval = 1.0, + const double _sensitivity = 0.4); + + /// \brief Start the transform process. To be used with helper functions + /// that computions transforms from 2d movements. + /// \sa Stop + public: virtual void Start(); + + /// \brief Stop the transform process. To be used with helper functions + /// that computions transforms from 2d movements. + /// \sa Stop + public: virtual void Stop(); + + /// \brief Check if the transform process is active + /// \return True if node is being transformed + public: virtual bool Active() const; + + /// \brief Helper function to compute 3d translation from 2d translation + /// movement. Useful for converting 2d mouse drag motion to displacement + /// in world frame. Note that the camera must be set and Start() must be + /// called before using this function. + /// \param[in] _axis Axis of 3d translation. The resulting 3d vector + /// is constrained to this axis. + /// \param[in] _start Starting position of the 2d translation movement + /// \param[in] _end End position of the 2d translation movement + /// \return 3d translation vector in the current transform space + public: math::Vector3d TranslationFrom2d(const math::Vector3d &_axis, + const math::Vector2d &_start, const math::Vector2d &_end); + + /// \brief Helper function to compute 3d rotation from 2d translation + /// movement. Useful for converting 2d mouse drag motion to rotation angle + /// in world frame. Note that the camera must be set and Start() must be + /// called before using this function. + /// \param[in] _axis Axis of 3d rotation. The resulting rotation is + /// is constrained to this axis. + /// \param[in] _start Starting position of the 2d translation movement + /// \param[in] _end End position of the 2d translation movement + /// \return Rotation in the current transform space + public: math::Quaterniond RotationFrom2d(const math::Vector3d &_axis, + const math::Vector2d &_start, const math::Vector2d &_end); + + /// \brief Helper function to compute 3d scale from 2d translation + /// movement. Useful for converting 2d mouse drag motion to scale vector + /// in world frame. Note that the camera must be set and Start() must be + /// called before using this function. + /// \param[in] _axis Axis of scale. The resulting 3d vector + /// is constrained to this axis. + /// \param[in] _start Starting position of the 2d translation movement + /// \param[in] _end End position of the 2d translation movement + /// \return 3d scale vector in the current transform space + public: math::Vector3d ScaleFrom2d(const math::Vector3d &_axis, + const math::Vector2d &_start, const math::Vector2d &_end); + + /// \brief Convert a TransformAxis to a vector type + /// \param[in] _axis Transform axis + /// \return 3d axis vector + public: static math::Vector3d ToAxis(TransformAxis _axis); + + /// \brief Helper function to create a plane for transfomation. + /// The plane is chosen based on the current transform mode and the + /// transform axis specified. + /// \param[in] _axis Transformation axis used to identify the plane for + /// projection. + /// \param[in] _pt2d 2d point to help fine tune the plane created. + /// \return Plane created for transform + protected: math::Planed CreatePlaneForTransform( + const math::Vector3d &_axis, const math::Vector2d &_pt2d); + + /// \brief Helper function to compute ray plane intersection + /// \param[in] _ray Input ray + /// \param[in] _plane Plane to check for intersection + /// \param[out] _result Intersection point + /// \return True if intersection point exist, false if ray is parallel + /// to plane + protected: bool RayPlaneIntersection(RayQueryPtr _ray, + const math::Planed &_plane, math::Vector3d &_result); + + /// \brief Private data pointer + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/TransformType.hh b/include/gz/rendering/TransformType.hh new file mode 100644 index 000000000..158b4d07b --- /dev/null +++ b/include/gz/rendering/TransformType.hh @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GZ_RENDERING_TRANSFORMTYPE_HH_ +#define GZ_RENDERING_TRANSFORMTYPE_HH_ + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \enum TransformAxis + /// \brief Unique identifiers for transformation axes. + enum IGNITION_RENDERING_VISIBLE TransformAxis + { + /// \brief No axis + TA_NONE = 0, + /// \brief Translation in x + TA_TRANSLATION_X = 0x00000001, + /// \brief Translation in y + TA_TRANSLATION_Y = 0x00000002, + /// \brief Translation in z + TA_TRANSLATION_Z = 0x00000004, + /// \brief Rotation in x + TA_ROTATION_X = 0x00000010, + /// \brief Rotation in y + TA_ROTATION_Y = 0x00000020, + /// \brief Rotation in z + TA_ROTATION_Z = 0x00000040, + /// \brief Scale in x + TA_SCALE_X = 0x00000100, + /// \brief Scale in y + TA_SCALE_Y = 0x00000200, + /// \brief Scale in z + TA_SCALE_Z = 0x00000400 + }; + + /// \enum TransformMode + /// \brief Unique identifiers for transformation modes. + enum IGNITION_RENDERING_VISIBLE TransformMode + { + /// \brief Inactive state + TM_NONE = 0, + /// \brief Translation mode + TM_TRANSLATION = TA_TRANSLATION_X | TA_TRANSLATION_Y | TA_TRANSLATION_Z, + /// \brief Rotation mode + TM_ROTATION = TA_ROTATION_X | TA_ROTATION_Y | TA_ROTATION_Z, + /// \brief Scale mode + TM_SCALE = TA_SCALE_X | TA_SCALE_Y, TA_SCALEZ, + }; + + /// \enum TransformSpace + /// \brief Unique identifiers for transformation spaces. + enum IGNITION_RENDERING_VISIBLE TransformSpace + { + /// \brief transformation in local frame + TS_LOCAL, + /// \brief transformation in world frame + TS_WORLD + }; + } + } +} +#endif diff --git a/include/gz/rendering/Utils.hh b/include/gz/rendering/Utils.hh new file mode 100644 index 000000000..cc552d4d1 --- /dev/null +++ b/include/gz/rendering/Utils.hh @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_UTILS_HH_ +#define GZ_RENDERING_UTILS_HH_ + +#include + +#include +#include +#include +#include +#include + +#include "gz/rendering/Camera.hh" +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" +#include "gz/rendering/RayQuery.hh" + + +namespace ignition +{ + /// \brief Rendering classes and function useful in robot applications. + namespace rendering + { + // Inline bracket to help doxygen filtering. + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Retrieve the first point on a surface in the 3D scene hit by a + /// ray cast from the given 2D screen coordinates. + /// \param[in] _screenPos 2D coordinates on the screen, in pixels. + /// \param[in] _camera User camera + /// \param[in] _rayQuery Ray query for mouse clicks + /// \param[in] _maxDistance maximum distance to check the collision + /// \return 3D coordinates of a point in the 3D scene. + IGNITION_RENDERING_VISIBLE + math::Vector3d screenToScene( + const math::Vector2i &_screenPos, + const CameraPtr &_camera, + const RayQueryPtr &_rayQuery, + float _maxDistance = 10.0); + + /// \brief Retrieve the first point on a surface in the 3D scene hit by a + /// ray cast from the given 2D screen coordinates. + /// \param[in] _screenPos 2D coordinates on the screen, in pixels. + /// \param[in] _camera User camera + /// \param[in] _rayQuery Ray query for mouse clicks + /// \param[inout] _rayResult Ray query result + /// \param[in] _maxDistance maximum distance to check the collision + /// \return 3D coordinates of a point in the 3D scene. + IGNITION_RENDERING_VISIBLE + math::Vector3d screenToScene( + const math::Vector2i &_screenPos, + const CameraPtr &_camera, + const RayQueryPtr &_rayQuery, + RayQueryResult &_rayResult, + float _maxDistance = 10.0); + + /// \brief Retrieve the point on a plane at z = 0 in the 3D scene hit by a + /// ray cast from the given 2D screen coordinates. + /// \param[in] _screenPos 2D coordinates on the screen, in pixels. + /// \param[in] _camera User camera + /// \param[in] _rayQuery Ray query for mouse clicks + /// \param[in] _offset Offset along the plane normal + /// \return 3D coordinates of a point in the 3D scene. + IGNITION_RENDERING_VISIBLE + math::Vector3d screenToPlane( + const math::Vector2i &_screenPos, + const CameraPtr &_camera, + const RayQueryPtr &_rayQuery, + const float _offset = 0.0); + + /// \brief Get the screen scaling factor. + /// \return The screen scaling factor. + IGNITION_RENDERING_VISIBLE + float screenScalingFactor(); + + /// \brief Transform a bounding box. + /// \param[in] _box The bounding box. + /// \param[in] _pose Pose used to transform the bounding box. + /// \return Vertices of the transformed bounding box in + /// world coordinates. + IGNITION_RENDERING_VISIBLE + ignition::math::AxisAlignedBox transformAxisAlignedBox( + const ignition::math::AxisAlignedBox &_box, + const ignition::math::Pose3d &_pose); + } + } +} +#endif diff --git a/include/gz/rendering/ViewController.hh b/include/gz/rendering/ViewController.hh new file mode 100644 index 000000000..dbde046e0 --- /dev/null +++ b/include/gz/rendering/ViewController.hh @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_VIEWCONTROLLER_HH_ +#define GZ_RENDERING_VIEWCONTROLLER_HH_ + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class ViewController ViewController.hh + /// ignition/rendering/ViewController.hh + /// \brief A camera view controller + class IGNITION_RENDERING_VISIBLE ViewController + { + /// \brief Deconstructor + public: virtual ~ViewController() { } + + /// \brief Set the camera that will be controlled by this view controller. + /// \param[in] _camera Camera to control + public: virtual void SetCamera(const CameraPtr &_camera) = 0; + + /// \brief Set target point for pan, zoom, oribit + /// \param[in] _target Target point in world coordinates + public: virtual void SetTarget(const math::Vector3d &_target) = 0; + + /// \brief Set zoom amount + /// \param[in] _value Camera zoon value, e.g. mouse scroll delta + public: virtual void Zoom(const double _value) = 0; + + /// \brief Set camera pan (translational movement) around target point. + /// \param[in] _value Pan amount in image plane, e.g. mouse drag delta. + public: virtual void Pan(const math::Vector2d &_value) = 0; + + /// \brief Set camera orbit (rotational movement) around target point. + /// \param[in] _value robit amount in image plane, e.g. mouse drag delta + public: virtual void Orbit(const math::Vector2d &_value) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Visual.hh b/include/gz/rendering/Visual.hh new file mode 100644 index 000000000..fe71f7366 --- /dev/null +++ b/include/gz/rendering/Visual.hh @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_VISUAL_HH_ +#define GZ_RENDERING_VISUAL_HH_ + +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Node.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \class Visual Visual.hh ignition/rendering/Visual.hh + /// \brief Represents a visual node in a scene graph. A Visual is the only + /// node that can have Geometry and other Visual children. + class IGNITION_RENDERING_VISIBLE Visual : + public virtual Node + { + /// \brief Deconstructor + public: virtual ~Visual() { } + + /// \brief Get the number of geometries attached to this visual + /// \return The number of geometries attached to this visual + public: virtual unsigned int GeometryCount() const = 0; + + /// \brief Determine if given geometry is attached to this visual + /// \param[in] _geometry Geometry in question + /// \return True if given node is attached to this visual + public: virtual bool HasGeometry(ConstGeometryPtr _geometry) const = 0; + + /// \brief Get geometry at given index. If no geometry exists at given + /// index, NULL will be returned. + /// \param[in] _index Index of the desired geometry + /// \return The specified geometry + public: virtual GeometryPtr GeometryByIndex( + unsigned int _index) const = 0; + + /// \brief Add the given geometry to this visual. If the given node is + /// already attached, no work will be done. + /// \param[in] _geometry Geometry to be added + public: virtual void AddGeometry(GeometryPtr _geometry) = 0; + + /// \brief Remove the given geometry from this visual. If the given node + /// is not a child of this visual, no work will be done. + /// \param[in] _geometry Geometry to be removed + /// \return The removed geometry + public: virtual GeometryPtr RemoveGeometry(GeometryPtr _geometry) = 0; + + /// \brief Remove the geometry at the given index from this visual. If the + /// specified node is not attached this visual, no work will be done. + /// \param[in] _index Index of the geometry to be removed + /// \return The removed geometry + public: virtual GeometryPtr RemoveGeometryByIndex( + unsigned int _index) = 0; + + /// \brief Remove all attached geometries from this visual + public: virtual void RemoveGeometries() = 0; + + /// \brief Set the material for all attached visuals and geometries. The + /// specified material will be retrieved from Scene::Material using + /// the given material name. If no material is registered with the given + /// name, no work will be done. + /// \param[in] _name Name of the material to be assigned + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetMaterial(const std::string &_name, + bool _unique = true) = 0; + + /// \brief Set the material for all attached visuals and geometries + /// \param[in] _material Name of the material to be assigned + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true) = 0; + + /// \brief Set the material for all attached visuals only + /// \param[in] _material Name of the material to be assigned + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetChildMaterial(MaterialPtr _material, + bool _unique = true) = 0; + + /// \brief Set the material for all attached geometries only + /// \param[in] _material Name of the material to be assigned + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetGeometryMaterial(MaterialPtr _material, + bool _unique = true) = 0; + + /// \brief Get the material assigned to attached visuals and geometries. + /// \return the Pointer to the material assigned to this visual. If the + /// material is cloned at the time it is set to this visual, the cloned + /// material will be returned. + public: virtual MaterialPtr Material() const = 0; + + /// \brief Enable or disable wireframe + /// \param[in] _show True to enable wireframe + public: virtual void SetWireframe(bool _show) = 0; + + /// \brief Get whether wireframe is enabled for this visual. + /// \return True if wireframe is enabled for this visual. + public: virtual bool Wireframe() const = 0; + + /// \brief Specify if this visual is visible + /// \param[in] _visible True if this visual should be made visible + public: virtual void SetVisible(bool _visible) = 0; + + /// \brief Set visibility flags + /// \param[in] _flags Visibility flags + public: virtual void SetVisibilityFlags(uint32_t _flags) = 0; + + /// \brief Get visibility flags + /// \return visibility flags + public: virtual uint32_t VisibilityFlags() const = 0; + + /// \brief Add visibility flags + /// \param[in] _flags Visibility flags + public: virtual void AddVisibilityFlags(uint32_t _flags) = 0; + + /// \brief Remove visibility flags + /// \param[in] _flags Visibility flags + public: virtual void RemoveVisibilityFlags(uint32_t _flags) = 0; + + /// \brief Get the bounding box in world frame coordinates. + /// \return The axis aligned bounding box + public: virtual ignition::math::AxisAlignedBox BoundingBox() const = 0; + + /// \brief Get the local bounding box of the visual. + /// \return The local bounding box + public: virtual ignition::math::AxisAlignedBox LocalBoundingBox() + const = 0; + + /// \brief Clone the visual (and its children) with a new name. + /// \param[in] _name Name of the cloned Visual. Set this to an empty + /// string to auto-generate a unique name for the cloned visual. + /// \param[in] _newParent Parent of the cloned Visual. Set to nullptr if + /// the cloned visual should have no parent. + /// \return The visual. nullptr is returned if cloning failed. + public: virtual VisualPtr Clone(const std::string &_name, + NodePtr _newParent) const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/WireBox.hh b/include/gz/rendering/WireBox.hh new file mode 100644 index 000000000..f4c4ec459 --- /dev/null +++ b/include/gz/rendering/WireBox.hh @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_WIREBOX_HH_ +#define IGNITION_RENDERING_WIREBOX_HH_ + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Geometry.hh" +#include "ignition/math/AxisAlignedBox.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class WireBox WireBox.hh ignition/rendering/WireBox + /// \brief Draws a wireframe box. + class IGNITION_RENDERING_VISIBLE WireBox : + public virtual Geometry + { + /// \brief Constructor + protected: WireBox(); + + /// \brief Destructor + public: virtual ~WireBox(); + + /// \brief Set the axis aligned box + /// \param[in] _box The axis aligned box + public: virtual void SetBox( + const ignition::math::AxisAlignedBox &_box) = 0; + + /// \brief Get the wireframe box. + /// \return The wireframe box. + public: virtual ignition::math::AxisAlignedBox Box() const = 0; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/base/BaseArrowVisual.hh b/include/gz/rendering/base/BaseArrowVisual.hh new file mode 100644 index 000000000..edba57409 --- /dev/null +++ b/include/gz/rendering/base/BaseArrowVisual.hh @@ -0,0 +1,215 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEARROWVISUAL_HH_ +#define GZ_RENDERING_BASE_BASEARROWVISUAL_HH_ + +#include + +#include + +#include "gz/rendering/ArrowVisual.hh" +#include "gz/rendering/Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseArrowVisual : + public virtual ArrowVisual, + public virtual T + { + /// \brief Constructor + protected: BaseArrowVisual(); + + /// \brief Destructor + public: virtual ~BaseArrowVisual(); + + // Documentation inherited. + protected: virtual void Destroy() override; + + // Documentation inherited. + public: virtual VisualPtr Head() const override; + + // Documentation inherited. + public: virtual VisualPtr Shaft() const override; + + // Documentation inherited. + public: virtual VisualPtr Rotation() const override; + + // Documentation inherited + public: virtual void ShowArrowHead(bool _b) override; + + // Documentation inherited + public: virtual void ShowArrowShaft(bool _b) override; + + // Documentation inherited + public: virtual void ShowArrowRotation(bool _b) override; + + // Documentation inherited + public: virtual void SetVisible(bool _visible) override; + + // Documentation inherited. + protected: virtual void Init() override; + + /// \brief Flag to indicate whether arrow rotation is visible + protected: bool rotationVisible = false; + }; + + ////////////////////////////////////////////////// + template + BaseArrowVisual::BaseArrowVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseArrowVisual::~BaseArrowVisual() + { + } + + ///////////////////////////////////////////////// + template + void BaseArrowVisual::Destroy() + { + while (this->ChildCount() > 0u) + { + auto visual = std::dynamic_pointer_cast(this->ChildByIndex(0)); + if (visual) + { + visual->Destroy(); + } + } + T::Destroy(); + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseArrowVisual::Head() const + { + return std::dynamic_pointer_cast(this->ChildByIndex(2)); + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseArrowVisual::Shaft() const + { + return std::dynamic_pointer_cast(this->ChildByIndex(1)); + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseArrowVisual::Rotation() const + { + return std::dynamic_pointer_cast(this->ChildByIndex(0)); + } + + ////////////////////////////////////////////////// + template + void BaseArrowVisual::ShowArrowHead(bool _b) + { + NodePtr child = this->ChildByIndex(2); + VisualPtr visual = std::dynamic_pointer_cast(child); + if (visual) + { + visual->SetVisible(_b); + } + } + + ////////////////////////////////////////////////// + template + void BaseArrowVisual::ShowArrowShaft(bool _b) + { + NodePtr child = this->ChildByIndex(1); + VisualPtr visual = std::dynamic_pointer_cast(child); + if (visual) + { + visual->SetVisible(_b); + } + } + + ////////////////////////////////////////////////// + template + void BaseArrowVisual::ShowArrowRotation(bool _b) + { + NodePtr child = this->ChildByIndex(0); + VisualPtr visual = std::dynamic_pointer_cast(child); + if (visual) + { + visual->SetVisible(_b); + this->rotationVisible = _b; + } + } + + ////////////////////////////////////////////////// + template + void BaseArrowVisual::SetVisible(bool _visible) + { + T::SetVisible(_visible); + + NodePtr child = this->ChildByIndex(0); + VisualPtr visual = std::dynamic_pointer_cast(child); + if (visual) + { + // Force rotation visual visibility to false + // if the arrow visual is not visible. + // Else, rotation visual's visibility overrides + // its parent's visibility. + visual->SetVisible(this->rotationVisible && _visible); + } + } + + ////////////////////////////////////////////////// + template + void BaseArrowVisual::Init() + { + T::Init(); + + VisualPtr cone = this->Scene()->CreateVisual(); + cone->AddGeometry(this->Scene()->CreateCone()); + cone->SetOrigin(0, 0, -0.5); + cone->SetLocalPosition(0, 0, 0); + cone->SetLocalScale(0.1, 0.1, 0.25); + this->AddChild(cone); + + VisualPtr cylinder = this->Scene()->CreateVisual(); + cylinder->AddGeometry(this->Scene()->CreateCylinder()); + cylinder->SetOrigin(0, 0, 0.5); + cylinder->SetLocalPosition(0, 0, 0); + cylinder->SetLocalScale(0.05, 0.05, 0.5); + this->AddChild(cylinder); + + common::MeshManager *meshMgr = common::MeshManager::Instance(); + std::string rotMeshName = "arrow_rotation"; + if (!meshMgr->HasMesh(rotMeshName)) + meshMgr->CreateTube(rotMeshName, 0.070f, 0.075f, 0.01f, 1, 32); + + VisualPtr rotationVis = this->Scene()->CreateVisual(); + rotationVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); + rotationVis->SetOrigin(0, 0, -0.125); + rotationVis->SetLocalPosition(0, 0, 0); + rotationVis->SetVisible(this->rotationVisible); + this->AddChild(rotationVis); + + this->SetOrigin(0, 0, -0.5); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseAxisVisual.hh b/include/gz/rendering/base/BaseAxisVisual.hh new file mode 100644 index 000000000..cc0943ab0 --- /dev/null +++ b/include/gz/rendering/base/BaseAxisVisual.hh @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEAXISVISUAL_HH_ +#define GZ_RENDERING_BASE_BASEAXISVISUAL_HH_ + +#include "gz/rendering/AxisVisual.hh" +#include "gz/rendering/ArrowVisual.hh" +#include "gz/rendering/Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseAxisVisual : + public virtual AxisVisual, + public virtual T + { + protected: BaseAxisVisual(); + + public: virtual ~BaseAxisVisual(); + + public: virtual void Init() override; + + // Documentation inherited. + protected: virtual void Destroy() override; + + // Documentation inherited. + public: virtual void SetLocalScale( + const math::Vector3d &_scale) override; + + // Documentation inherited. + public: virtual math::Vector3d LocalScale() const override; + + // Documentation inherited. + public: void ShowAxisHead(bool _b) override; + + // Documentation inherited. + public: void ShowAxisHead(unsigned int _axis, bool _b) override; + + // Documentation inherited. + public: virtual void SetVisible(bool _visible) override; + }; + + ////////////////////////////////////////////////// + template + BaseAxisVisual::BaseAxisVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseAxisVisual::~BaseAxisVisual() + { + } + + ///////////////////////////////////////////////// + template + void BaseAxisVisual::Destroy() + { + for (unsigned int i = 0; i < this->ChildCount(); ++i) + { + auto arrow = std::dynamic_pointer_cast( + this->ChildByIndex(i)); + if (arrow) + { + arrow->Destroy(); + } + } + T::Destroy(); + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseAxisVisual::LocalScale() const + { + if (this->ChildCount() > 0) { + return this->ChildByIndex(0)->LocalScale(); + } + return math::Vector3d::Zero; + } + + ////////////////////////////////////////////////// + template + void BaseAxisVisual::SetLocalScale(const math::Vector3d &_scale) + { + for (unsigned int i = 0; i < this->ChildCount(); ++i) + this->ChildByIndex(i)->SetLocalScale(_scale.X(), + _scale.Y(), + _scale.Z()); + } + + ////////////////////////////////////////////////// + template + void BaseAxisVisual::ShowAxisHead(bool _b) + { + for (unsigned int i = 0; i < this->ChildCount(); ++i) + { + auto arrow = std::dynamic_pointer_cast( + this->ChildByIndex(i)); + if (arrow) + { + arrow->ShowArrowHead(_b); + } + } + } + + ////////////////////////////////////////////////// + template + void BaseAxisVisual::ShowAxisHead(unsigned int _axis, bool _b) + { + auto arrow = std::dynamic_pointer_cast( + this->ChildByIndex(2u - _axis)); + if (arrow) + { + arrow->ShowArrowHead(_b); + } + } + + ////////////////////////////////////////////////// + template + void BaseAxisVisual::Init() + { + T::Init(); + + ArrowVisualPtr xArrow = this->Scene()->CreateArrowVisual(); + xArrow->SetLocalPosition(0, 0, 0); + xArrow->SetLocalRotation(0, IGN_PI / 2, 0); + xArrow->SetMaterial("Default/TransRed"); + this->AddChild(xArrow); + + ArrowVisualPtr yArrow = this->Scene()->CreateArrowVisual(); + yArrow->SetLocalPosition(0, 0, 0); + yArrow->SetLocalRotation(-IGN_PI / 2, 0, 0); + yArrow->SetMaterial("Default/TransGreen"); + this->AddChild(yArrow); + + ArrowVisualPtr zArrow = this->Scene()->CreateArrowVisual(); + zArrow->SetLocalPosition(0, 0, 0); + zArrow->SetLocalRotation(0, 0, 0); + zArrow->SetMaterial("Default/TransBlue"); + this->AddChild(zArrow); + } + + ////////////////////////////////////////////////// + template + void BaseAxisVisual::SetVisible(bool _visible) + { + T::SetVisible(_visible); + + for (unsigned int i = 0; i < this->ChildCount(); ++i) + { + auto arrow = std::dynamic_pointer_cast( + this->ChildByIndex(i)); + if (arrow != nullptr) + arrow->SetVisible(_visible); + } + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseBoundingBoxCamera.hh b/include/gz/rendering/base/BaseBoundingBoxCamera.hh new file mode 100644 index 000000000..3fcf6f69b --- /dev/null +++ b/include/gz/rendering/base/BaseBoundingBoxCamera.hh @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BASE_BASEBOUNDINGBOXCAMERA_HH_ +#define IGNITION_RENDERING_BASE_BASEBOUNDINGBOXCAMERA_HH_ + +#include + +#include +#include + +#include "ignition/rendering/base/BaseCamera.hh" +#include "ignition/rendering/BoundingBoxCamera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + template + class BaseBoundingBoxCamera: + public virtual BoundingBoxCamera, + public virtual BaseCamera, + public virtual T + { + /// \brief Constructor + protected: BaseBoundingBoxCamera(); + + /// \brief Destructor + public: virtual ~BaseBoundingBoxCamera(); + + // Documentation inherited + public: virtual const std::vector &BoundingBoxData() const; + + // Documentation inherited + public: virtual ignition::common::ConnectionPtr ConnectNewBoundingBoxes( + std::function &)> _subscriber) = 0; + + // Documentation inherited + public: virtual void SetBoundingBoxType(BoundingBoxType _type); + + // Documentation inherited + public: virtual BoundingBoxType Type() const; + + // Documentation inherited + public: virtual void DrawBoundingBox(unsigned char *_data, + const math::Color &_color, const BoundingBox &_box) const = 0; + + /// \brief The bounding box type + protected: BoundingBoxType type = BoundingBoxType::BBT_FULLBOX2D; + + /// \brief The bounding box data + protected: std::vector boundingBoxes; + }; + + ////////////////////////////////////////////////// + template + BaseBoundingBoxCamera::BaseBoundingBoxCamera() + { + } + + ////////////////////////////////////////////////// + template + BaseBoundingBoxCamera::~BaseBoundingBoxCamera() + { + } + + ////////////////////////////////////////////////// + template + const std::vector & + BaseBoundingBoxCamera::BoundingBoxData() const + { + return this->boundingBoxes; + } + + ////////////////////////////////////////////////// + template + void BaseBoundingBoxCamera::SetBoundingBoxType(BoundingBoxType _type) + { + this->type = _type; + } + + ////////////////////////////////////////////////// + template + BoundingBoxType BaseBoundingBoxCamera::Type() const + { + return this->type; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseCOMVisual.hh b/include/gz/rendering/base/BaseCOMVisual.hh new file mode 100644 index 000000000..29059091d --- /dev/null +++ b/include/gz/rendering/base/BaseCOMVisual.hh @@ -0,0 +1,183 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BASE_BASECOMVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASECOMVISUAL_HH_ + +#include + +#include "ignition/common/Console.hh" + +#include "ignition/rendering/base/BaseObject.hh" +#include "ignition/rendering/base/BaseRenderTypes.hh" +#include "ignition/rendering/COMVisual.hh" +#include "ignition/rendering/Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of an center of mass visual + template + class BaseCOMVisual : + public virtual COMVisual, + public virtual T + { + /// \brief Constructor + protected: BaseCOMVisual(); + + /// \brief Destructor + public: virtual ~BaseCOMVisual(); + + // Documentation inherited. + protected: virtual void Init() override; + + // Documentation inherited. + protected: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void SetInertial( + const ignition::math::Inertiald &_inertial) override; + + // Documentation inherited. + public: virtual void SetMass(double _mass) override; + + // Documentation inherited + public: virtual double Mass() const override; + + // Documentation inherited + public: virtual ignition::math::Pose3d InertiaPose() const override; + + // Documentation inherited + public: virtual VisualPtr SphereVisual() const override; + + /// \brief Get the radius of the CoM sphere + /// \return Radius of the CoM sphere + protected: double SphereRadius() const; + + /// \brief Parent visual name. + protected: std::string parentName = ""; + + /// \brief Parent mass. + protected: double mass = 1.0; + + /// \brief Inertia pose in parent frame. + protected: ignition::math::Pose3d inertiaPose = + ignition::math::Pose3d::Zero; + + /// \brief Flag to indicate parent properties have changed. + protected: bool dirtyCOMVisual = false; + }; + + ////////////////////////////////////////////////// + template + BaseCOMVisual::BaseCOMVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseCOMVisual::~BaseCOMVisual() + { + } + + ///////////////////////////////////////////////// + template + void BaseCOMVisual::PreRender() + { + T::PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseCOMVisual::Init() + { + T::Init(); + } + + ////////////////////////////////////////////////// + template + void BaseCOMVisual::SetInertial( + const ignition::math::Inertiald &_inertial) + { + this->inertiaPose = _inertial.Pose(); + + this->SetMass(_inertial.MassMatrix().Mass()); + } + + template + void BaseCOMVisual::SetMass(double _mass) + { + if (_mass <= 0) + { + // Unrealistic mass, load with default mass + if (_mass < 0) + { + ignlog << "The parent " << this->parentName + << " has unrealistic mass, " + << "unable to visualize sphere of equivalent mass.\n"; + } + else + { + ignlog << "The parent " << this->parentName + << " is static or has mass of 0, " + << "so a sphere of equivalent mass will not be shown.\n"; + } + return; + } + + this->mass = _mass; + this->dirtyCOMVisual = true; + } + + ////////////////////////////////////////////////// + template + double BaseCOMVisual::Mass() const + { + return this->mass; + } + + ////////////////////////////////////////////////// + template + ignition::math::Pose3d BaseCOMVisual::InertiaPose() const + { + return this->inertiaPose; + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseCOMVisual::SphereVisual() const + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + double BaseCOMVisual::SphereRadius() const + { + // Compute radius of sphere with density of lead and equivalent mass. + double sphereRadius; + double densityLead = 11340; + sphereRadius = cbrt((0.75 * this->Mass()) / (IGN_PI * densityLead)); + + return sphereRadius; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseCamera.hh b/include/gz/rendering/base/BaseCamera.hh new file mode 100644 index 000000000..768ad57f8 --- /dev/null +++ b/include/gz/rendering/base/BaseCamera.hh @@ -0,0 +1,848 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASECAMERA_HH_ +#define GZ_RENDERING_BASE_BASECAMERA_HH_ + +#include + +#include +#include + +#include +#include +#include + +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/base/BaseRenderTarget.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + template + class BaseDepthCamera; + + template + class BaseCamera : + public virtual Camera, + public virtual T + { + protected: BaseCamera(); + + public: virtual ~BaseCamera(); + + public: virtual unsigned int ImageWidth() const override; + + public: virtual void SetImageWidth(const unsigned int _width) override; + + public: virtual unsigned int ImageHeight() const override; + + public: virtual void SetImageHeight(const unsigned int _height) override; + + public: virtual PixelFormat ImageFormat() const override; + + public: virtual unsigned int ImageMemorySize() const override; + + public: virtual void SetImageFormat(PixelFormat _format) override; + + public: virtual math::Angle HFOV() const override; + + public: virtual void SetHFOV(const math::Angle &_hfov) override; + + public: virtual double AspectRatio() const override; + + public: virtual void SetAspectRatio(const double _ratio) override; + + public: virtual unsigned int AntiAliasing() const override; + + public: virtual void SetAntiAliasing(const unsigned int _aa) override; + + public: virtual double FarClipPlane() const override; + + public: virtual void SetFarClipPlane(const double _far) override; + + public: virtual double NearClipPlane() const override; + + public: virtual void SetNearClipPlane(const double _near) override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void PostRender() override; + + public: virtual void Update() override; + + public: virtual Image CreateImage() const override; + + public: virtual void Capture(Image &_image) override; + + public: virtual void Copy(Image &_image) const override; + + public: virtual bool SaveFrame(const std::string &_name) override; + + public: virtual common::ConnectionPtr ConnectNewImageFrame( + Camera::NewFrameListener _listener) override; + + public: virtual RenderWindowPtr CreateRenderWindow() override; + + // Documentation inherited. + public: virtual VisualPtr VisualAt(const gz::math::Vector2i + &_mousePos) override; + + // Documentation inherited. + public: virtual math::Matrix4d ProjectionMatrix() const override; + + // Documentation inherited. + public: virtual math::Matrix4d ViewMatrix() const override; + + // Documentation inherited. + public: virtual void SetProjectionMatrix(const math::Matrix4d &_matrix) + override; + + // Documentation inherited. + public: virtual CameraProjectionType ProjectionType() const override; + + // Documentation inherited. + public: virtual void SetProjectionType( + CameraProjectionType _type) override; + + // Documentation inherited. + public: virtual math::Vector2i Project(const math::Vector3d &_pt) const + override; + + // Documentation inherited. + // \sa Camera::SetMaterial(const MaterialPtr &) override; + public: virtual void SetMaterial(const MaterialPtr &_material) + override; + + // Documentation inherited. + public: virtual void SetTrackTarget(const NodePtr &_target, + const math::Vector3d &_offset, + const bool _worldFrame) override; + + // Documentation inherited. + public: virtual NodePtr TrackTarget() const override; + + // Documentation inherited. + public: virtual void SetTrackOffset(const math::Vector3d &_offset) + override; + + // Documentation inherited. + public: virtual math::Vector3d TrackOffset() const override; + + // Documentation inherited. + public: virtual void SetTrackPGain(const double _pGain) override; + + // Documentation inherited. + public: virtual double TrackPGain() const override; + + // Documentation inherited. + public: virtual void SetFollowTarget(const NodePtr &_target, + const math::Vector3d &_Offset, const bool _worldFrame) + override; + + // Documentation inherited. + public: virtual NodePtr FollowTarget() const override; + + // Documentation inherited. + public: virtual void SetFollowOffset(const math::Vector3d &_offset) + override; + + // Documentation inherited. + public: virtual math::Vector3d FollowOffset() const override; + + // Documentation inherited. + public: virtual void SetFollowPGain(const double _pGain) override; + + // Documentation inherited. + public: virtual double FollowPGain() const override; + + // Documentation inherited. + public: virtual unsigned int RenderTextureGLId() const override; + + // Documentation inherited. + public: virtual void AddRenderPass(const RenderPassPtr &_pass) override; + + // Documentation inherited. + public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) + override; + + // Documentation inherited. + public: virtual unsigned int RenderPassCount() const override; + + // Documentation inherited. + public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) + const override; + + // Documentation inherited. + public: virtual void SetShadowsDirty() override; + + protected: virtual void *CreateImageBuffer() const; + + protected: virtual void Load() override; + + protected: virtual void Reset(); + + protected: virtual RenderTargetPtr RenderTarget() const = 0; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: common::EventT newFrameEvent; + + protected: ImagePtr imageBuffer; + + /// \brief Near clipping plane distance + protected: double nearClip = 0.01; + + /// \brief Far clipping plane distance + protected: double farClip = 1000.0; + + /// \brief Aspect ratio + protected: double aspect = 1.3333333; + + /// \brief Horizontal camera field of view + protected: math::Angle hfov; + + /// \brief Anti-aliasing + protected: unsigned int antiAliasing = 0u; + + /// \brief Target node to track if camera tracking is on. + protected: NodePtr trackNode; + + /// \brief Track point relative to target in world frame. + protected: bool trackWorldFrame = false; + + /// \brief Set camera to track a point offset in target node's local or + /// world frame depending on trackWorldFrame. + protected: math::Vector3d trackOffset; + + /// \brief P gain for tracking. Determines how fast the camera rotates + /// to look at the target node. Valid range: [0-1] + protected: double trackPGain = 1.0; + + /// \brief Target node to follow + protected: NodePtr followNode; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Follow target in world frame. + protected: bool followWorldFrame = false; + + /// \brief P gain for follow mode. Determines how fast the camera moves + /// to follow the target node. Valid range: [0-1] + protected: double followPGain = 1.0; + + /// \brief Offset distance between camera and target node being followed + protected: math::Vector3d followOffset; + + /// \brief Custom projection matrix + protected: math::Matrix4d projectionMatrix; + + /// \brief Camera projection type + protected: CameraProjectionType projectionType = CPT_PERSPECTIVE; + + friend class BaseDepthCamera; + }; + + ////////////////////////////////////////////////// + template + BaseCamera::BaseCamera() + { + } + + ////////////////////////////////////////////////// + template + BaseCamera::~BaseCamera() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCamera::ImageWidth() const + { + return this->RenderTarget()->Width(); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetImageWidth(const unsigned int _width) + { + this->RenderTarget()->SetWidth(_width); + this->SetAspectRatio( + static_cast(_width) / static_cast(this->ImageHeight())); + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCamera::ImageHeight() const + { + return this->RenderTarget()->Height(); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetImageHeight(const unsigned int _height) + { + this->RenderTarget()->SetHeight(_height); + this->SetAspectRatio( + static_cast(this->ImageWidth()) / static_cast(_height)); + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCamera::ImageMemorySize() const + { + PixelFormat format = this->ImageFormat(); + unsigned int width = this->ImageWidth(); + unsigned int height = this->ImageHeight(); + return PixelUtil::MemorySize(format, width, height); + } + + ////////////////////////////////////////////////// + template + PixelFormat BaseCamera::ImageFormat() const + { + return this->RenderTarget()->Format(); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetImageFormat(PixelFormat _format) + { + this->RenderTarget()->SetFormat(_format); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::PreRender() + { + T::PreRender(); + + this->RenderTarget()->PreRender(); + + // camera following + if (this->followNode) + { + // tether camera fixed in world frame + if (this->followWorldFrame) + { + math::Vector3d targetCamPos = + this->followNode->WorldPosition() + this->followOffset; + math::Vector3d pos = this->WorldPosition() + + (targetCamPos - this->WorldPosition()) * this->followPGain; + this->SetWorldPosition(pos); + } + // tether camera fixed in target's local frame + else + { + math::Pose3d targetCamPose = math::Pose3d(this->followOffset, + this->WorldRotation()); + targetCamPose = this->followNode->WorldPose() * targetCamPose; + + math::Vector3d pos = this->WorldPosition() + + (targetCamPose.Pos() - this->WorldPosition()) * this->followPGain; + this->SetWorldPosition(pos); + } + } + + // camera tracking + if (this->trackNode) + { + math::Vector3d eye = this->WorldPosition(); + math::Pose3d targetPose = math::Pose3d(this->trackOffset, + math::Quaterniond::Identity); + if (this->trackWorldFrame) + { + targetPose.Pos() += this->trackNode->WorldPosition(); + } + else + { + targetPose = this->trackNode->WorldPose() * targetPose; + } + + math::Pose3d p = + math::Matrix4d::LookAt(eye, targetPose.Pos()).Pose(); + + math::Quaterniond q = p.Rot(); + // skip slerp if we don't need it + if (!math::equal(this->trackPGain, 1.0)) + { + q = math::Quaterniond::Slerp( + this->trackPGain, this->WorldRotation(), p.Rot(), true); + } + this->SetWorldRotation(q); + } + } + + ////////////////////////////////////////////////// + template + void BaseCamera::PostRender() + { + this->RenderTarget()->PostRender(); + } + + ////////////////////////////////////////////////// + template + Image BaseCamera::CreateImage() const + { + PixelFormat format = this->ImageFormat(); + unsigned int width = this->ImageWidth(); + unsigned int height = this->ImageHeight(); + return Image(width, height, format); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::Update() + { + this->Scene()->PreRender(); + this->Render(); + this->PostRender(); + if (!this->Scene()->LegacyAutoGpuFlush()) + { + this->Scene()->PostRender(); + } + } + + ////////////////////////////////////////////////// + template + void BaseCamera::Capture(Image &_image) + { + this->Update(); + this->Copy(_image); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::Copy(Image &_image) const + { + this->RenderTarget()->Copy(_image); + } + + ////////////////////////////////////////////////// + template + bool BaseCamera::SaveFrame(const std::string &/*_name*/) + { + return false; + } + + ////////////////////////////////////////////////// + template + common::ConnectionPtr BaseCamera::ConnectNewImageFrame( + Camera::NewFrameListener _listener) + { + return newFrameEvent.Connect(_listener); + } + + ////////////////////////////////////////////////// + template + void *BaseCamera::CreateImageBuffer() const + { + // TODO(anyone): determine proper type + unsigned int size = this->ImageMemorySize(); + return new unsigned char *[size]; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::Load() + { + T::Load(); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::Reset() + { + math::Angle fov; + fov.Degree(60); + this->SetImageWidth(1); + this->SetImageHeight(1); + this->SetImageFormat(PF_R8G8B8); + this->SetAspectRatio(1.33333); + this->SetAntiAliasing(0u); + this->SetHFOV(fov); + this->SetNearClipPlane(0.01); + this->SetFarClipPlane(1000); + } + + ////////////////////////////////////////////////// + template + RenderWindowPtr BaseCamera::CreateRenderWindow() + { + // Does nothing by default + ignerr << "Render window not supported for render engine: " << + this->Scene()->Engine()->Name() << std::endl; + return RenderWindowPtr(); + } + + ////////////////////////////////////////////////// + template + math::Matrix4d BaseCamera::ProjectionMatrix() const + { + math::Matrix4d result = this->projectionMatrix; + if (this->projectionType == CPT_PERSPECTIVE) + { + double ratio = this->AspectRatio(); + double fov = this->HFOV().Radian(); + double vfov = 2.0 * std::atan(std::tan(fov / 2.0) / ratio); + double f = 1.0; + double _near = this->NearClipPlane(); + double _far = this->FarClipPlane(); + double top = _near * std::tan(0.5*vfov) / f; + double height = 2 * top; + double width = ratio * height; + double left = -0.5 * width; + double right = left + width; + double bottom = top - height; + + double invw = 1.0 / (right - left); + double invh = 1.0 / (top - bottom); + double invd = 1.0 / (_far - _near); + double x = 2 * _near * invw; + double y = 2 * _near * invh; + double a = (right + left) * invw; + double b = (top + bottom) * invh; + double c = -(_far + _near) * invd; + double d = -2 * _far * _near * invd; + result(0, 0) = x; + result(0, 2) = a; + result(1, 1) = y; + result(1, 2) = b; + result(2, 2) = c; + result(2, 3) = d; + result(3, 2) = -1; + } + else if (this->projectionType == CPT_ORTHOGRAPHIC) + { + double width = this->ImageWidth(); + double height = this->ImageHeight(); + double left = -width * 0.5; + double right = -left; + double top = height * 0.5; + double bottom = -top; + double _near = this->NearClipPlane(); + double _far = this->FarClipPlane(); + + double invw = 1.0 / (right - left); + double invh = 1.0 / (top - bottom); + double invd = 1.0 / (_far - _near); + + result(0, 0) = 2.0 * invw; + result(0, 3) = -(right + left) * invw; + result(1, 1) = 2.0 * invh; + result(1, 3) = -(top + bottom) * invh; + result(2, 2) = -2.0 * invd; + result(2, 3) = -(_far + _near) * invd; + result(3, 3) = 1.0; + } + else + { + ignerr << "Unknown camera projection type: " << this->projectionType + << std::endl; + } + + return result; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetProjectionMatrix(const math::Matrix4d &_matrix) + { + this->projectionMatrix = _matrix; + } + + ////////////////////////////////////////////////// + template + math::Matrix4d BaseCamera::ViewMatrix() const + { + math::Matrix3d r(this->WorldPose().Rot()); + // transform from y up to z up + math::Matrix3d tf(0, 0, -1, + -1, 0, 0, + 0, 1, 0); + r = r * tf; + r.Transpose(); + math::Vector3d t = r * this->WorldPose().Pos() * -1; + math::Matrix4d result; + result = r; + result.SetTranslation(t); + result(3, 3) = 1.0; + return result; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetProjectionType(CameraProjectionType _type) + { + this->projectionType = _type; + } + + ////////////////////////////////////////////////// + template + CameraProjectionType BaseCamera::ProjectionType() const + { + return this->projectionType; + } + + ////////////////////////////////////////////////// + template + math::Vector2i BaseCamera::Project(const math::Vector3d &_pt) const + { + math::Vector2i screenPos; + math::Matrix4d m = this->ProjectionMatrix() * this->ViewMatrix(); + math::Vector3d pos = m * _pt; + double w = m(3, 0) * _pt.X() + m(3, 1) * _pt.Y() + m(3, 2) * _pt.Z() + + m(3, 3); + pos.X() = pos.X() / w; + pos.Y() = pos.Y() / w; + + screenPos.X() = static_cast( + ((pos.X() / 2.0) + 0.5) * this->ImageWidth()); + screenPos.Y() = static_cast( + (1 - ((pos.Y() / 2.0) + 0.5)) * this->ImageHeight()); + return screenPos; + } + + ////////////////////////////////////////////////// + template + math::Angle BaseCamera::HFOV() const + { + return this->hfov; + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseCamera::VisualAt(const gz::math::Vector2i + &/*_mousePos*/) + { + ignerr << "VisualAt not implemented for the render engine" << std::endl; + return VisualPtr(); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetHFOV(const math::Angle &_hfov) + { + this->hfov = _hfov; + } + + ////////////////////////////////////////////////// + template + double BaseCamera::AspectRatio() const + { + return this->aspect; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetAspectRatio(const double _aspect) + { + this->aspect = _aspect; + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCamera::AntiAliasing() const + { + return this->antiAliasing; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetAntiAliasing(const unsigned int _aa) + { + this->antiAliasing = _aa; + } + + ////////////////////////////////////////////////// + template + double BaseCamera::FarClipPlane() const + { + return this->farClip; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetFarClipPlane(const double _far) + { + this->farClip = _far; + } + + ////////////////////////////////////////////////// + template + double BaseCamera::NearClipPlane() const + { + return this->nearClip; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetNearClipPlane(const double _near) + { + this->nearClip = _near; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetTrackTarget(const NodePtr &_target, + const math::Vector3d &_offset, const bool _worldFrame) + { + this->trackNode = _target; + this->trackWorldFrame = _worldFrame; + this->trackOffset = _offset; + } + + ////////////////////////////////////////////////// + template + NodePtr BaseCamera::TrackTarget() const + { + return this->trackNode; + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseCamera::TrackOffset() const + { + return this->trackOffset; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetTrackOffset(const math::Vector3d &_offset) + { + this->trackOffset = _offset; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetTrackPGain(const double _pGain) + { + this->trackPGain = math::clamp(_pGain, 0.0, 1.0); + } + + ////////////////////////////////////////////////// + template + double BaseCamera::TrackPGain() const + { + return this->trackPGain; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetFollowTarget(const NodePtr &_target, + const math::Vector3d &_offset, const bool _worldFrame) + { + this->followNode = _target; + this->followWorldFrame = _worldFrame; + this->followOffset = _offset; + } + + ////////////////////////////////////////////////// + template + NodePtr BaseCamera::FollowTarget() const + { + return this->followNode; + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseCamera::FollowOffset() const + { + return this->followOffset; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetFollowOffset(const math::Vector3d &_offset) + { + this->followOffset = _offset; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetFollowPGain(const double _pGain) + { + this->followPGain = math::clamp(_pGain, 0.0, 1.0); + } + + ////////////////////////////////////////////////// + template + double BaseCamera::FollowPGain() const + { + return this->followPGain; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetMaterial(const MaterialPtr &/*_material*/) + { + ignerr << "SetMaterial not implemented for current render" + << " engine" << std::endl; + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCamera::RenderTextureGLId() const + { + ignerr << "RenderTextureGLId is not supported by current render" + << " engine" << std::endl; + return 0u; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::AddRenderPass(const RenderPassPtr &_pass) + { + this->RenderTarget()->AddRenderPass(_pass); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::RemoveRenderPass(const RenderPassPtr &_pass) + { + this->RenderTarget()->RemoveRenderPass(_pass); + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCamera::RenderPassCount() const + { + return this->RenderTarget()->RenderPassCount(); + } + + ////////////////////////////////////////////////// + template + RenderPassPtr BaseCamera::RenderPassByIndex(unsigned int _index) const + { + return this->RenderTarget()->RenderPassByIndex(_index); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetShadowsDirty() + { + // no op + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseCapsule.hh b/include/gz/rendering/base/BaseCapsule.hh new file mode 100644 index 000000000..653be69b5 --- /dev/null +++ b/include/gz/rendering/base/BaseCapsule.hh @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_BASECAPSULE_HH_ +#define IGNITION_RENDERING_BASECAPSULE_HH_ + +#include + +#include "ignition/rendering/Capsule.hh" +#include "ignition/rendering/Scene.hh" +#include "ignition/rendering/base/BaseObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \brief Base implementation of a Capsule Geometry + template + class BaseCapsule : + public virtual Capsule, + public virtual T + { + // Documentation inherited + protected: BaseCapsule(); + + // Documentation inherited + public: virtual ~BaseCapsule(); + + // Documentation inherited + public: virtual void SetRadius(double _radius) override; + + // Documentation inherited + public: virtual void SetLength(double _length) override; + + // Documentation inherited + public: virtual double Radius() const override; + + // Documentation inherited + public: virtual double Length() const override; + + // Documentation inherited + public: virtual GeometryPtr Clone() const override; + + /// \brief Radius of the capsule + protected: double radius = 0.5; + + /// \brief Length of the capsule + protected: double length = 0.5; + + /// \brief Flag to indicate capsule properties have changed + protected: bool capsuleDirty = false; + }; + + ///////////////////////////////////////////////// + // BaseCapsule + ///////////////////////////////////////////////// + template + BaseCapsule::BaseCapsule() + { + } + + ///////////////////////////////////////////////// + template + BaseCapsule::~BaseCapsule() + { + } + + ///////////////////////////////////////////////// + template + void BaseCapsule::SetRadius(double _radius) + { + this->radius = _radius; + this->capsuleDirty = true; + } + + ///////////////////////////////////////////////// + template + double BaseCapsule::Radius() const + { + return this->radius; + } + + ///////////////////////////////////////////////// + template + void BaseCapsule::SetLength(double _length) + { + this->length = _length; + this->capsuleDirty = true; + } + + ///////////////////////////////////////////////// + template + double BaseCapsule::Length() const + { + return this->length; + } + + ///////////////////////////////////////////////// + template + GeometryPtr BaseCapsule::Clone() const + { + if (!this->Scene()) + { + ignerr << "Cloning a Capsule failed because the capsule to be " + << "cloned does not belong to a scene.\n"; + return nullptr; + } + + auto result = this->Scene()->CreateCapsule(); + if (result) + { + result->SetRadius(this->Radius()); + result->SetLength(this->Length()); + + if (this->Material()) + result->SetMaterial(this->Material()); + } + + return result; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseDepthCamera.hh b/include/gz/rendering/base/BaseDepthCamera.hh new file mode 100644 index 000000000..9781fae90 --- /dev/null +++ b/include/gz/rendering/base/BaseDepthCamera.hh @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEDEPTHCAMERA_HH_ +#define GZ_RENDERING_BASE_BASEDEPTHCAMERA_HH_ + +#include + +#include + +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/DepthCamera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + template + class BaseDepthCamera : + public virtual DepthCamera, + public virtual BaseCamera, + public virtual T + { + protected: BaseDepthCamera(); + + public: virtual ~BaseDepthCamera(); + + public: virtual void CreateDepthTexture(); + + public: virtual const float *DepthData() const; + + public: virtual gz::common::ConnectionPtr ConnectNewDepthFrame( + std::function _subscriber); + + public: virtual gz::common::ConnectionPtr ConnectNewRGBPointCloud( + std::function _subscriber); + }; + + ////////////////////////////////////////////////// + template + BaseDepthCamera::BaseDepthCamera() + { + } + + ////////////////////////////////////////////////// + template + BaseDepthCamera::~BaseDepthCamera() + { + } + + ////////////////////////////////////////////////// + template + void BaseDepthCamera::CreateDepthTexture() + { + } + + ////////////////////////////////////////////////// + template + const float *BaseDepthCamera::DepthData() const + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + gz::common::ConnectionPtr BaseDepthCamera::ConnectNewDepthFrame( + std::function) + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + gz::common::ConnectionPtr BaseDepthCamera::ConnectNewRGBPointCloud( + std::function) + { + return nullptr; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseDistortionPass.hh b/include/gz/rendering/base/BaseDistortionPass.hh new file mode 100644 index 000000000..843139e08 --- /dev/null +++ b/include/gz/rendering/base/BaseDistortionPass.hh @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BASEDISTORTIONPASS_HH_ +#define IGNITION_RENDERING_BASEDISTORTIONPASS_HH_ + +#include "ignition/rendering/DistortionPass.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class BaseDistortionPass BaseDistortionPass.hh \ + * ignition/rendering/base/BaseDistortionPass.hh + */ + /// \brief Base distortion render pass + template + class BaseDistortionPass : + public virtual DistortionPass, + public virtual T + { + /// \brief Constructor + protected: BaseDistortionPass(); + + /// \brief Destructor + public: virtual ~BaseDistortionPass(); + + // Documentation inherited. + public: double K1() const; + + // Documentation inherited. + public: double K2() const; + + // Documentation inherited. + public: double K3() const; + + // Documentation inherited. + public: double P1() const; + + // Documentation inherited. + public: double P2() const; + + // Documentation inherited. + public: math::Vector2d Center() const; + + // Documentation inherited. + public: void SetK1(double _k1); + + // Documentation inherited. + public: void SetK2(double _k2); + + // Documentation inherited. + public: void SetK3(double _k3); + + // Documentation inherited. + public: void SetP1(double _p1); + + // Documentation inherited. + public: void SetP2(double _p2); + + // Documentation inherited. + public: void SetCenter(const math::Vector2d &_center); + + /// \brief Radial distortion coefficient k1. + public: double k1 = 0; + + /// \brief Radial distortion coefficient k2. + public: double k2 = 0; + + /// \brief Radial distortion coefficient k3. + public: double k3 = 0; + + /// \brief Tangential distortion coefficient p1. + public: double p1 = 0; + + /// \brief Tangential distortion coefficient p2. + public: double p2 = 0; + + /// \brief Lens center used for distortion + public: math::Vector2d lensCenter = {0.5, 0.5}; + }; + + ////////////////////////////////////////////////// + // BaseDistortionPass + ////////////////////////////////////////////////// + template + BaseDistortionPass::BaseDistortionPass() + { + } + + ////////////////////////////////////////////////// + template + BaseDistortionPass::~BaseDistortionPass() + { + } + + ////////////////////////////////////////////////// + template + double BaseDistortionPass::K1() const + { + return this->k1; + } + + ////////////////////////////////////////////////// + template + double BaseDistortionPass::K2() const + { + return this->k2; + } + + ////////////////////////////////////////////////// + template + double BaseDistortionPass::K3() const + { + return this->k3; + } + + ////////////////////////////////////////////////// + template + double BaseDistortionPass::P1() const + { + return this->p1; + } + + ////////////////////////////////////////////////// + template + double BaseDistortionPass::P2() const + { + return this->p2; + } + + ////////////////////////////////////////////////// + template + math::Vector2d BaseDistortionPass::Center() const + { + return this->lensCenter; + } + + ////////////////////////////////////////////////// + template + void BaseDistortionPass::SetK1(double _k1) + { + this->k1 = _k1; + } + + ////////////////////////////////////////////////// + template + void BaseDistortionPass::SetK2(double _k2) + { + this->k2 = _k2; + } + + ////////////////////////////////////////////////// + template + void BaseDistortionPass::SetK3(double _k3) + { + this->k3 = _k3; + } + + ////////////////////////////////////////////////// + template + void BaseDistortionPass::SetP1(double _p1) + { + this->p1 = _p1; + } + + ////////////////////////////////////////////////// + template + void BaseDistortionPass::SetP2(double _p2) + { + this->p2 = _p2; + } + + ////////////////////////////////////////////////// + template + void BaseDistortionPass::SetCenter(const math::Vector2d &_center) + { + this->lensCenter = _center; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseGaussianNoisePass.hh b/include/gz/rendering/base/BaseGaussianNoisePass.hh new file mode 100644 index 000000000..82a99c014 --- /dev/null +++ b/include/gz/rendering/base/BaseGaussianNoisePass.hh @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_ +#define GZ_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_ + +#include +#include + +#include "gz/rendering/GaussianNoisePass.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class BaseGaussianNoisePass BaseGaussianNoisePass.hh \ + * ignition/rendering/base/BaseGaussianNoisePass.hh + */ + /// \brief Base Gaussian noise render pass. + template + class BaseGaussianNoisePass : + public virtual GaussianNoisePass, + public virtual T + { + /// \brief Constructor + protected: BaseGaussianNoisePass(); + + /// \brief Destructor + public: virtual ~BaseGaussianNoisePass(); + + // Documentation inherited. + public: double Mean() const; + + // Documentation inherited. + public: double StdDev() const; + + // Documentation inherited. + public: double Bias() const; + + // Documentation inherited. + public: void SetMean(double _mean); + + // Documentation inherited. + public: void SetStdDev(double _stdDev); + + // Documentation inherited. + public: void SetBiasMean(double _biasMean); + + // Documentation inherited. + public: void SetBiasStdDev(double _biasStdDev); + + // Sample the bias from bias mean and bias standard deviation + protected: void SampleBias(); + + /// \brief Gaussian noise mean. + protected: double mean = 0.0; + + /// \brief Standard deviation of Gaussian noise + protected: double stdDev = 0.0; + + /// \brief Gaussian noise bias. + protected: double bias = 0.0; + + /// \brief The mean of the Gaussian distribution from which bias values + /// are drawn. + protected: double biasMean = 0; + + /// \brief The standard deviation of the Gaussian distribution from + /// which bias values are drawn. + protected: double biasStdDev = 0; + }; + + ////////////////////////////////////////////////// + // BaseGaussianNoisePass + ////////////////////////////////////////////////// + template + BaseGaussianNoisePass::BaseGaussianNoisePass() + { + } + + ////////////////////////////////////////////////// + template + BaseGaussianNoisePass::~BaseGaussianNoisePass() + { + } + + ////////////////////////////////////////////////// + template + double BaseGaussianNoisePass::Mean() const + { + return this->mean; + } + + ////////////////////////////////////////////////// + template + double BaseGaussianNoisePass::StdDev() const + { + return this->stdDev; + } + + ////////////////////////////////////////////////// + template + double BaseGaussianNoisePass::Bias() const + { + return this->bias; + } + + ////////////////////////////////////////////////// + template + void BaseGaussianNoisePass::SetMean(double _mean) + { + this->mean = _mean; + } + + ////////////////////////////////////////////////// + template + void BaseGaussianNoisePass::SetStdDev(double _stdDev) + { + this->stdDev = _stdDev; + } + + ////////////////////////////////////////////////// + template + void BaseGaussianNoisePass::SetBiasMean(double _biasMean) + { + this->biasMean = _biasMean; + this->SampleBias(); + } + + ////////////////////////////////////////////////// + template + void BaseGaussianNoisePass::SetBiasStdDev(double _biasStdDev) + { + this->biasStdDev = _biasStdDev; + this->SampleBias(); + } + + ////////////////////////////////////////////////// + template + void BaseGaussianNoisePass::SampleBias() + { + this->bias = + gz::math::Rand::DblNormal(this->biasMean, this->biasStdDev); + // With equal probability, we pick a negative bias (by convention, + // rateBiasMean should be positive, though it would work fine if + // negative). + if (gz::math::Rand::DblUniform() < 0.5) + this->bias = -this->bias; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseGeometry.hh b/include/gz/rendering/base/BaseGeometry.hh new file mode 100644 index 000000000..d66679d40 --- /dev/null +++ b/include/gz/rendering/base/BaseGeometry.hh @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEGEOMETRY_HH_ +#define GZ_RENDERING_BASE_BASEGEOMETRY_HH_ + +#include + +#include + +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseGeometry : + public virtual Geometry, + public virtual T + { + protected: BaseGeometry(); + + public: virtual ~BaseGeometry(); + + public: virtual VisualPtr Parent() const override = 0; + + public: virtual void RemoveParent() override; + + // Documentation inherited + public: virtual void SetMaterial(const std::string &_material, + bool _unique = true) override; + + // Documentation inherited + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true) override = 0; + + // Documentation inherited + public: virtual GeometryPtr Clone() const override; + + // Documentation inherited + public: virtual void Destroy() override; + }; + + ////////////////////////////////////////////////// + template + BaseGeometry::BaseGeometry() + { + } + + ////////////////////////////////////////////////// + template + BaseGeometry::~BaseGeometry() + { + } + + ////////////////////////////////////////////////// + template + void BaseGeometry::RemoveParent() + { + VisualPtr parent = this->Parent(); + + if (parent) + { + auto baseShared = this->shared_from_this(); + + auto thisShared = + std::dynamic_pointer_cast>(baseShared); + + parent->RemoveGeometry(thisShared); + } + } + + ////////////////////////////////////////////////// + template + void BaseGeometry::SetMaterial(const std::string &_name, bool _unique) + { + MaterialPtr material = this->Scene()->Material(_name); + if (material) this->SetMaterial(material, _unique); + } + + ////////////////////////////////////////////////// + template + GeometryPtr BaseGeometry::Clone() const + { + ignwarn << "Clone functionality for Geometry does not exist yet.\n"; + return nullptr; + } + + ////////////////////////////////////////////////// + template + void BaseGeometry::Destroy() + { + T::Destroy(); + this->RemoveParent(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseGizmoVisual.hh b/include/gz/rendering/base/BaseGizmoVisual.hh new file mode 100644 index 000000000..ccc329941 --- /dev/null +++ b/include/gz/rendering/base/BaseGizmoVisual.hh @@ -0,0 +1,723 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GZ_RENDERING_BASE_BASEGIZMOVISUAL_HH_ +#define GZ_RENDERING_BASE_BASEGIZMOVISUAL_HH_ + +#include +#include +#include +#include + +#include "gz/rendering/base/BaseScene.hh" +#include "gz/rendering/base/BaseNode.hh" +#include "gz/rendering/ArrowVisual.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GizmoVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class BaseGizmoVisual BaseGizmoVisuall.hh \ + * ignition/rendering/base/BaseGizmoVisual.hh + */ + /// \brief A base implementation of the GizmoVisual class + template + class BaseGizmoVisual : + public virtual GizmoVisual, + public virtual T + { + /// \brief Constructor + protected: BaseGizmoVisual(); + + /// \brief Destructor + public: virtual ~BaseGizmoVisual(); + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void SetTransformMode(TransformMode _mode) override; + + // Documentation inherited + public: virtual TransformMode Mode() const override; + + // Documentation inherited + public: virtual void SetActiveAxis(const math::Vector3d &_axis) override; + + // Documentation inherited + public: virtual math::Vector3d ActiveAxis() const override; + + // Documentation inherited + public: virtual TransformAxis AxisById(unsigned int _id) const override; + + // Documentation inherited + public: virtual VisualPtr ChildByAxis(unsigned int _axis) const override; + + /// \brief Reset the gizmo visual state + public: virtual void Reset(); + + /// \brief Create materials used by the gizmo visual + protected: void CreateMaterials(); + + /// \brief Create gizmo visual for translation + protected: void CreateTranslationVisual(); + + /// \brief Create gizmo visual for rotation + protected: void CreateRotationVisual(); + + /// \brief Create gizmo visual for scale + protected: void CreateScaleVisual(); + + /// \brief Current gizmo mode + protected: TransformMode mode = TransformMode::TM_NONE; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief A map of gizmo axis and their visuals + protected: std::map visuals; + + /// \brief A map of gizmo axis and their handle visuals + protected: std::map handles; + + /// \brief Currently active visual. + protected: VisualPtr activeVis; + + /// \brief Flag to indicate the mode has changed. + protected: bool modeDirty = false; + + /// \brief Active axis + protected: math::Vector3d axis = math::Vector3d::Zero; + + /// \brief A map of axis enums to materials + protected: std::map materials; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Material used by axes + protected: enum AxisMaterial + { + /// \brief X axis + AM_X, + /// \brief Y axis + AM_Y, + /// \brief Z axis + AM_Z, + /// \brief Active axis + AM_ACTIVE, + /// \brief Origin + AM_O, + /// \brief handle + AM_HANDLE + }; + + /// \brief Only the scene can create a GizmoVisual + private: friend class BaseScene; + }; + + ////////////////////////////////////////////////// + template + BaseGizmoVisual::BaseGizmoVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseGizmoVisual::~BaseGizmoVisual() + { + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::Init() + { + T::Init(); + + this->CreateMaterials(); + this->CreateTranslationVisual(); + this->CreateRotationVisual(); + this->CreateScaleVisual(); + + for (auto v : this->visuals) + v.second->SetVisible(false); + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::Reset() + { + this->visuals[TransformAxis::TA_TRANSLATION_X]->SetMaterial( + this->materials[AM_X], false); + this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( + this->materials[AM_Y], false); + this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( + this->materials[AM_Z], false); + this->visuals[TransformAxis::TA_ROTATION_X]->SetMaterial( + this->materials[AM_X], false); + this->visuals[TransformAxis::TA_ROTATION_Y]->SetMaterial( + this->materials[AM_Y], false); + this->visuals[TransformAxis::TA_ROTATION_Z]->SetMaterial( + this->materials[AM_Z], false); + this->visuals[TransformAxis::TA_SCALE_X]->SetMaterial( + this->materials[AM_X], false); + this->visuals[TransformAxis::TA_SCALE_Y]->SetMaterial( + this->materials[AM_Y], false); + this->visuals[TransformAxis::TA_SCALE_Z]->SetMaterial( + this->materials[AM_Z], false); + + this->handles[TransformAxis::TA_TRANSLATION_X]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + + this->handles[TransformAxis::TA_ROTATION_X]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_ROTATION_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_ROTATION_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + + this->handles[TransformAxis::TA_SCALE_X]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_SCALE_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_SCALE_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + + for (auto v : this->visuals) + v.second->SetVisible(false); + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::PreRender() + { + if (!this->modeDirty) + return; + + this->Reset(); + + if (this->mode == TransformMode::TM_NONE) + { + this->modeDirty = false; + return; + } + + if (this->mode & TransformMode::TM_TRANSLATION) + { + this->visuals[TransformAxis::TA_TRANSLATION_X]->SetVisible(true); + this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetVisible(true); + this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetVisible(true); + this->visuals[TransformAxis::TA_TRANSLATION_Z << 1]->SetVisible(true); + if (this->axis.X() > 0) + { + this->visuals[TransformAxis::TA_TRANSLATION_X]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_TRANSLATION_X]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Y() > 0) + { + this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Z() > 0) + { + this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + } + } + else if (this->mode & TransformMode::TM_ROTATION) + { + this->visuals[TransformAxis::TA_ROTATION_X]->SetVisible(true); + this->visuals[TransformAxis::TA_ROTATION_Y]->SetVisible(true); + this->visuals[TransformAxis::TA_ROTATION_Z]->SetVisible(true); + this->visuals[TransformAxis::TA_ROTATION_Z << 1]->SetVisible(true); + if (this->axis.X() > 0) + { + this->visuals[TransformAxis::TA_ROTATION_X]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_ROTATION_X]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Y() > 0) + { + this->visuals[TransformAxis::TA_ROTATION_Y]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_ROTATION_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Z() > 0) + { + this->visuals[TransformAxis::TA_ROTATION_Z]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_ROTATION_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + } + } + else if (this->mode & TransformMode::TM_SCALE) + { + this->visuals[TransformAxis::TA_SCALE_X]->SetVisible(true); + this->visuals[TransformAxis::TA_SCALE_Y]->SetVisible(true); + this->visuals[TransformAxis::TA_SCALE_Z]->SetVisible(true); + if (this->axis.X() > 0) + { + this->visuals[TransformAxis::TA_SCALE_X]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_SCALE_X]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Y() > 0) + { + this->visuals[TransformAxis::TA_SCALE_Y]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_SCALE_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Z() > 0) + { + this->visuals[TransformAxis::TA_SCALE_Z]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_SCALE_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + } + } + + this->modeDirty = false; + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::SetTransformMode(TransformMode _mode) + { + if (this->mode == _mode) + return; + + this->mode = _mode; + // clear active axis when mode changes + this->axis = math::Vector3d::Zero; + this->modeDirty = true; + } + + ////////////////////////////////////////////////// + template + TransformMode BaseGizmoVisual::Mode() const + { + return this->mode; + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::SetActiveAxis(const math::Vector3d &_axis) + { + if (this->axis == _axis) + return; + + this->axis = _axis; + this->modeDirty = true; + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseGizmoVisual::ActiveAxis() const + { + return this->axis; + } + + ////////////////////////////////////////////////// + template + TransformAxis BaseGizmoVisual::AxisById(unsigned int _id) const + { + for (auto v : this->visuals) + { + // each axis visual has a child handle so also check children for + // matching id + if (v.second->Id() == _id || v.second->ChildById(_id)) + return static_cast(v.first); + } + return TransformAxis::TA_NONE; + } + + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::CreateMaterials() + { + MaterialPtr xMat = this->Scene()->Material("Default/TransRed")->Clone(); + MaterialPtr yMat = this->Scene()->Material("Default/TransGreen")->Clone(); + MaterialPtr zMat = this->Scene()->Material("Default/TransBlue")->Clone(); + MaterialPtr activeMat = + this->Scene()->Material("Default/TransYellow")->Clone(); + + // disable depth checking and writing, make them overlays + xMat->SetDepthWriteEnabled(false); + xMat->SetDepthCheckEnabled(false); + yMat->SetDepthWriteEnabled(false); + yMat->SetDepthCheckEnabled(false); + zMat->SetDepthWriteEnabled(false); + zMat->SetDepthCheckEnabled(false); + activeMat->SetDepthWriteEnabled(false); + activeMat->SetDepthCheckEnabled(false); + + MaterialPtr oMat = this->Scene()->Material("GizmoGray"); + if (!oMat) + { + oMat = this->Scene()->CreateMaterial("GizmoGray"); + oMat->SetAmbient(0.5, 0.5, 0.5); + oMat->SetDiffuse(0.5, 0.5, 0.5); + oMat->SetEmissive(0.5, 0.5, 0.5); + oMat->SetTransparency(0.5); + oMat->SetCastShadows(false); + oMat->SetReceiveShadows(false); + oMat->SetLightingEnabled(false); + oMat->SetDepthWriteEnabled(false); + oMat->SetDepthCheckEnabled(false); + } + + MaterialPtr handleMat = this->Scene()->Material("GizmoHandle"); + if (!handleMat) + { + handleMat = this->Scene()->CreateMaterial("GizmoHandle"); + handleMat->SetAmbient(0.0, 0.0, 0.0); + handleMat->SetDiffuse(0.0, 0.0, 0.0); + handleMat->SetEmissive(0.0, 0.0, 0.0); + handleMat->SetTransparency(1.0); + handleMat->SetCastShadows(false); + handleMat->SetReceiveShadows(false); + handleMat->SetLightingEnabled(false); + handleMat->SetDepthWriteEnabled(false); + handleMat->SetDepthCheckEnabled(false); + } + + this->materials[AM_X] = xMat; + this->materials[AM_Y] = yMat; + this->materials[AM_Z] = zMat; + this->materials[AM_ACTIVE] = activeMat; + this->materials[AM_O] = oMat; + this->materials[AM_HANDLE] = handleMat; + } + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::CreateTranslationVisual() + { + VisualPtr transVis = this->Scene()->CreateVisual(); + + // trans x + VisualPtr transXVis = this->Scene()->CreateVisual(); + VisualPtr transShaftXVis = this->Scene()->CreateVisual(); + transShaftXVis->AddGeometry(this->Scene()->CreateCylinder()); + transShaftXVis->SetOrigin(0, 0, 0.5); + transShaftXVis->SetLocalPosition(0, 0, 0.5); + transShaftXVis->SetLocalScale(0.02, 0.02, 0.45); + transXVis->AddChild(transShaftXVis); + + VisualPtr transHeadXVis = this->Scene()->CreateVisual(); + transHeadXVis->AddGeometry(this->Scene()->CreateCone()); + transHeadXVis->SetOrigin(0, 0, -0.5); + transHeadXVis->SetLocalPosition(0, 0, 0.5); + transHeadXVis->SetLocalScale(0.07, 0.07, 0.2); + transXVis->AddChild(transHeadXVis); + + transXVis->SetMaterial(this->materials[AM_X], false); + transXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); + transVis->AddChild(transXVis); + + // trans y + VisualPtr transYVis = this->Scene()->CreateVisual(); + VisualPtr transShaftYVis = this->Scene()->CreateVisual(); + transShaftYVis->AddGeometry(this->Scene()->CreateCylinder()); + transShaftYVis->SetOrigin(0, 0, 0.5); + transShaftYVis->SetLocalPosition(0, 0, 0.5); + transShaftYVis->SetLocalScale(0.02, 0.02, 0.45); + transYVis->AddChild(transShaftYVis); + + VisualPtr transHeadYVis = this->Scene()->CreateVisual(); + transHeadYVis->AddGeometry(this->Scene()->CreateCone()); + transHeadYVis->SetOrigin(0, 0, -0.5); + transHeadYVis->SetLocalPosition(0, 0, 0.5); + transHeadYVis->SetLocalScale(0.07, 0.07, 0.2); + transYVis->AddChild(transHeadYVis); + + transYVis->SetMaterial(this->materials[AM_Y], false); + transYVis->SetLocalRotation(-IGN_PI * 0.5, 0, 0); + transVis->AddChild(transYVis); + + // trans z + VisualPtr transZVis = this->Scene()->CreateVisual(); + VisualPtr transShaftZVis = this->Scene()->CreateVisual(); + transShaftZVis->AddGeometry(this->Scene()->CreateCylinder()); + transShaftZVis->SetOrigin(0, 0, 0.5); + transShaftZVis->SetLocalPosition(0, 0, 0.5); + transShaftZVis->SetLocalScale(0.02, 0.02, 0.45); + transZVis->AddChild(transShaftZVis); + + VisualPtr transHeadZVis = this->Scene()->CreateVisual(); + transHeadZVis->AddGeometry(this->Scene()->CreateCone()); + transHeadZVis->SetOrigin(0, 0, -0.5); + transHeadZVis->SetLocalPosition(0, 0, 0.5); + transHeadZVis->SetLocalScale(0.07, 0.07, 0.2); + transZVis->AddChild(transHeadZVis); + + transZVis->SetMaterial(this->materials[AM_Z], false); + transVis->AddChild(transZVis); + + // trans origin + VisualPtr transOrigin = this->Scene()->CreateVisual(); + transOrigin->AddGeometry(this->Scene()->CreateSphere()); + transOrigin->SetLocalScale(0.05, 0.05, 0.05); + transOrigin->SetMaterial(this->materials[AM_O], false); + transVis->AddChild(transOrigin); + + this->visuals[TransformAxis::TA_TRANSLATION_X] = transXVis; + this->visuals[TransformAxis::TA_TRANSLATION_Y] = transYVis; + this->visuals[TransformAxis::TA_TRANSLATION_Z] = transZVis; + this->visuals[TransformAxis::TA_TRANSLATION_Z << 1] = transOrigin; + + // translation handles + VisualPtr transHandleXVis = this->Scene()->CreateVisual(); + transHandleXVis->AddGeometry(this->Scene()->CreateCylinder()); + transHandleXVis->SetLocalPosition(0, 0, 0.35); + transHandleXVis->SetLocalScale(0.11, 0.11, 0.7); + transHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); + transXVis->AddChild(transHandleXVis); + + VisualPtr transHandleYVis = this->Scene()->CreateVisual(); + transHandleYVis->AddGeometry(this->Scene()->CreateCylinder()); + transHandleYVis->SetLocalPosition(0, 0, 0.35); + transHandleYVis->SetLocalScale(0.11, 0.11, 0.7); + transHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); + transYVis->AddChild(transHandleYVis); + + VisualPtr transHandleZVis = this->Scene()->CreateVisual(); + transHandleZVis->AddGeometry(this->Scene()->CreateCylinder()); + transHandleZVis->SetLocalPosition(0, 0, 0.35); + transHandleZVis->SetLocalScale(0.11, 0.11, 0.7); + transHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); + transZVis->AddChild(transHandleZVis); + + this->handles[TransformAxis::TA_TRANSLATION_X] = transHandleXVis; + this->handles[TransformAxis::TA_TRANSLATION_Y] = transHandleYVis; + this->handles[TransformAxis::TA_TRANSLATION_Z] = transHandleZVis; + + this->AddChild(transVis); + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::CreateRotationVisual() + { + common::MeshManager *meshMgr = common::MeshManager::Instance(); + std::string rotMeshName = "gizmo_rotate"; + if (!meshMgr->HasMesh(rotMeshName)) + meshMgr->CreateTube(rotMeshName, 1.0f, 1.02f, 0.02f, 1, 64, IGN_PI); + + std::string rotFullMeshName = "gizmo_rotate_full"; + if (!meshMgr->HasMesh(rotFullMeshName)) + { + meshMgr->CreateTube(rotFullMeshName, 1.0f, 1.02f, 0.02f, 1, 64, + 2 * IGN_PI); + } + + std::string rotHandleMeshName = "gizmo_rotate_handle"; + if (!meshMgr->HasMesh(rotHandleMeshName)) + { + meshMgr->CreateTube(rotHandleMeshName, 0.95f, 1.07f, 0.1f, 1, 64, + IGN_PI); + } + + VisualPtr rotVis = this->Scene()->CreateVisual(); + + // rotation x + VisualPtr rotXVis = this->Scene()->CreateVisual(); + rotXVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); + rotXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); + rotXVis->SetLocalScale(0.5, 0.5, 0.5); + rotXVis->SetMaterial(this->materials[AM_X], false); + rotVis->AddChild(rotXVis); + + // rotation y + VisualPtr rotYVis = this->Scene()->CreateVisual(); + rotYVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); + rotYVis->SetLocalRotation(IGN_PI * 0.5, 0, 0); + rotYVis->SetLocalScale(0.5, 0.5, 0.5); + rotYVis->SetMaterial(this->materials[AM_Y], false); + rotVis->AddChild(rotYVis); + + // rotation z + VisualPtr rotZVis = this->Scene()->CreateVisual(); + rotZVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); + rotZVis->SetLocalScale(0.5, 0.5, 0.5); + rotZVis->SetMaterial(this->materials[AM_Z], false); + rotVis->AddChild(rotZVis); + + // rotation origin + VisualPtr rotFullVis = this->Scene()->CreateVisual(); + rotFullVis->AddGeometry(this->Scene()->CreateMesh(rotFullMeshName)); + rotFullVis->SetLocalScale(0.5, 0.5, 0.5); + rotFullVis->SetMaterial(this->materials[AM_O], false); + rotVis->AddChild(rotFullVis); + + this->visuals[TransformAxis::TA_ROTATION_X] = rotXVis; + this->visuals[TransformAxis::TA_ROTATION_Y] = rotYVis; + this->visuals[TransformAxis::TA_ROTATION_Z] = rotZVis; + this->visuals[TransformAxis::TA_ROTATION_Z << 1] = rotFullVis; + + // rotation handles + VisualPtr rotHandleXVis = this->Scene()->CreateVisual(); + rotHandleXVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); + rotHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); + rotXVis->AddChild(rotHandleXVis); + + VisualPtr rotHandleYVis = this->Scene()->CreateVisual(); + rotHandleYVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); + rotHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); + rotYVis->AddChild(rotHandleYVis); + + VisualPtr rotHandleZVis = this->Scene()->CreateVisual(); + rotHandleZVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); + rotHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); + rotZVis->AddChild(rotHandleZVis); + + this->handles[TransformAxis::TA_ROTATION_X] = rotHandleXVis; + this->handles[TransformAxis::TA_ROTATION_Y] = rotHandleYVis; + this->handles[TransformAxis::TA_ROTATION_Z] = rotHandleZVis; + + this->AddChild(rotVis); + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::CreateScaleVisual() + { + VisualPtr scaleVis = this->Scene()->CreateVisual(); + + // scale x + VisualPtr scaleXVis = this->Scene()->CreateVisual(); + VisualPtr scaleShaftXVis = this->Scene()->CreateVisual(); + scaleShaftXVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleShaftXVis->SetOrigin(0, 0, 0.5); + scaleShaftXVis->SetLocalPosition(0, 0, 0.5); + scaleShaftXVis->SetLocalScale(0.02, 0.02, 0.5); + scaleXVis->AddChild(scaleShaftXVis); + + VisualPtr scaleHeadXVis = this->Scene()->CreateVisual(); + scaleHeadXVis->AddGeometry(this->Scene()->CreateBox()); + scaleHeadXVis->SetOrigin(0, 0, -0.5); + scaleHeadXVis->SetLocalPosition(0, 0, 0.5); + scaleHeadXVis->SetLocalScale(0.07, 0.07, 0.07); + scaleXVis->AddChild(scaleHeadXVis); + + scaleXVis->SetMaterial(this->materials[AM_X], false); + scaleXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); + scaleVis->AddChild(scaleXVis); + + // scale y + VisualPtr scaleYVis = this->Scene()->CreateVisual(); + VisualPtr scaleShaftYVis = this->Scene()->CreateVisual(); + scaleShaftYVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleShaftYVis->SetOrigin(0, 0, 0.5); + scaleShaftYVis->SetLocalPosition(0, 0, 0.5); + scaleShaftYVis->SetLocalScale(0.02, 0.02, 0.5); + scaleYVis->AddChild(scaleShaftYVis); + + VisualPtr scaleHeadYVis = this->Scene()->CreateVisual(); + scaleHeadYVis->AddGeometry(this->Scene()->CreateBox()); + scaleHeadYVis->SetOrigin(0, 0, -0.5); + scaleHeadYVis->SetLocalPosition(0, 0, 0.5); + scaleHeadYVis->SetLocalScale(0.07, 0.07, 0.07); + scaleYVis->AddChild(scaleHeadYVis); + + scaleYVis->SetMaterial(this->materials[AM_Y], false); + scaleYVis->SetLocalRotation(-IGN_PI * 0.5, 0, 0); + scaleVis->AddChild(scaleYVis); + + // scale z + VisualPtr scaleZVis = this->Scene()->CreateVisual(); + VisualPtr scaleShaftZVis = this->Scene()->CreateVisual(); + scaleShaftZVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleShaftZVis->SetOrigin(0, 0, 0.5); + scaleShaftZVis->SetLocalPosition(0, 0, 0.5); + scaleShaftZVis->SetLocalScale(0.02, 0.02, 0.5); + scaleZVis->AddChild(scaleShaftZVis); + + VisualPtr scaleHeadZVis = this->Scene()->CreateVisual(); + scaleHeadZVis->AddGeometry(this->Scene()->CreateBox()); + scaleHeadZVis->SetOrigin(0, 0, -0.5); + scaleHeadZVis->SetLocalPosition(0, 0, 0.5); + scaleHeadZVis->SetLocalScale(0.07, 0.07, 0.07); + scaleZVis->AddChild(scaleHeadZVis); + + scaleZVis->SetMaterial(this->materials[AM_Z], false); + scaleVis->AddChild(scaleZVis); + + this->visuals[TransformAxis::TA_SCALE_X] = scaleXVis; + this->visuals[TransformAxis::TA_SCALE_Y] = scaleYVis; + this->visuals[TransformAxis::TA_SCALE_Z] = scaleZVis; + + // scale handles + VisualPtr scaleHandleXVis = this->Scene()->CreateVisual(); + scaleHandleXVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleHandleXVis->SetLocalPosition(0, 0, 0.285); + scaleHandleXVis->SetLocalScale(0.11, 0.11, 0.57); + scaleHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); + scaleXVis->AddChild(scaleHandleXVis); + + VisualPtr scaleHandleYVis = this->Scene()->CreateVisual(); + scaleHandleYVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleHandleYVis->SetLocalPosition(0, 0, 0.285); + scaleHandleYVis->SetLocalScale(0.11, 0.11, 0.57); + scaleHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); + scaleYVis->AddChild(scaleHandleYVis); + + VisualPtr scaleHandleZVis = this->Scene()->CreateVisual(); + scaleHandleZVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleHandleZVis->SetLocalPosition(0, 0, 0.285); + scaleHandleZVis->SetLocalScale(0.11, 0.11, 0.57); + scaleHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); + scaleZVis->AddChild(scaleHandleZVis); + + this->handles[TransformAxis::TA_SCALE_X] = scaleHandleXVis; + this->handles[TransformAxis::TA_SCALE_Y] = scaleHandleYVis; + this->handles[TransformAxis::TA_SCALE_Z] = scaleHandleZVis; + + this->AddChild(scaleVis); + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseGizmoVisual::ChildByAxis(unsigned int _axis) const + { + auto it = this->visuals.find(_axis); + if (it != this->visuals.end()) + return it->second; + + return VisualPtr(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseGpuRays.hh b/include/gz/rendering/base/BaseGpuRays.hh new file mode 100644 index 000000000..f160d0c36 --- /dev/null +++ b/include/gz/rendering/base/BaseGpuRays.hh @@ -0,0 +1,452 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEGPURAYS_HH_ +#define GZ_RENDERING_BASE_BASEGPURAYS_HH_ + +#include + +#include +#include + +#include "gz/rendering/GpuRays.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/base/BaseRenderTarget.hh" +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/Visual.hh" +#include "gz/rendering/RenderTypes.hh" + + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseGpuRays : + public virtual GpuRays, + public virtual BaseCamera, + public virtual T + { + /// \brief Constructor + protected: BaseGpuRays(); + + /// \brief Destructor + public: virtual ~BaseGpuRays(); + + // Documentation inherited. + public: virtual const float *Data() const override; + + // Documentation inherited. + public: virtual void Copy(float *_data) override; + + // Documentation inherited. + public: virtual void SetClamp(bool _enable) override; + + // Documentation inherited. + public: virtual bool Clamp() const override; + + // Documentation inherited. + public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( + std::function _subscriber) override; + + /// \brief Pointer to the render target + public: virtual RenderTargetPtr RenderTarget() const override = 0; + + // Documentation inherited. + public: virtual void SetIsHorizontal(const bool _horizontal) override; + + // Documentation inherited. + public: virtual bool IsHorizontal() const override; + + /// \brief Set the vertical fov + /// \param[in] _vfov vertical fov + public: virtual void SetVFOV(const math::Angle &_vfov); + + // Documentation inherited. + public: virtual math::Angle VFOV() const override; + + // Documentation inherited. + public: virtual double RayCountRatio() const override; + + // Documentation inherited. + public: virtual double RangeCountRatio() const override; + + // Documentation inherited. + public: virtual void SetRayCountRatio( + const double _rayCountRatio) override; + + // Documentation inherited. + public: virtual gz::math::Angle AngleMin() const override; + + // Documentation inherited. + public: virtual void SetAngleMin(double _angle) override; + + // Documentation inherited. + public: virtual gz::math::Angle AngleMax() const override; + + // Documentation inherited. + public: virtual void SetAngleMax(double _angle) override; + + // Documentation inherited. + public: virtual void SetVerticalRayCount(int _samples) override; + + // Documentation inherited. + public: virtual void SetRayCount(int _samples) override; + + // Documentation inherited. + public: virtual int RayCount() const override; + + // Documentation inherited. + public: virtual int RangeCount() const override; + + // Documentation inherited. + public: virtual int VerticalRayCount() const override; + + // Documentation inherited. + public: virtual int VerticalRangeCount() const override; + + // Documentation inherited. + public: virtual gz::math::Angle VerticalAngleMin() const override; + + // Documentation inherited. + public: virtual void SetVerticalAngleMin(const double _angle) override; + + // Documentation inherited. + public: virtual gz::math::Angle VerticalAngleMax() const override; + + // Documentation inherited. + public: virtual void SetVerticalAngleMax(const double _angle) override; + + // Documentation inherited. + public: virtual unsigned int Channels() const override; + + // Documentation inherited. + public: virtual void SetHorizontalResolution(double _resolution) override; + + // Documentation inherited. + public: virtual double HorizontalResolution() const override; + + // Documentation inherited. + public: virtual void SetVerticalResolution(double resolution) override; + + // Documentation inherited. + public: virtual double VerticalResolution() const override; + + /// \brief maximum value used for data outside sensor range + public: float dataMaxVal = gz::math::INF_D; + + /// \brief minimum value used for data outside sensor range + public: float dataMinVal = -gz::math::INF_D; + + /// \brief True if data values are clamped to camera clip distances, + // false if data outside of camera range is +/- inf + public: bool clamping = false; + + /// \brief Ray count ratio. + protected: double rayCountRatio = 0; + + /// \brief Range count ratio. + protected: double rangeCountRatio = 0; + + /// \brief Vertical field-of-view. + protected: math::Angle vfov; + + /// \brief True if the sensor is horizontal only. + protected: bool isHorizontal = true; + + /// \brief Horizontal minimal angle + protected: double minAngle = 0; + + /// \brief Horizontal maximal angle + protected: double maxAngle = 0; + + /// \brief Vertical minimal angle + protected: double vMinAngle = 0; + + /// \brief Vertical maximal angle + protected: double vMaxAngle = 0; + + /// \brief Quantity of horizontal rays + protected: int hSamples = 0; + + /// \brief Quantity of verical rays + protected: int vSamples = 0; + + /// \brief Resolution of horizontal rays + protected: double hResolution = 1; + + /// \brief Resolution of vertical rays + protected: double vResolution = 1; + + /// \brief Number of channels used to store the data + protected: unsigned int channels = 1u; + + private: friend class OgreScene; + }; + + ////////////////////////////////////////////////// + template + BaseGpuRays::BaseGpuRays() + { + } + + ////////////////////////////////////////////////// + template + BaseGpuRays::~BaseGpuRays() + { + } + + ////////////////////////////////////////////////// + template + const float *BaseGpuRays::Data() const + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + void BaseGpuRays::Copy(float *_dataDest) + { + // Unused + (void)_dataDest; + } + + ////////////////////////////////////////////////// + template + void BaseGpuRays::SetClamp(bool _enable) + { + this->clamping = _enable; + + if (this->clamping) + { + this->dataMinVal = this->NearClipPlane(); + this->dataMaxVal = this->FarClipPlane(); + } + else + { + this->dataMinVal = -gz::math::INF_D; + this->dataMaxVal = gz::math::INF_D; + } + } + + ////////////////////////////////////////////////// + template + bool BaseGpuRays::Clamp() const + + { + return this->clamping; + } + + ////////////////////////////////////////////////// + template + gz::common::ConnectionPtr BaseGpuRays::ConnectNewGpuRaysFrame( + std::function) + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + void BaseGpuRays::SetIsHorizontal(const bool _horizontal) + { + this->isHorizontal = _horizontal; + } + + ////////////////////////////////////////////////// + template + bool BaseGpuRays::IsHorizontal() const + { + return this->isHorizontal; + } + + ////////////////////////////////////////////////// + template + double BaseGpuRays::RayCountRatio() const + { + return this->rayCountRatio; + } + + ////////////////////////////////////////////////// + template + void BaseGpuRays::SetRayCountRatio(const double _rayCountRatio) + { + this->rayCountRatio = _rayCountRatio; + } + + ////////////////////////////////////////////////// + template + double BaseGpuRays::RangeCountRatio() const + { + return this->rangeCountRatio; + } + + ////////////////////////////////////////////////// + template + math::Angle BaseGpuRays::VFOV() const + { + return this->vfov; + } + + ////////////////////////////////////////////////// + template + void BaseGpuRays::SetVFOV(const math::Angle &_vfov) + { + this->vfov = _vfov; + } + + template + ////////////////////////////////////////////////// + gz::math::Angle BaseGpuRays::AngleMin() const + { + return this->minAngle; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetAngleMin(double _angle) + { + this->minAngle = _angle; + } + + template + ////////////////////////////////////////////////// + gz::math::Angle BaseGpuRays::AngleMax() const + { + return this->maxAngle; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetAngleMax(double _angle) + { + this->maxAngle = _angle; + } + + template + ////////////////////////////////////////////////// + int BaseGpuRays::RayCount() const + { + return this->hSamples; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetRayCount(int _samples) + { + this->hSamples = _samples; + } + + template + ////////////////////////////////////////////////// + int BaseGpuRays::RangeCount() const + { + return static_cast(this->RayCount() * this->hResolution); + } + + template + ////////////////////////////////////////////////// + int BaseGpuRays::VerticalRayCount() const + { + return this->vSamples; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetVerticalRayCount(int _samples) + { + this->vSamples = _samples; + } + + template + ////////////////////////////////////////////////// + int BaseGpuRays::VerticalRangeCount() const + { + return static_cast(this->VerticalRayCount() * this->vResolution); + } + + template + ////////////////////////////////////////////////// + gz::math::Angle BaseGpuRays::VerticalAngleMin() const + { + return this->vMinAngle; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetVerticalAngleMin(const double _angle) + { + this->vMinAngle = _angle; + } + + template + ////////////////////////////////////////////////// + gz::math::Angle BaseGpuRays::VerticalAngleMax() const + { + return this->vMaxAngle; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetVerticalAngleMax(const double _angle) + { + this->vMaxAngle = _angle; + } + + template + ////////////////////////////////////////////////// + unsigned int BaseGpuRays::Channels() const + { + return this->channels; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetHorizontalResolution(double _resolution) + { + this->hResolution = std::abs(_resolution); + } + + template + ////////////////////////////////////////////////// + double BaseGpuRays::HorizontalResolution() const + { + return this->hResolution; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetVerticalResolution(double _resolution) + { + this->vResolution = std::abs(_resolution); + } + + template + ////////////////////////////////////////////////// + double BaseGpuRays::VerticalResolution() const + { + return this->vResolution; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseGrid.hh b/include/gz/rendering/base/BaseGrid.hh new file mode 100644 index 000000000..899f703ff --- /dev/null +++ b/include/gz/rendering/base/BaseGrid.hh @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEGRID_HH_ +#define GZ_RENDERING_BASE_BASEGRID_HH_ + +#include +#include "gz/rendering/Grid.hh" +#include "gz/rendering/base/BaseObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of a grid geometry + template + class BaseGrid : + public virtual Grid, + public virtual T + { + /// \brief Constructor + protected: BaseGrid(); + + /// \brief Destructor + public: virtual ~BaseGrid(); + + // Documentation inherited. + public: virtual void PreRender(); + + // Documentation inherited. + public: virtual void Destroy(); + + // Documentation inherited. + public: virtual unsigned int CellCount() const; + + // Documentation inherited. + public: virtual void SetCellCount(const unsigned int _count); + + // Documentation inherited. + public: virtual double CellLength() const; + + // Documentation inherited. + public: virtual void SetCellLength(const double _len); + + // Documentation inherited. + public: virtual unsigned int VerticalCellCount() const; + + // Documentation inherited. + public: virtual void SetVerticalCellCount(const unsigned int _count); + + /// \brief Number of cells in grid + protected: unsigned int cellCount = 10u; + + /// \brief Length of a single cell + protected: double cellLength = 1.0; + + /// \brief Number of cells in vertical direction + protected: unsigned int verticalCellCount = 0; + + /// \brief vertical offset of the XY plane from origin + protected: double heightOffset = 0.0; + + /// \brief Flag to indicate grid properties have changed + protected: bool gridDirty = false; + }; + + ////////////////////////////////////////////////// + // BaseGrid + ////////////////////////////////////////////////// + template + BaseGrid::BaseGrid() + { + } + + ////////////////////////////////////////////////// + template + BaseGrid::~BaseGrid() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseGrid::CellCount() const + { + return this->cellCount; + } + + ////////////////////////////////////////////////// + template + void BaseGrid::SetCellCount(const unsigned int _count) + { + this->cellCount = _count; + this->gridDirty = true; + } + + ////////////////////////////////////////////////// + template + double BaseGrid::CellLength() const + { + return this->cellLength; + } + + ////////////////////////////////////////////////// + template + void BaseGrid::SetCellLength(const double _len) + { + this->cellLength = _len; + this->gridDirty = true; + } + + ////////////////////////////////////////////////// + template + unsigned int BaseGrid::VerticalCellCount() const + { + return this->verticalCellCount; + } + + ////////////////////////////////////////////////// + template + void BaseGrid::SetVerticalCellCount(const unsigned int _count) + { + this->verticalCellCount = _count; + this->gridDirty = true; + } + + ////////////////////////////////////////////////// + template + void BaseGrid::PreRender() + { + T::PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseGrid::Destroy() + { + T::Destroy(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseHeightmap.hh b/include/gz/rendering/base/BaseHeightmap.hh new file mode 100644 index 000000000..cafcf2c5a --- /dev/null +++ b/include/gz/rendering/base/BaseHeightmap.hh @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BASE_BASEHEIGHTMAP_HH_ +#define IGNITION_RENDERING_BASE_BASEHEIGHTMAP_HH_ + +#include "ignition/rendering/Heightmap.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + ////////////////////////////////////////////////// + template + class BaseHeightmap : + public virtual Heightmap, + public virtual T + { + /// \brief Constructor + /// \param[in] _desc Descriptor containing heightmap information. + protected: explicit BaseHeightmap(const HeightmapDescriptor &_desc); + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual const HeightmapDescriptor &Descriptor() override; + + /// \brief Descriptor containing heightmap information + public: HeightmapDescriptor descriptor; + }; + + ////////////////////////////////////////////////// + template + BaseHeightmap::BaseHeightmap(const HeightmapDescriptor &_desc) + : descriptor{_desc} + { + } + + ////////////////////////////////////////////////// + template + void BaseHeightmap::PreRender() + { + T::PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseHeightmap::Destroy() + { + T::Destroy(); + } + + ////////////////////////////////////////////////// + template + const HeightmapDescriptor &BaseHeightmap::Descriptor() + { + return this->descriptor; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseInertiaVisual.hh b/include/gz/rendering/base/BaseInertiaVisual.hh new file mode 100644 index 000000000..9be984395 --- /dev/null +++ b/include/gz/rendering/base/BaseInertiaVisual.hh @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BASE_BASEINERTIAVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASEINERTIAVISUAL_HH_ + +#include "ignition/common/Console.hh" + +#include "ignition/rendering/base/BaseObject.hh" +#include "ignition/rendering/base/BaseRenderTypes.hh" +#include "ignition/rendering/InertiaVisual.hh" +#include "ignition/rendering/Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of an inertia visual + template + class BaseInertiaVisual : + public virtual InertiaVisual, + public virtual T + { + /// \brief Constructor + protected: BaseInertiaVisual(); + + /// \brief Destructor + public: virtual ~BaseInertiaVisual(); + + // Documentation inherited. + protected: virtual void Init() override; + + // Documentation inherited. + protected: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void SetInertial( + const ignition::math::Inertiald &_inertial) override; + + // Documentation inherited. + public: virtual void Load(const ignition::math::Pose3d &, + const ignition::math::Vector3d &) override; + + // Documentation inherited + public: virtual VisualPtr BoxVisual() const override; + }; + + ////////////////////////////////////////////////// + template + BaseInertiaVisual::BaseInertiaVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseInertiaVisual::~BaseInertiaVisual() + { + } + + ///////////////////////////////////////////////// + template + void BaseInertiaVisual::PreRender() + { + T::PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseInertiaVisual::Init() + { + T::Init(); + } + + ////////////////////////////////////////////////// + template + void BaseInertiaVisual::SetInertial( + const ignition::math::Inertiald &_inertial) + { + auto xyz = _inertial.Pose().Pos(); + auto q = _inertial.Pose().Rot(); + + // Use ignition::math::MassMatrix3 to compute + // equivalent box size and rotation + auto m = _inertial.MassMatrix(); + ignition::math::Vector3d boxScale; + ignition::math::Quaterniond boxRot; + if (!m.EquivalentBox(boxScale, boxRot)) + { + // Invalid inertia, load with default scale + ignlog << "The link is static or has unrealistic " + << "inertia, so the equivalent inertia box will not be shown.\n"; + } + else + { + // Apply additional rotation by boxRot + this->Load(ignition::math::Pose3d(xyz, q * boxRot), boxScale); + } + } + + ////////////////////////////////////////////////// + template + void BaseInertiaVisual::Load(const ignition::math::Pose3d &, + const ignition::math::Vector3d &) + { + // no op + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseInertiaVisual::BoxVisual() const + { + return nullptr; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseJointVisual.hh b/include/gz/rendering/base/BaseJointVisual.hh new file mode 100644 index 000000000..7a151f4fa --- /dev/null +++ b/include/gz/rendering/base/BaseJointVisual.hh @@ -0,0 +1,549 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BASE_BASEJOINTVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASEJOINTVISUAL_HH_ + +#include +#include + +#include "ignition/common/Console.hh" + +#include "ignition/rendering/ArrowVisual.hh" +#include "ignition/rendering/AxisVisual.hh" +#include "ignition/rendering/JointVisual.hh" +#include "ignition/rendering/Scene.hh" +#include "ignition/rendering/base/BaseObject.hh" +#include "ignition/rendering/base/BaseRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of a joint visual + template + class BaseJointVisual : + public virtual JointVisual, + public virtual T + { + /// \brief Constructor + protected: BaseJointVisual(); + + /// \brief Destructor + public: virtual ~BaseJointVisual(); + + // Documentation inherited. + protected: virtual void Init() override; + + // Documentation inherited. + protected: virtual void PreRender() override; + + // Documentation inherited. + protected: virtual void Destroy() override; + + // Documentation inherited. + public: virtual void SetAxis(const ignition::math::Vector3d &_axis, + bool _useParentFrame) override; + + // Documentation inherited. + public: virtual ignition::math::Vector3d Axis() const override; + + // Documentation inherited. + public: virtual void SetParentAxis( + const ignition::math::Vector3d &_axis, + const std::string &_parentName, + bool _useParentFrame) override; + + // Documentation inherited. + public: virtual ignition::math::Vector3d ParentAxis() const override; + + // Documentation inherited. + public: virtual bool UpdateAxis(const ignition::math::Vector3d &_axis, + bool _useParentFrame) override; + + // Documentation inherited. + public: virtual bool UpdateParentAxis( + const ignition::math::Vector3d &_axis, + bool _useParentFrame) override; + + // Documentation inherited. + public: virtual void SetType(const JointVisualType _type) override; + + // Documentation inherited. + public: virtual JointVisualType Type() const override; + + // Documentation inherited. + public: virtual JointVisualPtr ParentAxisVisual() const override; + + // Documentation inherited. + public: virtual ArrowVisualPtr ArrowVisual() const override; + + // Documentation inherited. + public: virtual void SetVisible(bool _visible) override; + + /// \brief Implementation for updating an axis' arrow visual. + /// \param[in] _arrowVisual Arrow visual to be updated. + /// \param[in] _axis Axis vector. + /// \param[in] _useParentFrame True if the axis vector is + /// expressed in the joint parent frame. + protected: void UpdateAxisImpl(ArrowVisualPtr _arrowVisual, + const ignition::math::Vector3d &_axis, + bool _useParentFrame); + + /// \brief Helper function to create axis visual. + protected: void CreateAxis(); + + /// \brief Helper function to create parent axis visual. + protected: void CreateParentAxis(); + + /// \brief Scale the joint visual according to the joint's child. + protected: void ScaleToChild(); + + /// \brief Type of joint visualization. + protected: JointVisualType jointVisualType = + JointVisualType::JVT_NONE; + + /// \brief The joint's XYZ frame visual. + protected: AxisVisualPtr axisVisual = nullptr; + + /// \brief The visual representing the one joint axis. There can be only + /// one axis visual per joint visual, so joints with two axes have a 2nd + /// JointVisual with its own arrowVisual. + protected: ArrowVisualPtr arrowVisual = nullptr; + + /// \brief Second joint visual for hinge2 and universal joints. It is a + /// simplified visual without an XYZ frame. + protected: JointVisualPtr parentAxisVis = nullptr; + + /// \brief Scale based on the size of the joint's child. + protected: ignition::math::Vector3d scaleToChild = + ignition::math::Vector3d::One; + + /// \brief Flag to indicate joint visual type has changed. + protected: bool dirtyJointType = false; + + /// \brief Flag to indicate axis data has changed. + protected: bool dirtyAxis = false; + + /// \brief Flag to indicate parent axis data has changed. + protected: bool dirtyParentAxis = false; + + /// \brief Joint visual axis vector. + protected: ignition::math::Vector3d axis = + ignition::math::Vector3d::Zero; + + /// \brief Flag to indicate whether axis vector is + /// expressed in joint parent frame. + protected: bool useParentFrame = false; + + /// \brief Flag to update the axis visual. + protected: bool updateAxis = false; + + /// \brief Parent axis vector. + protected: ignition::math::Vector3d parentAxis = + ignition::math::Vector3d::Zero; + + /// \brief Joint parent name. + protected: std::string jointParentName = ""; + + /// \brief Flag to indicate whether parent axis vector is + /// expressed in joint parent frame. + protected: bool parentAxisUseParentFrame = false; + + /// \brief Flag to update the parent axis visual. + protected: bool updateParentAxis = false; + }; + + ////////////////////////////////////////////////// + template + BaseJointVisual::BaseJointVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseJointVisual::~BaseJointVisual() + { + } + + ///////////////////////////////////////////////// + template + void BaseJointVisual::PreRender() + { + T::PreRender(); + + if (this->ParentAxisVisual()) + { + this->ParentAxisVisual()->PreRender(); + } + + if (this->dirtyJointType) + { + this->UpdateAxis(this->axis, this->useParentFrame); + this->UpdateParentAxis(this->parentAxis, + this->parentAxisUseParentFrame); + + this->dirtyJointType = false; + } + + if (this->dirtyAxis) + { + this->CreateAxis(); + this->dirtyAxis = false; + } + + if (this->dirtyParentAxis) + { + this->CreateParentAxis(); + this->dirtyParentAxis = false; + } + + if (this->updateAxis) + { + this->updateAxis = + !this->UpdateAxis(this->axis, this->useParentFrame); + } + + if (this->updateParentAxis) + { + this->updateParentAxis = + !this->UpdateParentAxis(this->parentAxis, + this->parentAxisUseParentFrame); + } + } + + ////////////////////////////////////////////////// + template + void BaseJointVisual::Init() + { + T::Init(); + + this->axisVisual = this->Scene()->CreateAxisVisual(); + this->AddChild(this->axisVisual); + this->SetInheritScale(false); + } + + ///////////////////////////////////////////////// + template + void BaseJointVisual::Destroy() + { + if (this->arrowVisual != nullptr) + { + this->arrowVisual->Destroy(); + this->arrowVisual.reset(); + } + + if (this->axisVisual != nullptr) + { + this->axisVisual->Destroy(); + this->axisVisual.reset(); + } + + if (this->parentAxisVis != nullptr) + { + this->parentAxisVis->Destroy(); + this->parentAxisVis.reset(); + } + + this->dirtyJointType = false; + this->dirtyAxis = false; + this->dirtyParentAxis = false; + + T::Destroy(); + } + + ///////////////////////////////////////////////// + template + void BaseJointVisual::SetAxis( + const ignition::math::Vector3d &_axis, + bool _useParentFrame) + { + this->axis = _axis; + this->useParentFrame = _useParentFrame; + this->dirtyAxis = true; + } + + ///////////////////////////////////////////////// + template + void BaseJointVisual::CreateAxis() + { + if (this->arrowVisual) + { + this->arrowVisual->Destroy(); + this->arrowVisual.reset(); + } + + this->arrowVisual = this->Scene()->CreateArrowVisual(); + this->arrowVisual->SetMaterial("Default/TransYellow"); + this->arrowVisual->SetLocalPosition(0, 0, 0); + this->arrowVisual->SetLocalRotation(0, 0, 0); + this->AddChild(this->arrowVisual); + + this->updateAxis = true; + this->ScaleToChild(); + } + + ///////////////////////////////////////////////// + template + void BaseJointVisual::SetParentAxis( + const ignition::math::Vector3d &_axis, + const std::string &_parentName, + bool _useParentFrame) + { + if (this->Type() != JointVisualType::JVT_REVOLUTE2 && + this->Type() != JointVisualType::JVT_UNIVERSAL) + { + ignlog << "Joint visual is not of type Revolute2 or " + << " Universal " + << " so the parent axis will not be shown\n"; + return; + } + + this->parentAxis = _axis; + this->parentAxisUseParentFrame = _useParentFrame; + this->jointParentName = _parentName; + this->dirtyParentAxis = true; + } + + ///////////////////////////////////////////////// + template + void BaseJointVisual::CreateParentAxis() + { + auto jointParentVis = this->Scene()->NodeByName(this->jointParentName); + if (jointParentVis == nullptr) + { + ignlog << "Joint parent with name " << this->jointParentName + << " does not exist" + << " so the parent axis will not be shown\n"; + return; + } + + if (this->parentAxisVis) + { + this->parentAxisVis->Destroy(); + this->parentAxisVis.reset(); + } + + this->parentAxisVis = this->Scene()->CreateJointVisual(); + jointParentVis->AddChild(this->parentAxisVis); + this->parentAxisVis->SetType(this->Type()); + this->parentAxisVis->SetAxis(this->parentAxis, + this->parentAxisUseParentFrame); + + this->updateParentAxis = true; + this->ScaleToChild(); + } + + ////////////////////////////////////////////////// + template + bool BaseJointVisual::UpdateAxis(const ignition::math::Vector3d &_axis, + bool _useParentFrame) + { + if (this->ArrowVisual() && this->HasParent()) + { + this->UpdateAxisImpl(this->ArrowVisual(), _axis, _useParentFrame); + return true; + } + + return false; + } + + ////////////////////////////////////////////////// + template + bool BaseJointVisual::UpdateParentAxis( + const ignition::math::Vector3d &_axis, + bool _useParentFrame) + { + if (this->ParentAxisVisual() && + this->ParentAxisVisual()->ArrowVisual() && + this->ParentAxisVisual()->HasParent()) + { + this->UpdateAxisImpl(this->ParentAxisVisual()->ArrowVisual(), + _axis, _useParentFrame); + return true; + } + + return false; + } + + ////////////////////////////////////////////////// + template + void BaseJointVisual::UpdateAxisImpl(ArrowVisualPtr _arrowVisual, + const ignition::math::Vector3d &_axis, + bool _useParentFrame) + { + // Get rotation to axis vector + ignition::math::Vector3d axisDir = _axis; + ignition::math::Vector3d u = axisDir.Normalize(); + ignition::math::Vector3d v = ignition::math::Vector3d::UnitZ; + double cosTheta = v.Dot(u); + double angle = acos(cosTheta); + ignition::math::Quaterniond quat; + // check the parallel case + if (ignition::math::equal(angle, IGN_PI)) + quat.Axis(u.Perpendicular(), angle); + else + quat.Axis((v.Cross(u)).Normalize(), angle); + _arrowVisual->SetLocalRotation(quat); + + if (_useParentFrame) + { + ignition::math::Pose3d parentInitPose = + this->Parent()->InitialLocalPose(); + + // get rotation of joint visual in model frame + ignition::math::Quaterniond quatFromModel = + (parentInitPose * this->LocalPose()).Rot(); + + // rotate arrow visual so that the axis vector applies to the model + // frame. + _arrowVisual->SetLocalRotation(quatFromModel.Inverse() * + _arrowVisual->LocalRotation()); + } + + _arrowVisual->ShowArrowRotation( + this->Type() == JointVisualType::JVT_REVOLUTE || + this->Type() == JointVisualType::JVT_REVOLUTE2 || + this->Type() == JointVisualType::JVT_UNIVERSAL || + this->Type() == JointVisualType::JVT_GEARBOX); + + if (this->axisVisual) + _arrowVisual->SetVisible(true); + else + return; + + // Don't change the visibility of joint child axis + if (this->ArrowVisual() != _arrowVisual) + return; + + // Hide existing arrow head if it overlaps with the axis + auto axisWorldRotation = _arrowVisual->WorldPose().Rot(); + auto jointWorldRotation = this->WorldPose().Rot(); + + this->axisVisual->ShowAxisHead(true); + _arrowVisual->ShowArrowShaft(true); + + auto axisWorld = axisWorldRotation * ignition::math::Vector3d::UnitZ; + if (axisWorld == jointWorldRotation * ignition::math::Vector3d::UnitX) + { + this->axisVisual->ShowAxisHead(0, false); + _arrowVisual->ShowArrowShaft(false); + } + else if (axisWorld == + jointWorldRotation * ignition::math::Vector3d::UnitY) + { + this->axisVisual->ShowAxisHead(1, false); + _arrowVisual->ShowArrowShaft(false); + } + else if (axisWorld == + jointWorldRotation * ignition::math::Vector3d::UnitZ) + { + this->axisVisual->ShowAxisHead(2, false); + _arrowVisual->ShowArrowShaft(false); + } + } + + ////////////////////////////////////////////////// + template + void BaseJointVisual::ScaleToChild() + { + if (!this->HasParent()) + return; + + // Joint visual is attached to the child's visual + VisualPtr parentVisual = + std::dynamic_pointer_cast(this->Parent()); + + if (parentVisual) + { + double childSize = + std::max(0.1, parentVisual->BoundingBox().Size().Length()); + this->scaleToChild = ignition::math::Vector3d(childSize * 0.2, + childSize * 0.2, childSize * 0.2); + this->SetLocalScale(this->scaleToChild); + if (this->ParentAxisVisual()) + this->ParentAxisVisual()->SetLocalScale(this->scaleToChild); + } + } + + ////////////////////////////////////////////////// + template + void BaseJointVisual::SetType(const JointVisualType _type) + { + this->jointVisualType = _type; + this->dirtyJointType = true; + } + + ////////////////////////////////////////////////// + template + ignition::math::Vector3d BaseJointVisual::Axis() const + { + return this->axis; + } + + ////////////////////////////////////////////////// + template + ignition::math::Vector3d BaseJointVisual::ParentAxis() const + { + return this->parentAxis; + } + + ////////////////////////////////////////////////// + template + JointVisualType BaseJointVisual::Type() const + { + return this->jointVisualType; + } + + ////////////////////////////////////////////////// + template + JointVisualPtr BaseJointVisual::ParentAxisVisual() const + { + return this->parentAxisVis; + } + + ////////////////////////////////////////////////// + template + ArrowVisualPtr BaseJointVisual::ArrowVisual() const + { + return this->arrowVisual; + } + + ////////////////////////////////////////////////// + template + void BaseJointVisual::SetVisible(bool _visible) + { + T::SetVisible(_visible); + + if (this->ArrowVisual()) + this->ArrowVisual()->SetVisible(_visible); + + if (this->Type() == JointVisualType::JVT_REVOLUTE2 || + this->Type() == JointVisualType::JVT_UNIVERSAL) + { + if (this->ParentAxisVisual()) + this->ParentAxisVisual()->SetVisible(_visible); + } + + if (this->axisVisual) + this->axisVisual->SetVisible(_visible); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseLidarVisual.hh b/include/gz/rendering/base/BaseLidarVisual.hh new file mode 100644 index 000000000..4e0edb24d --- /dev/null +++ b/include/gz/rendering/base/BaseLidarVisual.hh @@ -0,0 +1,539 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef IGNITION_RENDERING_BASELIDARVISUAL_HH_ +#define IGNITION_RENDERING_BASELIDARVISUAL_HH_ + +#include + +#include "ignition/rendering/LidarVisual.hh" +#include "ignition/rendering/base/BaseObject.hh" +#include "ignition/rendering/base/BaseRenderTypes.hh" +#include "ignition/rendering/Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \brief Base implementation of a Lidar Visual + template + class BaseLidarVisual : + public virtual LidarVisual, + public virtual T + { + // Documentation inherited + protected: BaseLidarVisual(); + + // Documentation inherited + public: virtual ~BaseLidarVisual(); + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual void ClearPoints() override; + + // Documentation inherited + public: virtual void SetPoints( + const std::vector &_points) override; + + // Documentation inherited + public: virtual void SetPoints(const std::vector &_points, + const std::vector &_colors) + override; + + // Documentation inherited + public: virtual void Update() override; + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void SetMinVerticalAngle( + double _minVerticalAngle) override; + + // Documentation inherited + public: virtual double MinVerticalAngle() const override; + + // Documentation inherited + public: virtual void SetMaxVerticalAngle( + double _maxVerticalAngle) override; + + // Documentation inherited + public: virtual double MaxVerticalAngle() const override; + + // Documentation inherited + public: virtual void SetMinHorizontalAngle( + double _minHorizontalAngle) override; + + // Documentation inherited + public: virtual double MinHorizontalAngle() const override; + + // Documentation inherited + public: virtual void SetMaxHorizontalAngle( + double _maxHorizontalAngle) override; + + // Documentation inherited + public: virtual double MaxHorizontalAngle() const override; + + // Documentation inherited + public: virtual void SetVerticalRayCount( + unsigned int _verticalRayCount) override; + + // Documentation inherited + public: virtual unsigned int VerticalRayCount() const override; + + // Documentation inherited + public: virtual void SetHorizontalRayCount( + unsigned int _horizontalRayCount) override; + + // Documentation inherited + public: virtual unsigned int HorizontalRayCount() const override; + + // Documentation inherited + public: virtual void SetMinRange(double _minRange) override; + + // Documentation inherited + public: virtual double MinRange() const override; + + // Documentation inherited + public: virtual void SetMaxRange(double _maxRange) override; + + // Documentation inherited + public: virtual double MaxRange() const override; + + // Documentation inherited + public: virtual void SetOffset( + const ignition::math::Pose3d _offset) override; + + // Documentation inherited + public: virtual ignition::math::Pose3d Offset() const override; + + // Documentation inherited + public: virtual unsigned int PointCount() const override; + + // Documentation inherited + public: virtual std::vector Points() const override; + + // Documentation inherited + public: virtual void SetType(const LidarVisualType _type) override; + + // Documentation inherited + public: virtual LidarVisualType Type() const override; + + // Documentation inherited + public: virtual void SetSize(double _size) override; + + // Documentation inherited + public: virtual double Size() const override; + + /// \brief Create predefined materials for lidar visual + public: virtual void CreateMaterials(); + + // Documentation inherited + public: virtual void SetDisplayNonHitting(bool _display) override; + + // Documentation inherited + public: virtual bool DisplayNonHitting() const override; + + /// \brief Vertical minimal angle + protected: double minVerticalAngle = 0; + + /// \brief Vertical maximum angle + protected: double maxVerticalAngle = 0; + + /// \brief Vertical laser count + protected: unsigned int verticalCount = 1u; + + /// \brief Angle between two vertical rays + protected: double verticalAngleStep = 0; + + /// \brief Horizontal minimal angle + protected: double minHorizontalAngle = 0; + + /// \brief Horizontal maximum angle + protected: double maxHorizontalAngle = 0; + + /// \brief Horizontal laser count + protected: unsigned int horizontalCount = 1u; + + /// \brief Angle between two horizontal rays + protected: double horizontalAngleStep = 0; + + /// \brief Minimum Range + protected: double minRange = 0; + + /// \brief Maximum Range + protected: double maxRange = 0; + + /// \brief Option to display non-hitting rays + protected: bool displayNonHitting = true; + + /// \brief Offset of visual + protected: ignition::math::Pose3d offset = ignition::math::Pose3d::Zero; + + /// \brief Type of lidar visualisation + protected: LidarVisualType lidarVisualType = + LidarVisualType::LVT_TRIANGLE_STRIPS; + + /// \brief Size of lidar visualisation + protected: double size = 1.0; + }; + + ///////////////////////////////////////////////// + // BaseLidarVisual + ///////////////////////////////////////////////// + template + BaseLidarVisual::BaseLidarVisual() + { + } + + ///////////////////////////////////////////////// + template + BaseLidarVisual::~BaseLidarVisual() + { + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::PreRender() + { + T::PreRender(); + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::Destroy() + { + T::Destroy(); + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::ClearPoints() + { + // no op + } + + ///////////////////////////////////////////////// + template + unsigned int BaseLidarVisual::PointCount() const + { + return 0u; + } + + ///////////////////////////////////////////////// + template + std::vector BaseLidarVisual::Points() const + { + std::vector d; + return d; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::Update() + { + // no op + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetPoints(const std::vector &) + { + // no op + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetPoints(const std::vector &, + const std::vector &) + { + // no op + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::Init() + { + T::Init(); + this->CreateMaterials(); + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetMinVerticalAngle( + double _minVerticalAngle) + { + this->minVerticalAngle = _minVerticalAngle; + } + + ///////////////////////////////////////////////// + template + double BaseLidarVisual::MinVerticalAngle() const + { + return this->minVerticalAngle; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetMaxVerticalAngle( + double _maxVerticalAngle) + { + this->maxVerticalAngle = _maxVerticalAngle; + } + + ///////////////////////////////////////////////// + template + double BaseLidarVisual::MaxVerticalAngle() const + { + return this->maxVerticalAngle; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetVerticalRayCount( + unsigned int _verticalRayCount) + { + if (_verticalRayCount == 0) + { + ignwarn << "Cannot have zero vertical rays. Setting value to 1." + << std::endl; + this->verticalCount = 1; + } + else + { + this->verticalCount = _verticalRayCount; + } + } + + ///////////////////////////////////////////////// + template + unsigned int BaseLidarVisual::VerticalRayCount() const + { + return this->verticalCount; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetMinHorizontalAngle( + double _minHorizontalAngle) + { + this->minHorizontalAngle = _minHorizontalAngle; + } + + ///////////////////////////////////////////////// + template + double BaseLidarVisual::MinHorizontalAngle() const + { + return this->minHorizontalAngle; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetMaxHorizontalAngle( + double _maxHorizontalAngle) + { + this->maxHorizontalAngle = _maxHorizontalAngle; + } + + ///////////////////////////////////////////////// + template + double BaseLidarVisual::MaxHorizontalAngle() const + { + return this->maxHorizontalAngle; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetHorizontalRayCount( + unsigned int _horizontalRayCount) + { + if (_horizontalRayCount == 0) + { + ignwarn << "Cannot have zero horizontal rays. Setting value to 1." + << std::endl; + this->horizontalCount = 1u; + } + else + { + this->horizontalCount = _horizontalRayCount; + } + } + + ///////////////////////////////////////////////// + template + unsigned int BaseLidarVisual::HorizontalRayCount() const + { + return this->horizontalCount; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetMinRange(double _minRange) + { + this->minRange = _minRange; + } + + ///////////////////////////////////////////////// + template + double BaseLidarVisual::MinRange() const + { + return this->minRange; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetMaxRange(double _maxRange) + { + this->maxRange = _maxRange; + } + + ///////////////////////////////////////////////// + template + double BaseLidarVisual::MaxRange() const + { + return this->maxRange; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetOffset(const ignition::math::Pose3d _offset) + { + this->offset = _offset; + } + + ///////////////////////////////////////////////// + template + ignition::math::Pose3d BaseLidarVisual::Offset() const + { + return this->offset; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetType(const LidarVisualType _type) + { + this->lidarVisualType = _type; + } + + ///////////////////////////////////////////////// + template + LidarVisualType BaseLidarVisual::Type() const + { + return this->lidarVisualType; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetSize(double _size) + { + this->size = _size; + } + + ///////////////////////////////////////////////// + template + double BaseLidarVisual::Size() const + { + return this->size; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::SetDisplayNonHitting(bool _display) + { + this->displayNonHitting = _display; + } + + ///////////////////////////////////////////////// + template + bool BaseLidarVisual::DisplayNonHitting() const + { + return this->displayNonHitting; + } + + ///////////////////////////////////////////////// + template + void BaseLidarVisual::CreateMaterials() + { + MaterialPtr mtl; + + if (!this->Scene()->MaterialRegistered("Lidar/BlueStrips")) + { + mtl = this->Scene()->CreateMaterial("Lidar/BlueStrips"); + mtl->SetAmbient(0.0, 0.0, 1.0); + mtl->SetDiffuse(0.0, 0.0, 1.0); + mtl->SetEmissive(0.0, 0.0, 1.0); + mtl->SetTransparency(0.4); + mtl->SetCastShadows(false); + mtl->SetReceiveShadows(false); + mtl->SetLightingEnabled(false); + mtl->SetMetalness(0.0f); + mtl->SetReflectivity(0.0); + } + + if (!this->Scene()->MaterialRegistered("Lidar/LightBlueStrips")) + { + mtl = this->Scene()->CreateMaterial("Lidar/LightBlueStrips"); + mtl->SetAmbient(0.0, 0.0, 1.0); + mtl->SetDiffuse(0.0, 0.0, 1.0); + mtl->SetEmissive(0.0, 0.0, 1.0); + mtl->SetTransparency(0.8); + mtl->SetCastShadows(false); + mtl->SetReceiveShadows(false); + mtl->SetLightingEnabled(false); + mtl->SetMetalness(0.0f); + mtl->SetReflectivity(0.0); + } + + if (!this->Scene()->MaterialRegistered("Lidar/TransBlack")) + { + mtl = this->Scene()->CreateMaterial("Lidar/TransBlack"); + mtl->SetAmbient(0.0, 0.0, 0.0); + mtl->SetDiffuse(0.0, 0.0, 0.0); + mtl->SetEmissive(0.0, 0.0, 0.0); + mtl->SetTransparency(0.4); + mtl->SetCastShadows(false); + mtl->SetReceiveShadows(false); + mtl->SetLightingEnabled(false); + mtl->SetMetalness(0.5f); + mtl->SetReflectivity(0.2); + } + + if (!this->Scene()->MaterialRegistered("Lidar/BlueRay")) + { + mtl = this->Scene()->CreateMaterial("Lidar/BlueRay"); + mtl->SetAmbient(0.0, 0.0, 1.0); + mtl->SetDiffuse(0.0, 0.0, 1.0); + mtl->SetEmissive(0.0, 0.0, 1.0); + mtl->SetSpecular(0.0, 0.0, 1.0); + mtl->SetTransparency(0.0); + mtl->SetCastShadows(false); + mtl->SetReceiveShadows(false); + mtl->SetLightingEnabled(false); + mtl->SetMetalness(0.1f); + mtl->SetReflectivity(0.2); + } + return; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseLight.hh b/include/gz/rendering/base/BaseLight.hh new file mode 100644 index 000000000..3e467b140 --- /dev/null +++ b/include/gz/rendering/base/BaseLight.hh @@ -0,0 +1,249 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASELIGHT_HH_ +#define GZ_RENDERING_BASE_BASELIGHT_HH_ + +#include "gz/rendering/Light.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseLight : + public virtual Light, + public virtual T + { + protected: BaseLight(); + + public: virtual ~BaseLight(); + + // Documentation inherited + public: virtual void SetDiffuseColor(double _r, double _g, double _b, + double _a = 1.0); + + // Documentation inherited. + public: virtual void SetDiffuseColor(const math::Color &_color) = 0; + + // Documentation inherited. + public: virtual void SetSpecularColor(double _r, double _g, double _b, + double _a = 1.0); + + // Documentation inherited. + public: virtual void SetSpecularColor(const math::Color &_color) = 0; + + // Documentation inherited. + public: virtual void SetAttenuationConstant(double _value) = 0; + + // Documentation inherited. + public: virtual void SetAttenuationLinear(double _value) = 0; + + // Documentation inherited. + public: virtual void SetAttenuationQuadratic(double _value) = 0; + + // Documentation inherited. + public: virtual void SetAttenuationRange(double _range) = 0; + + // Documentation inherited. + public: virtual void SetCastShadows(bool _castShadows) = 0; + + // Documentation inherited. + protected: virtual void Reset(); + }; + + template + class BaseDirectionalLight : + public virtual DirectionalLight, + public virtual T + { + protected: BaseDirectionalLight(); + + public: virtual ~BaseDirectionalLight(); + + public: virtual void SetDirection(double _x, double _y, double _z); + + public: virtual void SetDirection(const math::Vector3d &_dir) = 0; + + protected: virtual void Reset(); + }; + + template + class BasePointLight : + public virtual PointLight, + public virtual T + { + protected: BasePointLight(); + + public: virtual ~BasePointLight(); + }; + + template + class BaseSpotLight : + public virtual SpotLight, + public virtual T + { + protected: BaseSpotLight(); + + public: virtual ~BaseSpotLight(); + + public: virtual void SetDirection(double _x, double _y, double _z); + + public: virtual void SetDirection(const math::Vector3d &_dir) = 0; + + public: virtual void SetInnerAngle(double _radians); + + public: virtual void SetInnerAngle(const math::Angle &_angle) = 0; + + public: virtual void SetOuterAngle(double _radians); + + public: virtual void SetOuterAngle(const math::Angle &_angle) = 0; + + public: virtual void SetFalloff(double _falloff) = 0; + + protected: virtual void Reset(); + }; + + ////////////////////////////////////////////////// + template + BaseLight::BaseLight() + { + } + + ////////////////////////////////////////////////// + template + BaseLight::~BaseLight() + { + } + + ////////////////////////////////////////////////// + template + void BaseLight::SetDiffuseColor(double _r, double _g, double _b, + double _a) + { + this->SetDiffuseColor(math::Color(_r, _g, _b, _a)); + } + + ////////////////////////////////////////////////// + template + void BaseLight::SetSpecularColor(double _r, double _g, double _b, + double _a) + { + this->SetSpecularColor(math::Color(_r, _g, _b, _a)); + } + + ////////////////////////////////////////////////// + template + void BaseLight::Reset() + { + this->SetDiffuseColor(math::Color::White); + this->SetSpecularColor(math::Color::White); + this->SetAttenuationConstant(1); + this->SetAttenuationLinear(0); + this->SetAttenuationQuadratic(0); + this->SetAttenuationRange(100); + this->SetCastShadows(true); + this->SetIntensity(1.0); + } + + ////////////////////////////////////////////////// + template + BaseDirectionalLight::BaseDirectionalLight() + { + } + + ////////////////////////////////////////////////// + template + BaseDirectionalLight::~BaseDirectionalLight() + { + } + + ////////////////////////////////////////////////// + template + void BaseDirectionalLight::SetDirection(double _x, double _y, double _z) + { + this->SetDirection(math::Vector3d(_x, _y, _z)); + } + + ////////////////////////////////////////////////// + template + void BaseDirectionalLight::Reset() + { + T::Reset(); + this->SetDirection(0, 0, -1); + } + + ////////////////////////////////////////////////// + template + BasePointLight::BasePointLight() + { + } + + ////////////////////////////////////////////////// + template + BasePointLight::~BasePointLight() + { + } + + ////////////////////////////////////////////////// + template + BaseSpotLight::BaseSpotLight() + { + } + + ////////////////////////////////////////////////// + template + BaseSpotLight::~BaseSpotLight() + { + } + + ////////////////////////////////////////////////// + template + void BaseSpotLight::SetDirection(double _x, double _y, double _z) + { + this->SetDirection(math::Vector3d(_x, _y, _z)); + } + + ////////////////////////////////////////////////// + template + void BaseSpotLight::SetInnerAngle(double _radians) + { + this->SetInnerAngle(math::Angle(_radians)); + } + + ////////////////////////////////////////////////// + template + void BaseSpotLight::SetOuterAngle(double _radians) + { + this->SetOuterAngle(math::Angle(_radians)); + } + + ////////////////////////////////////////////////// + template + void BaseSpotLight::Reset() + { + T::Reset(); + this->SetDirection(0, 0, -1); + this->SetInnerAngle(IGN_PI / 4.5); + this->SetOuterAngle(IGN_PI / 4.0); + this->SetFalloff(1.0); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseLightVisual.hh b/include/gz/rendering/base/BaseLightVisual.hh new file mode 100644 index 000000000..d36e05280 --- /dev/null +++ b/include/gz/rendering/base/BaseLightVisual.hh @@ -0,0 +1,275 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BASE_BASELIGHTVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASELIGHTVISUAL_HH_ + +#include + +#include "ignition/rendering/base/BaseObject.hh" +#include "ignition/rendering/base/BaseRenderTypes.hh" +#include "ignition/rendering/LightVisual.hh" +#include "ignition/rendering/Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of a light visual + template + class BaseLightVisual : + public virtual LightVisual, + public virtual T + { + /// \brief Constructor + protected: BaseLightVisual(); + + /// \brief Destructor + public: virtual ~BaseLightVisual(); + + // Documentation inherited. + protected: virtual void Init() override; + + // Documentation inherited. + protected: virtual void PreRender() override; + + // Documentation inherited + public: virtual void SetType(LightVisualType _type) override; + + // Documentation inherited + public: virtual void SetInnerAngle(double _innerAngle) override; + + // Documentation inherited + public: virtual double InnerAngle() override; + + // Documentation inherited + public: virtual void SetOuterAngle(double _innerAngle) override; + + // Documentation inherited + public: virtual double OuterAngle() override; + + /// \brief Draw the light visual using dynamic renderables + public: std::vector CreateVisualLines(); + + // Documentation inherited + public: virtual LightVisualType Type() override; + + /// \brief Type of light visual + protected: LightVisualType type = LightVisualType::LVT_EMPTY; + + /// \brief Inner angle for spot lights + protected: double innerAngle = 0; + + /// \brief Outer angle for spot lights + protected: double outerAngle = 0; + + /// \brief Flag to indicate light properties have changed + protected: bool dirtyLightVisual = false; + }; + + ////////////////////////////////////////////////// + template + BaseLightVisual::BaseLightVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseLightVisual::~BaseLightVisual() + { + } + + ///////////////////////////////////////////////// + template + void BaseLightVisual::PreRender() + { + T::PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseLightVisual::Init() + { + T::Init(); + } + + ////////////////////////////////////////////////// + template + void BaseLightVisual::SetType(LightVisualType _type) + { + this->type = _type; + this->dirtyLightVisual = true; + } + + ////////////////////////////////////////////////// + template + LightVisualType BaseLightVisual::Type() + { + return this->type; + } + + ////////////////////////////////////////////////// + template + void BaseLightVisual::SetInnerAngle(double _innerAngle) + { + this->innerAngle = _innerAngle; + this->dirtyLightVisual = true; + } + + ////////////////////////////////////////////////// + template + double BaseLightVisual::InnerAngle() + { + return this->innerAngle; + } + + ////////////////////////////////////////////////// + template + void BaseLightVisual::SetOuterAngle(double _outerAngle) + { + this->outerAngle = _outerAngle; + this->dirtyLightVisual = true; + } + + ////////////////////////////////////////////////// + template + double BaseLightVisual::OuterAngle() + { + return this->outerAngle; + } + + template + std::vector + BaseLightVisual::CreateVisualLines() + { + std::vector positions; + + if (this->type == LightVisualType::LVT_DIRECTIONAL) + { + float s = 0.5; + positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); + positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); + + positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); + positions.emplace_back(ignition::math::Vector3d(s, s, 0)); + + positions.emplace_back(ignition::math::Vector3d(s, s, 0)); + positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); + + positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); + positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); + + positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); + positions.emplace_back(ignition::math::Vector3d(0, 0, -s)); + } + else if (this->type == LightVisualType::LVT_POINT) + { + float s = 0.1f; + positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); + positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); + + positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); + positions.emplace_back(ignition::math::Vector3d(s, s, 0)); + + positions.emplace_back(ignition::math::Vector3d(s, s, 0)); + positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); + + positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); + positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); + + positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); + positions.emplace_back(ignition::math::Vector3d(0, 0, s)); + + positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); + positions.emplace_back(ignition::math::Vector3d(0, 0, s)); + + positions.emplace_back(ignition::math::Vector3d(s, s, 0)); + positions.emplace_back(ignition::math::Vector3d(0, 0, s)); + + positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); + positions.emplace_back(ignition::math::Vector3d(0, 0, s)); + + positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); + positions.emplace_back(ignition::math::Vector3d(0, 0, -s)); + + positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); + positions.emplace_back(ignition::math::Vector3d(0, 0, -s)); + + positions.emplace_back(ignition::math::Vector3d(s, s, 0)); + positions.emplace_back(ignition::math::Vector3d(0, 0, -s)); + + positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); + positions.emplace_back(ignition::math::Vector3d(0, 0, -s)); + } + else if (this->type == LightVisualType::LVT_SPOT) + { + double angles[2]; + double range = 0.2; + angles[0] = range * tan(outerAngle / 2.0); + angles[1] = range * tan(innerAngle / 2.0); + + unsigned int i = 0; + positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); + positions.emplace_back( + ignition::math::Vector3d(angles[i], angles[i], -range)); + + for (i = 0; i < 2; i++) + { + positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); + positions.emplace_back(ignition::math::Vector3d( + angles[i], angles[i], -range)); + + positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); + positions.emplace_back(ignition::math::Vector3d( + -angles[i], -angles[i], -range)); + + positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); + positions.emplace_back(ignition::math::Vector3d( + angles[i], -angles[i], -range)); + + positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); + positions.emplace_back(ignition::math::Vector3d( + -angles[i], angles[i], -range)); + + positions.emplace_back(ignition::math::Vector3d( + angles[i], angles[i], -range)); + positions.emplace_back(ignition::math::Vector3d( + -angles[i], angles[i], -range)); + + positions.emplace_back(ignition::math::Vector3d( + -angles[i], angles[i], -range)); + positions.emplace_back(ignition::math::Vector3d( + -angles[i], -angles[i], -range)); + + positions.emplace_back(ignition::math::Vector3d( + -angles[i], -angles[i], -range)); + positions.emplace_back(ignition::math::Vector3d( + angles[i], -angles[i], -range)); + + positions.emplace_back(ignition::math::Vector3d( + angles[i], -angles[i], -range)); + positions.emplace_back(ignition::math::Vector3d( + angles[i], angles[i], -range)); + } + } + return positions; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseMarker.hh b/include/gz/rendering/base/BaseMarker.hh new file mode 100644 index 000000000..2f7070964 --- /dev/null +++ b/include/gz/rendering/base/BaseMarker.hh @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_BASEMARKER_HH_ +#define GZ_RENDERING_BASEMARKER_HH_ + +#include + +#include "gz/rendering/Marker.hh" +#include "gz/rendering/base/BaseObject.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \brief Base implementation of a Marker geometry + template + class BaseMarker : + public virtual Marker, + public virtual T + { + /// \brief Constructor. + protected: BaseMarker(); + + /// \brief Destructor. + public: virtual ~BaseMarker(); + + /// \brief PreRender function + public: virtual void PreRender() override; + + /// \brief Destroy function + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual void SetLifetime(const + std::chrono::steady_clock::duration &_lifetime) override; + + // Documentation inherited + public: virtual std::chrono::steady_clock::duration Lifetime() + const override; + + // Documentation inherited + public: virtual void SetType(const MarkerType _markerType) override; + + // Documentation inherited + public: virtual MarkerType Type() const override; + + // Documentation inherited + public: virtual void SetSize(double _size) override; + + // Documentation inherited + public: virtual double Size() const override; + + // Documentation inherited + public: virtual void SetLayer(int32_t _layer) override; + + // Documentation inherited + public: virtual int32_t Layer() const override; + + // Documentation inherited + public: virtual void ClearPoints() override; + + // Documentation inherited + public: virtual void AddPoint(double _x, + double _y, double _z, + const gz::math::Color &_color) override; + + // Documentation inherited + public: virtual void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color) override; + + // Documentation inherited + public: virtual void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value) override; + + /// \brief Life time of a marker + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: std::chrono::steady_clock::duration lifetime = + std::chrono::steady_clock::duration::zero(); + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Layer at which the marker will reside + protected: int32_t layer = 0; + + /// \brief Flag to indicate if marker needs to be updated + protected: bool markerDirty = false; + + /// \brief Marker type + protected: MarkerType markerType = + gz::rendering::MarkerType::MT_NONE; + + /// \brief Marker size + protected: double size = 1.0; + }; + + ///////////////////////////////////////////////// + // BaseMarker + ///////////////////////////////////////////////// + template + BaseMarker::BaseMarker() + { + } + + ///////////////////////////////////////////////// + template + BaseMarker::~BaseMarker() + { + } + + ///////////////////////////////////////////////// + template + void BaseMarker::SetLifetime( + const std::chrono::steady_clock::duration &_lifetime) + { + this->lifetime = _lifetime; + this->markerDirty = true; + } + + ///////////////////////////////////////////////// + template + std::chrono::steady_clock::duration BaseMarker::Lifetime() const + { + return this->lifetime; + } + + ///////////////////////////////////////////////// + template + void BaseMarker::SetLayer(int32_t _layer) + { + this->layer = _layer; + this->markerDirty = true; + } + + ///////////////////////////////////////////////// + template + int32_t BaseMarker::Layer() const + { + return this->layer; + } + + ///////////////////////////////////////////////// + template + void BaseMarker::SetType(const MarkerType _markerType) + { + this->markerType = _markerType; + this->markerDirty = true; + } + + ///////////////////////////////////////////////// + template + MarkerType BaseMarker::Type() const + { + return this->markerType; + } + + ///////////////////////////////////////////////// + template + void BaseMarker::SetSize(double _size) + { + this->size = _size; + this->markerDirty = true; + } + + ///////////////////////////////////////////////// + template + double BaseMarker::Size() const + { + return this->size; + } + + ///////////////////////////////////////////////// + template + void BaseMarker::PreRender() + { + T::PreRender(); + } + + ///////////////////////////////////////////////// + template + void BaseMarker::Destroy() + { + T::Destroy(); + } + + ///////////////////////////////////////////////// + template + void BaseMarker::ClearPoints() + { + // no op + } + + ///////////////////////////////////////////////// + template + void BaseMarker::AddPoint(const gz::math::Vector3d &, + const gz::math::Color &) + { + // no op + } + + ///////////////////////////////////////////////// + template + void BaseMarker::AddPoint(double _x, double _y, double _z, + const gz::math::Color &_color) + { + this->AddPoint(gz::math::Vector3d(_x, _y, _z), _color); + } + + ///////////////////////////////////////////////// + template + void BaseMarker::SetPoint(unsigned int, + const gz::math::Vector3d &) + { + // no op + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseMaterial.hh b/include/gz/rendering/base/BaseMaterial.hh new file mode 100644 index 000000000..6d82c173b --- /dev/null +++ b/include/gz/rendering/base/BaseMaterial.hh @@ -0,0 +1,1065 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEMATERIAL_HH_ +#define GZ_RENDERING_BASE_BASEMATERIAL_HH_ + +#include + +#include "gz/common/Console.hh" + +#include "gz/rendering/Material.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/ShaderType.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Default pbr material properties + static const common::Pbr kDefaultPbr; + + template + class BaseMaterial : + public virtual Material, + public virtual T + { + protected: BaseMaterial(); + + public: virtual ~BaseMaterial(); + + // Documentation inherited + public: virtual MaterialPtr Clone(const std::string &_name = "") const + override; + + // Documentation inherited + public: virtual void SetAmbient(const double _r, const double _g, + const double _b, const double _a = 1.0) override; + + // Documentation inherited + public: virtual void SetAmbient(const math::Color &_color) override; + + // Documentation inherited + public: virtual void SetDiffuse(const double _r, const double _g, + const double _b, const double _a = 1.0) override; + + // Documentation inherited + public: virtual void SetDiffuse(const math::Color &_color) override; + + // Documentation inherited + public: virtual void SetSpecular(const double _r, const double _g, + const double _b, const double _a = 1.0) override; + + // Documentation inherited + public: virtual void SetSpecular(const math::Color &_color) override; + + // Documentation inherited + public: virtual void SetEmissive(const double _r, const double _g, + const double _b, const double _a = 1.0) override; + + // Documentation inherited + public: virtual void SetEmissive(const math::Color &_color) override; + + // Documentation inherited + public: virtual void SetTransparency(const double _transparency) override; + + // Documentation inherited + public: virtual void SetAlphaFromTexture(bool _enabled, + double _alpha = 0.5, bool _twoSided = true) override; + + // Documentation inherited + public: bool TextureAlphaEnabled() const override; + + // Documentation inherited + public: double AlphaThreshold() const override; + + // Documentation inherited + public: bool TwoSidedEnabled() const override; + + // Documentation inherited + public: virtual void SetShininess(const double _shininess) override; + + // Documentation inherited + public: virtual void SetReflectivity(const double _reflectivity) override; + + // Documentation inherited + public: virtual void SetCastShadows(const bool _castShadows) override; + + // Documentation inherited + public: virtual void SetReceiveShadows(const bool _receiveShadows) + override; + + // Documentation inherited + public: virtual void SetReflectionEnabled(const bool _enabled) override; + + // Documentation inherited + public: virtual void SetLightingEnabled(const bool _enabled) override; + + // Documentation inherited. + public: virtual void SetDepthCheckEnabled(bool _enabled) override; + + // Documentation inherited. + public: virtual void SetDepthWriteEnabled(bool _enabled) override; + + // Documentation inherited + public: virtual math::Color Ambient() const override; + + // Documentation inherited + public: virtual math::Color Diffuse() const override; + + // Documentation inherited + public: virtual math::Color Specular() const override; + + // Documentation inherited + public: virtual math::Color Emissive() const override; + + // Documentation inherited + public: virtual double Transparency() const override; + + // Documentation inherited + public: virtual double Reflectivity() const override; + + // Documentation inherited + public: virtual double Shininess() const override; + + // Documentation inherited + public: virtual bool CastShadows() const override; + + // Documentation inherited + public: virtual bool ReceiveShadows() const override; + + // Documentation inherited + public: virtual bool LightingEnabled() const override; + + // Documentation inherited + public: virtual bool DepthCheckEnabled() const override; + + // Documentation inherited + public: virtual bool DepthWriteEnabled() const override; + + // Documentation inherited + public: virtual bool ReflectionEnabled() const override; + + // Documentation inherited + public: virtual bool HasTexture() const override; + + // Documentation inherited + public: virtual std::string Texture() const override; + + // Documentation inherited + public: virtual void SetTexture(const std::string &_texture) override; + + // Documentation inherited + public: virtual void ClearTexture() override; + + // Documentation inherited + public: virtual bool HasNormalMap() const override; + + // Documentation inherited + public: virtual std::string NormalMap() const override; + + // Documentation inherited + public: virtual void SetNormalMap(const std::string &_normalMap) + override; + + // Documentation inherited + public: virtual void ClearNormalMap() override; + + // Documentation inherited + public: virtual bool HasRoughnessMap() const override; + + // Documentation inherited + public: virtual std::string RoughnessMap() const override; + + // Documentation inherited + public: virtual void SetRoughnessMap(const std::string &_roughnessMap) + override; + + // Documentation inherited + public: virtual void ClearRoughnessMap() override; + + // Documentation inherited + public: virtual bool HasMetalnessMap() const override; + + // Documentation inherited + public: virtual std::string MetalnessMap() const override; + + // Documentation inherited + public: virtual void SetMetalnessMap(const std::string &_metalnessMap) + override; + + // Documentation inherited + public: virtual void ClearMetalnessMap() override; + + // Documentation inherited + public: virtual bool HasEnvironmentMap() const override; + + // Documentation inherited + public: virtual std::string EnvironmentMap() const override; + + // Documentation inherited + public: virtual void SetEnvironmentMap(const std::string &_metalnessMap) + override; + + // Documentation inherited + public: virtual void ClearEnvironmentMap() override; + + // Documentation inherited + public: virtual bool HasEmissiveMap() const override; + + // Documentation inherited + public: virtual std::string EmissiveMap() const override; + + // Documentation inherited + public: virtual void SetEmissiveMap(const std::string &_emissiveMap) + override; + + // Documentation inherited + public: virtual void ClearEmissiveMap() override; + + // Documentation inherited + public: virtual bool HasLightMap() const override; + + // Documentation inherited + public: virtual std::string LightMap() const override; + + // Documentation inherited + public: virtual unsigned int LightMapTexCoordSet() const override; + + // Documentation inherited + public: virtual void SetLightMap(const std::string &_lightMap, + unsigned int _uvSet = 0u) override; + + // Documentation inherited + public: virtual void ClearLightMap() override; + + // Documentation inherited + public: virtual void SetRenderOrder(const float _renderOrder) override; + + // Documentation inherited + public: virtual float RenderOrder() const override; + + // Documentation inherited + public: virtual void SetRoughness(const float _roughness) override; + + // Documentation inherited + public: virtual float Roughness() const override; + + // Documentation inherited + public: virtual void SetMetalness(const float _metalness) override; + + // Documentation inherited + public: virtual float Metalness() const override; + + // Documentation inherited + public: virtual MaterialType Type() const override; + + public: virtual void SetShaderType(enum ShaderType _type) override + { + (void)_type; + // no op + } + + // Documentation inherited + public: virtual enum ShaderType ShaderType() const override + { + return ST_PIXEL; + } + + // Documentation inherited. + // \sa Material::SetDepthMaterial() + public: virtual void SetDepthMaterial(const double far, + const double near) override; + + // Documentation inherited. + // \sa Material::VertexShader() const + public: virtual std::string VertexShader() const override; + + // Documentation inherited. + // \sa Material::VertexShaderParams() + public: virtual ShaderParamsPtr VertexShaderParams() override; + + // Documentation inherited. + // \sa Material::SetVertexShader(const std::string &) + public: virtual void SetVertexShader(const std::string &_path) override; + + // Documentation inherited. + // \sa Material::FragmentShader() const + public: virtual std::string FragmentShader() const override; + + // Documentation inherited. + // \sa Material::FragmentShaderParams() + public: virtual ShaderParamsPtr FragmentShaderParams() override; + + // Documentation inherited. + // \sa Material::SetFragmentShader(const std::string &) + public: virtual void SetFragmentShader(const std::string &_path) override; + + // Documentation inherited. + public: virtual void CopyFrom(ConstMaterialPtr _material) override; + + // Documentation inherited. + public: virtual void CopyFrom(const common::Material &_material) override; + + // Documentation inherited. + public: virtual void PreRender() override; + + protected: virtual void Reset(); + + /// \brief Ambient color + protected: math::Color ambient; + + /// \brief Diffuse color + protected: math::Color diffuse; + + /// \brief Specular color + protected: math::Color specular; + + /// \brief Emissive color + protected: math::Color emissive; + + /// \brief Transparent. 1: fully transparent, 0: opaque + protected: double transparency = 0.0; + + /// \brief Enable alpha channel based texture transparency + protected: bool textureAlphaEnabled = false; + + /// \brief Threshold for alpha channel rejection + protected: double alphaThreshold = 0.5; + + /// \brief Enable two sided rendering + protected: bool twoSidedEnabled = false; + + /// \brief Material render order + protected: double renderOrder = 0.0; + + /// \brief Shininess factor + protected: double shininess = 0.0; + + /// \brief Reflectivity + protected: double reflectivity = 0.0; + + /// \brief Flag to indicate if dynamic lighting is enabled + protected: bool lightingEnabled = false; + + /// \brief Flag to indicate if depth buffer checking is enabled + protected: bool depthCheckEnabled = true; + + /// \brief Flag to indicate if depth buffer writing is enabled + protected: bool depthWriteEnabled = true; + + /// \brief Flag to indicate if reflection is enabled + protected: bool reflectionEnabled = false; + + /// \brief True if material receives shadows + protected: bool receiveShadows = true; + + /// \brief Set to true to enable object with this material to cast shadows + protected: bool castShadows = true; + }; + + ////////////////////////////////////////////////// + template + BaseMaterial::BaseMaterial() + { + } + + ////////////////////////////////////////////////// + template + BaseMaterial::~BaseMaterial() + { + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetAmbient(const double _r, const double _g, + const double _b, const double _a) + { + this->SetAmbient(math::Color(_r, _g, _b, _a)); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetAmbient(const math::Color &_color) + { + this->ambient = _color; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetDiffuse(const double _r, const double _g, + const double _b, const double _a) + { + this->SetDiffuse(math::Color(_r, _g, _b, _a)); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetDiffuse(const math::Color &_color) + { + this->diffuse = _color; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetSpecular(const double _r, const double _g, + const double _b, const double _a) + { + this->SetSpecular(math::Color(_r, _g, _b, _a)); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetSpecular(const math::Color &_color) + { + this->specular = _color; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetEmissive(const double _r, const double _g, + const double _b, const double _a) + { + this->SetEmissive(math::Color(_r, _g, _b, _a)); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetEmissive(const math::Color &_color) + { + this->emissive = _color; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetShininess(const double _shininess) + { + this->shininess = _shininess; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetTransparency(const double _transparency) + { + this->transparency = _transparency; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetAlphaFromTexture(bool _enabled, double _alpha, + bool _twoSided) + { + this->textureAlphaEnabled = _enabled; + this->alphaThreshold = _alpha; + this->twoSidedEnabled = _twoSided; + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::TextureAlphaEnabled() const + { + return this->textureAlphaEnabled; + } + + ////////////////////////////////////////////////// + template + double BaseMaterial::AlphaThreshold() const + { + return this->alphaThreshold; + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::TwoSidedEnabled() const + { + return this->twoSidedEnabled; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetReflectivity(const double _reflectivity) + { + this->reflectivity = _reflectivity; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetReflectionEnabled(const bool _enabled) + { + this->reflectionEnabled = _enabled; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetLightingEnabled(const bool _enabled) + { + this->lightingEnabled = _enabled; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetDepthCheckEnabled(bool _enabled) + { + this->depthCheckEnabled = _enabled; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetDepthWriteEnabled(bool _enabled) + { + this->depthWriteEnabled = _enabled; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetCastShadows(const bool _castShadows) + { + this->castShadows = _castShadows; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetReceiveShadows(const bool _receive) + { + this->receiveShadows = _receive; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetRenderOrder(const float _renderorder) + { + this->renderOrder = _renderorder; + } + + ////////////////////////////////////////////////// + template + math::Color BaseMaterial::Ambient() const + { + return this->ambient; + } + + ////////////////////////////////////////////////// + template + math::Color BaseMaterial::Diffuse() const + { + return this->diffuse; + } + + ////////////////////////////////////////////////// + template + math::Color BaseMaterial::Specular() const + { + return this->specular; + } + + ////////////////////////////////////////////////// + template + math::Color BaseMaterial::Emissive() const + { + return this->emissive; + } + + ////////////////////////////////////////////////// + template + double BaseMaterial::Shininess() const + { + return this->shininess; + } + + ////////////////////////////////////////////////// + template + double BaseMaterial::Transparency() const + { + return this->transparency; + } + + ////////////////////////////////////////////////// + template + float BaseMaterial::RenderOrder() const + { + return this->renderOrder; + } + + ////////////////////////////////////////////////// + template + double BaseMaterial::Reflectivity() const + { + return this->reflectivity; + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::CastShadows() const + { + return this->castShadows; + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::ReceiveShadows() const + { + return this->receiveShadows; + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::LightingEnabled() const + { + return this->lightingEnabled; + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::DepthCheckEnabled() const + { + return this->depthCheckEnabled; + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::DepthWriteEnabled() const + { + return this->depthWriteEnabled; + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::ReflectionEnabled() const + { + return this->reflectionEnabled; + } + + ////////////////////////////////////////////////// + template + MaterialType BaseMaterial::Type() const + { + return MT_CLASSIC; + } + + ////////////////////////////////////////////////// + template + std::string BaseMaterial::VertexShader() const + { + return std::string(); + } + + ////////////////////////////////////////////////// + template + ShaderParamsPtr BaseMaterial::VertexShaderParams() + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetVertexShader(const std::string &/*_path*/) + { + // no op + } + + ////////////////////////////////////////////////// + template + std::string BaseMaterial::FragmentShader() const + { + return std::string(); + } + + ////////////////////////////////////////////////// + template + ShaderParamsPtr BaseMaterial::FragmentShaderParams() + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetFragmentShader(const std::string &/*_path*/) + { + // no op + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::HasTexture() const + { + return false; + } + + ////////////////////////////////////////////////// + template + std::string BaseMaterial::Texture() const + { + return std::string(); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetTexture(const std::string &) + { + // no op + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::ClearTexture() + { + // no op + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::HasNormalMap() const + { + return false; + } + + ////////////////////////////////////////////////// + template + std::string BaseMaterial::NormalMap() const + { + return std::string(); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetNormalMap(const std::string &) + { + // no op + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::ClearNormalMap() + { + // no op + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::HasRoughnessMap() const + { + return false; + } + + ////////////////////////////////////////////////// + template + std::string BaseMaterial::RoughnessMap() const + { + return std::string(); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetRoughnessMap(const std::string &) + { + // no op + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::ClearRoughnessMap() + { + // no op + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::HasMetalnessMap() const + { + return false; + } + + ////////////////////////////////////////////////// + template + std::string BaseMaterial::MetalnessMap() const + { + return std::string(); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetMetalnessMap(const std::string &) + { + // no op + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::ClearMetalnessMap() + { + // no op + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::HasEnvironmentMap() const + { + return false; + } + + ////////////////////////////////////////////////// + template + std::string BaseMaterial::EnvironmentMap() const + { + return std::string(); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetEnvironmentMap(const std::string &) + { + // no op + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::ClearEnvironmentMap() + { + // no op + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::HasEmissiveMap() const + { + return false; + } + + ////////////////////////////////////////////////// + template + std::string BaseMaterial::EmissiveMap() const + { + return std::string(); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetEmissiveMap(const std::string &) + { + // no op + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::ClearEmissiveMap() + { + // no op + } + + ////////////////////////////////////////////////// + template + bool BaseMaterial::HasLightMap() const + { + return false; + } + + ////////////////////////////////////////////////// + template + std::string BaseMaterial::LightMap() const + { + return std::string(); + } + + ////////////////////////////////////////////////// + template + unsigned int BaseMaterial::LightMapTexCoordSet() const + { + return 0u; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetLightMap(const std::string &, unsigned int) + { + // no op + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::ClearLightMap() + { + // no op + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetRoughness(const float) + { + // no op + } + + ////////////////////////////////////////////////// + template + float BaseMaterial::Roughness() const + { + return 0.0f; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetMetalness(const float) + { + // no op + } + + ////////////////////////////////////////////////// + template + float BaseMaterial::Metalness() const + { + return 0.0f; + } + + ////////////////////////////////////////////////// + template + MaterialPtr BaseMaterial::Clone(const std::string &_name) const + { + auto baseShared = this->shared_from_this(); + + auto thisShared = + std::dynamic_pointer_cast>(baseShared); + + MaterialPtr material = T::Scene()->CreateMaterial(_name); + material->CopyFrom(thisShared); + return material; + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::CopyFrom(ConstMaterialPtr _material) + { + this->SetLightingEnabled(_material->LightingEnabled()); + this->SetAmbient(_material->Ambient()); + this->SetDiffuse(_material->Diffuse()); + this->SetSpecular(_material->Specular()); + this->SetEmissive(_material->Emissive()); + this->SetRenderOrder(_material->RenderOrder()); + this->SetShininess(_material->Shininess()); + this->SetAlphaFromTexture(_material->TextureAlphaEnabled(), + _material->AlphaThreshold(), _material->TwoSidedEnabled()); + // override transparency / blend setting after setting alpha from texture + this->SetTransparency(_material->Transparency()); + // override depth check / depth write after setting transparency + this->SetDepthCheckEnabled(_material->DepthCheckEnabled()); + this->SetDepthWriteEnabled(_material->DepthWriteEnabled()); + this->SetReflectivity(_material->Reflectivity()); + this->SetCastShadows(_material->CastShadows()); + this->SetReceiveShadows(_material->ReceiveShadows()); + this->SetReflectionEnabled(_material->ReflectionEnabled()); + this->SetTexture(_material->Texture()); + this->SetNormalMap(_material->NormalMap()); + this->SetRoughnessMap(_material->RoughnessMap()); + this->SetMetalnessMap(_material->MetalnessMap()); + this->SetRoughness(_material->Roughness()); + this->SetMetalness(_material->Metalness()); + this->SetEnvironmentMap(_material->EnvironmentMap()); + this->SetEmissiveMap(_material->EmissiveMap()); + this->SetLightMap(_material->LightMap(), + _material->LightMapTexCoordSet()); + this->SetShaderType(_material->ShaderType()); + this->SetVertexShader(_material->VertexShader()); + this->SetFragmentShader(_material->FragmentShader()); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::CopyFrom(const common::Material &_material) + { + this->SetLightingEnabled(_material.Lighting()); + this->SetAmbient(_material.Ambient()); + this->SetDiffuse(_material.Diffuse()); + this->SetSpecular(_material.Specular()); + this->SetEmissive(_material.Emissive()); + this->SetShininess(_material.Shininess()); + this->SetTransparency(_material.Transparency()); + this->SetAlphaFromTexture(_material.TextureAlphaEnabled(), + _material.AlphaThreshold(), _material.TwoSidedEnabled()); + this->SetRenderOrder(_material.RenderOrder()); + // TODO(anyone): update common::Material + this->SetReflectivity(0); + this->SetTexture(_material.TextureImage()); + // TODO(anyone): update common::Material + this->SetCastShadows(true); + // TODO(anyone): update common::Material + this->SetReceiveShadows(true); + // TODO(anyone): update common::Material + this->SetReflectionEnabled(true); + // TODO(anyone): update common::Material + this->ClearNormalMap(); + // TODO(anyone): update common::Material + this->SetShaderType(ST_PIXEL); + + const common::Pbr *pbrMat = _material.PbrMaterial(); + if (!pbrMat) + pbrMat = &kDefaultPbr; + this->SetNormalMap(pbrMat->NormalMap()); + this->SetRoughnessMap(pbrMat->RoughnessMap()); + this->SetMetalnessMap(pbrMat->MetalnessMap()); + this->SetRoughness(pbrMat->Roughness()); + this->SetMetalness(pbrMat->Metalness()); + this->SetEnvironmentMap(pbrMat->EnvironmentMap()); + this->SetEmissiveMap(pbrMat->EmissiveMap()); + this->SetLightMap(pbrMat->LightMap(), pbrMat->LightMapTexCoordSet()); + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::PreRender() + { + // do nothing + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::SetDepthMaterial(const double /*far*/, + const double /*near*/) + { + // do nothing + } + + ////////////////////////////////////////////////// + template + void BaseMaterial::Reset() + { + this->SetLightingEnabled(true); + this->SetDepthCheckEnabled(true); + this->SetDepthWriteEnabled(true); + this->SetAmbient(0.3, 0.3, 0.3); + this->SetDiffuse(1.0, 1.0, 1.0); + this->SetSpecular(0.2, 0.2, 0.2); + this->SetEmissive(0, 0, 0); + this->SetRenderOrder(0); + this->SetShininess(1.5); + this->SetTransparency(0); + this->SetReflectivity(0); + this->SetCastShadows(true); + this->SetReceiveShadows(true); + this->SetReflectionEnabled(true); + this->ClearTexture(); + this->ClearNormalMap(); + this->ClearRoughnessMap(); + this->ClearMetalnessMap(); + this->ClearEmissiveMap(); + this->ClearLightMap(); + this->SetRoughness(kDefaultPbr.Roughness()); + this->SetMetalness(kDefaultPbr.Metalness()); + this->SetShaderType(ST_PIXEL); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseMesh.hh b/include/gz/rendering/base/BaseMesh.hh new file mode 100644 index 000000000..010d7c35c --- /dev/null +++ b/include/gz/rendering/base/BaseMesh.hh @@ -0,0 +1,466 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEMESH_HH_ +#define GZ_RENDERING_BASE_BASEMESH_HH_ + +#include +#include +#include +#include "gz/rendering/Mesh.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/Storage.hh" +#include "gz/rendering/base/BaseObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + ////////////////////////////////////////////////// + template + class BaseMesh : + public virtual Mesh, + public virtual T + { + protected: BaseMesh(); + + public: virtual ~BaseMesh(); + + // Documentation inherited. + public: virtual bool HasSkeleton() const override; + + // Documentation inherited. + public: virtual std::map + SkeletonLocalTransforms() const override; + + // Documentation inherited. + public: virtual void SetSkeletonLocalTransforms( + const std::map &_tfs) + override; + + // Documentation inherited. + public: virtual std::unordered_map SkeletonWeights() + const override; + + // Documentation inherited. + public: virtual void SetSkeletonWeights( + const std::unordered_map &_weights) + override; + + // Documentation inherited. + public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, + bool _enabled, bool _loop = true, float _weight = 1.0) override; + + // Documentation inherited. + public: virtual bool SkeletonAnimationEnabled(const std::string &_name) + const override; + + // Documentation inherited. + public: virtual void UpdateSkeletonAnimation( + std::chrono::steady_clock::duration _time) override; + + public: virtual unsigned int SubMeshCount() const override; + + public: virtual bool HasSubMesh(ConstSubMeshPtr _subMesh) const override; + + public: virtual bool HasSubMeshName(const std::string &_name) const + override; + + public: virtual SubMeshPtr SubMeshByName( + const std::string &_name) const override; + + public: virtual SubMeshPtr SubMeshByIndex(unsigned int _index) const + override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial(const std::string &_name, + bool _unique = true) override; + + // Documentation inherited. + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true) override; + + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual GeometryPtr Clone() const override; + + // Documentation inherited. + public: void SetDescriptor(const MeshDescriptor &_desc) override; + + // Documentation inherited. + public: const MeshDescriptor &Descriptor() const override; + + // Documentation inherited + public: virtual void Destroy() override; + + protected: virtual SubMeshStorePtr SubMeshes() const = 0; + + /// \brief Flag to indicate whether or not this mesh should be + /// responsible for destroying the material + protected: bool ownsMaterial = false; + + /// \brief Pointer to currently assigned material + protected: MaterialPtr material; + + /// \brief MeshDescriptor for this mesh + protected: MeshDescriptor meshDescriptor; + }; + + ////////////////////////////////////////////////// + template + class BaseSubMesh : + public virtual SubMesh, + public virtual T + { + protected: BaseSubMesh(); + + public: virtual ~BaseSubMesh(); + + // Documentation inherited + public: virtual MaterialPtr Material() const override; + + // Documentation inherited + public: virtual void SetMaterial(const std::string &_name, + bool _unique = true) override; + + // Documentation inherited + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true) override; + + /// \brief Engine implementation for setting the material of this SubMesh. + /// \param[in] _material New Material to be assigned + public: virtual void SetMaterialImpl(MaterialPtr _material) = 0; + + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Flag to indicate whether or not this submesh should be + /// responsible for destroying the material + protected: bool ownsMaterial = false; + + /// \brief Pointer to currently assigned material + protected: MaterialPtr material; + }; + + ////////////////////////////////////////////////// + // BaseMesh + ////////////////////////////////////////////////// + template + BaseMesh::BaseMesh() + { + } + + ////////////////////////////////////////////////// + template + BaseMesh::~BaseMesh() + { + } + + ////////////////////////////////////////////////// + template + bool BaseMesh::HasSkeleton() const + { + return false; + } + + ////////////////////////////////////////////////// + template + std::map + BaseMesh::SkeletonLocalTransforms() const + { + std::map tmpMap; + return tmpMap; + } + + ////////////////////////////////////////////////// + template + void BaseMesh::SetSkeletonLocalTransforms( + const std::map &) + { + } + + ////////////////////////////////////////////////// + template + std::unordered_map BaseMesh::SkeletonWeights() const + { + std::unordered_map tmpMap; + return tmpMap; + } + + ////////////////////////////////////////////////// + template + void BaseMesh::SetSkeletonWeights( + const std::unordered_map &) + { + ignerr << "SetSkeletonWeights not supported for render engine: " + << this->Scene()->Engine()->Name() << std::endl; + } + + ////////////////////////////////////////////////// + template + void BaseMesh::SetSkeletonAnimationEnabled(const std::string &, bool, + bool, float) + { + } + + ////////////////////////////////////////////////// + template + bool BaseMesh::SkeletonAnimationEnabled(const std::string &) const + { + return false; + } + + ////////////////////////////////////////////////// + template + void BaseMesh::UpdateSkeletonAnimation( + std::chrono::steady_clock::duration) + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseMesh::SubMeshCount() const + { + return this->SubMeshes()->Size(); + } + + ////////////////////////////////////////////////// + template + bool BaseMesh::HasSubMesh(ConstSubMeshPtr _subMesh) const + { + return this->SubMeshes()->Contains(_subMesh); + } + + ////////////////////////////////////////////////// + template + bool BaseMesh::HasSubMeshName(const std::string &_name) const + { + return this->SubMeshes()->ContainsName(_name); + } + + ////////////////////////////////////////////////// + template + SubMeshPtr BaseMesh::SubMeshByName(const std::string &_name) const + { + return this->SubMeshes()->GetByName(_name); + } + + ////////////////////////////////////////////////// + template + SubMeshPtr BaseMesh::SubMeshByIndex(unsigned int _index) const + { + return this->SubMeshes()->GetByIndex(_index); + } + + ////////////////////////////////////////////////// + template + MaterialPtr BaseMesh::Material() const + { + unsigned int count = this->SubMeshCount(); + return (count > 0) ? this->SubMeshByIndex(0)->Material() : + MaterialPtr(); + } + + ////////////////////////////////////////////////// + template + void BaseMesh::SetMaterial(const std::string &_name, bool _unique) + { + MaterialPtr mat = this->Scene()->Material(_name); + if (mat) this->SetMaterial(mat, _unique); + } + + ////////////////////////////////////////////////// + template + void BaseMesh::SetMaterial(MaterialPtr _material, bool _unique) + { + // todo(anyone) take ownership of reference _material if _unique + // and destroy the reference material when the mesh is destroyed + unsigned int count = this->SubMeshCount(); + _material = (_unique && count > 0) ? _material->Clone() : _material; + + for (unsigned int i = 0; i < count; ++i) + { + SubMeshPtr subMesh = this->SubMeshByIndex(i); + subMesh->SetMaterial(_material, false); + } + + if (this->material && this->ownsMaterial) + this->Scene()->DestroyMaterial(this->material); + + this->ownsMaterial = _unique; + this->material = _material; + } + + ////////////////////////////////////////////////// + template + void BaseMesh::PreRender() + { + unsigned int count = this->SubMeshCount(); + + for (unsigned int i = 0; i < count; ++i) + { + SubMeshPtr subMesh = this->SubMeshByIndex(i); + subMesh->PreRender(); + } + + T::PreRender(); + } + + ////////////////////////////////////////////////// + template + GeometryPtr BaseMesh::Clone() const + { + if (!this->Scene()) + { + ignerr << "Cloning a mesh failed because the mesh to be " + << "cloned does not belong to a scene.\n"; + return nullptr; + } + else if (this->meshDescriptor.meshName.empty()) + { + ignerr << "Cloning a geometry failed because the name of the mesh is " + << "missing.\n"; + return nullptr; + } + + auto result = this->Scene()->CreateMesh(this->meshDescriptor); + if (result) + { + if (this->Material()) + { + // this call will set the material for the mesh and its submeshes + result->SetMaterial(this->Material()); + } + else + { + // if the mesh doesn't have a material, clone any existing submesh + // materials + for (unsigned int i = 0; i < this->SubMeshCount(); ++i) + { + auto existingSubMeshMaterial = this->SubMeshByIndex(i)->Material(); + if (existingSubMeshMaterial) + result->SubMeshByIndex(i)->SetMaterial(existingSubMeshMaterial); + } + } + } + + return result; + } + + ////////////////////////////////////////////////// + template + const MeshDescriptor &BaseMesh::Descriptor() const + { + return this->meshDescriptor; + } + + ////////////////////////////////////////////////// + template + void BaseMesh::SetDescriptor(const MeshDescriptor &_desc) + { + this->meshDescriptor = _desc; + } + + ////////////////////////////////////////////////// + template + void BaseMesh::Destroy() + { + T::Destroy(); + this->SubMeshes()->DestroyAll(); + if (this->material && this->ownsMaterial) + this->Scene()->DestroyMaterial(this->material); + this->material.reset(); + this->meshDescriptor = MeshDescriptor(); + } + + ////////////////////////////////////////////////// + // BaseSubMesh + ////////////////////////////////////////////////// + template + BaseSubMesh::BaseSubMesh() + { + } + + ////////////////////////////////////////////////// + template + BaseSubMesh::~BaseSubMesh() + { + } + + ////////////////////////////////////////////////// + template + void BaseSubMesh::Destroy() + { + T::Destroy(); + if (this->material && this->ownsMaterial) + this->Scene()->DestroyMaterial(this->material); + this->material.reset(); + } + + + ////////////////////////////////////////////////// + template + void BaseSubMesh::SetMaterial(const std::string &_name, bool _unique) + { + MaterialPtr mat = this->Scene()->Material(_name); + if (mat) this->SetMaterial(mat, _unique); + } + + ////////////////////////////////////////////////// + template + void BaseSubMesh::SetMaterial(MaterialPtr _material, bool _unique) + { + _material = (_unique) ? _material->Clone() : _material; + + MaterialPtr origMaterial = this->material; + bool origUnique = this->ownsMaterial; + + this->SetMaterialImpl(_material); + + if (origMaterial && origUnique) + this->Scene()->DestroyMaterial(origMaterial); + + this->material = _material; + this->ownsMaterial = _unique; + } + + ////////////////////////////////////////////////// + template + MaterialPtr BaseSubMesh::Material() const + { + return this->material; + } + + ////////////////////////////////////////////////// + template + void BaseSubMesh::PreRender() + { + T::PreRender(); + if (this->Material()) + this->Material()->PreRender(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseNode.hh b/include/gz/rendering/base/BaseNode.hh new file mode 100644 index 000000000..d7fa194a3 --- /dev/null +++ b/include/gz/rendering/base/BaseNode.hh @@ -0,0 +1,717 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASENODE_HH_ +#define GZ_RENDERING_BASE_BASENODE_HH_ + +#include +#include + +#include "gz/rendering/Node.hh" +#include "gz/rendering/Storage.hh" +#include "gz/rendering/base/BaseStorage.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseNode : + public virtual Node, + public virtual T + { + protected: BaseNode(); + + public: virtual ~BaseNode(); + + public: virtual NodePtr Parent() const override = 0; + + // Documentation inherited + public: virtual void RemoveParent() override; + + public: virtual math::Vector3d LocalPosition() const override; + + public: virtual math::Pose3d LocalPose() const override; + + // Documentation inherited + public: virtual math::Pose3d InitialLocalPose() const override; + + public: virtual void SetLocalPose(const math::Pose3d &_pose) override; + + public: virtual void SetLocalPosition(double _x, double _y, double _z) + override; + + public: virtual void SetLocalPosition(const math::Vector3d &_position) + override; + + public: virtual math::Quaterniond LocalRotation() const override; + + public: virtual void SetLocalRotation(double _r, double _p, double _y) + override; + + public: virtual void SetLocalRotation(double _w, double _x, double _y, + double _z) override; + + public: virtual void SetLocalRotation(const math::Quaterniond &_rotation) + override; + + public: virtual math::Pose3d WorldPose() const override; + + public: virtual void SetWorldPose(const math::Pose3d &_pose) override; + + public: virtual math::Vector3d WorldPosition() const override; + + public: virtual void SetWorldPosition(double _x, double _y, double _z) + override; + + public: virtual void SetWorldPosition(const math::Vector3d &_position) + override; + + public: virtual math::Quaterniond WorldRotation() const override; + + public: virtual void SetWorldRotation(double _r, double _p, double _y) + override; + + public: virtual void SetWorldRotation(double _w, double _x, double _y, + double _z) override; + + public: virtual void SetWorldRotation(const math::Quaterniond &_rotation) + override; + + public: virtual math::Pose3d WorldToLocal(const math::Pose3d &_pose) + const override; + + public: virtual math::Vector3d Origin() const override; + + public: virtual void SetOrigin(double _x, double _y, double _z) override; + + public: virtual void SetOrigin(const math::Vector3d &_origin) override; + + // Documentation inherited + public: virtual math::Vector3d LocalScale() const override = 0; + + // Documentation inherited + public: virtual void SetLocalScale(double _scale) override; + + // Documentation inherited + public: virtual void SetLocalScale(double _x, double _y, double _z) + override; + + // Documentation inherited + public: virtual void SetLocalScale(const math::Vector3d &_scale) override; + + // Documentation inherited + public: virtual math::Vector3d WorldScale() const override; + + // Documentation inherited + public: virtual void SetWorldScale(double _scale) override; + + // Documentation inherited + public: virtual void SetWorldScale(double _x, double _y, double _z) + override; + + // Documentation inherited + public: virtual void SetWorldScale(const math::Vector3d &_scale) override; + + // Documentation inherited + public: virtual void Scale(double _scale) override; + + // Documentation inherited + public: virtual void Scale(double _x, double _y, double _z) override; + + // Documentation inherited + public: virtual void Scale(const math::Vector3d &_scale) override; + + // Documentation inherited + public: virtual bool InheritScale() const override = 0; + + public: virtual void Destroy() override; + + public: virtual unsigned int ChildCount() const override; + + public: virtual bool HasChild(ConstNodePtr _child) const override; + + public: virtual bool HasChildId(unsigned int _id) const override; + + public: virtual bool HasChildName(const std::string &_name) const + override; + + public: virtual NodePtr ChildById(unsigned int _id) const override; + + public: virtual NodePtr ChildByName(const std::string &_name) const + override; + + public: virtual NodePtr ChildByIndex(unsigned int _index) const override; + + public: virtual void AddChild(NodePtr _child) override; + + public: virtual NodePtr RemoveChild(NodePtr _child) override; + + public: virtual NodePtr RemoveChildById(unsigned int _id) override; + + public: virtual NodePtr RemoveChildByName(const std::string &_name) + override; + + public: virtual NodePtr RemoveChildByIndex(unsigned int _index) override; + + public: virtual void RemoveChildren() override; + + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void SetUserData(const std::string &_key, Variant _value) + override; + + // Documentation inherited + public: virtual Variant UserData(const std::string &_key) const override; + + // Documentation inherited + public: virtual bool HasUserData(const std::string &_key) const override; + + protected: virtual void PreRenderChildren(); + + protected: virtual math::Pose3d RawLocalPose() const = 0; + + protected: virtual void SetRawLocalPose(const math::Pose3d &_pose) = 0; + + protected: virtual NodeStorePtr Children() const = 0; + + protected: virtual bool AttachChild(NodePtr _child) = 0; + + protected: virtual bool DetachChild(NodePtr _child) = 0; + + /// \brief Implementation of the SetLocalScale function + /// \param[in] _scale Scale to set the visual to + protected: virtual void SetLocalScaleImpl( + const math::Vector3d &_scale) = 0; + + protected: math::Vector3d origin; + + /// \brief Flag to indicate whether initial local pose + /// is set for this node. + protected: bool initialLocalPoseSet = false; + + /// \brief Initial local pose for this node. + protected: ignition::math::Pose3d initialLocalPose = + ignition::math::Pose3d::Zero; + + /// \brief A map of custom key value data + protected: std::map userData; + }; + + ////////////////////////////////////////////////// + template + BaseNode::BaseNode() + { + } + + ////////////////////////////////////////////////// + template + BaseNode::~BaseNode() + { + } + + ////////////////////////////////////////////////// + template + void BaseNode::RemoveParent() + { + NodePtr parent = this->Parent(); + + if (parent) + { + auto baseShared = this->shared_from_this(); + auto thisShared = std::dynamic_pointer_cast>(baseShared); + parent->RemoveChild(thisShared); + } + } + + + ////////////////////////////////////////////////// + template + void BaseNode::AddChild(NodePtr _child) + { + if (_child->Id() == this->Id()) + { + ignerr << "Cannot add self as a child node" << std::endl; + return; + } + + if (this->AttachChild(_child)) + { + this->Children()->Add(_child); + } + } + + ////////////////////////////////////////////////// + template + NodePtr BaseNode::RemoveChild(NodePtr _child) + { + NodePtr child = this->Children()->Remove(_child); + if (child) this->DetachChild(child); + return child; + } + + ////////////////////////////////////////////////// + template + NodePtr BaseNode::RemoveChildById(unsigned int _id) + { + NodePtr child = this->Children()->RemoveById(_id); + if (child) this->DetachChild(child); + return child; + } + + ////////////////////////////////////////////////// + template + NodePtr BaseNode::RemoveChildByName(const std::string &_name) + { + NodePtr child = this->Children()->RemoveByName(_name); + if (child) this->DetachChild(child); + return child; + } + + ////////////////////////////////////////////////// + template + NodePtr BaseNode::RemoveChildByIndex(unsigned int _index) + { + NodePtr child = this->Children()->RemoveByIndex(_index); + if (child) this->DetachChild(child); + return child; + } + + ////////////////////////////////////////////////// + template + void BaseNode::RemoveChildren() + { + for (unsigned int i = this->ChildCount(); i > 0; --i) + { + this->RemoveChildByIndex(i - 1); + } + } + + ////////////////////////////////////////////////// + template + void BaseNode::PreRender() + { + this->PreRenderChildren(); + } + + ////////////////////////////////////////////////// + template + void BaseNode::PreRenderChildren() + { + unsigned int count = this->ChildCount(); + + for (unsigned int i = 0; i < count; ++i) + { + this->ChildByIndex(i)->PreRender(); + } + } + + ////////////////////////////////////////////////// + template + math::Pose3d BaseNode::LocalPose() const + { + math::Pose3d pose = this->RawLocalPose(); + pose.Pos() += pose.Rot() * this->origin; + return pose; + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetLocalPose(const math::Pose3d &_pose) + { + if (!_pose.IsFinite()) + { + ignerr << "Unable to set non-finite pose [" << _pose + << "] to node [" << this->Name() << "]" << std::endl; + return; + } + + math::Pose3d pose = _pose; + pose.Pos() = pose.Pos() - pose.Rot() * this->origin; + + if (!initialLocalPoseSet) + { + this->initialLocalPose = pose; + this->initialLocalPoseSet = true; + } + + this->SetRawLocalPose(pose); + } + + ////////////////////////////////////////////////// + template + math::Pose3d BaseNode::InitialLocalPose() const + { + return this->initialLocalPose; + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseNode::LocalPosition() const + { + return this->LocalPose().Pos(); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetLocalPosition(double _x, double _y, double _z) + { + this->SetLocalPosition(math::Vector3d(_x, _y, _z)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetLocalPosition(const math::Vector3d &_position) + { + if (!_position.IsFinite()) + { + ignerr << "Unable to set non-finite position [" << _position + << "] to node [" << this->Name() << "]" << std::endl; + return; + } + + math::Pose3d pose = this->LocalPose(); + pose.Pos() = _position; + this->SetLocalPose(pose); + } + + ////////////////////////////////////////////////// + template + math::Quaterniond BaseNode::LocalRotation() const + { + return this->LocalPose().Rot(); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetLocalRotation(double _r, double _p, double _y) + { + this->SetLocalRotation(math::Quaterniond(_r, _p, _y)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetLocalRotation(double _w, double _x, double _y, + double _z) + { + this->SetLocalRotation(math::Quaterniond(_w, _x, _y, _z)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetLocalRotation(const math::Quaterniond &_rotation) + { + if (!_rotation.IsFinite()) + { + ignerr << "Unable to set non-finite rotation [" << _rotation + << "] to node [" << this->Name() << "]" << std::endl; + return; + } + + math::Pose3d pose = this->LocalPose(); + pose.Rot() = _rotation; + this->SetLocalPose(pose); + } + + ////////////////////////////////////////////////// + template + math::Pose3d BaseNode::WorldPose() const + { + NodePtr parent = this->Parent(); + math::Pose3d pose = this->LocalPose(); + + if (!parent) + { + return pose; + } + + return parent->WorldPose() * pose; + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetWorldPose(const math::Pose3d &_pose) + { + math::Pose3d pose = this->WorldToLocal(_pose); + this->SetLocalPose(pose); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetWorldPosition(double _x, double _y, double _z) + { + this->SetWorldPosition(math::Vector3d(_x, _y, _z)); + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseNode::WorldPosition() const + { + return this->WorldPose().Pos(); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetWorldPosition(const math::Vector3d &_position) + { + math::Pose3d pose = this->WorldPose(); + pose.Pos() = _position; + this->SetWorldPose(pose); + } + + ////////////////////////////////////////////////// + template + math::Quaterniond BaseNode::WorldRotation() const + { + return this->WorldPose().Rot(); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetWorldRotation(double _r, double _p, double _y) + { + this->SetWorldRotation(math::Quaterniond(_r, _p, _y)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetWorldRotation(double _w, double _x, double _y, + double _z) + { + this->SetWorldRotation(math::Quaterniond(_w, _x, _y, _z)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetWorldRotation(const math::Quaterniond &_rotation) + { + math::Pose3d pose = this->WorldPose(); + pose.Rot() = _rotation; + this->SetWorldPose(pose); + } + + ////////////////////////////////////////////////// + template + math::Pose3d BaseNode::WorldToLocal(const math::Pose3d &_pose) const + { + NodePtr parent = this->Parent(); + + if (!parent) + { + return _pose; + } + + return _pose - parent->WorldPose(); + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseNode::Origin() const + { + return this->origin; + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetOrigin(double _x, double _y, double _z) + { + this->SetOrigin(math::Vector3d(_x, _y, _z)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetOrigin(const math::Vector3d &_origin) + { + if (!_origin.IsFinite()) + { + ignerr << "Unable to set non-finite origin [" << _origin + << "] to node [" << this->Name() << "]" << std::endl; + return; + } + this->origin = _origin; + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetLocalScale(double _scale) + { + this->SetLocalScale(math::Vector3d(_scale, _scale, _scale)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetLocalScale(double _x, double _y, double _z) + { + this->SetLocalScale(math::Vector3d(_x, _y, _z)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetLocalScale(const math::Vector3d &_scale) + { + math::Pose3d rawPose = this->LocalPose(); + this->SetLocalScaleImpl(_scale); + this->SetLocalPose(rawPose); + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseNode::WorldScale() const + { + math::Vector3d scale = this->LocalScale(); + + if (!this->InheritScale() || !this->HasParent()) + { + return scale; + } + + return scale * this->Parent()->WorldScale(); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetWorldScale(double _scale) + { + this->SetWorldScale(math::Vector3d(_scale, _scale, _scale)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetWorldScale(double _x, double _y, double _z) + { + this->SetWorldScale(math::Vector3d(_x, _y, _z)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetWorldScale(const math::Vector3d &_scale) + { + math::Vector3d toScale = math::Vector3d::One; + if (this->InheritScale() && this->HasParent()) + toScale = this->Parent()->WorldScale(); + + this->SetLocalScale(_scale / toScale); + } + + ////////////////////////////////////////////////// + template + void BaseNode::Scale(double _scale) + { + this->Scale(math::Vector3d(_scale, _scale, _scale)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::Scale(double _x, double _y, double _z) + { + this->Scale(math::Vector3d(_x, _y, _z)); + } + + ////////////////////////////////////////////////// + template + void BaseNode::Scale(const math::Vector3d &_scale) + { + this->SetLocalScale(_scale * this->LocalScale()); + } + + ////////////////////////////////////////////////// + template + void BaseNode::Destroy() + { + T::Destroy(); + this->RemoveParent(); + } + + ////////////////////////////////////////////////// + template + unsigned int BaseNode::ChildCount() const + { + return this->Children()->Size(); + } + + ////////////////////////////////////////////////// + template + bool BaseNode::HasChild(ConstNodePtr _child) const + { + return this->Children()->Contains(_child); + } + + ////////////////////////////////////////////////// + template + bool BaseNode::HasChildId(unsigned int _id) const + { + return this->Children()->ContainsId(_id); + } + + ////////////////////////////////////////////////// + template + bool BaseNode::HasChildName(const std::string &_name) const + { + return this->Children()->ContainsName(_name); + } + + ////////////////////////////////////////////////// + template + NodePtr BaseNode::ChildById(unsigned int _id) const + { + return this->Children()->GetById(_id); + } + + ////////////////////////////////////////////////// + template + NodePtr BaseNode::ChildByName(const std::string &_name) const + { + return this->Children()->GetByName(_name); + } + + ////////////////////////////////////////////////// + template + NodePtr BaseNode::ChildByIndex(unsigned int _index) const + { + return this->Children()->GetByIndex(_index); + } + } + + ////////////////////////////////////////////////// + template + void BaseNode::SetUserData(const std::string &_key, Variant _value) + { + this->userData[_key] = _value; + } + + ////////////////////////////////////////////////// + template + Variant BaseNode::UserData(const std::string &_key) const + { + Variant value; + auto it = this->userData.find(_key); + if (it != this->userData.end()) + value = it->second; + return value; + } + + ////////////////////////////////////////////////// + template + bool BaseNode::HasUserData(const std::string &_key) const + { + return this->userData.find(_key) != this->userData.end(); + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseObject.hh b/include/gz/rendering/base/BaseObject.hh new file mode 100644 index 000000000..65f61c9d5 --- /dev/null +++ b/include/gz/rendering/base/BaseObject.hh @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEOBJECT_HH_ +#define GZ_RENDERING_BASE_BASEOBJECT_HH_ + +#include +#include +#include +#include "gz/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_VISIBLE BaseObject : + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public virtual std::enable_shared_from_this, + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + public virtual Object + { + protected: BaseObject(); + + public: virtual ~BaseObject(); + + public: virtual unsigned int Id() const override; + + public: virtual std::string Name() const override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void PostRender() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // TODO(anyone): make pure virtual + protected: virtual void Load(); + + // TODO(anyone): make pure virtual + protected: virtual void Init(); + + protected: unsigned int id; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: std::string name; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseParticleEmitter.hh b/include/gz/rendering/base/BaseParticleEmitter.hh new file mode 100644 index 000000000..c02395d53 --- /dev/null +++ b/include/gz/rendering/base/BaseParticleEmitter.hh @@ -0,0 +1,441 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef IGNITION_RENDERING_BASE_BASEPARTICLEEMITTER_HH_ +#define IGNITION_RENDERING_BASE_BASEPARTICLEEMITTER_HH_ + +#include +#include "ignition/rendering/base/BaseScene.hh" +#include "ignition/rendering/base/BaseNode.hh" +#include "ignition/rendering/ParticleEmitter.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class BaseParticleEmitter BaseParticleEmitter.hh \ + * ignition/rendering/base/BaseParticleEmitter.hh + */ + /// \brief A base implementation of the ParticleEmitter class + template + class BaseParticleEmitter : + public virtual ParticleEmitter, + public virtual T + { + /// \brief Constructor + protected: BaseParticleEmitter(); + + /// \brief Destructor + public: virtual ~BaseParticleEmitter(); + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void PreRender() override; + + /// \brief Reset the particle emitter visual state + public: virtual void Reset(); + + // Documentation inherited. + public: virtual EmitterType Type() const override; + + // Documentation inherited. + public: virtual void SetType(const EmitterType _type) override; + + // Documentation inherited. + public: virtual ignition::math::Vector3d EmitterSize() const override; + + // Documentation inherited. + public: virtual void SetEmitterSize( + const ignition::math::Vector3d &_size) override; + + // Documentation inherited. + public: virtual double Rate() const override; + + // Documentation inherited. + public: virtual void SetRate(double _rate) override; + + // Documentation inherited. + public: virtual double Duration() const override; + + // Documentation inherited. + public: virtual void SetDuration(double _duration) override; + + // Documentation inherited. + public: virtual bool Emitting() const override; + + // Documentation inherited. + public: virtual void SetEmitting(bool _enable) override; + + // Documentation inherited. + public: virtual ignition::math::Vector3d ParticleSize() const override; + + // Documentation inherited. + public: virtual void SetParticleSize( + const ignition::math::Vector3d &_size) override; + + // Documentation inherited. + public: virtual double Lifetime() const override; + + // Documentation inherited. + public: virtual void SetLifetime(double _lifetime) override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial(const MaterialPtr &_material) override; + + // Documentation inherited. + public: virtual double MinVelocity() const override; + + // Documentation inherited. + public: virtual double MaxVelocity() const override; + + // Documentation inherited. + public: virtual void SetVelocityRange(double _minVelocity, + double _maxVelocity) override; + + // Documentation inherited. + public: virtual ignition::math::Color ColorStart() const override; + + // Documentation inherited. + public: virtual ignition::math::Color ColorEnd() const override; + + // Documentation inherited. + public: virtual void SetColorRange( + const ignition::math::Color &_colorStart, + const ignition::math::Color &_colorEnd) override; + + // Documentation inherited. + public: virtual double ScaleRate() const override; + + // Documentation inherited. + public: virtual void SetScaleRate(double _scaleRate) override; + + // Documentation inherited. + public: virtual std::string ColorRangeImage() const override; + + // Documentation inherited. + public: virtual void SetColorRangeImage( + const std::string &_image) override; + + // Documentation inherited. + public: virtual float ParticleScatterRatio() const override; + + // Documentation inherited. + public: virtual void SetParticleScatterRatio(float _ratio) override; + + /// \brief Emitter type. + protected: EmitterType type = EM_POINT; + + /// \brief Emitter size. + protected: ignition::math::Vector3d emitterSize = + ignition::math::Vector3d::One; + + /// \brief Rate of emission. + protected: double rate = 10; + + /// \brief Duration of the emitter. + protected: double duration = 0; + + /// \brief Whether particle emitter is enabled or not. + protected: bool emitting = false; + + /// \brief Particle size. + protected: ignition::math::Vector3d particleSize = {1, 1, 1}; + + /// \brief Particle lifetime. + protected: double lifetime = 5; + + /// \brief Particle material. + protected: MaterialPtr material = nullptr; + + /// \brief The minimum velocity of each particle. + protected: double minVelocity = 1; + + /// \brief The maximum velocity of each particle. + protected: double maxVelocity = 1; + + /// \brief The start color of a particle to choose from. + protected: ignition::math::Color colorStart = + ignition::math::Color::White; + + /// \brief The end color of a particle to choose from. + protected: ignition::math::Color colorEnd = + ignition::math::Color::White; + + /// \brief The scale rate. + protected: double scaleRate = 1; + + /// \brief The color image. + protected: std::string colorRangeImage = ""; + + /// \brief The particle scatter ratio. This is used to determine the ratio + /// of particles that will be detected by sensors. Increasing the ratio + /// increases the scatter of the particles, which means there is a higher + /// chance of particles reflecting and interfering with depth sensing, + /// making the emitter appear more dense. Decreasing the ratio decreases + /// the scatter of the particles, making it appear less dense. This value + /// should be > 0. + protected: float particleScatterRatio = 0.65f; + + /// \brief Only the scene can create a particle emitter + private: friend class BaseScene; + }; + + ////////////////////////////////////////////////// + template + BaseParticleEmitter::BaseParticleEmitter() + { + } + + ////////////////////////////////////////////////// + template + BaseParticleEmitter::~BaseParticleEmitter() + { + } + + ////////////////////////////////////////////////// + template + void BaseParticleEmitter::Init() + { + T::Init(); + } + + ////////////////////////////////////////////////// + template + void BaseParticleEmitter::Reset() + { + } + + ////////////////////////////////////////////////// + template + void BaseParticleEmitter::PreRender() + { + } + + ////////////////////////////////////////////////// + template + EmitterType BaseParticleEmitter::Type() const + { + return this->type; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetType(const EmitterType _type) + { + this->type = _type; + } + + ////////////////////////////////////////////////// + template + ignition::math::Vector3d BaseParticleEmitter::EmitterSize() const + { + return this->emitterSize; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetEmitterSize( + const ignition::math::Vector3d &_size) + { + this->emitterSize = _size; + } + + ////////////////////////////////////////////////// + template + double BaseParticleEmitter::Rate() const + { + return this->rate; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetRate(double _rate) + { + this->rate = _rate; + } + + ////////////////////////////////////////////////// + template + double BaseParticleEmitter::Duration() const + { + return this->duration; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetDuration(double _duration) + { + this->duration = _duration; + } + + ////////////////////////////////////////////////// + template + bool BaseParticleEmitter::Emitting() const + { + return this->emitting; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetEmitting(bool _enable) + { + this->emitting = _enable; + } + + ////////////////////////////////////////////////// + template + ignition::math::Vector3d BaseParticleEmitter::ParticleSize() const + { + return this->particleSize; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetParticleSize( + const ignition::math::Vector3d &_size) + { + this->particleSize = _size; + } + + ////////////////////////////////////////////////// + template + double BaseParticleEmitter::Lifetime() const + { + return this->lifetime; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetLifetime(double _lifetime) + { + this->lifetime = _lifetime; + } + + ////////////////////////////////////////////////// + template + MaterialPtr BaseParticleEmitter::Material() const + { + return this->material; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetMaterial(const MaterialPtr &_material) + { + this->material = _material; + } + + ////////////////////////////////////////////////// + template + double BaseParticleEmitter::MinVelocity() const + { + return this->minVelocity; + } + + ////////////////////////////////////////////////// + template + double BaseParticleEmitter::MaxVelocity() const + { + return this->maxVelocity; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetVelocityRange(double _minVelocity, + double _maxVelocity) + { + this->minVelocity = _minVelocity; + this->maxVelocity = _maxVelocity; + } + + ////////////////////////////////////////////////// + template + ignition::math::Color BaseParticleEmitter::ColorStart() const + { + return this->colorStart; + } + + ////////////////////////////////////////////////// + template + ignition::math::Color BaseParticleEmitter::ColorEnd() const + { + return this->colorEnd; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetColorRange( + const ignition::math::Color &_colorStart, + const ignition::math::Color &_colorEnd) + { + this->colorStart = _colorStart; + this->colorEnd = _colorEnd; + } + + ///////////////////////////////////////////////// + template + double BaseParticleEmitter::ScaleRate() const + { + return this->scaleRate; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetScaleRate(double _scaleRate) + { + this->scaleRate = _scaleRate; + } + + ///////////////////////////////////////////////// + template + std::string BaseParticleEmitter::ColorRangeImage() const + { + return this->colorRangeImage; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetColorRangeImage(const std::string &_image) + { + this->colorRangeImage = _image; + } + + ///////////////////////////////////////////////// + template + float BaseParticleEmitter::ParticleScatterRatio() const + { + return this->particleScatterRatio; + } + + ///////////////////////////////////////////////// + template + void BaseParticleEmitter::SetParticleScatterRatio(float _ratio) + { + if (_ratio > 0.0f) + this->particleScatterRatio = _ratio; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseRayQuery.hh b/include/gz/rendering/base/BaseRayQuery.hh new file mode 100644 index 000000000..7648b8d48 --- /dev/null +++ b/include/gz/rendering/base/BaseRayQuery.hh @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASERAYQUERY_HH_ +#define GZ_RENDERING_BASE_BASERAYQUERY_HH_ + +#include +#include + +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class BaseRayQuery BaseRayQuery.hh + /// ignition/rendering/base/BaseRayQuery.hh + /// \brief A Ray Query class used for computing ray object intersections + template + class BaseRayQuery : + public virtual RayQuery, + public T + { + /// \brief Constructor + protected: BaseRayQuery(); + + /// \brief Destructor + public: virtual ~BaseRayQuery() override; + + // Documentation inherited + public: virtual void SetOrigin(const math::Vector3d &_origin) override; + + // Documentation inherited + public: virtual math::Vector3d Origin() const override; + + // Documentation inherited + public: virtual void SetDirection(const math::Vector3d &_dir) override; + + // Documentation inherited + public: virtual math::Vector3d Direction() const override; + + // Documentation inherited + public: virtual void SetFromCamera(const CameraPtr &_camera, + const math::Vector2d &_coord) override; + + // Documentation inherited + public: virtual RayQueryResult ClosestPoint() override; + + /// \brief Ray origin + protected: math::Vector3d origin; + + /// \brief Ray direction + protected: math::Vector3d direction; + }; + + ////////////////////////////////////////////////// + template + BaseRayQuery::BaseRayQuery() + { + } + + ////////////////////////////////////////////////// + template + BaseRayQuery::~BaseRayQuery() + { + } + + ////////////////////////////////////////////////// + template + void BaseRayQuery::SetOrigin(const math::Vector3d &_origin) + { + this->origin = _origin; + } + + ////////////////////////////////////////////////// + template + gz::math::Vector3d BaseRayQuery::Origin() const + { + return this->origin; + } + + ////////////////////////////////////////////////// + template + void BaseRayQuery::SetDirection(const math::Vector3d &_dir) + { + this->direction = _dir; + } + + ////////////////////////////////////////////////// + template + gz::math::Vector3d BaseRayQuery::Direction() const + { + return this->direction; + } + + ////////////////////////////////////////////////// + template + void BaseRayQuery::SetFromCamera(const CameraPtr &_camera, + const gz::math::Vector2d &_coord) + { + math::Matrix4d projectionMatrix = _camera->ProjectionMatrix(); + math::Matrix4d viewMatrix = _camera->ViewMatrix(); + math::Vector3d start(_coord.X(), _coord.Y(), -1.0); + math::Vector3d end(_coord.X(), _coord.Y(), 0.0); + math::Matrix4d viewProjInv = (projectionMatrix * viewMatrix).Inverse(); + + // rotate start and end + // ign math does not support matrix4 * vec4 + // so calc homogeneous coordinate w ourselves + double startw = viewProjInv(3, 0) * start[0] + + viewProjInv(3, 1) * start[1] + + viewProjInv(3, 2) * start[2] + viewProjInv(3, 3); + double endw = viewProjInv(3, 0) * end[0] + + viewProjInv(3, 1) * end[1] + + viewProjInv(3, 2) * end[2] + viewProjInv(3, 3); + start = viewProjInv * start; + end = viewProjInv * end; + // normalize + start = start / startw; + end = end / endw; + math::Vector3d dir = (end - start).Normalize(); + + this->origin = start; + this->direction = dir; + } + + ////////////////////////////////////////////////// + template + RayQueryResult BaseRayQuery::ClosestPoint() + { + // TODO(anyone): implement a generic ray query here? + RayQueryResult result; + result.distance = -1; + return result; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseRenderEngine.hh b/include/gz/rendering/base/BaseRenderEngine.hh new file mode 100644 index 000000000..4ad308622 --- /dev/null +++ b/include/gz/rendering/base/BaseRenderEngine.hh @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASERENDERENGINE_HH_ +#define GZ_RENDERING_BASE_BASERENDERENGINE_HH_ + +#include +#include +#include +#include +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/Storage.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_VISIBLE BaseRenderEngine : + public virtual RenderEngine + { + protected: BaseRenderEngine(); + + public: virtual ~BaseRenderEngine(); + + // Documentation Inherited. + public: virtual bool Load( + const std::map &_params = {}) override; + + public: virtual bool Init() override; + + public: virtual bool Fini() override; + + public: virtual bool IsLoaded() const override; + + public: virtual bool IsInitialized() const override; + + public: virtual bool IsEnabled() const override; + + public: virtual unsigned int SceneCount() const override; + + public: virtual bool HasScene(ConstScenePtr _scene) const override; + + public: virtual bool HasSceneId(unsigned int _id) const override; + + public: virtual bool HasSceneName(const std::string &_name) const + override; + + public: virtual ScenePtr SceneById(unsigned int _id) const override; + + public: virtual ScenePtr SceneByName(const std::string &_name) const + override; + + public: virtual ScenePtr SceneByIndex(unsigned int _index) const override; + + public: virtual void DestroyScene(ScenePtr _scene) override; + + public: virtual void DestroySceneById(unsigned int _id) override; + + public: virtual void DestroySceneByName(const std::string &_name) + override; + + public: virtual void DestroySceneByIndex(unsigned int _index) override; + + public: virtual void DestroyScenes() override; + + public: virtual ScenePtr CreateScene(const std::string &_name) override; + + public: virtual ScenePtr CreateScene(unsigned int _id, + const std::string &_name) override; + + public: virtual void Destroy() override; + + // Documentation Inherited + public: virtual void AddResourcePath(const std::string &_path) override; + + // Documentation Inherited + public: virtual void SetHeadless(bool _headless) override; + + // Documentation Inherited + public: virtual bool Headless() const override; + + // Documentation Inherited + public: virtual RenderPassSystemPtr RenderPassSystem() const override; + + protected: virtual void PrepareScene(ScenePtr _scene); + + protected: virtual unsigned int NextSceneId(); + + /// \brief Engine implementation of Load function. + /// \param[in] _params Parameters to be passed to the render engine. + protected: virtual bool LoadImpl( + const std::map &_params) = 0; + + protected: virtual bool InitImpl() = 0; + + protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual SceneStorePtr Scenes() const = 0; + + protected: bool loaded = false; + + protected: bool initialized = false; + + protected: bool isHeadless = false; + + /// \brief ID from a external window + protected: std::string winID = ""; + + protected: unsigned int nextSceneId; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief a list of paths that render engines use to locate their + /// resources + protected: std::vector resourcePaths; + + /// \brief Render pass system for this render engine. + protected: RenderPassSystemPtr renderPassSystem; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseRenderPass.hh b/include/gz/rendering/base/BaseRenderPass.hh new file mode 100644 index 000000000..d380f67e1 --- /dev/null +++ b/include/gz/rendering/base/BaseRenderPass.hh @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASERENDERPASS_HH_ +#define GZ_RENDERING_BASE_BASERENDERPASS_HH_ + +#include +#include "gz/rendering/RenderPass.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class BaseRenderPass BaseRenderPass.hh \ + * ignition/rendering/base/BaseRenderPass.hh + */ + /// \brief Base render pass that can be applied to a render target + template + class BaseRenderPass: + public virtual RenderPass, + public T + { + /// \brief Constructor + protected: BaseRenderPass(); + + /// \brief Destructor + public: virtual ~BaseRenderPass(); + + // Documentation inherited + public: virtual void SetEnabled(bool _enabled) override; + + // Documentation inherited + public: virtual bool IsEnabled() const override; + + /// \brief Flag to indicate if render pass is enabled or not + protected: bool enabled = true; + }; + + ////////////////////////////////////////////////// + // BaseRenderPass + ////////////////////////////////////////////////// + template + BaseRenderPass::BaseRenderPass() + { + } + + ////////////////////////////////////////////////// + template + BaseRenderPass::~BaseRenderPass() + { + } + + ////////////////////////////////////////////////// + template + void BaseRenderPass::SetEnabled(bool _enabled) + { + this->enabled = _enabled; + } + + ////////////////////////////////////////////////// + template + bool BaseRenderPass::IsEnabled() const + { + return this->enabled; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseRenderTarget.hh b/include/gz/rendering/base/BaseRenderTarget.hh new file mode 100644 index 000000000..adaf34869 --- /dev/null +++ b/include/gz/rendering/base/BaseRenderTarget.hh @@ -0,0 +1,357 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASERENDERTARGET_HH_ +#define GZ_RENDERING_BASE_BASERENDERTARGET_HH_ + +#include +#include + +#include "gz/rendering/RenderPass.hh" +#include "gz/rendering/RenderTarget.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseRenderTarget : + public virtual RenderTarget, + public virtual T + { + public: BaseRenderTarget(); + + public: virtual ~BaseRenderTarget(); + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void PostRender() override; + + public: virtual unsigned int Width() const override; + + public: virtual void SetWidth(const unsigned int _width) override; + + public: virtual unsigned int Height() const override; + + public: virtual void SetHeight(const unsigned int _height) override; + + public: virtual PixelFormat Format() const override; + + public: virtual void SetFormat(PixelFormat _format) override; + + // Documentation inherited + public: virtual math::Color BackgroundColor() const override; + + // Documentation inherited + public: virtual void AddRenderPass(const RenderPassPtr &_pass) override; + + // Documentation inherited + public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) + override; + + // Documentation inherited + public: virtual unsigned int RenderPassCount() const override; + + // Documentation inherited + public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) + const override; + + protected: virtual void Rebuild(); + + protected: virtual void RebuildImpl() = 0; + + protected: PixelFormat format = PF_UNKNOWN; + + protected: bool targetDirty = true; + + /// \brief Flag to indicate if render pass need to be rebuilt + protected: bool renderPassDirty = false; + + protected: unsigned int width = 0u; + + protected: unsigned int height = 0u; + + /// \brief A chain of render passes applied to the render target + protected: std::vector renderPasses; + }; + + template + class BaseRenderTexture : + public virtual RenderTexture, + public virtual T + { + public: BaseRenderTexture(); + + public: virtual ~BaseRenderTexture(); + + // Documentation inherited. + public: virtual unsigned int GLId() const override; + }; + + template + class BaseRenderWindow : + public virtual RenderWindow, + public virtual T + { + public: BaseRenderWindow(); + + public: virtual ~BaseRenderWindow(); + + public: virtual std::string Handle() const; + + public: virtual void SetHandle(const std::string &_handle); + + public: virtual double DevicePixelRatio() const; + + public: virtual void SetDevicePixelRatio(const double _ratio); + + public: virtual void OnResize(const unsigned int _width, + const unsigned int _height); + + public: virtual void OnMove(); + + protected: std::string handle; + + protected: double ratio = 1.0; + }; + + ////////////////////////////////////////////////// + // BaseRenderTarget + ////////////////////////////////////////////////// + template + BaseRenderTarget::BaseRenderTarget() + { + } + + ////////////////////////////////////////////////// + template + BaseRenderTarget::~BaseRenderTarget() + { + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::PreRender() + { + T::PreRender(); + this->Rebuild(); + for (auto &pass : this->renderPasses) + pass->PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::PostRender() + { + T::PostRender(); + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::Rebuild() + { + if (this->targetDirty) + { + this->RebuildImpl(); + this->targetDirty = false; + } + } + + ////////////////////////////////////////////////// + template + unsigned int BaseRenderTarget::Width() const + { + return this->width; + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::SetWidth(const unsigned int _width) + { + this->width = _width; + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + unsigned int BaseRenderTarget::Height() const + { + return this->height; + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::SetHeight(const unsigned int _height) + { + this->height = _height; + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + PixelFormat BaseRenderTarget::Format() const + { + return this->format; + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::SetFormat(PixelFormat _format) + { + this->format = PixelUtil::Sanitize(_format); + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + math::Color BaseRenderTarget::BackgroundColor() const + { + return this->Scene()->BackgroundColor(); + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::AddRenderPass(const RenderPassPtr &_pass) + { + this->renderPasses.push_back(_pass); + this->renderPassDirty = true; + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::RemoveRenderPass(const RenderPassPtr &_pass) + { + auto it = std::find(this->renderPasses.begin(), this->renderPasses.end(), + _pass); + if (it != this->renderPasses.end()) + { + (*it)->Destroy(); + this->renderPasses.erase(it); + this->renderPassDirty = true; + } + } + + ////////////////////////////////////////////////// + template + unsigned int BaseRenderTarget::RenderPassCount() const + { + return this->renderPasses.size(); + } + + ////////////////////////////////////////////////// + template + RenderPassPtr BaseRenderTarget::RenderPassByIndex(unsigned int _index) + const + { + if (_index > this->renderPasses.size()) + { + ignerr << "RenderPass index out of range: " << _index << std::endl; + return RenderPassPtr(); + } + return this->renderPasses[_index]; + } + + ////////////////////////////////////////////////// + // BaseRenderTexture + ////////////////////////////////////////////////// + template + BaseRenderTexture::BaseRenderTexture() + { + } + + ////////////////////////////////////////////////// + template + BaseRenderTexture::~BaseRenderTexture() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseRenderTexture::GLId() const + { + return 0u; + } + + ////////////////////////////////////////////////// + // BaseRenderWindow + ////////////////////////////////////////////////// + template + BaseRenderWindow::BaseRenderWindow() + { + } + + ////////////////////////////////////////////////// + template + BaseRenderWindow::~BaseRenderWindow() + { + } + + ////////////////////////////////////////////////// + template + std::string BaseRenderWindow::Handle() const + { + return this->handle; + } + + ////////////////////////////////////////////////// + template + void BaseRenderWindow::SetHandle(const std::string &_handle) + { + this->handle = _handle; + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + double BaseRenderWindow::DevicePixelRatio() const + { + return this->ratio; + } + + ////////////////////////////////////////////////// + template + void BaseRenderWindow::SetDevicePixelRatio(const double _ratio) + { + this->ratio = _ratio; + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + void BaseRenderWindow::OnResize(const unsigned int _width, + const unsigned int _height) + { + this->width = _width; + this->height = _height; + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + void BaseRenderWindow::OnMove() + { + this->targetDirty = true; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseRenderTypes.hh b/include/gz/rendering/base/BaseRenderTypes.hh new file mode 100644 index 000000000..bda3c2506 --- /dev/null +++ b/include/gz/rendering/base/BaseRenderTypes.hh @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASERENDERTYPES_HH_ +#define GZ_RENDERING_BASE_BASERENDERTYPES_HH_ + +#include + +#include "gz/rendering/RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class BaseNodeCompositeStore; + typedef shared_ptr BaseNodeCompositeStorePtr; + + class BaseObject; + typedef std::shared_ptr BaseObjectPtr; + + template class BaseSceneStore; + template class BaseNodeStore; + template class BaseLightStore; + template class BaseSensorStore; + template class BaseVisualStore; + template class BaseGeometryStore; + template class BaseSubMeshStore; + template class BaseMaterialMap; + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseScene.hh b/include/gz/rendering/base/BaseScene.hh new file mode 100644 index 000000000..a620960b6 --- /dev/null +++ b/include/gz/rendering/base/BaseScene.hh @@ -0,0 +1,866 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASESCENE_HH_ +#define GZ_RENDERING_BASE_BASESCENE_HH_ + +#include +#include +#include + +#include +#include + +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_VISIBLE BaseScene : + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public std::enable_shared_from_this, + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + public virtual Scene + { + protected: BaseScene(unsigned int _id, const std::string &_name); + + public: virtual ~BaseScene(); + + public: virtual void Load() override; + + public: virtual void Init() override; + + public: virtual void Fini() override; + + public: virtual bool IsLoaded() const; + + public: virtual bool IsInitialized() const override; + + public: virtual unsigned int Id() const override; + + public: virtual std::string Name() const override; + + public: virtual void IGN_DEPRECATED(4) + SetSimTime(const common::Time &_time) override; + + public: virtual common::Time IGN_DEPRECATED(4) SimTime() const override; + + public: virtual std::chrono::steady_clock::duration Time() + const override; + + public: virtual void SetTime( + const std::chrono::steady_clock::duration &_time) override; + + public: virtual void SetAmbientLight(double _r, double _g, double _b, + double _a = 1.0) override; + + public: virtual void SetAmbientLight(const math::Color &_color) + override = 0; + + public: virtual math::Color BackgroundColor() const override; + + public: virtual void SetBackgroundColor(double _r, double _g, double _b, + double _a = 1.0) override; + + public: virtual void SetBackgroundColor(const math::Color &_color) + override; + + // Documentation inherited. + public: virtual bool IsGradientBackgroundColor() const override; + + // Documentation inherited. + public: virtual std::array GradientBackgroundColor() + const override; + + // Documentation inherited. + public: virtual void SetGradientBackgroundColor( + const std::array &_colors) override; + + // Documentation inherited. + public: virtual void RemoveGradientBackgroundColor() override; + + // Documentation inherited. + public: virtual MaterialPtr BackgroundMaterial() const override; + + // Documentation inherited. + public: virtual void SetBackgroundMaterial(MaterialPtr _material) + override; + + public: virtual unsigned int NodeCount() const override; + + public: virtual bool HasNode(ConstNodePtr _node) const override; + + public: virtual bool HasNodeId(unsigned int _id) const override; + + public: virtual bool HasNodeName(const std::string &_name) const override; + + public: virtual NodePtr NodeById(unsigned int _id) const override; + + public: virtual NodePtr NodeByName(const std::string &_name) const + override; + + public: virtual NodePtr NodeByIndex(unsigned int _index) const override; + + // Documentation inherited. + public: virtual void DestroyNode(NodePtr _node, bool _recursive = false) + override; + + public: virtual void DestroyNodeById(unsigned int _id) override; + + public: virtual void DestroyNodeByName(const std::string &_name) override; + + public: virtual void DestroyNodeByIndex(unsigned int _index) override; + + public: virtual void DestroyNodes() override; + + public: virtual unsigned int LightCount() const override; + + public: virtual bool HasLight(ConstLightPtr _light) const override; + + public: virtual bool HasLightId(unsigned int _id) const override; + + public: virtual bool HasLightName(const std::string &_name) const + override; + + public: virtual LightPtr LightById(unsigned int _id) const override; + + public: virtual LightPtr LightByName(const std::string &_name) const + override; + + public: virtual LightPtr LightByIndex(unsigned int _index) const override; + + // Documentation inherited. + public: virtual void DestroyLight(LightPtr _light, + bool _recursive = false) override; + + public: virtual void DestroyLightById(unsigned int _id) override; + + public: virtual void DestroyLightByName(const std::string &_name) + override; + + public: virtual void DestroyLightByIndex(unsigned int _index) override; + + public: virtual void DestroyLights() override; + + public: virtual unsigned int SensorCount() const override; + + public: virtual bool HasSensor(ConstSensorPtr _sensor) const override; + + public: virtual bool HasSensorId(unsigned int _id) const override; + + public: virtual bool HasSensorName(const std::string &_name) const + override; + + public: virtual SensorPtr SensorById(unsigned int _id) const override; + + public: virtual SensorPtr SensorByName(const std::string &_name) const + override; + + public: virtual SensorPtr SensorByIndex(unsigned int _index) const + override; + + // Documentation inherited. + public: virtual void DestroySensor(SensorPtr _sensor, + bool _recursive = false) override; + + public: virtual void DestroySensorById(unsigned int _id) override; + + public: virtual void DestroySensorByName(const std::string &_name) + override; + + public: virtual void DestroySensorByIndex(unsigned int _index) override; + + public: virtual void DestroySensors() override; + + public: virtual unsigned int VisualCount() const override; + + public: virtual bool HasVisual(ConstVisualPtr _visual) const override; + + public: virtual bool HasVisualId(unsigned int _id) const override; + + public: virtual bool HasVisualName(const std::string &_name) const + override; + + public: virtual VisualPtr VisualById(unsigned int _id) const override; + + public: virtual VisualPtr VisualByName(const std::string &_name) const + override; + + public: virtual VisualPtr VisualByIndex(unsigned int _index) const + override; + + // Documentation inherited + public: virtual VisualPtr VisualAt(const CameraPtr &_camera, + const gz::math::Vector2i &_mousePos) override; + + // Documentation inherited. + public: virtual void DestroyVisual(VisualPtr _visual, + bool _recursive = false) override; + + public: virtual void DestroyVisualById(unsigned int _id) override; + + public: virtual void DestroyVisualByName(const std::string &_name) + override; + + public: virtual void DestroyVisualByIndex(unsigned int _index) override; + + public: virtual void DestroyVisuals() override; + + public: virtual bool MaterialRegistered(const std::string &_name) const + override; + + public: virtual MaterialPtr Material(const std::string &_name) const + override; + + public: virtual void RegisterMaterial(const std::string &_name, + MaterialPtr _material) override; + + public: virtual void UnregisterMaterial(const std::string &_name) + override; + + public: virtual void UnregisterMaterials() override; + + // Documentation inherited + public: virtual void DestroyMaterial(MaterialPtr _material) override; + + // Documentation inherited + public: virtual void DestroyMaterials() override; + + public: virtual DirectionalLightPtr CreateDirectionalLight() override; + + public: virtual DirectionalLightPtr CreateDirectionalLight( + unsigned int _id) override; + + public: virtual DirectionalLightPtr CreateDirectionalLight( + const std::string &_name) override; + + public: virtual DirectionalLightPtr CreateDirectionalLight( + unsigned int _id, const std::string &_name) override; + + public: virtual PointLightPtr CreatePointLight() override; + + public: virtual PointLightPtr CreatePointLight(unsigned int _id) override; + + public: virtual PointLightPtr CreatePointLight(const std::string &_name) + override; + + public: virtual PointLightPtr CreatePointLight(unsigned int _id, + const std::string &_name) override; + + /// \brief Implementation for creating CoM visual. + /// \param[in] _id Unique id + /// \param[in] _name Name of CoM visual + /// \return Pointer to a CoM visual object + protected: virtual COMVisualPtr CreateCOMVisualImpl(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Implementation for creating Inertia visual. + /// \param[in] _id Unique id + /// \param[in] _name Name of inertia visual + /// \return Pointer to a inertia visual object + protected: virtual InertiaVisualPtr CreateInertiaVisualImpl( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Implementation for creating Joint visual. + /// \param[in] _id Unique id + /// \param[in] _name Name of Joint visual + /// \return Pointer to a joint visual object + protected: virtual JointVisualPtr CreateJointVisualImpl(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Implementation for creating Light visual. + /// \param[in] _id Unique id + /// \param[in] _name Name of light visual + /// \return Pointer to a light visual object + protected: virtual LightVisualPtr CreateLightVisualImpl(unsigned int _id, + const std::string &_name) = 0; + + public: virtual SpotLightPtr CreateSpotLight() override; + + public: virtual SpotLightPtr CreateSpotLight(unsigned int _id) override; + + public: virtual SpotLightPtr CreateSpotLight(const std::string &_name) + override; + + public: virtual SpotLightPtr CreateSpotLight(unsigned int _id, + const std::string &_name) override; + + public: virtual CameraPtr CreateCamera() override; + + public: virtual CameraPtr CreateCamera(unsigned int _id) override; + + public: virtual CameraPtr CreateCamera(const std::string &_name) override; + + public: virtual CameraPtr CreateCamera(unsigned int _id, + const std::string &_name) override; + + public: virtual DepthCameraPtr CreateDepthCamera() override; + + public: virtual DepthCameraPtr CreateDepthCamera(const unsigned int _id) + override; + + public: virtual DepthCameraPtr CreateDepthCamera( + const std::string &_name) override; + + public: virtual DepthCameraPtr CreateDepthCamera(const unsigned int _id, + const std::string &_name) override; + + // Documentation inherited. + public: virtual ThermalCameraPtr CreateThermalCamera() override; + + // Documentation inherited. + public: virtual ThermalCameraPtr CreateThermalCamera( + const unsigned int _id) override; + + // Documentation inherited. + public: virtual ThermalCameraPtr CreateThermalCamera( + const std::string &_name) override; + + // Documentation inherited. + public: virtual ThermalCameraPtr CreateThermalCamera( + const unsigned int _id, const std::string &_name) override; + + // Documentation inherited. + public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera() override; + + // Documentation inherited. + public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( + const unsigned int _id) override; + + // Documentation inherited. + public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( + const std::string &_name) override; + + // Documentation inherited. + public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( + const unsigned int _id, const std::string &_name) override; + + // Documentation inherited. + public: virtual SegmentationCameraPtr CreateSegmentationCamera() override; + + // Documentation inherited. + public: virtual SegmentationCameraPtr CreateSegmentationCamera( + const unsigned int _id) override; + + // Documentation inherited. + public: virtual SegmentationCameraPtr CreateSegmentationCamera( + const std::string &_name) override; + + // Documentation inherited. + public: virtual SegmentationCameraPtr CreateSegmentationCamera( + const unsigned int _id, const std::string &_name) override; + + // Documentation inherited. + public: virtual GpuRaysPtr CreateGpuRays() override; + + // Documentation inherited. + public: virtual GpuRaysPtr CreateGpuRays(const unsigned int _id) override; + + // Documentation inherited. + public: virtual GpuRaysPtr CreateGpuRays( + const std::string &_name) override; + + // Documentation inherited. + public: virtual GpuRaysPtr CreateGpuRays(const unsigned int _id, + const std::string &_name) override; + + public: virtual VisualPtr CreateVisual() override; + + public: virtual VisualPtr CreateVisual(unsigned int _id) override; + + public: virtual VisualPtr CreateVisual(const std::string &_name) override; + + public: virtual VisualPtr CreateVisual(unsigned int _id, + const std::string &_name) override; + + public: virtual ArrowVisualPtr CreateArrowVisual() override; + + public: virtual ArrowVisualPtr CreateArrowVisual(unsigned int _id) + override; + + public: virtual ArrowVisualPtr CreateArrowVisual( + const std::string &_name) override; + + public: virtual ArrowVisualPtr CreateArrowVisual(unsigned int _id, + const std::string &_name) override; + + public: virtual AxisVisualPtr CreateAxisVisual() override; + + public: virtual AxisVisualPtr CreateAxisVisual(unsigned int _id) override; + + public: virtual AxisVisualPtr CreateAxisVisual(const std::string &_name) + override; + + public: virtual AxisVisualPtr CreateAxisVisual(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + public: virtual COMVisualPtr CreateCOMVisual() override; + + // Documentation inherited + public: virtual COMVisualPtr CreateCOMVisual(unsigned int _id) + override; + + // Documentation inherited + public: virtual COMVisualPtr CreateCOMVisual(const std::string &_name) + override; + + // Documentation inherited + public: virtual COMVisualPtr CreateCOMVisual(unsigned int _id, + const std::string &_name) override; + + public: virtual InertiaVisualPtr CreateInertiaVisual() override; + + // Documentation inherited + public: virtual InertiaVisualPtr CreateInertiaVisual(unsigned int _id) + override; + + // Documentation inherited + public: virtual InertiaVisualPtr CreateInertiaVisual( + const std::string &_name) override; + + // Documentation inherited + public: virtual InertiaVisualPtr CreateInertiaVisual(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + public: virtual JointVisualPtr CreateJointVisual() override; + + // Documentation inherited + public: virtual JointVisualPtr CreateJointVisual(unsigned int _id) + override; + + // Documentation inherited + public: virtual JointVisualPtr CreateJointVisual( + const std::string &_name) override; + + // Documentation inherited + public: virtual JointVisualPtr CreateJointVisual(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + public: virtual LightVisualPtr CreateLightVisual() override; + + // Documentation inherited + public: virtual LightVisualPtr CreateLightVisual(unsigned int _id) + override; + + // Documentation inherited + public: virtual LightVisualPtr CreateLightVisual(const std::string &_name) + override; + + // Documentation inherited + public: virtual LightVisualPtr CreateLightVisual(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + public: virtual GizmoVisualPtr CreateGizmoVisual() override; + + // Documentation inherited + public: virtual GizmoVisualPtr CreateGizmoVisual(unsigned int _id) + override; + + // Documentation inherited + public: virtual GizmoVisualPtr CreateGizmoVisual(const std::string &_name) + override; + + // Documentation inherited + public: virtual GizmoVisualPtr CreateGizmoVisual(unsigned int _id, + const std::string &_name) override; + + + public: virtual GeometryPtr CreateBox() override; + + public: virtual GeometryPtr CreateCone() override; + + public: virtual GeometryPtr CreateCylinder() override; + + public: virtual GeometryPtr CreatePlane() override; + + public: virtual GeometryPtr CreateSphere() override; + + public: virtual MeshPtr CreateMesh(const std::string &_meshName) override; + + public: virtual MeshPtr CreateMesh(const common::Mesh *_mesh) override; + + public: virtual MeshPtr CreateMesh(const MeshDescriptor &_desc) override; + + // Documentation inherited. + public: virtual CapsulePtr CreateCapsule() override; + + // Documentation inherited. + public: virtual GridPtr CreateGrid() override; + + // Documentation inherited. + public: virtual MarkerPtr CreateMarker() override; + + // Documentation inherited. + public: virtual LidarVisualPtr CreateLidarVisual() override; + + // Documentation inherited. + public: virtual LidarVisualPtr CreateLidarVisual( + unsigned int _id) override; + + // Documentation inherited. + public: virtual LidarVisualPtr CreateLidarVisual( + const std::string &_name) override; + + // Documentation inherited. + public: virtual LidarVisualPtr CreateLidarVisual(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited. + public: virtual HeightmapPtr CreateHeightmap( + const HeightmapDescriptor &_desc) override; + + // Documentation inherited. + public: virtual WireBoxPtr CreateWireBox() override; + + // Documentation inherited. + public: virtual TextPtr CreateText() override; + + public: virtual MaterialPtr CreateMaterial(const std::string &_name = "") + override; + + public: virtual MaterialPtr CreateMaterial( + const common::Material &_material) override; + + public: virtual RenderTexturePtr CreateRenderTexture() override; + + // Documentation inherited. + public: virtual RenderWindowPtr CreateRenderWindow() override; + + public: virtual RayQueryPtr CreateRayQuery() override; + + // Documentation inherited. + public: virtual ParticleEmitterPtr CreateParticleEmitter() override; + + // Documentation inherited. + public: virtual ParticleEmitterPtr CreateParticleEmitter(unsigned int _id) + override; + + // Documentation inherited. + public: virtual ParticleEmitterPtr CreateParticleEmitter( + const std::string &_name) override; + + // Documentation inherited. + public: virtual ParticleEmitterPtr CreateParticleEmitter( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited. + public: virtual void SetSkyEnabled(bool _enabled) override; + + // Documentation inherited. + public: virtual bool SkyEnabled() const override; + + public: virtual void PreRender() override; + + public: virtual void Clear() override; + + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual void PostRender() override; + + // Documentation inherited. + public: virtual void SetCameraPassCountPerGpuFlush( + uint8_t _numPass) override; + + // Documentation inherited. + public: virtual uint8_t CameraPassCountPerGpuFlush() const override; + + // Documentation inherited. + public: virtual bool LegacyAutoGpuFlush() const override; + + protected: virtual unsigned int CreateObjectId(); + + protected: virtual std::string CreateObjectName(unsigned int _id, + const std::string &_prefix); + + protected: virtual bool RegisterLight(LightPtr _light); + + protected: virtual bool RegisterSensor(SensorPtr _vensor); + + protected: virtual bool RegisterVisual(VisualPtr _visual); + + protected: virtual DirectionalLightPtr CreateDirectionalLightImpl( + unsigned int _id, const std::string &_name) = 0; + + protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual CameraPtr CreateCameraImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Implementation for creating a thermal camera. + /// \param[in] _id Unique id + /// \param[in] _name Name of thermal camera + protected: virtual ThermalCameraPtr CreateThermalCameraImpl( + unsigned int _id, const std::string &_name) + { + // The following two lines will avoid doxygen warnings + (void)_id; + (void)_name; + ignerr << "Thermal camera not supported by: " + << this->Engine()->Name() << std::endl; + return ThermalCameraPtr(); + } + + /// \brief Implementation for creating a BoundingBox camera. + /// \param[in] _id Unique id + /// \param[in] _name Name of BoundingBox camera + /// \return Pointer to BoundingBox camera + protected: virtual BoundingBoxCameraPtr CreateBoundingBoxCameraImpl( + unsigned int _id, const std::string &_name) + { + // The following two lines will avoid doxygen warnings + (void)_id; + (void)_name; + ignerr << "BoundingBox camera not supported by: " + << this->Engine()->Name() << std::endl; + return BoundingBoxCameraPtr(); + } + + /// \brief Implementation for creating a segmentation camera. + /// \param[in] _id Unique id + /// \param[in] _name Name of segmentation camera + /// \return Pointer to segmentation camera + protected: virtual SegmentationCameraPtr CreateSegmentationCameraImpl( + unsigned int _id, + const std::string &_name) + { + // The following two lines will avoid doxygen warnings + (void)_id; + (void)_name; + ignerr << "Segmentation camera not supported by: " + << this->Engine()->Name() << std::endl; + return SegmentationCameraPtr(); + } + + /// \brief Implementation for creating GpuRays sensor. + /// \param[in] _id Unique id + /// \param[in] _name Name of GpuRays sensor + protected: virtual GpuRaysPtr CreateGpuRaysImpl(unsigned int _id, + const std::string & _name) + { + (void)_id; + (void)_name; + ignerr << "GpuRays not supported by: " + << this->Engine()->Name() << std::endl; + return GpuRaysPtr(); + } + + protected: virtual VisualPtr CreateVisualImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Implementation for creating a GizmoVisual. + /// \param[in] _id Unique id + /// \param[in] _name Name of GizmoVisual + protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id, + const std::string &_name) + { + (void)_id; + (void)_name; + ignerr << "GizmoVisual not supported by: " + << this->Engine()->Name() << std::endl; + return GizmoVisualPtr(); + } + + protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual GeometryPtr CreateConeImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, + const std::string &_name, + const MeshDescriptor &_desc) = 0; + + /// \brief Implementation for creating a capsule geometry object + /// \param[in] _id unique object id. + /// \param[in] _name unique object name. + /// \return Pointer to a capsule geometry object + protected: virtual CapsulePtr CreateCapsuleImpl(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Implementation for creating a grid geometry object + /// \param[in] _id unique object id. + /// \param[in] _name unique object name. + /// \return Pointer to a grid geometry object + protected: virtual GridPtr CreateGridImpl(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Implementation for creating a marker geometry object + /// \param[in] _id unique object id. + /// \param[in] _name unique object name. + /// \return Pointer to a marker geometry object + protected: virtual MarkerPtr CreateMarkerImpl(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Implementation for creating a lidar visual + /// \param[in] _id unique object id. + /// \param[in] _name unique object name. + /// \return Pointer to a lidar visual + protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Implementation for creating a heightmap geometry + /// \param[in] _id Unique object id. + /// \param[in] _name Unique object name. + /// \param[in] _desc Heightmap descriptor. + /// \return Pointer to a heightmap geometry. + protected: virtual HeightmapPtr CreateHeightmapImpl(unsigned int _id, + const std::string &_name, + const HeightmapDescriptor &_desc) = 0; + + /// \brief Implementation for creating a wire box geometry + /// \param[in] _id unique object id. + /// \param[in] _name unique object name. + /// \return Pointer to a wire box geometry object + protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Implementation for creating a text's geometry object + /// \param[in] _id unique object id. + /// \param[in] _name unique object name. + /// \return Pointer to a text geometry object + protected: virtual TextPtr CreateTextImpl(unsigned int _id, + const std::string &_name); + + protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id, + const std::string &_name) = 0; + + protected: virtual RenderTexturePtr CreateRenderTextureImpl( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Render engine specific implementation for creating a render + /// window + /// \param[in] _id unique object id + /// \param[in] _name object name + /// \return Pointer to the created render window. + protected: virtual RenderWindowPtr CreateRenderWindowImpl( + unsigned int _id, const std::string &_name) = 0; + + protected: virtual RayQueryPtr CreateRayQueryImpl( + unsigned int _id, const std::string &_name) = 0; + + /// \brief Implementation for creating a ParticleEmitter. + /// \param[in] _id Unique id. + /// \param[in] _name Name of ParticleEmitter. + /// \return Pointer to the created particle emitter. + protected: virtual ParticleEmitterPtr CreateParticleEmitterImpl( + unsigned int _id, const std::string &_name) + { + (void)_id; + (void)_name; + ignerr << "ParticleEmitter not supported by: " + << this->Engine()->Name() << std::endl; + return ParticleEmitterPtr(); + } + + protected: virtual LightStorePtr Lights() const = 0; + + protected: virtual SensorStorePtr Sensors() const = 0; + + protected: virtual VisualStorePtr Visuals() const = 0; + + protected: virtual MaterialMapPtr Materials() const = 0; + + protected: virtual bool LoadImpl() = 0; + + protected: virtual bool InitImpl() = 0; + + private: virtual void CreateNodeStore(); + + private: virtual void CreateMaterials(); + + /// \brief Helper function to recursively destory nodes while checking + /// for loops. + /// \param[in] _node Node to be destroyed + /// \param[in] _nodeId Holds all node ids that have been visited in the + /// tree during the destroy process. Used for loop detection. + private: void DestroyNodeRecursive(NodePtr _node, + std::set &_nodeIds); + + protected: unsigned int id; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: std::string name; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + protected: common::Time IGN_DEPRECATED(4) simTime; + + protected: std::chrono::steady_clock::duration time = + std::chrono::steady_clock::duration::zero(); + + protected: bool loaded; + + protected: bool initialized; + + /// \brief Scene background color. Default should be black. + protected: math::Color backgroundColor; + + /// \brief The four corners of the gradient background color. + /// Next is the description of how to interpret each value of the array: + /// 0: Top left corner color. + /// 1: Bottom left corner color. + /// 2: Top right corner color. + /// 3: Bottom right corner color. + /// Default should be black. + protected: std::array gradientBackgroundColor; + + /// \brief Whether the scene has a gradient background. + protected: bool isGradientBackgroundColor = false; + + /// \brief Scene background material. + protected: MaterialPtr backgroundMaterial; + + private: unsigned int nextObjectId; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: NodeStorePtr nodes; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseSegmentationCamera.hh b/include/gz/rendering/base/BaseSegmentationCamera.hh new file mode 100644 index 000000000..c74fea088 --- /dev/null +++ b/include/gz/rendering/base/BaseSegmentationCamera.hh @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_ +#define IGNITION_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_ + +#include + +#include + +#include "ignition/rendering/base/BaseCamera.hh" +#include "ignition/rendering/SegmentationCamera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + template + class BaseSegmentationCamera : + public virtual SegmentationCamera, + public virtual BaseCamera, + public virtual T + { + /// \brief Constructor + protected: BaseSegmentationCamera(); + + /// \brief Destructor + public: virtual ~BaseSegmentationCamera(); + + // Documentation inherited + public: virtual void CreateSegmentationTexture() override = 0; + + // Documentation inherited + public: virtual uint8_t *SegmentationData() const override; + + // Documentation inherited + public: virtual ignition::common::ConnectionPtr + ConnectNewSegmentationFrame( + std::function _subscriber) override; + + // Documentation inherited + public: virtual void SetSegmentationType( + SegmentationType _type) override; + + // Documentation inherited + public: virtual SegmentationType Type() const override; + + // Documentation inherited + public: virtual void EnableColoredMap(bool _enable) override; + + // Documentation inherited + public: virtual bool IsColoredMap() const override; + + // Documentation inherited + public: virtual void SetBackgroundColor( + const math::Color &_color) override; + + // Documentation inherited + public: virtual void SetBackgroundLabel(int _label) override; + + // Documentation inherited + public: virtual const math::Color &BackgroundColor() const override; + + // Documentation inherited + public: virtual int BackgroundLabel() const override; + + // Documentation inherited + public: void LabelMapFromColoredBuffer( + uint8_t *_labelBuffer) const override = 0; + + /// \brief The buffer that contains segmentation data + protected: uint8_t *segmentationData {nullptr}; + + /// \brief The segmentation type + protected: SegmentationType type {SegmentationType::ST_SEMANTIC}; + + /// \brief Whether a colored map is being generated (true) or label ID map + /// is being generated (false) + protected: bool isColoredMap {false}; + + /// \brief The color of objects that are considered background (i.e., + /// objects that have no label) + protected: math::Color backgroundColor {0, 0, 0}; + + /// \brief The label of background objects + protected: int backgroundLabel {0}; + }; + + ////////////////////////////////////////////////// + template + BaseSegmentationCamera::BaseSegmentationCamera() + { + } + + ////////////////////////////////////////////////// + template + BaseSegmentationCamera::~BaseSegmentationCamera() + { + if (this->segmentationData) + { + delete [] this->segmentationData; + this->segmentationData = nullptr; + } + } + + ////////////////////////////////////////////////// + template + uint8_t *BaseSegmentationCamera::SegmentationData() const + { + return this->segmentationData; + } + + ////////////////////////////////////////////////// + template + ignition::common::ConnectionPtr BaseSegmentationCamera:: + ConnectNewSegmentationFrame( + std::function) + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + void BaseSegmentationCamera::SetSegmentationType(SegmentationType _type) + { + this->type = _type; + } + + ////////////////////////////////////////////////// + template + void BaseSegmentationCamera::EnableColoredMap(bool _enable) + { + this->isColoredMap = _enable; + } + + ////////////////////////////////////////////////// + template + SegmentationType BaseSegmentationCamera::Type() const + { + return this->type; + } + + ////////////////////////////////////////////////// + template + bool BaseSegmentationCamera::IsColoredMap() const + { + return this->isColoredMap; + } + + ////////////////////////////////////////////////// + template + void BaseSegmentationCamera::SetBackgroundColor( + const math::Color &_color) + { + this->backgroundColor = _color; + } + + ////////////////////////////////////////////////// + template + void BaseSegmentationCamera::SetBackgroundLabel(int _label) + { + this->backgroundLabel = _label; + } + + ////////////////////////////////////////////////// + template + const math::Color &BaseSegmentationCamera::BackgroundColor() const + { + return this->backgroundColor; + } + + ////////////////////////////////////////////////// + template + int BaseSegmentationCamera::BackgroundLabel() const + { + return this->backgroundLabel; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseSensor.hh b/include/gz/rendering/base/BaseSensor.hh new file mode 100644 index 000000000..d49e95309 --- /dev/null +++ b/include/gz/rendering/base/BaseSensor.hh @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASESENSOR_HH_ +#define GZ_RENDERING_BASE_BASESENSOR_HH_ + +#include "gz/rendering/Sensor.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseSensor : + public virtual Sensor, + public virtual T + { + protected: BaseSensor(); + + public: virtual ~BaseSensor(); + + // Documentation inherited. + public: virtual void SetVisibilityMask(uint32_t _mask) override; + + // Documentation inherited. + public: virtual uint32_t VisibilityMask() const override; + + /// \brief Camera's visibility mask + protected: uint32_t visibilityMask = IGN_VISIBILITY_ALL; + }; + + ////////////////////////////////////////////////// + template + BaseSensor::BaseSensor() + { + } + + ////////////////////////////////////////////////// + template + BaseSensor::~BaseSensor() + { + } + + ////////////////////////////////////////////////// + template + void BaseSensor::SetVisibilityMask(uint32_t _mask) + { + this->visibilityMask = _mask; + } + + ////////////////////////////////////////////////// + template + uint32_t BaseSensor::VisibilityMask() const + { + return this->visibilityMask; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseStorage.hh b/include/gz/rendering/base/BaseStorage.hh new file mode 100644 index 000000000..89b8785b6 --- /dev/null +++ b/include/gz/rendering/base/BaseStorage.hh @@ -0,0 +1,1465 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASESTORAGE_HH_ +#define GZ_RENDERING_BASE_BASESTORAGE_HH_ + +#include +#include +#include +#include + +#include +#include + +#include "gz/rendering/Storage.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + ////////////////////////////////////////////////// + template + class BaseMap : + public Map + { + typedef std::shared_ptr TPtr; + + typedef std::shared_ptr ConstTPtr; + + typedef std::shared_ptr UPtr; + + typedef std::map UMap; + + typedef typename UMap::iterator UIter; + + typedef typename UMap::const_iterator ConstUIter; + + public: BaseMap(); + + public: virtual ~BaseMap(); + + public: virtual unsigned int Size() const; + + public: virtual bool ContainsKey(const std::string &_key) const; + + public: virtual bool ContainsValue(ConstTPtr _value) const; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public: virtual TPtr Get(const std::string &_key) const; + + public: virtual TPtr GetByIndex(unsigned int _index) const; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + public: virtual bool Put(const std::string &_key, TPtr _value); + + public: virtual void Remove(const std::string &_key); + + public: virtual void Remove(TPtr _value); + + public: virtual void RemoveAll(); + + public: virtual UPtr Derived(const std::string &_key) const; + + public: virtual UPtr DerivedByIndex(unsigned int _index) const; + + protected: virtual bool IsValidIter(ConstUIter _iter) const; + + protected: UMap map; + }; + + ////////////////////////////////////////////////// + template + class BaseStore : + public Store + { + typedef std::shared_ptr TPtr; + + typedef std::shared_ptr ConstTPtr; + + typedef std::shared_ptr UPtr; + + typedef std::map UStore; + + typedef typename UStore::iterator UIter; + + typedef typename UStore::const_iterator ConstUIter; + + public: BaseStore(); + + public: virtual ~BaseStore(); + + public: virtual unsigned int Size() const; + + public: virtual bool Contains(ConstTPtr _object) const; + + public: virtual bool ContainsId(unsigned int _id) const; + + public: virtual bool ContainsName(const std::string &_name) const; + + public: virtual TPtr GetById(unsigned int _id) const; + + public: virtual TPtr GetByName(const std::string &_name) const; + + public: virtual TPtr GetByIndex(unsigned int _index) const; + + public: virtual bool Add(TPtr _object); + + public: virtual TPtr Remove(TPtr _object); + + public: virtual TPtr RemoveById(unsigned int _id); + + public: virtual TPtr RemoveByName(const std::string &_name); + + public: virtual TPtr RemoveByIndex(unsigned int _index); + + public: virtual void RemoveAll(); + + public: virtual void Destroy(TPtr _object); + + public: virtual void DestroyById(unsigned int _id); + + public: virtual void DestroyByName(const std::string &_name); + + public: virtual void DestroyByIndex(unsigned int _index); + + public: virtual void DestroyAll(); + + public: virtual UPtr DerivedById(unsigned int _id) const; + + public: virtual UPtr DerivedByName(const std::string &_name) const; + + public: virtual UPtr DerivedByIndex(unsigned int _index) const; + + public: virtual bool AddDerived(UPtr _object); + + public: virtual UPtr RemoveDerived(UPtr _object); + + public: virtual UPtr RemoveDerivedById(unsigned int _id); + + public: virtual UPtr RemoveDerivedByName(const std::string &_name); + + public: virtual UPtr RemoveDerivedByIndex(unsigned int _index); + + /// \brief Return an iterator to the beginning + /// \returns Iterator to beginning + public: virtual UIter Begin(); + + /// \brief Return an iterator to the end + /// \returns Iterator to end + public: virtual UIter End(); + + protected: virtual ConstUIter ConstIter(ConstTPtr _object) const; + + protected: virtual ConstUIter ConstIterById(unsigned int _id) const; + + protected: virtual ConstUIter ConstIterByName( + const std::string &_name) const; + + protected: virtual ConstUIter ConstIterByIndex(unsigned int _index) const; + + protected: virtual UIter Iter(ConstTPtr _object); + + protected: virtual UIter IterById(unsigned int _id); + + protected: virtual UIter IterByName(const std::string &_name); + + protected: virtual UIter IterByIndex(unsigned int _index); + + protected: virtual bool AddImpl(UPtr _object); + + protected: virtual UPtr RemoveImpl(UIter _iter); + + protected: virtual void DestroyImpl(UIter _iter); + + protected: virtual bool IsValidIter(ConstUIter _iter) const; + + protected: virtual UIter RemoveConstness(ConstUIter _iter); + + protected: UStore store; + }; + + ////////////////////////////////////////////////// + template + class BaseCompositeStore : + public CompositeStore + { + typedef std::shared_ptr TPtr; + + typedef std::shared_ptr ConstTPtr; + + typedef Store TStore; + + typedef std::shared_ptr TStorePtr; + + typedef std::shared_ptr ConstTStorePtr; + + typedef std::vector TStoreList; + + typedef typename TStoreList::iterator TStoreIter; + + public: BaseCompositeStore(); + + public: virtual ~BaseCompositeStore(); + + public: virtual unsigned int Size() const; + + public: virtual bool Contains(ConstTPtr _object) const; + + public: virtual bool ContainsId(unsigned int _id) const; + + public: virtual bool ContainsName(const std::string &_name) const; + + public: virtual TPtr GetById(unsigned int _id) const; + + public: virtual TPtr GetByName(const std::string &_name) const; + + public: virtual TPtr GetByIndex(unsigned int _index) const; + + public: virtual bool Add(TPtr _object); + + public: virtual TPtr Remove(TPtr _object); + + public: virtual TPtr RemoveById(unsigned int _id); + + public: virtual TPtr RemoveByName(const std::string &_name); + + public: virtual TPtr RemoveByIndex(unsigned int _index); + + public: virtual void RemoveAll(); + + public: virtual void Destroy(TPtr _object); + + public: virtual void DestroyById(unsigned int _id); + + public: virtual void DestroyByName(const std::string &_name); + + public: virtual void DestroyByIndex(unsigned int _index); + + public: virtual void DestroyAll(); + + public: virtual unsigned int GetStoreCount() const; + + public: virtual bool ContainsStore(ConstTStorePtr _store) const; + + public: virtual TStorePtr GetStore(unsigned int _index) const; + + public: virtual bool AddStore(TStorePtr _store); + + public: virtual TStorePtr RemoveStore(TStorePtr _store); + + public: virtual TStorePtr RemoveStore(unsigned int _index); + + public: virtual TStorePtr RemoveStoreImpl(TStoreIter _iter); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: TStoreList stores; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + + ////////////////////////////////////////////////// + template + class BaseStoreWrapper : + public StoreWrapper + { + typedef std::shared_ptr TPtr; + + typedef std::shared_ptr ConstTPtr; + + typedef std::shared_ptr UPtr; + + typedef std::shared_ptr ConstUPtr; + + typedef Store UStore; + + typedef std::shared_ptr UStorePtr; + + public: explicit BaseStoreWrapper(UStorePtr _store); + + public: virtual ~BaseStoreWrapper(); + + public: virtual unsigned int Size() const; + + public: virtual bool Contains(ConstTPtr _object) const; + + public: virtual bool ContainsId(unsigned int _id) const; + + public: virtual bool ContainsName(const std::string &_name) const; + + public: virtual TPtr GetById(unsigned int _id) const; + + public: virtual TPtr GetByName(const std::string &_name) const; + + public: virtual TPtr GetByIndex(unsigned int _index) const; + + public: virtual bool Add(TPtr _object); + + public: virtual TPtr Remove(TPtr _object); + + public: virtual TPtr RemoveById(unsigned int _id); + + public: virtual TPtr RemoveByName(const std::string &_name); + + public: virtual TPtr RemoveByIndex(unsigned int _index); + + public: virtual void RemoveAll(); + + public: virtual void Destroy(TPtr _object); + + public: virtual void DestroyById(unsigned int _id); + + public: virtual void DestroyByName(const std::string &_name); + + public: virtual void DestroyByIndex(unsigned int _index); + + public: virtual void DestroyAll(); + + protected: UStorePtr store; + }; + + ////////////////////////////////////////////////// + class BaseNodeCompositeStore : + public BaseCompositeStore + { + }; + + template + class BaseSceneStore : + public BaseStore + { + }; + + template + class BaseNodeStore : + public BaseStore + { + }; + + template + class BaseLightStore : + public BaseStore + { + }; + + template + class BaseSensorStore : + public BaseStore + { + }; + + template + class BaseVisualStore : + public BaseStore + { + }; + + template + class BaseGeometryStore : + public BaseStore + { + }; + + template + class BaseSubMeshStore : + public BaseStore + { + }; + + template + class BaseMaterialMap : + public BaseMap + { + }; + + ////////////////////////////////////////////////// + template + BaseMap::BaseMap() + { + } + + ////////////////////////////////////////////////// + template + BaseMap::~BaseMap() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseMap::Size() const + { + return this->map.size(); + } + + ////////////////////////////////////////////////// + template + bool BaseMap::ContainsKey(const std::string &_key) const + { + return this->map.count(_key) > 0; + } + + ////////////////////////////////////////////////// + template + bool BaseMap::ContainsValue(ConstTPtr _value) const + { + for (auto pair : this->map) + { + if (pair.second == _value) return true; + } + + return false; + } + + ////////////////////////////////////////////////// + template + typename BaseMap::TPtr + BaseMap::Get(const std::string &_key) const + { + return this->Derived(_key); + } + + ////////////////////////////////////////////////// + template + typename BaseMap::TPtr + BaseMap::GetByIndex(unsigned int _index) const + { + return this->DerivedByIndex(_index); + } + + ////////////////////////////////////////////////// + template + bool BaseMap::Put(const std::string &_key, TPtr _value) + { + if (_key.empty()) + { + ignerr << "Cannot store item with empty key" << std::endl; + return false; + } + + if (!_value) + { + ignerr << "Cannot store null pointer value" << std::endl; + return false; + } + + if (this->ContainsKey(_key)) + { + ignerr << "Item already registered with key: " << _key << std::endl; + return false; + } + + UPtr derived = std::dynamic_pointer_cast(_value); + + if (!derived) + { + ignerr << "Cannot add item created by another render-engine" + << std::endl; + + return false; + } + + this->map[_key] = derived; + return true; + } + + ////////////////////////////////////////////////// + template + void BaseMap::Remove(const std::string &_key) + { + auto iter = this->map.find(_key); + + if (this->IsValidIter(iter)) + { + this->map.erase(iter); + } + } + + ////////////////////////////////////////////////// + template + void BaseMap::Remove(TPtr _value) + { + auto iter = this->map.begin(); + + while (this->IsValidIter(iter)) + { + if (iter->second == _value) + { + this->map.erase(iter); + continue; + } + + ++iter; + } + } + + ////////////////////////////////////////////////// + template + void BaseMap::RemoveAll() + { + this->map.clear(); + } + + ////////////////////////////////////////////////// + template + typename BaseMap::UPtr + BaseMap::Derived(const std::string &_key) const + { + auto iter = this->map.find(_key); + return (this->IsValidIter(iter)) ? iter->second : nullptr; + } + + ////////////////////////////////////////////////// + template + typename BaseMap::UPtr + BaseMap::DerivedByIndex(unsigned int _index) const + { + if (_index >= this->Size()) + { + ignerr << "Invalid index: " << _index << std::endl; + return nullptr; + } + + auto iter = this->map.begin(); + std::advance(iter, _index); + return iter->second; + } + + ////////////////////////////////////////////////// + template + bool BaseMap::IsValidIter(ConstUIter _iter) const + { + return _iter != this->map.end(); + } + + ////////////////////////////////////////////////// + template + BaseStore::BaseStore() + { + } + + ////////////////////////////////////////////////// + template + BaseStore::~BaseStore() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseStore::Size() const + { + return this->store.size(); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::Begin() + { + return this->store.begin(); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::End() + { + return this->store.end(); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::Contains(ConstTPtr _object) const + { + auto iter = this->ConstIter(_object); + return this->IsValidIter(iter); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::ContainsId(unsigned int _id) const + { + auto iter = this->ConstIterById(_id); + return this->IsValidIter(iter); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::ContainsName(const std::string &_name) const + { + auto iter = this->ConstIterByName(_name); + return this->IsValidIter(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::GetById(unsigned int _id) const + { + return this->DerivedById(_id); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::GetByName(const std::string &_name) const + { + return this->DerivedByName(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::GetByIndex(unsigned int _index) const + { + return this->DerivedByIndex(_index); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::Add(TPtr _object) + { + if (!_object) + { + ignerr << "Cannot add null pointer" << std::endl; + return false; + } + + UPtr derived = std::dynamic_pointer_cast(_object); + + if (!derived) + { + ignerr << "Cannot add item created by another render-engine" + << std::endl; + + return false; + } + + return this->AddImpl(derived); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::Remove(TPtr _object) + { + auto iter = this->Iter(_object); + return this->RemoveImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::RemoveById(unsigned int _id) + { + return this->RemoveDerivedById(_id); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::RemoveByName(const std::string &_name) + { + return this->RemoveDerivedByName(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::RemoveByIndex(unsigned int _index) + { + return this->RemoveDerivedByIndex(_index); + } + + ////////////////////////////////////////////////// + template + void BaseStore::RemoveAll() + { + this->store.clear(); + } + + ////////////////////////////////////////////////// + template + void BaseStore::Destroy(TPtr _object) + { + auto iter = this->Iter(_object); + this->DestroyImpl(iter); + } + + ////////////////////////////////////////////////// + template + void BaseStore::DestroyById(unsigned int _id) + { + auto iter = this->IterById(_id); + this->DestroyImpl(iter); + } + + ////////////////////////////////////////////////// + template + void BaseStore::DestroyByName(const std::string &_name) + { + auto iter = this->IterByName(_name); + this->DestroyImpl(iter); + } + + ////////////////////////////////////////////////// + template + void BaseStore::DestroyByIndex(unsigned int _index) + { + auto iter = this->IterByIndex(_index); + this->DestroyImpl(iter); + } + + ////////////////////////////////////////////////// + template + void BaseStore::DestroyAll() + { + unsigned int i = this->Size(); + + while (i > 0) + { + this->DestroyByIndex(--i); + } + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::DerivedById(unsigned int _id) const + { + auto iter = this->ConstIterById(_id); + return (this->IsValidIter(iter)) ? iter->second : nullptr; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::DerivedByName(const std::string &_name) const + { + auto iter = this->ConstIterByName(_name); + return (this->IsValidIter(iter)) ? iter->second : nullptr; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::DerivedByIndex(unsigned int _index) const + { + auto iter = this->ConstIterByIndex(_index); + return (this->IsValidIter(iter)) ? iter->second : nullptr; + } + + ////////////////////////////////////////////////// + template + bool BaseStore::AddDerived(UPtr _object) + { + if (!_object) + { + ignerr << "Cannot add null pointer" << std::endl; + return false; + } + + return this->AddImpl(_object); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::RemoveDerived(UPtr _object) + { + auto iter = this->Iter(_object); + return this->RemoveImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::RemoveDerivedById(unsigned int _id) + { + auto iter = this->IterById(_id); + return this->RemoveImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::RemoveDerivedByName(const std::string &_name) + { + auto iter = this->IterByName(_name); + return this->RemoveImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::RemoveDerivedByIndex(unsigned int _index) + { + auto iter = this->IterByIndex(_index); + return this->RemoveImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::ConstUIter + BaseStore::ConstIter(ConstTPtr _object) const + { + auto begin = this->store.begin(); + auto end = this->store.end(); + + for (auto iter = begin; iter != end; ++iter) + { + if (iter->second == _object) + { + return iter; + } + } + + return end; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::ConstUIter + BaseStore::ConstIterById(unsigned int _id) const + { + auto begin = this->store.begin(); + auto end = this->store.end(); + + for (auto iter = begin; iter != end; ++iter) + { + if (iter->second->Id() == _id) + { + return iter; + } + } + + return end; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::ConstUIter + BaseStore::ConstIterByName(const std::string &_name) const + { + return this->store.find(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::ConstUIter + BaseStore::ConstIterByIndex(unsigned int _index) const + { + if (_index >= this->Size()) + { + ignerr << "Invalid index: " << _index << std::endl; + return this->store.end(); + } + + auto iter = this->store.begin(); + std::advance(iter, _index); + return iter; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::Iter(ConstTPtr _object) + { + auto iter = this->ConstIter(_object); + return this->RemoveConstness(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::IterById(unsigned int _id) + { + auto iter = this->ConstIterById(_id); + return this->RemoveConstness(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::IterByName(const std::string &_name) + { + auto iter = this->ConstIterByName(_name); + return this->RemoveConstness(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::IterByIndex(unsigned int _index) + { + auto iter = this->ConstIterByIndex(_index); + return this->RemoveConstness(iter); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::AddImpl(UPtr _object) + { + unsigned int id = _object->Id(); + std::string name = _object->Name(); + + if (this->ContainsId(id)) + { + ignerr << "Another item already exists with id: " << id << std::endl; + return false; + } + + if (this->ContainsName(name)) + { + ignerr << "Another item already exists with name: " << name + << std::endl; + return false; + } + + this->store[name] = _object; + return true; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::RemoveImpl(UIter _iter) + { + if (!this->IsValidIter(_iter)) + { + return nullptr; + } + + UPtr result = _iter->second; + this->store.erase(_iter); + return result; + } + + ////////////////////////////////////////////////// + template + void BaseStore::DestroyImpl(UIter _iter) + { + UPtr result = this->RemoveImpl(_iter); + if (result) result->Destroy(); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::IsValidIter(ConstUIter _iter) const + { + return _iter != this->store.end(); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::RemoveConstness(ConstUIter _iter) + { + return (this->IsValidIter(_iter)) ? + this->store.erase(_iter, _iter) : this->store.end(); + } + + ////////////////////////////////////////////////// + template + BaseCompositeStore::BaseCompositeStore() + { + } + + ////////////////////////////////////////////////// + template + BaseCompositeStore::~BaseCompositeStore() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCompositeStore::Size() const + { + unsigned int size = 0; + + for (auto store : this->stores) + { + size += store->Size(); + } + + return size; + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::Contains(ConstTPtr _object) const + { + for (auto store : this->stores) + { + if (store->Contains(_object)) return true; + } + + return false; + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::ContainsId(unsigned int _id) const + { + for (auto store : this->stores) + { + if (store->ContainsId(_id)) return true; + } + + return false; + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::ContainsName(const std::string &_name) const + { + for (auto store : this->stores) + { + if (store->ContainsName(_name)) return true; + } + + return false; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::GetById(unsigned int _id) const + { + for (auto store : this->stores) + { + TPtr object = store->GetById(_id); + if (object) return object; + } + + return nullptr; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::GetByName(const std::string &_name) const + { + for (auto store : this->stores) + { + TPtr object = store->GetByName(_name); + if (object) return object; + } + + return nullptr; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::GetByIndex(unsigned int _index) const + { + unsigned int origIndex = _index; + + for (auto store : this->stores) + { + unsigned int size = store->Size(); + if (_index < size) + return store->GetByIndex(_index); + _index -= size; + } + + ignerr << "Invalid index: " << origIndex << std::endl; + return nullptr; + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::Add(TPtr) + { + ignerr << "Adding to BaseCompositeStore not supported" << std::endl; + return false; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::Remove(TPtr _object) + { + TPtr result = nullptr; + + for (auto store : this->stores) + { + TPtr temp = store->Remove(_object); + if (!result) result = temp; + } + + return result; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::RemoveById(unsigned int _id) + { + TPtr result = nullptr; + + for (auto store : this->stores) + { + TPtr temp = store->RemoveById(_id); + if (!result) result = temp; + } + + return result; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::RemoveByName(const std::string &_name) + { + TPtr result = nullptr; + + for (auto store : this->stores) + { + TPtr temp = store->RemoveByName(_name); + if (!result) result = temp; + } + + return result; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::RemoveByIndex(unsigned int _index) + { + TPtr result = nullptr; + + for (auto store : this->stores) + { + TPtr temp = store->RemoveByIndex(_index); + if (!result) result = temp; + } + + return result; + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::RemoveAll() + { + for (auto store : this->stores) + { + store->RemoveAll(); + } + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::Destroy(TPtr _object) + { + for (auto store : this->stores) + { + if (store->Contains(_object)) + { + store->Destroy(_object); + return; + } + } + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::DestroyById(unsigned int _id) + { + for (auto store : this->stores) + { + store->DestroyById(_id); + } + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::DestroyByName(const std::string &_name) + { + for (auto store : this->stores) + { + store->DestroyByName(_name); + } + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::DestroyByIndex(unsigned int _index) + { + for (auto store : this->stores) + { + store->DestroyByIndex(_index); + } + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::DestroyAll() + { + for (auto store : this->stores) + { + store->DestroyAll(); + } + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCompositeStore::GetStoreCount() const + { + return this->stores.size(); + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::ContainsStore(ConstTStorePtr _store) const + { + auto begin = this->stores.begin(); + auto end = this->stores.end(); + auto iter = std::find(begin, end, _store); + return iter != end; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TStorePtr + BaseCompositeStore::GetStore(unsigned int _index) const + { + if (_index >= this->GetStoreCount()) + { + ignerr << "Invalid store index: " << _index << std::endl; + return nullptr; + } + + return this->stores[_index]; + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::AddStore(TStorePtr _store) + { + if (!_store) + { + ignerr << "Cannot all null store pointer" << std::endl; + return false; + } + + if (this->ContainsStore(_store)) + { + ignerr << "Store has already been added" << std::endl; + return false; + } + + this->stores.push_back(_store); + return true; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TStorePtr + BaseCompositeStore::RemoveStore(TStorePtr _store) + { + auto begin = this->stores.begin(); + auto end = this->stores.end(); + auto iter = std::find(begin, end, _store); + return this->RemoveStoreImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TStorePtr + BaseCompositeStore::RemoveStore(unsigned int _index) + { + if (_index >= this->GetStoreCount()) + { + ignerr << "Invalid store index: " << _index << std::endl; + return nullptr; + } + + auto iter = this->stores.begin(); + std::advance(iter, _index); + return this->RemoveStoreImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TStorePtr + BaseCompositeStore::RemoveStoreImpl(TStoreIter _iter) + { + if (_iter == this->stores.end()) + { + return nullptr; + } + + TStorePtr result = *_iter; + this->stores.erase(_iter); + return result; + } + + ////////////////////////////////////////////////// + template + BaseStoreWrapper::BaseStoreWrapper(UStorePtr _store) : + store(_store) + { + } + + ////////////////////////////////////////////////// + template + BaseStoreWrapper::~BaseStoreWrapper() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseStoreWrapper::Size() const + { + return this->store->Size(); + } + + ////////////////////////////////////////////////// + template + bool BaseStoreWrapper::Contains(ConstTPtr _object) const + { + ConstUPtr derived = std::dynamic_pointer_cast(_object); + return this->store->Contains(derived); + } + + ////////////////////////////////////////////////// + template + bool BaseStoreWrapper::ContainsId(unsigned int _id) const + { + return this->store->ContainsId(_id); + } + + ////////////////////////////////////////////////// + template + bool BaseStoreWrapper::ContainsName(const std::string &_name) const + { + return this->store->ContainsName(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::GetById(unsigned int _id) const + { + return this->store->GetById(_id); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::GetByName(const std::string &_name) const + { + return this->store->GetByName(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::GetByIndex(unsigned int _index) const + { + return this->store->GetByIndex(_index); + } + + ////////////////////////////////////////////////// + template + bool BaseStoreWrapper::Add(TPtr _object) + { + UPtr derived = std::dynamic_pointer_cast(_object); + return this->store->Add(derived); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::Remove(TPtr _object) + { + UPtr derived = std::dynamic_pointer_cast(_object); + return this->store->Remove(derived); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::RemoveById(unsigned int _id) + { + return this->store->RemoveById(_id); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::RemoveByName(const std::string &_name) + { + return this->store->RemoveByName(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::RemoveByIndex(unsigned int _index) + { + return this->store->RemoveByIndex(_index); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::RemoveAll() + { + this->store->RemoveAll(); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::Destroy(TPtr _object) + { + UPtr derived = std::dynamic_pointer_cast(_object); + this->store->Destroy(derived); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::DestroyById(unsigned int _id) + { + this->store->DestroyById(_id); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::DestroyByName(const std::string &_name) + { + this->store->DestroyByName(_name); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::DestroyByIndex(unsigned int _index) + { + this->store->DestroyByIndex(_index); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::DestroyAll() + { + this->store->DestroyAll(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseText.hh b/include/gz/rendering/base/BaseText.hh new file mode 100644 index 000000000..0f5774da2 --- /dev/null +++ b/include/gz/rendering/base/BaseText.hh @@ -0,0 +1,303 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASETEXT_HH_ +#define GZ_RENDERING_BASE_BASETEXT_HH_ + +#include +#include "gz/rendering/Text.hh" +#include "gz/rendering/base/BaseObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of a text geometry + template + class BaseText : + public virtual Text, + public virtual T + { + /// \brief Constructor + protected: BaseText(); + + /// \brief Destructor + public: virtual ~BaseText(); + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: void SetFontName(const std::string &_font) override; + + // Documentation inherited. + public: std::string FontName() const override; + + // Documentation inherited. + public: virtual void SetTextString(const std::string &_text) override; + + // Documentation inherited. + public: virtual std::string TextString() const override; + + // Documentation inherited. + public: virtual void SetColor(const gz::math::Color &_color) + override; + + // Documentation inherited. + public: virtual gz::math::Color Color() const override; + + // Documentation inherited. + public: virtual void SetCharHeight(const float _height) override; + + // Documentation inherited. + public: virtual float CharHeight() const override; + + // Documentation inherited. + public: virtual void SetSpaceWidth(const float _width) override; + + // Documentation inherited. + public: virtual float SpaceWidth() const override; + + // Documentation inherited. + public: virtual void SetTextAlignment(const TextHorizontalAlign &_hAlign, + const TextVerticalAlign &_vAlign) override; + // Documentation inherited. + public: virtual TextHorizontalAlign HorizontalAlignment() const override; + + // Documentation inherited. + public: virtual TextVerticalAlign VerticalAlignment() const override; + + // Documentation inherited. + public: virtual void SetBaseline(const float _baseline) override; + + // Documentation inherited. + public: virtual float Baseline() const override; + + // Documentation inherited. + public: void SetShowOnTop(const bool _onTop) override; + + // Documentation inherited. + public: virtual bool ShowOnTop() const override; + + // Documentation inherited. + public: virtual gz::math::AxisAlignedBox AABB() const override; + + /// \brief Font name, such as "Liberation Sans" + protected: std::string fontName = "Liberation Sans"; + + /// \brief Text being displayed + protected: std::string text; + + /// \brief Text color + protected: gz::math::Color color = gz::math::Color::White; + + /// \brief Character height in meters + protected: float charHeight = 1.0; + + /// \brief Width of space between letters + protected: float spaceWidth = 0; + + /// \brief Horizontal alignment + protected: TextHorizontalAlign horizontalAlign = + TextHorizontalAlign::LEFT; + + /// \brief Vertical alignment + protected: TextVerticalAlign verticalAlign = TextVerticalAlign::BOTTOM; + + /// \brief Baseline height in meters. + protected: float baseline = 0; + + /// \brief True for text to be displayed on top of other objects in the + /// scene. + protected: bool onTop = false; + + /// \brief Flag to indicate text properties have changed + protected: bool textDirty = false; + }; + + ////////////////////////////////////////////////// + // BaseText + ////////////////////////////////////////////////// + template + BaseText::BaseText() + { + } + + ////////////////////////////////////////////////// + template + BaseText::~BaseText() + { + } + + ////////////////////////////////////////////////// + template + std::string BaseText::FontName() const + { + return this->fontName; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetFontName(const std::string &_font) + { + this->fontName = _font; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + std::string BaseText::TextString() const + { + return this->text; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetTextString(const std::string &_text) + { + this->text = _text; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + gz::math::Color BaseText::Color() const + { + return this->color; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetColor(const gz::math::Color &_color) + { + this->color = _color; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + float BaseText::CharHeight() const + { + return this->charHeight; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetCharHeight(const float _height) + { + this->charHeight = _height; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + float BaseText::SpaceWidth() const + { + return this->spaceWidth; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetSpaceWidth(const float _width) + { + this->spaceWidth = _width; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + TextHorizontalAlign BaseText::HorizontalAlignment() const + { + return this->horizontalAlign; + } + + ////////////////////////////////////////////////// + template + TextVerticalAlign BaseText::VerticalAlignment() const + { + return this->verticalAlign; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetTextAlignment(const TextHorizontalAlign &_horzAlign, + const TextVerticalAlign &_vertAlign) + { + this->horizontalAlign = _horzAlign; + this->verticalAlign = _vertAlign; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + float BaseText::Baseline() const + { + return this->baseline; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetBaseline(const float _baseline) + { + this->baseline = _baseline; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + bool BaseText::ShowOnTop() const + { + return this->onTop; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetShowOnTop(const bool _onTop) + { + this->onTop = _onTop; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + gz::math::AxisAlignedBox BaseText::AABB() const + { + math::AxisAlignedBox box; + return box; + } + + ////////////////////////////////////////////////// + template + void BaseText::PreRender() + { + T::PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseText::Destroy() + { + T::Destroy(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseThermalCamera.hh b/include/gz/rendering/base/BaseThermalCamera.hh new file mode 100644 index 000000000..a0bee4984 --- /dev/null +++ b/include/gz/rendering/base/BaseThermalCamera.hh @@ -0,0 +1,211 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASETHERMALCAMERA_HH_ +#define GZ_RENDERING_BASE_BASETHERMALCAMERA_HH_ + +#include + +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/ThermalCamera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of the ThermalCamera class + template + class BaseThermalCamera : + public virtual ThermalCamera, + public virtual BaseCamera, + public virtual T + { + /// \brief Constructor + protected: BaseThermalCamera(); + + /// \brief Destructor + public: virtual ~BaseThermalCamera(); + + // Documentation inherited. + public: virtual void SetAmbientTemperature(float _ambient) override; + + // Documentation inherited. + public: virtual float AmbientTemperature() const override; + + // Documentation inherited. + public: virtual void SetAmbientTemperatureRange(float _range) override; + + // Documentation inherited. + public: virtual float AmbientTemperatureRange() const override; + + // Documentation inherited. + public: virtual void SetMinTemperature(float _min) override; + + // Documentation inherited. + public: virtual float MinTemperature() const override; + + // Documentation inherited. + public: virtual void SetMaxTemperature(float _max) override; + + // Documentation inherited. + public: virtual float MaxTemperature() const override; + + // Documentation inherited. + public: virtual void SetLinearResolution(float _max) override; + + // Documentation inherited. + public: virtual float LinearResolution() const override; + + // Documentation inherited. + public: virtual float HeatSourceTemperatureRange() const override; + + // Documentation inherited. + public: virtual void SetHeatSourceTemperatureRange(float _range) override; + + // Documentation inherted. + public: virtual gz::common::ConnectionPtr ConnectNewThermalFrame( + std::function _subscriber) override; + + /// \brief Ambient temperature of the environment + protected: float ambient = 0.0f; + + /// \brief Ambient temperature range + protected: float ambientRange = 0.0f; + + /// \brief Minimum temperature + protected: float minTemp = -gz::math::INF_F; + + /// \brief Maximum temperature + protected: float maxTemp = gz::math::INF_F; + + /// \brief Linear resolution. Defaults to 10mK. + protected: float resolution = 0.01f; + + /// \brief Range of heat source temperature variation + protected: float heatSourceTempRange = 0.0f; + }; + + ////////////////////////////////////////////////// + template + BaseThermalCamera::BaseThermalCamera() + { + } + + ////////////////////////////////////////////////// + template + BaseThermalCamera::~BaseThermalCamera() + { + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetAmbientTemperature(float _ambient) + { + this->ambient = _ambient; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::AmbientTemperature() const + { + return this->ambient; + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetAmbientTemperatureRange(float _range) + { + this->ambientRange = _range; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::AmbientTemperatureRange() const + { + return this->ambientRange; + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetMinTemperature(float _min) + { + this->minTemp = _min; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::MinTemperature() const + { + return this->minTemp; + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetMaxTemperature(float _max) + { + this->maxTemp = _max; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::MaxTemperature() const + { + return this->maxTemp; + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetLinearResolution(float _resolution) + { + this->resolution = _resolution; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::LinearResolution() const + { + return this->resolution; + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetHeatSourceTemperatureRange(float _range) + { + this->heatSourceTempRange = _range; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::HeatSourceTemperatureRange() const + { + return this->heatSourceTempRange; + } + + ////////////////////////////////////////////////// + template + common::ConnectionPtr BaseThermalCamera::ConnectNewThermalFrame( + std::function) + { + return nullptr; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseVisual.hh b/include/gz/rendering/base/BaseVisual.hh new file mode 100644 index 000000000..b369d95ca --- /dev/null +++ b/include/gz/rendering/base/BaseVisual.hh @@ -0,0 +1,554 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEVISUAL_HH_ +#define GZ_RENDERING_BASE_BASEVISUAL_HH_ + +#include +#include + +#include + +#include "gz/rendering/Visual.hh" +#include "gz/rendering/Storage.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/base/BaseStorage.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseVisual : + public virtual Visual, + public virtual T + { + protected: BaseVisual(); + + public: virtual ~BaseVisual(); + + public: virtual math::Pose3d LocalPose() const override; + + public: virtual void SetLocalPose(const math::Pose3d &_pose) override; + + public: virtual unsigned int GeometryCount() const override; + + public: virtual bool HasGeometry(ConstGeometryPtr _geometry) const + override; + + public: virtual GeometryPtr GeometryByIndex(unsigned int _index) const + override; + + public: virtual void AddGeometry(GeometryPtr _geometry) override; + + public: virtual GeometryPtr RemoveGeometry(GeometryPtr _geometry) + override; + + public: virtual GeometryPtr RemoveGeometryByIndex(unsigned int _index) + override; + + public: virtual void RemoveGeometries() override; + + public: virtual void SetMaterial(const std::string &_name, + bool _unique = true) override; + + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true) override; + + public: virtual void SetChildMaterial(MaterialPtr _material, + bool _unique = true) override; + + public: virtual void SetGeometryMaterial(MaterialPtr _material, + bool _unique = true) override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetWireframe(bool _show) override; + + // Documentation inherited. + public: virtual bool Wireframe() const override; + + // Documentation inherited. + public: virtual void SetVisible(bool _visible) override; + + // Documentation inherited. + public: virtual void SetVisibilityFlags(uint32_t _flags) override; + + // Documentation inherited. + public: virtual uint32_t VisibilityFlags() const override; + + // Documentation inherited. + public: virtual void AddVisibilityFlags(uint32_t _flags) override; + + // Documentation inherited. + public: virtual void RemoveVisibilityFlags(uint32_t _flags) override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual ignition::math::AxisAlignedBox BoundingBox() + const override; + + // Documentation inherited. + public: virtual ignition::math::AxisAlignedBox LocalBoundingBox() + const override; + + // Documentation inherited. + public: virtual VisualPtr Clone(const std::string &_name, + NodePtr _newParent) const override; + + protected: virtual void PreRenderChildren() override; + + protected: virtual void PreRenderGeometries(); + + protected: virtual GeometryStorePtr Geometries() const = 0; + + protected: virtual bool AttachGeometry(GeometryPtr _geometry) = 0; + + protected: virtual bool DetachGeometry(GeometryPtr _geometry) = 0; + + /// \brief Pointer to material assigned to this visual + protected: MaterialPtr material; + + /// \brief Visual's visibility flags + protected: uint32_t visibilityFlags = IGN_VISIBILITY_ALL; + + /// \brief The bounding box of the visual + protected: ignition::math::AxisAlignedBox boundingBox; + + /// \brief True if wireframe mode is enabled else false + protected: bool wireframe = false; + }; + + ////////////////////////////////////////////////// + template + BaseVisual::BaseVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseVisual::~BaseVisual() + { + } + + ////////////////////////////////////////////////// + template + math::Pose3d BaseVisual::LocalPose() const + { + math::Pose3d rawPose = this->RawLocalPose(); + math::Vector3d scale = this->LocalScale(); + rawPose.Pos() += rawPose.Rot() * (scale * this->origin); + return rawPose; + } + + ////////////////////////////////////////////////// + template + void BaseVisual::SetLocalPose(const math::Pose3d &_pose) + { + math::Pose3d rawPose = _pose; + math::Vector3d scale = this->LocalScale(); + rawPose.Pos() -= rawPose.Rot() * (scale * this->origin); + + if (!rawPose.IsFinite()) + { + ignerr << "Unable to set pose of a node: " + << "non-finite (nan, inf) values detected." << std::endl; + return; + } + + this->SetRawLocalPose(rawPose); + } + + ////////////////////////////////////////////////// + template + unsigned int BaseVisual::GeometryCount() const + { + return this->Geometries()->Size(); + } + + ////////////////////////////////////////////////// + template + bool BaseVisual::HasGeometry(ConstGeometryPtr _geometry) const + { + return this->Geometries()->Contains(_geometry); + } + + ////////////////////////////////////////////////// + template + GeometryPtr BaseVisual::GeometryByIndex(unsigned int _index) const + { + return this->Geometries()->GetByIndex(_index); + } + + ////////////////////////////////////////////////// + template + void BaseVisual::AddGeometry(GeometryPtr _geometry) + { + if (this->AttachGeometry(_geometry)) + { + this->Geometries()->Add(_geometry); + } + } + + ////////////////////////////////////////////////// + template + GeometryPtr BaseVisual::RemoveGeometry(GeometryPtr _geometry) + { + if (this->DetachGeometry(_geometry)) + { + this->Geometries()->Remove(_geometry); + } + return _geometry; + } + + ////////////////////////////////////////////////// + template + GeometryPtr BaseVisual::RemoveGeometryByIndex(unsigned int _index) + { + return this->RemoveGeometry(this->GeometryByIndex(_index)); + } + + ////////////////////////////////////////////////// + template + void BaseVisual::RemoveGeometries() + { + for (unsigned int i = this->GeometryCount(); i > 0; --i) + { + this->RemoveGeometryByIndex(i-1); + } + } + + ////////////////////////////////////////////////// + template + void BaseVisual::SetMaterial(const std::string &_name, bool _unique) + { + MaterialPtr mat = this->Scene()->Material(_name); + if (mat) this->SetMaterial(mat, _unique); + } + + ////////////////////////////////////////////////// + template + void BaseVisual::SetMaterial(MaterialPtr _material, bool _unique) + { + _material = (_unique) ? _material->Clone() : _material; + this->SetChildMaterial(_material, false); + this->SetGeometryMaterial(_material, false); + this->material = _material; + } + + ////////////////////////////////////////////////// + template + void BaseVisual::SetChildMaterial(MaterialPtr _material, bool _unique) + { + unsigned int count = this->ChildCount(); + _material = (_unique && count > 0) ? _material->Clone() : _material; + + auto children_ = + std::dynamic_pointer_cast>( + this->Children()); + if (!children_) + { + ignerr << "Cast failed in BaseVisual::SetChildMaterial" << std::endl; + return; + } + for (auto it = children_->Begin(); it != children_->End(); ++it) + { + NodePtr child = it->second; + VisualPtr visual = std::dynamic_pointer_cast(child); + if (visual) visual->SetMaterial(_material, false); + } + } + + ////////////////////////////////////////////////// + template + void BaseVisual::SetGeometryMaterial(MaterialPtr _material, bool _unique) + { + unsigned int count = this->GeometryCount(); + _material = (_unique && count > 0) ? _material->Clone() : _material; + + for (unsigned int i = 0; i < count; ++i) + { + GeometryPtr geometry = this->GeometryByIndex(i); + geometry->SetMaterial(_material, false); + } + } + + ////////////////////////////////////////////////// + template + MaterialPtr BaseVisual::Material() const + { + return this->material; + } + + ////////////////////////////////////////////////// + template + void BaseVisual::PreRender() + { + this->PreRenderChildren(); + this->PreRenderGeometries(); + } + + ////////////////////////////////////////////////// + template + void BaseVisual::Destroy() + { + this->Geometries()->DestroyAll(); + this->Children()->RemoveAll(); + this->material.reset(); + T::Destroy(); + } + + ////////////////////////////////////////////////// + template + void BaseVisual::PreRenderChildren() + { + auto children_ = + std::dynamic_pointer_cast>( + this->Children()); + if (!children_) + { + ignerr << "Cast failed in BaseVisual::PreRenderChildren" << std::endl; + return; + } + for (auto it = children_->Begin(); it != children_->End(); ++it) + { + it->second->PreRender(); + } + } + + ////////////////////////////////////////////////// + template + void BaseVisual::PreRenderGeometries() + { + unsigned int count = this->GeometryCount(); + + for (unsigned int i = 0; i < count; ++i) + { + GeometryPtr geometry = this->GeometryByIndex(i); + geometry->PreRender(); + } + } + + ////////////////////////////////////////////////// + template + bool BaseVisual::Wireframe() const + { + return this->wireframe; + } + + ////////////////////////////////////////////////// + template + void BaseVisual::SetWireframe(bool _show) + { + ignerr << "SetWireframe(" << _show << ") not supported for " + << "render engine: " << this->Scene()->Engine()->Name() + << std::endl; + } + + ////////////////////////////////////////////////// + template + void BaseVisual::SetVisible(bool _visible) + { + ignerr << "SetVisible(" << _visible << ") not supported for " + << "render engine: " << this->Scene()->Engine()->Name() + << std::endl; + } + + ////////////////////////////////////////////////// + template + ignition::math::AxisAlignedBox BaseVisual::LocalBoundingBox() const + { + ignition::math::AxisAlignedBox box; + + // Recursively loop through child visuals + auto childNodes = + std::dynamic_pointer_cast>( + this->Children()); + if (!childNodes) + { + ignerr << "Cast failed in BaseVisual::LocalBoundingBox" << std::endl; + return box; + } + for (auto it = childNodes->Begin(); it != childNodes->End(); ++it) + { + NodePtr child = it->second; + VisualPtr visual = std::dynamic_pointer_cast(child); + if (visual) + { + ignition::math::AxisAlignedBox aabb = visual->LocalBoundingBox(); + if (aabb.Min().IsFinite() && aabb.Max().IsFinite()) + box.Merge(aabb); + } + } + return box; + } + + ////////////////////////////////////////////////// + template + ignition::math::AxisAlignedBox BaseVisual::BoundingBox() const + { + ignition::math::AxisAlignedBox box; + + // Recursively loop through child visuals + auto childNodes = + std::dynamic_pointer_cast>( + this->Children()); + if (!childNodes) + { + ignerr << "Cast failed in BaseVisual::BoundingBox" << std::endl; + return box; + } + for (auto it = childNodes->Begin(); it != childNodes->End(); ++it) + { + NodePtr child = it->second; + VisualPtr visual = std::dynamic_pointer_cast(child); + if (visual) + box.Merge(visual->BoundingBox()); + } + return box; + } + + ////////////////////////////////////////////////// + template + void BaseVisual::AddVisibilityFlags(uint32_t _flags) + { + this->SetVisibilityFlags(this->VisibilityFlags() | _flags); + } + + ////////////////////////////////////////////////// + template + void BaseVisual::RemoveVisibilityFlags(uint32_t _flags) + { + this->SetVisibilityFlags(this->VisibilityFlags() & ~(_flags)); + } + + ////////////////////////////////////////////////// + template + void BaseVisual::SetVisibilityFlags(uint32_t _flags) + { + this->visibilityFlags = _flags; + + // recursively set child visuals' visibility flags + auto childNodes = + std::dynamic_pointer_cast>( + this->Children()); + if (!childNodes) + { + ignerr << "Cast failed in BaseVisual::SetVisibiltyFlags" << std::endl; + return; + } + for (auto it = childNodes->Begin(); it != childNodes->End(); ++it) + { + NodePtr child = it->second; + VisualPtr visual = std::dynamic_pointer_cast(child); + if (visual) + visual->SetVisibilityFlags(_flags); + } + } + + ////////////////////////////////////////////////// + template + uint32_t BaseVisual::VisibilityFlags() const + { + return this->visibilityFlags; + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseVisual::Clone(const std::string &_name, + NodePtr _newParent) const + { + ScenePtr scene_ = this->Scene(); + if (nullptr == scene_) + { + ignerr << "Cloning a visual failed because the visual to be cloned is " + << "not attached to a scene.\n"; + return nullptr; + } + VisualPtr result; + if (_name.empty()) + result = scene_->CreateVisual(); + else + result = scene_->CreateVisual(_name); + + if (nullptr != _newParent) + { + auto parentScene = _newParent->Scene(); + if (nullptr != parentScene && parentScene->Id() != scene_->Id()) + { + ignerr << "Cloning a visual failed because the desired parent of the " + << "cloned visual belongs to a different scene.\n"; + scene_->DestroyVisual(result); + return nullptr; + } + _newParent->AddChild(result); + } + + result->SetOrigin(this->Origin()); + result->SetInheritScale(this->InheritScale()); + result->SetLocalScale(this->LocalScale()); + result->SetLocalPose(this->LocalPose()); + result->SetVisibilityFlags(this->VisibilityFlags()); + result->SetWireframe(this->Wireframe()); + + // if the visual that was cloned has child visuals, clone those as well + auto children_ = + std::dynamic_pointer_cast>( + this->Children()); + if (!children_) + { + ignerr << "Cast failed in BaseVisual::Clone\n"; + scene_->DestroyVisual(result); + return nullptr; + } + for (auto it = children_->Begin(); it != children_->End(); ++it) + { + NodePtr child = it->second; + VisualPtr visual = std::dynamic_pointer_cast(child); + // recursively delete all cloned visuals if the child cannot be + // retrieved, or if cloning the child visual failed + if (!visual || !visual->Clone("", result)) + { + ignerr << "Cloning a child visual failed.\n"; + scene_->DestroyVisual(result, true); + return nullptr; + } + } + + for (unsigned int i = 0; i < this->GeometryCount(); ++i) + result->AddGeometry(this->GeometryByIndex(i)->Clone()); + + if (this->Material()) + result->SetMaterial(this->Material()); + + for (const auto &[key, val] : this->userData) + result->SetUserData(key, val); + + return result; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseWireBox.hh b/include/gz/rendering/base/BaseWireBox.hh new file mode 100644 index 000000000..db7fe12e9 --- /dev/null +++ b/include/gz/rendering/base/BaseWireBox.hh @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_BASE_WIREBOX_HH_ +#define IGNITION_RENDERING_BASE_WIREBOX_HH_ + +#include +#include "ignition/rendering/WireBox.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of a wireframe box. + template + class BaseWireBox : + public virtual WireBox, + public virtual T + { + /// \brief Constructor + protected: BaseWireBox(); + + /// \brief Destructor + public: virtual ~BaseWireBox(); + + // Documentation inherited. + public: virtual void PreRender(); + + // Documentation inherited. + public: virtual void Destroy(); + + // Documentation inherited. + public: virtual void SetBox(const ignition::math::AxisAlignedBox &_box); + + // Documentation inherited. + public: virtual ignition::math::AxisAlignedBox Box() const; + + // \brief Underlying axis aligned box that the wire box reflects. + protected: ignition::math::AxisAlignedBox box; + + /// \brief Flag to indicate WireBox properties have changed + protected: bool wireBoxDirty = false; + }; + + ////////////////////////////////////////////////// + // BaseWireBox + ////////////////////////////////////////////////// + template + BaseWireBox::BaseWireBox() + { + } + + ////////////////////////////////////////////////// + template + BaseWireBox::~BaseWireBox() + { + } + + ////////////////////////////////////////////////// + template + void BaseWireBox::PreRender() + { + T::PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseWireBox::Destroy() + { + T::Destroy(); + } + + ////////////////////////////////////////////////// + template + void BaseWireBox::SetBox(const ignition::math::AxisAlignedBox &_box) + { + this->box = _box; + this->wireBoxDirty = true; + } + + ////////////////////////////////////////////////// + template + ignition::math::AxisAlignedBox BaseWireBox::Box() const + { + return this->box; + } + } + } +} +#endif diff --git a/include/ignition/rendering/base/CMakeLists.txt b/include/gz/rendering/base/CMakeLists.txt similarity index 100% rename from include/ignition/rendering/base/CMakeLists.txt rename to include/gz/rendering/base/CMakeLists.txt diff --git a/include/gz/rendering/base/base.hh.in b/include/gz/rendering/base/base.hh.in new file mode 100644 index 000000000..c4092f0cd --- /dev/null +++ b/include/gz/rendering/base/base.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/include/ignition/rendering/config.hh.in b/include/gz/rendering/config.hh.in similarity index 93% rename from include/ignition/rendering/config.hh.in rename to include/gz/rendering/config.hh.in index fd052ebf6..0a74f1205 100644 --- a/include/ignition/rendering/config.hh.in +++ b/include/gz/rendering/config.hh.in @@ -24,3 +24,12 @@ #cmakedefine HAVE_OPTIX 1 #cmakedefine HAVE_GAZEBO 1 #cmakedefine INCLUDE_RTSHADER 1 + +namespace ignition +{ +} + +namespace gz +{ + using namespace ignition; +} diff --git a/include/gz/rendering/rendering.hh.in b/include/gz/rendering/rendering.hh.in new file mode 100644 index 000000000..2602ad19b --- /dev/null +++ b/include/gz/rendering/rendering.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +//#include +${ign_headers} diff --git a/include/ignition/rendering.hh b/include/ignition/rendering.hh new file mode 100644 index 000000000..c7494084f --- /dev/null +++ b/include/ignition/rendering.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/include/ignition/rendering/ArrowVisual.hh b/include/ignition/rendering/ArrowVisual.hh index 2f4696be8..b8fb951af 100644 --- a/include/ignition/rendering/ArrowVisual.hh +++ b/include/ignition/rendering/ArrowVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,52 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_ARROWVISUAL_HH_ -#define IGNITION_RENDERING_ARROWVISUAL_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/CompositeVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class ArrowVisual ArrowVisual.hh ignition/rendering/ArrowVisual.hh - /// \brief Represents a arrow composite visual - class IGNITION_RENDERING_VISIBLE ArrowVisual : - public virtual CompositeVisual - { - /// \brief Destructor - public: virtual ~ArrowVisual() { } - - /// \brief Get arrow-head visual - /// \return The arrow-head visual - public: virtual VisualPtr Head() const = 0; - - /// \brief Get arrow-shaft visual - /// \return The arrow-shaft visual - public: virtual VisualPtr Shaft() const = 0; - - /// \brief Get arrow-rotation visual - /// \return The arrow-rotation visual - public: virtual VisualPtr Rotation() const = 0; - - /// \brief set true to show the arrow head, false otherwise - /// \param[in] _b true to show the arrow head, false otherwise - public: virtual void ShowArrowHead(bool _b) = 0; - - /// \brief set true to show the arrow shaft, false otherwise - /// \param[in] _b true to show the arrow shaft, false otherwise - public: virtual void ShowArrowShaft(bool _b) = 0; - - /// \brief Set true to show the rotation of the arrow, false otherwise - /// \param[in] _b True to show the arrow rotation. - public: virtual void ShowArrowRotation(bool _b) = 0; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/AxisVisual.hh b/include/ignition/rendering/AxisVisual.hh index 57fe72853..58a952c7c 100644 --- a/include/ignition/rendering/AxisVisual.hh +++ b/include/ignition/rendering/AxisVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,36 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_AXISVISUAL_HH_ -#define IGNITION_RENDERING_AXISVISUAL_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/CompositeVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class AxisVisual AxisVisual.hh ignition/rendering/AxisVisual.hh - /// \brief Represents a axis composite visual - class IGNITION_RENDERING_VISIBLE AxisVisual : - public virtual CompositeVisual - { - /// \brief Destructor - public: virtual ~AxisVisual() { } - - /// \brief set true to show the axis heads, false otherwise - /// \param[in] _b true to show the axis heads, false otherwise - public: virtual void ShowAxisHead(bool _b) = 0; - - /// \brief set true to show the specified axis head, false otherwise - /// \param[in] _axis Axis index. 0: x, 1: y, 2: z - /// \param[in] _b true to show the specified axis head, false otherwise - public: virtual void ShowAxisHead(unsigned int _axis, bool _b) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/BoundingBox.hh b/include/ignition/rendering/BoundingBox.hh index 1337dc96e..9f9fe977e 100644 --- a/include/ignition/rendering/BoundingBox.hh +++ b/include/ignition/rendering/BoundingBox.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,113 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BOUNDINGBOX_HH_ -#define IGNITION_RENDERING_BOUNDINGBOX_HH_ -#include -#include -#include -#include - -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ -namespace rendering -{ -inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - class BoundingBoxPrivate; - - /// \brief 2D or 3D Bounding box. It stores the - /// position / orientation / size info of the box and its label - class IGNITION_RENDERING_VISIBLE BoundingBox - { - /// \brief Constructor - public: BoundingBox(); - - /// \brief Copy constructor - /// \param[in] _box BoundingBox to copy. - public: BoundingBox(const BoundingBox &_box); - - /// \brief Move constructor - /// \param[in] _box BoundingBox to move. - public: BoundingBox(BoundingBox &&_box) noexcept; - - /// \brief Destructor - public: virtual ~BoundingBox(); - - /// \brief Move assignment operator. - /// \param[in] _box Heightmap box to move. - /// \return Reference to this. - public: BoundingBox &operator=(BoundingBox &&_box); - - /// \brief Copy Assignment operator. - /// \param[in] _box The heightmap box to set values from. - /// \return *this - public: BoundingBox &operator=(const BoundingBox &_box); - - /// \brief Get the center of the bounding box. - /// \return The center of the bounding box, in (x,y,z) representation. - /// If this is a 2D bounding box, the z component should be ignored. - public: const math::Vector3d &Center() const; - - /// \brief Set the center of the bounding box. - /// \param[in] _center The center of the bounding box, in (x,y,z) - /// representation. If this is a 2D bounding box, the z component should be - /// ignored. - public: void SetCenter(const math::Vector3d &_center); - - /// \brief Get the size of the bounding box. - /// \return The size of the box (width, height, depth). If this is a 2D - /// bounding box, the depth should be ignored. - public: const math::Vector3d &Size() const; - - /// \brief Set the size of the bounding box. - /// \param[in] _size The size of the box (width, height, depth). If this is - /// a 2D bounding box, the depth should be ignored. - public: void SetSize(const math::Vector3d &_size); - - /// \brief Get the orientation of the bounding box. - /// \return The orientation of the bounding box, in camera coordinates. - public: const math::Quaterniond &Orientation() const; - - /// \brief Set the orientation of the bounding box. - /// \param[in] _orientation The orientation of the bounding box, in camera - /// coordinates. - public: void SetOrientation(const math::Quaterniond &_orientation); - - /// \brief Get the vertices of the 3D bounding box representation. - /// \return The vertices, in the following order: - /// - /// 1 -------- 0 - /// /| /| - /// 2 -------- 3 . - /// | | | | - /// . 5 -------- 4 - /// |/ |/ - /// 6 -------- 7 - public: const std::vector &Vertices3D() const; - - /// \brief Get the label of the bounding box. - /// \return The label of the bounding box. - public: uint32_t Label() const; - - /// \brief Set the label of the bounding box. - /// \param[in] _label The label of the bounding box. - public: void SetLabel(uint32_t _label); - - /// \internal - /// \brief Private data - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; -} -} -} -#endif +#include +#include diff --git a/include/ignition/rendering/BoundingBoxCamera.hh b/include/ignition/rendering/BoundingBoxCamera.hh index e0f88808e..8e0755035 100644 --- a/include/ignition/rendering/BoundingBoxCamera.hh +++ b/include/ignition/rendering/BoundingBoxCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,78 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BOUNDINGBOXCAMERA_HH_ -#define IGNITION_RENDERING_BOUNDINGBOXCAMERA_HH_ -#include -#include - -#include -#include -#include - -#include "ignition/rendering/BoundingBox.hh" -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief BoundingBox types for Visible / Full 2D Boxes / 3D Boxes - enum class BoundingBoxType - { - /// 2D box that shows the full box of occluded objects - BBT_FULLBOX2D = 0, - - /// 2D box that shows the visible part of the - /// occluded object - BBT_VISIBLEBOX2D = 1, - - /// 3D oriented box - BBT_BOX3D = 2 - }; - - /// \class BoundingBoxCamera BoundingBoxCamera.hh - /// ignition/rendering/BoundingBoxCamera.hh - /// \brief Poseable BoundingBox camera used for rendering bounding boxes of - /// objects in the scene. - class IGNITION_RENDERING_VISIBLE BoundingBoxCamera : - public virtual Camera - { - /// \brief Destructor - public: virtual ~BoundingBoxCamera() { } - - /// \brief Get the BoundingBox data - /// \return Buffer of bounding boxes info (label, minX, minY, maxX, maxY). - /// If the camera's bounding box type is 3D, minZ and maxZ are also - /// defined) - public: virtual const std::vector &BoundingBoxData() - const = 0; - - /// \brief Connect to the new BoundingBox info - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewBoundingBoxes( - std::function &)> _subscriber) = 0; - - /// \brief Set BoundingBox Type (Visible / Full) - /// \param[in] _type BoundingBox Type (Visible / Full) - public: virtual void SetBoundingBoxType(BoundingBoxType _type) = 0; - - /// \brief Get the BoundingBox Type (Visible / Full) - /// \return BoundingBox Type (Visible / Full) - public: virtual BoundingBoxType Type() const = 0; - - /// \brief Draw a bounding box on the given image - /// \param[in] _data buffer containing the image data - /// \param[in] _color Color of the bounding box to be drawn - /// \param[in] _box bounding box to be drawn - public: virtual void DrawBoundingBox(unsigned char *_data, - const math::Color &_color, const BoundingBox &_box) const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/COMVisual.hh b/include/ignition/rendering/COMVisual.hh index a0f811cba..aeb023f0e 100644 --- a/include/ignition/rendering/COMVisual.hh +++ b/include/ignition/rendering/COMVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,53 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_COMVISUAL_HH_ -#define IGNITION_RENDERING_COMVISUAL_HH_ -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - /// \class COMVisual COMVisual.hh - /// ignition/rendering/COMVisual.hh - /// \brief Represents a center of mass visual - class IGNITION_RENDERING_VISIBLE COMVisual : - public virtual Visual - { - /// \brief Destructor - public: virtual ~COMVisual() {} - - /// \brief Set the inertial component of the visual - /// \param[in] _inertial Inertial component of the visual - public: virtual void SetInertial( - const ignition::math::Inertiald &_inertial) = 0; - - /// \brief Set the mass of the parent - /// \param[in] _mass Parent mass - public: virtual void SetMass(double _mass) = 0; - - /// \brief Get the mass of the parent - /// \return Parent mass - public: virtual double Mass() const = 0; - - /// \brief Get the inertia pose - /// \return Inertia pose in parent frame. - public: virtual ignition::math::Pose3d InertiaPose() const = 0; - - /// \brief Get the sphere visual - /// \return Pointer to the sphere visual - public: virtual VisualPtr SphereVisual() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Camera.hh b/include/ignition/rendering/Camera.hh index f39108262..009827525 100644 --- a/include/ignition/rendering/Camera.hh +++ b/include/ignition/rendering/Camera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,331 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_CAMERA_HH_ -#define IGNITION_RENDERING_CAMERA_HH_ -#include - -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/Sensor.hh" -#include "ignition/rendering/Scene.hh" - - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Enum for projection types - enum IGNITION_RENDERING_VISIBLE CameraProjectionType - { - /// \brief Perspective projection - CPT_PERSPECTIVE, - /// \brief Orthographic projection - CPT_ORTHOGRAPHIC - }; - - /// \class Camera Camera.hh ignition/rendering/Camera.hh - /// \brief Posable camera used for rendering the scene graph - class IGNITION_RENDERING_VISIBLE Camera : - public virtual Sensor - { - /// \brief Callback function for new frame render event listeners - public: typedef std::function NewFrameListener; - - /// \brief Destructor - public: virtual ~Camera() { } - - /// \brief Get the image width in pixels - /// \return The image width in pixels - public: virtual unsigned int ImageWidth() const = 0; - - /// \brief Set the image width in pixels - /// \param[in] _width New image width in pixels - public: virtual void SetImageWidth(unsigned int _width) = 0; - - /// \brief Get the image height in pixels - /// \return The image height in pixels - public: virtual unsigned int ImageHeight() const = 0; - - /// \brief Set the image height in pixels - /// \param[in] _height New image height in pixels - public: virtual void SetImageHeight(unsigned int _height) = 0; - - /// \brief Get the image pixel format. If the image pixel format has not - /// been set with a valid value, PF_UNKNOWN will be returned. - /// \return The image pixel format - public: virtual PixelFormat ImageFormat() const = 0; - - /// \brief Set the image pixel format - /// \param[in] _format New image pixel format - public: virtual void SetImageFormat(PixelFormat _format) = 0; - - /// \brief Get the total image memory size in bytes - /// \return The image memory size in bytes - public: virtual unsigned int ImageMemorySize() const = 0; - - /// \brief Get the camera's horizontal field-of-view - /// \return Angle containing the camera's horizontal field-of-view - public: virtual math::Angle HFOV() const = 0; - - /// \brief Set the camera's horizontal field-of-view - /// \param[in] _hfov Desired horizontal field-of-view - public: virtual void SetHFOV(const math::Angle &_hfov) = 0; - - /// \brief Get the camera's aspect ratio - /// \return The camera's aspect ratio - public: virtual double AspectRatio() const = 0; - - /// \brief Set the camera's aspect ratio. This value determines the - /// cameras vertical field-of-view. It is often the \code image_height / - /// image_width \endcode but this is not necessarily true. - /// \return The camera's aspect ratio - public: virtual void SetAspectRatio(const double _ratio) = 0; - - // TODO(anyone): add auto-aspect ratio - - /// \brief Get the level of anti-aliasing used during rendering - /// \return The level of anti-aliasing used during rendering - public: virtual unsigned int AntiAliasing() const = 0; - - /// \brief Set the level of anti-aliasing used during rendering. If a - /// value of 0 is given, no anti-aliasing will be performed. Higher values - /// can significantly slow-down rendering times, depending on the - /// underlying render engine. - /// \param[in] _aa Level of anti-aliasing used during rendering - public: virtual void SetAntiAliasing(const unsigned int _aa) = 0; - - /// \brief Get the camera's far clipping plane distance - /// \return Far clipping plane distance - public: virtual double FarClipPlane() const = 0; - - /// \brief Set the camera's far clipping plane distance - /// \param[in] _far Far clipping plane distance - public: virtual void SetFarClipPlane(const double _far) = 0; - - /// \brief Get the camera's near clipping plane distance - /// \return Near clipping plane distance - public: virtual double NearClipPlane() const = 0; - - /// \brief Set the camera's near clipping plane distance - /// \param[in] _near Near clipping plane distance - public: virtual void SetNearClipPlane(const double _near) = 0; - - /// \brief Renders the current scene using this camera. This function - /// assumes PreRender() has already been called on the parent Scene, - /// allowing the camera and the scene itself to prepare for rendering. - public: virtual void Render() = 0; - - /// \brief Preforms any necessary final rendering work. Once rendering is - /// complete the camera will alert any listeners of the new frame event. - /// This function should only be called after a call to Render has - /// successfully been executed. - public: virtual void PostRender() = 0; - - /// \brief Get the visual for a given mouse position - /// param[in] _mousePos mouse position - // \return visual for that position, null if no visual was found - public: virtual VisualPtr VisualAt(const ignition::math::Vector2i - &_mousePos) = 0; - - /// \brief Renders a new frame. - /// This is a convenience function for single-camera scenes. It wraps the - /// pre-render, render, and post-render into a single - /// function. This should NOT be used in applications with multiple - /// cameras or multiple consumers of a single camera's images. - public: virtual void Update() = 0; - - /// \brief Created an empty image buffer for capturing images. The - /// resulting image will have sufficient memory allocated for subsequent - /// calls to this camera's Capture function. However, any changes to this - /// cameras properties may invalidate the condition. - /// \return A newly allocated Image for storing this cameras images - public: virtual Image CreateImage() const = 0; - - /// \brief Renders a new frame and writes the results to the given image. - /// This is a convenience function for single-camera scenes. It wraps the - /// pre-render, render, post-render, and get-image calls into a single - /// function. This should NOT be used in applications with multiple - /// cameras or multiple consumers of a single camera's images. - /// \param[out] _image Output image buffer - public: virtual void Capture(Image &_image) = 0; - - /// \brief Writes the last rendered image to the given image buffer. This - /// function can be called multiple times after PostRender has been - /// called, without rendering the scene again. Calling this function - /// before a single image has been rendered will have undefined behavior. - /// \param[out] _image Output image buffer - public: virtual void Copy(Image &_image) const = 0; - - /// \brief Writes the previously rendered frame to a file. This function - /// can be called multiple times after PostRender has been called, - /// without rendering the scene again. Calling this function before a - /// single image has been rendered will have undefined behavior. - /// \param[in] _name Name of the output file - public: virtual bool SaveFrame(const std::string &_name) = 0; - - /// \brief Subscribes a new listener to this camera's new frame event - /// \param[in] _listener New camera listener callback - public: virtual common::ConnectionPtr ConnectNewImageFrame( - NewFrameListener _listener) = 0; - - /// \brief Create a render window. - /// \return A pointer to the render window. - public: virtual RenderWindowPtr CreateRenderWindow() = 0; - - /// \brief Get the projection matrix for this camera - /// \return Camera projection matrix - public: virtual math::Matrix4d ProjectionMatrix() const = 0; - - /// \brief Get the view matrix for this camera - /// \return Camera view matrix - public: virtual math::Matrix4d ViewMatrix() const = 0; - - /// \brief Set the projection matrix for this camera. This overrides - /// the standard projection matrix computed based on camera parameters. - /// \param[in] _matrix Camera projection matrix - public: virtual void SetProjectionMatrix(const math::Matrix4d &_matrix) - = 0; - - /// \brief Get the projection type for this camera - /// \return Camera projection type - public: virtual CameraProjectionType ProjectionType() const = 0; - - /// \brief Set the projection type for this camera - /// This changes the projection matrix of the camera based on the camera - /// projection type. A custom projection matrix can be specified via - /// `SetProjectionMatrix` to override the provided one. To disable the - /// custom projection matrix, just call this function again with the - /// desired projection type. - /// \param[in] _type Camera projection type - /// \sa SetProjectionMatrix - public: virtual void SetProjectionType(CameraProjectionType _type) = 0; - - /// \brief Project point in 3d world space to 2d screen space - /// \param[in] _pt Point in 3d world space - /// \return Point in 2d screen space - public: virtual math::Vector2i Project(const math::Vector3d &_pt) const - = 0; - - /// \brief Set a node for camera to track. The camera will automatically - /// change its orientation to face the target being tracked. If null is - /// specified, tracking is disabled. In contrast to SetFollowTarget - /// the camera does not change its position when tracking is enabled. - /// \param[in] _target Target node to track - /// \param[in] _offset Track a point that is at an offset relative - /// to target. - /// \param[in] _worldFrame If true, the offset point to track will be - /// treated in world frame and its position relative to the target - /// node remains fixed regardless of the target node's rotation. Default - /// is false, which means the camera tracks the point in target node's - /// local frame. - public: virtual void SetTrackTarget(const NodePtr &_target, - const math::Vector3d &_offset = math::Vector3d::Zero, - const bool _worldFrame = false) = 0; - - /// \brief Get the target node being tracked - /// \return Target node being tracked. - public: virtual NodePtr TrackTarget() const = 0; - - /// \brief Set track offset. Camera will track a point that's at an - /// offset from the target node. The offset will be in the frame - /// that is specified at the time the track target is set. - /// \param[in] _offset Point offset to track - public: virtual void SetTrackOffset(const math::Vector3d &_offset) = 0; - - /// \brief Get the track offset vector in the frame specified at the time - /// the track target is set. - /// \return Point offset from target. - public: virtual math::Vector3d TrackOffset() const = 0; - - /// \brief Set track P Gain. Determines how fast the camera rotates - /// to look at the target node. Valid range: [0-1] - /// \param[in] _pGain P gain for camera tracking - public: virtual void SetTrackPGain(const double _pGain) = 0; - - /// \brief Get the camera track rotation P gain. - /// \return P gain for camera tracking - public: virtual double TrackPGain() const = 0; - - /// \brief Set a node for camera to follow. The camera will automatically - /// update its position to keep itself at the specified offset distance - /// from the target being followed. If null is specified, camera follow is - /// disabled. In contrast to SetTrackTarget, the camera does not change - /// its orientation when following is enabled. - /// \param[in] _target Target node to follow - /// \param[in] _offset Tether the camera at an offset distance from the - /// target node. - /// \param[in] _worldFrame True to follow the target node at a - /// distance that's fixed in world frame. Default is false which means - /// the camera follows at fixed distance in target node's local frame. - public: virtual void SetFollowTarget(const NodePtr &_target, - const math::Vector3d &_offset = math::Vector3d::Zero, - const bool _worldFrame = false) = 0; - - /// \brief Get the target node being followed - /// \return Target node being tracked. - public: virtual NodePtr FollowTarget() const = 0; - - /// \brief Set offset of camera from target node being followed. The - /// offset will be in the frame that is specified at the time the follow - /// target is set. - /// \param[in] _offset Offset distance from target node. - public: virtual void SetFollowOffset(const math::Vector3d &_offset) = 0; - - /// \brief Get the follow offset vector in the frame specified at the - /// time the follow target is set. - /// \return Offset of camera from target. - public: virtual math::Vector3d FollowOffset() const = 0; - - /// \brief Set follow P Gain. Determines how fast the camera moves - /// to follow the target node. Valid range: [0-1] - /// \param[in] _pGain P gain for camera following - public: virtual void SetFollowPGain(const double _pGain) = 0; - - /// \brief Get the camera follow movement P gain. - /// \return P gain for camera following - public: virtual double FollowPGain() const = 0; - - /// \brief Set a material that the camera should see on all objects - /// \param[in] _material a material instance - public: virtual void SetMaterial(const MaterialPtr &_material) = 0; - - /// \brief Get the OpenGL texture id associated with the render texture - /// used by this camera. A valid id is returned only if the underlying - /// render engine is OpenGL based. - /// \return Texture Id of type GLuint. - public: virtual unsigned int RenderTextureGLId() const = 0; - - /// \brief Add a render pass to the camera - /// \param[in] _pass New render pass to add - public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0; - - /// \brief Remove a render pass from the camera - /// \param[in] _pass render pass to remove - public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) = 0; - - /// \brief Get the number of render passes applied to the camera - /// \return Number of render passes applied - public: virtual unsigned int RenderPassCount() const = 0; - - /// \brief Get a render passes by index - /// \return Render pass at the specified index - public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) - const = 0; - - /// \internal - /// \brief Notify that shadows are dirty and need to be regenerated - public: virtual void SetShadowsDirty() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Capsule.hh b/include/ignition/rendering/Capsule.hh index 7423be1d7..1463ab4f5 100644 --- a/include/ignition/rendering/Capsule.hh +++ b/include/ignition/rendering/Capsule.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,39 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_CAPSULE_HH_ -#define IGNITION_RENDERING_CAPSULE_HH_ - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \class Capsule Capsule.hh ignition/rendering/Capsule - /// \brief Geometry for a capsule shape. - class IGNITION_RENDERING_VISIBLE Capsule : - public virtual Geometry - { - /// \brief Destructor - public: virtual ~Capsule() { } - - /// \brief Set the radius of the capsule - public: virtual void SetRadius(double _radius) = 0; - - /// \brief Set the length of the capsule - public: virtual void SetLength(double _length) = 0; - - /// \brief Get the radius of the capsule - public: virtual double Radius() const = 0; - - /// \brief Get the length of the capsule - public: virtual double Length() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/CompositeVisual.hh b/include/ignition/rendering/CompositeVisual.hh index 2813f7393..e64586d0a 100644 --- a/include/ignition/rendering/CompositeVisual.hh +++ b/include/ignition/rendering/CompositeVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_COMPOSITEVISUAL_HH_ -#define IGNITION_RENDERING_COMPOSITEVISUAL_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class CompositeVisual CompositeVisual.hh - /// ignition/rendering/CompositeVisual.hh - /// \brief Represents a predefined collection of geometries and visuals - class IGNITION_RENDERING_VISIBLE CompositeVisual : - public virtual Visual - { - /// \brief Destructor - public: virtual ~CompositeVisual() { } - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/DepthCamera.hh b/include/ignition/rendering/DepthCamera.hh index a70795458..ee904b7d1 100644 --- a/include/ignition/rendering/DepthCamera.hh +++ b/include/ignition/rendering/DepthCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,69 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_DEPTHCAMERA_HH_ -#define IGNITION_RENDERING_DEPTHCAMERA_HH_ -#include - -#include -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \class Camera Camera.hh ignition/rendering/Camera.hh - /// \brief Poseable depth camera used for rendering the scene graph. - /// This camera is designed to produced depth data, instead of a 2D - /// image. - class IGNITION_RENDERING_VISIBLE DepthCamera : - public virtual Camera - { - /// \brief Callback function for new frame render event listeners - public: typedef std::function NewFrameListener; - - /// \brief Destructor - public: virtual ~DepthCamera() { } - - /// \brief Create a texture which will hold the depth data - public: virtual void CreateDepthTexture() = 0; - - /// \brief All things needed to get back z buffer for depth data - /// \return The z-buffer as a float array - public: virtual const float *DepthData() const = 0; - - /// \brief Connect to the new depth image signal - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewDepthFrame( - std::function _subscriber) = 0; - - /// \brief Connect to the new rgb point cloud signal. - /// \param[in] _subscriber Subscriber callback function - /// The arguments of the callback function are: - /// _pointCloud Point cloud data. Each point is represented by four - /// 32 bit floating point values [X, Y, Z, RGBA]. The last - /// field can be decoded into 4 unsigned 8 bit color values: - /// uint32_t *rgba = reinterpret_cast(&_rgba) - /// r = static_cast(*rgba >> 24 & 0xFF); - /// g = static_cast(*rgba >> 16 & 0xFF); - /// b = static_cast(*rgba >> 8 & 0xFF); - /// a = static_cast(*rgba >> 0 & 0xFF); - /// _width Point cloud image width - /// _height Point cloud image height - /// _depth Point cloud image depth - /// _format Point cloud image format - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewRgbPointCloud( - std::function _subscriber) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/DistortionPass.hh b/include/ignition/rendering/DistortionPass.hh index c4d02221d..2edc28d9b 100644 --- a/include/ignition/rendering/DistortionPass.hh +++ b/include/ignition/rendering/DistortionPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,84 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_DISTORTIONPASS_HH_ -#define IGNITION_RENDERING_DISTORTIONPASS_HH_ -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/RenderPass.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class DistortionPass DistortionPass.hh \ - * ignition/rendering/DistortionPass.hh - */ - /// \brief A render pass that applies distortion to the render target - class IGNITION_RENDERING_VISIBLE DistortionPass - : public virtual RenderPass - { - /// \brief Constructor - public: DistortionPass(); - - /// \brief Destructor - public: virtual ~DistortionPass(); - - /// \brief Get the radial distortion coefficient k1. - /// \return Distortion coefficient k1. - public: virtual double K1() const = 0; - - /// \brief Get the radial distortion coefficient k2. - /// \return Distortion coefficient k2. - public: virtual double K2() const = 0; - - /// \brief Get the radial distortion coefficient k3. - /// \return Distortion coefficient k3. - public: virtual double K3() const = 0; - - /// \brief Get the tangential distortion coefficient p1. - /// \return Distortion coefficient p1. - public: virtual double P1() const = 0; - - /// \brief Get the tangential distortion coefficient p2. - /// \return Distortion coefficient p2. - public: virtual double P2() const = 0; - - /// \brief Get the distortion center. - /// \return Distortion center. - public: virtual math::Vector2d Center() const = 0; - - /// \brief Set the radial distortion coefficient k1. - /// \param[in] _k1 Distortion coefficient k1. - public: virtual void SetK1(double _k1) = 0; - - /// \brief Set the radial distortion coefficient k2. - /// \param[in] _k2 Distortion coefficient k1. - public: virtual void SetK2(double _k2) = 0; - - /// \brief Set the radial distortion coefficient k3. - /// \param[in] _k3 Distortion coefficient k1. - public: virtual void SetK3(double _k3) = 0; - - /// \brief Set the tangential distortion coefficient p1. - /// \param[in] _p1 Distortion coefficient k1. - public: virtual void SetP1(double _p1) = 0; - - /// \brief Set the tangential distortion coefficient p2. - /// \param[in] _p2 Distortion coefficient k1. - public: virtual void SetP2(double _p2) = 0; - - /// \brief Set the distortion center. - /// \param[in] _center Distortion center. - public: virtual void SetCenter(const math::Vector2d &_center) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Export.hh b/include/ignition/rendering/Export.hh new file mode 100644 index 000000000..d6119ebf2 --- /dev/null +++ b/include/ignition/rendering/Export.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/include/ignition/rendering/GaussianNoisePass.hh b/include/ignition/rendering/GaussianNoisePass.hh index efb3cc7f8..6e296ef88 100644 --- a/include/ignition/rendering/GaussianNoisePass.hh +++ b/include/ignition/rendering/GaussianNoisePass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,64 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GAUSSIANNOISEPASS_HH_ -#define IGNITION_RENDERING_GAUSSIANNOISEPASS_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/RenderPass.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class GaussianNoisePass GaussianNoisePass.hh \ - * ignition/rendering/GaussianNoisePass.hh - */ - /// \brief A render pass that applies Gaussian noise to the render target - class IGNITION_RENDERING_VISIBLE GaussianNoisePass - : public virtual RenderPass - { - /// \brief Constructor - public: GaussianNoisePass(); - - /// \brief Destructor - public: virtual ~GaussianNoisePass(); - - /// \brief Accessor for mean. - /// \return Mean of Gaussian noise. - public: virtual double Mean() const = 0; - - /// \brief Accessor for stddev. - /// \return Standard deviation of Gaussian noise. - public: virtual double StdDev() const = 0; - - /// \brief Accessor for bias. - /// \return Bias on output. - public: virtual double Bias() const = 0; - - /// \brief Set mean. - /// \param[in] _mean Mean of Gaussian noise. - public: virtual void SetMean(double _mean) = 0; - - /// \brief Set stddev. - /// \param[in] _stdDev Standard deviation of Gaussian noise. - public: virtual void SetStdDev(double _stdDev) = 0; - - /// \brief Set the mean of the bias value. Bias is computed based on - /// the bias mean and bias standard deviation. - /// \sa SetBiasStdDev - public: virtual void SetBiasMean(double _biasMean) = 0; - - /// \brief Set the standard deviation of the bias value. Bias is computed - /// based on the bias mean and bias standard deviation. - /// \sa SetBiasMean - public: virtual void SetBiasStdDev(double _biasStdDev) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Geometry.hh b/include/ignition/rendering/Geometry.hh index d841eaf52..185a2afe3 100644 --- a/include/ignition/rendering/Geometry.hh +++ b/include/ignition/rendering/Geometry.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,65 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GEOMETRY_HH_ -#define IGNITION_RENDERING_GEOMETRY_HH_ -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Geometry Geometry.hh ignition/rendering/Geometry.hh - /// \brief Represents a geometric shape to be rendered - class IGNITION_RENDERING_VISIBLE Geometry : - public virtual Object - { - /// \brief Destructor - public: virtual ~Geometry() { } - - /// \brief Determine if this Geometry is attached to a Visual - /// \return True if this Geometry has a parent Visual - public: virtual bool HasParent() const = 0; - - /// \brief Get the parent Visual - /// \return the parent Visual - public: virtual VisualPtr Parent() const = 0; - - /// \brief Detach this Geometry from its parent Visual. If this - /// Geometry does not have a parent, no work will be done. - public: virtual void RemoveParent() = 0; - - /// \brief Set the materials of this Geometry. The specified material - /// will be retrieved from the parent Scene. If no material is registered - /// by the given name, no work will be done. - /// \param[in] _name Name of registered Material - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetMaterial(const std::string &_name, - bool _unique = true) = 0; - - /// \brief Set the materials of this Geometry - /// \param[in] _material New Material to be assigned - /// \param[in] _unique True if the given material should be cloned - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true) = 0; - - /// \brief Get the material of this geometry - /// \return Material used by this geometry - public: virtual MaterialPtr Material() const = 0; - - /// \brief Clone the geometry. - /// \return The cloned geometry. - public: virtual GeometryPtr Clone() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/GizmoVisual.hh b/include/ignition/rendering/GizmoVisual.hh index ed50a664f..040a54a40 100644 --- a/include/ignition/rendering/GizmoVisual.hh +++ b/include/ignition/rendering/GizmoVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,63 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GIZMOVISUAL_HH_ -#define IGNITION_RENDERING_GIZMOVISUAL_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/CompositeVisual.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/TransformType.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class GizmoVisual GizmoVisual.hh ignition/rendering/GizmoVisual.hh - /// \brief A gizmo that contains rotate, translate, and scale visuals - class IGNITION_RENDERING_VISIBLE GizmoVisual : - public virtual CompositeVisual - { - /// \brief Destructor - public: virtual ~GizmoVisual() { } - - /// \brief Set the transform mode of the gizmo. This controls the visual - /// appearance of the gizmo. Only the visuals in the specified mode will - /// be visible, e.g. if set to TM_TRANSLATION mode, then only the - /// translation axis visuals will be visible. - /// \param[in] _mode Transform mode to set the gizmo to - /// \sa GizmoMode - public: virtual void SetTransformMode(TransformMode _mode) = 0; - - /// \brief Get the current transform mode. - /// \return Transform mode - /// \sa SetTransformMode - public: virtual TransformMode Mode() const = 0; - - /// \brief Set the active axis in the gizmo visual - /// \param[in] _axis Axis to be set active - public: virtual void SetActiveAxis(const math::Vector3d &_axis) = 0; - - /// \brief Get the current active axis. - /// \return Active axis - /// \sa SetActiveAxis - public: virtual math::Vector3d ActiveAxis() const = 0; - - /// \brief Get the Transform axis associated with the given id. - /// \param[in] _id Id of the visual associated with a transform axis - /// \return Transform axis with the given id - public: virtual TransformAxis AxisById(unsigned int _id) const = 0; - - /// \brief Get the child visual by axis - /// \return Visual representing the specified transform axis or transform - /// mode - /// \sa TransformAxis, TransformMode - public: virtual VisualPtr ChildByAxis(unsigned int _axis) const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/GpuRays.hh b/include/ignition/rendering/GpuRays.hh index 242eba088..2ac4b0b29 100644 --- a/include/ignition/rendering/GpuRays.hh +++ b/include/ignition/rendering/GpuRays.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,184 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GPURAYS_HH_ -#define IGNITION_RENDERING_GPURAYS_HH_ -#include - -#include - -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/Sensor.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class GpuRays GpuRays.hh ignition/rendering/GpuRays.hh - /// \brief Generate depth ray data. - class IGNITION_RENDERING_VISIBLE GpuRays : - public virtual Camera - { - /// \brief Callback function for new frame render event listeners - public: typedef std::function NewFrameListener; - - /// \brief Destructor - public: virtual ~GpuRays() { } - - /// \brief All things needed to get back z buffer for gpu rays data. - /// \return Array of gpu rays data. - public: virtual const float *Data() const = 0; - - /// \brief Copy to the specified memory direction the gpu rays data. - public: virtual void Copy(float *_data) = 0; - - /// \brief Configure behaviour for data values outside of camera range - /// \param[in] _clamp True to clamp data to camera clip distances, - // false to leave data values as +/-inf when out of camera range - public: virtual void SetClamp(const bool _clamp) = 0; - - /// \brief Get behaviour for data values outside of camera range - /// \return True if data values are clampped to camera clip distances, - // false if data values outside of camera range are returned as +/-inf - public: virtual bool Clamp() const = 0; - - /// \brief Connect to a gpu rays frame signal - /// \param[in] _subscriber Callback that is called when a new image is - /// generated. The callback function parameters are: - /// _frame: Image frame is an array of floats. Size is equal - /// to width * height * channels - /// Each gpu rays reading occupies 3 floats - /// Index 0: depth value - /// Index 1: retro value - /// Index 2: 0. Not used - /// _width: Width of image, i.e. number of data in the horizonal scan - /// _height: Height o image, i.e. number of scans in vertical direction - /// _channels: Number of channels, i.e. 3 floats per gpu rays reading - /// _format: Pixel format of the image frame. - /// \return A pointer to the connection. This must be kept in scope. - public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( - std::function _subscriber) = 0; - - /// \brief Set sensor horizontal or vertical - /// \param[in] _horizontal True if horizontal, false if not - public: virtual void SetIsHorizontal(const bool _horizontal) = 0; - - /// \brief Gets if sensor is horizontal - /// \return True if horizontal, false if not - public: virtual bool IsHorizontal() const = 0; - - /// \brief Get the vertical field-of-view. - /// \return The vertical field of view of the gpu rays. - public: virtual math::Angle VFOV() const = 0; - - /// \brief Get the ray count ratio (equivalent to aspect ratio) - /// \return The ray count ratio (equivalent to aspect ratio) - public: virtual double RayCountRatio() const = 0; - - /// \brief Get the ray count ratio (equivalent to aspect ratio) - /// \return The ray count ratio (equivalent to aspect ratio) - public: virtual double RangeCountRatio() const = 0; - - /// \brief Sets the ray count ratio (equivalent to aspect ratio) - /// \param[in] _rayCountRatio ray count ratio (equivalent to aspect ratio) - public: virtual void SetRayCountRatio(const double _rayCountRatio) = 0; - - /// \brief Get minimal horizontal angle value - // \return minimal horizontal angle value - public: virtual ignition::math::Angle AngleMin() const = 0; - - /// \brief Set minimal horizontal angle value - public: virtual void SetAngleMin(double _angle) = 0; - - /// \brief Get maximal horizontal angle value - // \return maximal horizontal angle value - public: virtual ignition::math::Angle AngleMax() const = 0; - - /// \brief Set maximal horizontal angle value - public: virtual void SetAngleMax(double _angle) = 0; - - /// \brief Get horizontal quantity of rays - // \return horizontal quantity of rays - public: virtual int RayCount() const = 0; - - /// \brief Set horizontal quantity of rays - public: virtual void SetRayCount(int _samples) = 0; - - /// \brief Get hoizontal range count, i.e. ray count * horz resolution - // \return horizontal range count - public: virtual int RangeCount() const = 0; - - /// \brief Get vertical quantity of rays - // \return vertical quantity of rays - public: virtual int VerticalRayCount() const = 0; - - /// \brief Set vertical quantity of rays - public: virtual void SetVerticalRayCount(int _samples) = 0; - - /// \brief Get vertical range count, i.e. ray count * vert resolution - // \return Vertical range count - public: virtual int VerticalRangeCount() const = 0; - - /// \brief Get minimal vertical angle value - // \return minimal vertical angle value - public: virtual ignition::math::Angle VerticalAngleMin() const = 0; - - /// \brief Set minimal vertical angle value - public: virtual void SetVerticalAngleMin(const double _angle) = 0; - - /// \brief Get maximal vertical angle value - // \return maximal vertical angle value - public: virtual ignition::math::Angle VerticalAngleMax() const = 0; - - /// \brief Set maximal vertical angle value - // \return minimal vertical angle value - public: virtual void SetVerticalAngleMax(const double _angle) = 0; - - /// \brief Get the number of channels used to store the ray data. - /// \return Channel count. - public: virtual unsigned int Channels() const = 0; - - /// \brief Set the horizontal resolution. This number is multiplied by - /// RayCount to calculate RangeCount, which is the the number range data - /// points. - /// \sa RayCount() - /// \param[in] _resolution The new horizontal resolution. The - /// absolute value of this parameter is used to prevent a - /// negative resolution value. - public: virtual void SetHorizontalResolution(double _resolution) = 0; - - /// \brief Get the horizontal resolution. This number is multiplied by - /// RayCount to calculate RangeCount, which is the the number range data - /// points. - /// \sa RayCount() - /// \return The horizontal resolution - public: virtual double HorizontalResolution() const = 0; - - /// \brief Set the vertical resolution. This number is multiplied by - /// VerticalRayCount to calculate VerticalRangeCount, which is the the - /// number vertical range data points. - /// \param[in] _resolution The new vertical resolution. The - /// absolute value of this parameter is used to prevent a - /// negative resolution value. - /// \sa VerticalRayCount() - public: virtual void SetVerticalResolution(double _resolution) = 0; - - /// \brief Get the vertical resolution. This number is multiplied by - /// VerticalRayCount to calculate VerticalRangeCount, which is the the - /// number vertical range data points. - /// \return The vertical resolution. - /// \sa VerticalRayCount() - public: virtual double VerticalResolution() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/GraphicsAPI.hh b/include/ignition/rendering/GraphicsAPI.hh index 505e4019d..c400a81fe 100644 --- a/include/ignition/rendering/GraphicsAPI.hh +++ b/include/ignition/rendering/GraphicsAPI.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,66 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GRAPHICSAPI_HH_ -#define IGNITION_RENDERING_GRAPHICSAPI_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - /// \brief The graphics API used by the render engine - enum class IGNITION_RENDERING_VISIBLE GraphicsAPI : uint16_t - { - /// \internal - /// \brief Indicator used to create an iterator over the - /// enum. Do not use this. - GRAPHICS_API_BEGIN = 0, - - /// \brief Unknown graphics interface - UNKNOWN = GRAPHICS_API_BEGIN, - - /// \brief OpenGL graphics interface - OPENGL = 1, - - /// \brief Direct3D11 graphics interface - DIRECT3D11 = 2, - - /// \brief Vulkan graphics interface - VULKAN = 3, - - /// \brief Metal graphics interface - METAL = 4, - - /// \internal - /// \brief Indicator used to create an iterator over the - /// enum. Do not use this. - GRAPHICS_API_END - }; - - /// \brief Utils to convert GraphicsAPI to and from strings - class IGNITION_RENDERING_VISIBLE GraphicsAPIUtils - { - /// \brief Convert enum value to string. - /// \param[in] _e Enum value to convert. - /// \return String representation of the enum. An empty string is - /// returned if _e is invalid, or the names for the enum have not been - /// set. - public: static std::string Str(GraphicsAPI _e); - - /// \brief Set an enum from a string. This function requires a valid - /// string, and an array of names for the enum must exist. - /// The string is not case sensitive. - /// \param[in] _str String value to convert to enum value. - /// \return GraphicsAPI enum - public: static GraphicsAPI Set(const std::string &_str); - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Grid.hh b/include/ignition/rendering/Grid.hh index e4f95969d..4f77236cc 100644 --- a/include/ignition/rendering/Grid.hh +++ b/include/ignition/rendering/Grid.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,56 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GRID_HH_ -#define IGNITION_RENDERING_GRID_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Grid Grid.hh ignition/rendering/Grid - /// \brief Represents a grid geometry drawn along the XY plane. - /// If vertical cell count is specified then the grid becomes 3D. - class IGNITION_RENDERING_VISIBLE Grid : - public virtual Geometry - { - /// \brief Destructor - public: virtual ~Grid() { } - - /// \brief Set the number of cells on a planar grid - /// \param[in] _count The number of cells - public: virtual void SetCellCount(const unsigned int _count) = 0; - - /// \brief Get the number of cells on a planar grid - /// \return Number of cells - public: virtual unsigned int CellCount() const = 0; - - /// \brief Set the cell length in one direction. - /// The cells are assumed to be square. - /// \param[in] _len The cell length - public: virtual void SetCellLength(const double _len) = 0; - - /// \brief Get the cell length - /// \return The cell length - public: virtual double CellLength() const = 0; - - /// \brief Set the vertical cell count of the grid. This makes the grid 3D - /// \param[in] _count Number of cells in vertical direction. - public: virtual void SetVerticalCellCount(const unsigned int _count) = 0; - - /// \brief Get the vertical cell count - /// \return The vertical cell count. - public: virtual unsigned int VerticalCellCount() const = 0; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/Heightmap.hh b/include/ignition/rendering/Heightmap.hh index dbd818b68..c1b2270a6 100644 --- a/include/ignition/rendering/Heightmap.hh +++ b/include/ignition/rendering/Heightmap.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_HEIGHTMAP_HH_ -#define IGNITION_RENDERING_HEIGHTMAP_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/HeightmapDescriptor.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Heightmap Heightmap.hh ignition/rendering/Heightmap - /// \brief A terrain defined by a heightfield. - class Heightmap : - public virtual Geometry - { - /// \brief Get the immutable heightmap descriptor. - /// \return Descriptor with heightmap information. - public: virtual const HeightmapDescriptor &Descriptor() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/HeightmapDescriptor.hh b/include/ignition/rendering/HeightmapDescriptor.hh index 2717554c2..4384c009b 100644 --- a/include/ignition/rendering/HeightmapDescriptor.hh +++ b/include/ignition/rendering/HeightmapDescriptor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,249 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_HEIGHTMAPDESCRIPTOR_HH_ -#define IGNITION_RENDERING_HEIGHTMAPDESCRIPTOR_HH_ -#include -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ -namespace rendering -{ -inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - class HeightmapDescriptorPrivate; - class HeightmapTexturePrivate; - class HeightmapBlendPrivate; - - /// \brief Texture to be used on heightmaps. - class IGNITION_RENDERING_VISIBLE HeightmapTexture - { - /// \brief Constructor - public: HeightmapTexture(); - - /// \brief Copy constructor - /// \param[in] _texture HeightmapTexture to copy. - public: HeightmapTexture(const HeightmapTexture &_texture); - - /// \brief Move constructor - /// \param[in] _texture HeightmapTexture to move. - public: HeightmapTexture(HeightmapTexture &&_texture) noexcept; - - /// \brief Destructor - public: virtual ~HeightmapTexture(); - - /// \brief Move assignment operator. - /// \param[in] _texture Heightmap texture to move. - /// \return Reference to this. - public: HeightmapTexture &operator=(HeightmapTexture &&_texture); - - /// \brief Copy Assignment operator. - /// \param[in] _texture The heightmap texture to set values from. - /// \return *this - public: HeightmapTexture &operator=(const HeightmapTexture &_texture); - - /// \brief Get the heightmap texture's size. - /// \return The size of the heightmap texture in meters. - public: double Size() const; - - /// \brief Set the size of the texture in meters. - /// \param[in] _size The size of the texture in meters. - public: void SetSize(double _size); - - /// \brief Get the heightmap texture's diffuse map. - /// \return The diffuse map of the heightmap texture. - public: std::string Diffuse() const; - - /// \brief Set the filename of the diffuse map. - /// \param[in] _diffuse The diffuse map of the heightmap texture. - public: void SetDiffuse(const std::string &_diffuse); - - /// \brief Get the heightmap texture's normal map. - /// \return The normal map of the heightmap texture. - public: std::string Normal() const; - - /// \brief Set the filename of the normal map. - /// \param[in] _normal The normal map of the heightmap texture. - public: void SetNormal(const std::string &_normal); - - /// \brief Private data pointer. - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - - /// \brief Blend information to be used between textures on heightmaps. - class IGNITION_RENDERING_VISIBLE HeightmapBlend - { - /// \brief Constructor - public: HeightmapBlend(); - - /// \brief Copy constructor - /// \param[in] _blend HeightmapBlend to copy. - public: HeightmapBlend(const HeightmapBlend &_blend); - - /// \brief Move constructor - /// \param[in] _blend HeightmapBlend to move. - public: HeightmapBlend(HeightmapBlend &&_blend) noexcept; - - /// \brief Destructor - public: virtual ~HeightmapBlend(); - - /// \brief Move assignment operator. - /// \param[in] _blend Heightmap blend to move. - /// \return Reference to this. - public: HeightmapBlend &operator=(HeightmapBlend &&_blend); - - /// \brief Copy Assignment operator. - /// \param[in] _blend The heightmap blend to set values from. - /// \return *this - public: HeightmapBlend &operator=(const HeightmapBlend &_blend); - - /// \brief Get the heightmap blend's minimum height. - /// \return The minimum height of the blend layer. - public: double MinHeight() const; - - /// \brief Set the minimum height of the blend in meters. - /// \param[in] _minHeight The minimum height of the blend in meters. - public: void SetMinHeight(double _minHeight); - - /// \brief Get the heightmap blend's fade distance. - /// \return The fade distance of the heightmap blend in meters. - public: double FadeDistance() const; - - /// \brief Set the distance over which the blend occurs. - /// \param[in] _fadeDistance The distance in meters. - public: void SetFadeDistance(double _fadeDistance); - - /// \brief Private data pointer. - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - - /// \class HeightmapDescriptor HeightmapDescriptor.hh - /// ignition/rendering/HeightmapDescriptor.hh - /// \brief Describes how a Heightmap should be loaded - class IGNITION_RENDERING_VISIBLE HeightmapDescriptor - { - /// \brief Constructor - public: HeightmapDescriptor(); - - /// \brief Copy constructor - /// \param[in] _desc HeightmapDescriptor to copy. - public: HeightmapDescriptor(const HeightmapDescriptor &_desc); - - /// \brief Move constructor - /// \param[in] _desc HeightmapDescriptor to move. - public: HeightmapDescriptor(HeightmapDescriptor &&_desc) noexcept; - - /// \brief Destructor - public: virtual ~HeightmapDescriptor(); - - /// \brief Move assignment operator. - /// \param[in] _desc HeightmapDescriptor to move. - /// \return Reference to this. - public: HeightmapDescriptor &operator=(HeightmapDescriptor &&_desc); - - /// \brief Copy Assignment operator. - /// \param[in] _desc The heightmap to set values from. - /// \return *this - public: HeightmapDescriptor &operator=(const HeightmapDescriptor &_desc); - - /// \brief Get the heightmap's name used for caching. - /// This is different from its unique `Heightmap::Name()`. - /// \return Heightmap's given name. Defaults to `Heightmap::Name()`. - public: const std::string &Name() const; - - /// \brief Set the heightmap's name. - /// \param[in] _name Heightmap's name. - public: void SetName(const std::string &_name); - - /// \brief Get the heightfield data. - /// \return Heightmap data. - public: std::shared_ptr Data() const; - - /// \brief Set the heightfield data. - /// \param[in] _data New data. - public: void SetData(const std::shared_ptr &_data); - - /// \brief Get the heightmap's scaling factor. - /// \return The heightmap's size. - public: ignition::math::Vector3d Size() const; - - /// \brief Set the heightmap's scaling factor. Defaults to 1x1x1. - /// \return The heightmap's size factor. - public: void SetSize(const ignition::math::Vector3d &_size); - - /// \brief Get the heightmap's position offset. - /// \return The heightmap's position offset. - public: ignition::math::Vector3d Position() const; - - /// \brief Set the heightmap's position offset. - /// \return The heightmap's position offset. - public: void SetPosition(const ignition::math::Vector3d &_position); - - /// \brief Get whether the heightmap uses terrain paging. - /// \return True if the heightmap uses terrain paging. - public: bool UseTerrainPaging() const; - - /// \brief Set whether the heightmap uses terrain paging. Defaults to false. - /// \param[in] _use True to use. - public: void SetUseTerrainPaging(bool _use); - - /// \brief Get the heightmap's sampling per datum. - /// \return The heightmap's sampling. - public: unsigned int Sampling() const; - - /// \brief Set the heightmap's sampling. Defaults to 1. - /// \param[in] _sampling The heightmap's sampling per datum. - public: void SetSampling(unsigned int _sampling); - - /// \brief Get the number of heightmap textures. - /// \return Number of heightmap textures contained in this Heightmap object. - public: uint64_t TextureCount() const; - - /// \brief Get a heightmap texture based on an index. - /// \param[in] _index Index of the heightmap texture. The index should be in - /// the range [0..TextureCount()). - /// \return Pointer to the heightmap texture. Nullptr if the index does not - /// exist. - /// \sa uint64_t TextureCount() const - public: const HeightmapTexture *TextureByIndex(uint64_t _index) const; - - /// \brief Add a heightmap texture. - /// \param[in] _texture Texture to add. - public: void AddTexture(const HeightmapTexture &_texture); - - /// \brief Get the number of heightmap blends. - /// \return Number of heightmap blends contained in this Heightmap object. - public: uint64_t BlendCount() const; - - /// \brief Get a heightmap blend based on an index. - /// \param[in] _index Index of the heightmap blend. The index should be in - /// the range [0..BlendCount()). - /// \return Pointer to the heightmap blend. Nullptr if the index does not - /// exist. - /// \sa uint64_t BlendCount() const - public: const HeightmapBlend *BlendByIndex(uint64_t _index) const; - - /// \brief Add a heightmap blend. - /// \param[in] _blend Blend to add. - public: void AddBlend(const HeightmapBlend &_blend); - - /// \internal - /// \brief Private data - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; -} -} -} -#endif +#include +#include diff --git a/include/ignition/rendering/Image.hh b/include/ignition/rendering/Image.hh index d1c10652d..c618e023a 100644 --- a/include/ignition/rendering/Image.hh +++ b/include/ignition/rendering/Image.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,112 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_IMAGE_HH_ -#define IGNITION_RENDERING_IMAGE_HH_ -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Image Image.hh ignition/rendering/Image.hh - /// \brief Encapsulates a raw image buffer and relevant properties - class IGNITION_RENDERING_VISIBLE Image - { - /// \brief Shared pointer to raw image buffer - typedef std::shared_ptr DataPtr; - - /// \brief Default constructor - public: Image() = default; - - /// \brief Constructor - /// \param[in] _width Image width in pixels - /// \param[in] _height Image height in pixels - /// \param[in] _format Image pixel format - public: Image(unsigned int _width, unsigned int _height, - PixelFormat _format); - - /// \brief Destructor - public: ~Image(); - - /// \brief Get image width in pixels - /// \return The image width in pixels - public: unsigned int Width() const; - - /// \brief Get image height in pixels - /// \return The image height in pixels - public: unsigned int Height() const; - - /// \brief Get image pixel format - /// \return The image pixel format - public: PixelFormat Format() const; - - /// \brief Get image channel depth - /// \return The image channel depth - public: unsigned int Depth() const; - - /// \brief Get image channel depth - /// \return The image channel depth - public: unsigned int MemorySize() const; - - /// \brief Get a const pointer to image data - /// \return The const pointer to image data - public: const void *Data() const; - - /// \brief Get a pointer to image data - /// \return The pointer to image data - public: void *Data(); - - /// \brief Get a const pointer to image data. The returned image buffer - /// will be statically cast to the given template type T. - /// \return The const pointer to image data - public: template - const T *Data() const; - - /// \brief Get a pointer to image data. The returned image buffer will be - /// statically cast to the given template type T. - /// \return The pointer to image data - public: template - T *Data(); - - /// \brief Image width in pixels - private: unsigned int width = 0; - - /// \brief Image height in pixels - private: unsigned int height = 0; - - /// \brief Image pixel format - private: PixelFormat format = PF_UNKNOWN; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Pointer to the image data - private: DataPtr data = nullptr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - - ////////////////////////////////////////////////// - template - const T *Image::Data() const - { - return static_cast(this->data.get()); - } - - ////////////////////////////////////////////////// - template - T *Image::Data() - { - return static_cast(this->data.get()); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/InertiaVisual.hh b/include/ignition/rendering/InertiaVisual.hh index 2b233aef0..98cbc7b31 100644 --- a/include/ignition/rendering/InertiaVisual.hh +++ b/include/ignition/rendering/InertiaVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,46 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_INERTIAVISUAL_HH_ -#define IGNITION_RENDERING_INERTIAVISUAL_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - /// \class InertiaVisual InertiaVisual.hh - /// ignition/rendering/InertiaVisual.hh - /// \brief Represents a inertia visual - class IGNITION_RENDERING_VISIBLE InertiaVisual : - public virtual Visual - { - /// \brief Destructor - public: virtual ~InertiaVisual() {} - - /// \brief Set the inertial component of the visual - /// \param[in] _inertial Inertial component of the visual - public: virtual void SetInertial( - const ignition::math::Inertiald &_inertial) = 0; - - /// \brief Load the Inertia visual from its pose and scale - /// \param[in] _pose Pose of the Inertia visual - /// \param[in] _scale Scale factor of the box visual - public: virtual void Load(const ignition::math::Pose3d &_pose, - const ignition::math::Vector3d &_scale) = 0; - - /// \brief Get the box visual - /// \return Pointer to the box visual - public: virtual VisualPtr BoxVisual() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/JointVisual.hh b/include/ignition/rendering/JointVisual.hh index d0cb89664..e46e8894e 100644 --- a/include/ignition/rendering/JointVisual.hh +++ b/include/ignition/rendering/JointVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,125 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_JOINTVISUAL_HH_ -#define IGNITION_RENDERING_JOINTVISUAL_HH_ -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Enum for JointVisual types - enum IGNITION_RENDERING_VISIBLE JointVisualType - { - /// \brief No type - JVT_NONE = 0, - - /// \brief Revolute joint type - JVT_REVOLUTE = 1, - - /// \brief Revolute2 joint type - JVT_REVOLUTE2 = 2, - - /// \brief Prismatic joint type - JVT_PRISMATIC = 3, - - /// \brief Universal joint type - JVT_UNIVERSAL = 4, - - /// \brief Ball joint type - JVT_BALL = 5, - - /// \brief Screw joint type - JVT_SCREW = 6, - - /// \brief Gearbox joint type - JVT_GEARBOX = 7, - - /// \brief Fixed joint type - JVT_FIXED = 8 - }; - - /// \class JointVisual JointVisual.hh - /// ignition/rendering/JointVisual.hh - /// \brief Represents a joint visual - class IGNITION_RENDERING_VISIBLE JointVisual : - public virtual Visual - { - /// \brief Destructor - public: virtual ~JointVisual() {} - - /// \brief Create an axis and attach it to the joint visual. - /// \param[in] _axis Axis vector. - /// \param[in] _useParentFrame True if axis vector is expressed in - /// parent frame. - public: virtual void SetAxis(const ignition::math::Vector3d &_axis, - bool _useParentFrame = false) = 0; - - /// \brief Get axis vector. - /// \return The axis vector. - public: virtual ignition::math::Vector3d Axis() const = 0; - - /// \brief Create a parent axis for hinge2 and universal joint types - /// and attach it to the joint visual. - /// \param[in] _axis Axis vector. - /// \param[in] _parentName Joint parent name. - /// \param[in] _useParentFrame True if axis vector is expressed in - /// parent frame. - public: virtual void SetParentAxis( - const ignition::math::Vector3d &_axis, - const std::string &_parentName, - bool _useParentFrame = false) = 0; - - /// \brief Get parent axis vector. - /// \return The parent axis vector. - public: virtual ignition::math::Vector3d ParentAxis() const = 0; - - /// \brief Update an axis' arrow visual. - /// \param[in] _axis Axis vector. - /// \param[in] _useParentFrame True if axis vector is expressed in - /// parent frame. - /// \return True if axis was updated else false. - public: virtual bool UpdateAxis(const ignition::math::Vector3d &_axis, - bool _useParentFrame = false) = 0; - - /// \brief Update the parent axis' arrow visual if it exists. - /// \param[in] _axis Axis vector. - /// \param[in] _useParentFrame True if axis vector is expressed in - /// parent frame. - /// \return True if parent axis was updated else false. - public: virtual bool UpdateParentAxis( - const ignition::math::Vector3d &_axis, - bool _useParentFrame = false) = 0; - - /// \brief Set type for joint visual. - /// \param[in] _type The type of visualisation for joint. - public: virtual void SetType(const JointVisualType _type) = 0; - - /// \brief Get joint visual type. - /// \return The joint visual type. - public: virtual JointVisualType Type() const = 0; - - /// \brief Get the JointVisual which is attached to the parent. - /// \return Parent axis visual. - public: virtual JointVisualPtr ParentAxisVisual() const = 0; - - /// \brief Get the arrow visual which represents the axis attached to the - /// child. - /// \return Arrow visual. - public: virtual ArrowVisualPtr ArrowVisual() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/LidarVisual.hh b/include/ignition/rendering/LidarVisual.hh index 1d2314f30..06616fcbe 100644 --- a/include/ignition/rendering/LidarVisual.hh +++ b/include/ignition/rendering/LidarVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,183 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_LIDARVISUAL_HH_ -#define IGNITION_RENDERING_LIDARVISUAL_HH_ -#include -#include -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Visual.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Marker.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Enum for LidarVisual types - enum IGNITION_RENDERING_VISIBLE LidarVisualType - { - /// \brief No type - LVT_NONE = 0, - - /// \brief Ray line visual - LVT_RAY_LINES = 1, - - /// \brief Points visual - LVT_POINTS = 2, - - /// \brief Triangle strips visual - LVT_TRIANGLE_STRIPS = 3 - }; - - /// \class LidarVisual LidarVisual.hh ignition/rendering/LidarVisual - /// \brief A LidarVisual geometry class. The visual appearance is based - /// on the type specified. - class IGNITION_RENDERING_VISIBLE LidarVisual : - public virtual Visual - { - protected: LidarVisual(); - - /// \brief Destructor - public: virtual ~LidarVisual(); - - /// \brief Clear the points of the lidar visual - public: virtual void ClearPoints() = 0; - - /// \brief Update the Visual - public: virtual void Update() = 0; - - /// \brief Set lidar points to be visualised - /// \param[in] _points Vector of points representing distance of the ray - public: virtual void SetPoints(const std::vector &_points) = 0; - - /// \brief Set lidar points to be visualised - /// \param[in] _points Vector of points representing distance of the ray - /// \param[in] _colors Vector of colors for the rendered points - public: virtual void SetPoints(const std::vector &_points, - const std::vector &_colors) = 0; - - /// \brief Set minimum vertical angle - /// \param[in] _minVerticalAngle Minimum vertical angle - public: virtual void SetMinVerticalAngle( - double _minVerticalAngle) = 0; - - /// \brief Get minimum vertical angle - /// \return The minimum vertical angle value of the lidar visual - public: virtual double MinVerticalAngle() const = 0; - - /// \brief Set maximum vertical angle - /// \param[in] _maxVerticalAngle Maximum vertical angle value - public: virtual void SetMaxVerticalAngle( - double _maxVerticalAngle) = 0; - - /// \brief Get minimum vertical angle - /// \return The maximum vertical angle value of the lidar visual - public: virtual double MaxVerticalAngle() const = 0; - - /// \brief Set minimum horizontal angle - /// \param[in] _minHorizontalAngle Minimum horizontal angle value - public: virtual void SetMinHorizontalAngle( - double _minHorizontalAngle) = 0; - - /// \brief Get minimum horizontal angle - /// \return The minimum horizontal angle value of the lidar visual - public: virtual double MinHorizontalAngle() const = 0; - - /// \brief Set maximum horizontal angle - /// \param[in] _maxHorizontalAngle Maximum horizontal angle value - public: virtual void SetMaxHorizontalAngle( - double _maxHorizontalAngle) = 0; - - /// \brief Get maximum horizontal angle - /// \return The maximum horizontal angle value of the lidar visual - public: virtual double MaxHorizontalAngle() const = 0; - - /// \brief Set number of vertical rays - /// \param[in] _verticalRayCount Number of vertical rays - public: virtual void SetVerticalRayCount( - unsigned int _verticalRayCount) = 0; - - /// \brief Get number of vertical rays - /// \return The number of vertical rays - public: virtual unsigned int VerticalRayCount() const = 0; - - /// \brief Set number of horizontal rays - /// \return _horizontalRayCount Number of vertical rays - public: virtual void SetHorizontalRayCount( - unsigned int _horizontalRayCount) = 0; - - /// \brief Get number of horizontal rays - /// \return The number of horizontal rays - public: virtual unsigned int HorizontalRayCount() const = 0; - - /// \brief Set minimum range of lidar rays - /// \param[in] _minRange The minimum range for lidar rays - public: virtual void SetMinRange(double _minRange) = 0; - - /// \brief Get minimum range of lidar rays - /// \return The minimum range for lidar rays - public: virtual double MinRange() const = 0; - - /// \brief Set maximum range of lidar rays - /// \param[in] _maxRange The maximum range for lidar rays - public: virtual void SetMaxRange(double _maxRange) = 0; - - /// \brief Get maximum range of lidar rays - /// \return The maximum range for lidar rays - public: virtual double MaxRange() const = 0; - - /// \brief Set offset of visual - /// \param[in] _offset The offset of the lidar rays from visual origin - public: virtual void SetOffset( - const ignition::math::Pose3d _offset) = 0; - - /// \brief Get offset of visual - /// \return The offset of the lidar rays from visual origin - public: virtual ignition::math::Pose3d Offset() const = 0; - - /// \brief Get number of points in laser data - /// \return The number of points in the laser data - public: virtual unsigned int PointCount() const = 0; - - /// \brief Get the points in laser data - /// \return The points in the laser data - public: virtual std::vector Points() const = 0; - - /// \brief Set type for lidar visual - /// \param[in] _type The type of visualisation for lidar data - public: virtual void SetType(const LidarVisualType _type) = 0; - - /// \brief Get the type for lidar visual - /// \return The type for lidar visual - public: virtual LidarVisualType Type() const = 0; - - /// \brief Set size of the lidar visualization, - /// e.g. size of rasterized lidar points in pixels - /// \param[in] _size Size of the lidar visualization. - public: virtual void SetSize(double _size) = 0; - - /// \brief Get size of the lidar visualization - /// \return Size of the lidar visualization. - /// \sa SetSize - public: virtual double Size() const = 0; - - /// \brief Set if non-hitting rays will be displayed - /// (this does not work for TRIANGLE_STRIPS visual) - /// \param[in] _display Boolean value to display non hitting visuals - public: virtual void SetDisplayNonHitting(bool _display) = 0; - - /// \brief Get if non-hitting rays will be displayed - /// \return Boolean value if non-hitting rays will be displayed - public: virtual bool DisplayNonHitting() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Light.hh b/include/ignition/rendering/Light.hh index e620dcc10..9e884a192 100644 --- a/include/ignition/rendering/Light.hh +++ b/include/ignition/rendering/Light.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,195 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_LIGHT_HH_ -#define IGNITION_RENDERING_LIGHT_HH_ -#include "ignition/math/Color.hh" -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Node.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Light Light.hh ignition/rendering/Light.hh - /// \brief Represents a light source in the scene graph - class IGNITION_RENDERING_VISIBLE Light : - public virtual Node - { - /// \brief Destructor - public: virtual ~Light() { } - - /// \brief Get the diffuse color - /// \return The diffuse color - public: virtual math::Color DiffuseColor() const = 0; - - /// \brief Set the diffuse color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetDiffuseColor(double _r, double _g, double _b, - double _a = 1.0) = 0; - - /// \brief Set the diffuse color - /// \param[in] _color New diffuse color - public: virtual void SetDiffuseColor(const math::Color &_color) = 0; - - /// \brief Get the specular color - /// \return The specular color - public: virtual math::Color SpecularColor() const = 0; - - /// \brief Set the specular color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetSpecularColor(double _r, double _g, double _b, - double _a = 1.0) = 0; - - /// \brief Set the specular color - /// \param[in] _color New specular color - public: virtual void SetSpecularColor(const math::Color &_color) = 0; - - /// \brief Get the attenuation constant value - /// \return The attenuation constant value - public: virtual double AttenuationConstant() const = 0; - - /// \brief Set the attenuation constant value - /// \param[in] _value New attenuation constant value - public: virtual void SetAttenuationConstant(double _value) = 0; - - /// \brief Get the attenuation linear value - /// \return The attenuation linear value - public: virtual double AttenuationLinear() const = 0; - - /// \brief Set the attenuation linear value - /// \param[in] _value New attenuation linear value - public: virtual void SetAttenuationLinear(double _value) = 0; - - /// \brief Get the attenuation quadratic value - /// \return The attenuation quadratic value - public: virtual double AttenuationQuadratic() const = 0; - - /// \brief Set the attenuation quadratic value - /// \param[in] _value New attenuation quadratic value - public: virtual void SetAttenuationQuadratic(double _value) = 0; - - /// \brief Get the attenuation range - /// \return The attenuation range - public: virtual double AttenuationRange() const = 0; - - /// \brief Set the attenuation range - /// \param[in] _range New attenuation range - public: virtual void SetAttenuationRange(double _range) = 0; - - /// \brief Determine if this light cast shadows - /// \return True if this light cast shadows - public: virtual bool CastShadows() const = 0; - - /// \brief Specify if this light should cast shadows - /// \param[in] _castShadows True if this light cast shadows - public: virtual void SetCastShadows(bool _castShadows) = 0; - - /// \brief Get the light intensity - /// \return The light intensity - public: virtual double Intensity() const = 0; - - /// \brief Set the light intensity - /// \param[in] _intensity New light intensity - public: virtual void SetIntensity(double _intensity) = 0; - }; - - /// \class DirectionalLight Light.hh ignition/rendering/Light.hh - /// \brief Represents a infinite directional light - class IGNITION_RENDERING_VISIBLE DirectionalLight : - public virtual Light - { - /// \brief Destructor - public: virtual ~DirectionalLight() { } - - /// \brief Get the direction of the light - /// \return The direction of the light - public: virtual math::Vector3d Direction() const = 0; - - /// \brief Set the direction of the light - /// \param[in] _x X-component of direction vector - /// \param[in] _y Y-component of direction vector - /// \param[in] _z Z-component of direction vector - public: virtual void SetDirection(double _x, double _y, double _z) = 0; - - /// \brief Set the direction of the light - /// \param[in] _dir New direction vector - public: virtual void SetDirection(const math::Vector3d &_dir) = 0; - }; - - /// \class PointLight Light.hh ignition/rendering/Light.hh - /// \brief Represents a point light - class IGNITION_RENDERING_VISIBLE PointLight : - public virtual Light - { - /// \brief Destructor - public: virtual ~PointLight() { } - }; - - /// \class SpotLight Light.hh ignition/rendering/Light.hh - /// \brief Represents a spotlight - class IGNITION_RENDERING_VISIBLE SpotLight : - public virtual Light - { - /// \brief Destructor - public: virtual ~SpotLight() { } - - /// \brief Get direction of the light - /// \return The direction of the light - public: virtual math::Vector3d Direction() const = 0; - - /// \brief Set the direction of the light - /// \param[in] _x X-component of direction vector - /// \param[in] _y Y-component of direction vector - /// \param[in] _z Z-component of direction vector - public: virtual void SetDirection(double _x, double _y, double _z) = 0; - - /// \brief Set the direction of the light - /// \param[in] _dir New direction vector - public: virtual void SetDirection(const math::Vector3d &_dir) = 0; - - /// \brief Get the inner angle of the spotlight - /// \return The inner angle of the spotlight - public: virtual math::Angle InnerAngle() const = 0; - - /// \brief Set the inner angle of the spotlight - /// \param[in] _radians New inner angle of the spotlight in radians - public: virtual void SetInnerAngle(double _radians) = 0; - - /// \brief Set the inner angle of the spotlight - /// \param[in] _angle New inner angle of the spotlight - public: virtual void SetInnerAngle(const math::Angle &_angle) = 0; - - /// \brief Get the outer angle of the spotlight - /// \return The outer angle of the spotlight - public: virtual math::Angle OuterAngle() const = 0; - - /// \brief Set the outer angle of the spotlight - /// \param[in] _radians New outer angle of the spotlight in radians - public: virtual void SetOuterAngle(double _radians) = 0; - - /// \brief Set the outer angle of the spotlight - /// \param[in] _angle New outer angle of the spotlight - public: virtual void SetOuterAngle(const math::Angle &_angle) = 0; - - /// \brief Get the falloff of the spotlight - /// \return The falloff of the spotlight - public: virtual double Falloff() const = 0; - - /// \brief Set the falloff of the spotlight - /// \param[in] _falloff New falloff of the spotlight - public: virtual void SetFalloff(double _falloff) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/LightVisual.hh b/include/ignition/rendering/LightVisual.hh index cc8c6090f..5c889e199 100644 --- a/include/ignition/rendering/LightVisual.hh +++ b/include/ignition/rendering/LightVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,69 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_LIGHTVISUAL_HH_ -#define IGNITION_RENDERING_LIGHTVISUAL_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - /// \brief Enum for LightVisual types - enum IGNITION_RENDERING_VISIBLE LightVisualType - { - /// \brief No type - LVT_EMPTY = 0, - - /// \brief Point light - LVT_POINT = 1, - - /// \brief Directional light - LVT_DIRECTIONAL = 2, - - /// \brief Spot light - LVT_SPOT = 3 - }; - - /// \class LightVisual LightVisual.hh ignition/rendering/LightVisual.hh - /// \brief Represents a light visual - class IGNITION_RENDERING_VISIBLE LightVisual : - public virtual Visual - { - /// \brief Descructor - public: virtual ~LightVisual() {} - - /// \brief set type of the light - /// \param[in] _type type of the light - public: virtual void SetType(LightVisualType _type) = 0; - - /// \brief Get light visual type - /// \return The light visual type - public: virtual LightVisualType Type() = 0; - - /// \brief Set inner angle for spot lights - /// \param[in] _innerAngle Inner angle - public: virtual void SetInnerAngle(double _innerAngle) = 0; - - /// \brief Get inner angle - /// \return The light inner angle - public: virtual double InnerAngle() = 0; - - /// \brief Set outer angle for spot lights - /// \param[in] _outerAngle Outer angle - public: virtual void SetOuterAngle(double _outerAngle) = 0; - - /// \brief Get outer angle - /// \return The light outer angle - public: virtual double OuterAngle() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Marker.hh b/include/ignition/rendering/Marker.hh index 85b4795d7..662658c4a 100644 --- a/include/ignition/rendering/Marker.hh +++ b/include/ignition/rendering/Marker.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,136 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_MARKER_HH_ -#define IGNITION_RENDERING_MARKER_HH_ -#include -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Enum for marker types - enum IGNITION_RENDERING_VISIBLE MarkerType - { - /// \brief No type - MT_NONE = 0, - - /// \brief Box geometry - MT_BOX = 1, - - /// \brief Cylinder geometry - MT_CYLINDER = 2, - - /// \brief Line strip primitive - MT_LINE_STRIP = 3, - - /// \brief Line list primitive - MT_LINE_LIST = 4, - - /// \brief Points primitive - MT_POINTS = 5, - - /// \brief Sphere geometry - MT_SPHERE = 6, - - /// \brief Text geometry - MT_TEXT = 7, - - /// \brief Triangle fan primitive - MT_TRIANGLE_FAN = 8, - - /// \brief Triangle list primitive - MT_TRIANGLE_LIST = 9, - - /// \brief Triangle strip primitive - MT_TRIANGLE_STRIP = 10, - - /// \brief Capsule geometry - MT_CAPSULE = 11, - }; - - /// \class Marker Marker.hh ignition/rendering/Marker - /// \brief A marker geometry class. The marker's visual appearance is based - /// on the marker type specified. - class IGNITION_RENDERING_VISIBLE Marker : - public virtual Geometry - { - protected: Marker(); - - /// \brief Destructor - public: virtual ~Marker(); - - /// \brief Set the lifetime of this Marker - /// \param[in] _lifetime The time at which the marker will be removed - public: virtual void SetLifetime( - const std::chrono::steady_clock::duration &_lifetime) = 0; - - /// \brief Get the lifetime of this Marker - /// \return The time at which the marker will be removed - public: virtual std::chrono::steady_clock::duration Lifetime() const = 0; - - /// \brief Set the layer of this Marker - /// \param[in] _layer Layer at which the marker will reside - public: virtual void SetLayer(int32_t _layer) = 0; - - /// \brief Get the layer of this Marker - /// \return The layer of the marker - public: virtual int32_t Layer() const = 0; - - /// \brief Set the render type of this Marker - /// \param[in] _markerType The desired render type - public: virtual void SetType( - const ignition::rendering::MarkerType _markerType) = 0; - - /// \brief Get the render type of this Marker - /// \return The render type of the marker - public: virtual ignition::rendering::MarkerType Type() const = 0; - - /// \brief Set size of the marker. Only affects MT_POINTS. - /// e.g. size of rasterized points in pixels - /// \param[in] _size Size of the marker - public: virtual void SetSize(double _size) = 0; - - /// \brief Get the size of the marker. - /// \return The size of the marker - /// \sa SetSize - public: virtual double Size() const = 0; - - /// \brief Clear the points of the marker, if applicable - public: virtual void ClearPoints() = 0; - - /// \brief Add a point with its respective color to the marker - /// \param[in] _x X coordinate - /// \param[in] _y Y coordinate - /// \param[in] _z Z coordinate - /// \param[in] _color The color the point is set to - public: virtual void AddPoint(double _x, - double _y, double _z, - const ignition::math::Color &_color) = 0; - - /// \brief Add a point with its respective color to the marker - /// \param[in] _pt A vector containing the position of the point - /// \param[in] _color The color the point is set to - public: virtual void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color) = 0; - - /// \brief Set an existing point's vector - /// \param[in] _index The index of the point - /// \param[in] _value The new positional vector of the point - public: virtual void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value) = 0; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/Material.hh b/include/ignition/rendering/Material.hh index 6dc28e51a..ea472d9ba 100644 --- a/include/ignition/rendering/Material.hh +++ b/include/ignition/rendering/Material.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,394 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_MATERIAL_HH_ -#define IGNITION_RENDERING_MATERIAL_HH_ -#include -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/ShaderType.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief An enum for the type of material - enum IGNITION_RENDERING_VISIBLE MaterialType - { - /// \brief Classic shading, i.e. variants of Phong - MT_CLASSIC = 0, - - /// \brief Physically Based Shading - MT_PBS = 1 - }; - - /// \class Material Material.hh ignition/rendering/Material.hh - /// \brief Represents a surface material of a Geometry - class IGNITION_RENDERING_VISIBLE Material : - public virtual Object - { - /// \brief Destructor - public: virtual ~Material() { } - - /// \brief Determine if lighting affects this material - /// \return True if lighting affects this material - public: virtual bool LightingEnabled() const = 0; - - /// \brief Specify if lighting affects this material - /// \param[in] _enabled True if lighting affects this material - public: virtual void SetLightingEnabled(const bool _enabled) = 0; - - /// \brief Specify if depth buffer checking is enabled - /// \param[in] _enabled True if depth check is enabled - public: virtual void SetDepthCheckEnabled(bool _enabled) = 0; - - /// \brief Determine if depth buffer checking is enabled - /// \return True if depth check is enabled - public: virtual bool DepthCheckEnabled() const = 0; - - /// \brief Specify if depth buffer writing is enabled - /// \param[in] _enabled True if depth buffer writing is enabled - public: virtual void SetDepthWriteEnabled(bool _enabled) = 0; - - /// \brief Determine if depth buffer writing is enabled - /// \return True if depth buffer writing is enabled - public: virtual bool DepthWriteEnabled() const = 0; - - /// \brief Get the ambient color - /// \return The ambient color - public: virtual math::Color Ambient() const = 0; - - /// \brief Set the ambient color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetAmbient(const double _r, const double _g, - const double _b, const double _a = 1.0) = 0; - - /// \brief Set the ambient color - /// \param[in] _color New ambient color - public: virtual void SetAmbient(const math::Color &_color) = 0; - - /// \brief Get the diffuse color - /// \return The diffuse color - public: virtual math::Color Diffuse() const = 0; - - /// \brief Set the diffuse color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetDiffuse(const double _r, const double _g, - const double _b, const double _a = 1.0) = 0; - - /// \brief Set the diffuse color - /// \param[in] _color New diffuse color - public: virtual void SetDiffuse(const math::Color &_color) = 0; - - /// \brief Get the specular color - /// \return The specular color - public: virtual math::Color Specular() const = 0; - - /// \brief Set the specular color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetSpecular(const double _r, const double _g, - const double _b, const double _a = 1.0) = 0; - - /// \brief Set the specular color - /// \param[in] _color New specular color - public: virtual void SetSpecular(const math::Color &_color) = 0; - - /// \brief Get the emissive color - /// \return The emissive color - public: virtual math::Color Emissive() const = 0; - - /// \brief Set the emissive color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetEmissive(const double _r, const double _g, - const double _b, const double _a = 1.0) = 0; - - /// \brief Set the emissive color - /// \param[in] _color New emissive color - public: virtual void SetEmissive(const math::Color &_color) = 0; - - /// \brief Get the shininess value - /// \return The shininess value - public: virtual double Shininess() const = 0; - - /// \brief Set the shininess value - /// \param[in] _shininess New shininess value - public: virtual void SetShininess(const double _shininess) = 0; - - /// \brief Get the transparency value - /// \return The transparency value - public: virtual double Transparency() const = 0; - - /// \brief Configuration for Depth Material - /// \param[in] far Far distance for normalized output - /// \param[in] near Near distance for normalized output - public: virtual void SetDepthMaterial(const double far, - const double near) = 0; - - /// \brief Set the transparency value - /// \param[in] _transparency New transparency value - public: virtual void SetTransparency(const double _transparency) = 0; - - /// \brief Set the material to use the alpha channel from the textures - /// \param[in] _enabled Enable alpha channel based rendering - /// \param[in] _alpha Set the alpha threshold value - /// \param[in] _twoSided Enable two sided rendering - public: virtual void SetAlphaFromTexture(bool _enabled, - double _alpha = 0.5, bool _twoSided = true) = 0; - - /// \brief Get the enable alpha from textures - /// \return The enable alpha value - public: virtual bool TextureAlphaEnabled() const = 0; - - /// \brief Get the alpha threshold - /// \return The alpha threshold value - public: virtual double AlphaThreshold() const = 0; - - /// \brief Get the enable two sided rendering value - /// \return The enable two sided rendering value - public: virtual bool TwoSidedEnabled() const = 0; - - /// \brief Get the reflectivity value - /// \return The reflectivity value - public: virtual double Reflectivity() const = 0; - - /// \brief Set the reflectivity value - /// \param[in] _reflectivity New reflectivity value - public: virtual void SetReflectivity(const double _reflectivity) = 0; - - /// \brief Determine if this material casts shadows - /// \return True if this material casts shadows - public: virtual bool CastShadows() const = 0; - - /// \brief Specify if this material casts shadows - /// \param[in] _castShadows True if this material casts shadows - public: virtual void SetCastShadows(const bool _castShadows) = 0; - - /// \brief Determine if this material receives shadows - /// \return True if this material receives shadows - public: virtual bool ReceiveShadows() const = 0; - - /// \brief Specify if this material receives shadows - /// \param[in] _receiveShadows True if this material receives shadows - public: virtual void SetReceiveShadows(const bool _receiveShadows) = 0; - - /// \brief Determine if this material has a reflection - /// \return True if this material has a reflection - public: virtual bool ReflectionEnabled() const = 0; - - /// \brief Specify if this material has a reflection - /// \param[in] _enabled True if this material has a reflection - public: virtual void SetReflectionEnabled(const bool _enabled) = 0; - - /// \brief Determine if this material has a texture - /// \return True if this material has a texture - public: virtual bool HasTexture() const = 0; - - /// \brief Get the URI of the texture file - /// \return URI of the texture file - public: virtual std::string Texture() const = 0; - - /// \brief Set the material texture - /// \param[in] _texture URI of the new texture file - public: virtual void SetTexture(const std::string &_texture) = 0; - - /// \brief Removes any texture mapped to this material - public: virtual void ClearTexture() = 0; - - /// \brief Determine if this material has a normal map - /// \return True if this material has a normal map - public: virtual bool HasNormalMap() const = 0; - - /// \brief Get the URI of the normal map file - /// \return URI of the normal map file - public: virtual std::string NormalMap() const = 0; - - /// \brief Set the material normal map - /// \param[in] _normalMap URI of the new normal map file - public: virtual void SetNormalMap(const std::string &_normalMap) = 0; - - /// \brief Removes any normal map mapped to this material - public: virtual void ClearNormalMap() = 0; - - /// \brief Determine if this material has a roughness map - /// \return True if this material has a roughness map - public: virtual bool HasRoughnessMap() const = 0; - - /// \brief Get the URI of the roughness map file - /// \return URI of the roughness map file - public: virtual std::string RoughnessMap() const = 0; - - /// \brief Set the material roughness map - /// \param[in] _roughnessMap URI of the new roughness map file - public: virtual void SetRoughnessMap( - const std::string &_roughnessMap) = 0; - - /// \brief Removes any roughness map mapped to this material - public: virtual void ClearRoughnessMap() = 0; - - /// \brief Determine if this material has a metalness map - /// \return True if this material has a metalness map - public: virtual bool HasMetalnessMap() const = 0; - - /// \brief Get the URI of the metalness map file - /// \return URI of the metalness map file - public: virtual std::string MetalnessMap() const = 0; - - /// \brief Set the material metalness map - /// \param[in] _metalnessMap URI of the new metalness map file - public: virtual void SetMetalnessMap( - const std::string &_metalnessMap) = 0; - - /// \brief Removes any metalness map mapped to this material - public: virtual void ClearMetalnessMap() = 0; - - /// \brief Determine if this material has a environment map - /// \return True if this material has a environment map - public: virtual bool HasEnvironmentMap() const = 0; - - /// \brief Get the URI of the environment map file - /// \return URI of the environment map file - public: virtual std::string EnvironmentMap() const = 0; - - /// \brief Set the material environment map - /// \param[in] _metalnessMap URI of the new environment map file - public: virtual void SetEnvironmentMap( - const std::string &_metalnessMap) = 0; - - /// \brief Removes any environment map mapped to this material - public: virtual void ClearEnvironmentMap() = 0; - - /// \brief Determine if this material has an emissive map - /// \return True if this material has an emissive map - public: virtual bool HasEmissiveMap() const = 0; - - /// \brief Get the URI of the emissive map file - /// \return URI of the emissive map file - public: virtual std::string EmissiveMap() const = 0; - - /// \brief Set the material emissive map - /// \param[in] _emissiveMap URI of the new emissive map file - public: virtual void SetEmissiveMap( - const std::string &_emissiveMap) = 0; - - /// \brief Removes any emissive map mapped to this material - public: virtual void ClearEmissiveMap() = 0; - - /// \brief Determine if this material has a light map - /// \return True if this material has a light map - public: virtual bool HasLightMap() const = 0; - - /// \brief Get the URI of the light map file - /// \return URI of the light map file - public: virtual std::string LightMap() const = 0; - - /// \brief Get the texture coordinate set used by lightmap - /// \return texture coordinate set of the light map - public: virtual unsigned int LightMapTexCoordSet() const = 0; - - /// \brief Set the material light map - /// \param[in] _lightMap URI of the new light map file - /// \param[in] _uvSet Texture coordinate set to use - public: virtual void SetLightMap(const std::string &_lightMap, - unsigned int _uvSet = 0u) = 0; - - /// \brief Removes any light map mapped to this material - public: virtual void ClearLightMap() = 0; - - /// \brief Set the render order. When polygons are coplanar, you can get - /// problems with 'depth fighting' where the pixels from the two polys - /// compete for the same screen pixel. This param help to avoid this - /// problem. - /// \param[in] _renderOrder Render order to set to - public: virtual void SetRenderOrder(const float _renderOrder) = 0; - - /// \brief Get the render order value of this material. - /// \return Material render order - public: virtual float RenderOrder() const = 0; - - /// \brief Set the roughness value. Only affects material of type MT_PBS - /// \param[in] _roughness Roughness to set to - public: virtual void SetRoughness(const float _roughness) = 0; - - /// \brief Get the roughness value of this material. - /// \return Material roughness - public: virtual float Roughness() const = 0; - - /// \brief Set the metalness value. Only affects material of type MT_PBS - /// \param[in] _metalness Metalness to set to - public: virtual void SetMetalness(const float _metalness) = 0; - - /// \brief Get the metalness value of this material - /// \return Material metalness - public: virtual float Metalness() const = 0; - - /// \brief Removes any metalness map mapped to this material - public: virtual enum MaterialType Type() const = 0; - - /// \brief Get the ShaderType value - /// \return The ShaderType value - public: virtual enum ShaderType ShaderType() const = 0; - - /// \brief Set the ShaderType value - /// \param[in] _type New ShaderType value - public: virtual void SetShaderType(enum ShaderType _type) = 0; - - /// \brief Clone this material - /// \return New cloned material - public: virtual MaterialPtr Clone(const std::string &_name = "") - const = 0; - - /// \brief Copy properties from given Material - /// \param[in] _material Source Material to be copied from - public: virtual void CopyFrom(ConstMaterialPtr _material) = 0; - - /// \brief Copy properties from given Material - /// \param[in] _material Source Material to be copied from - public: virtual void CopyFrom(const common::Material &_material) = 0; - - /// \brief Get path to the vertex shader - /// \return Path to vertex shader - public: virtual std::string VertexShader() const = 0; - - /// \brief Get params for the vertex shader - /// \return editable parameters - public: virtual ShaderParamsPtr VertexShaderParams() = 0; - - /// \brief Set the vertex shader - /// \param[in] _path path to a file containing a glsl shader - public: virtual void SetVertexShader(const std::string &_path) = 0; - - /// \brief Get path to the fragment shader - /// \return Path to fragment shader - public: virtual std::string FragmentShader() const = 0; - - /// \brief Get params for the fragment shader - /// \return editable parameters - public: virtual ShaderParamsPtr FragmentShaderParams() = 0; - - /// \brief Set the fragment shader - /// \param[in] _path path to a file containing a glsl shader - public: virtual void SetFragmentShader(const std::string &_path) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Mesh.hh b/include/ignition/rendering/Mesh.hh index a98c96790..83406d35f 100644 --- a/include/ignition/rendering/Mesh.hh +++ b/include/ignition/rendering/Mesh.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,149 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_MESH_HH_ -#define IGNITION_RENDERING_MESH_HH_ -#include -#include -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/MeshDescriptor.hh" -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Mesh Mesh.hh ignition/rendering/Mesh - /// \brief Represents a collection of mesh geometries - class IGNITION_RENDERING_VISIBLE Mesh : - public virtual Geometry - { - /// \brief Destructor - public: virtual ~Mesh() { } - - /// \brief Check whether the mesh has skeleton - /// \return True if the mesh has skeleton - public: virtual bool HasSkeleton() const = 0; - - /// \brief Get the skeleton local transforms - /// \return Map of skeleton local transformations - /// * Map holding: - /// * Skeleton node names - /// * Local transformations of the skeleton nodes - public: virtual std::map - SkeletonLocalTransforms() const = 0; - - /// \brief Set transforms for the skeleton - /// \param[in] _tfs Map of skeleton local transformations - /// * Map holding: - /// * Skeleton node names - /// * Local transformations of the skeleton nodes - public: virtual void SetSkeletonLocalTransforms( - const std::map &_tfs) = 0; - - /// \brief Get skeleton node weight - /// \return Map of skeleton node name to its weight - /// * Map holding: - /// * Skeleton node names - /// * Weight the skeleton nodes - public: virtual std::unordered_map SkeletonWeights() - const = 0; - - /// \brief Set skeleton node weight - /// \param[in] _weights Map of skeleton node's name to its weight - /// * Map holding: - /// * Skeleton node names - /// * Weight the skeleton nodes - public: virtual void SetSkeletonWeights( - const std::unordered_map &_weights) = 0; - - /// \brief Set whether a skeleton animation should be enabled or not - /// \param[in] _name Name of animation - /// \param[in] _enabled True to enable animation, false to disable - /// \param[in] _loop True to loop animation - /// \param[in] _weight Weight of animation - public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, - bool _enabled, bool _loop = true, float _weight = 1.0) = 0; - - /// \brief Get whether a skeleton animation is enabled or not - /// \param[in] _name Name of animation - /// \return True is the skeleton animation is enabled, false otherwise - public: virtual bool SkeletonAnimationEnabled(const std::string &_name) - const = 0; - - /// \brief Play the active skeleton animation to the specified time - /// \param[in] _time Time to set the skeleton animation to - public: virtual void UpdateSkeletonAnimation( - std::chrono::steady_clock::duration _time) = 0; - - /// \brief Get the sub-mesh count - /// \return The sub-mesh count - public: virtual unsigned int SubMeshCount() const = 0; - - /// \brief Determine if has given sub-mesh - /// \param[in] _subMesh Sub-mesh in question - /// \return True if has given sub-mesh - public: virtual bool HasSubMesh(ConstSubMeshPtr _subMesh) const = 0; - - /// \brief Determine if has sub-mesh with given name - /// \param[in] _name Name of sub-mesh in question - /// \return True if has sub-mesh with given name - public: virtual bool HasSubMeshName(const std::string &_name) const = 0; - - /// \brief Get sub-mesh with given name - /// \param[in] _name Name of sub-mesh - /// \return The sub-mesh with the given name - public: virtual SubMeshPtr SubMeshByName( - const std::string &_name) const = 0; - - /// \brief Get sub-mesh at given index - /// \param[in] _index Index of sub-mesh - /// \return The sub-mesh at the given index - public: virtual SubMeshPtr SubMeshByIndex( - unsigned int _index) const = 0; - - /// \brief Set the mesh's mesh descriptor - /// \return The mesh's mesh descriptor - public: virtual void SetDescriptor(const MeshDescriptor &_desc) = 0; - - /// \brief Get the mesh's mesh descriptor - /// \return The mesh's mesh descriptor - public: virtual const MeshDescriptor &Descriptor() const = 0; - }; - - /// \class SubMesh Mesh.hh ignition/rendering/Mesh.hh - /// \brief Represents a single mesh geometry - class IGNITION_RENDERING_VISIBLE SubMesh : - public virtual Object - { - /// \brief Destructor - public: virtual ~SubMesh() { } - - /// \brief Get the currently assigned material - /// \return The currently assigned material - public: virtual MaterialPtr Material() const = 0; - - /// \brief Set the materials of this SubMesh. The specified material - /// will be retrieved from the parent Scene. If no material is registered - /// by the given name, no work will be done. - /// \param[in] _name Name of registered Material - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetMaterial(const std::string &_name, - bool _unique = true) = 0; - - /// \brief Set the materials of this SubMesh - /// \param[in] _material New Material to be assigned - /// \param[in] _unique True if the given material should be cloned - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/MeshDescriptor.hh b/include/ignition/rendering/MeshDescriptor.hh index 3ec101d56..f22291457 100644 --- a/include/ignition/rendering/MeshDescriptor.hh +++ b/include/ignition/rendering/MeshDescriptor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,71 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_MESHDESCRIPTOR_HH_ -#define IGNITION_RENDERING_MESHDESCRIPTOR_HH_ -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace common - { - class Mesh; - } -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \struct MeshDescriptor MeshDescriptor.hh - /// ignition/rendering/MeshDescriptor.hh - /// \brief Describes how a Mesh should be loaded - struct IGNITION_RENDERING_VISIBLE MeshDescriptor - { - /// \brief Constructor - public: MeshDescriptor(); - - /// \brief Constructor. A common::Mesh will be retrieved from the - /// MeshManager by the given name upon a call to Normalize. - /// \param[in] _meshName Name of the mesh to load - public: explicit MeshDescriptor(const std::string &_meshName); - - /// \brief Constructor - /// \param[in] _mesh Mesh to load - public: explicit MeshDescriptor(const common::Mesh *_mesh); - - /// \brief Ensures both the meshName and mesh member variables have been - /// assigned. If mesh is not null, it will be used to override the value - /// of meshName. - public: void Load(); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief common::Mesh object - public: const common::Mesh *mesh = nullptr; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Name of the registered Mesh - public: std::string meshName; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Name of the sub-mesh to be loaded. An empty string signifies - /// all sub-meshes should be loaded. - public: std::string subMeshName; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Denotes if the loaded sub-mesh vertices should be centered - public: bool centerSubMesh = false; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/MoveToHelper.hh b/include/ignition/rendering/MoveToHelper.hh index d14f9da1a..7fb4bab57 100644 --- a/include/ignition/rendering/MoveToHelper.hh +++ b/include/ignition/rendering/MoveToHelper.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,87 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_MOVETOHELPER_HH_ -#define IGNITION_RENDERING_MOVETOHELPER_HH_ + */ -#include - -#include -#include - -#include -#include - -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - // Inline bracket to help doxygen filtering. - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // forward declaration - class MoveToHelperPrivate; - - /// \brief Helper class for animating a user camera to move to a target - /// entity - class IGNITION_RENDERING_VISIBLE MoveToHelper - { - public: MoveToHelper(); - - public: ~MoveToHelper(); - - /// \brief Move the camera to look at the specified target - /// param[in] _camera Camera to be moved - /// param[in] _target Target to look at - /// param[in] _duration Duration of the move to animation, in seconds. - /// param[in] _onAnimationComplete Callback function when animation is - /// complete - public: void MoveTo(const rendering::CameraPtr &_camera, - const rendering::NodePtr &_target, double _duration, - std::function _onAnimationComplete); - - /// \brief Move the camera to the specified pose. - /// param[in] _camera Camera to be moved - /// param[in] _target Pose to move to - /// param[in] _duration Duration of the move to animation, in seconds. - /// param[in] _onAnimationComplete Callback function when animation is - /// complete - public: void MoveTo(const rendering::CameraPtr &_camera, - const math::Pose3d &_target, double _duration, - std::function _onAnimationComplete); - - /// \brief Move the camera to look at the specified target - /// param[in] _camera Camera to be moved - /// param[in] _direction The pose to assume relative to the - /// entit(y/ies), (0, 0, 0) indicates to return the camera back to the - /// home pose originally loaded in from the sdf. - /// param[in] _duration Duration of the move to animation, in seconds. - /// param[in] _onAnimationComplete Callback function when animation is - /// complete - public: void LookDirection(const rendering::CameraPtr &_camera, - const math::Vector3d &_direction, const math::Vector3d &_lookAt, - double _duration, std::function _onAnimationComplete); - - /// \brief Add time to the animation. - /// \param[in] _time Time to add in seconds - public: void AddTime(double _time); - - /// \brief Get whether the move to helper is idle, i.e. no animation - /// is being executed. - /// \return True if idle, false otherwise - public: bool Idle() const; - - /// \brief Set the initial camera pose - /// param[in] _pose The init pose of the camera - public: void SetInitCameraPose(const math::Pose3d &_pose); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Node.hh b/include/ignition/rendering/Node.hh index fc33d1794..f9defde3b 100644 --- a/include/ignition/rendering/Node.hh +++ b/include/ignition/rendering/Node.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,331 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_NODE_HH_ -#define IGNITION_RENDERING_NODE_HH_ -#include -#include -#include - -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Alias for a variant that can hold various types of data. - /// The first type of the variant is std::monostate in order to prevent - /// default-constructed variants from holding a type (a default-constructed - /// variant is returned when a user calls Node::UserData with a key that - /// doesn't exist for the node. In this case, since the key doesn't - /// exist, the variant that is returned shouldn't hold any types - an - /// "empty variant" should be returned for keys that don't exist) - using Variant = - std::variant; - - /// \class Node Node.hh ignition/rendering/Node.hh - /// \brief Represents a single posable node in the scene graph - class IGNITION_RENDERING_VISIBLE Node : - public virtual Object - { - /// \brief Destructor - public: virtual ~Node() { } - - /// \brief Determine if this Node is attached to another Node. - /// \return True if this Node has a parent Node - public: virtual bool HasParent() const = 0; - - /// \brief Get the parent Node - /// \return the parent Node - public: virtual NodePtr Parent() const = 0; - - /// \brief Detach this Node from its parent. If this - /// Node does not have a parent, no work will be done. - public: virtual void RemoveParent() = 0; - - /// \brief Get the local pose - /// \return The local pose - public: virtual math::Pose3d LocalPose() const = 0; - - /// \brief Get the initial local pose - /// \return The initial local pose - public: virtual math::Pose3d InitialLocalPose() const = 0; - - /// \brief Set the local pose - /// \param[in] _pose New local pose - public: virtual void SetLocalPose(const math::Pose3d &_pose) = 0; - - /// \brief Get the local position - /// \return The local position - public: virtual math::Vector3d LocalPosition() const = 0; - - /// \brief Set the local position - /// \param[in] _x X-coordinate - /// \param[in] _y Y-coordinate - /// \param[in] _z Z-coordinate - public: virtual void SetLocalPosition(double _x, double _y, - double _z) = 0; - - /// \brief Set the local position - /// \param[in] _position New local position - public: virtual void SetLocalPosition( - const math::Vector3d &_position) = 0; - - /// \brief Get the local rotation - /// \return The local rotation - public: virtual math::Quaterniond LocalRotation() const = 0; - - /// \brief Set the local rotation - /// \param[in] _r roll - /// \param[in] _p pitch - /// \param[in] _y yaw - public: virtual void SetLocalRotation(double _r, double _p, - double _y) = 0; - - /// \brief Set the local rotation - /// \param[in] _w W-coordinate - /// \param[in] _x X-coordinate - /// \param[in] _y Y-coordinate - /// \param[in] _z Z-coordinate - public: virtual void SetLocalRotation(double _w, double _x, double _y, - double _z) = 0; - - /// \brief Set the local rotation - /// \param[in] _rotation New local rotation - public: virtual void SetLocalRotation( - const math::Quaterniond &_rotation) = 0; - - /// \brief Get the world pose - /// \return The world pose - public: virtual math::Pose3d WorldPose() const = 0; - - /// \brief Set the world pose - /// \param[in] _pose New world pose - public: virtual void SetWorldPose(const math::Pose3d &_pose) = 0; - - /// \brief Get the world position - /// \return The world position - public: virtual math::Vector3d WorldPosition() const = 0; - - /// \brief Set the world position - /// \param[in] _x X-coordinate - /// \param[in] _y Y-coordinate - /// \param[in] _z Z-coordinate - public: virtual void SetWorldPosition(double _x, double _y, - double _z) = 0; - - /// \brief Set the world position - /// \param[in] _position New world position - public: virtual void SetWorldPosition( - const math::Vector3d &_position) = 0; - - /// \brief Get the world rotation - /// \return The world rotation - public: virtual math::Quaterniond WorldRotation() const = 0; - - /// \brief Set the world rotation - /// \param[in] _r roll - /// \param[in] _p pitch - /// \param[in] _y yaw - public: virtual void SetWorldRotation(double _r, double _p, - double _y) = 0; - - /// \brief Set the world rotation - /// \param[in] _w W-coordinate - /// \param[in] _x X-coordinate - /// \param[in] _y Y-coordinate - /// \param[in] _z Z-coordinate - public: virtual void SetWorldRotation(double _w, double _x, double _y, - double _z) = 0; - - /// \brief Set the world rotation - /// \param[in] _rotation New world rotation - public: virtual void SetWorldRotation( - const math::Quaterniond &_rotation) = 0; - - /// \brief Convert given world pose to local pose - /// \param[in] _pose World pose to be converted - public: virtual math::Pose3d WorldToLocal( - const math::Pose3d &_pose) const = 0; - - /// \brief Get position of origin - /// \return The position of the origin - public: virtual math::Vector3d Origin() const = 0; - - /// \brief Set position of origin. The position should be relative to the - /// original origin of the geometry. - /// \param[in] _x X-coordinate - /// \param[in] _y Y-coordinate - /// \param[in] _z Z-coordinate - public: virtual void SetOrigin(double _x, double _y, double _z) = 0; - - /// \brief Set position of origin. The position should be relative to the - /// original origin of the geometry. - /// \param[in] _origin New origin position - public: virtual void SetOrigin(const math::Vector3d &_origin) = 0; - - /// \brief Get the local scale - /// \return The local scale - public: virtual math::Vector3d LocalScale() const = 0; - - /// \brief Set the local scale. The given scale will be assigned to the - /// x, y, and z coordinates. - /// \param[in] _scale New local scale - public: virtual void SetLocalScale(double _scale) = 0; - - /// \brief Set the local scale - /// \param[in] _x New x-coordinate scale - /// \param[in] _y New y-coordinate scale - /// \param[in] _z New z-coordinate scale - public: virtual void SetLocalScale(double _x, double _y, double _z) = 0; - - /// \brief Set the local scale - /// \param[in] _scale New local scale - public: virtual void SetLocalScale(const math::Vector3d &_scale) = 0; - - /// \brief Get the world scale - /// \return The world scale - public: virtual math::Vector3d WorldScale() const = 0; - - /// \brief Set the world scale. The given scale will be assigned to the - /// x, y, and z coordinates. - /// \param[in] _scale New world scale - public: virtual void SetWorldScale(double _scale) = 0; - - /// \brief Set the world scale - /// \param[in] _x New x-coordinate scale - /// \param[in] _y New y-coordinate scale - /// \param[in] _z New z-coordinate scale - public: virtual void SetWorldScale(double _x, double _y, double _z) = 0; - - /// \brief Set the world scale - /// \param[in] _scale New world scale - public: virtual void SetWorldScale(const math::Vector3d &_scale) = 0; - - /// \brief Scale the current scale by the given scalar. The given scalar - /// will be assigned to the x, y, and z coordinates. - /// \param[in] _scale Scalar to alter the current scale - public: virtual void Scale(double _scale) = 0; - - /// \brief Scale the current scale by the given scalars - /// \param[in] _x Scalar to alter the current x-coordinate scale - /// \param[in] _y Scalar to alter the current y-coordinate scale - /// \param[in] _z Scalar to alter the current z-coordinate scale - public: virtual void Scale(double _x, double _y, double _z) = 0; - - /// \brief Scale the current scale by the given scalars - /// \param[in] _scale Scalars to alter the current scale - public: virtual void Scale(const math::Vector3d &_scale) = 0; - - /// \brief Determine if this node inherits scale from this parent - /// \return True if this node inherits scale from this parent - public: virtual bool InheritScale() const = 0; - - /// \brief Specify if this node inherits scale from its parent - /// \param[in] _inherit True if this node inherits scale from its parent - public: virtual void SetInheritScale(bool _inherit) = 0; - - /// \brief Get number of child nodes - /// \return The number of child nodes - public: virtual unsigned int ChildCount() const = 0; - - /// \brief Determine if given node is an attached child - /// \return True if given node is an attached child - public: virtual bool HasChild(ConstNodePtr _child) const = 0; - - /// \brief Determine if node with given ID is an attached child - /// \param[in] _id ID of the node in question - /// \return True if node with given ID is an attached child - public: virtual bool HasChildId(unsigned int _id) const = 0; - - /// \brief Determine if node with given name is an attached child - /// \param[in] _name Name of the node in question - /// \return True if node with given name is an attached child - public: virtual bool HasChildName(const std::string &_name) const = 0; - - /// \brief Get node with given ID. If no child exists with given ID, NULL - /// will be returned. - /// \param[in] _id ID of the desired node - /// \return The specified node - public: virtual NodePtr ChildById(unsigned int _id) const = 0; - - /// \brief Get node with given name. If no child exists with given name, - /// NULL will be returned. - /// \param[in] _name Name of the desired node - /// \return The specified node - public: virtual NodePtr ChildByName( - const std::string &_name) const = 0; - - /// \brief Get node at given index. If no child exists at given index, - /// NULL will be returned. - /// \param[in] _index Index of the desired node - /// \return The specified node - public: virtual NodePtr ChildByIndex(unsigned int _index) const = 0; - - /// \brief Add the given node to this node. If the given node is - /// already a child, no work will be done. - /// \param[in] _child Child node to be added - public: virtual void AddChild(NodePtr _child) = 0; - - /// \brief Remove (detach) the given node from this node. If the given - /// node is not a child of this node, no work will be done. - /// \param[in] _child Child node to be removed - /// \return The removed child node - public: virtual NodePtr RemoveChild(NodePtr _child) = 0; - - /// \brief Remove (detach) the node with the given ID from this node. - /// If the specified node is not a child of this node, no work will be - /// done. - /// \param[in] _id ID of the child node to be removed - /// \return The removed child node - public: virtual NodePtr RemoveChildById(unsigned int _id) = 0; - - /// \brief Remove (detach) the node with the given name from this node. - /// If the specified node is not a child of this node, no work will be - /// done. - /// \param[in] _name Name of the child node to be removed - /// \return The removed child node - public: virtual NodePtr RemoveChildByName(const std::string &_name) = 0; - - /// \brief Remove (detach) the node at the given index from this node. - /// If the specified node is not a child of this node, no work will be - /// done. - /// \param[in] _index Index of the child node to be removed - /// \return The removed child node - public: virtual NodePtr RemoveChildByIndex(unsigned int _index) = 0; - - /// \brief Remove all child nodes from this node - /// This detaches all the child nodes but does not destroy them - public: virtual void RemoveChildren() = 0; - - /// \brief Store any custom data associated with this node - /// \param[in] _key Unique key - /// \param[in] _value Value in any type - public: virtual void SetUserData( - const std::string &_key, Variant _value) = 0; - - /// \brief Get custom data stored in this node - /// \param[in] _key Unique key - /// \return Value in any type. If _key does not exist for the node, an - /// empty variant is returned (i.e., no data). - public: virtual Variant UserData(const std::string &_key) const = 0; - - /// \brief Check if node has custom data - /// \param[in] _key Unique key - /// \return True if node has custom data with the specified key - public: virtual bool HasUserData(const std::string &_key) const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Object.hh b/include/ignition/rendering/Object.hh index 45ce3e894..a3a6bcac7 100644 --- a/include/ignition/rendering/Object.hh +++ b/include/ignition/rendering/Object.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,59 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OBJECT_HH_ -#define IGNITION_RENDERING_OBJECT_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Object Object.hh ignition/rendering/Object.hh - /// \brief Represents an object present in the scene graph. This includes - /// sub-meshes, materials, render targets, as well as posable nodes. - class IGNITION_RENDERING_VISIBLE Object - { - /// \brief Destructor - public: virtual ~Object() { } - - /// \brief Get the object ID. This ID will be unique across all objects - /// inside a given scene, but necessarily true for objects across - /// different scenes. - /// \return The object ID - public: virtual unsigned int Id() const = 0; - - /// \brief Get the object name. This name will be unique across all - /// objects inside a given scene, but necessarily true for objects across - /// different scenes. - /// \return The object name - public: virtual std::string Name() const = 0; - - /// \brief Get the Scene that created this object. - /// \return The parent scene - public: virtual ScenePtr Scene() const = 0; - - /// \brief Prepare this object and any of its children for rendering. - /// This should be called for each object in a scene just before - /// rendering, which can be achieved by a single call to Scene::PreRender - public: virtual void PreRender() = 0; - - /// \brief Post process this object and any of its children after - /// rendering. - public: virtual void PostRender() = 0; - - /// \brief Destroy any resources associated with this object. Invoking - /// any other functions after destroying an object will result in - /// undefined behavior. - public: virtual void Destroy() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/OrbitViewController.hh b/include/ignition/rendering/OrbitViewController.hh index ec9743c94..d464bddb2 100644 --- a/include/ignition/rendering/OrbitViewController.hh +++ b/include/ignition/rendering/OrbitViewController.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,77 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_ORBITVIEWCONTROLLER_HH_ -#define IGNITION_RENDERING_ORBITVIEWCONTROLLER_HH_ -#include - -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/ViewController.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations - class OrbitViewControllerPrivate; - - /// \class OrbitViewController OrbitViewController.hh - /// ignition/rendering/OrbitViewController.hh - /// \brief A camera view controller - class IGNITION_RENDERING_VISIBLE OrbitViewController - : public virtual ViewController - { - /// \brief Destructor - public: OrbitViewController(); - - /// \brief Destructor - public: explicit OrbitViewController(const CameraPtr &_camera); - - /// \brief Destructor - public: virtual ~OrbitViewController(); - - /// \brief Set the camera that will be controlled by this view controller. - /// \param[in] _camera Camera to control - public: virtual void SetCamera(const CameraPtr &_camera); - - /// \brief Get the camera that is controlled by this view controller. - /// \return Camera being controlled - public: virtual CameraPtr Camera() const; - - /// \brief Set target point for pan, zoom, oribit - /// \param[in] _target Target point in world coordinates - public: virtual void SetTarget(const math::Vector3d &_target); - - /// \brief Get target point for pan, zoom, oribit - /// \return target point in world coordinates - public: virtual const math::Vector3d &Target() const; - - /// \brief Set zoom amount - /// \param[in] _value Camera zoon value, e.g. mouse scroll delta - public: virtual void Zoom(const double _value); - - /// \brief Set camera pan (translational movement) around target point. - /// \param[in] _value Pan amount in image plane, e.g. mouse drag delta. - public: virtual void Pan(const math::Vector2d &_value); - - /// \brief Set camera orbit (rotational movement) around target point. - /// \param[in] _value robit amount in image plane, e.g. mouse drag delta - public: virtual void Orbit(const math::Vector2d &_value); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Private data pointer - public: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/OrthoViewController.hh b/include/ignition/rendering/OrthoViewController.hh index 59d7b05f9..c189c8523 100644 --- a/include/ignition/rendering/OrthoViewController.hh +++ b/include/ignition/rendering/OrthoViewController.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,80 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_ORTHOVIEWCONTROLLER_HH_ -#define IGNITION_RENDERING_ORTHOVIEWCONTROLLER_HH_ + */ -#include -#include -#include - -#include "ignition/rendering/ViewController.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declare private data pointer. - class OrthoViewControllerPrivate; - - /// \class OrthoViewController OrthoViewController.hh - /// \brief Orthographic view controller - class IGNITION_RENDERING_VISIBLE OrthoViewController - : public virtual ViewController - { - /// \brief Constructor - public: OrthoViewController(); - - /// \brief Constructor. - /// \param[in] _camera Pointer to the camera to control. - public: explicit OrthoViewController(const CameraPtr &_camera); - - /// \brief Destructor. - public: virtual ~OrthoViewController(); - - /// \brief Set the camera that will be controlled by this view controller. - /// \param[in] _camera Camera to control - public: virtual void SetCamera(const CameraPtr &_camera); - - /// \brief Get the camera that is controlled by this view controller. - /// \return Camera being controlled - public: virtual CameraPtr Camera() const; - - /// \brief Set target point for pan, zoom, oribit - /// \param[in] _target Target point in world coordinates - public: virtual void SetTarget(const math::Vector3d &_target); - - /// \brief Get target point for pan, zoom, oribit - /// \return target point in world coordinates - public: virtual const math::Vector3d &Target() const; - - /// \brief Set zoom amount - /// \param[in] _value Camera zoon value, e.g. mouse scroll delta - public: virtual void Zoom(const double _value); - - /// \brief Set camera pan (translational movement) around target point. - /// \param[in] _value Pan amount in image plane, e.g. mouse drag delta. - public: virtual void Pan(const math::Vector2d &_value); - - /// \brief Set camera orbit (rotational movement) around target point. - /// \param[in] _value robit amount in image plane, e.g. mouse drag delta - public: virtual void Orbit(const math::Vector2d &_value); - - /// \brief Resize and update the camera projection matrix - /// \param[in] _width Image width - /// \param[in] _height Image height - private: virtual void Resize(const unsigned int _width, - const unsigned int _height); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Private data pointer - public: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/ParticleEmitter.hh b/include/ignition/rendering/ParticleEmitter.hh index 3cd481b01..d9b1b9b3c 100644 --- a/include/ignition/rendering/ParticleEmitter.hh +++ b/include/ignition/rendering/ParticleEmitter.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,250 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_PARTICLEEMITTER_HH_ -#define IGNITION_RENDERING_PARTICLEEMITTER_HH_ -#include -#include "ignition/math/Color.hh" -#include "ignition/math/Pose3.hh" -#include "ignition/math/Vector3.hh" -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Enum for emitter types. - enum IGNITION_RENDERING_VISIBLE EmitterType - { - /// \brief Point emitter. - EM_POINT = 0, - - /// \brief Box emitter. - EM_BOX = 1, - - /// \brief Cylinder emitter. - EM_CYLINDER = 2, - - /// \brief Ellipsoid emitter. - EM_ELLIPSOID = 3, - - /// \brief Total number of emitters (keep always at the end). - EM_NUM_EMITTERS = 4, - }; - - /// \class ParticleEmitter ParticleEmitter.hh - /// ignition/rendering/ParticleEmitter.hh - // - /// \brief Class to manage a particle emitter. - class IGNITION_RENDERING_VISIBLE ParticleEmitter : - public virtual Visual - { - /// \brief Destructor - public: virtual ~ParticleEmitter() {} - - /// \brief \brief Get the emitter type. - /// \return Emitter type. - /// \sa EmitterType. - /// \sa SetType. - public: virtual EmitterType Type() const = 0; - - /// \brief \brief Set the emitter type. - /// Default value is EM_POINT. - /// \param[in] _type Emitter type. - /// \sa EmitterType. - /// \sa Type. - public: virtual void SetType(const EmitterType _type) = 0; - - /// \brief Get the size of the emitter where the particles are sampled. - /// \return The emitter size. See SetEmitterSize() for the interpretation - /// of the dimensions depending on the emitter type. - /// \sa SetEmitterSize - public: virtual ignition::math::Vector3d EmitterSize() const = 0; - - /// \brief Set the size of the emitter where the particles are sampled. - /// Default value is (1, 1, 1). - /// Note that the interpretation of the emitter area varies depending on - /// the emmiter type: - /// - EM_POINT: The area is ignored. - /// - EM_BOX: The area is interpreted as width X height X depth. - /// - EM_CYLINDER: The area is interpreted as the bounding box of the - /// cilinder. The cylinder is oriented along the Z-axis. - /// - EM_ELLIPSOID: The area is interpreted as the bounding box of an - /// ellipsoid shaped area, i.e. a sphere or - /// squashed-sphere area. The parameters are again - /// identical to EM_BOX, except that the dimensions - /// describe the widest points along each of the axes. - /// \param[in] _size Size of the emitter (width, height, depth). - /// \sa EmitterSize - public: virtual void SetEmitterSize( - const ignition::math::Vector3d &_size) = 0; - - /// \brief Get how many particles per second should be emitted. - /// \return Particles per second. - /// \sa SetRate - public: virtual double Rate() const = 0; - - /// \brief Set how many particles per second should be emitted. - /// Default value is 10. - /// \param[in] _rate Particles per second. - /// \sa Rate - public: virtual void SetRate(double _rate) = 0; - - /// \brief Get the number of seconds the emitter is active. - /// A value of 0 means infinite duration. - /// \return Total duration of the emitter (seconds). - /// \sa SetDuration - public: virtual double Duration() const = 0; - - /// \brief Set the number of seconds the emitter is active. - /// A value of 0 means infinite duration. - /// Default value is 0. - /// \param[in] _duration Total duration of the emitter (seconds). - /// \sa Duration - public: virtual void SetDuration(double _duration) = 0; - - /// \brief Is the particle emitter enabled? - /// \return True when enabled or false otherwise. - /// \sa SetEmitting - public: virtual bool Emitting() const = 0; - - /// \brief This is used to turn on or off particle emission. - /// Default value is false. - /// \param[in] _enable True for enabling the emission or false otherwise. - /// \sa Emitting - public: virtual void SetEmitting(bool _enable) = 0; - - /// \brief Get the particle dimensions (width, height, depth). - /// \return Particle dimensions. - /// \sa SetParticleSize - public: virtual ignition::math::Vector3d ParticleSize() const = 0; - - /// \brief Set the particle dimensions (width, height, depth). - /// Default value is {1, 1, 1}. - /// \param[in] _size Particle dimensions. - /// \sa ParticleSize - public: virtual void SetParticleSize( - const ignition::math::Vector3d &_size) = 0; - - /// \brief Get the number of seconds each particle will ’live’ for before - /// being destroyed. - /// \return Lifetime of each particle (seconds). - /// \sa SetLifetime - public: virtual double Lifetime() const = 0; - - /// \brief Set the number of seconds each particle will ’live’ for before - /// being destroyed. - /// Default value is 5. - /// \param[in] _lifetime Lifetime of each particle (seconds). - /// \sa Lifetime - public: virtual void SetLifetime(double _lifetime) = 0; - - /// \brief Get the material which all particles in the emitter will use. - /// \return The material pointer. - /// \sa SetMaterial - public: virtual MaterialPtr Material() const = 0; - - /// \brief Sets the material which all particles in the emitter will use. - /// \param[in] _material The material pointer. - /// \sa Material - public: virtual void SetMaterial(const MaterialPtr &_material) = 0; - - /// \brief Get the minimum velocity each particle is emitted (m/s). - /// \return Minimum velocity. - /// \sa MaxVelocity - /// \sa SetVelocityRange - public: virtual double MinVelocity() const = 0; - - /// \brief Get the maximum velocity each particle is emitted (m/s). - /// \return Maximum velocity. - /// \sa MinVelocity - /// \sa SetVelocityRange - public: virtual double MaxVelocity() const = 0; - - /// \brief Set a velocity range and each particle is emitted with a - /// random velocity within this range (m/s). - /// Default value is 1 for both velocities. - /// \param[in] _minVelocity Minimum velocity. - /// \param[in] _maxVelocity Maximum velocity. - /// \sa MinVelocity - /// \sa MaxVelocity - public: virtual void SetVelocityRange(double _minVelocity, - double _maxVelocity) = 0; - - /// \brief Get the starting color of the particles. - /// \return Start color. - /// \sa ColorEnd - /// \sa SetColorRange - public: virtual ignition::math::Color ColorStart() const = 0; - - /// \brief Get the end color of the particles. - /// \return End color. - /// \sa ColorStart - /// \sa SetColorRange - public: virtual ignition::math::Color ColorEnd() const = 0; - - /// \brief Sets a color for all particle emitted. - /// The actual color will be interpolated between these two colors - /// Color::White is the default color for the particles unless a specific - /// function is used. - /// Note that this function overrides the particle colors set with - /// SetColorRangeImage(). - /// \param[in] _colorStart Start color. - /// \param[in] _colorEnd End color. - /// \sa ColorStart - /// \sa ColorEnd - public: virtual void SetColorRange( - const ignition::math::Color &_colorStart, - const ignition::math::Color &_colorEnd) = 0; - - /// \brief Get the amount by which to scale the particles in both x and y - /// direction per second. - /// Default value is 1. - /// \return The scale rate. - /// \sa SetScaleRate - public: virtual double ScaleRate() const = 0; - - /// \brief Set the amount by which to scale the particles in both x and y - /// direction per second. - /// \param[in] _scaleRate The scale rate. - /// \sa ScaleRate - public: virtual void SetScaleRate(double _scaleRate) = 0; - - /// \brief Get the path to the color image used as an affector. - /// \return The color image name or empty string if the image is not set. - /// \sa SetColorRangeImage - public: virtual std::string ColorRangeImage() const = 0; - - /// \brief Set the path to the color image used as an affector. This - /// affector modifies the color of particles in flight. The colors are - /// taken from a specified image file. The range of color values begins - /// from the left side of the image and move to the right over the - /// lifetime of the particle, therefore only the horizontal dimension of - /// the image is used. - /// Note that this function overrides the particle colors set with - /// SetColorRange(). - /// \param[in] _image The color image name. - /// \sa ColorRangeImage - public: virtual void SetColorRangeImage(const std::string &_image) = 0; - - /// \brief Get the particle scatter ratio. - /// \return The particle scatter ratio. - /// \sa SetParticleScatterRatio - public: virtual float ParticleScatterRatio() const = 0; - - /// \brief Set the particle scatter ratio. - /// \param[in] _ratio The scatter ratio. The particle emitter's scatter - /// ratio will only be set to _ratio if _ratio > 0. - /// \sa ParticleScatterRatio - public: virtual void SetParticleScatterRatio(float _ratio) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/PixelFormat.hh b/include/ignition/rendering/PixelFormat.hh index 06f8b1dad..d01a8eb86 100644 --- a/include/ignition/rendering/PixelFormat.hh +++ b/include/ignition/rendering/PixelFormat.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,119 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_PIXELFORMAT_HH_ -#define IGNITION_RENDERING_PIXELFORMAT_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \enum PixelFormat PixelFormat.hh ignition/rendering/PixelFormat.hh - /// \brief Image pixel format types - enum IGNITION_RENDERING_VISIBLE PixelFormat - { - /// < Unknown or errant type - PF_UNKNOWN = 0, - /// < Grayscale, 1-byte per channel - PF_L8 = 1, - /// < RGB, 1-byte per channel - PF_R8G8B8 = 2, - /// < BGR, 1-byte per channel - PF_B8G8R8 = 3, - /// < Bayer RGGB, 1-byte per channel - PF_BAYER_RGGB8 = 4, - /// < Bayer BGGR, 1-byte per channel - PF_BAYER_BGGR8 = 5, - /// < Bayer GBGR, 1-byte per channel - PF_BAYER_GBGR8 = 6, - /// < Bayer GRGB, 1-byte per channel - PF_BAYER_GRGB8 = 7, - // Float32 format one channel - PF_FLOAT32_R = 8, - // Float32 format and RGB - PF_FLOAT32_RGBA = 9, - // Float32 format and RGB - PF_FLOAT32_RGB = 10, - // 16 bit single channel - PF_L16 = 11, - /// < RGBA, 1-byte per channel - PF_R8G8B8A8 = 12, - /// < Number of pixel format types - PF_COUNT = 13 - }; - - /// \class PixelUtil PixelFormat.hh ignition/rendering/PixelFormat.hh - /// \brief Provides supporting functions for PixelFormat enum - class IGNITION_RENDERING_VISIBLE PixelUtil - { - /// \brief Determine if given format is valid PixelFormat enum - /// \param[in] _format Enum value to be evaluated - public: static bool IsValid(PixelFormat _format); - - /// \brief Sanitize given format. If the given value is invalid, - /// PF_UNKNOWN will be returned, otherwise input will be returned - /// unchanged. - /// \param[in] _format Image pixel format to be sanitized - /// \return The sanitized pixel format - public: static PixelFormat Sanitize(PixelFormat _format); - - /// \brief Get human-readable name for pixel format value. - /// \param[in] _format Image pixel format - /// \return The format name - public: static std::string Name(PixelFormat _format); - - /// \brief Get number of channels for given format. If an invalid format - /// is given, 0 will be returned. - /// \param[in] _format Image pixel format - /// \return The channel count - public: static unsigned int ChannelCount(PixelFormat _format); - - /// \brief Get number of bytes per channel for given format. If an invalid - /// format is given, 0 will be returned. - /// \param[in] _format Image pixel format - /// \return The number of bytes per channel - public: static unsigned int BytesPerChannel(PixelFormat _format); - - /// \brief Get number of bytes per pixel for given format. If an invalid - /// format is given, 0 will be returned. This is simply the product of - /// GetChannelCount and GetBytesPerChannel. - /// \return The number of bytes per pixel - public: static unsigned int BytesPerPixel(PixelFormat _format); - - /// \brief Get total memory size in bytes for an image with the given - /// format and dimensions. If an invalid format is given, 0 will be - /// returned. This is simply the product of GetBytesPerPixel, _width, - /// and, _height. - /// \param[in] _format Image pixel format - /// \param[in] _width Image width in pixels - /// \param[in] _height Image height in pixels - /// \return The number of bytes per pixel - public: static unsigned int MemorySize(PixelFormat _format, - unsigned int _width, unsigned int _height); - - /// \brief Get enum value by human-readable name. The given string should - /// match watch is returned by GetName. If an invalid name is given, - /// PF_UNKNOWN will be returned. - /// \param[in] _name Name of the pixel format to be retrieved - /// \return The specified PixelFormat enum value - public: static PixelFormat Enum(const std::string &_name); - - /// \brief Array of human-readable names for each PixelFormat - private: static const char *names[PF_COUNT]; - - /// \brief Array of channel counts for each PixelFormat - private: static const unsigned char channelCounts[PF_COUNT]; - - /// \brief Array of bytes per channel for each PixelFormat - private: static const unsigned char channelByteCounts[PF_COUNT]; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RayQuery.hh b/include/ignition/rendering/RayQuery.hh index b1402075e..b4c6174f9 100644 --- a/include/ignition/rendering/RayQuery.hh +++ b/include/ignition/rendering/RayQuery.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,85 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RAYQUERY_HH_ -#define IGNITION_RENDERING_RAYQUERY_HH_ -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief A class that stores ray query intersection results. - class IGNITION_RENDERING_VISIBLE RayQueryResult - { - /// \brief Intersection distance - public: double distance = -1; - - /// \brief Intersection point in 3d space - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public: math::Vector3d point; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Intersected object id - public: unsigned int objectId = 0; - - /// \brief Returns false if result is not valid - public: operator bool() const - { - return distance > 0; - } - - /// \brief Returns false if result is not valid - public: operator bool() - { - return distance > 0; - } - }; - - /// \class RayQuery RayQuery.hh ignition/rendering/RayQuery.hh - /// \brief A Ray Query class used for computing ray object intersections - class IGNITION_RENDERING_VISIBLE RayQuery - : public virtual Object - { - /// \brief Destructor - public: virtual ~RayQuery() { } - - /// \brief Set ray origin - /// \param[in] _origin Ray origin - public: virtual void SetOrigin(const math::Vector3d &_origin) = 0; - - /// \brief Get ray origin - /// \return Ray origin - public: virtual math::Vector3d Origin() const = 0; - - /// \brief Set ray direction - /// \param[in] _dir Ray origin - public: virtual void SetDirection(const math::Vector3d &_dir) = 0; - - /// \brief Get ray direction - /// \return Ray direction. - public: virtual math::Vector3d Direction() const = 0; - - /// \brief Create the ray query from camera - /// \param[in] _camera Camera to construct ray - /// \param[in] _coord normalized device coords [-1, +1] - public: virtual void SetFromCamera(const CameraPtr &_camera, - const math::Vector2d &_coord) = 0; - - /// \brief Compute intersections - /// \return A vector of intersection results - public: virtual RayQueryResult ClosestPoint() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderEngine.hh b/include/ignition/rendering/RenderEngine.hh index a1b3d2b5c..e76cf64ba 100644 --- a/include/ignition/rendering/RenderEngine.hh +++ b/include/ignition/rendering/RenderEngine.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,172 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERENGINE_HH_ -#define IGNITION_RENDERING_RENDERENGINE_HH_ -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class RenderEngine RenderEngine.hh ignition/rendering/RenderEngine.hh - /// \brief An abstract interface to a concrete render-engine. A - /// RenderEngine is responsible for initializing a render-engine as well as - /// creating, storing, and destroying scenes. - class IGNITION_RENDERING_VISIBLE RenderEngine - { - /// \brief Destructor - public: virtual ~RenderEngine() { } - - /// \brief Load any necessary resources to set up render-engine. This - /// should called before any other function. - /// \param[in] _params Parameters to be passed to the underlying - /// rendering engine. - /// \return True if the render-engine was successfully loaded - public: virtual bool Load( - const std::map &_params = {}) = 0; - - /// \brief Initialize the render-engine. This should be called immediately - /// after a successful call to Load. - /// \return True if the render-engine was successfully initialized - public: virtual bool Init() = 0; - - /// \brief Destroys all scenes created by render-engine and releases all - /// loaded resources. This should be called when the given render-engine - /// will no longer be used during runtime. - /// \return True if the render-engine was successfully destroyed - public: virtual void Destroy() = 0; - - // TODO(anyone): merge with Destroy - public: virtual bool Fini() = 0; - - /// \brief Determines if the render-engine has been loaded. - /// \return True if the render-engine is loaded - public: virtual bool IsLoaded() const = 0; - - /// \brief Determines if the render-engine has been initialized. - /// \return True if the render-engine is initialized - public: virtual bool IsInitialized() const = 0; - - /// \brief Determines if the render-engine can be used. Despite loading - /// and initializing the render-engine, it may not be possible to use due - /// to hardware capabilities of the runtime system. - /// \return True if the render-engine can be used - public: virtual bool IsEnabled() const = 0; - - /// \brief Get name of the render-engine. - /// \return The render-engine name - public: virtual std::string Name() const = 0; - - /// \brief Get the number of scenes actively managed by this - /// render-engine - /// \return The number of active scenes - public: virtual unsigned int SceneCount() const = 0; - - /// \brief Determine if the given scene is actively managed by this - /// render-engine - /// \param[in] _scene Scene in question - /// \return True if the scene is managed by this render-engine - public: virtual bool HasScene(ConstScenePtr _scene) const = 0; - - /// \brief Determine if this render-engine manages a scene with the - /// given ID. - /// \param[in] _id ID of scene in question - /// \return True if this render-engine manages the specified scene - public: virtual bool HasSceneId(unsigned int _id) const = 0; - - /// \brief Determine if this render-engine manages a scene with the - /// given name. - /// \param[in] _name Name of scene in question - /// \return True if this render-engine manages the specified scene - public: virtual bool HasSceneName(const std::string &_name) const = 0; - - /// \brief Get the scene with the given ID. If no scenes exist with the - /// given ID, NULL will be returned. - /// \param[in] _id ID of scene to be retrieved - /// \return The specified scene - public: virtual ScenePtr SceneById(unsigned int _id) const = 0; - - /// \brief Get the scene with the given name. If no scenes exist with the - /// given name, NULL will be returned. - /// \param[in] _name Name of scene to be retrieved - /// \return The specified scene - public: virtual ScenePtr SceneByName( - const std::string &_name) const = 0; - - /// \brief Get the scene at the given index. If no scenes exist at the - /// given index, NULL will be returned. - /// \param[in] _index Index of scene, which is a number from 0 to - /// SceneCount() - 1. Note that the index for a specific scene might - /// change as other scenes are destroyed. - /// \return The specified scene - public: virtual ScenePtr SceneByIndex(unsigned int _index) const = 0; - - /// \brief Destroy the given scene. If the given scene is not managed by - /// this render-engine, no work will be done. - /// \param[in] _scene Scene to be destroyed - public: virtual void DestroyScene(ScenePtr _scene) = 0; - - /// \brief Destroy the scene with the given ID. If no scenes exist with - /// the given ID, no work will be done. - /// \param[in] _id ID of the scene to destroy - public: virtual void DestroySceneById(unsigned int _id) = 0; - - /// \brief Destroy the scene with the given name. If no scenes exist with - /// the given name, no work will be done. - /// \param[in] _name Name of the scene to destroy - public: virtual void DestroySceneByName(const std::string &_name) = 0; - - /// \brief Destroy the scene at the given index. If no scenes exist at the - /// given index, no work will be done. - /// \param[in] _index Index of the scene to destroy - public: virtual void DestroySceneByIndex(unsigned int _index) = 0; - - /// \brief Destroy all scenes managed by this render-engine - public: virtual void DestroyScenes() = 0; - - /// \brief Create a new scene with the given name. The given name should - /// be unique across all scenes managed by this render-engine. If a - /// duplicate name is given, NULL will be returned. An unique ID will - /// automatically be assigned to the created scene. - /// \param[in] _name Name of the new scene - /// \return The created scene - public: virtual ScenePtr CreateScene(const std::string &_name) = 0; - - /// \brief Create a new scene with the given ID. The given ID should - /// be unique across all scenes managed by this render-engine. If a - /// duplicate ID is given, NULL will be returned. An unique name will - /// automatically be assigned to the created scene. - /// \param[in] _id ID of the new scene - /// \param[in] _name Name of the new scene - /// \return The created scene - public: virtual ScenePtr CreateScene(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Set headless mode - /// Only available in OGRE 2.2, which makes use of EGL - /// \param[in] _headless Set to true to enable headless mode. - public: virtual void SetHeadless(bool _headless) = 0; - - /// \brief Get headless mode - /// \return True if headless mode is enable, false otherwise. - public: virtual bool Headless() const = 0; - - /// \brief Add path to media resource location - /// \param[in] _path Absolute path to resource location - public: virtual void AddResourcePath(const std::string &_path) = 0; - - /// \brief Get the render pass system for this engine. - public: virtual RenderPassSystemPtr RenderPassSystem() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderEngineManager.hh b/include/ignition/rendering/RenderEngineManager.hh index cf80edd82..162ba7f0b 100644 --- a/include/ignition/rendering/RenderEngineManager.hh +++ b/include/ignition/rendering/RenderEngineManager.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,136 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERENGINEMANAGER_HH_ -#define IGNITION_RENDERING_RENDERENGINEMANAGER_HH_ -#include -#include -#include -#include -#include -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations. - class RenderEngine; - class RenderEngineManagerPrivate; - - /// \class RenderEngineManager RenderEngineManager.hh - /// ignition/rendering/RenderEngineManager.hh - /// \brief Collection of render-engines. This provides access to all the - /// render-engines available at runtime. RenderEngine objects should not - /// be access directly, but instead via the RenderEngineManager to maintain - /// a flexible render-engine agnostic design. - class IGNITION_RENDERING_VISIBLE RenderEngineManager : - public virtual common::SingletonT - { - /// \brief Constructor - public: RenderEngineManager(); - - /// \brief Destructor - public: ~RenderEngineManager(); - - /// \brief Get the number of available render-engines - /// \return the number of available render-engines - public: unsigned int EngineCount() const; - - /// \brief Determine if a render-engine with the given name is avaiable. - /// It also checks the list of default engines supplied by ign-rendering. - /// \param[in] _name Name of the desired render-engine - /// \return True if the specified render-engine is available - public: bool HasEngine(const std::string &_name) const; - - /// \brief Determine if a render-engine with the given name is already - /// loaded. - /// \param[in] _name Name of the desired render-engine - /// \return True if the specified render-engine is loaded. - public: bool IsEngineLoaded(const std::string &_name) const; - - /// \brief Get the list of all engines already loaded. - /// \return Names of all loaded engines. - public: std::vector LoadedEngines() const; - - /// \brief Get the render-engine with the given name. If the no - /// render-engine is registered under the given name, NULL will be - /// returned. - /// \param[in] _name Name of the desired render-engine - /// \param[in] _params Parameters to be passed to the render engine. - /// \param[in] _path Another search path for rendering engine plugin. - /// \return The specified render-engine - public: RenderEngine *Engine(const std::string &_name, - const std::map &_params = {}, - const std::string &_path = ""); - - /// \brief Get the render-engine at the given index. If no - /// render-engine is exists at the given index, NULL will be returned. - /// \param[in] _index Index of the desired render-engine - /// \param[in] _params Parameters to be passed to the render engine. - /// \param[in] _path Another search path for rendering engine plugin. - /// \return The specified render-engine - public: RenderEngine *EngineAt(unsigned int _index, - const std::map &_params = {}, - const std::string &_path = ""); - - /// \brief Unload the render-engine with the given name. If the no - /// render-engine is registered under the given name, false will be - /// returned. - /// \param[in] _name Name of the desired render-engine - /// \return True if the engine is unloaded - public: bool UnloadEngine(const std::string &_name); - - /// \brief Unload the render-engine at the given index. If the no - /// render-engine is registered under the given name, false will be - /// returned. - /// \param[in] _index Index of the desired render-engine - /// \return True if the engine is unloaded - public: bool UnloadEngineAt(unsigned int _index); - - /// \brief Register a new render-engine under the given name. If the - /// given name is already in use, the render-engine will not be - /// registered. - /// \param[in] _name Name the render-engine will be registered under - /// \param[in] _engine Render-engine to be registered - public: void RegisterEngine(const std::string &_name, - RenderEngine *_engine); - - /// \brief Unregister a render-engine registered under the given name. - /// If no render-engine is registered under the given name no work - /// will be done. - /// \param[in] _name Name of the render-engine to unregister - public: void UnregisterEngine(const std::string &_name); - - /// \brief Unregister the given render-engine. If the given render-engine - /// is not currently registered, no work will be done. - /// \param[in] _engine Render-engine to unregister - public: void UnregisterEngine(RenderEngine *_engine); - - /// \brief Unregister a render-engine at the given index. If the no - /// render-engine is registered at the given index, no work will be done. - /// \param[in] _index Index of the render-engine to unregister - public: void UnregisterEngineAt(unsigned int _index); - - /// \brief Set the plugin paths from which render engines can be loaded. - /// \param[in] _paths The list of the plugin paths - public: void SetPluginPaths(const std::list &_paths); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief private implementation details - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief required SingletonT friendship - private: friend class ignition::common::SingletonT; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderEnginePlugin.hh b/include/ignition/rendering/RenderEnginePlugin.hh index c64c9558f..cdb9d5a3e 100644 --- a/include/ignition/rendering/RenderEnginePlugin.hh +++ b/include/ignition/rendering/RenderEnginePlugin.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,50 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_RENDERENGINEPLUGIN_HH_ -#define IGNITION_RENDERING_RENDERENGINEPLUGIN_HH_ - -#include -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declarations - class RenderEngine; - class RenderEnginePluginPrivate; - - /// \brief Base plugin class for render engines - class IGNITION_RENDERING_VISIBLE RenderEnginePlugin - { - /// \brief Constructor - public: RenderEnginePlugin(); - - /// \brief Destructor - public: virtual ~RenderEnginePlugin(); - - /// \brief Get the name of render engine - /// \return Name of render engine - public: virtual std::string Name() const = 0; - - /// \brief Get a pointer to the render engine - /// \return Render engine instance - public: virtual RenderEngine *Engine() const = 0; - - /// \brief Pointer to private data class - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderPass.hh b/include/ignition/rendering/RenderPass.hh index 6d9b611f4..41028ee1a 100644 --- a/include/ignition/rendering/RenderPass.hh +++ b/include/ignition/rendering/RenderPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,38 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERPASS_HH_ -#define IGNITION_RENDERING_RENDERPASS_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class RenderPass RenderPass.hh ignition/rendering/RenderPass.hh - /// \brief A render pass can be added to a camera to affect how the scene - /// is rendered. It can be used to add post-processing effects. Multiple - /// passes can be chained together. - class IGNITION_RENDERING_VISIBLE RenderPass - : public virtual Object - { - /// \brief Destructor - public: virtual ~RenderPass() { } - - /// \brief Set to enable or disable the render pass - /// \param[in] _enabled True to enable the render pass, false to disable. - public: virtual void SetEnabled(bool _enabled) = 0; - - /// \brief Get whether or not the render pass is enabled - /// \return True if the render pass is enabled, false otherwise. - public: virtual bool IsEnabled() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderPassSystem.hh b/include/ignition/rendering/RenderPassSystem.hh index 3bcb5466c..a45a54c08 100644 --- a/include/ignition/rendering/RenderPassSystem.hh +++ b/include/ignition/rendering/RenderPassSystem.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,99 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERPASSSYSTEM_HH_ -#define IGNITION_RENDERING_RENDERPASSSYSTEM_HH_ -#include -#include -#include -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/RenderPass.hh" -#include "ignition/rendering/RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class RenderPassSystemPrivate; - - /* \class RenderPassFactory RenderPassSystem.hh \ - * ignition/rendering/RenderPassSystem.hh - */ - /// \brief A factory interface for creating render passes - class IGNITION_RENDERING_VISIBLE RenderPassFactory - { - /// \brief Instantiate new render pass - /// \return New render pass - public: virtual RenderPass *New() const = 0; - }; - - /* \class RenderPassSystem RenderPassSystem.hh \ - * ignition/rendering/RenderPassSystem.hh - */ - /// \brief A class for creating and managing render passes - class IGNITION_RENDERING_VISIBLE RenderPassSystem - { - /// \brief Constructor - public: RenderPassSystem(); - - /// \brief Destructor - public: virtual ~RenderPassSystem(); - - /// \brief Templated function for creating render passes - /// \return Pointer to the render pass created - public: template RenderPassPtr Create() - { - return this->CreateImpl(typeid(T).name()); - } - - /// \brief Register a render pass factory to the system - /// \param[in] _type Render pass type, i.e. type id of render pass class - /// \param[in] _factory Factory used to create the render pass - public: static void Register(const std::string &_type, - RenderPassFactory *_factory); - - /// \brief Implementation for creating render passes - /// \param[in] _type Render pass type, i.e. type id of render pass class - /// \return Pointer to the render pass created - private: RenderPassPtr CreateImpl(const std::string &_type); - - /// \brief A map of render pass type id name to its factory class - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: static std::map renderPassMap; - - /// \internal - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - - /// \brief Render pass registration macro - /// - /// Use this macro to register render pass with the render pass factory. - #define IGN_RENDERING_REGISTER_RENDER_PASS(classname, interface) \ - class classname##Factory : public ignition::rendering::RenderPassFactory \ - { \ - public: classname##Factory() \ - { \ - ignition::rendering::RenderPassSystem::Register( \ - typeid(interface).name(), this); \ - } \ - public: RenderPass *New() const override \ - { \ - return new classname(); \ - } \ - }; \ - static classname##Factory global_##classname##Factory; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderTarget.hh b/include/ignition/rendering/RenderTarget.hh index 8a37987a1..00b7b0f6a 100644 --- a/include/ignition/rendering/RenderTarget.hh +++ b/include/ignition/rendering/RenderTarget.hh @@ -1,7 +1,7 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * - * Licensed under the Apache License, Version 2.0 (the "License") = 0; + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -14,140 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERTARGET_HH_ -#define IGNITION_RENDERING_RENDERTARGET_HH_ -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class RenderTarget RenderTarget.hh ignition/rendering/RenderTarget.hh - /// \brief Represents a render-target to which cameras can render images. - class IGNITION_RENDERING_VISIBLE RenderTarget : - public virtual Object - { - /// \brief Destructor - public: virtual ~RenderTarget() { } - - /// \brief Get render target width in pixels - /// \return The render target width in pixels - public: virtual unsigned int Width() const = 0; - - /// \brief Get render target height in pixels - /// \return The Render target height in pixels - public: virtual unsigned int Height() const = 0; - - /// \brief Set the render target width in pixels - /// \param[in] _width New render target width in pixels - public: virtual void SetWidth(const unsigned int _width) = 0; - - /// \brief Set the render target height in pixels - /// \param[in] _height New render target height in pixels - public: virtual void SetHeight(const unsigned int _height) = 0; - - /// \brief Set the render target image format - /// \return Render target format - public: virtual PixelFormat Format() const = 0; - - /// \brief Set the render target image format - /// \param[in] _format New target format - public: virtual void SetFormat(PixelFormat _format) = 0; - - /// \brief Write rendered image to given Image. The RenderTarget will - /// convert the underlying image to the specified format listed in the - /// given Image. However if the given image is not of the correct size no - /// work will be done. Calling this function before an image has been - /// rendered will result in undefined behavior. - /// \param[out] _image Image to which output will be written - public: virtual void Copy(Image &_image) const = 0; - - /// \brief Get the background color of the render target. - /// This should be the same as the scene background color. - /// \return Render target background color. - public: virtual math::Color BackgroundColor() const = 0; - - /// \brief Add a render pass to the render target - /// \param[in] _pass New render pass to add - public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0; - - /// \brief Remove a render pass from the render target - /// \param[in] _pass render pass to remove - public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) = 0; - - /// \brief Get the number of render passes applied to the render target - /// \return Number of render passes applied - public: virtual unsigned int RenderPassCount() const = 0; - - /// \brief Get a render pass by index - /// \return Render pass at the specified index - public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) - const = 0; - }; - - /* \class RenderTexture RenderTexture.hh \ - * ignition/rendering/RenderTexture.hh - */ - /// \brief Represents a off-screen render-texture to which cameras can - /// render images. - class IGNITION_RENDERING_VISIBLE RenderTexture : - public virtual RenderTarget - { - /// \brief Destructor - public: virtual ~RenderTexture() { } - - /// \brief Returns the OpenGL texture Id. A valid Id is returned only - // if this is an OpenGL render texture - public: virtual unsigned int GLId() const = 0; - }; - - /* \class RenderWindow RenderWindow.hh \ - * ignition/rendering/RenderWindow.hh - */ - /// \brief Represents a on-screen render-window to which cameras can - /// render images. - class IGNITION_RENDERING_VISIBLE RenderWindow : - public virtual RenderTarget - { - /// \brief Destructor - public: virtual ~RenderWindow() { } - - /// \brief Get the window handle that the render window is attached to. - /// \return Window handle - public: virtual std::string Handle() const = 0; - - /// \brief Set the window handle to attach the render window to - /// \param[in] _handle Window handle - public: virtual void SetHandle(const std::string &_handle) = 0; - - /// \brief Get the device to pixel ratio - /// \return Device to pixel ratio - public: virtual double DevicePixelRatio() const = 0; - - /// \brief Set the device to pixel ratio - /// \param[in] _ratio Device to pixel ratio - public: virtual void SetDevicePixelRatio(const double _ratio) = 0; - - /// \brief Alert the window of a window resize event - /// \param[in] _width New window width in pixels - /// \param[in] _height New window height in pixels - public: virtual void OnResize(unsigned int _width, - unsigned int _height) = 0; - - /// \brief Alert the window of a window move event - public: virtual void OnMove() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderTypes.hh b/include/ignition/rendering/RenderTypes.hh index 1dfd10edd..7a3a038b4 100644 --- a/include/ignition/rendering/RenderTypes.hh +++ b/include/ignition/rendering/RenderTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,411 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERTYPES_HH_ -#define IGNITION_RENDERING_RENDERTYPES_HH_ -#include +#include #include - - -/// \typedef IGN_VISIBILITY_ALL -/// \brief Render everything visibility mask. -#define IGN_VISIBILITY_ALL 0x0FFFFFFF - -/// \typedef IGN_VISIBILITY_SELECTION -/// \brief Renders only objects that can be selected. -#define IGN_VISIBILITY_SELECTION 0x10000000 - -/// \typedef IGN_VISIBILITY_GUI -/// \brief Render GUI visuals mask. -#define IGN_VISIBILITY_GUI 0x00000001 - -/// \typedef IGN_VISIBILITY_SELECTABLE -/// \brief Render visuals that are selectable mask. -#define IGN_VISIBILITY_SELECTABLE 0x00000002 - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - using shared_ptr = std::shared_ptr; - - class ArrowVisual; - class AxisVisual; - class BoundingBoxCamera; - class Camera; - class Capsule; - class COMVisual; - class DepthCamera; - class DirectionalLight; - class DistortionPass; - class GaussianNoisePass; - class Geometry; - class GizmoVisual; - class GpuRays; - class Grid; - class Heightmap; - class Image; - class InertiaVisual; - class Light; - class LightVisual; - class JointVisual; - class LidarVisual; - class Light; - class Marker; - class Material; - class Mesh; - class Node; - class Object; - class ObjectFactory; - class ParticleEmitter; - class PointLight; - class RayQuery; - class RenderEngine; - class RenderPass; - class RenderPassSystem; - class RenderTarget; - class RenderTexture; - class RenderWindow; - class Scene; - class SegmentationCamera; - class Sensor; - class ShaderParams; - class SpotLight; - class SubMesh; - class Text; - class ThermalCamera; - class Visual; - class WireBox; - - /// \typedef ArrowVisualPtr - /// \brief Shared pointer to ArrowVisual - typedef shared_ptr ArrowVisualPtr; - - /// \typedef AxisVisualPtr - /// \brief Shared pointer to AxisVisual - typedef shared_ptr AxisVisualPtr; - - /// \typedef CameraPtr - /// \brief Shared pointer to Camera - typedef shared_ptr CameraPtr; - - /// \typedef DepthCameraPtr - /// \brief Shared pointer to DepthCamera - typedef shared_ptr DepthCameraPtr; - - /// \typedef ThermalCameraPtr - /// \brief Shared pointer to ThermalCamera - typedef shared_ptr ThermalCameraPtr; - - /// \typedef BoundingBoxCameraPtr - /// \brief Shared pointer to BoundingBoxCamera - typedef shared_ptr BoundingBoxCameraPtr; - - /// \typedef SegmentationCameraPtr - /// \brief Shared pointer to Segmentation Camera - typedef shared_ptr SegmentationCameraPtr; - - /// \typedef GpuRaysPtr - /// \brief Shared pointer to GpuRays - typedef shared_ptr GpuRaysPtr; - - /// \typedef DirectionalLightPtr - /// \brief Shared pointer to DirectionalLight - typedef shared_ptr DirectionalLightPtr; - - /// \typedef DistortionPassPtr - /// \brief Shared pointer to DistortionPass - typedef shared_ptr DistortionPassPtr; - - /// \typedef GaussianNoisePassPtr - /// \brief Shared pointer to GaussianNoisePass - typedef shared_ptr GaussianNoisePassPtr; - - /// \typedef GeometryPtr - /// \brief Shared pointer to Geometry - typedef shared_ptr GeometryPtr; - - /// \typedef GizmoVisualPtr - /// \brief Shared pointer to GizmoVisual - typedef shared_ptr GizmoVisualPtr; - - /// \typedef CapsulePtr - /// \brief Shared pointer to Capsule - typedef shared_ptr CapsulePtr; - - /// \typedef GridPtr - /// \brief Shared pointer to Grid - typedef shared_ptr GridPtr; - - /// \typedef JointVisualPtr - /// \brief Shared pointer to JointVisual - typedef shared_ptr JointVisualPtr; - - /// \typedef HeightmapPtr - /// \brief Shared pointer to Heightmap - typedef shared_ptr HeightmapPtr; - - /// \typedef ImagePtr - /// \brief Shared pointer to Image - typedef shared_ptr ImagePtr; - - /// \typedef InertiaVisualPtr - /// \def Shared pointer to InertiaVisual - typedef shared_ptr InertiaVisualPtr; - - /// \typedef LightPtr - /// \brief Shared pointer to Light - typedef shared_ptr LightPtr; - - /// \typedef COMVisualPtr - /// \brief Shared pointer to COMVisual - typedef shared_ptr COMVisualPtr; - - /// \typedef LightVisualPtr - /// \brief Shared pointer to Light - typedef shared_ptr LightVisualPtr; - - /// \typedef LidarVisualPtr - /// \brief Shared pointer to LidarVisual - typedef shared_ptr LidarVisualPtr; - - /// \typedef MaterialPtr - /// \brief Shared pointer to Material - typedef shared_ptr MaterialPtr; - - /// \typedef MarkerPtr - /// \brief Shared pointer to Marker - typedef shared_ptr MarkerPtr; - - /// \typedef MeshPtr - /// \brief Shared pointer to Mesh - typedef shared_ptr MeshPtr; - - /// \typedef NodePtr - /// \brief Shared pointer to Node - typedef shared_ptr NodePtr; - - /// \typedef ObjectPtr - /// \brief Shared pointer to Object - typedef shared_ptr ObjectPtr; - - /// \typedef ObjectFactoryPtr - /// \brief Shared pointer to ObjectFactory - typedef shared_ptr ObjectFactoryPtr; - - /// \typedef ParticleEmitterPtr - /// \brief Shared pointer to ParticleEmitter - typedef shared_ptr ParticleEmitterPtr; - - /// \typedef PointLightPtr - /// \brief Shared pointer to PointLight - typedef shared_ptr PointLightPtr; - - /// \typedef RayQueryPtr - /// \brief Shared pointer to RayQuery - typedef shared_ptr RayQueryPtr; - - /// \typedef RenderPassPtr - /// \brief Shared pointer to RenderPass - typedef shared_ptr RenderPassPtr; - - /// \typedef RenderPassSystemPtr - /// \brief Shared pointer to RenderPassSystem - typedef shared_ptr RenderPassSystemPtr; - - /// \typedef RenderTargetPtr - /// \brief Shared pointer to RenderTarget - typedef shared_ptr RenderTargetPtr; - - /// \typedef RenderTexturePtr - /// \brief Shared pointer to RenderTexture - typedef shared_ptr RenderTexturePtr; - - /// \typedef RenderWindowPtr - /// \brief Shared pointer to RenderWindow - typedef shared_ptr RenderWindowPtr; - /// \typedef ScenePtr - /// \brief Shared pointer to Scene - typedef shared_ptr ScenePtr; - - /// \typedef SensorPtr - /// \brief Shared pointer to Sensor - typedef shared_ptr SensorPtr; - - /// \brief Shared pointer to ShaderParams - typedef shared_ptr ShaderParamsPtr; - - /// \typedef SpotLightPtr - /// \brief Shared pointer to SpotLight - typedef shared_ptr SpotLightPtr; - - /// \typedef SubMeshPtr - /// \brief Shared pointer to SubMesh - typedef shared_ptr SubMeshPtr; - - /// \typedef TextPtr - /// \brief Shared pointer to Text - typedef shared_ptr TextPtr; - - /// \typedef VisualPtr - /// \brief Shared pointer to Visual - typedef shared_ptr VisualPtr; - - /// \typedef WireBoxPtr - /// \brief Shared pointer to WireBox - typedef shared_ptr WireBoxPtr; - - /// \typedef const ArrowVisualPtr - /// \brief Shared pointer to const ArrowVisual - typedef shared_ptr ConstArrowVisualPtr; - - /// \typedef const AxisVisualPtr - /// \brief Shared pointer to const AxisVisual - typedef shared_ptr ConstAxisVisualPtr; - - /// \typedef const CameraPtr - /// \brief Shared pointer to const Camera - typedef shared_ptr ConstCameraPtr; - - /// \typedef const DepthCameraPtr - /// \brief Shared pointer to const DepthCamera - typedef shared_ptr ConstDepthCameraPtr; - - /// \typedef const ThermalCameraPtr - /// \brief Shared pointer to const ThermalCamera - typedef shared_ptr ConstThermalCameraPtr; - - /// \typedef const BoundingBoxCameraPtr - /// \brief Shared pointer to const BoundingBox Camera - typedef shared_ptr ConstBoundingBoxCameraPtr; - - /// \typedef const SegmentationCameraPtr - /// \brief Shared pointer to const Segmentation Camera - typedef shared_ptr ConstSegmentationCameraPtr; - - /// \typedef const GpuRaysPtr - /// \brief Shared pointer to const GpuRays - typedef shared_ptr ConstGpuRaysPtr; - - /// \typedef const DirectionalLightPtr - /// \brief Shared pointer to const DirectionalLight - typedef shared_ptr ConstDirectionalLightPtr; - - /// \typedef const ConstGaussianNoisePass - /// \brief Shared pointer to const GaussianNoisePass - typedef shared_ptr ConstGaussianNoisePass; - - /// \typedef const GeometryPtr - /// \brief Shared pointer to const Geometry - typedef shared_ptr ConstGeometryPtr; - - /// \typedef const GizmoVisualPtr - /// \brief Shared pointer to const GizmoVisual - typedef shared_ptr ConstGizmoVisualPtr; - - /// \typedef const JointVisualPtr - /// \brief Shared pointer to const JointVisual - typedef shared_ptr ConstJointVisualPtr; - - /// \typedef const HeightmapPtr - /// \brief Shared pointer to const Heightmap - typedef shared_ptr ConstHeightmapPtr; - - /// \typedef const ImagePtr - /// \brief Shared pointer to const Image - typedef shared_ptr ConstImagePtr; - - /// \typedef const LightPtr - /// \brief Shared pointer to const Light - typedef shared_ptr ConstLightPtr; - - /// \typedef const LidarVisualPtr - /// \brief Shared pointer to const LidarVisual - typedef shared_ptr ConstLidarVisualPtr; - - /// \typedef const MaterialPtr - /// \brief Shared pointer to const Material - typedef shared_ptr ConstMaterialPtr; - - /// \typedef const MeshPtr - /// \brief Shared pointer to const Mesh - typedef shared_ptr ConstMeshPtr; - - /// \typedef const NodePtr - /// \brief Shared pointer to const Node - typedef shared_ptr ConstNodePtr; - - /// \typedef const ObjectPtr - /// \brief Shared pointer to const Object - typedef shared_ptr ConstObjectPtr; - - /// \typedef const ObjectFactoryPtr - /// \brief Shared pointer to const ObjectFactory - typedef shared_ptr ConstObjectFactoryPtr; - - /// \typedef const ParticleEmitterPtr - /// \brief Shared pointer to const ParticleEmitter - typedef shared_ptr ConstParticleEmitterPtr; - - /// \typedef const PointLightPtr - /// \brief Shared pointer to const PointLight - typedef shared_ptr ConstPointLightPtr; - - /// \typedef RayQueryPtr - /// \brief Shared pointer to RayQuery - typedef shared_ptr ConstRayQueryPtr; - - /// \typedef const RenderPassPtr - /// \brief Shared pointer to const RenderPass - typedef shared_ptr ConstRenderPassPtr; - - /// \typedef const RenderPassSystemPtr - /// \brief Shared pointer to const RenderPassSystem - typedef shared_ptr ConstRenderPassSystemPtr; - - /// \typedef const RenderTargetPtr - /// \brief Shared pointer to const RenderTarget - typedef shared_ptr ConstRenderTargetPtr; - - /// \typedef const RenderTexturePtr - /// \brief Shared pointer to const RenderTexture - typedef shared_ptr ConstRenderTexturePtr; - - /// \typedef const RenderWindowPtr - /// \brief Shared pointer to const RenderWindow - typedef shared_ptr ConstRenderWindowPtr; - - /// \typedef const ScenePtr - /// \brief Shared pointer to const Scene - typedef shared_ptr ConstScenePtr; - - /// \typedef const SensorPtr - /// \brief Shared pointer to const Sensor - typedef shared_ptr ConstSensorPtr; - - /// \brief Shared pointer to const ShaderParams - typedef shared_ptr ConstShaderParamsPtr; - - /// \typedef const SpotLightPtr - /// \brief Shared pointer to const SpotLight - typedef shared_ptr ConstSpotLightPtr; - - /// \typedef const SubMeshPtr - /// \brief Shared pointer to const SubMesh - typedef shared_ptr ConstSubMeshPtr; - - /// \typedef const SubMeshPtr - /// \brief Shared pointer to const SubMesh - typedef shared_ptr ConstTextPtr; - - /// \typedef const VisualPtr - /// \brief Shared pointer to const Visual - typedef shared_ptr ConstVisualPtr; - } - } -} -#endif diff --git a/include/ignition/rendering/RenderingIface.hh b/include/ignition/rendering/RenderingIface.hh index b48fae4d9..ab8fd158e 100644 --- a/include/ignition/rendering/RenderingIface.hh +++ b/include/ignition/rendering/RenderingIface.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,136 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERINGIFACE_HH_ -#define IGNITION_RENDERING_RENDERINGIFACE_HH_ -#include -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class RenderEngine; - - /// \brief Load shared render-engine resources - /// \return True if successful - IGNITION_RENDERING_VISIBLE - bool load(); - - /// \brief Initialized shared render-engine features - /// \return True if successful - IGNITION_RENDERING_VISIBLE - bool init(); - - /// \brief Destroy all render-engines and related resources - /// \return True if successful - IGNITION_RENDERING_VISIBLE - bool fini(); - - /// \brief Get the number of available render-engines. - /// \return The number of available render-engines - IGNITION_RENDERING_VISIBLE - unsigned int engineCount(); - - /// \brief Determine if a render-engine is registered under the given name - /// \param[in] _name Name of the desired render-engine - /// \return True if a render-engine is registered under the given name - IGNITION_RENDERING_VISIBLE - bool hasEngine(const std::string &_name); - - /// \brief Determine if a render-engine is already loaded. - /// \param[in] _name Name of the desired render-engine - /// \return True if a render-engine is loaded under the given name - IGNITION_RENDERING_VISIBLE - bool isEngineLoaded(const std::string &_name); - - /// \brief Get the names of all engines currently loaded. - /// \return All the engines currently loaded. - IGNITION_RENDERING_VISIBLE - std::vector loadedEngines(); - - /// \brief Get the render-engine registered under the given name. If no - /// render-engine is registered under the given name, NULL will be - /// returned. - /// If the engine is registered, but not loaded, this function will load it. - /// \param[in] _name Name of the desired render-engine - /// \param[in] _params Parameters to be passed to the render engine. - /// \param[in] _path Another search path for rendering engine plugin. - /// \return The specified render-engine - IGNITION_RENDERING_VISIBLE - RenderEngine *engine(const std::string &_name, - const std::map &_params = {}, - const std::string &_path = ""); - - /// \brief Get the render-engine registered at the given index. If no - /// render-engine is registered at the given index, NULL will be returned. - /// If the engine is registered, but not loaded, this function will load it. - /// \param[in] _index Index of the desired render-engine - /// \param[in] _params Parameters to be passed to the render engine. - /// \param[in] _path Another search path for rendering engine plugin. - /// \return The specified render-engine - IGNITION_RENDERING_VISIBLE - RenderEngine *engine(const unsigned int _index, - const std::map &_params = {}, - const std::string &_path = ""); - - /// \brief Unload the render-engine registered under the given name. - /// \param[in] _name Name of the desired render-engine - /// \return True if the engine is unloaded - IGNITION_RENDERING_VISIBLE - bool unloadEngine(const std::string &_name); - - /// \brief Register a new render-engine under the given name. If the given - /// name is already in use, the render-engine will not be registered. - /// \param[in] _name Name the render-engine will be registered under - /// \param[in] _engine Render-engine to be registered - IGNITION_RENDERING_VISIBLE - void registerEngine(const std::string &_name, RenderEngine *_engine); - - /// \brief Unregister a render-engine registered under the given name. - /// If the no render-engine is registered under the given name no work - /// will be done. - /// \param[in] _name Name of the render-engine to unregister - IGNITION_RENDERING_VISIBLE - void unregisterEngine(const std::string &_name); - - /// \brief Unregister the given render-engine. If the given render-engine - /// is not currently registered, no work will be done. - /// \param[in] _engine Render-engine to unregister - IGNITION_RENDERING_VISIBLE - void unregisterEngine(RenderEngine *_engine); - - /// \brief Unregister a render-engine at the given index. If the no - /// render-engine is registered at the given index, no work will be done. - /// \param[in] _index Index of the render-engine to unregister - IGNITION_RENDERING_VISIBLE - void unregisterEngine(const unsigned int _index); - - /// \brief Set the plugin paths from which render engines can be loaded. - /// \param[in] _paths The list of the plugin paths - IGNITION_RENDERING_VISIBLE - void setPluginPaths(const std::list &_paths); - - /// \brief Most applications will only have one rendering engine loaded - /// at a time, and only one scene within that. This helper function gets - /// the first scene that can be found in the first loaded rendering engine. - /// - /// It's not recommended to call this function when there's more than one - /// engine or scene. - /// - /// \return Pointer to a scene that was found, null if no scene is loaded. - IGNITION_RENDERING_VISIBLE - ScenePtr sceneFromFirstRenderEngine(); - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Scene.hh b/include/ignition/rendering/Scene.hh index d88fd6bd8..210d489e4 100644 --- a/include/ignition/rendering/Scene.hh +++ b/include/ignition/rendering/Scene.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,1281 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_SCENE_HH_ -#define IGNITION_RENDERING_SCENE_HH_ -#include -#include -#include - -#include -#include -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/HeightmapDescriptor.hh" -#include "ignition/rendering/MeshDescriptor.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Storage.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class RenderEngine; - - /// \class Scene Scene.hh ignition/rendering/Scene.hh - /// \brief Manages a single scene-graph. This class updates scene-wide - /// properties and holds the root scene node. A Scene also serves as a - /// factory for all scene objects. - class IGNITION_RENDERING_VISIBLE Scene - { - /// \brief Destructor - public: virtual ~Scene() { } - - /// \brief Load scene-specific resources - public: virtual void Load() = 0; - - /// \brief Initialize the scene - public: virtual void Init() = 0; - - // TODO(anyone): merge with Destroy - public: virtual void Fini() = 0; - - /// \brief Determine if the scene is initialized - /// \return True if the scene is initialized - public: virtual bool IsInitialized() const = 0; - - /// \brief Get the ID of the scene - /// \return The scene ID - public: virtual unsigned int Id() const = 0; - - /// \brief Get the name of the scene - /// \return The scene name - public: virtual std::string Name() const = 0; - - /// \brief Get the creating render-engine of the scene - /// \return The creating render-engine - public: virtual RenderEngine *Engine() const = 0; - - /// \brief Get the last simulation update time - /// \return The last simulation update time - public: virtual common::Time IGN_DEPRECATED(4) SimTime() const = 0; - - /// \brief Get the last simulation update time - /// \return The last simulation update time - public: virtual std::chrono::steady_clock::duration - Time() const = 0; - - /// \brief Set the last simulation update time - /// \param[in] _time Latest simulation update time - public: virtual void IGN_DEPRECATED(4) - SetSimTime(const common::Time &_time) = 0; - - /// \brief Set the last simulation update time - /// \param[in] _time Latest simulation update time - public: virtual void SetTime( - const std::chrono::steady_clock::duration &_time) = 0; - - /// \brief Get root Visual node. All nodes that are desired to be - /// rendered in a scene should be added to this Visual or one of its - /// ancestors in the scene-graph. Nodes created by this Scene will not be - /// added to the scene by default. - /// \return The root Visual node - public: virtual VisualPtr RootVisual() const = 0; - - /// \brief Get a visual at a mouse position. - /// \param[in] _camera Camera pointer being used - /// \param[in] _mousePos position of the mouse in pixels - /// \return Pointer to the visual, NULL if none found. - public: virtual VisualPtr VisualAt(const CameraPtr &_camera, - const math::Vector2i &_mousePos) = 0; - - /// \brief Get the scene ambient light color - /// \return The scene ambient light color - public: virtual math::Color AmbientLight() const = 0; - - /// \brief Set the scene ambient light color - /// \param[in] _r Red color - /// \param[in] _g Green color - /// \param[in] _b Blue color - /// \param[in] _a Alpha color - public: virtual void SetAmbientLight(double _r, double _g, double _b, - double _a = 1.0) = 0; - - /// \brief Set the scene ambient light color - /// \param[in] _color The scene ambient light color - public: virtual void SetAmbientLight(const math::Color &_color) = 0; - - /// \brief Get the scene background color - /// \return The scene background color - public: virtual math::Color BackgroundColor() const = 0; - - /// \brief Set the scene background color - /// \param[in] _r Red color - /// \param[in] _g Green color - /// \param[in] _b Blue color - /// \param[in] _a Alpha color - public: virtual void SetBackgroundColor(double _r, double _g, double _b, - double _a = 1.0) = 0; - - /// \brief Set the scene background color - /// \param[in] _color The scene background color - public: virtual void SetBackgroundColor(const math::Color &_color) = 0; - - /// \brief Whether the scene has a gradient background or not (solid) - /// \return True if the scene has a gradient background or false otherwise - public: virtual bool IsGradientBackgroundColor() const = 0; - - /// \brief Get the scene gradient background color - /// \return The scene gradient background color - /// \sa bool IsGradientBackgroundColor() const - public: virtual std::array - GradientBackgroundColor() const = 0; - - /// \brief Set a custom gradient background color on top of the regular - /// background. Default should be black. - /// - /// Important note: Keep in mind that this object will always be rendered - /// on top of any existing scene or camera background. - /// - /// \param[in] _colors The scene gradient background color. - /// Next is the description of how to interpret each value of the array: - /// 0: Top left corner color. - /// 1: Bottom left corner color. - /// 2: Top right corner color. - /// 3: Bottom right corner color. - /// \sa void RemoveGradientBackgroundColor() - public: virtual void SetGradientBackgroundColor( - const std::array &_colors) = 0; - - /// \brief Remove the scene gradient background color - /// \sa void SetGradientBackgroundColor( - /// const std::array &_colors) - public: virtual void RemoveGradientBackgroundColor() = 0; - - /// \brief Get the scene background material - /// e.g. a material with skybox cubemap texture - /// \return Material of the background - public: virtual MaterialPtr BackgroundMaterial() const = 0; - - /// \brief Set the scene background material - /// e.g. a material with skybox cubemap texture - /// \param[in] _material Material to set the background to - public: virtual void SetBackgroundMaterial(MaterialPtr _material) = 0; - - /// \brief Get the number of nodes managed by this scene. Note these - /// nodes may not be directly or indirectly attached to the root node. - /// \return The number of nodes managed by this scene - public: virtual unsigned int NodeCount() const = 0; - - /// \brief Determine if the given node is managed by this Scene - /// \param[in] _node Node in question - /// \return True if a node is managed by this scene - public: virtual bool HasNode(ConstNodePtr _node) const = 0; - - /// \brief Determine if a given node with the given id is managed by - /// this Scene - /// \param[in] _id ID of the node in question - /// \return True if a node is managed by this scene - public: virtual bool HasNodeId(unsigned int _id) const = 0; - - /// \brief Determine if a given node with the given name is managed by - /// this Scene - /// \param[in] _name Name of the node in question - /// \return True if a node is managed by this scene - public: virtual bool HasNodeName(const std::string &_name) const = 0; - - /// \brief Get node with the given id. If no node exists with the given - /// id, NULL will be returned. - /// \param[in] _id ID of the desired node - /// \return The desired node - public: virtual NodePtr NodeById(unsigned int _id) const = 0; - - /// \brief Get node with the given name. If no node exists with the given - /// name, NULL will be returned. - /// \param[in] _name Name of the desired node - /// \return The desired node - public: virtual NodePtr NodeByName(const std::string &_name) const = 0; - - /// \brief Get node at the given index. If no node exists at the given - /// index, NULL will be returned. - /// \param[in] _index Index of the desired node - /// \return The desired node - public: virtual NodePtr NodeByIndex(unsigned int _index) const = 0; - - /// \brief Destroy given node. If the given node is not managed by this - /// scene, no work will be done. Depending on the _recursive argument, - /// this function will either detach all child nodes from the scene graph - /// or recursively destroy them. - /// \param[in] _node Node pointer to destroy - /// \param[in] _recursive True to recursively destroy the node and its - /// children, false to destroy only this node and detach the children - public: virtual void DestroyNode(NodePtr _node, - bool _recursive = false) = 0; - - /// \brief Destroy node with the given id. If no node exists with the - /// given id, no work will be done. All children of the node will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _id ID of the node to destroy - public: virtual void DestroyNodeById(unsigned int _id) = 0; - - /// \brief Destroy node with the given name. If no node exists with the - /// given name, no work will be done. All children of the node will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _name Name of the node to destroy - public: virtual void DestroyNodeByName(const std::string &_name) = 0; - - /// \brief Destroy node at the given index. If no node exists at the - /// given index, no work will be done. All children of the node will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _index Index of the node to destroy - public: virtual void DestroyNodeByIndex(unsigned int _index) = 0; - - /// \brief Destroy all nodes manages by this scene. - public: virtual void DestroyNodes() = 0; - - /// \brief Get the number of lights managed by this scene. Note these - /// lights may not be directly or indirectly attached to the root light. - /// \return The number of lights managed by this scene - public: virtual unsigned int LightCount() const = 0; - - /// \brief Determine if the given light is managed by this Scene - /// \param[in] _light Light in question - /// \return True if a light is managed by this scene - public: virtual bool HasLight(ConstLightPtr _light) const = 0; - - /// \brief Determine if a given light with the given id is managed by - /// this Scene - /// \param[in] _id ID of the light in question - /// \return True if a light is managed by this scene - public: virtual bool HasLightId(unsigned int _id) const = 0; - - /// \brief Determine if a given light with the given name is managed by - /// this Scene - /// \param[in] _name Name of the light in question - /// \return True if a light is managed by this scene - public: virtual bool HasLightName(const std::string &_name) const = 0; - - /// \brief Get light with the given id. If no light exists with the given - /// id, NULL will be returned. - /// \param[in] _id ID of the desired light - /// \return The desired light - public: virtual LightPtr LightById(unsigned int _id) const = 0; - - /// \brief Get light with the given name. If no light exists with the - /// given name, NULL will be returned. - /// \param[in] _name Name of the desired light - /// \return The desired light - public: virtual LightPtr LightByName( - const std::string &_name) const = 0; - - /// \brief Get light at the given index. If no light exists at the given - /// index, NULL will be returned. - /// \param[in] _index Index of the desired light - /// \return The desired light - public: virtual LightPtr LightByIndex(unsigned int _index) const = 0; - - /// \brief Destroy given light. If the given light is not managed by this - /// scene, no work will be done. Depending on the _recursive argument, - /// this function will either detach all child nodes from the scene graph - /// or recursively destroy them. - /// \param[in] _light Light pointer to destroy - /// \param[in] _recursive True to recursively destroy the node and its - /// children, false to destroy only this node and detach the children - public: virtual void DestroyLight(LightPtr _light, - bool _recursive = false) = 0; - - /// \brief Destroy light with the given id. If no light exists with the - /// given id, no work will be done. All children of the light will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _id ID of the light to destroy - public: virtual void DestroyLightById(unsigned int _id) = 0; - - /// \brief Destroy light with the given name. If no light exists with the - /// given name, no work will be done. All children of the light will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _name Name of the light to destroy - public: virtual void DestroyLightByName(const std::string &_name) = 0; - - /// \brief Destroy light at the given index. If no light exists at the - /// given index, no work will be done. All children of the light will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _index Index of the light to destroy - public: virtual void DestroyLightByIndex(unsigned int _index) = 0; - - /// \brief Destroy all lights manages by this scene. - public: virtual void DestroyLights() = 0; - - /// \brief Get the number of sensors managed by this scene. Note these - /// sensors may not be directly or indirectly attached to the root sensor. - /// \return The number of sensors managed by this scene - public: virtual unsigned int SensorCount() const = 0; - - /// \brief Determine if the given sensor is managed by this Scene - /// \param[in] _sensor Sensor in question - /// \return True if a sensor is managed by this scene - public: virtual bool HasSensor(ConstSensorPtr _sensor) const = 0; - - /// \brief Determine if a given sensor with the given id is managed by - /// this Scene - /// \param[in] _id ID of the sensor in question - /// \return True if a sensor is managed by this scene - public: virtual bool HasSensorId(unsigned int _id) const = 0; - - /// \brief Determine if a given sensor with the given name is managed by - /// this Scene - /// \param[in] _name Name of the sensor in question - /// \return True if a sensor is managed by this scene - public: virtual bool HasSensorName(const std::string &_name) const = 0; - - /// \brief Get sensor with the given id. If no sensor exists with the - /// given id, NULL will be returned. - /// \param[in] _id ID of the desired sensor - /// \return The desired sensor - public: virtual SensorPtr SensorById(unsigned int _id) const = 0; - - /// \brief Get sensor with the given name. If no sensor exists with the - /// given name, NULL will be returned. - /// \param[in] _name Name of the desired sensor - /// \return The desired sensor - public: virtual SensorPtr SensorByName( - const std::string &_name) const = 0; - - /// \brief Get sensor at the given index. If no sensor exists at the given - /// index, NULL will be returned. - /// \param[in] _index Index of the desired sensor - /// \return The desired sensor - public: virtual SensorPtr SensorByIndex(unsigned int _index) const = 0; - - /// \brief Destroy given sensor. If the given sensor is not managed by - /// this scene, no work will be done. Depending on the _recursive - /// argument, this function will either detach all child nodes from the - /// scene graph or recursively destroy them. - /// \param[in] _sensor Sensor pointer to destroy - /// \param[in] _recursive True to recursively destroy the node and its - /// children, false to destroy only this node and detach the children - public: virtual void DestroySensor(SensorPtr _sensor, - bool _recursive = false) = 0; - - /// \brief Destroy sensor with the given id. If no sensor exists with the - /// given id, no work will be done. All children of the sensor will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _id ID of the sensor to destroy - public: virtual void DestroySensorById(unsigned int _id) = 0; - - /// \brief Destroy sensor with the given name. If no sensor exists with - /// the given name, no work will be done. All children of the sensor will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _name Name of the sensor to destroy - public: virtual void DestroySensorByName(const std::string &_name) = 0; - - /// \brief Destroy sensor at the given index. If no sensor exists at the - /// given index, no work will be done. All children of the sensor will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _index Index of the sensor to destroy - public: virtual void DestroySensorByIndex(unsigned int _index) = 0; - - /// \brief Destroy all sensors manages by this scene. - public: virtual void DestroySensors() = 0; - - /// \brief Get the number of nodes managed by this scene. Note these - /// nodes may not be directly or indirectly attached to the root node. - /// \return The number of nodes managed by this scene - public: virtual unsigned int VisualCount() const = 0; - - /// \brief Determine if the given node is managed by this Scene - /// \param[in] _node Visual in question - /// \return True if a node is managed by this scene - public: virtual bool HasVisual(ConstVisualPtr _node) const = 0; - - /// \brief Determine if a given node with the given id is managed by - /// this Scene - /// \param[in] _id ID of the node in question - /// \return True if a node is managed by this scene - public: virtual bool HasVisualId(unsigned int _id) const = 0; - - /// \brief Determine if a given node with the given name is managed by - /// this Scene - /// \param[in] _name Name of the node in question - /// \return True if a node is managed by this scene - public: virtual bool HasVisualName(const std::string &_name) const = 0; - - /// \brief Get node with the given id. If no node exists with the given - /// id, NULL will be returned. - /// \param[in] _id ID of the desired node - /// \return The desired node - public: virtual VisualPtr VisualById(unsigned int _id) const = 0; - - /// \brief Get node with the given name. If no node exists with the given - /// name, NULL will be returned. - /// \param[in] _name Name of the desired node - /// \return The desired node - public: virtual VisualPtr VisualByName( - const std::string &_name) const = 0; - - /// \brief Get node at the given index. If no node exists at the given - /// index, NULL will be returned. - /// \param[in] _index Index of the desired node - /// \return The desired node - public: virtual VisualPtr VisualByIndex(unsigned int _index) const = 0; - - /// \brief Destroy given node. If the given node is not managed by this - /// scene, no work will be done. Depending on the _recursive argument, - /// this function will either detach all child nodes from the scene graph - /// or recursively destroy them. - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _node Visual pointer to destroy - /// \param[in] _recursive True to recursively destroy the node and its - /// children, false to destroy only this node and detach the children - public: virtual void DestroyVisual(VisualPtr _node, - bool _recursive = false) = 0; - - /// \brief Destroy node with the given id. If no node exists with the - /// given id, no work will be done. All children of the node will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _id ID of the node to destroy - public: virtual void DestroyVisualById(unsigned int _id) = 0; - - /// \brief Destroy node with the given name. If no node exists with the - /// given name, no work will be done. All children of the node will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _name Name of the node to destroy - public: virtual void DestroyVisualByName(const std::string &_name) = 0; - - /// \brief Destroy node at the given index. If no node exists at the - /// given index, no work will be done. All children of the node will - /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _index Index of the node to destroy - public: virtual void DestroyVisualByIndex(unsigned int _index) = 0; - - /// \brief Destroy all nodes manages by this scene. - public: virtual void DestroyVisuals() = 0; - - /// \brief Determine if a material is registered under the given name - /// \param[in] _name Name of the material in question - /// \return True if a material is registered under the given name - public: virtual bool MaterialRegistered( - const std::string &_name) const = 0; - - /// \brief Get material registered under the given name. If no material - /// is registered under the given name, NULL will be returned. - /// \param[in] _name Name of the desired material - /// \return The specified material - public: virtual MaterialPtr Material( - const std::string &_name) const = 0; - - /// \brief Register a new material under the given name. If the name is - /// already in use, no work will be done. - /// \param[in] _name Name which the material will be registered under - /// \param[in] _material Material to register - public: virtual void RegisterMaterial(const std::string &_name, - MaterialPtr _material) = 0; - - /// \brief Unregister material registered under the given name. If no - /// material is registered under this name, no work will be done. - /// \param[in] _name Name of the material to unregistered - public: virtual void UnregisterMaterial(const std::string &_name) = 0; - - /// \brief Unregister all registered materials - public: virtual void UnregisterMaterials() = 0; - - /// \brief Unregister and destroy a material - /// \param[in] _material Material to be unregistered and destroyed - public: virtual void DestroyMaterial(MaterialPtr _material) = 0; - - /// \brief Unregister and destroys all registered materials - public: virtual void DestroyMaterials() = 0; - - /// \brief Create new directional light. A unique ID and name will - /// automatically be assigned to the light. - /// \return The created light - public: virtual DirectionalLightPtr CreateDirectionalLight() = 0; - - /// \brief Create new directional light with the given ID. A unique name - /// will automatically be assigned to the light. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new light - /// \return The created light - public: virtual DirectionalLightPtr CreateDirectionalLight( - unsigned int _id) = 0; - - /// \brief Create new directional light with the given name. A unique ID - /// will automatically be assigned to the light. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new light - /// \return The created light - public: virtual DirectionalLightPtr CreateDirectionalLight( - const std::string &_name) = 0; - - /// \brief Create new directional light with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new light - /// \param[in] _name Name of the new light - /// \return The created light - public: virtual DirectionalLightPtr CreateDirectionalLight( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new point light. A unique ID and name will - /// automatically be assigned to the light. - /// \return The created light - public: virtual PointLightPtr CreatePointLight() = 0; - - /// \brief Create new point light with the given ID. A unique name - /// will automatically be assigned to the light. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new light - /// \return The created light - public: virtual PointLightPtr CreatePointLight( - unsigned int _id) = 0; - - /// \brief Create new point light with the given name. A unique ID - /// will automatically be assigned to the light. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new light - /// \return The created light - public: virtual PointLightPtr CreatePointLight( - const std::string &_name) = 0; - - /// \brief Create new point light with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new light - /// \param[in] _name Name of the new light - /// \return The created light - public: virtual PointLightPtr CreatePointLight( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new spotlight. A unique ID and name will - /// automatically be assigned to the light. - /// \return The created light - public: virtual SpotLightPtr CreateSpotLight() = 0; - - /// \brief Create new spotlight with the given ID. A unique name - /// will automatically be assigned to the light. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new light - /// \return The created light - public: virtual SpotLightPtr CreateSpotLight( - unsigned int _id) = 0; - - /// \brief Create new spotlight with the given name. A unique ID - /// will automatically be assigned to the light. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new light - /// \return The created light - public: virtual SpotLightPtr CreateSpotLight( - const std::string &_name) = 0; - - /// \brief Create new spotlight with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new light - /// \param[in] _name Name of the new light - /// \return The created light - public: virtual SpotLightPtr CreateSpotLight( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new camera. A unique ID and name will - /// automatically be assigned to the camera. - /// \return The created camera - public: virtual CameraPtr CreateCamera() = 0; - - /// \brief Create new camera with the given ID. A unique name - /// will automatically be assigned to the camera. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new camera - /// \return The created camera - public: virtual CameraPtr CreateCamera( - unsigned int _id) = 0; - - /// \brief Create new camera with the given name. A unique ID - /// will automatically be assigned to the camera. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new camera - /// \return The created camera - public: virtual CameraPtr CreateCamera( - const std::string &_name) = 0; - - /// \brief Create new camera with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new camera - /// \param[in] _name Name of the new camera - /// \return The created camera - public: virtual CameraPtr CreateCamera( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new depth camera. A unique ID and name will - /// automatically be assigned to the camera. - /// \return The created camera - public: virtual DepthCameraPtr CreateDepthCamera() = 0; - - /// \brief Create new depth camera with the given ID. A unique name - /// will automatically be assigned to the camera. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new camera - /// \return The created camera - public: virtual DepthCameraPtr CreateDepthCamera( - unsigned int _id) = 0; - - /// \brief Create new depth camera with the given name. A unique ID - /// will automatically be assigned to the camera. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new camera - /// \return The created camera - public: virtual DepthCameraPtr CreateDepthCamera( - const std::string &_name) = 0; - - /// \brief Create new depth camera with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new camera - /// \param[in] _name Name of the new camera - /// \return The created camera - public: virtual DepthCameraPtr CreateDepthCamera( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new thermal camera. A unique ID and name will - /// automatically be assigned to the camera. - /// \return The created camera - public: virtual ThermalCameraPtr CreateThermalCamera() = 0; - - /// \brief Create new thermal camera with the given ID. A unique name - /// will automatically be assigned to the camera. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new camera - /// \return The created camera - public: virtual ThermalCameraPtr CreateThermalCamera( - unsigned int _id) = 0; - - /// \brief Create new thermal camera with the given name. A unique ID - /// will automatically be assigned to the camera. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new camera - /// \return The created camera - public: virtual ThermalCameraPtr CreateThermalCamera( - const std::string &_name) = 0; - - /// \brief Create new thermal camera with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new camera - /// \param[in] _name Name of the new camera - /// \return The created camera - public: virtual ThermalCameraPtr CreateThermalCamera( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new BoundingBox camera. A unique ID and name will - /// automatically be assigned to the camera. - /// \return The created camera - public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera() = 0; - - /// \brief Create new BoundingBox camera with the given ID. - /// A unique name will automatically be assigned to the camera. - /// If the given ID is already in use, NULL will be returned. - /// \param[in] _id ID of the new camera - /// \return The created camera - public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( - unsigned int _id) = 0; - - /// \brief Create new BoundingBox camera with the given name. - /// A unique ID will automatically be assigned to the camera. - /// If the given name is already in use, NULL will be returned. - /// \param[in] _name Name of the new camera - /// \return The created camera - public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( - const std::string &_name) = 0; - - /// \brief Create new BoundingBox camera with the given ID & name. If - /// either the given ID or name is already in use, will return NULL. - /// \param[in] _id ID of the new camera - /// \param[in] _name Name of the new camera - /// \return The created camera - public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new segmentation camera. A unique ID and name will - /// automatically be assigned to the camera. - /// \return The created camera - public: virtual SegmentationCameraPtr CreateSegmentationCamera() = 0; - - /// \brief Create new segmentation camera with the given ID. - /// A unique name will automatically be assigned to the camera. - /// If the given ID is already in use, NULL will be returned. - /// \param[in] _id ID of the new camera - /// \return The created camera - public: virtual SegmentationCameraPtr CreateSegmentationCamera( - unsigned int _id) = 0; - - /// \brief Create new segmentation camera with the given name. - /// A unique ID will automatically be assigned to the camera. - /// If the given name is already in use, NULL will be returned. - /// \param[in] _name Name of the new camera - /// \return The created camera - public: virtual SegmentationCameraPtr CreateSegmentationCamera( - const std::string &_name) = 0; - - /// \brief Create new segmentation camera with the given name and ID. If - /// either the given ID or name is already in use, will return NULL. - /// \param[in] _id ID of the new camera - /// \param[in] _name Name of the new camera - /// \return The created camera - public: virtual SegmentationCameraPtr CreateSegmentationCamera( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new gpu rays caster. A unique ID and name will - /// automatically be assigned to the gpu rays caster. - /// \return The created gpu rays caster - public: virtual GpuRaysPtr CreateGpuRays() = 0; - - /// \brief Create new gpu rays caster with the given ID. A unique name - /// will automatically be assigned to the gpu rays caster. If the given - /// ID is already in use, NULL will be returned. - /// \param[in] _id ID of the new gpu rays caster - /// \return The created gpu rays caster - public: virtual GpuRaysPtr CreateGpuRays(unsigned int _id) = 0; - - /// \brief Create new gpu rays caster with the given name. A unique ID - /// will automatically be assigned to the gpu rays caster. If the given - /// name is already in use, NULL will be returned. - /// \param[in] _name Name of the new gpu rays caster - /// \return The created gpu ray caster - public: virtual GpuRaysPtr CreateGpuRays( - const std::string &_name) = 0; - - /// \brief Create new gpu rays caster with the given name. If either - /// the given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the gpu ray caster - /// \param[in] _name Name of the new gpu ray caster - /// \return The created Gpu ray caster - public: virtual GpuRaysPtr CreateGpuRays( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new visual. A unique ID and name will - /// automatically be assigned to the visual. - /// \return The created visual - public: virtual VisualPtr CreateVisual() = 0; - - /// \brief Create new visual with the given ID. A unique name - /// will automatically be assigned to the visual. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new visual - /// \return The created visual - public: virtual VisualPtr CreateVisual( - unsigned int _id) = 0; - - /// \brief Create new visual with the given name. A unique ID - /// will automatically be assigned to the visual. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new visual - /// \return The created visual - public: virtual VisualPtr CreateVisual( - const std::string &_name) = 0; - - /// \brief Create new visual with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new visual - /// \param[in] _name Name of the new visual - /// \return The created visual - public: virtual VisualPtr CreateVisual( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new arrow visual. A unique ID and name will - /// automatically be assigned to the visual. - /// \return The created arrow visual - public: virtual ArrowVisualPtr CreateArrowVisual() = 0; - - /// \brief Create new arrow visual with the given ID. A unique name - /// will automatically be assigned to the visual. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new arrow visual - /// \return The created arrow visual - public: virtual ArrowVisualPtr CreateArrowVisual( - unsigned int _id) = 0; - - /// \brief Create new arrow visual with the given name. A unique ID - /// will automatically be assigned to the visual. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new arrow visual - /// \return The created arrow visual - public: virtual ArrowVisualPtr CreateArrowVisual( - const std::string &_name) = 0; - - /// \brief Create new arrow visual with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new arrow visual - /// \param[in] _name Name of the new arrow visual - /// \return The created arrow visual - public: virtual ArrowVisualPtr CreateArrowVisual( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new axis visual. A unique ID and name will - /// automatically be assigned to the visual. - /// \return The created axis visual - public: virtual AxisVisualPtr CreateAxisVisual() = 0; - - /// \brief Create new axis visual with the given ID. A unique name - /// will automatically be assigned to the visual. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new axis visual - /// \return The created axis visual - public: virtual AxisVisualPtr CreateAxisVisual( - unsigned int _id) = 0; - - /// \brief Create new axis visual with the given name. A unique ID - /// will automatically be assigned to the visual. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new axis visual - /// \return The created axis visual - public: virtual AxisVisualPtr CreateAxisVisual( - const std::string &_name) = 0; - - /// \brief Create new axis visual with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new axis visual - /// \param[in] _name Name of the new axis visual - /// \return The created axis visual - public: virtual AxisVisualPtr CreateAxisVisual( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new gizmo visual. A unique ID and name will - /// automatically be assigned to the visual. - /// \return The created gizmo visual - public: virtual GizmoVisualPtr CreateGizmoVisual() = 0; - - /// \brief Create new gizmo visual with the given ID. A unique name - /// will automatically be assigned to the visual. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new gizmo visual - /// \return The created gizmo visual - public: virtual GizmoVisualPtr CreateGizmoVisual( - unsigned int _id) = 0; - - /// \brief Create new gizmo visual with the given name. A unique ID - /// will automatically be assigned to the visual. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new gizmo visual - /// \return The created gizmo visual - public: virtual GizmoVisualPtr CreateGizmoVisual( - const std::string &_name) = 0; - - /// \brief Create new gizmo visual with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new gizmo visual - /// \param[in] _name Name of the new gizmo visual - /// \return The created gizmo visual - public: virtual GizmoVisualPtr CreateGizmoVisual( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new CoM visual. A unique ID and name will - /// automatically be assigned to the CoM visual. - /// \return The created CoM visual - public: virtual COMVisualPtr CreateCOMVisual() = 0; - - /// \brief Create new CoM visual with the given ID. A unique name - /// will automatically be assigned to the visual. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new CoM visual - /// \return The created CoM visual - public: virtual COMVisualPtr CreateCOMVisual( - unsigned int _id) = 0; - - /// \brief Create new CoM visual with the given name. A unique ID - /// will automatically be assigned to the visual. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new CoM visual - /// \return The created CoM visual - public: virtual COMVisualPtr CreateCOMVisual( - const std::string &_name) = 0; - - /// \brief Create new CoM visual with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new CoM visual - /// \param[in] _name Name of the new CoM visual - /// \return The created CoM visual - public: virtual COMVisualPtr CreateCOMVisual( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new inertia visual. A unique ID and name will - /// automatically be assigned to the inertia visual. - /// \return The created inertia visual - public: virtual InertiaVisualPtr CreateInertiaVisual() = 0; - - /// \brief Create new inertia visual with the given ID. A unique name - /// will automatically be assigned to the visual. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new inertia visual - /// \return The created light visual - public: virtual InertiaVisualPtr CreateInertiaVisual( - unsigned int _id) = 0; - - /// \brief Create new inertia visual with the given name. A unique ID - /// will automatically be assigned to the visual. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new inertia visual - /// \return The created light visual - public: virtual InertiaVisualPtr CreateInertiaVisual( - const std::string &_name) = 0; - - /// \brief Create new inertia visual with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new inertia visual - /// \param[in] _name Name of the new inertia visual - /// \return The created inertia visual - public: virtual InertiaVisualPtr CreateInertiaVisual( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new joint visual. A unique ID and name will - /// automatically be assigned to the Joint visual. - /// \return The created Joint visual - public: virtual JointVisualPtr CreateJointVisual() = 0; - - /// \brief Create new joint visual with the given ID. A unique name - /// will automatically be assigned to the visual. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new Joint visual - /// \return The created Joint visual - public: virtual JointVisualPtr CreateJointVisual( - unsigned int _id) = 0; - - /// \brief Create new joint visual with the given name. A unique ID - /// will automatically be assigned to the visual. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new Joint visual - /// \return The created Joint visual - public: virtual JointVisualPtr CreateJointVisual( - const std::string &_name) = 0; - - /// \brief Create new joint visual with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new Joint visual - /// \param[in] _name Name of the new Joint visual - /// \return The created Joint visual - public: virtual JointVisualPtr CreateJointVisual( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new light visual. A unique ID and name will - /// automatically be assigned to the light visual. - /// \return The created light visual - public: virtual LightVisualPtr CreateLightVisual() = 0; - - /// \brief Create new light visual with the given ID. A unique name - /// will automatically be assigned to the visual. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new light visual - /// \return The created light visual - public: virtual LightVisualPtr CreateLightVisual( - unsigned int _id) = 0; - - /// \brief Create new light visual with the given name. A unique ID - /// will automatically be assigned to the visual. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new light visual - /// \return The created light visual - public: virtual LightVisualPtr CreateLightVisual( - const std::string &_name) = 0; - - /// \brief Create new light visual with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new light visual - /// \param[in] _name Name of the new light visual - /// \return The created light visual - public: virtual LightVisualPtr CreateLightVisual( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new box geometry - /// \return The created box - public: virtual GeometryPtr CreateBox() = 0; - - /// \brief Create new capsule geometry - /// \return The created capsule - public: virtual CapsulePtr CreateCapsule() = 0; - - /// \brief Create new cone geometry - /// \return The created cone - public: virtual GeometryPtr CreateCone() = 0; - - /// \brief Create new cylinder geometry - /// \return The created cylinder - public: virtual GeometryPtr CreateCylinder() = 0; - - /// \brief Create new plane geometry - /// \return The created plane - public: virtual GeometryPtr CreatePlane() = 0; - - /// \brief Create new sphere or ellipsoid geometry - /// This method allow to create ellipsoid too, because it can be scaled - /// in 3 dimensions. - /// \return The created sphere - public: virtual GeometryPtr CreateSphere() = 0; - - /// \brief Create new mesh geomerty. The rendering::Mesh will be created - /// from a common::Mesh retrieved from common::MeshManager using the given - /// mesh name. If no mesh exists by this name, NULL will be returned. All - /// sub-meshes will be loaded into the created mesh, uncentered. - /// \param[in] _meshName Name of the reference mesh - /// \return The created mesh - public: virtual MeshPtr CreateMesh(const std::string &_meshName) = 0; - - /// \brief Create new mesh geomerty. The rendering::Mesh will be created - /// from the given common::Mesh. All sub-meshes will be loaded into this - /// created mesh, uncentered. - /// \param[in] _mesh Reference mesh - /// \return The created mesh - public: virtual MeshPtr CreateMesh(const common::Mesh *_mesh) = 0; - - /// \brief Create new mesh geometry. The rendering::Mesh will be created - /// from the given common::Mesh specified in the MeshDescriptor. - /// Sub-meshes will be loaded and centered according to the descriptor. - /// \param[in] _desc Descriptor of the mesh to load - /// \return The created mesh - public: virtual MeshPtr CreateMesh(const MeshDescriptor &_desc) = 0; - - /// \brief Create new grid geometry. - /// \return The created grid - public: virtual GridPtr CreateGrid() = 0; - - /// \brief Create new wire box geometry. - /// \return The created wire box - public: virtual WireBoxPtr CreateWireBox() = 0; - - /// \brief Create new marker geometry. - /// \return The created marker - public: virtual MarkerPtr CreateMarker() = 0; - - /// \brief Create new lidar visual. A unique ID and name will - /// automatically be assigned to the lidar visual. - /// \return The created lidar visual - public: virtual LidarVisualPtr CreateLidarVisual() = 0; - - /// \brief Create new lidar visual with the given ID. A unique name - /// will automatically be assigned to the lidar visual. If the given - /// ID is already in use, NULL will be returned. - /// \param[in] _id ID of the new lidar visual - /// \return The created lidar visual - public: virtual LidarVisualPtr CreateLidarVisual(unsigned int _id) = 0; - - /// \brief Create new lidar visual with the given name. A unique ID - /// will automatically be assigned to the lidar visual. If the given - /// name is already in use, NULL will be returned. - /// \param[in] _name Name of the new lidar visual - /// \return The created lidar visual - public: virtual LidarVisualPtr CreateLidarVisual( - const std::string &_name) = 0; - - /// \brief Create new lidar visual with the given name. If either - /// the given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the lidar visual. - /// \param[in] _name Name of the new lidar visual. - /// \return The created lidar visual - public: virtual LidarVisualPtr CreateLidarVisual( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Create new heightmap geomerty. The rendering::Heightmap will be - /// created from the given HeightmapDescriptor. - /// \param[in] _desc Data about the heightmap - /// \return The created heightmap - public: virtual HeightmapPtr CreateHeightmap( - const HeightmapDescriptor &_desc) = 0; - - /// \brief Create new text geometry. - /// \return The created text - public: virtual TextPtr CreateText() = 0; - - /// \brief Create new material with the given name. Created material will - /// have default properties. - /// \param[in] _name Name for the new material. - /// \return The created material - public: virtual MaterialPtr CreateMaterial(const std::string &_name = "") - = 0; - - /// \brief Create new material from the reference common::Material - /// \param[in] _material Reference material - /// \return The created material - public: virtual MaterialPtr CreateMaterial( - const common::Material &_material) = 0; - - /// \brief Create new render texture - /// \return The created render texture - public: virtual RenderTexturePtr CreateRenderTexture() = 0; - - /// \brief Create new render window. This feature is render engine - /// dependent. If the engine does not support attaching to a windowing - /// system then it should behave as a a render texture. - /// \return The created render window - public: virtual RenderWindowPtr CreateRenderWindow() = 0; - - /// \brief Create new ray query - /// \return The created ray query - public: virtual RayQueryPtr CreateRayQuery() = 0; - - /// \brief Create new particle emitter. A unique ID and name will - /// automatically be assigned to the visual. - /// \return The created particle emitter - public: virtual ParticleEmitterPtr CreateParticleEmitter() = 0; - - /// \brief Create new particle emitter with the given ID. A unique name - /// will automatically be assigned to the visual. If the given ID is - /// already in use, NULL will be returned. - /// \param[in] _id ID of the new particle emitter - /// \return The created particle emitter - public: virtual ParticleEmitterPtr CreateParticleEmitter( - unsigned int _id) = 0; - - /// \brief Create new particle emitter with the given name. A unique ID - /// will automatically be assigned to the visual. If the given name is - /// already in use, NULL will be returned. - /// \param[in] _name Name of the new particle emitter - /// \return The created particle emitter - public: virtual ParticleEmitterPtr CreateParticleEmitter( - const std::string &_name) = 0; - - /// \brief Create new particle emitter with the given name. If either the - /// given ID or name is already in use, NULL will be returned. - /// \param[in] _id ID of the new particle emitter - /// \param[in] _name Name of the new particle emitter - /// \return The created particle emitter - public: virtual ParticleEmitterPtr CreateParticleEmitter( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Enable sky in the scene. - /// \param[in] _enabled True to enable sky - public: virtual void SetSkyEnabled(bool _enabled) = 0; - - /// \brief Get whether the sky is enabled in the scene. - /// \return true to sky is enabled, false otherwise - public: virtual bool SkyEnabled() const = 0; - - /// \brief Prepare scene for rendering. The scene will flushing any scene - /// changes by traversing scene-graph, calling PreRender on all objects - public: virtual void PreRender() = 0; - - /// \brief Call this function after you're done updating ALL cameras - /// \remark Each PreRender must have a correspondent PostRender - /// \remark Particle FX simulation is moved forward after this call - /// - /// \see Scene::SetCameraPassCountPerGpuFlush - public: virtual void PostRender() = 0; - - /// \brief - /// The ideal render loop is as follows: - /// - /// \code - /// scene->PreRender(); - /// for (auto &camera in cameras) - /// camera->Render(); - /// for (auto &camera in cameras) - /// camera->PostRender(); - /// scene->PostRender(); - /// \endcode - /// - /// Now... Camera Render calls MUST happen between Scene::PreRender and - /// Scene::PostRender. - /// - /// The scene must not be modified (e.g. add/remove objects, lights, etc) - /// while inside Scene PreRender/PostRender - /// - /// # Legacy mode: Set this value to 0. - /// - /// Old projects migrating to newer ign versions may break - /// these rules (e.g. not calling Render between Scene's - /// Pre/PostRender). - /// - /// Setting this value to 0 forces Gazebo to flush commands for - /// every camera; thus avoiding the need to call PostRender at all - /// - /// This is much slower but will ease porting, specially - /// if it's not easy to adapt your code to call PostRender for some - /// reason (in non-legacy mode each call *must* correspond to a - /// previous PreRender call) - /// - /// Legacy mode forces Particle FX simulations to move forward - /// after each camera render, which can cause inconsistencies - /// when Cameras are supposed to be rendering the same frame from - /// different angles - /// - /// # New mode i.e. values greater than 0: - /// - /// The CPU normally queues up of rendering commands from each Camera and - /// then waits for the GPU to finish up. - /// - /// 1. If we flush too often, the CPU will often have to wait for - /// the GPU to finish. - /// 2. If we flush infrequently, RAM consumption will rise due to - /// queueing up too much unsubmitted work. - /// - /// Larger values values queue up more work; lower values flush more - /// frequently. - /// - /// Note that work may be submitted earlier if required by a specific - /// operation (e.g. reading GPU -> CPU) - /// - /// A sensible value in the range of [2; 6] is probably the best - /// ratio between parallel performance / RAM cost. - /// - /// Actual value depends on scene complexity and number of shadow - /// casting lights - /// - /// If you're too tight on RAM consumption, try setting this value to 1. - /// - /// ## Example: - /// - /// Cubemap rendering w/ 3 probes and 5 shadowmaps can cause - /// a blow up of passes: - /// - /// (5 shadow maps per face + 1 regular render) x 6 faces x 3 probes = - /// 108 render_scene passes. - /// 108 is way too much, causing out of memory situations; - /// - /// so setting the value to 6 (1 cubemap face = 1 pass) will - /// force one flush per cubemap face, flushing a total of 3 times - /// (one per cubemap). - /// - /// ## Upper bound - /// - /// Once Scene::PostRender is called, a flush is always forced. - /// - /// If you set a value of e.g. 6, but you have a single camera, it - /// will be flushed after Scene::PostRender, thus having a value of 1 or - /// 6 won't matter as the result will be exactly the same (in every term: - /// performance, memory consumption) - /// - /// A value of 6 is like an upper bound. - /// We may queue _up to_ 6 render passes or less; but never more. - /// - /// \remarks Not all rendering engines care about this. - /// ogre2 plugin does. - /// - /// \param[in] _numPass 0 for old projects who can't or don't know - /// when to call PostRender and prefer to penalize rendering - /// performance - /// Value in range [1; 255] - public: virtual void SetCameraPassCountPerGpuFlush(uint8_t _numPass) = 0; - - /// \brief Returns the value set in SetCameraPassCountPerGpuFlush - /// \return Value in range [0; 255]. - /// ALWAYS returns 0 for plugins that ignore - /// SetCameraPassCountPerGpuFlush - public: virtual uint8_t CameraPassCountPerGpuFlush() const = 0; - - /// \brief Checks if SetCameraPassCountPerGpuFlush is 0 - /// \return True if Gazebo is using the old method (i.e. 0). - /// ALWAYS returns true for plugins that ignore - /// SetCameraPassCountPerGpuFlush - public: virtual bool LegacyAutoGpuFlush() const = 0; - - /// \brief Remove and destroy all objects from the scene graph. This does - /// not completely destroy scene resources, so new objects can be created - /// and added to the scene afterwards. - public: virtual void Clear() = 0; - - /// \brief Completely destroy the scene an all its resources. Continued - /// use of this scene after its destruction will result in undefined - /// behavior. - public: virtual void Destroy() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/SegmentationCamera.hh b/include/ignition/rendering/SegmentationCamera.hh index afc69079d..17e586731 100644 --- a/include/ignition/rendering/SegmentationCamera.hh +++ b/include/ignition/rendering/SegmentationCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,109 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_SEGMENTATIONCAMERA_HH_ -#define IGNITION_RENDERING_SEGMENTATIONCAMERA_HH_ -#include -#include - -#include -#include - -#include "ignition/rendering/Camera.hh" - - -namespace ignition -{ - namespace rendering - { - /// \brief Segmentation types for Semantic / Panpoptic segmentation - enum class SegmentationType - { - /// \brief Pixels of same label from different items - /// have the same color & id. - ST_SEMANTIC = 0, - - /// \brief Pixels of same label from different items, have different - /// color & id. 1 channel for label id & 2 channels for instance id - ST_PANOPTIC = 1 - }; - - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \class SegmentationCamera SegmentationCamera.hh - /// ignition/rendering/SegmentationCamera.hh - /// \brief Poseable Segmentation camera used for rendering the scene graph. - /// This camera is designed to produce segmentation data, instead of a 2D - /// image. - class IGNITION_RENDERING_VISIBLE SegmentationCamera : - public virtual Camera - { - /// \brief Destructor - public: virtual ~SegmentationCamera() { } - - /// \brief Create a texture which will hold the segmentation data - public: virtual void CreateSegmentationTexture() = 0; - - /// \brief Get the segmentation image data. - /// If the segmentation type is panoptic, the first two channels are the - /// instance count, and the last channel is the label. - /// \return The labels-buffer as an array of unsigned ints - public: virtual uint8_t *SegmentationData() const = 0; - - /// \brief Connect to the new Segmentation image event - /// \param[in] _subscriber Subscriber callback function. - /// The callback function arguments are: - /// - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr - ConnectNewSegmentationFrame( - std::function _subscriber) = 0; - - /// \brief Set Segmentation Type - /// \param[in] _type Segmentation Type - public: virtual void SetSegmentationType(SegmentationType _type) = 0; - - /// \brief Get Segmentation Type - /// \return Segmentation Type - public: virtual SegmentationType Type() const = 0; - - /// \brief Enable Color map mode to generate colored semantics - /// \param[in] _enable True to generate colored map, False to generate - /// label id map - public: virtual void EnableColoredMap(bool _enable) = 0; - - /// \brief Check if color map mode is enabled - /// \return True if colored map, False if label id map - public: virtual bool IsColoredMap() const = 0; - - /// \brief Set color for background & unlabeled items in the colored map - /// \param[in] _color Color of background & unlabeled items - public: virtual void SetBackgroundColor(const math::Color &_color) = 0; - - /// \brief Set label for background & unlabeled items in the semantic map - /// \param[in] _label label of background & unlabeled items - public: virtual void SetBackgroundLabel(int _label) = 0; - - /// \brief Get color for background & unlabeled items in the colored map - /// \return Color of background & unlabeled items - public: virtual const math::Color &BackgroundColor() const = 0; - - /// \brief Get label for background & unlabeled items in the semantic map - /// \return label of background & unlabeled items - public: virtual int BackgroundLabel() const = 0; - - /// \brief Convert the colored map stored in the internal buffer to label - /// IDs map, so users get both the colored map and the corresponding IDs - /// map. This function must be called before the next render loop and - /// the colored map mode must be enabeled - /// \param[out] _labelBuffer A buffer that is populated with the label - /// IDs map data. This output buffer must be allocated with the same size - /// before calling - public: virtual void LabelMapFromColoredBuffer( - uint8_t *_labelBuffer) const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Sensor.hh b/include/ignition/rendering/Sensor.hh index 41da10872..91c77a516 100644 --- a/include/ignition/rendering/Sensor.hh +++ b/include/ignition/rendering/Sensor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,36 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_SENSOR_HH_ -#define IGNITION_RENDERING_SENSOR_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Node.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Sensor Sensor.hh ignition/rendering/Sensor.hh - /// \brief Represents a scene sensor. The most obvious example is a camera, - /// but it can be anything that generates output from the scene. - class IGNITION_RENDERING_VISIBLE Sensor : - public virtual Node - { - /// \brief Sensor - public: virtual ~Sensor() { } - - /// \brief Set visibility mask - /// \param[in] _mask Visibility mask - public: virtual void SetVisibilityMask(uint32_t _mask) = 0; - - /// \brief Get visibility mask - /// \return visibility mask - public: virtual uint32_t VisibilityMask() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/ShaderParam.hh b/include/ignition/rendering/ShaderParam.hh index 50ca81f1b..c4cb1ab8c 100644 --- a/include/ignition/rendering/ShaderParam.hh +++ b/include/ignition/rendering/ShaderParam.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,134 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_SHADERPARAM_HH_ -#define IGNITION_RENDERING_SHADERPARAM_HH_ - -#include -#include -#include -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief forward declaration - class ShaderParamPrivate; - - /// \brief a variant type that holds params that can be passed to a shader - class IGNITION_RENDERING_VISIBLE ShaderParam - { - public: enum ParamType : uint16_t - { - /// \brief Type none - PARAM_NONE = 0, - - /// \brief Float type parameter - PARAM_FLOAT = 1, - - /// \brief Integer type parameter - PARAM_INT = 2, - - /// \brief Float Buffer type parameter - PARAM_FLOAT_BUFFER = 3, - - /// \brief Int Buffer type parameter - PARAM_INT_BUFFER = 4, - - /// \brief texture type parameter - PARAM_TEXTURE = 5, - - /// \brief cube map type parameter - PARAM_TEXTURE_CUBE = 6, - }; - - /// \brief constructor - public: ShaderParam(); - - /// \brief copy constructor - /// \param[in] _other Another ShaderParam - public: ShaderParam(const ShaderParam &_other); - - /// \brief destructor - public: ~ShaderParam(); - - /// \brief Get the type of this parameter - /// \return Type of this parameter - public: ParamType Type() const; - - /// \brief Get the element count of this parameter's buffer - /// \return Count of elements in this parameter's buffer - public: uint32_t Count() const; - - /// \brief Set from another ShaderParam - /// \param[in] _other Another ShaderParam - /// \return Reference to this ShaderParam - public: ShaderParam &operator=(const ShaderParam &_other); - - /// \brief Set this to be a float parameter - /// \param[in] _value Value to set this parameter to - public: void operator=(const float _value); - - /// \brief Set this to be an integer parameter - /// \param[in] _value Value to set this parameter to - public: void operator=(const int _value); - - /// \brief Set this to be a texture parameter - /// \param[in] _value Value to set this parameter to - /// \param[in] _type Type of texture - /// \param[in] _uvSetIndex Texture coordinate set index - public: void SetTexture(const std::string &_value, - ShaderParam::ParamType _type = ShaderParam::ParamType::PARAM_TEXTURE, - uint32_t _uvSetIndex = 0u); - - /// \brief Set this to be a buffer parameter - /// \param[in] _count Number of 32-bit elements in the buffer - public: void InitializeBuffer(uint32_t _count); - - /// \brief Copy a buffer to this parameter - /// \param[in] _floatBuffer Source buffer to copy from - public: void UpdateBuffer(float *_floatBuffer); - - /// \brief Copy a buffer to this parameter - /// \param[in] _intBuffer Source buffer to copy from - public: void UpdateBuffer(int *_intBuffer); - - /// \brief Get the value of this parameter if it is a float - /// \param[out] _value variable the value will be copied to - /// \return true if the parameter is the expected type - public: bool Value(float *_value) const; - - /// \brief Get the value of this parameter if it is an int - /// \param[out] _value variable the value will be copied to - /// \return true if the parameter is the expected type - public: bool Value(int *_value) const; - - /// \brief Get the value of this parameter if it is a texture - /// \param[out] _value variable the value will be copied to - /// \param[out] _uvSetIndex Texture coordinate set index - /// \return true if the parameter filled - public: bool Value(std::string &_value, uint32_t &_uvSetIndex) const; - - /// \brief Get the value of this parameter if it is a buffer - /// \param[out] _buffer variable the value will be copied to - /// \return true if the parameter is the expected type - public: bool Buffer(std::shared_ptr &_buffer) const; - - /// \brief private implementation - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/ShaderParams.hh b/include/ignition/rendering/ShaderParams.hh index adc4a17f5..cf358abe5 100644 --- a/include/ignition/rendering/ShaderParams.hh +++ b/include/ignition/rendering/ShaderParams.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,120 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_SHADERPARAMS_HH_ -#define IGNITION_RENDERING_SHADERPARAMS_HH_ - -#include -#include -#include - -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/ShaderParam.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief forward declaration - class ShaderParamsPrivate; - - /// \brief a map that holds params to be passed to a shader - class IGNITION_RENDERING_VISIBLE ShaderParams - { - /// \brief forward declaration - class IteratorPrivate; - - /// \brief Iterator for looping through params - /// \remarks implements a forward-iterator - class IGNITION_RENDERING_VISIBLE Iterator - { - /// \brief Default constructor - public: Iterator(); - - /// \brief Special constructor used by ShaderParams implementation - /// \param[in] _dataPtr Pointer to private data. - public: explicit Iterator(std::unique_ptr _dataPtr); - - /// \brief Copy constructor - /// \param[in] _iter Another iterator - public: Iterator(const Iterator &_iter); - - /// \brief Copy assignment - /// \param[in] _iter Another iterator - /// \return this - Iterator& operator=(const Iterator &_iter); - - /// \brief Destructor - public: ~Iterator(); - - /// \brief Equality operator - /// \param[in] _iter Another iterator - /// \return True if input interator equal to this one, false otherwise. - public: bool operator==(const Iterator &_iter); - - /// \brief Inequality operator - /// \param[in] _iter Another iterator - /// \return True if input interator is equal to this one, - /// false otherwise - public: bool operator!=(const Iterator &_iter); - - /// \brief Dereference operator - public: const std::pair &operator*(); - - /// \brief Arrow dereference operator - public: const std::pair *operator->(); - - /// \brief prefix increment - public: Iterator &operator++(); - - /// \brief postfix increment - public: Iterator operator++(int); - - private: std::unique_ptr dataPtr; - }; - - /// \brief constructor - public: ShaderParams(); - - /// \brief destructor - public: ~ShaderParams(); - - /// \brief Access a param with a given name - /// \param[in] _name Identifier for the parameter - /// \returns parameter reference - public: ShaderParam &operator[](const std::string &_name); - - /// \brief Access a param with a given name - /// \param[in] _name Identifier for the parameter - /// \returns const parameter reference - public: const ShaderParam &operator[](const std::string &_name) const; - - /// \brief Iterator to first parameter - /// \remarks Necessary for range-base for loop support - /// \return Iterator pointing to first parameter. - public: Iterator begin() const; - - /// \brief Iterator to one past last param - /// \remarks Necessary for range-base for loop support - /// \return Iterator pointing to one past last parameter. - public: Iterator end() const; - - /// \brief Have the params changed? - /// \internal - /// \returns true if the parameters have changed - public: bool IsDirty() const; - - /// \brief Resets the dirty flag - /// \internal - public: void ClearDirty(); - - /// \brief private implementation - private: std::unique_ptr dataPtr; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/ShaderType.hh b/include/ignition/rendering/ShaderType.hh index a0e55e509..43013005b 100644 --- a/include/ignition/rendering/ShaderType.hh +++ b/include/ignition/rendering/ShaderType.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,76 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_SHADERTYPE_HH_ -#define IGNITION_RENDERING_SHADERTYPE_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \enum ShaderType ShaderType.hh ignition/rendering/ShaderType.hh - /// \brief Available types of shaders. Note that not all rendering-engines - /// will be able to use each type. They will instead default to the closest - /// alternative. - enum IGNITION_RENDERING_VISIBLE ShaderType - { - /// \brief Unknown or errant type - ST_UNKNOWN = 0, - - /// \brief Per pixel lighting shader - ST_PIXEL = 1, - - /// \brief Per vertex lighting shader - ST_VERTEX = 2, - - /// \brief Object-space normal map shader - ST_NORM_OBJ = 3, - - /// \brief Tangent-space normal map shader - ST_NORM_TAN = 4, - - /// \brief Total number of shader types - ST_COUNT = 5, - }; - - /// \class ShaderUtil ShaderType.hh ignition/rendering/ShaderType.hh - /// \brief Provides supporting functions for ShaderType enum - class IGNITION_RENDERING_VISIBLE ShaderUtil - { - /// \brief Determine if given type is valid ShaderType enum - /// \param[in] _type Enum value to be evaluated - /// \return True if the given type is valid - public: static bool IsValid(ShaderType _type); - - /// \brief Sanitize given type. If the given value is invalid, - /// ST_UNKNOWN will be returned, otherwise input will be returned - /// unchanged. - /// \param[in] _type Shader type to be sanitized - /// \return The santized shader type - public: static ShaderType Sanitize(ShaderType _type); - - /// \brief Get human-readable name for shader type value. - /// \param[in] _type Shader type enum value - /// \return The type name - public: static std::string Name(ShaderType _type); - - /// \brief Get enum value by human-readable name. The given string should - /// match watch is returned by GetName. If an invalid name is given, - /// ST_UNKNOWN will be returned. - /// \param[in] _name Name of the shader type to be retrieved - /// \return The specified ShaderType enum value - public: static ShaderType Enum(const std::string &_name); - - /// \brief Array of human-readable names for each ShaderType - private: static const char *names[ST_COUNT]; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Storage.hh b/include/ignition/rendering/Storage.hh index ff02a5947..9fdeb0b9c 100644 --- a/include/ignition/rendering/Storage.hh +++ b/include/ignition/rendering/Storage.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,373 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_STORAGE_HH_ -#define IGNITION_RENDERING_STORAGE_HH_ -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Node.hh" -#include "ignition/rendering/Light.hh" -#include "ignition/rendering/Sensor.hh" -#include "ignition/rendering/Visual.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Material.hh" -#include "ignition/rendering/Mesh.hh" -#include "ignition/rendering/Export.hh" - -// An X11 header file defines a macro that conflicts with our function name, -// so undefine it here -#ifdef DestroyAll -#undef DestroyAll -#endif - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Map Storage.hh ignition/rendering/Storage.hh - /// \brief Storage map from std::string to template class T - /// \tparam T The storage element type - template - class IGNITION_RENDERING_VISIBLE Map - { - /// \typedef TPtr - /// \brief Shared pointer to T - typedef std::shared_ptr TPtr; - - /// \typedef const TPtr - /// \brief Shared pointer to const T - typedef std::shared_ptr ConstTPtr; - - /// \brief Destructor - public: virtual ~Map() { } - - /// \brief Get the number of elements in this map - /// \return The number of elements in this map - public: virtual unsigned int Size() const = 0; - - /// \brief Determine if an elements is mapped to the given key - /// \param[in] _key Key of the element in question - /// \return True if an elements is mapped to the given key - public: virtual bool ContainsKey(const std::string &_key) const = 0; - - /// \brief Determine if the given element exists in this map - /// \param[in] _value Element in question - /// \return True if the given element exists in this map - public: virtual bool ContainsValue(ConstTPtr _value) const = 0; - - /// \brief Get the element mapped to the given key - /// \param[in] _key Key of the element in question - /// \return The element mapped to the given key - public: virtual TPtr Get(const std::string &_key) const = 0; - - /// \brief Get the element at the given index - /// \param[in] _index Index of the element in question - /// \return The element at the given index - public: virtual TPtr GetByIndex(unsigned int _index) const = 0; - - /// \brief Map to given element to the given key. If the given key is - /// already in use, no work will be done. - /// \param[in] _key Key of the new element - /// \param[in] _value Element to be mapped - /// \return True if successful - public: virtual bool Put(const std::string &_key, TPtr _value) = 0; - - /// \brief Remove the element mapped to the given key. If the specified - /// element does not exists, no work will be done. - /// \param[in] _key Key of the element in question - public: virtual void Remove(const std::string &_key) = 0; - - /// \brief Remove the given element. If the given element does not exist - /// no work will be done. - /// \param[in] _value Key of the element in question - public: virtual void Remove(TPtr _value) = 0; - - /// \brief Remove all elements from this map - public: virtual void RemoveAll() = 0; - }; - - /// \class Store Storage.hh ignition/rendering/Storage.hh - /// \brief Multi-access storage structure of template class T. Template - /// class T is expected to have functions GetId, GetName(), Destroy() which - /// return unsigned int, std::string, and void respectively. This store - /// will ensure that each element's name and ID are unique. - /// \tparam T The storage element type - template - class IGNITION_RENDERING_VISIBLE Store - { - /// \typedef TPtr - /// \brief Shared pointer to T - typedef std::shared_ptr TPtr; - - /// \typedef const TPtr - /// \brief Shared pointer to const T - typedef std::shared_ptr ConstTPtr; - - /// \brief Destructor - public: virtual ~Store() { } - - /// \brief Get number of elements in this store - /// \return The number of elements in this store - public: virtual unsigned int Size() const = 0; - - /// \brief Determine if store contains the given element - /// \param[in] _object The element in question - /// \return True if this store contains the given element - public: virtual bool Contains(ConstTPtr _object) const = 0; - - /// \brief Determine if store contains the element with the given ID - /// \param[in] _id ID of the element in question - /// \return True if this store contains the specified element - public: virtual bool ContainsId(unsigned int _id) const = 0; - - /// \brief Determine if store contains the element with the given name - /// \param[in] _name Name of the element in question - /// \return True if this store contains the specified element - public: virtual bool ContainsName(const std::string &_name) const = 0; - - /// \brief Get element with the given ID - /// \param[in] _id ID of the desired element - /// \return The specified element - public: virtual TPtr GetById(unsigned int _id) const = 0; - - /// \brief Get element with the given name - /// \param[in] _name Name of the desired element - /// \return The specified element - public: virtual TPtr GetByName(const std::string &_name) const = 0; - - /// \brief Get element at the given index - /// \param[in] _index Index of the desired element - /// \return The specified element - public: virtual TPtr GetByIndex(unsigned int _index) const = 0; - - /// \brief Add given element. If the element has already been added - /// or its name or ID conflict with other existing elements, then no - /// work will be done. - /// \param[in] _object Element to be added - /// \return True if successful - public: virtual bool Add(TPtr _object) = 0; - - /// \brief Remove given element. If the given element does not exists - /// in this store, then no work will be done. - /// \param[in] _object Element to be removed - /// \return The removed element - public: virtual TPtr Remove(TPtr _object) = 0; - - /// \brief Remove element with the given ID. If the specified element - /// does not exists in this store, then no work will be done. - /// \param[in] _id ID of the element to be removed - /// \return The removed element - public: virtual TPtr RemoveById(unsigned int _id) = 0; - - /// \brief Remove element with the given name. If the specified element - /// does not exists in this store, then no work will be done. - /// \param[in] _name Name of the element to be removed - /// \return The removed element - public: virtual TPtr RemoveByName(const std::string &_name) = 0; - - /// \brief Remove element at the given index. If the specified element - /// does not exists in this store, then no work will be done. - /// \param[in] _index Index of the element to be removed - /// \return The removed element - public: virtual TPtr RemoveByIndex(unsigned int _index) = 0; - - /// \brief Remove all elements from store - public: virtual void RemoveAll() = 0; - - /// \brief Remove and destroy given element. If the given element does - /// not exists, in this store, then no work will be done. - /// \param[in] _object Element to be removed - public: virtual void Destroy(TPtr _object) = 0; - - /// \brief Remove and destroy element with the given ID. If the specified - /// element does not exists in this store, then no work will be done. - /// \param[in] _id ID of the element to be removed - public: virtual void DestroyById(unsigned int _id) = 0; - - /// \brief Remove and destroy element with the given name. If the - /// specified element does not exists in this store, then no work - /// will be done. - /// \param[in] _name Name of the element to be removed - public: virtual void DestroyByName(const std::string &_name) = 0; - - /// \brief Remove and destroy element at the given index. If the - /// specified element does not exists in this store, then no work - /// will be done. - /// \param[in] _index Index of the element to be removed - public: virtual void DestroyByIndex(unsigned int _index) = 0; - - /// \brief Remove and destroy all elements in store - public: virtual void DestroyAll() = 0; - }; - - /// \class CompositeStore Storage.hh ignition/rendering/Storage.hh - /// ignition/rendering/CompositeStore.hh - /// \brief Represents a collection of Store objects, collectively working as - /// a single composite store. - /// \tparam T The storage element type - template - class IGNITION_RENDERING_VISIBLE CompositeStore : - public Store - { - /// \typedef TPtr - /// \brief Shared pointer to T - typedef std::shared_ptr TPtr; - - /// \typedef TPtr - /// \brief Store of T - typedef Store TStore; - - /// \typedef TStorePtr - /// \brief Shared pointer to TStore - typedef std::shared_ptr TStorePtr; - - /// \typedef const TStorePtr - /// \brief Shared pointer to const TStore - typedef std::shared_ptr ConstTStorePtr; - - /// \brief Destructor - public: virtual ~CompositeStore() { } - - /// \brief Get number of Stores - /// \return The number of Stores - public: virtual unsigned int GetStoreCount() const = 0; - - /// \brief Determine if given store exists - /// \param[in] _store Store in question - /// \return True if given store exists - public: virtual bool ContainsStore(ConstTStorePtr _store) const = 0; - - /// \brief Add the given store. If the given store already exists, then - /// no work will be done. - /// \param[in] _store Store to be added - /// \return True if successful - public: virtual bool AddStore(TStorePtr _store) = 0; - - /// \brief Get store at the given index. If no such store exists NULL - /// will be returned. - /// \param[in] _index Index of the desired store - /// \return The specified store - public: virtual TStorePtr GetStore(unsigned int _index) const = 0; - - /// \brief Remove given store. If no such store exists no - /// work will be done and NULL will be returned. - /// \param[in] _store Store to be removed - /// \return The removed store - public: virtual TStorePtr RemoveStore(TStorePtr _store) = 0; - - /// \brief Remove store at the given index. If no such store exists no - /// work will be done and NULL will be returned. - /// \param[in] _index Index of the store to be removed - /// \return The removed store - public: virtual TStorePtr RemoveStore(unsigned int _index) = 0; - }; - - /// \class StoreWrapper Storage.hh ignition/rendering/StoreWrapper.hh - /// \brief Simple wrapper class that allows a Store of type Derived to be - /// treated as a Store of type Base, where Derived is some class derived - /// from Base. This is useful in storing Stores of different derived types - /// in a single CompositeStore instance. - /// \tparam T New storage type - /// \tparam U Some derived class of T - template - class IGNITION_RENDERING_VISIBLE StoreWrapper : - public Store - { - public: virtual ~StoreWrapper() { } - }; - -// armhf failed to build with this code. It can not be removed for the rest -// of arches to keep ABI but should be removed in major versions unreleased -// see https://github.com/ignitionrobotics/ign-rendering/pull/457 -#ifndef __ARM_PCS_VFP - template class Store; - template class Store; - template class Store; - template class Store; - template class Store; - template class Store; - template class Store; - template class Map; - template class CompositeStore; -#endif - - /// \def SceneStore - /// \brief Store of Scene - typedef Store SceneStore; - - /// \def NodeStore - /// \brief Store of Node - typedef Store NodeStore; - - /// \def LightStore - /// \brief Store of Light - typedef Store LightStore; - - /// \def SensorStore - /// \brief Store of Sensor - typedef Store SensorStore; - - /// \def VisualStore - /// \brief Store of Visual - typedef Store VisualStore; - - /// \def GeometryStore - /// \brief Store of Geometry - typedef Store GeometryStore; - - /// \def SubMeshStore - /// \brief Store of SubMesh - typedef Store SubMeshStore; - - /// \def MaterialMap - /// \brief Material Map - typedef Map MaterialMap; - - /// \def NodeCompositeStore - /// \brief Node Composite Store - typedef CompositeStore NodeCompositeStore; - - /// \def SceneStorePtr - /// \brief Shared pointer to SceneStore - typedef std::shared_ptr SceneStorePtr; - - /// \def NodeStorePtr - /// \brief Shared pointer to NodeStore - typedef std::shared_ptr NodeStorePtr; - - /// \def LightStorePtr - /// \brief Shared pointer to LightStore - typedef std::shared_ptr LightStorePtr; - - /// \def SensorStorePtr - /// \brief Shared pointer to SensorStore - typedef std::shared_ptr SensorStorePtr; - - /// \def VisualStorePtr - /// \brief Shared pointer to VisualStore - typedef std::shared_ptr VisualStorePtr; - - /// \def GeometryStorePtr - /// \brief Shared pointer to GeometryStore - typedef std::shared_ptr GeometryStorePtr; - - /// \def SubMeshStorePtr - /// \brief Shared pointer to SubMeshStore - typedef std::shared_ptr SubMeshStorePtr; - - /// \def MaterialMapPtr - /// \brief Shared pointer to MaterialMap - typedef std::shared_ptr MaterialMapPtr; - - /// \def NodeCompositeStorePtr - /// \brief Shared pointer to NodeCompositeStore - typedef std::shared_ptr NodeCompositeStorePtr; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Text.hh b/include/ignition/rendering/Text.hh index bcd7d91e2..be58413fc 100644 --- a/include/ignition/rendering/Text.hh +++ b/include/ignition/rendering/Text.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,151 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_TEXT_HH_ -#define IGNITION_RENDERING_TEXT_HH_ -#include - -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \enum TextHorizontalAlign - /// \brief Text Horizontal alignment - enum class TextHorizontalAlign - { - /// \brief Left alignment - LEFT = 0, - /// \brief Center alignment - CENTER = 1, - /// \brief Right alignment - RIGHT = 2 - }; - - /// \enum TextVerticalAlign - /// \brief Text vertical alignment - enum class TextVerticalAlign - { - /// \brief Align bottom - BOTTOM = 0, - /// \brief Align center - CENTER = 1, - /// \brief Align top - TOP = 2 - }; - - /// \class Text Text.hh ignition/rendering/Text - /// \brief Represents a billboard text geometry that is always facing the - /// camera. - class IGNITION_RENDERING_VISIBLE Text : - public virtual Geometry - { - /// \brief Constructor - public: Text() = default; - - /// \brief Destructor - public: virtual ~Text() = default; - - /// \brief Set the font. - /// \param[in] _font Name of the font - /// \sa FontName() - public: virtual void SetFontName(const std::string &_font) = 0; - - /// \brief Get the font name. - /// \return The font name. - /// \sa SetFontName() - public: virtual std::string FontName() const = 0; - - /// \brief Set the text to display. - /// \param[in] _text The text to display. - /// \sa Text() - public: virtual void SetTextString(const std::string &_text) = 0; - - /// \brief Get the displayed text. - /// \return The displayed text. - /// \sa SetText() - public: virtual std::string TextString() const = 0; - - /// \brief Set the text color. - /// \param[in] _color Text color. - /// \sa Color() - public: virtual void SetColor(const ignition::math::Color &_color) = 0; - - /// \brief Get the text color. - /// \return Text color. - /// \sa SetColor() - public: virtual ignition::math::Color Color() const = 0; - - /// \brief Set the height of the character in meters. - /// \param[in] _height Height of the characters. - /// \sa CharHeight() - public: virtual void SetCharHeight(const float _height) = 0; - - /// \brief Get the height of the characters in meters - /// return Height of the characters. - /// \sa SetCharHeight() - public: virtual float CharHeight() const = 0; - - /// \brief Set the width of spaces between words. - /// \param[in] _width Space width - /// \sa SpaceWidth() - public: virtual void SetSpaceWidth(const float _width) = 0; - - /// \brief Get the width of spaces between words. - /// \return Space width - /// \sa SetSpaceWidth() - public: virtual float SpaceWidth() const = 0; - - /// \brief Set the alignment of the text - /// \param[in] _hAlign Horizontal alignment - /// \param[in] _vAlign Vertical alignment - public: virtual void SetTextAlignment(const TextHorizontalAlign &_hAlign, - const TextVerticalAlign &_vAlign) = 0; - - /// \brief Get the horizontal alignment of the text - /// \return Text horizontal alignment - public: virtual TextHorizontalAlign HorizontalAlignment() const = 0; - - /// \brief Get the vertical alignment of the text - /// \return Text verical alignment - public: virtual TextVerticalAlign VerticalAlignment() const = 0; - - /// \brief Set the baseline height of the text - /// \param[in] _baseline Baseline height - /// \sa Baseline() - public: virtual void SetBaseline(const float _baseline) = 0; - - /// \brief Get the baseline height in meters. - /// \return Baseline height - /// \sa SetBaseline() - public: virtual float Baseline() const = 0; - - /// \brief True = text always is displayed ontop. - /// \param[in] _onTop Set to true to render the text on top of - /// all other drawables. - /// \sa ShowOnTop() - public: virtual void SetShowOnTop(const bool _onTop) = 0; - - /// \brief Get whether the is displayed above other objects. - /// \return True if it is on top. - /// \sa SetShowOnTop() - public: virtual bool ShowOnTop() const = 0; - - /// \brief Get the axis aligned bounding box of the text. - /// \return The axis aligned bounding box. - public: virtual ignition::math::AxisAlignedBox AABB() const = 0; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/ThermalCamera.hh b/include/ignition/rendering/ThermalCamera.hh index 643fed05a..8e7a4b5b2 100644 --- a/include/ignition/rendering/ThermalCamera.hh +++ b/include/ignition/rendering/ThermalCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,112 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_THERMALCAMERA_HH_ -#define IGNITION_RENDERING_THERMALCAMERA_HH_ -#include -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /* \class ThermalCamera ThermalCamera.hh \ - * ignition/rendering/ThermalCamera.hh - */ - /// \brief Thermal camera that produces temperature data. - /// An object's temperature can be set through the Visual class - /// using SetUserData with the key "temperature". Ambient temperature - /// is returned for object that do not have this property set. Note that - /// temperature variations for the environment and objects can be set using - /// the Set*Range functions in this class. For simplicity, the variations - /// are modeled as a function of depth (which is not how a real thermal - /// sensor works). Ideally we support heatmaps for visuals in order to - /// produce more realistic temperature output. - class IGNITION_RENDERING_VISIBLE ThermalCamera : - public virtual Camera - { - /// \brief Destructor - public: virtual ~ThermalCamera() { } - - /// \brief Set the ambient temperature of the environment - /// \param[in] _ambient Ambient temperature in kelvin - /// \sa AmbientTemperature - public: virtual void SetAmbientTemperature(float _ambient) = 0; - - /// \brief Get the ambient temperature of the environment - /// \return Ambient temperature in kelvin - /// \sa SetAmbientTemperature - public: virtual float AmbientTemperature() const = 0; - - /// \brief Set the range of ambient temperature - /// \param[in] _range The ambient temperature ranges from - /// (ambient - range/2) to (ambient + range/2). - /// \sa AmbientTemperatureRange - public: virtual void SetAmbientTemperatureRange(float _range) = 0; - - /// \brief Get the range of ambient temperature - /// \return The ambient temperature range. Ambient temperature ranges - /// from (ambient - range/2) to (ambient - range/2) - /// \sa SetAmbientTemperatureRange - public: virtual float AmbientTemperatureRange() const = 0; - - /// \brief Set the minimum temperature the sensor can detect - /// \param[in] _min Min temperature in kelvin - /// \sa MinTemperature - public: virtual void SetMinTemperature(float _min) = 0; - - /// \brief Get the minimum temperature the sensor can detect - /// \return Min temperature in kelvin - /// \sa SetMinTemperature - public: virtual float MinTemperature() const = 0; - - /// \brief Set the maximum temperature the sensor can detect - /// \param[in] _max Max temperature in kelvin - /// \sa MaxTemperature - public: virtual void SetMaxTemperature(float _max) = 0; - - /// \brief Get the maximum temperature the sensor can detect - /// \return Max temperature in kelvin - /// \sa SetMaxTemperature - public: virtual float MaxTemperature() const = 0; - - /// \brief Set the temperature linear resolution. The thermal image data - /// returned will be temperature in kelvin / resolution. - /// Typical values are 0.01 (10mK), 0.1 (100mK), or 0.04 to simulate - /// 14 bit format. - /// \param[in] _resolution Temperature linear resolution - /// \sa LinearResolution - public: virtual void SetLinearResolution(float _resolution) = 0; - - /// \brief Get the temperature linear resolution - /// \return Temperature linear resolution - /// \sa SetLinearResolution - public: virtual float LinearResolution() const = 0; - - /// \brief Get the range of temperature variation for all heat sources. - /// \return Temperature variation range - /// \sa SetHeatSourceTemperatureRange - public: virtual float HeatSourceTemperatureRange() const = 0; - - /// \brief Set the range of temperature variation for all heat sources. - /// If set, the temperature reading of heat sources will vary within - /// a temperature of +/- range/2 instead of returning a fixed uniform - /// temperature for the entire heat source - /// \param[in] _range Temperature variation range - /// \sa HeatSourceTemperatureRange - public: virtual void SetHeatSourceTemperatureRange(float _range) = 0; - - /// \brief Connect to the new thermal image event - /// \param[in] _subscriber Subscriber callback function. The callback - /// function arguments are: - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewThermalFrame( - std::function _subscriber) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/TransformController.hh b/include/ignition/rendering/TransformController.hh index 8f0be4f8c..7b40c38a1 100644 --- a/include/ignition/rendering/TransformController.hh +++ b/include/ignition/rendering/TransformController.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,210 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_TRANSFORMCONTROLLER_HH_ -#define IGNITION_RENDERING_TRANSFORMCONTROLLER_HH_ -#include - -#include - -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GizmoVisual.hh" -#include "ignition/rendering/TransformType.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations - class TransformControllerPrivate; - - /* \class TransformController TransformController.hh \ - * ignition/rendering/TransformController.hh - */ - /// \brief An transform tool for translating, rotating, and scaling objects. - class IGNITION_RENDERING_VISIBLE TransformController - { - /// \brief Constructor - public: TransformController(); - - /// \brief Destructor - public: virtual ~TransformController(); - - /// \brief Update the transform controller. Its visual is updated based - /// on the current transform mode, space, and axis. - public: virtual void Update(); - - /// \brief Set the camera. - /// \param[in] _camera Camera - public: virtual void SetCamera(const CameraPtr &_camera); - - /// \brief get the camera that is controlled by this view controller. - /// \return camera being controlled - public: virtual CameraPtr Camera() const; - - /// \brief Get the attached node - /// \return The node which is being transformed, nullptr if there is no - /// node attached. - public: virtual NodePtr Node() const; - - /// \brief Attach the transform controller to the specified node - /// \param[in] _node Node that will be transformed - public: virtual void Attach(NodePtr _node); - - /// \brief Detach the transform controller from the currently attached - /// node - public: virtual void Detach(); - - /// \brief Set the transform mode - /// \param[in] _mode Transform mode to set to - public: virtual void SetTransformMode(TransformMode _mode); - - /// \brief Get the current transform mode - /// \return Transform mode - public: virtual TransformMode Mode() const; - - /// \brief Set the transform space - /// \param[in] _space Transform space to set to - public: virtual void SetTransformSpace(TransformSpace _space); - - /// \brief Get the transform space - /// \return Transform space - public: virtual TransformSpace Space() const; - - /// \brief Set the active transform axis. This highlights the axis visual - /// \param[in] _axis Transform axis vector - public: virtual void SetActiveAxis(const math::Vector3d &_axis); - - /// \brief Get the current highlighted active axis of transform - /// \return Active axis of transform - public: virtual math::Vector3d ActiveAxis() const; - - /// \brief Get the axis of transform represented by the given node id - /// \param[in] _id Id of the node to check - /// \return Transform axis - public: virtual math::Vector3d AxisById(unsigned int _id) const; - - /// \brief Translate the attached node - /// \param[in] _translation Translation in the current transform space - /// \param[in] _snap True to snap the final position to fixed increments - /// \sa SetTransformSpace - public: virtual void Translate(const math::Vector3d &_translation, - bool _snap = false); - - /// \brief Rotate the attached node - /// \param[in] _rotation Rotation in the current transform space - /// \param[in] _snap True to snap rotation angle to fixed increments - /// \sa SetTransformSpace - public: virtual void Rotate(const math::Quaterniond &_rotation, - bool _snap = false); - - /// \brief Scale the attached node. - /// \param[in] _scale Scale in the current transform space - /// \param[in] _snap True to snap scale to fixed increments - /// \sa SetTransformSpace - public: virtual void Scale(const math::Vector3d &_scale, - bool _snap = false); - - /// \brief Snap a point at intervals of a fixed distance. Currently used - /// to give a snapping behavior when transforming objects - /// \param[in] _point Input point. - /// \param[in] _interval Fixed distance interval at which the point - /// is snapped. - /// \param[in] _sensitivity Sensitivity of point snapping, in terms of a - /// percentage of the interval. - /// \return Snapped 3D point. - public: static ignition::math::Vector3d SnapPoint( - const ignition::math::Vector3d &_point, const double _interval = 1.0, - const double _sensitivity = 0.4); - - /// \brief Start the transform process. To be used with helper functions - /// that computions transforms from 2d movements. - /// \sa Stop - public: virtual void Start(); - - /// \brief Stop the transform process. To be used with helper functions - /// that computions transforms from 2d movements. - /// \sa Stop - public: virtual void Stop(); - - /// \brief Check if the transform process is active - /// \return True if node is being transformed - public: virtual bool Active() const; - - /// \brief Helper function to compute 3d translation from 2d translation - /// movement. Useful for converting 2d mouse drag motion to displacement - /// in world frame. Note that the camera must be set and Start() must be - /// called before using this function. - /// \param[in] _axis Axis of 3d translation. The resulting 3d vector - /// is constrained to this axis. - /// \param[in] _start Starting position of the 2d translation movement - /// \param[in] _end End position of the 2d translation movement - /// \return 3d translation vector in the current transform space - public: math::Vector3d TranslationFrom2d(const math::Vector3d &_axis, - const math::Vector2d &_start, const math::Vector2d &_end); - - /// \brief Helper function to compute 3d rotation from 2d translation - /// movement. Useful for converting 2d mouse drag motion to rotation angle - /// in world frame. Note that the camera must be set and Start() must be - /// called before using this function. - /// \param[in] _axis Axis of 3d rotation. The resulting rotation is - /// is constrained to this axis. - /// \param[in] _start Starting position of the 2d translation movement - /// \param[in] _end End position of the 2d translation movement - /// \return Rotation in the current transform space - public: math::Quaterniond RotationFrom2d(const math::Vector3d &_axis, - const math::Vector2d &_start, const math::Vector2d &_end); - - /// \brief Helper function to compute 3d scale from 2d translation - /// movement. Useful for converting 2d mouse drag motion to scale vector - /// in world frame. Note that the camera must be set and Start() must be - /// called before using this function. - /// \param[in] _axis Axis of scale. The resulting 3d vector - /// is constrained to this axis. - /// \param[in] _start Starting position of the 2d translation movement - /// \param[in] _end End position of the 2d translation movement - /// \return 3d scale vector in the current transform space - public: math::Vector3d ScaleFrom2d(const math::Vector3d &_axis, - const math::Vector2d &_start, const math::Vector2d &_end); - - /// \brief Convert a TransformAxis to a vector type - /// \param[in] _axis Transform axis - /// \return 3d axis vector - public: static math::Vector3d ToAxis(TransformAxis _axis); - - /// \brief Helper function to create a plane for transfomation. - /// The plane is chosen based on the current transform mode and the - /// transform axis specified. - /// \param[in] _axis Transformation axis used to identify the plane for - /// projection. - /// \param[in] _pt2d 2d point to help fine tune the plane created. - /// \return Plane created for transform - protected: math::Planed CreatePlaneForTransform( - const math::Vector3d &_axis, const math::Vector2d &_pt2d); - - /// \brief Helper function to compute ray plane intersection - /// \param[in] _ray Input ray - /// \param[in] _plane Plane to check for intersection - /// \param[out] _result Intersection point - /// \return True if intersection point exist, false if ray is parallel - /// to plane - protected: bool RayPlaneIntersection(RayQueryPtr _ray, - const math::Planed &_plane, math::Vector3d &_result); - - /// \brief Private data pointer - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/TransformType.hh b/include/ignition/rendering/TransformType.hh index faf1f66d5..cdf69c53d 100644 --- a/include/ignition/rendering/TransformType.hh +++ b/include/ignition/rendering/TransformType.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,70 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_TRANSFORMTYPE_HH_ -#define IGNITION_RENDERING_TRANSFORMTYPE_HH_ - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \enum TransformAxis - /// \brief Unique identifiers for transformation axes. - enum IGNITION_RENDERING_VISIBLE TransformAxis - { - /// \brief No axis - TA_NONE = 0, - /// \brief Translation in x - TA_TRANSLATION_X = 0x00000001, - /// \brief Translation in y - TA_TRANSLATION_Y = 0x00000002, - /// \brief Translation in z - TA_TRANSLATION_Z = 0x00000004, - /// \brief Rotation in x - TA_ROTATION_X = 0x00000010, - /// \brief Rotation in y - TA_ROTATION_Y = 0x00000020, - /// \brief Rotation in z - TA_ROTATION_Z = 0x00000040, - /// \brief Scale in x - TA_SCALE_X = 0x00000100, - /// \brief Scale in y - TA_SCALE_Y = 0x00000200, - /// \brief Scale in z - TA_SCALE_Z = 0x00000400 - }; - - /// \enum TransformMode - /// \brief Unique identifiers for transformation modes. - enum IGNITION_RENDERING_VISIBLE TransformMode - { - /// \brief Inactive state - TM_NONE = 0, - /// \brief Translation mode - TM_TRANSLATION = TA_TRANSLATION_X | TA_TRANSLATION_Y | TA_TRANSLATION_Z, - /// \brief Rotation mode - TM_ROTATION = TA_ROTATION_X | TA_ROTATION_Y | TA_ROTATION_Z, - /// \brief Scale mode - TM_SCALE = TA_SCALE_X | TA_SCALE_Y, TA_SCALEZ, - }; - - /// \enum TransformSpace - /// \brief Unique identifiers for transformation spaces. - enum IGNITION_RENDERING_VISIBLE TransformSpace - { - /// \brief transformation in local frame - TS_LOCAL, - /// \brief transformation in world frame - TS_WORLD - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Utils.hh b/include/ignition/rendering/Utils.hh index d1cea0cf8..78bcf3746 100644 --- a/include/ignition/rendering/Utils.hh +++ b/include/ignition/rendering/Utils.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,91 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_UTILS_HH_ -#define IGNITION_RENDERING_UTILS_HH_ + */ -#include - -#include -#include -#include -#include -#include - -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/RayQuery.hh" - - -namespace ignition -{ - /// \brief Rendering classes and function useful in robot applications. - namespace rendering - { - // Inline bracket to help doxygen filtering. - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Retrieve the first point on a surface in the 3D scene hit by a - /// ray cast from the given 2D screen coordinates. - /// \param[in] _screenPos 2D coordinates on the screen, in pixels. - /// \param[in] _camera User camera - /// \param[in] _rayQuery Ray query for mouse clicks - /// \param[in] _maxDistance maximum distance to check the collision - /// \return 3D coordinates of a point in the 3D scene. - IGNITION_RENDERING_VISIBLE - math::Vector3d screenToScene( - const math::Vector2i &_screenPos, - const CameraPtr &_camera, - const RayQueryPtr &_rayQuery, - float _maxDistance = 10.0); - - /// \brief Retrieve the first point on a surface in the 3D scene hit by a - /// ray cast from the given 2D screen coordinates. - /// \param[in] _screenPos 2D coordinates on the screen, in pixels. - /// \param[in] _camera User camera - /// \param[in] _rayQuery Ray query for mouse clicks - /// \param[inout] _rayResult Ray query result - /// \param[in] _maxDistance maximum distance to check the collision - /// \return 3D coordinates of a point in the 3D scene. - IGNITION_RENDERING_VISIBLE - math::Vector3d screenToScene( - const math::Vector2i &_screenPos, - const CameraPtr &_camera, - const RayQueryPtr &_rayQuery, - RayQueryResult &_rayResult, - float _maxDistance = 10.0); - - /// \brief Retrieve the point on a plane at z = 0 in the 3D scene hit by a - /// ray cast from the given 2D screen coordinates. - /// \param[in] _screenPos 2D coordinates on the screen, in pixels. - /// \param[in] _camera User camera - /// \param[in] _rayQuery Ray query for mouse clicks - /// \param[in] _offset Offset along the plane normal - /// \return 3D coordinates of a point in the 3D scene. - IGNITION_RENDERING_VISIBLE - math::Vector3d screenToPlane( - const math::Vector2i &_screenPos, - const CameraPtr &_camera, - const RayQueryPtr &_rayQuery, - const float _offset = 0.0); - - /// \brief Get the screen scaling factor. - /// \return The screen scaling factor. - IGNITION_RENDERING_VISIBLE - float screenScalingFactor(); - - /// \brief Transform a bounding box. - /// \param[in] _box The bounding box. - /// \param[in] _pose Pose used to transform the bounding box. - /// \return Vertices of the transformed bounding box in - /// world coordinates. - IGNITION_RENDERING_VISIBLE - ignition::math::AxisAlignedBox transformAxisAlignedBox( - const ignition::math::AxisAlignedBox &_box, - const ignition::math::Pose3d &_pose); - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/ViewController.hh b/include/ignition/rendering/ViewController.hh index a7245450c..8fd982496 100644 --- a/include/ignition/rendering/ViewController.hh +++ b/include/ignition/rendering/ViewController.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,50 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_VIEWCONTROLLER_HH_ -#define IGNITION_RENDERING_VIEWCONTROLLER_HH_ -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class ViewController ViewController.hh - /// ignition/rendering/ViewController.hh - /// \brief A camera view controller - class IGNITION_RENDERING_VISIBLE ViewController - { - /// \brief Destructor - public: virtual ~ViewController() { } - - /// \brief Set the camera that will be controlled by this view controller. - /// \param[in] _camera Camera to control - public: virtual void SetCamera(const CameraPtr &_camera) = 0; - - /// \brief Set target point for pan, zoom, oribit - /// \param[in] _target Target point in world coordinates - public: virtual void SetTarget(const math::Vector3d &_target) = 0; - - /// \brief Set zoom amount - /// \param[in] _value Camera zoon value, e.g. mouse scroll delta - public: virtual void Zoom(const double _value) = 0; - - /// \brief Set camera pan (translational movement) around target point. - /// \param[in] _value Pan amount in image plane, e.g. mouse drag delta. - public: virtual void Pan(const math::Vector2d &_value) = 0; - - /// \brief Set camera orbit (rotational movement) around target point. - /// \param[in] _value robit amount in image plane, e.g. mouse drag delta - public: virtual void Orbit(const math::Vector2d &_value) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Visual.hh b/include/ignition/rendering/Visual.hh index 8ce909c0e..0ac2c26ab 100644 --- a/include/ignition/rendering/Visual.hh +++ b/include/ignition/rendering/Visual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,145 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_VISUAL_HH_ -#define IGNITION_RENDERING_VISUAL_HH_ -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Node.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \class Visual Visual.hh ignition/rendering/Visual.hh - /// \brief Represents a visual node in a scene graph. A Visual is the only - /// node that can have Geometry and other Visual children. - class IGNITION_RENDERING_VISIBLE Visual : - public virtual Node - { - /// \brief Destructor - public: virtual ~Visual() { } - - /// \brief Get the number of geometries attached to this visual - /// \return The number of geometries attached to this visual - public: virtual unsigned int GeometryCount() const = 0; - - /// \brief Determine if given geometry is attached to this visual - /// \param[in] _geometry Geometry in question - /// \return True if given node is attached to this visual - public: virtual bool HasGeometry(ConstGeometryPtr _geometry) const = 0; - - /// \brief Get geometry at given index. If no geometry exists at given - /// index, NULL will be returned. - /// \param[in] _index Index of the desired geometry - /// \return The specified geometry - public: virtual GeometryPtr GeometryByIndex( - unsigned int _index) const = 0; - - /// \brief Add the given geometry to this visual. If the given node is - /// already attached, no work will be done. - /// \param[in] _geometry Geometry to be added - public: virtual void AddGeometry(GeometryPtr _geometry) = 0; - - /// \brief Remove the given geometry from this visual. If the given node - /// is not a child of this visual, no work will be done. - /// \param[in] _geometry Geometry to be removed - /// \return The removed geometry - public: virtual GeometryPtr RemoveGeometry(GeometryPtr _geometry) = 0; - - /// \brief Remove the geometry at the given index from this visual. If the - /// specified node is not attached this visual, no work will be done. - /// \param[in] _index Index of the geometry to be removed - /// \return The removed geometry - public: virtual GeometryPtr RemoveGeometryByIndex( - unsigned int _index) = 0; - - /// \brief Remove all attached geometries from this visual - public: virtual void RemoveGeometries() = 0; - - /// \brief Set the material for all attached visuals and geometries. The - /// specified material will be retrieved from Scene::Material using - /// the given material name. If no material is registered with the given - /// name, no work will be done. - /// \param[in] _name Name of the material to be assigned - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetMaterial(const std::string &_name, - bool _unique = true) = 0; - - /// \brief Set the material for all attached visuals and geometries - /// \param[in] _material Name of the material to be assigned - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true) = 0; - - /// \brief Set the material for all attached visuals only - /// \param[in] _material Name of the material to be assigned - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetChildMaterial(MaterialPtr _material, - bool _unique = true) = 0; - - /// \brief Set the material for all attached geometries only - /// \param[in] _material Name of the material to be assigned - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetGeometryMaterial(MaterialPtr _material, - bool _unique = true) = 0; - - /// \brief Get the material assigned to attached visuals and geometries. - /// \return the Pointer to the material assigned to this visual. If the - /// material is cloned at the time it is set to this visual, the cloned - /// material will be returned. - public: virtual MaterialPtr Material() const = 0; - - /// \brief Enable or disable wireframe - /// \param[in] _show True to enable wireframe - public: virtual void SetWireframe(bool _show) = 0; - - /// \brief Get whether wireframe is enabled for this visual. - /// \return True if wireframe is enabled for this visual. - public: virtual bool Wireframe() const = 0; - - /// \brief Specify if this visual is visible - /// \param[in] _visible True if this visual should be made visible - public: virtual void SetVisible(bool _visible) = 0; - - /// \brief Set visibility flags - /// \param[in] _flags Visibility flags - public: virtual void SetVisibilityFlags(uint32_t _flags) = 0; - - /// \brief Get visibility flags - /// \return visibility flags - public: virtual uint32_t VisibilityFlags() const = 0; - - /// \brief Add visibility flags - /// \param[in] _flags Visibility flags - public: virtual void AddVisibilityFlags(uint32_t _flags) = 0; - - /// \brief Remove visibility flags - /// \param[in] _flags Visibility flags - public: virtual void RemoveVisibilityFlags(uint32_t _flags) = 0; - - /// \brief Get the bounding box in world frame coordinates. - /// \return The axis aligned bounding box - public: virtual ignition::math::AxisAlignedBox BoundingBox() const = 0; - - /// \brief Get the local bounding box of the visual. - /// \return The local bounding box - public: virtual ignition::math::AxisAlignedBox LocalBoundingBox() - const = 0; - - /// \brief Clone the visual (and its children) with a new name. - /// \param[in] _name Name of the cloned Visual. Set this to an empty - /// string to auto-generate a unique name for the cloned visual. - /// \param[in] _newParent Parent of the cloned Visual. Set to nullptr if - /// the cloned visual should have no parent. - /// \return The visual. nullptr is returned if cloning failed. - public: virtual VisualPtr Clone(const std::string &_name, - NodePtr _newParent) const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/WireBox.hh b/include/ignition/rendering/WireBox.hh index f4c4ec459..e14aa7f96 100644 --- a/include/ignition/rendering/WireBox.hh +++ b/include/ignition/rendering/WireBox.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,41 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_WIREBOX_HH_ -#define IGNITION_RENDERING_WIREBOX_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/math/AxisAlignedBox.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class WireBox WireBox.hh ignition/rendering/WireBox - /// \brief Draws a wireframe box. - class IGNITION_RENDERING_VISIBLE WireBox : - public virtual Geometry - { - /// \brief Constructor - protected: WireBox(); - - /// \brief Destructor - public: virtual ~WireBox(); - - /// \brief Set the axis aligned box - /// \param[in] _box The axis aligned box - public: virtual void SetBox( - const ignition::math::AxisAlignedBox &_box) = 0; - - /// \brief Get the wireframe box. - /// \return The wireframe box. - public: virtual ignition::math::AxisAlignedBox Box() const = 0; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseArrowVisual.hh b/include/ignition/rendering/base/BaseArrowVisual.hh index 9ab10a202..0c5e64329 100644 --- a/include/ignition/rendering/base/BaseArrowVisual.hh +++ b/include/ignition/rendering/base/BaseArrowVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,202 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEARROWVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASEARROWVISUAL_HH_ -#include - -#include - -#include "ignition/rendering/ArrowVisual.hh" -#include "ignition/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseArrowVisual : - public virtual ArrowVisual, - public virtual T - { - /// \brief Constructor - protected: BaseArrowVisual(); - - /// \brief Destructor - public: virtual ~BaseArrowVisual(); - - // Documentation inherited. - protected: virtual void Destroy() override; - - // Documentation inherited. - public: virtual VisualPtr Head() const override; - - // Documentation inherited. - public: virtual VisualPtr Shaft() const override; - - // Documentation inherited. - public: virtual VisualPtr Rotation() const override; - - // Documentation inherited - public: virtual void ShowArrowHead(bool _b) override; - - // Documentation inherited - public: virtual void ShowArrowShaft(bool _b) override; - - // Documentation inherited - public: virtual void ShowArrowRotation(bool _b) override; - - // Documentation inherited - public: virtual void SetVisible(bool _visible) override; - - // Documentation inherited. - protected: virtual void Init() override; - - /// \brief Flag to indicate whether arrow rotation is visible - protected: bool rotationVisible = false; - }; - - ////////////////////////////////////////////////// - template - BaseArrowVisual::BaseArrowVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseArrowVisual::~BaseArrowVisual() - { - } - - ///////////////////////////////////////////////// - template - void BaseArrowVisual::Destroy() - { - while (this->ChildCount() > 0u) - { - auto visual = std::dynamic_pointer_cast(this->ChildByIndex(0)); - if (visual) - { - visual->Destroy(); - } - } - T::Destroy(); - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseArrowVisual::Head() const - { - return std::dynamic_pointer_cast(this->ChildByIndex(2)); - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseArrowVisual::Shaft() const - { - return std::dynamic_pointer_cast(this->ChildByIndex(1)); - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseArrowVisual::Rotation() const - { - return std::dynamic_pointer_cast(this->ChildByIndex(0)); - } - - ////////////////////////////////////////////////// - template - void BaseArrowVisual::ShowArrowHead(bool _b) - { - NodePtr child = this->ChildByIndex(2); - VisualPtr visual = std::dynamic_pointer_cast(child); - if (visual) - { - visual->SetVisible(_b); - } - } - - ////////////////////////////////////////////////// - template - void BaseArrowVisual::ShowArrowShaft(bool _b) - { - NodePtr child = this->ChildByIndex(1); - VisualPtr visual = std::dynamic_pointer_cast(child); - if (visual) - { - visual->SetVisible(_b); - } - } - - ////////////////////////////////////////////////// - template - void BaseArrowVisual::ShowArrowRotation(bool _b) - { - NodePtr child = this->ChildByIndex(0); - VisualPtr visual = std::dynamic_pointer_cast(child); - if (visual) - { - visual->SetVisible(_b); - this->rotationVisible = _b; - } - } - - ////////////////////////////////////////////////// - template - void BaseArrowVisual::SetVisible(bool _visible) - { - T::SetVisible(_visible); - - NodePtr child = this->ChildByIndex(0); - VisualPtr visual = std::dynamic_pointer_cast(child); - if (visual) - { - // Force rotation visual visibility to false - // if the arrow visual is not visible. - // Else, rotation visual's visibility overrides - // its parent's visibility. - visual->SetVisible(this->rotationVisible && _visible); - } - } - - ////////////////////////////////////////////////// - template - void BaseArrowVisual::Init() - { - T::Init(); - - VisualPtr cone = this->Scene()->CreateVisual(); - cone->AddGeometry(this->Scene()->CreateCone()); - cone->SetOrigin(0, 0, -0.5); - cone->SetLocalPosition(0, 0, 0); - cone->SetLocalScale(0.1, 0.1, 0.25); - this->AddChild(cone); - - VisualPtr cylinder = this->Scene()->CreateVisual(); - cylinder->AddGeometry(this->Scene()->CreateCylinder()); - cylinder->SetOrigin(0, 0, 0.5); - cylinder->SetLocalPosition(0, 0, 0); - cylinder->SetLocalScale(0.05, 0.05, 0.5); - this->AddChild(cylinder); - - common::MeshManager *meshMgr = common::MeshManager::Instance(); - std::string rotMeshName = "arrow_rotation"; - if (!meshMgr->HasMesh(rotMeshName)) - meshMgr->CreateTube(rotMeshName, 0.070f, 0.075f, 0.01f, 1, 32); - - VisualPtr rotationVis = this->Scene()->CreateVisual(); - rotationVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); - rotationVis->SetOrigin(0, 0, -0.125); - rotationVis->SetLocalPosition(0, 0, 0); - rotationVis->SetVisible(this->rotationVisible); - this->AddChild(rotationVis); - - this->SetOrigin(0, 0, -0.5); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseAxisVisual.hh b/include/ignition/rendering/base/BaseAxisVisual.hh index e803068f4..706e8b0c2 100644 --- a/include/ignition/rendering/base/BaseAxisVisual.hh +++ b/include/ignition/rendering/base/BaseAxisVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,165 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEAXISVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASEAXISVISUAL_HH_ -#include "ignition/rendering/AxisVisual.hh" -#include "ignition/rendering/ArrowVisual.hh" -#include "ignition/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseAxisVisual : - public virtual AxisVisual, - public virtual T - { - protected: BaseAxisVisual(); - - public: virtual ~BaseAxisVisual(); - - public: virtual void Init() override; - - // Documentation inherited. - protected: virtual void Destroy() override; - - // Documentation inherited. - public: virtual void SetLocalScale( - const math::Vector3d &_scale) override; - - // Documentation inherited. - public: virtual math::Vector3d LocalScale() const override; - - // Documentation inherited. - public: void ShowAxisHead(bool _b) override; - - // Documentation inherited. - public: void ShowAxisHead(unsigned int _axis, bool _b) override; - - // Documentation inherited. - public: virtual void SetVisible(bool _visible) override; - }; - - ////////////////////////////////////////////////// - template - BaseAxisVisual::BaseAxisVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseAxisVisual::~BaseAxisVisual() - { - } - - ///////////////////////////////////////////////// - template - void BaseAxisVisual::Destroy() - { - for (unsigned int i = 0; i < this->ChildCount(); ++i) - { - auto arrow = std::dynamic_pointer_cast( - this->ChildByIndex(i)); - if (arrow) - { - arrow->Destroy(); - } - } - T::Destroy(); - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseAxisVisual::LocalScale() const - { - if (this->ChildCount() > 0) { - return this->ChildByIndex(0)->LocalScale(); - } - return math::Vector3d::Zero; - } - - ////////////////////////////////////////////////// - template - void BaseAxisVisual::SetLocalScale(const math::Vector3d &_scale) - { - for (unsigned int i = 0; i < this->ChildCount(); ++i) - this->ChildByIndex(i)->SetLocalScale(_scale.X(), - _scale.Y(), - _scale.Z()); - } - - ////////////////////////////////////////////////// - template - void BaseAxisVisual::ShowAxisHead(bool _b) - { - for (unsigned int i = 0; i < this->ChildCount(); ++i) - { - auto arrow = std::dynamic_pointer_cast( - this->ChildByIndex(i)); - if (arrow) - { - arrow->ShowArrowHead(_b); - } - } - } - - ////////////////////////////////////////////////// - template - void BaseAxisVisual::ShowAxisHead(unsigned int _axis, bool _b) - { - auto arrow = std::dynamic_pointer_cast( - this->ChildByIndex(2u - _axis)); - if (arrow) - { - arrow->ShowArrowHead(_b); - } - } - - ////////////////////////////////////////////////// - template - void BaseAxisVisual::Init() - { - T::Init(); - - ArrowVisualPtr xArrow = this->Scene()->CreateArrowVisual(); - xArrow->SetLocalPosition(0, 0, 0); - xArrow->SetLocalRotation(0, IGN_PI / 2, 0); - xArrow->SetMaterial("Default/TransRed"); - this->AddChild(xArrow); - - ArrowVisualPtr yArrow = this->Scene()->CreateArrowVisual(); - yArrow->SetLocalPosition(0, 0, 0); - yArrow->SetLocalRotation(-IGN_PI / 2, 0, 0); - yArrow->SetMaterial("Default/TransGreen"); - this->AddChild(yArrow); - - ArrowVisualPtr zArrow = this->Scene()->CreateArrowVisual(); - zArrow->SetLocalPosition(0, 0, 0); - zArrow->SetLocalRotation(0, 0, 0); - zArrow->SetMaterial("Default/TransBlue"); - this->AddChild(zArrow); - } - - ////////////////////////////////////////////////// - template - void BaseAxisVisual::SetVisible(bool _visible) - { - T::SetVisible(_visible); - - for (unsigned int i = 0; i < this->ChildCount(); ++i) - { - auto arrow = std::dynamic_pointer_cast( - this->ChildByIndex(i)); - if (arrow != nullptr) - arrow->SetVisible(_visible); - } - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseBoundingBoxCamera.hh b/include/ignition/rendering/base/BaseBoundingBoxCamera.hh index 3fcf6f69b..9b278b470 100644 --- a/include/ignition/rendering/base/BaseBoundingBoxCamera.hh +++ b/include/ignition/rendering/base/BaseBoundingBoxCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,93 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEBOUNDINGBOXCAMERA_HH_ -#define IGNITION_RENDERING_BASE_BASEBOUNDINGBOXCAMERA_HH_ -#include - -#include -#include - -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/BoundingBoxCamera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - template - class BaseBoundingBoxCamera: - public virtual BoundingBoxCamera, - public virtual BaseCamera, - public virtual T - { - /// \brief Constructor - protected: BaseBoundingBoxCamera(); - - /// \brief Destructor - public: virtual ~BaseBoundingBoxCamera(); - - // Documentation inherited - public: virtual const std::vector &BoundingBoxData() const; - - // Documentation inherited - public: virtual ignition::common::ConnectionPtr ConnectNewBoundingBoxes( - std::function &)> _subscriber) = 0; - - // Documentation inherited - public: virtual void SetBoundingBoxType(BoundingBoxType _type); - - // Documentation inherited - public: virtual BoundingBoxType Type() const; - - // Documentation inherited - public: virtual void DrawBoundingBox(unsigned char *_data, - const math::Color &_color, const BoundingBox &_box) const = 0; - - /// \brief The bounding box type - protected: BoundingBoxType type = BoundingBoxType::BBT_FULLBOX2D; - - /// \brief The bounding box data - protected: std::vector boundingBoxes; - }; - - ////////////////////////////////////////////////// - template - BaseBoundingBoxCamera::BaseBoundingBoxCamera() - { - } - - ////////////////////////////////////////////////// - template - BaseBoundingBoxCamera::~BaseBoundingBoxCamera() - { - } - - ////////////////////////////////////////////////// - template - const std::vector & - BaseBoundingBoxCamera::BoundingBoxData() const - { - return this->boundingBoxes; - } - - ////////////////////////////////////////////////// - template - void BaseBoundingBoxCamera::SetBoundingBoxType(BoundingBoxType _type) - { - this->type = _type; - } - - ////////////////////////////////////////////////// - template - BoundingBoxType BaseBoundingBoxCamera::Type() const - { - return this->type; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseCOMVisual.hh b/include/ignition/rendering/base/BaseCOMVisual.hh index 29059091d..789943b49 100644 --- a/include/ignition/rendering/base/BaseCOMVisual.hh +++ b/include/ignition/rendering/base/BaseCOMVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,170 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASECOMVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASECOMVISUAL_HH_ -#include - -#include "ignition/common/Console.hh" - -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/COMVisual.hh" -#include "ignition/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of an center of mass visual - template - class BaseCOMVisual : - public virtual COMVisual, - public virtual T - { - /// \brief Constructor - protected: BaseCOMVisual(); - - /// \brief Destructor - public: virtual ~BaseCOMVisual(); - - // Documentation inherited. - protected: virtual void Init() override; - - // Documentation inherited. - protected: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void SetInertial( - const ignition::math::Inertiald &_inertial) override; - - // Documentation inherited. - public: virtual void SetMass(double _mass) override; - - // Documentation inherited - public: virtual double Mass() const override; - - // Documentation inherited - public: virtual ignition::math::Pose3d InertiaPose() const override; - - // Documentation inherited - public: virtual VisualPtr SphereVisual() const override; - - /// \brief Get the radius of the CoM sphere - /// \return Radius of the CoM sphere - protected: double SphereRadius() const; - - /// \brief Parent visual name. - protected: std::string parentName = ""; - - /// \brief Parent mass. - protected: double mass = 1.0; - - /// \brief Inertia pose in parent frame. - protected: ignition::math::Pose3d inertiaPose = - ignition::math::Pose3d::Zero; - - /// \brief Flag to indicate parent properties have changed. - protected: bool dirtyCOMVisual = false; - }; - - ////////////////////////////////////////////////// - template - BaseCOMVisual::BaseCOMVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseCOMVisual::~BaseCOMVisual() - { - } - - ///////////////////////////////////////////////// - template - void BaseCOMVisual::PreRender() - { - T::PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseCOMVisual::Init() - { - T::Init(); - } - - ////////////////////////////////////////////////// - template - void BaseCOMVisual::SetInertial( - const ignition::math::Inertiald &_inertial) - { - this->inertiaPose = _inertial.Pose(); - - this->SetMass(_inertial.MassMatrix().Mass()); - } - - template - void BaseCOMVisual::SetMass(double _mass) - { - if (_mass <= 0) - { - // Unrealistic mass, load with default mass - if (_mass < 0) - { - ignlog << "The parent " << this->parentName - << " has unrealistic mass, " - << "unable to visualize sphere of equivalent mass.\n"; - } - else - { - ignlog << "The parent " << this->parentName - << " is static or has mass of 0, " - << "so a sphere of equivalent mass will not be shown.\n"; - } - return; - } - - this->mass = _mass; - this->dirtyCOMVisual = true; - } - - ////////////////////////////////////////////////// - template - double BaseCOMVisual::Mass() const - { - return this->mass; - } - - ////////////////////////////////////////////////// - template - ignition::math::Pose3d BaseCOMVisual::InertiaPose() const - { - return this->inertiaPose; - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseCOMVisual::SphereVisual() const - { - return nullptr; - } - - ////////////////////////////////////////////////// - template - double BaseCOMVisual::SphereRadius() const - { - // Compute radius of sphere with density of lead and equivalent mass. - double sphereRadius; - double densityLead = 11340; - sphereRadius = cbrt((0.75 * this->Mass()) / (IGN_PI * densityLead)); - - return sphereRadius; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseCamera.hh b/include/ignition/rendering/base/BaseCamera.hh index 28e797235..75d1fe0b6 100644 --- a/include/ignition/rendering/base/BaseCamera.hh +++ b/include/ignition/rendering/base/BaseCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,835 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASECAMERA_HH_ -#define IGNITION_RENDERING_BASE_BASECAMERA_HH_ -#include - -#include -#include - -#include -#include -#include - -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/base/BaseRenderTarget.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - template - class BaseDepthCamera; - - template - class BaseCamera : - public virtual Camera, - public virtual T - { - protected: BaseCamera(); - - public: virtual ~BaseCamera(); - - public: virtual unsigned int ImageWidth() const override; - - public: virtual void SetImageWidth(const unsigned int _width) override; - - public: virtual unsigned int ImageHeight() const override; - - public: virtual void SetImageHeight(const unsigned int _height) override; - - public: virtual PixelFormat ImageFormat() const override; - - public: virtual unsigned int ImageMemorySize() const override; - - public: virtual void SetImageFormat(PixelFormat _format) override; - - public: virtual math::Angle HFOV() const override; - - public: virtual void SetHFOV(const math::Angle &_hfov) override; - - public: virtual double AspectRatio() const override; - - public: virtual void SetAspectRatio(const double _ratio) override; - - public: virtual unsigned int AntiAliasing() const override; - - public: virtual void SetAntiAliasing(const unsigned int _aa) override; - - public: virtual double FarClipPlane() const override; - - public: virtual void SetFarClipPlane(const double _far) override; - - public: virtual double NearClipPlane() const override; - - public: virtual void SetNearClipPlane(const double _near) override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - public: virtual void Update() override; - - public: virtual Image CreateImage() const override; - - public: virtual void Capture(Image &_image) override; - - public: virtual void Copy(Image &_image) const override; - - public: virtual bool SaveFrame(const std::string &_name) override; - - public: virtual common::ConnectionPtr ConnectNewImageFrame( - Camera::NewFrameListener _listener) override; - - public: virtual RenderWindowPtr CreateRenderWindow() override; - - // Documentation inherited. - public: virtual VisualPtr VisualAt(const ignition::math::Vector2i - &_mousePos) override; - - // Documentation inherited. - public: virtual math::Matrix4d ProjectionMatrix() const override; - - // Documentation inherited. - public: virtual math::Matrix4d ViewMatrix() const override; - - // Documentation inherited. - public: virtual void SetProjectionMatrix(const math::Matrix4d &_matrix) - override; - - // Documentation inherited. - public: virtual CameraProjectionType ProjectionType() const override; - - // Documentation inherited. - public: virtual void SetProjectionType( - CameraProjectionType _type) override; - - // Documentation inherited. - public: virtual math::Vector2i Project(const math::Vector3d &_pt) const - override; - - // Documentation inherited. - // \sa Camera::SetMaterial(const MaterialPtr &) override; - public: virtual void SetMaterial(const MaterialPtr &_material) - override; - - // Documentation inherited. - public: virtual void SetTrackTarget(const NodePtr &_target, - const math::Vector3d &_offset, - const bool _worldFrame) override; - - // Documentation inherited. - public: virtual NodePtr TrackTarget() const override; - - // Documentation inherited. - public: virtual void SetTrackOffset(const math::Vector3d &_offset) - override; - - // Documentation inherited. - public: virtual math::Vector3d TrackOffset() const override; - - // Documentation inherited. - public: virtual void SetTrackPGain(const double _pGain) override; - - // Documentation inherited. - public: virtual double TrackPGain() const override; - - // Documentation inherited. - public: virtual void SetFollowTarget(const NodePtr &_target, - const math::Vector3d &_Offset, const bool _worldFrame) - override; - - // Documentation inherited. - public: virtual NodePtr FollowTarget() const override; - - // Documentation inherited. - public: virtual void SetFollowOffset(const math::Vector3d &_offset) - override; - - // Documentation inherited. - public: virtual math::Vector3d FollowOffset() const override; - - // Documentation inherited. - public: virtual void SetFollowPGain(const double _pGain) override; - - // Documentation inherited. - public: virtual double FollowPGain() const override; - - // Documentation inherited. - public: virtual unsigned int RenderTextureGLId() const override; - - // Documentation inherited. - public: virtual void AddRenderPass(const RenderPassPtr &_pass) override; - - // Documentation inherited. - public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) - override; - - // Documentation inherited. - public: virtual unsigned int RenderPassCount() const override; - - // Documentation inherited. - public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) - const override; - - // Documentation inherited. - public: virtual void SetShadowsDirty() override; - - protected: virtual void *CreateImageBuffer() const; - - protected: virtual void Load() override; - - protected: virtual void Reset(); - - protected: virtual RenderTargetPtr RenderTarget() const = 0; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: common::EventT newFrameEvent; - - protected: ImagePtr imageBuffer; - - /// \brief Near clipping plane distance - protected: double nearClip = 0.01; - - /// \brief Far clipping plane distance - protected: double farClip = 1000.0; - - /// \brief Aspect ratio - protected: double aspect = 1.3333333; - - /// \brief Horizontal camera field of view - protected: math::Angle hfov; - - /// \brief Anti-aliasing - protected: unsigned int antiAliasing = 0u; - - /// \brief Target node to track if camera tracking is on. - protected: NodePtr trackNode; - - /// \brief Track point relative to target in world frame. - protected: bool trackWorldFrame = false; - - /// \brief Set camera to track a point offset in target node's local or - /// world frame depending on trackWorldFrame. - protected: math::Vector3d trackOffset; - - /// \brief P gain for tracking. Determines how fast the camera rotates - /// to look at the target node. Valid range: [0-1] - protected: double trackPGain = 1.0; - - /// \brief Target node to follow - protected: NodePtr followNode; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Follow target in world frame. - protected: bool followWorldFrame = false; - - /// \brief P gain for follow mode. Determines how fast the camera moves - /// to follow the target node. Valid range: [0-1] - protected: double followPGain = 1.0; - - /// \brief Offset distance between camera and target node being followed - protected: math::Vector3d followOffset; - - /// \brief Custom projection matrix - protected: math::Matrix4d projectionMatrix; - - /// \brief Camera projection type - protected: CameraProjectionType projectionType = CPT_PERSPECTIVE; - - friend class BaseDepthCamera; - }; - - ////////////////////////////////////////////////// - template - BaseCamera::BaseCamera() - { - } - - ////////////////////////////////////////////////// - template - BaseCamera::~BaseCamera() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCamera::ImageWidth() const - { - return this->RenderTarget()->Width(); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetImageWidth(const unsigned int _width) - { - this->RenderTarget()->SetWidth(_width); - this->SetAspectRatio( - static_cast(_width) / static_cast(this->ImageHeight())); - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCamera::ImageHeight() const - { - return this->RenderTarget()->Height(); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetImageHeight(const unsigned int _height) - { - this->RenderTarget()->SetHeight(_height); - this->SetAspectRatio( - static_cast(this->ImageWidth()) / static_cast(_height)); - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCamera::ImageMemorySize() const - { - PixelFormat format = this->ImageFormat(); - unsigned int width = this->ImageWidth(); - unsigned int height = this->ImageHeight(); - return PixelUtil::MemorySize(format, width, height); - } - - ////////////////////////////////////////////////// - template - PixelFormat BaseCamera::ImageFormat() const - { - return this->RenderTarget()->Format(); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetImageFormat(PixelFormat _format) - { - this->RenderTarget()->SetFormat(_format); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::PreRender() - { - T::PreRender(); - - this->RenderTarget()->PreRender(); - - // camera following - if (this->followNode) - { - // tether camera fixed in world frame - if (this->followWorldFrame) - { - math::Vector3d targetCamPos = - this->followNode->WorldPosition() + this->followOffset; - math::Vector3d pos = this->WorldPosition() + - (targetCamPos - this->WorldPosition()) * this->followPGain; - this->SetWorldPosition(pos); - } - // tether camera fixed in target's local frame - else - { - math::Pose3d targetCamPose = math::Pose3d(this->followOffset, - this->WorldRotation()); - targetCamPose = this->followNode->WorldPose() * targetCamPose; - - math::Vector3d pos = this->WorldPosition() + - (targetCamPose.Pos() - this->WorldPosition()) * this->followPGain; - this->SetWorldPosition(pos); - } - } - - // camera tracking - if (this->trackNode) - { - math::Vector3d eye = this->WorldPosition(); - math::Pose3d targetPose = math::Pose3d(this->trackOffset, - math::Quaterniond::Identity); - if (this->trackWorldFrame) - { - targetPose.Pos() += this->trackNode->WorldPosition(); - } - else - { - targetPose = this->trackNode->WorldPose() * targetPose; - } - - math::Pose3d p = - math::Matrix4d::LookAt(eye, targetPose.Pos()).Pose(); - - math::Quaterniond q = p.Rot(); - // skip slerp if we don't need it - if (!math::equal(this->trackPGain, 1.0)) - { - q = math::Quaterniond::Slerp( - this->trackPGain, this->WorldRotation(), p.Rot(), true); - } - this->SetWorldRotation(q); - } - } - - ////////////////////////////////////////////////// - template - void BaseCamera::PostRender() - { - this->RenderTarget()->PostRender(); - } - - ////////////////////////////////////////////////// - template - Image BaseCamera::CreateImage() const - { - PixelFormat format = this->ImageFormat(); - unsigned int width = this->ImageWidth(); - unsigned int height = this->ImageHeight(); - return Image(width, height, format); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::Update() - { - this->Scene()->PreRender(); - this->Render(); - this->PostRender(); - if (!this->Scene()->LegacyAutoGpuFlush()) - { - this->Scene()->PostRender(); - } - } - - ////////////////////////////////////////////////// - template - void BaseCamera::Capture(Image &_image) - { - this->Update(); - this->Copy(_image); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::Copy(Image &_image) const - { - this->RenderTarget()->Copy(_image); - } - - ////////////////////////////////////////////////// - template - bool BaseCamera::SaveFrame(const std::string &/*_name*/) - { - return false; - } - - ////////////////////////////////////////////////// - template - common::ConnectionPtr BaseCamera::ConnectNewImageFrame( - Camera::NewFrameListener _listener) - { - return newFrameEvent.Connect(_listener); - } - - ////////////////////////////////////////////////// - template - void *BaseCamera::CreateImageBuffer() const - { - // TODO(anyone): determine proper type - unsigned int size = this->ImageMemorySize(); - return new unsigned char *[size]; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::Load() - { - T::Load(); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::Reset() - { - math::Angle fov; - fov.Degree(60); - this->SetImageWidth(1); - this->SetImageHeight(1); - this->SetImageFormat(PF_R8G8B8); - this->SetAspectRatio(1.33333); - this->SetAntiAliasing(0u); - this->SetHFOV(fov); - this->SetNearClipPlane(0.01); - this->SetFarClipPlane(1000); - } - - ////////////////////////////////////////////////// - template - RenderWindowPtr BaseCamera::CreateRenderWindow() - { - // Does nothing by default - ignerr << "Render window not supported for render engine: " << - this->Scene()->Engine()->Name() << std::endl; - return RenderWindowPtr(); - } - - ////////////////////////////////////////////////// - template - math::Matrix4d BaseCamera::ProjectionMatrix() const - { - math::Matrix4d result = this->projectionMatrix; - if (this->projectionType == CPT_PERSPECTIVE) - { - double ratio = this->AspectRatio(); - double fov = this->HFOV().Radian(); - double vfov = 2.0 * std::atan(std::tan(fov / 2.0) / ratio); - double f = 1.0; - double _near = this->NearClipPlane(); - double _far = this->FarClipPlane(); - double top = _near * std::tan(0.5*vfov) / f; - double height = 2 * top; - double width = ratio * height; - double left = -0.5 * width; - double right = left + width; - double bottom = top - height; - - double invw = 1.0 / (right - left); - double invh = 1.0 / (top - bottom); - double invd = 1.0 / (_far - _near); - double x = 2 * _near * invw; - double y = 2 * _near * invh; - double a = (right + left) * invw; - double b = (top + bottom) * invh; - double c = -(_far + _near) * invd; - double d = -2 * _far * _near * invd; - result(0, 0) = x; - result(0, 2) = a; - result(1, 1) = y; - result(1, 2) = b; - result(2, 2) = c; - result(2, 3) = d; - result(3, 2) = -1; - } - else if (this->projectionType == CPT_ORTHOGRAPHIC) - { - double width = this->ImageWidth(); - double height = this->ImageHeight(); - double left = -width * 0.5; - double right = -left; - double top = height * 0.5; - double bottom = -top; - double _near = this->NearClipPlane(); - double _far = this->FarClipPlane(); - - double invw = 1.0 / (right - left); - double invh = 1.0 / (top - bottom); - double invd = 1.0 / (_far - _near); - - result(0, 0) = 2.0 * invw; - result(0, 3) = -(right + left) * invw; - result(1, 1) = 2.0 * invh; - result(1, 3) = -(top + bottom) * invh; - result(2, 2) = -2.0 * invd; - result(2, 3) = -(_far + _near) * invd; - result(3, 3) = 1.0; - } - else - { - ignerr << "Unknown camera projection type: " << this->projectionType - << std::endl; - } - - return result; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetProjectionMatrix(const math::Matrix4d &_matrix) - { - this->projectionMatrix = _matrix; - } - - ////////////////////////////////////////////////// - template - math::Matrix4d BaseCamera::ViewMatrix() const - { - math::Matrix3d r(this->WorldPose().Rot()); - // transform from y up to z up - math::Matrix3d tf(0, 0, -1, - -1, 0, 0, - 0, 1, 0); - r = r * tf; - r.Transpose(); - math::Vector3d t = r * this->WorldPose().Pos() * -1; - math::Matrix4d result; - result = r; - result.SetTranslation(t); - result(3, 3) = 1.0; - return result; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetProjectionType(CameraProjectionType _type) - { - this->projectionType = _type; - } - - ////////////////////////////////////////////////// - template - CameraProjectionType BaseCamera::ProjectionType() const - { - return this->projectionType; - } - - ////////////////////////////////////////////////// - template - math::Vector2i BaseCamera::Project(const math::Vector3d &_pt) const - { - math::Vector2i screenPos; - math::Matrix4d m = this->ProjectionMatrix() * this->ViewMatrix(); - math::Vector3d pos = m * _pt; - double w = m(3, 0) * _pt.X() + m(3, 1) * _pt.Y() + m(3, 2) * _pt.Z() - + m(3, 3); - pos.X() = pos.X() / w; - pos.Y() = pos.Y() / w; - - screenPos.X() = static_cast( - ((pos.X() / 2.0) + 0.5) * this->ImageWidth()); - screenPos.Y() = static_cast( - (1 - ((pos.Y() / 2.0) + 0.5)) * this->ImageHeight()); - return screenPos; - } - - ////////////////////////////////////////////////// - template - math::Angle BaseCamera::HFOV() const - { - return this->hfov; - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseCamera::VisualAt(const ignition::math::Vector2i - &/*_mousePos*/) - { - ignerr << "VisualAt not implemented for the render engine" << std::endl; - return VisualPtr(); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetHFOV(const math::Angle &_hfov) - { - this->hfov = _hfov; - } - - ////////////////////////////////////////////////// - template - double BaseCamera::AspectRatio() const - { - return this->aspect; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetAspectRatio(const double _aspect) - { - this->aspect = _aspect; - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCamera::AntiAliasing() const - { - return this->antiAliasing; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetAntiAliasing(const unsigned int _aa) - { - this->antiAliasing = _aa; - } - - ////////////////////////////////////////////////// - template - double BaseCamera::FarClipPlane() const - { - return this->farClip; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetFarClipPlane(const double _far) - { - this->farClip = _far; - } - - ////////////////////////////////////////////////// - template - double BaseCamera::NearClipPlane() const - { - return this->nearClip; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetNearClipPlane(const double _near) - { - this->nearClip = _near; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetTrackTarget(const NodePtr &_target, - const math::Vector3d &_offset, const bool _worldFrame) - { - this->trackNode = _target; - this->trackWorldFrame = _worldFrame; - this->trackOffset = _offset; - } - - ////////////////////////////////////////////////// - template - NodePtr BaseCamera::TrackTarget() const - { - return this->trackNode; - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseCamera::TrackOffset() const - { - return this->trackOffset; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetTrackOffset(const math::Vector3d &_offset) - { - this->trackOffset = _offset; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetTrackPGain(const double _pGain) - { - this->trackPGain = math::clamp(_pGain, 0.0, 1.0); - } - - ////////////////////////////////////////////////// - template - double BaseCamera::TrackPGain() const - { - return this->trackPGain; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetFollowTarget(const NodePtr &_target, - const math::Vector3d &_offset, const bool _worldFrame) - { - this->followNode = _target; - this->followWorldFrame = _worldFrame; - this->followOffset = _offset; - } - - ////////////////////////////////////////////////// - template - NodePtr BaseCamera::FollowTarget() const - { - return this->followNode; - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseCamera::FollowOffset() const - { - return this->followOffset; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetFollowOffset(const math::Vector3d &_offset) - { - this->followOffset = _offset; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetFollowPGain(const double _pGain) - { - this->followPGain = math::clamp(_pGain, 0.0, 1.0); - } - - ////////////////////////////////////////////////// - template - double BaseCamera::FollowPGain() const - { - return this->followPGain; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetMaterial(const MaterialPtr &/*_material*/) - { - ignerr << "SetMaterial not implemented for current render" - << " engine" << std::endl; - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCamera::RenderTextureGLId() const - { - ignerr << "RenderTextureGLId is not supported by current render" - << " engine" << std::endl; - return 0u; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::AddRenderPass(const RenderPassPtr &_pass) - { - this->RenderTarget()->AddRenderPass(_pass); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::RemoveRenderPass(const RenderPassPtr &_pass) - { - this->RenderTarget()->RemoveRenderPass(_pass); - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCamera::RenderPassCount() const - { - return this->RenderTarget()->RenderPassCount(); - } - - ////////////////////////////////////////////////// - template - RenderPassPtr BaseCamera::RenderPassByIndex(unsigned int _index) const - { - return this->RenderTarget()->RenderPassByIndex(_index); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetShadowsDirty() - { - // no op - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseCapsule.hh b/include/ignition/rendering/base/BaseCapsule.hh index 653be69b5..d4931d4ef 100644 --- a/include/ignition/rendering/base/BaseCapsule.hh +++ b/include/ignition/rendering/base/BaseCapsule.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,127 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_BASECAPSULE_HH_ -#define IGNITION_RENDERING_BASECAPSULE_HH_ - -#include - -#include "ignition/rendering/Capsule.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/base/BaseObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \brief Base implementation of a Capsule Geometry - template - class BaseCapsule : - public virtual Capsule, - public virtual T - { - // Documentation inherited - protected: BaseCapsule(); - - // Documentation inherited - public: virtual ~BaseCapsule(); - - // Documentation inherited - public: virtual void SetRadius(double _radius) override; - - // Documentation inherited - public: virtual void SetLength(double _length) override; - - // Documentation inherited - public: virtual double Radius() const override; - - // Documentation inherited - public: virtual double Length() const override; - - // Documentation inherited - public: virtual GeometryPtr Clone() const override; - - /// \brief Radius of the capsule - protected: double radius = 0.5; - - /// \brief Length of the capsule - protected: double length = 0.5; - - /// \brief Flag to indicate capsule properties have changed - protected: bool capsuleDirty = false; - }; - - ///////////////////////////////////////////////// - // BaseCapsule - ///////////////////////////////////////////////// - template - BaseCapsule::BaseCapsule() - { - } - - ///////////////////////////////////////////////// - template - BaseCapsule::~BaseCapsule() - { - } - - ///////////////////////////////////////////////// - template - void BaseCapsule::SetRadius(double _radius) - { - this->radius = _radius; - this->capsuleDirty = true; - } - - ///////////////////////////////////////////////// - template - double BaseCapsule::Radius() const - { - return this->radius; - } - - ///////////////////////////////////////////////// - template - void BaseCapsule::SetLength(double _length) - { - this->length = _length; - this->capsuleDirty = true; - } - - ///////////////////////////////////////////////// - template - double BaseCapsule::Length() const - { - return this->length; - } - - ///////////////////////////////////////////////// - template - GeometryPtr BaseCapsule::Clone() const - { - if (!this->Scene()) - { - ignerr << "Cloning a Capsule failed because the capsule to be " - << "cloned does not belong to a scene.\n"; - return nullptr; - } - - auto result = this->Scene()->CreateCapsule(); - if (result) - { - result->SetRadius(this->Radius()); - result->SetLength(this->Length()); - - if (this->Material()) - result->SetMaterial(this->Material()); - } - - return result; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseDepthCamera.hh b/include/ignition/rendering/base/BaseDepthCamera.hh index 1372ac69e..dc4993072 100644 --- a/include/ignition/rendering/base/BaseDepthCamera.hh +++ b/include/ignition/rendering/base/BaseDepthCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,87 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEDEPTHCAMERA_HH_ -#define IGNITION_RENDERING_BASE_BASEDEPTHCAMERA_HH_ -#include - -#include - -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/DepthCamera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - template - class BaseDepthCamera : - public virtual DepthCamera, - public virtual BaseCamera, - public virtual T - { - protected: BaseDepthCamera(); - - public: virtual ~BaseDepthCamera(); - - public: virtual void CreateDepthTexture(); - - public: virtual const float *DepthData() const; - - public: virtual ignition::common::ConnectionPtr ConnectNewDepthFrame( - std::function _subscriber); - - public: virtual ignition::common::ConnectionPtr ConnectNewRGBPointCloud( - std::function _subscriber); - }; - - ////////////////////////////////////////////////// - template - BaseDepthCamera::BaseDepthCamera() - { - } - - ////////////////////////////////////////////////// - template - BaseDepthCamera::~BaseDepthCamera() - { - } - - ////////////////////////////////////////////////// - template - void BaseDepthCamera::CreateDepthTexture() - { - } - - ////////////////////////////////////////////////// - template - const float *BaseDepthCamera::DepthData() const - { - return nullptr; - } - - ////////////////////////////////////////////////// - template - ignition::common::ConnectionPtr BaseDepthCamera::ConnectNewDepthFrame( - std::function) - { - return nullptr; - } - - ////////////////////////////////////////////////// - template - ignition::common::ConnectionPtr BaseDepthCamera::ConnectNewRGBPointCloud( - std::function) - { - return nullptr; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseDistortionPass.hh b/include/ignition/rendering/base/BaseDistortionPass.hh index 843139e08..67cc23cfa 100644 --- a/include/ignition/rendering/base/BaseDistortionPass.hh +++ b/include/ignition/rendering/base/BaseDistortionPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,185 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASEDISTORTIONPASS_HH_ -#define IGNITION_RENDERING_BASEDISTORTIONPASS_HH_ -#include "ignition/rendering/DistortionPass.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class BaseDistortionPass BaseDistortionPass.hh \ - * ignition/rendering/base/BaseDistortionPass.hh - */ - /// \brief Base distortion render pass - template - class BaseDistortionPass : - public virtual DistortionPass, - public virtual T - { - /// \brief Constructor - protected: BaseDistortionPass(); - - /// \brief Destructor - public: virtual ~BaseDistortionPass(); - - // Documentation inherited. - public: double K1() const; - - // Documentation inherited. - public: double K2() const; - - // Documentation inherited. - public: double K3() const; - - // Documentation inherited. - public: double P1() const; - - // Documentation inherited. - public: double P2() const; - - // Documentation inherited. - public: math::Vector2d Center() const; - - // Documentation inherited. - public: void SetK1(double _k1); - - // Documentation inherited. - public: void SetK2(double _k2); - - // Documentation inherited. - public: void SetK3(double _k3); - - // Documentation inherited. - public: void SetP1(double _p1); - - // Documentation inherited. - public: void SetP2(double _p2); - - // Documentation inherited. - public: void SetCenter(const math::Vector2d &_center); - - /// \brief Radial distortion coefficient k1. - public: double k1 = 0; - - /// \brief Radial distortion coefficient k2. - public: double k2 = 0; - - /// \brief Radial distortion coefficient k3. - public: double k3 = 0; - - /// \brief Tangential distortion coefficient p1. - public: double p1 = 0; - - /// \brief Tangential distortion coefficient p2. - public: double p2 = 0; - - /// \brief Lens center used for distortion - public: math::Vector2d lensCenter = {0.5, 0.5}; - }; - - ////////////////////////////////////////////////// - // BaseDistortionPass - ////////////////////////////////////////////////// - template - BaseDistortionPass::BaseDistortionPass() - { - } - - ////////////////////////////////////////////////// - template - BaseDistortionPass::~BaseDistortionPass() - { - } - - ////////////////////////////////////////////////// - template - double BaseDistortionPass::K1() const - { - return this->k1; - } - - ////////////////////////////////////////////////// - template - double BaseDistortionPass::K2() const - { - return this->k2; - } - - ////////////////////////////////////////////////// - template - double BaseDistortionPass::K3() const - { - return this->k3; - } - - ////////////////////////////////////////////////// - template - double BaseDistortionPass::P1() const - { - return this->p1; - } - - ////////////////////////////////////////////////// - template - double BaseDistortionPass::P2() const - { - return this->p2; - } - - ////////////////////////////////////////////////// - template - math::Vector2d BaseDistortionPass::Center() const - { - return this->lensCenter; - } - - ////////////////////////////////////////////////// - template - void BaseDistortionPass::SetK1(double _k1) - { - this->k1 = _k1; - } - - ////////////////////////////////////////////////// - template - void BaseDistortionPass::SetK2(double _k2) - { - this->k2 = _k2; - } - - ////////////////////////////////////////////////// - template - void BaseDistortionPass::SetK3(double _k3) - { - this->k3 = _k3; - } - - ////////////////////////////////////////////////// - template - void BaseDistortionPass::SetP1(double _p1) - { - this->p1 = _p1; - } - - ////////////////////////////////////////////////// - template - void BaseDistortionPass::SetP2(double _p2) - { - this->p2 = _p2; - } - - ////////////////////////////////////////////////// - template - void BaseDistortionPass::SetCenter(const math::Vector2d &_center) - { - this->lensCenter = _center; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseGaussianNoisePass.hh b/include/ignition/rendering/base/BaseGaussianNoisePass.hh index 03e03930b..b8fd713db 100644 --- a/include/ignition/rendering/base/BaseGaussianNoisePass.hh +++ b/include/ignition/rendering/base/BaseGaussianNoisePass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,155 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_ -#define IGNITION_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_ -#include -#include - -#include "ignition/rendering/GaussianNoisePass.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class BaseGaussianNoisePass BaseGaussianNoisePass.hh \ - * ignition/rendering/base/BaseGaussianNoisePass.hh - */ - /// \brief Base Gaussian noise render pass. - template - class BaseGaussianNoisePass : - public virtual GaussianNoisePass, - public virtual T - { - /// \brief Constructor - protected: BaseGaussianNoisePass(); - - /// \brief Destructor - public: virtual ~BaseGaussianNoisePass(); - - // Documentation inherited. - public: double Mean() const; - - // Documentation inherited. - public: double StdDev() const; - - // Documentation inherited. - public: double Bias() const; - - // Documentation inherited. - public: void SetMean(double _mean); - - // Documentation inherited. - public: void SetStdDev(double _stdDev); - - // Documentation inherited. - public: void SetBiasMean(double _biasMean); - - // Documentation inherited. - public: void SetBiasStdDev(double _biasStdDev); - - // Sample the bias from bias mean and bias standard deviation - protected: void SampleBias(); - - /// \brief Gaussian noise mean. - protected: double mean = 0.0; - - /// \brief Standard deviation of Gaussian noise - protected: double stdDev = 0.0; - - /// \brief Gaussian noise bias. - protected: double bias = 0.0; - - /// \brief The mean of the Gaussian distribution from which bias values - /// are drawn. - protected: double biasMean = 0; - - /// \brief The standard deviation of the Gaussian distribution from - /// which bias values are drawn. - protected: double biasStdDev = 0; - }; - - ////////////////////////////////////////////////// - // BaseGaussianNoisePass - ////////////////////////////////////////////////// - template - BaseGaussianNoisePass::BaseGaussianNoisePass() - { - } - - ////////////////////////////////////////////////// - template - BaseGaussianNoisePass::~BaseGaussianNoisePass() - { - } - - ////////////////////////////////////////////////// - template - double BaseGaussianNoisePass::Mean() const - { - return this->mean; - } - - ////////////////////////////////////////////////// - template - double BaseGaussianNoisePass::StdDev() const - { - return this->stdDev; - } - - ////////////////////////////////////////////////// - template - double BaseGaussianNoisePass::Bias() const - { - return this->bias; - } - - ////////////////////////////////////////////////// - template - void BaseGaussianNoisePass::SetMean(double _mean) - { - this->mean = _mean; - } - - ////////////////////////////////////////////////// - template - void BaseGaussianNoisePass::SetStdDev(double _stdDev) - { - this->stdDev = _stdDev; - } - - ////////////////////////////////////////////////// - template - void BaseGaussianNoisePass::SetBiasMean(double _biasMean) - { - this->biasMean = _biasMean; - this->SampleBias(); - } - - ////////////////////////////////////////////////// - template - void BaseGaussianNoisePass::SetBiasStdDev(double _biasStdDev) - { - this->biasStdDev = _biasStdDev; - this->SampleBias(); - } - - ////////////////////////////////////////////////// - template - void BaseGaussianNoisePass::SampleBias() - { - this->bias = - ignition::math::Rand::DblNormal(this->biasMean, this->biasStdDev); - // With equal probability, we pick a negative bias (by convention, - // rateBiasMean should be positive, though it would work fine if - // negative). - if (ignition::math::Rand::DblUniform() < 0.5) - this->bias = -this->bias; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseGeometry.hh b/include/ignition/rendering/base/BaseGeometry.hh index 337262037..1ce00859c 100644 --- a/include/ignition/rendering/base/BaseGeometry.hh +++ b/include/ignition/rendering/base/BaseGeometry.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,103 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEGEOMETRY_HH_ -#define IGNITION_RENDERING_BASE_BASEGEOMETRY_HH_ -#include - -#include - -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseGeometry : - public virtual Geometry, - public virtual T - { - protected: BaseGeometry(); - - public: virtual ~BaseGeometry(); - - public: virtual VisualPtr Parent() const override = 0; - - public: virtual void RemoveParent() override; - - // Documentation inherited - public: virtual void SetMaterial(const std::string &_material, - bool _unique = true) override; - - // Documentation inherited - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true) override = 0; - - // Documentation inherited - public: virtual GeometryPtr Clone() const override; - - // Documentation inherited - public: virtual void Destroy() override; - }; - - ////////////////////////////////////////////////// - template - BaseGeometry::BaseGeometry() - { - } - - ////////////////////////////////////////////////// - template - BaseGeometry::~BaseGeometry() - { - } - - ////////////////////////////////////////////////// - template - void BaseGeometry::RemoveParent() - { - VisualPtr parent = this->Parent(); - - if (parent) - { - auto baseShared = this->shared_from_this(); - - auto thisShared = - std::dynamic_pointer_cast>(baseShared); - - parent->RemoveGeometry(thisShared); - } - } - - ////////////////////////////////////////////////// - template - void BaseGeometry::SetMaterial(const std::string &_name, bool _unique) - { - MaterialPtr material = this->Scene()->Material(_name); - if (material) this->SetMaterial(material, _unique); - } - - ////////////////////////////////////////////////// - template - GeometryPtr BaseGeometry::Clone() const - { - ignwarn << "Clone functionality for Geometry does not exist yet.\n"; - return nullptr; - } - - ////////////////////////////////////////////////// - template - void BaseGeometry::Destroy() - { - T::Destroy(); - this->RemoveParent(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseGizmoVisual.hh b/include/ignition/rendering/base/BaseGizmoVisual.hh index c517f861f..9ea5f4cdc 100644 --- a/include/ignition/rendering/base/BaseGizmoVisual.hh +++ b/include/ignition/rendering/base/BaseGizmoVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,709 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_BASE_BASEGIZMOVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASEGIZMOVISUAL_HH_ - -#include -#include -#include -#include - -#include "ignition/rendering/base/BaseScene.hh" -#include "ignition/rendering/base/BaseNode.hh" -#include "ignition/rendering/ArrowVisual.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GizmoVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class BaseGizmoVisual BaseGizmoVisuall.hh \ - * ignition/rendering/base/BaseGizmoVisual.hh - */ - /// \brief A base implementation of the GizmoVisual class - template - class BaseGizmoVisual : - public virtual GizmoVisual, - public virtual T - { - /// \brief Constructor - protected: BaseGizmoVisual(); - - /// \brief Destructor - public: virtual ~BaseGizmoVisual(); - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void SetTransformMode(TransformMode _mode) override; - - // Documentation inherited - public: virtual TransformMode Mode() const override; - - // Documentation inherited - public: virtual void SetActiveAxis(const math::Vector3d &_axis) override; - - // Documentation inherited - public: virtual math::Vector3d ActiveAxis() const override; - - // Documentation inherited - public: virtual TransformAxis AxisById(unsigned int _id) const override; - - // Documentation inherited - public: virtual VisualPtr ChildByAxis(unsigned int _axis) const override; - - /// \brief Reset the gizmo visual state - public: virtual void Reset(); - - /// \brief Create materials used by the gizmo visual - protected: void CreateMaterials(); - - /// \brief Create gizmo visual for translation - protected: void CreateTranslationVisual(); - - /// \brief Create gizmo visual for rotation - protected: void CreateRotationVisual(); - - /// \brief Create gizmo visual for scale - protected: void CreateScaleVisual(); - - /// \brief Current gizmo mode - protected: TransformMode mode = TransformMode::TM_NONE; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief A map of gizmo axis and their visuals - protected: std::map visuals; - - /// \brief A map of gizmo axis and their handle visuals - protected: std::map handles; - - /// \brief Currently active visual. - protected: VisualPtr activeVis; - - /// \brief Flag to indicate the mode has changed. - protected: bool modeDirty = false; - - /// \brief Active axis - protected: math::Vector3d axis = math::Vector3d::Zero; - - /// \brief A map of axis enums to materials - protected: std::map materials; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Material used by axes - protected: enum AxisMaterial - { - /// \brief X axis - AM_X, - /// \brief Y axis - AM_Y, - /// \brief Z axis - AM_Z, - /// \brief Active axis - AM_ACTIVE, - /// \brief Origin - AM_O, - /// \brief handle - AM_HANDLE - }; - - /// \brief Only the scene can create a GizmoVisual - private: friend class BaseScene; - }; - - ////////////////////////////////////////////////// - template - BaseGizmoVisual::BaseGizmoVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseGizmoVisual::~BaseGizmoVisual() - { - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::Init() - { - T::Init(); - - this->CreateMaterials(); - this->CreateTranslationVisual(); - this->CreateRotationVisual(); - this->CreateScaleVisual(); - - for (auto v : this->visuals) - v.second->SetVisible(false); - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::Reset() - { - this->visuals[TransformAxis::TA_TRANSLATION_X]->SetMaterial( - this->materials[AM_X], false); - this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( - this->materials[AM_Y], false); - this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( - this->materials[AM_Z], false); - this->visuals[TransformAxis::TA_ROTATION_X]->SetMaterial( - this->materials[AM_X], false); - this->visuals[TransformAxis::TA_ROTATION_Y]->SetMaterial( - this->materials[AM_Y], false); - this->visuals[TransformAxis::TA_ROTATION_Z]->SetMaterial( - this->materials[AM_Z], false); - this->visuals[TransformAxis::TA_SCALE_X]->SetMaterial( - this->materials[AM_X], false); - this->visuals[TransformAxis::TA_SCALE_Y]->SetMaterial( - this->materials[AM_Y], false); - this->visuals[TransformAxis::TA_SCALE_Z]->SetMaterial( - this->materials[AM_Z], false); - - this->handles[TransformAxis::TA_TRANSLATION_X]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - - this->handles[TransformAxis::TA_ROTATION_X]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_ROTATION_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_ROTATION_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - - this->handles[TransformAxis::TA_SCALE_X]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_SCALE_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_SCALE_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - - for (auto v : this->visuals) - v.second->SetVisible(false); - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::PreRender() - { - if (!this->modeDirty) - return; - - this->Reset(); - - if (this->mode == TransformMode::TM_NONE) - { - this->modeDirty = false; - return; - } - - if (this->mode & TransformMode::TM_TRANSLATION) - { - this->visuals[TransformAxis::TA_TRANSLATION_X]->SetVisible(true); - this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetVisible(true); - this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetVisible(true); - this->visuals[TransformAxis::TA_TRANSLATION_Z << 1]->SetVisible(true); - if (this->axis.X() > 0) - { - this->visuals[TransformAxis::TA_TRANSLATION_X]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_TRANSLATION_X]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Y() > 0) - { - this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Z() > 0) - { - this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - } - } - else if (this->mode & TransformMode::TM_ROTATION) - { - this->visuals[TransformAxis::TA_ROTATION_X]->SetVisible(true); - this->visuals[TransformAxis::TA_ROTATION_Y]->SetVisible(true); - this->visuals[TransformAxis::TA_ROTATION_Z]->SetVisible(true); - this->visuals[TransformAxis::TA_ROTATION_Z << 1]->SetVisible(true); - if (this->axis.X() > 0) - { - this->visuals[TransformAxis::TA_ROTATION_X]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_ROTATION_X]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Y() > 0) - { - this->visuals[TransformAxis::TA_ROTATION_Y]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_ROTATION_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Z() > 0) - { - this->visuals[TransformAxis::TA_ROTATION_Z]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_ROTATION_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - } - } - else if (this->mode & TransformMode::TM_SCALE) - { - this->visuals[TransformAxis::TA_SCALE_X]->SetVisible(true); - this->visuals[TransformAxis::TA_SCALE_Y]->SetVisible(true); - this->visuals[TransformAxis::TA_SCALE_Z]->SetVisible(true); - if (this->axis.X() > 0) - { - this->visuals[TransformAxis::TA_SCALE_X]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_SCALE_X]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Y() > 0) - { - this->visuals[TransformAxis::TA_SCALE_Y]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_SCALE_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Z() > 0) - { - this->visuals[TransformAxis::TA_SCALE_Z]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_SCALE_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - } - } - - this->modeDirty = false; - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::SetTransformMode(TransformMode _mode) - { - if (this->mode == _mode) - return; - - this->mode = _mode; - // clear active axis when mode changes - this->axis = math::Vector3d::Zero; - this->modeDirty = true; - } - - ////////////////////////////////////////////////// - template - TransformMode BaseGizmoVisual::Mode() const - { - return this->mode; - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::SetActiveAxis(const math::Vector3d &_axis) - { - if (this->axis == _axis) - return; - - this->axis = _axis; - this->modeDirty = true; - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseGizmoVisual::ActiveAxis() const - { - return this->axis; - } - - ////////////////////////////////////////////////// - template - TransformAxis BaseGizmoVisual::AxisById(unsigned int _id) const - { - for (auto v : this->visuals) - { - // each axis visual has a child handle so also check children for - // matching id - if (v.second->Id() == _id || v.second->ChildById(_id)) - return static_cast(v.first); - } - return TransformAxis::TA_NONE; - } - - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::CreateMaterials() - { - MaterialPtr xMat = this->Scene()->Material("Default/TransRed")->Clone(); - MaterialPtr yMat = this->Scene()->Material("Default/TransGreen")->Clone(); - MaterialPtr zMat = this->Scene()->Material("Default/TransBlue")->Clone(); - MaterialPtr activeMat = - this->Scene()->Material("Default/TransYellow")->Clone(); - - // disable depth checking and writing, make them overlays - xMat->SetDepthWriteEnabled(false); - xMat->SetDepthCheckEnabled(false); - yMat->SetDepthWriteEnabled(false); - yMat->SetDepthCheckEnabled(false); - zMat->SetDepthWriteEnabled(false); - zMat->SetDepthCheckEnabled(false); - activeMat->SetDepthWriteEnabled(false); - activeMat->SetDepthCheckEnabled(false); - - MaterialPtr oMat = this->Scene()->Material("GizmoGray"); - if (!oMat) - { - oMat = this->Scene()->CreateMaterial("GizmoGray"); - oMat->SetAmbient(0.5, 0.5, 0.5); - oMat->SetDiffuse(0.5, 0.5, 0.5); - oMat->SetEmissive(0.5, 0.5, 0.5); - oMat->SetTransparency(0.5); - oMat->SetCastShadows(false); - oMat->SetReceiveShadows(false); - oMat->SetLightingEnabled(false); - oMat->SetDepthWriteEnabled(false); - oMat->SetDepthCheckEnabled(false); - } - - MaterialPtr handleMat = this->Scene()->Material("GizmoHandle"); - if (!handleMat) - { - handleMat = this->Scene()->CreateMaterial("GizmoHandle"); - handleMat->SetAmbient(0.0, 0.0, 0.0); - handleMat->SetDiffuse(0.0, 0.0, 0.0); - handleMat->SetEmissive(0.0, 0.0, 0.0); - handleMat->SetTransparency(1.0); - handleMat->SetCastShadows(false); - handleMat->SetReceiveShadows(false); - handleMat->SetLightingEnabled(false); - handleMat->SetDepthWriteEnabled(false); - handleMat->SetDepthCheckEnabled(false); - } - - this->materials[AM_X] = xMat; - this->materials[AM_Y] = yMat; - this->materials[AM_Z] = zMat; - this->materials[AM_ACTIVE] = activeMat; - this->materials[AM_O] = oMat; - this->materials[AM_HANDLE] = handleMat; - } - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::CreateTranslationVisual() - { - VisualPtr transVis = this->Scene()->CreateVisual(); - - // trans x - VisualPtr transXVis = this->Scene()->CreateVisual(); - VisualPtr transShaftXVis = this->Scene()->CreateVisual(); - transShaftXVis->AddGeometry(this->Scene()->CreateCylinder()); - transShaftXVis->SetOrigin(0, 0, 0.5); - transShaftXVis->SetLocalPosition(0, 0, 0.5); - transShaftXVis->SetLocalScale(0.02, 0.02, 0.45); - transXVis->AddChild(transShaftXVis); - - VisualPtr transHeadXVis = this->Scene()->CreateVisual(); - transHeadXVis->AddGeometry(this->Scene()->CreateCone()); - transHeadXVis->SetOrigin(0, 0, -0.5); - transHeadXVis->SetLocalPosition(0, 0, 0.5); - transHeadXVis->SetLocalScale(0.07, 0.07, 0.2); - transXVis->AddChild(transHeadXVis); - - transXVis->SetMaterial(this->materials[AM_X], false); - transXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); - transVis->AddChild(transXVis); - - // trans y - VisualPtr transYVis = this->Scene()->CreateVisual(); - VisualPtr transShaftYVis = this->Scene()->CreateVisual(); - transShaftYVis->AddGeometry(this->Scene()->CreateCylinder()); - transShaftYVis->SetOrigin(0, 0, 0.5); - transShaftYVis->SetLocalPosition(0, 0, 0.5); - transShaftYVis->SetLocalScale(0.02, 0.02, 0.45); - transYVis->AddChild(transShaftYVis); - - VisualPtr transHeadYVis = this->Scene()->CreateVisual(); - transHeadYVis->AddGeometry(this->Scene()->CreateCone()); - transHeadYVis->SetOrigin(0, 0, -0.5); - transHeadYVis->SetLocalPosition(0, 0, 0.5); - transHeadYVis->SetLocalScale(0.07, 0.07, 0.2); - transYVis->AddChild(transHeadYVis); - - transYVis->SetMaterial(this->materials[AM_Y], false); - transYVis->SetLocalRotation(-IGN_PI * 0.5, 0, 0); - transVis->AddChild(transYVis); - - // trans z - VisualPtr transZVis = this->Scene()->CreateVisual(); - VisualPtr transShaftZVis = this->Scene()->CreateVisual(); - transShaftZVis->AddGeometry(this->Scene()->CreateCylinder()); - transShaftZVis->SetOrigin(0, 0, 0.5); - transShaftZVis->SetLocalPosition(0, 0, 0.5); - transShaftZVis->SetLocalScale(0.02, 0.02, 0.45); - transZVis->AddChild(transShaftZVis); - - VisualPtr transHeadZVis = this->Scene()->CreateVisual(); - transHeadZVis->AddGeometry(this->Scene()->CreateCone()); - transHeadZVis->SetOrigin(0, 0, -0.5); - transHeadZVis->SetLocalPosition(0, 0, 0.5); - transHeadZVis->SetLocalScale(0.07, 0.07, 0.2); - transZVis->AddChild(transHeadZVis); - - transZVis->SetMaterial(this->materials[AM_Z], false); - transVis->AddChild(transZVis); - - // trans origin - VisualPtr transOrigin = this->Scene()->CreateVisual(); - transOrigin->AddGeometry(this->Scene()->CreateSphere()); - transOrigin->SetLocalScale(0.05, 0.05, 0.05); - transOrigin->SetMaterial(this->materials[AM_O], false); - transVis->AddChild(transOrigin); - - this->visuals[TransformAxis::TA_TRANSLATION_X] = transXVis; - this->visuals[TransformAxis::TA_TRANSLATION_Y] = transYVis; - this->visuals[TransformAxis::TA_TRANSLATION_Z] = transZVis; - this->visuals[TransformAxis::TA_TRANSLATION_Z << 1] = transOrigin; - - // translation handles - VisualPtr transHandleXVis = this->Scene()->CreateVisual(); - transHandleXVis->AddGeometry(this->Scene()->CreateCylinder()); - transHandleXVis->SetLocalPosition(0, 0, 0.35); - transHandleXVis->SetLocalScale(0.11, 0.11, 0.7); - transHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); - transXVis->AddChild(transHandleXVis); - - VisualPtr transHandleYVis = this->Scene()->CreateVisual(); - transHandleYVis->AddGeometry(this->Scene()->CreateCylinder()); - transHandleYVis->SetLocalPosition(0, 0, 0.35); - transHandleYVis->SetLocalScale(0.11, 0.11, 0.7); - transHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); - transYVis->AddChild(transHandleYVis); - - VisualPtr transHandleZVis = this->Scene()->CreateVisual(); - transHandleZVis->AddGeometry(this->Scene()->CreateCylinder()); - transHandleZVis->SetLocalPosition(0, 0, 0.35); - transHandleZVis->SetLocalScale(0.11, 0.11, 0.7); - transHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); - transZVis->AddChild(transHandleZVis); - - this->handles[TransformAxis::TA_TRANSLATION_X] = transHandleXVis; - this->handles[TransformAxis::TA_TRANSLATION_Y] = transHandleYVis; - this->handles[TransformAxis::TA_TRANSLATION_Z] = transHandleZVis; - - this->AddChild(transVis); - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::CreateRotationVisual() - { - common::MeshManager *meshMgr = common::MeshManager::Instance(); - std::string rotMeshName = "gizmo_rotate"; - if (!meshMgr->HasMesh(rotMeshName)) - meshMgr->CreateTube(rotMeshName, 1.0f, 1.02f, 0.02f, 1, 64, IGN_PI); - - std::string rotFullMeshName = "gizmo_rotate_full"; - if (!meshMgr->HasMesh(rotFullMeshName)) - { - meshMgr->CreateTube(rotFullMeshName, 1.0f, 1.02f, 0.02f, 1, 64, - 2 * IGN_PI); - } - - std::string rotHandleMeshName = "gizmo_rotate_handle"; - if (!meshMgr->HasMesh(rotHandleMeshName)) - { - meshMgr->CreateTube(rotHandleMeshName, 0.95f, 1.07f, 0.1f, 1, 64, - IGN_PI); - } - - VisualPtr rotVis = this->Scene()->CreateVisual(); - - // rotation x - VisualPtr rotXVis = this->Scene()->CreateVisual(); - rotXVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); - rotXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); - rotXVis->SetLocalScale(0.5, 0.5, 0.5); - rotXVis->SetMaterial(this->materials[AM_X], false); - rotVis->AddChild(rotXVis); - - // rotation y - VisualPtr rotYVis = this->Scene()->CreateVisual(); - rotYVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); - rotYVis->SetLocalRotation(IGN_PI * 0.5, 0, 0); - rotYVis->SetLocalScale(0.5, 0.5, 0.5); - rotYVis->SetMaterial(this->materials[AM_Y], false); - rotVis->AddChild(rotYVis); - - // rotation z - VisualPtr rotZVis = this->Scene()->CreateVisual(); - rotZVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); - rotZVis->SetLocalScale(0.5, 0.5, 0.5); - rotZVis->SetMaterial(this->materials[AM_Z], false); - rotVis->AddChild(rotZVis); - - // rotation origin - VisualPtr rotFullVis = this->Scene()->CreateVisual(); - rotFullVis->AddGeometry(this->Scene()->CreateMesh(rotFullMeshName)); - rotFullVis->SetLocalScale(0.5, 0.5, 0.5); - rotFullVis->SetMaterial(this->materials[AM_O], false); - rotVis->AddChild(rotFullVis); - - this->visuals[TransformAxis::TA_ROTATION_X] = rotXVis; - this->visuals[TransformAxis::TA_ROTATION_Y] = rotYVis; - this->visuals[TransformAxis::TA_ROTATION_Z] = rotZVis; - this->visuals[TransformAxis::TA_ROTATION_Z << 1] = rotFullVis; - - // rotation handles - VisualPtr rotHandleXVis = this->Scene()->CreateVisual(); - rotHandleXVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); - rotHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); - rotXVis->AddChild(rotHandleXVis); - - VisualPtr rotHandleYVis = this->Scene()->CreateVisual(); - rotHandleYVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); - rotHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); - rotYVis->AddChild(rotHandleYVis); - - VisualPtr rotHandleZVis = this->Scene()->CreateVisual(); - rotHandleZVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); - rotHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); - rotZVis->AddChild(rotHandleZVis); - - this->handles[TransformAxis::TA_ROTATION_X] = rotHandleXVis; - this->handles[TransformAxis::TA_ROTATION_Y] = rotHandleYVis; - this->handles[TransformAxis::TA_ROTATION_Z] = rotHandleZVis; - - this->AddChild(rotVis); - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::CreateScaleVisual() - { - VisualPtr scaleVis = this->Scene()->CreateVisual(); - - // scale x - VisualPtr scaleXVis = this->Scene()->CreateVisual(); - VisualPtr scaleShaftXVis = this->Scene()->CreateVisual(); - scaleShaftXVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleShaftXVis->SetOrigin(0, 0, 0.5); - scaleShaftXVis->SetLocalPosition(0, 0, 0.5); - scaleShaftXVis->SetLocalScale(0.02, 0.02, 0.5); - scaleXVis->AddChild(scaleShaftXVis); - - VisualPtr scaleHeadXVis = this->Scene()->CreateVisual(); - scaleHeadXVis->AddGeometry(this->Scene()->CreateBox()); - scaleHeadXVis->SetOrigin(0, 0, -0.5); - scaleHeadXVis->SetLocalPosition(0, 0, 0.5); - scaleHeadXVis->SetLocalScale(0.07, 0.07, 0.07); - scaleXVis->AddChild(scaleHeadXVis); - - scaleXVis->SetMaterial(this->materials[AM_X], false); - scaleXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); - scaleVis->AddChild(scaleXVis); - - // scale y - VisualPtr scaleYVis = this->Scene()->CreateVisual(); - VisualPtr scaleShaftYVis = this->Scene()->CreateVisual(); - scaleShaftYVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleShaftYVis->SetOrigin(0, 0, 0.5); - scaleShaftYVis->SetLocalPosition(0, 0, 0.5); - scaleShaftYVis->SetLocalScale(0.02, 0.02, 0.5); - scaleYVis->AddChild(scaleShaftYVis); - - VisualPtr scaleHeadYVis = this->Scene()->CreateVisual(); - scaleHeadYVis->AddGeometry(this->Scene()->CreateBox()); - scaleHeadYVis->SetOrigin(0, 0, -0.5); - scaleHeadYVis->SetLocalPosition(0, 0, 0.5); - scaleHeadYVis->SetLocalScale(0.07, 0.07, 0.07); - scaleYVis->AddChild(scaleHeadYVis); - - scaleYVis->SetMaterial(this->materials[AM_Y], false); - scaleYVis->SetLocalRotation(-IGN_PI * 0.5, 0, 0); - scaleVis->AddChild(scaleYVis); - - // scale z - VisualPtr scaleZVis = this->Scene()->CreateVisual(); - VisualPtr scaleShaftZVis = this->Scene()->CreateVisual(); - scaleShaftZVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleShaftZVis->SetOrigin(0, 0, 0.5); - scaleShaftZVis->SetLocalPosition(0, 0, 0.5); - scaleShaftZVis->SetLocalScale(0.02, 0.02, 0.5); - scaleZVis->AddChild(scaleShaftZVis); - - VisualPtr scaleHeadZVis = this->Scene()->CreateVisual(); - scaleHeadZVis->AddGeometry(this->Scene()->CreateBox()); - scaleHeadZVis->SetOrigin(0, 0, -0.5); - scaleHeadZVis->SetLocalPosition(0, 0, 0.5); - scaleHeadZVis->SetLocalScale(0.07, 0.07, 0.07); - scaleZVis->AddChild(scaleHeadZVis); - - scaleZVis->SetMaterial(this->materials[AM_Z], false); - scaleVis->AddChild(scaleZVis); - - this->visuals[TransformAxis::TA_SCALE_X] = scaleXVis; - this->visuals[TransformAxis::TA_SCALE_Y] = scaleYVis; - this->visuals[TransformAxis::TA_SCALE_Z] = scaleZVis; - - // scale handles - VisualPtr scaleHandleXVis = this->Scene()->CreateVisual(); - scaleHandleXVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleHandleXVis->SetLocalPosition(0, 0, 0.285); - scaleHandleXVis->SetLocalScale(0.11, 0.11, 0.57); - scaleHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); - scaleXVis->AddChild(scaleHandleXVis); - - VisualPtr scaleHandleYVis = this->Scene()->CreateVisual(); - scaleHandleYVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleHandleYVis->SetLocalPosition(0, 0, 0.285); - scaleHandleYVis->SetLocalScale(0.11, 0.11, 0.57); - scaleHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); - scaleYVis->AddChild(scaleHandleYVis); - - VisualPtr scaleHandleZVis = this->Scene()->CreateVisual(); - scaleHandleZVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleHandleZVis->SetLocalPosition(0, 0, 0.285); - scaleHandleZVis->SetLocalScale(0.11, 0.11, 0.57); - scaleHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); - scaleZVis->AddChild(scaleHandleZVis); - - this->handles[TransformAxis::TA_SCALE_X] = scaleHandleXVis; - this->handles[TransformAxis::TA_SCALE_Y] = scaleHandleYVis; - this->handles[TransformAxis::TA_SCALE_Z] = scaleHandleZVis; - - this->AddChild(scaleVis); - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseGizmoVisual::ChildByAxis(unsigned int _axis) const - { - auto it = this->visuals.find(_axis); - if (it != this->visuals.end()) - return it->second; - - return VisualPtr(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseGpuRays.hh b/include/ignition/rendering/base/BaseGpuRays.hh index ebf1ec694..c4d48806b 100644 --- a/include/ignition/rendering/base/BaseGpuRays.hh +++ b/include/ignition/rendering/base/BaseGpuRays.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,439 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEGPURAYS_HH_ -#define IGNITION_RENDERING_BASE_BASEGPURAYS_HH_ -#include - -#include -#include - -#include "ignition/rendering/GpuRays.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/base/BaseRenderTarget.hh" -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/Visual.hh" -#include "ignition/rendering/RenderTypes.hh" - - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseGpuRays : - public virtual GpuRays, - public virtual BaseCamera, - public virtual T - { - /// \brief Constructor - protected: BaseGpuRays(); - - /// \brief Destructor - public: virtual ~BaseGpuRays(); - - // Documentation inherited. - public: virtual const float *Data() const override; - - // Documentation inherited. - public: virtual void Copy(float *_data) override; - - // Documentation inherited. - public: virtual void SetClamp(bool _enable) override; - - // Documentation inherited. - public: virtual bool Clamp() const override; - - // Documentation inherited. - public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( - std::function _subscriber) override; - - /// \brief Pointer to the render target - public: virtual RenderTargetPtr RenderTarget() const override = 0; - - // Documentation inherited. - public: virtual void SetIsHorizontal(const bool _horizontal) override; - - // Documentation inherited. - public: virtual bool IsHorizontal() const override; - - /// \brief Set the vertical fov - /// \param[in] _vfov vertical fov - public: virtual void SetVFOV(const math::Angle &_vfov); - - // Documentation inherited. - public: virtual math::Angle VFOV() const override; - - // Documentation inherited. - public: virtual double RayCountRatio() const override; - - // Documentation inherited. - public: virtual double RangeCountRatio() const override; - - // Documentation inherited. - public: virtual void SetRayCountRatio( - const double _rayCountRatio) override; - - // Documentation inherited. - public: virtual ignition::math::Angle AngleMin() const override; - - // Documentation inherited. - public: virtual void SetAngleMin(double _angle) override; - - // Documentation inherited. - public: virtual ignition::math::Angle AngleMax() const override; - - // Documentation inherited. - public: virtual void SetAngleMax(double _angle) override; - - // Documentation inherited. - public: virtual void SetVerticalRayCount(int _samples) override; - - // Documentation inherited. - public: virtual void SetRayCount(int _samples) override; - - // Documentation inherited. - public: virtual int RayCount() const override; - - // Documentation inherited. - public: virtual int RangeCount() const override; - - // Documentation inherited. - public: virtual int VerticalRayCount() const override; - - // Documentation inherited. - public: virtual int VerticalRangeCount() const override; - - // Documentation inherited. - public: virtual ignition::math::Angle VerticalAngleMin() const override; - - // Documentation inherited. - public: virtual void SetVerticalAngleMin(const double _angle) override; - - // Documentation inherited. - public: virtual ignition::math::Angle VerticalAngleMax() const override; - - // Documentation inherited. - public: virtual void SetVerticalAngleMax(const double _angle) override; - - // Documentation inherited. - public: virtual unsigned int Channels() const override; - - // Documentation inherited. - public: virtual void SetHorizontalResolution(double _resolution) override; - - // Documentation inherited. - public: virtual double HorizontalResolution() const override; - - // Documentation inherited. - public: virtual void SetVerticalResolution(double resolution) override; - - // Documentation inherited. - public: virtual double VerticalResolution() const override; - - /// \brief maximum value used for data outside sensor range - public: float dataMaxVal = ignition::math::INF_D; - - /// \brief minimum value used for data outside sensor range - public: float dataMinVal = -ignition::math::INF_D; - - /// \brief True if data values are clamped to camera clip distances, - // false if data outside of camera range is +/- inf - public: bool clamping = false; - - /// \brief Ray count ratio. - protected: double rayCountRatio = 0; - - /// \brief Range count ratio. - protected: double rangeCountRatio = 0; - - /// \brief Vertical field-of-view. - protected: math::Angle vfov; - - /// \brief True if the sensor is horizontal only. - protected: bool isHorizontal = true; - - /// \brief Horizontal minimal angle - protected: double minAngle = 0; - - /// \brief Horizontal maximal angle - protected: double maxAngle = 0; - - /// \brief Vertical minimal angle - protected: double vMinAngle = 0; - - /// \brief Vertical maximal angle - protected: double vMaxAngle = 0; - - /// \brief Quantity of horizontal rays - protected: int hSamples = 0; - - /// \brief Quantity of verical rays - protected: int vSamples = 0; - - /// \brief Resolution of horizontal rays - protected: double hResolution = 1; - - /// \brief Resolution of vertical rays - protected: double vResolution = 1; - - /// \brief Number of channels used to store the data - protected: unsigned int channels = 1u; - - private: friend class OgreScene; - }; - - ////////////////////////////////////////////////// - template - BaseGpuRays::BaseGpuRays() - { - } - - ////////////////////////////////////////////////// - template - BaseGpuRays::~BaseGpuRays() - { - } - - ////////////////////////////////////////////////// - template - const float *BaseGpuRays::Data() const - { - return nullptr; - } - - ////////////////////////////////////////////////// - template - void BaseGpuRays::Copy(float *_dataDest) - { - // Unused - (void)_dataDest; - } - - ////////////////////////////////////////////////// - template - void BaseGpuRays::SetClamp(bool _enable) - { - this->clamping = _enable; - - if (this->clamping) - { - this->dataMinVal = this->NearClipPlane(); - this->dataMaxVal = this->FarClipPlane(); - } - else - { - this->dataMinVal = -ignition::math::INF_D; - this->dataMaxVal = ignition::math::INF_D; - } - } - - ////////////////////////////////////////////////// - template - bool BaseGpuRays::Clamp() const - - { - return this->clamping; - } - - ////////////////////////////////////////////////// - template - ignition::common::ConnectionPtr BaseGpuRays::ConnectNewGpuRaysFrame( - std::function) - { - return nullptr; - } - - ////////////////////////////////////////////////// - template - void BaseGpuRays::SetIsHorizontal(const bool _horizontal) - { - this->isHorizontal = _horizontal; - } - - ////////////////////////////////////////////////// - template - bool BaseGpuRays::IsHorizontal() const - { - return this->isHorizontal; - } - - ////////////////////////////////////////////////// - template - double BaseGpuRays::RayCountRatio() const - { - return this->rayCountRatio; - } - - ////////////////////////////////////////////////// - template - void BaseGpuRays::SetRayCountRatio(const double _rayCountRatio) - { - this->rayCountRatio = _rayCountRatio; - } - - ////////////////////////////////////////////////// - template - double BaseGpuRays::RangeCountRatio() const - { - return this->rangeCountRatio; - } - - ////////////////////////////////////////////////// - template - math::Angle BaseGpuRays::VFOV() const - { - return this->vfov; - } - - ////////////////////////////////////////////////// - template - void BaseGpuRays::SetVFOV(const math::Angle &_vfov) - { - this->vfov = _vfov; - } - - template - ////////////////////////////////////////////////// - ignition::math::Angle BaseGpuRays::AngleMin() const - { - return this->minAngle; - } - - template - ////////////////////////////////////////////////// - void BaseGpuRays::SetAngleMin(double _angle) - { - this->minAngle = _angle; - } - - template - ////////////////////////////////////////////////// - ignition::math::Angle BaseGpuRays::AngleMax() const - { - return this->maxAngle; - } - - template - ////////////////////////////////////////////////// - void BaseGpuRays::SetAngleMax(double _angle) - { - this->maxAngle = _angle; - } - - template - ////////////////////////////////////////////////// - int BaseGpuRays::RayCount() const - { - return this->hSamples; - } - - template - ////////////////////////////////////////////////// - void BaseGpuRays::SetRayCount(int _samples) - { - this->hSamples = _samples; - } - - template - ////////////////////////////////////////////////// - int BaseGpuRays::RangeCount() const - { - return static_cast(this->RayCount() * this->hResolution); - } - - template - ////////////////////////////////////////////////// - int BaseGpuRays::VerticalRayCount() const - { - return this->vSamples; - } - - template - ////////////////////////////////////////////////// - void BaseGpuRays::SetVerticalRayCount(int _samples) - { - this->vSamples = _samples; - } - - template - ////////////////////////////////////////////////// - int BaseGpuRays::VerticalRangeCount() const - { - return static_cast(this->VerticalRayCount() * this->vResolution); - } - - template - ////////////////////////////////////////////////// - ignition::math::Angle BaseGpuRays::VerticalAngleMin() const - { - return this->vMinAngle; - } - - template - ////////////////////////////////////////////////// - void BaseGpuRays::SetVerticalAngleMin(const double _angle) - { - this->vMinAngle = _angle; - } - - template - ////////////////////////////////////////////////// - ignition::math::Angle BaseGpuRays::VerticalAngleMax() const - { - return this->vMaxAngle; - } - - template - ////////////////////////////////////////////////// - void BaseGpuRays::SetVerticalAngleMax(const double _angle) - { - this->vMaxAngle = _angle; - } - - template - ////////////////////////////////////////////////// - unsigned int BaseGpuRays::Channels() const - { - return this->channels; - } - - template - ////////////////////////////////////////////////// - void BaseGpuRays::SetHorizontalResolution(double _resolution) - { - this->hResolution = std::abs(_resolution); - } - - template - ////////////////////////////////////////////////// - double BaseGpuRays::HorizontalResolution() const - { - return this->hResolution; - } - - template - ////////////////////////////////////////////////// - void BaseGpuRays::SetVerticalResolution(double _resolution) - { - this->vResolution = std::abs(_resolution); - } - - template - ////////////////////////////////////////////////// - double BaseGpuRays::VerticalResolution() const - { - return this->vResolution; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseGrid.hh b/include/ignition/rendering/base/BaseGrid.hh index 26aabc464..9b6de6e41 100644 --- a/include/ignition/rendering/base/BaseGrid.hh +++ b/include/ignition/rendering/base/BaseGrid.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,144 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEGRID_HH_ -#define IGNITION_RENDERING_BASE_BASEGRID_HH_ -#include -#include "ignition/rendering/Grid.hh" -#include "ignition/rendering/base/BaseObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of a grid geometry - template - class BaseGrid : - public virtual Grid, - public virtual T - { - /// \brief Constructor - protected: BaseGrid(); - - /// \brief Destructor - public: virtual ~BaseGrid(); - - // Documentation inherited. - public: virtual void PreRender(); - - // Documentation inherited. - public: virtual void Destroy(); - - // Documentation inherited. - public: virtual unsigned int CellCount() const; - - // Documentation inherited. - public: virtual void SetCellCount(const unsigned int _count); - - // Documentation inherited. - public: virtual double CellLength() const; - - // Documentation inherited. - public: virtual void SetCellLength(const double _len); - - // Documentation inherited. - public: virtual unsigned int VerticalCellCount() const; - - // Documentation inherited. - public: virtual void SetVerticalCellCount(const unsigned int _count); - - /// \brief Number of cells in grid - protected: unsigned int cellCount = 10u; - - /// \brief Length of a single cell - protected: double cellLength = 1.0; - - /// \brief Number of cells in vertical direction - protected: unsigned int verticalCellCount = 0; - - /// \brief vertical offset of the XY plane from origin - protected: double heightOffset = 0.0; - - /// \brief Flag to indicate grid properties have changed - protected: bool gridDirty = false; - }; - - ////////////////////////////////////////////////// - // BaseGrid - ////////////////////////////////////////////////// - template - BaseGrid::BaseGrid() - { - } - - ////////////////////////////////////////////////// - template - BaseGrid::~BaseGrid() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseGrid::CellCount() const - { - return this->cellCount; - } - - ////////////////////////////////////////////////// - template - void BaseGrid::SetCellCount(const unsigned int _count) - { - this->cellCount = _count; - this->gridDirty = true; - } - - ////////////////////////////////////////////////// - template - double BaseGrid::CellLength() const - { - return this->cellLength; - } - - ////////////////////////////////////////////////// - template - void BaseGrid::SetCellLength(const double _len) - { - this->cellLength = _len; - this->gridDirty = true; - } - - ////////////////////////////////////////////////// - template - unsigned int BaseGrid::VerticalCellCount() const - { - return this->verticalCellCount; - } - - ////////////////////////////////////////////////// - template - void BaseGrid::SetVerticalCellCount(const unsigned int _count) - { - this->verticalCellCount = _count; - this->gridDirty = true; - } - - ////////////////////////////////////////////////// - template - void BaseGrid::PreRender() - { - T::PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseGrid::Destroy() - { - T::Destroy(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseHeightmap.hh b/include/ignition/rendering/base/BaseHeightmap.hh index cafcf2c5a..5549c1376 100644 --- a/include/ignition/rendering/base/BaseHeightmap.hh +++ b/include/ignition/rendering/base/BaseHeightmap.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,68 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEHEIGHTMAP_HH_ -#define IGNITION_RENDERING_BASE_BASEHEIGHTMAP_HH_ -#include "ignition/rendering/Heightmap.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - ////////////////////////////////////////////////// - template - class BaseHeightmap : - public virtual Heightmap, - public virtual T - { - /// \brief Constructor - /// \param[in] _desc Descriptor containing heightmap information. - protected: explicit BaseHeightmap(const HeightmapDescriptor &_desc); - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual const HeightmapDescriptor &Descriptor() override; - - /// \brief Descriptor containing heightmap information - public: HeightmapDescriptor descriptor; - }; - - ////////////////////////////////////////////////// - template - BaseHeightmap::BaseHeightmap(const HeightmapDescriptor &_desc) - : descriptor{_desc} - { - } - - ////////////////////////////////////////////////// - template - void BaseHeightmap::PreRender() - { - T::PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseHeightmap::Destroy() - { - T::Destroy(); - } - - ////////////////////////////////////////////////// - template - const HeightmapDescriptor &BaseHeightmap::Descriptor() - { - return this->descriptor; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseInertiaVisual.hh b/include/ignition/rendering/base/BaseInertiaVisual.hh index 9be984395..c7a431278 100644 --- a/include/ignition/rendering/base/BaseInertiaVisual.hh +++ b/include/ignition/rendering/base/BaseInertiaVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,119 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEINERTIAVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASEINERTIAVISUAL_HH_ -#include "ignition/common/Console.hh" - -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/InertiaVisual.hh" -#include "ignition/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of an inertia visual - template - class BaseInertiaVisual : - public virtual InertiaVisual, - public virtual T - { - /// \brief Constructor - protected: BaseInertiaVisual(); - - /// \brief Destructor - public: virtual ~BaseInertiaVisual(); - - // Documentation inherited. - protected: virtual void Init() override; - - // Documentation inherited. - protected: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void SetInertial( - const ignition::math::Inertiald &_inertial) override; - - // Documentation inherited. - public: virtual void Load(const ignition::math::Pose3d &, - const ignition::math::Vector3d &) override; - - // Documentation inherited - public: virtual VisualPtr BoxVisual() const override; - }; - - ////////////////////////////////////////////////// - template - BaseInertiaVisual::BaseInertiaVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseInertiaVisual::~BaseInertiaVisual() - { - } - - ///////////////////////////////////////////////// - template - void BaseInertiaVisual::PreRender() - { - T::PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseInertiaVisual::Init() - { - T::Init(); - } - - ////////////////////////////////////////////////// - template - void BaseInertiaVisual::SetInertial( - const ignition::math::Inertiald &_inertial) - { - auto xyz = _inertial.Pose().Pos(); - auto q = _inertial.Pose().Rot(); - - // Use ignition::math::MassMatrix3 to compute - // equivalent box size and rotation - auto m = _inertial.MassMatrix(); - ignition::math::Vector3d boxScale; - ignition::math::Quaterniond boxRot; - if (!m.EquivalentBox(boxScale, boxRot)) - { - // Invalid inertia, load with default scale - ignlog << "The link is static or has unrealistic " - << "inertia, so the equivalent inertia box will not be shown.\n"; - } - else - { - // Apply additional rotation by boxRot - this->Load(ignition::math::Pose3d(xyz, q * boxRot), boxScale); - } - } - - ////////////////////////////////////////////////// - template - void BaseInertiaVisual::Load(const ignition::math::Pose3d &, - const ignition::math::Vector3d &) - { - // no op - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseInertiaVisual::BoxVisual() const - { - return nullptr; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseJointVisual.hh b/include/ignition/rendering/base/BaseJointVisual.hh index 7a151f4fa..01b54cff9 100644 --- a/include/ignition/rendering/base/BaseJointVisual.hh +++ b/include/ignition/rendering/base/BaseJointVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,536 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEJOINTVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASEJOINTVISUAL_HH_ -#include -#include - -#include "ignition/common/Console.hh" - -#include "ignition/rendering/ArrowVisual.hh" -#include "ignition/rendering/AxisVisual.hh" -#include "ignition/rendering/JointVisual.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of a joint visual - template - class BaseJointVisual : - public virtual JointVisual, - public virtual T - { - /// \brief Constructor - protected: BaseJointVisual(); - - /// \brief Destructor - public: virtual ~BaseJointVisual(); - - // Documentation inherited. - protected: virtual void Init() override; - - // Documentation inherited. - protected: virtual void PreRender() override; - - // Documentation inherited. - protected: virtual void Destroy() override; - - // Documentation inherited. - public: virtual void SetAxis(const ignition::math::Vector3d &_axis, - bool _useParentFrame) override; - - // Documentation inherited. - public: virtual ignition::math::Vector3d Axis() const override; - - // Documentation inherited. - public: virtual void SetParentAxis( - const ignition::math::Vector3d &_axis, - const std::string &_parentName, - bool _useParentFrame) override; - - // Documentation inherited. - public: virtual ignition::math::Vector3d ParentAxis() const override; - - // Documentation inherited. - public: virtual bool UpdateAxis(const ignition::math::Vector3d &_axis, - bool _useParentFrame) override; - - // Documentation inherited. - public: virtual bool UpdateParentAxis( - const ignition::math::Vector3d &_axis, - bool _useParentFrame) override; - - // Documentation inherited. - public: virtual void SetType(const JointVisualType _type) override; - - // Documentation inherited. - public: virtual JointVisualType Type() const override; - - // Documentation inherited. - public: virtual JointVisualPtr ParentAxisVisual() const override; - - // Documentation inherited. - public: virtual ArrowVisualPtr ArrowVisual() const override; - - // Documentation inherited. - public: virtual void SetVisible(bool _visible) override; - - /// \brief Implementation for updating an axis' arrow visual. - /// \param[in] _arrowVisual Arrow visual to be updated. - /// \param[in] _axis Axis vector. - /// \param[in] _useParentFrame True if the axis vector is - /// expressed in the joint parent frame. - protected: void UpdateAxisImpl(ArrowVisualPtr _arrowVisual, - const ignition::math::Vector3d &_axis, - bool _useParentFrame); - - /// \brief Helper function to create axis visual. - protected: void CreateAxis(); - - /// \brief Helper function to create parent axis visual. - protected: void CreateParentAxis(); - - /// \brief Scale the joint visual according to the joint's child. - protected: void ScaleToChild(); - - /// \brief Type of joint visualization. - protected: JointVisualType jointVisualType = - JointVisualType::JVT_NONE; - - /// \brief The joint's XYZ frame visual. - protected: AxisVisualPtr axisVisual = nullptr; - - /// \brief The visual representing the one joint axis. There can be only - /// one axis visual per joint visual, so joints with two axes have a 2nd - /// JointVisual with its own arrowVisual. - protected: ArrowVisualPtr arrowVisual = nullptr; - - /// \brief Second joint visual for hinge2 and universal joints. It is a - /// simplified visual without an XYZ frame. - protected: JointVisualPtr parentAxisVis = nullptr; - - /// \brief Scale based on the size of the joint's child. - protected: ignition::math::Vector3d scaleToChild = - ignition::math::Vector3d::One; - - /// \brief Flag to indicate joint visual type has changed. - protected: bool dirtyJointType = false; - - /// \brief Flag to indicate axis data has changed. - protected: bool dirtyAxis = false; - - /// \brief Flag to indicate parent axis data has changed. - protected: bool dirtyParentAxis = false; - - /// \brief Joint visual axis vector. - protected: ignition::math::Vector3d axis = - ignition::math::Vector3d::Zero; - - /// \brief Flag to indicate whether axis vector is - /// expressed in joint parent frame. - protected: bool useParentFrame = false; - - /// \brief Flag to update the axis visual. - protected: bool updateAxis = false; - - /// \brief Parent axis vector. - protected: ignition::math::Vector3d parentAxis = - ignition::math::Vector3d::Zero; - - /// \brief Joint parent name. - protected: std::string jointParentName = ""; - - /// \brief Flag to indicate whether parent axis vector is - /// expressed in joint parent frame. - protected: bool parentAxisUseParentFrame = false; - - /// \brief Flag to update the parent axis visual. - protected: bool updateParentAxis = false; - }; - - ////////////////////////////////////////////////// - template - BaseJointVisual::BaseJointVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseJointVisual::~BaseJointVisual() - { - } - - ///////////////////////////////////////////////// - template - void BaseJointVisual::PreRender() - { - T::PreRender(); - - if (this->ParentAxisVisual()) - { - this->ParentAxisVisual()->PreRender(); - } - - if (this->dirtyJointType) - { - this->UpdateAxis(this->axis, this->useParentFrame); - this->UpdateParentAxis(this->parentAxis, - this->parentAxisUseParentFrame); - - this->dirtyJointType = false; - } - - if (this->dirtyAxis) - { - this->CreateAxis(); - this->dirtyAxis = false; - } - - if (this->dirtyParentAxis) - { - this->CreateParentAxis(); - this->dirtyParentAxis = false; - } - - if (this->updateAxis) - { - this->updateAxis = - !this->UpdateAxis(this->axis, this->useParentFrame); - } - - if (this->updateParentAxis) - { - this->updateParentAxis = - !this->UpdateParentAxis(this->parentAxis, - this->parentAxisUseParentFrame); - } - } - - ////////////////////////////////////////////////// - template - void BaseJointVisual::Init() - { - T::Init(); - - this->axisVisual = this->Scene()->CreateAxisVisual(); - this->AddChild(this->axisVisual); - this->SetInheritScale(false); - } - - ///////////////////////////////////////////////// - template - void BaseJointVisual::Destroy() - { - if (this->arrowVisual != nullptr) - { - this->arrowVisual->Destroy(); - this->arrowVisual.reset(); - } - - if (this->axisVisual != nullptr) - { - this->axisVisual->Destroy(); - this->axisVisual.reset(); - } - - if (this->parentAxisVis != nullptr) - { - this->parentAxisVis->Destroy(); - this->parentAxisVis.reset(); - } - - this->dirtyJointType = false; - this->dirtyAxis = false; - this->dirtyParentAxis = false; - - T::Destroy(); - } - - ///////////////////////////////////////////////// - template - void BaseJointVisual::SetAxis( - const ignition::math::Vector3d &_axis, - bool _useParentFrame) - { - this->axis = _axis; - this->useParentFrame = _useParentFrame; - this->dirtyAxis = true; - } - - ///////////////////////////////////////////////// - template - void BaseJointVisual::CreateAxis() - { - if (this->arrowVisual) - { - this->arrowVisual->Destroy(); - this->arrowVisual.reset(); - } - - this->arrowVisual = this->Scene()->CreateArrowVisual(); - this->arrowVisual->SetMaterial("Default/TransYellow"); - this->arrowVisual->SetLocalPosition(0, 0, 0); - this->arrowVisual->SetLocalRotation(0, 0, 0); - this->AddChild(this->arrowVisual); - - this->updateAxis = true; - this->ScaleToChild(); - } - - ///////////////////////////////////////////////// - template - void BaseJointVisual::SetParentAxis( - const ignition::math::Vector3d &_axis, - const std::string &_parentName, - bool _useParentFrame) - { - if (this->Type() != JointVisualType::JVT_REVOLUTE2 && - this->Type() != JointVisualType::JVT_UNIVERSAL) - { - ignlog << "Joint visual is not of type Revolute2 or " - << " Universal " - << " so the parent axis will not be shown\n"; - return; - } - - this->parentAxis = _axis; - this->parentAxisUseParentFrame = _useParentFrame; - this->jointParentName = _parentName; - this->dirtyParentAxis = true; - } - - ///////////////////////////////////////////////// - template - void BaseJointVisual::CreateParentAxis() - { - auto jointParentVis = this->Scene()->NodeByName(this->jointParentName); - if (jointParentVis == nullptr) - { - ignlog << "Joint parent with name " << this->jointParentName - << " does not exist" - << " so the parent axis will not be shown\n"; - return; - } - - if (this->parentAxisVis) - { - this->parentAxisVis->Destroy(); - this->parentAxisVis.reset(); - } - - this->parentAxisVis = this->Scene()->CreateJointVisual(); - jointParentVis->AddChild(this->parentAxisVis); - this->parentAxisVis->SetType(this->Type()); - this->parentAxisVis->SetAxis(this->parentAxis, - this->parentAxisUseParentFrame); - - this->updateParentAxis = true; - this->ScaleToChild(); - } - - ////////////////////////////////////////////////// - template - bool BaseJointVisual::UpdateAxis(const ignition::math::Vector3d &_axis, - bool _useParentFrame) - { - if (this->ArrowVisual() && this->HasParent()) - { - this->UpdateAxisImpl(this->ArrowVisual(), _axis, _useParentFrame); - return true; - } - - return false; - } - - ////////////////////////////////////////////////// - template - bool BaseJointVisual::UpdateParentAxis( - const ignition::math::Vector3d &_axis, - bool _useParentFrame) - { - if (this->ParentAxisVisual() && - this->ParentAxisVisual()->ArrowVisual() && - this->ParentAxisVisual()->HasParent()) - { - this->UpdateAxisImpl(this->ParentAxisVisual()->ArrowVisual(), - _axis, _useParentFrame); - return true; - } - - return false; - } - - ////////////////////////////////////////////////// - template - void BaseJointVisual::UpdateAxisImpl(ArrowVisualPtr _arrowVisual, - const ignition::math::Vector3d &_axis, - bool _useParentFrame) - { - // Get rotation to axis vector - ignition::math::Vector3d axisDir = _axis; - ignition::math::Vector3d u = axisDir.Normalize(); - ignition::math::Vector3d v = ignition::math::Vector3d::UnitZ; - double cosTheta = v.Dot(u); - double angle = acos(cosTheta); - ignition::math::Quaterniond quat; - // check the parallel case - if (ignition::math::equal(angle, IGN_PI)) - quat.Axis(u.Perpendicular(), angle); - else - quat.Axis((v.Cross(u)).Normalize(), angle); - _arrowVisual->SetLocalRotation(quat); - - if (_useParentFrame) - { - ignition::math::Pose3d parentInitPose = - this->Parent()->InitialLocalPose(); - - // get rotation of joint visual in model frame - ignition::math::Quaterniond quatFromModel = - (parentInitPose * this->LocalPose()).Rot(); - - // rotate arrow visual so that the axis vector applies to the model - // frame. - _arrowVisual->SetLocalRotation(quatFromModel.Inverse() * - _arrowVisual->LocalRotation()); - } - - _arrowVisual->ShowArrowRotation( - this->Type() == JointVisualType::JVT_REVOLUTE || - this->Type() == JointVisualType::JVT_REVOLUTE2 || - this->Type() == JointVisualType::JVT_UNIVERSAL || - this->Type() == JointVisualType::JVT_GEARBOX); - - if (this->axisVisual) - _arrowVisual->SetVisible(true); - else - return; - - // Don't change the visibility of joint child axis - if (this->ArrowVisual() != _arrowVisual) - return; - - // Hide existing arrow head if it overlaps with the axis - auto axisWorldRotation = _arrowVisual->WorldPose().Rot(); - auto jointWorldRotation = this->WorldPose().Rot(); - - this->axisVisual->ShowAxisHead(true); - _arrowVisual->ShowArrowShaft(true); - - auto axisWorld = axisWorldRotation * ignition::math::Vector3d::UnitZ; - if (axisWorld == jointWorldRotation * ignition::math::Vector3d::UnitX) - { - this->axisVisual->ShowAxisHead(0, false); - _arrowVisual->ShowArrowShaft(false); - } - else if (axisWorld == - jointWorldRotation * ignition::math::Vector3d::UnitY) - { - this->axisVisual->ShowAxisHead(1, false); - _arrowVisual->ShowArrowShaft(false); - } - else if (axisWorld == - jointWorldRotation * ignition::math::Vector3d::UnitZ) - { - this->axisVisual->ShowAxisHead(2, false); - _arrowVisual->ShowArrowShaft(false); - } - } - - ////////////////////////////////////////////////// - template - void BaseJointVisual::ScaleToChild() - { - if (!this->HasParent()) - return; - - // Joint visual is attached to the child's visual - VisualPtr parentVisual = - std::dynamic_pointer_cast(this->Parent()); - - if (parentVisual) - { - double childSize = - std::max(0.1, parentVisual->BoundingBox().Size().Length()); - this->scaleToChild = ignition::math::Vector3d(childSize * 0.2, - childSize * 0.2, childSize * 0.2); - this->SetLocalScale(this->scaleToChild); - if (this->ParentAxisVisual()) - this->ParentAxisVisual()->SetLocalScale(this->scaleToChild); - } - } - - ////////////////////////////////////////////////// - template - void BaseJointVisual::SetType(const JointVisualType _type) - { - this->jointVisualType = _type; - this->dirtyJointType = true; - } - - ////////////////////////////////////////////////// - template - ignition::math::Vector3d BaseJointVisual::Axis() const - { - return this->axis; - } - - ////////////////////////////////////////////////// - template - ignition::math::Vector3d BaseJointVisual::ParentAxis() const - { - return this->parentAxis; - } - - ////////////////////////////////////////////////// - template - JointVisualType BaseJointVisual::Type() const - { - return this->jointVisualType; - } - - ////////////////////////////////////////////////// - template - JointVisualPtr BaseJointVisual::ParentAxisVisual() const - { - return this->parentAxisVis; - } - - ////////////////////////////////////////////////// - template - ArrowVisualPtr BaseJointVisual::ArrowVisual() const - { - return this->arrowVisual; - } - - ////////////////////////////////////////////////// - template - void BaseJointVisual::SetVisible(bool _visible) - { - T::SetVisible(_visible); - - if (this->ArrowVisual()) - this->ArrowVisual()->SetVisible(_visible); - - if (this->Type() == JointVisualType::JVT_REVOLUTE2 || - this->Type() == JointVisualType::JVT_UNIVERSAL) - { - if (this->ParentAxisVisual()) - this->ParentAxisVisual()->SetVisible(_visible); - } - - if (this->axisVisual) - this->axisVisual->SetVisible(_visible); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseLidarVisual.hh b/include/ignition/rendering/base/BaseLidarVisual.hh index 4e0edb24d..39dc63d3f 100644 --- a/include/ignition/rendering/base/BaseLidarVisual.hh +++ b/include/ignition/rendering/base/BaseLidarVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,527 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_BASELIDARVISUAL_HH_ -#define IGNITION_RENDERING_BASELIDARVISUAL_HH_ + */ -#include - -#include "ignition/rendering/LidarVisual.hh" -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \brief Base implementation of a Lidar Visual - template - class BaseLidarVisual : - public virtual LidarVisual, - public virtual T - { - // Documentation inherited - protected: BaseLidarVisual(); - - // Documentation inherited - public: virtual ~BaseLidarVisual(); - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void ClearPoints() override; - - // Documentation inherited - public: virtual void SetPoints( - const std::vector &_points) override; - - // Documentation inherited - public: virtual void SetPoints(const std::vector &_points, - const std::vector &_colors) - override; - - // Documentation inherited - public: virtual void Update() override; - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void SetMinVerticalAngle( - double _minVerticalAngle) override; - - // Documentation inherited - public: virtual double MinVerticalAngle() const override; - - // Documentation inherited - public: virtual void SetMaxVerticalAngle( - double _maxVerticalAngle) override; - - // Documentation inherited - public: virtual double MaxVerticalAngle() const override; - - // Documentation inherited - public: virtual void SetMinHorizontalAngle( - double _minHorizontalAngle) override; - - // Documentation inherited - public: virtual double MinHorizontalAngle() const override; - - // Documentation inherited - public: virtual void SetMaxHorizontalAngle( - double _maxHorizontalAngle) override; - - // Documentation inherited - public: virtual double MaxHorizontalAngle() const override; - - // Documentation inherited - public: virtual void SetVerticalRayCount( - unsigned int _verticalRayCount) override; - - // Documentation inherited - public: virtual unsigned int VerticalRayCount() const override; - - // Documentation inherited - public: virtual void SetHorizontalRayCount( - unsigned int _horizontalRayCount) override; - - // Documentation inherited - public: virtual unsigned int HorizontalRayCount() const override; - - // Documentation inherited - public: virtual void SetMinRange(double _minRange) override; - - // Documentation inherited - public: virtual double MinRange() const override; - - // Documentation inherited - public: virtual void SetMaxRange(double _maxRange) override; - - // Documentation inherited - public: virtual double MaxRange() const override; - - // Documentation inherited - public: virtual void SetOffset( - const ignition::math::Pose3d _offset) override; - - // Documentation inherited - public: virtual ignition::math::Pose3d Offset() const override; - - // Documentation inherited - public: virtual unsigned int PointCount() const override; - - // Documentation inherited - public: virtual std::vector Points() const override; - - // Documentation inherited - public: virtual void SetType(const LidarVisualType _type) override; - - // Documentation inherited - public: virtual LidarVisualType Type() const override; - - // Documentation inherited - public: virtual void SetSize(double _size) override; - - // Documentation inherited - public: virtual double Size() const override; - - /// \brief Create predefined materials for lidar visual - public: virtual void CreateMaterials(); - - // Documentation inherited - public: virtual void SetDisplayNonHitting(bool _display) override; - - // Documentation inherited - public: virtual bool DisplayNonHitting() const override; - - /// \brief Vertical minimal angle - protected: double minVerticalAngle = 0; - - /// \brief Vertical maximum angle - protected: double maxVerticalAngle = 0; - - /// \brief Vertical laser count - protected: unsigned int verticalCount = 1u; - - /// \brief Angle between two vertical rays - protected: double verticalAngleStep = 0; - - /// \brief Horizontal minimal angle - protected: double minHorizontalAngle = 0; - - /// \brief Horizontal maximum angle - protected: double maxHorizontalAngle = 0; - - /// \brief Horizontal laser count - protected: unsigned int horizontalCount = 1u; - - /// \brief Angle between two horizontal rays - protected: double horizontalAngleStep = 0; - - /// \brief Minimum Range - protected: double minRange = 0; - - /// \brief Maximum Range - protected: double maxRange = 0; - - /// \brief Option to display non-hitting rays - protected: bool displayNonHitting = true; - - /// \brief Offset of visual - protected: ignition::math::Pose3d offset = ignition::math::Pose3d::Zero; - - /// \brief Type of lidar visualisation - protected: LidarVisualType lidarVisualType = - LidarVisualType::LVT_TRIANGLE_STRIPS; - - /// \brief Size of lidar visualisation - protected: double size = 1.0; - }; - - ///////////////////////////////////////////////// - // BaseLidarVisual - ///////////////////////////////////////////////// - template - BaseLidarVisual::BaseLidarVisual() - { - } - - ///////////////////////////////////////////////// - template - BaseLidarVisual::~BaseLidarVisual() - { - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::PreRender() - { - T::PreRender(); - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::Destroy() - { - T::Destroy(); - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::ClearPoints() - { - // no op - } - - ///////////////////////////////////////////////// - template - unsigned int BaseLidarVisual::PointCount() const - { - return 0u; - } - - ///////////////////////////////////////////////// - template - std::vector BaseLidarVisual::Points() const - { - std::vector d; - return d; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::Update() - { - // no op - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetPoints(const std::vector &) - { - // no op - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetPoints(const std::vector &, - const std::vector &) - { - // no op - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::Init() - { - T::Init(); - this->CreateMaterials(); - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetMinVerticalAngle( - double _minVerticalAngle) - { - this->minVerticalAngle = _minVerticalAngle; - } - - ///////////////////////////////////////////////// - template - double BaseLidarVisual::MinVerticalAngle() const - { - return this->minVerticalAngle; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetMaxVerticalAngle( - double _maxVerticalAngle) - { - this->maxVerticalAngle = _maxVerticalAngle; - } - - ///////////////////////////////////////////////// - template - double BaseLidarVisual::MaxVerticalAngle() const - { - return this->maxVerticalAngle; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetVerticalRayCount( - unsigned int _verticalRayCount) - { - if (_verticalRayCount == 0) - { - ignwarn << "Cannot have zero vertical rays. Setting value to 1." - << std::endl; - this->verticalCount = 1; - } - else - { - this->verticalCount = _verticalRayCount; - } - } - - ///////////////////////////////////////////////// - template - unsigned int BaseLidarVisual::VerticalRayCount() const - { - return this->verticalCount; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetMinHorizontalAngle( - double _minHorizontalAngle) - { - this->minHorizontalAngle = _minHorizontalAngle; - } - - ///////////////////////////////////////////////// - template - double BaseLidarVisual::MinHorizontalAngle() const - { - return this->minHorizontalAngle; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetMaxHorizontalAngle( - double _maxHorizontalAngle) - { - this->maxHorizontalAngle = _maxHorizontalAngle; - } - - ///////////////////////////////////////////////// - template - double BaseLidarVisual::MaxHorizontalAngle() const - { - return this->maxHorizontalAngle; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetHorizontalRayCount( - unsigned int _horizontalRayCount) - { - if (_horizontalRayCount == 0) - { - ignwarn << "Cannot have zero horizontal rays. Setting value to 1." - << std::endl; - this->horizontalCount = 1u; - } - else - { - this->horizontalCount = _horizontalRayCount; - } - } - - ///////////////////////////////////////////////// - template - unsigned int BaseLidarVisual::HorizontalRayCount() const - { - return this->horizontalCount; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetMinRange(double _minRange) - { - this->minRange = _minRange; - } - - ///////////////////////////////////////////////// - template - double BaseLidarVisual::MinRange() const - { - return this->minRange; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetMaxRange(double _maxRange) - { - this->maxRange = _maxRange; - } - - ///////////////////////////////////////////////// - template - double BaseLidarVisual::MaxRange() const - { - return this->maxRange; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetOffset(const ignition::math::Pose3d _offset) - { - this->offset = _offset; - } - - ///////////////////////////////////////////////// - template - ignition::math::Pose3d BaseLidarVisual::Offset() const - { - return this->offset; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetType(const LidarVisualType _type) - { - this->lidarVisualType = _type; - } - - ///////////////////////////////////////////////// - template - LidarVisualType BaseLidarVisual::Type() const - { - return this->lidarVisualType; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetSize(double _size) - { - this->size = _size; - } - - ///////////////////////////////////////////////// - template - double BaseLidarVisual::Size() const - { - return this->size; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::SetDisplayNonHitting(bool _display) - { - this->displayNonHitting = _display; - } - - ///////////////////////////////////////////////// - template - bool BaseLidarVisual::DisplayNonHitting() const - { - return this->displayNonHitting; - } - - ///////////////////////////////////////////////// - template - void BaseLidarVisual::CreateMaterials() - { - MaterialPtr mtl; - - if (!this->Scene()->MaterialRegistered("Lidar/BlueStrips")) - { - mtl = this->Scene()->CreateMaterial("Lidar/BlueStrips"); - mtl->SetAmbient(0.0, 0.0, 1.0); - mtl->SetDiffuse(0.0, 0.0, 1.0); - mtl->SetEmissive(0.0, 0.0, 1.0); - mtl->SetTransparency(0.4); - mtl->SetCastShadows(false); - mtl->SetReceiveShadows(false); - mtl->SetLightingEnabled(false); - mtl->SetMetalness(0.0f); - mtl->SetReflectivity(0.0); - } - - if (!this->Scene()->MaterialRegistered("Lidar/LightBlueStrips")) - { - mtl = this->Scene()->CreateMaterial("Lidar/LightBlueStrips"); - mtl->SetAmbient(0.0, 0.0, 1.0); - mtl->SetDiffuse(0.0, 0.0, 1.0); - mtl->SetEmissive(0.0, 0.0, 1.0); - mtl->SetTransparency(0.8); - mtl->SetCastShadows(false); - mtl->SetReceiveShadows(false); - mtl->SetLightingEnabled(false); - mtl->SetMetalness(0.0f); - mtl->SetReflectivity(0.0); - } - - if (!this->Scene()->MaterialRegistered("Lidar/TransBlack")) - { - mtl = this->Scene()->CreateMaterial("Lidar/TransBlack"); - mtl->SetAmbient(0.0, 0.0, 0.0); - mtl->SetDiffuse(0.0, 0.0, 0.0); - mtl->SetEmissive(0.0, 0.0, 0.0); - mtl->SetTransparency(0.4); - mtl->SetCastShadows(false); - mtl->SetReceiveShadows(false); - mtl->SetLightingEnabled(false); - mtl->SetMetalness(0.5f); - mtl->SetReflectivity(0.2); - } - - if (!this->Scene()->MaterialRegistered("Lidar/BlueRay")) - { - mtl = this->Scene()->CreateMaterial("Lidar/BlueRay"); - mtl->SetAmbient(0.0, 0.0, 1.0); - mtl->SetDiffuse(0.0, 0.0, 1.0); - mtl->SetEmissive(0.0, 0.0, 1.0); - mtl->SetSpecular(0.0, 0.0, 1.0); - mtl->SetTransparency(0.0); - mtl->SetCastShadows(false); - mtl->SetReceiveShadows(false); - mtl->SetLightingEnabled(false); - mtl->SetMetalness(0.1f); - mtl->SetReflectivity(0.2); - } - return; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseLight.hh b/include/ignition/rendering/base/BaseLight.hh index 540f0a9a8..4aab8ac8c 100644 --- a/include/ignition/rendering/base/BaseLight.hh +++ b/include/ignition/rendering/base/BaseLight.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,236 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASELIGHT_HH_ -#define IGNITION_RENDERING_BASE_BASELIGHT_HH_ -#include "ignition/rendering/Light.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseLight : - public virtual Light, - public virtual T - { - protected: BaseLight(); - - public: virtual ~BaseLight(); - - // Documentation inherited - public: virtual void SetDiffuseColor(double _r, double _g, double _b, - double _a = 1.0); - - // Documentation inherited. - public: virtual void SetDiffuseColor(const math::Color &_color) = 0; - - // Documentation inherited. - public: virtual void SetSpecularColor(double _r, double _g, double _b, - double _a = 1.0); - - // Documentation inherited. - public: virtual void SetSpecularColor(const math::Color &_color) = 0; - - // Documentation inherited. - public: virtual void SetAttenuationConstant(double _value) = 0; - - // Documentation inherited. - public: virtual void SetAttenuationLinear(double _value) = 0; - - // Documentation inherited. - public: virtual void SetAttenuationQuadratic(double _value) = 0; - - // Documentation inherited. - public: virtual void SetAttenuationRange(double _range) = 0; - - // Documentation inherited. - public: virtual void SetCastShadows(bool _castShadows) = 0; - - // Documentation inherited. - protected: virtual void Reset(); - }; - - template - class BaseDirectionalLight : - public virtual DirectionalLight, - public virtual T - { - protected: BaseDirectionalLight(); - - public: virtual ~BaseDirectionalLight(); - - public: virtual void SetDirection(double _x, double _y, double _z); - - public: virtual void SetDirection(const math::Vector3d &_dir) = 0; - - protected: virtual void Reset(); - }; - - template - class BasePointLight : - public virtual PointLight, - public virtual T - { - protected: BasePointLight(); - - public: virtual ~BasePointLight(); - }; - - template - class BaseSpotLight : - public virtual SpotLight, - public virtual T - { - protected: BaseSpotLight(); - - public: virtual ~BaseSpotLight(); - - public: virtual void SetDirection(double _x, double _y, double _z); - - public: virtual void SetDirection(const math::Vector3d &_dir) = 0; - - public: virtual void SetInnerAngle(double _radians); - - public: virtual void SetInnerAngle(const math::Angle &_angle) = 0; - - public: virtual void SetOuterAngle(double _radians); - - public: virtual void SetOuterAngle(const math::Angle &_angle) = 0; - - public: virtual void SetFalloff(double _falloff) = 0; - - protected: virtual void Reset(); - }; - - ////////////////////////////////////////////////// - template - BaseLight::BaseLight() - { - } - - ////////////////////////////////////////////////// - template - BaseLight::~BaseLight() - { - } - - ////////////////////////////////////////////////// - template - void BaseLight::SetDiffuseColor(double _r, double _g, double _b, - double _a) - { - this->SetDiffuseColor(math::Color(_r, _g, _b, _a)); - } - - ////////////////////////////////////////////////// - template - void BaseLight::SetSpecularColor(double _r, double _g, double _b, - double _a) - { - this->SetSpecularColor(math::Color(_r, _g, _b, _a)); - } - - ////////////////////////////////////////////////// - template - void BaseLight::Reset() - { - this->SetDiffuseColor(math::Color::White); - this->SetSpecularColor(math::Color::White); - this->SetAttenuationConstant(1); - this->SetAttenuationLinear(0); - this->SetAttenuationQuadratic(0); - this->SetAttenuationRange(100); - this->SetCastShadows(true); - this->SetIntensity(1.0); - } - - ////////////////////////////////////////////////// - template - BaseDirectionalLight::BaseDirectionalLight() - { - } - - ////////////////////////////////////////////////// - template - BaseDirectionalLight::~BaseDirectionalLight() - { - } - - ////////////////////////////////////////////////// - template - void BaseDirectionalLight::SetDirection(double _x, double _y, double _z) - { - this->SetDirection(math::Vector3d(_x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseDirectionalLight::Reset() - { - T::Reset(); - this->SetDirection(0, 0, -1); - } - - ////////////////////////////////////////////////// - template - BasePointLight::BasePointLight() - { - } - - ////////////////////////////////////////////////// - template - BasePointLight::~BasePointLight() - { - } - - ////////////////////////////////////////////////// - template - BaseSpotLight::BaseSpotLight() - { - } - - ////////////////////////////////////////////////// - template - BaseSpotLight::~BaseSpotLight() - { - } - - ////////////////////////////////////////////////// - template - void BaseSpotLight::SetDirection(double _x, double _y, double _z) - { - this->SetDirection(math::Vector3d(_x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseSpotLight::SetInnerAngle(double _radians) - { - this->SetInnerAngle(math::Angle(_radians)); - } - - ////////////////////////////////////////////////// - template - void BaseSpotLight::SetOuterAngle(double _radians) - { - this->SetOuterAngle(math::Angle(_radians)); - } - - ////////////////////////////////////////////////// - template - void BaseSpotLight::Reset() - { - T::Reset(); - this->SetDirection(0, 0, -1); - this->SetInnerAngle(IGN_PI / 4.5); - this->SetOuterAngle(IGN_PI / 4.0); - this->SetFalloff(1.0); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseLightVisual.hh b/include/ignition/rendering/base/BaseLightVisual.hh index d36e05280..583416a6c 100644 --- a/include/ignition/rendering/base/BaseLightVisual.hh +++ b/include/ignition/rendering/base/BaseLightVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,262 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASELIGHTVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASELIGHTVISUAL_HH_ -#include - -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/LightVisual.hh" -#include "ignition/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of a light visual - template - class BaseLightVisual : - public virtual LightVisual, - public virtual T - { - /// \brief Constructor - protected: BaseLightVisual(); - - /// \brief Destructor - public: virtual ~BaseLightVisual(); - - // Documentation inherited. - protected: virtual void Init() override; - - // Documentation inherited. - protected: virtual void PreRender() override; - - // Documentation inherited - public: virtual void SetType(LightVisualType _type) override; - - // Documentation inherited - public: virtual void SetInnerAngle(double _innerAngle) override; - - // Documentation inherited - public: virtual double InnerAngle() override; - - // Documentation inherited - public: virtual void SetOuterAngle(double _innerAngle) override; - - // Documentation inherited - public: virtual double OuterAngle() override; - - /// \brief Draw the light visual using dynamic renderables - public: std::vector CreateVisualLines(); - - // Documentation inherited - public: virtual LightVisualType Type() override; - - /// \brief Type of light visual - protected: LightVisualType type = LightVisualType::LVT_EMPTY; - - /// \brief Inner angle for spot lights - protected: double innerAngle = 0; - - /// \brief Outer angle for spot lights - protected: double outerAngle = 0; - - /// \brief Flag to indicate light properties have changed - protected: bool dirtyLightVisual = false; - }; - - ////////////////////////////////////////////////// - template - BaseLightVisual::BaseLightVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseLightVisual::~BaseLightVisual() - { - } - - ///////////////////////////////////////////////// - template - void BaseLightVisual::PreRender() - { - T::PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseLightVisual::Init() - { - T::Init(); - } - - ////////////////////////////////////////////////// - template - void BaseLightVisual::SetType(LightVisualType _type) - { - this->type = _type; - this->dirtyLightVisual = true; - } - - ////////////////////////////////////////////////// - template - LightVisualType BaseLightVisual::Type() - { - return this->type; - } - - ////////////////////////////////////////////////// - template - void BaseLightVisual::SetInnerAngle(double _innerAngle) - { - this->innerAngle = _innerAngle; - this->dirtyLightVisual = true; - } - - ////////////////////////////////////////////////// - template - double BaseLightVisual::InnerAngle() - { - return this->innerAngle; - } - - ////////////////////////////////////////////////// - template - void BaseLightVisual::SetOuterAngle(double _outerAngle) - { - this->outerAngle = _outerAngle; - this->dirtyLightVisual = true; - } - - ////////////////////////////////////////////////// - template - double BaseLightVisual::OuterAngle() - { - return this->outerAngle; - } - - template - std::vector - BaseLightVisual::CreateVisualLines() - { - std::vector positions; - - if (this->type == LightVisualType::LVT_DIRECTIONAL) - { - float s = 0.5; - positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); - positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); - - positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); - positions.emplace_back(ignition::math::Vector3d(s, s, 0)); - - positions.emplace_back(ignition::math::Vector3d(s, s, 0)); - positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); - - positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); - positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); - - positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); - positions.emplace_back(ignition::math::Vector3d(0, 0, -s)); - } - else if (this->type == LightVisualType::LVT_POINT) - { - float s = 0.1f; - positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); - positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); - - positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); - positions.emplace_back(ignition::math::Vector3d(s, s, 0)); - - positions.emplace_back(ignition::math::Vector3d(s, s, 0)); - positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); - - positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); - positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); - - positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); - positions.emplace_back(ignition::math::Vector3d(0, 0, s)); - - positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); - positions.emplace_back(ignition::math::Vector3d(0, 0, s)); - - positions.emplace_back(ignition::math::Vector3d(s, s, 0)); - positions.emplace_back(ignition::math::Vector3d(0, 0, s)); - - positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); - positions.emplace_back(ignition::math::Vector3d(0, 0, s)); - - positions.emplace_back(ignition::math::Vector3d(-s, -s, 0)); - positions.emplace_back(ignition::math::Vector3d(0, 0, -s)); - - positions.emplace_back(ignition::math::Vector3d(-s, s, 0)); - positions.emplace_back(ignition::math::Vector3d(0, 0, -s)); - - positions.emplace_back(ignition::math::Vector3d(s, s, 0)); - positions.emplace_back(ignition::math::Vector3d(0, 0, -s)); - - positions.emplace_back(ignition::math::Vector3d(s, -s, 0)); - positions.emplace_back(ignition::math::Vector3d(0, 0, -s)); - } - else if (this->type == LightVisualType::LVT_SPOT) - { - double angles[2]; - double range = 0.2; - angles[0] = range * tan(outerAngle / 2.0); - angles[1] = range * tan(innerAngle / 2.0); - - unsigned int i = 0; - positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); - positions.emplace_back( - ignition::math::Vector3d(angles[i], angles[i], -range)); - - for (i = 0; i < 2; i++) - { - positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); - positions.emplace_back(ignition::math::Vector3d( - angles[i], angles[i], -range)); - - positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); - positions.emplace_back(ignition::math::Vector3d( - -angles[i], -angles[i], -range)); - - positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); - positions.emplace_back(ignition::math::Vector3d( - angles[i], -angles[i], -range)); - - positions.emplace_back(ignition::math::Vector3d(0, 0, 0)); - positions.emplace_back(ignition::math::Vector3d( - -angles[i], angles[i], -range)); - - positions.emplace_back(ignition::math::Vector3d( - angles[i], angles[i], -range)); - positions.emplace_back(ignition::math::Vector3d( - -angles[i], angles[i], -range)); - - positions.emplace_back(ignition::math::Vector3d( - -angles[i], angles[i], -range)); - positions.emplace_back(ignition::math::Vector3d( - -angles[i], -angles[i], -range)); - - positions.emplace_back(ignition::math::Vector3d( - -angles[i], -angles[i], -range)); - positions.emplace_back(ignition::math::Vector3d( - angles[i], -angles[i], -range)); - - positions.emplace_back(ignition::math::Vector3d( - angles[i], -angles[i], -range)); - positions.emplace_back(ignition::math::Vector3d( - angles[i], angles[i], -range)); - } - } - return positions; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseMarker.hh b/include/ignition/rendering/base/BaseMarker.hh index 4de3193ba..bcff5773d 100644 --- a/include/ignition/rendering/base/BaseMarker.hh +++ b/include/ignition/rendering/base/BaseMarker.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,221 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_BASEMARKER_HH_ -#define IGNITION_RENDERING_BASEMARKER_HH_ + */ -#include - -#include "ignition/rendering/Marker.hh" -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \brief Base implementation of a Marker geometry - template - class BaseMarker : - public virtual Marker, - public virtual T - { - /// \brief Constructor. - protected: BaseMarker(); - - /// \brief Destructor. - public: virtual ~BaseMarker(); - - /// \brief PreRender function - public: virtual void PreRender() override; - - /// \brief Destroy function - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void SetLifetime(const - std::chrono::steady_clock::duration &_lifetime) override; - - // Documentation inherited - public: virtual std::chrono::steady_clock::duration Lifetime() - const override; - - // Documentation inherited - public: virtual void SetType(const MarkerType _markerType) override; - - // Documentation inherited - public: virtual MarkerType Type() const override; - - // Documentation inherited - public: virtual void SetSize(double _size) override; - - // Documentation inherited - public: virtual double Size() const override; - - // Documentation inherited - public: virtual void SetLayer(int32_t _layer) override; - - // Documentation inherited - public: virtual int32_t Layer() const override; - - // Documentation inherited - public: virtual void ClearPoints() override; - - // Documentation inherited - public: virtual void AddPoint(double _x, - double _y, double _z, - const ignition::math::Color &_color) override; - - // Documentation inherited - public: virtual void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color) override; - - // Documentation inherited - public: virtual void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value) override; - - /// \brief Life time of a marker - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: std::chrono::steady_clock::duration lifetime = - std::chrono::steady_clock::duration::zero(); - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Layer at which the marker will reside - protected: int32_t layer = 0; - - /// \brief Flag to indicate if marker needs to be updated - protected: bool markerDirty = false; - - /// \brief Marker type - protected: MarkerType markerType = - ignition::rendering::MarkerType::MT_NONE; - - /// \brief Marker size - protected: double size = 1.0; - }; - - ///////////////////////////////////////////////// - // BaseMarker - ///////////////////////////////////////////////// - template - BaseMarker::BaseMarker() - { - } - - ///////////////////////////////////////////////// - template - BaseMarker::~BaseMarker() - { - } - - ///////////////////////////////////////////////// - template - void BaseMarker::SetLifetime( - const std::chrono::steady_clock::duration &_lifetime) - { - this->lifetime = _lifetime; - this->markerDirty = true; - } - - ///////////////////////////////////////////////// - template - std::chrono::steady_clock::duration BaseMarker::Lifetime() const - { - return this->lifetime; - } - - ///////////////////////////////////////////////// - template - void BaseMarker::SetLayer(int32_t _layer) - { - this->layer = _layer; - this->markerDirty = true; - } - - ///////////////////////////////////////////////// - template - int32_t BaseMarker::Layer() const - { - return this->layer; - } - - ///////////////////////////////////////////////// - template - void BaseMarker::SetType(const MarkerType _markerType) - { - this->markerType = _markerType; - this->markerDirty = true; - } - - ///////////////////////////////////////////////// - template - MarkerType BaseMarker::Type() const - { - return this->markerType; - } - - ///////////////////////////////////////////////// - template - void BaseMarker::SetSize(double _size) - { - this->size = _size; - this->markerDirty = true; - } - - ///////////////////////////////////////////////// - template - double BaseMarker::Size() const - { - return this->size; - } - - ///////////////////////////////////////////////// - template - void BaseMarker::PreRender() - { - T::PreRender(); - } - - ///////////////////////////////////////////////// - template - void BaseMarker::Destroy() - { - T::Destroy(); - } - - ///////////////////////////////////////////////// - template - void BaseMarker::ClearPoints() - { - // no op - } - - ///////////////////////////////////////////////// - template - void BaseMarker::AddPoint(const ignition::math::Vector3d &, - const ignition::math::Color &) - { - // no op - } - - ///////////////////////////////////////////////// - template - void BaseMarker::AddPoint(double _x, double _y, double _z, - const ignition::math::Color &_color) - { - this->AddPoint(ignition::math::Vector3d(_x, _y, _z), _color); - } - - ///////////////////////////////////////////////// - template - void BaseMarker::SetPoint(unsigned int, - const ignition::math::Vector3d &) - { - // no op - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseMaterial.hh b/include/ignition/rendering/base/BaseMaterial.hh index 11bb6a11a..449fbe372 100644 --- a/include/ignition/rendering/base/BaseMaterial.hh +++ b/include/ignition/rendering/base/BaseMaterial.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,1052 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEMATERIAL_HH_ -#define IGNITION_RENDERING_BASE_BASEMATERIAL_HH_ -#include - -#include "ignition/common/Console.hh" - -#include "ignition/rendering/Material.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/ShaderType.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Default pbr material properties - static const common::Pbr kDefaultPbr; - - template - class BaseMaterial : - public virtual Material, - public virtual T - { - protected: BaseMaterial(); - - public: virtual ~BaseMaterial(); - - // Documentation inherited - public: virtual MaterialPtr Clone(const std::string &_name = "") const - override; - - // Documentation inherited - public: virtual void SetAmbient(const double _r, const double _g, - const double _b, const double _a = 1.0) override; - - // Documentation inherited - public: virtual void SetAmbient(const math::Color &_color) override; - - // Documentation inherited - public: virtual void SetDiffuse(const double _r, const double _g, - const double _b, const double _a = 1.0) override; - - // Documentation inherited - public: virtual void SetDiffuse(const math::Color &_color) override; - - // Documentation inherited - public: virtual void SetSpecular(const double _r, const double _g, - const double _b, const double _a = 1.0) override; - - // Documentation inherited - public: virtual void SetSpecular(const math::Color &_color) override; - - // Documentation inherited - public: virtual void SetEmissive(const double _r, const double _g, - const double _b, const double _a = 1.0) override; - - // Documentation inherited - public: virtual void SetEmissive(const math::Color &_color) override; - - // Documentation inherited - public: virtual void SetTransparency(const double _transparency) override; - - // Documentation inherited - public: virtual void SetAlphaFromTexture(bool _enabled, - double _alpha = 0.5, bool _twoSided = true) override; - - // Documentation inherited - public: bool TextureAlphaEnabled() const override; - - // Documentation inherited - public: double AlphaThreshold() const override; - - // Documentation inherited - public: bool TwoSidedEnabled() const override; - - // Documentation inherited - public: virtual void SetShininess(const double _shininess) override; - - // Documentation inherited - public: virtual void SetReflectivity(const double _reflectivity) override; - - // Documentation inherited - public: virtual void SetCastShadows(const bool _castShadows) override; - - // Documentation inherited - public: virtual void SetReceiveShadows(const bool _receiveShadows) - override; - - // Documentation inherited - public: virtual void SetReflectionEnabled(const bool _enabled) override; - - // Documentation inherited - public: virtual void SetLightingEnabled(const bool _enabled) override; - - // Documentation inherited. - public: virtual void SetDepthCheckEnabled(bool _enabled) override; - - // Documentation inherited. - public: virtual void SetDepthWriteEnabled(bool _enabled) override; - - // Documentation inherited - public: virtual math::Color Ambient() const override; - - // Documentation inherited - public: virtual math::Color Diffuse() const override; - - // Documentation inherited - public: virtual math::Color Specular() const override; - - // Documentation inherited - public: virtual math::Color Emissive() const override; - - // Documentation inherited - public: virtual double Transparency() const override; - - // Documentation inherited - public: virtual double Reflectivity() const override; - - // Documentation inherited - public: virtual double Shininess() const override; - - // Documentation inherited - public: virtual bool CastShadows() const override; - - // Documentation inherited - public: virtual bool ReceiveShadows() const override; - - // Documentation inherited - public: virtual bool LightingEnabled() const override; - - // Documentation inherited - public: virtual bool DepthCheckEnabled() const override; - - // Documentation inherited - public: virtual bool DepthWriteEnabled() const override; - - // Documentation inherited - public: virtual bool ReflectionEnabled() const override; - - // Documentation inherited - public: virtual bool HasTexture() const override; - - // Documentation inherited - public: virtual std::string Texture() const override; - - // Documentation inherited - public: virtual void SetTexture(const std::string &_texture) override; - - // Documentation inherited - public: virtual void ClearTexture() override; - - // Documentation inherited - public: virtual bool HasNormalMap() const override; - - // Documentation inherited - public: virtual std::string NormalMap() const override; - - // Documentation inherited - public: virtual void SetNormalMap(const std::string &_normalMap) - override; - - // Documentation inherited - public: virtual void ClearNormalMap() override; - - // Documentation inherited - public: virtual bool HasRoughnessMap() const override; - - // Documentation inherited - public: virtual std::string RoughnessMap() const override; - - // Documentation inherited - public: virtual void SetRoughnessMap(const std::string &_roughnessMap) - override; - - // Documentation inherited - public: virtual void ClearRoughnessMap() override; - - // Documentation inherited - public: virtual bool HasMetalnessMap() const override; - - // Documentation inherited - public: virtual std::string MetalnessMap() const override; - - // Documentation inherited - public: virtual void SetMetalnessMap(const std::string &_metalnessMap) - override; - - // Documentation inherited - public: virtual void ClearMetalnessMap() override; - - // Documentation inherited - public: virtual bool HasEnvironmentMap() const override; - - // Documentation inherited - public: virtual std::string EnvironmentMap() const override; - - // Documentation inherited - public: virtual void SetEnvironmentMap(const std::string &_metalnessMap) - override; - - // Documentation inherited - public: virtual void ClearEnvironmentMap() override; - - // Documentation inherited - public: virtual bool HasEmissiveMap() const override; - - // Documentation inherited - public: virtual std::string EmissiveMap() const override; - - // Documentation inherited - public: virtual void SetEmissiveMap(const std::string &_emissiveMap) - override; - - // Documentation inherited - public: virtual void ClearEmissiveMap() override; - - // Documentation inherited - public: virtual bool HasLightMap() const override; - - // Documentation inherited - public: virtual std::string LightMap() const override; - - // Documentation inherited - public: virtual unsigned int LightMapTexCoordSet() const override; - - // Documentation inherited - public: virtual void SetLightMap(const std::string &_lightMap, - unsigned int _uvSet = 0u) override; - - // Documentation inherited - public: virtual void ClearLightMap() override; - - // Documentation inherited - public: virtual void SetRenderOrder(const float _renderOrder) override; - - // Documentation inherited - public: virtual float RenderOrder() const override; - - // Documentation inherited - public: virtual void SetRoughness(const float _roughness) override; - - // Documentation inherited - public: virtual float Roughness() const override; - - // Documentation inherited - public: virtual void SetMetalness(const float _metalness) override; - - // Documentation inherited - public: virtual float Metalness() const override; - - // Documentation inherited - public: virtual MaterialType Type() const override; - - public: virtual void SetShaderType(enum ShaderType _type) override - { - (void)_type; - // no op - } - - // Documentation inherited - public: virtual enum ShaderType ShaderType() const override - { - return ST_PIXEL; - } - - // Documentation inherited. - // \sa Material::SetDepthMaterial() - public: virtual void SetDepthMaterial(const double far, - const double near) override; - - // Documentation inherited. - // \sa Material::VertexShader() const - public: virtual std::string VertexShader() const override; - - // Documentation inherited. - // \sa Material::VertexShaderParams() - public: virtual ShaderParamsPtr VertexShaderParams() override; - - // Documentation inherited. - // \sa Material::SetVertexShader(const std::string &) - public: virtual void SetVertexShader(const std::string &_path) override; - - // Documentation inherited. - // \sa Material::FragmentShader() const - public: virtual std::string FragmentShader() const override; - - // Documentation inherited. - // \sa Material::FragmentShaderParams() - public: virtual ShaderParamsPtr FragmentShaderParams() override; - - // Documentation inherited. - // \sa Material::SetFragmentShader(const std::string &) - public: virtual void SetFragmentShader(const std::string &_path) override; - - // Documentation inherited. - public: virtual void CopyFrom(ConstMaterialPtr _material) override; - - // Documentation inherited. - public: virtual void CopyFrom(const common::Material &_material) override; - - // Documentation inherited. - public: virtual void PreRender() override; - - protected: virtual void Reset(); - - /// \brief Ambient color - protected: math::Color ambient; - - /// \brief Diffuse color - protected: math::Color diffuse; - - /// \brief Specular color - protected: math::Color specular; - - /// \brief Emissive color - protected: math::Color emissive; - - /// \brief Transparent. 1: fully transparent, 0: opaque - protected: double transparency = 0.0; - - /// \brief Enable alpha channel based texture transparency - protected: bool textureAlphaEnabled = false; - - /// \brief Threshold for alpha channel rejection - protected: double alphaThreshold = 0.5; - - /// \brief Enable two sided rendering - protected: bool twoSidedEnabled = false; - - /// \brief Material render order - protected: double renderOrder = 0.0; - - /// \brief Shininess factor - protected: double shininess = 0.0; - - /// \brief Reflectivity - protected: double reflectivity = 0.0; - - /// \brief Flag to indicate if dynamic lighting is enabled - protected: bool lightingEnabled = false; - - /// \brief Flag to indicate if depth buffer checking is enabled - protected: bool depthCheckEnabled = true; - - /// \brief Flag to indicate if depth buffer writing is enabled - protected: bool depthWriteEnabled = true; - - /// \brief Flag to indicate if reflection is enabled - protected: bool reflectionEnabled = false; - - /// \brief True if material receives shadows - protected: bool receiveShadows = true; - - /// \brief Set to true to enable object with this material to cast shadows - protected: bool castShadows = true; - }; - - ////////////////////////////////////////////////// - template - BaseMaterial::BaseMaterial() - { - } - - ////////////////////////////////////////////////// - template - BaseMaterial::~BaseMaterial() - { - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetAmbient(const double _r, const double _g, - const double _b, const double _a) - { - this->SetAmbient(math::Color(_r, _g, _b, _a)); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetAmbient(const math::Color &_color) - { - this->ambient = _color; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetDiffuse(const double _r, const double _g, - const double _b, const double _a) - { - this->SetDiffuse(math::Color(_r, _g, _b, _a)); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetDiffuse(const math::Color &_color) - { - this->diffuse = _color; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetSpecular(const double _r, const double _g, - const double _b, const double _a) - { - this->SetSpecular(math::Color(_r, _g, _b, _a)); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetSpecular(const math::Color &_color) - { - this->specular = _color; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetEmissive(const double _r, const double _g, - const double _b, const double _a) - { - this->SetEmissive(math::Color(_r, _g, _b, _a)); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetEmissive(const math::Color &_color) - { - this->emissive = _color; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetShininess(const double _shininess) - { - this->shininess = _shininess; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetTransparency(const double _transparency) - { - this->transparency = _transparency; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetAlphaFromTexture(bool _enabled, double _alpha, - bool _twoSided) - { - this->textureAlphaEnabled = _enabled; - this->alphaThreshold = _alpha; - this->twoSidedEnabled = _twoSided; - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::TextureAlphaEnabled() const - { - return this->textureAlphaEnabled; - } - - ////////////////////////////////////////////////// - template - double BaseMaterial::AlphaThreshold() const - { - return this->alphaThreshold; - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::TwoSidedEnabled() const - { - return this->twoSidedEnabled; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetReflectivity(const double _reflectivity) - { - this->reflectivity = _reflectivity; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetReflectionEnabled(const bool _enabled) - { - this->reflectionEnabled = _enabled; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetLightingEnabled(const bool _enabled) - { - this->lightingEnabled = _enabled; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetDepthCheckEnabled(bool _enabled) - { - this->depthCheckEnabled = _enabled; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetDepthWriteEnabled(bool _enabled) - { - this->depthWriteEnabled = _enabled; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetCastShadows(const bool _castShadows) - { - this->castShadows = _castShadows; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetReceiveShadows(const bool _receive) - { - this->receiveShadows = _receive; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetRenderOrder(const float _renderorder) - { - this->renderOrder = _renderorder; - } - - ////////////////////////////////////////////////// - template - math::Color BaseMaterial::Ambient() const - { - return this->ambient; - } - - ////////////////////////////////////////////////// - template - math::Color BaseMaterial::Diffuse() const - { - return this->diffuse; - } - - ////////////////////////////////////////////////// - template - math::Color BaseMaterial::Specular() const - { - return this->specular; - } - - ////////////////////////////////////////////////// - template - math::Color BaseMaterial::Emissive() const - { - return this->emissive; - } - - ////////////////////////////////////////////////// - template - double BaseMaterial::Shininess() const - { - return this->shininess; - } - - ////////////////////////////////////////////////// - template - double BaseMaterial::Transparency() const - { - return this->transparency; - } - - ////////////////////////////////////////////////// - template - float BaseMaterial::RenderOrder() const - { - return this->renderOrder; - } - - ////////////////////////////////////////////////// - template - double BaseMaterial::Reflectivity() const - { - return this->reflectivity; - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::CastShadows() const - { - return this->castShadows; - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::ReceiveShadows() const - { - return this->receiveShadows; - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::LightingEnabled() const - { - return this->lightingEnabled; - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::DepthCheckEnabled() const - { - return this->depthCheckEnabled; - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::DepthWriteEnabled() const - { - return this->depthWriteEnabled; - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::ReflectionEnabled() const - { - return this->reflectionEnabled; - } - - ////////////////////////////////////////////////// - template - MaterialType BaseMaterial::Type() const - { - return MT_CLASSIC; - } - - ////////////////////////////////////////////////// - template - std::string BaseMaterial::VertexShader() const - { - return std::string(); - } - - ////////////////////////////////////////////////// - template - ShaderParamsPtr BaseMaterial::VertexShaderParams() - { - return nullptr; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetVertexShader(const std::string &/*_path*/) - { - // no op - } - - ////////////////////////////////////////////////// - template - std::string BaseMaterial::FragmentShader() const - { - return std::string(); - } - - ////////////////////////////////////////////////// - template - ShaderParamsPtr BaseMaterial::FragmentShaderParams() - { - return nullptr; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetFragmentShader(const std::string &/*_path*/) - { - // no op - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::HasTexture() const - { - return false; - } - - ////////////////////////////////////////////////// - template - std::string BaseMaterial::Texture() const - { - return std::string(); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetTexture(const std::string &) - { - // no op - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::ClearTexture() - { - // no op - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::HasNormalMap() const - { - return false; - } - - ////////////////////////////////////////////////// - template - std::string BaseMaterial::NormalMap() const - { - return std::string(); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetNormalMap(const std::string &) - { - // no op - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::ClearNormalMap() - { - // no op - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::HasRoughnessMap() const - { - return false; - } - - ////////////////////////////////////////////////// - template - std::string BaseMaterial::RoughnessMap() const - { - return std::string(); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetRoughnessMap(const std::string &) - { - // no op - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::ClearRoughnessMap() - { - // no op - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::HasMetalnessMap() const - { - return false; - } - - ////////////////////////////////////////////////// - template - std::string BaseMaterial::MetalnessMap() const - { - return std::string(); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetMetalnessMap(const std::string &) - { - // no op - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::ClearMetalnessMap() - { - // no op - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::HasEnvironmentMap() const - { - return false; - } - - ////////////////////////////////////////////////// - template - std::string BaseMaterial::EnvironmentMap() const - { - return std::string(); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetEnvironmentMap(const std::string &) - { - // no op - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::ClearEnvironmentMap() - { - // no op - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::HasEmissiveMap() const - { - return false; - } - - ////////////////////////////////////////////////// - template - std::string BaseMaterial::EmissiveMap() const - { - return std::string(); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetEmissiveMap(const std::string &) - { - // no op - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::ClearEmissiveMap() - { - // no op - } - - ////////////////////////////////////////////////// - template - bool BaseMaterial::HasLightMap() const - { - return false; - } - - ////////////////////////////////////////////////// - template - std::string BaseMaterial::LightMap() const - { - return std::string(); - } - - ////////////////////////////////////////////////// - template - unsigned int BaseMaterial::LightMapTexCoordSet() const - { - return 0u; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetLightMap(const std::string &, unsigned int) - { - // no op - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::ClearLightMap() - { - // no op - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetRoughness(const float) - { - // no op - } - - ////////////////////////////////////////////////// - template - float BaseMaterial::Roughness() const - { - return 0.0f; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetMetalness(const float) - { - // no op - } - - ////////////////////////////////////////////////// - template - float BaseMaterial::Metalness() const - { - return 0.0f; - } - - ////////////////////////////////////////////////// - template - MaterialPtr BaseMaterial::Clone(const std::string &_name) const - { - auto baseShared = this->shared_from_this(); - - auto thisShared = - std::dynamic_pointer_cast>(baseShared); - - MaterialPtr material = T::Scene()->CreateMaterial(_name); - material->CopyFrom(thisShared); - return material; - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::CopyFrom(ConstMaterialPtr _material) - { - this->SetLightingEnabled(_material->LightingEnabled()); - this->SetAmbient(_material->Ambient()); - this->SetDiffuse(_material->Diffuse()); - this->SetSpecular(_material->Specular()); - this->SetEmissive(_material->Emissive()); - this->SetRenderOrder(_material->RenderOrder()); - this->SetShininess(_material->Shininess()); - this->SetAlphaFromTexture(_material->TextureAlphaEnabled(), - _material->AlphaThreshold(), _material->TwoSidedEnabled()); - // override transparency / blend setting after setting alpha from texture - this->SetTransparency(_material->Transparency()); - // override depth check / depth write after setting transparency - this->SetDepthCheckEnabled(_material->DepthCheckEnabled()); - this->SetDepthWriteEnabled(_material->DepthWriteEnabled()); - this->SetReflectivity(_material->Reflectivity()); - this->SetCastShadows(_material->CastShadows()); - this->SetReceiveShadows(_material->ReceiveShadows()); - this->SetReflectionEnabled(_material->ReflectionEnabled()); - this->SetTexture(_material->Texture()); - this->SetNormalMap(_material->NormalMap()); - this->SetRoughnessMap(_material->RoughnessMap()); - this->SetMetalnessMap(_material->MetalnessMap()); - this->SetRoughness(_material->Roughness()); - this->SetMetalness(_material->Metalness()); - this->SetEnvironmentMap(_material->EnvironmentMap()); - this->SetEmissiveMap(_material->EmissiveMap()); - this->SetLightMap(_material->LightMap(), - _material->LightMapTexCoordSet()); - this->SetShaderType(_material->ShaderType()); - this->SetVertexShader(_material->VertexShader()); - this->SetFragmentShader(_material->FragmentShader()); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::CopyFrom(const common::Material &_material) - { - this->SetLightingEnabled(_material.Lighting()); - this->SetAmbient(_material.Ambient()); - this->SetDiffuse(_material.Diffuse()); - this->SetSpecular(_material.Specular()); - this->SetEmissive(_material.Emissive()); - this->SetShininess(_material.Shininess()); - this->SetTransparency(_material.Transparency()); - this->SetAlphaFromTexture(_material.TextureAlphaEnabled(), - _material.AlphaThreshold(), _material.TwoSidedEnabled()); - this->SetRenderOrder(_material.RenderOrder()); - // TODO(anyone): update common::Material - this->SetReflectivity(0); - this->SetTexture(_material.TextureImage()); - // TODO(anyone): update common::Material - this->SetCastShadows(true); - // TODO(anyone): update common::Material - this->SetReceiveShadows(true); - // TODO(anyone): update common::Material - this->SetReflectionEnabled(true); - // TODO(anyone): update common::Material - this->ClearNormalMap(); - // TODO(anyone): update common::Material - this->SetShaderType(ST_PIXEL); - - const common::Pbr *pbrMat = _material.PbrMaterial(); - if (!pbrMat) - pbrMat = &kDefaultPbr; - this->SetNormalMap(pbrMat->NormalMap()); - this->SetRoughnessMap(pbrMat->RoughnessMap()); - this->SetMetalnessMap(pbrMat->MetalnessMap()); - this->SetRoughness(pbrMat->Roughness()); - this->SetMetalness(pbrMat->Metalness()); - this->SetEnvironmentMap(pbrMat->EnvironmentMap()); - this->SetEmissiveMap(pbrMat->EmissiveMap()); - this->SetLightMap(pbrMat->LightMap(), pbrMat->LightMapTexCoordSet()); - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::PreRender() - { - // do nothing - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::SetDepthMaterial(const double /*far*/, - const double /*near*/) - { - // do nothing - } - - ////////////////////////////////////////////////// - template - void BaseMaterial::Reset() - { - this->SetLightingEnabled(true); - this->SetDepthCheckEnabled(true); - this->SetDepthWriteEnabled(true); - this->SetAmbient(0.3, 0.3, 0.3); - this->SetDiffuse(1.0, 1.0, 1.0); - this->SetSpecular(0.2, 0.2, 0.2); - this->SetEmissive(0, 0, 0); - this->SetRenderOrder(0); - this->SetShininess(1.5); - this->SetTransparency(0); - this->SetReflectivity(0); - this->SetCastShadows(true); - this->SetReceiveShadows(true); - this->SetReflectionEnabled(true); - this->ClearTexture(); - this->ClearNormalMap(); - this->ClearRoughnessMap(); - this->ClearMetalnessMap(); - this->ClearEmissiveMap(); - this->ClearLightMap(); - this->SetRoughness(kDefaultPbr.Roughness()); - this->SetMetalness(kDefaultPbr.Metalness()); - this->SetShaderType(ST_PIXEL); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseMesh.hh b/include/ignition/rendering/base/BaseMesh.hh index 456787770..f2faa8de0 100644 --- a/include/ignition/rendering/base/BaseMesh.hh +++ b/include/ignition/rendering/base/BaseMesh.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,453 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEMESH_HH_ -#define IGNITION_RENDERING_BASE_BASEMESH_HH_ -#include -#include -#include -#include "ignition/rendering/Mesh.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/Storage.hh" -#include "ignition/rendering/base/BaseObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - ////////////////////////////////////////////////// - template - class BaseMesh : - public virtual Mesh, - public virtual T - { - protected: BaseMesh(); - - public: virtual ~BaseMesh(); - - // Documentation inherited. - public: virtual bool HasSkeleton() const override; - - // Documentation inherited. - public: virtual std::map - SkeletonLocalTransforms() const override; - - // Documentation inherited. - public: virtual void SetSkeletonLocalTransforms( - const std::map &_tfs) - override; - - // Documentation inherited. - public: virtual std::unordered_map SkeletonWeights() - const override; - - // Documentation inherited. - public: virtual void SetSkeletonWeights( - const std::unordered_map &_weights) - override; - - // Documentation inherited. - public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, - bool _enabled, bool _loop = true, float _weight = 1.0) override; - - // Documentation inherited. - public: virtual bool SkeletonAnimationEnabled(const std::string &_name) - const override; - - // Documentation inherited. - public: virtual void UpdateSkeletonAnimation( - std::chrono::steady_clock::duration _time) override; - - public: virtual unsigned int SubMeshCount() const override; - - public: virtual bool HasSubMesh(ConstSubMeshPtr _subMesh) const override; - - public: virtual bool HasSubMeshName(const std::string &_name) const - override; - - public: virtual SubMeshPtr SubMeshByName( - const std::string &_name) const override; - - public: virtual SubMeshPtr SubMeshByIndex(unsigned int _index) const - override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial(const std::string &_name, - bool _unique = true) override; - - // Documentation inherited. - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true) override; - - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual GeometryPtr Clone() const override; - - // Documentation inherited. - public: void SetDescriptor(const MeshDescriptor &_desc) override; - - // Documentation inherited. - public: const MeshDescriptor &Descriptor() const override; - - // Documentation inherited - public: virtual void Destroy() override; - - protected: virtual SubMeshStorePtr SubMeshes() const = 0; - - /// \brief Flag to indicate whether or not this mesh should be - /// responsible for destroying the material - protected: bool ownsMaterial = false; - - /// \brief Pointer to currently assigned material - protected: MaterialPtr material; - - /// \brief MeshDescriptor for this mesh - protected: MeshDescriptor meshDescriptor; - }; - - ////////////////////////////////////////////////// - template - class BaseSubMesh : - public virtual SubMesh, - public virtual T - { - protected: BaseSubMesh(); - - public: virtual ~BaseSubMesh(); - - // Documentation inherited - public: virtual MaterialPtr Material() const override; - - // Documentation inherited - public: virtual void SetMaterial(const std::string &_name, - bool _unique = true) override; - - // Documentation inherited - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true) override; - - /// \brief Engine implementation for setting the material of this SubMesh. - /// \param[in] _material New Material to be assigned - public: virtual void SetMaterialImpl(MaterialPtr _material) = 0; - - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Flag to indicate whether or not this submesh should be - /// responsible for destroying the material - protected: bool ownsMaterial = false; - - /// \brief Pointer to currently assigned material - protected: MaterialPtr material; - }; - - ////////////////////////////////////////////////// - // BaseMesh - ////////////////////////////////////////////////// - template - BaseMesh::BaseMesh() - { - } - - ////////////////////////////////////////////////// - template - BaseMesh::~BaseMesh() - { - } - - ////////////////////////////////////////////////// - template - bool BaseMesh::HasSkeleton() const - { - return false; - } - - ////////////////////////////////////////////////// - template - std::map - BaseMesh::SkeletonLocalTransforms() const - { - std::map tmpMap; - return tmpMap; - } - - ////////////////////////////////////////////////// - template - void BaseMesh::SetSkeletonLocalTransforms( - const std::map &) - { - } - - ////////////////////////////////////////////////// - template - std::unordered_map BaseMesh::SkeletonWeights() const - { - std::unordered_map tmpMap; - return tmpMap; - } - - ////////////////////////////////////////////////// - template - void BaseMesh::SetSkeletonWeights( - const std::unordered_map &) - { - ignerr << "SetSkeletonWeights not supported for render engine: " - << this->Scene()->Engine()->Name() << std::endl; - } - - ////////////////////////////////////////////////// - template - void BaseMesh::SetSkeletonAnimationEnabled(const std::string &, bool, - bool, float) - { - } - - ////////////////////////////////////////////////// - template - bool BaseMesh::SkeletonAnimationEnabled(const std::string &) const - { - return false; - } - - ////////////////////////////////////////////////// - template - void BaseMesh::UpdateSkeletonAnimation( - std::chrono::steady_clock::duration) - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseMesh::SubMeshCount() const - { - return this->SubMeshes()->Size(); - } - - ////////////////////////////////////////////////// - template - bool BaseMesh::HasSubMesh(ConstSubMeshPtr _subMesh) const - { - return this->SubMeshes()->Contains(_subMesh); - } - - ////////////////////////////////////////////////// - template - bool BaseMesh::HasSubMeshName(const std::string &_name) const - { - return this->SubMeshes()->ContainsName(_name); - } - - ////////////////////////////////////////////////// - template - SubMeshPtr BaseMesh::SubMeshByName(const std::string &_name) const - { - return this->SubMeshes()->GetByName(_name); - } - - ////////////////////////////////////////////////// - template - SubMeshPtr BaseMesh::SubMeshByIndex(unsigned int _index) const - { - return this->SubMeshes()->GetByIndex(_index); - } - - ////////////////////////////////////////////////// - template - MaterialPtr BaseMesh::Material() const - { - unsigned int count = this->SubMeshCount(); - return (count > 0) ? this->SubMeshByIndex(0)->Material() : - MaterialPtr(); - } - - ////////////////////////////////////////////////// - template - void BaseMesh::SetMaterial(const std::string &_name, bool _unique) - { - MaterialPtr mat = this->Scene()->Material(_name); - if (mat) this->SetMaterial(mat, _unique); - } - - ////////////////////////////////////////////////// - template - void BaseMesh::SetMaterial(MaterialPtr _material, bool _unique) - { - // todo(anyone) take ownership of reference _material if _unique - // and destroy the reference material when the mesh is destroyed - unsigned int count = this->SubMeshCount(); - _material = (_unique && count > 0) ? _material->Clone() : _material; - - for (unsigned int i = 0; i < count; ++i) - { - SubMeshPtr subMesh = this->SubMeshByIndex(i); - subMesh->SetMaterial(_material, false); - } - - if (this->material && this->ownsMaterial) - this->Scene()->DestroyMaterial(this->material); - - this->ownsMaterial = _unique; - this->material = _material; - } - - ////////////////////////////////////////////////// - template - void BaseMesh::PreRender() - { - unsigned int count = this->SubMeshCount(); - - for (unsigned int i = 0; i < count; ++i) - { - SubMeshPtr subMesh = this->SubMeshByIndex(i); - subMesh->PreRender(); - } - - T::PreRender(); - } - - ////////////////////////////////////////////////// - template - GeometryPtr BaseMesh::Clone() const - { - if (!this->Scene()) - { - ignerr << "Cloning a mesh failed because the mesh to be " - << "cloned does not belong to a scene.\n"; - return nullptr; - } - else if (this->meshDescriptor.meshName.empty()) - { - ignerr << "Cloning a geometry failed because the name of the mesh is " - << "missing.\n"; - return nullptr; - } - - auto result = this->Scene()->CreateMesh(this->meshDescriptor); - if (result) - { - if (this->Material()) - { - // this call will set the material for the mesh and its submeshes - result->SetMaterial(this->Material()); - } - else - { - // if the mesh doesn't have a material, clone any existing submesh - // materials - for (unsigned int i = 0; i < this->SubMeshCount(); ++i) - { - auto existingSubMeshMaterial = this->SubMeshByIndex(i)->Material(); - if (existingSubMeshMaterial) - result->SubMeshByIndex(i)->SetMaterial(existingSubMeshMaterial); - } - } - } - - return result; - } - - ////////////////////////////////////////////////// - template - const MeshDescriptor &BaseMesh::Descriptor() const - { - return this->meshDescriptor; - } - - ////////////////////////////////////////////////// - template - void BaseMesh::SetDescriptor(const MeshDescriptor &_desc) - { - this->meshDescriptor = _desc; - } - - ////////////////////////////////////////////////// - template - void BaseMesh::Destroy() - { - T::Destroy(); - this->SubMeshes()->DestroyAll(); - if (this->material && this->ownsMaterial) - this->Scene()->DestroyMaterial(this->material); - this->material.reset(); - this->meshDescriptor = MeshDescriptor(); - } - - ////////////////////////////////////////////////// - // BaseSubMesh - ////////////////////////////////////////////////// - template - BaseSubMesh::BaseSubMesh() - { - } - - ////////////////////////////////////////////////// - template - BaseSubMesh::~BaseSubMesh() - { - } - - ////////////////////////////////////////////////// - template - void BaseSubMesh::Destroy() - { - T::Destroy(); - if (this->material && this->ownsMaterial) - this->Scene()->DestroyMaterial(this->material); - this->material.reset(); - } - - - ////////////////////////////////////////////////// - template - void BaseSubMesh::SetMaterial(const std::string &_name, bool _unique) - { - MaterialPtr mat = this->Scene()->Material(_name); - if (mat) this->SetMaterial(mat, _unique); - } - - ////////////////////////////////////////////////// - template - void BaseSubMesh::SetMaterial(MaterialPtr _material, bool _unique) - { - _material = (_unique) ? _material->Clone() : _material; - - MaterialPtr origMaterial = this->material; - bool origUnique = this->ownsMaterial; - - this->SetMaterialImpl(_material); - - if (origMaterial && origUnique) - this->Scene()->DestroyMaterial(origMaterial); - - this->material = _material; - this->ownsMaterial = _unique; - } - - ////////////////////////////////////////////////// - template - MaterialPtr BaseSubMesh::Material() const - { - return this->material; - } - - ////////////////////////////////////////////////// - template - void BaseSubMesh::PreRender() - { - T::PreRender(); - if (this->Material()) - this->Material()->PreRender(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseNode.hh b/include/ignition/rendering/base/BaseNode.hh index 646488148..7737eed80 100644 --- a/include/ignition/rendering/base/BaseNode.hh +++ b/include/ignition/rendering/base/BaseNode.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,704 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASENODE_HH_ -#define IGNITION_RENDERING_BASE_BASENODE_HH_ -#include -#include - -#include "ignition/rendering/Node.hh" -#include "ignition/rendering/Storage.hh" -#include "ignition/rendering/base/BaseStorage.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseNode : - public virtual Node, - public virtual T - { - protected: BaseNode(); - - public: virtual ~BaseNode(); - - public: virtual NodePtr Parent() const override = 0; - - // Documentation inherited - public: virtual void RemoveParent() override; - - public: virtual math::Vector3d LocalPosition() const override; - - public: virtual math::Pose3d LocalPose() const override; - - // Documentation inherited - public: virtual math::Pose3d InitialLocalPose() const override; - - public: virtual void SetLocalPose(const math::Pose3d &_pose) override; - - public: virtual void SetLocalPosition(double _x, double _y, double _z) - override; - - public: virtual void SetLocalPosition(const math::Vector3d &_position) - override; - - public: virtual math::Quaterniond LocalRotation() const override; - - public: virtual void SetLocalRotation(double _r, double _p, double _y) - override; - - public: virtual void SetLocalRotation(double _w, double _x, double _y, - double _z) override; - - public: virtual void SetLocalRotation(const math::Quaterniond &_rotation) - override; - - public: virtual math::Pose3d WorldPose() const override; - - public: virtual void SetWorldPose(const math::Pose3d &_pose) override; - - public: virtual math::Vector3d WorldPosition() const override; - - public: virtual void SetWorldPosition(double _x, double _y, double _z) - override; - - public: virtual void SetWorldPosition(const math::Vector3d &_position) - override; - - public: virtual math::Quaterniond WorldRotation() const override; - - public: virtual void SetWorldRotation(double _r, double _p, double _y) - override; - - public: virtual void SetWorldRotation(double _w, double _x, double _y, - double _z) override; - - public: virtual void SetWorldRotation(const math::Quaterniond &_rotation) - override; - - public: virtual math::Pose3d WorldToLocal(const math::Pose3d &_pose) - const override; - - public: virtual math::Vector3d Origin() const override; - - public: virtual void SetOrigin(double _x, double _y, double _z) override; - - public: virtual void SetOrigin(const math::Vector3d &_origin) override; - - // Documentation inherited - public: virtual math::Vector3d LocalScale() const override = 0; - - // Documentation inherited - public: virtual void SetLocalScale(double _scale) override; - - // Documentation inherited - public: virtual void SetLocalScale(double _x, double _y, double _z) - override; - - // Documentation inherited - public: virtual void SetLocalScale(const math::Vector3d &_scale) override; - - // Documentation inherited - public: virtual math::Vector3d WorldScale() const override; - - // Documentation inherited - public: virtual void SetWorldScale(double _scale) override; - - // Documentation inherited - public: virtual void SetWorldScale(double _x, double _y, double _z) - override; - - // Documentation inherited - public: virtual void SetWorldScale(const math::Vector3d &_scale) override; - - // Documentation inherited - public: virtual void Scale(double _scale) override; - - // Documentation inherited - public: virtual void Scale(double _x, double _y, double _z) override; - - // Documentation inherited - public: virtual void Scale(const math::Vector3d &_scale) override; - - // Documentation inherited - public: virtual bool InheritScale() const override = 0; - - public: virtual void Destroy() override; - - public: virtual unsigned int ChildCount() const override; - - public: virtual bool HasChild(ConstNodePtr _child) const override; - - public: virtual bool HasChildId(unsigned int _id) const override; - - public: virtual bool HasChildName(const std::string &_name) const - override; - - public: virtual NodePtr ChildById(unsigned int _id) const override; - - public: virtual NodePtr ChildByName(const std::string &_name) const - override; - - public: virtual NodePtr ChildByIndex(unsigned int _index) const override; - - public: virtual void AddChild(NodePtr _child) override; - - public: virtual NodePtr RemoveChild(NodePtr _child) override; - - public: virtual NodePtr RemoveChildById(unsigned int _id) override; - - public: virtual NodePtr RemoveChildByName(const std::string &_name) - override; - - public: virtual NodePtr RemoveChildByIndex(unsigned int _index) override; - - public: virtual void RemoveChildren() override; - - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void SetUserData(const std::string &_key, Variant _value) - override; - - // Documentation inherited - public: virtual Variant UserData(const std::string &_key) const override; - - // Documentation inherited - public: virtual bool HasUserData(const std::string &_key) const override; - - protected: virtual void PreRenderChildren(); - - protected: virtual math::Pose3d RawLocalPose() const = 0; - - protected: virtual void SetRawLocalPose(const math::Pose3d &_pose) = 0; - - protected: virtual NodeStorePtr Children() const = 0; - - protected: virtual bool AttachChild(NodePtr _child) = 0; - - protected: virtual bool DetachChild(NodePtr _child) = 0; - - /// \brief Implementation of the SetLocalScale function - /// \param[in] _scale Scale to set the visual to - protected: virtual void SetLocalScaleImpl( - const math::Vector3d &_scale) = 0; - - protected: math::Vector3d origin; - - /// \brief Flag to indicate whether initial local pose - /// is set for this node. - protected: bool initialLocalPoseSet = false; - - /// \brief Initial local pose for this node. - protected: ignition::math::Pose3d initialLocalPose = - ignition::math::Pose3d::Zero; - - /// \brief A map of custom key value data - protected: std::map userData; - }; - - ////////////////////////////////////////////////// - template - BaseNode::BaseNode() - { - } - - ////////////////////////////////////////////////// - template - BaseNode::~BaseNode() - { - } - - ////////////////////////////////////////////////// - template - void BaseNode::RemoveParent() - { - NodePtr parent = this->Parent(); - - if (parent) - { - auto baseShared = this->shared_from_this(); - auto thisShared = std::dynamic_pointer_cast>(baseShared); - parent->RemoveChild(thisShared); - } - } - - - ////////////////////////////////////////////////// - template - void BaseNode::AddChild(NodePtr _child) - { - if (_child->Id() == this->Id()) - { - ignerr << "Cannot add self as a child node" << std::endl; - return; - } - - if (this->AttachChild(_child)) - { - this->Children()->Add(_child); - } - } - - ////////////////////////////////////////////////// - template - NodePtr BaseNode::RemoveChild(NodePtr _child) - { - NodePtr child = this->Children()->Remove(_child); - if (child) this->DetachChild(child); - return child; - } - - ////////////////////////////////////////////////// - template - NodePtr BaseNode::RemoveChildById(unsigned int _id) - { - NodePtr child = this->Children()->RemoveById(_id); - if (child) this->DetachChild(child); - return child; - } - - ////////////////////////////////////////////////// - template - NodePtr BaseNode::RemoveChildByName(const std::string &_name) - { - NodePtr child = this->Children()->RemoveByName(_name); - if (child) this->DetachChild(child); - return child; - } - - ////////////////////////////////////////////////// - template - NodePtr BaseNode::RemoveChildByIndex(unsigned int _index) - { - NodePtr child = this->Children()->RemoveByIndex(_index); - if (child) this->DetachChild(child); - return child; - } - - ////////////////////////////////////////////////// - template - void BaseNode::RemoveChildren() - { - for (unsigned int i = this->ChildCount(); i > 0; --i) - { - this->RemoveChildByIndex(i - 1); - } - } - - ////////////////////////////////////////////////// - template - void BaseNode::PreRender() - { - this->PreRenderChildren(); - } - - ////////////////////////////////////////////////// - template - void BaseNode::PreRenderChildren() - { - unsigned int count = this->ChildCount(); - - for (unsigned int i = 0; i < count; ++i) - { - this->ChildByIndex(i)->PreRender(); - } - } - - ////////////////////////////////////////////////// - template - math::Pose3d BaseNode::LocalPose() const - { - math::Pose3d pose = this->RawLocalPose(); - pose.Pos() += pose.Rot() * this->origin; - return pose; - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetLocalPose(const math::Pose3d &_pose) - { - if (!_pose.IsFinite()) - { - ignerr << "Unable to set non-finite pose [" << _pose - << "] to node [" << this->Name() << "]" << std::endl; - return; - } - - math::Pose3d pose = _pose; - pose.Pos() = pose.Pos() - pose.Rot() * this->origin; - - if (!initialLocalPoseSet) - { - this->initialLocalPose = pose; - this->initialLocalPoseSet = true; - } - - this->SetRawLocalPose(pose); - } - - ////////////////////////////////////////////////// - template - math::Pose3d BaseNode::InitialLocalPose() const - { - return this->initialLocalPose; - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseNode::LocalPosition() const - { - return this->LocalPose().Pos(); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetLocalPosition(double _x, double _y, double _z) - { - this->SetLocalPosition(math::Vector3d(_x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetLocalPosition(const math::Vector3d &_position) - { - if (!_position.IsFinite()) - { - ignerr << "Unable to set non-finite position [" << _position - << "] to node [" << this->Name() << "]" << std::endl; - return; - } - - math::Pose3d pose = this->LocalPose(); - pose.Pos() = _position; - this->SetLocalPose(pose); - } - - ////////////////////////////////////////////////// - template - math::Quaterniond BaseNode::LocalRotation() const - { - return this->LocalPose().Rot(); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetLocalRotation(double _r, double _p, double _y) - { - this->SetLocalRotation(math::Quaterniond(_r, _p, _y)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetLocalRotation(double _w, double _x, double _y, - double _z) - { - this->SetLocalRotation(math::Quaterniond(_w, _x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetLocalRotation(const math::Quaterniond &_rotation) - { - if (!_rotation.IsFinite()) - { - ignerr << "Unable to set non-finite rotation [" << _rotation - << "] to node [" << this->Name() << "]" << std::endl; - return; - } - - math::Pose3d pose = this->LocalPose(); - pose.Rot() = _rotation; - this->SetLocalPose(pose); - } - - ////////////////////////////////////////////////// - template - math::Pose3d BaseNode::WorldPose() const - { - NodePtr parent = this->Parent(); - math::Pose3d pose = this->LocalPose(); - - if (!parent) - { - return pose; - } - - return parent->WorldPose() * pose; - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetWorldPose(const math::Pose3d &_pose) - { - math::Pose3d pose = this->WorldToLocal(_pose); - this->SetLocalPose(pose); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetWorldPosition(double _x, double _y, double _z) - { - this->SetWorldPosition(math::Vector3d(_x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseNode::WorldPosition() const - { - return this->WorldPose().Pos(); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetWorldPosition(const math::Vector3d &_position) - { - math::Pose3d pose = this->WorldPose(); - pose.Pos() = _position; - this->SetWorldPose(pose); - } - - ////////////////////////////////////////////////// - template - math::Quaterniond BaseNode::WorldRotation() const - { - return this->WorldPose().Rot(); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetWorldRotation(double _r, double _p, double _y) - { - this->SetWorldRotation(math::Quaterniond(_r, _p, _y)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetWorldRotation(double _w, double _x, double _y, - double _z) - { - this->SetWorldRotation(math::Quaterniond(_w, _x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetWorldRotation(const math::Quaterniond &_rotation) - { - math::Pose3d pose = this->WorldPose(); - pose.Rot() = _rotation; - this->SetWorldPose(pose); - } - - ////////////////////////////////////////////////// - template - math::Pose3d BaseNode::WorldToLocal(const math::Pose3d &_pose) const - { - NodePtr parent = this->Parent(); - - if (!parent) - { - return _pose; - } - - return _pose - parent->WorldPose(); - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseNode::Origin() const - { - return this->origin; - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetOrigin(double _x, double _y, double _z) - { - this->SetOrigin(math::Vector3d(_x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetOrigin(const math::Vector3d &_origin) - { - if (!_origin.IsFinite()) - { - ignerr << "Unable to set non-finite origin [" << _origin - << "] to node [" << this->Name() << "]" << std::endl; - return; - } - this->origin = _origin; - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetLocalScale(double _scale) - { - this->SetLocalScale(math::Vector3d(_scale, _scale, _scale)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetLocalScale(double _x, double _y, double _z) - { - this->SetLocalScale(math::Vector3d(_x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetLocalScale(const math::Vector3d &_scale) - { - math::Pose3d rawPose = this->LocalPose(); - this->SetLocalScaleImpl(_scale); - this->SetLocalPose(rawPose); - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseNode::WorldScale() const - { - math::Vector3d scale = this->LocalScale(); - - if (!this->InheritScale() || !this->HasParent()) - { - return scale; - } - - return scale * this->Parent()->WorldScale(); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetWorldScale(double _scale) - { - this->SetWorldScale(math::Vector3d(_scale, _scale, _scale)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetWorldScale(double _x, double _y, double _z) - { - this->SetWorldScale(math::Vector3d(_x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetWorldScale(const math::Vector3d &_scale) - { - math::Vector3d toScale = math::Vector3d::One; - if (this->InheritScale() && this->HasParent()) - toScale = this->Parent()->WorldScale(); - - this->SetLocalScale(_scale / toScale); - } - - ////////////////////////////////////////////////// - template - void BaseNode::Scale(double _scale) - { - this->Scale(math::Vector3d(_scale, _scale, _scale)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::Scale(double _x, double _y, double _z) - { - this->Scale(math::Vector3d(_x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseNode::Scale(const math::Vector3d &_scale) - { - this->SetLocalScale(_scale * this->LocalScale()); - } - - ////////////////////////////////////////////////// - template - void BaseNode::Destroy() - { - T::Destroy(); - this->RemoveParent(); - } - - ////////////////////////////////////////////////// - template - unsigned int BaseNode::ChildCount() const - { - return this->Children()->Size(); - } - - ////////////////////////////////////////////////// - template - bool BaseNode::HasChild(ConstNodePtr _child) const - { - return this->Children()->Contains(_child); - } - - ////////////////////////////////////////////////// - template - bool BaseNode::HasChildId(unsigned int _id) const - { - return this->Children()->ContainsId(_id); - } - - ////////////////////////////////////////////////// - template - bool BaseNode::HasChildName(const std::string &_name) const - { - return this->Children()->ContainsName(_name); - } - - ////////////////////////////////////////////////// - template - NodePtr BaseNode::ChildById(unsigned int _id) const - { - return this->Children()->GetById(_id); - } - - ////////////////////////////////////////////////// - template - NodePtr BaseNode::ChildByName(const std::string &_name) const - { - return this->Children()->GetByName(_name); - } - - ////////////////////////////////////////////////// - template - NodePtr BaseNode::ChildByIndex(unsigned int _index) const - { - return this->Children()->GetByIndex(_index); - } - } - - ////////////////////////////////////////////////// - template - void BaseNode::SetUserData(const std::string &_key, Variant _value) - { - this->userData[_key] = _value; - } - - ////////////////////////////////////////////////// - template - Variant BaseNode::UserData(const std::string &_key) const - { - Variant value; - auto it = this->userData.find(_key); - if (it != this->userData.end()) - value = it->second; - return value; - } - - ////////////////////////////////////////////////// - template - bool BaseNode::HasUserData(const std::string &_key) const - { - return this->userData.find(_key) != this->userData.end(); - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseObject.hh b/include/ignition/rendering/base/BaseObject.hh index 73f670ddf..1ce9353b5 100644 --- a/include/ignition/rendering/base/BaseObject.hh +++ b/include/ignition/rendering/base/BaseObject.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,56 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEOBJECT_HH_ -#define IGNITION_RENDERING_BASE_BASEOBJECT_HH_ -#include -#include -#include -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_VISIBLE BaseObject : - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public virtual std::enable_shared_from_this, - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - public virtual Object - { - protected: BaseObject(); - - public: virtual ~BaseObject(); - - public: virtual unsigned int Id() const override; - - public: virtual std::string Name() const override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // TODO(anyone): make pure virtual - protected: virtual void Load(); - - // TODO(anyone): make pure virtual - protected: virtual void Init(); - - protected: unsigned int id; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: std::string name; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseParticleEmitter.hh b/include/ignition/rendering/base/BaseParticleEmitter.hh index c02395d53..cc078b3a0 100644 --- a/include/ignition/rendering/base/BaseParticleEmitter.hh +++ b/include/ignition/rendering/base/BaseParticleEmitter.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,427 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_BASE_BASEPARTICLEEMITTER_HH_ -#define IGNITION_RENDERING_BASE_BASEPARTICLEEMITTER_HH_ - -#include -#include "ignition/rendering/base/BaseScene.hh" -#include "ignition/rendering/base/BaseNode.hh" -#include "ignition/rendering/ParticleEmitter.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class BaseParticleEmitter BaseParticleEmitter.hh \ - * ignition/rendering/base/BaseParticleEmitter.hh - */ - /// \brief A base implementation of the ParticleEmitter class - template - class BaseParticleEmitter : - public virtual ParticleEmitter, - public virtual T - { - /// \brief Constructor - protected: BaseParticleEmitter(); - - /// \brief Destructor - public: virtual ~BaseParticleEmitter(); - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void PreRender() override; - - /// \brief Reset the particle emitter visual state - public: virtual void Reset(); - - // Documentation inherited. - public: virtual EmitterType Type() const override; - - // Documentation inherited. - public: virtual void SetType(const EmitterType _type) override; - - // Documentation inherited. - public: virtual ignition::math::Vector3d EmitterSize() const override; - - // Documentation inherited. - public: virtual void SetEmitterSize( - const ignition::math::Vector3d &_size) override; - - // Documentation inherited. - public: virtual double Rate() const override; - - // Documentation inherited. - public: virtual void SetRate(double _rate) override; - - // Documentation inherited. - public: virtual double Duration() const override; - - // Documentation inherited. - public: virtual void SetDuration(double _duration) override; - - // Documentation inherited. - public: virtual bool Emitting() const override; - - // Documentation inherited. - public: virtual void SetEmitting(bool _enable) override; - - // Documentation inherited. - public: virtual ignition::math::Vector3d ParticleSize() const override; - - // Documentation inherited. - public: virtual void SetParticleSize( - const ignition::math::Vector3d &_size) override; - - // Documentation inherited. - public: virtual double Lifetime() const override; - - // Documentation inherited. - public: virtual void SetLifetime(double _lifetime) override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial(const MaterialPtr &_material) override; - - // Documentation inherited. - public: virtual double MinVelocity() const override; - - // Documentation inherited. - public: virtual double MaxVelocity() const override; - - // Documentation inherited. - public: virtual void SetVelocityRange(double _minVelocity, - double _maxVelocity) override; - - // Documentation inherited. - public: virtual ignition::math::Color ColorStart() const override; - - // Documentation inherited. - public: virtual ignition::math::Color ColorEnd() const override; - - // Documentation inherited. - public: virtual void SetColorRange( - const ignition::math::Color &_colorStart, - const ignition::math::Color &_colorEnd) override; - - // Documentation inherited. - public: virtual double ScaleRate() const override; - - // Documentation inherited. - public: virtual void SetScaleRate(double _scaleRate) override; - - // Documentation inherited. - public: virtual std::string ColorRangeImage() const override; - - // Documentation inherited. - public: virtual void SetColorRangeImage( - const std::string &_image) override; - - // Documentation inherited. - public: virtual float ParticleScatterRatio() const override; - - // Documentation inherited. - public: virtual void SetParticleScatterRatio(float _ratio) override; - - /// \brief Emitter type. - protected: EmitterType type = EM_POINT; - - /// \brief Emitter size. - protected: ignition::math::Vector3d emitterSize = - ignition::math::Vector3d::One; - - /// \brief Rate of emission. - protected: double rate = 10; - - /// \brief Duration of the emitter. - protected: double duration = 0; - - /// \brief Whether particle emitter is enabled or not. - protected: bool emitting = false; - - /// \brief Particle size. - protected: ignition::math::Vector3d particleSize = {1, 1, 1}; - - /// \brief Particle lifetime. - protected: double lifetime = 5; - - /// \brief Particle material. - protected: MaterialPtr material = nullptr; - - /// \brief The minimum velocity of each particle. - protected: double minVelocity = 1; - - /// \brief The maximum velocity of each particle. - protected: double maxVelocity = 1; - - /// \brief The start color of a particle to choose from. - protected: ignition::math::Color colorStart = - ignition::math::Color::White; - - /// \brief The end color of a particle to choose from. - protected: ignition::math::Color colorEnd = - ignition::math::Color::White; - - /// \brief The scale rate. - protected: double scaleRate = 1; - - /// \brief The color image. - protected: std::string colorRangeImage = ""; - - /// \brief The particle scatter ratio. This is used to determine the ratio - /// of particles that will be detected by sensors. Increasing the ratio - /// increases the scatter of the particles, which means there is a higher - /// chance of particles reflecting and interfering with depth sensing, - /// making the emitter appear more dense. Decreasing the ratio decreases - /// the scatter of the particles, making it appear less dense. This value - /// should be > 0. - protected: float particleScatterRatio = 0.65f; - - /// \brief Only the scene can create a particle emitter - private: friend class BaseScene; - }; - - ////////////////////////////////////////////////// - template - BaseParticleEmitter::BaseParticleEmitter() - { - } - - ////////////////////////////////////////////////// - template - BaseParticleEmitter::~BaseParticleEmitter() - { - } - - ////////////////////////////////////////////////// - template - void BaseParticleEmitter::Init() - { - T::Init(); - } - - ////////////////////////////////////////////////// - template - void BaseParticleEmitter::Reset() - { - } - - ////////////////////////////////////////////////// - template - void BaseParticleEmitter::PreRender() - { - } - - ////////////////////////////////////////////////// - template - EmitterType BaseParticleEmitter::Type() const - { - return this->type; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetType(const EmitterType _type) - { - this->type = _type; - } - - ////////////////////////////////////////////////// - template - ignition::math::Vector3d BaseParticleEmitter::EmitterSize() const - { - return this->emitterSize; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetEmitterSize( - const ignition::math::Vector3d &_size) - { - this->emitterSize = _size; - } - - ////////////////////////////////////////////////// - template - double BaseParticleEmitter::Rate() const - { - return this->rate; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetRate(double _rate) - { - this->rate = _rate; - } - - ////////////////////////////////////////////////// - template - double BaseParticleEmitter::Duration() const - { - return this->duration; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetDuration(double _duration) - { - this->duration = _duration; - } - - ////////////////////////////////////////////////// - template - bool BaseParticleEmitter::Emitting() const - { - return this->emitting; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetEmitting(bool _enable) - { - this->emitting = _enable; - } - - ////////////////////////////////////////////////// - template - ignition::math::Vector3d BaseParticleEmitter::ParticleSize() const - { - return this->particleSize; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetParticleSize( - const ignition::math::Vector3d &_size) - { - this->particleSize = _size; - } - - ////////////////////////////////////////////////// - template - double BaseParticleEmitter::Lifetime() const - { - return this->lifetime; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetLifetime(double _lifetime) - { - this->lifetime = _lifetime; - } - - ////////////////////////////////////////////////// - template - MaterialPtr BaseParticleEmitter::Material() const - { - return this->material; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetMaterial(const MaterialPtr &_material) - { - this->material = _material; - } - - ////////////////////////////////////////////////// - template - double BaseParticleEmitter::MinVelocity() const - { - return this->minVelocity; - } - - ////////////////////////////////////////////////// - template - double BaseParticleEmitter::MaxVelocity() const - { - return this->maxVelocity; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetVelocityRange(double _minVelocity, - double _maxVelocity) - { - this->minVelocity = _minVelocity; - this->maxVelocity = _maxVelocity; - } - - ////////////////////////////////////////////////// - template - ignition::math::Color BaseParticleEmitter::ColorStart() const - { - return this->colorStart; - } - - ////////////////////////////////////////////////// - template - ignition::math::Color BaseParticleEmitter::ColorEnd() const - { - return this->colorEnd; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetColorRange( - const ignition::math::Color &_colorStart, - const ignition::math::Color &_colorEnd) - { - this->colorStart = _colorStart; - this->colorEnd = _colorEnd; - } - - ///////////////////////////////////////////////// - template - double BaseParticleEmitter::ScaleRate() const - { - return this->scaleRate; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetScaleRate(double _scaleRate) - { - this->scaleRate = _scaleRate; - } - - ///////////////////////////////////////////////// - template - std::string BaseParticleEmitter::ColorRangeImage() const - { - return this->colorRangeImage; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetColorRangeImage(const std::string &_image) - { - this->colorRangeImage = _image; - } - - ///////////////////////////////////////////////// - template - float BaseParticleEmitter::ParticleScatterRatio() const - { - return this->particleScatterRatio; - } - - ///////////////////////////////////////////////// - template - void BaseParticleEmitter::SetParticleScatterRatio(float _ratio) - { - if (_ratio > 0.0f) - this->particleScatterRatio = _ratio; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseRayQuery.hh b/include/ignition/rendering/base/BaseRayQuery.hh index efef2bdee..0d1b88803 100644 --- a/include/ignition/rendering/base/BaseRayQuery.hh +++ b/include/ignition/rendering/base/BaseRayQuery.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,142 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASERAYQUERY_HH_ -#define IGNITION_RENDERING_BASE_BASERAYQUERY_HH_ -#include -#include - -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class BaseRayQuery BaseRayQuery.hh - /// ignition/rendering/base/BaseRayQuery.hh - /// \brief A Ray Query class used for computing ray object intersections - template - class BaseRayQuery : - public virtual RayQuery, - public T - { - /// \brief Constructor - protected: BaseRayQuery(); - - /// \brief Destructor - public: virtual ~BaseRayQuery() override; - - // Documentation inherited - public: virtual void SetOrigin(const math::Vector3d &_origin) override; - - // Documentation inherited - public: virtual math::Vector3d Origin() const override; - - // Documentation inherited - public: virtual void SetDirection(const math::Vector3d &_dir) override; - - // Documentation inherited - public: virtual math::Vector3d Direction() const override; - - // Documentation inherited - public: virtual void SetFromCamera(const CameraPtr &_camera, - const math::Vector2d &_coord) override; - - // Documentation inherited - public: virtual RayQueryResult ClosestPoint() override; - - /// \brief Ray origin - protected: math::Vector3d origin; - - /// \brief Ray direction - protected: math::Vector3d direction; - }; - - ////////////////////////////////////////////////// - template - BaseRayQuery::BaseRayQuery() - { - } - - ////////////////////////////////////////////////// - template - BaseRayQuery::~BaseRayQuery() - { - } - - ////////////////////////////////////////////////// - template - void BaseRayQuery::SetOrigin(const math::Vector3d &_origin) - { - this->origin = _origin; - } - - ////////////////////////////////////////////////// - template - ignition::math::Vector3d BaseRayQuery::Origin() const - { - return this->origin; - } - - ////////////////////////////////////////////////// - template - void BaseRayQuery::SetDirection(const math::Vector3d &_dir) - { - this->direction = _dir; - } - - ////////////////////////////////////////////////// - template - ignition::math::Vector3d BaseRayQuery::Direction() const - { - return this->direction; - } - - ////////////////////////////////////////////////// - template - void BaseRayQuery::SetFromCamera(const CameraPtr &_camera, - const ignition::math::Vector2d &_coord) - { - math::Matrix4d projectionMatrix = _camera->ProjectionMatrix(); - math::Matrix4d viewMatrix = _camera->ViewMatrix(); - math::Vector3d start(_coord.X(), _coord.Y(), -1.0); - math::Vector3d end(_coord.X(), _coord.Y(), 0.0); - math::Matrix4d viewProjInv = (projectionMatrix * viewMatrix).Inverse(); - - // rotate start and end - // ign math does not support matrix4 * vec4 - // so calc homogeneous coordinate w ourselves - double startw = viewProjInv(3, 0) * start[0] + - viewProjInv(3, 1) * start[1] + - viewProjInv(3, 2) * start[2] + viewProjInv(3, 3); - double endw = viewProjInv(3, 0) * end[0] + - viewProjInv(3, 1) * end[1] + - viewProjInv(3, 2) * end[2] + viewProjInv(3, 3); - start = viewProjInv * start; - end = viewProjInv * end; - // normalize - start = start / startw; - end = end / endw; - math::Vector3d dir = (end - start).Normalize(); - - this->origin = start; - this->direction = dir; - } - - ////////////////////////////////////////////////// - template - RayQueryResult BaseRayQuery::ClosestPoint() - { - // TODO(anyone): implement a generic ray query here? - RayQueryResult result; - result.distance = -1; - return result; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseRenderEngine.hh b/include/ignition/rendering/base/BaseRenderEngine.hh index 3d99ef085..0202704c4 100644 --- a/include/ignition/rendering/base/BaseRenderEngine.hh +++ b/include/ignition/rendering/base/BaseRenderEngine.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,126 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASERENDERENGINE_HH_ -#define IGNITION_RENDERING_BASE_BASERENDERENGINE_HH_ -#include -#include -#include -#include -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/Storage.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_VISIBLE BaseRenderEngine : - public virtual RenderEngine - { - protected: BaseRenderEngine(); - - public: virtual ~BaseRenderEngine(); - - // Documentation Inherited. - public: virtual bool Load( - const std::map &_params = {}) override; - - public: virtual bool Init() override; - - public: virtual bool Fini() override; - - public: virtual bool IsLoaded() const override; - - public: virtual bool IsInitialized() const override; - - public: virtual bool IsEnabled() const override; - - public: virtual unsigned int SceneCount() const override; - - public: virtual bool HasScene(ConstScenePtr _scene) const override; - - public: virtual bool HasSceneId(unsigned int _id) const override; - - public: virtual bool HasSceneName(const std::string &_name) const - override; - - public: virtual ScenePtr SceneById(unsigned int _id) const override; - - public: virtual ScenePtr SceneByName(const std::string &_name) const - override; - - public: virtual ScenePtr SceneByIndex(unsigned int _index) const override; - - public: virtual void DestroyScene(ScenePtr _scene) override; - - public: virtual void DestroySceneById(unsigned int _id) override; - - public: virtual void DestroySceneByName(const std::string &_name) - override; - - public: virtual void DestroySceneByIndex(unsigned int _index) override; - - public: virtual void DestroyScenes() override; - - public: virtual ScenePtr CreateScene(const std::string &_name) override; - - public: virtual ScenePtr CreateScene(unsigned int _id, - const std::string &_name) override; - - public: virtual void Destroy() override; - - // Documentation Inherited - public: virtual void AddResourcePath(const std::string &_path) override; - - // Documentation Inherited - public: virtual void SetHeadless(bool _headless) override; - - // Documentation Inherited - public: virtual bool Headless() const override; - - // Documentation Inherited - public: virtual RenderPassSystemPtr RenderPassSystem() const override; - - protected: virtual void PrepareScene(ScenePtr _scene); - - protected: virtual unsigned int NextSceneId(); - - /// \brief Engine implementation of Load function. - /// \param[in] _params Parameters to be passed to the render engine. - protected: virtual bool LoadImpl( - const std::map &_params) = 0; - - protected: virtual bool InitImpl() = 0; - - protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual SceneStorePtr Scenes() const = 0; - - protected: bool loaded = false; - - protected: bool initialized = false; - - protected: bool isHeadless = false; - - /// \brief ID from a external window - protected: std::string winID = ""; - - protected: unsigned int nextSceneId; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief a list of paths that render engines use to locate their - /// resources - protected: std::vector resourcePaths; - - /// \brief Render pass system for this render engine. - protected: RenderPassSystemPtr renderPassSystem; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseRenderPass.hh b/include/ignition/rendering/base/BaseRenderPass.hh index 347cdc211..b758dfe90 100644 --- a/include/ignition/rendering/base/BaseRenderPass.hh +++ b/include/ignition/rendering/base/BaseRenderPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,71 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASERENDERPASS_HH_ -#define IGNITION_RENDERING_BASE_BASERENDERPASS_HH_ -#include -#include "ignition/rendering/RenderPass.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class BaseRenderPass BaseRenderPass.hh \ - * ignition/rendering/base/BaseRenderPass.hh - */ - /// \brief Base render pass that can be applied to a render target - template - class BaseRenderPass: - public virtual RenderPass, - public T - { - /// \brief Constructor - protected: BaseRenderPass(); - - /// \brief Destructor - public: virtual ~BaseRenderPass(); - - // Documentation inherited - public: virtual void SetEnabled(bool _enabled) override; - - // Documentation inherited - public: virtual bool IsEnabled() const override; - - /// \brief Flag to indicate if render pass is enabled or not - protected: bool enabled = true; - }; - - ////////////////////////////////////////////////// - // BaseRenderPass - ////////////////////////////////////////////////// - template - BaseRenderPass::BaseRenderPass() - { - } - - ////////////////////////////////////////////////// - template - BaseRenderPass::~BaseRenderPass() - { - } - - ////////////////////////////////////////////////// - template - void BaseRenderPass::SetEnabled(bool _enabled) - { - this->enabled = _enabled; - } - - ////////////////////////////////////////////////// - template - bool BaseRenderPass::IsEnabled() const - { - return this->enabled; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseRenderTarget.hh b/include/ignition/rendering/base/BaseRenderTarget.hh index c0c795c79..546ad2f48 100644 --- a/include/ignition/rendering/base/BaseRenderTarget.hh +++ b/include/ignition/rendering/base/BaseRenderTarget.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,344 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASERENDERTARGET_HH_ -#define IGNITION_RENDERING_BASE_BASERENDERTARGET_HH_ -#include -#include - -#include "ignition/rendering/RenderPass.hh" -#include "ignition/rendering/RenderTarget.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseRenderTarget : - public virtual RenderTarget, - public virtual T - { - public: BaseRenderTarget(); - - public: virtual ~BaseRenderTarget(); - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - public: virtual unsigned int Width() const override; - - public: virtual void SetWidth(const unsigned int _width) override; - - public: virtual unsigned int Height() const override; - - public: virtual void SetHeight(const unsigned int _height) override; - - public: virtual PixelFormat Format() const override; - - public: virtual void SetFormat(PixelFormat _format) override; - - // Documentation inherited - public: virtual math::Color BackgroundColor() const override; - - // Documentation inherited - public: virtual void AddRenderPass(const RenderPassPtr &_pass) override; - - // Documentation inherited - public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) - override; - - // Documentation inherited - public: virtual unsigned int RenderPassCount() const override; - - // Documentation inherited - public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) - const override; - - protected: virtual void Rebuild(); - - protected: virtual void RebuildImpl() = 0; - - protected: PixelFormat format = PF_UNKNOWN; - - protected: bool targetDirty = true; - - /// \brief Flag to indicate if render pass need to be rebuilt - protected: bool renderPassDirty = false; - - protected: unsigned int width = 0u; - - protected: unsigned int height = 0u; - - /// \brief A chain of render passes applied to the render target - protected: std::vector renderPasses; - }; - - template - class BaseRenderTexture : - public virtual RenderTexture, - public virtual T - { - public: BaseRenderTexture(); - - public: virtual ~BaseRenderTexture(); - - // Documentation inherited. - public: virtual unsigned int GLId() const override; - }; - - template - class BaseRenderWindow : - public virtual RenderWindow, - public virtual T - { - public: BaseRenderWindow(); - - public: virtual ~BaseRenderWindow(); - - public: virtual std::string Handle() const; - - public: virtual void SetHandle(const std::string &_handle); - - public: virtual double DevicePixelRatio() const; - - public: virtual void SetDevicePixelRatio(const double _ratio); - - public: virtual void OnResize(const unsigned int _width, - const unsigned int _height); - - public: virtual void OnMove(); - - protected: std::string handle; - - protected: double ratio = 1.0; - }; - - ////////////////////////////////////////////////// - // BaseRenderTarget - ////////////////////////////////////////////////// - template - BaseRenderTarget::BaseRenderTarget() - { - } - - ////////////////////////////////////////////////// - template - BaseRenderTarget::~BaseRenderTarget() - { - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::PreRender() - { - T::PreRender(); - this->Rebuild(); - for (auto &pass : this->renderPasses) - pass->PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::PostRender() - { - T::PostRender(); - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::Rebuild() - { - if (this->targetDirty) - { - this->RebuildImpl(); - this->targetDirty = false; - } - } - - ////////////////////////////////////////////////// - template - unsigned int BaseRenderTarget::Width() const - { - return this->width; - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::SetWidth(const unsigned int _width) - { - this->width = _width; - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - unsigned int BaseRenderTarget::Height() const - { - return this->height; - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::SetHeight(const unsigned int _height) - { - this->height = _height; - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - PixelFormat BaseRenderTarget::Format() const - { - return this->format; - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::SetFormat(PixelFormat _format) - { - this->format = PixelUtil::Sanitize(_format); - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - math::Color BaseRenderTarget::BackgroundColor() const - { - return this->Scene()->BackgroundColor(); - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::AddRenderPass(const RenderPassPtr &_pass) - { - this->renderPasses.push_back(_pass); - this->renderPassDirty = true; - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::RemoveRenderPass(const RenderPassPtr &_pass) - { - auto it = std::find(this->renderPasses.begin(), this->renderPasses.end(), - _pass); - if (it != this->renderPasses.end()) - { - (*it)->Destroy(); - this->renderPasses.erase(it); - this->renderPassDirty = true; - } - } - - ////////////////////////////////////////////////// - template - unsigned int BaseRenderTarget::RenderPassCount() const - { - return this->renderPasses.size(); - } - - ////////////////////////////////////////////////// - template - RenderPassPtr BaseRenderTarget::RenderPassByIndex(unsigned int _index) - const - { - if (_index > this->renderPasses.size()) - { - ignerr << "RenderPass index out of range: " << _index << std::endl; - return RenderPassPtr(); - } - return this->renderPasses[_index]; - } - - ////////////////////////////////////////////////// - // BaseRenderTexture - ////////////////////////////////////////////////// - template - BaseRenderTexture::BaseRenderTexture() - { - } - - ////////////////////////////////////////////////// - template - BaseRenderTexture::~BaseRenderTexture() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseRenderTexture::GLId() const - { - return 0u; - } - - ////////////////////////////////////////////////// - // BaseRenderWindow - ////////////////////////////////////////////////// - template - BaseRenderWindow::BaseRenderWindow() - { - } - - ////////////////////////////////////////////////// - template - BaseRenderWindow::~BaseRenderWindow() - { - } - - ////////////////////////////////////////////////// - template - std::string BaseRenderWindow::Handle() const - { - return this->handle; - } - - ////////////////////////////////////////////////// - template - void BaseRenderWindow::SetHandle(const std::string &_handle) - { - this->handle = _handle; - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - double BaseRenderWindow::DevicePixelRatio() const - { - return this->ratio; - } - - ////////////////////////////////////////////////// - template - void BaseRenderWindow::SetDevicePixelRatio(const double _ratio) - { - this->ratio = _ratio; - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - void BaseRenderWindow::OnResize(const unsigned int _width, - const unsigned int _height) - { - this->width = _width; - this->height = _height; - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - void BaseRenderWindow::OnMove() - { - this->targetDirty = true; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseRenderTypes.hh b/include/ignition/rendering/base/BaseRenderTypes.hh index ebc1004cb..578bc4af8 100644 --- a/include/ignition/rendering/base/BaseRenderTypes.hh +++ b/include/ignition/rendering/base/BaseRenderTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,34 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASERENDERTYPES_HH_ -#define IGNITION_RENDERING_BASE_BASERENDERTYPES_HH_ -#include - -#include "ignition/rendering/RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class BaseNodeCompositeStore; - typedef shared_ptr BaseNodeCompositeStorePtr; - - class BaseObject; - typedef std::shared_ptr BaseObjectPtr; - - template class BaseSceneStore; - template class BaseNodeStore; - template class BaseLightStore; - template class BaseSensorStore; - template class BaseVisualStore; - template class BaseGeometryStore; - template class BaseSubMeshStore; - template class BaseMaterialMap; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseScene.hh b/include/ignition/rendering/base/BaseScene.hh index 29d30a015..a27964e73 100644 --- a/include/ignition/rendering/base/BaseScene.hh +++ b/include/ignition/rendering/base/BaseScene.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,853 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASESCENE_HH_ -#define IGNITION_RENDERING_BASE_BASESCENE_HH_ -#include -#include -#include - -#include -#include - -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_VISIBLE BaseScene : - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public std::enable_shared_from_this, - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - public virtual Scene - { - protected: BaseScene(unsigned int _id, const std::string &_name); - - public: virtual ~BaseScene(); - - public: virtual void Load() override; - - public: virtual void Init() override; - - public: virtual void Fini() override; - - public: virtual bool IsLoaded() const; - - public: virtual bool IsInitialized() const override; - - public: virtual unsigned int Id() const override; - - public: virtual std::string Name() const override; - - public: virtual void IGN_DEPRECATED(4) - SetSimTime(const common::Time &_time) override; - - public: virtual common::Time IGN_DEPRECATED(4) SimTime() const override; - - public: virtual std::chrono::steady_clock::duration Time() - const override; - - public: virtual void SetTime( - const std::chrono::steady_clock::duration &_time) override; - - public: virtual void SetAmbientLight(double _r, double _g, double _b, - double _a = 1.0) override; - - public: virtual void SetAmbientLight(const math::Color &_color) - override = 0; - - public: virtual math::Color BackgroundColor() const override; - - public: virtual void SetBackgroundColor(double _r, double _g, double _b, - double _a = 1.0) override; - - public: virtual void SetBackgroundColor(const math::Color &_color) - override; - - // Documentation inherited. - public: virtual bool IsGradientBackgroundColor() const override; - - // Documentation inherited. - public: virtual std::array GradientBackgroundColor() - const override; - - // Documentation inherited. - public: virtual void SetGradientBackgroundColor( - const std::array &_colors) override; - - // Documentation inherited. - public: virtual void RemoveGradientBackgroundColor() override; - - // Documentation inherited. - public: virtual MaterialPtr BackgroundMaterial() const override; - - // Documentation inherited. - public: virtual void SetBackgroundMaterial(MaterialPtr _material) - override; - - public: virtual unsigned int NodeCount() const override; - - public: virtual bool HasNode(ConstNodePtr _node) const override; - - public: virtual bool HasNodeId(unsigned int _id) const override; - - public: virtual bool HasNodeName(const std::string &_name) const override; - - public: virtual NodePtr NodeById(unsigned int _id) const override; - - public: virtual NodePtr NodeByName(const std::string &_name) const - override; - - public: virtual NodePtr NodeByIndex(unsigned int _index) const override; - - // Documentation inherited. - public: virtual void DestroyNode(NodePtr _node, bool _recursive = false) - override; - - public: virtual void DestroyNodeById(unsigned int _id) override; - - public: virtual void DestroyNodeByName(const std::string &_name) override; - - public: virtual void DestroyNodeByIndex(unsigned int _index) override; - - public: virtual void DestroyNodes() override; - - public: virtual unsigned int LightCount() const override; - - public: virtual bool HasLight(ConstLightPtr _light) const override; - - public: virtual bool HasLightId(unsigned int _id) const override; - - public: virtual bool HasLightName(const std::string &_name) const - override; - - public: virtual LightPtr LightById(unsigned int _id) const override; - - public: virtual LightPtr LightByName(const std::string &_name) const - override; - - public: virtual LightPtr LightByIndex(unsigned int _index) const override; - - // Documentation inherited. - public: virtual void DestroyLight(LightPtr _light, - bool _recursive = false) override; - - public: virtual void DestroyLightById(unsigned int _id) override; - - public: virtual void DestroyLightByName(const std::string &_name) - override; - - public: virtual void DestroyLightByIndex(unsigned int _index) override; - - public: virtual void DestroyLights() override; - - public: virtual unsigned int SensorCount() const override; - - public: virtual bool HasSensor(ConstSensorPtr _sensor) const override; - - public: virtual bool HasSensorId(unsigned int _id) const override; - - public: virtual bool HasSensorName(const std::string &_name) const - override; - - public: virtual SensorPtr SensorById(unsigned int _id) const override; - - public: virtual SensorPtr SensorByName(const std::string &_name) const - override; - - public: virtual SensorPtr SensorByIndex(unsigned int _index) const - override; - - // Documentation inherited. - public: virtual void DestroySensor(SensorPtr _sensor, - bool _recursive = false) override; - - public: virtual void DestroySensorById(unsigned int _id) override; - - public: virtual void DestroySensorByName(const std::string &_name) - override; - - public: virtual void DestroySensorByIndex(unsigned int _index) override; - - public: virtual void DestroySensors() override; - - public: virtual unsigned int VisualCount() const override; - - public: virtual bool HasVisual(ConstVisualPtr _visual) const override; - - public: virtual bool HasVisualId(unsigned int _id) const override; - - public: virtual bool HasVisualName(const std::string &_name) const - override; - - public: virtual VisualPtr VisualById(unsigned int _id) const override; - - public: virtual VisualPtr VisualByName(const std::string &_name) const - override; - - public: virtual VisualPtr VisualByIndex(unsigned int _index) const - override; - - // Documentation inherited - public: virtual VisualPtr VisualAt(const CameraPtr &_camera, - const ignition::math::Vector2i &_mousePos) override; - - // Documentation inherited. - public: virtual void DestroyVisual(VisualPtr _visual, - bool _recursive = false) override; - - public: virtual void DestroyVisualById(unsigned int _id) override; - - public: virtual void DestroyVisualByName(const std::string &_name) - override; - - public: virtual void DestroyVisualByIndex(unsigned int _index) override; - - public: virtual void DestroyVisuals() override; - - public: virtual bool MaterialRegistered(const std::string &_name) const - override; - - public: virtual MaterialPtr Material(const std::string &_name) const - override; - - public: virtual void RegisterMaterial(const std::string &_name, - MaterialPtr _material) override; - - public: virtual void UnregisterMaterial(const std::string &_name) - override; - - public: virtual void UnregisterMaterials() override; - - // Documentation inherited - public: virtual void DestroyMaterial(MaterialPtr _material) override; - - // Documentation inherited - public: virtual void DestroyMaterials() override; - - public: virtual DirectionalLightPtr CreateDirectionalLight() override; - - public: virtual DirectionalLightPtr CreateDirectionalLight( - unsigned int _id) override; - - public: virtual DirectionalLightPtr CreateDirectionalLight( - const std::string &_name) override; - - public: virtual DirectionalLightPtr CreateDirectionalLight( - unsigned int _id, const std::string &_name) override; - - public: virtual PointLightPtr CreatePointLight() override; - - public: virtual PointLightPtr CreatePointLight(unsigned int _id) override; - - public: virtual PointLightPtr CreatePointLight(const std::string &_name) - override; - - public: virtual PointLightPtr CreatePointLight(unsigned int _id, - const std::string &_name) override; - - /// \brief Implementation for creating CoM visual. - /// \param[in] _id Unique id - /// \param[in] _name Name of CoM visual - /// \return Pointer to a CoM visual object - protected: virtual COMVisualPtr CreateCOMVisualImpl(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Implementation for creating Inertia visual. - /// \param[in] _id Unique id - /// \param[in] _name Name of inertia visual - /// \return Pointer to a inertia visual object - protected: virtual InertiaVisualPtr CreateInertiaVisualImpl( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Implementation for creating Joint visual. - /// \param[in] _id Unique id - /// \param[in] _name Name of Joint visual - /// \return Pointer to a joint visual object - protected: virtual JointVisualPtr CreateJointVisualImpl(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Implementation for creating Light visual. - /// \param[in] _id Unique id - /// \param[in] _name Name of light visual - /// \return Pointer to a light visual object - protected: virtual LightVisualPtr CreateLightVisualImpl(unsigned int _id, - const std::string &_name) = 0; - - public: virtual SpotLightPtr CreateSpotLight() override; - - public: virtual SpotLightPtr CreateSpotLight(unsigned int _id) override; - - public: virtual SpotLightPtr CreateSpotLight(const std::string &_name) - override; - - public: virtual SpotLightPtr CreateSpotLight(unsigned int _id, - const std::string &_name) override; - - public: virtual CameraPtr CreateCamera() override; - - public: virtual CameraPtr CreateCamera(unsigned int _id) override; - - public: virtual CameraPtr CreateCamera(const std::string &_name) override; - - public: virtual CameraPtr CreateCamera(unsigned int _id, - const std::string &_name) override; - - public: virtual DepthCameraPtr CreateDepthCamera() override; - - public: virtual DepthCameraPtr CreateDepthCamera(const unsigned int _id) - override; - - public: virtual DepthCameraPtr CreateDepthCamera( - const std::string &_name) override; - - public: virtual DepthCameraPtr CreateDepthCamera(const unsigned int _id, - const std::string &_name) override; - - // Documentation inherited. - public: virtual ThermalCameraPtr CreateThermalCamera() override; - - // Documentation inherited. - public: virtual ThermalCameraPtr CreateThermalCamera( - const unsigned int _id) override; - - // Documentation inherited. - public: virtual ThermalCameraPtr CreateThermalCamera( - const std::string &_name) override; - - // Documentation inherited. - public: virtual ThermalCameraPtr CreateThermalCamera( - const unsigned int _id, const std::string &_name) override; - - // Documentation inherited. - public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera() override; - - // Documentation inherited. - public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( - const unsigned int _id) override; - - // Documentation inherited. - public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( - const std::string &_name) override; - - // Documentation inherited. - public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera( - const unsigned int _id, const std::string &_name) override; - - // Documentation inherited. - public: virtual SegmentationCameraPtr CreateSegmentationCamera() override; - - // Documentation inherited. - public: virtual SegmentationCameraPtr CreateSegmentationCamera( - const unsigned int _id) override; - - // Documentation inherited. - public: virtual SegmentationCameraPtr CreateSegmentationCamera( - const std::string &_name) override; - - // Documentation inherited. - public: virtual SegmentationCameraPtr CreateSegmentationCamera( - const unsigned int _id, const std::string &_name) override; - - // Documentation inherited. - public: virtual GpuRaysPtr CreateGpuRays() override; - - // Documentation inherited. - public: virtual GpuRaysPtr CreateGpuRays(const unsigned int _id) override; - - // Documentation inherited. - public: virtual GpuRaysPtr CreateGpuRays( - const std::string &_name) override; - - // Documentation inherited. - public: virtual GpuRaysPtr CreateGpuRays(const unsigned int _id, - const std::string &_name) override; - - public: virtual VisualPtr CreateVisual() override; - - public: virtual VisualPtr CreateVisual(unsigned int _id) override; - - public: virtual VisualPtr CreateVisual(const std::string &_name) override; - - public: virtual VisualPtr CreateVisual(unsigned int _id, - const std::string &_name) override; - - public: virtual ArrowVisualPtr CreateArrowVisual() override; - - public: virtual ArrowVisualPtr CreateArrowVisual(unsigned int _id) - override; - - public: virtual ArrowVisualPtr CreateArrowVisual( - const std::string &_name) override; - - public: virtual ArrowVisualPtr CreateArrowVisual(unsigned int _id, - const std::string &_name) override; - - public: virtual AxisVisualPtr CreateAxisVisual() override; - - public: virtual AxisVisualPtr CreateAxisVisual(unsigned int _id) override; - - public: virtual AxisVisualPtr CreateAxisVisual(const std::string &_name) - override; - - public: virtual AxisVisualPtr CreateAxisVisual(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - public: virtual COMVisualPtr CreateCOMVisual() override; - - // Documentation inherited - public: virtual COMVisualPtr CreateCOMVisual(unsigned int _id) - override; - - // Documentation inherited - public: virtual COMVisualPtr CreateCOMVisual(const std::string &_name) - override; - - // Documentation inherited - public: virtual COMVisualPtr CreateCOMVisual(unsigned int _id, - const std::string &_name) override; - - public: virtual InertiaVisualPtr CreateInertiaVisual() override; - - // Documentation inherited - public: virtual InertiaVisualPtr CreateInertiaVisual(unsigned int _id) - override; - - // Documentation inherited - public: virtual InertiaVisualPtr CreateInertiaVisual( - const std::string &_name) override; - - // Documentation inherited - public: virtual InertiaVisualPtr CreateInertiaVisual(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - public: virtual JointVisualPtr CreateJointVisual() override; - - // Documentation inherited - public: virtual JointVisualPtr CreateJointVisual(unsigned int _id) - override; - - // Documentation inherited - public: virtual JointVisualPtr CreateJointVisual( - const std::string &_name) override; - - // Documentation inherited - public: virtual JointVisualPtr CreateJointVisual(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - public: virtual LightVisualPtr CreateLightVisual() override; - - // Documentation inherited - public: virtual LightVisualPtr CreateLightVisual(unsigned int _id) - override; - - // Documentation inherited - public: virtual LightVisualPtr CreateLightVisual(const std::string &_name) - override; - - // Documentation inherited - public: virtual LightVisualPtr CreateLightVisual(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - public: virtual GizmoVisualPtr CreateGizmoVisual() override; - - // Documentation inherited - public: virtual GizmoVisualPtr CreateGizmoVisual(unsigned int _id) - override; - - // Documentation inherited - public: virtual GizmoVisualPtr CreateGizmoVisual(const std::string &_name) - override; - - // Documentation inherited - public: virtual GizmoVisualPtr CreateGizmoVisual(unsigned int _id, - const std::string &_name) override; - - - public: virtual GeometryPtr CreateBox() override; - - public: virtual GeometryPtr CreateCone() override; - - public: virtual GeometryPtr CreateCylinder() override; - - public: virtual GeometryPtr CreatePlane() override; - - public: virtual GeometryPtr CreateSphere() override; - - public: virtual MeshPtr CreateMesh(const std::string &_meshName) override; - - public: virtual MeshPtr CreateMesh(const common::Mesh *_mesh) override; - - public: virtual MeshPtr CreateMesh(const MeshDescriptor &_desc) override; - - // Documentation inherited. - public: virtual CapsulePtr CreateCapsule() override; - - // Documentation inherited. - public: virtual GridPtr CreateGrid() override; - - // Documentation inherited. - public: virtual MarkerPtr CreateMarker() override; - - // Documentation inherited. - public: virtual LidarVisualPtr CreateLidarVisual() override; - - // Documentation inherited. - public: virtual LidarVisualPtr CreateLidarVisual( - unsigned int _id) override; - - // Documentation inherited. - public: virtual LidarVisualPtr CreateLidarVisual( - const std::string &_name) override; - - // Documentation inherited. - public: virtual LidarVisualPtr CreateLidarVisual(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited. - public: virtual HeightmapPtr CreateHeightmap( - const HeightmapDescriptor &_desc) override; - - // Documentation inherited. - public: virtual WireBoxPtr CreateWireBox() override; - - // Documentation inherited. - public: virtual TextPtr CreateText() override; - - public: virtual MaterialPtr CreateMaterial(const std::string &_name = "") - override; - - public: virtual MaterialPtr CreateMaterial( - const common::Material &_material) override; - - public: virtual RenderTexturePtr CreateRenderTexture() override; - - // Documentation inherited. - public: virtual RenderWindowPtr CreateRenderWindow() override; - - public: virtual RayQueryPtr CreateRayQuery() override; - - // Documentation inherited. - public: virtual ParticleEmitterPtr CreateParticleEmitter() override; - - // Documentation inherited. - public: virtual ParticleEmitterPtr CreateParticleEmitter(unsigned int _id) - override; - - // Documentation inherited. - public: virtual ParticleEmitterPtr CreateParticleEmitter( - const std::string &_name) override; - - // Documentation inherited. - public: virtual ParticleEmitterPtr CreateParticleEmitter( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited. - public: virtual void SetSkyEnabled(bool _enabled) override; - - // Documentation inherited. - public: virtual bool SkyEnabled() const override; - - public: virtual void PreRender() override; - - public: virtual void Clear() override; - - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - // Documentation inherited. - public: virtual void SetCameraPassCountPerGpuFlush( - uint8_t _numPass) override; - - // Documentation inherited. - public: virtual uint8_t CameraPassCountPerGpuFlush() const override; - - // Documentation inherited. - public: virtual bool LegacyAutoGpuFlush() const override; - - protected: virtual unsigned int CreateObjectId(); - - protected: virtual std::string CreateObjectName(unsigned int _id, - const std::string &_prefix); - - protected: virtual bool RegisterLight(LightPtr _light); - - protected: virtual bool RegisterSensor(SensorPtr _vensor); - - protected: virtual bool RegisterVisual(VisualPtr _visual); - - protected: virtual DirectionalLightPtr CreateDirectionalLightImpl( - unsigned int _id, const std::string &_name) = 0; - - protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual CameraPtr CreateCameraImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Implementation for creating a thermal camera. - /// \param[in] _id Unique id - /// \param[in] _name Name of thermal camera - protected: virtual ThermalCameraPtr CreateThermalCameraImpl( - unsigned int _id, const std::string &_name) - { - // The following two lines will avoid doxygen warnings - (void)_id; - (void)_name; - ignerr << "Thermal camera not supported by: " - << this->Engine()->Name() << std::endl; - return ThermalCameraPtr(); - } - - /// \brief Implementation for creating a BoundingBox camera. - /// \param[in] _id Unique id - /// \param[in] _name Name of BoundingBox camera - /// \return Pointer to BoundingBox camera - protected: virtual BoundingBoxCameraPtr CreateBoundingBoxCameraImpl( - unsigned int _id, const std::string &_name) - { - // The following two lines will avoid doxygen warnings - (void)_id; - (void)_name; - ignerr << "BoundingBox camera not supported by: " - << this->Engine()->Name() << std::endl; - return BoundingBoxCameraPtr(); - } - - /// \brief Implementation for creating a segmentation camera. - /// \param[in] _id Unique id - /// \param[in] _name Name of segmentation camera - /// \return Pointer to segmentation camera - protected: virtual SegmentationCameraPtr CreateSegmentationCameraImpl( - unsigned int _id, - const std::string &_name) - { - // The following two lines will avoid doxygen warnings - (void)_id; - (void)_name; - ignerr << "Segmentation camera not supported by: " - << this->Engine()->Name() << std::endl; - return SegmentationCameraPtr(); - } - - /// \brief Implementation for creating GpuRays sensor. - /// \param[in] _id Unique id - /// \param[in] _name Name of GpuRays sensor - protected: virtual GpuRaysPtr CreateGpuRaysImpl(unsigned int _id, - const std::string & _name) - { - (void)_id; - (void)_name; - ignerr << "GpuRays not supported by: " - << this->Engine()->Name() << std::endl; - return GpuRaysPtr(); - } - - protected: virtual VisualPtr CreateVisualImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Implementation for creating a GizmoVisual. - /// \param[in] _id Unique id - /// \param[in] _name Name of GizmoVisual - protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id, - const std::string &_name) - { - (void)_id; - (void)_name; - ignerr << "GizmoVisual not supported by: " - << this->Engine()->Name() << std::endl; - return GizmoVisualPtr(); - } - - protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual GeometryPtr CreateConeImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, - const std::string &_name, - const MeshDescriptor &_desc) = 0; - - /// \brief Implementation for creating a capsule geometry object - /// \param[in] _id unique object id. - /// \param[in] _name unique object name. - /// \return Pointer to a capsule geometry object - protected: virtual CapsulePtr CreateCapsuleImpl(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Implementation for creating a grid geometry object - /// \param[in] _id unique object id. - /// \param[in] _name unique object name. - /// \return Pointer to a grid geometry object - protected: virtual GridPtr CreateGridImpl(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Implementation for creating a marker geometry object - /// \param[in] _id unique object id. - /// \param[in] _name unique object name. - /// \return Pointer to a marker geometry object - protected: virtual MarkerPtr CreateMarkerImpl(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Implementation for creating a lidar visual - /// \param[in] _id unique object id. - /// \param[in] _name unique object name. - /// \return Pointer to a lidar visual - protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Implementation for creating a heightmap geometry - /// \param[in] _id Unique object id. - /// \param[in] _name Unique object name. - /// \param[in] _desc Heightmap descriptor. - /// \return Pointer to a heightmap geometry. - protected: virtual HeightmapPtr CreateHeightmapImpl(unsigned int _id, - const std::string &_name, - const HeightmapDescriptor &_desc) = 0; - - /// \brief Implementation for creating a wire box geometry - /// \param[in] _id unique object id. - /// \param[in] _name unique object name. - /// \return Pointer to a wire box geometry object - protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Implementation for creating a text's geometry object - /// \param[in] _id unique object id. - /// \param[in] _name unique object name. - /// \return Pointer to a text geometry object - protected: virtual TextPtr CreateTextImpl(unsigned int _id, - const std::string &_name); - - protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id, - const std::string &_name) = 0; - - protected: virtual RenderTexturePtr CreateRenderTextureImpl( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Render engine specific implementation for creating a render - /// window - /// \param[in] _id unique object id - /// \param[in] _name object name - /// \return Pointer to the created render window. - protected: virtual RenderWindowPtr CreateRenderWindowImpl( - unsigned int _id, const std::string &_name) = 0; - - protected: virtual RayQueryPtr CreateRayQueryImpl( - unsigned int _id, const std::string &_name) = 0; - - /// \brief Implementation for creating a ParticleEmitter. - /// \param[in] _id Unique id. - /// \param[in] _name Name of ParticleEmitter. - /// \return Pointer to the created particle emitter. - protected: virtual ParticleEmitterPtr CreateParticleEmitterImpl( - unsigned int _id, const std::string &_name) - { - (void)_id; - (void)_name; - ignerr << "ParticleEmitter not supported by: " - << this->Engine()->Name() << std::endl; - return ParticleEmitterPtr(); - } - - protected: virtual LightStorePtr Lights() const = 0; - - protected: virtual SensorStorePtr Sensors() const = 0; - - protected: virtual VisualStorePtr Visuals() const = 0; - - protected: virtual MaterialMapPtr Materials() const = 0; - - protected: virtual bool LoadImpl() = 0; - - protected: virtual bool InitImpl() = 0; - - private: virtual void CreateNodeStore(); - - private: virtual void CreateMaterials(); - - /// \brief Helper function to recursively destory nodes while checking - /// for loops. - /// \param[in] _node Node to be destroyed - /// \param[in] _nodeId Holds all node ids that have been visited in the - /// tree during the destroy process. Used for loop detection. - private: void DestroyNodeRecursive(NodePtr _node, - std::set &_nodeIds); - - protected: unsigned int id; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: std::string name; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - protected: common::Time IGN_DEPRECATED(4) simTime; - - protected: std::chrono::steady_clock::duration time = - std::chrono::steady_clock::duration::zero(); - - protected: bool loaded; - - protected: bool initialized; - - /// \brief Scene background color. Default should be black. - protected: math::Color backgroundColor; - - /// \brief The four corners of the gradient background color. - /// Next is the description of how to interpret each value of the array: - /// 0: Top left corner color. - /// 1: Bottom left corner color. - /// 2: Top right corner color. - /// 3: Bottom right corner color. - /// Default should be black. - protected: std::array gradientBackgroundColor; - - /// \brief Whether the scene has a gradient background. - protected: bool isGradientBackgroundColor = false; - - /// \brief Scene background material. - protected: MaterialPtr backgroundMaterial; - - private: unsigned int nextObjectId; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: NodeStorePtr nodes; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseSegmentationCamera.hh b/include/ignition/rendering/base/BaseSegmentationCamera.hh index c74fea088..ebb9d70de 100644 --- a/include/ignition/rendering/base/BaseSegmentationCamera.hh +++ b/include/ignition/rendering/base/BaseSegmentationCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,185 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_ -#define IGNITION_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_ -#include - -#include - -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/SegmentationCamera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - template - class BaseSegmentationCamera : - public virtual SegmentationCamera, - public virtual BaseCamera, - public virtual T - { - /// \brief Constructor - protected: BaseSegmentationCamera(); - - /// \brief Destructor - public: virtual ~BaseSegmentationCamera(); - - // Documentation inherited - public: virtual void CreateSegmentationTexture() override = 0; - - // Documentation inherited - public: virtual uint8_t *SegmentationData() const override; - - // Documentation inherited - public: virtual ignition::common::ConnectionPtr - ConnectNewSegmentationFrame( - std::function _subscriber) override; - - // Documentation inherited - public: virtual void SetSegmentationType( - SegmentationType _type) override; - - // Documentation inherited - public: virtual SegmentationType Type() const override; - - // Documentation inherited - public: virtual void EnableColoredMap(bool _enable) override; - - // Documentation inherited - public: virtual bool IsColoredMap() const override; - - // Documentation inherited - public: virtual void SetBackgroundColor( - const math::Color &_color) override; - - // Documentation inherited - public: virtual void SetBackgroundLabel(int _label) override; - - // Documentation inherited - public: virtual const math::Color &BackgroundColor() const override; - - // Documentation inherited - public: virtual int BackgroundLabel() const override; - - // Documentation inherited - public: void LabelMapFromColoredBuffer( - uint8_t *_labelBuffer) const override = 0; - - /// \brief The buffer that contains segmentation data - protected: uint8_t *segmentationData {nullptr}; - - /// \brief The segmentation type - protected: SegmentationType type {SegmentationType::ST_SEMANTIC}; - - /// \brief Whether a colored map is being generated (true) or label ID map - /// is being generated (false) - protected: bool isColoredMap {false}; - - /// \brief The color of objects that are considered background (i.e., - /// objects that have no label) - protected: math::Color backgroundColor {0, 0, 0}; - - /// \brief The label of background objects - protected: int backgroundLabel {0}; - }; - - ////////////////////////////////////////////////// - template - BaseSegmentationCamera::BaseSegmentationCamera() - { - } - - ////////////////////////////////////////////////// - template - BaseSegmentationCamera::~BaseSegmentationCamera() - { - if (this->segmentationData) - { - delete [] this->segmentationData; - this->segmentationData = nullptr; - } - } - - ////////////////////////////////////////////////// - template - uint8_t *BaseSegmentationCamera::SegmentationData() const - { - return this->segmentationData; - } - - ////////////////////////////////////////////////// - template - ignition::common::ConnectionPtr BaseSegmentationCamera:: - ConnectNewSegmentationFrame( - std::function) - { - return nullptr; - } - - ////////////////////////////////////////////////// - template - void BaseSegmentationCamera::SetSegmentationType(SegmentationType _type) - { - this->type = _type; - } - - ////////////////////////////////////////////////// - template - void BaseSegmentationCamera::EnableColoredMap(bool _enable) - { - this->isColoredMap = _enable; - } - - ////////////////////////////////////////////////// - template - SegmentationType BaseSegmentationCamera::Type() const - { - return this->type; - } - - ////////////////////////////////////////////////// - template - bool BaseSegmentationCamera::IsColoredMap() const - { - return this->isColoredMap; - } - - ////////////////////////////////////////////////// - template - void BaseSegmentationCamera::SetBackgroundColor( - const math::Color &_color) - { - this->backgroundColor = _color; - } - - ////////////////////////////////////////////////// - template - void BaseSegmentationCamera::SetBackgroundLabel(int _label) - { - this->backgroundLabel = _label; - } - - ////////////////////////////////////////////////// - template - const math::Color &BaseSegmentationCamera::BackgroundColor() const - { - return this->backgroundColor; - } - - ////////////////////////////////////////////////// - template - int BaseSegmentationCamera::BackgroundLabel() const - { - return this->backgroundLabel; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseSensor.hh b/include/ignition/rendering/base/BaseSensor.hh index 676ec3c11..0f41bad9e 100644 --- a/include/ignition/rendering/base/BaseSensor.hh +++ b/include/ignition/rendering/base/BaseSensor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,62 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASESENSOR_HH_ -#define IGNITION_RENDERING_BASE_BASESENSOR_HH_ -#include "ignition/rendering/Sensor.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseSensor : - public virtual Sensor, - public virtual T - { - protected: BaseSensor(); - - public: virtual ~BaseSensor(); - - // Documentation inherited. - public: virtual void SetVisibilityMask(uint32_t _mask) override; - - // Documentation inherited. - public: virtual uint32_t VisibilityMask() const override; - - /// \brief Camera's visibility mask - protected: uint32_t visibilityMask = IGN_VISIBILITY_ALL; - }; - - ////////////////////////////////////////////////// - template - BaseSensor::BaseSensor() - { - } - - ////////////////////////////////////////////////// - template - BaseSensor::~BaseSensor() - { - } - - ////////////////////////////////////////////////// - template - void BaseSensor::SetVisibilityMask(uint32_t _mask) - { - this->visibilityMask = _mask; - } - - ////////////////////////////////////////////////// - template - uint32_t BaseSensor::VisibilityMask() const - { - return this->visibilityMask; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseStorage.hh b/include/ignition/rendering/base/BaseStorage.hh index c3068d8c9..97ddef866 100644 --- a/include/ignition/rendering/base/BaseStorage.hh +++ b/include/ignition/rendering/base/BaseStorage.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,1452 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASESTORAGE_HH_ -#define IGNITION_RENDERING_BASE_BASESTORAGE_HH_ -#include -#include -#include -#include - -#include -#include - -#include "ignition/rendering/Storage.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - ////////////////////////////////////////////////// - template - class BaseMap : - public Map - { - typedef std::shared_ptr TPtr; - - typedef std::shared_ptr ConstTPtr; - - typedef std::shared_ptr UPtr; - - typedef std::map UMap; - - typedef typename UMap::iterator UIter; - - typedef typename UMap::const_iterator ConstUIter; - - public: BaseMap(); - - public: virtual ~BaseMap(); - - public: virtual unsigned int Size() const; - - public: virtual bool ContainsKey(const std::string &_key) const; - - public: virtual bool ContainsValue(ConstTPtr _value) const; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public: virtual TPtr Get(const std::string &_key) const; - - public: virtual TPtr GetByIndex(unsigned int _index) const; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - public: virtual bool Put(const std::string &_key, TPtr _value); - - public: virtual void Remove(const std::string &_key); - - public: virtual void Remove(TPtr _value); - - public: virtual void RemoveAll(); - - public: virtual UPtr Derived(const std::string &_key) const; - - public: virtual UPtr DerivedByIndex(unsigned int _index) const; - - protected: virtual bool IsValidIter(ConstUIter _iter) const; - - protected: UMap map; - }; - - ////////////////////////////////////////////////// - template - class BaseStore : - public Store - { - typedef std::shared_ptr TPtr; - - typedef std::shared_ptr ConstTPtr; - - typedef std::shared_ptr UPtr; - - typedef std::map UStore; - - typedef typename UStore::iterator UIter; - - typedef typename UStore::const_iterator ConstUIter; - - public: BaseStore(); - - public: virtual ~BaseStore(); - - public: virtual unsigned int Size() const; - - public: virtual bool Contains(ConstTPtr _object) const; - - public: virtual bool ContainsId(unsigned int _id) const; - - public: virtual bool ContainsName(const std::string &_name) const; - - public: virtual TPtr GetById(unsigned int _id) const; - - public: virtual TPtr GetByName(const std::string &_name) const; - - public: virtual TPtr GetByIndex(unsigned int _index) const; - - public: virtual bool Add(TPtr _object); - - public: virtual TPtr Remove(TPtr _object); - - public: virtual TPtr RemoveById(unsigned int _id); - - public: virtual TPtr RemoveByName(const std::string &_name); - - public: virtual TPtr RemoveByIndex(unsigned int _index); - - public: virtual void RemoveAll(); - - public: virtual void Destroy(TPtr _object); - - public: virtual void DestroyById(unsigned int _id); - - public: virtual void DestroyByName(const std::string &_name); - - public: virtual void DestroyByIndex(unsigned int _index); - - public: virtual void DestroyAll(); - - public: virtual UPtr DerivedById(unsigned int _id) const; - - public: virtual UPtr DerivedByName(const std::string &_name) const; - - public: virtual UPtr DerivedByIndex(unsigned int _index) const; - - public: virtual bool AddDerived(UPtr _object); - - public: virtual UPtr RemoveDerived(UPtr _object); - - public: virtual UPtr RemoveDerivedById(unsigned int _id); - - public: virtual UPtr RemoveDerivedByName(const std::string &_name); - - public: virtual UPtr RemoveDerivedByIndex(unsigned int _index); - - /// \brief Return an iterator to the beginning - /// \returns Iterator to beginning - public: virtual UIter Begin(); - - /// \brief Return an iterator to the end - /// \returns Iterator to end - public: virtual UIter End(); - - protected: virtual ConstUIter ConstIter(ConstTPtr _object) const; - - protected: virtual ConstUIter ConstIterById(unsigned int _id) const; - - protected: virtual ConstUIter ConstIterByName( - const std::string &_name) const; - - protected: virtual ConstUIter ConstIterByIndex(unsigned int _index) const; - - protected: virtual UIter Iter(ConstTPtr _object); - - protected: virtual UIter IterById(unsigned int _id); - - protected: virtual UIter IterByName(const std::string &_name); - - protected: virtual UIter IterByIndex(unsigned int _index); - - protected: virtual bool AddImpl(UPtr _object); - - protected: virtual UPtr RemoveImpl(UIter _iter); - - protected: virtual void DestroyImpl(UIter _iter); - - protected: virtual bool IsValidIter(ConstUIter _iter) const; - - protected: virtual UIter RemoveConstness(ConstUIter _iter); - - protected: UStore store; - }; - - ////////////////////////////////////////////////// - template - class BaseCompositeStore : - public CompositeStore - { - typedef std::shared_ptr TPtr; - - typedef std::shared_ptr ConstTPtr; - - typedef Store TStore; - - typedef std::shared_ptr TStorePtr; - - typedef std::shared_ptr ConstTStorePtr; - - typedef std::vector TStoreList; - - typedef typename TStoreList::iterator TStoreIter; - - public: BaseCompositeStore(); - - public: virtual ~BaseCompositeStore(); - - public: virtual unsigned int Size() const; - - public: virtual bool Contains(ConstTPtr _object) const; - - public: virtual bool ContainsId(unsigned int _id) const; - - public: virtual bool ContainsName(const std::string &_name) const; - - public: virtual TPtr GetById(unsigned int _id) const; - - public: virtual TPtr GetByName(const std::string &_name) const; - - public: virtual TPtr GetByIndex(unsigned int _index) const; - - public: virtual bool Add(TPtr _object); - - public: virtual TPtr Remove(TPtr _object); - - public: virtual TPtr RemoveById(unsigned int _id); - - public: virtual TPtr RemoveByName(const std::string &_name); - - public: virtual TPtr RemoveByIndex(unsigned int _index); - - public: virtual void RemoveAll(); - - public: virtual void Destroy(TPtr _object); - - public: virtual void DestroyById(unsigned int _id); - - public: virtual void DestroyByName(const std::string &_name); - - public: virtual void DestroyByIndex(unsigned int _index); - - public: virtual void DestroyAll(); - - public: virtual unsigned int GetStoreCount() const; - - public: virtual bool ContainsStore(ConstTStorePtr _store) const; - - public: virtual TStorePtr GetStore(unsigned int _index) const; - - public: virtual bool AddStore(TStorePtr _store); - - public: virtual TStorePtr RemoveStore(TStorePtr _store); - - public: virtual TStorePtr RemoveStore(unsigned int _index); - - public: virtual TStorePtr RemoveStoreImpl(TStoreIter _iter); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: TStoreList stores; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - - ////////////////////////////////////////////////// - template - class BaseStoreWrapper : - public StoreWrapper - { - typedef std::shared_ptr TPtr; - - typedef std::shared_ptr ConstTPtr; - - typedef std::shared_ptr UPtr; - - typedef std::shared_ptr ConstUPtr; - - typedef Store UStore; - - typedef std::shared_ptr UStorePtr; - - public: explicit BaseStoreWrapper(UStorePtr _store); - - public: virtual ~BaseStoreWrapper(); - - public: virtual unsigned int Size() const; - - public: virtual bool Contains(ConstTPtr _object) const; - - public: virtual bool ContainsId(unsigned int _id) const; - - public: virtual bool ContainsName(const std::string &_name) const; - - public: virtual TPtr GetById(unsigned int _id) const; - - public: virtual TPtr GetByName(const std::string &_name) const; - - public: virtual TPtr GetByIndex(unsigned int _index) const; - - public: virtual bool Add(TPtr _object); - - public: virtual TPtr Remove(TPtr _object); - - public: virtual TPtr RemoveById(unsigned int _id); - - public: virtual TPtr RemoveByName(const std::string &_name); - - public: virtual TPtr RemoveByIndex(unsigned int _index); - - public: virtual void RemoveAll(); - - public: virtual void Destroy(TPtr _object); - - public: virtual void DestroyById(unsigned int _id); - - public: virtual void DestroyByName(const std::string &_name); - - public: virtual void DestroyByIndex(unsigned int _index); - - public: virtual void DestroyAll(); - - protected: UStorePtr store; - }; - - ////////////////////////////////////////////////// - class BaseNodeCompositeStore : - public BaseCompositeStore - { - }; - - template - class BaseSceneStore : - public BaseStore - { - }; - - template - class BaseNodeStore : - public BaseStore - { - }; - - template - class BaseLightStore : - public BaseStore - { - }; - - template - class BaseSensorStore : - public BaseStore - { - }; - - template - class BaseVisualStore : - public BaseStore - { - }; - - template - class BaseGeometryStore : - public BaseStore - { - }; - - template - class BaseSubMeshStore : - public BaseStore - { - }; - - template - class BaseMaterialMap : - public BaseMap - { - }; - - ////////////////////////////////////////////////// - template - BaseMap::BaseMap() - { - } - - ////////////////////////////////////////////////// - template - BaseMap::~BaseMap() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseMap::Size() const - { - return this->map.size(); - } - - ////////////////////////////////////////////////// - template - bool BaseMap::ContainsKey(const std::string &_key) const - { - return this->map.count(_key) > 0; - } - - ////////////////////////////////////////////////// - template - bool BaseMap::ContainsValue(ConstTPtr _value) const - { - for (auto pair : this->map) - { - if (pair.second == _value) return true; - } - - return false; - } - - ////////////////////////////////////////////////// - template - typename BaseMap::TPtr - BaseMap::Get(const std::string &_key) const - { - return this->Derived(_key); - } - - ////////////////////////////////////////////////// - template - typename BaseMap::TPtr - BaseMap::GetByIndex(unsigned int _index) const - { - return this->DerivedByIndex(_index); - } - - ////////////////////////////////////////////////// - template - bool BaseMap::Put(const std::string &_key, TPtr _value) - { - if (_key.empty()) - { - ignerr << "Cannot store item with empty key" << std::endl; - return false; - } - - if (!_value) - { - ignerr << "Cannot store null pointer value" << std::endl; - return false; - } - - if (this->ContainsKey(_key)) - { - ignerr << "Item already registered with key: " << _key << std::endl; - return false; - } - - UPtr derived = std::dynamic_pointer_cast(_value); - - if (!derived) - { - ignerr << "Cannot add item created by another render-engine" - << std::endl; - - return false; - } - - this->map[_key] = derived; - return true; - } - - ////////////////////////////////////////////////// - template - void BaseMap::Remove(const std::string &_key) - { - auto iter = this->map.find(_key); - - if (this->IsValidIter(iter)) - { - this->map.erase(iter); - } - } - - ////////////////////////////////////////////////// - template - void BaseMap::Remove(TPtr _value) - { - auto iter = this->map.begin(); - - while (this->IsValidIter(iter)) - { - if (iter->second == _value) - { - this->map.erase(iter); - continue; - } - - ++iter; - } - } - - ////////////////////////////////////////////////// - template - void BaseMap::RemoveAll() - { - this->map.clear(); - } - - ////////////////////////////////////////////////// - template - typename BaseMap::UPtr - BaseMap::Derived(const std::string &_key) const - { - auto iter = this->map.find(_key); - return (this->IsValidIter(iter)) ? iter->second : nullptr; - } - - ////////////////////////////////////////////////// - template - typename BaseMap::UPtr - BaseMap::DerivedByIndex(unsigned int _index) const - { - if (_index >= this->Size()) - { - ignerr << "Invalid index: " << _index << std::endl; - return nullptr; - } - - auto iter = this->map.begin(); - std::advance(iter, _index); - return iter->second; - } - - ////////////////////////////////////////////////// - template - bool BaseMap::IsValidIter(ConstUIter _iter) const - { - return _iter != this->map.end(); - } - - ////////////////////////////////////////////////// - template - BaseStore::BaseStore() - { - } - - ////////////////////////////////////////////////// - template - BaseStore::~BaseStore() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseStore::Size() const - { - return this->store.size(); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::Begin() - { - return this->store.begin(); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::End() - { - return this->store.end(); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::Contains(ConstTPtr _object) const - { - auto iter = this->ConstIter(_object); - return this->IsValidIter(iter); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::ContainsId(unsigned int _id) const - { - auto iter = this->ConstIterById(_id); - return this->IsValidIter(iter); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::ContainsName(const std::string &_name) const - { - auto iter = this->ConstIterByName(_name); - return this->IsValidIter(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::GetById(unsigned int _id) const - { - return this->DerivedById(_id); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::GetByName(const std::string &_name) const - { - return this->DerivedByName(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::GetByIndex(unsigned int _index) const - { - return this->DerivedByIndex(_index); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::Add(TPtr _object) - { - if (!_object) - { - ignerr << "Cannot add null pointer" << std::endl; - return false; - } - - UPtr derived = std::dynamic_pointer_cast(_object); - - if (!derived) - { - ignerr << "Cannot add item created by another render-engine" - << std::endl; - - return false; - } - - return this->AddImpl(derived); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::Remove(TPtr _object) - { - auto iter = this->Iter(_object); - return this->RemoveImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::RemoveById(unsigned int _id) - { - return this->RemoveDerivedById(_id); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::RemoveByName(const std::string &_name) - { - return this->RemoveDerivedByName(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::RemoveByIndex(unsigned int _index) - { - return this->RemoveDerivedByIndex(_index); - } - - ////////////////////////////////////////////////// - template - void BaseStore::RemoveAll() - { - this->store.clear(); - } - - ////////////////////////////////////////////////// - template - void BaseStore::Destroy(TPtr _object) - { - auto iter = this->Iter(_object); - this->DestroyImpl(iter); - } - - ////////////////////////////////////////////////// - template - void BaseStore::DestroyById(unsigned int _id) - { - auto iter = this->IterById(_id); - this->DestroyImpl(iter); - } - - ////////////////////////////////////////////////// - template - void BaseStore::DestroyByName(const std::string &_name) - { - auto iter = this->IterByName(_name); - this->DestroyImpl(iter); - } - - ////////////////////////////////////////////////// - template - void BaseStore::DestroyByIndex(unsigned int _index) - { - auto iter = this->IterByIndex(_index); - this->DestroyImpl(iter); - } - - ////////////////////////////////////////////////// - template - void BaseStore::DestroyAll() - { - unsigned int i = this->Size(); - - while (i > 0) - { - this->DestroyByIndex(--i); - } - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::DerivedById(unsigned int _id) const - { - auto iter = this->ConstIterById(_id); - return (this->IsValidIter(iter)) ? iter->second : nullptr; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::DerivedByName(const std::string &_name) const - { - auto iter = this->ConstIterByName(_name); - return (this->IsValidIter(iter)) ? iter->second : nullptr; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::DerivedByIndex(unsigned int _index) const - { - auto iter = this->ConstIterByIndex(_index); - return (this->IsValidIter(iter)) ? iter->second : nullptr; - } - - ////////////////////////////////////////////////// - template - bool BaseStore::AddDerived(UPtr _object) - { - if (!_object) - { - ignerr << "Cannot add null pointer" << std::endl; - return false; - } - - return this->AddImpl(_object); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::RemoveDerived(UPtr _object) - { - auto iter = this->Iter(_object); - return this->RemoveImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::RemoveDerivedById(unsigned int _id) - { - auto iter = this->IterById(_id); - return this->RemoveImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::RemoveDerivedByName(const std::string &_name) - { - auto iter = this->IterByName(_name); - return this->RemoveImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::RemoveDerivedByIndex(unsigned int _index) - { - auto iter = this->IterByIndex(_index); - return this->RemoveImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::ConstUIter - BaseStore::ConstIter(ConstTPtr _object) const - { - auto begin = this->store.begin(); - auto end = this->store.end(); - - for (auto iter = begin; iter != end; ++iter) - { - if (iter->second == _object) - { - return iter; - } - } - - return end; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::ConstUIter - BaseStore::ConstIterById(unsigned int _id) const - { - auto begin = this->store.begin(); - auto end = this->store.end(); - - for (auto iter = begin; iter != end; ++iter) - { - if (iter->second->Id() == _id) - { - return iter; - } - } - - return end; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::ConstUIter - BaseStore::ConstIterByName(const std::string &_name) const - { - return this->store.find(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::ConstUIter - BaseStore::ConstIterByIndex(unsigned int _index) const - { - if (_index >= this->Size()) - { - ignerr << "Invalid index: " << _index << std::endl; - return this->store.end(); - } - - auto iter = this->store.begin(); - std::advance(iter, _index); - return iter; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::Iter(ConstTPtr _object) - { - auto iter = this->ConstIter(_object); - return this->RemoveConstness(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::IterById(unsigned int _id) - { - auto iter = this->ConstIterById(_id); - return this->RemoveConstness(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::IterByName(const std::string &_name) - { - auto iter = this->ConstIterByName(_name); - return this->RemoveConstness(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::IterByIndex(unsigned int _index) - { - auto iter = this->ConstIterByIndex(_index); - return this->RemoveConstness(iter); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::AddImpl(UPtr _object) - { - unsigned int id = _object->Id(); - std::string name = _object->Name(); - - if (this->ContainsId(id)) - { - ignerr << "Another item already exists with id: " << id << std::endl; - return false; - } - - if (this->ContainsName(name)) - { - ignerr << "Another item already exists with name: " << name - << std::endl; - return false; - } - - this->store[name] = _object; - return true; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::RemoveImpl(UIter _iter) - { - if (!this->IsValidIter(_iter)) - { - return nullptr; - } - - UPtr result = _iter->second; - this->store.erase(_iter); - return result; - } - - ////////////////////////////////////////////////// - template - void BaseStore::DestroyImpl(UIter _iter) - { - UPtr result = this->RemoveImpl(_iter); - if (result) result->Destroy(); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::IsValidIter(ConstUIter _iter) const - { - return _iter != this->store.end(); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::RemoveConstness(ConstUIter _iter) - { - return (this->IsValidIter(_iter)) ? - this->store.erase(_iter, _iter) : this->store.end(); - } - - ////////////////////////////////////////////////// - template - BaseCompositeStore::BaseCompositeStore() - { - } - - ////////////////////////////////////////////////// - template - BaseCompositeStore::~BaseCompositeStore() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCompositeStore::Size() const - { - unsigned int size = 0; - - for (auto store : this->stores) - { - size += store->Size(); - } - - return size; - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::Contains(ConstTPtr _object) const - { - for (auto store : this->stores) - { - if (store->Contains(_object)) return true; - } - - return false; - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::ContainsId(unsigned int _id) const - { - for (auto store : this->stores) - { - if (store->ContainsId(_id)) return true; - } - - return false; - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::ContainsName(const std::string &_name) const - { - for (auto store : this->stores) - { - if (store->ContainsName(_name)) return true; - } - - return false; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::GetById(unsigned int _id) const - { - for (auto store : this->stores) - { - TPtr object = store->GetById(_id); - if (object) return object; - } - - return nullptr; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::GetByName(const std::string &_name) const - { - for (auto store : this->stores) - { - TPtr object = store->GetByName(_name); - if (object) return object; - } - - return nullptr; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::GetByIndex(unsigned int _index) const - { - unsigned int origIndex = _index; - - for (auto store : this->stores) - { - unsigned int size = store->Size(); - if (_index < size) - return store->GetByIndex(_index); - _index -= size; - } - - ignerr << "Invalid index: " << origIndex << std::endl; - return nullptr; - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::Add(TPtr) - { - ignerr << "Adding to BaseCompositeStore not supported" << std::endl; - return false; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::Remove(TPtr _object) - { - TPtr result = nullptr; - - for (auto store : this->stores) - { - TPtr temp = store->Remove(_object); - if (!result) result = temp; - } - - return result; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::RemoveById(unsigned int _id) - { - TPtr result = nullptr; - - for (auto store : this->stores) - { - TPtr temp = store->RemoveById(_id); - if (!result) result = temp; - } - - return result; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::RemoveByName(const std::string &_name) - { - TPtr result = nullptr; - - for (auto store : this->stores) - { - TPtr temp = store->RemoveByName(_name); - if (!result) result = temp; - } - - return result; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::RemoveByIndex(unsigned int _index) - { - TPtr result = nullptr; - - for (auto store : this->stores) - { - TPtr temp = store->RemoveByIndex(_index); - if (!result) result = temp; - } - - return result; - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::RemoveAll() - { - for (auto store : this->stores) - { - store->RemoveAll(); - } - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::Destroy(TPtr _object) - { - for (auto store : this->stores) - { - if (store->Contains(_object)) - { - store->Destroy(_object); - return; - } - } - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::DestroyById(unsigned int _id) - { - for (auto store : this->stores) - { - store->DestroyById(_id); - } - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::DestroyByName(const std::string &_name) - { - for (auto store : this->stores) - { - store->DestroyByName(_name); - } - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::DestroyByIndex(unsigned int _index) - { - for (auto store : this->stores) - { - store->DestroyByIndex(_index); - } - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::DestroyAll() - { - for (auto store : this->stores) - { - store->DestroyAll(); - } - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCompositeStore::GetStoreCount() const - { - return this->stores.size(); - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::ContainsStore(ConstTStorePtr _store) const - { - auto begin = this->stores.begin(); - auto end = this->stores.end(); - auto iter = std::find(begin, end, _store); - return iter != end; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TStorePtr - BaseCompositeStore::GetStore(unsigned int _index) const - { - if (_index >= this->GetStoreCount()) - { - ignerr << "Invalid store index: " << _index << std::endl; - return nullptr; - } - - return this->stores[_index]; - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::AddStore(TStorePtr _store) - { - if (!_store) - { - ignerr << "Cannot all null store pointer" << std::endl; - return false; - } - - if (this->ContainsStore(_store)) - { - ignerr << "Store has already been added" << std::endl; - return false; - } - - this->stores.push_back(_store); - return true; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TStorePtr - BaseCompositeStore::RemoveStore(TStorePtr _store) - { - auto begin = this->stores.begin(); - auto end = this->stores.end(); - auto iter = std::find(begin, end, _store); - return this->RemoveStoreImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TStorePtr - BaseCompositeStore::RemoveStore(unsigned int _index) - { - if (_index >= this->GetStoreCount()) - { - ignerr << "Invalid store index: " << _index << std::endl; - return nullptr; - } - - auto iter = this->stores.begin(); - std::advance(iter, _index); - return this->RemoveStoreImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TStorePtr - BaseCompositeStore::RemoveStoreImpl(TStoreIter _iter) - { - if (_iter == this->stores.end()) - { - return nullptr; - } - - TStorePtr result = *_iter; - this->stores.erase(_iter); - return result; - } - - ////////////////////////////////////////////////// - template - BaseStoreWrapper::BaseStoreWrapper(UStorePtr _store) : - store(_store) - { - } - - ////////////////////////////////////////////////// - template - BaseStoreWrapper::~BaseStoreWrapper() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseStoreWrapper::Size() const - { - return this->store->Size(); - } - - ////////////////////////////////////////////////// - template - bool BaseStoreWrapper::Contains(ConstTPtr _object) const - { - ConstUPtr derived = std::dynamic_pointer_cast(_object); - return this->store->Contains(derived); - } - - ////////////////////////////////////////////////// - template - bool BaseStoreWrapper::ContainsId(unsigned int _id) const - { - return this->store->ContainsId(_id); - } - - ////////////////////////////////////////////////// - template - bool BaseStoreWrapper::ContainsName(const std::string &_name) const - { - return this->store->ContainsName(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::GetById(unsigned int _id) const - { - return this->store->GetById(_id); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::GetByName(const std::string &_name) const - { - return this->store->GetByName(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::GetByIndex(unsigned int _index) const - { - return this->store->GetByIndex(_index); - } - - ////////////////////////////////////////////////// - template - bool BaseStoreWrapper::Add(TPtr _object) - { - UPtr derived = std::dynamic_pointer_cast(_object); - return this->store->Add(derived); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::Remove(TPtr _object) - { - UPtr derived = std::dynamic_pointer_cast(_object); - return this->store->Remove(derived); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::RemoveById(unsigned int _id) - { - return this->store->RemoveById(_id); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::RemoveByName(const std::string &_name) - { - return this->store->RemoveByName(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::RemoveByIndex(unsigned int _index) - { - return this->store->RemoveByIndex(_index); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::RemoveAll() - { - this->store->RemoveAll(); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::Destroy(TPtr _object) - { - UPtr derived = std::dynamic_pointer_cast(_object); - this->store->Destroy(derived); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::DestroyById(unsigned int _id) - { - this->store->DestroyById(_id); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::DestroyByName(const std::string &_name) - { - this->store->DestroyByName(_name); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::DestroyByIndex(unsigned int _index) - { - this->store->DestroyByIndex(_index); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::DestroyAll() - { - this->store->DestroyAll(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseText.hh b/include/ignition/rendering/base/BaseText.hh index 349848032..10be4ecd5 100644 --- a/include/ignition/rendering/base/BaseText.hh +++ b/include/ignition/rendering/base/BaseText.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,290 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASETEXT_HH_ -#define IGNITION_RENDERING_BASE_BASETEXT_HH_ -#include -#include "ignition/rendering/Text.hh" -#include "ignition/rendering/base/BaseObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of a text geometry - template - class BaseText : - public virtual Text, - public virtual T - { - /// \brief Constructor - protected: BaseText(); - - /// \brief Destructor - public: virtual ~BaseText(); - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: void SetFontName(const std::string &_font) override; - - // Documentation inherited. - public: std::string FontName() const override; - - // Documentation inherited. - public: virtual void SetTextString(const std::string &_text) override; - - // Documentation inherited. - public: virtual std::string TextString() const override; - - // Documentation inherited. - public: virtual void SetColor(const ignition::math::Color &_color) - override; - - // Documentation inherited. - public: virtual ignition::math::Color Color() const override; - - // Documentation inherited. - public: virtual void SetCharHeight(const float _height) override; - - // Documentation inherited. - public: virtual float CharHeight() const override; - - // Documentation inherited. - public: virtual void SetSpaceWidth(const float _width) override; - - // Documentation inherited. - public: virtual float SpaceWidth() const override; - - // Documentation inherited. - public: virtual void SetTextAlignment(const TextHorizontalAlign &_hAlign, - const TextVerticalAlign &_vAlign) override; - // Documentation inherited. - public: virtual TextHorizontalAlign HorizontalAlignment() const override; - - // Documentation inherited. - public: virtual TextVerticalAlign VerticalAlignment() const override; - - // Documentation inherited. - public: virtual void SetBaseline(const float _baseline) override; - - // Documentation inherited. - public: virtual float Baseline() const override; - - // Documentation inherited. - public: void SetShowOnTop(const bool _onTop) override; - - // Documentation inherited. - public: virtual bool ShowOnTop() const override; - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox AABB() const override; - - /// \brief Font name, such as "Liberation Sans" - protected: std::string fontName = "Liberation Sans"; - - /// \brief Text being displayed - protected: std::string text; - - /// \brief Text color - protected: ignition::math::Color color = ignition::math::Color::White; - - /// \brief Character height in meters - protected: float charHeight = 1.0; - - /// \brief Width of space between letters - protected: float spaceWidth = 0; - - /// \brief Horizontal alignment - protected: TextHorizontalAlign horizontalAlign = - TextHorizontalAlign::LEFT; - - /// \brief Vertical alignment - protected: TextVerticalAlign verticalAlign = TextVerticalAlign::BOTTOM; - - /// \brief Baseline height in meters. - protected: float baseline = 0; - - /// \brief True for text to be displayed on top of other objects in the - /// scene. - protected: bool onTop = false; - - /// \brief Flag to indicate text properties have changed - protected: bool textDirty = false; - }; - - ////////////////////////////////////////////////// - // BaseText - ////////////////////////////////////////////////// - template - BaseText::BaseText() - { - } - - ////////////////////////////////////////////////// - template - BaseText::~BaseText() - { - } - - ////////////////////////////////////////////////// - template - std::string BaseText::FontName() const - { - return this->fontName; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetFontName(const std::string &_font) - { - this->fontName = _font; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - std::string BaseText::TextString() const - { - return this->text; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetTextString(const std::string &_text) - { - this->text = _text; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - ignition::math::Color BaseText::Color() const - { - return this->color; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetColor(const ignition::math::Color &_color) - { - this->color = _color; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - float BaseText::CharHeight() const - { - return this->charHeight; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetCharHeight(const float _height) - { - this->charHeight = _height; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - float BaseText::SpaceWidth() const - { - return this->spaceWidth; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetSpaceWidth(const float _width) - { - this->spaceWidth = _width; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - TextHorizontalAlign BaseText::HorizontalAlignment() const - { - return this->horizontalAlign; - } - - ////////////////////////////////////////////////// - template - TextVerticalAlign BaseText::VerticalAlignment() const - { - return this->verticalAlign; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetTextAlignment(const TextHorizontalAlign &_horzAlign, - const TextVerticalAlign &_vertAlign) - { - this->horizontalAlign = _horzAlign; - this->verticalAlign = _vertAlign; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - float BaseText::Baseline() const - { - return this->baseline; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetBaseline(const float _baseline) - { - this->baseline = _baseline; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - bool BaseText::ShowOnTop() const - { - return this->onTop; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetShowOnTop(const bool _onTop) - { - this->onTop = _onTop; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - ignition::math::AxisAlignedBox BaseText::AABB() const - { - math::AxisAlignedBox box; - return box; - } - - ////////////////////////////////////////////////// - template - void BaseText::PreRender() - { - T::PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseText::Destroy() - { - T::Destroy(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseThermalCamera.hh b/include/ignition/rendering/base/BaseThermalCamera.hh index a061a371b..5c1699e4f 100644 --- a/include/ignition/rendering/base/BaseThermalCamera.hh +++ b/include/ignition/rendering/base/BaseThermalCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,198 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASETHERMALCAMERA_HH_ -#define IGNITION_RENDERING_BASE_BASETHERMALCAMERA_HH_ -#include - -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/ThermalCamera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of the ThermalCamera class - template - class BaseThermalCamera : - public virtual ThermalCamera, - public virtual BaseCamera, - public virtual T - { - /// \brief Constructor - protected: BaseThermalCamera(); - - /// \brief Destructor - public: virtual ~BaseThermalCamera(); - - // Documentation inherited. - public: virtual void SetAmbientTemperature(float _ambient) override; - - // Documentation inherited. - public: virtual float AmbientTemperature() const override; - - // Documentation inherited. - public: virtual void SetAmbientTemperatureRange(float _range) override; - - // Documentation inherited. - public: virtual float AmbientTemperatureRange() const override; - - // Documentation inherited. - public: virtual void SetMinTemperature(float _min) override; - - // Documentation inherited. - public: virtual float MinTemperature() const override; - - // Documentation inherited. - public: virtual void SetMaxTemperature(float _max) override; - - // Documentation inherited. - public: virtual float MaxTemperature() const override; - - // Documentation inherited. - public: virtual void SetLinearResolution(float _max) override; - - // Documentation inherited. - public: virtual float LinearResolution() const override; - - // Documentation inherited. - public: virtual float HeatSourceTemperatureRange() const override; - - // Documentation inherited. - public: virtual void SetHeatSourceTemperatureRange(float _range) override; - - // Documentation inherted. - public: virtual ignition::common::ConnectionPtr ConnectNewThermalFrame( - std::function _subscriber) override; - - /// \brief Ambient temperature of the environment - protected: float ambient = 0.0f; - - /// \brief Ambient temperature range - protected: float ambientRange = 0.0f; - - /// \brief Minimum temperature - protected: float minTemp = -ignition::math::INF_F; - - /// \brief Maximum temperature - protected: float maxTemp = ignition::math::INF_F; - - /// \brief Linear resolution. Defaults to 10mK. - protected: float resolution = 0.01f; - - /// \brief Range of heat source temperature variation - protected: float heatSourceTempRange = 0.0f; - }; - - ////////////////////////////////////////////////// - template - BaseThermalCamera::BaseThermalCamera() - { - } - - ////////////////////////////////////////////////// - template - BaseThermalCamera::~BaseThermalCamera() - { - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetAmbientTemperature(float _ambient) - { - this->ambient = _ambient; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::AmbientTemperature() const - { - return this->ambient; - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetAmbientTemperatureRange(float _range) - { - this->ambientRange = _range; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::AmbientTemperatureRange() const - { - return this->ambientRange; - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetMinTemperature(float _min) - { - this->minTemp = _min; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::MinTemperature() const - { - return this->minTemp; - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetMaxTemperature(float _max) - { - this->maxTemp = _max; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::MaxTemperature() const - { - return this->maxTemp; - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetLinearResolution(float _resolution) - { - this->resolution = _resolution; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::LinearResolution() const - { - return this->resolution; - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetHeatSourceTemperatureRange(float _range) - { - this->heatSourceTempRange = _range; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::HeatSourceTemperatureRange() const - { - return this->heatSourceTempRange; - } - - ////////////////////////////////////////////////// - template - common::ConnectionPtr BaseThermalCamera::ConnectNewThermalFrame( - std::function) - { - return nullptr; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseVisual.hh b/include/ignition/rendering/base/BaseVisual.hh index 02013966b..e03cd87b9 100644 --- a/include/ignition/rendering/base/BaseVisual.hh +++ b/include/ignition/rendering/base/BaseVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,541 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASEVISUAL_HH_ -#include -#include - -#include - -#include "ignition/rendering/Visual.hh" -#include "ignition/rendering/Storage.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/base/BaseStorage.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseVisual : - public virtual Visual, - public virtual T - { - protected: BaseVisual(); - - public: virtual ~BaseVisual(); - - public: virtual math::Pose3d LocalPose() const override; - - public: virtual void SetLocalPose(const math::Pose3d &_pose) override; - - public: virtual unsigned int GeometryCount() const override; - - public: virtual bool HasGeometry(ConstGeometryPtr _geometry) const - override; - - public: virtual GeometryPtr GeometryByIndex(unsigned int _index) const - override; - - public: virtual void AddGeometry(GeometryPtr _geometry) override; - - public: virtual GeometryPtr RemoveGeometry(GeometryPtr _geometry) - override; - - public: virtual GeometryPtr RemoveGeometryByIndex(unsigned int _index) - override; - - public: virtual void RemoveGeometries() override; - - public: virtual void SetMaterial(const std::string &_name, - bool _unique = true) override; - - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true) override; - - public: virtual void SetChildMaterial(MaterialPtr _material, - bool _unique = true) override; - - public: virtual void SetGeometryMaterial(MaterialPtr _material, - bool _unique = true) override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetWireframe(bool _show) override; - - // Documentation inherited. - public: virtual bool Wireframe() const override; - - // Documentation inherited. - public: virtual void SetVisible(bool _visible) override; - - // Documentation inherited. - public: virtual void SetVisibilityFlags(uint32_t _flags) override; - - // Documentation inherited. - public: virtual uint32_t VisibilityFlags() const override; - - // Documentation inherited. - public: virtual void AddVisibilityFlags(uint32_t _flags) override; - - // Documentation inherited. - public: virtual void RemoveVisibilityFlags(uint32_t _flags) override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox BoundingBox() - const override; - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox LocalBoundingBox() - const override; - - // Documentation inherited. - public: virtual VisualPtr Clone(const std::string &_name, - NodePtr _newParent) const override; - - protected: virtual void PreRenderChildren() override; - - protected: virtual void PreRenderGeometries(); - - protected: virtual GeometryStorePtr Geometries() const = 0; - - protected: virtual bool AttachGeometry(GeometryPtr _geometry) = 0; - - protected: virtual bool DetachGeometry(GeometryPtr _geometry) = 0; - - /// \brief Pointer to material assigned to this visual - protected: MaterialPtr material; - - /// \brief Visual's visibility flags - protected: uint32_t visibilityFlags = IGN_VISIBILITY_ALL; - - /// \brief The bounding box of the visual - protected: ignition::math::AxisAlignedBox boundingBox; - - /// \brief True if wireframe mode is enabled else false - protected: bool wireframe = false; - }; - - ////////////////////////////////////////////////// - template - BaseVisual::BaseVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseVisual::~BaseVisual() - { - } - - ////////////////////////////////////////////////// - template - math::Pose3d BaseVisual::LocalPose() const - { - math::Pose3d rawPose = this->RawLocalPose(); - math::Vector3d scale = this->LocalScale(); - rawPose.Pos() += rawPose.Rot() * (scale * this->origin); - return rawPose; - } - - ////////////////////////////////////////////////// - template - void BaseVisual::SetLocalPose(const math::Pose3d &_pose) - { - math::Pose3d rawPose = _pose; - math::Vector3d scale = this->LocalScale(); - rawPose.Pos() -= rawPose.Rot() * (scale * this->origin); - - if (!rawPose.IsFinite()) - { - ignerr << "Unable to set pose of a node: " - << "non-finite (nan, inf) values detected." << std::endl; - return; - } - - this->SetRawLocalPose(rawPose); - } - - ////////////////////////////////////////////////// - template - unsigned int BaseVisual::GeometryCount() const - { - return this->Geometries()->Size(); - } - - ////////////////////////////////////////////////// - template - bool BaseVisual::HasGeometry(ConstGeometryPtr _geometry) const - { - return this->Geometries()->Contains(_geometry); - } - - ////////////////////////////////////////////////// - template - GeometryPtr BaseVisual::GeometryByIndex(unsigned int _index) const - { - return this->Geometries()->GetByIndex(_index); - } - - ////////////////////////////////////////////////// - template - void BaseVisual::AddGeometry(GeometryPtr _geometry) - { - if (this->AttachGeometry(_geometry)) - { - this->Geometries()->Add(_geometry); - } - } - - ////////////////////////////////////////////////// - template - GeometryPtr BaseVisual::RemoveGeometry(GeometryPtr _geometry) - { - if (this->DetachGeometry(_geometry)) - { - this->Geometries()->Remove(_geometry); - } - return _geometry; - } - - ////////////////////////////////////////////////// - template - GeometryPtr BaseVisual::RemoveGeometryByIndex(unsigned int _index) - { - return this->RemoveGeometry(this->GeometryByIndex(_index)); - } - - ////////////////////////////////////////////////// - template - void BaseVisual::RemoveGeometries() - { - for (unsigned int i = this->GeometryCount(); i > 0; --i) - { - this->RemoveGeometryByIndex(i-1); - } - } - - ////////////////////////////////////////////////// - template - void BaseVisual::SetMaterial(const std::string &_name, bool _unique) - { - MaterialPtr mat = this->Scene()->Material(_name); - if (mat) this->SetMaterial(mat, _unique); - } - - ////////////////////////////////////////////////// - template - void BaseVisual::SetMaterial(MaterialPtr _material, bool _unique) - { - _material = (_unique) ? _material->Clone() : _material; - this->SetChildMaterial(_material, false); - this->SetGeometryMaterial(_material, false); - this->material = _material; - } - - ////////////////////////////////////////////////// - template - void BaseVisual::SetChildMaterial(MaterialPtr _material, bool _unique) - { - unsigned int count = this->ChildCount(); - _material = (_unique && count > 0) ? _material->Clone() : _material; - - auto children_ = - std::dynamic_pointer_cast>( - this->Children()); - if (!children_) - { - ignerr << "Cast failed in BaseVisual::SetChildMaterial" << std::endl; - return; - } - for (auto it = children_->Begin(); it != children_->End(); ++it) - { - NodePtr child = it->second; - VisualPtr visual = std::dynamic_pointer_cast(child); - if (visual) visual->SetMaterial(_material, false); - } - } - - ////////////////////////////////////////////////// - template - void BaseVisual::SetGeometryMaterial(MaterialPtr _material, bool _unique) - { - unsigned int count = this->GeometryCount(); - _material = (_unique && count > 0) ? _material->Clone() : _material; - - for (unsigned int i = 0; i < count; ++i) - { - GeometryPtr geometry = this->GeometryByIndex(i); - geometry->SetMaterial(_material, false); - } - } - - ////////////////////////////////////////////////// - template - MaterialPtr BaseVisual::Material() const - { - return this->material; - } - - ////////////////////////////////////////////////// - template - void BaseVisual::PreRender() - { - this->PreRenderChildren(); - this->PreRenderGeometries(); - } - - ////////////////////////////////////////////////// - template - void BaseVisual::Destroy() - { - this->Geometries()->DestroyAll(); - this->Children()->RemoveAll(); - this->material.reset(); - T::Destroy(); - } - - ////////////////////////////////////////////////// - template - void BaseVisual::PreRenderChildren() - { - auto children_ = - std::dynamic_pointer_cast>( - this->Children()); - if (!children_) - { - ignerr << "Cast failed in BaseVisual::PreRenderChildren" << std::endl; - return; - } - for (auto it = children_->Begin(); it != children_->End(); ++it) - { - it->second->PreRender(); - } - } - - ////////////////////////////////////////////////// - template - void BaseVisual::PreRenderGeometries() - { - unsigned int count = this->GeometryCount(); - - for (unsigned int i = 0; i < count; ++i) - { - GeometryPtr geometry = this->GeometryByIndex(i); - geometry->PreRender(); - } - } - - ////////////////////////////////////////////////// - template - bool BaseVisual::Wireframe() const - { - return this->wireframe; - } - - ////////////////////////////////////////////////// - template - void BaseVisual::SetWireframe(bool _show) - { - ignerr << "SetWireframe(" << _show << ") not supported for " - << "render engine: " << this->Scene()->Engine()->Name() - << std::endl; - } - - ////////////////////////////////////////////////// - template - void BaseVisual::SetVisible(bool _visible) - { - ignerr << "SetVisible(" << _visible << ") not supported for " - << "render engine: " << this->Scene()->Engine()->Name() - << std::endl; - } - - ////////////////////////////////////////////////// - template - ignition::math::AxisAlignedBox BaseVisual::LocalBoundingBox() const - { - ignition::math::AxisAlignedBox box; - - // Recursively loop through child visuals - auto childNodes = - std::dynamic_pointer_cast>( - this->Children()); - if (!childNodes) - { - ignerr << "Cast failed in BaseVisual::LocalBoundingBox" << std::endl; - return box; - } - for (auto it = childNodes->Begin(); it != childNodes->End(); ++it) - { - NodePtr child = it->second; - VisualPtr visual = std::dynamic_pointer_cast(child); - if (visual) - { - ignition::math::AxisAlignedBox aabb = visual->LocalBoundingBox(); - if (aabb.Min().IsFinite() && aabb.Max().IsFinite()) - box.Merge(aabb); - } - } - return box; - } - - ////////////////////////////////////////////////// - template - ignition::math::AxisAlignedBox BaseVisual::BoundingBox() const - { - ignition::math::AxisAlignedBox box; - - // Recursively loop through child visuals - auto childNodes = - std::dynamic_pointer_cast>( - this->Children()); - if (!childNodes) - { - ignerr << "Cast failed in BaseVisual::BoundingBox" << std::endl; - return box; - } - for (auto it = childNodes->Begin(); it != childNodes->End(); ++it) - { - NodePtr child = it->second; - VisualPtr visual = std::dynamic_pointer_cast(child); - if (visual) - box.Merge(visual->BoundingBox()); - } - return box; - } - - ////////////////////////////////////////////////// - template - void BaseVisual::AddVisibilityFlags(uint32_t _flags) - { - this->SetVisibilityFlags(this->VisibilityFlags() | _flags); - } - - ////////////////////////////////////////////////// - template - void BaseVisual::RemoveVisibilityFlags(uint32_t _flags) - { - this->SetVisibilityFlags(this->VisibilityFlags() & ~(_flags)); - } - - ////////////////////////////////////////////////// - template - void BaseVisual::SetVisibilityFlags(uint32_t _flags) - { - this->visibilityFlags = _flags; - - // recursively set child visuals' visibility flags - auto childNodes = - std::dynamic_pointer_cast>( - this->Children()); - if (!childNodes) - { - ignerr << "Cast failed in BaseVisual::SetVisibiltyFlags" << std::endl; - return; - } - for (auto it = childNodes->Begin(); it != childNodes->End(); ++it) - { - NodePtr child = it->second; - VisualPtr visual = std::dynamic_pointer_cast(child); - if (visual) - visual->SetVisibilityFlags(_flags); - } - } - - ////////////////////////////////////////////////// - template - uint32_t BaseVisual::VisibilityFlags() const - { - return this->visibilityFlags; - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseVisual::Clone(const std::string &_name, - NodePtr _newParent) const - { - ScenePtr scene_ = this->Scene(); - if (nullptr == scene_) - { - ignerr << "Cloning a visual failed because the visual to be cloned is " - << "not attached to a scene.\n"; - return nullptr; - } - VisualPtr result; - if (_name.empty()) - result = scene_->CreateVisual(); - else - result = scene_->CreateVisual(_name); - - if (nullptr != _newParent) - { - auto parentScene = _newParent->Scene(); - if (nullptr != parentScene && parentScene->Id() != scene_->Id()) - { - ignerr << "Cloning a visual failed because the desired parent of the " - << "cloned visual belongs to a different scene.\n"; - scene_->DestroyVisual(result); - return nullptr; - } - _newParent->AddChild(result); - } - - result->SetOrigin(this->Origin()); - result->SetInheritScale(this->InheritScale()); - result->SetLocalScale(this->LocalScale()); - result->SetLocalPose(this->LocalPose()); - result->SetVisibilityFlags(this->VisibilityFlags()); - result->SetWireframe(this->Wireframe()); - - // if the visual that was cloned has child visuals, clone those as well - auto children_ = - std::dynamic_pointer_cast>( - this->Children()); - if (!children_) - { - ignerr << "Cast failed in BaseVisual::Clone\n"; - scene_->DestroyVisual(result); - return nullptr; - } - for (auto it = children_->Begin(); it != children_->End(); ++it) - { - NodePtr child = it->second; - VisualPtr visual = std::dynamic_pointer_cast(child); - // recursively delete all cloned visuals if the child cannot be - // retrieved, or if cloning the child visual failed - if (!visual || !visual->Clone("", result)) - { - ignerr << "Cloning a child visual failed.\n"; - scene_->DestroyVisual(result, true); - return nullptr; - } - } - - for (unsigned int i = 0; i < this->GeometryCount(); ++i) - result->AddGeometry(this->GeometryByIndex(i)->Clone()); - - if (this->Material()) - result->SetMaterial(this->Material()); - - for (const auto &[key, val] : this->userData) - result->SetUserData(key, val); - - return result; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseWireBox.hh b/include/ignition/rendering/base/BaseWireBox.hh index db7fe12e9..e4f65999a 100644 --- a/include/ignition/rendering/base/BaseWireBox.hh +++ b/include/ignition/rendering/base/BaseWireBox.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,92 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_WIREBOX_HH_ -#define IGNITION_RENDERING_BASE_WIREBOX_HH_ -#include -#include "ignition/rendering/WireBox.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of a wireframe box. - template - class BaseWireBox : - public virtual WireBox, - public virtual T - { - /// \brief Constructor - protected: BaseWireBox(); - - /// \brief Destructor - public: virtual ~BaseWireBox(); - - // Documentation inherited. - public: virtual void PreRender(); - - // Documentation inherited. - public: virtual void Destroy(); - - // Documentation inherited. - public: virtual void SetBox(const ignition::math::AxisAlignedBox &_box); - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox Box() const; - - // \brief Underlying axis aligned box that the wire box reflects. - protected: ignition::math::AxisAlignedBox box; - - /// \brief Flag to indicate WireBox properties have changed - protected: bool wireBoxDirty = false; - }; - - ////////////////////////////////////////////////// - // BaseWireBox - ////////////////////////////////////////////////// - template - BaseWireBox::BaseWireBox() - { - } - - ////////////////////////////////////////////////// - template - BaseWireBox::~BaseWireBox() - { - } - - ////////////////////////////////////////////////// - template - void BaseWireBox::PreRender() - { - T::PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseWireBox::Destroy() - { - T::Destroy(); - } - - ////////////////////////////////////////////////// - template - void BaseWireBox::SetBox(const ignition::math::AxisAlignedBox &_box) - { - this->box = _box; - this->wireBoxDirty = true; - } - - ////////////////////////////////////////////////// - template - ignition::math::AxisAlignedBox BaseWireBox::Box() const - { - return this->box; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/base.hh.in b/include/ignition/rendering/base/base.hh.in deleted file mode 100644 index acfd26ae7..000000000 --- a/include/ignition/rendering/base/base.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/include/ignition/rendering/config.hh b/include/ignition/rendering/config.hh new file mode 100644 index 000000000..6dd936c31 --- /dev/null +++ b/include/ignition/rendering/config.hh @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef IGNITION_RENDERING__CONFIG_HH_ +#define IGNITION_RENDERING__CONFIG_HH_ + +#include + +/* Version number */ +// #define IGNITION_RENDERING_MAJOR_VERSION GZ_RENDERING_MAJOR_VERSION +// #define IGNITION_RENDERING_MINOR_VERSION GZ_RENDERING_MINOR_VERSION +// #define IGNITION_RENDERING_PATCH_VERSION GZ_RENDERING_PATCH_VERSION + +// #define IGNITION_RENDERING_VERSION GZ_RENDERING_VERSION +// #define IGNITION_RENDERING_VERSION_FULL GZ_RENDERING_VERSION_FULL + +// #define IGNITION_RENDERING_VERSION_NAMESPACE GZ_RENDERING_VERSION_NAMESPACE + +// #define IGNITION_RENDERING_VERSION_HEADER GZ_RENDERING_VERSION_HEADER + +// #define IGN_RENDERING_RESOURCE_PATH GZ_RENDERING_RESOURCE_PATH + +// #define IGNITION_RENDERING_ENGINE_INSTALL_DIR GZ_RENDERING_ENGINE_INSTALL_DIR + +/* #undef BUILD_TYPE_PROFILE */ +/* #undef BUILD_TYPE_DEBUG */ +/* #undef BUILD_TYPE_RELEASE */ +// #define HAVE_OGRE 1 +/* #undef HAVE_OGRE2 */ +/* #undef HAVE_OPTIX */ +/* #undef HAVE_GAZEBO */ +/* #undef INCLUDE_RTSHADER */ + +#endif diff --git a/include/ignition/rendering/rendering.hh.in b/include/ignition/rendering/rendering.hh.in deleted file mode 100644 index 13484ca76..000000000 --- a/include/ignition/rendering/rendering.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -//#include -${ign_headers} diff --git a/ogre/include/CMakeLists.txt b/ogre/include/CMakeLists.txt index 297e254ff..a7479f53e 100644 --- a/ogre/include/CMakeLists.txt +++ b/ogre/include/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(ignition/rendering) +add_subdirectory(gz/rendering) +install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) diff --git a/ogre/include/ignition/rendering/CMakeLists.txt b/ogre/include/gz/rendering/CMakeLists.txt similarity index 100% rename from ogre/include/ignition/rendering/CMakeLists.txt rename to ogre/include/gz/rendering/CMakeLists.txt diff --git a/ogre/include/gz/rendering/ogre/OgreArrowVisual.hh b/ogre/include/gz/rendering/ogre/OgreArrowVisual.hh new file mode 100644 index 000000000..9bdb05a61 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreArrowVisual.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREARROWVISUAL_HH_ +#define GZ_RENDERING_OGRE_OGREARROWVISUAL_HH_ + +#include "gz/rendering/base/BaseArrowVisual.hh" +#include "gz/rendering/ogre/OgreVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreArrowVisual : + public BaseArrowVisual + { + protected: OgreArrowVisual(); + + public: virtual ~OgreArrowVisual(); + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreAxisVisual.hh b/ogre/include/gz/rendering/ogre/OgreAxisVisual.hh new file mode 100644 index 000000000..aa4277a98 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreAxisVisual.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREAXISVISUAL_HH_ +#define GZ_RENDERING_OGRE_OGREAXISVISUAL_HH_ + +#include "gz/rendering/base/BaseAxisVisual.hh" +#include "gz/rendering/ogre/OgreVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreAxisVisual : + public BaseAxisVisual + { + protected: OgreAxisVisual(); + + public: virtual ~OgreAxisVisual(); + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreCOMVisual.hh b/ogre/include/gz/rendering/ogre/OgreCOMVisual.hh new file mode 100644 index 000000000..6dda62d99 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreCOMVisual.hh @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE_OGRECOMVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGRECOMVISUAL_HH_ + +#include + +#include "ignition/rendering/base/BaseCOMVisual.hh" +#include "ignition/rendering/ogre/OgreIncludes.hh" +#include "ignition/rendering/ogre/OgreMaterial.hh" +#include "ignition/rendering/ogre/OgreVisual.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + // Forward declaration + class OgreCOMVisualPrivate; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreCOMVisual : + public BaseCOMVisual + { + /// \brief Constructor + protected: OgreCOMVisual(); + + /// \brief Destructor + public: virtual ~OgreCOMVisual(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: Ogre::MovableObject *OgreObject() const; + + /// \brief Create the Light Visual in Ogre + public: void CreateVisual(); + + // Documentation inherited + public: virtual VisualPtr SphereVisual() const override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial( + MaterialPtr _material, bool _unique) override; + + /// \brief Set material to grid geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); + + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreCamera.hh b/ogre/include/gz/rendering/ogre/OgreCamera.hh new file mode 100644 index 000000000..a5458d94c --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreCamera.hh @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRECAMERA_HH_ +#define GZ_RENDERING_OGRE_OGRECAMERA_HH_ + +#include + +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreSensor.hh" +#include "gz/rendering/ogre/OgreSelectionBuffer.hh" + +namespace Ogre +{ + class Camera; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreSelectionBuffer; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreCamera : + public BaseCamera + { + protected: OgreCamera(); + + public: virtual ~OgreCamera(); + + // Documentation inherited. + public: virtual math::Angle HFOV() const override; + + // Documentation inherited. + public: virtual void SetHFOV(const math::Angle &_hfov) override; + + // Documentation inherited. + public: virtual double AspectRatio() const override; + + // Documentation inherited. + public: virtual void SetAspectRatio(const double _ratio) override; + + // Documentation inherited. + public: virtual unsigned int AntiAliasing() const override; + + // Documentation inherited. + public: virtual void SetAntiAliasing(const unsigned int _aa) override; + + // Documentation inherited. + public: virtual void SetFarClipPlane(const double _far) override; + + // Documentation inherited. + public: virtual void SetNearClipPlane(const double _near) override; + + public: virtual math::Color BackgroundColor() const; + + public: virtual void SetBackgroundColor(const math::Color &_color); + + // Documentation inherited. + public: virtual void Render() override; + + // Documentation inherited. + public: virtual RenderWindowPtr CreateRenderWindow() override; + + // Documentation inherited. + public: virtual math::Matrix4d ProjectionMatrix() const override; + + // Documentation inherited. + public: virtual void SetProjectionMatrix( + const math::Matrix4d &_matrix) override; + + // Documentation inherited. + public: virtual math::Matrix4d ViewMatrix() const override; + + // Documentation inherited. + public: virtual void SetProjectionType(CameraProjectionType _type) + override; + + public: void SetVFOV(double cameraVFOV) const; + + /// \brief Get the near clip distance + /// \return Near clip distance + public: double NearClip() const; + + /// \brief Get the far clip distance + /// \return Far clip distance + public: double FarClip() const; + + // Documentation inherited + public: virtual VisualPtr VisualAt(const gz::math::Vector2i + &_mousePos) override; + + // Documentation Inherited. + // \sa Camera::SetMaterial(const MaterialPtr &) + public: virtual void SetMaterial( + const MaterialPtr &_material) override; + + // Documentation inherited. + public: virtual unsigned int RenderTextureGLId() const override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual void SetVisibilityMask(uint32_t _mask) override; + + /// \brief Get underlying Ogre camera + public: Ogre::Camera *Camera() const; + + // Documentation inherited. + // public: virtual uint32_t VisibilityMask() const override; + + protected: virtual RenderTargetPtr RenderTarget() const override; + + protected: virtual void Init() override; + + protected: virtual void SetSelectionBuffer(); + + private: void CreateCamera(); + + protected: virtual void CreateRenderTexture(); + + /// \brief Destroy render texture created by CreateRenderTexture() + /// Note: It's not virtual. + protected: void DestroyRenderTexture(); + + protected: Ogre::Camera *ogreCamera = nullptr; + + protected: OgreSelectionBuffer *selectionBuffer = nullptr; + + protected: OgreRenderTargetPtr renderTexture; + + protected: math::Color backgroundColor; + + private: friend class OgreScene; + private: friend class OgreRayQuery; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreCapsule.hh b/ogre/include/gz/rendering/ogre/OgreCapsule.hh new file mode 100644 index 000000000..9cbb2a2ee --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreCapsule.hh @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE_OGRECAPSULE_HH_ +#define IGNITION_RENDERING_OGRE_OGRECAPSULE_HH_ + +#include +#include "ignition/rendering/base/BaseCapsule.hh" +#include "ignition/rendering/ogre/OgreGeometry.hh" +#include "ignition/rendering/ogre/OgreIncludes.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // Forward declaration + class OgreCapsulePrivate; + + /// \brief Ogre 2.x implementation of a Capsule Visual. + class IGNITION_RENDERING_OGRE_VISIBLE OgreCapsule + : public BaseCapsule + { + /// \brief Constructor + protected: OgreCapsule(); + + /// \brief Destructor + public: virtual ~OgreCapsule(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void + SetMaterial(MaterialPtr _material, bool _unique) override; + + /// \brief Update the capsule geometry in ogre + private: void Update(); + + /// \brief Capsule should only be created by scene. + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreConversions.hh b/ogre/include/gz/rendering/ogre/OgreConversions.hh new file mode 100644 index 000000000..1783addda --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreConversions.hh @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRECONVERSIONS_HH_ +#define GZ_RENDERING_OGRE_OGRECONVERSIONS_HH_ + +#include +#include +#include +#include + +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \addtogroup ign_rendering + /// \{ + + /// \brief Conversions Conversions.hh rendering/Conversions.hh + /// \brief A set of utility function to convert between Gazebo and Ogre + /// data types + class IGNITION_RENDERING_OGRE_VISIBLE OgreConversions + { + /// \brief Return the equivalent ogre color + /// \param[in] _color ign-math color to convert + /// \return Ogre color value + public: static Ogre::ColourValue Convert( + const math::Color &_color); + + /// \brief Return the equivalent ign-math color + /// \param[in] _color Ogre color to convert + /// \return ign-math color value + public: static math::Color Convert( + const Ogre::ColourValue &_color); + + /// \brief return Ogre Vector from ign-math Vector3 + /// \param[in] _vector ign-math vector + /// \return Ogre vector + public: static Ogre::Vector3 Convert(const math::Vector3d &_vector); + + /// \brief return ign-math Vector from ogre Vector3 + /// \param[in] _vector Ogre vector + /// \return ign-math vector + public: static math::Vector3d Convert(const Ogre::Vector3 &_vector); + + /// \brief Ign-math quaternion to Ogre quaternion + /// \param[in] _quat ign-math quaternion + /// \return Ogre quaternion + public: static Ogre::Quaternion Convert(const math::Quaterniond &_quat); + + /// \brief Ogre quaternion to ign-math quaternion + /// \param[in] _quat Ogre quaternion + /// return ign-math quaternion + public: static math::Quaterniond Convert(const Ogre::Quaternion &_quat); + + /// \brief Ign-math angle to Ogre angle + /// \param[in] _angle ign-math angle + /// \return Ogre angle + public: static Ogre::Radian Convert(const math::Angle &_angle); + + /// \brief Ogre angle to ign-math angle + /// \param[in] _angle Ogre angle + /// return Ign-math angle + public: static math::Angle Convert(const Ogre::Radian &_angle); + + /// \brief Ogre Matrix4 to ignition math Matrix4d + /// \param[in] _m Ogre Matrix4 + /// \return ignition math Matrix4d + public: static math::Matrix4d Convert(const Ogre::Matrix4 &_m); + + /// \brief Ignition math Matrix4d to Ogre Matrix4 + /// \param[in] _m ignition math Matrix4d + /// \return Ogre Matrix4 + public: static Ogre::Matrix4 Convert(const math::Matrix4d &_m); + + /// \brief Ign-rendering PixelFormat to Ogre PixelFormat + /// \param[in] _format Ign-rendering PixelFormat + /// return Ogre PixelFormat + public: static Ogre::PixelFormat Convert(PixelFormat _format); + + private: static const Ogre::PixelFormat ogrePixelFormats[PF_COUNT]; + }; + /// \} + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreDepthCamera.hh b/ogre/include/gz/rendering/ogre/OgreDepthCamera.hh new file mode 100644 index 000000000..70a642b54 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreDepthCamera.hh @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGREDEPTHCAMERA_HH_ +#define GZ_RENDERING_OGRE_OGREDEPTHCAMERA_HH_ + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +#include +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/base/BaseDepthCamera.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreSensor.hh" +#include "gz/rendering/ogre/OgreSelectionBuffer.hh" + +#include "gz/common/Event.hh" +#include "gz/common/Console.hh" + + +namespace Ogre +{ + class Material; + class RenderTarget; + class Texture; + class Viewport; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreDepthCameraPrivate; + + /** \class OgreDepthCamera OgreDepthCamera.hh\ + * rendering/ogre/OgreDepthCamera.hh + **/ + /// \brief Depth camera used to render depth data into an image buffer + class IGNITION_RENDERING_OGRE_VISIBLE OgreDepthCamera : + public BaseDepthCamera + { + /// \brief Constructor + protected: OgreDepthCamera(); + + /// \brief Destructor + public: virtual ~OgreDepthCamera(); + + /// \brief Initialize the camera + public: virtual void Init() override; + + /// \brief Create a texture which will hold the depth data + public: virtual void CreateDepthTexture() override; + + /// \brief Destroy render texture created by CreateDepthTexture() + /// Note: It's not virtual. + protected: void DestroyDepthTexture(); + + /// \brief Render the camera + public: virtual void PostRender() override; + + /// \brief All things needed to get back z buffer for depth data + /// \return The z-buffer as a float array + public: virtual const float *DepthData() const override; + + /// \brief Connect a to the new depth image signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewDepthFrame( + std::function _subscriber) override; + + /// \brief Connect a to the new rgb point cloud signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewRgbPointCloud( + std::function _subscriber) override; + + // Documentation inherited. + public: virtual void PreRender() override; + + /// \brief Implementation of the render call + public: virtual void Render() override; + + /// \brief Set the far clip distance + /// \param[in] _far far clip distance + public: virtual void SetFarClipPlane(const double _far) override; + + /// \brief Set the near clip distance + /// \param[in] _near Near clip distance + public: virtual void SetNearClipPlane(const double _near) override; + + /// \brief Get the near clip distance + /// \return Near clip distance. A value of zero is returned if the + /// ogre camera has not been created. + public: double NearClipPlane() const override; + + /// \brief Get the far clip distance + /// \return Far clip distance. A value of zero is returned if the + /// ogre camera has not been created. + public: double FarClipPlane() const override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Update a render target + /// \param[in] _target Render target to update + /// \param[in] _material Material to use + /// \param[in] _matName Material name + protected: void UpdateRenderTarget(OgreRenderTexturePtr _target, + Ogre::Material *_material, + const std::string &_matName); + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Limit field of view taking care of using a valid value for + /// an OGRE camera. + /// \param[in] _fov expected field of view + /// \return valid field of view + protected: static double LimitFOV(const double _fov); + + /// \brief Create the camera. + protected: void CreateCamera(); + + /// \brief Create point cloud texture. This stores xyz rgb data + private: void CreatePointCloudTexture(); + + /// \brief Destroy render texture created by CreatePointCloudTexture() + /// Note: It's not virtual. + protected: void DestroyPointCloudTexture(); + + /// \brief Communicates that a frams was rendered + protected: bool newData = false; + + protected: bool captureData = false; + + /// \brief Pointer to the depth texture + protected: OgreRenderTexturePtr depthTexture; + + /// \brief Pointer to the depth viewport + protected: Ogre::Viewport *depthViewport = nullptr; + + /// \brief Pointer to the ogre camera + protected: Ogre::Camera *ogreCamera; + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + private: friend class OgreScene; + private: friend class OgreRayQuery; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreDistortionPass.hh b/ogre/include/gz/rendering/ogre/OgreDistortionPass.hh new file mode 100644 index 000000000..a89f15f56 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreDistortionPass.hh @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_OGRE_OGREDISTORTIONPASS_HH_ +#define IGNITION_RENDERING_OGRE_OGREDISTORTIONPASS_HH_ + +#include +#include + +#include +#include + +#include "ignition/rendering/base/BaseDistortionPass.hh" +#include "ignition/rendering/ogre/OgreIncludes.hh" +#include "ignition/rendering/ogre/OgreRenderPass.hh" +#include "ignition/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class DistortionCompositorListener; + + /* \class OgreDistortionPass OgreDistortionPass.hh \ + * ignition/rendering/ogre/OgreDistortionPass.hh + */ + /// \brief Ogre implementation of the DistortionPass class + class IGNITION_RENDERING_OGRE_VISIBLE OgreDistortionPass : + public BaseDistortionPass + { + /// \brief Constructor + public: OgreDistortionPass(); + + /// \brief Destructor + public: virtual ~OgreDistortionPass(); + + // Documentation inherited + public: void PreRender() override; + + // Documentation inherited + public: void Destroy() override; + + // Documentation inherited + public: void CreateRenderPass() override; + + /// \brief Apply distortion model using camera coordinates projection + /// \param[in] _in Input uv coordinate. + /// \param[in] _center Normalized distortion center. + /// \param[in] _k1 Radial distortion coefficient k1. + /// \param[in] _k2 Radial distortion coefficient k2. + /// \param[in] _k3 Radial distortion coefficient k3. + /// \param[in] _p1 Tangential distortion coefficient p1. + /// \param[in] _p2 Tangential distortion coefficient p2. + /// \param[in] _width Width of the image texture in pixels. + /// \param[in] _f Focal length in pixels. + /// \return Distorted coordinate. + public: static ignition::math::Vector2d Distort( + const ignition::math::Vector2d &_in, + const ignition::math::Vector2d &_center, + double _k1, double _k2, double _k3, + double _p1, double _p2, + unsigned int _width, double _f); + + /// \brief get the distortion map value. + /// \param[in] _x X component of map. + /// \param[in] _y Y component of map. + /// \return the distortion map value at the specified index. + protected: ignition::math::Vector2d + DistortionMapValueClamped(int _x, int _y) const; + + /// \brief calculate the correct scale factor to "zoom" the render, + /// cutting off black borders caused by distortion (only if the crop + /// flag has been set). + protected: void CalculateAndApplyDistortionScale(); + + /// \internal + /// \brief Private data pointer + IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr) + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreDynamicLines.hh b/ogre/include/gz/rendering/ogre/OgreDynamicLines.hh new file mode 100644 index 000000000..490f02963 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreDynamicLines.hh @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_OGRE_OGREDYNAMICLINES_HH_ +#define GZ_RENDERING_OGRE_OGREDYNAMICLINES_HH_ + +#include +#include +#include +#include + +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreDynamicRenderable.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \brief Forward declaration + class OgreDynamicLinesPrivate; + + /* \class OgreDynamicLines OgreDynamicLines.hh \ + * ignition/rendering/ogre/OgreDynamicLines.hh + */ + /// \brief Class for drawing lines that can change + class IGNITION_RENDERING_OGRE_VISIBLE OgreDynamicLines : + public OgreDynamicRenderable + { + /// \brief Constructor + /// \param[in] _opType The type of Line + public: explicit OgreDynamicLines( + MarkerType _opType = MT_LINE_STRIP); + + /// \brief Destructor + public: virtual ~OgreDynamicLines(); + + /// \brief Add a point to the point list + /// \param[in] _pt gz::math::Vector3d point + /// \param[in] _color gz::math::Color Point color + public: void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color = gz::math::Color::White); + + /// \brief Add a point to the point list. + /// \param[in] _x X position + /// \param[in] _y Y position + /// \param[in] _z Z position + /// \param[in] _color gz::math::Color Point color + public: void AddPoint(const double _x, const double _y, const double _z, + const gz::math::Color &_color = gz::math::Color::White); + + /// \brief Change the location of an existing point in the point list + /// \param[in] _index Index of the point to set + /// \param[in] _value gz::math::Vector3d value to set the point to + public: void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value); + + /// \brief Change the color of an existing point in the point list + /// \param[in] _index Index of the point to set + /// \param[in] _color gz::math::Color Pixelcolor color to set the + /// point to + public: void SetColor(unsigned int _index, + const gz::math::Color &_color); + + /// \brief Return the location of an existing point in the point list + /// \param[in] _index Number of the point to return + /// \return gz::math::Vector3d value of the point. A vector of + /// [gz::math::INF_D, gz::math::INF_D, gz::math::INF_D] + /// is returned when then the _index is out of bounds. + /// gz::math::INF_D==std::numeric_limits::infinity() + public: gz::math::Vector3d Point(unsigned int _index) const; + + /// \brief Return the total number of points in the point list + /// \return Number of points + public: unsigned int PointCount() const; + + /// \brief Remove all points from the point list + public: void Clear(); + + /// \brief Call this to update the hardware buffer after making changes. + public: void Update(); + + /// \brief Implementation DynamicRenderable, + /// creates a simple vertex-only decl + private: virtual void CreateVertexDeclaration(); + + /// \brief Implementation DynamicRenderable, pushes point + /// list out to hardware memory + private: virtual void FillHardwareBuffers(); + + /// \brief private implementation + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreDynamicRenderable.hh b/ogre/include/gz/rendering/ogre/OgreDynamicRenderable.hh new file mode 100644 index 000000000..73a28cfa9 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreDynamicRenderable.hh @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_OGRE_OGREDYNAMICRENDERABLE_HH_ +#define GZ_RENDERING_OGRE_OGREDYNAMICRENDERABLE_HH_ + +#include +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/Marker.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /* \class OgreDynamicRenderable OgreDynamicRenderable.hh \ + * ignition/rendering/ogre/OgreDynamicRenderable.hh + */ + /// \brief Abstract base class providing mechanisms for dynamically + /// growing hardware buffers. + class IGNITION_RENDERING_OGRE_VISIBLE OgreDynamicRenderable : + public Ogre::SimpleRenderable + { + /// \brief Constructor + public: OgreDynamicRenderable(); + + /// \brief Virtual destructor + public: virtual ~OgreDynamicRenderable(); + + /// \brief Initializes the dynamic renderable. + /// \remarks This function should only be called once. It initializes the + /// render operation, and calls the abstract function + /// CreateVertexDeclaration(). + /// \param[in] _opType The type of render operation to perform. + /// \param[in] _useIndices Specifies whether to use indices to + /// determine the vertices to use as input. + public: void Init(MarkerType _opType, bool _useIndices = false); + + /// \brief Set the render operation type + /// \param[in] _opType The type of render operation to perform. + public: void SetOperationType(MarkerType _opType); + + /// \brief Get the render operation type + /// \return The render operation type. + public: MarkerType OperationType() const; + + /// \brief Implementation of Ogre::SimpleRenderable + /// \return The bounding radius + public: virtual Ogre::Real getBoundingRadius() const; + + /// \brief Implementation of Ogre::SimpleRenderable + /// \param[in] _cam Pointer to the Ogre camera that views the + /// renderable. + /// \return The squared depth in the Camera's view + public: virtual Ogre::Real getSquaredViewDepth( + const Ogre::Camera *_cam) const; + + /// \brief Creates the vertex declaration. @remarks Override and set + /// mRenderOp.vertexData->vertexDeclaration here. mRenderOp.vertexData + /// will be created for you before this method is called. + protected: virtual void CreateVertexDeclaration() = 0; + + /// \brief Prepares the hardware buffers for the requested vertex and + /// index counts. + /// \remarks + /// This function must be called before locking the buffers in + /// fillHardwareBuffers(). It guarantees that the hardware buffers + /// are large enough to hold at least the requested number of + /// vertices and indices (if using indices). The buffers are + /// possibly reallocated to achieve this. + /// \par The vertex and index count in the render operation are set to + /// the values of vertexCount and indexCount respectively. + /// \param[in] _vertexCount The number of vertices the buffer must hold. + /// \param[in] _indexCount The number of indices the buffer must hold. + /// This parameter is ignored if not using indices. + protected: void PrepareHardwareBuffers(size_t _vertexCount, + size_t _indexCount); + + /// \brief Fills the hardware vertex and index buffers with data. + /// @remarks + /// This function must call prepareHardwareBuffers() before locking the + /// buffers to ensure the they are large enough for the data to be + /// written. Afterwards the vertex and index buffers (if using indices) + /// can be locked, and data can be written to them. + protected: virtual void FillHardwareBuffers() = 0; + + /// \brief Maximum capacity of the currently allocated vertex buffer. + protected: size_t vertexBufferCapacity = 0; + + /// \brief Maximum capacity of the currently allocated index buffer. + protected: size_t indexBufferCapacity = 0; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGaussianNoisePass.hh b/ogre/include/gz/rendering/ogre/OgreGaussianNoisePass.hh new file mode 100644 index 000000000..453ee2a50 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreGaussianNoisePass.hh @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREGAUSSIANNOISEPASS_HH_ +#define GZ_RENDERING_OGRE_OGREGAUSSIANNOISEPASS_HH_ + +#include + +#include + +#include "gz/rendering/base/BaseGaussianNoisePass.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderPass.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class GaussianNoiseCompositorListener; + + /* \class OgreGaussianNoisePass OgreGaussianNoisePass.hh \ + * ignition/rendering/ogre/OgreGaussianNoisePass.hh + */ + /// \brief Ogre implementation of the GaussianNoisePass class + class IGNITION_RENDERING_OGRE_VISIBLE OgreGaussianNoisePass : + public BaseGaussianNoisePass + { + /// \brief Constructor + public: OgreGaussianNoisePass(); + + /// \brief Destructor + public: virtual ~OgreGaussianNoisePass(); + + // Documentation inherited + public: void PreRender() override; + + // Documentation inherited + public: void Destroy() override; + + // Documentation inherited + public: void CreateRenderPass() override; + + /// \brief Gaussian noise compositor. + public: Ogre::CompositorInstance *gaussianNoiseInstance = nullptr; + + /// \brief Gaussian noise compositor listener + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public: std::shared_ptr + gaussianNoiseCompositorListener; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGeometry.hh b/ogre/include/gz/rendering/ogre/OgreGeometry.hh new file mode 100644 index 000000000..55e3ad4bd --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreGeometry.hh @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREGEOMETRY_HH_ +#define GZ_RENDERING_OGRE_OGREGEOMETRY_HH_ + +#include + +#include "gz/rendering/base/BaseGeometry.hh" +#include "gz/rendering/ogre/OgreObject.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreGeometry : + public BaseGeometry + { + protected: OgreGeometry(); + + public: virtual ~OgreGeometry(); + + public: virtual bool HasParent() const; + + public: virtual VisualPtr Parent() const; + + public: virtual Ogre::MovableObject *OgreObject() const = 0; + + protected: virtual void SetParent(OgreVisualPtr _parent); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: OgreVisualPtr parent; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreVisual; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGizmoVisual.hh b/ogre/include/gz/rendering/ogre/OgreGizmoVisual.hh new file mode 100644 index 000000000..c871c3703 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreGizmoVisual.hh @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREGIZMOVISUAL_HH_ +#define GZ_RENDERING_OGRE_OGREGIZMOVISUAL_HH_ + +#include "gz/rendering/base/BaseGizmoVisual.hh" +#include "gz/rendering/ogre/OgreVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreGizmoVisual : + public BaseGizmoVisual + { + /// \brief Constructor + protected: OgreGizmoVisual(); + + /// \brief Destructor + public: virtual ~OgreGizmoVisual(); + + /// \brief Only the ogre scene can instanstiate this class + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGpuRays.hh b/ogre/include/gz/rendering/ogre/OgreGpuRays.hh new file mode 100644 index 000000000..ce1a12ffd --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreGpuRays.hh @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGREGPURAYS_HH_ +#define GZ_RENDERING_OGRE_OGREGPURAYS_HH_ + +#include +#include +#include +#include + +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/base/BaseGpuRays.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreSensor.hh" + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class OgreGpuRaysPrivate; + + /** \class OgreGpuRays OgreGpuRays.hh\ + * rendering/ogre/OgreGpuRays.hh + **/ + /// \brief Gpu Rays used to render depth data into an image buffer + class IGNITION_RENDERING_OGRE_VISIBLE OgreGpuRays : + public BaseGpuRays, public Ogre::RenderObjectListener + { + /// \brief Constructor + protected: OgreGpuRays(); + + /// \brief Destructor + public: virtual ~OgreGpuRays(); + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Create dummy render texture. Needed to satisfy inheritance + public: virtual void CreateRenderTexture(); + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void PostRender() override; + + // Documentation inherited + public: virtual const float *Data() const override; + + // Documentation inherited. + public: virtual void Copy(float *_data) override; + + // Documentation inherited. + public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( + std::function _subscriber) override; + + // Documentation inherited. + public: virtual RenderTargetPtr RenderTarget() const override; + + /// \internal + /// \brief Implementation of Ogre::RenderObjectListener + public: virtual void notifyRenderSingleObject(Ogre::Renderable *_rend, + const Ogre::Pass *_p, const Ogre::AutoParamDataSource *_s, + const Ogre::LightList *_ll, bool _supp) override; + + /// \brief Set the number of samples in the width and height for the + /// first pass texture. + /// \param[in] _w Number of samples in the horizontal sweep + /// \param[in] _h Number of samples in the vertical sweep + private: virtual void Set1stTextureSize(const unsigned int _w, + const unsigned int _h = 1); + + /// \brief Set the number of samples in the width and height for the + /// second pass texture. + /// \param[in] _w Number of samples in the horizontal sweep + /// \param[in] _h Number of samples in the vertical sweep + private: virtual void SetRangeCount(const unsigned int _w, + const unsigned int _h = 1); + + // Documentation inherited. + private: virtual void Render() override; + + /// \brief Configure cameras. + private: void ConfigureCameras(); + + /// \brief Create a mesh. + private: void CreateMesh(); + + /// \brief Create a canvas. + private: void CreateCanvas(); + + /// \brief Create an ortho camera. + private: void CreateOrthoCam(); + + /// \brief Create an ortho camera. + private: void CreateCamera(); + + /// \brief Create the texture which is used to render gpu rays data. + private: virtual void CreateGpuRaysTextures(); + + /// \brief Builds scaled Orthogonal Matrix from parameters. + /// \param[in] _left Left clip. + /// \param[in] _right Right clip. + /// \param[in] _bottom Bottom clip. + /// \param[in] _top Top clip. + /// \param[in] _near Near clip. + /// \param[in] _far Far clip. + /// \return The Scaled orthogonal Ogre::Matrix4 + private: Ogre::Matrix4 BuildScaledOrthoMatrix(const float _left, + const float _right, const float _bottom, const float _top, + const float _near, const float _far); + + private: void UpdateRenderTarget(Ogre::RenderTarget *_target, + Ogre::Material *_material, + Ogre::Camera *_cam, + const bool _updateTex); + + /// \brief Get Cos Horz field-of-view + /// \return 2 * atan(tan(this->hfov/2) / cos(this->vfov/2)) + private: virtual double CosHorzFOV() const; + + /// \brief Set the Cos Horz FOV + /// \param[in] _chfov Cos Horz FOV + private: virtual void SetCosHorzFOV(const double _chfov); + + /// \brief Get Cos Vert field-of-view + /// \return 2 * atan(tan(this->vfov/2) / cos(this->hfov/2)) + private: virtual double CosVertFOV() const; + + /// \brief Set the Cos Horz FOV + /// \param[in] _cvfov Cos Horz FOV + private: virtual void SetCosVertFOV(const double _cvfov); + + /// \brief Get (horizontal_max_angle + horizontal_min_angle) * 0.5 + /// \return (horizontal_max_angle + horizontal_min_angle) * 0.5 + private: virtual double HorzHalfAngle() const; + + /// \brief Get (vertical_max_angle + vertical_min_angle) * 0.5 + /// \return (vertical_max_angle + vertical_min_angle) * 0.5 + private: virtual double VertHalfAngle() const; + + /// \brief Set the horizontal half angle + /// \param[in] _angle horizontal half angle + private: virtual void SetHorzHalfAngle(const double _angle); + + /// \brief Set the vertical half angle + /// \param[in] _angle vertical half angle + private: virtual void SetVertHalfAngle(const double _angle); + + /// \internal + /// \brief Pointer to private data. + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGrid.hh b/ogre/include/gz/rendering/ogre/OgreGrid.hh new file mode 100644 index 000000000..6a577051b --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreGrid.hh @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGREGRID_HH_ +#define GZ_RENDERING_OGRE_OGREGRID_HH_ + +#include +#include "gz/rendering/base/BaseGrid.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class OgreGridPrivate; + + /// \brief Ogre implementation of a grid geometry. + class IGNITION_RENDERING_OGRE_VISIBLE OgreGrid + : public BaseGrid + { + /// \brief Constructor + protected: OgreGrid(); + + /// \brief Destructor + public: virtual ~OgreGrid(); + + // Documentation inherited. + public: virtual void Init(); + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const; + + // Documentation inherited. + public: virtual void PreRender(); + + // Documentation inherited. + public: virtual MaterialPtr Material() const; + + // Documentation inherited. + public: virtual void SetMaterial(MaterialPtr _material, bool _unique); + + /// \brief Set material to grid geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); + + /// \brief Create the grid geometry in ogre + private: void Create(); + + /// \brief Grid should only be created by scene. + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreHeightmap.hh b/ogre/include/gz/rendering/ogre/OgreHeightmap.hh new file mode 100644 index 000000000..b75fde249 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreHeightmap.hh @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE_OGREHEIGHTMAP_HH_ +#define IGNITION_RENDERING_OGRE_OGREHEIGHTMAP_HH_ + +#include +#include +#include + +#include "ignition/rendering/base/BaseHeightmap.hh" +#include "ignition/rendering/ogre/OgreGeometry.hh" +#include "ignition/rendering/ogre/OgreIncludes.hh" + +// Ignoring warning: "non dll-interface class +// 'ignition::rendering::v5::Heightmap' used as base for dll-interface class" +// because `Heightmap` and `BaseHeightmap` are header-only +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4275) +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class OgreHeightmapPrivate; + + /// \brief Ogre implementation of a heightmap geometry. + class IGNITION_RENDERING_OGRE_VISIBLE OgreHeightmap + : public BaseHeightmap + { + /// \brief Constructor + protected: explicit OgreHeightmap(const HeightmapDescriptor &_desc); + + /// \brief Destructor + public: virtual ~OgreHeightmap(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + /// \brief Returns NULL, heightmaps don't have movable objects. + /// \return Null pointer. + public: virtual Ogre::MovableObject *OgreObject() const override; + + /// \brief Returns NULL, heightmap materials don't inherit from + /// MaterialPtr. + /// \return Null pointer. + public: virtual MaterialPtr Material() const override; + + /// \brief Has no effect for heightmaps. The material is set through a + /// HeightmapDescriptor. + /// \param[in] _material Not used. + /// \param[in] _unique Not used. + public: virtual void SetMaterial(MaterialPtr _material, bool _unique) + override; + + /// \brief Configure the terrain default values. + /// \todo Move to private? + private: void ConfigureTerrainDefaults(); + + /// \brief Checks if the terrain was previously loaded by comparing its + /// hash against the one stored in the terrain directory + /// \param[in] _terrainDirPath Path to the directory containing the + /// terrain files and hash. + /// \return True if the terrain requires to regenerate the terrain files. + private: bool PrepareTerrain(const std::string &_terrainDirPath); + + /// \brief Update the hash of a terrain file. The hash will be written in + /// a file called gzterrain.SHA1 . This method will be used when the + /// paging is enabled and the terrain is loaded for the first time or if + /// the heightmap's image has been modified. + /// \param[in] _hash New hash value + /// \param[in] _terrainDir Directory where the terrain hash and the + /// terrain pages are stored. Ex: $TMP/gazebo-paging/heigthmap_bowl + private: void UpdateTerrainHash(const std::string &_hash, + const std::string &_terrainDir); + + /// \brief Split a terrain into subterrains + /// \param[in] _heightmap Source vector of floats with the heights. + /// \param[in] _n Number of subterrains. + /// \param[out] _v Destination vector with the subterrains. + private: void SplitHeights(const std::vector &_heightmap, + int _n, std::vector> &_v); + + /// \brief Define a section of the terrain. + /// \param[in] _x X coordinate of the terrain. + /// \param[in] _y Y coordinate of the terrain. + private: void DefineTerrain(int _x, int _y); + + /// \brief Create terrain material generator. There are two types: + /// custom material generator that support user material scripts, + /// and a default material generator that uses our own glsl shader + /// and supports PSSM shadows. + private: void CreateMaterial(); + + /// \brief Initialize all the blend material maps. + /// \param[in] _terrain The terrain to initialize the blend maps. + private: bool InitBlendMaps(Ogre::Terrain *_terrain); + + /// \brief Internal function used to setup shadows for the terrain. + /// \param[in] _enabled True to enable shadows. + private: void SetupShadows(bool _enabled); + + /// \brief Heightmap should only be created by scene. + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreIncludes.hh b/ogre/include/gz/rendering/ogre/OgreIncludes.hh new file mode 100644 index 000000000..6901618c4 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreIncludes.hh @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREINCLUDES_HH_ +#define GZ_RENDERING_OGRE_OGREINCLUDES_HH_ + +// This disables warning messages for OGRE +#ifndef _MSC_VER + #pragma GCC system_header +#else + #pragma warning(push, 0) + #pragma warning(disable:4275) + #pragma warning(disable:4005) +#endif + +// This prevents some deprecation #warning messages on OSX 10.9 +#pragma clang diagnostic ignored "-W#warnings" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if OGRE_VERSION_MAJOR > 1 || OGRE_VERSION_MINOR >= 7 + #include +#endif + +#if OGRE_VERSION_MAJOR > 1 || OGRE_VERSION_MINOR >= 9 + #include + #include + #include + #include + #include +#else + #include +#endif + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreInertiaVisual.hh b/ogre/include/gz/rendering/ogre/OgreInertiaVisual.hh new file mode 100644 index 000000000..a956823d5 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreInertiaVisual.hh @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE_OGREINERTIAVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGREINERTIAVISUAL_HH_ + +#include + +#include "ignition/rendering/base/BaseInertiaVisual.hh" +#include "ignition/rendering/ogre/OgreIncludes.hh" +#include "ignition/rendering/ogre/OgreMaterial.hh" +#include "ignition/rendering/ogre/OgreVisual.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + // Forward declaration + class OgreInertiaVisualPrivate; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreInertiaVisual : + public BaseInertiaVisual + { + /// \brief Constructor + protected: OgreInertiaVisual(); + + /// \brief Destructor + public: virtual ~OgreInertiaVisual(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: Ogre::MovableObject *OgreObject() const; + + /// \brief Load the Inertia visual from its pose and scale + /// \param[in] _pose Pose of the Inertia visual + /// \param[in] _scale Scale factor of the box visual + public: void Load(const ignition::math::Pose3d &_pose, + const ignition::math::Vector3d &_scale) override; + + /// \brief Get the box visual + /// \return Pointer to the box visual + public: VisualPtr BoxVisual() const override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial( + MaterialPtr _material, bool _unique) override; + + /// \brief Set material to line geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); + + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreJointVisual.hh b/ogre/include/gz/rendering/ogre/OgreJointVisual.hh new file mode 100644 index 000000000..fb57497cc --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreJointVisual.hh @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_OGRE_OGREJOINTVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGREJOINTVISUAL_HH_ + +#include "ignition/rendering/base/BaseJointVisual.hh" +#include "ignition/rendering/ogre/OgreVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreJointVisual : + public BaseJointVisual + { + /// \brief Constructor + protected: OgreJointVisual(); + + /// \brief Destructor + public: virtual ~OgreJointVisual(); + + /// \brief Only scene can instantiate this class + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreLidarVisual.hh b/ogre/include/gz/rendering/ogre/OgreLidarVisual.hh new file mode 100644 index 000000000..f9ea3c40c --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreLidarVisual.hh @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE_OGRELIDARVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGRELIDARVISUAL_HH_ + +#include +#include +#include "ignition/rendering/base/BaseLidarVisual.hh" +#include "ignition/rendering/ogre/OgreVisual.hh" +#include "ignition/rendering/ogre/OgreIncludes.hh" +#include "ignition/rendering/ogre/OgreScene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class OgreLidarVisualPrivate; + + /// \brief Ogre implementation of a Lidar Visual. + class IGNITION_RENDERING_OGRE_VISIBLE OgreLidarVisual + : public BaseLidarVisual + { + /// \brief Constructor + protected: OgreLidarVisual(); + + /// \brief Destructor + public: virtual ~OgreLidarVisual(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual void Update() override; + + // Documentation inherited + public: virtual void SetPoints( + const std::vector &_points) override; + + // Documentation inherited + // This only affects lidar visuals with type LVT_POINTS + public: virtual void SetPoints(const std::vector &_points, + const std::vector &_colors) + override; + + // Documentation inherited + public: virtual void ClearPoints() override; + + // Documentation inherited + public: virtual unsigned int PointCount() const override; + + // Documentation inherited + public: virtual std::vector Points() const override; + + /// \brief Create the Lidar Visual in ogre + private: void Create(); + + /// \brief Clear data stored by dynamiclines + private: void ClearVisualData(); + + // Documentation inherited + public: virtual void SetVisible(bool _visible) override; + + /// \brief Lidar Visual should only be created by scene. + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreLight.hh b/ogre/include/gz/rendering/ogre/OgreLight.hh new file mode 100644 index 000000000..0274f9139 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreLight.hh @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRELIGHT_HH_ +#define GZ_RENDERING_OGRE_OGRELIGHT_HH_ + +#include "gz/rendering/base/BaseLight.hh" +#include "gz/rendering/ogre/OgreNode.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" + +namespace Ogre +{ + class Light; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreLight : + public BaseLight + { + protected: OgreLight(); + + public: virtual ~OgreLight(); + + public: virtual math::Color DiffuseColor() const override; + + public: virtual void SetDiffuseColor(const math::Color &_color) override; + + public: virtual math::Color SpecularColor() const override; + + public: virtual void SetSpecularColor( + const math::Color &_color) override; + + public: virtual double AttenuationConstant() const override; + + public: virtual void SetAttenuationConstant(double _value) override; + + public: virtual double AttenuationLinear() const override; + + public: virtual void SetAttenuationLinear(double _value) override; + + public: virtual double AttenuationQuadratic() const override; + + public: virtual void SetAttenuationQuadratic(double _value) override; + + public: virtual double AttenuationRange() const override; + + public: virtual void SetAttenuationRange(double _range) override; + + public: virtual bool CastShadows() const override; + + public: virtual void SetCastShadows(bool _castShadows) override; + + // Documentation Inherited + public: virtual double Intensity() const override; + + // Documentation Inherited + public: virtual void SetIntensity(double _intensity) override; + + public: virtual Ogre::Light *Light() const; + + public: virtual void Destroy() override; + + protected: virtual void Init() override; + + private: void CreateLight(); + + private: void UpdateAttenuation(); + + protected: double attenConstant; + + protected: double attenLinear; + + protected: double attenQuadratic; + + protected: double attenRange; + + protected: Ogre::Light *ogreLight; + + protected: Ogre::Light::LightTypes ogreLightType; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreDirectionalLight : + public BaseDirectionalLight + { + protected: OgreDirectionalLight(); + + public: virtual ~OgreDirectionalLight(); + + public: virtual math::Vector3d Direction() const; + + public: virtual void SetDirection(const math::Vector3d &_dir); + + private: friend class OgreScene; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgrePointLight : + public BasePointLight + { + protected: OgrePointLight(); + + public: virtual ~OgrePointLight(); + + private: friend class OgreScene; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreSpotLight : + public BaseSpotLight + { + protected: OgreSpotLight(); + + public: virtual ~OgreSpotLight(); + + public: virtual math::Vector3d Direction() const; + + public: virtual void SetDirection(const math::Vector3d &_dir); + + public: virtual math::Angle InnerAngle() const; + + public: virtual void SetInnerAngle(const math::Angle &_angle); + + public: virtual math::Angle OuterAngle() const; + + public: virtual void SetOuterAngle(const math::Angle &_angle); + + public: virtual double Falloff() const; + + public: virtual void SetFalloff(double _falloff); + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreLightVisual.hh b/ogre/include/gz/rendering/ogre/OgreLightVisual.hh new file mode 100644 index 000000000..801049c52 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreLightVisual.hh @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE_OGRELIGHTVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGRELIGHTVISUAL_HH_ + +#include + +#include "ignition/rendering/base/BaseLightVisual.hh" +#include "ignition/rendering/ogre/OgreIncludes.hh" +#include "ignition/rendering/ogre/OgreMaterial.hh" +#include "ignition/rendering/ogre/OgreVisual.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + // Forward declaration + class OgreLightVisualPrivate; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreLightVisual : + public BaseLightVisual + { + /// \brief Constructor + protected: OgreLightVisual(); + + /// \brief Destructor + public: virtual ~OgreLightVisual(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: Ogre::MovableObject *OgreObject() const; + + /// \brief Create the Light Visual in Ogre + public: void CreateVisual(); + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial( + MaterialPtr _material, bool _unique) override; + + /// \brief Set material to grid geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); + + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreMarker.hh b/ogre/include/gz/rendering/ogre/OgreMarker.hh new file mode 100644 index 000000000..3c0a4bd51 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreMarker.hh @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGREMARKER_HH_ +#define GZ_RENDERING_OGRE_OGREMARKER_HH_ + +#include +#include "gz/rendering/base/BaseMarker.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class OgreMarkerPrivate; + + /// \brief Ogre implementation of a marker geometry. + class IGNITION_RENDERING_OGRE_VISIBLE OgreMarker + : public BaseMarker + { + /// \brief Constructor + protected: OgreMarker(); + + /// \brief Destructor + public: virtual ~OgreMarker(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial( + MaterialPtr _material, bool _unique) override; + + // Documentation inherited + public: virtual void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value) override; + + // Documentation inherited + public: virtual void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color) override; + + // Documentation inherited + public: virtual void ClearPoints() override; + + // Documentation inherited + public: virtual void SetType(const MarkerType _markerType) override; + + // Documentation inherited + public: virtual MarkerType Type() const override; + + /// \brief Create the marker geometry in ogre + private: void Create(); + + /// \brief Marker should only be created by scene. + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreMaterial.hh b/ogre/include/gz/rendering/ogre/OgreMaterial.hh new file mode 100644 index 000000000..8469251b4 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreMaterial.hh @@ -0,0 +1,246 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREMATERIAL_HH_ +#define GZ_RENDERING_OGRE_OGREMATERIAL_HH_ + +#include + +#include + +#include "gz/rendering/base/BaseMaterial.hh" +#include "gz/rendering/ogre/OgreObject.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // TODO(anyone): use a better way to find shader configurations + const std::string depth_vertex_shader_file = + "depth_vertex_shader.glsl"; + const std::string depth_fragment_shader_file = + "depth_fragment_shader.glsl"; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterial : + public BaseMaterial + { + protected: OgreMaterial(); + + public: virtual ~OgreMaterial(); + + // Documentation inherited + public: virtual void Destroy() override; + + public: virtual bool LightingEnabled() const override; + + public: virtual void SetLightingEnabled(const bool _enabled) override; + + // Documentation inherited + public: virtual bool DepthCheckEnabled() const override; + + // Documentation inherited + public: virtual void SetDepthCheckEnabled(bool _enabled) override; + + // Documentation inherited + public: virtual bool DepthWriteEnabled() const override; + + // Documentation inherited + public: virtual void SetDepthWriteEnabled(bool _enabled) override; + + public: virtual math::Color Ambient() const override; + + public: virtual void SetAmbient(const math::Color &_color) override; + + public: virtual math::Color Diffuse() const override; + + public: virtual void SetDiffuse(const math::Color &_color) override; + + public: virtual math::Color Specular() const override; + + public: virtual void SetSpecular(const math::Color &_color) override; + + public: virtual math::Color Emissive() const override; + + public: virtual void SetEmissive(const math::Color &_color) override; + + public: virtual double Shininess() const override; + + public: virtual void SetShininess(const double _shininess) override; + + public: virtual double Transparency() const override; + + public: virtual void SetTransparency(const double _transparency) + override; + + // Documentation inherited + public: virtual void SetAlphaFromTexture(bool _enabled, + double _alpha = 0.5, bool _twoSided = true) override; + + public: virtual double Reflectivity() const override; + + public: virtual void SetReflectivity(const double _reflectivity) + override; + + public: virtual bool CastShadows() const override; + + // Documentation inherited. + public: virtual void SetCastShadows(const bool _castShadows) override; + + public: virtual bool ReceiveShadows() const override; + + public: virtual void SetReceiveShadows(const bool _receiveShadows) + override; + + // Documentation inherited + public: virtual float RenderOrder() const override; + + // Documentation inherited + // Review the official documentation to get more details about this + // parameter, in particular Ogre::Pass::setDepthBias() + // https://www.ogre3d.org/docs/api/1.8/class_ogre_1_1_pass.html + public: virtual void SetRenderOrder(const float _renderOrder) override; + + public: virtual bool ReflectionEnabled() const override; + + public: virtual void SetReflectionEnabled(const bool _enabled) override; + + public: virtual bool HasTexture() const override; + + public: virtual std::string Texture() const override; + + // Documentation inherited. + public: virtual void SetTexture(const std::string &_texture) override; + + public: virtual void ClearTexture() override; + + public: virtual bool HasNormalMap() const override; + + public: virtual std::string NormalMap() const override; + + // Documentation inherited. + public: virtual void SetNormalMap(const std::string &_normalMap) override; + + public: virtual void ClearNormalMap() override; + + public: virtual enum ShaderType ShaderType() const override; + + // Documentation inherited. + public: virtual void SetShaderType(enum ShaderType _type) override; + + public: virtual Ogre::MaterialPtr Material() const; + + // Documentation inherited. + // \sa Material::Set3DMaterial() + public: virtual void SetDepthMaterial(const double far, + const double near) override; + + // Documentation inherited. + // \sa Material::SetVertexShader(const std::string &) + public: virtual void SetVertexShader(const std::string &_path) override; + + // Documentation inherited. + // \sa Material::VertexShader() const + public: virtual std::string VertexShader() const override; + + // Documentation inherited. + // \sa Material::VertexShaderParams() + public: virtual ShaderParamsPtr VertexShaderParams() override; + + // Documentation inherited. + // \sa Material::SetFragmentShader(const std::string &) + public: virtual void SetFragmentShader(const std::string &_path) + override; + + // Documentation inherited. + // \sa Material::FragmentShader() const + public: virtual std::string FragmentShader() const override; + + // Documentation inherited. + // \sa Material::FragmentShaderParams() + public: virtual ShaderParamsPtr FragmentShaderParams() override; + + // Documentation inherited. + // \sa BaseMaterial::PreRender() + public: virtual void PreRender() override; + + protected: virtual void LoadOneImage(const std::string &_name, + Ogre::Image &_image); + + /// \brief Set the texture for this material + /// \param[in] _texture Name of the texture. + protected: virtual void SetTextureImpl(const std::string &_texture); + + protected: virtual Ogre::TexturePtr Texture(const std::string &_name); + + protected: virtual Ogre::TexturePtr CreateTexture( + const std::string &_name); + + protected: virtual void UpdateTransparency(); + + protected: virtual void UpdateColorOperation(); + + /// \brief bind shader parameters that have changed + protected: void UpdateShaderParams(); + + /// \brief Transfer params from ign-rendering type to ogre type + /// \param[in] _params ignition rendering params + /// \param[out] _ogreParams ogre type for holding params + protected: void UpdateShaderParams(ConstShaderParamsPtr _params, + Ogre::GpuProgramParametersSharedPtr _ogreParams); + + protected: virtual void Init() override; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: Ogre::MaterialPtr ogreMaterial; + + protected: Ogre::Technique *ogreTechnique = nullptr; + + protected: Ogre::Pass *ogrePass = nullptr; + + protected: Ogre::TextureUnitState *ogreTexState = nullptr; + + protected: Ogre::String ogreGroup; + +#if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR <= 7 + protected: math::Color emissiveColor; +#endif + protected: std::string textureName; + + protected: std::string normalMapName; + + protected: enum ShaderType shaderType = ST_PIXEL; + + /// \brief Path to vertex shader program. + protected: std::string vertexShaderPath; + + /// \brief Path to fragment shader program. + protected: std::string fragmentShaderPath; + + /// \brief Parameters to be bound to the vertex shader + protected: ShaderParamsPtr vertexShaderParams; + + /// \brief Parameters to be bound to the fragment shader + protected: ShaderParamsPtr fragmentShaderParams; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreMaterialSwitcher.hh b/ogre/include/gz/rendering/ogre/OgreMaterialSwitcher.hh new file mode 100644 index 000000000..141cfff4f --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreMaterialSwitcher.hh @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGREMATERIALSWITCHER_HH_ +#define GZ_RENDERING_OGRE_OGREMATERIALSWITCHER_HH_ + +#include +#include + +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations + class OgreSelectionBuffer; + + /// \brief Helper class to assign unique colors to renderables + class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterialSwitcher : +// Ogre::MaterialManager::Listener isn't a dll-interface class, this may cause +// issues +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4275) +#endif + public Ogre::MaterialManager::Listener, +#ifdef _MSC_VER + #pragma warning(pop) +#endif + Ogre::RenderTargetListener + { + /// \brief Constructor + public: OgreMaterialSwitcher(); + + /// \brief Destructor + public: ~OgreMaterialSwitcher(); + + /// \brief Get the entity with a specific color + /// \param[in] _color The entity's color. + public: std::string EntityName( + const gz::math::Color &_color) const; + + /// \brief Reset the color value incrementor + public: void Reset(); + + /// \brief Ogre callback that assigns colors to new renderables when the + /// requested scheme is not found + /// \param[in] _schemeIndex Index of scheme requested + /// \param[in] _schemeName Name of scheme requested + /// \param[in] _originalMaterial Orignal material that does not contain + /// the requested scheme + /// \param[in] _lodIndex The material level-of-detail + /// \param[in] _rend Pointer to the Ogre::Renderable object requesting + /// the use of the techinique + /// \return The Ogre material technique to use when scheme is not found. + public: virtual Ogre::Technique *handleSchemeNotFound( + uint16_t _schemeIndex, const Ogre::String &_schemeName, + Ogre::Material *_originalMaterial, uint16_t _lodIndex, + const Ogre::Renderable *_rend); + + /// \brief Ogre's pre render update callback + /// \param[in] _evt Ogre render target event containing information about + /// the source render target. + public: virtual void preRenderTargetUpdate( + const Ogre::RenderTargetEvent &_evt); + + /// \brief Ogre's post render update callback + /// \param[in] _evt Ogre render target event containing information about + /// the source render target. + public: virtual void postRenderTargetUpdate( + const Ogre::RenderTargetEvent &_evt); + + /// \brief Current unique color value + private: gz::math::Color currentColor; + + /// \brief last entity assigned an unique color value + private: std::string lastEntity; + + /// \brief last technique assigned to an entity. + private: Ogre::Technique *lastTechnique = nullptr; + + /// \brief Color dictionary that maps the unique color value to + /// renderable name + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::map colorDict; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Increment unique color value that will be assigned to the + /// next renderable + private: void NextColor(); + + /// \brief Selection Buffer class that make use of this class for + /// selecting entitiies + public: friend class OgreSelectionBuffer; + + /// \brief Plain material technique + private: Ogre::Technique *plainTechnique = nullptr; + + /// \brief Overlay material technique + private: Ogre::Technique *overlayTechnique = nullptr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreMesh.hh b/ogre/include/gz/rendering/ogre/OgreMesh.hh new file mode 100644 index 000000000..c2328bca8 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreMesh.hh @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREMESH_HH_ +#define GZ_RENDERING_OGRE_OGREMESH_HH_ + +#include +#include +#include +#include +#include +#include "gz/rendering/base/BaseMesh.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreObject.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" + +namespace Ogre +{ + class Entity; + class SubEntity; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations + class OgreMeshPrivate; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreMesh : + public BaseMesh + { + typedef std::vector NameList; + + protected: OgreMesh(); + + public: virtual ~OgreMesh(); + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual bool HasSkeleton() const override; + + // Documentation inherited. + public: virtual std::map + SkeletonLocalTransforms() const override; + + // Documentation inherited. + public: virtual void SetSkeletonLocalTransforms( + const std::map &_tfs) override; + + // Documentation inherited. + public: virtual std::unordered_map SkeletonWeights() + const override; + + // Documentation inherited. + public: virtual void SetSkeletonWeights( + const std::unordered_map &_weights) override; + + // Documentation inherited. + public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, + bool _enabled, bool _loop = true, float _weight = 1.0) override; + + // Documentation inherited. + public: virtual bool SkeletonAnimationEnabled(const std::string &_name) + const override; + + // Documentation inherited. + public: virtual void UpdateSkeletonAnimation( + std::chrono::steady_clock::duration _time) override; + + public: virtual Ogre::MovableObject *OgreObject() const override; + + protected: virtual SubMeshStorePtr SubMeshes() const override; + + protected: OgreSubMeshStorePtr subMeshes; + + protected: Ogre::Entity *ogreEntity = nullptr; + + private: friend class OgreScene; + + private: friend class OgreMeshFactory; + + /// \brief Pointer to private data + private: std::unique_ptr dataPtr; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreSubMesh : + public BaseSubMesh + { + protected: OgreSubMesh(); + + public: virtual ~OgreSubMesh(); + + public: virtual Ogre::SubEntity *OgreSubEntity() const; + + public: virtual void Destroy() override; + + // Documentation inherited + protected: virtual void SetMaterialImpl(MaterialPtr _material) override; + + protected: virtual void Init() override; + + protected: Ogre::SubEntity *ogreSubEntity; + + private: friend class OgreScene; + + private: friend class OgreSubMeshStoreFactory; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreMeshFactory.hh b/ogre/include/gz/rendering/ogre/OgreMeshFactory.hh new file mode 100644 index 000000000..92eb9f041 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreMeshFactory.hh @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREMESHFACTORY_HH_ +#define GZ_RENDERING_OGRE_OGREMESHFACTORY_HH_ + +#include +#include + +#include "gz/rendering/MeshDescriptor.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace Ogre +{ + class Entity; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreMeshFactory + { + public: explicit OgreMeshFactory(OgreScenePtr _scene); + + public: virtual ~OgreMeshFactory(); + + public: virtual OgreMeshPtr Create(const MeshDescriptor &_desc); + + protected: virtual Ogre::Entity *OgreEntity( + const MeshDescriptor &_desc); + + protected: virtual bool Load(const MeshDescriptor &_desc); + + protected: virtual bool IsLoaded(const MeshDescriptor &_desc); + + protected: virtual bool LoadImpl(const MeshDescriptor &_desc); + + protected: virtual std::string MeshName(const MeshDescriptor &_desc); + + protected: virtual bool Validate(const MeshDescriptor &_desc); + + /// \brief Remove internal material cache for a specific material + /// \param[in] _name Name of the template material to remove. + public: void ClearMaterialsCache(const std::string &_name); + + protected: OgreScenePtr scene; + + /// \brief Vector with the template materials, we keep the pointer to be + /// able to remove it when nobody is using it. + protected: std::vector materialCache; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreSubMeshStoreFactory + { + typedef std::vector NameList; + + public: OgreSubMeshStoreFactory(OgreScenePtr _scene, + Ogre::Entity *_entity); + + public: virtual ~OgreSubMeshStoreFactory(); + + public: virtual OgreSubMeshStorePtr Create(); + + protected: virtual OgreSubMeshPtr CreateSubMesh(unsigned int _index); + + protected: virtual void CreateNameList(); + + protected: virtual void PopulateDefaultNames(); + + protected: virtual void PopulateGivenNames(); + + protected: OgreScenePtr scene; + + protected: Ogre::Entity *ogreEntity; + + protected: NameList names; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreNode.hh b/ogre/include/gz/rendering/ogre/OgreNode.hh new file mode 100644 index 000000000..28c641680 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreNode.hh @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRENODE_HH_ +#define GZ_RENDERING_OGRE_OGRENODE_HH_ + +#include + +#include "gz/rendering/base/BaseNode.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreObject.hh" + +namespace Ogre +{ + class SceneNode; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreNode : + public BaseNode + { + protected: OgreNode(); + + public: virtual ~OgreNode(); + + public: virtual bool HasParent() const override; + + public: virtual NodePtr Parent() const override; + + public: virtual Ogre::SceneNode *Node() const; + + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual math::Vector3d LocalScale() const override; + + // Documentation inherited. + public: virtual bool InheritScale() const override; + + // Documentation inherited. + public: virtual void SetInheritScale(bool _inherit) override; + + // Documentation inherited. + protected: virtual void SetLocalScaleImpl( + const math::Vector3d &_scale) override; + + protected: virtual NodeStorePtr Children() const override; + + protected: virtual bool AttachChild(NodePtr _child) override; + + protected: virtual bool DetachChild(NodePtr _child) override; + + protected: virtual math::Pose3d RawLocalPose() const override; + + protected: virtual void SetRawLocalPose(const math::Pose3d &_Pose3d) + override; + + protected: virtual math::Vector3d RawLocalPosition() const; + + protected: virtual void SetRawLocalPosition( + const math::Vector3d &_position); + + protected: virtual math::Quaterniond RawLocalRotation() const; + + protected: virtual void SetRawLocalRotation( + const math::Quaterniond &_rotation); + + protected: virtual void SetParent(OgreNodePtr _parent); + + protected: virtual void Load() override; + + protected: virtual void Init() override; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: OgreNodePtr parent; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + protected: Ogre::SceneNode *ogreNode = nullptr; + + protected: OgreNodeStorePtr children; + + private: OgreNodePtr SharedThis(); + + // TODO(anyone): remove the need for a visual friend class + private: friend class OgreVisual; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreObject.hh b/ogre/include/gz/rendering/ogre/OgreObject.hh new file mode 100644 index 000000000..4acc1acc1 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreObject.hh @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREOBJECT_HH_ +#define GZ_RENDERING_OGRE_OGREOBJECT_HH_ + +#include + +#include "gz/rendering/base/BaseObject.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreObject : + public BaseObject + { + protected: OgreObject(); + + public: virtual ~OgreObject(); + + public: virtual ScenePtr Scene() const; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: OgreScenePtr scene; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreParticleEmitter.hh b/ogre/include/gz/rendering/ogre/OgreParticleEmitter.hh new file mode 100644 index 000000000..92604ff78 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreParticleEmitter.hh @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_OGRE_PARTICLEEMITTER_HH_ +#define IGNITION_RENDERING_OGRE_PARTICLEEMITTER_HH_ + +#include "ignition/rendering/base/BaseParticleEmitter.hh" +#include "ignition/rendering/ogre/OgreVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \brief Class to manage a particle emitter. + class IGNITION_RENDERING_OGRE_VISIBLE OgreParticleEmitter : + public BaseParticleEmitter + { + /// \brief Constructor + protected: OgreParticleEmitter(); + + /// \brief Destructor + public: virtual ~OgreParticleEmitter(); + + /// \brief Only the ogre scene can instanstiate this class + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRTShaderSystem.hh b/ogre/include/gz/rendering/ogre/OgreRTShaderSystem.hh new file mode 100644 index 000000000..1e4d1611b --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRTShaderSystem.hh @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRERTSHADERSYSTEM_HH_ +#define GZ_RENDERING_OGRE_OGRERTSHADERSYSTEM_HH_ + +#include +#include + +#include +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreRTShaderSystemPrivate; + + /// \addtogroup ign_rendering + /// \{ + + /// \class OgreRTShaderSystem OgreRTShaderSystem.hh rendering/rendering.hh + /// \brief Implements Ogre's Run-Time Shader system. + /// + /// This class allows Gazebo to generate per-pixel shaders for every + /// material at run-time. + class IGNITION_RENDERING_OGRE_VISIBLE OgreRTShaderSystem : + public common::SingletonT + { + /// \enum LightingModel + /// \brief The type of lighting + public: enum LightingModel + { + /// \brief Per-Vertex lighting: best performance. + SSLM_PerVertexLighting, + /// \brief Per-Pixel lighting: best look. + SSLM_PerPixelLighting, + /// \brief Normal Map lighting: lighting calculations have + /// been stored in a light map (texture) using tangent space. + SSLM_NormalMapLightingTangentSpace, + /// \brief Normal Map lighting: lighting calculations have + /// been stored in a light map (texture) using object space. + SSLM_NormalMapLightingObjectSpace + }; + + /// \brief Constructor. + private: OgreRTShaderSystem(); + + /// \brief Destructor. + private: virtual ~OgreRTShaderSystem(); + + /// \brief Initialize the run time shader system. + /// \return True if the run time shader system is initialized + /// successfully. + public: bool Init(); + + /// \brief Finalize the shader system + public: void Fini(); + + /// \brief Clear the shader system + public: void Clear(); + + /// \brief Add a scene manager + /// \param[in] _scene The scene to process + public: void AddScene(OgreScenePtr _scene); + + /// \brief Remove a scene + /// \param[in] _scene The scene to remove + public: void RemoveScene(OgreScenePtr _scene); + + /// \brief Remove a scene + /// \param[in] _scene Name of the scene to remove. + public: void RemoveScene(const std::string &_scene); + + /// \brief Update the shaders. This should not be called frequently. + public: void UpdateShaders(); + + /// \brief Set an Ogre::Entity to use RT shaders. + /// \param[in] _vis OgreSubMesh that will use the OgreRTShaderSystem. + public: void AttachEntity(OgreSubMesh *_vis); + + /// \brief Remove and entity. + /// \param[in] _vis Remove this visual. + public: void DetachEntity(OgreSubMesh *_vis); + + /// \brief Set a viewport to use shaders. + /// \param[in] _viewport The viewport to add. + /// \param[in] _scene The scene that the viewport uses. + public: static void AttachViewport(Ogre::Viewport *_viewport, + OgreScenePtr _scene); + + /// \brief Set a viewport to not use shaders. + /// \param[in] _viewport The viewport to remove. + /// \param[in] _scene The scene that the viewport uses. + public: static void DetachViewport(Ogre::Viewport *_viewport, + OgreScenePtr _scene); + + /// \brief Set the lighting model to per pixel or per vertex. + /// \param[in] _set True means to use per-pixel shaders. + public: void SetPerPixelLighting(bool _set); + + /// \brief Generate shaders for an entity + /// \param[in] _subMesh The submesh to remove shaders for. + public: void RemoveShaders(OgreSubMesh *_subMesh); + + /// \brief Generate shaders for an entity + /// \param[in] _subMesh The submesh to generate shaders for. + public: void GenerateShaders(OgreSubMesh *_subMesh); + + /// \brief Apply shadows to a scene. + /// \param[in] _scene The scene to receive shadows. + public: void ApplyShadows(OgreScenePtr _scene); + + /// \brief Remove shadows from a scene. + /// \param[in] _scene The scene to remove shadows from. + public: void RemoveShadows(OgreScenePtr _scene); + + /// \brief Get the Ogre PSSM Shadows camera setup. + /// \return The Ogre PSSM Shadows camera setup. + public: Ogre::PSSMShadowCameraSetup *PSSMShadowCameraSetup() const; + + /// \brief Get paths for the shader system + /// \param[out] _coreLibsPath Path to the core libraries. + /// \param[out] _cachePath Path to where the generated shaders are + /// stored. + private: bool Paths(std::string &_coreLibsPath, + std::string &_cachePath); + + /// \brief Set the shadow texture size. + /// \param[in] _size Size of shadow texture to set to. This must be a + /// power of 2. The default size is 1024. + /// \return True if size is set successfully, false otherwise. + public: bool SetShadowTextureSize(const unsigned int _size); + + /// \brief Get the shadow texture size. + /// \return Size of the shadow texture. The default size is 1024. + public: unsigned int ShadowTextureSize() const; + + /// \brief Get if RTShaderSystem is initialized or not + /// \return True if intialized. + public: bool IsInitialized() const; + + /// \brief Update the RT shaders. The call will only take effect if + /// shadow properties changed, e.g. texture size, or the shaders + /// have been marked dirty by UpdateShaders, e.g. when entities are + /// added. The function reapplies shadows if properties have changed, + /// and iterates through all entities added to RTShaderSystem + /// and regenerates shader programs for each entity if shaders are dirty. + /// This function is currently called by OgreScene::PreRender + /// \sa OgreScene::PreRender + public: void Update(); + + /// \brief Make the RTShader system a singleton. + private: friend class common::SingletonT; + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + }; + /// \} + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRayQuery.hh b/ogre/include/gz/rendering/ogre/OgreRayQuery.hh new file mode 100644 index 000000000..1e3c527b0 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRayQuery.hh @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRERAYQUERY_HH_ +#define GZ_RENDERING_OGRE_OGRERAYQUERY_HH_ + +#include + +#include "gz/rendering/base/BaseRayQuery.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreObject.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreRayQueryPrivate; + + /// \class OgreRayQuery OgreRayQuery.hh + /// ignition/rendering/base/OgreRayQuery.hh + /// \brief A Ray Query class used for computing ray object intersections + class IGNITION_RENDERING_OGRE_VISIBLE OgreRayQuery : + public BaseRayQuery + { + /// \brief Constructor + protected: OgreRayQuery(); + + /// \brief Destructor + public: virtual ~OgreRayQuery(); + + // Documentation inherited + public: virtual void SetFromCamera(const CameraPtr &_camera, + const math::Vector2d &_coord); + + // Documentation inherited + public: virtual RayQueryResult ClosestPoint(); + + /// \brief Get the mesh information for the given mesh. + /// \param[in] _mesh Mesh to get info about. + /// \param[out] _vertexCount Number of vertices in the mesh. + /// \param[out] _vertices Array of the vertices. + /// \param[out] _indexCount Number if indices. + /// \param[out] _indices Array of the indices. + /// \param[in] _position Position of the mesh. + /// \param[in] _orient Orientation of the mesh. + /// \param[in] _scale Scale of the mesh + // Code found in Wiki: www.ogre3d.org/wiki/index.php/RetrieveVertexData + private: void MeshInformation(const Ogre::Mesh *_mesh, + size_t &_vertexCount, + Ogre::Vector3* &_vertices, + size_t &_indexCount, + uint64_t* &_indices, + const math::Vector3d &_position, + const math::Quaterniond &_orient, + const math::Vector3d &_scale); + + /// \brief Private data pointer + private: std::unique_ptr dataPtr; + + /// \brief Pointer to friend scene class for creating ray query + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRenderEngine.hh b/ogre/include/gz/rendering/ogre/OgreRenderEngine.hh new file mode 100644 index 000000000..dd168a5cf --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRenderEngine.hh @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRERENDERENGINE_HH_ +#define GZ_RENDERING_OGRE_OGRERENDERENGINE_HH_ + +#include +#include +#include +#include + +#include + +#include "gz/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/base/BaseRenderEngine.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace Ogre +{ + class LogManager; + class Root; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreRenderEnginePrivate; + + /// \brief Plugin for loading ogre render engine + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderEnginePlugin : + public RenderEnginePlugin + { + /// \brief Constructor + public: OgreRenderEnginePlugin(); + + /// \brief Destructor + public: ~OgreRenderEnginePlugin() = default; + + /// \brief Get the name of the render engine loaded by this plugin. + /// \return Name of render engine + public: std::string Name() const; + + /// \brief Get a pointer to the render engine loaded by this plugin. + /// \return Render engine instance + public: RenderEngine *Engine() const; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderEngine : + public virtual BaseRenderEngine, + public common::SingletonT + { + /// \enum OgreRenderPathType + /// \brief The type of rendering path used by the rendering engine. + public: enum OgreRenderPathType + { + /// \brief No rendering is done. + NONE = 0, + /// \brief Most basic rendering, with least fidelity. + VERTEX = 1, + /// \brief Utilizes the RTT shader system. + FORWARD = 2, + /// \brief Utilizes deferred rendering. Best fidelity. + DEFERRED = 3, + /// \brief Count of the rendering path enums. + RENDER_PATH_COUNT + }; + + /// \brief Constructor + private: OgreRenderEngine(); + + public: virtual ~OgreRenderEngine(); + + public: virtual void Destroy() override; + + public: virtual bool IsEnabled() const override; + + public: virtual std::string Name() const override; + + public: OgreRenderPathType RenderPathType() const; + + public: void AddResourcePath(const std::string &_uri) override; + + public: virtual Ogre::Root *OgreRoot() const; + + public: std::string CreateRenderWindow(const std::string &_handle, + const unsigned int _width, const unsigned int _height, + const double _ratio, const unsigned int _antiAliasing); + + /// \brief Get a list of all supported FSAA levels for this render system + /// \return a list of FSAA levels + public: std::vector FSAALevels() const; + + protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual SceneStorePtr Scenes() const override; + + /// \brief Engine implementation of Load function. + /// \param[in] _params Parameters to be passed to the render engine. + /// Current accepts the following parameters and values: + /// "useCurrentGLContext" : "1" or "0". Use current OpenGL context for + /// rendering + protected: virtual bool LoadImpl( + const std::map &_params) override; + + protected: virtual bool InitImpl() override; + + private: void LoadAttempt(); + + private: void CreateLogger(); + + private: void CreateContext(); + + private: void CreateRoot(); + + private: void CreateOverlay(); + + private: void LoadPlugins(); + + private: void CreateRenderSystem(); + + private: void CreateResources(); + + private: void CreateRenderWindow(); + + private: void CheckCapabilities(); + + private: void InitAttempt(); + +#if (OGRE_VERSION >= ((1 << 16) | (9 << 8) | 0)) + /// \internal + /// \brief Get a pointer to the Ogre overlay system. + /// \return Pointer to the OGRE overlay system. + public: Ogre::OverlaySystem *OverlaySystem() const; + + private: Ogre::OverlaySystem *ogreOverlaySystem = nullptr; + +#endif + private: OgreSceneStorePtr scenes; + + private: OgreRenderPathType renderPathType; + + private: Ogre::Root *ogreRoot = nullptr; + + private: Ogre::LogManager *ogreLogManager = nullptr; + + /// \brief Paths to ogre plugins + private: std::vector ogrePaths; + +#if !defined(__APPLE__) && !defined(_WIN32) + private: void *dummyDisplay = nullptr; + + private: void *dummyContext = nullptr; +#endif + + private: uint64_t dummyWindowId = 0u; + + /// \brief True to use the current opengl context + private: bool useCurrentGLContext = false; + + private: std::unique_ptr dataPtr; + + private: friend class common::SingletonT; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRenderPass.hh b/ogre/include/gz/rendering/ogre/OgreRenderPass.hh new file mode 100644 index 000000000..629045cb4 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRenderPass.hh @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRERENDERPASS_HH_ +#define GZ_RENDERING_OGRE_OGRERENDERPASS_HH_ + +#include "gz/rendering/base/BaseRenderPass.hh" +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class OgreRenderPass OgreRenderPass.hh \ + * ignition/rendering/ogre/OgreRenderPass.hh + */ + /// \brief Ogre implementation of the RenderPass class + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderPass : + public BaseRenderPass + { + /// \brief Constructor + protected: OgreRenderPass(); + + /// \brief Destructor + public: virtual ~OgreRenderPass(); + + /// \brief Set the ogre camera that the render pass applies to + /// \param[in] _camera Pointer to the ogre camera. + public: virtual void SetCamera(Ogre::Camera *_camera); + + // Documentation inherited. + public: void Destroy() override; + + /// \brief Create the render pass using ogre compositor + public: virtual void CreateRenderPass(); + + /// \brief Pointer to the ogre camera + protected: Ogre::Camera *ogreCamera = nullptr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRenderTarget.hh b/ogre/include/gz/rendering/ogre/OgreRenderTarget.hh new file mode 100644 index 000000000..cbda9cc91 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRenderTarget.hh @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRERENDERTARGET_HH_ +#define GZ_RENDERING_OGRE_OGRERENDERTARGET_HH_ + +#include + +#include "gz/rendering/base/BaseRenderTypes.hh" +#include "gz/rendering/base/BaseRenderTarget.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreObject.hh" +#include "gz/rendering/ogre/OgreRenderTargetMaterial.hh" + +namespace Ogre +{ + class Camera; + class RenderTarget; + class Texture; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTarget : + public virtual BaseRenderTarget + { + protected: OgreRenderTarget(); + + public: virtual ~OgreRenderTarget(); + + public: virtual unsigned int AntiAliasing() const; + + public: virtual void SetAntiAliasing(unsigned int _aa); + + public: virtual void Copy(Image &_image) const override; + + public: virtual Ogre::Camera *Camera() const; + + public: virtual void SetCamera(Ogre::Camera *_camera); + + // Documentation inherited + public: virtual math::Color BackgroundColor() const override; + + public: virtual void SetBackgroundColor(math::Color _color); + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void PostRender() override; + + public: virtual void Render(); + + public: virtual void Destroy() override = 0; + + /// \brief Set a material to render on every object. This method is used + /// for special cases like the render target of a depth camera. + /// \param[in] _material The material to render + public: void SetMaterial(MaterialPtr _material); + + public: virtual Ogre::RenderTarget *RenderTarget() const = 0; + + public: Ogre::Viewport *AddViewport(Ogre::Camera *_viewport); + + public: Ogre::Viewport *Viewport(const int _viewportId) const; + + public: void SetUpdate(const bool _value); + + public: void SetAutoUpdated(const bool _value); + + /// \brief Set visibility mask for the viewport associated with this + /// render target + /// \param[in] _mask Visibility mask + public: virtual void SetVisibilityMask(uint32_t _mask); + + protected: virtual void UpdateBackgroundColor(); + + /// \brief Update render pass chain if changes were made + protected: virtual void UpdateRenderPassChain(); + + protected: virtual void RebuildImpl() override; + + protected: virtual void RebuildTarget() = 0; + + protected: virtual void RebuildViewport(); + + /// \brief Re-initializes render target material to apply a material to + /// everything in the scene. Does nothing if no material has been set + /// \sa OgreRenderTarget::RebuildImpl() + /// \sa BaseRenderTarget::Rebuild() + protected: void RebuildMaterial(); + + protected: Ogre::Camera *ogreCamera = nullptr; + + protected: Ogre::Viewport *ogreViewport = nullptr; + + protected: Ogre::ColourValue ogreBackgroundColor; + + /// \brief a material used by for the render target + protected: MaterialPtr material; + + /// \brief Helper class that applies the material to the render target + protected: OgreRenderTargetMaterialPtr materialApplicator; + + protected: bool colorDirty = true; + + protected: unsigned int antiAliasing = 4; + + /// \brief visibility mask associated with this render target + protected: uint32_t visibilityMask = IGN_VISIBILITY_ALL; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTexture : + public virtual BaseRenderTexture + { + protected: OgreRenderTexture(); + + public: virtual ~OgreRenderTexture(); + + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void PostRender() override; + + // Documentation inherited. + public: virtual unsigned int GLId(); + + public: virtual void Buffer(float *buffer); + + public: virtual Ogre::RenderTarget *RenderTarget() const override; + + protected: virtual void RebuildTarget() override; + + protected: virtual void DestroyTarget(); + + protected: virtual void BuildTarget(); + + protected: Ogre::Texture *ogreTexture = nullptr; + + private: friend class OgreScene; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderWindow : + public virtual BaseRenderWindow + { + protected: OgreRenderWindow(); + + public: virtual ~OgreRenderWindow(); + + public: virtual void Destroy(); + + protected: virtual Ogre::RenderTarget *RenderTarget() const; + + protected: virtual void RebuildTarget(); + + protected: virtual void BuildTarget(); + + protected: Ogre::RenderTarget *ogreRenderWindow = nullptr; + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRenderTargetMaterial.hh b/ogre/include/gz/rendering/ogre/OgreRenderTargetMaterial.hh new file mode 100644 index 000000000..627709d86 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRenderTargetMaterial.hh @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRRENDERTARGETMATERIAL_HH_ +#define GZ_RENDERING_OGRE_OGRRENDERTARGETMATERIAL_HH_ + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/Export.hh" + +// Ogre::MaterialManager::Listener isn't a dll-interface class, this may cause +// issues +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4275) +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Causes all objects in a scene to be rendered with the same + /// material when rendered by a given RenderTarget. + /// \internal + /// + /// On construction it registers as an Ogre::RenderTargetListener + /// on the provided Ogre::RenderTarget, and sets the material scheme name + /// to a value that is unlikely to exist. + /// When the target is about to be rendered it adds itself as an + /// Ogre::MaterialManager::Listener. + /// Every time ogre tries to get a technique for a material it will call + /// handleSchemeNotFound which returns the first supported technique on the + /// material provided to this class's constructor. + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTargetMaterial : + public Ogre::RenderTargetListener, + public Ogre::MaterialManager::Listener + { + /// \brief constructor + /// \param[in] _scene the scene manager responsible for rendering + /// \param[in] _renderTarget the RenderTarget this should apply to + /// \param[in] _material the material to apply to all renderables + public: OgreRenderTargetMaterial(OgreScenePtr _scene, + Ogre::RenderTarget *_renderTarget, Ogre::Material *_material); + + /// \brief destructor + public: ~OgreRenderTargetMaterial(); + + /// \brief Callback when a render target is about to be rendered + /// \param[in] _evt Ogre render target event containing information about + /// the source render target. + private: virtual void preRenderTargetUpdate( + const Ogre::RenderTargetEvent &_evt) override; + + /// \brief Callback when a render target is finisned being rendered + /// \param[in] _evt Ogre render target event containing information about + /// the source render target. + private: virtual void postRenderTargetUpdate( + const Ogre::RenderTargetEvent &_evt) override; + + /// \brief Ogre callback that assigned same material to all renderables + /// when the requested scheme is not found + /// \param[in] _schemeIndex Index of scheme requested + /// \param[in] _schemeName Name of scheme requested + /// \param[in] _originalMaterial Orignal material that does not contain + /// the requested scheme + /// \param[in] _lodIndex The material level-of-detail + /// \param[in] _rend Pointer to the Ogre::Renderable object requesting + /// the use of the techinique + /// \return The Ogre material technique to use when scheme is not found. + public: virtual Ogre::Technique *handleSchemeNotFound( + uint16_t _schemeIndex, const Ogre::String &_schemeName, + Ogre::Material *_originalMaterial, uint16_t _lodIndex, + const Ogre::Renderable *_rend) override; + + /// \brief scene manager responsible for rendering + private: OgreScenePtr scene; + + /// \brief render target that should see a uniform material + private: Ogre::RenderTarget *renderTarget; + + /// \brief material that should be applied to all objects + private: Ogre::Material *material; + + /// \brief name of the material scheme used by this applicator + private: Ogre::String schemeName; + }; + } + } +} + +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRenderTypes.hh b/ogre/include/gz/rendering/ogre/OgreRenderTypes.hh new file mode 100644 index 000000000..ab84a233d --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRenderTypes.hh @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRERENDERTYPES_HH_ +#define GZ_RENDERING_OGRE_OGRERENDERTYPES_HH_ + +#include +#include "gz/rendering/base/BaseRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class OgreArrowVisual; + class OgreAxisVisual; + class OgreCamera; + class OgreCapsule; + class OgreCOMVisual; + class OgreDepthCamera; + class OgreDirectionalLight; + class OgreGeometry; + class OgreGizmoVisual; + class OgreGpuRays; + class OgreGrid; + class OgreHeightmap; + class OgreInertiaVisual; + class OgreJointVisual; + class OgreLight; + class OgreLightVisual; + class OgreLidarVisual; + class OgreLight; + class OgreMarker; + class OgreMaterial; + class OgreMesh; + class OgreMeshFactory; + class OgreNode; + class OgreObject; + class OgreParticleEmitter; + class OgrePointLight; + class OgreRayQuery; + class OgreRenderEngine; + class OgreRenderTarget; + class OgreRenderTargetMaterial; + class OgreRenderTexture; + class OgreRenderWindow; + class OgreScene; + class OgreSensor; + class OgreSpotLight; + class OgreSubMesh; + class OgreText; + class OgreThermalCamera; + class OgreVisual; + class OgreWireBox; + + typedef BaseSceneStore OgreSceneStore; + typedef BaseNodeStore OgreNodeStore; + typedef BaseLightStore OgreLightStore; + typedef BaseSensorStore OgreSensorStore; + typedef BaseVisualStore OgreVisualStore; + typedef BaseGeometryStore OgreGeometryStore; + typedef BaseSubMeshStore OgreSubMeshStore; + typedef BaseMaterialMap OgreMaterialMap; + + typedef shared_ptr OgreArrowVisualPtr; + typedef shared_ptr OgreAxisVisualPtr; + typedef shared_ptr OgreCameraPtr; + typedef shared_ptr OgreCapsulePtr; + typedef shared_ptr OgreCOMVisualPtr; + typedef shared_ptr OgreDepthCameraPtr; + typedef shared_ptr OgreDirectionalLightPtr; + typedef shared_ptr OgreGeometryPtr; + typedef shared_ptr OgreGeometryStorePtr; + typedef shared_ptr OgreGizmoVisualPtr; + typedef shared_ptr OgreGpuRaysPtr; + typedef shared_ptr OgreGridPtr; + typedef shared_ptr OgreHeightmapPtr; + typedef shared_ptr OgreInertiaVisualPtr; + typedef shared_ptr OgreJointVisualPtr; + typedef shared_ptr OgreLightPtr; + typedef shared_ptr OgreLightVisualPtr; + typedef shared_ptr OgreLidarVisualPtr; + typedef shared_ptr OgreLightPtr; + typedef shared_ptr OgreLightStorePtr; + typedef shared_ptr OgreMarkerPtr; + typedef shared_ptr OgreMaterialPtr; + typedef shared_ptr OgreMaterialMapPtr; + typedef shared_ptr OgreMeshPtr; + typedef shared_ptr OgreMeshFactoryPtr; + typedef shared_ptr OgreNodePtr; + typedef shared_ptr OgreNodeStorePtr; + typedef shared_ptr OgreObjectPtr; + typedef shared_ptr OgreParticleEmitterPtr; + typedef shared_ptr OgrePointLightPtr; + typedef shared_ptr OgreRayQueryPtr; + typedef shared_ptr OgreRenderEnginePtr; + typedef shared_ptr OgreRenderTargetPtr; + typedef shared_ptr OgreRenderTargetMaterialPtr; + typedef shared_ptr OgreRenderTexturePtr; + typedef shared_ptr OgreRenderWindowPtr; + typedef shared_ptr OgreScenePtr; + typedef shared_ptr OgreSceneStorePtr; + typedef shared_ptr OgreSensorPtr; + typedef shared_ptr OgreSensorStorePtr; + typedef shared_ptr OgreSpotLightPtr; + typedef shared_ptr OgreSubMeshPtr; + typedef shared_ptr OgreSubMeshStorePtr; + typedef shared_ptr OgreTextPtr; + typedef shared_ptr OgreThermalCameraPtr; + typedef shared_ptr OgreVisualPtr; + typedef shared_ptr OgreVisualStorePtr; + typedef shared_ptr OgreWireBoxPtr; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreScene.hh b/ogre/include/gz/rendering/ogre/OgreScene.hh new file mode 100644 index 000000000..167fb8e5d --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreScene.hh @@ -0,0 +1,249 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRESCENE_HH_ +#define GZ_RENDERING_OGRE_OGRESCENE_HH_ + +#include +#include +#include "gz/rendering/base/BaseScene.hh" +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" + + +namespace Ogre +{ + class Root; + class SceneManager; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreScene : + public BaseScene + { + protected: OgreScene(unsigned int _id, const std::string &_name); + + public: virtual ~OgreScene(); + + public: virtual void Fini() override; + + public: virtual RenderEngine *Engine() const override; + + public: virtual VisualPtr RootVisual() const override; + + public: virtual math::Color AmbientLight() const override; + + public: virtual void SetAmbientLight(const math::Color &_color) override; + + public: virtual void SetBackgroundColor( + const math::Color &_color) override; + + // Documentation inherited. + public: virtual void SetGradientBackgroundColor( + const std::array &_colors) override; + + // Documentation inherited. + public: virtual void RemoveGradientBackgroundColor() override; + + public: virtual void PreRender() override; + + public: virtual void Clear() override; + + public: virtual void Destroy() override; + + public: virtual Ogre::SceneManager *OgreSceneManager() const; + + protected: virtual bool LoadImpl() override; + + protected: virtual bool InitImpl() override; + + protected: virtual DirectionalLightPtr CreateDirectionalLightImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited + protected: virtual COMVisualPtr CreateCOMVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual InertiaVisualPtr CreateInertiaVisualImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited + protected: virtual JointVisualPtr CreateJointVisualImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual LightVisualPtr CreateLightVisualImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual CameraPtr CreateCameraImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual DepthCameraPtr CreateDepthCameraImpl( + const unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual ThermalCameraPtr CreateThermalCameraImpl( + const unsigned int _id, + const std::string &_name) override; + + protected: virtual GpuRaysPtr CreateGpuRaysImpl( + const unsigned int _id, + const std::string &_name) override; + + protected: virtual VisualPtr CreateVisualImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual GeometryPtr CreateConeImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, + const std::string &_name, const std::string &_meshName); + + protected: virtual MeshPtr CreateMeshImpl( + unsigned int _id, + const std::string &_name, + const MeshDescriptor &_desc) override; + + // Documentation inherited + protected: virtual HeightmapPtr CreateHeightmapImpl( + unsigned int _id, + const std::string &_name, + const HeightmapDescriptor &_desc) override; + + // Documentation inherited + protected: virtual CapsulePtr CreateCapsuleImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual GridPtr CreateGridImpl( + unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual MarkerPtr CreateMarkerImpl( + unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual TextPtr CreateTextImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual RenderTexturePtr CreateRenderTextureImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited. + protected: virtual RenderWindowPtr CreateRenderWindowImpl( + unsigned int _id, const std::string &_name) override; + + protected: virtual RayQueryPtr CreateRayQueryImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited + protected: virtual ParticleEmitterPtr CreateParticleEmitterImpl( + unsigned int _id, const std::string &_name) override; + + protected: virtual bool InitObject(OgreObjectPtr _object, + unsigned int _id, const std::string &_name); + + protected: virtual LightStorePtr Lights() const override; + + protected: virtual SensorStorePtr Sensors() const override; + + protected: virtual VisualStorePtr Visuals() const override; + + protected: virtual MaterialMapPtr Materials() const override; + + /// \brief Remove internal material cache for a specific material + /// \param[in] _name Name of the template material to remove. + public: void ClearMaterialsCache(const std::string &_name); + + private: void CreateContext(); + + private: void CreateRootVisual(); + + private: void CreateMeshFactory(); + + private: void CreateStores(); + + private: OgreScenePtr SharedThis(); + + protected: OgreVisualPtr rootVisual; + + protected: OgreMeshFactoryPtr meshFactory; + + protected: OgreLightStorePtr lights; + + protected: OgreSensorStorePtr sensors; + + protected: OgreVisualStorePtr visuals; + + protected: OgreMaterialMapPtr materials; + + protected: Ogre::Root *ogreRoot; + + protected: Ogre::SceneManager *ogreSceneManager; + + private: friend class OgreRenderEngine; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreSelectionBuffer.hh b/ogre/include/gz/rendering/ogre/OgreSelectionBuffer.hh new file mode 100644 index 000000000..3a6932018 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreSelectionBuffer.hh @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_OGRE_OGRESELECTIONBUFFER_HH_ +#define GZ_RENDERING_OGRE_OGRESELECTIONBUFFER_HH_ + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace Ogre +{ + class Entity; + class RenderTarget; + class SceneManager; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreSelectionBufferPrivate; + + /// \brief Generates a selection buffer object for a given camera. + /// The selection buffer is used of entity selection. On setup, a unique + /// color is assigned to each entity. Whenever a selection request is made, + /// the selection buffer camera renders to a 1x1 sized offscreen buffer. + /// The color value of that pixel gives the identity of the entity. + class IGNITION_RENDERING_OGRE_VISIBLE OgreSelectionBuffer + { + /// \brief Constructor + /// \param[in] _cameraName Name of the camera to generate a selection + /// buffer for. + /// \param[in] _mgr Pointer to the scene manager. + public: OgreSelectionBuffer(const std::string &_cameraName, + Ogre::SceneManager *_mgr); + + /// \brief Destructor + public: ~OgreSelectionBuffer(); + + /// \brief Handle on mouse click + /// \param[in] _x X coordinate in pixels. + /// \param[in] _y Y coordinate in pixels. + /// \return Returns the Ogre entity at the coordinate. + public: Ogre::Entity *OnSelectionClick(const int _x, const int _y); + + /// \brief Debug show overlay + /// \param[in] _show True to show the selection buffer in an overlay. + public: void ShowOverlay(const bool _show); + + /// \brief Call this to update the selection buffer contents + public: void Update(); + + /// \brief Delete the render texture + private: void DeleteRTTBuffer(); + + /// \brief Create the render texture + private: void CreateRTTBuffer(); + + /// \brief Create the selection buffer offscreen render texture. + private: void CreateRTTOverlays(); + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreSensor.hh b/ogre/include/gz/rendering/ogre/OgreSensor.hh new file mode 100644 index 000000000..af5643099 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreSensor.hh @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRESENSOR_HH_ +#define GZ_RENDERING_OGRE_OGRESENSOR_HH_ + +#include "gz/rendering/base/BaseSensor.hh" +#include "gz/rendering/ogre/OgreNode.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreSensor : + public BaseSensor + { + protected: OgreSensor(); + + public: virtual ~OgreSensor(); + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreStorage.hh b/ogre/include/gz/rendering/ogre/OgreStorage.hh new file mode 100644 index 000000000..50db5882b --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreStorage.hh @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRESTORAGE_HH_ +#define GZ_RENDERING_OGRE_OGRESTORAGE_HH_ + +#include +#include "gz/rendering/base/BaseStorage.hh" + +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreLight.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreMesh.hh" +#include "gz/rendering/ogre/OgreNode.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreSensor.hh" +#include "gz/rendering/ogre/OgreVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + +// armhf failed to build with this code. It can not be removed for the rest +// of arches to keep ABI but should be removed in major versions unreleased +// see https://github.com/ignitionrobotics/ign-rendering/pull/457 +#ifndef __ARM_PCS_VFP + template class BaseSceneStore; + template class BaseNodeStore; + template class BaseLightStore; + template class BaseSensorStore; + template class BaseVisualStore; + template class BaseGeometryStore; + template class BaseSubMeshStore; + template class BaseMaterialMap; +#endif + + typedef BaseSceneStore OgreSceneStore; + typedef BaseNodeStore OgreNodeStore; + typedef BaseLightStore OgreLightStore; + typedef BaseSensorStore OgreSensorStore; + typedef BaseVisualStore OgreVisualStore; + typedef BaseGeometryStore OgreGeometryStore; + typedef BaseSubMeshStore OgreSubMeshStore; + typedef BaseMaterialMap OgreMaterialMap; + + typedef std::shared_ptr OgreSceneStorePtr; + typedef std::shared_ptr OgreNodeStorePtr; + typedef std::shared_ptr OgreLightStorePtr; + typedef std::shared_ptr OgreSensorStorePtr; + typedef std::shared_ptr OgreVisualStorePtr; + typedef std::shared_ptr OgreGeometryStorePtr; + typedef std::shared_ptr OgreSubMeshStorePtr; + typedef std::shared_ptr OgreMaterialMapPtr; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreText.hh b/ogre/include/gz/rendering/ogre/OgreText.hh new file mode 100644 index 000000000..fdda47cf1 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreText.hh @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGRETEXT_HH_ +#define GZ_RENDERING_OGRE_OGRETEXT_HH_ + +#include +#include + +#include +#include + +#include "gz/rendering/base/BaseText.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class OgreMovableText; + class OgreTextPrivate; + + /// \brief Ogre implementation of text geometry + class IGNITION_RENDERING_OGRE_VISIBLE OgreText + : public BaseText + { + /// \brief Constructor + protected: OgreText(); + + /// \brief Destructor + public: virtual ~OgreText(); + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual Ogre::MovableObject *OgreObject() const override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial(MaterialPtr _material, bool _unique) + override; + + // Documentation inherited. + public: virtual void SetFontName(const std::string &_font) override; + + // Documentation inherited. + public: virtual void SetTextString(const std::string &_text) override; + + // Documentation inherited. + public: virtual void SetColor(const gz::math::Color &_color) + override; + + // Documentation inherited. + public: virtual void SetCharHeight(const float _height) override; + + // Documentation inherited. + public: virtual void SetSpaceWidth(const float _width) override; + + // Documentation inherited. + public: virtual void SetTextAlignment( + const TextHorizontalAlign &_horizAlign, + const TextVerticalAlign &_vertAlign) override; + // Documentation inherited. + public: virtual void SetBaseline(const float _baseline) override; + + // Documentation inherited. + public: virtual void SetShowOnTop(const bool _onTop) override; + + // Documentation inherited. + public: virtual gz::math::AxisAlignedBox AABB() const override; + + /// \brief Set material to text geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); + + /// \brief Text should only be created by scene. + private: friend class OgreScene; + + /// \internal + /// \brief Private data pointer + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreThermalCamera.hh b/ogre/include/gz/rendering/ogre/OgreThermalCamera.hh new file mode 100644 index 000000000..c83b4fa58 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreThermalCamera.hh @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGRETHERMALCAMERA_HH_ +#define GZ_RENDERING_OGRE_OGRETHERMALCAMERA_HH_ + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +#include +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/base/BaseThermalCamera.hh" +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreSensor.hh" + +#include "gz/common/Event.hh" +#include "gz/common/Console.hh" + + +namespace Ogre +{ + class Material; + class Camera; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreThermalCameraPrivate; + + /** \class OgreThermalCamera OgreThermalCamera.hh\ + * rendering/ogre/OgreThermalCamera.hh + **/ + /// \brief Depth camera used to render thermal data into an image buffer + class IGNITION_RENDERING_OGRE_VISIBLE OgreThermalCamera : + public BaseThermalCamera + { + /// \brief Constructor + protected: OgreThermalCamera(); + + /// \brief Destructor + public: virtual ~OgreThermalCamera(); + + /// \brief Initialize the camera + public: virtual void Init() override; + + /// \brief Create a texture + public: virtual void CreateRenderTexture(); + + /// \brief Destroy render texture created by CreateRenderTexture() + /// Note: It's not virtual. + protected: void DestroyRenderTexture(); + + /// \brief Render the camera + public: virtual void PostRender() override; + + /// \brief Connect to the new thermal image signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewThermalFrame( + std::function _subscriber) override; + + // Documentation inherited. + public: virtual void PreRender() override; + + /// \brief Implementation of the render call + public: virtual void Render() override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Create the camera. + protected: void CreateCamera(); + + /// \brief Create thermal texture. This stores temperature data + private: void CreateThermalTexture(); + + /// \brief Pointer to the ogre camera + protected: Ogre::Camera *ogreCamera = nullptr; + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreVisual.hh b/ogre/include/gz/rendering/ogre/OgreVisual.hh new file mode 100644 index 000000000..532caae9e --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreVisual.hh @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREVISUAL_HH_ +#define GZ_RENDERING_OGRE_OGREVISUAL_HH_ + +#include + +#include "gz/rendering/base/BaseVisual.hh" +#include "gz/rendering/ogre/OgreNode.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreVisualPrivate; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreVisual : + public BaseVisual + { + protected: OgreVisual(); + + public: virtual ~OgreVisual(); + + // Documentation inherited. + public: virtual void SetWireframe(bool _show) override; + + // Documentation inherited. + public: virtual bool Wireframe() const override; + + // Documentation inherited. + public: virtual void SetVisible(bool _visible) override; + + // Documentation inherited. + public: virtual void SetVisibilityFlags(uint32_t _flags) override; + + // Documentation inherited. + public: virtual ignition::math::AxisAlignedBox LocalBoundingBox() + const override; + + // Documentation inherited. + public: virtual ignition::math::AxisAlignedBox BoundingBox() + const override; + + /// \brief Recursively loop through this visual's children + /// to obtain bounding box. + /// \param[in,out] _box The bounding box. + /// \param[in] _local A flag indicating if the local bounding box is to + /// be calculated. + /// \param[in] _pose World pose of the visual. + private: virtual void BoundsHelper( + ignition::math::AxisAlignedBox &_box, bool _local, + const ignition::math::Pose3d &_pose) const; + + /// \brief Wrapper function for BoundsHelper to reduce redundant + /// world pose access + /// \param[in,out] _box The bounding box. + /// \param[in] _local A flag indicating if the local bounding box is to + /// be calculated. + private: virtual void BoundsHelper( + ignition::math::AxisAlignedBox &_box, bool _local) const; + + protected: virtual GeometryStorePtr Geometries() const override; + + // Documentation inherited. + protected: virtual bool AttachGeometry(GeometryPtr _geometry) override; + + // Documentation inherited. + protected: virtual bool DetachGeometry(GeometryPtr _geometry) override; + + // Documentation inherited. + protected: virtual void Init() override; + + protected: OgreGeometryStorePtr geometries; + + private: OgreVisualPtr SharedThis(); + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreWireBox.hh b/ogre/include/gz/rendering/ogre/OgreWireBox.hh new file mode 100644 index 000000000..b22078f19 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreWireBox.hh @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE_OGREWIREBOX_HH_ +#define IGNITION_RENDERING_OGRE_OGREWIREBOX_HH_ + +#include +#include "ignition/rendering/base/BaseWireBox.hh" +#include "ignition/rendering/ogre/OgreGeometry.hh" +#include "ignition/rendering/ogre/OgreIncludes.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class OgreWireBoxPrivate; + + /// \brief Ogre implementation of a wire box geometry. + class IGNITION_RENDERING_OGRE_VISIBLE OgreWireBox + : public BaseWireBox + { + /// \brief Constructor + protected: OgreWireBox(); + + /// \brief Destructor + public: virtual ~OgreWireBox(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial(MaterialPtr _material, bool _unique) + override; + + /// \brief Set material to wire box geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); + + /// \brief Create the wire box geometry in ogre + private: void Create(); + + /// \brief Wire Box should only be created by scene. + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/ogre.hh.in b/ogre/include/gz/rendering/ogre/ogre.hh.in new file mode 100644 index 000000000..c4092f0cd --- /dev/null +++ b/ogre/include/gz/rendering/ogre/ogre.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/ogre/include/ignition/rendering/ogre.hh b/ogre/include/ignition/rendering/ogre.hh new file mode 100644 index 000000000..4e6486152 --- /dev/null +++ b/ogre/include/ignition/rendering/ogre.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/Export.hh b/ogre/include/ignition/rendering/ogre/Export.hh new file mode 100644 index 000000000..edc020462 --- /dev/null +++ b/ogre/include/ignition/rendering/ogre/Export.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2023 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh b/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh index 5e1bb8687..90e1bca8e 100644 --- a/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREARROWVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREARROWVISUAL_HH_ -#include "ignition/rendering/base/BaseArrowVisual.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreArrowVisual : - public BaseArrowVisual - { - protected: OgreArrowVisual(); - - public: virtual ~OgreArrowVisual(); - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh b/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh index 2dc439ae1..4cfcbd33a 100644 --- a/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREAXISVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREAXISVISUAL_HH_ -#include "ignition/rendering/base/BaseAxisVisual.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreAxisVisual : - public BaseAxisVisual - { - protected: OgreAxisVisual(); - - public: virtual ~OgreAxisVisual(); - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreCOMVisual.hh b/ogre/include/ignition/rendering/ogre/OgreCOMVisual.hh index 6dda62d99..ed8fc9bd1 100644 --- a/ogre/include/ignition/rendering/ogre/OgreCOMVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreCOMVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,73 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGRECOMVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGRECOMVISUAL_HH_ - -#include - -#include "ignition/rendering/base/BaseCOMVisual.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - // Forward declaration - class OgreCOMVisualPrivate; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreCOMVisual : - public BaseCOMVisual - { - /// \brief Constructor - protected: OgreCOMVisual(); - - /// \brief Destructor - public: virtual ~OgreCOMVisual(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: Ogre::MovableObject *OgreObject() const; - - /// \brief Create the Light Visual in Ogre - public: void CreateVisual(); - - // Documentation inherited - public: virtual VisualPtr SphereVisual() const override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial( - MaterialPtr _material, bool _unique) override; - - /// \brief Set material to grid geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); - - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreCamera.hh b/ogre/include/ignition/rendering/ogre/OgreCamera.hh index c14ef4014..6e81e2112 100644 --- a/ogre/include/ignition/rendering/ogre/OgreCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,145 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRECAMERA_HH_ -#define IGNITION_RENDERING_OGRE_OGRECAMERA_HH_ -#include - -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreSensor.hh" -#include "ignition/rendering/ogre/OgreSelectionBuffer.hh" - -namespace Ogre -{ - class Camera; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreSelectionBuffer; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreCamera : - public BaseCamera - { - protected: OgreCamera(); - - public: virtual ~OgreCamera(); - - // Documentation inherited. - public: virtual math::Angle HFOV() const override; - - // Documentation inherited. - public: virtual void SetHFOV(const math::Angle &_hfov) override; - - // Documentation inherited. - public: virtual double AspectRatio() const override; - - // Documentation inherited. - public: virtual void SetAspectRatio(const double _ratio) override; - - // Documentation inherited. - public: virtual unsigned int AntiAliasing() const override; - - // Documentation inherited. - public: virtual void SetAntiAliasing(const unsigned int _aa) override; - - // Documentation inherited. - public: virtual void SetFarClipPlane(const double _far) override; - - // Documentation inherited. - public: virtual void SetNearClipPlane(const double _near) override; - - public: virtual math::Color BackgroundColor() const; - - public: virtual void SetBackgroundColor(const math::Color &_color); - - // Documentation inherited. - public: virtual void Render() override; - - // Documentation inherited. - public: virtual RenderWindowPtr CreateRenderWindow() override; - - // Documentation inherited. - public: virtual math::Matrix4d ProjectionMatrix() const override; - - // Documentation inherited. - public: virtual void SetProjectionMatrix( - const math::Matrix4d &_matrix) override; - - // Documentation inherited. - public: virtual math::Matrix4d ViewMatrix() const override; - - // Documentation inherited. - public: virtual void SetProjectionType(CameraProjectionType _type) - override; - - public: void SetVFOV(double cameraVFOV) const; - - /// \brief Get the near clip distance - /// \return Near clip distance - public: double NearClip() const; - - /// \brief Get the far clip distance - /// \return Far clip distance - public: double FarClip() const; - - // Documentation inherited - public: virtual VisualPtr VisualAt(const ignition::math::Vector2i - &_mousePos) override; - - // Documentation Inherited. - // \sa Camera::SetMaterial(const MaterialPtr &) - public: virtual void SetMaterial( - const MaterialPtr &_material) override; - - // Documentation inherited. - public: virtual unsigned int RenderTextureGLId() const override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual void SetVisibilityMask(uint32_t _mask) override; - - /// \brief Get underlying Ogre camera - public: Ogre::Camera *Camera() const; - - // Documentation inherited. - // public: virtual uint32_t VisibilityMask() const override; - - protected: virtual RenderTargetPtr RenderTarget() const override; - - protected: virtual void Init() override; - - protected: virtual void SetSelectionBuffer(); - - private: void CreateCamera(); - - protected: virtual void CreateRenderTexture(); - - /// \brief Destroy render texture created by CreateRenderTexture() - /// Note: It's not virtual. - protected: void DestroyRenderTexture(); - - protected: Ogre::Camera *ogreCamera = nullptr; - - protected: OgreSelectionBuffer *selectionBuffer = nullptr; - - protected: OgreRenderTargetPtr renderTexture; - - protected: math::Color backgroundColor; - - private: friend class OgreScene; - private: friend class OgreRayQuery; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreCapsule.hh b/ogre/include/ignition/rendering/ogre/OgreCapsule.hh index 9cbb2a2ee..520a8354d 100644 --- a/ogre/include/ignition/rendering/ogre/OgreCapsule.hh +++ b/ogre/include/ignition/rendering/ogre/OgreCapsule.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,68 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGRECAPSULE_HH_ -#define IGNITION_RENDERING_OGRE_OGRECAPSULE_HH_ - -#include -#include "ignition/rendering/base/BaseCapsule.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // Forward declaration - class OgreCapsulePrivate; - - /// \brief Ogre 2.x implementation of a Capsule Visual. - class IGNITION_RENDERING_OGRE_VISIBLE OgreCapsule - : public BaseCapsule - { - /// \brief Constructor - protected: OgreCapsule(); - - /// \brief Destructor - public: virtual ~OgreCapsule(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void - SetMaterial(MaterialPtr _material, bool _unique) override; - - /// \brief Update the capsule geometry in ogre - private: void Update(); - - /// \brief Capsule should only be created by scene. - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreConversions.hh b/ogre/include/ignition/rendering/ogre/OgreConversions.hh index 0bb3b632e..88adfcdaa 100644 --- a/ogre/include/ignition/rendering/ogre/OgreConversions.hh +++ b/ogre/include/ignition/rendering/ogre/OgreConversions.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,93 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRECONVERSIONS_HH_ -#define IGNITION_RENDERING_OGRE_OGRECONVERSIONS_HH_ -#include -#include -#include -#include - -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \addtogroup ign_rendering - /// \{ - - /// \brief Conversions Conversions.hh rendering/Conversions.hh - /// \brief A set of utility function to convert between Gazebo and Ogre - /// data types - class IGNITION_RENDERING_OGRE_VISIBLE OgreConversions - { - /// \brief Return the equivalent ogre color - /// \param[in] _color ign-math color to convert - /// \return Ogre color value - public: static Ogre::ColourValue Convert( - const math::Color &_color); - - /// \brief Return the equivalent ign-math color - /// \param[in] _color Ogre color to convert - /// \return ign-math color value - public: static math::Color Convert( - const Ogre::ColourValue &_color); - - /// \brief return Ogre Vector from ign-math Vector3 - /// \param[in] _vector ign-math vector - /// \return Ogre vector - public: static Ogre::Vector3 Convert(const math::Vector3d &_vector); - - /// \brief return ign-math Vector from ogre Vector3 - /// \param[in] _vector Ogre vector - /// \return ign-math vector - public: static math::Vector3d Convert(const Ogre::Vector3 &_vector); - - /// \brief Ign-math quaternion to Ogre quaternion - /// \param[in] _quat ign-math quaternion - /// \return Ogre quaternion - public: static Ogre::Quaternion Convert(const math::Quaterniond &_quat); - - /// \brief Ogre quaternion to ign-math quaternion - /// \param[in] _quat Ogre quaternion - /// return ign-math quaternion - public: static math::Quaterniond Convert(const Ogre::Quaternion &_quat); - - /// \brief Ign-math angle to Ogre angle - /// \param[in] _angle ign-math angle - /// \return Ogre angle - public: static Ogre::Radian Convert(const math::Angle &_angle); - - /// \brief Ogre angle to ign-math angle - /// \param[in] _angle Ogre angle - /// return Ign-math angle - public: static math::Angle Convert(const Ogre::Radian &_angle); - - /// \brief Ogre Matrix4 to ignition math Matrix4d - /// \param[in] _m Ogre Matrix4 - /// \return ignition math Matrix4d - public: static math::Matrix4d Convert(const Ogre::Matrix4 &_m); - - /// \brief Ignition math Matrix4d to Ogre Matrix4 - /// \param[in] _m ignition math Matrix4d - /// \return Ogre Matrix4 - public: static Ogre::Matrix4 Convert(const math::Matrix4d &_m); - - /// \brief Ign-rendering PixelFormat to Ogre PixelFormat - /// \param[in] _format Ign-rendering PixelFormat - /// return Ogre PixelFormat - public: static Ogre::PixelFormat Convert(PixelFormat _format); - - private: static const Ogre::PixelFormat ogrePixelFormats[PF_COUNT]; - }; - /// \} - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh b/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh index 452e9fe2b..879bc7296 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,172 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREDEPTHCAMERA_HH_ -#define IGNITION_RENDERING_OGRE_OGREDEPTHCAMERA_HH_ - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -#include -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/base/BaseDepthCamera.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreSensor.hh" -#include "ignition/rendering/ogre/OgreSelectionBuffer.hh" - -#include "ignition/common/Event.hh" -#include "ignition/common/Console.hh" - - -namespace Ogre -{ - class Material; - class RenderTarget; - class Texture; - class Viewport; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreDepthCameraPrivate; - - /** \class OgreDepthCamera OgreDepthCamera.hh\ - * rendering/ogre/OgreDepthCamera.hh - **/ - /// \brief Depth camera used to render depth data into an image buffer - class IGNITION_RENDERING_OGRE_VISIBLE OgreDepthCamera : - public BaseDepthCamera - { - /// \brief Constructor - protected: OgreDepthCamera(); - - /// \brief Destructor - public: virtual ~OgreDepthCamera(); - - /// \brief Initialize the camera - public: virtual void Init() override; - - /// \brief Create a texture which will hold the depth data - public: virtual void CreateDepthTexture() override; - - /// \brief Destroy render texture created by CreateDepthTexture() - /// Note: It's not virtual. - protected: void DestroyDepthTexture(); - - /// \brief Render the camera - public: virtual void PostRender() override; - - /// \brief All things needed to get back z buffer for depth data - /// \return The z-buffer as a float array - public: virtual const float *DepthData() const override; - - /// \brief Connect a to the new depth image signal - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewDepthFrame( - std::function _subscriber) override; - - /// \brief Connect a to the new rgb point cloud signal - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewRgbPointCloud( - std::function _subscriber) override; - - // Documentation inherited. - public: virtual void PreRender() override; - - /// \brief Implementation of the render call - public: virtual void Render() override; - - /// \brief Set the far clip distance - /// \param[in] _far far clip distance - public: virtual void SetFarClipPlane(const double _far) override; - - /// \brief Set the near clip distance - /// \param[in] _near Near clip distance - public: virtual void SetNearClipPlane(const double _near) override; - - /// \brief Get the near clip distance - /// \return Near clip distance. A value of zero is returned if the - /// ogre camera has not been created. - public: double NearClipPlane() const override; - - /// \brief Get the far clip distance - /// \return Far clip distance. A value of zero is returned if the - /// ogre camera has not been created. - public: double FarClipPlane() const override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Update a render target - /// \param[in] _target Render target to update - /// \param[in] _material Material to use - /// \param[in] _matName Material name - protected: void UpdateRenderTarget(OgreRenderTexturePtr _target, - Ogre::Material *_material, - const std::string &_matName); - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Limit field of view taking care of using a valid value for - /// an OGRE camera. - /// \param[in] _fov expected field of view - /// \return valid field of view - protected: static double LimitFOV(const double _fov); - - /// \brief Create the camera. - protected: void CreateCamera(); - - /// \brief Create point cloud texture. This stores xyz rgb data - private: void CreatePointCloudTexture(); - - /// \brief Destroy render texture created by CreatePointCloudTexture() - /// Note: It's not virtual. - protected: void DestroyPointCloudTexture(); - - /// \brief Communicates that a frams was rendered - protected: bool newData = false; - - protected: bool captureData = false; - - /// \brief Pointer to the depth texture - protected: OgreRenderTexturePtr depthTexture; - - /// \brief Pointer to the depth viewport - protected: Ogre::Viewport *depthViewport = nullptr; - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera; - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - private: friend class OgreScene; - private: friend class OgreRayQuery; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreDistortionPass.hh b/ogre/include/ignition/rendering/ogre/OgreDistortionPass.hh index a89f15f56..e9340859c 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDistortionPass.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDistortionPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,86 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREDISTORTIONPASS_HH_ -#define IGNITION_RENDERING_OGRE_OGREDISTORTIONPASS_HH_ -#include -#include - -#include -#include - -#include "ignition/rendering/base/BaseDistortionPass.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderPass.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class DistortionCompositorListener; - - /* \class OgreDistortionPass OgreDistortionPass.hh \ - * ignition/rendering/ogre/OgreDistortionPass.hh - */ - /// \brief Ogre implementation of the DistortionPass class - class IGNITION_RENDERING_OGRE_VISIBLE OgreDistortionPass : - public BaseDistortionPass - { - /// \brief Constructor - public: OgreDistortionPass(); - - /// \brief Destructor - public: virtual ~OgreDistortionPass(); - - // Documentation inherited - public: void PreRender() override; - - // Documentation inherited - public: void Destroy() override; - - // Documentation inherited - public: void CreateRenderPass() override; - - /// \brief Apply distortion model using camera coordinates projection - /// \param[in] _in Input uv coordinate. - /// \param[in] _center Normalized distortion center. - /// \param[in] _k1 Radial distortion coefficient k1. - /// \param[in] _k2 Radial distortion coefficient k2. - /// \param[in] _k3 Radial distortion coefficient k3. - /// \param[in] _p1 Tangential distortion coefficient p1. - /// \param[in] _p2 Tangential distortion coefficient p2. - /// \param[in] _width Width of the image texture in pixels. - /// \param[in] _f Focal length in pixels. - /// \return Distorted coordinate. - public: static ignition::math::Vector2d Distort( - const ignition::math::Vector2d &_in, - const ignition::math::Vector2d &_center, - double _k1, double _k2, double _k3, - double _p1, double _p2, - unsigned int _width, double _f); - - /// \brief get the distortion map value. - /// \param[in] _x X component of map. - /// \param[in] _y Y component of map. - /// \return the distortion map value at the specified index. - protected: ignition::math::Vector2d - DistortionMapValueClamped(int _x, int _y) const; - - /// \brief calculate the correct scale factor to "zoom" the render, - /// cutting off black borders caused by distortion (only if the crop - /// flag has been set). - protected: void CalculateAndApplyDistortionScale(); - - /// \internal - /// \brief Private data pointer - IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr) - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh b/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh index 09dc6f265..1f909473b 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,99 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_OGRE_OGREDYNAMICLINES_HH_ -#define IGNITION_RENDERING_OGRE_OGREDYNAMICLINES_HH_ + */ -#include -#include -#include -#include - -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreDynamicRenderable.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \brief Forward declaration - class OgreDynamicLinesPrivate; - - /* \class OgreDynamicLines OgreDynamicLines.hh \ - * ignition/rendering/ogre/OgreDynamicLines.hh - */ - /// \brief Class for drawing lines that can change - class IGNITION_RENDERING_OGRE_VISIBLE OgreDynamicLines : - public OgreDynamicRenderable - { - /// \brief Constructor - /// \param[in] _opType The type of Line - public: explicit OgreDynamicLines( - MarkerType _opType = MT_LINE_STRIP); - - /// \brief Destructor - public: virtual ~OgreDynamicLines(); - - /// \brief Add a point to the point list - /// \param[in] _pt ignition::math::Vector3d point - /// \param[in] _color ignition::math::Color Point color - public: void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color = ignition::math::Color::White); - - /// \brief Add a point to the point list. - /// \param[in] _x X position - /// \param[in] _y Y position - /// \param[in] _z Z position - /// \param[in] _color ignition::math::Color Point color - public: void AddPoint(const double _x, const double _y, const double _z, - const ignition::math::Color &_color = ignition::math::Color::White); - - /// \brief Change the location of an existing point in the point list - /// \param[in] _index Index of the point to set - /// \param[in] _value ignition::math::Vector3d value to set the point to - public: void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value); - - /// \brief Change the color of an existing point in the point list - /// \param[in] _index Index of the point to set - /// \param[in] _color ignition::math::Color Pixelcolor color to set the - /// point to - public: void SetColor(unsigned int _index, - const ignition::math::Color &_color); - - /// \brief Return the location of an existing point in the point list - /// \param[in] _index Number of the point to return - /// \return ignition::math::Vector3d value of the point. A vector of - /// [ignition::math::INF_D, ignition::math::INF_D, ignition::math::INF_D] - /// is returned when then the _index is out of bounds. - /// ignition::math::INF_D==std::numeric_limits::infinity() - public: ignition::math::Vector3d Point(unsigned int _index) const; - - /// \brief Return the total number of points in the point list - /// \return Number of points - public: unsigned int PointCount() const; - - /// \brief Remove all points from the point list - public: void Clear(); - - /// \brief Call this to update the hardware buffer after making changes. - public: void Update(); - - /// \brief Implementation DynamicRenderable, - /// creates a simple vertex-only decl - private: virtual void CreateVertexDeclaration(); - - /// \brief Implementation DynamicRenderable, pushes point - /// list out to hardware memory - private: virtual void FillHardwareBuffers(); - - /// \brief private implementation - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh b/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh index f27132405..3c800846e 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,99 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_OGRE_OGREDYNAMICRENDERABLE_HH_ -#define IGNITION_RENDERING_OGRE_OGREDYNAMICRENDERABLE_HH_ + */ -#include -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/Marker.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /* \class OgreDynamicRenderable OgreDynamicRenderable.hh \ - * ignition/rendering/ogre/OgreDynamicRenderable.hh - */ - /// \brief Abstract base class providing mechanisms for dynamically - /// growing hardware buffers. - class IGNITION_RENDERING_OGRE_VISIBLE OgreDynamicRenderable : - public Ogre::SimpleRenderable - { - /// \brief Constructor - public: OgreDynamicRenderable(); - - /// \brief Virtual destructor - public: virtual ~OgreDynamicRenderable(); - - /// \brief Initializes the dynamic renderable. - /// \remarks This function should only be called once. It initializes the - /// render operation, and calls the abstract function - /// CreateVertexDeclaration(). - /// \param[in] _opType The type of render operation to perform. - /// \param[in] _useIndices Specifies whether to use indices to - /// determine the vertices to use as input. - public: void Init(MarkerType _opType, bool _useIndices = false); - - /// \brief Set the render operation type - /// \param[in] _opType The type of render operation to perform. - public: void SetOperationType(MarkerType _opType); - - /// \brief Get the render operation type - /// \return The render operation type. - public: MarkerType OperationType() const; - - /// \brief Implementation of Ogre::SimpleRenderable - /// \return The bounding radius - public: virtual Ogre::Real getBoundingRadius() const; - - /// \brief Implementation of Ogre::SimpleRenderable - /// \param[in] _cam Pointer to the Ogre camera that views the - /// renderable. - /// \return The squared depth in the Camera's view - public: virtual Ogre::Real getSquaredViewDepth( - const Ogre::Camera *_cam) const; - - /// \brief Creates the vertex declaration. @remarks Override and set - /// mRenderOp.vertexData->vertexDeclaration here. mRenderOp.vertexData - /// will be created for you before this method is called. - protected: virtual void CreateVertexDeclaration() = 0; - - /// \brief Prepares the hardware buffers for the requested vertex and - /// index counts. - /// \remarks - /// This function must be called before locking the buffers in - /// fillHardwareBuffers(). It guarantees that the hardware buffers - /// are large enough to hold at least the requested number of - /// vertices and indices (if using indices). The buffers are - /// possibly reallocated to achieve this. - /// \par The vertex and index count in the render operation are set to - /// the values of vertexCount and indexCount respectively. - /// \param[in] _vertexCount The number of vertices the buffer must hold. - /// \param[in] _indexCount The number of indices the buffer must hold. - /// This parameter is ignored if not using indices. - protected: void PrepareHardwareBuffers(size_t _vertexCount, - size_t _indexCount); - - /// \brief Fills the hardware vertex and index buffers with data. - /// @remarks - /// This function must call prepareHardwareBuffers() before locking the - /// buffers to ensure the they are large enough for the data to be - /// written. Afterwards the vertex and index buffers (if using indices) - /// can be locked, and data can be written to them. - protected: virtual void FillHardwareBuffers() = 0; - - /// \brief Maximum capacity of the currently allocated vertex buffer. - protected: size_t vertexBufferCapacity = 0; - - /// \brief Maximum capacity of the currently allocated index buffer. - protected: size_t indexBufferCapacity = 0; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh b/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh index 93c5ddee3..35c88ee26 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,59 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREGAUSSIANNOISEPASS_HH_ -#define IGNITION_RENDERING_OGRE_OGREGAUSSIANNOISEPASS_HH_ -#include - -#include - -#include "ignition/rendering/base/BaseGaussianNoisePass.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderPass.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class GaussianNoiseCompositorListener; - - /* \class OgreGaussianNoisePass OgreGaussianNoisePass.hh \ - * ignition/rendering/ogre/OgreGaussianNoisePass.hh - */ - /// \brief Ogre implementation of the GaussianNoisePass class - class IGNITION_RENDERING_OGRE_VISIBLE OgreGaussianNoisePass : - public BaseGaussianNoisePass - { - /// \brief Constructor - public: OgreGaussianNoisePass(); - - /// \brief Destructor - public: virtual ~OgreGaussianNoisePass(); - - // Documentation inherited - public: void PreRender() override; - - // Documentation inherited - public: void Destroy() override; - - // Documentation inherited - public: void CreateRenderPass() override; - - /// \brief Gaussian noise compositor. - public: Ogre::CompositorInstance *gaussianNoiseInstance = nullptr; - - /// \brief Gaussian noise compositor listener - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public: std::shared_ptr - gaussianNoiseCompositorListener; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreGeometry.hh b/ogre/include/ignition/rendering/ogre/OgreGeometry.hh index 2700d3c97..263043a72 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGeometry.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGeometry.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,47 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREGEOMETRY_HH_ -#define IGNITION_RENDERING_OGRE_OGREGEOMETRY_HH_ -#include - -#include "ignition/rendering/base/BaseGeometry.hh" -#include "ignition/rendering/ogre/OgreObject.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreGeometry : - public BaseGeometry - { - protected: OgreGeometry(); - - public: virtual ~OgreGeometry(); - - public: virtual bool HasParent() const; - - public: virtual VisualPtr Parent() const; - - public: virtual Ogre::MovableObject *OgreObject() const = 0; - - protected: virtual void SetParent(OgreVisualPtr _parent); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: OgreVisualPtr parent; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - private: friend class OgreVisual; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh b/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh index 2fdb75e52..6ecdbe616 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREGIZMOVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREGIZMOVISUAL_HH_ -#include "ignition/rendering/base/BaseGizmoVisual.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreGizmoVisual : - public BaseGizmoVisual - { - /// \brief Constructor - protected: OgreGizmoVisual(); - - /// \brief Destructor - public: virtual ~OgreGizmoVisual(); - - /// \brief Only the ogre scene can instanstiate this class - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh b/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh index fa39bee88..3a7cfcc2b 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,185 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREGPURAYS_HH_ -#define IGNITION_RENDERING_OGRE_OGREGPURAYS_HH_ - -#include -#include -#include -#include - -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/base/BaseGpuRays.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreSensor.hh" - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class OgreGpuRaysPrivate; - - /** \class OgreGpuRays OgreGpuRays.hh\ - * rendering/ogre/OgreGpuRays.hh - **/ - /// \brief Gpu Rays used to render depth data into an image buffer - class IGNITION_RENDERING_OGRE_VISIBLE OgreGpuRays : - public BaseGpuRays, public Ogre::RenderObjectListener - { - /// \brief Constructor - protected: OgreGpuRays(); - - /// \brief Destructor - public: virtual ~OgreGpuRays(); - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Create dummy render texture. Needed to satisfy inheritance - public: virtual void CreateRenderTexture(); - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void PostRender() override; - - // Documentation inherited - public: virtual const float *Data() const override; - - // Documentation inherited. - public: virtual void Copy(float *_data) override; - - // Documentation inherited. - public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( - std::function _subscriber) override; - - // Documentation inherited. - public: virtual RenderTargetPtr RenderTarget() const override; - - /// \internal - /// \brief Implementation of Ogre::RenderObjectListener - public: virtual void notifyRenderSingleObject(Ogre::Renderable *_rend, - const Ogre::Pass *_p, const Ogre::AutoParamDataSource *_s, - const Ogre::LightList *_ll, bool _supp) override; - - /// \brief Set the number of samples in the width and height for the - /// first pass texture. - /// \param[in] _w Number of samples in the horizontal sweep - /// \param[in] _h Number of samples in the vertical sweep - private: virtual void Set1stTextureSize(const unsigned int _w, - const unsigned int _h = 1); - - /// \brief Set the number of samples in the width and height for the - /// second pass texture. - /// \param[in] _w Number of samples in the horizontal sweep - /// \param[in] _h Number of samples in the vertical sweep - private: virtual void SetRangeCount(const unsigned int _w, - const unsigned int _h = 1); - - // Documentation inherited. - private: virtual void Render() override; - - /// \brief Configure cameras. - private: void ConfigureCameras(); - - /// \brief Create a mesh. - private: void CreateMesh(); - - /// \brief Create a canvas. - private: void CreateCanvas(); - - /// \brief Create an ortho camera. - private: void CreateOrthoCam(); - - /// \brief Create an ortho camera. - private: void CreateCamera(); - - /// \brief Create the texture which is used to render gpu rays data. - private: virtual void CreateGpuRaysTextures(); - - /// \brief Builds scaled Orthogonal Matrix from parameters. - /// \param[in] _left Left clip. - /// \param[in] _right Right clip. - /// \param[in] _bottom Bottom clip. - /// \param[in] _top Top clip. - /// \param[in] _near Near clip. - /// \param[in] _far Far clip. - /// \return The Scaled orthogonal Ogre::Matrix4 - private: Ogre::Matrix4 BuildScaledOrthoMatrix(const float _left, - const float _right, const float _bottom, const float _top, - const float _near, const float _far); - - private: void UpdateRenderTarget(Ogre::RenderTarget *_target, - Ogre::Material *_material, - Ogre::Camera *_cam, - const bool _updateTex); - - /// \brief Get Cos Horz field-of-view - /// \return 2 * atan(tan(this->hfov/2) / cos(this->vfov/2)) - private: virtual double CosHorzFOV() const; - - /// \brief Set the Cos Horz FOV - /// \param[in] _chfov Cos Horz FOV - private: virtual void SetCosHorzFOV(const double _chfov); - - /// \brief Get Cos Vert field-of-view - /// \return 2 * atan(tan(this->vfov/2) / cos(this->hfov/2)) - private: virtual double CosVertFOV() const; - - /// \brief Set the Cos Horz FOV - /// \param[in] _cvfov Cos Horz FOV - private: virtual void SetCosVertFOV(const double _cvfov); - - /// \brief Get (horizontal_max_angle + horizontal_min_angle) * 0.5 - /// \return (horizontal_max_angle + horizontal_min_angle) * 0.5 - private: virtual double HorzHalfAngle() const; - - /// \brief Get (vertical_max_angle + vertical_min_angle) * 0.5 - /// \return (vertical_max_angle + vertical_min_angle) * 0.5 - private: virtual double VertHalfAngle() const; - - /// \brief Set the horizontal half angle - /// \param[in] _angle horizontal half angle - private: virtual void SetHorzHalfAngle(const double _angle); - - /// \brief Set the vertical half angle - /// \param[in] _angle vertical half angle - private: virtual void SetVertHalfAngle(const double _angle); - - /// \internal - /// \brief Pointer to private data. - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreGrid.hh b/ogre/include/ignition/rendering/ogre/OgreGrid.hh index b6f188b56..13e5c30cb 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGrid.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGrid.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,69 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREGRID_HH_ -#define IGNITION_RENDERING_OGRE_OGREGRID_HH_ - -#include -#include "ignition/rendering/base/BaseGrid.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class OgreGridPrivate; - - /// \brief Ogre implementation of a grid geometry. - class IGNITION_RENDERING_OGRE_VISIBLE OgreGrid - : public BaseGrid - { - /// \brief Constructor - protected: OgreGrid(); - - /// \brief Destructor - public: virtual ~OgreGrid(); - - // Documentation inherited. - public: virtual void Init(); - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const; - - // Documentation inherited. - public: virtual void PreRender(); - - // Documentation inherited. - public: virtual MaterialPtr Material() const; - - // Documentation inherited. - public: virtual void SetMaterial(MaterialPtr _material, bool _unique); - - /// \brief Set material to grid geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); - - /// \brief Create the grid geometry in ogre - private: void Create(); - - /// \brief Grid should only be created by scene. - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreHeightmap.hh b/ogre/include/ignition/rendering/ogre/OgreHeightmap.hh index b75fde249..ce4338432 100644 --- a/ogre/include/ignition/rendering/ogre/OgreHeightmap.hh +++ b/ogre/include/ignition/rendering/ogre/OgreHeightmap.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,126 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREHEIGHTMAP_HH_ -#define IGNITION_RENDERING_OGRE_OGREHEIGHTMAP_HH_ - -#include -#include -#include - -#include "ignition/rendering/base/BaseHeightmap.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -// Ignoring warning: "non dll-interface class -// 'ignition::rendering::v5::Heightmap' used as base for dll-interface class" -// because `Heightmap` and `BaseHeightmap` are header-only -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable:4275) -#endif - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class OgreHeightmapPrivate; - - /// \brief Ogre implementation of a heightmap geometry. - class IGNITION_RENDERING_OGRE_VISIBLE OgreHeightmap - : public BaseHeightmap - { - /// \brief Constructor - protected: explicit OgreHeightmap(const HeightmapDescriptor &_desc); - - /// \brief Destructor - public: virtual ~OgreHeightmap(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - /// \brief Returns NULL, heightmaps don't have movable objects. - /// \return Null pointer. - public: virtual Ogre::MovableObject *OgreObject() const override; - - /// \brief Returns NULL, heightmap materials don't inherit from - /// MaterialPtr. - /// \return Null pointer. - public: virtual MaterialPtr Material() const override; - - /// \brief Has no effect for heightmaps. The material is set through a - /// HeightmapDescriptor. - /// \param[in] _material Not used. - /// \param[in] _unique Not used. - public: virtual void SetMaterial(MaterialPtr _material, bool _unique) - override; - - /// \brief Configure the terrain default values. - /// \todo Move to private? - private: void ConfigureTerrainDefaults(); - - /// \brief Checks if the terrain was previously loaded by comparing its - /// hash against the one stored in the terrain directory - /// \param[in] _terrainDirPath Path to the directory containing the - /// terrain files and hash. - /// \return True if the terrain requires to regenerate the terrain files. - private: bool PrepareTerrain(const std::string &_terrainDirPath); - - /// \brief Update the hash of a terrain file. The hash will be written in - /// a file called gzterrain.SHA1 . This method will be used when the - /// paging is enabled and the terrain is loaded for the first time or if - /// the heightmap's image has been modified. - /// \param[in] _hash New hash value - /// \param[in] _terrainDir Directory where the terrain hash and the - /// terrain pages are stored. Ex: $TMP/gazebo-paging/heigthmap_bowl - private: void UpdateTerrainHash(const std::string &_hash, - const std::string &_terrainDir); - - /// \brief Split a terrain into subterrains - /// \param[in] _heightmap Source vector of floats with the heights. - /// \param[in] _n Number of subterrains. - /// \param[out] _v Destination vector with the subterrains. - private: void SplitHeights(const std::vector &_heightmap, - int _n, std::vector> &_v); - - /// \brief Define a section of the terrain. - /// \param[in] _x X coordinate of the terrain. - /// \param[in] _y Y coordinate of the terrain. - private: void DefineTerrain(int _x, int _y); - - /// \brief Create terrain material generator. There are two types: - /// custom material generator that support user material scripts, - /// and a default material generator that uses our own glsl shader - /// and supports PSSM shadows. - private: void CreateMaterial(); - - /// \brief Initialize all the blend material maps. - /// \param[in] _terrain The terrain to initialize the blend maps. - private: bool InitBlendMaps(Ogre::Terrain *_terrain); - - /// \brief Internal function used to setup shadows for the terrain. - /// \param[in] _enabled True to enable shadows. - private: void SetupShadows(bool _enabled); - - /// \brief Heightmap should only be created by scene. - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreIncludes.hh b/ogre/include/ignition/rendering/ogre/OgreIncludes.hh index 817bff8d4..4cbddfd32 100644 --- a/ogre/include/ignition/rendering/ogre/OgreIncludes.hh +++ b/ogre/include/ignition/rendering/ogre/OgreIncludes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,80 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREINCLUDES_HH_ -#define IGNITION_RENDERING_OGRE_OGREINCLUDES_HH_ -// This disables warning messages for OGRE -#ifndef _MSC_VER - #pragma GCC system_header -#else - #pragma warning(push, 0) - #pragma warning(disable:4275) - #pragma warning(disable:4005) -#endif - -// This prevents some deprecation #warning messages on OSX 10.9 -#pragma clang diagnostic ignored "-W#warnings" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if OGRE_VERSION_MAJOR > 1 || OGRE_VERSION_MINOR >= 7 - #include -#endif - -#if OGRE_VERSION_MAJOR > 1 || OGRE_VERSION_MINOR >= 9 - #include - #include - #include - #include - #include -#else - #include -#endif - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreInertiaVisual.hh b/ogre/include/ignition/rendering/ogre/OgreInertiaVisual.hh index a956823d5..14da4b01a 100644 --- a/ogre/include/ignition/rendering/ogre/OgreInertiaVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreInertiaVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,77 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREINERTIAVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREINERTIAVISUAL_HH_ - -#include - -#include "ignition/rendering/base/BaseInertiaVisual.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - // Forward declaration - class OgreInertiaVisualPrivate; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreInertiaVisual : - public BaseInertiaVisual - { - /// \brief Constructor - protected: OgreInertiaVisual(); - - /// \brief Destructor - public: virtual ~OgreInertiaVisual(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: Ogre::MovableObject *OgreObject() const; - - /// \brief Load the Inertia visual from its pose and scale - /// \param[in] _pose Pose of the Inertia visual - /// \param[in] _scale Scale factor of the box visual - public: void Load(const ignition::math::Pose3d &_pose, - const ignition::math::Vector3d &_scale) override; - - /// \brief Get the box visual - /// \return Pointer to the box visual - public: VisualPtr BoxVisual() const override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial( - MaterialPtr _material, bool _unique) override; - - /// \brief Set material to line geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); - - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreJointVisual.hh b/ogre/include/ignition/rendering/ogre/OgreJointVisual.hh index fb57497cc..3fde43816 100644 --- a/ogre/include/ignition/rendering/ogre/OgreJointVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreJointVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREJOINTVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREJOINTVISUAL_HH_ -#include "ignition/rendering/base/BaseJointVisual.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreJointVisual : - public BaseJointVisual - { - /// \brief Constructor - protected: OgreJointVisual(); - - /// \brief Destructor - public: virtual ~OgreJointVisual(); - - /// \brief Only scene can instantiate this class - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreLidarVisual.hh b/ogre/include/ignition/rendering/ogre/OgreLidarVisual.hh index f9ea3c40c..d2d987c18 100644 --- a/ogre/include/ignition/rendering/ogre/OgreLidarVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreLidarVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,84 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGRELIDARVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGRELIDARVISUAL_HH_ - -#include -#include -#include "ignition/rendering/base/BaseLidarVisual.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreScene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class OgreLidarVisualPrivate; - - /// \brief Ogre implementation of a Lidar Visual. - class IGNITION_RENDERING_OGRE_VISIBLE OgreLidarVisual - : public BaseLidarVisual - { - /// \brief Constructor - protected: OgreLidarVisual(); - - /// \brief Destructor - public: virtual ~OgreLidarVisual(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void Update() override; - - // Documentation inherited - public: virtual void SetPoints( - const std::vector &_points) override; - - // Documentation inherited - // This only affects lidar visuals with type LVT_POINTS - public: virtual void SetPoints(const std::vector &_points, - const std::vector &_colors) - override; - - // Documentation inherited - public: virtual void ClearPoints() override; - - // Documentation inherited - public: virtual unsigned int PointCount() const override; - - // Documentation inherited - public: virtual std::vector Points() const override; - - /// \brief Create the Lidar Visual in ogre - private: void Create(); - - /// \brief Clear data stored by dynamiclines - private: void ClearVisualData(); - - // Documentation inherited - public: virtual void SetVisible(bool _visible) override; - - /// \brief Lidar Visual should only be created by scene. - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreLight.hh b/ogre/include/ignition/rendering/ogre/OgreLight.hh index 98c8cc3e1..50f9315f1 100644 --- a/ogre/include/ignition/rendering/ogre/OgreLight.hh +++ b/ogre/include/ignition/rendering/ogre/OgreLight.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,139 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRELIGHT_HH_ -#define IGNITION_RENDERING_OGRE_OGRELIGHT_HH_ -#include "ignition/rendering/base/BaseLight.hh" -#include "ignition/rendering/ogre/OgreNode.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -namespace Ogre -{ - class Light; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreLight : - public BaseLight - { - protected: OgreLight(); - - public: virtual ~OgreLight(); - - public: virtual math::Color DiffuseColor() const override; - - public: virtual void SetDiffuseColor(const math::Color &_color) override; - - public: virtual math::Color SpecularColor() const override; - - public: virtual void SetSpecularColor( - const math::Color &_color) override; - - public: virtual double AttenuationConstant() const override; - - public: virtual void SetAttenuationConstant(double _value) override; - - public: virtual double AttenuationLinear() const override; - - public: virtual void SetAttenuationLinear(double _value) override; - - public: virtual double AttenuationQuadratic() const override; - - public: virtual void SetAttenuationQuadratic(double _value) override; - - public: virtual double AttenuationRange() const override; - - public: virtual void SetAttenuationRange(double _range) override; - - public: virtual bool CastShadows() const override; - - public: virtual void SetCastShadows(bool _castShadows) override; - - // Documentation Inherited - public: virtual double Intensity() const override; - - // Documentation Inherited - public: virtual void SetIntensity(double _intensity) override; - - public: virtual Ogre::Light *Light() const; - - public: virtual void Destroy() override; - - protected: virtual void Init() override; - - private: void CreateLight(); - - private: void UpdateAttenuation(); - - protected: double attenConstant; - - protected: double attenLinear; - - protected: double attenQuadratic; - - protected: double attenRange; - - protected: Ogre::Light *ogreLight; - - protected: Ogre::Light::LightTypes ogreLightType; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreDirectionalLight : - public BaseDirectionalLight - { - protected: OgreDirectionalLight(); - - public: virtual ~OgreDirectionalLight(); - - public: virtual math::Vector3d Direction() const; - - public: virtual void SetDirection(const math::Vector3d &_dir); - - private: friend class OgreScene; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgrePointLight : - public BasePointLight - { - protected: OgrePointLight(); - - public: virtual ~OgrePointLight(); - - private: friend class OgreScene; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreSpotLight : - public BaseSpotLight - { - protected: OgreSpotLight(); - - public: virtual ~OgreSpotLight(); - - public: virtual math::Vector3d Direction() const; - - public: virtual void SetDirection(const math::Vector3d &_dir); - - public: virtual math::Angle InnerAngle() const; - - public: virtual void SetInnerAngle(const math::Angle &_angle); - - public: virtual math::Angle OuterAngle() const; - - public: virtual void SetOuterAngle(const math::Angle &_angle); - - public: virtual double Falloff() const; - - public: virtual void SetFalloff(double _falloff); - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreLightVisual.hh b/ogre/include/ignition/rendering/ogre/OgreLightVisual.hh index 801049c52..1fd49efa5 100644 --- a/ogre/include/ignition/rendering/ogre/OgreLightVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreLightVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,70 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGRELIGHTVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGRELIGHTVISUAL_HH_ - -#include - -#include "ignition/rendering/base/BaseLightVisual.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - // Forward declaration - class OgreLightVisualPrivate; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreLightVisual : - public BaseLightVisual - { - /// \brief Constructor - protected: OgreLightVisual(); - - /// \brief Destructor - public: virtual ~OgreLightVisual(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: Ogre::MovableObject *OgreObject() const; - - /// \brief Create the Light Visual in Ogre - public: void CreateVisual(); - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial( - MaterialPtr _material, bool _unique) override; - - /// \brief Set material to grid geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); - - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreMarker.hh b/ogre/include/ignition/rendering/ogre/OgreMarker.hh index ef98c16c9..2eb74ea3f 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMarker.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMarker.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,81 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREMARKER_HH_ -#define IGNITION_RENDERING_OGRE_OGREMARKER_HH_ - -#include -#include "ignition/rendering/base/BaseMarker.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class OgreMarkerPrivate; - - /// \brief Ogre implementation of a marker geometry. - class IGNITION_RENDERING_OGRE_VISIBLE OgreMarker - : public BaseMarker - { - /// \brief Constructor - protected: OgreMarker(); - - /// \brief Destructor - public: virtual ~OgreMarker(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial( - MaterialPtr _material, bool _unique) override; - - // Documentation inherited - public: virtual void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value) override; - - // Documentation inherited - public: virtual void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color) override; - - // Documentation inherited - public: virtual void ClearPoints() override; - - // Documentation inherited - public: virtual void SetType(const MarkerType _markerType) override; - - // Documentation inherited - public: virtual MarkerType Type() const override; - - /// \brief Create the marker geometry in ogre - private: void Create(); - - /// \brief Marker should only be created by scene. - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreMaterial.hh b/ogre/include/ignition/rendering/ogre/OgreMaterial.hh index ed9e8260c..8cbfc0fce 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMaterial.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMaterial.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,233 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREMATERIAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREMATERIAL_HH_ -#include - -#include - -#include "ignition/rendering/base/BaseMaterial.hh" -#include "ignition/rendering/ogre/OgreObject.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // TODO(anyone): use a better way to find shader configurations - const std::string depth_vertex_shader_file = - "depth_vertex_shader.glsl"; - const std::string depth_fragment_shader_file = - "depth_fragment_shader.glsl"; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterial : - public BaseMaterial - { - protected: OgreMaterial(); - - public: virtual ~OgreMaterial(); - - // Documentation inherited - public: virtual void Destroy() override; - - public: virtual bool LightingEnabled() const override; - - public: virtual void SetLightingEnabled(const bool _enabled) override; - - // Documentation inherited - public: virtual bool DepthCheckEnabled() const override; - - // Documentation inherited - public: virtual void SetDepthCheckEnabled(bool _enabled) override; - - // Documentation inherited - public: virtual bool DepthWriteEnabled() const override; - - // Documentation inherited - public: virtual void SetDepthWriteEnabled(bool _enabled) override; - - public: virtual math::Color Ambient() const override; - - public: virtual void SetAmbient(const math::Color &_color) override; - - public: virtual math::Color Diffuse() const override; - - public: virtual void SetDiffuse(const math::Color &_color) override; - - public: virtual math::Color Specular() const override; - - public: virtual void SetSpecular(const math::Color &_color) override; - - public: virtual math::Color Emissive() const override; - - public: virtual void SetEmissive(const math::Color &_color) override; - - public: virtual double Shininess() const override; - - public: virtual void SetShininess(const double _shininess) override; - - public: virtual double Transparency() const override; - - public: virtual void SetTransparency(const double _transparency) - override; - - // Documentation inherited - public: virtual void SetAlphaFromTexture(bool _enabled, - double _alpha = 0.5, bool _twoSided = true) override; - - public: virtual double Reflectivity() const override; - - public: virtual void SetReflectivity(const double _reflectivity) - override; - - public: virtual bool CastShadows() const override; - - // Documentation inherited. - public: virtual void SetCastShadows(const bool _castShadows) override; - - public: virtual bool ReceiveShadows() const override; - - public: virtual void SetReceiveShadows(const bool _receiveShadows) - override; - - // Documentation inherited - public: virtual float RenderOrder() const override; - - // Documentation inherited - // Review the official documentation to get more details about this - // parameter, in particular Ogre::Pass::setDepthBias() - // https://www.ogre3d.org/docs/api/1.8/class_ogre_1_1_pass.html - public: virtual void SetRenderOrder(const float _renderOrder) override; - - public: virtual bool ReflectionEnabled() const override; - - public: virtual void SetReflectionEnabled(const bool _enabled) override; - - public: virtual bool HasTexture() const override; - - public: virtual std::string Texture() const override; - - // Documentation inherited. - public: virtual void SetTexture(const std::string &_texture) override; - - public: virtual void ClearTexture() override; - - public: virtual bool HasNormalMap() const override; - - public: virtual std::string NormalMap() const override; - - // Documentation inherited. - public: virtual void SetNormalMap(const std::string &_normalMap) override; - - public: virtual void ClearNormalMap() override; - - public: virtual enum ShaderType ShaderType() const override; - - // Documentation inherited. - public: virtual void SetShaderType(enum ShaderType _type) override; - - public: virtual Ogre::MaterialPtr Material() const; - - // Documentation inherited. - // \sa Material::Set3DMaterial() - public: virtual void SetDepthMaterial(const double far, - const double near) override; - - // Documentation inherited. - // \sa Material::SetVertexShader(const std::string &) - public: virtual void SetVertexShader(const std::string &_path) override; - - // Documentation inherited. - // \sa Material::VertexShader() const - public: virtual std::string VertexShader() const override; - - // Documentation inherited. - // \sa Material::VertexShaderParams() - public: virtual ShaderParamsPtr VertexShaderParams() override; - - // Documentation inherited. - // \sa Material::SetFragmentShader(const std::string &) - public: virtual void SetFragmentShader(const std::string &_path) - override; - - // Documentation inherited. - // \sa Material::FragmentShader() const - public: virtual std::string FragmentShader() const override; - - // Documentation inherited. - // \sa Material::FragmentShaderParams() - public: virtual ShaderParamsPtr FragmentShaderParams() override; - - // Documentation inherited. - // \sa BaseMaterial::PreRender() - public: virtual void PreRender() override; - - protected: virtual void LoadOneImage(const std::string &_name, - Ogre::Image &_image); - - /// \brief Set the texture for this material - /// \param[in] _texture Name of the texture. - protected: virtual void SetTextureImpl(const std::string &_texture); - - protected: virtual Ogre::TexturePtr Texture(const std::string &_name); - - protected: virtual Ogre::TexturePtr CreateTexture( - const std::string &_name); - - protected: virtual void UpdateTransparency(); - - protected: virtual void UpdateColorOperation(); - - /// \brief bind shader parameters that have changed - protected: void UpdateShaderParams(); - - /// \brief Transfer params from ign-rendering type to ogre type - /// \param[in] _params ignition rendering params - /// \param[out] _ogreParams ogre type for holding params - protected: void UpdateShaderParams(ConstShaderParamsPtr _params, - Ogre::GpuProgramParametersSharedPtr _ogreParams); - - protected: virtual void Init() override; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: Ogre::MaterialPtr ogreMaterial; - - protected: Ogre::Technique *ogreTechnique = nullptr; - - protected: Ogre::Pass *ogrePass = nullptr; - - protected: Ogre::TextureUnitState *ogreTexState = nullptr; - - protected: Ogre::String ogreGroup; - -#if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR <= 7 - protected: math::Color emissiveColor; -#endif - protected: std::string textureName; - - protected: std::string normalMapName; - - protected: enum ShaderType shaderType = ST_PIXEL; - - /// \brief Path to vertex shader program. - protected: std::string vertexShaderPath; - - /// \brief Path to fragment shader program. - protected: std::string fragmentShaderPath; - - /// \brief Parameters to be bound to the vertex shader - protected: ShaderParamsPtr vertexShaderParams; - - /// \brief Parameters to be bound to the fragment shader - protected: ShaderParamsPtr fragmentShaderParams; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh b/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh index b893dd058..239381654 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,115 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREMATERIALSWITCHER_HH_ -#define IGNITION_RENDERING_OGRE_OGREMATERIALSWITCHER_HH_ - -#include -#include - -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations - class OgreSelectionBuffer; - - /// \brief Helper class to assign unique colors to renderables - class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterialSwitcher : -// Ogre::MaterialManager::Listener isn't a dll-interface class, this may cause -// issues -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable:4275) -#endif - public Ogre::MaterialManager::Listener, -#ifdef _MSC_VER - #pragma warning(pop) -#endif - Ogre::RenderTargetListener - { - /// \brief Constructor - public: OgreMaterialSwitcher(); - - /// \brief Destructor - public: ~OgreMaterialSwitcher(); - - /// \brief Get the entity with a specific color - /// \param[in] _color The entity's color. - public: std::string EntityName( - const ignition::math::Color &_color) const; - - /// \brief Reset the color value incrementor - public: void Reset(); - - /// \brief Ogre callback that assigns colors to new renderables when the - /// requested scheme is not found - /// \param[in] _schemeIndex Index of scheme requested - /// \param[in] _schemeName Name of scheme requested - /// \param[in] _originalMaterial Orignal material that does not contain - /// the requested scheme - /// \param[in] _lodIndex The material level-of-detail - /// \param[in] _rend Pointer to the Ogre::Renderable object requesting - /// the use of the techinique - /// \return The Ogre material technique to use when scheme is not found. - public: virtual Ogre::Technique *handleSchemeNotFound( - uint16_t _schemeIndex, const Ogre::String &_schemeName, - Ogre::Material *_originalMaterial, uint16_t _lodIndex, - const Ogre::Renderable *_rend); - - /// \brief Ogre's pre render update callback - /// \param[in] _evt Ogre render target event containing information about - /// the source render target. - public: virtual void preRenderTargetUpdate( - const Ogre::RenderTargetEvent &_evt); - - /// \brief Ogre's post render update callback - /// \param[in] _evt Ogre render target event containing information about - /// the source render target. - public: virtual void postRenderTargetUpdate( - const Ogre::RenderTargetEvent &_evt); - - /// \brief Current unique color value - private: ignition::math::Color currentColor; - - /// \brief last entity assigned an unique color value - private: std::string lastEntity; - - /// \brief last technique assigned to an entity. - private: Ogre::Technique *lastTechnique = nullptr; - - /// \brief Color dictionary that maps the unique color value to - /// renderable name - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::map colorDict; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Increment unique color value that will be assigned to the - /// next renderable - private: void NextColor(); - - /// \brief Selection Buffer class that make use of this class for - /// selecting entitiies - public: friend class OgreSelectionBuffer; - - /// \brief Plain material technique - private: Ogre::Technique *plainTechnique = nullptr; - - /// \brief Overlay material technique - private: Ogre::Technique *overlayTechnique = nullptr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreMesh.hh b/ogre/include/ignition/rendering/ogre/OgreMesh.hh index 50d8e0b16..157be78c8 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMesh.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMesh.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,116 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREMESH_HH_ -#define IGNITION_RENDERING_OGRE_OGREMESH_HH_ -#include -#include -#include -#include -#include -#include "ignition/rendering/base/BaseMesh.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreObject.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" - -namespace Ogre -{ - class Entity; - class SubEntity; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations - class OgreMeshPrivate; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreMesh : - public BaseMesh - { - typedef std::vector NameList; - - protected: OgreMesh(); - - public: virtual ~OgreMesh(); - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual bool HasSkeleton() const override; - - // Documentation inherited. - public: virtual std::map - SkeletonLocalTransforms() const override; - - // Documentation inherited. - public: virtual void SetSkeletonLocalTransforms( - const std::map &_tfs) override; - - // Documentation inherited. - public: virtual std::unordered_map SkeletonWeights() - const override; - - // Documentation inherited. - public: virtual void SetSkeletonWeights( - const std::unordered_map &_weights) override; - - // Documentation inherited. - public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, - bool _enabled, bool _loop = true, float _weight = 1.0) override; - - // Documentation inherited. - public: virtual bool SkeletonAnimationEnabled(const std::string &_name) - const override; - - // Documentation inherited. - public: virtual void UpdateSkeletonAnimation( - std::chrono::steady_clock::duration _time) override; - - public: virtual Ogre::MovableObject *OgreObject() const override; - - protected: virtual SubMeshStorePtr SubMeshes() const override; - - protected: OgreSubMeshStorePtr subMeshes; - - protected: Ogre::Entity *ogreEntity = nullptr; - - private: friend class OgreScene; - - private: friend class OgreMeshFactory; - - /// \brief Pointer to private data - private: std::unique_ptr dataPtr; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreSubMesh : - public BaseSubMesh - { - protected: OgreSubMesh(); - - public: virtual ~OgreSubMesh(); - - public: virtual Ogre::SubEntity *OgreSubEntity() const; - - public: virtual void Destroy() override; - - // Documentation inherited - protected: virtual void SetMaterialImpl(MaterialPtr _material) override; - - protected: virtual void Init() override; - - protected: Ogre::SubEntity *ogreSubEntity; - - private: friend class OgreScene; - - private: friend class OgreSubMeshStoreFactory; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh b/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh index 6c28369ab..9427ded93 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,85 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREMESHFACTORY_HH_ -#define IGNITION_RENDERING_OGRE_OGREMESHFACTORY_HH_ -#include -#include - -#include "ignition/rendering/MeshDescriptor.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace Ogre -{ - class Entity; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreMeshFactory - { - public: explicit OgreMeshFactory(OgreScenePtr _scene); - - public: virtual ~OgreMeshFactory(); - - public: virtual OgreMeshPtr Create(const MeshDescriptor &_desc); - - protected: virtual Ogre::Entity *OgreEntity( - const MeshDescriptor &_desc); - - protected: virtual bool Load(const MeshDescriptor &_desc); - - protected: virtual bool IsLoaded(const MeshDescriptor &_desc); - - protected: virtual bool LoadImpl(const MeshDescriptor &_desc); - - protected: virtual std::string MeshName(const MeshDescriptor &_desc); - - protected: virtual bool Validate(const MeshDescriptor &_desc); - - /// \brief Remove internal material cache for a specific material - /// \param[in] _name Name of the template material to remove. - public: void ClearMaterialsCache(const std::string &_name); - - protected: OgreScenePtr scene; - - /// \brief Vector with the template materials, we keep the pointer to be - /// able to remove it when nobody is using it. - protected: std::vector materialCache; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreSubMeshStoreFactory - { - typedef std::vector NameList; - - public: OgreSubMeshStoreFactory(OgreScenePtr _scene, - Ogre::Entity *_entity); - - public: virtual ~OgreSubMeshStoreFactory(); - - public: virtual OgreSubMeshStorePtr Create(); - - protected: virtual OgreSubMeshPtr CreateSubMesh(unsigned int _index); - - protected: virtual void CreateNameList(); - - protected: virtual void PopulateDefaultNames(); - - protected: virtual void PopulateGivenNames(); - - protected: OgreScenePtr scene; - - protected: Ogre::Entity *ogreEntity; - - protected: NameList names; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreNode.hh b/ogre/include/ignition/rendering/ogre/OgreNode.hh index a68e5a12f..1a912d5ec 100644 --- a/ogre/include/ignition/rendering/ogre/OgreNode.hh +++ b/ogre/include/ignition/rendering/ogre/OgreNode.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,95 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRENODE_HH_ -#define IGNITION_RENDERING_OGRE_OGRENODE_HH_ -#include - -#include "ignition/rendering/base/BaseNode.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreObject.hh" - -namespace Ogre -{ - class SceneNode; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreNode : - public BaseNode - { - protected: OgreNode(); - - public: virtual ~OgreNode(); - - public: virtual bool HasParent() const override; - - public: virtual NodePtr Parent() const override; - - public: virtual Ogre::SceneNode *Node() const; - - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual math::Vector3d LocalScale() const override; - - // Documentation inherited. - public: virtual bool InheritScale() const override; - - // Documentation inherited. - public: virtual void SetInheritScale(bool _inherit) override; - - // Documentation inherited. - protected: virtual void SetLocalScaleImpl( - const math::Vector3d &_scale) override; - - protected: virtual NodeStorePtr Children() const override; - - protected: virtual bool AttachChild(NodePtr _child) override; - - protected: virtual bool DetachChild(NodePtr _child) override; - - protected: virtual math::Pose3d RawLocalPose() const override; - - protected: virtual void SetRawLocalPose(const math::Pose3d &_Pose3d) - override; - - protected: virtual math::Vector3d RawLocalPosition() const; - - protected: virtual void SetRawLocalPosition( - const math::Vector3d &_position); - - protected: virtual math::Quaterniond RawLocalRotation() const; - - protected: virtual void SetRawLocalRotation( - const math::Quaterniond &_rotation); - - protected: virtual void SetParent(OgreNodePtr _parent); - - protected: virtual void Load() override; - - protected: virtual void Init() override; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: OgreNodePtr parent; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - protected: Ogre::SceneNode *ogreNode = nullptr; - - protected: OgreNodeStorePtr children; - - private: OgreNodePtr SharedThis(); - - // TODO(anyone): remove the need for a visual friend class - private: friend class OgreVisual; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreObject.hh b/ogre/include/ignition/rendering/ogre/OgreObject.hh index e8d691516..475e12b5a 100644 --- a/ogre/include/ignition/rendering/ogre/OgreObject.hh +++ b/ogre/include/ignition/rendering/ogre/OgreObject.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,37 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREOBJECT_HH_ -#define IGNITION_RENDERING_OGRE_OGREOBJECT_HH_ -#include - -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreObject : - public BaseObject - { - protected: OgreObject(); - - public: virtual ~OgreObject(); - - public: virtual ScenePtr Scene() const; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: OgreScenePtr scene; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreParticleEmitter.hh b/ogre/include/ignition/rendering/ogre/OgreParticleEmitter.hh index 92604ff78..37cea53f8 100644 --- a/ogre/include/ignition/rendering/ogre/OgreParticleEmitter.hh +++ b/ogre/include/ignition/rendering/ogre/OgreParticleEmitter.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_PARTICLEEMITTER_HH_ -#define IGNITION_RENDERING_OGRE_PARTICLEEMITTER_HH_ -#include "ignition/rendering/base/BaseParticleEmitter.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \brief Class to manage a particle emitter. - class IGNITION_RENDERING_OGRE_VISIBLE OgreParticleEmitter : - public BaseParticleEmitter - { - /// \brief Constructor - protected: OgreParticleEmitter(); - - /// \brief Destructor - public: virtual ~OgreParticleEmitter(); - - /// \brief Only the ogre scene can instanstiate this class - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh b/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh index 56450b8fc..06d2a35ad 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,168 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERTSHADERSYSTEM_HH_ -#define IGNITION_RENDERING_OGRE_OGRERTSHADERSYSTEM_HH_ -#include -#include - -#include -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreRTShaderSystemPrivate; - - /// \addtogroup ign_rendering - /// \{ - - /// \class OgreRTShaderSystem OgreRTShaderSystem.hh rendering/rendering.hh - /// \brief Implements Ogre's Run-Time Shader system. - /// - /// This class allows Gazebo to generate per-pixel shaders for every - /// material at run-time. - class IGNITION_RENDERING_OGRE_VISIBLE OgreRTShaderSystem : - public common::SingletonT - { - /// \enum LightingModel - /// \brief The type of lighting - public: enum LightingModel - { - /// \brief Per-Vertex lighting: best performance. - SSLM_PerVertexLighting, - /// \brief Per-Pixel lighting: best look. - SSLM_PerPixelLighting, - /// \brief Normal Map lighting: lighting calculations have - /// been stored in a light map (texture) using tangent space. - SSLM_NormalMapLightingTangentSpace, - /// \brief Normal Map lighting: lighting calculations have - /// been stored in a light map (texture) using object space. - SSLM_NormalMapLightingObjectSpace - }; - - /// \brief Constructor. - private: OgreRTShaderSystem(); - - /// \brief Destructor. - private: virtual ~OgreRTShaderSystem(); - - /// \brief Initialize the run time shader system. - /// \return True if the run time shader system is initialized - /// successfully. - public: bool Init(); - - /// \brief Finalize the shader system - public: void Fini(); - - /// \brief Clear the shader system - public: void Clear(); - - /// \brief Add a scene manager - /// \param[in] _scene The scene to process - public: void AddScene(OgreScenePtr _scene); - - /// \brief Remove a scene - /// \param[in] _scene The scene to remove - public: void RemoveScene(OgreScenePtr _scene); - - /// \brief Remove a scene - /// \param[in] _scene Name of the scene to remove. - public: void RemoveScene(const std::string &_scene); - - /// \brief Update the shaders. This should not be called frequently. - public: void UpdateShaders(); - - /// \brief Set an Ogre::Entity to use RT shaders. - /// \param[in] _vis OgreSubMesh that will use the OgreRTShaderSystem. - public: void AttachEntity(OgreSubMesh *_vis); - - /// \brief Remove and entity. - /// \param[in] _vis Remove this visual. - public: void DetachEntity(OgreSubMesh *_vis); - - /// \brief Set a viewport to use shaders. - /// \param[in] _viewport The viewport to add. - /// \param[in] _scene The scene that the viewport uses. - public: static void AttachViewport(Ogre::Viewport *_viewport, - OgreScenePtr _scene); - - /// \brief Set a viewport to not use shaders. - /// \param[in] _viewport The viewport to remove. - /// \param[in] _scene The scene that the viewport uses. - public: static void DetachViewport(Ogre::Viewport *_viewport, - OgreScenePtr _scene); - - /// \brief Set the lighting model to per pixel or per vertex. - /// \param[in] _set True means to use per-pixel shaders. - public: void SetPerPixelLighting(bool _set); - - /// \brief Generate shaders for an entity - /// \param[in] _subMesh The submesh to remove shaders for. - public: void RemoveShaders(OgreSubMesh *_subMesh); - - /// \brief Generate shaders for an entity - /// \param[in] _subMesh The submesh to generate shaders for. - public: void GenerateShaders(OgreSubMesh *_subMesh); - - /// \brief Apply shadows to a scene. - /// \param[in] _scene The scene to receive shadows. - public: void ApplyShadows(OgreScenePtr _scene); - - /// \brief Remove shadows from a scene. - /// \param[in] _scene The scene to remove shadows from. - public: void RemoveShadows(OgreScenePtr _scene); - - /// \brief Get the Ogre PSSM Shadows camera setup. - /// \return The Ogre PSSM Shadows camera setup. - public: Ogre::PSSMShadowCameraSetup *PSSMShadowCameraSetup() const; - - /// \brief Get paths for the shader system - /// \param[out] _coreLibsPath Path to the core libraries. - /// \param[out] _cachePath Path to where the generated shaders are - /// stored. - private: bool Paths(std::string &_coreLibsPath, - std::string &_cachePath); - - /// \brief Set the shadow texture size. - /// \param[in] _size Size of shadow texture to set to. This must be a - /// power of 2. The default size is 1024. - /// \return True if size is set successfully, false otherwise. - public: bool SetShadowTextureSize(const unsigned int _size); - - /// \brief Get the shadow texture size. - /// \return Size of the shadow texture. The default size is 1024. - public: unsigned int ShadowTextureSize() const; - - /// \brief Get if RTShaderSystem is initialized or not - /// \return True if intialized. - public: bool IsInitialized() const; - - /// \brief Update the RT shaders. The call will only take effect if - /// shadow properties changed, e.g. texture size, or the shaders - /// have been marked dirty by UpdateShaders, e.g. when entities are - /// added. The function reapplies shadows if properties have changed, - /// and iterates through all entities added to RTShaderSystem - /// and regenerates shader programs for each entity if shaders are dirty. - /// This function is currently called by OgreScene::PreRender - /// \sa OgreScene::PreRender - public: void Update(); - - /// \brief Make the RTShader system a singleton. - private: friend class common::SingletonT; - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - }; - /// \} - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh b/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh index 9d766082e..9b8060d87 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,70 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERAYQUERY_HH_ -#define IGNITION_RENDERING_OGRE_OGRERAYQUERY_HH_ -#include - -#include "ignition/rendering/base/BaseRayQuery.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreObject.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreRayQueryPrivate; - - /// \class OgreRayQuery OgreRayQuery.hh - /// ignition/rendering/base/OgreRayQuery.hh - /// \brief A Ray Query class used for computing ray object intersections - class IGNITION_RENDERING_OGRE_VISIBLE OgreRayQuery : - public BaseRayQuery - { - /// \brief Constructor - protected: OgreRayQuery(); - - /// \brief Destructor - public: virtual ~OgreRayQuery(); - - // Documentation inherited - public: virtual void SetFromCamera(const CameraPtr &_camera, - const math::Vector2d &_coord); - - // Documentation inherited - public: virtual RayQueryResult ClosestPoint(); - - /// \brief Get the mesh information for the given mesh. - /// \param[in] _mesh Mesh to get info about. - /// \param[out] _vertexCount Number of vertices in the mesh. - /// \param[out] _vertices Array of the vertices. - /// \param[out] _indexCount Number if indices. - /// \param[out] _indices Array of the indices. - /// \param[in] _position Position of the mesh. - /// \param[in] _orient Orientation of the mesh. - /// \param[in] _scale Scale of the mesh - // Code found in Wiki: www.ogre3d.org/wiki/index.php/RetrieveVertexData - private: void MeshInformation(const Ogre::Mesh *_mesh, - size_t &_vertexCount, - Ogre::Vector3* &_vertices, - size_t &_indexCount, - uint64_t* &_indices, - const math::Vector3d &_position, - const math::Quaterniond &_orient, - const math::Vector3d &_scale); - - /// \brief Private data pointer - private: std::unique_ptr dataPtr; - - /// \brief Pointer to friend scene class for creating ray query - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh b/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh index 6003fbc3b..8ada49d91 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,175 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERENDERENGINE_HH_ -#define IGNITION_RENDERING_OGRE_OGRERENDERENGINE_HH_ -#include -#include -#include -#include - -#include - -#include "ignition/rendering/RenderEnginePlugin.hh" -#include "ignition/rendering/base/BaseRenderEngine.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace Ogre -{ - class LogManager; - class Root; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreRenderEnginePrivate; - - /// \brief Plugin for loading ogre render engine - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderEnginePlugin : - public RenderEnginePlugin - { - /// \brief Constructor - public: OgreRenderEnginePlugin(); - - /// \brief Destructor - public: ~OgreRenderEnginePlugin() = default; - - /// \brief Get the name of the render engine loaded by this plugin. - /// \return Name of render engine - public: std::string Name() const; - - /// \brief Get a pointer to the render engine loaded by this plugin. - /// \return Render engine instance - public: RenderEngine *Engine() const; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderEngine : - public virtual BaseRenderEngine, - public common::SingletonT - { - /// \enum OgreRenderPathType - /// \brief The type of rendering path used by the rendering engine. - public: enum OgreRenderPathType - { - /// \brief No rendering is done. - NONE = 0, - /// \brief Most basic rendering, with least fidelity. - VERTEX = 1, - /// \brief Utilizes the RTT shader system. - FORWARD = 2, - /// \brief Utilizes deferred rendering. Best fidelity. - DEFERRED = 3, - /// \brief Count of the rendering path enums. - RENDER_PATH_COUNT - }; - - /// \brief Constructor - private: OgreRenderEngine(); - - public: virtual ~OgreRenderEngine(); - - public: virtual void Destroy() override; - - public: virtual bool IsEnabled() const override; - - public: virtual std::string Name() const override; - - public: OgreRenderPathType RenderPathType() const; - - public: void AddResourcePath(const std::string &_uri) override; - - public: virtual Ogre::Root *OgreRoot() const; - - public: std::string CreateRenderWindow(const std::string &_handle, - const unsigned int _width, const unsigned int _height, - const double _ratio, const unsigned int _antiAliasing); - - /// \brief Get a list of all supported FSAA levels for this render system - /// \return a list of FSAA levels - public: std::vector FSAALevels() const; - - protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual SceneStorePtr Scenes() const override; - - /// \brief Engine implementation of Load function. - /// \param[in] _params Parameters to be passed to the render engine. - /// Current accepts the following parameters and values: - /// "useCurrentGLContext" : "1" or "0". Use current OpenGL context for - /// rendering - protected: virtual bool LoadImpl( - const std::map &_params) override; - - protected: virtual bool InitImpl() override; - - private: void LoadAttempt(); - - private: void CreateLogger(); - - private: void CreateContext(); - - private: void CreateRoot(); - - private: void CreateOverlay(); - - private: void LoadPlugins(); - - private: void CreateRenderSystem(); - - private: void CreateResources(); - - private: void CreateRenderWindow(); - - private: void CheckCapabilities(); - - private: void InitAttempt(); - -#if (OGRE_VERSION >= ((1 << 16) | (9 << 8) | 0)) - /// \internal - /// \brief Get a pointer to the Ogre overlay system. - /// \return Pointer to the OGRE overlay system. - public: Ogre::OverlaySystem *OverlaySystem() const; - - private: Ogre::OverlaySystem *ogreOverlaySystem = nullptr; - -#endif - private: OgreSceneStorePtr scenes; - - private: OgreRenderPathType renderPathType; - - private: Ogre::Root *ogreRoot = nullptr; - - private: Ogre::LogManager *ogreLogManager = nullptr; - - /// \brief Paths to ogre plugins - private: std::vector ogrePaths; - -#if !defined(__APPLE__) && !defined(_WIN32) - private: void *dummyDisplay = nullptr; - - private: void *dummyContext = nullptr; -#endif - - private: uint64_t dummyWindowId = 0u; - - /// \brief True to use the current opengl context - private: bool useCurrentGLContext = false; - - private: std::unique_ptr dataPtr; - - private: friend class common::SingletonT; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh b/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh index cbfe312e9..8499a6950 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,47 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERENDERPASS_HH_ -#define IGNITION_RENDERING_OGRE_OGRERENDERPASS_HH_ -#include "ignition/rendering/base/BaseRenderPass.hh" -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class OgreRenderPass OgreRenderPass.hh \ - * ignition/rendering/ogre/OgreRenderPass.hh - */ - /// \brief Ogre implementation of the RenderPass class - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderPass : - public BaseRenderPass - { - /// \brief Constructor - protected: OgreRenderPass(); - - /// \brief Destructor - public: virtual ~OgreRenderPass(); - - /// \brief Set the ogre camera that the render pass applies to - /// \param[in] _camera Pointer to the ogre camera. - public: virtual void SetCamera(Ogre::Camera *_camera); - - // Documentation inherited. - public: void Destroy() override; - - /// \brief Create the render pass using ogre compositor - public: virtual void CreateRenderPass(); - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera = nullptr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh index 9fddb44ee..19c800a2f 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,173 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERENDERTARGET_HH_ -#define IGNITION_RENDERING_OGRE_OGRERENDERTARGET_HH_ -#include - -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/base/BaseRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreObject.hh" -#include "ignition/rendering/ogre/OgreRenderTargetMaterial.hh" - -namespace Ogre -{ - class Camera; - class RenderTarget; - class Texture; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTarget : - public virtual BaseRenderTarget - { - protected: OgreRenderTarget(); - - public: virtual ~OgreRenderTarget(); - - public: virtual unsigned int AntiAliasing() const; - - public: virtual void SetAntiAliasing(unsigned int _aa); - - public: virtual void Copy(Image &_image) const override; - - public: virtual Ogre::Camera *Camera() const; - - public: virtual void SetCamera(Ogre::Camera *_camera); - - // Documentation inherited - public: virtual math::Color BackgroundColor() const override; - - public: virtual void SetBackgroundColor(math::Color _color); - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - public: virtual void Render(); - - public: virtual void Destroy() override = 0; - - /// \brief Set a material to render on every object. This method is used - /// for special cases like the render target of a depth camera. - /// \param[in] _material The material to render - public: void SetMaterial(MaterialPtr _material); - - public: virtual Ogre::RenderTarget *RenderTarget() const = 0; - - public: Ogre::Viewport *AddViewport(Ogre::Camera *_viewport); - - public: Ogre::Viewport *Viewport(const int _viewportId) const; - - public: void SetUpdate(const bool _value); - - public: void SetAutoUpdated(const bool _value); - - /// \brief Set visibility mask for the viewport associated with this - /// render target - /// \param[in] _mask Visibility mask - public: virtual void SetVisibilityMask(uint32_t _mask); - - protected: virtual void UpdateBackgroundColor(); - - /// \brief Update render pass chain if changes were made - protected: virtual void UpdateRenderPassChain(); - - protected: virtual void RebuildImpl() override; - - protected: virtual void RebuildTarget() = 0; - - protected: virtual void RebuildViewport(); - - /// \brief Re-initializes render target material to apply a material to - /// everything in the scene. Does nothing if no material has been set - /// \sa OgreRenderTarget::RebuildImpl() - /// \sa BaseRenderTarget::Rebuild() - protected: void RebuildMaterial(); - - protected: Ogre::Camera *ogreCamera = nullptr; - - protected: Ogre::Viewport *ogreViewport = nullptr; - - protected: Ogre::ColourValue ogreBackgroundColor; - - /// \brief a material used by for the render target - protected: MaterialPtr material; - - /// \brief Helper class that applies the material to the render target - protected: OgreRenderTargetMaterialPtr materialApplicator; - - protected: bool colorDirty = true; - - protected: unsigned int antiAliasing = 4; - - /// \brief visibility mask associated with this render target - protected: uint32_t visibilityMask = IGN_VISIBILITY_ALL; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTexture : - public virtual BaseRenderTexture - { - protected: OgreRenderTexture(); - - public: virtual ~OgreRenderTexture(); - - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - // Documentation inherited. - public: virtual unsigned int GLId(); - - public: virtual void Buffer(float *buffer); - - public: virtual Ogre::RenderTarget *RenderTarget() const override; - - protected: virtual void RebuildTarget() override; - - protected: virtual void DestroyTarget(); - - protected: virtual void BuildTarget(); - - protected: Ogre::Texture *ogreTexture = nullptr; - - private: friend class OgreScene; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderWindow : - public virtual BaseRenderWindow - { - protected: OgreRenderWindow(); - - public: virtual ~OgreRenderWindow(); - - public: virtual void Destroy(); - - protected: virtual Ogre::RenderTarget *RenderTarget() const; - - protected: virtual void RebuildTarget(); - - protected: virtual void BuildTarget(); - - protected: Ogre::RenderTarget *ogreRenderWindow = nullptr; - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh index e738438e8..e2dceb240 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,100 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRRENDERTARGETMATERIAL_HH_ -#define IGNITION_RENDERING_OGRE_OGRRENDERTARGETMATERIAL_HH_ -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/Export.hh" - -// Ogre::MaterialManager::Listener isn't a dll-interface class, this may cause -// issues -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable:4275) -#endif - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Causes all objects in a scene to be rendered with the same - /// material when rendered by a given RenderTarget. - /// \internal - /// - /// On construction it registers as an Ogre::RenderTargetListener - /// on the provided Ogre::RenderTarget, and sets the material scheme name - /// to a value that is unlikely to exist. - /// When the target is about to be rendered it adds itself as an - /// Ogre::MaterialManager::Listener. - /// Every time ogre tries to get a technique for a material it will call - /// handleSchemeNotFound which returns the first supported technique on the - /// material provided to this class's constructor. - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTargetMaterial : - public Ogre::RenderTargetListener, - public Ogre::MaterialManager::Listener - { - /// \brief constructor - /// \param[in] _scene the scene manager responsible for rendering - /// \param[in] _renderTarget the RenderTarget this should apply to - /// \param[in] _material the material to apply to all renderables - public: OgreRenderTargetMaterial(OgreScenePtr _scene, - Ogre::RenderTarget *_renderTarget, Ogre::Material *_material); - - /// \brief destructor - public: ~OgreRenderTargetMaterial(); - - /// \brief Callback when a render target is about to be rendered - /// \param[in] _evt Ogre render target event containing information about - /// the source render target. - private: virtual void preRenderTargetUpdate( - const Ogre::RenderTargetEvent &_evt) override; - - /// \brief Callback when a render target is finisned being rendered - /// \param[in] _evt Ogre render target event containing information about - /// the source render target. - private: virtual void postRenderTargetUpdate( - const Ogre::RenderTargetEvent &_evt) override; - - /// \brief Ogre callback that assigned same material to all renderables - /// when the requested scheme is not found - /// \param[in] _schemeIndex Index of scheme requested - /// \param[in] _schemeName Name of scheme requested - /// \param[in] _originalMaterial Orignal material that does not contain - /// the requested scheme - /// \param[in] _lodIndex The material level-of-detail - /// \param[in] _rend Pointer to the Ogre::Renderable object requesting - /// the use of the techinique - /// \return The Ogre material technique to use when scheme is not found. - public: virtual Ogre::Technique *handleSchemeNotFound( - uint16_t _schemeIndex, const Ogre::String &_schemeName, - Ogre::Material *_originalMaterial, uint16_t _lodIndex, - const Ogre::Renderable *_rend) override; - - /// \brief scene manager responsible for rendering - private: OgreScenePtr scene; - - /// \brief render target that should see a uniform material - private: Ogre::RenderTarget *renderTarget; - - /// \brief material that should be applied to all objects - private: Ogre::Material *material; - - /// \brief name of the material scheme used by this applicator - private: Ogre::String schemeName; - }; - } - } -} - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh index e1a60a0d1..a7984f454 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,117 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERENDERTYPES_HH_ -#define IGNITION_RENDERING_OGRE_OGRERENDERTYPES_HH_ -#include -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class OgreArrowVisual; - class OgreAxisVisual; - class OgreCamera; - class OgreCapsule; - class OgreCOMVisual; - class OgreDepthCamera; - class OgreDirectionalLight; - class OgreGeometry; - class OgreGizmoVisual; - class OgreGpuRays; - class OgreGrid; - class OgreHeightmap; - class OgreInertiaVisual; - class OgreJointVisual; - class OgreLight; - class OgreLightVisual; - class OgreLidarVisual; - class OgreLight; - class OgreMarker; - class OgreMaterial; - class OgreMesh; - class OgreMeshFactory; - class OgreNode; - class OgreObject; - class OgreParticleEmitter; - class OgrePointLight; - class OgreRayQuery; - class OgreRenderEngine; - class OgreRenderTarget; - class OgreRenderTargetMaterial; - class OgreRenderTexture; - class OgreRenderWindow; - class OgreScene; - class OgreSensor; - class OgreSpotLight; - class OgreSubMesh; - class OgreText; - class OgreThermalCamera; - class OgreVisual; - class OgreWireBox; - - typedef BaseSceneStore OgreSceneStore; - typedef BaseNodeStore OgreNodeStore; - typedef BaseLightStore OgreLightStore; - typedef BaseSensorStore OgreSensorStore; - typedef BaseVisualStore OgreVisualStore; - typedef BaseGeometryStore OgreGeometryStore; - typedef BaseSubMeshStore OgreSubMeshStore; - typedef BaseMaterialMap OgreMaterialMap; - - typedef shared_ptr OgreArrowVisualPtr; - typedef shared_ptr OgreAxisVisualPtr; - typedef shared_ptr OgreCameraPtr; - typedef shared_ptr OgreCapsulePtr; - typedef shared_ptr OgreCOMVisualPtr; - typedef shared_ptr OgreDepthCameraPtr; - typedef shared_ptr OgreDirectionalLightPtr; - typedef shared_ptr OgreGeometryPtr; - typedef shared_ptr OgreGeometryStorePtr; - typedef shared_ptr OgreGizmoVisualPtr; - typedef shared_ptr OgreGpuRaysPtr; - typedef shared_ptr OgreGridPtr; - typedef shared_ptr OgreHeightmapPtr; - typedef shared_ptr OgreInertiaVisualPtr; - typedef shared_ptr OgreJointVisualPtr; - typedef shared_ptr OgreLightPtr; - typedef shared_ptr OgreLightVisualPtr; - typedef shared_ptr OgreLidarVisualPtr; - typedef shared_ptr OgreLightPtr; - typedef shared_ptr OgreLightStorePtr; - typedef shared_ptr OgreMarkerPtr; - typedef shared_ptr OgreMaterialPtr; - typedef shared_ptr OgreMaterialMapPtr; - typedef shared_ptr OgreMeshPtr; - typedef shared_ptr OgreMeshFactoryPtr; - typedef shared_ptr OgreNodePtr; - typedef shared_ptr OgreNodeStorePtr; - typedef shared_ptr OgreObjectPtr; - typedef shared_ptr OgreParticleEmitterPtr; - typedef shared_ptr OgrePointLightPtr; - typedef shared_ptr OgreRayQueryPtr; - typedef shared_ptr OgreRenderEnginePtr; - typedef shared_ptr OgreRenderTargetPtr; - typedef shared_ptr OgreRenderTargetMaterialPtr; - typedef shared_ptr OgreRenderTexturePtr; - typedef shared_ptr OgreRenderWindowPtr; - typedef shared_ptr OgreScenePtr; - typedef shared_ptr OgreSceneStorePtr; - typedef shared_ptr OgreSensorPtr; - typedef shared_ptr OgreSensorStorePtr; - typedef shared_ptr OgreSpotLightPtr; - typedef shared_ptr OgreSubMeshPtr; - typedef shared_ptr OgreSubMeshStorePtr; - typedef shared_ptr OgreTextPtr; - typedef shared_ptr OgreThermalCameraPtr; - typedef shared_ptr OgreVisualPtr; - typedef shared_ptr OgreVisualStorePtr; - typedef shared_ptr OgreWireBoxPtr; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreScene.hh b/ogre/include/ignition/rendering/ogre/OgreScene.hh index 81278e160..57d7e3386 100644 --- a/ogre/include/ignition/rendering/ogre/OgreScene.hh +++ b/ogre/include/ignition/rendering/ogre/OgreScene.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,236 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRESCENE_HH_ -#define IGNITION_RENDERING_OGRE_OGRESCENE_HH_ -#include -#include -#include "ignition/rendering/base/BaseScene.hh" -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" - - -namespace Ogre -{ - class Root; - class SceneManager; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreScene : - public BaseScene - { - protected: OgreScene(unsigned int _id, const std::string &_name); - - public: virtual ~OgreScene(); - - public: virtual void Fini() override; - - public: virtual RenderEngine *Engine() const override; - - public: virtual VisualPtr RootVisual() const override; - - public: virtual math::Color AmbientLight() const override; - - public: virtual void SetAmbientLight(const math::Color &_color) override; - - public: virtual void SetBackgroundColor( - const math::Color &_color) override; - - // Documentation inherited. - public: virtual void SetGradientBackgroundColor( - const std::array &_colors) override; - - // Documentation inherited. - public: virtual void RemoveGradientBackgroundColor() override; - - public: virtual void PreRender() override; - - public: virtual void Clear() override; - - public: virtual void Destroy() override; - - public: virtual Ogre::SceneManager *OgreSceneManager() const; - - protected: virtual bool LoadImpl() override; - - protected: virtual bool InitImpl() override; - - protected: virtual DirectionalLightPtr CreateDirectionalLightImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited - protected: virtual COMVisualPtr CreateCOMVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual InertiaVisualPtr CreateInertiaVisualImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited - protected: virtual JointVisualPtr CreateJointVisualImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual LightVisualPtr CreateLightVisualImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual CameraPtr CreateCameraImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual DepthCameraPtr CreateDepthCameraImpl( - const unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual ThermalCameraPtr CreateThermalCameraImpl( - const unsigned int _id, - const std::string &_name) override; - - protected: virtual GpuRaysPtr CreateGpuRaysImpl( - const unsigned int _id, - const std::string &_name) override; - - protected: virtual VisualPtr CreateVisualImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual GeometryPtr CreateConeImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, - const std::string &_name, const std::string &_meshName); - - protected: virtual MeshPtr CreateMeshImpl( - unsigned int _id, - const std::string &_name, - const MeshDescriptor &_desc) override; - - // Documentation inherited - protected: virtual HeightmapPtr CreateHeightmapImpl( - unsigned int _id, - const std::string &_name, - const HeightmapDescriptor &_desc) override; - - // Documentation inherited - protected: virtual CapsulePtr CreateCapsuleImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual GridPtr CreateGridImpl( - unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual MarkerPtr CreateMarkerImpl( - unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual TextPtr CreateTextImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual RenderTexturePtr CreateRenderTextureImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited. - protected: virtual RenderWindowPtr CreateRenderWindowImpl( - unsigned int _id, const std::string &_name) override; - - protected: virtual RayQueryPtr CreateRayQueryImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited - protected: virtual ParticleEmitterPtr CreateParticleEmitterImpl( - unsigned int _id, const std::string &_name) override; - - protected: virtual bool InitObject(OgreObjectPtr _object, - unsigned int _id, const std::string &_name); - - protected: virtual LightStorePtr Lights() const override; - - protected: virtual SensorStorePtr Sensors() const override; - - protected: virtual VisualStorePtr Visuals() const override; - - protected: virtual MaterialMapPtr Materials() const override; - - /// \brief Remove internal material cache for a specific material - /// \param[in] _name Name of the template material to remove. - public: void ClearMaterialsCache(const std::string &_name); - - private: void CreateContext(); - - private: void CreateRootVisual(); - - private: void CreateMeshFactory(); - - private: void CreateStores(); - - private: OgreScenePtr SharedThis(); - - protected: OgreVisualPtr rootVisual; - - protected: OgreMeshFactoryPtr meshFactory; - - protected: OgreLightStorePtr lights; - - protected: OgreSensorStorePtr sensors; - - protected: OgreVisualStorePtr visuals; - - protected: OgreMaterialMapPtr materials; - - protected: Ogre::Root *ogreRoot; - - protected: Ogre::SceneManager *ogreSceneManager; - - private: friend class OgreRenderEngine; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh b/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh index 51c76af25..1368dace4 100644 --- a/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh +++ b/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,76 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_OGRE_OGRESELECTIONBUFFER_HH_ -#define IGNITION_RENDERING_OGRE_OGRESELECTIONBUFFER_HH_ + */ -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace Ogre -{ - class Entity; - class RenderTarget; - class SceneManager; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreSelectionBufferPrivate; - - /// \brief Generates a selection buffer object for a given camera. - /// The selection buffer is used of entity selection. On setup, a unique - /// color is assigned to each entity. Whenever a selection request is made, - /// the selection buffer camera renders to a 1x1 sized offscreen buffer. - /// The color value of that pixel gives the identity of the entity. - class IGNITION_RENDERING_OGRE_VISIBLE OgreSelectionBuffer - { - /// \brief Constructor - /// \param[in] _cameraName Name of the camera to generate a selection - /// buffer for. - /// \param[in] _mgr Pointer to the scene manager. - public: OgreSelectionBuffer(const std::string &_cameraName, - Ogre::SceneManager *_mgr); - - /// \brief Destructor - public: ~OgreSelectionBuffer(); - - /// \brief Handle on mouse click - /// \param[in] _x X coordinate in pixels. - /// \param[in] _y Y coordinate in pixels. - /// \return Returns the Ogre entity at the coordinate. - public: Ogre::Entity *OnSelectionClick(const int _x, const int _y); - - /// \brief Debug show overlay - /// \param[in] _show True to show the selection buffer in an overlay. - public: void ShowOverlay(const bool _show); - - /// \brief Call this to update the selection buffer contents - public: void Update(); - - /// \brief Delete the render texture - private: void DeleteRTTBuffer(); - - /// \brief Create the render texture - private: void CreateRTTBuffer(); - - /// \brief Create the selection buffer offscreen render texture. - private: void CreateRTTOverlays(); - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreSensor.hh b/ogre/include/ignition/rendering/ogre/OgreSensor.hh index 6f4e6f3c1..4bb39d0b8 100644 --- a/ogre/include/ignition/rendering/ogre/OgreSensor.hh +++ b/ogre/include/ignition/rendering/ogre/OgreSensor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,26 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRESENSOR_HH_ -#define IGNITION_RENDERING_OGRE_OGRESENSOR_HH_ -#include "ignition/rendering/base/BaseSensor.hh" -#include "ignition/rendering/ogre/OgreNode.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreSensor : - public BaseSensor - { - protected: OgreSensor(); - - public: virtual ~OgreSensor(); - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreStorage.hh b/ogre/include/ignition/rendering/ogre/OgreStorage.hh index bd113c1fb..4dcf7e553 100644 --- a/ogre/include/ignition/rendering/ogre/OgreStorage.hh +++ b/ogre/include/ignition/rendering/ogre/OgreStorage.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,59 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRESTORAGE_HH_ -#define IGNITION_RENDERING_OGRE_OGRESTORAGE_HH_ -#include -#include "ignition/rendering/base/BaseStorage.hh" - -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreLight.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreMesh.hh" -#include "ignition/rendering/ogre/OgreNode.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreSensor.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - -// armhf failed to build with this code. It can not be removed for the rest -// of arches to keep ABI but should be removed in major versions unreleased -// see https://github.com/ignitionrobotics/ign-rendering/pull/457 -#ifndef __ARM_PCS_VFP - template class BaseSceneStore; - template class BaseNodeStore; - template class BaseLightStore; - template class BaseSensorStore; - template class BaseVisualStore; - template class BaseGeometryStore; - template class BaseSubMeshStore; - template class BaseMaterialMap; -#endif - - typedef BaseSceneStore OgreSceneStore; - typedef BaseNodeStore OgreNodeStore; - typedef BaseLightStore OgreLightStore; - typedef BaseSensorStore OgreSensorStore; - typedef BaseVisualStore OgreVisualStore; - typedef BaseGeometryStore OgreGeometryStore; - typedef BaseSubMeshStore OgreSubMeshStore; - typedef BaseMaterialMap OgreMaterialMap; - - typedef std::shared_ptr OgreSceneStorePtr; - typedef std::shared_ptr OgreNodeStorePtr; - typedef std::shared_ptr OgreLightStorePtr; - typedef std::shared_ptr OgreSensorStorePtr; - typedef std::shared_ptr OgreVisualStorePtr; - typedef std::shared_ptr OgreGeometryStorePtr; - typedef std::shared_ptr OgreSubMeshStorePtr; - typedef std::shared_ptr OgreMaterialMapPtr; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreText.hh b/ogre/include/ignition/rendering/ogre/OgreText.hh index 61511d5a0..6bca24fdf 100644 --- a/ogre/include/ignition/rendering/ogre/OgreText.hh +++ b/ogre/include/ignition/rendering/ogre/OgreText.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,98 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGRETEXT_HH_ -#define IGNITION_RENDERING_OGRE_OGRETEXT_HH_ - -#include -#include - -#include -#include - -#include "ignition/rendering/base/BaseText.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class OgreMovableText; - class OgreTextPrivate; - - /// \brief Ogre implementation of text geometry - class IGNITION_RENDERING_OGRE_VISIBLE OgreText - : public BaseText - { - /// \brief Constructor - protected: OgreText(); - - /// \brief Destructor - public: virtual ~OgreText(); - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual Ogre::MovableObject *OgreObject() const override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial(MaterialPtr _material, bool _unique) - override; - - // Documentation inherited. - public: virtual void SetFontName(const std::string &_font) override; - - // Documentation inherited. - public: virtual void SetTextString(const std::string &_text) override; - - // Documentation inherited. - public: virtual void SetColor(const ignition::math::Color &_color) - override; - - // Documentation inherited. - public: virtual void SetCharHeight(const float _height) override; - - // Documentation inherited. - public: virtual void SetSpaceWidth(const float _width) override; - - // Documentation inherited. - public: virtual void SetTextAlignment( - const TextHorizontalAlign &_horizAlign, - const TextVerticalAlign &_vertAlign) override; - // Documentation inherited. - public: virtual void SetBaseline(const float _baseline) override; - - // Documentation inherited. - public: virtual void SetShowOnTop(const bool _onTop) override; - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox AABB() const override; - - /// \brief Set material to text geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); - - /// \brief Text should only be created by scene. - private: friend class OgreScene; - - /// \internal - /// \brief Private data pointer - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh b/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh index fdeee48ae..ee3696e49 100644 --- a/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,111 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGRETHERMALCAMERA_HH_ -#define IGNITION_RENDERING_OGRE_OGRETHERMALCAMERA_HH_ - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -#include -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/base/BaseThermalCamera.hh" -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreSensor.hh" - -#include "ignition/common/Event.hh" -#include "ignition/common/Console.hh" - - -namespace Ogre -{ - class Material; - class Camera; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreThermalCameraPrivate; - - /** \class OgreThermalCamera OgreThermalCamera.hh\ - * rendering/ogre/OgreThermalCamera.hh - **/ - /// \brief Depth camera used to render thermal data into an image buffer - class IGNITION_RENDERING_OGRE_VISIBLE OgreThermalCamera : - public BaseThermalCamera - { - /// \brief Constructor - protected: OgreThermalCamera(); - - /// \brief Destructor - public: virtual ~OgreThermalCamera(); - - /// \brief Initialize the camera - public: virtual void Init() override; - - /// \brief Create a texture - public: virtual void CreateRenderTexture(); - - /// \brief Destroy render texture created by CreateRenderTexture() - /// Note: It's not virtual. - protected: void DestroyRenderTexture(); - - /// \brief Render the camera - public: virtual void PostRender() override; - - /// \brief Connect to the new thermal image signal - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewThermalFrame( - std::function _subscriber) override; - - // Documentation inherited. - public: virtual void PreRender() override; - - /// \brief Implementation of the render call - public: virtual void Render() override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Create the camera. - protected: void CreateCamera(); - - /// \brief Create thermal texture. This stores temperature data - private: void CreateThermalTexture(); - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera = nullptr; - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreVisual.hh b/ogre/include/ignition/rendering/ogre/OgreVisual.hh index ab9843ef1..97b23807e 100644 --- a/ogre/include/ignition/rendering/ogre/OgreVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,91 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREVISUAL_HH_ -#include -#include - -#include "ignition/rendering/base/BaseVisual.hh" -#include "ignition/rendering/ogre/OgreNode.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreVisualPrivate; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreVisual : - public BaseVisual - { - protected: OgreVisual(); - - public: virtual ~OgreVisual(); - - // Documentation inherited. - public: virtual void SetWireframe(bool _show) override; - - // Documentation inherited. - public: virtual bool Wireframe() const override; - - // Documentation inherited. - public: virtual void SetVisible(bool _visible) override; - - // Documentation inherited. - public: virtual void SetVisibilityFlags(uint32_t _flags) override; - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox LocalBoundingBox() - const override; - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox BoundingBox() - const override; - - /// \brief Recursively loop through this visual's children - /// to obtain bounding box. - /// \param[in,out] _box The bounding box. - /// \param[in] _local A flag indicating if the local bounding box is to - /// be calculated. - /// \param[in] _pose World pose of the visual. - private: virtual void BoundsHelper( - ignition::math::AxisAlignedBox &_box, bool _local, - const ignition::math::Pose3d &_pose) const; - - /// \brief Wrapper function for BoundsHelper to reduce redundant - /// world pose access - /// \param[in,out] _box The bounding box. - /// \param[in] _local A flag indicating if the local bounding box is to - /// be calculated. - private: virtual void BoundsHelper( - ignition::math::AxisAlignedBox &_box, bool _local) const; - - protected: virtual GeometryStorePtr Geometries() const override; - - // Documentation inherited. - protected: virtual bool AttachGeometry(GeometryPtr _geometry) override; - - // Documentation inherited. - protected: virtual bool DetachGeometry(GeometryPtr _geometry) override; - - // Documentation inherited. - protected: virtual void Init() override; - - protected: OgreGeometryStorePtr geometries; - - private: OgreVisualPtr SharedThis(); - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreWireBox.hh b/ogre/include/ignition/rendering/ogre/OgreWireBox.hh index b22078f19..14e019a07 100644 --- a/ogre/include/ignition/rendering/ogre/OgreWireBox.hh +++ b/ogre/include/ignition/rendering/ogre/OgreWireBox.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,70 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREWIREBOX_HH_ -#define IGNITION_RENDERING_OGRE_OGREWIREBOX_HH_ - -#include -#include "ignition/rendering/base/BaseWireBox.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class OgreWireBoxPrivate; - - /// \brief Ogre implementation of a wire box geometry. - class IGNITION_RENDERING_OGRE_VISIBLE OgreWireBox - : public BaseWireBox - { - /// \brief Constructor - protected: OgreWireBox(); - - /// \brief Destructor - public: virtual ~OgreWireBox(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial(MaterialPtr _material, bool _unique) - override; - - /// \brief Set material to wire box geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); - - /// \brief Create the wire box geometry in ogre - private: void Create(); - - /// \brief Wire Box should only be created by scene. - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/ogre.hh.in b/ogre/include/ignition/rendering/ogre/ogre.hh.in deleted file mode 100644 index acfd26ae7..000000000 --- a/ogre/include/ignition/rendering/ogre/ogre.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/ogre/src/OgreArrowVisual.cc b/ogre/src/OgreArrowVisual.cc index d32693a05..809ec73ae 100644 --- a/ogre/src/OgreArrowVisual.cc +++ b/ogre/src/OgreArrowVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreArrowVisual.hh" +#include "gz/rendering/ogre/OgreArrowVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreAxisVisual.cc b/ogre/src/OgreAxisVisual.cc index 22e98e888..e612276cd 100644 --- a/ogre/src/OgreAxisVisual.cc +++ b/ogre/src/OgreAxisVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreAxisVisual.hh" +#include "gz/rendering/ogre/OgreAxisVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreCamera.cc b/ogre/src/OgreCamera.cc index 9a94ec6bb..b93f83994 100644 --- a/ogre/src/OgreCamera.cc +++ b/ogre/src/OgreCamera.cc @@ -15,16 +15,16 @@ * */ -#include "ignition/rendering/ogre/OgreCamera.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreSelectionBuffer.hh" -#include "ignition/rendering/Utils.hh" - -using namespace ignition; +#include "gz/rendering/ogre/OgreCamera.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreSelectionBuffer.hh" +#include "gz/rendering/Utils.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreConversions.cc b/ogre/src/OgreConversions.cc index e03e5ea4e..1362cfe38 100644 --- a/ogre/src/OgreConversions.cc +++ b/ogre/src/OgreConversions.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreConversions.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreDepthCamera.cc b/ogre/src/OgreDepthCamera.cc index bb85a0a17..860d13d4f 100644 --- a/ogre/src/OgreDepthCamera.cc +++ b/ogre/src/OgreDepthCamera.cc @@ -22,13 +22,13 @@ #endif #include #endif -#include -#include "ignition/rendering/ogre/OgreDepthCamera.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" +#include +#include "gz/rendering/ogre/OgreDepthCamera.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" /// \internal /// \brief Private data for the OgreDepthCamera class -class ignition::rendering::OgreDepthCameraPrivate +class gz::rendering::OgreDepthCameraPrivate { /// \brief The depth buffer public: float *depthBuffer = nullptr; @@ -58,23 +58,23 @@ class ignition::rendering::OgreDepthCameraPrivate public: bool outputPoints = false; /// \brief maximum value used for data outside sensor range - public: float dataMaxVal = ignition::math::INF_D; + public: float dataMaxVal = gz::math::INF_D; /// \brief minimum value used for data outside sensor range - public: float dataMinVal = -ignition::math::INF_D; + public: float dataMinVal = -gz::math::INF_D; /// \brief Event used to signal rgb point cloud data - public: ignition::common::EventT newRgbPointCloud; /// \brief Event used to signal depth data - public: ignition::common::EventT newDepthFrame; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// @@ -130,6 +130,9 @@ void OgreDepthCamera::Destroy() this->ogreCamera = nullptr; } } + + // call base node destroy to remove parent + OgreNode::Destroy(); } ////////////////////////////////////////////////// diff --git a/ogre/src/OgreDynamicLines.cc b/ogre/src/OgreDynamicLines.cc index 0c3b7be18..a9a11ec88 100644 --- a/ogre/src/OgreDynamicLines.cc +++ b/ogre/src/OgreDynamicLines.cc @@ -18,19 +18,19 @@ #include #include -#include +#include -#include "ignition/common/Console.hh" -#include "ignition/rendering/ogre/OgreDynamicLines.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/ogre/OgreDynamicLines.hh" -using namespace ignition; +using namespace gz; using namespace rendering; enum {POSITION_BINDING, TEXCOORD_BINDING}; /// \brief Private implementation -class ignition::rendering::OgreDynamicLinesPrivate +class gz::rendering::OgreDynamicLinesPrivate { /// \brief list of colors at each point public: std::vector colors; diff --git a/ogre/src/OgreDynamicRenderable.cc b/ogre/src/OgreDynamicRenderable.cc index cca6792da..c0e8be934 100644 --- a/ogre/src/OgreDynamicRenderable.cc +++ b/ogre/src/OgreDynamicRenderable.cc @@ -15,10 +15,10 @@ * */ -#include "ignition/common/Console.hh" -#include "ignition/rendering/ogre/OgreDynamicRenderable.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/ogre/OgreDynamicRenderable.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreGaussianNoisePass.cc b/ogre/src/OgreGaussianNoisePass.cc index 082c89f18..0f81ab498 100644 --- a/ogre/src/OgreGaussianNoisePass.cc +++ b/ogre/src/OgreGaussianNoisePass.cc @@ -16,11 +16,11 @@ */ -#include +#include -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreGaussianNoisePass.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreGaussianNoisePass.hh" namespace ignition { @@ -55,9 +55,9 @@ namespace ignition // Sample three values within the range [0,1.0] and set them for use in // the fragment shader, which will interpret them as offsets from (0,0) // to use when computing pseudo-random values. - Ogre::Vector3 offsets(ignition::math::Rand::DblUniform(0.0, 1.0), - ignition::math::Rand::DblUniform(0.0, 1.0), - ignition::math::Rand::DblUniform(0.0, 1.0)); + Ogre::Vector3 offsets(gz::math::Rand::DblUniform(0.0, 1.0), + gz::math::Rand::DblUniform(0.0, 1.0), + gz::math::Rand::DblUniform(0.0, 1.0)); // These calls are setting parameters that are declared in two places: // 1. media/materials/scripts/gaussian_noise.material, in // fragment_program GaussianNoiseFS @@ -89,7 +89,7 @@ namespace ignition } } -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreGeometry.cc b/ogre/src/OgreGeometry.cc index 821967c35..787dff754 100644 --- a/ogre/src/OgreGeometry.cc +++ b/ogre/src/OgreGeometry.cc @@ -14,12 +14,12 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreGizmoVisual.cc b/ogre/src/OgreGizmoVisual.cc index 8cbfc67ff..6e3310acf 100644 --- a/ogre/src/OgreGizmoVisual.cc +++ b/ogre/src/OgreGizmoVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreGizmoVisual.hh" +#include "gz/rendering/ogre/OgreGizmoVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreGpuRays.cc b/ogre/src/OgreGpuRays.cc index e916fb195..eb07d3d21 100644 --- a/ogre/src/OgreGpuRays.cc +++ b/ogre/src/OgreGpuRays.cc @@ -15,21 +15,21 @@ * */ -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre/OgreCamera.hh" -#include "ignition/rendering/ogre/OgreGpuRays.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre/OgreCamera.hh" +#include "gz/rendering/ogre/OgreGpuRays.hh" /// \internal /// \brief Private data for the OgreGpuRays class -class ignition::rendering::OgreGpuRaysPrivate +class gz::rendering::OgreGpuRaysPrivate { /// \brief Event triggered when new gpu rays range data are available. /// \param[in] _frame New frame containing raw gpu rays data. @@ -37,7 +37,7 @@ class ignition::rendering::OgreGpuRaysPrivate /// \param[in] _height Height of frame. /// \param[in] _channels Number of channels /// \param[in] _format Format of frame. - public: ignition::common::EventT newGpuRaysFrame; @@ -129,7 +129,7 @@ class ignition::rendering::OgreGpuRaysPrivate public: const math::Angle kMinAllowedAngle = 1e-4; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreGrid.cc b/ogre/src/OgreGrid.cc index 168ab96ea..bf80ebea1 100644 --- a/ogre/src/OgreGrid.cc +++ b/ogre/src/OgreGrid.cc @@ -15,13 +15,13 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreGrid.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreGrid.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreScene.hh" -class ignition::rendering::OgreGridPrivate +class gz::rendering::OgreGridPrivate { /// \brief Grid materal public: OgreMaterialPtr material; @@ -30,7 +30,7 @@ class ignition::rendering::OgreGridPrivate public: Ogre::ManualObject *manualObject = nullptr; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreLight.cc b/ogre/src/OgreLight.cc index 8c899e04a..938e09389 100644 --- a/ogre/src/OgreLight.cc +++ b/ogre/src/OgreLight.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreLight.hh" +#include "gz/rendering/ogre/OgreLight.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreMarker.cc b/ogre/src/OgreMarker.cc index 4dc4493cc..0ce683dfe 100644 --- a/ogre/src/OgreMarker.cc +++ b/ogre/src/OgreMarker.cc @@ -15,16 +15,16 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreCapsule.hh" -#include "ignition/rendering/ogre/OgreDynamicLines.hh" -#include "ignition/rendering/ogre/OgreMarker.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreMesh.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreCapsule.hh" +#include "gz/rendering/ogre/OgreDynamicLines.hh" +#include "gz/rendering/ogre/OgreMarker.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreMesh.hh" +#include "gz/rendering/ogre/OgreScene.hh" -class ignition::rendering::OgreMarkerPrivate +class gz::rendering::OgreMarkerPrivate { /// \brief Marker material public: OgreMaterialPtr material = nullptr; @@ -36,7 +36,7 @@ class ignition::rendering::OgreMarkerPrivate public: OgreGeometryPtr geom{nullptr}; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreMaterial.cc b/ogre/src/OgreMaterial.cc index e6ad80c2e..8a05aea2f 100644 --- a/ogre/src/OgreMaterial.cc +++ b/ogre/src/OgreMaterial.cc @@ -15,17 +15,17 @@ * */ -#include -#include +#include +#include -#include "ignition/rendering/ShaderParams.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ShaderParams.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" +#include "gz/rendering/ogre/OgreScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreMaterialSwitcher.cc b/ogre/src/OgreMaterialSwitcher.cc index f7b692534..2814146cf 100644 --- a/ogre/src/OgreMaterialSwitcher.cc +++ b/ogre/src/OgreMaterialSwitcher.cc @@ -15,12 +15,12 @@ * */ -#include "ignition/common/Console.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterialSwitcher.hh" -#include "ignition/rendering/RenderTypes.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreMaterialSwitcher.hh" +#include "gz/rendering/RenderTypes.hh" -using namespace ignition; +using namespace gz; using namespace rendering; diff --git a/ogre/src/OgreMesh.cc b/ogre/src/OgreMesh.cc index d55ab443e..89e371c39 100644 --- a/ogre/src/OgreMesh.cc +++ b/ogre/src/OgreMesh.cc @@ -15,22 +15,22 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreMesh.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreMesh.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" /// brief Private implementation of the OgreMesh class -class ignition::rendering::OgreMeshPrivate +class gz::rendering::OgreMeshPrivate { }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreMeshFactory.cc b/ogre/src/OgreMeshFactory.cc index d30c55a79..bd4e8faf1 100644 --- a/ogre/src/OgreMeshFactory.cc +++ b/ogre/src/OgreMeshFactory.cc @@ -18,24 +18,24 @@ #include -#include -#include -#include -#include -#include -#include - -#include - -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMesh.hh" -#include "ignition/rendering/ogre/OgreMeshFactory.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" - -using namespace ignition; +#include +#include +#include +#include +#include +#include + +#include + +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreMesh.hh" +#include "gz/rendering/ogre/OgreMeshFactory.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreStorage.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreNode.cc b/ogre/src/OgreNode.cc index 0040201e8..d955c991b 100644 --- a/ogre/src/OgreNode.cc +++ b/ogre/src/OgreNode.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreNode.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/ogre/OgreNode.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreObject.cc b/ogre/src/OgreObject.cc index 2b2fed8b7..c543ea6cf 100644 --- a/ogre/src/OgreObject.cc +++ b/ogre/src/OgreObject.cc @@ -14,11 +14,11 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreObject.hh" +#include "gz/rendering/ogre/OgreObject.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRTShaderSystem.cc b/ogre/src/OgreRTShaderSystem.cc index 026e6dceb..b27028215 100644 --- a/ogre/src/OgreRTShaderSystem.cc +++ b/ogre/src/OgreRTShaderSystem.cc @@ -24,18 +24,18 @@ #include #include -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreMesh.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" - -class ignition::rendering::OgreRTShaderSystemPrivate +#include +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreMesh.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" + +class gz::rendering::OgreRTShaderSystemPrivate { /// \brief The shader generator. public: Ogre::RTShader::ShaderGenerator *shaderGenerator = nullptr; @@ -75,7 +75,7 @@ class ignition::rendering::OgreRTShaderSystemPrivate public: std::thread::id threadId; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRayQuery.cc b/ogre/src/OgreRayQuery.cc index e5e54b117..50bd66354 100644 --- a/ogre/src/OgreRayQuery.cc +++ b/ogre/src/OgreRayQuery.cc @@ -17,21 +17,21 @@ #include -#include +#include -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreCamera.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreRayQuery.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreCamera.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreRayQuery.hh" +#include "gz/rendering/ogre/OgreScene.hh" -class ignition::rendering::OgreRayQueryPrivate +class gz::rendering::OgreRayQueryPrivate { /// \brief Ogre ray scene query object for computing intersection. public: Ogre::RaySceneQuery *rayQuery = nullptr; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRenderEngine.cc b/ogre/src/OgreRenderEngine.cc index 41a9636f7..1e104873f 100644 --- a/ogre/src/OgreRenderEngine.cc +++ b/ogre/src/OgreRenderEngine.cc @@ -30,21 +30,21 @@ # include -#include +#include -#include -#include -#include +#include +#include +#include -#include "ignition/rendering/RenderEngineManager.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/RenderEngineManager.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreStorage.hh" -class ignition::rendering::OgreRenderEnginePrivate +class gz::rendering::OgreRenderEnginePrivate { #if !defined(__APPLE__) && !defined(_WIN32) public: XVisualInfo *dummyVisual = nullptr; @@ -54,7 +54,7 @@ class ignition::rendering::OgreRenderEnginePrivate public: std::vector fsaaLevels; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRenderPass.cc b/ogre/src/OgreRenderPass.cc index ce36cd804..0146a499d 100644 --- a/ogre/src/OgreRenderPass.cc +++ b/ogre/src/OgreRenderPass.cc @@ -14,10 +14,10 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreRenderPass.hh" +#include "gz/rendering/ogre/OgreRenderPass.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRenderTarget.cc b/ogre/src/OgreRenderTarget.cc index 30c0bb1bc..568e9a51e 100644 --- a/ogre/src/OgreRenderTarget.cc +++ b/ogre/src/OgreRenderTarget.cc @@ -19,7 +19,7 @@ # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wunused-parameter" #else -# pragma warning(push, 0) +# pragma warning(push) # pragma warning(disable: 4005) # pragma warning(disable: 4275) #endif @@ -33,21 +33,21 @@ #endif -#include +#include -#include "ignition/rendering/Material.hh" +#include "gz/rendering/Material.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreRenderPass.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreCamera.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreRenderPass.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreCamera.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRenderTargetMaterial.cc b/ogre/src/OgreRenderTargetMaterial.cc index b3f9ed84b..9215ea996 100644 --- a/ogre/src/OgreRenderTargetMaterial.cc +++ b/ogre/src/OgreRenderTargetMaterial.cc @@ -15,10 +15,10 @@ * */ -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreRenderTargetMaterial.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreRenderTargetMaterial.hh" -using namespace ignition::rendering; +using namespace gz::rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreScene.cc b/ogre/src/OgreScene.cc index 8e23efbd8..d893ebcb9 100644 --- a/ogre/src/OgreScene.cc +++ b/ogre/src/OgreScene.cc @@ -15,39 +15,39 @@ * */ -#include - -#include "ignition/rendering/ogre/OgreArrowVisual.hh" -#include "ignition/rendering/ogre/OgreAxisVisual.hh" -#include "ignition/rendering/ogre/OgreCamera.hh" -#include "ignition/rendering/ogre/OgreCapsule.hh" -#include "ignition/rendering/ogre/OgreCOMVisual.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreDepthCamera.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreGizmoVisual.hh" -#include "ignition/rendering/ogre/OgreGpuRays.hh" -#include "ignition/rendering/ogre/OgreGrid.hh" -#include "ignition/rendering/ogre/OgreHeightmap.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreInertiaVisual.hh" -#include "ignition/rendering/ogre/OgreJointVisual.hh" -#include "ignition/rendering/ogre/OgreLidarVisual.hh" -#include "ignition/rendering/ogre/OgreLightVisual.hh" -#include "ignition/rendering/ogre/OgreMarker.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreMeshFactory.hh" -#include "ignition/rendering/ogre/OgreParticleEmitter.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" -#include "ignition/rendering/ogre/OgreRayQuery.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" -#include "ignition/rendering/ogre/OgreText.hh" -#include "ignition/rendering/ogre/OgreThermalCamera.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" -#include "ignition/rendering/ogre/OgreWireBox.hh" +#include + +#include "gz/rendering/ogre/OgreArrowVisual.hh" +#include "gz/rendering/ogre/OgreAxisVisual.hh" +#include "gz/rendering/ogre/OgreCamera.hh" +#include "gz/rendering/ogre/OgreCapsule.hh" +#include "gz/rendering/ogre/OgreCOMVisual.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreDepthCamera.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreGizmoVisual.hh" +#include "gz/rendering/ogre/OgreGpuRays.hh" +#include "gz/rendering/ogre/OgreGrid.hh" +#include "gz/rendering/ogre/OgreHeightmap.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreInertiaVisual.hh" +#include "gz/rendering/ogre/OgreJointVisual.hh" +#include "gz/rendering/ogre/OgreLidarVisual.hh" +#include "gz/rendering/ogre/OgreLightVisual.hh" +#include "gz/rendering/ogre/OgreMarker.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreMeshFactory.hh" +#include "gz/rendering/ogre/OgreParticleEmitter.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" +#include "gz/rendering/ogre/OgreRayQuery.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/ogre/OgreText.hh" +#include "gz/rendering/ogre/OgreThermalCamera.hh" +#include "gz/rendering/ogre/OgreVisual.hh" +#include "gz/rendering/ogre/OgreWireBox.hh" namespace ignition { @@ -128,7 +128,7 @@ namespace ignition } } -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreSelectionBuffer.cc b/ogre/src/OgreSelectionBuffer.cc index 09a41083b..49815dd0e 100644 --- a/ogre/src/OgreSelectionBuffer.cc +++ b/ogre/src/OgreSelectionBuffer.cc @@ -16,18 +16,18 @@ */ #include -#include +#include -#include "ignition/common/Console.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterialSwitcher.hh" -#include "ignition/rendering/ogre/OgreSelectionBuffer.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreMaterialSwitcher.hh" +#include "gz/rendering/ogre/OgreSelectionBuffer.hh" -using namespace ignition; +using namespace gz; using namespace rendering; -class ignition::rendering::OgreSelectionBufferPrivate +class gz::rendering::OgreSelectionBufferPrivate { /// \brief This is a material listener and a RenderTargetListener. /// The material switcher is applied to only the selection camera diff --git a/ogre/src/OgreSensor.cc b/ogre/src/OgreSensor.cc index 58c965834..b45f5978a 100644 --- a/ogre/src/OgreSensor.cc +++ b/ogre/src/OgreSensor.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreSensor.hh" +#include "gz/rendering/ogre/OgreSensor.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreText.cc b/ogre/src/OgreText.cc index 1d2841a44..d2edd4c3f 100644 --- a/ogre/src/OgreText.cc +++ b/ogre/src/OgreText.cc @@ -20,17 +20,17 @@ #include #endif -#include -#include +#include +#include -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreText.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreText.hh" #define POS_TEX_BINDING 0 #define COLOUR_BINDING 1 -class ignition::rendering::OgreMovableText +class gz::rendering::OgreMovableText : public Ogre::MovableObject, public Ogre::Renderable { /// \brief Constructor @@ -50,7 +50,7 @@ class ignition::rendering::OgreMovableText /// \brief Set the text color. /// \param[in] _color Text color. - public: void SetColor(const ignition::math::Color &_color); + public: void SetColor(const gz::math::Color &_color); /// \brief Set the height of the character in meters. /// \param[in] _height Height of the characters. @@ -77,7 +77,7 @@ class ignition::rendering::OgreMovableText /// \brief Get the axis aligned bounding box of the text. /// \return The axis aligned bounding box. - public: ignition::math::AxisAlignedBox AABB() const; + public: gz::math::AxisAlignedBox AABB() const; /// \brief Setup the geometry based on input text string. public: void SetupGeometry(); @@ -187,7 +187,7 @@ class ignition::rendering::OgreMovableText private: std::string text; /// \brief Text color - private: ignition::math::Color color; + private: gz::math::Color color; /// \brief Character height in meters private: float charHeight = 0.0; @@ -210,7 +210,7 @@ class ignition::rendering::OgreMovableText }; /// \brief Private data for the OgreText class. -class ignition::rendering::OgreTextPrivate +class gz::rendering::OgreTextPrivate { /// \brief Text materal public: OgreMaterialPtr material; @@ -219,7 +219,7 @@ class ignition::rendering::OgreTextPrivate public: std::unique_ptr ogreObj; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreThermalCamera.cc b/ogre/src/OgreThermalCamera.cc index 7e4e5867a..b6a8a47f7 100644 --- a/ogre/src/OgreThermalCamera.cc +++ b/ogre/src/OgreThermalCamera.cc @@ -25,11 +25,11 @@ #include -#include -#include "ignition/rendering/ShaderParams.hh" -#include "ignition/rendering/ogre/OgreThermalCamera.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" +#include +#include "gz/rendering/ShaderParams.hh" +#include "gz/rendering/ogre/OgreThermalCamera.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreVisual.hh" namespace ignition { @@ -90,7 +90,7 @@ class OgreThermalCameraMaterialSwitcher : public Ogre::RenderTargetListener, /// \internal /// \brief Private data for the OgreThermalCamera class -class ignition::rendering::OgreThermalCameraPrivate +class gz::rendering::OgreThermalCameraPrivate { /// \brief The thermal material public: Ogre::MaterialPtr thermalMaterial; @@ -120,7 +120,7 @@ class ignition::rendering::OgreThermalCameraPrivate public: uint16_t dataMinVal = 0u; /// \brief Event used to signal thermal image data - public: ignition::common::EventT newThermalFrame; @@ -129,7 +129,7 @@ class ignition::rendering::OgreThermalCameraPrivate thermalMaterialSwitcher; }; -using namespace ignition; +using namespace gz; using namespace rendering; diff --git a/ogre/src/OgreVisual.cc b/ogre/src/OgreVisual.cc index fba1eee91..d9feaf86f 100644 --- a/ogre/src/OgreVisual.cc +++ b/ogre/src/OgreVisual.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreVisual.hh" -#include "ignition/rendering/ogre/OgreWireBox.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" -#include "ignition/rendering/Utils.hh" +#include "gz/rendering/ogre/OgreVisual.hh" +#include "gz/rendering/ogre/OgreWireBox.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/Utils.hh" -using namespace ignition; +using namespace gz; using namespace rendering; /// \brief Private data for the Ogre2Visual class diff --git a/ogre2/include/CMakeLists.txt b/ogre2/include/CMakeLists.txt index 297e254ff..a7479f53e 100644 --- a/ogre2/include/CMakeLists.txt +++ b/ogre2/include/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(ignition/rendering) +add_subdirectory(gz/rendering) +install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) diff --git a/ogre2/include/ignition/rendering/CMakeLists.txt b/ogre2/include/gz/rendering/CMakeLists.txt similarity index 100% rename from ogre2/include/ignition/rendering/CMakeLists.txt rename to ogre2/include/gz/rendering/CMakeLists.txt diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2ArrowVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2ArrowVisual.hh new file mode 100644 index 000000000..33dd8012b --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2ArrowVisual.hh @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2ARROWVISUAL_HH_ +#define GZ_RENDERING_OGRE2_OGRE2ARROWVISUAL_HH_ + +#include "gz/rendering/base/BaseArrowVisual.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre2.x implementation of the arrow visual class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ArrowVisual : + public BaseArrowVisual + { + /// \brief Constructor + protected: Ogre2ArrowVisual(); + + /// \brief Destructor + public: virtual ~Ogre2ArrowVisual(); + + /// \brief Only scene can instantiate an arrow visual + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2AxisVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2AxisVisual.hh new file mode 100644 index 000000000..a431b5875 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2AxisVisual.hh @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2AXISVISUAL_HH_ +#define GZ_RENDERING_OGRE2_OGRE2AXISVISUAL_HH_ + +#include "gz/rendering/base/BaseAxisVisual.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre2.x implementation of the axis visual class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2AxisVisual : + public BaseAxisVisual + { + /// \brief Constructor + protected: Ogre2AxisVisual(); + + /// \brief Destructor + public: virtual ~Ogre2AxisVisual(); + + /// \brief Only scene can instantiate an axis visual + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2BoundingBoxCamera.hh b/ogre2/include/gz/rendering/ogre2/Ogre2BoundingBoxCamera.hh new file mode 100644 index 000000000..28366b031 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2BoundingBoxCamera.hh @@ -0,0 +1,172 @@ +/* + * + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE2_OGRE2BOUNDINGBOXCAMERA_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2BOUNDINGBOXCAMERA_HH_ + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +#include +#include + +#include "ignition/rendering/base/BaseBoundingBoxCamera.hh" +#include "ignition/rendering/ogre2/Ogre2Includes.hh" +#include "ignition/rendering/ogre2/Ogre2Sensor.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2BoundingBoxCameraPrivate; + + /// \brief BoundingBox camera used to detect 2d / 3d bounding boxes + /// of labeled objects in the scene + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2BoundingBoxCamera : + public BaseBoundingBoxCamera + { + /// \brief Constructor + protected: Ogre2BoundingBoxCamera(); + + /// \brief Destructor + public: virtual ~Ogre2BoundingBoxCamera(); + + /// \brief Initialize the camera + public: virtual void Init() override; + + /// \brief Destroy the camera + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void Render() override; + + // Documentation inherited + public: virtual void PostRender() override; + + // Documentation inherited + public: virtual const std::vector &BoundingBoxData() const + override; + + // Documentation inherited + public: virtual ignition::common::ConnectionPtr + ConnectNewBoundingBoxes( + std::function &)>) override; + + // Documentation inherited + public: virtual void SetBoundingBoxType(BoundingBoxType _type) override; + + // Documentation inherited + public: virtual BoundingBoxType Type() const override; + + /// \brief Create texture to hold ogre Ids to calculate the boundaries + /// of each ogre id mask + public: void CreateBoundingBoxTexture(); + + /// \brief Create dummy render texture. Needed to satisfy inheritance + /// and to set image's dims + public: void CreateRenderTexture(); + + /// \brief Compute the full bounding boxes by projecting all mesh vertices + /// of each object, then get the min & max of x & y to get the full bbox. + /// Check the visibility by looping over pixels of the ogre Ids map + public: void FullBoundingBoxes(); + + /// \brief Compute the visible bounding boxes by looping over pixels of + /// the ogre Ids map, to get the boundaries of each unique ogre Id mask + public: void VisibleBoundingBoxes(); + + /// \brief Compute the 3D bounding boxes + public: void BoundingBoxes3D(); + + /// \brief Get minimal bounding box of the mesh by projecting the 3d + /// vertices of the vertex buffer to 2d, then get the min & max of x & y + /// \param[in] _mesh Mesh of the item to get its minimal bbox + /// \param[in] _viewMatrix Camera view matrix + /// \param[in] _projMatrix Camera projection matrix + /// \param[out] _minVertex Minimum of projected x & y & z of the vertices + /// \param[out] _maxVertex Maximum of projected x & y & z of the vertices + /// \param[in] _position position of the item in the world space + /// \param[in] _orientation rotation of the item + /// \param[in] _scale scale of the item + public: void MeshMinimalBox( + const Ogre::MeshPtr _mesh, + const Ogre::Matrix4 &_viewMatrix, + const Ogre::Matrix4 &_projMatrix, + Ogre::Vector3 &_minVertex, + Ogre::Vector3 &_maxVertex, + const Ogre::Vector3 &_position, + const Ogre::Quaternion &_orientation, + const Ogre::Vector3 &_scale + ); + + // Documentation inherited + public: virtual void DrawBoundingBox(unsigned char *_data, + const math::Color &_color, const BoundingBox &_box) const override; + + /// \brief Draw line between any 2 points in the image data buffer + /// Algorithm: https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm + /// \param[in] _data buffer contains the image data + /// \param[in] _point1 The 1st 2D point in screen coordinates + /// \param[in] _point2 The 2nd 2D point in screen coordinates + /// \param[in] _color The color of the line + public: void DrawLine(unsigned char *_data, + const math::Vector2i &_point1, const math::Vector2i &_point2, + const ignition::math::Color &_color) const; + + /// \brief Convert from clip coord (after projection) to screen coord. + /// \param[in, out] _minVertex min vertex in clip coord to screen coord + /// \param[in, out] _maxVertex max vertex in clip coord to screen coord + public: void ConvertToScreenCoord(Ogre::Vector3 &_minVertex, + Ogre::Vector3 &_maxVertex) const; + + /// \brief Mark the visible boxes by checking the ogre ids map and mark + /// the ogre id which appears in the map. + public: void MarkVisibleBoxes(); + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Create the camera. + private: void CreateCamera(); + + /// \brief Merge a links's 2d boxes of multi links models + private: void MergeMultiLinksModels2D(); + + /// \brief Merge a links's 3d boxes of multi links models + private: void MergeMultiLinksModels3D(); + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2COMVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2COMVisual.hh new file mode 100644 index 000000000..d55afb8b7 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2COMVisual.hh @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE_OGRE2COMVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGRE2COMVISUAL_HH_ + +#include + +#include "ignition/rendering/base/BaseCOMVisual.hh" +#include "ignition/rendering/ogre2/Ogre2Visual.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + // Forward declaration + class Ogre2COMVisualPrivate; + + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2COMVisual : + public BaseCOMVisual + { + /// \brief Constructor + protected: Ogre2COMVisual(); + + /// \brief Destructor + public: virtual ~Ogre2COMVisual(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + protected: virtual void Destroy() override; + + /// \brief Create the Light Visual in Ogre + public: void CreateVisual(); + + // Documentation inherited + public: virtual VisualPtr SphereVisual() const override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial( + MaterialPtr _material, bool _unique) override; + + /// \brief Set material to grid geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); + + private: friend class Ogre2Scene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Camera.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Camera.hh new file mode 100644 index 000000000..941dc0139 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Camera.hh @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2CAMERA_HH_ +#define GZ_RENDERING_OGRE2_OGRE2CAMERA_HH_ + +#include + +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" + +namespace Ogre +{ + class Camera; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2CameraPrivate; + class Ogre2SelectionBuffer; + + /// \brief Ogre2.x implementation of the camera class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Camera : + public BaseCamera + { + /// \brief Constructor + protected: Ogre2Camera(); + + /// \brief Destructor + public: virtual ~Ogre2Camera(); + + // Documentation inherited. + public: virtual math::Angle HFOV() const override; + + // Documentation inherited. + public: virtual void SetHFOV(const math::Angle &_hfov) override; + + // Documentation inherited. + public: virtual double AspectRatio() const override; + + // Documentation inherited. + public: virtual void SetAspectRatio(const double _ratio) override; + + // Documentation inherited. + public: virtual unsigned int AntiAliasing() const override; + + // Documentation inherited. + public: virtual void SetAntiAliasing(const unsigned int _aa) override; + + // Documentation inherited. + public: virtual void SetFarClipPlane(const double _far) override; + + // Documentation inherited. + public: virtual void SetNearClipPlane(const double _near) override; + + public: virtual math::Color BackgroundColor() const; + + public: virtual void SetBackgroundColor(const math::Color &_color); + + /// \brief Get the background material of this camera + /// \return Background material of this camera + public: virtual MaterialPtr BackgroundMaterial() const; + + /// \brief Set the background material of this camera + /// \param[in] _material Material to set the background to + public: virtual void SetBackgroundMaterial(MaterialPtr _material); + + // Documentation inherited. + public: virtual void Render() override; + + // Documentation inherited. + public: virtual RenderWindowPtr CreateRenderWindow() override; + + // Documentation inherited. + public: virtual math::Matrix4d ProjectionMatrix() const override; + + // Documentation inherited. + public: virtual void SetProjectionMatrix( + const math::Matrix4d &_matrix) override; + + // Documentation inherited. + public: virtual math::Matrix4d ViewMatrix() const override; + + // Documentation inherited. + public: virtual void SetProjectionType(CameraProjectionType _type) + override; + + // Documentation inherited + public: virtual VisualPtr VisualAt(const ignition::math::Vector2i + &_mousePos) override; + + // Documentation Inherited. + // \sa Camera::SetMaterial(const MaterialPtr &) + public: virtual void SetMaterial( + const MaterialPtr &_material) override; + + // Documentation inherited. + public: virtual unsigned int RenderTextureGLId() const override; + + // Documentation inherited. + public: void SetShadowsDirty() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + public: Ogre::Camera *OgreCamera() const; + + // Documentation inherited. + public: virtual void SetVisibilityMask(uint32_t _mask) override; + + /// \brief Get the selection buffer object + /// \return the selection buffer object + public: Ogre2SelectionBuffer *SelectionBuffer() const; + + // Documentation inherited. + protected: virtual RenderTargetPtr RenderTarget() const override; + + // Documentation inherited. + protected: virtual void Init() override; + + /// \brief Create a render texture for the camera for offscreen rendering + protected: virtual void CreateRenderTexture(); + + /// \brief Destroy render texture created by CreateRenderTexture() + /// Note: It's not virtual. + protected: void DestroyRenderTexture(); + + /// \brief Create and set selection buffer object + /// TODO(anyone) to be implemented + protected: virtual void SetSelectionBuffer(); + + /// \brief Create internal camera object + private: void CreateCamera(); + + /// \brief Notifies us that the shadow node definition is about to be + /// updated. This means our compositor workspace must be destroyed + /// because the shadow node definition it's using will become a + /// dangling pointer otherwise + /// \sa SetShadowsDirty + private: void SetShadowsNodeDefDirty(); + + /// \brief Pointer to ogre camera object + protected: Ogre::Camera *ogreCamera = nullptr; + + /// \brief Selection buffer object for entity picking + protected: Ogre2SelectionBuffer *selectionBuffer = nullptr; + + /// \brief Pointer to render texture + protected: Ogre2RenderTargetPtr renderTexture; + + /// \brief Color of background + protected: math::Color backgroundColor; + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + + /// \brief Make scene our friend so it can create a camera + private: friend class Ogre2Scene; + + /// \brief Make ray query our friend so it can use the internal ogre + /// camera to execute queries + private: friend class Ogre2RayQuery; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Capsule.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Capsule.hh new file mode 100644 index 000000000..8832c012a --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Capsule.hh @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE2_OGRE2CAPSULE_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2CAPSULE_HH_ + +#include +#include + +#include "ignition/rendering/base/BaseCapsule.hh" +#include "ignition/rendering/ogre2/Ogre2Geometry.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // Forward declaration + class Ogre2CapsulePrivate; + + /// \brief Ogre 2.x implementation of a Capsule Geometry. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Capsule + : public BaseCapsule + { + /// \brief Constructor + protected: Ogre2Capsule(); + + /// \brief Destructor + public: virtual ~Ogre2Capsule(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void + SetMaterial(MaterialPtr _material, bool _unique) override; + + /// \brief Update the capsule geometry in ogre + private: void Update(); + + /// \brief Capsule should only be created by scene. + private: friend class Ogre2Scene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Conversions.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Conversions.hh new file mode 100644 index 000000000..1b7afbc44 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Conversions.hh @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2CONVERSIONS_HH_ +#define GZ_RENDERING_OGRE2_OGRE2CONVERSIONS_HH_ + +#include +#include +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/ogre2/Export.hh" + +#ifdef _MSC_VER + #pragma warning(push, 0) +#endif + +#include +#include +#include + +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \addtogroup ign_rendering + /// \{ + + /// \brief Conversions Conversions.hh rendering/Conversions.hh + /// \brief A set of utility function to convert between Ignition and Ogre + /// data types + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Conversions + { + /// \brief Return the equivalent ogre color + /// \param[in] _color ign-math color to convert + /// \return Ogre color value + public: static Ogre::ColourValue Convert( + const math::Color &_color); + + /// \brief Return the equivalent ign-math color + /// \param[in] _color Ogre color to convert + /// \return ign-math color value + public: static math::Color Convert( + const Ogre::ColourValue &_color); + + /// \brief return Ogre Vector from ign-math Vector3 + /// \param[in] _vector ign-math vector + /// \return Ogre vector + public: static Ogre::Vector3 Convert(const math::Vector3d &_vector); + + /// \brief return ign-math Vector from ogre Vector3 + /// \param[in] _vector Ogre vector + /// \return ign-math vector + public: static math::Vector3d Convert(const Ogre::Vector3 &_vector); + + /// \brief Ign-math quaternion to Ogre quaternion + /// \param[in] _quat ign-math quaternion + /// \return Ogre quaternion + public: static Ogre::Quaternion Convert(const math::Quaterniond &_quat); + + /// \brief Ogre quaternion to ign-math quaternion + /// \param[in] _quat Ogre quaternion + /// return ign-math quaternion + public: static math::Quaterniond Convert(const Ogre::Quaternion &_quat); + + /// \brief Ign-math angle to Ogre angle + /// \param[in] _angle ign-math angle + /// \return Ogre angle + public: static Ogre::Radian Convert(const math::Angle &_angle); + + /// \brief Ogre angle to ign-math angle + /// \param[in] _angle Ogre angle + /// return Ign-math angle + public: static math::Angle Convert(const Ogre::Radian &_angle); + + /// \brief Ogre Matrix4 to ignition math Matrix4d + /// \param[in] _m Ogre Matrix4 + /// \return ignition math Matrix4d + public: static math::Matrix4d Convert(const Ogre::Matrix4 &_m); + + /// \brief Ignition math Matrix4d to Ogre Matrix4 + /// \param[in] _m ignition math Matrix4d + /// \return Ogre Matrix4 + public: static Ogre::Matrix4 Convert(const math::Matrix4d &_m); + + /// \brief Ign-rendering PixelFormat to Ogre PixelFormat + /// \param[in] _format Ign-rendering PixelFormat + /// return Ogre PixelFormat + public: static Ogre::PixelFormatGpu Convert(PixelFormat _format); + + /// \brief A list of ogre pixel formats + private: static const Ogre::PixelFormatGpu ogrePixelFormats[PF_COUNT]; + }; + /// \} + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2DepthCamera.hh b/ogre2/include/gz/rendering/ogre2/Ogre2DepthCamera.hh new file mode 100644 index 000000000..458b7ef6a --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2DepthCamera.hh @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE2_OGRE2DEPTHCAMERA_HH_ +#define GZ_RENDERING_OGRE2_OGRE2DEPTHCAMERA_HH_ + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +#include +#include + +#include "gz/rendering/base/BaseDepthCamera.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" + +#include "gz/common/Event.hh" +#include "gz/common/Console.hh" + +namespace Ogre +{ + class Material; + class RenderTarget; + class Texture; + class Viewport; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2DepthCameraPrivate; + + /// \brief Depth camera used to render depth data into an image buffer + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DepthCamera : + public BaseDepthCamera + { + /// \brief Constructor + protected: Ogre2DepthCamera(); + + /// \brief Destructor + public: virtual ~Ogre2DepthCamera(); + + /// \brief Initialize the camera + public: virtual void Init() override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Create dummy render texture. Needed to satisfy inheritance + public: virtual void CreateRenderTexture(); + + /// \brief Create a texture which will hold the depth data + /// \brief Set up 1st pass material, texture, and compositor + public: virtual void CreateDepthTexture() override; + + /// \brief Creates an Ogre Workspace instance. Assumes the definition + /// already and the depth texture have already been created + private: void CreateWorkspaceInstance(); + + // Documentation inherited + public: virtual void PreRender() override; + + /// \brief Render the camera + public: virtual void PostRender() override; + + /// \brief All things needed to get back z buffer for depth data + /// \return The z-buffer as a float array + public: virtual const float *DepthData() const override; + + /// \brief Connect a to the new depth image signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewDepthFrame( + std::function _subscriber) override; + + /// \brief Connect a to the new rgb point cloud signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewRgbPointCloud( + std::function _subscriber) override; + + /// \brief Implementation of the render call + public: virtual void Render() override; + + /// \brief Set the far clip distance + /// \param[in] _far far clip distance + public: virtual void SetFarClipPlane(const double _far) override; + + /// \brief Set the near clip distance + /// \param[in] _near Near clip distance + public: virtual void SetNearClipPlane(const double _near) override; + + /// \brief Get the near clip distance + /// \return Near clip distance. A value of zero is returned if the + /// ogre camera has not been created. + public: double NearClipPlane() const override; + + /// \brief Get the far clip distance + /// \return Far clip distance. A value of zero is returned if the + /// ogre camera has not been created. + public: double FarClipPlane() const override; + + // Documentation inherited. + public: void SetShadowsDirty() override; + + // Documentation inherited. + public: void AddRenderPass(const RenderPassPtr &_pass) override; + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Limit field of view taking care of using a valid value for + /// an OGRE camera. + /// \param[in] _fov expected field of view + /// \return valid field of view + protected: static double LimitFOV(const double _fov); + + /// \brief Create the camera. + protected: void CreateCamera(); + + /// \brief Notifies us that the shadow node definition is about to be + /// updated. This means our compositor workspace must be destroyed + /// because the shadow node definition it's using will become a + /// dangling pointer otherwise + /// \sa SetShadowsDirty + private: void SetShadowsNodeDefDirty(); + + /// \brief Pointer to the ogre camera + protected: Ogre::Camera *ogreCamera; + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2DynamicRenderable.hh b/ogre2/include/gz/rendering/ogre2/Ogre2DynamicRenderable.hh new file mode 100644 index 000000000..d74e032bc --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2DynamicRenderable.hh @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_OGRE2_OGRE2DYNAMICRENDERABLE_HH_ +#define GZ_RENDERING_OGRE2_OGRE2DYNAMICRENDERABLE_HH_ + +#include +#include +#include + +#include "gz/rendering/ogre2/Export.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/Marker.hh" + +#ifdef _MSC_VER + #pragma warning(push, 0) +#endif +#include +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations + class Ogre2DynamicRenderablePrivate; + + /* \class Ogre2DynamicRenderable Ogre2DynamicRenderable.hh \ + * ignition/rendering/ogre2/Ogre2DynamicRenderable.hh + */ + /// \brief Dynamic renderable class that manages hardware buffers for + /// a dynamic geometry + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DynamicRenderable + { + /// \brief Constructor + /// \param[in] _scene Pointer to scene + public: explicit Ogre2DynamicRenderable(ScenePtr _scene); + + /// \brief Virtual destructor + public: virtual ~Ogre2DynamicRenderable(); + + /// \brief Set the render operation type + /// \param[in] _opType The type of render operation to perform. + public: void SetOperationType(MarkerType _opType); + + /// \brief Get the render operation type + /// \return The render operation type. + public: MarkerType OperationType() const; + + /// \brief Update the dynamic renderable + public: void Update(); + + /// \brief Get the ogre object associated with this dynamic renderable + public: Ogre::MovableObject *OgreObject() const; + + /// \brief Add a point to the point list + /// \param[in] _pt gz::math::Vector3d point + /// \param[in] _color gz::math::Color Point color + public: void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color = gz::math::Color::White); + + /// \brief Add a point to the point list. + /// \param[in] _x X position + /// \param[in] _y Y position + /// \param[in] _z Z position + /// \param[in] _color Point color + public: void AddPoint(const double _x, const double _y, const double _z, + const gz::math::Color &_color = gz::math::Color::White); + + /// \brief Change the location of an existing point in the point list + /// \param[in] _index Index of the point to set + /// \param[in] _value Position of the point + public: void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value); + + /// \brief Change the color of an existing point in the point list + /// \param[in] _index Index of the point to set + /// \param[in] _color color to set the point to + public: void SetColor(unsigned int _index, + const gz::math::Color &_color); + + /// \brief Return the position of an existing point in the point list + /// \param[in] _index Get the point at this index + /// \return position of point. A vector of + /// [gz::math::INF_D, gz::math::INF_D, gz::math::INF_D] + /// is returned when then the _index is out of bounds. + /// gz::math::INF_D==std::numeric_limits::infinity() + public: gz::math::Vector3d Point(unsigned int _index) const; + + /// \brief Return the total number of points in the point list + /// \return Number of points + public: unsigned int PointCount() const; + + /// \brief Remove all points from the point list + public: void Clear(); + + /// \brief Destroy the dynamic renderable + public: void Destroy(); + + /// \brief Set the material for this dynamic renderable + /// \param[in] _material New Material to be assigned + /// \param[in] _unique True if the given material should be cloned + public: void SetMaterial(MaterialPtr _material, bool _unique = true); + + /// \brief Create the dynamic mesh + private: void CreateDynamicMesh(); + + /// \brief Update vertex buffer if vertices have changes + private: void UpdateBuffer(); + + /// \brief Helper function to generate normals + /// \param[in] _opType Ogre render operation type + /// \param[in] _vertices a list of vertices + /// \param[in,out] _vbuffer vertex buffer to be filled + private: void GenerateNormals(Ogre::OperationType _opType, + const std::vector &_vertices, float *_vbuffer); + + /// \brief Destroy the vertex buffer + private: void DestroyBuffer(); + + /// \brief Pointer to private data + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2GaussianNoisePass.hh b/ogre2/include/gz/rendering/ogre2/Ogre2GaussianNoisePass.hh new file mode 100644 index 000000000..7ec7a2b63 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2GaussianNoisePass.hh @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2GAUSSIANNOISEPASS_HH_ +#define GZ_RENDERING_OGRE2_OGRE2GAUSSIANNOISEPASS_HH_ + +#include + +#include "gz/rendering/base/BaseGaussianNoisePass.hh" +#include "gz/rendering/ogre2/Ogre2RenderPass.hh" +#include "gz/rendering/ogre2/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2GaussianNoisePassPrivate; + + /* \class Ogre2GaussianNoisePass Ogre2GaussianNoisePass.hh \ + * ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh + */ + /// \brief Ogre2 Implementation of a Gaussian noise render pass. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2GaussianNoisePass : + public BaseGaussianNoisePass + { + /// \brief Constructor + public: Ogre2GaussianNoisePass(); + + /// \brief Destructor + public: virtual ~Ogre2GaussianNoisePass(); + + // Documentation inherited + public: void PreRender() override; + + // Documentation inherited + public: void CreateRenderPass() override; + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Geometry.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Geometry.hh new file mode 100644 index 000000000..04f2e2b9b --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Geometry.hh @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2GEOMETRY_HH_ +#define GZ_RENDERING_OGRE2_OGRE2GEOMETRY_HH_ + +#include "gz/rendering/base/BaseGeometry.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre2.x implementation of the geometry class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Geometry : + public BaseGeometry + { + /// \brief Constructor + protected: Ogre2Geometry(); + + /// \brief Destructor + public: virtual ~Ogre2Geometry(); + + // Documentation inherited. + public: virtual bool HasParent() const override; + + // Documentation inherited. + public: virtual VisualPtr Parent() const override; + + /// \brief Get the ogre object representing this geometry + /// \return Pointer to an ogre movable object + public: virtual Ogre::MovableObject *OgreObject() const = 0; + + /// \brief Set the parent of this ogre geometry + /// \param[in] _parent Parent visual + protected: virtual void SetParent(Ogre2VisualPtr _parent); + + /// \brief Parent visual + protected: Ogre2VisualPtr parent; + + /// \brief Make ogre2 visual our friend so it can it can access function + /// for setting the parent of this geometry + private: friend class Ogre2Visual; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2GizmoVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2GizmoVisual.hh new file mode 100644 index 000000000..149c06d90 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2GizmoVisual.hh @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2GIZMOVISUAL_HH_ +#define GZ_RENDERING_OGRE2_OGRE2GIZMOVISUAL_HH_ + +#include "gz/rendering/base/BaseGizmoVisual.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2GizmoVisual : + public BaseGizmoVisual + { + /// \brief Constructor + protected: Ogre2GizmoVisual(); + + /// \brief Destructor + public: virtual ~Ogre2GizmoVisual(); + + /// \brief Only the ogre scene can instanstiate this class + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2GpuRays.hh b/ogre2/include/gz/rendering/ogre2/Ogre2GpuRays.hh new file mode 100644 index 000000000..237712e75 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2GpuRays.hh @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE2_OGRE2GPURAYS_HH_ +#define GZ_RENDERING_OGRE2_OGRE2GPURAYS_HH_ + +#include +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/base/BaseGpuRays.hh" +#include "gz/rendering/ogre2/Export.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" + +#include "gz/common/Event.hh" +#include "gz/common/Console.hh" + +namespace Ogre +{ + class Material; + class RenderTarget; + class Texture; + class Viewport; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2GpuRaysPrivate; + + /// \brief Gpu Rays used to render range data into an image buffer + /// The ogre2 implementation takes a 2 pass process to generate + /// the final range data. + /// 1st Pass: Creates a cubemap of range data. The cubemap is created from + /// six cameras looking in all directions. Depending on the min/max angles + /// specified, not all cameras need to be created. Internally in the 1st + /// pass shaders, we reconstruct 3d viewspace pos from depth buffer data + /// then convert them into ranges, i.e. length(pos.xyz). + /// 2nd Pass: Samples range data from cubemap using predefined rays. The + /// rays are generated based on the specified vertical and horizontal + /// min/max angles and no. of samples. Each ray is a direction vector that + /// is used to sample/lookup the range data stored in the faces of the + /// cubemap. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2GpuRays : + public BaseGpuRays + { + /// \brief Constructor + protected: Ogre2GpuRays(); + + /// \brief Destructor + public: virtual ~Ogre2GpuRays(); + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Create dummy render texture. Needed to satisfy inheritance + public: virtual void CreateRenderTexture(); + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void PostRender() override; + + // Documentation inherited + public: virtual const float *Data() const override; + + // Documentation inherited. + public: virtual void Copy(float *_data) override; + + // Documentation inherited. + public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( + std::function _subscriber) override; + + // Documentation inherited. + public: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Set the number of samples in the width and height for the + /// first pass texture. + /// \param[in] _w Number of samples in the horizontal sweep + /// \param[in] _h Number of samples in the vertical sweep + private: virtual void Set1stTextureSize(const unsigned int _w, + const unsigned int _h = 1); + + /// \brief Set the number of samples in the width and height for the + /// second pass texture. + /// \param[in] _w Number of samples in the horizontal sweep + /// \param[in] _h Number of samples in the vertical sweep + private: virtual void SetRangeCount(const unsigned int _w, + const unsigned int _h = 1); + + // Documentation inherited. + private: virtual void Render() override; + + /// \brief Configure camera. + private: void ConfigureCamera(); + + /// \brief Create an ortho camera. + private: void CreateCamera(); + + /// \brief Create the texture which is used to render gpu rays data. + private: virtual void CreateGpuRaysTextures(); + + /// \brief Update the render targets in the 1st pass + private: void UpdateRenderTarget1stPass(); + + /// \brief Update the 2nd pass render target + private: void UpdateRenderTarget2ndPass(); + + /// \brief Create texture that store cubemap uv coordinates and + /// cubemap face index data + private: void CreateSampleTexture(); + + /// \brief Set up 1st pass material, texture, and compositor + private: void Setup1stPass(); + + /// \brief Set up 2nd pass material, texture, and compositor + private: void Setup2ndPass(); + + /// \brief Helper function to convert a direction vector to the + /// index number of a cubemap face and texture uv coordinates on that face + /// \param[in] _v Direction vector + /// \param[out] _faceIndex Index of face to sample + /// \return Texture UV coordinates on the face indicated by _faceIndex + private: math::Vector2d SampleCubemap(const math::Vector3d &_v, + unsigned int &_faceIndex); + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + /// \brief Only the scene can create a GpuRays sensor + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Grid.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Grid.hh new file mode 100644 index 000000000..dab992c6b --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Grid.hh @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE2_OGRE2GRID_HH_ +#define GZ_RENDERING_OGRE2_OGRE2GRID_HH_ + +#include +#include "gz/rendering/base/BaseGrid.hh" +#include "gz/rendering/ogre2/Ogre2Geometry.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2GridPrivate; + + /// \brief Ogre2 implementation of a grid geometry. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Grid + : public BaseGrid + { + /// \brief Constructor + protected: Ogre2Grid(); + + /// \brief Destructor + public: virtual ~Ogre2Grid(); + + // Documentation inherited. + public: virtual void Init(); + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const; + + // Documentation inherited. + public: virtual void PreRender(); + + // Documentation inherited. + public: virtual MaterialPtr Material() const; + + // Documentation inherited. + public: virtual void SetMaterial(MaterialPtr _material, bool _unique); + + /// \brief Set material to grid geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); + + /// \brief Create the grid geometry in ogre + private: void Create(); + + /// \brief Grid should only be created by scene. + private: friend class Ogre2Scene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Heightmap.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Heightmap.hh new file mode 100644 index 000000000..cd214addb --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Heightmap.hh @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE2_OGRE2HEIGHTMAP_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2HEIGHTMAP_HH_ + +#include + +#include "ignition/rendering/base/BaseHeightmap.hh" +#include "ignition/rendering/ogre2/Ogre2Geometry.hh" + +// Ignoring warning: "non dll-interface class +// 'ignition::rendering::v5::Heightmap' used as base for dll-interface class" +// because `Heightmap` and `BaseHeightmap` are header-only +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4275) +#endif + +namespace Ogre +{ + class Camera; + class Terra; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2HeightmapPrivate; + + /// \brief Ogre implementation of a heightmap geometry. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Heightmap + : public BaseHeightmap + { + /// \brief Constructor + /// \param[in] _desc Parameters describing how a + /// heightmap should be loaded + public: explicit Ogre2Heightmap(const HeightmapDescriptor &_desc); + + /// \brief Destructor + public: virtual ~Ogre2Heightmap() override; + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + /// \brief Returns the Terra pointer as it is a movable object that + /// must be attached to a regular SceneNode + /// \remarks This behavior is different from ogre1 + /// \return Terra pointer + public: virtual Ogre::MovableObject *OgreObject() const override; + + /// \brief Returns NULL, heightmap materials don't inherit from + /// MaterialPtr. + /// \return Null pointer. + public: virtual MaterialPtr Material() const override; + + /// \brief Has no effect for heightmaps. The material is set through a + /// HeightmapDescriptor. + /// \param[in] _material Not used. + /// \param[in] _unique Not used. + public: virtual void SetMaterial(MaterialPtr _material, bool _unique) + override; + + /// \internal + /// \brief Retrieves the internal Terra pointer + /// \return internal Terra pointer + public: Ogre::Terra* Terra(); + + /// \internal + /// \brief Must be called before rendering with the camera + /// that will perform rendering. + /// + /// May update shadows if light direction changed + /// \param[in] _activeCamera Camera about to be used for rendering + public: void UpdateForRender(Ogre::Camera *_activeCamera); + + // Documentation inherited. + // \todo(iche033) rename this to Destroy and + // make this function public and virtual + private: void DestroyImpl(); + + /// \brief Heightmap should only be created by scene. + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh new file mode 100644 index 000000000..f5c04839b --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2INCLUDES_HH_ +#define GZ_RENDERING_OGRE2_OGRE2INCLUDES_HH_ + +// This disables warning messages for OGRE +#ifndef _MSC_VER + #pragma GCC system_header +#else + #pragma warning(push, 0) +#endif + +// This prevents some deprecation #warning messages on OSX 10.9 +#pragma clang diagnostic ignored "-W#warnings" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +// TODO(anyone): enable when ogre 2.1 fully supports paging +// and terrain components +// #include +// #include +// #include +// #include +// #include +// #include + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2InertiaVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2InertiaVisual.hh new file mode 100644 index 000000000..c15a2b112 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2InertiaVisual.hh @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2INERTIAVISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2INERTIAVISUAL_HH_ + +#include + +#include "ignition/rendering/base/BaseInertiaVisual.hh" +#include "ignition/rendering/ogre2/Ogre2Visual.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + // Forward declaration + class Ogre2InertiaVisualPrivate; + + /// \brief Ogre2.x implementation of the inertia visual class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2InertiaVisual : + public BaseInertiaVisual + { + /// \brief Constructor + protected: Ogre2InertiaVisual(); + + /// \brief Destructor + public: virtual ~Ogre2InertiaVisual(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + protected: virtual void Destroy() override; + + /// \brief Load the Inertia visual from its pose and scale + /// \param[in] _pose Pose of the Inertia visual + /// \param[in] _scale Scale factor of the box visual + public: void Load(const ignition::math::Pose3d &_pose, + const ignition::math::Vector3d &_scale) override; + + /// \brief Get the box visual + /// \return Pointer to the box visual + public: VisualPtr BoxVisual() const override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial( + MaterialPtr _material, bool _unique) override; + + /// \brief Set material to line geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); + + private: friend class Ogre2Scene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2JointVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2JointVisual.hh new file mode 100644 index 000000000..4a7879384 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2JointVisual.hh @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2JOINTVISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2JOINTVISUAL_HH_ + +#include "ignition/rendering/base/BaseJointVisual.hh" +#include "ignition/rendering/ogre2/Ogre2Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2JointVisual : + public BaseJointVisual + { + /// \brief Constructor + protected: Ogre2JointVisual(); + + /// \brief Destructor + public: virtual ~Ogre2JointVisual(); + + /// \brief Only scene can instantiate this class + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2LidarVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2LidarVisual.hh new file mode 100644 index 000000000..8a3877496 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2LidarVisual.hh @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE2_OGRELIDARVISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRELIDARVISUAL_HH_ + +#include +#include +#include "ignition/rendering/base/BaseLidarVisual.hh" +#include "ignition/rendering/ogre2/Ogre2Visual.hh" +#include "ignition/rendering/ogre2/Ogre2Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2LidarVisualPrivate; + + /// \brief Ogre 2.x implementation of a Lidar Visual. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2LidarVisual + : public BaseLidarVisual + { + /// \brief Constructor + protected: Ogre2LidarVisual(); + + /// \brief Destructor + public: virtual ~Ogre2LidarVisual(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual void Update() override; + + // Documentation inherited + public: virtual void SetPoints( + const std::vector &_points) override; + + // Documentation inherited + public: virtual void ClearPoints() override; + + // Documentation inherited + public: virtual unsigned int PointCount() const override; + + // Documentation inherited + public: virtual std::vector Points() const override; + + /// \brief Create the Lidar Visual in ogre + private: void Create(); + + /// \brief Clear data stored by dynamiclines + private: void ClearVisualData(); + + // Documentation inherited + public: virtual void SetVisible(bool _visible) override; + + /// \brief Lidar Visual should only be created by scene. + private: friend class Ogre2Scene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Light.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Light.hh new file mode 100644 index 000000000..85eff319e --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Light.hh @@ -0,0 +1,216 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2LIGHT_HH_ +#define GZ_RENDERING_OGRE2_OGRE2LIGHT_HH_ + +#include + +#include "gz/rendering/base/BaseLight.hh" +#include "gz/rendering/ogre2/Ogre2Node.hh" + +#ifdef _MSC_VER + #pragma warning(push, 0) +#endif +#include +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +namespace Ogre +{ + class Light; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2LightPrivate; + + /// \brief Ogre 2.x implementation of the light class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Light : + public BaseLight + { + /// \brief Constructor + protected: Ogre2Light(); + + /// \brief Destructor + public: virtual ~Ogre2Light(); + + // Documentation Inherited + public: virtual math::Color DiffuseColor() const override; + + // Documentation Inherited + public: virtual void SetDiffuseColor(const math::Color &_color) override; + + // Documentation Inherited + public: virtual math::Color SpecularColor() const override; + + // Documentation Inherited + public: virtual void SetSpecularColor(const math::Color &_color) override; + + // Documentation Inherited + public: virtual double AttenuationConstant() const override; + + // Documentation Inherited + public: virtual void SetAttenuationConstant(double _value) override; + + // Documentation Inherited + public: virtual double AttenuationLinear() const override; + + // Documentation Inherited + public: virtual void SetAttenuationLinear(double _value) override; + + // Documentation Inherited + public: virtual double AttenuationQuadratic() const override; + + // Documentation Inherited + public: virtual void SetAttenuationQuadratic(double _value) override; + + // Documentation Inherited + public: virtual double AttenuationRange() const override; + + // Documentation Inherited + public: virtual void SetAttenuationRange(double _range) override; + + // Documentation Inherited + public: virtual bool CastShadows() const override; + + // Documentation Inherited + public: virtual void SetCastShadows(bool _castShadows) override; + + // Documentation Inherited + public: virtual double Intensity() const override; + + // Documentation Inherited + public: virtual void SetIntensity(double _intensity) override; + + /// \brief Get a pointer to ogre light + public: virtual Ogre::Light *Light() const; + + /// \brief Destroy the light + public: virtual void Destroy() override; + + /// \brief Initialize the light + protected: virtual void Init() override; + + /// \brief Create the light + private: void CreateLight(); + + /// \brief Update the attenuation based on the values specified. + private: void UpdateAttenuation(); + + /// \brief Attenuation constant value + protected: double attenConstant = 1.0; + + /// \brief Attenuation linear factor + protected: double attenLinear = 0.0; + + /// \brief Attenuation quadratic factor + protected: double attenQuadratic = 0.0; + + /// \brief Attenuation range + protected: double attenRange = 100.0; + + /// \brief Pointer to ogre light + protected: Ogre::Light *ogreLight = nullptr; + + /// \brief Light type + protected: Ogre::Light::LightTypes ogreLightType; + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + }; + + /// \brief Ogre 2.x implementation of the directional light class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DirectionalLight : + public BaseDirectionalLight + { + /// \brief Constructor + protected: Ogre2DirectionalLight(); + + /// \brief Destructor + public: virtual ~Ogre2DirectionalLight(); + + // Documentation Inherited + public: virtual math::Vector3d Direction() const override; + + // Documentation Inherited + public: virtual void SetDirection(const math::Vector3d &_dir) override; + + /// \brief Ogre 2.x implementation of the directional light class + private: friend class Ogre2Scene; + }; + + /// \brief Ogre 2.x implementation of the point light class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2PointLight : + public BasePointLight + { + /// \brief Constructor + protected: Ogre2PointLight(); + + /// \brief Destructor + public: virtual ~Ogre2PointLight(); + + /// \brief Only an ogre scene can create an ogre point light + private: friend class Ogre2Scene; + }; + + /// \brief Ogre 2.x implementation of the spot light class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SpotLight : + public BaseSpotLight + { + /// \brief Constructor + protected: Ogre2SpotLight(); + + /// \brief Destructor + public: virtual ~Ogre2SpotLight(); + + // Documentation inherited. + public: virtual math::Vector3d Direction() const override; + + // Documentation Inherited + public: virtual void SetDirection(const math::Vector3d &_dir) override; + + // Documentation Inherited + public: virtual math::Angle InnerAngle() const override; + + // Documentation Inherited + public: virtual void SetInnerAngle(const math::Angle &_angle) override; + + // Documentation Inherited + public: virtual math::Angle OuterAngle() const override; + + // Documentation Inherited + public: virtual void SetOuterAngle(const math::Angle &_angle) override; + + // Documentation Inherited + public: virtual double Falloff() const override; + + // Documentation Inherited + public: virtual void SetFalloff(double _falloff) override; + + /// \brief Only an ogre scene can create an ogre spot light + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2LightVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2LightVisual.hh new file mode 100644 index 000000000..b1bd2281b --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2LightVisual.hh @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2LIGHTVISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2LIGHTVISUAL_HH_ + +#include + +#include "ignition/rendering/base/BaseLightVisual.hh" +#include "ignition/rendering/ogre2/Ogre2Visual.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + // Forward declaration + class Ogre2LightVisualPrivate; + + /// \brief Ogre2.x implementation of the light visual class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2LightVisual : + public BaseLightVisual + { + /// \brief Constructor + protected: Ogre2LightVisual(); + + /// \brief Destructor + public: virtual ~Ogre2LightVisual(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: Ogre::MovableObject *OgreObject() const; + + /// \brief Create the Light Visual in Ogre2 + public: void CreateVisual(); + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial( + MaterialPtr _material, bool _unique) override; + + /// \brief Set material to grid geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); + + /// \brief Only scene can instantiate an arrow visual + private: friend class Ogre2Scene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Marker.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Marker.hh new file mode 100644 index 000000000..690065285 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Marker.hh @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE2_OGREMARKER_HH_ +#define GZ_RENDERING_OGRE2_OGREMARKER_HH_ + +#include +#include "gz/rendering/base/BaseMarker.hh" +#include "gz/rendering/ogre2/Ogre2Geometry.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2MarkerPrivate; + + /// \brief Ogre 2.x implementation of a marker geometry. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Marker + : public BaseMarker + { + /// \brief Constructor + protected: Ogre2Marker(); + + /// \brief Destructor + public: virtual ~Ogre2Marker(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial( + MaterialPtr _material, bool _unique) override; + + // Documentation inherited + public: virtual void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value) override; + + // Documentation inherited + public: virtual void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color) override; + + // Documentation inherited + public: virtual void ClearPoints() override; + + // Documentation inherited + public: virtual void SetType(const MarkerType _markerType) override; + + // Documentation inherited + public: virtual MarkerType Type() const override; + + /// \brief Create the marker geometry in ogre + private: void Create(); + + /// \brief Marker should only be created by scene. + private: friend class Ogre2Scene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Material.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Material.hh new file mode 100644 index 000000000..b570b4884 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Material.hh @@ -0,0 +1,345 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2MATERIAL_HH_ +#define GZ_RENDERING_OGRE2_OGRE2MATERIAL_HH_ + +#include +#include + +#include "gz/rendering/base/BaseMaterial.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" + +#ifdef _MSC_VER + #pragma warning(push, 0) +#endif +#include +#include +#include +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +namespace Ogre +{ + class HlmsPbsDatablock; + class HlmsUnlitDatablock; +} // namespace Ogre + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2MaterialPrivate; + + /// \brief Ogre 2.x implementation of the material class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Material : + public BaseMaterial + { + /// \brief Constructor + protected: Ogre2Material(); + + /// \brief Destructor + public: virtual ~Ogre2Material(); + + // Documentation inherited + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual math::Color Diffuse() const override; + + // Documentation inherited + public: virtual void SetDiffuse(const math::Color &_color) override; + + // Documentation inherited + public: virtual math::Color Specular() const override; + + // Documentation inherited + public: virtual void SetSpecular(const math::Color &_color) override; + + // Documentation inherited + public: virtual math::Color Emissive() const override; + + // Documentation inherited + public: virtual void SetEmissive(const math::Color &_color) override; + + // Documentation inherited + public: virtual void SetTransparency(const double _transparency) override; + + // Documentation inherited + public: virtual void SetAlphaFromTexture(bool _enabled, + double _alpha = 0.5, bool _twoSided = true) override; + + // Documentation inherited + public: virtual float RenderOrder() const override; + + // Documentation inherited + // Review the official documentation to get more details about this + // parameter, in particular mDepthBiasConstant + public: virtual void SetRenderOrder(const float _renderOrder) override; + + // Documentation inherited + public: virtual bool ReceiveShadows() const override; + + // Documentation inherited + public: virtual void SetReceiveShadows(const bool _receiveShadows) + override; + + // Documentation inherited + public: virtual bool HasTexture() const override; + + // Documentation inherited + public: virtual std::string Texture() const override; + + // Documentation inherited + public: virtual void SetTexture(const std::string &_texture) override; + + // Documentation inherited + public: virtual void ClearTexture() override; + + // Documentation inherited + public: virtual bool HasNormalMap() const override; + + // Documentation inherited + public: virtual std::string NormalMap() const override; + + // Documentation inherited + public: virtual void SetNormalMap(const std::string &_normalMap) override; + + // Documentation inherited + public: virtual void ClearNormalMap() override; + + // Documentation inherited + public: virtual bool HasRoughnessMap() const override; + + // Documentation inherited + public: virtual std::string RoughnessMap() const override; + + // Documentation inherited + public: virtual void SetRoughnessMap( + const std::string &_roughnessMap) override; + + // Documentation inherited + public: virtual void ClearRoughnessMap() override; + + // Documentation inherited + public: virtual bool HasMetalnessMap() const override; + + // Documentation inherited + public: virtual std::string MetalnessMap() const override; + + // Documentation inherited + public: virtual void SetMetalnessMap( + const std::string &_metalnessMap) override; + + // Documentation inherited + public: virtual void ClearMetalnessMap() override; + + // Documentation inherited + public: virtual bool HasEnvironmentMap() const override; + + // Documentation inherited + public: virtual std::string EnvironmentMap() const override; + + // Documentation inherited + public: virtual void SetEnvironmentMap( + const std::string &_metalnessMap) override; + + // Documentation inherited + public: virtual void ClearEnvironmentMap() override; + + // Documentation inherited + public: virtual void SetRoughness(const float _roughness) override; + + // Documentation inherited + public: virtual bool HasEmissiveMap() const override; + + // Documentation inherited + public: virtual std::string EmissiveMap() const override; + + // Documentation inherited + public: virtual void SetEmissiveMap( + const std::string &_emissiveMap) override; + + // Documentation inherited + public: virtual void ClearEmissiveMap() override; + + // Documentation inherited + public: virtual bool HasLightMap() const override; + + // Documentation inherited + public: virtual std::string LightMap() const override; + + // Documentation inherited + public: virtual unsigned int LightMapTexCoordSet() const override; + + // Documentation inherited + public: virtual void SetLightMap(const std::string &_lightMap, + unsigned int _uvSet = 0u) override; + + // Documentation inherited + public: virtual void ClearLightMap() override; + + // Documentation inherited + public: virtual float Roughness() const override; + + // Documentation inherited + public: virtual void SetMetalness(const float _roughness) override; + + // Documentation inherited + public: virtual float Metalness() const override; + + /// \brief Return ogre low level material + /// \return Ogre material pointer + public: virtual Ogre::MaterialPtr Material(); + + /// \brief Return ogre Hlms material pbs datablock + /// \return Ogre Hlms pbs datablock + public: virtual Ogre::HlmsPbsDatablock *Datablock() const; + + /// \brief Return ogre Hlms material unlit datablock + /// \return Ogre Hlms unlit datablock + public: virtual Ogre::HlmsUnlitDatablock *UnlitDatablock(); + + /// \brief Fill the input unlit datablock with current material + /// properties from the pbs datablock + /// \param[in] _datablock Unlit datablock to fill + public: virtual void FillUnlitDatablock( + Ogre::HlmsUnlitDatablock *_datablock) const; + + // Documentation inherited. + // \sa BaseMaterial::PreRender() + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual enum MaterialType Type() const override; + + // Documentation inherited + public: virtual bool DepthCheckEnabled() const override; + + // Documentation inherited + public: virtual void SetDepthCheckEnabled(bool _enabled) override; + + // Documentation inherited + public: virtual bool DepthWriteEnabled() const override; + + // Documentation inherited + public: virtual void SetDepthWriteEnabled(bool _enabled) override; + + // Documentation inherited. + // \sa Material::SetVertexShader(const std::string &) + public: virtual void SetVertexShader(const std::string &_path) override; + + // Documentation inherited. + // \sa Material::VertexShader() const + public: virtual std::string VertexShader() const override; + + // Documentation inherited. + // \sa Material::VertexShaderParams() + public: virtual ShaderParamsPtr VertexShaderParams() override; + + // Documentation inherited. + // \sa Material::SetFragmentShader(const std::string &) + public: virtual void SetFragmentShader(const std::string &_path) + override; + + // Documentation inherited. + // \sa Material::FragmentShader() const + public: virtual std::string FragmentShader() const override; + + // Documentation inherited. + // \sa Material::FragmentShaderParams() + public: virtual ShaderParamsPtr FragmentShaderParams() override; + + /// \brief Set the texture map for this material + /// \param[in] _texture Name of the texture. + /// \param[in] _type Type of texture, i.e. diffuse, normal, roughness, + /// metalness + protected: virtual void SetTextureMapImpl(const std::string &_texture, + Ogre::PbsTextureTypes _type); + + /// \brief Get a pointer to the ogre texture by name + /// \return Ogre texture + protected: virtual Ogre::TextureGpu *Texture(const std::string &_name); + + /// \brief Updates the material transparency in the engine, + /// based on transparency and diffuse alpha values + protected: virtual void UpdateTransparency(); + + // Documentation inherited. + protected: virtual void Init() override; + + /// \brief bind shader parameters that have changed + protected: void UpdateShaderParams(); + + /// \brief Transfer params from ign-rendering type to ogre type + /// \param[in] _params ignition rendering params + /// \param[out] _ogreParams ogre type for holding params + protected: void UpdateShaderParams(ConstShaderParamsPtr _params, + Ogre::GpuProgramParametersSharedPtr _ogreParams); + + /// \brief Ogre material. Mainly used for render targets. + protected: Ogre::MaterialPtr ogreMaterial; + + /// \brief Ogre data block containing all pbs material properties + protected: Ogre::HlmsPbsDatablock *ogreDatablock = nullptr; + + /// \brief Ogre data block containing all unlit material properties + protected: Ogre::HlmsUnlitDatablock *ogreUnlitDatablock = nullptr; + + /// \brief Ogre high level physical based shading object + protected: Ogre::HlmsPbs *ogreHlmsPbs = nullptr; + + /// \brief Name of the texture + protected: std::string textureName; + + /// \brief Name of the normal map + protected: std::string normalMapName; + + /// \brief Name of the roughness map + protected: std::string roughnessMapName; + + /// \brief Name of the metalness map + protected: std::string metalnessMapName; + + /// \brief Name of the environment map + protected: std::string environmentMapName; + + /// \brief Name of the emissive map + protected: std::string emissiveMapName; + + /// \brief Name of the light map + protected: std::string lightMapName; + + /// \brief Texture coorindate set used by the light map + protected: unsigned int lightMapUvSet = 0u; + + /// \brief Unique id assigned to ogre hlms datablock + protected: std::string ogreDatablockId; + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + + /// \brief Only an ogre scene can create an ogre material + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2MaterialSwitcher.hh b/ogre2/include/gz/rendering/ogre2/Ogre2MaterialSwitcher.hh new file mode 100644 index 000000000..a613917af --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2MaterialSwitcher.hh @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_ +#define GZ_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_ + +#include +#include + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre2/Export.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" + +#ifdef _MSC_VER + #pragma warning(push, 0) +#endif +#include +#include +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations + class Ogre2SelectionBuffer; + + /// \brief Helper class to assign unique colors to renderables + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2MaterialSwitcher : + public Ogre::Camera::Listener + { + /// \brief Constructor + public: explicit Ogre2MaterialSwitcher(Ogre2ScenePtr _scene); + + /// \brief Destructor + public: ~Ogre2MaterialSwitcher(); + + /// \brief Get the entity with a specific color + /// \param[in] _color The entity's color. + public: std::string EntityName( + const ignition::math::Color &_color) const; + + /// \brief Reset the color value incrementor + public: void Reset(); + + /// \brief Ogre's pre render update callback + /// \param[in] _cam Ogre render target event containing information about + /// the source render target. + public: virtual void cameraPreRenderScene( + Ogre::Camera *_cam) override; + + /// \brief Ogre's post render update callback + /// \param[in] _cam Ogre render target event containing information about + /// the source render target. + public: virtual void cameraPostRenderScene(Ogre::Camera *_cam) override; + + /// \brief Current unique color value + private: gz::math::Color currentColor; + + /// \brief Color dictionary that maps the unique color value to + /// renderable name + private: std::map colorDict; + + /// \brief A map of ogre sub item pointer to their original hlms material + private: std::map datablockMap; + + /// \brief Ogre v1 material consisting of a shader that changes the + /// appearance of item to use a unique color for mouse picking + private: Ogre::MaterialPtr plainMaterial; + + /// \brief Ogre v1 material consisting of a shader that changes the + /// appearance of item to use a unique color for mouse picking. In + /// addition, the depth check and depth write properties disabled. + private: Ogre::MaterialPtr plainOverlayMaterial; + + /// \brief Increment unique color value that will be assigned to the + /// next renderable + private: void NextColor(); + + /// \brief Selection Buffer class that make use of this class for + /// selecting entitiies + public: friend class Ogre2SelectionBuffer; + + /// \brief Plain material technique + private: Ogre2ScenePtr scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Mesh.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Mesh.hh new file mode 100644 index 000000000..ef3c8cd03 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Mesh.hh @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2MESH_HH_ +#define GZ_RENDERING_OGRE2_OGRE2MESH_HH_ + +#include +#include +#include +#include +#include +#include "gz/rendering/base/BaseMesh.hh" +#include "gz/rendering/ogre2/Ogre2Geometry.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" + +namespace Ogre +{ + class Item; + class SubItem; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2MeshPrivate; + class Ogre2SubMeshPrivate; + + /// \brief Ogre2.x implementation of the mesh class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Mesh : + public BaseMesh + { + /// \brief Constructor + protected: Ogre2Mesh(); + + /// \brief Destructor + public: virtual ~Ogre2Mesh(); + + // Documentation inherited + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual bool HasSkeleton() const override; + + // Documentation inherited. + public: virtual std::map + SkeletonLocalTransforms() const override; + + // Documentation inherited. + public: virtual void SetSkeletonLocalTransforms( + const std::map &_tfs) override; + + // Documentation inherited. + public: virtual std::unordered_map + SkeletonWeights() const override; + + // Documentation inherited. + public: virtual void SetSkeletonWeights( + const std::unordered_map &_weights) override; + + // Documentation inherited. + public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, + bool _enabled, bool _loop = true, float _weight = 1.0) override; + + // Documentation inherited. + public: virtual bool SkeletonAnimationEnabled(const std::string &_name) + const override; + + // Documentation inherited. + public: virtual void UpdateSkeletonAnimation( + std::chrono::steady_clock::duration _time) override; + + // Documentation inherited + public: virtual Ogre::MovableObject *OgreObject() const override; + + /// \brief Get a list of submeshes in this mesh + protected: virtual SubMeshStorePtr SubMeshes() const override; + + /// \brief Store containing all the submeshes + protected: Ogre2SubMeshStorePtr subMeshes; + + /// \brief Pointer to the ogre item object + protected: Ogre::Item *ogreItem = nullptr; + + /// \brief Make scene our friend so it can create an ogre2 mesh + private: friend class Ogre2Scene; + + /// \brief Make mesh factory our friend so it can create an ogre2 mesh + private: friend class Ogre2MeshFactory; + + /// \brief Pointer to private data + private: std::unique_ptr dataPtr; + }; + + /// \brief Ogre2.x implementation of the submesh class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SubMesh : + public BaseSubMesh + { + /// \brief Constructor + protected: Ogre2SubMesh(); + + /// \brief Destructor + public: virtual ~Ogre2SubMesh(); + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Set the name of the mesh stored in Ogre2 + /// \param[in] _name Name of the mesh + public: void SetMeshName(const std::string &_name); + + /// \brief Get internal ogre subitem created from this submesh + public: virtual Ogre::SubItem *Ogre2SubItem() const; + + /// \brief Helper function for setting the material to use + /// \param[in] _material Material to be assigned to the submesh + protected: virtual void SetMaterialImpl(MaterialPtr _material) override; + + /// \brief Initialize the submesh + protected: virtual void Init() override; + + /// \brief Ogre subitem representing the submesh + protected: Ogre::SubItem *ogreSubItem = nullptr; + + /// \brief Make scene our friend so it can create an ogre2 mesh + private: friend class Ogre2Scene; + + /// \brief Make submesh factory our friend so it can create an + /// ogre2 submesh + private: friend class Ogre2SubMeshStoreFactory; + + /// \brief Pointer to private data + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2MeshFactory.hh b/ogre2/include/gz/rendering/ogre2/Ogre2MeshFactory.hh new file mode 100644 index 000000000..43ab40d56 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2MeshFactory.hh @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_ +#define GZ_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_ + +#include +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/MeshDescriptor.hh" +#include "gz/rendering/ogre2/Ogre2Mesh.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Export.hh" + +namespace Ogre +{ + class Item; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2MeshFactoryPrivate; + class Ogre2SubMeshStoreFactoryPrivate; + + /// \brief Ogre2.x implementation of the mesh factory class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2MeshFactory + { + /// \brief Constructor + /// \param[in] _scene Pointer to the scene + public: explicit Ogre2MeshFactory(Ogre2ScenePtr _scene); + + /// \brief Destructor + public: virtual ~Ogre2MeshFactory(); + + /// \brief Create a mesh from a descriptor + /// \param[in] _desc Mesh descriptor containing data needed to create a + /// mesh + public: virtual Ogre2MeshPtr Create(const MeshDescriptor &_desc); + + /// \brief Cleanup and clear all internal ogre v2 meshes created by this + /// factory + public: virtual void Clear(); + + /// \brief Get the ogre item based on the mesh descriptor + /// \param[in] _desc Descriptor describing the target mesh + protected: virtual Ogre::Item *OgreItem( + const MeshDescriptor &_desc); + + /// \brief Load a mesh using a mesh descriptor + /// \param[in] _desc Mesh descriptor + protected: virtual bool Load(const MeshDescriptor &_desc); + + /// \brief Check if the mesh is loaded using a mesh descriptor + /// \param[in] _desc Mesh descriptor containing the mesh name used + /// by this function for checking the loaded state + protected: virtual bool IsLoaded(const MeshDescriptor &_desc); + + /// \brief Helper function to load the mesh from the input mesh descriptor + /// \param[in] _desc Input mesh descriptor + protected: virtual bool LoadImpl(const MeshDescriptor &_desc); + + /// \brief Get the mesh name from the mesh descriptor + /// \param[in] _desc Mesh descriptor containing the mesh name + protected: virtual std::string MeshName(const MeshDescriptor &_desc); + + /// \brief Validate the mesh descriptor to make sure it contains all the + /// needed information to create a mesh + /// \param[in] _desc Mesh descriptor to be validated + protected: virtual bool Validate(const MeshDescriptor &_desc); + + /// \brief A list of ogre meshes created by this factory + protected: std::vector ogreMeshes; + + /// \brief Pointer to the scene object + protected: Ogre2ScenePtr scene; + + /// \brief Remove internal material cache for a specific material + public: void ClearMaterialsCache(const std::string &_name); + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + }; + + /// \brief Ogre2.x implementation of a submesh store factory class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SubMeshStoreFactory + { + /// \brief Constructor + /// \param[in] _scene Pointer to the scene object + /// \param[in] _item Parent ogre item + public: Ogre2SubMeshStoreFactory(Ogre2ScenePtr _scene, + Ogre::Item *_item); + + /// \brief Destructor + public: virtual ~Ogre2SubMeshStoreFactory(); + + /// \brief Create the submeshes + /// \return A store containing all the submeshes + public: virtual Ogre2SubMeshStorePtr Create(); + + /// \brief Helper function to create submesh at the given index + /// \param[in] _index Index of the ogre subitem. The subitem is then used + /// to create the submesh. + protected: virtual Ogre2SubMeshPtr CreateSubMesh(unsigned int _index); + + /// \brief Create a list of names and the corresponding submesh object + protected: virtual void CreateNameList(); + + /// \brief Populate the name list with default generated names + protected: virtual void PopulateDefaultNames(); + + /// \brief Populate the name list with names associated with each ogre + /// subitem + protected: virtual void PopulateGivenNames(); + + /// \brief Pointer to the scene object + protected: Ogre2ScenePtr scene; + + /// \brief Pointer to the parent ogre item + protected: Ogre::Item *ogreItem = nullptr; + + /// \brief A list of names associated with each ogre subitem / submesh + protected: std::vector names; + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Node.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Node.hh new file mode 100644 index 000000000..bcf40ffb3 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Node.hh @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2NODE_HH_ +#define GZ_RENDERING_OGRE2_OGRE2NODE_HH_ + +#include "gz/rendering/base/BaseNode.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" + +namespace Ogre +{ + class SceneNode; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre2.x implementation of the Node class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Node : + public BaseNode + { + /// \brief Constructor + protected: Ogre2Node(); + + /// \brief Destructor + public: virtual ~Ogre2Node(); + + // Documentation inherited. + public: virtual bool HasParent() const override; + + // Documentation inherited. + public: virtual NodePtr Parent() const override; + + /// \brief Get a pointer to the underlying scene node + /// \return Ogre scene node pointer + public: virtual Ogre::SceneNode *Node() const; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual math::Vector3d LocalScale() const override; + + // Documentation inherited. + public: virtual bool InheritScale() const override; + + // Documentation inherited. + public: virtual void SetInheritScale(bool _inherit) override; + + // Documentation inherited. + protected: virtual void SetLocalScaleImpl( + const math::Vector3d &_scale) override; + + // Documentation inherited. + protected: virtual NodeStorePtr Children() const override; + + // Documentation inherited. + protected: virtual bool AttachChild(NodePtr _child) override; + + // Documentation inherited. + protected: virtual bool DetachChild(NodePtr _child) override; + + // Documentation inherited. + protected: virtual math::Pose3d RawLocalPose() const override; + + // Documentation inherited. + protected: virtual void SetRawLocalPose(const math::Pose3d &_Pose3d) + override; + + /// \brief Get the raw local position of the node + /// \return Local position + protected: virtual math::Vector3d RawLocalPosition() const; + + /// \brief Set the raw local position of the node + /// \param[in] _position Local position to set the node to + protected: virtual void SetRawLocalPosition( + const math::Vector3d &_position); + + /// \brief Get the raw local rotation of the node + /// \return Local rotation + protected: virtual math::Quaterniond RawLocalRotation() const; + + /// \brief Set the raw local rotation of the node + /// \param[in] _rotation Local rotation to set the node to + protected: virtual void SetRawLocalRotation( + const math::Quaterniond &_rotation); + + /// \brief Set the parent node + /// \param[in] _parent The parent ogre node + protected: virtual void SetParent(Ogre2NodePtr _parent); + + // Documentation inherited. + protected: virtual void Load() override; + + // Documentation inherited. + protected: virtual void Init() override; + + /// \brief get a shared pointer to this + private: Ogre2NodePtr SharedThis(); + + /// \brief Pointer to the parent ogre node + protected: Ogre2NodePtr parent; + + /// \brief The underlying ogre scene node + protected: Ogre::SceneNode *ogreNode = nullptr; + + /// \brief A list of child nodes + protected: Ogre2NodeStorePtr children; + + // TODO(anyone): remove the need for a visual friend class + private: friend class Ogre2Visual; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Object.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Object.hh new file mode 100644 index 000000000..50042bfc6 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Object.hh @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2OBJECT_HH_ +#define GZ_RENDERING_OGRE2_OGRE2OBJECT_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/base/BaseObject.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre2.x implementation of the Object class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Object : + public BaseObject + { + /// \brief Constructor + protected: Ogre2Object(); + + /// \brief Destructor + public: virtual ~Ogre2Object(); + + // Documentation inherited + public: virtual ScenePtr Scene() const override; + + /// \brief Pointer to the ogre scene + protected: Ogre2ScenePtr scene; + + /// \brief Make ogre scene our friend so it is able to create objects + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2ParticleEmitter.hh b/ogre2/include/gz/rendering/ogre2/Ogre2ParticleEmitter.hh new file mode 100644 index 000000000..2280f5b9f --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2ParticleEmitter.hh @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2PARTICLEEMITTER_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2PARTICLEEMITTER_HH_ + +#include +#include +#include "ignition/rendering/base/BaseParticleEmitter.hh" +#include "ignition/rendering/ogre2/Ogre2Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2ParticleEmitterPrivate; + + /// \brief Class to manage a particle emitter. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ParticleEmitter : + public BaseParticleEmitter + { + /// \brief Constructor + protected: Ogre2ParticleEmitter(); + + /// \brief Destructor + public: virtual ~Ogre2ParticleEmitter(); + + // Documentation inherited. + public: void Destroy() override; + + // Documentation inherited. + public: virtual void SetType(const EmitterType _type) override; + + // Documentation inherited. + public: virtual void SetEmitterSize( + const ignition::math::Vector3d &_size) override; + + // Documentation inherited. + public: virtual void SetRate(double _rate) override; + + // Documentation inherited. + public: virtual void SetDuration(double _duration) override; + + // Documentation inherited. + public: virtual void SetEmitting(bool _enable) override; + + // Documentation inherited. + public: virtual void SetParticleSize( + const ignition::math::Vector3d &_size) override; + + // Documentation inherited. + public: virtual void SetLifetime(double _lifetime) override; + + // Documentation inherited. + public: virtual void SetMaterial(const MaterialPtr &_material) override; + + // Documentation inherited. + public: virtual void SetVelocityRange(double _minVelocity, + double _maxVelocity) override; + + // Documentation inherited. + public: virtual void SetColorRange( + const ignition::math::Color &_colorStart, + const ignition::math::Color &_colorEnd) override; + + // Documentation inherited. + public: virtual void SetScaleRate(double _scaleRate) override; + + // Documentation inherited. + public: virtual void SetColorRangeImage(const std::string &_image) + override; + + /// \brief Particle system visibility flags + public: static const uint32_t kParticleVisibilityFlags; + + // Documentation inherited. + protected: virtual void Init() override; + + /// \brief Internal pre-render function added to avoid breaking ABI + /// compatibility + private: void PreRenderImpl(); + + /// \brief Create the particle system + private: void CreateParticleSystem(); + + /// \brief Only the ogre scene can instanstiate this class + private: friend class Ogre2Scene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RayQuery.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RayQuery.hh new file mode 100644 index 000000000..ea6b5f607 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RayQuery.hh @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2RAYQUERY_HH_ +#define GZ_RENDERING_OGRE2_OGRE2RAYQUERY_HH_ + +#include + +#include "gz/rendering/base/BaseRayQuery.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2RayQueryPrivate; + + /// \class Ogre2RayQuery Ogre2RayQuery.hh + /// ignition/rendering/ogre2/Ogre2RayQuery.hh + /// \brief A Ray Query class used for computing ray object intersections + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RayQuery : + public BaseRayQuery + { + /// \brief Constructor + protected: Ogre2RayQuery(); + + /// \brief Destructor + public: virtual ~Ogre2RayQuery(); + + // Documentation inherited + public: virtual void SetFromCamera(const CameraPtr &_camera, + const math::Vector2d &_coord); + + // Documentation inherited + public: virtual RayQueryResult ClosestPoint(); + + /// \brief Get closest point by selection buffer. + /// This is executed on the GPU. + private: RayQueryResult ClosestPointBySelectionBuffer(); + + /// \brief Get closest point by ray triangle intersection test. + /// This is executed on the CPU. + private: RayQueryResult ClosestPointByIntersection(); + + /// \brief Private data pointer + private: std::unique_ptr dataPtr; + + /// \brief Pointer to friend scene class for creating ray query + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh new file mode 100644 index 000000000..8cfb6396d --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh @@ -0,0 +1,251 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2RENDERENGINE_HH_ +#define GZ_RENDERING_OGRE2_OGRE2RENDERENGINE_HH_ + +#include +#include +#include +#include + +#include + +#include "gz/rendering/GraphicsAPI.hh" +#include "gz/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/base/BaseRenderEngine.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Export.hh" + +namespace Ogre +{ + class LogManager; + class Root; + class Window; + namespace v1 + { + class OverlaySystem; + } + + class HlmsPbsTerraShadows; + class CompositorWorkspaceListener; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2RenderEnginePrivate; + class Ogre2IgnHlmsCustomizations; + + /// \brief Plugin for loading ogre render engine + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderEnginePlugin : + public RenderEnginePlugin + { + /// \brief Constructor + public: Ogre2RenderEnginePlugin(); + + /// \brief Destructor + public: ~Ogre2RenderEnginePlugin() = default; + + /// \brief Get the name of the render engine loaded by this plugin. + /// \return Name of render engine + public: std::string Name() const; + + /// \brief Get a pointer to the render engine loaded by this plugin. + /// \return Render engine instance + public: RenderEngine *Engine() const; + }; + + /// \brief Ogre2 render engine class. A singleton class that manages the + /// underlying ogre2 render engine, loads its plugins, and creates + /// resources needed for the engine to run + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderEngine : + public virtual BaseRenderEngine, + public common::SingletonT + { + /// \brief Constructor + private: Ogre2RenderEngine(); + + /// \brief Destructor + public: virtual ~Ogre2RenderEngine(); + + // Documentation Inherited. + public: virtual void Destroy() override; + + // Documentation Inherited. + public: virtual bool IsEnabled() const override; + + // Documentation Inherited. + public: virtual std::string Name() const override; + + /// \brief Add path to resource in ogre2's resource manager + /// \param[in] _uri Resource path in the form of an uri + public: void AddResourcePath(const std::string &_uri) override; + + /// \brief return the ogre window + public: Ogre::Window * OgreWindow() const; + + /// \brief Get the ogre2 root object + /// \return ogre2 root object + public: virtual Ogre::Root *OgreRoot() const; + + /// \brief Create a render window + /// \param[in] _handle Handle of native window which the render window + /// will attach + /// \param[in] _width Width of render window + /// \param[in] _height Height of render window + /// \param[in] _ratio Device pixel ratio (typically needed for retina + /// displays) + /// \param[in] _antiAliasing Anti-aliasing level + public: std::string CreateRenderWindow(const std::string &_handle, + const unsigned int _width, const unsigned int _height, + const double _ratio, const unsigned int _antiAliasing); + + /// \brief Get the render engine's graphics API + /// Note: Do not merge this forward. This has been changed to + /// virtual function in ign-rendering7 + /// \return The graphics API enum class + public: rendering::GraphicsAPI GraphicsAPI() const; + + /// \brief Create a scene + /// \param[in] _id Unique scene Id + /// \param[in] _name Name of scene + protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, + const std::string &_name) override; + + /// \brief Get a pointer to the list of scenes managed by the render + /// engine + /// \return list of scenes + protected: virtual SceneStorePtr Scenes() const override; + + // Documentation Inherited. + protected: virtual bool LoadImpl( + const std::map &_params) override; + + /// \brief Initialize the render engine + /// \return True if the operation is successful + protected: virtual bool InitImpl() override; + + /// \brief Helper function to initialize the render engine + private: void LoadAttempt(); + + /// \brief Create the ogre logger for logging ogre messages to file + private: void CreateLogger(); + + /// \brief Create GL context + private: void CreateContext(); + + /// \brief Register Hlms + private: void RegisterHlms(); + + /// \brief Create ogre root + private: void CreateRoot(); + + /// \brief Create ogre overlay component + private: void CreateOverlay(); + + /// \brief Create ogre plugins. + private: void LoadPlugins(); + + /// \brief Creat the ogre render system + private: void CreateRenderSystem(); + + /// \brief Create dummy 1x1 render window for the main rendering context + private: void CreateRenderWindow(); + + /// \brief Create the resources needed by ogre + private: void CreateResources(); + + /// \brief Attempt to initialize engine and catch exeption if they occur + private: void InitAttempt(); + + /// \brief Get a list of all supported FSAA levels for this render system + /// \return a list of FSAA levels + public: std::vector FSAALevels() const; + + /// \brief Retrieves Hlms customizations for tweaking them + /// \return Ogre HLMS customizations + public: Ogre2IgnHlmsCustomizations &HlmsCustomizations(); + + /// \internal + /// \brief Get a pointer to the Ogre overlay system. + /// \return Pointer to the ogre overlay system. + public: Ogre::v1::OverlaySystem *OverlaySystem() const; + + /// \internal + /// \brief Get a pointer to the Pbs listener that adds terra shadows. + /// Do NOT assume HlmsPbs::getListener() == HlmsPbsTerraShadows() + /// as there may be more than one listener in the future with + /// a master listener coordinating them + /// \return Pointer to the Pbs listener that adds terra shadows. + public: Ogre::HlmsPbsTerraShadows *HlmsPbsTerraShadows() const; + + /// \internal + /// \brief Get a pointer to the workspace listener that adds terra + /// casting shadows from spot and point lights. + /// + /// This listener needs to be added to each workspace that wants + /// terrain shadows from spot/point lights. If no terrains are in scene + /// then the workspace's overhead is negligible / almost 0. + /// \return Pointer to the CompositorWorkspaceListener + public: Ogre::CompositorWorkspaceListener + *TerraWorkspaceListener() const; + + /// \brief Pointer to the ogre's overlay system + private: Ogre::v1::OverlaySystem *ogreOverlaySystem = nullptr; + + /// \brief List of scenes managed by the render engine + private: Ogre2SceneStorePtr scenes; + + /// \brief Ogre root + private: Ogre::Root *ogreRoot = nullptr; + + /// \brief Ogre log manager + private: Ogre::LogManager *ogreLogManager = nullptr; + + /// \brief Paths to ogre plugins + private: std::vector ogrePaths; + + /// \brief Dummy display needed for linux platform + private: void *dummyDisplay = nullptr; + + /// \brief Dummy context needed for linux platform + private: void *dummyContext = nullptr; + + /// \brief Dummy window Id needed for linux platform + private: uint64_t dummyWindowId = 0u; + + /// \brief Ogre Window + private: Ogre::Window *window = nullptr; + + /// \brief True to use the current opengl context + private: bool useCurrentGLContext = false; + + /// \brief Pointer to private data + private: std::unique_ptr dataPtr; + + /// \brief Singleton setup + private: friend class common::SingletonT; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderPass.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderPass.hh new file mode 100644 index 000000000..0adfc9565 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderPass.hh @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2RENDERPASS_HH_ +#define GZ_RENDERING_OGRE2_OGRE2RENDERPASS_HH_ + +#include +#include + +#include "gz/rendering/base/BaseRenderPass.hh" +#include "gz/rendering/ogre2/Export.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2RenderPassPrivate; + + /* \class Ogre2RenderPass Ogre2RenderPass.hh \ + * ignition/rendering/ogre2/Ogre2RenderPass.hh + */ + /// \brief Ogre2 Implementation of a render pass. + /// + /// The ogre2 compositor chain in ign-rendering is set up as follows: + /// * Base scene pass -> [0..N] RenderPass'es -> Final compositor pass. + /// This is set up by Ogre2RenderTarget which loads the compositor workspace + /// definiton from script. The base scene pass node is responsible for + /// rendering the initial scene and passes its output to any RenderPass'es + /// that are added to the RenderTarget. Each RenderPass has its own ogre + /// compositor node that receives the output from the previous RenderPass + /// as input, applies its own pass over the input, and sends the result to + /// the next RenderPass. Note that the Ogre2RenderPass class provides the + /// node definition only and the actual node creation work is done in the + /// Ogre2RenderTarget class when the whole workspace is constructed. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderPass : + public BaseRenderPass + { + /// \brief Constructor + protected: Ogre2RenderPass(); + + /// \brief Destructor + public: virtual ~Ogre2RenderPass(); + + // Documentation inherited. + public: void Destroy() override; + + /// \brief Get the ogre compositor node definition name for this + /// render pass + public: std::string OgreCompositorNodeDefinitionName() const; + + /// \brief Create the render pass using ogre compositor + public: virtual void CreateRenderPass(); + + /// \brief Name of the ogre compositor node definition + protected: std::string ogreCompositorNodeDefName; + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderTarget.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTarget.hh new file mode 100644 index 000000000..64c1132cf --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTarget.hh @@ -0,0 +1,308 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_ +#define GZ_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_ + +#include +#include +#include +#include + +#include "gz/rendering/base/BaseRenderTypes.hh" +#include "gz/rendering/base/BaseRenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" +#include "gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh" + +#ifdef _MSC_VER + #pragma warning(push, 0) +#endif +#include +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +namespace Ogre +{ + class Camera; + class RenderTarget; + class Texture; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2RenderTargetPrivate; + + /// \brief Ogre2.x implementation of the render target class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderTarget : + public virtual BaseRenderTarget + { + /// \brief Constructor + protected: Ogre2RenderTarget(); + + /// \brief Destructor + public: virtual ~Ogre2RenderTarget(); + + /// \brief Get the anti-aliasing level + public: virtual unsigned int AntiAliasing() const; + + /// \brief set the anti-aliasing level + /// \param[in] _aa Anti-aliasing level + public: virtual void SetAntiAliasing(unsigned int _aa); + + /// \brief Copy the render target buffer data to an image + /// \param[in] _image Image to copy the data to + public: virtual void Copy(Image &_image) const override; + + /// \brief Get a pointer to the internal ogre camera + /// \return Pointer to ogre camera + public: virtual Ogre::Camera *Camera() const; + + /// \brief Set the ogre camera to use for this render target + /// \param[in] _camera Pointer to ogre camera + public: virtual void SetCamera(Ogre::Camera *_camera); + + // Documentation inherited + public: virtual math::Color BackgroundColor() const override; + + /// \brief Set the background color of the render target + /// \param[in] _color Color to set the background to + public: virtual void SetBackgroundColor(math::Color _color); + + /// \brief Set the background material of this camera + /// \param[in] _material Material to set the background to + public: virtual void SetBackgroundMaterial(MaterialPtr _material); + + /// \brief Get the background material of this camera + /// \return background material + public: virtual MaterialPtr BackgroundMaterial() const; + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void PostRender() override; + + /// \brief Main render call + public: virtual void Render(); + + /// \brief Destroy the render target + public: virtual void Destroy() override = 0; + + /// \brief Set a material to render on every object. This method is used + /// for special cases like the render target of a depth camera. + /// \param[in] _material The material to render + public: void SetMaterial(MaterialPtr _material); + + /// \see Camera::SetShadowsNodeDefDirty + public: void SetShadowsNodeDefDirty(); + + /// \brief Returns the FSAA to use based on supported specs by HW + /// and value specified in Ogre2RenderTarget::AntiAliasing + /// \return Value in range [1; 256). 1 means no antialiasing. + protected: uint8_t TargetFSAA() const; + + /// \brief Get a pointer to the ogre render target containing + /// the results of the render (implemented separately + /// to avoid breaking ABI of the pure virtual function) + protected: Ogre::TextureGpu *RenderTargetImpl() const; + + /// \brief Get a pointer to the ogre render target containing + /// the results of the render + public: virtual Ogre::TextureGpu *RenderTarget() const = 0; + + /// \brief Returns true if this is a render window + /// \return True if this render target is a render window + public: virtual bool IsRenderWindow() const; + + // Documentation inherited + public: unsigned int GLIdImpl() const; + + /// \brief Destroy the render texture + protected: void DestroyTargetImpl(); + + /// \brief Build the render texture + protected: void BuildTargetImpl(); + + /// \brief Get visibility mask for the viewport associated with this + /// render target + /// \return Visibility mask + public: virtual uint32_t VisibilityMask() const; + + /// \brief Set visibility mask for the viewport associated with this + /// render target + /// \param[in] _mask Visibility mask + public: virtual void SetVisibilityMask(uint32_t _mask); + + /// \brief Update the render pass chain + public: static void UpdateRenderPassChain( + Ogre::CompositorWorkspace *_workspace, + const std::string &_workspaceDefName, + const std::string &_baseNode, const std::string &_finalNode, + const std::vector &_renderPasses, + bool _recreateNodes, + Ogre::TextureGpu *(*_ogreTextures)[2], + bool _isRenderWindow); + + /// \brief Update the background color + protected: virtual void UpdateBackgroundColor(); + + /// \brief Update the background material + protected: virtual void UpdateBackgroundMaterial(); + + /// \brief Update the render pass chain + protected: virtual void UpdateRenderPassChain(); + + /// \brief Implementation of the Rebuild function + protected: virtual void RebuildImpl() override; + + /// \brief Rebuild the render target + protected: virtual void RebuildTarget() = 0; + + /// \brief Rebuild the compositor + protected: virtual void RebuildCompositor(); + + /// \brief Build the compositor + protected: virtual void BuildCompositor(); + + /// \brief Destroy the compositor + protected: virtual void DestroyCompositor(); + + /// \brief Re-initializes render target material to apply a material to + /// everything in the scene. Does nothing if no material has been set + /// \sa Ogre2RenderTarget::RebuildImpl() + /// \sa BaseRenderTarget::Rebuild() + protected: void RebuildMaterial(); + + /// \brief Pointer to the internal ogre camera + protected: Ogre::Camera *ogreCamera = nullptr; + + /// \brief Ogre's compositor workspace - the main interface to render + /// into a render target or render texture. + protected: Ogre::CompositorWorkspace *ogreCompositorWorkspace = nullptr; + + /// \brief Ogre's compositor workspace definition name + protected: std::string ogreCompositorWorkspaceDefName; + + /// \brief Stores the background color of the render target + protected: Ogre::ColourValue ogreBackgroundColor; + + /// \brief Background material of the render target + protected: MaterialPtr backgroundMaterial; + + /// \brief a material used by for the render target + protected: MaterialPtr material; + + /// \brief Helper class that applies the material to the render target + protected: Ogre2RenderTargetMaterialPtr materialApplicator; + + /// \brief Flag to indicate if the render target color has changed + protected: bool colorDirty = true; + + /// \brief Flag to indicate if the render target background material has + /// changed + protected: bool backgroundMaterialDirty = false; + + /// \brief Anti-aliasing level + protected: unsigned int antiAliasing = 4; + + /// \brief visibility mask associated with this render target + protected: uint32_t visibilityMask = IGN_VISIBILITY_ALL; + + /// \brief Pointer to private data + private: std::unique_ptr dataPtr; + }; + + /// \brief Ogre2.x implementation of the render texture class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderTexture : + public virtual BaseRenderTexture + { + /// \brief Constructor + protected: Ogre2RenderTexture(); + + /// \brief Destructor + public: virtual ~Ogre2RenderTexture(); + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void PostRender() override; + + // Documentation inherited + public: virtual unsigned int GLId() const override; + + // Documentation inherited + // TODO(anyone): this function should be removed. + // We didn't do it to preserve ABI. + public: virtual Ogre::TextureGpu *RenderTarget() const override; + + // Documentation inherited. + protected: virtual void RebuildTarget() override; + + /// \brief Destroy the render texture + protected: virtual void DestroyTarget(); + + /// \brief Build the render texture + protected: virtual void BuildTarget(); + + /// \brief Make scene our friend so it can create a ogre2 render texture + private: friend class Ogre2Scene; + }; + + /// \brief Ogre2.x implementation of the render window class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderWindow : + public virtual BaseRenderWindow + { + /// \brief Constructor + protected: Ogre2RenderWindow(); + + /// \brief Destructor + public: virtual ~Ogre2RenderWindow(); + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual bool IsRenderWindow() const override; + + // Documentation inherited. + public: virtual Ogre::TextureGpu *RenderTarget() const override; + + // Documentation inherited. + protected: virtual void RebuildTarget() override; + + /// \brief Build the render window + protected: virtual void BuildTarget(); + + /// \brief Pointer to the internal ogre render target object + protected: Ogre::TextureGpu *ogreRenderWindow = nullptr; + + /// \brief Make scene our friend so it can create a ogre2 render window + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh new file mode 100644 index 000000000..6488a3ef6 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2RENDERTARGETMATERIAL_HH_ +#define GZ_RENDERING_OGRE2_OGRE2RENDERTARGETMATERIAL_HH_ + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre2/Export.hh" + +#ifdef _MSC_VER + #pragma warning(push, 0) +#endif +#include +#include +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +#ifdef _MSC_VER + #pragma warning(push) + // Silence deriving from Ogre::RenderTargetListener dll-linkage warnings + #pragma warning(disable:4275) +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Causes all objects in a scene to be rendered with the same + /// material when rendered by a given RenderTarget. + /// \internal + /// + /// On construction it registers as an Ogre::RenderTargetListener + /// on the provided Ogre::RenderTarget, and sets the material scheme name + /// to a value that is unlikely to exist. + /// When the target is about to be rendered it adds itself as an + /// Ogre::MaterialManager::Listener. + /// Every time ogre tries to get a technique for a material it will call + /// handleSchemeNotFound which returns the first supported technique on the + /// material provided to this class's constructor. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderTargetMaterial : + public Ogre::Camera::Listener, + public Ogre::MaterialManager::Listener + { + /// \brief constructor + /// \param[in] _scene the scene manager responsible for rendering + /// \param[in] _renderTarget the RenderTarget this should apply to + /// \param[in] _material the material to apply to all renderables + public: Ogre2RenderTargetMaterial(Ogre::SceneManager *_scene, + Ogre::Camera *_renderTarget, Ogre::Material *_material); + + /// \brief destructor + public: ~Ogre2RenderTargetMaterial(); + + /// \brief Callback when a camera is about to be rendered + /// \param[in] _cam Ogre camera. + private: virtual void cameraPreRenderScene( + Ogre::Camera *_cam) override; + + /// \brief Callback when a camera is finisned being rendered + /// \param[in] _evt Ogre camera + private: virtual void cameraPostRenderScene( + Ogre::Camera *_evt) override; + + /// \brief Ogre callback that assigned same material to all renderables + /// when the requested scheme is not found + /// \param[in] _schemeIndex Index of scheme requested + /// \param[in] _schemeName Name of scheme requested + /// \param[in] _originalMaterial Orignal material that does not contain + /// the requested scheme + /// \param[in] _lodIndex The material level-of-detail + /// \param[in] _rend Pointer to the Ogre::Renderable object requesting + /// the use of the techinique + /// \return The Ogre material technique to use when scheme is not found. + public: virtual Ogre::Technique *handleSchemeNotFound( + uint16_t _schemeIndex, const Ogre::String &_schemeName, + Ogre::Material *_originalMaterial, uint16_t _lodIndex, + const Ogre::Renderable *_rend) override; + + /// \brief scene manager responsible for rendering + private: Ogre::SceneManager *scene = nullptr; + + /// \brief render target that should see a uniform material + private: Ogre::Camera *renderCamera = nullptr; + + /// \brief material that should be applied to all objects + private: Ogre::Material *material = nullptr; + + /// \brief name of the material scheme used by this applicator + private: Ogre::String schemeName; + }; + } + } +} + +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderTypes.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTypes.hh new file mode 100644 index 000000000..06f43f57a --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTypes.hh @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2RENDERTYPES_HH_ +#define GZ_RENDERING_OGRE2_OGRE2RENDERTYPES_HH_ + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class Ogre2ArrowVisual; + class Ogre2AxisVisual; + class Ogre2BoundingBoxCamera; + class Ogre2Camera; + class Ogre2Capsule; + class Ogre2COMVisual; + class Ogre2DepthCamera; + class Ogre2DirectionalLight; + class Ogre2Geometry; + class Ogre2GizmoVisual; + class Ogre2GpuRays; + class Ogre2Grid; + class Ogre2Heightmap; + class Ogre2InertiaVisual; + class Ogre2JointVisual; + class Ogre2Light; + class Ogre2LightVisual; + class Ogre2LidarVisual; + class Ogre2Marker; + class Ogre2Material; + class Ogre2Mesh; + class Ogre2MeshFactory; + class Ogre2Node; + class Ogre2Object; + class Ogre2ParticleEmitter; + class Ogre2PointLight; + class Ogre2RayQuery; + class Ogre2RenderEngine; + class Ogre2RenderTarget; + class Ogre2RenderTargetMaterial; + class Ogre2RenderTexture; + class Ogre2RenderWindow; + class Ogre2Scene; + class Ogre2SegmentationCamera; + class Ogre2Sensor; + class Ogre2SpotLight; + class Ogre2SubMesh; + class Ogre2ThermalCamera; + class Ogre2Visual; + class Ogre2WireBox; + + typedef BaseGeometryStore Ogre2GeometryStore; + typedef BaseLightStore Ogre2LightStore; + typedef BaseNodeStore Ogre2NodeStore; + typedef BaseSceneStore Ogre2SceneStore; + typedef BaseSensorStore Ogre2SensorStore; + typedef BaseSubMeshStore Ogre2SubMeshStore; + typedef BaseVisualStore Ogre2VisualStore; + + typedef BaseMaterialMap Ogre2MaterialMap; + + typedef shared_ptr Ogre2ArrowVisualPtr; + typedef shared_ptr Ogre2AxisVisualPtr; + typedef shared_ptr Ogre2BoundingBoxCameraPtr; + typedef shared_ptr Ogre2CameraPtr; + typedef shared_ptr Ogre2CapsulePtr; + typedef shared_ptr Ogre2COMVisualPtr; + typedef shared_ptr Ogre2DepthCameraPtr; + typedef shared_ptr Ogre2DirectionalLightPtr; + typedef shared_ptr Ogre2GeometryPtr; + typedef shared_ptr Ogre2GizmoVisualPtr; + typedef shared_ptr Ogre2GpuRaysPtr; + typedef shared_ptr Ogre2GridPtr; + typedef shared_ptr Ogre2HeightmapPtr; + typedef shared_ptr Ogre2InertiaVisualPtr; + typedef shared_ptr Ogre2JointVisualPtr; + typedef shared_ptr Ogre2LightPtr; + typedef shared_ptr Ogre2LightVisualPtr; + typedef shared_ptr Ogre2LidarVisualPtr; + typedef shared_ptr Ogre2MarkerPtr; + typedef shared_ptr Ogre2MaterialPtr; + typedef shared_ptr Ogre2MeshPtr; + typedef shared_ptr Ogre2MeshFactoryPtr; + typedef shared_ptr Ogre2NodePtr; + typedef shared_ptr Ogre2ObjectPtr; + typedef shared_ptr Ogre2ParticleEmitterPtr; + typedef shared_ptr Ogre2PointLightPtr; + typedef shared_ptr Ogre2RayQueryPtr; + typedef shared_ptr Ogre2RenderEnginePtr; + typedef shared_ptr Ogre2RenderTargetPtr; + typedef shared_ptr Ogre2RenderTexturePtr; + typedef shared_ptr Ogre2RenderWindowPtr; + typedef shared_ptr Ogre2ScenePtr; + typedef shared_ptr + Ogre2SegmentationCameraPtr; + typedef shared_ptr Ogre2SensorPtr; + typedef shared_ptr Ogre2SpotLightPtr; + typedef shared_ptr Ogre2SubMeshPtr; + typedef shared_ptr Ogre2ThermalCameraPtr; + typedef shared_ptr Ogre2VisualPtr; + typedef shared_ptr Ogre2WireBoxPtr; + + typedef shared_ptr Ogre2GeometryStorePtr; + typedef shared_ptr Ogre2LightStorePtr; + typedef shared_ptr Ogre2NodeStorePtr; + typedef shared_ptr Ogre2RenderTargetMaterialPtr; + typedef shared_ptr Ogre2SceneStorePtr; + typedef shared_ptr Ogre2SensorStorePtr; + typedef shared_ptr Ogre2SubMeshStorePtr; + typedef shared_ptr Ogre2VisualStorePtr; + + typedef shared_ptr Ogre2MaterialMapPtr; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Scene.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Scene.hh new file mode 100644 index 000000000..c4996e590 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Scene.hh @@ -0,0 +1,452 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2SCENE_HH_ +#define GZ_RENDERING_OGRE2_OGRE2SCENE_HH_ + +#include +#include +#include + +#include "gz/rendering/Storage.hh" +#include "gz/rendering/base/BaseScene.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" + +#include "gz/rendering/ogre2/Export.hh" + +// This disables warning messages for OGRE +#ifndef _MSC_VER + #pragma GCC system_header +#else + #pragma warning(push, 0) +#endif +#include +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +namespace Ogre +{ + class Root; + class SceneManager; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2ScenePrivate; + // + /// \brief Ogre2.x implementation of the scene class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Scene : + public BaseScene + { + /// \brief Constructor + /// \param[in] _id Unique scene Id + /// \param[in] _name Scene name + protected: Ogre2Scene(unsigned int _id, const std::string &_name); + + /// \brief Destructor + public: virtual ~Ogre2Scene(); + + // Documentation inherited. + public: virtual void Fini() override; + + // Documentation inherited. + public: virtual RenderEngine *Engine() const override; + + // Documentation inherited. + public: virtual VisualPtr RootVisual() const override; + + // Documentation inherited. + public: virtual void SetTime( + const std::chrono::steady_clock::duration &_time) override; + + // Documentation inherited. + public: virtual math::Color AmbientLight() const override; + + // Documentation inherited. + public: virtual void SetAmbientLight(const math::Color &_color) override; + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void Clear() override; + + // Documentation inherited + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual void SetSkyEnabled(bool _enabled) override; + + // Documentation inherited + public: virtual bool SkyEnabled() const override; + + // Documentation inherited. + public: virtual void SetCameraPassCountPerGpuFlush( + uint8_t _numPass) override; + + // Documentation inherited. + public: virtual uint8_t CameraPassCountPerGpuFlush() const override; + + // Documentation inherited. + public: virtual bool LegacyAutoGpuFlush() const override; + + /// \brief Get a pointer to the ogre scene manager + /// \return Pointer to the ogre scene manager + public: virtual Ogre::SceneManager *OgreSceneManager() const; + + // Documentation inherited + public: virtual void PostRender() override; + + /// \cond PRIVATE + /// \brief Certain functions like Ogre2Camera::VisualAt would + /// need to call PreRender and PostFrame, which is very unintuitive + /// and user-hostile. + /// + /// More over, it's likely that we don't want to advance the frame + /// in those cases (e.g. particle FXs should not advance), but we + /// still have to initialize and cleanup Ogre once we're done. + /// + /// This function performs some PreRender steps but only if we're + /// not already inside PreRender/PostRender, necessary for rendering + /// Ogre2Camera::VisualAt (via Ogre2SelectionBuffer) + public: void StartForcedRender(); + + /// \brief Opposite of StartForcedRender + /// + /// This function performs some PostRender steps but only if we're + /// not already inside PreRender/PostRender pairs + public: void EndForcedRender(); + + /// \internal + /// \brief When LegacyAutoGpuFlush(), this function mimics + /// legacy behavior. + /// When not, it verifies PreRender has been called + /// It also performs necessary updates for all heightmaps + /// + /// \param _camera camera that is about to render, used + /// by heightmaps (Terra). See Ogre2Scene::UpdateAllHeightmaps + /// Can be null + public: void StartRendering(Ogre::Camera *_camera); + + /// \internal + /// \brief Every Render() function calls this function with + /// the number of pass_scene passes it just performed, so + /// that we decide if we should flush or not (based on + /// SetCameraPassCountPerGpuFlush) + /// + /// \param[in] _numPasses Number of pass_scene passes just performed + /// (excluding shadow nodes', otherwise it becomes too unpredictable) + /// \param[in] _startNewFrame whether we ignore + /// SetCameraPassCountPerGpuFlush. + /// Only PostRender should set this to true. + public: void FlushGpuCommandsAndStartNewFrame(uint8_t _numPasses, + bool _startNewFrame); + + /// \internal + /// \brief Performs actual flushing to GPU + protected: void FlushGpuCommandsOnly(); + + /// \internal + /// \brief Ends the frame, i.e. PostRender wants to do this. + /// + /// Ogre::SceneManager::updateSceneGraph can't be called again until + /// this function is called + /// + /// After calling this function again, + /// Ogre::SceneManager::updateSceneGraph must be called before + /// rendering anything (i.e. done inside PreRender) + /// + /// This is why every PreRender should be paired with a PostRender + /// call when in LegacyAutoGpuFlush == false + protected: void EndFrame(); + + /// \internal + /// \brief Mark shadows dirty to rebuild compostior shadow node + /// This is set when the number of shadow casting lighst changes + /// \param[in] _dirty True to mark shadows are dirty + /// \sa SetShadowsDirty + public: void SetShadowsDirty(bool _dirty); + + /// \internal + /// \brief Get whether shadows are dirty + /// \return True if the number of shadow casting lights changed + /// \sa ShadowsDirty + public: bool ShadowsDirty() const; + /// \endcond + + // Documentation inherited + protected: virtual bool LoadImpl() override; + + // Documentation inherited + protected: virtual bool InitImpl() override; + + // Documentation inherited + protected: virtual COMVisualPtr CreateCOMVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual InertiaVisualPtr CreateInertiaVisualImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited + protected: virtual JointVisualPtr CreateJointVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual LightVisualPtr CreateLightVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual DirectionalLightPtr CreateDirectionalLightImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited + protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual CameraPtr CreateCameraImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual ThermalCameraPtr CreateThermalCameraImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited + protected: virtual BoundingBoxCameraPtr CreateBoundingBoxCameraImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited + protected: virtual SegmentationCameraPtr CreateSegmentationCameraImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited + protected: virtual GpuRaysPtr CreateGpuRaysImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual VisualPtr CreateVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual GeometryPtr CreateConeImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id, + const std::string &_name) override; + + /// \brief Create a mesh object based on its name + /// \param[in] _id Unique Id to assign to the mesh + /// \param[in] _name Name to assign to the mesh + /// \param[in] _meshName Name of the mesh to create + protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, + const std::string &_name, const std::string &_meshName); + + // Documentation inherited + protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, + const std::string &_name, const MeshDescriptor &_desc) + override; + + // Documentation inherited + protected: virtual CapsulePtr CreateCapsuleImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual HeightmapPtr CreateHeightmapImpl(unsigned int _id, + const std::string &_name, const HeightmapDescriptor &_desc) + override; + + // Documentation inherited + protected: virtual GridPtr CreateGridImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual MarkerPtr CreateMarkerImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id, + const std::string &_name) override; + + // Documentation inherited + protected: virtual TextPtr CreateTextImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual RenderTexturePtr CreateRenderTextureImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited. + protected: virtual RenderWindowPtr CreateRenderWindowImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited + protected: virtual RayQueryPtr CreateRayQueryImpl( + unsigned int _id, const std::string &_name) override; + + // Documentation inherited + protected: virtual ParticleEmitterPtr CreateParticleEmitterImpl( + unsigned int _id, const std::string &_name) override; + + /// \brief Helper function to initialize an ogre2 object + /// \param[in] _object Ogre2 object that will be initialized + /// \param[in] _id Unique Id to assign to the object + /// \param[in] _name Name to assign to the object + protected: virtual bool InitObject(Ogre2ObjectPtr _object, + unsigned int _id, const std::string &_name); + + /// \internal + /// \brief Iterates through all Heightmaps and calls + /// Ogre2Heightmap::UpdateForRender on each of them + /// \param[in] _camera Camera about to be used for rendering + public: void UpdateAllHeightmaps(Ogre::Camera *_camera); + + /// \internal + /// \brief Return all heightmaps in the scene + public: const std::vector> &Heightmaps() + const; + + /// \brief Create a compositor shadow node with the same number of shadow + /// textures as the number of shadow casting lights + protected: void UpdateShadowNode(); + + /// \brief Create ogre compositor shadow node definition. The function + /// takes a vector of parameters that describe the type, number, and + /// resolution of textures create. Note that it is not necessary to + /// create separate textures for each shadow map. It is more efficient to + /// define a large texture atlas which is composed of multiple shadow + /// maps each occupying a subspace within the texture. This function is + /// similar to Ogre::ShadowNodeHelper::createShadowNodeWithSettings but + /// fixes a problem with the shadow map index when directional and spot + /// light shadow textures are defined on two different texture atlases. + /// \param[in] _compositorManager ogre compositor manager + /// \param[in] _shadowNodeName Name of the shadow node definition + /// \param[in] _shadowParams Parameters containing the shadow type, + /// texure resolution and position on the texture atlas. + private: void CreateShadowNodeWithSettings( + Ogre::CompositorManager2 *_compositorManager, + const std::string &_shadowNodeName, + const Ogre::ShadowNodeHelper::ShadowParamVec &_shadowParams); + + // Documentation inherited + protected: virtual LightStorePtr Lights() const override; + + // Documentation inherited + protected: virtual SensorStorePtr Sensors() const override; + + // Documentation inherited + protected: virtual VisualStorePtr Visuals() const override; + + // Documentation inherited + protected: virtual MaterialMapPtr Materials() const override; + + /// \brief Create the GL context + private: void CreateContext(); + + /// \brief Create the root visual in the scene + private: void CreateRootVisual(); + + /// \brief Create the mesh factory used to generate ogre meshes + private: void CreateMeshFactory(); + + /// \brief Create the vaiours storage objects + private: void CreateStores(); + + /// \brief Remove internal material cache for a specific material + /// \param[in] _name Name of the template material to remove. + public: void ClearMaterialsCache(const std::string &_name); + + /// \brief Create a shared pointer to self + private: Ogre2ScenePtr SharedThis(); + + /// \brief Root visual in the scene + protected: Ogre2VisualPtr rootVisual; + + /// \brief Mesh factory for generating ogre meshes + protected: Ogre2MeshFactoryPtr meshFactory; + + /// \brief A list of ogre sensors, e.g. cameras + protected: Ogre2SensorStorePtr sensors; + + /// \brief A list of ogre visuals + protected: Ogre2VisualStorePtr visuals; + + /// \brief A list of ogre lights + protected: Ogre2LightStorePtr lights; + + /// \brief A list of ogre materials + protected: Ogre2MaterialMapPtr materials; + + /// \brief A list of ogre heightmaps + protected: std::vector> heightmaps; + + /// \brief Pointer to the ogre scene manager + protected: Ogre::SceneManager *ogreSceneManager = nullptr; + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + + /// \brief Make the render engine our friend + private: friend class Ogre2RenderEngine; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2SegmentationCamera.hh b/ogre2/include/gz/rendering/ogre2/Ogre2SegmentationCamera.hh new file mode 100644 index 000000000..89dea5436 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2SegmentationCamera.hh @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE2_OGRE2SEGMENTATIONCAMERA_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2SEGMENTATIONCAMERA_HH_ + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +#include +#include + +#include +#include + +#include "ignition/rendering/base/BaseSegmentationCamera.hh" +#include "ignition/rendering/ogre2/Ogre2Includes.hh" +#include "ignition/rendering/ogre2/Ogre2Sensor.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2SegmentationCameraPrivate; + + /// \brief Segmentation camera used to label each pixel with a label id. + /// Supports Semantic / Panoptic Segmentation + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SegmentationCamera : + public BaseSegmentationCamera + { + /// \brief Constructor + protected: Ogre2SegmentationCamera(); + + /// \brief Destructor + public: virtual ~Ogre2SegmentationCamera(); + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void PostRender() override; + + // Documentation inherited + public: virtual ignition::common::ConnectionPtr + ConnectNewSegmentationFrame( + std::function _subscriber) override; + + // Documentation inherited + public: virtual void Render() override; + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + // Documentation inherited + public: void SetBackgroundLabel(int _label) override; + + // Documentation inherited + public: void LabelMapFromColoredBuffer( + uint8_t * _labelBuffer) const override; + + /// \brief Create the camera. + protected: void CreateCamera(); + + /// \brief Create render texture + protected: virtual void CreateRenderTexture(); + + // Documentation inherited + protected: virtual void CreateSegmentationTexture() override; + + /// \brief Pointer to the ogre camera + protected: Ogre::Camera *ogreCamera = nullptr; + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + /// \brief Make scene our friend so it can create a camera + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2SelectionBuffer.hh b/ogre2/include/gz/rendering/ogre2/Ogre2SelectionBuffer.hh new file mode 100644 index 000000000..6aaf3356c --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2SelectionBuffer.hh @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_OGRE2_OGRE2SELECTIONBUFFER_HH_ +#define GZ_RENDERING_OGRE2_OGRE2SELECTIONBUFFER_HH_ + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre2/Export.hh" + +namespace Ogre +{ + class Item; + class RenderTarget; + class SceneManager; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + struct Ogre2SelectionBufferPrivate; + + /// \brief Generates a selection buffer object for a given camera. + /// The selection buffer is used of entity selection. On setup, a unique + /// color is assigned to each entity. Whenever a selection request is made, + /// the selection buffer camera renders to a 1x1 sized offscreen buffer. + /// The color value of that pixel gives the identity of the entity. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SelectionBuffer + { + /// \brief Constructor + /// \param[in] _cameraName Name of the camera to generate a selection + /// buffer for. + /// \param[in] _scene Pointer to the scene + /// \param[in] _width width of the camera + /// \param[in] _height height of the camera + public: Ogre2SelectionBuffer(const std::string &_cameraName, + Ogre2ScenePtr _scene, unsigned int _width, + unsigned int _height); + + /// \brief Destructor + public: ~Ogre2SelectionBuffer(); + + /// \brief Handle on mouse click + /// \param[in] _x X coordinate in pixels. + /// \param[in] _y Y coordinate in pixels. + /// \return Returns the Ogre item at the coordinate. + public: Ogre::Item *OnSelectionClick(const int _x, const int _y); + + /// \brief Perform selection operation and get ogre item and + /// point of intersection. + /// \param[in] _x X coordinate in pixels. + /// \param[in] _y Y coordinate in pixels. + /// \param[out] _item Ogre item at the coordinate. + /// \param[out] _point 3D point of intersection with the ogre item's mesh. + /// \return True if an ogre item is found, false otherwise + public: bool ExecuteQuery(const int _x, const int _y, Ogre::Item *&_item, + math::Vector3d &_point); + + /// \brief Set dimension of the selection buffer + /// \param[in] _width X dimension in pixels. + /// \param[in] _height Y dimension in pixels. + public: void SetDimensions(unsigned int _width, unsigned int _height); + + /// \brief Call this to update the selection buffer contents + public: void Update(); + + /// \brief Delete the render texture + private: void DeleteRTTBuffer(); + + /// \brief Create the render texture + private: void CreateRTTBuffer(); + + /// \brief Create the selection buffer offscreen render texture. + // private: void CreateRTTOverlays(); + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Sensor.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Sensor.hh new file mode 100644 index 000000000..00141d7e0 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Sensor.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2SENSOR_HH_ +#define GZ_RENDERING_OGRE2_OGRE2SENSOR_HH_ + +#include "gz/rendering/base/BaseSensor.hh" +#include "gz/rendering/ogre2/Ogre2Node.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre2.x implementation of the sensor classs + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Sensor : + public BaseSensor + { + /// \brief Constructor + protected: Ogre2Sensor(); + + /// \brief Destructor + public: virtual ~Ogre2Sensor(); + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Storage.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Storage.hh new file mode 100644 index 000000000..6bb732a8b --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Storage.hh @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2STORAGE_HH_ +#define GZ_RENDERING_OGRE2_OGRE2STORAGE_HH_ + +#include + +#include "gz/rendering/base/BaseStorage.hh" + +#include "gz/rendering/ogre2/Ogre2Light.hh" +#include "gz/rendering/ogre2/Ogre2Mesh.hh" +#include "gz/rendering/ogre2/Ogre2Geometry.hh" +#include "gz/rendering/ogre2/Ogre2Node.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + +// armhf failed to build with this code. It can not be removed for the rest +// of arches to keep ABI but should be removed in major versions unreleased +// see https://github.com/ignitionrobotics/ign-rendering/pull/457 +#ifndef __ARM_PCS_VFP + template class BaseGeometryStore; + template class BaseLightStore; + template class BaseNodeStore; + template class BaseSceneStore; + template class BaseSensorStore; + template class BaseSubMeshStore; + template class BaseVisualStore; +#endif + + typedef BaseGeometryStore Ogre2GeometryStore; + typedef BaseLightStore Ogre2LightStore; + typedef BaseNodeStore Ogre2NodeStore; + typedef BaseSceneStore Ogre2SceneStore; + typedef BaseSensorStore Ogre2SensorStore; + typedef BaseSubMeshStore Ogre2SubMeshStore; + typedef BaseVisualStore Ogre2VisualStore; + + typedef std::shared_ptr Ogre2GeometryStorePtr; + typedef std::shared_ptr Ogre2LightStorePtr; + typedef std::shared_ptr Ogre2NodeStorePtr; + typedef std::shared_ptr Ogre2SceneStorePtr; + typedef std::shared_ptr Ogre2SensorStorePtr; + typedef std::shared_ptr Ogre2SubMeshStorePtr; + typedef std::shared_ptr Ogre2VisualStorePtr; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2ThermalCamera.hh b/ogre2/include/gz/rendering/ogre2/Ogre2ThermalCamera.hh new file mode 100644 index 000000000..667dd5e08 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2ThermalCamera.hh @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE2_OGRE2THERMALCAMERA_HH_ +#define GZ_RENDERING_OGRE2_OGRE2THERMALCAMERA_HH_ + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +#include +#include + +#include "gz/rendering/base/BaseThermalCamera.hh" +#include "gz/rendering/ogre2/Export.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" + +#include "gz/common/Event.hh" +#include "gz/common/Console.hh" + +namespace Ogre +{ + class Material; + class RenderTarget; + class Texture; + class Viewport; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2ThermalCameraPrivate; + + /// \brief Thermal camera used to render thermal data into an image buffer + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ThermalCamera : + public BaseThermalCamera + { + /// \brief Constructor + protected: Ogre2ThermalCamera(); + + /// \brief Destructor + public: virtual ~Ogre2ThermalCamera(); + + /// \brief Initialize the camera + public: virtual void Init() override; + + // Documentation inherited + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual void PreRender() override; + + /// \brief Render the camera + public: virtual void PostRender() override; + + /// \brief Connect to the new thermal image event + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewThermalFrame( + std::function _subscriber) override; + + /// \brief Implementation of the render call + public: virtual void Render() override; + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Create the camera. + protected: void CreateCamera(); + + /// \brief Create dummy render texture. Needed to satisfy inheritance + protected: virtual void CreateRenderTexture(); + + /// \brief Create thermal texture + protected: virtual void CreateThermalTexture(); + + /// \brief Pointer to the ogre camera + protected: Ogre::Camera *ogreCamera = nullptr; + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Visual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Visual.hh new file mode 100644 index 000000000..eec1bbdbc --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Visual.hh @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2VISUAL_HH_ +#define GZ_RENDERING_OGRE2_OGRE2VISUAL_HH_ + +#include +#include + +#include "gz/rendering/base/BaseVisual.hh" +#include "gz/rendering/ogre2/Ogre2Node.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2VisualPrivate; + + /// \brief Ogre2.x implementation of the visual class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Visual : + public BaseVisual + { + /// \brief Constructor + protected: Ogre2Visual(); + + /// \brief Destructor + public: virtual ~Ogre2Visual(); + + // Documentation inherited + public: virtual void SetWireframe(bool _show) override; + + // Documentation inherited + public: virtual bool Wireframe() const override; + + // Documentation inherited. + public: virtual void SetVisible(bool _visible) override; + + // Documentation inherited. + public: virtual void SetVisibilityFlags(uint32_t _flags) override; + + // Documentation inherited. + public: virtual ignition::math::AxisAlignedBox BoundingBox() + const override; + + // Documentation inherited. + public: virtual ignition::math::AxisAlignedBox LocalBoundingBox() + const override; + + /// \brief Recursively loop through this visual's children + /// to obtain the bounding box. + /// \param[in,out] _box The bounding box. + /// \param[in] _local A flag indicating if the local bounding box is to + /// be calculated. + /// \param[in] _pose World pose of the visual + private: virtual void BoundsHelper( + ignition::math::AxisAlignedBox &_box, bool _local, + const ignition::math::Pose3d &_pose) const; + + /// \brief Wrapper function for BoundsHelper to reduce redundant + /// world pose access + /// \param[in,out] _box The bounding box. + /// \param[in] _local A flag indicating if the local bounding box is to + /// be calculated. + private: virtual void BoundsHelper( + ignition::math::AxisAlignedBox &_box, bool _local) const; + + // Documentation inherited. + protected: virtual GeometryStorePtr Geometries() const override; + + // Documentation inherited. + protected: virtual bool AttachGeometry(GeometryPtr _geometry) override; + + // Documentation inherited. + protected: virtual bool DetachGeometry(GeometryPtr _geometry) override; + + /// \brief Initialize the visual + protected: virtual void Init() override; + + /// \brief Get a shared pointer to this. + /// \return Shared pointer to this + private: Ogre2VisualPtr SharedThis(); + + /// \brief Pointer to the attached geometries + protected: Ogre2GeometryStorePtr geometries; + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + + /// \brief Make scene our friend so it can create ogre2 visuals + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2WireBox.hh b/ogre2/include/gz/rendering/ogre2/Ogre2WireBox.hh new file mode 100644 index 000000000..48ed93447 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2WireBox.hh @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE2_OGRE2WIREBOX_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2WIREBOX_HH_ + +#include +#include "ignition/rendering/base/BaseWireBox.hh" +#include "ignition/rendering/ogre2/Ogre2Geometry.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2WireBoxPrivate; + + /// \brief Ogre2 implementation of a wire box geometry. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2WireBox + : public BaseWireBox + { + /// \brief Constructor + protected: Ogre2WireBox(); + + /// \brief Destructor + public: virtual ~Ogre2WireBox(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial(MaterialPtr _material, bool _unique) + override; + + /// \brief Set material to wire box geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); + + /// \brief Create the wire box geometry in ogre2 + private: void Create(); + + /// \brief Wire Box should only be created by scene. + private: friend class Ogre2Scene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/ogre2.hh.in b/ogre2/include/gz/rendering/ogre2/ogre2.hh.in new file mode 100644 index 000000000..c4092f0cd --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/ogre2.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/ogre2/include/ignition/rendering/ogre2.hh b/ogre2/include/ignition/rendering/ogre2.hh new file mode 100644 index 000000000..d1fc687de --- /dev/null +++ b/ogre2/include/ignition/rendering/ogre2.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Export.hh b/ogre2/include/ignition/rendering/ogre2/Export.hh new file mode 100644 index 000000000..564f51473 --- /dev/null +++ b/ogre2/include/ignition/rendering/ogre2/Export.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2023 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh index 60dbd73c0..b8140cae0 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,32 +14,5 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2ARROWVISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2ARROWVISUAL_HH_ - -#include "ignition/rendering/base/BaseArrowVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre2.x implementation of the arrow visual class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ArrowVisual : - public BaseArrowVisual - { - /// \brief Constructor - protected: Ogre2ArrowVisual(); - - /// \brief Destructor - public: virtual ~Ogre2ArrowVisual(); - - /// \brief Only scene can instantiate an arrow visual - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh index e76bde5b8..198898c66 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,32 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2AXISVISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2AXISVISUAL_HH_ -#include "ignition/rendering/base/BaseAxisVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre2.x implementation of the axis visual class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2AxisVisual : - public BaseAxisVisual - { - /// \brief Constructor - protected: Ogre2AxisVisual(); - - /// \brief Destructor - public: virtual ~Ogre2AxisVisual(); - - /// \brief Only scene can instantiate an axis visual - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2BoundingBoxCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2BoundingBoxCamera.hh index 28366b031..0c5c31eb7 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2BoundingBoxCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2BoundingBoxCamera.hh @@ -1,6 +1,5 @@ /* - * - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,159 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ - -#ifndef IGNITION_RENDERING_OGRE2_OGRE2BOUNDINGBOXCAMERA_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2BOUNDINGBOXCAMERA_HH_ - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -#include -#include - -#include "ignition/rendering/base/BaseBoundingBoxCamera.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2BoundingBoxCameraPrivate; - - /// \brief BoundingBox camera used to detect 2d / 3d bounding boxes - /// of labeled objects in the scene - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2BoundingBoxCamera : - public BaseBoundingBoxCamera - { - /// \brief Constructor - protected: Ogre2BoundingBoxCamera(); - - /// \brief Destructor - public: virtual ~Ogre2BoundingBoxCamera(); - - /// \brief Initialize the camera - public: virtual void Init() override; - - /// \brief Destroy the camera - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void Render() override; - - // Documentation inherited - public: virtual void PostRender() override; - - // Documentation inherited - public: virtual const std::vector &BoundingBoxData() const - override; - - // Documentation inherited - public: virtual ignition::common::ConnectionPtr - ConnectNewBoundingBoxes( - std::function &)>) override; - - // Documentation inherited - public: virtual void SetBoundingBoxType(BoundingBoxType _type) override; - - // Documentation inherited - public: virtual BoundingBoxType Type() const override; - - /// \brief Create texture to hold ogre Ids to calculate the boundaries - /// of each ogre id mask - public: void CreateBoundingBoxTexture(); - - /// \brief Create dummy render texture. Needed to satisfy inheritance - /// and to set image's dims - public: void CreateRenderTexture(); - - /// \brief Compute the full bounding boxes by projecting all mesh vertices - /// of each object, then get the min & max of x & y to get the full bbox. - /// Check the visibility by looping over pixels of the ogre Ids map - public: void FullBoundingBoxes(); - - /// \brief Compute the visible bounding boxes by looping over pixels of - /// the ogre Ids map, to get the boundaries of each unique ogre Id mask - public: void VisibleBoundingBoxes(); - - /// \brief Compute the 3D bounding boxes - public: void BoundingBoxes3D(); - - /// \brief Get minimal bounding box of the mesh by projecting the 3d - /// vertices of the vertex buffer to 2d, then get the min & max of x & y - /// \param[in] _mesh Mesh of the item to get its minimal bbox - /// \param[in] _viewMatrix Camera view matrix - /// \param[in] _projMatrix Camera projection matrix - /// \param[out] _minVertex Minimum of projected x & y & z of the vertices - /// \param[out] _maxVertex Maximum of projected x & y & z of the vertices - /// \param[in] _position position of the item in the world space - /// \param[in] _orientation rotation of the item - /// \param[in] _scale scale of the item - public: void MeshMinimalBox( - const Ogre::MeshPtr _mesh, - const Ogre::Matrix4 &_viewMatrix, - const Ogre::Matrix4 &_projMatrix, - Ogre::Vector3 &_minVertex, - Ogre::Vector3 &_maxVertex, - const Ogre::Vector3 &_position, - const Ogre::Quaternion &_orientation, - const Ogre::Vector3 &_scale - ); - - // Documentation inherited - public: virtual void DrawBoundingBox(unsigned char *_data, - const math::Color &_color, const BoundingBox &_box) const override; - - /// \brief Draw line between any 2 points in the image data buffer - /// Algorithm: https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm - /// \param[in] _data buffer contains the image data - /// \param[in] _point1 The 1st 2D point in screen coordinates - /// \param[in] _point2 The 2nd 2D point in screen coordinates - /// \param[in] _color The color of the line - public: void DrawLine(unsigned char *_data, - const math::Vector2i &_point1, const math::Vector2i &_point2, - const ignition::math::Color &_color) const; - - /// \brief Convert from clip coord (after projection) to screen coord. - /// \param[in, out] _minVertex min vertex in clip coord to screen coord - /// \param[in, out] _maxVertex max vertex in clip coord to screen coord - public: void ConvertToScreenCoord(Ogre::Vector3 &_minVertex, - Ogre::Vector3 &_maxVertex) const; - - /// \brief Mark the visible boxes by checking the ogre ids map and mark - /// the ogre id which appears in the map. - public: void MarkVisibleBoxes(); - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Create the camera. - private: void CreateCamera(); - - /// \brief Merge a links's 2d boxes of multi links models - private: void MergeMultiLinksModels2D(); - - /// \brief Merge a links's 3d boxes of multi links models - private: void MergeMultiLinksModels3D(); - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - private: friend class Ogre2Scene; - }; - } - } -} -#endif + */ +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2COMVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2COMVisual.hh index d55afb8b7..37ffa91ee 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2COMVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2COMVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,71 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ - -#ifndef IGNITION_RENDERING_OGRE_OGRE2COMVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGRE2COMVISUAL_HH_ - -#include - -#include "ignition/rendering/base/BaseCOMVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - // Forward declaration - class Ogre2COMVisualPrivate; - - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2COMVisual : - public BaseCOMVisual - { - /// \brief Constructor - protected: Ogre2COMVisual(); - - /// \brief Destructor - public: virtual ~Ogre2COMVisual(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - protected: virtual void Destroy() override; - - /// \brief Create the Light Visual in Ogre - public: void CreateVisual(); - - // Documentation inherited - public: virtual VisualPtr SphereVisual() const override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial( - MaterialPtr _material, bool _unique) override; - - /// \brief Set material to grid geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); - - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif + */ +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh index 2cd990c36..c4f5bfede 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,174 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2CAMERA_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2CAMERA_HH_ -#include - -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" - -namespace Ogre -{ - class Camera; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2CameraPrivate; - class Ogre2SelectionBuffer; - - /// \brief Ogre2.x implementation of the camera class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Camera : - public BaseCamera - { - /// \brief Constructor - protected: Ogre2Camera(); - - /// \brief Destructor - public: virtual ~Ogre2Camera(); - - // Documentation inherited. - public: virtual math::Angle HFOV() const override; - - // Documentation inherited. - public: virtual void SetHFOV(const math::Angle &_hfov) override; - - // Documentation inherited. - public: virtual double AspectRatio() const override; - - // Documentation inherited. - public: virtual void SetAspectRatio(const double _ratio) override; - - // Documentation inherited. - public: virtual unsigned int AntiAliasing() const override; - - // Documentation inherited. - public: virtual void SetAntiAliasing(const unsigned int _aa) override; - - // Documentation inherited. - public: virtual void SetFarClipPlane(const double _far) override; - - // Documentation inherited. - public: virtual void SetNearClipPlane(const double _near) override; - - public: virtual math::Color BackgroundColor() const; - - public: virtual void SetBackgroundColor(const math::Color &_color); - - /// \brief Get the background material of this camera - /// \return Background material of this camera - public: virtual MaterialPtr BackgroundMaterial() const; - - /// \brief Set the background material of this camera - /// \param[in] _material Material to set the background to - public: virtual void SetBackgroundMaterial(MaterialPtr _material); - - // Documentation inherited. - public: virtual void Render() override; - - // Documentation inherited. - public: virtual RenderWindowPtr CreateRenderWindow() override; - - // Documentation inherited. - public: virtual math::Matrix4d ProjectionMatrix() const override; - - // Documentation inherited. - public: virtual void SetProjectionMatrix( - const math::Matrix4d &_matrix) override; - - // Documentation inherited. - public: virtual math::Matrix4d ViewMatrix() const override; - - // Documentation inherited. - public: virtual void SetProjectionType(CameraProjectionType _type) - override; - - // Documentation inherited - public: virtual VisualPtr VisualAt(const ignition::math::Vector2i - &_mousePos) override; - - // Documentation Inherited. - // \sa Camera::SetMaterial(const MaterialPtr &) - public: virtual void SetMaterial( - const MaterialPtr &_material) override; - - // Documentation inherited. - public: virtual unsigned int RenderTextureGLId() const override; - - // Documentation inherited. - public: void SetShadowsDirty() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - public: Ogre::Camera *OgreCamera() const; - - // Documentation inherited. - public: virtual void SetVisibilityMask(uint32_t _mask) override; - - /// \brief Get the selection buffer object - /// \return the selection buffer object - public: Ogre2SelectionBuffer *SelectionBuffer() const; - - // Documentation inherited. - protected: virtual RenderTargetPtr RenderTarget() const override; - - // Documentation inherited. - protected: virtual void Init() override; - - /// \brief Create a render texture for the camera for offscreen rendering - protected: virtual void CreateRenderTexture(); - - /// \brief Destroy render texture created by CreateRenderTexture() - /// Note: It's not virtual. - protected: void DestroyRenderTexture(); - - /// \brief Create and set selection buffer object - /// TODO(anyone) to be implemented - protected: virtual void SetSelectionBuffer(); - - /// \brief Create internal camera object - private: void CreateCamera(); - - /// \brief Notifies us that the shadow node definition is about to be - /// updated. This means our compositor workspace must be destroyed - /// because the shadow node definition it's using will become a - /// dangling pointer otherwise - /// \sa SetShadowsDirty - private: void SetShadowsNodeDefDirty(); - - /// \brief Pointer to ogre camera object - protected: Ogre::Camera *ogreCamera = nullptr; - - /// \brief Selection buffer object for entity picking - protected: Ogre2SelectionBuffer *selectionBuffer = nullptr; - - /// \brief Pointer to render texture - protected: Ogre2RenderTargetPtr renderTexture; - - /// \brief Color of background - protected: math::Color backgroundColor; - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - - /// \brief Make scene our friend so it can create a camera - private: friend class Ogre2Scene; - - /// \brief Make ray query our friend so it can use the internal ogre - /// camera to execute queries - private: friend class Ogre2RayQuery; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Capsule.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Capsule.hh index 8832c012a..1cb12beb8 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Capsule.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Capsule.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,69 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ - -#ifndef IGNITION_RENDERING_OGRE2_OGRE2CAPSULE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2CAPSULE_HH_ - -#include -#include - -#include "ignition/rendering/base/BaseCapsule.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // Forward declaration - class Ogre2CapsulePrivate; - - /// \brief Ogre 2.x implementation of a Capsule Geometry. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Capsule - : public BaseCapsule - { - /// \brief Constructor - protected: Ogre2Capsule(); - - /// \brief Destructor - public: virtual ~Ogre2Capsule(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void - SetMaterial(MaterialPtr _material, bool _unique) override; - - /// \brief Update the capsule geometry in ogre - private: void Update(); - - /// \brief Capsule should only be created by scene. - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif + */ +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh index ae88820c7..9a53f0a7e 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,106 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2CONVERSIONS_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2CONVERSIONS_HH_ -#include -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/ogre2/Export.hh" - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif - -#include -#include -#include - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \addtogroup ign_rendering - /// \{ - - /// \brief Conversions Conversions.hh rendering/Conversions.hh - /// \brief A set of utility function to convert between Ignition and Ogre - /// data types - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Conversions - { - /// \brief Return the equivalent ogre color - /// \param[in] _color ign-math color to convert - /// \return Ogre color value - public: static Ogre::ColourValue Convert( - const math::Color &_color); - - /// \brief Return the equivalent ign-math color - /// \param[in] _color Ogre color to convert - /// \return ign-math color value - public: static math::Color Convert( - const Ogre::ColourValue &_color); - - /// \brief return Ogre Vector from ign-math Vector3 - /// \param[in] _vector ign-math vector - /// \return Ogre vector - public: static Ogre::Vector3 Convert(const math::Vector3d &_vector); - - /// \brief return ign-math Vector from ogre Vector3 - /// \param[in] _vector Ogre vector - /// \return ign-math vector - public: static math::Vector3d Convert(const Ogre::Vector3 &_vector); - - /// \brief Ign-math quaternion to Ogre quaternion - /// \param[in] _quat ign-math quaternion - /// \return Ogre quaternion - public: static Ogre::Quaternion Convert(const math::Quaterniond &_quat); - - /// \brief Ogre quaternion to ign-math quaternion - /// \param[in] _quat Ogre quaternion - /// return ign-math quaternion - public: static math::Quaterniond Convert(const Ogre::Quaternion &_quat); - - /// \brief Ign-math angle to Ogre angle - /// \param[in] _angle ign-math angle - /// \return Ogre angle - public: static Ogre::Radian Convert(const math::Angle &_angle); - - /// \brief Ogre angle to ign-math angle - /// \param[in] _angle Ogre angle - /// return Ign-math angle - public: static math::Angle Convert(const Ogre::Radian &_angle); - - /// \brief Ogre Matrix4 to ignition math Matrix4d - /// \param[in] _m Ogre Matrix4 - /// \return ignition math Matrix4d - public: static math::Matrix4d Convert(const Ogre::Matrix4 &_m); - - /// \brief Ignition math Matrix4d to Ogre Matrix4 - /// \param[in] _m ignition math Matrix4d - /// \return Ogre Matrix4 - public: static Ogre::Matrix4 Convert(const math::Matrix4d &_m); - - /// \brief Ign-rendering PixelFormat to Ogre PixelFormat - /// \param[in] _format Ign-rendering PixelFormat - /// return Ogre PixelFormat - public: static Ogre::PixelFormatGpu Convert(PixelFormat _format); - - /// \brief A list of ogre pixel formats - private: static const Ogre::PixelFormatGpu ogrePixelFormats[PF_COUNT]; - }; - /// \} - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh index 8c97445fd..a82872719 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,151 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2DEPTHCAMERA_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2DEPTHCAMERA_HH_ - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -#include -#include - -#include "ignition/rendering/base/BaseDepthCamera.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" - -#include "ignition/common/Event.hh" -#include "ignition/common/Console.hh" - -namespace Ogre -{ - class Material; - class RenderTarget; - class Texture; - class Viewport; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2DepthCameraPrivate; - - /// \brief Depth camera used to render depth data into an image buffer - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DepthCamera : - public BaseDepthCamera - { - /// \brief Constructor - protected: Ogre2DepthCamera(); - - /// \brief Destructor - public: virtual ~Ogre2DepthCamera(); - - /// \brief Initialize the camera - public: virtual void Init() override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Create dummy render texture. Needed to satisfy inheritance - public: virtual void CreateRenderTexture(); - - /// \brief Create a texture which will hold the depth data - /// \brief Set up 1st pass material, texture, and compositor - public: virtual void CreateDepthTexture() override; - - /// \brief Creates an Ogre Workspace instance. Assumes the definition - /// already and the depth texture have already been created - private: void CreateWorkspaceInstance(); - - // Documentation inherited - public: virtual void PreRender() override; - - /// \brief Render the camera - public: virtual void PostRender() override; - - /// \brief All things needed to get back z buffer for depth data - /// \return The z-buffer as a float array - public: virtual const float *DepthData() const override; - - /// \brief Connect a to the new depth image signal - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewDepthFrame( - std::function _subscriber) override; - - /// \brief Connect a to the new rgb point cloud signal - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewRgbPointCloud( - std::function _subscriber) override; - - /// \brief Implementation of the render call - public: virtual void Render() override; - - /// \brief Set the far clip distance - /// \param[in] _far far clip distance - public: virtual void SetFarClipPlane(const double _far) override; - - /// \brief Set the near clip distance - /// \param[in] _near Near clip distance - public: virtual void SetNearClipPlane(const double _near) override; - - /// \brief Get the near clip distance - /// \return Near clip distance. A value of zero is returned if the - /// ogre camera has not been created. - public: double NearClipPlane() const override; - - /// \brief Get the far clip distance - /// \return Far clip distance. A value of zero is returned if the - /// ogre camera has not been created. - public: double FarClipPlane() const override; - - // Documentation inherited. - public: void SetShadowsDirty() override; - - // Documentation inherited. - public: void AddRenderPass(const RenderPassPtr &_pass) override; - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Limit field of view taking care of using a valid value for - /// an OGRE camera. - /// \param[in] _fov expected field of view - /// \return valid field of view - protected: static double LimitFOV(const double _fov); - - /// \brief Create the camera. - protected: void CreateCamera(); - - /// \brief Notifies us that the shadow node definition is about to be - /// updated. This means our compositor workspace must be destroyed - /// because the shadow node definition it's using will become a - /// dangling pointer otherwise - /// \sa SetShadowsDirty - private: void SetShadowsNodeDefDirty(); - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera; - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh index 245ef3fd9..53e199aff 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,137 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2DYNAMICRENDERABLE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2DYNAMICRENDERABLE_HH_ + */ -#include -#include -#include - -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/Marker.hh" - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif -#include -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations - class Ogre2DynamicRenderablePrivate; - - /* \class Ogre2DynamicRenderable Ogre2DynamicRenderable.hh \ - * ignition/rendering/ogre2/Ogre2DynamicRenderable.hh - */ - /// \brief Dynamic renderable class that manages hardware buffers for - /// a dynamic geometry - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DynamicRenderable - { - /// \brief Constructor - /// \param[in] _scene Pointer to scene - public: explicit Ogre2DynamicRenderable(ScenePtr _scene); - - /// \brief Virtual destructor - public: virtual ~Ogre2DynamicRenderable(); - - /// \brief Set the render operation type - /// \param[in] _opType The type of render operation to perform. - public: void SetOperationType(MarkerType _opType); - - /// \brief Get the render operation type - /// \return The render operation type. - public: MarkerType OperationType() const; - - /// \brief Update the dynamic renderable - public: void Update(); - - /// \brief Get the ogre object associated with this dynamic renderable - public: Ogre::MovableObject *OgreObject() const; - - /// \brief Add a point to the point list - /// \param[in] _pt ignition::math::Vector3d point - /// \param[in] _color ignition::math::Color Point color - public: void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color = ignition::math::Color::White); - - /// \brief Add a point to the point list. - /// \param[in] _x X position - /// \param[in] _y Y position - /// \param[in] _z Z position - /// \param[in] _color Point color - public: void AddPoint(const double _x, const double _y, const double _z, - const ignition::math::Color &_color = ignition::math::Color::White); - - /// \brief Change the location of an existing point in the point list - /// \param[in] _index Index of the point to set - /// \param[in] _value Position of the point - public: void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value); - - /// \brief Change the color of an existing point in the point list - /// \param[in] _index Index of the point to set - /// \param[in] _color color to set the point to - public: void SetColor(unsigned int _index, - const ignition::math::Color &_color); - - /// \brief Return the position of an existing point in the point list - /// \param[in] _index Get the point at this index - /// \return position of point. A vector of - /// [ignition::math::INF_D, ignition::math::INF_D, ignition::math::INF_D] - /// is returned when then the _index is out of bounds. - /// ignition::math::INF_D==std::numeric_limits::infinity() - public: ignition::math::Vector3d Point(unsigned int _index) const; - - /// \brief Return the total number of points in the point list - /// \return Number of points - public: unsigned int PointCount() const; - - /// \brief Remove all points from the point list - public: void Clear(); - - /// \brief Destroy the dynamic renderable - public: void Destroy(); - - /// \brief Set the material for this dynamic renderable - /// \param[in] _material New Material to be assigned - /// \param[in] _unique True if the given material should be cloned - public: void SetMaterial(MaterialPtr _material, bool _unique = true); - - /// \brief Create the dynamic mesh - private: void CreateDynamicMesh(); - - /// \brief Update vertex buffer if vertices have changes - private: void UpdateBuffer(); - - /// \brief Helper function to generate normals - /// \param[in] _opType Ogre render operation type - /// \param[in] _vertices a list of vertices - /// \param[in,out] _vbuffer vertex buffer to be filled - private: void GenerateNormals(Ogre::OperationType _opType, - const std::vector &_vertices, float *_vbuffer); - - /// \brief Destroy the vertex buffer - private: void DestroyBuffer(); - - /// \brief Pointer to private data - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh index 05c65caac..50ddf972a 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,47 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2GAUSSIANNOISEPASS_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2GAUSSIANNOISEPASS_HH_ -#include - -#include "ignition/rendering/base/BaseGaussianNoisePass.hh" -#include "ignition/rendering/ogre2/Ogre2RenderPass.hh" -#include "ignition/rendering/ogre2/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2GaussianNoisePassPrivate; - - /* \class Ogre2GaussianNoisePass Ogre2GaussianNoisePass.hh \ - * ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh - */ - /// \brief Ogre2 Implementation of a Gaussian noise render pass. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2GaussianNoisePass : - public BaseGaussianNoisePass - { - /// \brief Constructor - public: Ogre2GaussianNoisePass(); - - /// \brief Destructor - public: virtual ~Ogre2GaussianNoisePass(); - - // Documentation inherited - public: void PreRender() override; - - // Documentation inherited - public: void CreateRenderPass() override; - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh index fbea7edf5..8951eb047 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,55 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2GEOMETRY_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2GEOMETRY_HH_ -#include "ignition/rendering/base/BaseGeometry.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre2.x implementation of the geometry class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Geometry : - public BaseGeometry - { - /// \brief Constructor - protected: Ogre2Geometry(); - - /// \brief Destructor - public: virtual ~Ogre2Geometry(); - - // Documentation inherited. - public: virtual bool HasParent() const override; - - // Documentation inherited. - public: virtual VisualPtr Parent() const override; - - /// \brief Get the ogre object representing this geometry - /// \return Pointer to an ogre movable object - public: virtual Ogre::MovableObject *OgreObject() const = 0; - - /// \brief Set the parent of this ogre geometry - /// \param[in] _parent Parent visual - protected: virtual void SetParent(Ogre2VisualPtr _parent); - - /// \brief Parent visual - protected: Ogre2VisualPtr parent; - - /// \brief Make ogre2 visual our friend so it can it can access function - /// for setting the parent of this geometry - private: friend class Ogre2Visual; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh index daf85011d..b082ccdc7 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2GIZMOVISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2GIZMOVISUAL_HH_ -#include "ignition/rendering/base/BaseGizmoVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2GizmoVisual : - public BaseGizmoVisual - { - /// \brief Constructor - protected: Ogre2GizmoVisual(); - - /// \brief Destructor - public: virtual ~Ogre2GizmoVisual(); - - /// \brief Only the ogre scene can instanstiate this class - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh index 4e609a191..b524a3744 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,152 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2GPURAYS_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2GPURAYS_HH_ - -#include -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/base/BaseGpuRays.hh" -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" - -#include "ignition/common/Event.hh" -#include "ignition/common/Console.hh" - -namespace Ogre -{ - class Material; - class RenderTarget; - class Texture; - class Viewport; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2GpuRaysPrivate; - - /// \brief Gpu Rays used to render range data into an image buffer - /// The ogre2 implementation takes a 2 pass process to generate - /// the final range data. - /// 1st Pass: Creates a cubemap of range data. The cubemap is created from - /// six cameras looking in all directions. Depending on the min/max angles - /// specified, not all cameras need to be created. Internally in the 1st - /// pass shaders, we reconstruct 3d viewspace pos from depth buffer data - /// then convert them into ranges, i.e. length(pos.xyz). - /// 2nd Pass: Samples range data from cubemap using predefined rays. The - /// rays are generated based on the specified vertical and horizontal - /// min/max angles and no. of samples. Each ray is a direction vector that - /// is used to sample/lookup the range data stored in the faces of the - /// cubemap. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2GpuRays : - public BaseGpuRays - { - /// \brief Constructor - protected: Ogre2GpuRays(); - - /// \brief Destructor - public: virtual ~Ogre2GpuRays(); - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Create dummy render texture. Needed to satisfy inheritance - public: virtual void CreateRenderTexture(); - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void PostRender() override; - - // Documentation inherited - public: virtual const float *Data() const override; - - // Documentation inherited. - public: virtual void Copy(float *_data) override; - - // Documentation inherited. - public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( - std::function _subscriber) override; - - // Documentation inherited. - public: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Set the number of samples in the width and height for the - /// first pass texture. - /// \param[in] _w Number of samples in the horizontal sweep - /// \param[in] _h Number of samples in the vertical sweep - private: virtual void Set1stTextureSize(const unsigned int _w, - const unsigned int _h = 1); - - /// \brief Set the number of samples in the width and height for the - /// second pass texture. - /// \param[in] _w Number of samples in the horizontal sweep - /// \param[in] _h Number of samples in the vertical sweep - private: virtual void SetRangeCount(const unsigned int _w, - const unsigned int _h = 1); - - // Documentation inherited. - private: virtual void Render() override; - - /// \brief Configure camera. - private: void ConfigureCamera(); - - /// \brief Create an ortho camera. - private: void CreateCamera(); - - /// \brief Create the texture which is used to render gpu rays data. - private: virtual void CreateGpuRaysTextures(); - - /// \brief Update the render targets in the 1st pass - private: void UpdateRenderTarget1stPass(); - - /// \brief Update the 2nd pass render target - private: void UpdateRenderTarget2ndPass(); - - /// \brief Create texture that store cubemap uv coordinates and - /// cubemap face index data - private: void CreateSampleTexture(); - - /// \brief Set up 1st pass material, texture, and compositor - private: void Setup1stPass(); - - /// \brief Set up 2nd pass material, texture, and compositor - private: void Setup2ndPass(); - - /// \brief Helper function to convert a direction vector to the - /// index number of a cubemap face and texture uv coordinates on that face - /// \param[in] _v Direction vector - /// \param[out] _faceIndex Index of face to sample - /// \return Texture UV coordinates on the face indicated by _faceIndex - private: math::Vector2d SampleCubemap(const math::Vector3d &_v, - unsigned int &_faceIndex); - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - /// \brief Only the scene can create a GpuRays sensor - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh index 59538cdc4..81e386ec3 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,68 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2GRID_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2GRID_HH_ - -#include -#include "ignition/rendering/base/BaseGrid.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2GridPrivate; - - /// \brief Ogre2 implementation of a grid geometry. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Grid - : public BaseGrid - { - /// \brief Constructor - protected: Ogre2Grid(); - - /// \brief Destructor - public: virtual ~Ogre2Grid(); - - // Documentation inherited. - public: virtual void Init(); - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const; - - // Documentation inherited. - public: virtual void PreRender(); - - // Documentation inherited. - public: virtual MaterialPtr Material() const; - - // Documentation inherited. - public: virtual void SetMaterial(MaterialPtr _material, bool _unique); - - /// \brief Set material to grid geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); - - /// \brief Create the grid geometry in ogre - private: void Create(); - - /// \brief Grid should only be created by scene. - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Heightmap.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Heightmap.hh index cd214addb..fa6397375 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Heightmap.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Heightmap.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,104 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ - -#ifndef IGNITION_RENDERING_OGRE2_OGRE2HEIGHTMAP_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2HEIGHTMAP_HH_ - -#include - -#include "ignition/rendering/base/BaseHeightmap.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" - -// Ignoring warning: "non dll-interface class -// 'ignition::rendering::v5::Heightmap' used as base for dll-interface class" -// because `Heightmap` and `BaseHeightmap` are header-only -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable:4275) -#endif - -namespace Ogre -{ - class Camera; - class Terra; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2HeightmapPrivate; - - /// \brief Ogre implementation of a heightmap geometry. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Heightmap - : public BaseHeightmap - { - /// \brief Constructor - /// \param[in] _desc Parameters describing how a - /// heightmap should be loaded - public: explicit Ogre2Heightmap(const HeightmapDescriptor &_desc); - - /// \brief Destructor - public: virtual ~Ogre2Heightmap() override; - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - /// \brief Returns the Terra pointer as it is a movable object that - /// must be attached to a regular SceneNode - /// \remarks This behavior is different from ogre1 - /// \return Terra pointer - public: virtual Ogre::MovableObject *OgreObject() const override; - - /// \brief Returns NULL, heightmap materials don't inherit from - /// MaterialPtr. - /// \return Null pointer. - public: virtual MaterialPtr Material() const override; - - /// \brief Has no effect for heightmaps. The material is set through a - /// HeightmapDescriptor. - /// \param[in] _material Not used. - /// \param[in] _unique Not used. - public: virtual void SetMaterial(MaterialPtr _material, bool _unique) - override; - - /// \internal - /// \brief Retrieves the internal Terra pointer - /// \return internal Terra pointer - public: Ogre::Terra* Terra(); - - /// \internal - /// \brief Must be called before rendering with the camera - /// that will perform rendering. - /// - /// May update shadows if light direction changed - /// \param[in] _activeCamera Camera about to be used for rendering - public: void UpdateForRender(Ogre::Camera *_activeCamera); - - // Documentation inherited. - // \todo(iche033) rename this to Destroy and - // make this function public and virtual - private: void DestroyImpl(); - - /// \brief Heightmap should only be created by scene. - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#endif + */ +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh index 27d360bf7..06eb4d78e 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,106 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2INCLUDES_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2INCLUDES_HH_ -// This disables warning messages for OGRE -#ifndef _MSC_VER - #pragma GCC system_header -#else - #pragma warning(push, 0) -#endif - -// This prevents some deprecation #warning messages on OSX 10.9 -#pragma clang diagnostic ignored "-W#warnings" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -// TODO(anyone): enable when ogre 2.1 fully supports paging -// and terrain components -// #include -// #include -// #include -// #include -// #include -// #include - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2InertiaVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2InertiaVisual.hh index c15a2b112..87f84d034 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2InertiaVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2InertiaVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,74 +14,5 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2INERTIAVISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2INERTIAVISUAL_HH_ - -#include - -#include "ignition/rendering/base/BaseInertiaVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - // Forward declaration - class Ogre2InertiaVisualPrivate; - - /// \brief Ogre2.x implementation of the inertia visual class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2InertiaVisual : - public BaseInertiaVisual - { - /// \brief Constructor - protected: Ogre2InertiaVisual(); - - /// \brief Destructor - public: virtual ~Ogre2InertiaVisual(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - protected: virtual void Destroy() override; - - /// \brief Load the Inertia visual from its pose and scale - /// \param[in] _pose Pose of the Inertia visual - /// \param[in] _scale Scale factor of the box visual - public: void Load(const ignition::math::Pose3d &_pose, - const ignition::math::Vector3d &_scale) override; - - /// \brief Get the box visual - /// \return Pointer to the box visual - public: VisualPtr BoxVisual() const override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial( - MaterialPtr _material, bool _unique) override; - - /// \brief Set material to line geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); - - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2JointVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2JointVisual.hh index 4a7879384..311bb04db 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2JointVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2JointVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +14,5 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2JOINTVISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2JOINTVISUAL_HH_ - -#include "ignition/rendering/base/BaseJointVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2JointVisual : - public BaseJointVisual - { - /// \brief Constructor - protected: Ogre2JointVisual(); - - /// \brief Destructor - public: virtual ~Ogre2JointVisual(); - - /// \brief Only scene can instantiate this class - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2LidarVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2LidarVisual.hh index 8a3877496..eb233bd89 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2LidarVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2LidarVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,77 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ - -#ifndef IGNITION_RENDERING_OGRE2_OGRELIDARVISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRELIDARVISUAL_HH_ - -#include -#include -#include "ignition/rendering/base/BaseLidarVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2LidarVisualPrivate; - - /// \brief Ogre 2.x implementation of a Lidar Visual. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2LidarVisual - : public BaseLidarVisual - { - /// \brief Constructor - protected: Ogre2LidarVisual(); - - /// \brief Destructor - public: virtual ~Ogre2LidarVisual(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void Update() override; - - // Documentation inherited - public: virtual void SetPoints( - const std::vector &_points) override; - - // Documentation inherited - public: virtual void ClearPoints() override; - - // Documentation inherited - public: virtual unsigned int PointCount() const override; - - // Documentation inherited - public: virtual std::vector Points() const override; - - /// \brief Create the Lidar Visual in ogre - private: void Create(); - - /// \brief Clear data stored by dynamiclines - private: void ClearVisualData(); - - // Documentation inherited - public: virtual void SetVisible(bool _visible) override; - - /// \brief Lidar Visual should only be created by scene. - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif + */ +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh index 458a02e66..f8b328717 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,203 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2LIGHT_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2LIGHT_HH_ -#include - -#include "ignition/rendering/base/BaseLight.hh" -#include "ignition/rendering/ogre2/Ogre2Node.hh" - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif -#include -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -namespace Ogre -{ - class Light; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2LightPrivate; - - /// \brief Ogre 2.x implementation of the light class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Light : - public BaseLight - { - /// \brief Constructor - protected: Ogre2Light(); - - /// \brief Destructor - public: virtual ~Ogre2Light(); - - // Documentation Inherited - public: virtual math::Color DiffuseColor() const override; - - // Documentation Inherited - public: virtual void SetDiffuseColor(const math::Color &_color) override; - - // Documentation Inherited - public: virtual math::Color SpecularColor() const override; - - // Documentation Inherited - public: virtual void SetSpecularColor(const math::Color &_color) override; - - // Documentation Inherited - public: virtual double AttenuationConstant() const override; - - // Documentation Inherited - public: virtual void SetAttenuationConstant(double _value) override; - - // Documentation Inherited - public: virtual double AttenuationLinear() const override; - - // Documentation Inherited - public: virtual void SetAttenuationLinear(double _value) override; - - // Documentation Inherited - public: virtual double AttenuationQuadratic() const override; - - // Documentation Inherited - public: virtual void SetAttenuationQuadratic(double _value) override; - - // Documentation Inherited - public: virtual double AttenuationRange() const override; - - // Documentation Inherited - public: virtual void SetAttenuationRange(double _range) override; - - // Documentation Inherited - public: virtual bool CastShadows() const override; - - // Documentation Inherited - public: virtual void SetCastShadows(bool _castShadows) override; - - // Documentation Inherited - public: virtual double Intensity() const override; - - // Documentation Inherited - public: virtual void SetIntensity(double _intensity) override; - - /// \brief Get a pointer to ogre light - public: virtual Ogre::Light *Light() const; - - /// \brief Destroy the light - public: virtual void Destroy() override; - - /// \brief Initialize the light - protected: virtual void Init() override; - - /// \brief Create the light - private: void CreateLight(); - - /// \brief Update the attenuation based on the values specified. - private: void UpdateAttenuation(); - - /// \brief Attenuation constant value - protected: double attenConstant = 1.0; - - /// \brief Attenuation linear factor - protected: double attenLinear = 0.0; - - /// \brief Attenuation quadratic factor - protected: double attenQuadratic = 0.0; - - /// \brief Attenuation range - protected: double attenRange = 100.0; - - /// \brief Pointer to ogre light - protected: Ogre::Light *ogreLight = nullptr; - - /// \brief Light type - protected: Ogre::Light::LightTypes ogreLightType; - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - }; - - /// \brief Ogre 2.x implementation of the directional light class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DirectionalLight : - public BaseDirectionalLight - { - /// \brief Constructor - protected: Ogre2DirectionalLight(); - - /// \brief Destructor - public: virtual ~Ogre2DirectionalLight(); - - // Documentation Inherited - public: virtual math::Vector3d Direction() const override; - - // Documentation Inherited - public: virtual void SetDirection(const math::Vector3d &_dir) override; - - /// \brief Ogre 2.x implementation of the directional light class - private: friend class Ogre2Scene; - }; - - /// \brief Ogre 2.x implementation of the point light class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2PointLight : - public BasePointLight - { - /// \brief Constructor - protected: Ogre2PointLight(); - - /// \brief Destructor - public: virtual ~Ogre2PointLight(); - - /// \brief Only an ogre scene can create an ogre point light - private: friend class Ogre2Scene; - }; - - /// \brief Ogre 2.x implementation of the spot light class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SpotLight : - public BaseSpotLight - { - /// \brief Constructor - protected: Ogre2SpotLight(); - - /// \brief Destructor - public: virtual ~Ogre2SpotLight(); - - // Documentation inherited. - public: virtual math::Vector3d Direction() const override; - - // Documentation Inherited - public: virtual void SetDirection(const math::Vector3d &_dir) override; - - // Documentation Inherited - public: virtual math::Angle InnerAngle() const override; - - // Documentation Inherited - public: virtual void SetInnerAngle(const math::Angle &_angle) override; - - // Documentation Inherited - public: virtual math::Angle OuterAngle() const override; - - // Documentation Inherited - public: virtual void SetOuterAngle(const math::Angle &_angle) override; - - // Documentation Inherited - public: virtual double Falloff() const override; - - // Documentation Inherited - public: virtual void SetFalloff(double _falloff) override; - - /// \brief Only an ogre scene can create an ogre spot light - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2LightVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2LightVisual.hh index b1bd2281b..c8a21e599 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2LightVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2LightVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,68 +14,5 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2LIGHTVISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2LIGHTVISUAL_HH_ - -#include - -#include "ignition/rendering/base/BaseLightVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - // Forward declaration - class Ogre2LightVisualPrivate; - - /// \brief Ogre2.x implementation of the light visual class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2LightVisual : - public BaseLightVisual - { - /// \brief Constructor - protected: Ogre2LightVisual(); - - /// \brief Destructor - public: virtual ~Ogre2LightVisual(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: Ogre::MovableObject *OgreObject() const; - - /// \brief Create the Light Visual in Ogre2 - public: void CreateVisual(); - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial( - MaterialPtr _material, bool _unique) override; - - /// \brief Set material to grid geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); - - /// \brief Only scene can instantiate an arrow visual - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh index 0119aeec2..ecfb2ce75 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,80 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGREMARKER_HH_ -#define IGNITION_RENDERING_OGRE2_OGREMARKER_HH_ - -#include -#include "ignition/rendering/base/BaseMarker.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2MarkerPrivate; - - /// \brief Ogre 2.x implementation of a marker geometry. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Marker - : public BaseMarker - { - /// \brief Constructor - protected: Ogre2Marker(); - - /// \brief Destructor - public: virtual ~Ogre2Marker(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial( - MaterialPtr _material, bool _unique) override; - - // Documentation inherited - public: virtual void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value) override; - - // Documentation inherited - public: virtual void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color) override; - - // Documentation inherited - public: virtual void ClearPoints() override; - - // Documentation inherited - public: virtual void SetType(const MarkerType _markerType) override; - - // Documentation inherited - public: virtual MarkerType Type() const override; - - /// \brief Create the marker geometry in ogre - private: void Create(); - - /// \brief Marker should only be created by scene. - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh index dcf4c9fd8..23f14cb05 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,332 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2MATERIAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2MATERIAL_HH_ -#include -#include - -#include "ignition/rendering/base/BaseMaterial.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif -#include -#include -#include -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -namespace Ogre -{ - class HlmsPbsDatablock; - class HlmsUnlitDatablock; -} // namespace Ogre - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2MaterialPrivate; - - /// \brief Ogre 2.x implementation of the material class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Material : - public BaseMaterial - { - /// \brief Constructor - protected: Ogre2Material(); - - /// \brief Destructor - public: virtual ~Ogre2Material(); - - // Documentation inherited - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual math::Color Diffuse() const override; - - // Documentation inherited - public: virtual void SetDiffuse(const math::Color &_color) override; - - // Documentation inherited - public: virtual math::Color Specular() const override; - - // Documentation inherited - public: virtual void SetSpecular(const math::Color &_color) override; - - // Documentation inherited - public: virtual math::Color Emissive() const override; - - // Documentation inherited - public: virtual void SetEmissive(const math::Color &_color) override; - - // Documentation inherited - public: virtual void SetTransparency(const double _transparency) override; - - // Documentation inherited - public: virtual void SetAlphaFromTexture(bool _enabled, - double _alpha = 0.5, bool _twoSided = true) override; - - // Documentation inherited - public: virtual float RenderOrder() const override; - - // Documentation inherited - // Review the official documentation to get more details about this - // parameter, in particular mDepthBiasConstant - public: virtual void SetRenderOrder(const float _renderOrder) override; - - // Documentation inherited - public: virtual bool ReceiveShadows() const override; - - // Documentation inherited - public: virtual void SetReceiveShadows(const bool _receiveShadows) - override; - - // Documentation inherited - public: virtual bool HasTexture() const override; - - // Documentation inherited - public: virtual std::string Texture() const override; - - // Documentation inherited - public: virtual void SetTexture(const std::string &_texture) override; - - // Documentation inherited - public: virtual void ClearTexture() override; - - // Documentation inherited - public: virtual bool HasNormalMap() const override; - - // Documentation inherited - public: virtual std::string NormalMap() const override; - - // Documentation inherited - public: virtual void SetNormalMap(const std::string &_normalMap) override; - - // Documentation inherited - public: virtual void ClearNormalMap() override; - - // Documentation inherited - public: virtual bool HasRoughnessMap() const override; - - // Documentation inherited - public: virtual std::string RoughnessMap() const override; - - // Documentation inherited - public: virtual void SetRoughnessMap( - const std::string &_roughnessMap) override; - - // Documentation inherited - public: virtual void ClearRoughnessMap() override; - - // Documentation inherited - public: virtual bool HasMetalnessMap() const override; - - // Documentation inherited - public: virtual std::string MetalnessMap() const override; - - // Documentation inherited - public: virtual void SetMetalnessMap( - const std::string &_metalnessMap) override; - - // Documentation inherited - public: virtual void ClearMetalnessMap() override; - - // Documentation inherited - public: virtual bool HasEnvironmentMap() const override; - - // Documentation inherited - public: virtual std::string EnvironmentMap() const override; - - // Documentation inherited - public: virtual void SetEnvironmentMap( - const std::string &_metalnessMap) override; - - // Documentation inherited - public: virtual void ClearEnvironmentMap() override; - - // Documentation inherited - public: virtual void SetRoughness(const float _roughness) override; - - // Documentation inherited - public: virtual bool HasEmissiveMap() const override; - - // Documentation inherited - public: virtual std::string EmissiveMap() const override; - - // Documentation inherited - public: virtual void SetEmissiveMap( - const std::string &_emissiveMap) override; - - // Documentation inherited - public: virtual void ClearEmissiveMap() override; - - // Documentation inherited - public: virtual bool HasLightMap() const override; - - // Documentation inherited - public: virtual std::string LightMap() const override; - - // Documentation inherited - public: virtual unsigned int LightMapTexCoordSet() const override; - - // Documentation inherited - public: virtual void SetLightMap(const std::string &_lightMap, - unsigned int _uvSet = 0u) override; - - // Documentation inherited - public: virtual void ClearLightMap() override; - - // Documentation inherited - public: virtual float Roughness() const override; - - // Documentation inherited - public: virtual void SetMetalness(const float _roughness) override; - - // Documentation inherited - public: virtual float Metalness() const override; - - /// \brief Return ogre low level material - /// \return Ogre material pointer - public: virtual Ogre::MaterialPtr Material(); - - /// \brief Return ogre Hlms material pbs datablock - /// \return Ogre Hlms pbs datablock - public: virtual Ogre::HlmsPbsDatablock *Datablock() const; - - /// \brief Return ogre Hlms material unlit datablock - /// \return Ogre Hlms unlit datablock - public: virtual Ogre::HlmsUnlitDatablock *UnlitDatablock(); - - /// \brief Fill the input unlit datablock with current material - /// properties from the pbs datablock - /// \param[in] _datablock Unlit datablock to fill - public: virtual void FillUnlitDatablock( - Ogre::HlmsUnlitDatablock *_datablock) const; - - // Documentation inherited. - // \sa BaseMaterial::PreRender() - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual enum MaterialType Type() const override; - - // Documentation inherited - public: virtual bool DepthCheckEnabled() const override; - - // Documentation inherited - public: virtual void SetDepthCheckEnabled(bool _enabled) override; - - // Documentation inherited - public: virtual bool DepthWriteEnabled() const override; - - // Documentation inherited - public: virtual void SetDepthWriteEnabled(bool _enabled) override; - - // Documentation inherited. - // \sa Material::SetVertexShader(const std::string &) - public: virtual void SetVertexShader(const std::string &_path) override; - - // Documentation inherited. - // \sa Material::VertexShader() const - public: virtual std::string VertexShader() const override; - - // Documentation inherited. - // \sa Material::VertexShaderParams() - public: virtual ShaderParamsPtr VertexShaderParams() override; - - // Documentation inherited. - // \sa Material::SetFragmentShader(const std::string &) - public: virtual void SetFragmentShader(const std::string &_path) - override; - - // Documentation inherited. - // \sa Material::FragmentShader() const - public: virtual std::string FragmentShader() const override; - - // Documentation inherited. - // \sa Material::FragmentShaderParams() - public: virtual ShaderParamsPtr FragmentShaderParams() override; - - /// \brief Set the texture map for this material - /// \param[in] _texture Name of the texture. - /// \param[in] _type Type of texture, i.e. diffuse, normal, roughness, - /// metalness - protected: virtual void SetTextureMapImpl(const std::string &_texture, - Ogre::PbsTextureTypes _type); - - /// \brief Get a pointer to the ogre texture by name - /// \return Ogre texture - protected: virtual Ogre::TextureGpu *Texture(const std::string &_name); - - /// \brief Updates the material transparency in the engine, - /// based on transparency and diffuse alpha values - protected: virtual void UpdateTransparency(); - - // Documentation inherited. - protected: virtual void Init() override; - - /// \brief bind shader parameters that have changed - protected: void UpdateShaderParams(); - - /// \brief Transfer params from ign-rendering type to ogre type - /// \param[in] _params ignition rendering params - /// \param[out] _ogreParams ogre type for holding params - protected: void UpdateShaderParams(ConstShaderParamsPtr _params, - Ogre::GpuProgramParametersSharedPtr _ogreParams); - - /// \brief Ogre material. Mainly used for render targets. - protected: Ogre::MaterialPtr ogreMaterial; - - /// \brief Ogre data block containing all pbs material properties - protected: Ogre::HlmsPbsDatablock *ogreDatablock = nullptr; - - /// \brief Ogre data block containing all unlit material properties - protected: Ogre::HlmsUnlitDatablock *ogreUnlitDatablock = nullptr; - - /// \brief Ogre high level physical based shading object - protected: Ogre::HlmsPbs *ogreHlmsPbs = nullptr; - - /// \brief Name of the texture - protected: std::string textureName; - - /// \brief Name of the normal map - protected: std::string normalMapName; - - /// \brief Name of the roughness map - protected: std::string roughnessMapName; - - /// \brief Name of the metalness map - protected: std::string metalnessMapName; - - /// \brief Name of the environment map - protected: std::string environmentMapName; - - /// \brief Name of the emissive map - protected: std::string emissiveMapName; - - /// \brief Name of the light map - protected: std::string lightMapName; - - /// \brief Texture coorindate set used by the light map - protected: unsigned int lightMapUvSet = 0u; - - /// \brief Unique id assigned to ogre hlms datablock - protected: std::string ogreDatablockId; - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - - /// \brief Only an ogre scene can create an ogre material - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh index 8f861b87f..4cced0f3d 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,97 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_ - -#include -#include - -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif -#include -#include -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations - class Ogre2SelectionBuffer; - - /// \brief Helper class to assign unique colors to renderables - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2MaterialSwitcher : - public Ogre::Camera::Listener - { - /// \brief Constructor - public: explicit Ogre2MaterialSwitcher(Ogre2ScenePtr _scene); - - /// \brief Destructor - public: ~Ogre2MaterialSwitcher(); - - /// \brief Get the entity with a specific color - /// \param[in] _color The entity's color. - public: std::string EntityName( - const ignition::math::Color &_color) const; - - /// \brief Reset the color value incrementor - public: void Reset(); - - /// \brief Ogre's pre render update callback - /// \param[in] _cam Ogre render target event containing information about - /// the source render target. - public: virtual void cameraPreRenderScene( - Ogre::Camera *_cam) override; - - /// \brief Ogre's post render update callback - /// \param[in] _cam Ogre render target event containing information about - /// the source render target. - public: virtual void cameraPostRenderScene(Ogre::Camera *_cam) override; - - /// \brief Current unique color value - private: ignition::math::Color currentColor; - - /// \brief Color dictionary that maps the unique color value to - /// renderable name - private: std::map colorDict; - - /// \brief A map of ogre sub item pointer to their original hlms material - private: std::map datablockMap; - - /// \brief Ogre v1 material consisting of a shader that changes the - /// appearance of item to use a unique color for mouse picking - private: Ogre::MaterialPtr plainMaterial; - - /// \brief Ogre v1 material consisting of a shader that changes the - /// appearance of item to use a unique color for mouse picking. In - /// addition, the depth check and depth write properties disabled. - private: Ogre::MaterialPtr plainOverlayMaterial; - - /// \brief Increment unique color value that will be assigned to the - /// next renderable - private: void NextColor(); - - /// \brief Selection Buffer class that make use of this class for - /// selecting entitiies - public: friend class Ogre2SelectionBuffer; - - /// \brief Plain material technique - private: Ogre2ScenePtr scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh index cbad21a14..7c1ae35fa 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,142 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2MESH_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2MESH_HH_ -#include -#include -#include -#include -#include -#include "ignition/rendering/base/BaseMesh.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" - -namespace Ogre -{ - class Item; - class SubItem; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2MeshPrivate; - class Ogre2SubMeshPrivate; - - /// \brief Ogre2.x implementation of the mesh class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Mesh : - public BaseMesh - { - /// \brief Constructor - protected: Ogre2Mesh(); - - /// \brief Destructor - public: virtual ~Ogre2Mesh(); - - // Documentation inherited - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual bool HasSkeleton() const override; - - // Documentation inherited. - public: virtual std::map - SkeletonLocalTransforms() const override; - - // Documentation inherited. - public: virtual void SetSkeletonLocalTransforms( - const std::map &_tfs) override; - - // Documentation inherited. - public: virtual std::unordered_map - SkeletonWeights() const override; - - // Documentation inherited. - public: virtual void SetSkeletonWeights( - const std::unordered_map &_weights) override; - - // Documentation inherited. - public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, - bool _enabled, bool _loop = true, float _weight = 1.0) override; - - // Documentation inherited. - public: virtual bool SkeletonAnimationEnabled(const std::string &_name) - const override; - - // Documentation inherited. - public: virtual void UpdateSkeletonAnimation( - std::chrono::steady_clock::duration _time) override; - - // Documentation inherited - public: virtual Ogre::MovableObject *OgreObject() const override; - - /// \brief Get a list of submeshes in this mesh - protected: virtual SubMeshStorePtr SubMeshes() const override; - - /// \brief Store containing all the submeshes - protected: Ogre2SubMeshStorePtr subMeshes; - - /// \brief Pointer to the ogre item object - protected: Ogre::Item *ogreItem = nullptr; - - /// \brief Make scene our friend so it can create an ogre2 mesh - private: friend class Ogre2Scene; - - /// \brief Make mesh factory our friend so it can create an ogre2 mesh - private: friend class Ogre2MeshFactory; - - /// \brief Pointer to private data - private: std::unique_ptr dataPtr; - }; - - /// \brief Ogre2.x implementation of the submesh class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SubMesh : - public BaseSubMesh - { - /// \brief Constructor - protected: Ogre2SubMesh(); - - /// \brief Destructor - public: virtual ~Ogre2SubMesh(); - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Set the name of the mesh stored in Ogre2 - /// \param[in] _name Name of the mesh - public: void SetMeshName(const std::string &_name); - - /// \brief Get internal ogre subitem created from this submesh - public: virtual Ogre::SubItem *Ogre2SubItem() const; - - /// \brief Helper function for setting the material to use - /// \param[in] _material Material to be assigned to the submesh - protected: virtual void SetMaterialImpl(MaterialPtr _material) override; - - /// \brief Initialize the submesh - protected: virtual void Init() override; - - /// \brief Ogre subitem representing the submesh - protected: Ogre::SubItem *ogreSubItem = nullptr; - - /// \brief Make scene our friend so it can create an ogre2 mesh - private: friend class Ogre2Scene; - - /// \brief Make submesh factory our friend so it can create an - /// ogre2 submesh - private: friend class Ogre2SubMeshStoreFactory; - - /// \brief Pointer to private data - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh index 202607cea..51202d304 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,137 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_ -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/MeshDescriptor.hh" -#include "ignition/rendering/ogre2/Ogre2Mesh.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Export.hh" - -namespace Ogre -{ - class Item; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2MeshFactoryPrivate; - class Ogre2SubMeshStoreFactoryPrivate; - - /// \brief Ogre2.x implementation of the mesh factory class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2MeshFactory - { - /// \brief Constructor - /// \param[in] _scene Pointer to the scene - public: explicit Ogre2MeshFactory(Ogre2ScenePtr _scene); - - /// \brief Destructor - public: virtual ~Ogre2MeshFactory(); - - /// \brief Create a mesh from a descriptor - /// \param[in] _desc Mesh descriptor containing data needed to create a - /// mesh - public: virtual Ogre2MeshPtr Create(const MeshDescriptor &_desc); - - /// \brief Cleanup and clear all internal ogre v2 meshes created by this - /// factory - public: virtual void Clear(); - - /// \brief Get the ogre item based on the mesh descriptor - /// \param[in] _desc Descriptor describing the target mesh - protected: virtual Ogre::Item *OgreItem( - const MeshDescriptor &_desc); - - /// \brief Load a mesh using a mesh descriptor - /// \param[in] _desc Mesh descriptor - protected: virtual bool Load(const MeshDescriptor &_desc); - - /// \brief Check if the mesh is loaded using a mesh descriptor - /// \param[in] _desc Mesh descriptor containing the mesh name used - /// by this function for checking the loaded state - protected: virtual bool IsLoaded(const MeshDescriptor &_desc); - - /// \brief Helper function to load the mesh from the input mesh descriptor - /// \param[in] _desc Input mesh descriptor - protected: virtual bool LoadImpl(const MeshDescriptor &_desc); - - /// \brief Get the mesh name from the mesh descriptor - /// \param[in] _desc Mesh descriptor containing the mesh name - protected: virtual std::string MeshName(const MeshDescriptor &_desc); - - /// \brief Validate the mesh descriptor to make sure it contains all the - /// needed information to create a mesh - /// \param[in] _desc Mesh descriptor to be validated - protected: virtual bool Validate(const MeshDescriptor &_desc); - - /// \brief A list of ogre meshes created by this factory - protected: std::vector ogreMeshes; - - /// \brief Pointer to the scene object - protected: Ogre2ScenePtr scene; - - /// \brief Remove internal material cache for a specific material - public: void ClearMaterialsCache(const std::string &_name); - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - }; - - /// \brief Ogre2.x implementation of a submesh store factory class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SubMeshStoreFactory - { - /// \brief Constructor - /// \param[in] _scene Pointer to the scene object - /// \param[in] _item Parent ogre item - public: Ogre2SubMeshStoreFactory(Ogre2ScenePtr _scene, - Ogre::Item *_item); - - /// \brief Destructor - public: virtual ~Ogre2SubMeshStoreFactory(); - - /// \brief Create the submeshes - /// \return A store containing all the submeshes - public: virtual Ogre2SubMeshStorePtr Create(); - - /// \brief Helper function to create submesh at the given index - /// \param[in] _index Index of the ogre subitem. The subitem is then used - /// to create the submesh. - protected: virtual Ogre2SubMeshPtr CreateSubMesh(unsigned int _index); - - /// \brief Create a list of names and the corresponding submesh object - protected: virtual void CreateNameList(); - - /// \brief Populate the name list with default generated names - protected: virtual void PopulateDefaultNames(); - - /// \brief Populate the name list with names associated with each ogre - /// subitem - protected: virtual void PopulateGivenNames(); - - /// \brief Pointer to the scene object - protected: Ogre2ScenePtr scene; - - /// \brief Pointer to the parent ogre item - protected: Ogre::Item *ogreItem = nullptr; - - /// \brief A list of names associated with each ogre subitem / submesh - protected: std::vector names; - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh index 5a6be9005..2553e4f60 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,120 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2NODE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2NODE_HH_ -#include "ignition/rendering/base/BaseNode.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" - -namespace Ogre -{ - class SceneNode; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre2.x implementation of the Node class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Node : - public BaseNode - { - /// \brief Constructor - protected: Ogre2Node(); - - /// \brief Destructor - public: virtual ~Ogre2Node(); - - // Documentation inherited. - public: virtual bool HasParent() const override; - - // Documentation inherited. - public: virtual NodePtr Parent() const override; - - /// \brief Get a pointer to the underlying scene node - /// \return Ogre scene node pointer - public: virtual Ogre::SceneNode *Node() const; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual math::Vector3d LocalScale() const override; - - // Documentation inherited. - public: virtual bool InheritScale() const override; - - // Documentation inherited. - public: virtual void SetInheritScale(bool _inherit) override; - - // Documentation inherited. - protected: virtual void SetLocalScaleImpl( - const math::Vector3d &_scale) override; - - // Documentation inherited. - protected: virtual NodeStorePtr Children() const override; - - // Documentation inherited. - protected: virtual bool AttachChild(NodePtr _child) override; - - // Documentation inherited. - protected: virtual bool DetachChild(NodePtr _child) override; - - // Documentation inherited. - protected: virtual math::Pose3d RawLocalPose() const override; - - // Documentation inherited. - protected: virtual void SetRawLocalPose(const math::Pose3d &_Pose3d) - override; - - /// \brief Get the raw local position of the node - /// \return Local position - protected: virtual math::Vector3d RawLocalPosition() const; - - /// \brief Set the raw local position of the node - /// \param[in] _position Local position to set the node to - protected: virtual void SetRawLocalPosition( - const math::Vector3d &_position); - - /// \brief Get the raw local rotation of the node - /// \return Local rotation - protected: virtual math::Quaterniond RawLocalRotation() const; - - /// \brief Set the raw local rotation of the node - /// \param[in] _rotation Local rotation to set the node to - protected: virtual void SetRawLocalRotation( - const math::Quaterniond &_rotation); - - /// \brief Set the parent node - /// \param[in] _parent The parent ogre node - protected: virtual void SetParent(Ogre2NodePtr _parent); - - // Documentation inherited. - protected: virtual void Load() override; - - // Documentation inherited. - protected: virtual void Init() override; - - /// \brief get a shared pointer to this - private: Ogre2NodePtr SharedThis(); - - /// \brief Pointer to the parent ogre node - protected: Ogre2NodePtr parent; - - /// \brief The underlying ogre scene node - protected: Ogre::SceneNode *ogreNode = nullptr; - - /// \brief A list of child nodes - protected: Ogre2NodeStorePtr children; - - // TODO(anyone): remove the need for a visual friend class - private: friend class Ogre2Visual; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh index 1efe6b1eb..dd261d565 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,40 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2OBJECT_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2OBJECT_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre2.x implementation of the Object class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Object : - public BaseObject - { - /// \brief Constructor - protected: Ogre2Object(); - - /// \brief Destructor - public: virtual ~Ogre2Object(); - - // Documentation inherited - public: virtual ScenePtr Scene() const override; - - /// \brief Pointer to the ogre scene - protected: Ogre2ScenePtr scene; - - /// \brief Make ogre scene our friend so it is able to create objects - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ParticleEmitter.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ParticleEmitter.hh index 2280f5b9f..8bde790e4 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2ParticleEmitter.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ParticleEmitter.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,98 +14,5 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2PARTICLEEMITTER_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2PARTICLEEMITTER_HH_ - -#include -#include -#include "ignition/rendering/base/BaseParticleEmitter.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2ParticleEmitterPrivate; - - /// \brief Class to manage a particle emitter. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ParticleEmitter : - public BaseParticleEmitter - { - /// \brief Constructor - protected: Ogre2ParticleEmitter(); - - /// \brief Destructor - public: virtual ~Ogre2ParticleEmitter(); - - // Documentation inherited. - public: void Destroy() override; - - // Documentation inherited. - public: virtual void SetType(const EmitterType _type) override; - - // Documentation inherited. - public: virtual void SetEmitterSize( - const ignition::math::Vector3d &_size) override; - - // Documentation inherited. - public: virtual void SetRate(double _rate) override; - - // Documentation inherited. - public: virtual void SetDuration(double _duration) override; - - // Documentation inherited. - public: virtual void SetEmitting(bool _enable) override; - - // Documentation inherited. - public: virtual void SetParticleSize( - const ignition::math::Vector3d &_size) override; - - // Documentation inherited. - public: virtual void SetLifetime(double _lifetime) override; - - // Documentation inherited. - public: virtual void SetMaterial(const MaterialPtr &_material) override; - - // Documentation inherited. - public: virtual void SetVelocityRange(double _minVelocity, - double _maxVelocity) override; - - // Documentation inherited. - public: virtual void SetColorRange( - const ignition::math::Color &_colorStart, - const ignition::math::Color &_colorEnd) override; - - // Documentation inherited. - public: virtual void SetScaleRate(double _scaleRate) override; - - // Documentation inherited. - public: virtual void SetColorRangeImage(const std::string &_image) - override; - - /// \brief Particle system visibility flags - public: static const uint32_t kParticleVisibilityFlags; - - // Documentation inherited. - protected: virtual void Init() override; - - /// \brief Internal pre-render function added to avoid breaking ABI - /// compatibility - private: void PreRenderImpl(); - - /// \brief Create the particle system - private: void CreateParticleSystem(); - - /// \brief Only the ogre scene can instanstiate this class - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh index 1793a9ba6..3ce9ed7df 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,58 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RAYQUERY_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RAYQUERY_HH_ -#include - -#include "ignition/rendering/base/BaseRayQuery.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2RayQueryPrivate; - - /// \class Ogre2RayQuery Ogre2RayQuery.hh - /// ignition/rendering/ogre2/Ogre2RayQuery.hh - /// \brief A Ray Query class used for computing ray object intersections - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RayQuery : - public BaseRayQuery - { - /// \brief Constructor - protected: Ogre2RayQuery(); - - /// \brief Destructor - public: virtual ~Ogre2RayQuery(); - - // Documentation inherited - public: virtual void SetFromCamera(const CameraPtr &_camera, - const math::Vector2d &_coord); - - // Documentation inherited - public: virtual RayQueryResult ClosestPoint(); - - /// \brief Get closest point by selection buffer. - /// This is executed on the GPU. - private: RayQueryResult ClosestPointBySelectionBuffer(); - - /// \brief Get closest point by ray triangle intersection test. - /// This is executed on the CPU. - private: RayQueryResult ClosestPointByIntersection(); - - /// \brief Private data pointer - private: std::unique_ptr dataPtr; - - /// \brief Pointer to friend scene class for creating ray query - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh index c7dd6ef58..79ac0655c 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,238 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERENGINE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RENDERENGINE_HH_ -#include -#include -#include -#include - -#include - -#include "ignition/rendering/GraphicsAPI.hh" -#include "ignition/rendering/RenderEnginePlugin.hh" -#include "ignition/rendering/base/BaseRenderEngine.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Export.hh" - -namespace Ogre -{ - class LogManager; - class Root; - class Window; - namespace v1 - { - class OverlaySystem; - } - - class HlmsPbsTerraShadows; - class CompositorWorkspaceListener; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2RenderEnginePrivate; - class Ogre2IgnHlmsCustomizations; - - /// \brief Plugin for loading ogre render engine - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderEnginePlugin : - public RenderEnginePlugin - { - /// \brief Constructor - public: Ogre2RenderEnginePlugin(); - - /// \brief Destructor - public: ~Ogre2RenderEnginePlugin() = default; - - /// \brief Get the name of the render engine loaded by this plugin. - /// \return Name of render engine - public: std::string Name() const; - - /// \brief Get a pointer to the render engine loaded by this plugin. - /// \return Render engine instance - public: RenderEngine *Engine() const; - }; - - /// \brief Ogre2 render engine class. A singleton class that manages the - /// underlying ogre2 render engine, loads its plugins, and creates - /// resources needed for the engine to run - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderEngine : - public virtual BaseRenderEngine, - public common::SingletonT - { - /// \brief Constructor - private: Ogre2RenderEngine(); - - /// \brief Destructor - public: virtual ~Ogre2RenderEngine(); - - // Documentation Inherited. - public: virtual void Destroy() override; - - // Documentation Inherited. - public: virtual bool IsEnabled() const override; - - // Documentation Inherited. - public: virtual std::string Name() const override; - - /// \brief Add path to resource in ogre2's resource manager - /// \param[in] _uri Resource path in the form of an uri - public: void AddResourcePath(const std::string &_uri) override; - - /// \brief return the ogre window - public: Ogre::Window * OgreWindow() const; - - /// \brief Get the ogre2 root object - /// \return ogre2 root object - public: virtual Ogre::Root *OgreRoot() const; - - /// \brief Create a render window - /// \param[in] _handle Handle of native window which the render window - /// will attach - /// \param[in] _width Width of render window - /// \param[in] _height Height of render window - /// \param[in] _ratio Device pixel ratio (typically needed for retina - /// displays) - /// \param[in] _antiAliasing Anti-aliasing level - public: std::string CreateRenderWindow(const std::string &_handle, - const unsigned int _width, const unsigned int _height, - const double _ratio, const unsigned int _antiAliasing); - - /// \brief Get the render engine's graphics API - /// Note: Do not merge this forward. This has been changed to - /// virtual function in ign-rendering7 - /// \return The graphics API enum class - public: rendering::GraphicsAPI GraphicsAPI() const; - - /// \brief Create a scene - /// \param[in] _id Unique scene Id - /// \param[in] _name Name of scene - protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, - const std::string &_name) override; - - /// \brief Get a pointer to the list of scenes managed by the render - /// engine - /// \return list of scenes - protected: virtual SceneStorePtr Scenes() const override; - - // Documentation Inherited. - protected: virtual bool LoadImpl( - const std::map &_params) override; - - /// \brief Initialize the render engine - /// \return True if the operation is successful - protected: virtual bool InitImpl() override; - - /// \brief Helper function to initialize the render engine - private: void LoadAttempt(); - - /// \brief Create the ogre logger for logging ogre messages to file - private: void CreateLogger(); - - /// \brief Create GL context - private: void CreateContext(); - - /// \brief Register Hlms - private: void RegisterHlms(); - - /// \brief Create ogre root - private: void CreateRoot(); - - /// \brief Create ogre overlay component - private: void CreateOverlay(); - - /// \brief Create ogre plugins. - private: void LoadPlugins(); - - /// \brief Creat the ogre render system - private: void CreateRenderSystem(); - - /// \brief Create dummy 1x1 render window for the main rendering context - private: void CreateRenderWindow(); - - /// \brief Create the resources needed by ogre - private: void CreateResources(); - - /// \brief Attempt to initialize engine and catch exeption if they occur - private: void InitAttempt(); - - /// \brief Get a list of all supported FSAA levels for this render system - /// \return a list of FSAA levels - public: std::vector FSAALevels() const; - - /// \brief Retrieves Hlms customizations for tweaking them - /// \return Ogre HLMS customizations - public: Ogre2IgnHlmsCustomizations &HlmsCustomizations(); - - /// \internal - /// \brief Get a pointer to the Ogre overlay system. - /// \return Pointer to the ogre overlay system. - public: Ogre::v1::OverlaySystem *OverlaySystem() const; - - /// \internal - /// \brief Get a pointer to the Pbs listener that adds terra shadows. - /// Do NOT assume HlmsPbs::getListener() == HlmsPbsTerraShadows() - /// as there may be more than one listener in the future with - /// a master listener coordinating them - /// \return Pointer to the Pbs listener that adds terra shadows. - public: Ogre::HlmsPbsTerraShadows *HlmsPbsTerraShadows() const; - - /// \internal - /// \brief Get a pointer to the workspace listener that adds terra - /// casting shadows from spot and point lights. - /// - /// This listener needs to be added to each workspace that wants - /// terrain shadows from spot/point lights. If no terrains are in scene - /// then the workspace's overhead is negligible / almost 0. - /// \return Pointer to the CompositorWorkspaceListener - public: Ogre::CompositorWorkspaceListener - *TerraWorkspaceListener() const; - - /// \brief Pointer to the ogre's overlay system - private: Ogre::v1::OverlaySystem *ogreOverlaySystem = nullptr; - - /// \brief List of scenes managed by the render engine - private: Ogre2SceneStorePtr scenes; - - /// \brief Ogre root - private: Ogre::Root *ogreRoot = nullptr; - - /// \brief Ogre log manager - private: Ogre::LogManager *ogreLogManager = nullptr; - - /// \brief Paths to ogre plugins - private: std::vector ogrePaths; - - /// \brief Dummy display needed for linux platform - private: void *dummyDisplay = nullptr; - - /// \brief Dummy context needed for linux platform - private: void *dummyContext = nullptr; - - /// \brief Dummy window Id needed for linux platform - private: uint64_t dummyWindowId = 0u; - - /// \brief Ogre Window - private: Ogre::Window *window = nullptr; - - /// \brief True to use the current opengl context - private: bool useCurrentGLContext = false; - - /// \brief Pointer to private data - private: std::unique_ptr dataPtr; - - /// \brief Singleton setup - private: friend class common::SingletonT; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh index 83ae52efd..2f07a5006 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,67 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERPASS_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RENDERPASS_HH_ -#include -#include - -#include "ignition/rendering/base/BaseRenderPass.hh" -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2RenderPassPrivate; - - /* \class Ogre2RenderPass Ogre2RenderPass.hh \ - * ignition/rendering/ogre2/Ogre2RenderPass.hh - */ - /// \brief Ogre2 Implementation of a render pass. - /// - /// The ogre2 compositor chain in ign-rendering is set up as follows: - /// * Base scene pass -> [0..N] RenderPass'es -> Final compositor pass. - /// This is set up by Ogre2RenderTarget which loads the compositor workspace - /// definiton from script. The base scene pass node is responsible for - /// rendering the initial scene and passes its output to any RenderPass'es - /// that are added to the RenderTarget. Each RenderPass has its own ogre - /// compositor node that receives the output from the previous RenderPass - /// as input, applies its own pass over the input, and sends the result to - /// the next RenderPass. Note that the Ogre2RenderPass class provides the - /// node definition only and the actual node creation work is done in the - /// Ogre2RenderTarget class when the whole workspace is constructed. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderPass : - public BaseRenderPass - { - /// \brief Constructor - protected: Ogre2RenderPass(); - - /// \brief Destructor - public: virtual ~Ogre2RenderPass(); - - // Documentation inherited. - public: void Destroy() override; - - /// \brief Get the ogre compositor node definition name for this - /// render pass - public: std::string OgreCompositorNodeDefinitionName() const; - - /// \brief Create the render pass using ogre compositor - public: virtual void CreateRenderPass(); - - /// \brief Name of the ogre compositor node definition - protected: std::string ogreCompositorNodeDefName; - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh index 229157378..1842e0ff1 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,295 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_ -#include -#include -#include -#include - -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/base/BaseRenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh" - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif -#include -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -namespace Ogre -{ - class Camera; - class RenderTarget; - class Texture; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2RenderTargetPrivate; - - /// \brief Ogre2.x implementation of the render target class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderTarget : - public virtual BaseRenderTarget - { - /// \brief Constructor - protected: Ogre2RenderTarget(); - - /// \brief Destructor - public: virtual ~Ogre2RenderTarget(); - - /// \brief Get the anti-aliasing level - public: virtual unsigned int AntiAliasing() const; - - /// \brief set the anti-aliasing level - /// \param[in] _aa Anti-aliasing level - public: virtual void SetAntiAliasing(unsigned int _aa); - - /// \brief Copy the render target buffer data to an image - /// \param[in] _image Image to copy the data to - public: virtual void Copy(Image &_image) const override; - - /// \brief Get a pointer to the internal ogre camera - /// \return Pointer to ogre camera - public: virtual Ogre::Camera *Camera() const; - - /// \brief Set the ogre camera to use for this render target - /// \param[in] _camera Pointer to ogre camera - public: virtual void SetCamera(Ogre::Camera *_camera); - - // Documentation inherited - public: virtual math::Color BackgroundColor() const override; - - /// \brief Set the background color of the render target - /// \param[in] _color Color to set the background to - public: virtual void SetBackgroundColor(math::Color _color); - - /// \brief Set the background material of this camera - /// \param[in] _material Material to set the background to - public: virtual void SetBackgroundMaterial(MaterialPtr _material); - - /// \brief Get the background material of this camera - /// \return background material - public: virtual MaterialPtr BackgroundMaterial() const; - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void PostRender() override; - - /// \brief Main render call - public: virtual void Render(); - - /// \brief Destroy the render target - public: virtual void Destroy() override = 0; - - /// \brief Set a material to render on every object. This method is used - /// for special cases like the render target of a depth camera. - /// \param[in] _material The material to render - public: void SetMaterial(MaterialPtr _material); - - /// \see Camera::SetShadowsNodeDefDirty - public: void SetShadowsNodeDefDirty(); - - /// \brief Returns the FSAA to use based on supported specs by HW - /// and value specified in Ogre2RenderTarget::AntiAliasing - /// \return Value in range [1; 256). 1 means no antialiasing. - protected: uint8_t TargetFSAA() const; - - /// \brief Get a pointer to the ogre render target containing - /// the results of the render (implemented separately - /// to avoid breaking ABI of the pure virtual function) - protected: Ogre::TextureGpu *RenderTargetImpl() const; - - /// \brief Get a pointer to the ogre render target containing - /// the results of the render - public: virtual Ogre::TextureGpu *RenderTarget() const = 0; - - /// \brief Returns true if this is a render window - /// \return True if this render target is a render window - public: virtual bool IsRenderWindow() const; - - // Documentation inherited - public: unsigned int GLIdImpl() const; - - /// \brief Destroy the render texture - protected: void DestroyTargetImpl(); - - /// \brief Build the render texture - protected: void BuildTargetImpl(); - - /// \brief Get visibility mask for the viewport associated with this - /// render target - /// \return Visibility mask - public: virtual uint32_t VisibilityMask() const; - - /// \brief Set visibility mask for the viewport associated with this - /// render target - /// \param[in] _mask Visibility mask - public: virtual void SetVisibilityMask(uint32_t _mask); - - /// \brief Update the render pass chain - public: static void UpdateRenderPassChain( - Ogre::CompositorWorkspace *_workspace, - const std::string &_workspaceDefName, - const std::string &_baseNode, const std::string &_finalNode, - const std::vector &_renderPasses, - bool _recreateNodes, - Ogre::TextureGpu *(*_ogreTextures)[2], - bool _isRenderWindow); - - /// \brief Update the background color - protected: virtual void UpdateBackgroundColor(); - - /// \brief Update the background material - protected: virtual void UpdateBackgroundMaterial(); - - /// \brief Update the render pass chain - protected: virtual void UpdateRenderPassChain(); - - /// \brief Implementation of the Rebuild function - protected: virtual void RebuildImpl() override; - - /// \brief Rebuild the render target - protected: virtual void RebuildTarget() = 0; - - /// \brief Rebuild the compositor - protected: virtual void RebuildCompositor(); - - /// \brief Build the compositor - protected: virtual void BuildCompositor(); - - /// \brief Destroy the compositor - protected: virtual void DestroyCompositor(); - - /// \brief Re-initializes render target material to apply a material to - /// everything in the scene. Does nothing if no material has been set - /// \sa Ogre2RenderTarget::RebuildImpl() - /// \sa BaseRenderTarget::Rebuild() - protected: void RebuildMaterial(); - - /// \brief Pointer to the internal ogre camera - protected: Ogre::Camera *ogreCamera = nullptr; - - /// \brief Ogre's compositor workspace - the main interface to render - /// into a render target or render texture. - protected: Ogre::CompositorWorkspace *ogreCompositorWorkspace = nullptr; - - /// \brief Ogre's compositor workspace definition name - protected: std::string ogreCompositorWorkspaceDefName; - - /// \brief Stores the background color of the render target - protected: Ogre::ColourValue ogreBackgroundColor; - - /// \brief Background material of the render target - protected: MaterialPtr backgroundMaterial; - - /// \brief a material used by for the render target - protected: MaterialPtr material; - - /// \brief Helper class that applies the material to the render target - protected: Ogre2RenderTargetMaterialPtr materialApplicator; - - /// \brief Flag to indicate if the render target color has changed - protected: bool colorDirty = true; - - /// \brief Flag to indicate if the render target background material has - /// changed - protected: bool backgroundMaterialDirty = false; - - /// \brief Anti-aliasing level - protected: unsigned int antiAliasing = 4; - - /// \brief visibility mask associated with this render target - protected: uint32_t visibilityMask = IGN_VISIBILITY_ALL; - - /// \brief Pointer to private data - private: std::unique_ptr dataPtr; - }; - - /// \brief Ogre2.x implementation of the render texture class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderTexture : - public virtual BaseRenderTexture - { - /// \brief Constructor - protected: Ogre2RenderTexture(); - - /// \brief Destructor - public: virtual ~Ogre2RenderTexture(); - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void PostRender() override; - - // Documentation inherited - public: virtual unsigned int GLId() const override; - - // Documentation inherited - // TODO(anyone): this function should be removed. - // We didn't do it to preserve ABI. - public: virtual Ogre::TextureGpu *RenderTarget() const override; - - // Documentation inherited. - protected: virtual void RebuildTarget() override; - - /// \brief Destroy the render texture - protected: virtual void DestroyTarget(); - - /// \brief Build the render texture - protected: virtual void BuildTarget(); - - /// \brief Make scene our friend so it can create a ogre2 render texture - private: friend class Ogre2Scene; - }; - - /// \brief Ogre2.x implementation of the render window class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderWindow : - public virtual BaseRenderWindow - { - /// \brief Constructor - protected: Ogre2RenderWindow(); - - /// \brief Destructor - public: virtual ~Ogre2RenderWindow(); - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual bool IsRenderWindow() const override; - - // Documentation inherited. - public: virtual Ogre::TextureGpu *RenderTarget() const override; - - // Documentation inherited. - protected: virtual void RebuildTarget() override; - - /// \brief Build the render window - protected: virtual void BuildTarget(); - - /// \brief Pointer to the internal ogre render target object - protected: Ogre::TextureGpu *ogreRenderWindow = nullptr; - - /// \brief Make scene our friend so it can create a ogre2 render window - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh index fcda332d5..49cf9ca38 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,104 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGETMATERIAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGETMATERIAL_HH_ -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre2/Export.hh" - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif -#include -#include -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#ifdef _MSC_VER - #pragma warning(push) - // Silence deriving from Ogre::RenderTargetListener dll-linkage warnings - #pragma warning(disable:4275) -#endif - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Causes all objects in a scene to be rendered with the same - /// material when rendered by a given RenderTarget. - /// \internal - /// - /// On construction it registers as an Ogre::RenderTargetListener - /// on the provided Ogre::RenderTarget, and sets the material scheme name - /// to a value that is unlikely to exist. - /// When the target is about to be rendered it adds itself as an - /// Ogre::MaterialManager::Listener. - /// Every time ogre tries to get a technique for a material it will call - /// handleSchemeNotFound which returns the first supported technique on the - /// material provided to this class's constructor. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderTargetMaterial : - public Ogre::Camera::Listener, - public Ogre::MaterialManager::Listener - { - /// \brief constructor - /// \param[in] _scene the scene manager responsible for rendering - /// \param[in] _renderTarget the RenderTarget this should apply to - /// \param[in] _material the material to apply to all renderables - public: Ogre2RenderTargetMaterial(Ogre::SceneManager *_scene, - Ogre::Camera *_renderTarget, Ogre::Material *_material); - - /// \brief destructor - public: ~Ogre2RenderTargetMaterial(); - - /// \brief Callback when a camera is about to be rendered - /// \param[in] _cam Ogre camera. - private: virtual void cameraPreRenderScene( - Ogre::Camera *_cam) override; - - /// \brief Callback when a camera is finisned being rendered - /// \param[in] _evt Ogre camera - private: virtual void cameraPostRenderScene( - Ogre::Camera *_evt) override; - - /// \brief Ogre callback that assigned same material to all renderables - /// when the requested scheme is not found - /// \param[in] _schemeIndex Index of scheme requested - /// \param[in] _schemeName Name of scheme requested - /// \param[in] _originalMaterial Orignal material that does not contain - /// the requested scheme - /// \param[in] _lodIndex The material level-of-detail - /// \param[in] _rend Pointer to the Ogre::Renderable object requesting - /// the use of the techinique - /// \return The Ogre material technique to use when scheme is not found. - public: virtual Ogre::Technique *handleSchemeNotFound( - uint16_t _schemeIndex, const Ogre::String &_schemeName, - Ogre::Material *_originalMaterial, uint16_t _lodIndex, - const Ogre::Renderable *_rend) override; - - /// \brief scene manager responsible for rendering - private: Ogre::SceneManager *scene = nullptr; - - /// \brief render target that should see a uniform material - private: Ogre::Camera *renderCamera = nullptr; - - /// \brief material that should be applied to all objects - private: Ogre::Material *material = nullptr; - - /// \brief name of the material scheme used by this applicator - private: Ogre::String schemeName; - }; - } - } -} - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh index 93d93ed57..fca4ffa0c 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,123 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERTYPES_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RENDERTYPES_HH_ -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class Ogre2ArrowVisual; - class Ogre2AxisVisual; - class Ogre2BoundingBoxCamera; - class Ogre2Camera; - class Ogre2Capsule; - class Ogre2COMVisual; - class Ogre2DepthCamera; - class Ogre2DirectionalLight; - class Ogre2Geometry; - class Ogre2GizmoVisual; - class Ogre2GpuRays; - class Ogre2Grid; - class Ogre2Heightmap; - class Ogre2InertiaVisual; - class Ogre2JointVisual; - class Ogre2Light; - class Ogre2LightVisual; - class Ogre2LidarVisual; - class Ogre2Marker; - class Ogre2Material; - class Ogre2Mesh; - class Ogre2MeshFactory; - class Ogre2Node; - class Ogre2Object; - class Ogre2ParticleEmitter; - class Ogre2PointLight; - class Ogre2RayQuery; - class Ogre2RenderEngine; - class Ogre2RenderTarget; - class Ogre2RenderTargetMaterial; - class Ogre2RenderTexture; - class Ogre2RenderWindow; - class Ogre2Scene; - class Ogre2SegmentationCamera; - class Ogre2Sensor; - class Ogre2SpotLight; - class Ogre2SubMesh; - class Ogre2ThermalCamera; - class Ogre2Visual; - class Ogre2WireBox; - - typedef BaseGeometryStore Ogre2GeometryStore; - typedef BaseLightStore Ogre2LightStore; - typedef BaseNodeStore Ogre2NodeStore; - typedef BaseSceneStore Ogre2SceneStore; - typedef BaseSensorStore Ogre2SensorStore; - typedef BaseSubMeshStore Ogre2SubMeshStore; - typedef BaseVisualStore Ogre2VisualStore; - - typedef BaseMaterialMap Ogre2MaterialMap; - - typedef shared_ptr Ogre2ArrowVisualPtr; - typedef shared_ptr Ogre2AxisVisualPtr; - typedef shared_ptr Ogre2BoundingBoxCameraPtr; - typedef shared_ptr Ogre2CameraPtr; - typedef shared_ptr Ogre2CapsulePtr; - typedef shared_ptr Ogre2COMVisualPtr; - typedef shared_ptr Ogre2DepthCameraPtr; - typedef shared_ptr Ogre2DirectionalLightPtr; - typedef shared_ptr Ogre2GeometryPtr; - typedef shared_ptr Ogre2GizmoVisualPtr; - typedef shared_ptr Ogre2GpuRaysPtr; - typedef shared_ptr Ogre2GridPtr; - typedef shared_ptr Ogre2HeightmapPtr; - typedef shared_ptr Ogre2InertiaVisualPtr; - typedef shared_ptr Ogre2JointVisualPtr; - typedef shared_ptr Ogre2LightPtr; - typedef shared_ptr Ogre2LightVisualPtr; - typedef shared_ptr Ogre2LidarVisualPtr; - typedef shared_ptr Ogre2MarkerPtr; - typedef shared_ptr Ogre2MaterialPtr; - typedef shared_ptr Ogre2MeshPtr; - typedef shared_ptr Ogre2MeshFactoryPtr; - typedef shared_ptr Ogre2NodePtr; - typedef shared_ptr Ogre2ObjectPtr; - typedef shared_ptr Ogre2ParticleEmitterPtr; - typedef shared_ptr Ogre2PointLightPtr; - typedef shared_ptr Ogre2RayQueryPtr; - typedef shared_ptr Ogre2RenderEnginePtr; - typedef shared_ptr Ogre2RenderTargetPtr; - typedef shared_ptr Ogre2RenderTexturePtr; - typedef shared_ptr Ogre2RenderWindowPtr; - typedef shared_ptr Ogre2ScenePtr; - typedef shared_ptr - Ogre2SegmentationCameraPtr; - typedef shared_ptr Ogre2SensorPtr; - typedef shared_ptr Ogre2SpotLightPtr; - typedef shared_ptr Ogre2SubMeshPtr; - typedef shared_ptr Ogre2ThermalCameraPtr; - typedef shared_ptr Ogre2VisualPtr; - typedef shared_ptr Ogre2WireBoxPtr; - - typedef shared_ptr Ogre2GeometryStorePtr; - typedef shared_ptr Ogre2LightStorePtr; - typedef shared_ptr Ogre2NodeStorePtr; - typedef shared_ptr Ogre2RenderTargetMaterialPtr; - typedef shared_ptr Ogre2SceneStorePtr; - typedef shared_ptr Ogre2SensorStorePtr; - typedef shared_ptr Ogre2SubMeshStorePtr; - typedef shared_ptr Ogre2VisualStorePtr; - - typedef shared_ptr Ogre2MaterialMapPtr; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh index 949fe09de..efc13e0b2 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,439 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2SCENE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2SCENE_HH_ -#include -#include -#include - -#include "ignition/rendering/Storage.hh" -#include "ignition/rendering/base/BaseScene.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" - -#include "ignition/rendering/ogre2/Export.hh" - -// This disables warning messages for OGRE -#ifndef _MSC_VER - #pragma GCC system_header -#else - #pragma warning(push, 0) -#endif -#include -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -namespace Ogre -{ - class Root; - class SceneManager; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2ScenePrivate; - // - /// \brief Ogre2.x implementation of the scene class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Scene : - public BaseScene - { - /// \brief Constructor - /// \param[in] _id Unique scene Id - /// \param[in] _name Scene name - protected: Ogre2Scene(unsigned int _id, const std::string &_name); - - /// \brief Destructor - public: virtual ~Ogre2Scene(); - - // Documentation inherited. - public: virtual void Fini() override; - - // Documentation inherited. - public: virtual RenderEngine *Engine() const override; - - // Documentation inherited. - public: virtual VisualPtr RootVisual() const override; - - // Documentation inherited. - public: virtual void SetTime( - const std::chrono::steady_clock::duration &_time) override; - - // Documentation inherited. - public: virtual math::Color AmbientLight() const override; - - // Documentation inherited. - public: virtual void SetAmbientLight(const math::Color &_color) override; - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void Clear() override; - - // Documentation inherited - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void SetSkyEnabled(bool _enabled) override; - - // Documentation inherited - public: virtual bool SkyEnabled() const override; - - // Documentation inherited. - public: virtual void SetCameraPassCountPerGpuFlush( - uint8_t _numPass) override; - - // Documentation inherited. - public: virtual uint8_t CameraPassCountPerGpuFlush() const override; - - // Documentation inherited. - public: virtual bool LegacyAutoGpuFlush() const override; - - /// \brief Get a pointer to the ogre scene manager - /// \return Pointer to the ogre scene manager - public: virtual Ogre::SceneManager *OgreSceneManager() const; - - // Documentation inherited - public: virtual void PostRender() override; - - /// \cond PRIVATE - /// \brief Certain functions like Ogre2Camera::VisualAt would - /// need to call PreRender and PostFrame, which is very unintuitive - /// and user-hostile. - /// - /// More over, it's likely that we don't want to advance the frame - /// in those cases (e.g. particle FXs should not advance), but we - /// still have to initialize and cleanup Ogre once we're done. - /// - /// This function performs some PreRender steps but only if we're - /// not already inside PreRender/PostRender, necessary for rendering - /// Ogre2Camera::VisualAt (via Ogre2SelectionBuffer) - public: void StartForcedRender(); - - /// \brief Opposite of StartForcedRender - /// - /// This function performs some PostRender steps but only if we're - /// not already inside PreRender/PostRender pairs - public: void EndForcedRender(); - - /// \internal - /// \brief When LegacyAutoGpuFlush(), this function mimics - /// legacy behavior. - /// When not, it verifies PreRender has been called - /// It also performs necessary updates for all heightmaps - /// - /// \param _camera camera that is about to render, used - /// by heightmaps (Terra). See Ogre2Scene::UpdateAllHeightmaps - /// Can be null - public: void StartRendering(Ogre::Camera *_camera); - - /// \internal - /// \brief Every Render() function calls this function with - /// the number of pass_scene passes it just performed, so - /// that we decide if we should flush or not (based on - /// SetCameraPassCountPerGpuFlush) - /// - /// \param[in] _numPasses Number of pass_scene passes just performed - /// (excluding shadow nodes', otherwise it becomes too unpredictable) - /// \param[in] _startNewFrame whether we ignore - /// SetCameraPassCountPerGpuFlush. - /// Only PostRender should set this to true. - public: void FlushGpuCommandsAndStartNewFrame(uint8_t _numPasses, - bool _startNewFrame); - - /// \internal - /// \brief Performs actual flushing to GPU - protected: void FlushGpuCommandsOnly(); - - /// \internal - /// \brief Ends the frame, i.e. PostRender wants to do this. - /// - /// Ogre::SceneManager::updateSceneGraph can't be called again until - /// this function is called - /// - /// After calling this function again, - /// Ogre::SceneManager::updateSceneGraph must be called before - /// rendering anything (i.e. done inside PreRender) - /// - /// This is why every PreRender should be paired with a PostRender - /// call when in LegacyAutoGpuFlush == false - protected: void EndFrame(); - - /// \internal - /// \brief Mark shadows dirty to rebuild compostior shadow node - /// This is set when the number of shadow casting lighst changes - /// \param[in] _dirty True to mark shadows are dirty - /// \sa SetShadowsDirty - public: void SetShadowsDirty(bool _dirty); - - /// \internal - /// \brief Get whether shadows are dirty - /// \return True if the number of shadow casting lights changed - /// \sa ShadowsDirty - public: bool ShadowsDirty() const; - /// \endcond - - // Documentation inherited - protected: virtual bool LoadImpl() override; - - // Documentation inherited - protected: virtual bool InitImpl() override; - - // Documentation inherited - protected: virtual COMVisualPtr CreateCOMVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual InertiaVisualPtr CreateInertiaVisualImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited - protected: virtual JointVisualPtr CreateJointVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual LightVisualPtr CreateLightVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual DirectionalLightPtr CreateDirectionalLightImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited - protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual CameraPtr CreateCameraImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual ThermalCameraPtr CreateThermalCameraImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited - protected: virtual BoundingBoxCameraPtr CreateBoundingBoxCameraImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited - protected: virtual SegmentationCameraPtr CreateSegmentationCameraImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited - protected: virtual GpuRaysPtr CreateGpuRaysImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual VisualPtr CreateVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual GeometryPtr CreateConeImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id, - const std::string &_name) override; - - /// \brief Create a mesh object based on its name - /// \param[in] _id Unique Id to assign to the mesh - /// \param[in] _name Name to assign to the mesh - /// \param[in] _meshName Name of the mesh to create - protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, - const std::string &_name, const std::string &_meshName); - - // Documentation inherited - protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, - const std::string &_name, const MeshDescriptor &_desc) - override; - - // Documentation inherited - protected: virtual CapsulePtr CreateCapsuleImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual HeightmapPtr CreateHeightmapImpl(unsigned int _id, - const std::string &_name, const HeightmapDescriptor &_desc) - override; - - // Documentation inherited - protected: virtual GridPtr CreateGridImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual MarkerPtr CreateMarkerImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id, - const std::string &_name) override; - - // Documentation inherited - protected: virtual TextPtr CreateTextImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual RenderTexturePtr CreateRenderTextureImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited. - protected: virtual RenderWindowPtr CreateRenderWindowImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited - protected: virtual RayQueryPtr CreateRayQueryImpl( - unsigned int _id, const std::string &_name) override; - - // Documentation inherited - protected: virtual ParticleEmitterPtr CreateParticleEmitterImpl( - unsigned int _id, const std::string &_name) override; - - /// \brief Helper function to initialize an ogre2 object - /// \param[in] _object Ogre2 object that will be initialized - /// \param[in] _id Unique Id to assign to the object - /// \param[in] _name Name to assign to the object - protected: virtual bool InitObject(Ogre2ObjectPtr _object, - unsigned int _id, const std::string &_name); - - /// \internal - /// \brief Iterates through all Heightmaps and calls - /// Ogre2Heightmap::UpdateForRender on each of them - /// \param[in] _camera Camera about to be used for rendering - public: void UpdateAllHeightmaps(Ogre::Camera *_camera); - - /// \internal - /// \brief Return all heightmaps in the scene - public: const std::vector> &Heightmaps() - const; - - /// \brief Create a compositor shadow node with the same number of shadow - /// textures as the number of shadow casting lights - protected: void UpdateShadowNode(); - - /// \brief Create ogre compositor shadow node definition. The function - /// takes a vector of parameters that describe the type, number, and - /// resolution of textures create. Note that it is not necessary to - /// create separate textures for each shadow map. It is more efficient to - /// define a large texture atlas which is composed of multiple shadow - /// maps each occupying a subspace within the texture. This function is - /// similar to Ogre::ShadowNodeHelper::createShadowNodeWithSettings but - /// fixes a problem with the shadow map index when directional and spot - /// light shadow textures are defined on two different texture atlases. - /// \param[in] _compositorManager ogre compositor manager - /// \param[in] _shadowNodeName Name of the shadow node definition - /// \param[in] _shadowParams Parameters containing the shadow type, - /// texure resolution and position on the texture atlas. - private: void CreateShadowNodeWithSettings( - Ogre::CompositorManager2 *_compositorManager, - const std::string &_shadowNodeName, - const Ogre::ShadowNodeHelper::ShadowParamVec &_shadowParams); - - // Documentation inherited - protected: virtual LightStorePtr Lights() const override; - - // Documentation inherited - protected: virtual SensorStorePtr Sensors() const override; - - // Documentation inherited - protected: virtual VisualStorePtr Visuals() const override; - - // Documentation inherited - protected: virtual MaterialMapPtr Materials() const override; - - /// \brief Create the GL context - private: void CreateContext(); - - /// \brief Create the root visual in the scene - private: void CreateRootVisual(); - - /// \brief Create the mesh factory used to generate ogre meshes - private: void CreateMeshFactory(); - - /// \brief Create the vaiours storage objects - private: void CreateStores(); - - /// \brief Remove internal material cache for a specific material - /// \param[in] _name Name of the template material to remove. - public: void ClearMaterialsCache(const std::string &_name); - - /// \brief Create a shared pointer to self - private: Ogre2ScenePtr SharedThis(); - - /// \brief Root visual in the scene - protected: Ogre2VisualPtr rootVisual; - - /// \brief Mesh factory for generating ogre meshes - protected: Ogre2MeshFactoryPtr meshFactory; - - /// \brief A list of ogre sensors, e.g. cameras - protected: Ogre2SensorStorePtr sensors; - - /// \brief A list of ogre visuals - protected: Ogre2VisualStorePtr visuals; - - /// \brief A list of ogre lights - protected: Ogre2LightStorePtr lights; - - /// \brief A list of ogre materials - protected: Ogre2MaterialMapPtr materials; - - /// \brief A list of ogre heightmaps - protected: std::vector> heightmaps; - - /// \brief Pointer to the ogre scene manager - protected: Ogre::SceneManager *ogreSceneManager = nullptr; - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - - /// \brief Make the render engine our friend - private: friend class Ogre2RenderEngine; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh index 89dea5436..ddc76e9ad 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,99 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ - -#ifndef IGNITION_RENDERING_OGRE2_OGRE2SEGMENTATIONCAMERA_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2SEGMENTATIONCAMERA_HH_ - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -#include -#include - -#include -#include - -#include "ignition/rendering/base/BaseSegmentationCamera.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2SegmentationCameraPrivate; - - /// \brief Segmentation camera used to label each pixel with a label id. - /// Supports Semantic / Panoptic Segmentation - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SegmentationCamera : - public BaseSegmentationCamera - { - /// \brief Constructor - protected: Ogre2SegmentationCamera(); - - /// \brief Destructor - public: virtual ~Ogre2SegmentationCamera(); - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void PostRender() override; - - // Documentation inherited - public: virtual ignition::common::ConnectionPtr - ConnectNewSegmentationFrame( - std::function _subscriber) override; - - // Documentation inherited - public: virtual void Render() override; - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - // Documentation inherited - public: void SetBackgroundLabel(int _label) override; - - // Documentation inherited - public: void LabelMapFromColoredBuffer( - uint8_t * _labelBuffer) const override; - - /// \brief Create the camera. - protected: void CreateCamera(); - - /// \brief Create render texture - protected: virtual void CreateRenderTexture(); - - // Documentation inherited - protected: virtual void CreateSegmentationTexture() override; - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera = nullptr; - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - /// \brief Make scene our friend so it can create a camera - private: friend class Ogre2Scene; - }; - } - } -} -#endif + */ +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh index a41ceea66..7ae7df2c9 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,90 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2SELECTIONBUFFER_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2SELECTIONBUFFER_HH_ + */ -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre2/Export.hh" - -namespace Ogre -{ - class Item; - class RenderTarget; - class SceneManager; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - struct Ogre2SelectionBufferPrivate; - - /// \brief Generates a selection buffer object for a given camera. - /// The selection buffer is used of entity selection. On setup, a unique - /// color is assigned to each entity. Whenever a selection request is made, - /// the selection buffer camera renders to a 1x1 sized offscreen buffer. - /// The color value of that pixel gives the identity of the entity. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SelectionBuffer - { - /// \brief Constructor - /// \param[in] _cameraName Name of the camera to generate a selection - /// buffer for. - /// \param[in] _scene Pointer to the scene - /// \param[in] _width width of the camera - /// \param[in] _height height of the camera - public: Ogre2SelectionBuffer(const std::string &_cameraName, - Ogre2ScenePtr _scene, unsigned int _width, - unsigned int _height); - - /// \brief Destructor - public: ~Ogre2SelectionBuffer(); - - /// \brief Handle on mouse click - /// \param[in] _x X coordinate in pixels. - /// \param[in] _y Y coordinate in pixels. - /// \return Returns the Ogre item at the coordinate. - public: Ogre::Item *OnSelectionClick(const int _x, const int _y); - - /// \brief Perform selection operation and get ogre item and - /// point of intersection. - /// \param[in] _x X coordinate in pixels. - /// \param[in] _y Y coordinate in pixels. - /// \param[out] _item Ogre item at the coordinate. - /// \param[out] _point 3D point of intersection with the ogre item's mesh. - /// \return True if an ogre item is found, false otherwise - public: bool ExecuteQuery(const int _x, const int _y, Ogre::Item *&_item, - math::Vector3d &_point); - - /// \brief Set dimension of the selection buffer - /// \param[in] _width X dimension in pixels. - /// \param[in] _height Y dimension in pixels. - public: void SetDimensions(unsigned int _width, unsigned int _height); - - /// \brief Call this to update the selection buffer contents - public: void Update(); - - /// \brief Delete the render texture - private: void DeleteRTTBuffer(); - - /// \brief Create the render texture - private: void CreateRTTBuffer(); - - /// \brief Create the selection buffer offscreen render texture. - // private: void CreateRTTOverlays(); - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh index 47b7da64d..7bdae889b 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2SENSOR_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2SENSOR_HH_ -#include "ignition/rendering/base/BaseSensor.hh" -#include "ignition/rendering/ogre2/Ogre2Node.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre2.x implementation of the sensor classs - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Sensor : - public BaseSensor - { - /// \brief Constructor - protected: Ogre2Sensor(); - - /// \brief Destructor - public: virtual ~Ogre2Sensor(); - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh index 8c193562e..b5a1da7b8 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,56 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2STORAGE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2STORAGE_HH_ -#include - -#include "ignition/rendering/base/BaseStorage.hh" - -#include "ignition/rendering/ogre2/Ogre2Light.hh" -#include "ignition/rendering/ogre2/Ogre2Mesh.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" -#include "ignition/rendering/ogre2/Ogre2Node.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - -// armhf failed to build with this code. It can not be removed for the rest -// of arches to keep ABI but should be removed in major versions unreleased -// see https://github.com/ignitionrobotics/ign-rendering/pull/457 -#ifndef __ARM_PCS_VFP - template class BaseGeometryStore; - template class BaseLightStore; - template class BaseNodeStore; - template class BaseSceneStore; - template class BaseSensorStore; - template class BaseSubMeshStore; - template class BaseVisualStore; -#endif - - typedef BaseGeometryStore Ogre2GeometryStore; - typedef BaseLightStore Ogre2LightStore; - typedef BaseNodeStore Ogre2NodeStore; - typedef BaseSceneStore Ogre2SceneStore; - typedef BaseSensorStore Ogre2SensorStore; - typedef BaseSubMeshStore Ogre2SubMeshStore; - typedef BaseVisualStore Ogre2VisualStore; - - typedef std::shared_ptr Ogre2GeometryStorePtr; - typedef std::shared_ptr Ogre2LightStorePtr; - typedef std::shared_ptr Ogre2NodeStorePtr; - typedef std::shared_ptr Ogre2SceneStorePtr; - typedef std::shared_ptr Ogre2SensorStorePtr; - typedef std::shared_ptr Ogre2SubMeshStorePtr; - typedef std::shared_ptr Ogre2VisualStorePtr; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh index a6763e510..9f2377831 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,99 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2THERMALCAMERA_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2THERMALCAMERA_HH_ - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -#include -#include - -#include "ignition/rendering/base/BaseThermalCamera.hh" -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" - -#include "ignition/common/Event.hh" -#include "ignition/common/Console.hh" - -namespace Ogre -{ - class Material; - class RenderTarget; - class Texture; - class Viewport; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2ThermalCameraPrivate; - - /// \brief Thermal camera used to render thermal data into an image buffer - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ThermalCamera : - public BaseThermalCamera - { - /// \brief Constructor - protected: Ogre2ThermalCamera(); - - /// \brief Destructor - public: virtual ~Ogre2ThermalCamera(); - - /// \brief Initialize the camera - public: virtual void Init() override; - - // Documentation inherited - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void PreRender() override; - - /// \brief Render the camera - public: virtual void PostRender() override; - - /// \brief Connect to the new thermal image event - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewThermalFrame( - std::function _subscriber) override; - - /// \brief Implementation of the render call - public: virtual void Render() override; - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Create the camera. - protected: void CreateCamera(); - - /// \brief Create dummy render texture. Needed to satisfy inheritance - protected: virtual void CreateRenderTexture(); - - /// \brief Create thermal texture - protected: virtual void CreateThermalTexture(); - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera = nullptr; - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh index fd07fdca2..82e2f07e5 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,99 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2VISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2VISUAL_HH_ -#include -#include - -#include "ignition/rendering/base/BaseVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Node.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2VisualPrivate; - - /// \brief Ogre2.x implementation of the visual class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Visual : - public BaseVisual - { - /// \brief Constructor - protected: Ogre2Visual(); - - /// \brief Destructor - public: virtual ~Ogre2Visual(); - - // Documentation inherited - public: virtual void SetWireframe(bool _show) override; - - // Documentation inherited - public: virtual bool Wireframe() const override; - - // Documentation inherited. - public: virtual void SetVisible(bool _visible) override; - - // Documentation inherited. - public: virtual void SetVisibilityFlags(uint32_t _flags) override; - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox BoundingBox() - const override; - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox LocalBoundingBox() - const override; - - /// \brief Recursively loop through this visual's children - /// to obtain the bounding box. - /// \param[in,out] _box The bounding box. - /// \param[in] _local A flag indicating if the local bounding box is to - /// be calculated. - /// \param[in] _pose World pose of the visual - private: virtual void BoundsHelper( - ignition::math::AxisAlignedBox &_box, bool _local, - const ignition::math::Pose3d &_pose) const; - - /// \brief Wrapper function for BoundsHelper to reduce redundant - /// world pose access - /// \param[in,out] _box The bounding box. - /// \param[in] _local A flag indicating if the local bounding box is to - /// be calculated. - private: virtual void BoundsHelper( - ignition::math::AxisAlignedBox &_box, bool _local) const; - - // Documentation inherited. - protected: virtual GeometryStorePtr Geometries() const override; - - // Documentation inherited. - protected: virtual bool AttachGeometry(GeometryPtr _geometry) override; - - // Documentation inherited. - protected: virtual bool DetachGeometry(GeometryPtr _geometry) override; - - /// \brief Initialize the visual - protected: virtual void Init() override; - - /// \brief Get a shared pointer to this. - /// \return Shared pointer to this - private: Ogre2VisualPtr SharedThis(); - - /// \brief Pointer to the attached geometries - protected: Ogre2GeometryStorePtr geometries; - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - - /// \brief Make scene our friend so it can create ogre2 visuals - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2WireBox.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2WireBox.hh index 48ed93447..592cf0eef 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2WireBox.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2WireBox.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,69 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ - -#ifndef IGNITION_RENDERING_OGRE2_OGRE2WIREBOX_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2WIREBOX_HH_ - -#include -#include "ignition/rendering/base/BaseWireBox.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2WireBoxPrivate; - - /// \brief Ogre2 implementation of a wire box geometry. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2WireBox - : public BaseWireBox - { - /// \brief Constructor - protected: Ogre2WireBox(); - - /// \brief Destructor - public: virtual ~Ogre2WireBox(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial(MaterialPtr _material, bool _unique) - override; - - /// \brief Set material to wire box geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); - - /// \brief Create the wire box geometry in ogre2 - private: void Create(); - - /// \brief Wire Box should only be created by scene. - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif + */ +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/ogre2.hh.in b/ogre2/include/ignition/rendering/ogre2/ogre2.hh.in deleted file mode 100644 index acfd26ae7..000000000 --- a/ogre2/include/ignition/rendering/ogre2/ogre2.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/ogre2/src/Ogre2Camera.cc b/ogre2/src/Ogre2Camera.cc index ad4196fa9..ff61ab7be 100644 --- a/ogre2/src/Ogre2Camera.cc +++ b/ogre2/src/Ogre2Camera.cc @@ -15,12 +15,12 @@ * */ -#include "ignition/rendering/ogre2/Ogre2Camera.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2SelectionBuffer.hh" -#include "ignition/rendering/Utils.hh" +#include "gz/rendering/ogre2/Ogre2Camera.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2SelectionBuffer.hh" +#include "gz/rendering/Utils.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -33,11 +33,11 @@ #endif /// \brief Private data for the Ogre2Camera class -class ignition::rendering::Ogre2CameraPrivate +class gz::rendering::Ogre2CameraPrivate { }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// @@ -311,8 +311,17 @@ VisualPtr Ogre2Camera::VisualAt(const math::Vector2i &_mousePos) ////////////////////////////////////////////////// RenderWindowPtr Ogre2Camera::CreateRenderWindow() { - // TODO(anyone) - return RenderWindowPtr(); + RenderWindowPtr base = this->scene->CreateRenderWindow(); + Ogre2RenderWindowPtr renderWindow = + std::dynamic_pointer_cast(base); + renderWindow->SetWidth(this->ImageWidth()); + renderWindow->SetHeight(this->ImageHeight()); + renderWindow->SetDevicePixelRatio(1); + renderWindow->SetCamera(this->ogreCamera); + renderWindow->SetBackgroundColor(this->scene->BackgroundColor()); + + this->renderTexture = renderWindow; + return base; } ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Conversions.cc b/ogre2/src/Ogre2Conversions.cc index ea208b9be..f2f9f325e 100644 --- a/ogre2/src/Ogre2Conversions.cc +++ b/ogre2/src/Ogre2Conversions.cc @@ -14,7 +14,7 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -24,7 +24,7 @@ #pragma warning(pop) #endif -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2DepthCamera.cc b/ogre2/src/Ogre2DepthCamera.cc index a4ebcf09e..377f0a9a1 100644 --- a/ogre2/src/Ogre2DepthCamera.cc +++ b/ogre2/src/Ogre2DepthCamera.cc @@ -33,19 +33,19 @@ #endif #include -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2DepthCamera.hh" -#include "ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2ParticleEmitter.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2DepthCamera.hh" +#include "gz/rendering/ogre2/Ogre2GaussianNoisePass.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2ParticleEmitter.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" #include "Ogre2ParticleNoiseListener.hh" @@ -83,7 +83,7 @@ class Ogre2DepthGaussianNoisePass : public Ogre2GaussianNoisePass /// \internal /// \brief Private data for the Ogre2DepthCamera class -class ignition::rendering::Ogre2DepthCameraPrivate +class gz::rendering::Ogre2DepthCameraPrivate { /// \brief The depth buffer public: float *depthBuffer = nullptr; @@ -95,10 +95,10 @@ class ignition::rendering::Ogre2DepthCameraPrivate public: float *pointCloudImage = nullptr; /// \brief maximum value used for data outside sensor range - public: float dataMaxVal = ignition::math::INF_D; + public: float dataMaxVal = gz::math::INF_D; /// \brief minimum value used for data outside sensor range - public: float dataMinVal = -ignition::math::INF_D; + public: float dataMinVal = -gz::math::INF_D; /// \brief 1st pass compositor workspace definition public: std::string ogreCompositorWorkspaceDef; @@ -131,12 +131,12 @@ class ignition::rendering::Ogre2DepthCameraPrivate public: bool renderPassDirty = false; /// \brief Event used to signal rgb point cloud data - public: ignition::common::EventT newRgbPointCloud; /// \brief Event used to signal depth data - public: ignition::common::EventT newDepthFrame; @@ -158,7 +158,7 @@ class ignition::rendering::Ogre2DepthCameraPrivate public: const std::string kShadowNodeName = "PbsMaterialsShadowNode"; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2DynamicRenderable.cc b/ogre2/src/Ogre2DynamicRenderable.cc index 736de8680..e52228213 100644 --- a/ogre2/src/Ogre2DynamicRenderable.cc +++ b/ogre2/src/Ogre2DynamicRenderable.cc @@ -17,20 +17,21 @@ // Note this include is placed in the src file because // otherwise ogre produces compile errors -#ifdef _MSC_VER -#pragma warning(push, 0) +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable: 5033) #endif #include -#ifdef _MSC_VER +#if defined(_MSC_VER) #pragma warning(pop) #endif -#include "ignition/common/Console.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2DynamicRenderable.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2DynamicRenderable.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -46,13 +47,13 @@ #endif /// \brief Private implementation -class ignition::rendering::Ogre2DynamicRenderablePrivate +class gz::rendering::Ogre2DynamicRenderablePrivate { /// \brief list of colors at each point - public: std::vector colors; + public: std::vector colors; /// \brief List of vertices for the mesh - public: std::vector vertices; + public: std::vector vertices; /// \brief Used to indicate if the lines require an update public: bool dirty = false; @@ -93,7 +94,7 @@ class ignition::rendering::Ogre2DynamicRenderablePrivate }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2GaussianNoisePass.cc b/ogre2/src/Ogre2GaussianNoisePass.cc index b893388bc..46dffc35f 100644 --- a/ogre2/src/Ogre2GaussianNoisePass.cc +++ b/ogre2/src/Ogre2GaussianNoisePass.cc @@ -16,11 +16,11 @@ */ -#include +#include -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/ogre2/Ogre2GaussianNoisePass.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -39,13 +39,13 @@ #endif /// \brief Private data for the Ogre2GaussianNoisePass class -class ignition::rendering::Ogre2GaussianNoisePassPrivate +class gz::rendering::Ogre2GaussianNoisePassPrivate { /// brief Pointer to the Gaussian noise ogre material public: Ogre::Material *gaussianNoiseMat = nullptr; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Geometry.cc b/ogre2/src/Ogre2Geometry.cc index 759fe3b97..a19814a44 100644 --- a/ogre2/src/Ogre2Geometry.cc +++ b/ogre2/src/Ogre2Geometry.cc @@ -14,11 +14,11 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" +#include "gz/rendering/ogre2/Ogre2Geometry.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2GizmoVisual.cc b/ogre2/src/Ogre2GizmoVisual.cc index 5c7b2eba7..f5d3be24a 100644 --- a/ogre2/src/Ogre2GizmoVisual.cc +++ b/ogre2/src/Ogre2GizmoVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre2/Ogre2GizmoVisual.hh" +#include "gz/rendering/ogre2/Ogre2GizmoVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2GpuRays.cc b/ogre2/src/Ogre2GpuRays.cc index f49ccea9a..46f74728b 100644 --- a/ogre2/src/Ogre2GpuRays.cc +++ b/ogre2/src/Ogre2GpuRays.cc @@ -15,23 +15,23 @@ * */ -#include -#include - -#include -#include - -#include "ignition/rendering/ogre2/Ogre2Camera.hh" -#include "ignition/rendering/ogre2/Ogre2GpuRays.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2ParticleEmitter.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" +#include +#include + +#include +#include + +#include "gz/rendering/ogre2/Ogre2Camera.hh" +#include "gz/rendering/ogre2/Ogre2GpuRays.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2ParticleEmitter.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" #include "Ogre2IgnHlmsCustomizations.hh" #include "Ogre2ParticleNoiseListener.hh" @@ -45,10 +45,14 @@ #include #include #include +#include #include +#include #include #include +#include #include +#include #ifdef _MSC_VER #pragma warning(pop) #endif @@ -104,7 +108,7 @@ class Ogre2LaserRetroMaterialSwitcher : public Ogre::Camera::Listener /// \internal /// \brief Private data for the Ogre2GpuRays class -class ignition::rendering::Ogre2GpuRaysPrivate +class gz::rendering::Ogre2GpuRaysPrivate { /// \brief Event triggered when new gpu rays range data are available. /// \param[in] _frame New frame containing raw gpu rays data. @@ -112,7 +116,7 @@ class ignition::rendering::Ogre2GpuRaysPrivate /// \param[in] _height Height of frame. /// \param[in] _channel Number of channels /// \param[in] _format Format of frame. - public: ignition::common::EventT newGpuRaysFrame; @@ -202,7 +206,7 @@ class ignition::rendering::Ogre2GpuRaysPrivate public: const unsigned int kCubeCameraCount = 6; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Grid.cc b/ogre2/src/Ogre2Grid.cc index 08493253a..63078c3ed 100644 --- a/ogre2/src/Ogre2Grid.cc +++ b/ogre2/src/Ogre2Grid.cc @@ -15,17 +15,17 @@ * */ -#include +#include -#include "ignition/rendering/ogre2/Ogre2Grid.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2DynamicRenderable.hh" +#include "gz/rendering/ogre2/Ogre2Grid.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2DynamicRenderable.hh" -using namespace ignition; +using namespace gz; using namespace rendering; -class ignition::rendering::Ogre2GridPrivate +class gz::rendering::Ogre2GridPrivate { /// \brief Grid materal public: Ogre2MaterialPtr material; @@ -43,11 +43,14 @@ Ogre2Grid::Ogre2Grid() ////////////////////////////////////////////////// Ogre2Grid::~Ogre2Grid() { + BaseGrid::Destroy(); } ////////////////////////////////////////////////// void Ogre2Grid::PreRender() { + BaseGrid::PreRender(); + if (this->gridDirty) { this->Create(); diff --git a/ogre2/src/Ogre2Light.cc b/ogre2/src/Ogre2Light.cc index e5c048315..dd61fd539 100644 --- a/ogre2/src/Ogre2Light.cc +++ b/ogre2/src/Ogre2Light.cc @@ -15,12 +15,12 @@ * */ -#include +#include -#include "ignition/rendering/ogre2/Ogre2Light.hh" +#include "gz/rendering/ogre2/Ogre2Light.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -31,7 +31,7 @@ #endif /// \brief Private data for the Ogre2Light class -class ignition::rendering::Ogre2LightPrivate +class gz::rendering::Ogre2LightPrivate { }; diff --git a/ogre2/src/Ogre2Marker.cc b/ogre2/src/Ogre2Marker.cc index 5529eae58..411d1017c 100644 --- a/ogre2/src/Ogre2Marker.cc +++ b/ogre2/src/Ogre2Marker.cc @@ -25,20 +25,20 @@ #endif #endif -#include +#include -#include -#include +#include +#include -#include "ignition/rendering/ogre2/Ogre2Capsule.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2DynamicRenderable.hh" -#include "ignition/rendering/ogre2/Ogre2Marker.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2Mesh.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" +#include "gz/rendering/ogre2/Ogre2Capsule.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2DynamicRenderable.hh" +#include "gz/rendering/ogre2/Ogre2Marker.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2Mesh.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -51,7 +51,7 @@ #pragma warning(pop) #endif -class ignition::rendering::Ogre2MarkerPrivate +class gz::rendering::Ogre2MarkerPrivate { /// \brief Marker material public: Ogre2MaterialPtr material = nullptr; @@ -67,7 +67,7 @@ class ignition::rendering::Ogre2MarkerPrivate public: std::shared_ptr dynamicRenderable; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// @@ -136,6 +136,8 @@ void Ogre2Marker::PreRender() ////////////////////////////////////////////////// void Ogre2Marker::Destroy() { + BaseMarker::Destroy(); + if (this->dataPtr->geom) { this->dataPtr->geom->Destroy(); @@ -297,6 +299,7 @@ MaterialPtr Ogre2Marker::Material() const void Ogre2Marker::SetPoint(unsigned int _index, const math::Vector3d &_value) { + BaseMarker::SetPoint(_index, _value); this->dataPtr->dynamicRenderable->SetPoint(_index, _value); } @@ -304,12 +307,14 @@ void Ogre2Marker::SetPoint(unsigned int _index, void Ogre2Marker::AddPoint(const math::Vector3d &_pt, const math::Color &_color) { + BaseMarker::AddPoint(_pt, _color); this->dataPtr->dynamicRenderable->AddPoint(_pt, _color); } ////////////////////////////////////////////////// void Ogre2Marker::ClearPoints() { + BaseMarker::ClearPoints(); this->dataPtr->dynamicRenderable->Clear(); } diff --git a/ogre2/src/Ogre2Material.cc b/ogre2/src/Ogre2Material.cc index 56d130d2f..12b4ba3e2 100644 --- a/ogre2/src/Ogre2Material.cc +++ b/ogre2/src/Ogre2Material.cc @@ -37,21 +37,21 @@ #pragma warning(pop) #endif -#include -#include -#include +#include +#include +#include -#include "ignition/rendering/GraphicsAPI.hh" -#include "ignition/rendering/ShaderParams.hh" -#include "ignition/rendering/ShaderType.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/GraphicsAPI.hh" +#include "gz/rendering/ShaderParams.hh" +#include "gz/rendering/ShaderType.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" /// \brief Private data for the Ogre2Material class -class ignition::rendering::Ogre2MaterialPrivate +class gz::rendering::Ogre2MaterialPrivate { /// \brief Ogre stores the name using hashes. This variable will /// store the material hash name @@ -70,7 +70,7 @@ class ignition::rendering::Ogre2MaterialPrivate public: ShaderParamsPtr fragmentShaderParams; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2MaterialSwitcher.cc b/ogre2/src/Ogre2MaterialSwitcher.cc index c60f5a6be..f6c6c63e3 100644 --- a/ogre2/src/Ogre2MaterialSwitcher.cc +++ b/ogre2/src/Ogre2MaterialSwitcher.cc @@ -15,10 +15,10 @@ * */ -#include "ignition/common/Console.hh" -#include "ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/RenderTypes.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/ogre2/Ogre2MaterialSwitcher.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/RenderTypes.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -32,7 +32,7 @@ #pragma warning(pop) #endif -using namespace ignition; +using namespace gz; using namespace rendering; @@ -45,7 +45,7 @@ std::mapcurrentColor = math::Color(0.0, 0.0, 0.1); + this->currentColor = math::Color(0.0f, 0.0f, 0.1f); this->scene = _scene; // plain opaque material diff --git a/ogre2/src/Ogre2Mesh.cc b/ogre2/src/Ogre2Mesh.cc index 929078a22..cf307b312 100644 --- a/ogre2/src/Ogre2Mesh.cc +++ b/ogre2/src/Ogre2Mesh.cc @@ -17,8 +17,10 @@ // Note this include is placed in the src file because // otherwise ogre produces compile errors -#ifdef _MSC_VER -#pragma warning(push, 0) +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable: 4005) // Macro redefinition +#pragma warning(disable: 5033) // 'register' is no longer supported #endif #include #include @@ -27,31 +29,31 @@ #include #include #include -#ifdef _MSC_VER +#if defined(_MSC_VER) #pragma warning(pop) #endif -#include +#include -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Mesh.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2Storage.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Mesh.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2Storage.hh" /// brief Private implementation of the Ogre2Mesh class -class ignition::rendering::Ogre2MeshPrivate +class gz::rendering::Ogre2MeshPrivate { }; /// brief Private implementation of the Ogre2SubMesh class -class ignition::rendering::Ogre2SubMeshPrivate +class gz::rendering::Ogre2SubMeshPrivate { /// \brief name of the mesh inside the mesh manager to be able to /// remove it public: std::string subMeshName; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2MeshFactory.cc b/ogre2/src/Ogre2MeshFactory.cc index 82d392abb..102d901f2 100644 --- a/ogre2/src/Ogre2MeshFactory.cc +++ b/ogre2/src/Ogre2MeshFactory.cc @@ -18,22 +18,22 @@ #include -#include -#include -#include -#include -#include -#include - -#include - -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Mesh.hh" -#include "ignition/rendering/ogre2/Ogre2MeshFactory.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Storage.hh" +#include +#include +#include +#include +#include +#include + +#include + +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Mesh.hh" +#include "gz/rendering/ogre2/Ogre2MeshFactory.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Storage.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -56,7 +56,7 @@ #endif /// \brief Private data for the Ogre2MeshFactory class -class ignition::rendering::Ogre2MeshFactoryPrivate +class gz::rendering::Ogre2MeshFactoryPrivate { /// \brief Vector with the template materials, we keep the pointer to be /// able to remove it when nobody is using it. @@ -64,7 +64,7 @@ class ignition::rendering::Ogre2MeshFactoryPrivate }; /// \brief Private data for the Ogre2SubMeshStoreFactory class -class ignition::rendering::Ogre2SubMeshStoreFactoryPrivate +class gz::rendering::Ogre2SubMeshStoreFactoryPrivate { }; diff --git a/ogre2/src/Ogre2Node.cc b/ogre2/src/Ogre2Node.cc index a9b6b4d5d..33900568b 100644 --- a/ogre2/src/Ogre2Node.cc +++ b/ogre2/src/Ogre2Node.cc @@ -15,12 +15,12 @@ * */ -#include +#include -#include "ignition/rendering/ogre2/Ogre2Node.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Storage.hh" +#include "gz/rendering/ogre2/Ogre2Node.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Storage.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -30,7 +30,7 @@ #pragma warning(pop) #endif -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Object.cc b/ogre2/src/Ogre2Object.cc index 35db61317..1c4d2890d 100644 --- a/ogre2/src/Ogre2Object.cc +++ b/ogre2/src/Ogre2Object.cc @@ -15,11 +15,11 @@ * */ -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2RayQuery.cc b/ogre2/src/Ogre2RayQuery.cc index 98aaf6d3e..e2e016278 100644 --- a/ogre2/src/Ogre2RayQuery.cc +++ b/ogre2/src/Ogre2RayQuery.cc @@ -15,16 +15,16 @@ * */ -#include -#include -#include -#include +#include +#include +#include +#include -#include "ignition/rendering/ogre2/Ogre2Camera.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2RayQuery.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2SelectionBuffer.hh" +#include "gz/rendering/ogre2/Ogre2Camera.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2RayQuery.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2SelectionBuffer.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -39,7 +39,7 @@ #endif /// \brief Private data class for Ogre2RayQuery -class ignition::rendering::Ogre2RayQueryPrivate +class gz::rendering::Ogre2RayQueryPrivate { /// \brief Ogre ray scene query object for computing intersection. public: Ogre::RaySceneQuery *rayQuery = nullptr; @@ -54,7 +54,7 @@ class ignition::rendering::Ogre2RayQueryPrivate public: std::thread::id threadId; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index 9a20332e7..4264e9f39 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -27,26 +27,26 @@ // pulled in by anybody (e.g., Boost). #include #endif -#include -#include -#include +#include +#include +#include -#include +#include -#include "ignition/rendering/GraphicsAPI.hh" -#include "ignition/rendering/RenderEngineManager.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Storage.hh" +#include "gz/rendering/GraphicsAPI.hh" +#include "gz/rendering/RenderEngineManager.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Storage.hh" #include "Terra/Hlms/OgreHlmsTerra.h" #include "Terra/Hlms/PbsListener/OgreHlmsPbsTerraShadows.h" #include "Terra/TerraWorkspaceListener.h" #include "Ogre2IgnHlmsCustomizations.hh" -class ignition::rendering::Ogre2RenderEnginePrivate +class gz::rendering::Ogre2RenderEnginePrivate { #if HAVE_GLX public: GLXFBConfig* dummyFBConfigs = nullptr; @@ -69,7 +69,7 @@ class ignition::rendering::Ogre2RenderEnginePrivate public: std::unique_ptr terraWorkspaceListener; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// @@ -176,7 +176,7 @@ void Ogre2RenderEngine::Destroy() ////////////////////////////////////////////////// bool Ogre2RenderEngine::IsEnabled() const { - return this->initialized; + return BaseRenderEngine::IsEnabled(); } ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2RenderPass.cc b/ogre2/src/Ogre2RenderPass.cc index 267b2ffff..95c46c7dd 100644 --- a/ogre2/src/Ogre2RenderPass.cc +++ b/ogre2/src/Ogre2RenderPass.cc @@ -14,14 +14,14 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre2/Ogre2RenderPass.hh" +#include "gz/rendering/ogre2/Ogre2RenderPass.hh" /// \brief Private data for the Ogre2RenderPass class class ignition::rendering::Ogre2RenderPassPrivate { }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2RenderTarget.cc b/ogre2/src/Ogre2RenderTarget.cc index 2fef82bac..9d995439c 100644 --- a/ogre2/src/Ogre2RenderTarget.cc +++ b/ogre2/src/Ogre2RenderTarget.cc @@ -15,17 +15,17 @@ * */ -#include +#include -#include "ignition/rendering/Material.hh" +#include "gz/rendering/Material.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderPass.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderPass.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" namespace ignition { @@ -75,7 +75,7 @@ class Ogre2RenderTargetCompositorListener : } /// \brief Private data class for Ogre2RenderTarget -class ignition::rendering::Ogre2RenderTargetPrivate +class gz::rendering::Ogre2RenderTargetPrivate { /// \brief Listener for chaning compositor pass properties public: Ogre2RenderTargetCompositorListener *rtListener = nullptr; @@ -101,7 +101,7 @@ class ignition::rendering::Ogre2RenderTargetPrivate public: Ogre::TextureGpu *ogreTexture[2] = {nullptr, nullptr}; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2RenderTargetMaterial.cc b/ogre2/src/Ogre2RenderTargetMaterial.cc index d87645a78..8a2d31ca6 100644 --- a/ogre2/src/Ogre2RenderTargetMaterial.cc +++ b/ogre2/src/Ogre2RenderTargetMaterial.cc @@ -15,7 +15,7 @@ * */ -#include "ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh" +#include "gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -26,7 +26,7 @@ #pragma warning(pop) #endif -using namespace ignition::rendering; +using namespace gz::rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Scene.cc b/ogre2/src/Ogre2Scene.cc index 055cb911c..af534ecaa 100644 --- a/ogre2/src/Ogre2Scene.cc +++ b/ogre2/src/Ogre2Scene.cc @@ -15,40 +15,40 @@ * */ -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2ArrowVisual.hh" -#include "ignition/rendering/ogre2/Ogre2AxisVisual.hh" -#include "ignition/rendering/ogre2/Ogre2BoundingBoxCamera.hh" -#include "ignition/rendering/ogre2/Ogre2Camera.hh" -#include "ignition/rendering/ogre2/Ogre2Capsule.hh" -#include "ignition/rendering/ogre2/Ogre2COMVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2DepthCamera.hh" -#include "ignition/rendering/ogre2/Ogre2GizmoVisual.hh" -#include "ignition/rendering/ogre2/Ogre2GpuRays.hh" -#include "ignition/rendering/ogre2/Ogre2Grid.hh" -#include "ignition/rendering/ogre2/Ogre2Heightmap.hh" -#include "ignition/rendering/ogre2/Ogre2InertiaVisual.hh" -#include "ignition/rendering/ogre2/Ogre2JointVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Light.hh" -#include "ignition/rendering/ogre2/Ogre2LightVisual.hh" -#include "ignition/rendering/ogre2/Ogre2LidarVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Marker.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2MeshFactory.hh" -#include "ignition/rendering/ogre2/Ogre2Node.hh" -#include "ignition/rendering/ogre2/Ogre2ParticleEmitter.hh" -#include "ignition/rendering/ogre2/Ogre2RayQuery.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2ThermalCamera.hh" -#include "ignition/rendering/ogre2/Ogre2SegmentationCamera.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" -#include "ignition/rendering/ogre2/Ogre2WireBox.hh" +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2ArrowVisual.hh" +#include "gz/rendering/ogre2/Ogre2AxisVisual.hh" +#include "gz/rendering/ogre2/Ogre2BoundingBoxCamera.hh" +#include "gz/rendering/ogre2/Ogre2Camera.hh" +#include "gz/rendering/ogre2/Ogre2Capsule.hh" +#include "gz/rendering/ogre2/Ogre2COMVisual.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2DepthCamera.hh" +#include "gz/rendering/ogre2/Ogre2GizmoVisual.hh" +#include "gz/rendering/ogre2/Ogre2GpuRays.hh" +#include "gz/rendering/ogre2/Ogre2Grid.hh" +#include "gz/rendering/ogre2/Ogre2Heightmap.hh" +#include "gz/rendering/ogre2/Ogre2InertiaVisual.hh" +#include "gz/rendering/ogre2/Ogre2JointVisual.hh" +#include "gz/rendering/ogre2/Ogre2Light.hh" +#include "gz/rendering/ogre2/Ogre2LightVisual.hh" +#include "gz/rendering/ogre2/Ogre2LidarVisual.hh" +#include "gz/rendering/ogre2/Ogre2Marker.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2MeshFactory.hh" +#include "gz/rendering/ogre2/Ogre2Node.hh" +#include "gz/rendering/ogre2/Ogre2ParticleEmitter.hh" +#include "gz/rendering/ogre2/Ogre2RayQuery.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2ThermalCamera.hh" +#include "gz/rendering/ogre2/Ogre2SegmentationCamera.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" +#include "gz/rendering/ogre2/Ogre2WireBox.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -75,7 +75,7 @@ #endif /// \brief Private data for the Ogre2Scene class -class ignition::rendering::Ogre2ScenePrivate +class gz::rendering::Ogre2ScenePrivate { /// \brief Flag to indicate if shadows need to be updated public: bool shadowsDirty = true; @@ -121,7 +121,7 @@ class ignition::rendering::Ogre2ScenePrivate public: const std::string kShadowNodeName = "PbsMaterialsShadowNode"; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// @@ -1341,11 +1341,12 @@ RenderTexturePtr Ogre2Scene::CreateRenderTextureImpl(unsigned int _id, } ////////////////////////////////////////////////// -RenderWindowPtr Ogre2Scene::CreateRenderWindowImpl(unsigned int /*_id*/, - const std::string &/*_name*/) +RenderWindowPtr Ogre2Scene::CreateRenderWindowImpl(unsigned int _id, + const std::string &_name) { - // TODO(anyone) - return RenderWindowPtr(); + Ogre2RenderWindowPtr renderWindow(new Ogre2RenderWindow); + bool result = this->InitObject(renderWindow, _id, _name); + return (result) ? renderWindow : nullptr; } ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc b/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc index 923eaaf28..020b34dd3 100644 --- a/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc +++ b/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc @@ -23,10 +23,10 @@ #include -#include "ignition/rendering/ogre2/Ogre2Heightmap.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Heightmap.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" +#include "gz/rendering/RenderTypes.hh" #ifdef _MSC_VER #pragma warning(push, 0) diff --git a/ogre2/src/Ogre2SegmentationMaterialSwitcher.hh b/ogre2/src/Ogre2SegmentationMaterialSwitcher.hh index 8cd08b87e..10bc8940d 100644 --- a/ogre2/src/Ogre2SegmentationMaterialSwitcher.hh +++ b/ogre2/src/Ogre2SegmentationMaterialSwitcher.hh @@ -24,13 +24,13 @@ #include #include -#include +#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2Camera.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/SegmentationCamera.hh" +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre2/Export.hh" +#include "gz/rendering/ogre2/Ogre2Camera.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/SegmentationCamera.hh" namespace ignition { diff --git a/ogre2/src/Ogre2SelectionBuffer.cc b/ogre2/src/Ogre2SelectionBuffer.cc index bb9bac9de..3b996539f 100644 --- a/ogre2/src/Ogre2SelectionBuffer.cc +++ b/ogre2/src/Ogre2SelectionBuffer.cc @@ -16,16 +16,16 @@ */ #include -#include +#include -#include "ignition/common/Console.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2SelectionBuffer.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2MaterialSwitcher.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2SelectionBuffer.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -48,10 +48,10 @@ #pragma warning(pop) #endif -using namespace ignition; +using namespace gz; using namespace rendering; -class ignition::rendering::Ogre2SelectionBufferPrivate +struct gz::rendering::Ogre2SelectionBufferPrivate { /// \brief This is a material listener and a RenderTargetListener. /// The material switcher is applied to only the selection camera diff --git a/ogre2/src/Ogre2Sensor.cc b/ogre2/src/Ogre2Sensor.cc index 7c919314b..b5a3c831b 100644 --- a/ogre2/src/Ogre2Sensor.cc +++ b/ogre2/src/Ogre2Sensor.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2ThermalCamera.cc b/ogre2/src/Ogre2ThermalCamera.cc index a75d8ebea..19959d736 100644 --- a/ogre2/src/Ogre2ThermalCamera.cc +++ b/ogre2/src/Ogre2ThermalCamera.cc @@ -49,24 +49,24 @@ #pragma warning(pop) #endif -#include -#include -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2ParticleEmitter.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" -#include "ignition/rendering/ogre2/Ogre2ThermalCamera.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -#include +#include +#include +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2ParticleEmitter.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" +#include "gz/rendering/ogre2/Ogre2ThermalCamera.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" + +#include namespace ignition { @@ -156,7 +156,7 @@ class Ogre2ThermalCameraMaterialSwitcher : public Ogre::Camera::Listener /// \internal /// \brief Private data for the Ogre2ThermalCamera class -class ignition::rendering::Ogre2ThermalCameraPrivate +class gz::rendering::Ogre2ThermalCameraPrivate { /// \brief Outgoing thermal data, used by newThermalFrame event. public: uint16_t *thermalImage = nullptr; @@ -186,7 +186,7 @@ class ignition::rendering::Ogre2ThermalCameraPrivate public: Ogre::MaterialPtr thermalMaterial; /// \brief Event used to signal thermal image data - public: ignition::common::EventT newThermalFrame; @@ -203,7 +203,7 @@ class ignition::rendering::Ogre2ThermalCameraPrivate public: unsigned int bitDepth = 16u; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// @@ -282,7 +282,7 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPreRenderScene( { try { - temp = std::get(tempAny); + temp = static_cast(std::get(tempAny)); } catch(...) { diff --git a/ogre2/src/Ogre2Visual.cc b/ogre2/src/Ogre2Visual.cc index ba2658e41..74c6cd1b5 100644 --- a/ogre2/src/Ogre2Visual.cc +++ b/ogre2/src/Ogre2Visual.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" -#include "ignition/rendering/ogre2/Ogre2ParticleEmitter.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Storage.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" -#include "ignition/rendering/Utils.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Geometry.hh" +#include "gz/rendering/ogre2/Ogre2ParticleEmitter.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Storage.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" +#include "gz/rendering/Utils.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -33,7 +33,7 @@ #pragma warning(pop) #endif -using namespace ignition; +using namespace gz; using namespace rendering; /// \brief Private data for the Ogre2Visual class diff --git a/optix/include/CMakeLists.txt b/optix/include/CMakeLists.txt index 297e254ff..a7479f53e 100644 --- a/optix/include/CMakeLists.txt +++ b/optix/include/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(ignition/rendering) +add_subdirectory(gz/rendering) +install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) diff --git a/optix/include/ignition/rendering/CMakeLists.txt b/optix/include/gz/rendering/CMakeLists.txt similarity index 100% rename from optix/include/ignition/rendering/CMakeLists.txt rename to optix/include/gz/rendering/CMakeLists.txt diff --git a/optix/include/gz/rendering/optix/OptixArrowVisual.hh b/optix/include/gz/rendering/optix/OptixArrowVisual.hh new file mode 100644 index 000000000..260fa8dad --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixArrowVisual.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXARROWVISUAL_HH_ +#define GZ_RENDERING_OPTIX_OPTIXARROWVISUAL_HH_ + +#include "gz/rendering/base/BaseArrowVisual.hh" +#include "gz/rendering/optix/OptixVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixArrowVisual : + public BaseArrowVisual + { + protected: OptixArrowVisual(); + + public: virtual ~OptixArrowVisual(); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixAxisVisual.hh b/optix/include/gz/rendering/optix/OptixAxisVisual.hh new file mode 100644 index 000000000..37f93f619 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixAxisVisual.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXAXISVISUAL_HH_ +#define GZ_RENDERING_OPTIX_OPTIXAXISVISUAL_HH_ + +#include "gz/rendering/base/BaseAxisVisual.hh" +#include "gz/rendering/optix/OptixVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixAxisVisual : + public BaseAxisVisual + { + protected: OptixAxisVisual(); + + public: virtual ~OptixAxisVisual(); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixBox.hh b/optix/include/gz/rendering/optix/OptixBox.hh new file mode 100644 index 000000000..872173cfb --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixBox.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXBOX_HH_ +#define GZ_RENDERING_OPTIX_OPTIXBOX_HH_ + +#include "gz/rendering/optix/OptixPrimitive.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixBox : + public OptixPrimitive + { + protected: OptixBox(); + + public: virtual ~OptixBox(); + + public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixCamera.hh b/optix/include/gz/rendering/optix/OptixCamera.hh new file mode 100644 index 000000000..5ac597500 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixCamera.hh @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXCAMERA_HH_ +#define GZ_RENDERING_OPTIX_OPTIXCAMERA_HH_ + +#include +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixSensor.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixCamera : + public BaseCamera + { + protected: OptixCamera(); + + public: virtual ~OptixCamera(); + + public: virtual void SetHFOV(const math::Angle &_hfov); + + public: virtual void SetAspectRatio(const double _ratio); + + public: virtual void SetAntiAliasing(const unsigned int _aa); + + public: virtual void PreRender(); + + public: virtual void Render(); + + protected: virtual RenderTargetPtr RenderTarget() const; + + protected: virtual void WriteCameraToDevice(); + + protected: virtual void WriteCameraToDeviceImpl(); + + protected: virtual void WritePoseToDeviceImpl(); + + protected: virtual void Init(); + + protected: virtual void CreateRenderTexture(); + + // Documentation inherited. + protected: virtual RenderWindowPtr CreateRenderWindow(); + + protected: virtual void CreateRenderProgram(); + + protected: virtual void CreateClearProgram(); + + protected: virtual void CreateErrorProgram(); + + protected: optix::Program optixRenderProgram; + + protected: optix::Program optixClearProgram; + + protected: optix::Program optixErrorProgram; + + protected: OptixRenderTexturePtr renderTexture; + + protected: bool cameraDirty; + + protected: unsigned int traceId; + + protected: unsigned int clearId; + + private: static const std::string PTX_BASE_NAME; + + private: static const std::string PTX_RENDER_FUNCTION; + + private: static const std::string PTX_CLEAR_FUNCTION; + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixCone.hh b/optix/include/gz/rendering/optix/OptixCone.hh new file mode 100644 index 000000000..d3a4d6352 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixCone.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXCONE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXCONE_HH_ + +#include "gz/rendering/optix/OptixPrimitive.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixCone : + public OptixPrimitive + { + protected: OptixCone(); + + public: virtual ~OptixCone(); + + public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixConversions.hh b/optix/include/gz/rendering/optix/OptixConversions.hh new file mode 100644 index 000000000..bc6ac6a91 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixConversions.hh @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXCONVERSIONS_HH_ +#define GZ_RENDERING_OPTIX_OPTIXCONVERSIONS_HH_ + +#include +#include +#include + +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \addtogroup ign_rendering + /// \{ + + /// \brief Conversions Conversions.hh rendering/Conversions.hh + /// \brief A set of utility function to convert between Gazebo and Optix + /// data types + class IGNITION_RENDERING_OPTIX_VISIBLE OptixConversions + { + /// \brief Return the equivalent optix color + /// \param[in] _color Gazebo color to convert + /// \return Optix color value + public: static float4 ConvertColor(const math::Color &_color); + + /// \brief Return the equivalent ign-math color + /// \param[in] _color Optix color to convert + /// \return Gazebo color value + public: static math::Color ConvertColor(const float4 &_color); + + /// \brief return Optix Vector from Gazebo Vector3 + /// \param[in] _vector Gazebo vector + /// \return Optix vector + public: static float3 ConvertVector(const math::Vector3d &_vector); + + /// \brief return ign-math Vector from optix Vector3 + /// \param[in] _vector Optix vector + /// \return Gazebo vector + public: static math::Vector3d ConvertVector(const float3 &_vector); + }; + /// \} + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixCylinder.hh b/optix/include/gz/rendering/optix/OptixCylinder.hh new file mode 100644 index 000000000..08ac588fc --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixCylinder.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXCYLINDER_HH_ +#define GZ_RENDERING_OPTIX_OPTIXCYLINDER_HH_ + +#include "gz/rendering/optix/OptixPrimitive.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixCylinder : + public OptixPrimitive + { + protected: OptixCylinder(); + + public: virtual ~OptixCylinder(); + + public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixGeometry.hh b/optix/include/gz/rendering/optix/OptixGeometry.hh new file mode 100644 index 000000000..1f5b2b029 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixGeometry.hh @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXGEOMETRY_HH_ +#define GZ_RENDERING_OPTIX_OPTIXGEOMETRY_HH_ + +#include "gz/rendering/base/BaseGeometry.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixGeometry : + public BaseGeometry + { + protected: OptixGeometry(); + + public: virtual ~OptixGeometry(); + + public: virtual bool HasParent() const; + + public: virtual VisualPtr Parent() const; + + public: virtual optix::GeometryGroup OptixGeometryGroup() const = 0; + + protected: virtual void SetParent(OptixVisualPtr _parent); + + protected: virtual void SetScale(math::Vector3d _scale); + + protected: OptixVisualPtr parent; + + private: friend class OptixVisual; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixGrid.hh b/optix/include/gz/rendering/optix/OptixGrid.hh new file mode 100644 index 000000000..9adbaf707 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixGrid.hh @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXGRID_HH_ +#define GZ_RENDERING_OPTIX_OPTIXGRID_HH_ + +#include +#include +#include "gz/rendering/base/BaseGrid.hh" +#include "gz/rendering/optix/OptixPrimitive.hh" +#include "gz/rendering/optix/OptixObject.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// TODO Not implemented yet! + /// \brief Optix implementation of a grid geometry + class IGNITION_RENDERING_OPTIX_VISIBLE OptixGrid + : public BaseGrid + { + /// \brief Constructor + protected: OptixGrid(); + + /// \brief Destructor + public: virtual ~OptixGrid(); + + // Documentation inherited. + public: virtual void PreRender(); + + /// \brief Grids can only be created by scene + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixIncludes.hh b/optix/include/gz/rendering/optix/OptixIncludes.hh new file mode 100644 index 000000000..001c7d1ee --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixIncludes.hh @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXINCLUDES_HH_ +#define GZ_RENDERING_OPTIX_OPTIXINCLUDES_HH_ + +// #include +#include + +#endif diff --git a/optix/include/gz/rendering/optix/OptixLight.hh b/optix/include/gz/rendering/optix/OptixLight.hh new file mode 100644 index 000000000..cfc519a3d --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixLight.hh @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXLIGHT_HH_ +#define GZ_RENDERING_OPTIX_OPTIXLIGHT_HH_ + +#include "gz/rendering/base/BaseLight.hh" +#include "gz/rendering/optix/OptixNode.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixLightTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixLight : + public BaseLight + { + protected: OptixLight(); + + public: virtual ~OptixLight(); + + public: virtual gz::math::Color DiffuseColor() const; + + public: virtual void SetDiffuseColor( + const gz::math::Color &_color); + + public: virtual gz::math::Color SpecularColor() const; + + public: virtual void SetSpecularColor( + const gz::math::Color &_color); + + public: virtual double AttenuationConstant() const; + + public: virtual void SetAttenuationConstant(double _value); + + public: virtual double AttenuationLinear() const; + + public: virtual void SetAttenuationLinear(double _value); + + public: virtual double AttenuationQuadratic() const; + + public: virtual void SetAttenuationQuadratic(double _value); + + public: virtual double AttenuationRange() const; + + public: virtual void SetAttenuationRange(double _range); + + public: virtual bool CastShadows() const; + + public: virtual void SetCastShadows(bool _castShadows); + + protected: virtual void WritePoseToDeviceImpl(); + + protected: virtual OptixCommonLightData &CommonData() = 0; + + protected: virtual const OptixCommonLightData &CommonData() const = 0; + + protected: virtual void Init(); + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixDirectionalLight : + public BaseDirectionalLight + { + protected: OptixDirectionalLight(); + + public: virtual ~OptixDirectionalLight(); + + public: virtual gz::math::Vector3d Direction() const; + + public: virtual void SetDirection(const gz::math::Vector3d &_dir); + + public: virtual OptixDirectionalLightData Data() const; + + public: virtual void PreRender(); + + protected: virtual OptixCommonLightData &CommonData(); + + protected: virtual const OptixCommonLightData &CommonData() const; + + protected: OptixDirectionalLightData data; + + private: OptixDirectionalLightPtr SharedThis(); + + private: friend class OptixScene; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixPointLight : + public BasePointLight + { + protected: OptixPointLight(); + + public: virtual ~OptixPointLight(); + + public: virtual OptixPointLightData Data() const; + + public: virtual void PreRender(); + + protected: virtual OptixCommonLightData &CommonData(); + + protected: virtual const OptixCommonLightData &CommonData() const; + + protected: OptixPointLightData data; + + private: OptixPointLightPtr SharedThis(); + + private: friend class OptixScene; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixSpotLight : + public BaseSpotLight + { + protected: OptixSpotLight(); + + public: virtual ~OptixSpotLight(); + + public: virtual gz::math::Vector3d Direction() const; + + public: virtual void SetDirection(const gz::math::Vector3d &_dir); + + public: virtual gz::math::Angle InnerAngle() const; + + public: virtual void SetInnerAngle(const gz::math::Angle &_angle); + + public: virtual gz::math::Angle OuterAngle() const; + + public: virtual void SetOuterAngle(const gz::math::Angle &_angle); + + public: virtual double Falloff() const; + + public: virtual void SetFalloff(double _falloff); + + public: virtual OptixSpotLightData Data() const; + + public: virtual void PreRender(); + + protected: virtual OptixCommonLightData &CommonData(); + + protected: virtual const OptixCommonLightData &CommonData() const; + + protected: OptixSpotLightData data; + + private: OptixSpotLightPtr SharedThis(); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixLightManager.hh b/optix/include/gz/rendering/optix/OptixLightManager.hh new file mode 100644 index 000000000..36d321695 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixLightManager.hh @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXLIGHTMANAGER_HH_ +#define GZ_RENDERING_OPTIX_OPTIXLIGHTMANAGER_HH_ + +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/optix/OptixLightTypes.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixLightManager + { + public: explicit OptixLightManager(OptixScenePtr _scene); + + public: virtual ~OptixLightManager(); + + public: virtual void AddDirectionalLight(OptixDirectionalLightPtr _light); + + public: virtual void AddPointLight(OptixPointLightPtr _light); + + public: virtual void AddSpotLight(OptixSpotLightPtr _light); + + public: virtual void PreRender(); + + public: virtual void Clear(); + + protected: virtual void WriteDirectionalBuffer(); + + protected: virtual void WritePointBuffer(); + + protected: virtual void WriteSpotBuffer(); + + protected: template + void WriteBuffer(optix::Buffer _buffer, + const std::vector &_data); + + private: void CreateBuffers(); + + private: template + optix::Buffer CreateBuffer(const std::string &_name); + + protected: OptixScenePtr scene; + + protected: std::vector directionalData; + + protected: std::vector pointData; + + protected: std::vector spotData; + + protected: optix::Buffer directionalBuffer; + + protected: optix::Buffer pointBuffer; + + protected: optix::Buffer spotBuffer; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixLightTypes.hh b/optix/include/gz/rendering/optix/OptixLightTypes.hh new file mode 100644 index 000000000..bfbe04593 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixLightTypes.hh @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXLIGHTTYPES_HH_ +#define GZ_RENDERING_OPTIX_OPTIXLIGHTTYPES_HH_ + +#include + +#ifndef __CUDA_ARCH__ +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // +#endif + + typedef enum OptixLightType_t + { + LT_DIRECTIONAL = 0, + LT_POINT = 1, + LT_SPOT = 2, + LT_COUNT = 3, + } OptixLightType; + + struct OptixLightColor + { + float4 diffuse; + float4 specular; + }; + + struct OptixLightAttenuation + { + // cppcheck-suppress unusedStructMember + float range; + // cppcheck-suppress unusedStructMember + float constant; + // cppcheck-suppress unusedStructMember + float linear; + // cppcheck-suppress unusedStructMember + float quadratic; + }; + + struct OptixLightSpot + { + // cppcheck-suppress unusedStructMember + float innerAngle; + // cppcheck-suppress unusedStructMember + float outerAngle; + // cppcheck-suppress unusedStructMember + float falloff; + }; + + struct OptixCommonLightData + { + float3 position; + OptixLightColor color; + OptixLightAttenuation atten; + // cppcheck-suppress unusedStructMember + bool castShadows; + }; + + struct OptixDirectionalLightData + { + OptixCommonLightData common; + float3 direction; + }; + + struct OptixPointLightData + { + OptixCommonLightData common; + }; + + struct OptixSpotLightData + { + OptixCommonLightData common; + float3 direction; + OptixLightSpot spot; + }; + +#ifndef __CUDA_ARCH__ + } + } +} +#endif + +#endif diff --git a/optix/include/gz/rendering/optix/OptixMaterial.hh b/optix/include/gz/rendering/optix/OptixMaterial.hh new file mode 100644 index 000000000..1caa50378 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixMaterial.hh @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXMATERIAL_HH_ +#define GZ_RENDERING_OPTIX_OPTIXMATERIAL_HH_ + +#include +#include "gz/rendering/base/BaseMaterial.hh" +#include "gz/rendering/optix/OptixObject.hh" +#include "gz/rendering/optix/OptixIncludes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixMaterial : + public BaseMaterial + { + protected: OptixMaterial(); + + public: virtual ~OptixMaterial(); + + public: virtual bool LightingEnabled() const; + + public: virtual void SetLightingEnabled(const bool _enabled); + + public: virtual math::Color Ambient() const; + + public: virtual void SetAmbient(const math::Color &_color); + + public: virtual math::Color Diffuse() const; + + public: virtual void SetDiffuse(const math::Color &_color); + + public: virtual math::Color Specular() const; + + public: virtual void SetSpecular(const math::Color &_color); + + public: virtual math::Color Emissive() const; + + public: virtual void SetEmissive(const math::Color &_color); + + public: virtual double Shininess() const; + + public: virtual void SetShininess(const double _shininess); + + public: virtual double Transparency() const; + + public: virtual void SetTransparency(const double _transparency); + + public: virtual double Reflectivity() const; + + public: virtual void SetReflectivity(const double _reflectivity); + + public: virtual bool CastShadows() const; + + public: virtual void SetCastShadows(const bool _castShadows); + + public: virtual bool ReceiveShadows() const; + + public: virtual void SetReceiveShadows(const bool _receiveShadows); + + public: virtual bool ReflectionEnabled() const; + + public: virtual void SetReflectionEnabled(const bool _enabled); + + public: virtual bool HasTexture() const; + + public: virtual std::string Texture() const; + + public: virtual void SetTexture(const std::string &_texture); + + public: virtual void ClearTexture(); + + public: virtual bool HasNormalMap() const; + + public: virtual std::string NormalMap() const; + + public: virtual void SetNormalMap(const std::string &_normalMap); + + public: virtual void ClearNormalMap(); + + public: virtual void PreRender(); + + public: virtual void Destroy(); + + public: virtual optix::Material Material() const; + + protected: virtual void WriteColorToDevice(); + + protected: virtual void WriteTextureToDevice(); + + protected: virtual void WriteNormalMapToDevice(); + + protected: virtual void WriteColorToDeviceImpl(); + + protected: virtual void WriteTextureToDeviceImpl(); + + protected: virtual void WriteNormalMapToDeviceImpl(); + + protected: virtual void Init(); + + protected: bool colorDirty = true; + + protected: bool textureDirty = true; + + protected: bool normalMapDirty = true; + + protected: std::string textureName; + + protected: std::string normalMapName; + + protected: enum ShaderType shaderType; + + protected: optix::Material optixMaterial; + + protected: optix::TextureSampler optixTexture; + + protected: optix::TextureSampler optixNormalMap; + + protected: optix::TextureSampler optixEmptyTexture; + + private: static const std::string PTX_FILE_BASE; + + private: static const std::string PTX_CLOSEST_HIT_FUNC; + + private: static const std::string PTX_ANY_HIT_FUNC; + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixMesh.hh b/optix/include/gz/rendering/optix/OptixMesh.hh new file mode 100644 index 000000000..a9c777029 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixMesh.hh @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXMESH_HH_ +#define GZ_RENDERING_OPTIX_OPTIXMESH_HH_ + +#include +#include +#include "gz/rendering/base/BaseMesh.hh" +#include "gz/rendering/optix/OptixGeometry.hh" +#include "gz/rendering/optix/OptixObject.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixMesh : + public BaseMesh + { + typedef std::vector NameList; + + protected: OptixMesh(); + + public: virtual ~OptixMesh(); + + public: virtual optix::GeometryGroup OptixGeometryGroup() const; + + public: virtual optix::Acceleration OptixAccel() const; + + protected: virtual SubMeshStorePtr SubMeshes() const; + + protected: OptixSubMeshStorePtr subMeshes; + + protected: optix::GeometryGroup optixGeomGroup; + + protected: optix::Acceleration optixAccel; + + private: friend class OptixScene; + + private: friend class OptixMeshFactory; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixSubMesh : + public BaseSubMesh + { + protected: OptixSubMesh(); + + public: virtual ~OptixSubMesh(); + + public: virtual optix::GeometryInstance OptixGeometryInstance() const; + + protected: virtual void SetMaterialImpl(MaterialPtr _material) override; + + protected: optix::GeometryInstance optixGeomInstance; + + protected: optix::Geometry optixGeometry; + + protected: optix::Buffer optixVertexBuffer; + + protected: optix::Buffer optixNormalBuffer; + + protected: optix::Buffer optixTexCoordBuffer; + + protected: optix::Buffer optixIndexBuffer; + + private: friend class OptixScene; + + private: friend class OptixSubMeshStoreFactory; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixMeshFactory.hh b/optix/include/gz/rendering/optix/OptixMeshFactory.hh new file mode 100644 index 000000000..fc0681a1a --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixMeshFactory.hh @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXMESHFACTORY_HH_ +#define GZ_RENDERING_OPTIX_OPTIXMESHFACTORY_HH_ + +#include +#include +#include + +#include "gz/rendering/MeshDescriptor.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixMesh.hh" +#include "gz/rendering/optix/OptixIncludes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixSubMeshStoreFactory + { + // cppcheck-suppress noExplicitConstructor + public: OptixSubMeshStoreFactory(OptixScenePtr _scene); + + public: virtual ~OptixSubMeshStoreFactory(); + + public: virtual OptixSubMeshStorePtr Create(const MeshDescriptor &_desc); + + protected: virtual optix::Geometry Geometry( + const MeshDescriptor &_desc, unsigned int _subMeshIndex); + + protected: virtual std::string KeyName(const MeshDescriptor &_desc, + unsigned int _subMeshIndex); + + protected: std::map geometries; + + protected: OptixScenePtr scene; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixMeshFactory + { + // cppcheck-suppress noExplicitConstructor + public: OptixMeshFactory(OptixScenePtr _scene); + + public: virtual ~OptixMeshFactory(); + + public: virtual OptixMeshPtr Create(const MeshDescriptor &_desc); + + protected: virtual OptixMeshPtr Create(OptixSubMeshStorePtr _subMeshes); + + protected: OptixSubMeshStoreFactory subMeshStoreFactory; + + protected: OptixScenePtr scene; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixMeshGeometryFactory + { + public: OptixMeshGeometryFactory(OptixScenePtr _scene, + const common::SubMesh &_subMesh); + + public: virtual ~OptixMeshGeometryFactory(); + + public: virtual optix::Geometry Create(); + + protected: virtual void CreateGeometry(); + + protected: virtual optix::Buffer CreateVertexBuffer(); + + protected: virtual optix::Buffer CreateNormalBuffer(); + + protected: virtual optix::Buffer CreateTexCoordBuffer(); + + protected: virtual optix::Buffer CreateIndexBuffer(); + + protected: OptixScenePtr scene; + + protected: const common::SubMesh &subMesh; + + protected: optix::Geometry optixGeometry; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixNode.hh b/optix/include/gz/rendering/optix/OptixNode.hh new file mode 100644 index 000000000..5deb803e9 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixNode.hh @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXNODE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXNODE_HH_ + +#include "gz/rendering/base/BaseNode.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixNode : + public BaseNode + { + protected: OptixNode(); + + public: virtual ~OptixNode(); + + public: virtual bool HasParent() const override; + + public: virtual NodePtr Parent() const override; + + public: virtual void PreRender() override; + + public: virtual optix::Transform OptixTransform() const; + + // Documentation inherited. + public: virtual math::Vector3d LocalScale() const override; + + // Documentation inherited. + public: virtual bool InheritScale() const override; + + // Documentation inherited. + public: virtual void SetInheritScale(bool _inherit) override; + + // Documentation inherited. + protected: virtual void SetLocalScaleImpl( + const math::Vector3d &_scale) override; + + protected: virtual math::Pose3d RawLocalPose() const override; + + protected: virtual void SetRawLocalPose(const math::Pose3d &_pose) + override; + + protected: virtual void WritePoseToDevice(); + + protected: virtual void WritePoseToDeviceImpl(); + + protected: virtual void SetParent(OptixNodePtr _parent); + + protected: virtual void Init() override; + + protected: virtual NodeStorePtr Children() const override; + + protected: virtual bool AttachChild(NodePtr _child) override; + + protected: virtual bool DetachChild(NodePtr _child) override; + + protected: OptixNodePtr parent; + + protected: optix::Transform optixTransform; + + protected: optix::Group optixGroup; + + protected: optix::Acceleration optixAccel; + + protected: math::Pose3d pose; + + protected: bool poseDirty; + + protected: OptixNodeStorePtr children; + + protected: math::Vector3d scale = math::Vector3d::One; + + protected: bool inheritScale = true; + + private: OptixNodePtr SharedThis(); + + // TODO remove the need for a visual friend class + private: friend class OptixVisual; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixObject.hh b/optix/include/gz/rendering/optix/OptixObject.hh new file mode 100644 index 000000000..6ff746085 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixObject.hh @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXOBJECT_HH_ +#define GZ_RENDERING_OPTIX_OPTIXOBJECT_HH_ + +#include "gz/rendering/base/BaseObject.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixObject : + public BaseObject + { + protected: OptixObject(); + + public: virtual ~OptixObject(); + + public: virtual ScenePtr Scene() const; + + protected: OptixScenePtr scene; + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixPrimitive.hh b/optix/include/gz/rendering/optix/OptixPrimitive.hh new file mode 100644 index 000000000..649690aa2 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixPrimitive.hh @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXPRIMITIVE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXPRIMITIVE_HH_ + +#include +#include "gz/rendering/optix/OptixGeometry.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixPrimitive : + public OptixGeometry + { + protected: OptixPrimitive(); + + public: virtual ~OptixPrimitive(); + + public: virtual MaterialPtr Material() const; + + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true); + + public: virtual optix::GeometryGroup OptixGeometryGroup() const; + + public: virtual optix::Acceleration OptixAccel() const; + + public: virtual optix::GeometryInstance OptixGeometryInstance() const; + + public: virtual optix::Geometry OptixGeometry() const; + + public: virtual void PreRender(); + + protected: virtual void SetMaterialImpl(OptixMaterialPtr _material); + + protected: virtual void Init(); + + protected: static optix::Geometry CreateOptixGeometry( + OptixScenePtr _scene, const std::string &_ptxFile); + + protected: MaterialPtr material; + + protected: optix::GeometryGroup optixGeomGroup; + + protected: optix::Acceleration optixAccel; + + protected: optix::GeometryInstance optixGeomInstance; + + protected: optix::Geometry optixGeometry; + + protected: static const std::string PTX_INTERSECT_FUNC; + + protected: static const std::string PTX_BOUNDS_FUNC; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixRayTypes.hh b/optix/include/gz/rendering/optix/OptixRayTypes.hh new file mode 100644 index 000000000..b46c1ccf6 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixRayTypes.hh @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXRAYTYPES_HH_ +#define GZ_RENDERING_OPTIX_OPTIXRAYTYPES_HH_ + +#include + +#ifndef __CUDA_ARCH__ +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // +#endif + + typedef enum OptixRayType_t + { + RT_RADIANCE = 0, + RT_SHADOW = 1, + RT_COUNT = 2, + } OptixRayType; + + struct OptixRadianceRayData + { + float3 color; + // cppcheck-suppress unusedStructMember + float importance; + // cppcheck-suppress unusedStructMember + int depth; + }; + + struct OptixShadowRayData + { + float3 attenuation; + }; + +#ifndef __CUDA_ARCH__ + } + } +} +#endif + +#endif diff --git a/optix/include/gz/rendering/optix/OptixRenderEngine.hh b/optix/include/gz/rendering/optix/OptixRenderEngine.hh new file mode 100644 index 000000000..05635a883 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixRenderEngine.hh @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXRENDERENGINE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXRENDERENGINE_HH_ + +#include +#include +#include + +#include "gz/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/base/BaseRenderEngine.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Plugin for loading optix render engine + class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderEnginePlugin : + public RenderEnginePlugin + { + /// \brief Constructor + public: OptixRenderEnginePlugin(); + + /// \brief Destructor + public: ~OptixRenderEnginePlugin() = default; + + /// \brief Get the name of the render engine loaded by this plugin. + /// \return Name of render engine + public: std::string Name() const; + + /// \brief Get a pointer to the render engine loaded by this plugin. + /// \return Render engine instance + public: RenderEngine *Engine() const; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderEngine : + public virtual BaseRenderEngine, + public common::SingletonT + { + /// \brief Constructor + private: OptixRenderEngine(); + + public: virtual ~OptixRenderEngine(); + + public: virtual bool Fini(); + + public: virtual std::string Name() const; + + public: std::string PtxFile(const std::string& _fileBase) const; + + protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, + const std::string &_name); + + protected: virtual SceneStorePtr Scenes() const; + + // Documentation Inherited + protected: virtual bool LoadImpl( + const std::map &_params) override; + + protected: virtual bool InitImpl(); + + private: OptixSceneStorePtr scenes; + + private: static const std::string PTX_PREFIX; + + private: static const std::string PTX_SUFFIX; + + private: friend class SingletonT; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixRenderTarget.hh b/optix/include/gz/rendering/optix/OptixRenderTarget.hh new file mode 100644 index 000000000..5beffe443 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixRenderTarget.hh @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXRENDERTARGET_HH_ +#define GZ_RENDERING_OPTIX_OPTIXRENDERTARGET_HH_ + +#include "gz/rendering/base/BaseRenderTarget.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderTarget : + public virtual BaseRenderTarget + { + protected: OptixRenderTarget(); + + public: virtual ~OptixRenderTarget(); + + public: virtual void Copy(Image &_image) const; + + public: virtual optix::Buffer OptixBuffer() const = 0; + + protected: unsigned int MemorySize() const; + + protected: float *hostData; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderTexture : + public virtual BaseRenderTexture + { + protected: OptixRenderTexture(); + + public: virtual ~OptixRenderTexture(); + + public: virtual void Destroy(); + + public: virtual optix::Buffer OptixBuffer() const; + + protected: virtual void RebuildImpl(); + + protected: optix::Buffer optixBuffer; + + protected: virtual void Init(); + + private: friend class OptixScene; + }; + + /// \brief Render window mocked using a render texture. + class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderWindow : + public virtual BaseRenderWindow + { + /// \brief Constructor + protected: OptixRenderWindow(); + + /// \brief Destructor + public: virtual ~OptixRenderWindow(); + + /// \brief Render windows should only be created by the scene class + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixRenderTypes.hh b/optix/include/gz/rendering/optix/OptixRenderTypes.hh new file mode 100644 index 000000000..12202c74f --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixRenderTypes.hh @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXRENDERTYPES_HH_ +#define GZ_RENDERING_OPTIX_OPTIXRENDERTYPES_HH_ + +#include "gz/rendering/base/BaseRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class OptixArrowVisual; + class OptixAxisVisual; + class OptixBox; + class OptixCamera; + class OptixCone; + class OptixCylinder; + class OptixDirectionalLight; + class OptixGeometry; + class OptixGrid; + class OptixJointVisual; + class OptixLight; + class OptixMaterial; + class OptixMesh; + class OptixMeshFactory; + class OptixNode; + class OptixObject; + class OptixObjectFactory; + class OptixPointLight; + class OptixRenderEngine; + class OptixScene; + class OptixSensor; + class OptixSphere; + class OptixSpotLight; + class OptixSubMesh; + class OptixVisual; + class OptixRenderTarget; + class OptixRenderTexture; + class OptixRenderWindow; + class OptixLightManager; + + typedef BaseSceneStore OptixSceneStore; + typedef BaseNodeStore OptixNodeStore; + typedef BaseLightStore OptixLightStore; + typedef BaseSensorStore OptixSensorStore; + typedef BaseVisualStore OptixVisualStore; + typedef BaseGeometryStore OptixGeometryStore; + typedef BaseSubMeshStore OptixSubMeshStore; + typedef BaseMaterialMap OptixMaterialMap; + + typedef shared_ptr OptixArrowVisualPtr; + typedef shared_ptr OptixAxisVisualPtr; + typedef shared_ptr OptixBoxPtr; + typedef shared_ptr OptixCameraPtr; + typedef shared_ptr OptixConePtr; + typedef shared_ptr OptixCylinderPtr; + typedef shared_ptr OptixDirectionalLightPtr; + typedef shared_ptr OptixGeometryPtr; + typedef shared_ptr OptixGridPtr; + typedef shared_ptr OptixJointVisualPtr; + typedef shared_ptr OptixLightPtr; + typedef shared_ptr OptixMaterialPtr; + typedef shared_ptr OptixMeshPtr; + typedef shared_ptr OptixMeshFactoryPtr; + typedef shared_ptr OptixNodePtr; + typedef shared_ptr OptixObjectPtr; + typedef shared_ptr OptixObjectFactoryPtr; + typedef shared_ptr OptixPointLightPtr; + typedef shared_ptr OptixScenePtr; + typedef shared_ptr OptixSensorPtr; + typedef shared_ptr OptixSpherePtr; + typedef shared_ptr OptixSpotLightPtr; + typedef shared_ptr OptixSubMeshPtr; + typedef shared_ptr OptixVisualPtr; + typedef shared_ptr OptixSceneStorePtr; + typedef shared_ptr OptixNodeStorePtr; + typedef shared_ptr OptixLightStorePtr; + typedef shared_ptr OptixSensorStorePtr; + typedef shared_ptr OptixVisualStorePtr; + typedef shared_ptr OptixGeometryStorePtr; + typedef shared_ptr OptixSubMeshStorePtr; + typedef shared_ptr OptixMaterialMapPtr; + typedef shared_ptr OptixRenderTargetPtr; + typedef shared_ptr OptixRenderTexturePtr; + typedef shared_ptr OptixRenderWindowPtr; + typedef shared_ptr OptixLightManagerPtr; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixScene.hh b/optix/include/gz/rendering/optix/OptixScene.hh new file mode 100644 index 000000000..6f94fcff4 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixScene.hh @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXSCENE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXSCENE_HH_ + +#include + +#include "gz/rendering/base/BaseScene.hh" + +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixScene : + public BaseScene + { + protected: OptixScene(unsigned int _id, const std::string &_name); + + public: virtual ~OptixScene(); + + public: virtual void Fini(); + + public: virtual RenderEngine *Engine() const; + + public: virtual VisualPtr RootVisual() const; + + public: virtual math::Color AmbientLight() const; + + public: virtual void SetAmbientLight(const math::Color &_color); + + public: virtual void SetBackgroundColor(const math::Color &_color); + + // Documentation inherited. + public: virtual void SetGradientBackgroundColor( + const std::array &_colors); + + // Documentation inherited. + public: virtual void RemoveGradientBackgroundColor(); + + public: virtual void PreRender(); + + public: virtual void Clear(); + + public: virtual void Destroy(); + + public: virtual OptixLightManagerPtr LightManager() const; + + public: virtual optix::Context OptixContext() const; + + public: virtual optix::Program CreateOptixProgram( + const std::string &_fileBase, const std::string &_function); + + protected: virtual bool LoadImpl(); + + protected: virtual bool InitImpl(); + + protected: virtual DirectionalLightPtr CreateDirectionalLightImpl( + unsigned int _id, const std::string &_name); + + protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id, + const std::string &_name); + + protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id, + const std::string &_name); + + protected: virtual CameraPtr CreateCameraImpl(unsigned int _id, + const std::string &_name); + + // Documentation inherited + protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual VisualPtr CreateVisualImpl(unsigned int _id, + const std::string &_name); + + protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id, + const std::string &_name); + + protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id, + const std::string &_name); + + protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id, + const std::string &_name); + + protected: virtual GeometryPtr CreateConeImpl(unsigned int _id, + const std::string &_name); + + protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id, + const std::string &_name); + + protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id, + const std::string &_name); + + protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id, + const std::string &_name); + + protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, + const std::string &_name, const std::string &_meshName); + + protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, + const std::string &_name, const MeshDescriptor &_desc); + + // Documentation inherited. + protected: virtual GridPtr CreateGridImpl(unsigned int _id, + const std::string &_name); + + protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id, + const std::string &_name); + + protected: virtual RenderTexturePtr CreateRenderTextureImpl( + unsigned int _id, const std::string &_name); + + // Documentation inherited. + protected: virtual RenderWindowPtr CreateRenderWindowImpl( + unsigned int _id, const std::string &_name); + + protected: virtual RayQueryPtr CreateRayQueryImpl( + unsigned int _id, const std::string &_name); + + protected: virtual bool InitObject(OptixObjectPtr _object, + unsigned int _id, const std::string &_name); + + protected: virtual LightStorePtr Lights() const; + + protected: virtual SensorStorePtr Sensors() const; + + protected: virtual VisualStorePtr Visuals() const; + + protected: virtual MaterialMapPtr Materials() const; + + protected: virtual unsigned int NextEntryId(); + + private: void CreateContext(); + + private: void CreateRootVisual(); + + private: void CreateLightManager(); + + private: void CreateMeshFactory(); + + private: void CreateStores(); + + private: OptixScenePtr SharedThis(); + + protected: OptixVisualPtr rootVisual; + + protected: OptixLightManagerPtr lightManager; + + protected: OptixMeshFactoryPtr meshFactory; + + protected: OptixLightStorePtr lights; + + protected: OptixSensorStorePtr sensors; + + protected: OptixVisualStorePtr visuals; + + protected: OptixMaterialMapPtr materials; + + protected: optix::Context optixContext; + + protected: optix::Group optixRootGroup; + + protected: optix::Acceleration optixRootAccel; + + protected: optix::Program optixMissProgram; + + protected: optix::Geometry optixBoxGeometry; + + protected: optix::Geometry optixConeGeometry; + + protected: optix::Geometry optixCylinderGeometry; + + protected: optix::Geometry optixSphereGeometry; + + protected: math::Color ambientLight; + + private: friend class OptixRenderEngine; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixSensor.hh b/optix/include/gz/rendering/optix/OptixSensor.hh new file mode 100644 index 000000000..7d3f2dc0f --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixSensor.hh @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXSENSOR_HH_ +#define GZ_RENDERING_OPTIX_OPTIXSENSOR_HH_ + +#include "gz/rendering/base/BaseSensor.hh" +#include "gz/rendering/optix/OptixNode.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixSensor : + public BaseSensor + { + protected: OptixSensor(); + + public: virtual ~OptixSensor(); + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixSphere.hh b/optix/include/gz/rendering/optix/OptixSphere.hh new file mode 100644 index 000000000..9b3092413 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixSphere.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXSPHERE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXSPHERE_HH_ + +#include "gz/rendering/optix/OptixPrimitive.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixSphere : + public OptixPrimitive + { + protected: OptixSphere(); + + public: virtual ~OptixSphere(); + + public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixStorage.hh b/optix/include/gz/rendering/optix/OptixStorage.hh new file mode 100644 index 000000000..0e4fddd21 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixStorage.hh @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXSTORAGE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXSTORAGE_HH_ + +#include "gz/rendering/base/BaseStorage.hh" + +#include "gz/rendering/optix/OptixGeometry.hh" +#include "gz/rendering/optix/OptixLight.hh" +#include "gz/rendering/optix/OptixMaterial.hh" +#include "gz/rendering/optix/OptixMesh.hh" +#include "gz/rendering/optix/OptixNode.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixSensor.hh" +#include "gz/rendering/optix/OptixVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template class BaseSceneStore; + template class BaseNodeStore; + template class BaseLightStore; + template class BaseSensorStore; + template class BaseVisualStore; + template class BaseGeometryStore; + template class BaseSubMeshStore; + template class BaseMaterialMap; + + typedef BaseSceneStore OptixSceneStore; + typedef BaseNodeStore OptixNodeStore; + typedef BaseLightStore OptixLightStore; + typedef BaseSensorStore OptixSensorStore; + typedef BaseVisualStore OptixVisualStore; + typedef BaseGeometryStore OptixGeometryStore; + typedef BaseSubMeshStore OptixSubMeshStore; + typedef BaseMaterialMap OptixMaterialMap; + + typedef std::shared_ptr OptixSceneStorePtr; + typedef std::shared_ptr OptixNodeStorePtr; + typedef std::shared_ptr OptixLightStorePtr; + typedef std::shared_ptr OptixSensorStorePtr; + typedef std::shared_ptr OptixVisualStorePtr; + typedef std::shared_ptr OptixGeometryStorePtr; + typedef std::shared_ptr OptixSubMeshStorePtr; + typedef std::shared_ptr OptixMaterialMapPtr; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixTextureFactory.hh b/optix/include/gz/rendering/optix/OptixTextureFactory.hh new file mode 100644 index 000000000..62b1f3b47 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixTextureFactory.hh @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXTEXTUREFACTORY_HH_ +#define GZ_RENDERING_OPTIX_OPTIXTEXTUREFACTORY_HH_ + +#include +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixTextureFactory + { + public: explicit OptixTextureFactory(OptixScenePtr _scene); + + public: virtual ~OptixTextureFactory(); + + public: optix::TextureSampler Create(const std::string &_filename); + + public: optix::TextureSampler Create(); + + protected: optix::Buffer CreateBuffer(const std::string &_filename); + + protected: optix::Buffer CreateBuffer(); + + protected: optix::TextureSampler CreateSampler(optix::Buffer _buffer); + + protected: OptixScenePtr scene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixVisual.hh b/optix/include/gz/rendering/optix/OptixVisual.hh new file mode 100644 index 000000000..990427f22 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixVisual.hh @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXVISUAL_HH_ +#define GZ_RENDERING_OPTIX_OPTIXVISUAL_HH_ + +#include "gz/rendering/base/BaseVisual.hh" +#include "gz/rendering/optix/OptixNode.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixVisual : + public BaseVisual + { + protected: OptixVisual(); + + public: virtual ~OptixVisual(); + + public: virtual optix::Group OptixGroup() const; + + public: virtual optix::Acceleration OptixAccel() const; + + public: virtual void PreRender(); + + protected: virtual GeometryStorePtr Geometries() const; + + protected: virtual bool AttachGeometry(GeometryPtr _geometry); + + protected: virtual bool DetachGeometry(GeometryPtr _geometry); + + protected: virtual void Init(); + + private: void CreateStorage(); + + private: OptixVisualPtr SharedThis(); + + protected: OptixGeometryStorePtr geometries; + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/optix.hh.in b/optix/include/gz/rendering/optix/optix.hh.in new file mode 100644 index 000000000..c4092f0cd --- /dev/null +++ b/optix/include/gz/rendering/optix/optix.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/optix/include/ignition/rendering/optix.hh b/optix/include/ignition/rendering/optix.hh new file mode 100644 index 000000000..130fc6f6d --- /dev/null +++ b/optix/include/ignition/rendering/optix.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixArrowVisual.hh b/optix/include/ignition/rendering/optix/OptixArrowVisual.hh index e3e6d19d3..933329946 100644 --- a/optix/include/ignition/rendering/optix/OptixArrowVisual.hh +++ b/optix/include/ignition/rendering/optix/OptixArrowVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXARROWVISUAL_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXARROWVISUAL_HH_ -#include "ignition/rendering/base/BaseArrowVisual.hh" -#include "ignition/rendering/optix/OptixVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixArrowVisual : - public BaseArrowVisual - { - protected: OptixArrowVisual(); - - public: virtual ~OptixArrowVisual(); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixAxisVisual.hh b/optix/include/ignition/rendering/optix/OptixAxisVisual.hh index a4b47bca2..88ba6d763 100644 --- a/optix/include/ignition/rendering/optix/OptixAxisVisual.hh +++ b/optix/include/ignition/rendering/optix/OptixAxisVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXAXISVISUAL_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXAXISVISUAL_HH_ -#include "ignition/rendering/base/BaseAxisVisual.hh" -#include "ignition/rendering/optix/OptixVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixAxisVisual : - public BaseAxisVisual - { - protected: OptixAxisVisual(); - - public: virtual ~OptixAxisVisual(); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixBox.hh b/optix/include/ignition/rendering/optix/OptixBox.hh index 6073bdf97..b43db3020 100644 --- a/optix/include/ignition/rendering/optix/OptixBox.hh +++ b/optix/include/ignition/rendering/optix/OptixBox.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXBOX_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXBOX_HH_ -#include "ignition/rendering/optix/OptixPrimitive.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixBox : - public OptixPrimitive - { - protected: OptixBox(); - - public: virtual ~OptixBox(); - - public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixCamera.hh b/optix/include/ignition/rendering/optix/OptixCamera.hh index 5a02e6c12..5659c12e5 100644 --- a/optix/include/ignition/rendering/optix/OptixCamera.hh +++ b/optix/include/ignition/rendering/optix/OptixCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,81 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXCAMERA_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXCAMERA_HH_ -#include -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixSensor.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixCamera : - public BaseCamera - { - protected: OptixCamera(); - - public: virtual ~OptixCamera(); - - public: virtual void SetHFOV(const math::Angle &_hfov); - - public: virtual void SetAspectRatio(const double _ratio); - - public: virtual void SetAntiAliasing(const unsigned int _aa); - - public: virtual void PreRender(); - - public: virtual void Render(); - - protected: virtual RenderTargetPtr RenderTarget() const; - - protected: virtual void WriteCameraToDevice(); - - protected: virtual void WriteCameraToDeviceImpl(); - - protected: virtual void WritePoseToDeviceImpl(); - - protected: virtual void Init(); - - protected: virtual void CreateRenderTexture(); - - // Documentation inherited. - protected: virtual RenderWindowPtr CreateRenderWindow(); - - protected: virtual void CreateRenderProgram(); - - protected: virtual void CreateClearProgram(); - - protected: virtual void CreateErrorProgram(); - - protected: optix::Program optixRenderProgram; - - protected: optix::Program optixClearProgram; - - protected: optix::Program optixErrorProgram; - - protected: OptixRenderTexturePtr renderTexture; - - protected: bool cameraDirty; - - protected: unsigned int traceId; - - protected: unsigned int clearId; - - private: static const std::string PTX_BASE_NAME; - - private: static const std::string PTX_RENDER_FUNCTION; - - private: static const std::string PTX_CLEAR_FUNCTION; - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixCone.hh b/optix/include/ignition/rendering/optix/OptixCone.hh index 35a78afab..f2d0e9bf1 100644 --- a/optix/include/ignition/rendering/optix/OptixCone.hh +++ b/optix/include/ignition/rendering/optix/OptixCone.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXCONE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXCONE_HH_ -#include "ignition/rendering/optix/OptixPrimitive.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixCone : - public OptixPrimitive - { - protected: OptixCone(); - - public: virtual ~OptixCone(); - - public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixConversions.hh b/optix/include/ignition/rendering/optix/OptixConversions.hh index 646dbee82..cfc237f61 100644 --- a/optix/include/ignition/rendering/optix/OptixConversions.hh +++ b/optix/include/ignition/rendering/optix/OptixConversions.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,53 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXCONVERSIONS_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXCONVERSIONS_HH_ -#include -#include -#include - -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \addtogroup ign_rendering - /// \{ - - /// \brief Conversions Conversions.hh rendering/Conversions.hh - /// \brief A set of utility function to convert between Gazebo and Optix - /// data types - class IGNITION_RENDERING_OPTIX_VISIBLE OptixConversions - { - /// \brief Return the equivalent optix color - /// \param[in] _color Gazebo color to convert - /// \return Optix color value - public: static float4 ConvertColor(const math::Color &_color); - - /// \brief Return the equivalent ign-math color - /// \param[in] _color Optix color to convert - /// \return Gazebo color value - public: static math::Color ConvertColor(const float4 &_color); - - /// \brief return Optix Vector from Gazebo Vector3 - /// \param[in] _vector Gazebo vector - /// \return Optix vector - public: static float3 ConvertVector(const math::Vector3d &_vector); - - /// \brief return ign-math Vector from optix Vector3 - /// \param[in] _vector Optix vector - /// \return Gazebo vector - public: static math::Vector3d ConvertVector(const float3 &_vector); - }; - /// \} - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixCylinder.hh b/optix/include/ignition/rendering/optix/OptixCylinder.hh index f04d6591d..c34683269 100644 --- a/optix/include/ignition/rendering/optix/OptixCylinder.hh +++ b/optix/include/ignition/rendering/optix/OptixCylinder.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXCYLINDER_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXCYLINDER_HH_ -#include "ignition/rendering/optix/OptixPrimitive.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixCylinder : - public OptixPrimitive - { - protected: OptixCylinder(); - - public: virtual ~OptixCylinder(); - - public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixGeometry.hh b/optix/include/ignition/rendering/optix/OptixGeometry.hh index 579a1c6c5..0757681dd 100644 --- a/optix/include/ignition/rendering/optix/OptixGeometry.hh +++ b/optix/include/ignition/rendering/optix/OptixGeometry.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,41 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXGEOMETRY_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXGEOMETRY_HH_ -#include "ignition/rendering/base/BaseGeometry.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixGeometry : - public BaseGeometry - { - protected: OptixGeometry(); - - public: virtual ~OptixGeometry(); - - public: virtual bool HasParent() const; - - public: virtual VisualPtr Parent() const; - - public: virtual optix::GeometryGroup OptixGeometryGroup() const = 0; - - protected: virtual void SetParent(OptixVisualPtr _parent); - - protected: virtual void SetScale(math::Vector3d _scale); - - protected: OptixVisualPtr parent; - - private: friend class OptixVisual; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixGrid.hh b/optix/include/ignition/rendering/optix/OptixGrid.hh index ded3af240..4ff8ad710 100644 --- a/optix/include/ignition/rendering/optix/OptixGrid.hh +++ b/optix/include/ignition/rendering/optix/OptixGrid.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,40 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXGRID_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXGRID_HH_ -#include -#include -#include "ignition/rendering/base/BaseGrid.hh" -#include "ignition/rendering/optix/OptixPrimitive.hh" -#include "ignition/rendering/optix/OptixObject.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// TODO Not implemented yet! - /// \brief Optix implementation of a grid geometry - class IGNITION_RENDERING_OPTIX_VISIBLE OptixGrid - : public BaseGrid - { - /// \brief Constructor - protected: OptixGrid(); - - /// \brief Destructor - public: virtual ~OptixGrid(); - - // Documentation inherited. - public: virtual void PreRender(); - - /// \brief Grids can only be created by scene - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixIncludes.hh b/optix/include/ignition/rendering/optix/OptixIncludes.hh index 2966aa3ce..0d9bfc38f 100644 --- a/optix/include/ignition/rendering/optix/OptixIncludes.hh +++ b/optix/include/ignition/rendering/optix/OptixIncludes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,10 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXINCLUDES_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXINCLUDES_HH_ -// #include -#include - -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixLight.hh b/optix/include/ignition/rendering/optix/OptixLight.hh index 39fb91efa..f323a078a 100644 --- a/optix/include/ignition/rendering/optix/OptixLight.hh +++ b/optix/include/ignition/rendering/optix/OptixLight.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,152 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXLIGHT_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXLIGHT_HH_ -#include "ignition/rendering/base/BaseLight.hh" -#include "ignition/rendering/optix/OptixNode.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixLightTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixLight : - public BaseLight - { - protected: OptixLight(); - - public: virtual ~OptixLight(); - - public: virtual ignition::math::Color DiffuseColor() const; - - public: virtual void SetDiffuseColor( - const ignition::math::Color &_color); - - public: virtual ignition::math::Color SpecularColor() const; - - public: virtual void SetSpecularColor( - const ignition::math::Color &_color); - - public: virtual double AttenuationConstant() const; - - public: virtual void SetAttenuationConstant(double _value); - - public: virtual double AttenuationLinear() const; - - public: virtual void SetAttenuationLinear(double _value); - - public: virtual double AttenuationQuadratic() const; - - public: virtual void SetAttenuationQuadratic(double _value); - - public: virtual double AttenuationRange() const; - - public: virtual void SetAttenuationRange(double _range); - - public: virtual bool CastShadows() const; - - public: virtual void SetCastShadows(bool _castShadows); - - protected: virtual void WritePoseToDeviceImpl(); - - protected: virtual OptixCommonLightData &CommonData() = 0; - - protected: virtual const OptixCommonLightData &CommonData() const = 0; - - protected: virtual void Init(); - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixDirectionalLight : - public BaseDirectionalLight - { - protected: OptixDirectionalLight(); - - public: virtual ~OptixDirectionalLight(); - - public: virtual ignition::math::Vector3d Direction() const; - - public: virtual void SetDirection(const ignition::math::Vector3d &_dir); - - public: virtual OptixDirectionalLightData Data() const; - - public: virtual void PreRender(); - - protected: virtual OptixCommonLightData &CommonData(); - - protected: virtual const OptixCommonLightData &CommonData() const; - - protected: OptixDirectionalLightData data; - - private: OptixDirectionalLightPtr SharedThis(); - - private: friend class OptixScene; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixPointLight : - public BasePointLight - { - protected: OptixPointLight(); - - public: virtual ~OptixPointLight(); - - public: virtual OptixPointLightData Data() const; - - public: virtual void PreRender(); - - protected: virtual OptixCommonLightData &CommonData(); - - protected: virtual const OptixCommonLightData &CommonData() const; - - protected: OptixPointLightData data; - - private: OptixPointLightPtr SharedThis(); - - private: friend class OptixScene; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixSpotLight : - public BaseSpotLight - { - protected: OptixSpotLight(); - - public: virtual ~OptixSpotLight(); - - public: virtual ignition::math::Vector3d Direction() const; - - public: virtual void SetDirection(const ignition::math::Vector3d &_dir); - - public: virtual ignition::math::Angle InnerAngle() const; - - public: virtual void SetInnerAngle(const ignition::math::Angle &_angle); - - public: virtual ignition::math::Angle OuterAngle() const; - - public: virtual void SetOuterAngle(const ignition::math::Angle &_angle); - - public: virtual double Falloff() const; - - public: virtual void SetFalloff(double _falloff); - - public: virtual OptixSpotLightData Data() const; - - public: virtual void PreRender(); - - protected: virtual OptixCommonLightData &CommonData(); - - protected: virtual const OptixCommonLightData &CommonData() const; - - protected: OptixSpotLightData data; - - private: OptixSpotLightPtr SharedThis(); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixLightManager.hh b/optix/include/ignition/rendering/optix/OptixLightManager.hh index 312c66843..e0dc46dad 100644 --- a/optix/include/ignition/rendering/optix/OptixLightManager.hh +++ b/optix/include/ignition/rendering/optix/OptixLightManager.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,69 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXLIGHTMANAGER_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXLIGHTMANAGER_HH_ -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/optix/OptixLightTypes.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixLightManager - { - public: explicit OptixLightManager(OptixScenePtr _scene); - - public: virtual ~OptixLightManager(); - - public: virtual void AddDirectionalLight(OptixDirectionalLightPtr _light); - - public: virtual void AddPointLight(OptixPointLightPtr _light); - - public: virtual void AddSpotLight(OptixSpotLightPtr _light); - - public: virtual void PreRender(); - - public: virtual void Clear(); - - protected: virtual void WriteDirectionalBuffer(); - - protected: virtual void WritePointBuffer(); - - protected: virtual void WriteSpotBuffer(); - - protected: template - void WriteBuffer(optix::Buffer _buffer, - const std::vector &_data); - - private: void CreateBuffers(); - - private: template - optix::Buffer CreateBuffer(const std::string &_name); - - protected: OptixScenePtr scene; - - protected: std::vector directionalData; - - protected: std::vector pointData; - - protected: std::vector spotData; - - protected: optix::Buffer directionalBuffer; - - protected: optix::Buffer pointBuffer; - - protected: optix::Buffer spotBuffer; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixLightTypes.hh b/optix/include/ignition/rendering/optix/OptixLightTypes.hh index b150ad0f8..bb2b1dc2e 100644 --- a/optix/include/ignition/rendering/optix/OptixLightTypes.hh +++ b/optix/include/ignition/rendering/optix/OptixLightTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,87 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXLIGHTTYPES_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXLIGHTTYPES_HH_ -#include - -#ifndef __CUDA_ARCH__ -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // -#endif - - typedef enum OptixLightType_t - { - LT_DIRECTIONAL = 0, - LT_POINT = 1, - LT_SPOT = 2, - LT_COUNT = 3, - } OptixLightType; - - struct OptixLightColor - { - float4 diffuse; - float4 specular; - }; - - struct OptixLightAttenuation - { - // cppcheck-suppress unusedStructMember - float range; - // cppcheck-suppress unusedStructMember - float constant; - // cppcheck-suppress unusedStructMember - float linear; - // cppcheck-suppress unusedStructMember - float quadratic; - }; - - struct OptixLightSpot - { - // cppcheck-suppress unusedStructMember - float innerAngle; - // cppcheck-suppress unusedStructMember - float outerAngle; - // cppcheck-suppress unusedStructMember - float falloff; - }; - - struct OptixCommonLightData - { - float3 position; - OptixLightColor color; - OptixLightAttenuation atten; - // cppcheck-suppress unusedStructMember - bool castShadows; - }; - - struct OptixDirectionalLightData - { - OptixCommonLightData common; - float3 direction; - }; - - struct OptixPointLightData - { - OptixCommonLightData common; - }; - - struct OptixSpotLightData - { - OptixCommonLightData common; - float3 direction; - OptixLightSpot spot; - }; - -#ifndef __CUDA_ARCH__ - } - } -} -#endif - -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixMaterial.hh b/optix/include/ignition/rendering/optix/OptixMaterial.hh index 0c2605a2f..0a17cad23 100644 --- a/optix/include/ignition/rendering/optix/OptixMaterial.hh +++ b/optix/include/ignition/rendering/optix/OptixMaterial.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,136 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXMATERIAL_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXMATERIAL_HH_ -#include -#include "ignition/rendering/base/BaseMaterial.hh" -#include "ignition/rendering/optix/OptixObject.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixMaterial : - public BaseMaterial - { - protected: OptixMaterial(); - - public: virtual ~OptixMaterial(); - - public: virtual bool LightingEnabled() const; - - public: virtual void SetLightingEnabled(const bool _enabled); - - public: virtual math::Color Ambient() const; - - public: virtual void SetAmbient(const math::Color &_color); - - public: virtual math::Color Diffuse() const; - - public: virtual void SetDiffuse(const math::Color &_color); - - public: virtual math::Color Specular() const; - - public: virtual void SetSpecular(const math::Color &_color); - - public: virtual math::Color Emissive() const; - - public: virtual void SetEmissive(const math::Color &_color); - - public: virtual double Shininess() const; - - public: virtual void SetShininess(const double _shininess); - - public: virtual double Transparency() const; - - public: virtual void SetTransparency(const double _transparency); - - public: virtual double Reflectivity() const; - - public: virtual void SetReflectivity(const double _reflectivity); - - public: virtual bool CastShadows() const; - - public: virtual void SetCastShadows(const bool _castShadows); - - public: virtual bool ReceiveShadows() const; - - public: virtual void SetReceiveShadows(const bool _receiveShadows); - - public: virtual bool ReflectionEnabled() const; - - public: virtual void SetReflectionEnabled(const bool _enabled); - - public: virtual bool HasTexture() const; - - public: virtual std::string Texture() const; - - public: virtual void SetTexture(const std::string &_texture); - - public: virtual void ClearTexture(); - - public: virtual bool HasNormalMap() const; - - public: virtual std::string NormalMap() const; - - public: virtual void SetNormalMap(const std::string &_normalMap); - - public: virtual void ClearNormalMap(); - - public: virtual void PreRender(); - - public: virtual void Destroy(); - - public: virtual optix::Material Material() const; - - protected: virtual void WriteColorToDevice(); - - protected: virtual void WriteTextureToDevice(); - - protected: virtual void WriteNormalMapToDevice(); - - protected: virtual void WriteColorToDeviceImpl(); - - protected: virtual void WriteTextureToDeviceImpl(); - - protected: virtual void WriteNormalMapToDeviceImpl(); - - protected: virtual void Init(); - - protected: bool colorDirty = true; - - protected: bool textureDirty = true; - - protected: bool normalMapDirty = true; - - protected: std::string textureName; - - protected: std::string normalMapName; - - protected: enum ShaderType shaderType; - - protected: optix::Material optixMaterial; - - protected: optix::TextureSampler optixTexture; - - protected: optix::TextureSampler optixNormalMap; - - protected: optix::TextureSampler optixEmptyTexture; - - private: static const std::string PTX_FILE_BASE; - - private: static const std::string PTX_CLOSEST_HIT_FUNC; - - private: static const std::string PTX_ANY_HIT_FUNC; - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixMesh.hh b/optix/include/ignition/rendering/optix/OptixMesh.hh index 778ab54e5..615bcdfba 100644 --- a/optix/include/ignition/rendering/optix/OptixMesh.hh +++ b/optix/include/ignition/rendering/optix/OptixMesh.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,76 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXMESH_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXMESH_HH_ -#include -#include -#include "ignition/rendering/base/BaseMesh.hh" -#include "ignition/rendering/optix/OptixGeometry.hh" -#include "ignition/rendering/optix/OptixObject.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixMesh : - public BaseMesh - { - typedef std::vector NameList; - - protected: OptixMesh(); - - public: virtual ~OptixMesh(); - - public: virtual optix::GeometryGroup OptixGeometryGroup() const; - - public: virtual optix::Acceleration OptixAccel() const; - - protected: virtual SubMeshStorePtr SubMeshes() const; - - protected: OptixSubMeshStorePtr subMeshes; - - protected: optix::GeometryGroup optixGeomGroup; - - protected: optix::Acceleration optixAccel; - - private: friend class OptixScene; - - private: friend class OptixMeshFactory; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixSubMesh : - public BaseSubMesh - { - protected: OptixSubMesh(); - - public: virtual ~OptixSubMesh(); - - public: virtual optix::GeometryInstance OptixGeometryInstance() const; - - protected: virtual void SetMaterialImpl(MaterialPtr _material) override; - - protected: optix::GeometryInstance optixGeomInstance; - - protected: optix::Geometry optixGeometry; - - protected: optix::Buffer optixVertexBuffer; - - protected: optix::Buffer optixNormalBuffer; - - protected: optix::Buffer optixTexCoordBuffer; - - protected: optix::Buffer optixIndexBuffer; - - private: friend class OptixScene; - - private: friend class OptixSubMeshStoreFactory; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixMeshFactory.hh b/optix/include/ignition/rendering/optix/OptixMeshFactory.hh index 4bbe206c1..4ef7d2847 100644 --- a/optix/include/ignition/rendering/optix/OptixMeshFactory.hh +++ b/optix/include/ignition/rendering/optix/OptixMeshFactory.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,86 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXMESHFACTORY_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXMESHFACTORY_HH_ -#include -#include -#include - -#include "ignition/rendering/MeshDescriptor.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixMesh.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixSubMeshStoreFactory - { - // cppcheck-suppress noExplicitConstructor - public: OptixSubMeshStoreFactory(OptixScenePtr _scene); - - public: virtual ~OptixSubMeshStoreFactory(); - - public: virtual OptixSubMeshStorePtr Create(const MeshDescriptor &_desc); - - protected: virtual optix::Geometry Geometry( - const MeshDescriptor &_desc, unsigned int _subMeshIndex); - - protected: virtual std::string KeyName(const MeshDescriptor &_desc, - unsigned int _subMeshIndex); - - protected: std::map geometries; - - protected: OptixScenePtr scene; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixMeshFactory - { - // cppcheck-suppress noExplicitConstructor - public: OptixMeshFactory(OptixScenePtr _scene); - - public: virtual ~OptixMeshFactory(); - - public: virtual OptixMeshPtr Create(const MeshDescriptor &_desc); - - protected: virtual OptixMeshPtr Create(OptixSubMeshStorePtr _subMeshes); - - protected: OptixSubMeshStoreFactory subMeshStoreFactory; - - protected: OptixScenePtr scene; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixMeshGeometryFactory - { - public: OptixMeshGeometryFactory(OptixScenePtr _scene, - const common::SubMesh &_subMesh); - - public: virtual ~OptixMeshGeometryFactory(); - - public: virtual optix::Geometry Create(); - - protected: virtual void CreateGeometry(); - - protected: virtual optix::Buffer CreateVertexBuffer(); - - protected: virtual optix::Buffer CreateNormalBuffer(); - - protected: virtual optix::Buffer CreateTexCoordBuffer(); - - protected: virtual optix::Buffer CreateIndexBuffer(); - - protected: OptixScenePtr scene; - - protected: const common::SubMesh &subMesh; - - protected: optix::Geometry optixGeometry; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixNode.hh b/optix/include/ignition/rendering/optix/OptixNode.hh index 56efc518b..313f68011 100644 --- a/optix/include/ignition/rendering/optix/OptixNode.hh +++ b/optix/include/ignition/rendering/optix/OptixNode.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,91 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXNODE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXNODE_HH_ -#include "ignition/rendering/base/BaseNode.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixNode : - public BaseNode - { - protected: OptixNode(); - - public: virtual ~OptixNode(); - - public: virtual bool HasParent() const override; - - public: virtual NodePtr Parent() const override; - - public: virtual void PreRender() override; - - public: virtual optix::Transform OptixTransform() const; - - // Documentation inherited. - public: virtual math::Vector3d LocalScale() const override; - - // Documentation inherited. - public: virtual bool InheritScale() const override; - - // Documentation inherited. - public: virtual void SetInheritScale(bool _inherit) override; - - // Documentation inherited. - protected: virtual void SetLocalScaleImpl( - const math::Vector3d &_scale) override; - - protected: virtual math::Pose3d RawLocalPose() const override; - - protected: virtual void SetRawLocalPose(const math::Pose3d &_pose) - override; - - protected: virtual void WritePoseToDevice(); - - protected: virtual void WritePoseToDeviceImpl(); - - protected: virtual void SetParent(OptixNodePtr _parent); - - protected: virtual void Init() override; - - protected: virtual NodeStorePtr Children() const override; - - protected: virtual bool AttachChild(NodePtr _child) override; - - protected: virtual bool DetachChild(NodePtr _child) override; - - protected: OptixNodePtr parent; - - protected: optix::Transform optixTransform; - - protected: optix::Group optixGroup; - - protected: optix::Acceleration optixAccel; - - protected: math::Pose3d pose; - - protected: bool poseDirty; - - protected: OptixNodeStorePtr children; - - protected: math::Vector3d scale = math::Vector3d::One; - - protected: bool inheritScale = true; - - private: OptixNodePtr SharedThis(); - - // TODO remove the need for a visual friend class - private: friend class OptixVisual; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixObject.hh b/optix/include/ignition/rendering/optix/OptixObject.hh index a7ba45572..f39eb1b2d 100644 --- a/optix/include/ignition/rendering/optix/OptixObject.hh +++ b/optix/include/ignition/rendering/optix/OptixObject.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,33 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXOBJECT_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXOBJECT_HH_ -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixObject : - public BaseObject - { - protected: OptixObject(); - - public: virtual ~OptixObject(); - - public: virtual ScenePtr Scene() const; - - protected: OptixScenePtr scene; - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixPrimitive.hh b/optix/include/ignition/rendering/optix/OptixPrimitive.hh index 0e0ff3f5b..7a729f4e4 100644 --- a/optix/include/ignition/rendering/optix/OptixPrimitive.hh +++ b/optix/include/ignition/rendering/optix/OptixPrimitive.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,62 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXPRIMITIVE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXPRIMITIVE_HH_ -#include -#include "ignition/rendering/optix/OptixGeometry.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixPrimitive : - public OptixGeometry - { - protected: OptixPrimitive(); - - public: virtual ~OptixPrimitive(); - - public: virtual MaterialPtr Material() const; - - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true); - - public: virtual optix::GeometryGroup OptixGeometryGroup() const; - - public: virtual optix::Acceleration OptixAccel() const; - - public: virtual optix::GeometryInstance OptixGeometryInstance() const; - - public: virtual optix::Geometry OptixGeometry() const; - - public: virtual void PreRender(); - - protected: virtual void SetMaterialImpl(OptixMaterialPtr _material); - - protected: virtual void Init(); - - protected: static optix::Geometry CreateOptixGeometry( - OptixScenePtr _scene, const std::string &_ptxFile); - - protected: MaterialPtr material; - - protected: optix::GeometryGroup optixGeomGroup; - - protected: optix::Acceleration optixAccel; - - protected: optix::GeometryInstance optixGeomInstance; - - protected: optix::Geometry optixGeometry; - - protected: static const std::string PTX_INTERSECT_FUNC; - - protected: static const std::string PTX_BOUNDS_FUNC; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixRayTypes.hh b/optix/include/ignition/rendering/optix/OptixRayTypes.hh index bcfc9d966..e82e5f651 100644 --- a/optix/include/ignition/rendering/optix/OptixRayTypes.hh +++ b/optix/include/ignition/rendering/optix/OptixRayTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,45 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXRAYTYPES_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXRAYTYPES_HH_ -#include - -#ifndef __CUDA_ARCH__ -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // -#endif - - typedef enum OptixRayType_t - { - RT_RADIANCE = 0, - RT_SHADOW = 1, - RT_COUNT = 2, - } OptixRayType; - - struct OptixRadianceRayData - { - float3 color; - // cppcheck-suppress unusedStructMember - float importance; - // cppcheck-suppress unusedStructMember - int depth; - }; - - struct OptixShadowRayData - { - float3 attenuation; - }; - -#ifndef __CUDA_ARCH__ - } - } -} -#endif - -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixRenderEngine.hh b/optix/include/ignition/rendering/optix/OptixRenderEngine.hh index f823021f9..5f3b3ea56 100644 --- a/optix/include/ignition/rendering/optix/OptixRenderEngine.hh +++ b/optix/include/ignition/rendering/optix/OptixRenderEngine.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,77 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXRENDERENGINE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXRENDERENGINE_HH_ -#include -#include -#include - -#include "ignition/rendering/RenderEnginePlugin.hh" -#include "ignition/rendering/base/BaseRenderEngine.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Plugin for loading optix render engine - class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderEnginePlugin : - public RenderEnginePlugin - { - /// \brief Constructor - public: OptixRenderEnginePlugin(); - - /// \brief Destructor - public: ~OptixRenderEnginePlugin() = default; - - /// \brief Get the name of the render engine loaded by this plugin. - /// \return Name of render engine - public: std::string Name() const; - - /// \brief Get a pointer to the render engine loaded by this plugin. - /// \return Render engine instance - public: RenderEngine *Engine() const; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderEngine : - public virtual BaseRenderEngine, - public common::SingletonT - { - /// \brief Constructor - private: OptixRenderEngine(); - - public: virtual ~OptixRenderEngine(); - - public: virtual bool Fini(); - - public: virtual std::string Name() const; - - public: std::string PtxFile(const std::string& _fileBase) const; - - protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, - const std::string &_name); - - protected: virtual SceneStorePtr Scenes() const; - - // Documentation Inherited - protected: virtual bool LoadImpl( - const std::map &_params) override; - - protected: virtual bool InitImpl(); - - private: OptixSceneStorePtr scenes; - - private: static const std::string PTX_PREFIX; - - private: static const std::string PTX_SUFFIX; - - private: friend class SingletonT; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixRenderTarget.hh b/optix/include/ignition/rendering/optix/OptixRenderTarget.hh index 23ae139b8..78c4a22a8 100644 --- a/optix/include/ignition/rendering/optix/OptixRenderTarget.hh +++ b/optix/include/ignition/rendering/optix/OptixRenderTarget.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,70 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXRENDERTARGET_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXRENDERTARGET_HH_ -#include "ignition/rendering/base/BaseRenderTarget.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderTarget : - public virtual BaseRenderTarget - { - protected: OptixRenderTarget(); - - public: virtual ~OptixRenderTarget(); - - public: virtual void Copy(Image &_image) const; - - public: virtual optix::Buffer OptixBuffer() const = 0; - - protected: unsigned int MemorySize() const; - - protected: float *hostData; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderTexture : - public virtual BaseRenderTexture - { - protected: OptixRenderTexture(); - - public: virtual ~OptixRenderTexture(); - - public: virtual void Destroy(); - - public: virtual optix::Buffer OptixBuffer() const; - - protected: virtual void RebuildImpl(); - - protected: optix::Buffer optixBuffer; - - protected: virtual void Init(); - - private: friend class OptixScene; - }; - - /// \brief Render window mocked using a render texture. - class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderWindow : - public virtual BaseRenderWindow - { - /// \brief Constructor - protected: OptixRenderWindow(); - - /// \brief Destructor - public: virtual ~OptixRenderWindow(); - - /// \brief Render windows should only be created by the scene class - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixRenderTypes.hh b/optix/include/ignition/rendering/optix/OptixRenderTypes.hh index 6f876f2cb..5135414b5 100644 --- a/optix/include/ignition/rendering/optix/OptixRenderTypes.hh +++ b/optix/include/ignition/rendering/optix/OptixRenderTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,93 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXRENDERTYPES_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXRENDERTYPES_HH_ -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class OptixArrowVisual; - class OptixAxisVisual; - class OptixBox; - class OptixCamera; - class OptixCone; - class OptixCylinder; - class OptixDirectionalLight; - class OptixGeometry; - class OptixGrid; - class OptixJointVisual; - class OptixLight; - class OptixMaterial; - class OptixMesh; - class OptixMeshFactory; - class OptixNode; - class OptixObject; - class OptixObjectFactory; - class OptixPointLight; - class OptixRenderEngine; - class OptixScene; - class OptixSensor; - class OptixSphere; - class OptixSpotLight; - class OptixSubMesh; - class OptixVisual; - class OptixRenderTarget; - class OptixRenderTexture; - class OptixRenderWindow; - class OptixLightManager; - - typedef BaseSceneStore OptixSceneStore; - typedef BaseNodeStore OptixNodeStore; - typedef BaseLightStore OptixLightStore; - typedef BaseSensorStore OptixSensorStore; - typedef BaseVisualStore OptixVisualStore; - typedef BaseGeometryStore OptixGeometryStore; - typedef BaseSubMeshStore OptixSubMeshStore; - typedef BaseMaterialMap OptixMaterialMap; - - typedef shared_ptr OptixArrowVisualPtr; - typedef shared_ptr OptixAxisVisualPtr; - typedef shared_ptr OptixBoxPtr; - typedef shared_ptr OptixCameraPtr; - typedef shared_ptr OptixConePtr; - typedef shared_ptr OptixCylinderPtr; - typedef shared_ptr OptixDirectionalLightPtr; - typedef shared_ptr OptixGeometryPtr; - typedef shared_ptr OptixGridPtr; - typedef shared_ptr OptixJointVisualPtr; - typedef shared_ptr OptixLightPtr; - typedef shared_ptr OptixMaterialPtr; - typedef shared_ptr OptixMeshPtr; - typedef shared_ptr OptixMeshFactoryPtr; - typedef shared_ptr OptixNodePtr; - typedef shared_ptr OptixObjectPtr; - typedef shared_ptr OptixObjectFactoryPtr; - typedef shared_ptr OptixPointLightPtr; - typedef shared_ptr OptixScenePtr; - typedef shared_ptr OptixSensorPtr; - typedef shared_ptr OptixSpherePtr; - typedef shared_ptr OptixSpotLightPtr; - typedef shared_ptr OptixSubMeshPtr; - typedef shared_ptr OptixVisualPtr; - typedef shared_ptr OptixSceneStorePtr; - typedef shared_ptr OptixNodeStorePtr; - typedef shared_ptr OptixLightStorePtr; - typedef shared_ptr OptixSensorStorePtr; - typedef shared_ptr OptixVisualStorePtr; - typedef shared_ptr OptixGeometryStorePtr; - typedef shared_ptr OptixSubMeshStorePtr; - typedef shared_ptr OptixMaterialMapPtr; - typedef shared_ptr OptixRenderTargetPtr; - typedef shared_ptr OptixRenderTexturePtr; - typedef shared_ptr OptixRenderWindowPtr; - typedef shared_ptr OptixLightManagerPtr; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixScene.hh b/optix/include/ignition/rendering/optix/OptixScene.hh index 5b69b9fa8..8f7c7e061 100644 --- a/optix/include/ignition/rendering/optix/OptixScene.hh +++ b/optix/include/ignition/rendering/optix/OptixScene.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,189 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXSCENE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXSCENE_HH_ -#include - -#include "ignition/rendering/base/BaseScene.hh" - -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixScene : - public BaseScene - { - protected: OptixScene(unsigned int _id, const std::string &_name); - - public: virtual ~OptixScene(); - - public: virtual void Fini(); - - public: virtual RenderEngine *Engine() const; - - public: virtual VisualPtr RootVisual() const; - - public: virtual math::Color AmbientLight() const; - - public: virtual void SetAmbientLight(const math::Color &_color); - - public: virtual void SetBackgroundColor(const math::Color &_color); - - // Documentation inherited. - public: virtual void SetGradientBackgroundColor( - const std::array &_colors); - - // Documentation inherited. - public: virtual void RemoveGradientBackgroundColor(); - - public: virtual void PreRender(); - - public: virtual void Clear(); - - public: virtual void Destroy(); - - public: virtual OptixLightManagerPtr LightManager() const; - - public: virtual optix::Context OptixContext() const; - - public: virtual optix::Program CreateOptixProgram( - const std::string &_fileBase, const std::string &_function); - - protected: virtual bool LoadImpl(); - - protected: virtual bool InitImpl(); - - protected: virtual DirectionalLightPtr CreateDirectionalLightImpl( - unsigned int _id, const std::string &_name); - - protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id, - const std::string &_name); - - protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id, - const std::string &_name); - - protected: virtual CameraPtr CreateCameraImpl(unsigned int _id, - const std::string &_name); - - // Documentation inherited - protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual VisualPtr CreateVisualImpl(unsigned int _id, - const std::string &_name); - - protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id, - const std::string &_name); - - protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id, - const std::string &_name); - - protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id, - const std::string &_name); - - protected: virtual GeometryPtr CreateConeImpl(unsigned int _id, - const std::string &_name); - - protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id, - const std::string &_name); - - protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id, - const std::string &_name); - - protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id, - const std::string &_name); - - protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, - const std::string &_name, const std::string &_meshName); - - protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, - const std::string &_name, const MeshDescriptor &_desc); - - // Documentation inherited. - protected: virtual GridPtr CreateGridImpl(unsigned int _id, - const std::string &_name); - - protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id, - const std::string &_name); - - protected: virtual RenderTexturePtr CreateRenderTextureImpl( - unsigned int _id, const std::string &_name); - - // Documentation inherited. - protected: virtual RenderWindowPtr CreateRenderWindowImpl( - unsigned int _id, const std::string &_name); - - protected: virtual RayQueryPtr CreateRayQueryImpl( - unsigned int _id, const std::string &_name); - - protected: virtual bool InitObject(OptixObjectPtr _object, - unsigned int _id, const std::string &_name); - - protected: virtual LightStorePtr Lights() const; - - protected: virtual SensorStorePtr Sensors() const; - - protected: virtual VisualStorePtr Visuals() const; - - protected: virtual MaterialMapPtr Materials() const; - - protected: virtual unsigned int NextEntryId(); - - private: void CreateContext(); - - private: void CreateRootVisual(); - - private: void CreateLightManager(); - - private: void CreateMeshFactory(); - - private: void CreateStores(); - - private: OptixScenePtr SharedThis(); - - protected: OptixVisualPtr rootVisual; - - protected: OptixLightManagerPtr lightManager; - - protected: OptixMeshFactoryPtr meshFactory; - - protected: OptixLightStorePtr lights; - - protected: OptixSensorStorePtr sensors; - - protected: OptixVisualStorePtr visuals; - - protected: OptixMaterialMapPtr materials; - - protected: optix::Context optixContext; - - protected: optix::Group optixRootGroup; - - protected: optix::Acceleration optixRootAccel; - - protected: optix::Program optixMissProgram; - - protected: optix::Geometry optixBoxGeometry; - - protected: optix::Geometry optixConeGeometry; - - protected: optix::Geometry optixCylinderGeometry; - - protected: optix::Geometry optixSphereGeometry; - - protected: math::Color ambientLight; - - private: friend class OptixRenderEngine; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixSensor.hh b/optix/include/ignition/rendering/optix/OptixSensor.hh index 8804d5771..b296f55b5 100644 --- a/optix/include/ignition/rendering/optix/OptixSensor.hh +++ b/optix/include/ignition/rendering/optix/OptixSensor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,26 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXSENSOR_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXSENSOR_HH_ -#include "ignition/rendering/base/BaseSensor.hh" -#include "ignition/rendering/optix/OptixNode.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixSensor : - public BaseSensor - { - protected: OptixSensor(); - - public: virtual ~OptixSensor(); - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixSphere.hh b/optix/include/ignition/rendering/optix/OptixSphere.hh index e7deb55f1..5fefd0c50 100644 --- a/optix/include/ignition/rendering/optix/OptixSphere.hh +++ b/optix/include/ignition/rendering/optix/OptixSphere.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXSPHERE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXSPHERE_HH_ -#include "ignition/rendering/optix/OptixPrimitive.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixSphere : - public OptixPrimitive - { - protected: OptixSphere(); - - public: virtual ~OptixSphere(); - - public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixStorage.hh b/optix/include/ignition/rendering/optix/OptixStorage.hh index f81983810..02dc0ab8d 100644 --- a/optix/include/ignition/rendering/optix/OptixStorage.hh +++ b/optix/include/ignition/rendering/optix/OptixStorage.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,53 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXSTORAGE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXSTORAGE_HH_ -#include "ignition/rendering/base/BaseStorage.hh" - -#include "ignition/rendering/optix/OptixGeometry.hh" -#include "ignition/rendering/optix/OptixLight.hh" -#include "ignition/rendering/optix/OptixMaterial.hh" -#include "ignition/rendering/optix/OptixMesh.hh" -#include "ignition/rendering/optix/OptixNode.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixSensor.hh" -#include "ignition/rendering/optix/OptixVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template class BaseSceneStore; - template class BaseNodeStore; - template class BaseLightStore; - template class BaseSensorStore; - template class BaseVisualStore; - template class BaseGeometryStore; - template class BaseSubMeshStore; - template class BaseMaterialMap; - - typedef BaseSceneStore OptixSceneStore; - typedef BaseNodeStore OptixNodeStore; - typedef BaseLightStore OptixLightStore; - typedef BaseSensorStore OptixSensorStore; - typedef BaseVisualStore OptixVisualStore; - typedef BaseGeometryStore OptixGeometryStore; - typedef BaseSubMeshStore OptixSubMeshStore; - typedef BaseMaterialMap OptixMaterialMap; - - typedef std::shared_ptr OptixSceneStorePtr; - typedef std::shared_ptr OptixNodeStorePtr; - typedef std::shared_ptr OptixLightStorePtr; - typedef std::shared_ptr OptixSensorStorePtr; - typedef std::shared_ptr OptixVisualStorePtr; - typedef std::shared_ptr OptixGeometryStorePtr; - typedef std::shared_ptr OptixSubMeshStorePtr; - typedef std::shared_ptr OptixMaterialMapPtr; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixTextureFactory.hh b/optix/include/ignition/rendering/optix/OptixTextureFactory.hh index fa5f6cd86..266b65ad7 100644 --- a/optix/include/ignition/rendering/optix/OptixTextureFactory.hh +++ b/optix/include/ignition/rendering/optix/OptixTextureFactory.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,39 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXTEXTUREFACTORY_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXTEXTUREFACTORY_HH_ -#include -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixTextureFactory - { - public: explicit OptixTextureFactory(OptixScenePtr _scene); - - public: virtual ~OptixTextureFactory(); - - public: optix::TextureSampler Create(const std::string &_filename); - - public: optix::TextureSampler Create(); - - protected: optix::Buffer CreateBuffer(const std::string &_filename); - - protected: optix::Buffer CreateBuffer(); - - protected: optix::TextureSampler CreateSampler(optix::Buffer _buffer); - - protected: OptixScenePtr scene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixVisual.hh b/optix/include/ignition/rendering/optix/OptixVisual.hh index 9b38dd8fe..7ed4d7380 100644 --- a/optix/include/ignition/rendering/optix/OptixVisual.hh +++ b/optix/include/ignition/rendering/optix/OptixVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,49 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXVISUAL_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXVISUAL_HH_ -#include "ignition/rendering/base/BaseVisual.hh" -#include "ignition/rendering/optix/OptixNode.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixVisual : - public BaseVisual - { - protected: OptixVisual(); - - public: virtual ~OptixVisual(); - - public: virtual optix::Group OptixGroup() const; - - public: virtual optix::Acceleration OptixAccel() const; - - public: virtual void PreRender(); - - protected: virtual GeometryStorePtr Geometries() const; - - protected: virtual bool AttachGeometry(GeometryPtr _geometry); - - protected: virtual bool DetachGeometry(GeometryPtr _geometry); - - protected: virtual void Init(); - - private: void CreateStorage(); - - private: OptixVisualPtr SharedThis(); - - protected: OptixGeometryStorePtr geometries; - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/optix.hh.in b/optix/include/ignition/rendering/optix/optix.hh.in deleted file mode 100644 index acfd26ae7..000000000 --- a/optix/include/ignition/rendering/optix/optix.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/optix/src/OptixArrowVisual.cc b/optix/src/OptixArrowVisual.cc index 107b24f17..5492e1668 100644 --- a/optix/src/OptixArrowVisual.cc +++ b/optix/src/OptixArrowVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixArrowVisual.hh" +#include "gz/rendering/optix/OptixArrowVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixAxisVisual.cc b/optix/src/OptixAxisVisual.cc index e3b6d9f62..e12593d77 100644 --- a/optix/src/OptixAxisVisual.cc +++ b/optix/src/OptixAxisVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixAxisVisual.hh" +#include "gz/rendering/optix/OptixAxisVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixBox.cc b/optix/src/OptixBox.cc index 0138980c1..2d51ee2a9 100644 --- a/optix/src/OptixBox.cc +++ b/optix/src/OptixBox.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixBox.hh" +#include "gz/rendering/optix/OptixBox.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixCamera.cc b/optix/src/OptixCamera.cc index caf345b39..b0bc8d9cb 100644 --- a/optix/src/OptixCamera.cc +++ b/optix/src/OptixCamera.cc @@ -14,14 +14,14 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixCamera.hh" +#include "gz/rendering/optix/OptixCamera.hh" -#include -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixRenderTarget.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixRenderTarget.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixCamera.cu b/optix/src/OptixCamera.cu index 70b8021b3..370239064 100644 --- a/optix/src/OptixCamera.cu +++ b/optix/src/OptixCamera.cu @@ -16,7 +16,7 @@ */ #include #include -#include +#include // camera variables rtDeclareVariable(float3, eye, , ); diff --git a/optix/src/OptixCone.cc b/optix/src/OptixCone.cc index 6ab546321..a5f731bca 100644 --- a/optix/src/OptixCone.cc +++ b/optix/src/OptixCone.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixCone.hh" +#include "gz/rendering/optix/OptixCone.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixConversions.cc b/optix/src/OptixConversions.cc index 27fa476ce..3f7193947 100644 --- a/optix/src/OptixConversions.cc +++ b/optix/src/OptixConversions.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixConversions.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixCylinder.cc b/optix/src/OptixCylinder.cc index 69a0939e9..be0539d05 100644 --- a/optix/src/OptixCylinder.cc +++ b/optix/src/OptixCylinder.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixCylinder.hh" +#include "gz/rendering/optix/OptixCylinder.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixGeometry.cc b/optix/src/OptixGeometry.cc index 03721eea4..4d703df24 100644 --- a/optix/src/OptixGeometry.cc +++ b/optix/src/OptixGeometry.cc @@ -15,12 +15,12 @@ * */ -#include "ignition/rendering/optix/OptixGeometry.hh" +#include "gz/rendering/optix/OptixGeometry.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixVisual.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixGrid.cc b/optix/src/OptixGrid.cc index 6d2c438bb..1ec8f0cd8 100644 --- a/optix/src/OptixGrid.cc +++ b/optix/src/OptixGrid.cc @@ -15,11 +15,11 @@ * */ -#include "ignition/rendering/optix/OptixGrid.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixVisual.hh" +#include "gz/rendering/optix/OptixGrid.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixLight.cc b/optix/src/OptixLight.cc index ab759dad6..64e7df818 100644 --- a/optix/src/OptixLight.cc +++ b/optix/src/OptixLight.cc @@ -14,14 +14,14 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixLight.hh" +#include "gz/rendering/optix/OptixLight.hh" -#include "ignition/rendering/optix/OptixConversions.hh" -#include "ignition/rendering/optix/OptixLightManager.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixLightManager.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixLightManager.cc b/optix/src/OptixLightManager.cc index a7ee354af..ea12678c8 100644 --- a/optix/src/OptixLightManager.cc +++ b/optix/src/OptixLightManager.cc @@ -14,13 +14,13 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixLightManager.hh" +#include "gz/rendering/optix/OptixLightManager.hh" -#include "ignition/rendering/optix/OptixLight.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixVisual.hh" +#include "gz/rendering/optix/OptixLight.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixMaterial.cc b/optix/src/OptixMaterial.cc index a9b0561c8..9218c73d8 100644 --- a/optix/src/OptixMaterial.cc +++ b/optix/src/OptixMaterial.cc @@ -14,14 +14,14 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixMaterial.hh" -#include "ignition/rendering/optix/OptixConversions.hh" -#include "ignition/rendering/optix/OptixRayTypes.hh" -#include "ignition/rendering/optix/OptixRenderEngine.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixTextureFactory.hh" - -using namespace ignition; +#include "gz/rendering/optix/OptixMaterial.hh" +#include "gz/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixRayTypes.hh" +#include "gz/rendering/optix/OptixRenderEngine.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixTextureFactory.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixMaterial.cu b/optix/src/OptixMaterial.cu index 7539048fd..46ec0fa62 100644 --- a/optix/src/OptixMaterial.cu +++ b/optix/src/OptixMaterial.cu @@ -17,8 +17,8 @@ #include #include #include -#include "ignition/rendering/optix/OptixRayTypes.hh" -#include "ignition/rendering/optix/OptixLightTypes.hh" +#include "gz/rendering/optix/OptixRayTypes.hh" +#include "gz/rendering/optix/OptixLightTypes.hh" // scene variables rtDeclareVariable(float3, ambientLightColor, , ); diff --git a/optix/src/OptixMesh.cc b/optix/src/OptixMesh.cc index 8e0e0aa6b..39df3fcbb 100644 --- a/optix/src/OptixMesh.cc +++ b/optix/src/OptixMesh.cc @@ -15,14 +15,14 @@ * */ -#include +#include -#include "ignition/rendering/optix/OptixMesh.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixMaterial.hh" -#include "ignition/rendering/optix/OptixStorage.hh" +#include "gz/rendering/optix/OptixMesh.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixMaterial.hh" +#include "gz/rendering/optix/OptixStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixMeshFactory.cc b/optix/src/OptixMeshFactory.cc index 8788a3f2c..d7e0cc687 100644 --- a/optix/src/OptixMeshFactory.cc +++ b/optix/src/OptixMeshFactory.cc @@ -14,15 +14,15 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixMeshFactory.hh" +#include "gz/rendering/optix/OptixMeshFactory.hh" #include -#include -#include -#include "ignition/rendering/optix/OptixMesh.hh" -#include "ignition/rendering/optix/OptixStorage.hh" +#include +#include +#include "gz/rendering/optix/OptixMesh.hh" +#include "gz/rendering/optix/OptixStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixMissProgram.cu b/optix/src/OptixMissProgram.cu index 55a003a73..800b55b29 100644 --- a/optix/src/OptixMissProgram.cu +++ b/optix/src/OptixMissProgram.cu @@ -16,7 +16,7 @@ */ #include #include -#include "ignition/rendering/optix/OptixRayTypes.hh" +#include "gz/rendering/optix/OptixRayTypes.hh" rtDeclareVariable(float3, color, , ); rtDeclareVariable(OptixRadianceRayData, payload, rtPayload, ); diff --git a/optix/src/OptixNode.cc b/optix/src/OptixNode.cc index 9cbea0566..1e28cc737 100644 --- a/optix/src/OptixNode.cc +++ b/optix/src/OptixNode.cc @@ -14,13 +14,13 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixNode.hh" -#include "ignition/rendering/optix/OptixConversions.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixStorage.hh" +#include "gz/rendering/optix/OptixNode.hh" +#include "gz/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixObject.cc b/optix/src/OptixObject.cc index d30572cd9..07f25a4ab 100644 --- a/optix/src/OptixObject.cc +++ b/optix/src/OptixObject.cc @@ -14,11 +14,11 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixObject.hh" +#include "gz/rendering/optix/OptixObject.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixPrimitive.cc b/optix/src/OptixPrimitive.cc index 82eec6b7c..003d0401b 100644 --- a/optix/src/OptixPrimitive.cc +++ b/optix/src/OptixPrimitive.cc @@ -15,13 +15,13 @@ * */ -#include +#include -#include "ignition/rendering/optix/OptixPrimitive.hh" -#include "ignition/rendering/optix/OptixMaterial.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixPrimitive.hh" +#include "gz/rendering/optix/OptixMaterial.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixRenderEngine.cc b/optix/src/OptixRenderEngine.cc index 5c2d5e45e..fc9218295 100644 --- a/optix/src/OptixRenderEngine.cc +++ b/optix/src/OptixRenderEngine.cc @@ -17,15 +17,15 @@ #include -#include +#include -#include "ignition/rendering/RenderEngineManager.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixStorage.hh" -#include "ignition/rendering/optix/OptixRenderEngine.hh" +#include "gz/rendering/RenderEngineManager.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixStorage.hh" +#include "gz/rendering/optix/OptixRenderEngine.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixRenderTarget.cc b/optix/src/OptixRenderTarget.cc index 890d31958..5f03ce7ed 100644 --- a/optix/src/OptixRenderTarget.cc +++ b/optix/src/OptixRenderTarget.cc @@ -15,14 +15,14 @@ * */ -#include +#include -#include "ignition/rendering/optix/OptixRenderTarget.hh" +#include "gz/rendering/optix/OptixRenderTarget.hh" -#include "ignition/rendering/optix/OptixConversions.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixScene.cc b/optix/src/OptixScene.cc index d7e97063c..46dcae5d5 100644 --- a/optix/src/OptixScene.cc +++ b/optix/src/OptixScene.cc @@ -13,27 +13,27 @@ * */ -#include - -#include "ignition/rendering/optix/OptixArrowVisual.hh" -#include "ignition/rendering/optix/OptixAxisVisual.hh" -#include "ignition/rendering/optix/OptixBox.hh" -#include "ignition/rendering/optix/OptixCamera.hh" -#include "ignition/rendering/optix/OptixCone.hh" -#include "ignition/rendering/optix/OptixCylinder.hh" -#include "ignition/rendering/optix/OptixGeometry.hh" -#include "ignition/rendering/optix/OptixGrid.hh" -#include "ignition/rendering/optix/OptixLightManager.hh" -#include "ignition/rendering/optix/OptixMeshFactory.hh" -#include "ignition/rendering/optix/OptixRayTypes.hh" -#include "ignition/rendering/optix/OptixRenderEngine.hh" -#include "ignition/rendering/optix/OptixRenderTarget.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixSphere.hh" -#include "ignition/rendering/optix/OptixStorage.hh" -#include "ignition/rendering/optix/OptixVisual.hh" - -using namespace ignition; +#include + +#include "gz/rendering/optix/OptixArrowVisual.hh" +#include "gz/rendering/optix/OptixAxisVisual.hh" +#include "gz/rendering/optix/OptixBox.hh" +#include "gz/rendering/optix/OptixCamera.hh" +#include "gz/rendering/optix/OptixCone.hh" +#include "gz/rendering/optix/OptixCylinder.hh" +#include "gz/rendering/optix/OptixGeometry.hh" +#include "gz/rendering/optix/OptixGrid.hh" +#include "gz/rendering/optix/OptixLightManager.hh" +#include "gz/rendering/optix/OptixMeshFactory.hh" +#include "gz/rendering/optix/OptixRayTypes.hh" +#include "gz/rendering/optix/OptixRenderEngine.hh" +#include "gz/rendering/optix/OptixRenderTarget.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixSphere.hh" +#include "gz/rendering/optix/OptixStorage.hh" +#include "gz/rendering/optix/OptixVisual.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixSensor.cc b/optix/src/OptixSensor.cc index 59d3d69bf..6efeb9203 100644 --- a/optix/src/OptixSensor.cc +++ b/optix/src/OptixSensor.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixSensor.hh" +#include "gz/rendering/optix/OptixSensor.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixSphere.cc b/optix/src/OptixSphere.cc index da64723db..45f7e8943 100644 --- a/optix/src/OptixSphere.cc +++ b/optix/src/OptixSphere.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixSphere.hh" +#include "gz/rendering/optix/OptixSphere.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixTextureFactory.cc b/optix/src/OptixTextureFactory.cc index 29b369d1f..039e692eb 100644 --- a/optix/src/OptixTextureFactory.cc +++ b/optix/src/OptixTextureFactory.cc @@ -15,13 +15,13 @@ */ #include -#include +#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/optix/OptixTextureFactory.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include "gz/rendering/config.hh" +#include "gz/rendering/optix/OptixTextureFactory.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; // TODO: clone texture sampler, reuse texture buffers diff --git a/optix/src/OptixVisual.cc b/optix/src/OptixVisual.cc index 3596a1551..cb51a1d27 100644 --- a/optix/src/OptixVisual.cc +++ b/optix/src/OptixVisual.cc @@ -15,13 +15,13 @@ * */ -#include +#include -#include "ignition/rendering/optix/OptixVisual.hh" -#include "ignition/rendering/optix/OptixConversions.hh" -#include "ignition/rendering/optix/OptixStorage.hh" +#include "gz/rendering/optix/OptixVisual.hh" +#include "gz/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/ArrowVisual_TEST.cc b/src/ArrowVisual_TEST.cc index aef403980..e4a2d59b9 100644 --- a/src/ArrowVisual_TEST.cc +++ b/src/ArrowVisual_TEST.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,11 @@ #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/ArrowVisual.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Visual.hh" +#include "gz/rendering/ArrowVisual.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Visual.hh" using namespace ignition; using namespace rendering; diff --git a/src/Camera_TEST.cc b/src/Camera_TEST.cc index d3dc8c55e..ae2190f67 100644 --- a/src/Camera_TEST.cc +++ b/src/Camera_TEST.cc @@ -17,17 +17,17 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GaussianNoisePass.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/Scene.hh" - -using namespace ignition; +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GaussianNoisePass.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/Scene.hh" + +using namespace gz; using namespace rendering; class CameraTest : public testing::Test, diff --git a/src/GaussianNoisePass.cc b/src/GaussianNoisePass.cc index 9fed44dbc..231225416 100644 --- a/src/GaussianNoisePass.cc +++ b/src/GaussianNoisePass.cc @@ -16,9 +16,9 @@ */ -#include "ignition/rendering/GaussianNoisePass.hh" +#include "gz/rendering/GaussianNoisePass.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/GaussianNoisePass_TEST.cc b/src/GaussianNoisePass_TEST.cc index 51d362ab8..a20e72cf3 100644 --- a/src/GaussianNoisePass_TEST.cc +++ b/src/GaussianNoisePass_TEST.cc @@ -18,15 +18,15 @@ #include #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/GaussianNoisePass.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderPassSystem.hh" +#include "gz/rendering/GaussianNoisePass.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderPassSystem.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class GaussianNoisePassTest : public testing::Test, diff --git a/src/GizmoVisual_TEST.cc b/src/GizmoVisual_TEST.cc index 12e13a935..8d0fbcac7 100644 --- a/src/GizmoVisual_TEST.cc +++ b/src/GizmoVisual_TEST.cc @@ -18,16 +18,16 @@ #include #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/GizmoVisual.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/GizmoVisual.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class GizmoVisualTest : public testing::Test, diff --git a/src/Grid_TEST.cc b/src/Grid_TEST.cc index 5968d74d5..d83ff34c9 100644 --- a/src/Grid_TEST.cc +++ b/src/Grid_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Grid.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Grid.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class GridTest : public testing::Test, diff --git a/src/Image.cc b/src/Image.cc index a2ad9cc43..983022e66 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/Image.hh" +#include "gz/rendering/Image.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/InertiaVisual_TEST.cc b/src/InertiaVisual_TEST.cc index 0d958cadf..6b0357596 100644 --- a/src/InertiaVisual_TEST.cc +++ b/src/InertiaVisual_TEST.cc @@ -22,10 +22,10 @@ #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/InertiaVisual.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/InertiaVisual.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" using namespace ignition; using namespace rendering; diff --git a/src/Light_TEST.cc b/src/Light_TEST.cc index 8957129f2..275adda40 100644 --- a/src/Light_TEST.cc +++ b/src/Light_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Light.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Light.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class LightTest : public testing::Test, diff --git a/src/Marker.cc b/src/Marker.cc index d83c181df..71481eabe 100644 --- a/src/Marker.cc +++ b/src/Marker.cc @@ -16,9 +16,9 @@ */ -#include "ignition/rendering/Marker.hh" +#include "gz/rendering/Marker.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/Marker_TEST.cc b/src/Marker_TEST.cc index 52501f790..36a1cc4ff 100644 --- a/src/Marker_TEST.cc +++ b/src/Marker_TEST.cc @@ -16,16 +16,16 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Marker.hh" -#include "ignition/rendering/Material.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Marker.hh" +#include "gz/rendering/Material.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; using namespace std::chrono_literals; @@ -131,6 +131,8 @@ void MarkerTest::Marker(const std::string &_renderEngine) // exercise point api EXPECT_NO_THROW(marker->AddPoint(math::Vector3d(0, 1, 2), math::Color::White)); + EXPECT_NO_THROW(marker->AddPoint(-2, -1, 0, math::Color::White)); + EXPECT_NO_THROW(marker->SetPoint(0, math::Vector3d(3, 1, 2))); EXPECT_NO_THROW(marker->ClearPoints()); diff --git a/src/Material_TEST.cc b/src/Material_TEST.cc index dda070fc0..a529b1799 100644 --- a/src/Material_TEST.cc +++ b/src/Material_TEST.cc @@ -18,19 +18,19 @@ #include #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Material.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/ShaderType.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Material.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/ShaderType.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class MaterialTest : public testing::Test, diff --git a/src/MeshDescriptor.cc b/src/MeshDescriptor.cc index f1a9d0690..3d0d2f13d 100644 --- a/src/MeshDescriptor.cc +++ b/src/MeshDescriptor.cc @@ -15,13 +15,13 @@ * */ -#include -#include -#include +#include +#include +#include -#include "ignition/rendering/MeshDescriptor.hh" +#include "gz/rendering/MeshDescriptor.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/MeshDescriptor_TEST.cc b/src/MeshDescriptor_TEST.cc index 7a41e8aba..3254e355b 100644 --- a/src/MeshDescriptor_TEST.cc +++ b/src/MeshDescriptor_TEST.cc @@ -18,18 +18,18 @@ #include #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/MeshDescriptor.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/MeshDescriptor.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class MeshDescriptorTest : public testing::Test, @@ -53,6 +53,12 @@ void MeshDescriptorTest::Descriptor(const std::string &_renderEngine) ScenePtr scene = engine->CreateScene("scene"); ASSERT_TRUE(scene != nullptr); + MeshDescriptor failDescriptor; + failDescriptor.Load(); + + MeshDescriptor failDescriptor2("non_existing_mesh"); + failDescriptor2.Load(); + // empty constructor MeshDescriptor emptyDescriptor; EXPECT_TRUE(emptyDescriptor.meshName.empty()); diff --git a/src/Mesh_TEST.cc b/src/Mesh_TEST.cc index 4385782e2..6637fe150 100644 --- a/src/Mesh_TEST.cc +++ b/src/Mesh_TEST.cc @@ -19,19 +19,19 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Mesh.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Mesh.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class MeshTest : public testing::Test, @@ -90,6 +90,11 @@ void MeshTest::MeshSubMesh(const std::string &_renderEngine) EXPECT_FALSE(mesh->HasSkeleton()); + std::map skinFrames; + mesh->SetSkeletonLocalTransforms(skinFrames); + auto skeletonLocalTransforms = mesh->SkeletonLocalTransforms(); + EXPECT_EQ(0u, skeletonLocalTransforms.size()); + // test submesh API MaterialPtr mat = submesh->Material(); ASSERT_TRUE(mat != nullptr); @@ -101,6 +106,8 @@ void MeshTest::MeshSubMesh(const std::string &_renderEngine) EXPECT_EQ(matClone, submesh->Material()); EXPECT_NE(mat, submesh->Material()); + submesh->SetMaterial(MaterialPtr(), false); + submesh->SetMaterial("Default/White", false); EXPECT_EQ("Default/White", submesh->Material()->Name()); @@ -192,6 +199,9 @@ void MeshTest::MeshSkeleton(const std::string &_renderEngine) mesh->SetSkeletonLocalTransforms(skinFrames); } + auto skeletonLocalTransforms = mesh->SkeletonLocalTransforms(); + EXPECT_EQ(31u, skeletonLocalTransforms.size()); + // Clean up engine->DestroyScene(scene); unloadEngine(engine->Name()); diff --git a/src/MoveToHelper.cc b/src/MoveToHelper.cc index f5467b9fe..ed4c3e475 100644 --- a/src/MoveToHelper.cc +++ b/src/MoveToHelper.cc @@ -15,17 +15,17 @@ * */ -#include "ignition/rendering/MoveToHelper.hh" +#include "gz/rendering/MoveToHelper.hh" #include -#include -#include -#include +#include +#include +#include -#include "ignition/rendering/Camera.hh" +#include "gz/rendering/Camera.hh" -class ignition::rendering::MoveToHelperPrivate +class gz::rendering::MoveToHelperPrivate { /// \brief Pose animation object public: std::unique_ptr poseAnim; @@ -40,7 +40,7 @@ class ignition::rendering::MoveToHelperPrivate public: math::Pose3d initCameraPose; }; -using namespace ignition; +using namespace gz; using namespace rendering; //////////////////////////////////////////////// diff --git a/src/MoveToHelper_TEST.cc b/src/MoveToHelper_TEST.cc index 75cb8d28a..11960476e 100644 --- a/src/MoveToHelper_TEST.cc +++ b/src/MoveToHelper_TEST.cc @@ -17,17 +17,18 @@ #include #include +#include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class MoveToHelperTest : public testing::Test, @@ -111,6 +112,11 @@ void MoveToHelperTest::MoveTo(const std::string &_renderEngine) NodePtr target = scene->NodeByName("center"); + moveToHelper.SetInitCameraPose(math::Pose3d()); + + // This call should return, there is no camera + moveToHelper.AddTime(0.1); + moveToHelper.MoveTo(camera, target, 0.5, std::bind(&MoveToHelperTest::OnMoveToComplete, this)); EXPECT_FALSE(moveToHelper.Idle()); @@ -136,6 +142,22 @@ void MoveToHelperTest::MoveTo(const std::string &_renderEngine) EXPECT_EQ(math::Vector3d(0.0, -1, 0.0), camera->LocalPosition()); EXPECT_EQ(math::Quaterniond(0.0, -0.785398, 1.5708), camera->LocalRotation()); + moveToHelper.LookDirection(camera, + math::Vector3d::Zero, lookAt, + 0.5, std::bind(&MoveToHelperTest::OnMoveToComplete, this)); + EXPECT_FALSE(moveToHelper.Idle()); + checkIsCompleted(0.5); + EXPECT_TRUE(moveToHelper.Idle()); + EXPECT_EQ(math::Vector3d(0.0, 0, 0.0), camera->LocalPosition()); + EXPECT_EQ(math::Quaterniond(0.0, 0, 0), camera->LocalRotation()); + + moveToHelper.MoveTo(camera, math::Pose3d(INFINITY, 0.0, 0.0, 0, 0, 0), 0.5, + std::bind(&MoveToHelperTest::OnMoveToComplete, this)); + EXPECT_FALSE(moveToHelper.Idle()); + checkIsCompleted(0.5); + EXPECT_EQ(math::Vector3d(0.0, 0, 0.0), camera->LocalPosition()); + EXPECT_TRUE(moveToHelper.Idle()); + engine->DestroyScene(scene); unloadEngine(engine->Name()); } diff --git a/src/Node_TEST.cc b/src/Node_TEST.cc index 8bea71c14..2fa2573c2 100644 --- a/src/Node_TEST.cc +++ b/src/Node_TEST.cc @@ -18,17 +18,17 @@ #include #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Node.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Visual.hh" +#include "gz/rendering/Node.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Visual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class NodeTest : public testing::Test, diff --git a/src/OrbitViewController.cc b/src/OrbitViewController.cc index 9cdd317aa..05c3a16ae 100644 --- a/src/OrbitViewController.cc +++ b/src/OrbitViewController.cc @@ -14,33 +14,24 @@ * limitations under the License. * */ - #include -#include +#include -#include "ignition/rendering/OrbitViewController.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Visual.hh" +#include "gz/rendering/OrbitViewController.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Visual.hh" -class ignition::rendering::OrbitViewControllerPrivate +class gz::rendering::OrbitViewControllerPrivate { /// \brief Pointer to camera public: CameraPtr camera; /// \brief Target point for camera movements public: math::Vector3d target; - - /// \brief Keep yaw within limits - /// \return Normalized yaw - public: double NormalizeYaw(double _yaw); - - /// \brief Keep pitch within limits - /// \return Normalized pitch - public: double NormalizePitch(double _pitch); }; -using namespace ignition; +using namespace gz; using namespace rendering; static const float PITCH_LIMIT_LOW = -static_cast(IGN_PI)*0.5f + 0.001f; @@ -86,7 +77,7 @@ void OrbitViewController::SetTarget(const math::Vector3d &_target) } ////////////////////////////////////////////////// -const math::Vector3d &OrbitViewController::Target() const +math::Vector3d &OrbitViewController::Target() const { return this->dataPtr->target; } @@ -211,26 +202,3 @@ void OrbitViewController::Orbit(const math::Vector2d &_value) this->dataPtr->camera->SetWorldPosition( this->dataPtr->camera->WorldPosition() + this->dataPtr->target); } - -////////////////////////////////////////////////// -double OrbitViewControllerPrivate::NormalizeYaw(double _yaw) -{ - _yaw = fmod(_yaw, IGN_PI*2); - if (_yaw < 0.0f) - { - _yaw = IGN_PI * 2 + _yaw; - } - - return _yaw; -} - -////////////////////////////////////////////////// -double OrbitViewControllerPrivate::NormalizePitch(double _pitch) -{ - if (_pitch < PITCH_LIMIT_LOW) - _pitch = PITCH_LIMIT_LOW; - else if (_pitch > PITCH_LIMIT_HIGH) - _pitch = PITCH_LIMIT_HIGH; - - return _pitch; -} diff --git a/src/OrbitViewController_TEST.cc b/src/OrbitViewController_TEST.cc index 1d06777de..2d86e8ece 100644 --- a/src/OrbitViewController_TEST.cc +++ b/src/OrbitViewController_TEST.cc @@ -17,16 +17,16 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/OrbitViewController.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/OrbitViewController.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class OrbitViewControllerTest : public testing::Test, @@ -35,6 +35,10 @@ class OrbitViewControllerTest : public testing::Test, /// \brief Test basic api public: void OrbitViewControl(const std::string &_renderEngine); + /// \brief Test basic api + public: void OrbitViewControlCameraConstructor( + const std::string &_renderEngine); + /// \brief test zoom, pan, orbit public: void Control(const std::string &_renderEngine); }; @@ -83,6 +87,43 @@ void OrbitViewControllerTest::OrbitViewControl(const std::string &_renderEngine) unloadEngine(engine->Name()); } +///////////////////////////////////////////////// +void OrbitViewControllerTest::OrbitViewControlCameraConstructor( + const std::string &_renderEngine) +{ + RenderEngine *engine = rendering::engine(_renderEngine); + if (!engine) + { + igndbg << "Engine '" << _renderEngine + << "' is not supported" << std::endl; + return; + } + ScenePtr scene = engine->CreateScene("scene"); + EXPECT_NE(scene, nullptr); + + CameraPtr camera = scene->CreateCamera("camera"); + EXPECT_NE(camera, nullptr); + + OrbitViewController viewControl(camera); + + // verify intial values + EXPECT_EQ(camera, viewControl.Camera()); + EXPECT_EQ(math::Vector3d::Zero, viewControl.Target()); + + // test setting target + math::Vector3d target(1, 0, 0); + viewControl.SetTarget(target); + EXPECT_EQ(target, viewControl.Target()); + + target.Set(-0.3, -5, 1); + viewControl.SetTarget(target); + EXPECT_EQ(target, viewControl.Target()); + + // Clean up + engine->DestroyScene(scene); + unloadEngine(engine->Name()); +} + ///////////////////////////////////////////////// void OrbitViewControllerTest::Control(const std::string &_renderEngine) { @@ -107,6 +148,10 @@ void OrbitViewControllerTest::Control(const std::string &_renderEngine) OrbitViewController viewControl; + viewControl.Zoom(0); + viewControl.Pan(math::Vector2d(0, 0)); + viewControl.Orbit(math::Vector2d(0, 0)); + // test setting camera viewControl.SetCamera(camera); EXPECT_EQ(camera, viewControl.Camera()); @@ -229,6 +274,12 @@ TEST_P(OrbitViewControllerTest, OrbitViewController) OrbitViewControl(GetParam()); } +///////////////////////////////////////////////// +TEST_P(OrbitViewControllerTest, OrbitViewControllerCameraConstructor) +{ + OrbitViewControlCameraConstructor(GetParam()); +} + ///////////////////////////////////////////////// TEST_P(OrbitViewControllerTest, Control) { diff --git a/src/PixelFormat.cc b/src/PixelFormat.cc index 73b16951d..003ffea03 100644 --- a/src/PixelFormat.cc +++ b/src/PixelFormat.cc @@ -15,11 +15,11 @@ * */ -#include +#include -#include "ignition/rendering/PixelFormat.hh" +#include "gz/rendering/PixelFormat.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/PixelFormat_TEST.cc b/src/PixelFormat_TEST.cc index 622bf442e..fcb81b7a3 100644 --- a/src/PixelFormat_TEST.cc +++ b/src/PixelFormat_TEST.cc @@ -19,9 +19,9 @@ #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/PixelFormat.hh" +#include "gz/rendering/PixelFormat.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ///////////////////////////////////////////////// @@ -31,26 +31,36 @@ TEST(PixelFormatTest, PixelUtil) EXPECT_EQ(3u, PixelUtil::BytesPerPixel(format)); EXPECT_EQ(1u, PixelUtil::BytesPerChannel(format)); EXPECT_EQ(3072u, PixelUtil::MemorySize(format, 32, 32)); + EXPECT_EQ("R8G8B8", PixelUtil::Name(format)); + EXPECT_EQ(format, PixelUtil::Enum("R8G8B8")); format = PF_FLOAT32_R; EXPECT_EQ(4u, PixelUtil::BytesPerPixel(format)); EXPECT_EQ(4u, PixelUtil::BytesPerChannel(format)); EXPECT_EQ(4096u, PixelUtil::MemorySize(format, 32, 32)); + EXPECT_EQ("FLOAT32_R", PixelUtil::Name(format)); + EXPECT_EQ(format, PixelUtil::Enum("FLOAT32_R")); format = PF_FLOAT32_RGB; EXPECT_EQ(12u, PixelUtil::BytesPerPixel(format)); EXPECT_EQ(4u, PixelUtil::BytesPerChannel(format)); EXPECT_EQ(12288u, PixelUtil::MemorySize(format, 32, 32)); + EXPECT_EQ("FLOAT32_RGB", PixelUtil::Name(format)); + EXPECT_EQ(format, PixelUtil::Enum("FLOAT32_RGB")); format = PF_FLOAT32_RGBA; EXPECT_EQ(16u, PixelUtil::BytesPerPixel(format)); EXPECT_EQ(4u, PixelUtil::BytesPerChannel(format)); EXPECT_EQ(16384u, PixelUtil::MemorySize(format, 32, 32)); + EXPECT_EQ("FLOAT32_RGBA", PixelUtil::Name(format)); + EXPECT_EQ(format, PixelUtil::Enum("FLOAT32_RGBA")); format = PF_L16; EXPECT_EQ(2u, PixelUtil::BytesPerPixel(format)); EXPECT_EQ(2u, PixelUtil::BytesPerChannel(format)); EXPECT_EQ(2048u, PixelUtil::MemorySize(format, 32, 32)); + EXPECT_EQ("L16", PixelUtil::Name(format)); + EXPECT_EQ(format, PixelUtil::Enum("L16")); format = PF_R8G8B8A8; EXPECT_EQ(4u, PixelUtil::BytesPerPixel(format)); @@ -58,6 +68,17 @@ TEST(PixelFormatTest, PixelUtil) EXPECT_EQ(4096u, PixelUtil::MemorySize(format, 32, 32)); } +///////////////////////////////////////////////// +TEST(PixelFormatTest, PixelUtilInvalid) +{ + PixelFormat format = static_cast(16); + + EXPECT_EQ(PF_UNKNOWN, PixelUtil::Sanitize(format)); + EXPECT_EQ("UNKNOWN", PixelUtil::Name(format)); + + EXPECT_EQ(PF_UNKNOWN, PixelUtil::Enum("invalid")); +} + int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/src/RayQuery_TEST.cc b/src/RayQuery_TEST.cc index 1ae964c5e..761047c2a 100644 --- a/src/RayQuery_TEST.cc +++ b/src/RayQuery_TEST.cc @@ -17,17 +17,17 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class RayQueryTest : public testing::Test, diff --git a/src/RenderEngineManager.cc b/src/RenderEngineManager.cc index cb10def9d..e1c2246aa 100644 --- a/src/RenderEngineManager.cc +++ b/src/RenderEngineManager.cc @@ -18,15 +18,15 @@ #include #include -#include -#include +#include +#include -#include +#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderEngineManager.hh" -#include "ignition/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderEngineManager.hh" +#include "gz/rendering/RenderEnginePlugin.hh" /// \brief Holds information about an engine struct EngineInfo @@ -36,11 +36,11 @@ struct EngineInfo std::string name; /// \brief The pointer to the render engine. - ignition::rendering::RenderEngine *engine; + gz::rendering::RenderEngine *engine; }; /// \brief Private implementation of the RenderEngineManager class. -class ignition::rendering::RenderEngineManagerPrivate +class gz::rendering::RenderEngineManagerPrivate { /// \brief EngineMap that maps engine name to an engine pointer. typedef std::map EngineMap; @@ -93,7 +93,7 @@ class ignition::rendering::RenderEngineManagerPrivate public: std::map enginePlugins; /// \brief Plugin loader for managing render engine plugin libraries. - public: ignition::plugin::Loader pluginLoader; + public: gz::plugin::Loader pluginLoader; /// \brief Environment variable which holds paths to look for plugins public: std::string pluginPathEnv = "IGN_RENDERING_PLUGIN_PATH"; @@ -105,7 +105,7 @@ class ignition::rendering::RenderEngineManagerPrivate public: std::recursive_mutex enginesMutex; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/RenderEngineManager_TEST.cc b/src/RenderEngineManager_TEST.cc new file mode 100644 index 000000000..0ea1b9e8b --- /dev/null +++ b/src/RenderEngineManager_TEST.cc @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include + +#include + +#include "test_config.h" // NOLINT(build/include) + +#include "ignition/rendering/RenderingIface.hh" +#include "ignition/rendering/RenderEngine.hh" +#include "ignition/rendering/RenderEngineManager.hh" + +using namespace ignition; +using namespace rendering; + +class RenderEngineManagerTest : public testing::Test, + public testing::WithParamInterface +{ + public: void RenderEngineManager(const std::string &_renderEngine); +}; + +///////////////////////////////////////////////// +void RenderEngineManagerTest::RenderEngineManager( + const std::string &_renderEngine) +{ + // Tested missing APIs + EXPECT_FALSE(RenderEngineManager::Instance()->HasEngine("invalid")); + EXPECT_EQ(nullptr, RenderEngineManager::Instance()->Engine("invalid")); + EXPECT_FALSE(RenderEngineManager::Instance()->UnloadEngine("invalid")); + + EXPECT_FALSE(RenderEngineManager::Instance()->UnloadEngineAt(100)); + + RenderEngineManager::Instance()->RegisterEngine("invalid", nullptr); + + auto engine = rendering::engine(_renderEngine); + RenderEngineManager::Instance()->RegisterEngine("ogre2", engine); + + RenderEngineManager::Instance()->UnregisterEngine(engine); + EXPECT_FALSE(RenderEngineManager::Instance()->UnloadEngineAt(0)); + + std::list paths = {"path1", "path2"}; + RenderEngineManager::Instance()->SetPluginPaths(paths); +} + +///////////////////////////////////////////////// +TEST_P(RenderEngineManagerTest, RenderEngineManager) +{ + RenderEngineManager(GetParam()); +} + +INSTANTIATE_TEST_CASE_P(RenderEngineManager, RenderEngineManagerTest, + RENDER_ENGINE_VALUES, + PrintToStringParam()); + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/src/RenderEnginePlugin.cc b/src/RenderEnginePlugin.cc index e14d7aa06..7f89fa2b5 100644 --- a/src/RenderEnginePlugin.cc +++ b/src/RenderEnginePlugin.cc @@ -15,13 +15,13 @@ * */ -#include "ignition/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/RenderEnginePlugin.hh" -class ignition::rendering::RenderEnginePluginPrivate +class gz::rendering::RenderEnginePluginPrivate { }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/RenderEngine_TEST.cc b/src/RenderEngine_TEST.cc index b6d1bccab..e88d1def7 100644 --- a/src/RenderEngine_TEST.cc +++ b/src/RenderEngine_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class RenderEngineTest : public testing::Test, @@ -48,6 +48,7 @@ void RenderEngineTest::RenderEngine(const std::string &_renderEngine) EXPECT_EQ(_renderEngine, engine->Name()); EXPECT_TRUE(engine->IsEnabled()); + EXPECT_TRUE(engine->IsLoaded()); engine->AddResourcePath("none"); diff --git a/src/RenderPassSystem.cc b/src/RenderPassSystem.cc index 5d4116d39..ef16bca0d 100644 --- a/src/RenderPassSystem.cc +++ b/src/RenderPassSystem.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/RenderPassSystem.hh" +#include "gz/rendering/RenderPassSystem.hh" -using namespace ignition; +using namespace gz; using namespace rendering; /// \brief Private implementation of the RenderPassSystem class -class ignition::rendering::RenderPassSystemPrivate +class gz::rendering::RenderPassSystemPrivate { }; diff --git a/src/RenderPassSystem_TEST.cc b/src/RenderPassSystem_TEST.cc index eff503b6d..bc92b49e8 100644 --- a/src/RenderPassSystem_TEST.cc +++ b/src/RenderPassSystem_TEST.cc @@ -17,16 +17,16 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/DistortionPass.hh" -#include "ignition/rendering/GaussianNoisePass.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderPassSystem.hh" +#include "gz/rendering/DistortionPass.hh" +#include "gz/rendering/GaussianNoisePass.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderPassSystem.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class RenderPassSystemTest : public testing::Test, diff --git a/src/RenderTarget_TEST.cc b/src/RenderTarget_TEST.cc index 61cee8af7..9e3aadd1e 100644 --- a/src/RenderTarget_TEST.cc +++ b/src/RenderTarget_TEST.cc @@ -17,19 +17,19 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GaussianNoisePass.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/RenderTarget.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GaussianNoisePass.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/RenderTarget.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class RenderTargetTest : public testing::Test, diff --git a/src/RenderingIface.cc b/src/RenderingIface.cc index b4b586670..48b6727ce 100644 --- a/src/RenderingIface.cc +++ b/src/RenderingIface.cc @@ -15,12 +15,12 @@ * */ -#include "ignition/common/Console.hh" +#include "gz/common/Console.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderEngineManager.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderEngineManager.hh" +#include "gz/rendering/Scene.hh" namespace ignition { @@ -129,7 +129,7 @@ void setPluginPaths(const std::list &_paths) ////////////////////////////////////////////////// ScenePtr sceneFromFirstRenderEngine() { - auto loadedEngNames = ignition::rendering::loadedEngines(); + auto loadedEngNames = gz::rendering::loadedEngines(); if (loadedEngNames.empty()) { igndbg << "No rendering engine is loaded yet" << std::endl; @@ -143,7 +143,7 @@ ScenePtr sceneFromFirstRenderEngine() << "Using engine [" << engineName << "]" << std::endl; } - auto engine = ignition::rendering::engine(engineName); + auto engine = gz::rendering::engine(engineName); if (!engine) { ignerr << "Internal error: failed to load engine [" << engineName diff --git a/src/RenderingIface_TEST.cc b/src/RenderingIface_TEST.cc index 999ff536d..971afd4fb 100644 --- a/src/RenderingIface_TEST.cc +++ b/src/RenderingIface_TEST.cc @@ -19,13 +19,13 @@ #include "test_config.h" // NOLINT(build/include) -#include +#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ///////////////////////////////////////////////// diff --git a/src/Scene_TEST.cc b/src/Scene_TEST.cc index fa9f4fb98..3ec781015 100644 --- a/src/Scene_TEST.cc +++ b/src/Scene_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderTarget.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderTarget.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class SceneTest : public testing::Test, @@ -52,6 +52,10 @@ class SceneTest : public testing::Test, /// \brief Test creating and destroying materials public: void Materials(const std::string &_renderEngine); + public: const std::string TEST_MEDIA_PATH = + common::joinPaths(std::string(PROJECT_SOURCE_PATH), + "test", "media", "skeleton"); + /// \brief Test setting and getting Time public: void Time(const std::string &_renderEngine); @@ -87,7 +91,7 @@ void SceneTest::Scene(const std::string &_renderEngine) // TODO(anyone) gradient background color and render window only supported // by ogre - if (_renderEngine == "ogre") + if (_renderEngine == "ogre2") { EXPECT_FALSE(scene->IsGradientBackgroundColor()); @@ -456,7 +460,81 @@ void SceneTest::DestroyNodes(const std::string &_renderEngine) EXPECT_FALSE(scene->HasVisual(childB)); EXPECT_FALSE(scene->HasVisual(childAA)); + auto gizmoVisual = scene->CreateGizmoVisual("gizmo_visual"); + auto planeVisual = scene->CreatePlane(); + auto meshVisual = scene->CreateMesh( + common::joinPaths(TEST_MEDIA_PATH, "walk.dae")); + + common::MeshPtr mesh(new common::Mesh()); + meshVisual = scene->CreateMesh(mesh.get()); + + scene->DestroyVisuals(); + + common::Material mat(math::Color(1.0f, 0.5f, 0.2f, 1.0f)); + auto materialVisual = scene->CreateMaterial(mat); + scene->DestroyMaterial(materialVisual); + scene->DestroyMaterial(MaterialPtr()); + + auto depthCameraSensor = scene->CreateDepthCamera(); + scene->DestroySensors(); + depthCameraSensor = scene->CreateDepthCamera("camera_depth"); + scene->DestroySensorByName("camera_depth"); + depthCameraSensor = scene->CreateDepthCamera("camera_depth"); + EXPECT_FALSE(scene->HasSensor(ConstSensorPtr())); + EXPECT_FALSE(scene->HasSensorId(8)); + EXPECT_FALSE(scene->HasSensorName("invalid")); + EXPECT_TRUE(scene->HasSensorName("camera_depth")); + + auto dCSensor = scene->SensorByName("camera_depth"); + EXPECT_TRUE(scene->HasSensor(dCSensor)); + EXPECT_TRUE(scene->HasSensorName("camera_depth")); + scene->DestroySensor(dCSensor, false); + + depthCameraSensor = scene->CreateDepthCamera(76); + dCSensor = scene->SensorById(76); + EXPECT_TRUE(scene->HasSensor(dCSensor)); + EXPECT_TRUE(scene->HasSensorId(76)); + scene->DestroySensor(dCSensor, true); + + depthCameraSensor = scene->CreateDepthCamera(76); + scene->DestroySensorById(76); + + depthCameraSensor = scene->CreateDepthCamera(); + scene->DestroySensorByIndex(0); + + // lights + auto spotLight = scene->CreateSpotLight(); + auto pointLight = scene->CreatePointLight("point_light"); + auto directionalLight = scene->CreateDirectionalLight(99); + + auto directionalLight2 = scene->LightById(99); + EXPECT_EQ(directionalLight, directionalLight2); + + auto directionalLight3 = scene->CreateDirectionalLight("directional_light"); + + auto pointLight2 = scene->LightByName("point_light"); + EXPECT_EQ(pointLight, pointLight2); + + scene->DestroyLightByIndex(0); + scene->DestroyLight(pointLight, true); + scene->DestroyLights(); + + spotLight = scene->CreateSpotLight(); + scene->DestroyNodeByIndex(0); + + spotLight = scene->CreateSpotLight("light_node"); + scene->DestroyNodeByName("light_node"); + + spotLight = scene->CreateSpotLight(56); + scene->DestroyNodeById(56); + EXPECT_EQ(0u, scene->VisualCount()); + EXPECT_EQ(0u, scene->SensorCount()); + EXPECT_EQ(0u, scene->LightCount()); + + EXPECT_EQ(std::chrono::milliseconds(0), scene->Time()); + scene->SetTime(std::chrono::milliseconds(3550)); + EXPECT_EQ(std::chrono::milliseconds(3550), scene->Time()); // Clean up engine->DestroyScene(scene); diff --git a/src/ShaderParam.cc b/src/ShaderParam.cc index 00f13a846..4e07e274b 100644 --- a/src/ShaderParam.cc +++ b/src/ShaderParam.cc @@ -15,12 +15,12 @@ * */ -#include "ignition/rendering/ShaderParam.hh" +#include "gz/rendering/ShaderParam.hh" -using namespace ignition::rendering; +using namespace gz::rendering; -class ignition::rendering::ShaderParamPrivate +class gz::rendering::ShaderParamPrivate { /// \brief Type of parameter held public: ShaderParam::ParamType type = ShaderParam::PARAM_NONE; diff --git a/src/ShaderParam_TEST.cc b/src/ShaderParam_TEST.cc index 3e91702bd..6b2181c4e 100644 --- a/src/ShaderParam_TEST.cc +++ b/src/ShaderParam_TEST.cc @@ -17,9 +17,9 @@ #include -#include "ignition/rendering/ShaderParam.hh" +#include "gz/rendering/ShaderParam.hh" -using namespace ignition::rendering; +using namespace gz::rendering; ///////////////////////////////////////////////// diff --git a/src/ShaderParams.cc b/src/ShaderParams.cc index 3f59c08cb..336473a49 100644 --- a/src/ShaderParams.cc +++ b/src/ShaderParams.cc @@ -15,14 +15,14 @@ * */ -#include "ignition/rendering/ShaderParams.hh" +#include "gz/rendering/ShaderParams.hh" #include -using namespace ignition::rendering; +using namespace gz::rendering; -class ignition::rendering::ShaderParamsPrivate +class gz::rendering::ShaderParamsPrivate { /// \brief collection of parameters public: std::unordered_map parameters; @@ -32,7 +32,7 @@ class ignition::rendering::ShaderParamsPrivate }; -class ignition::rendering::ShaderParams::IteratorPrivate +class gz::rendering::ShaderParams::IteratorPrivate { /// \brief Iterator from the map in ShaderParamsPrivate public: std::unordered_map::const_iterator iter; diff --git a/src/ShaderParams_TEST.cc b/src/ShaderParams_TEST.cc index 3b824a0cf..31e7acbec 100644 --- a/src/ShaderParams_TEST.cc +++ b/src/ShaderParams_TEST.cc @@ -17,9 +17,9 @@ #include -#include "ignition/rendering/ShaderParams.hh" +#include "gz/rendering/ShaderParams.hh" -using namespace ignition::rendering; +using namespace gz::rendering; ///////////////////////////////////////////////// @@ -73,6 +73,30 @@ TEST(ShaderParams, ConstRangeForLoopDoesNotDirty) EXPECT_FALSE(params.IsDirty()); } +///////////////////////////////////////////////// +TEST(ShaderParams, Iterator) +{ + ShaderParams params; + params["some_parameter"] = 4.0f; + params["some_parameter2"] = 4.1f; + auto iterator = params.begin(); + auto iteratorCopy = iterator; + EXPECT_TRUE(iterator == params.begin()); + EXPECT_EQ(iteratorCopy->first, iterator->first); + EXPECT_EQ("some_parameter2", iterator->first); + EXPECT_EQ(ShaderParam::PARAM_FLOAT, iterator->second.Type()); + float val; + EXPECT_TRUE(iterator->second.Value(&val)); + EXPECT_FLOAT_EQ(4.1f, val); + + iterator++; + EXPECT_EQ("some_parameter", iterator->first); + EXPECT_EQ(ShaderParam::PARAM_FLOAT, iterator->second.Type()); + EXPECT_TRUE(iterator->second.Value(&val)); + EXPECT_FLOAT_EQ(4.0f, val); +} + + ////////////////////////////////////////////////// int main(int argc, char **argv) { diff --git a/src/ShaderType.cc b/src/ShaderType.cc index 5b175a3b3..81b3c2c17 100644 --- a/src/ShaderType.cc +++ b/src/ShaderType.cc @@ -15,11 +15,11 @@ * */ -#include +#include -#include "ignition/rendering/ShaderType.hh" +#include "gz/rendering/ShaderType.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/Text_TEST.cc b/src/Text_TEST.cc index 63f44f396..1eafe7472 100644 --- a/src/Text_TEST.cc +++ b/src/Text_TEST.cc @@ -16,15 +16,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Text.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Text.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class TextTest : public testing::Test, diff --git a/src/ThermalCamera_TEST.cc b/src/ThermalCamera_TEST.cc index 29a57724a..fdbe14dc5 100644 --- a/src/ThermalCamera_TEST.cc +++ b/src/ThermalCamera_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/ThermalCamera.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/ThermalCamera.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class ThermalCameraTest : public testing::Test, diff --git a/src/TransformController.cc b/src/TransformController.cc index 03ba26385..c9a1cf4a3 100644 --- a/src/TransformController.cc +++ b/src/TransformController.cc @@ -15,17 +15,17 @@ * */ -#include -#include +#include +#include -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GizmoVisual.hh" -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/TransformController.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GizmoVisual.hh" +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/TransformController.hh" /// \brief Private data class for TransformController -class ignition::rendering::TransformControllerPrivate +class gz::rendering::TransformControllerPrivate { /// \brief Gizmo visual that provides translation, rotation, and scale /// tandles for transformation @@ -48,21 +48,21 @@ class ignition::rendering::TransformControllerPrivate public: RayQueryPtr ray; /// \brief Current active axis of transformation - public: ignition::math::Vector3d axis; + public: gz::math::Vector3d axis; /// \brief Flag to indicate that transfomation is in progress. public: bool active = false; /// \brief Initial pose of the node being transformed. /// This is set in Start(); - public: ignition::math::Pose3d nodeStartPose; + public: gz::math::Pose3d nodeStartPose; /// \brief Initial scale of the node being transformed. /// This is set in Start(); - public: ignition::math::Vector3d nodeStartScale; + public: gz::math::Vector3d nodeStartScale; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/TransformController_TEST.cc b/src/TransformController_TEST.cc index eb25bdfdb..9b71e8185 100644 --- a/src/TransformController_TEST.cc +++ b/src/TransformController_TEST.cc @@ -17,17 +17,17 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/TransformController.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/TransformController.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class TransformControllerTest : public testing::Test, diff --git a/src/Utils.cc b/src/Utils.cc index dc2260a36..39154dd29 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -20,13 +20,13 @@ #include #endif -#include "ignition/math/Plane.hh" -#include "ignition/math/Vector2.hh" -#include "ignition/math/Vector3.hh" +#include "gz/math/Plane.hh" +#include "gz/math/Vector2.hh" +#include "gz/math/Vector3.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/Utils.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/Utils.hh" namespace ignition { @@ -91,7 +91,7 @@ math::Vector3d screenToPlane( _rayQuery->SetFromCamera( _camera, math::Vector2d(nx, ny)); - ignition::math::Planed plane(ignition::math::Vector3d(0, 0, 1), offset); + gz::math::Planed plane(gz::math::Vector3d(0, 0, 1), offset); math::Vector3d origin = _rayQuery->Origin(); math::Vector3d direction = _rayQuery->Direction(); diff --git a/src/Utils_TEST.cc b/src/Utils_TEST.cc index 6f06aef7e..4f673baef 100644 --- a/src/Utils_TEST.cc +++ b/src/Utils_TEST.cc @@ -15,19 +15,19 @@ */ #include -#include +#include -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Utils.hh" -#include "ignition/rendering/Visual.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Utils.hh" +#include "gz/rendering/Visual.hh" #include "test_config.h" // NOLINT(build/include) -using namespace ignition; +using namespace gz; using namespace rendering; class UtilTest : public testing::Test, diff --git a/src/Visual_TEST.cc b/src/Visual_TEST.cc index cf86da5d2..797a6cc1c 100644 --- a/src/Visual_TEST.cc +++ b/src/Visual_TEST.cc @@ -18,18 +18,18 @@ #include #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Visual.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Visual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class VisualTest : public testing::Test, diff --git a/src/base/BaseObject.cc b/src/base/BaseObject.cc index d27bcaa67..b00a5e987 100644 --- a/src/base/BaseObject.cc +++ b/src/base/BaseObject.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/base/BaseObject.hh" +#include "gz/rendering/base/BaseObject.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/base/BaseRenderEngine.cc b/src/base/BaseRenderEngine.cc index 9e05657fb..24f36779e 100644 --- a/src/base/BaseRenderEngine.cc +++ b/src/base/BaseRenderEngine.cc @@ -15,12 +15,12 @@ * */ -#include +#include -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/base/BaseRenderEngine.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/base/BaseRenderEngine.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/base/BaseScene.cc b/src/base/BaseScene.cc index f536d5bd3..59c809f6d 100644 --- a/src/base/BaseScene.cc +++ b/src/base/BaseScene.cc @@ -17,39 +17,39 @@ #include -#include - -#include -#include -#include - -#include "ignition/common/Time.hh" - -#include "ignition/rendering/ArrowVisual.hh" -#include "ignition/rendering/AxisVisual.hh" -#include "ignition/rendering/BoundingBoxCamera.hh" -#include "ignition/rendering/COMVisual.hh" -#include "ignition/rendering/InertiaVisual.hh" -#include "ignition/rendering/JointVisual.hh" -#include "ignition/rendering/LidarVisual.hh" -#include "ignition/rendering/LightVisual.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Capsule.hh" -#include "ignition/rendering/DepthCamera.hh" -#include "ignition/rendering/GizmoVisual.hh" -#include "ignition/rendering/GpuRays.hh" -#include "ignition/rendering/Grid.hh" -#include "ignition/rendering/ParticleEmitter.hh" -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/RenderTarget.hh" -#include "ignition/rendering/Text.hh" -#include "ignition/rendering/ThermalCamera.hh" -#include "ignition/rendering/SegmentationCamera.hh" -#include "ignition/rendering/Visual.hh" -#include "ignition/rendering/base/BaseStorage.hh" -#include "ignition/rendering/base/BaseScene.hh" - -using namespace ignition; +#include + +#include +#include +#include + +#include "gz/common/Time.hh" + +#include "gz/rendering/ArrowVisual.hh" +#include "gz/rendering/AxisVisual.hh" +#include "gz/rendering/BoundingBoxCamera.hh" +#include "gz/rendering/COMVisual.hh" +#include "gz/rendering/InertiaVisual.hh" +#include "gz/rendering/JointVisual.hh" +#include "gz/rendering/LidarVisual.hh" +#include "gz/rendering/LightVisual.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Capsule.hh" +#include "gz/rendering/DepthCamera.hh" +#include "gz/rendering/GizmoVisual.hh" +#include "gz/rendering/GpuRays.hh" +#include "gz/rendering/Grid.hh" +#include "gz/rendering/ParticleEmitter.hh" +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/RenderTarget.hh" +#include "gz/rendering/Text.hh" +#include "gz/rendering/ThermalCamera.hh" +#include "gz/rendering/SegmentationCamera.hh" +#include "gz/rendering/Visual.hh" +#include "gz/rendering/base/BaseStorage.hh" +#include "gz/rendering/base/BaseScene.hh" + +using namespace gz; using namespace rendering; // Prevent deprecation warnings for simTime diff --git a/test/integration/camera.cc b/test/integration/camera.cc index b801964ea..5e9f19397 100644 --- a/test/integration/camera.cc +++ b/test/integration/camera.cc @@ -17,22 +17,21 @@ #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GpuRays.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/SegmentationCamera.hh" -#include "ignition/rendering/ShaderParams.hh" -#include "ignition/rendering/ThermalCamera.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GpuRays.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/SegmentationCamera.hh" +#include "gz/rendering/ShaderParams.hh" +#include "gz/rendering/ThermalCamera.hh" - -using namespace ignition; +using namespace gz; using namespace rendering; class CameraTest: public testing::Test, diff --git a/test/integration/deprecated_TEST.cc b/test/integration/deprecated_TEST.cc new file mode 100644 index 000000000..c38c5ad83 --- /dev/null +++ b/test/integration/deprecated_TEST.cc @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include +#include + +///////////////////////////////////////////////// +// Make sure the ignition namespace still works +TEST(Deprecated, IgnitionNamespace) +{ + ignition::camera::Camera camera; +} diff --git a/test/integration/depth_camera.cc b/test/integration/depth_camera.cc index d5c0ebd8a..f442cccfd 100644 --- a/test/integration/depth_camera.cc +++ b/test/integration/depth_camera.cc @@ -17,17 +17,17 @@ #include -#include -#include -#include +#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/DepthCamera.hh" -#include "ignition/rendering/ParticleEmitter.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/DepthCamera.hh" +#include "gz/rendering/ParticleEmitter.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" #define DEPTH_TOL 1e-4 #define DOUBLE_TOL 1e-6 @@ -76,7 +76,7 @@ void DepthCameraTest::DepthCameraBoxes( double aspectRatio_ = imgWidth_/imgHeight_; double unitBoxSize = 1.0; - ignition::math::Vector3d boxPosition(1.8, 0.0, 0.0); + gz::math::Vector3d boxPosition(1.8, 0.0, 0.0); // Optix is not supported if (_renderEngine.compare("optix") == 0) @@ -87,7 +87,7 @@ void DepthCameraTest::DepthCameraBoxes( } // Setup ign-rendering with an empty scene - auto *engine = ignition::rendering::engine(_renderEngine); + auto *engine = gz::rendering::engine(_renderEngine); if (!engine) { igndbg << "Engine '" << _renderEngine @@ -95,7 +95,7 @@ void DepthCameraTest::DepthCameraBoxes( return; } - ignition::rendering::ScenePtr scene = engine->CreateScene("scene"); + gz::rendering::ScenePtr scene = engine->CreateScene("scene"); // red background scene->SetBackgroundColor(1.0, 0.0, 0.0); @@ -107,16 +107,16 @@ void DepthCameraTest::DepthCameraBoxes( // Create an scene with a box in it scene->SetAmbientLight(1.0, 1.0, 1.0); - ignition::rendering::VisualPtr root = scene->RootVisual(); + gz::rendering::VisualPtr root = scene->RootVisual(); // create blue material - ignition::rendering::MaterialPtr blue = scene->CreateMaterial(); + gz::rendering::MaterialPtr blue = scene->CreateMaterial(); blue->SetAmbient(0.0, 0.0, 1.0); blue->SetDiffuse(0.0, 0.0, 1.0); blue->SetSpecular(0.0, 0.0, 1.0); // create box visual - ignition::rendering::VisualPtr box = scene->CreateVisual(); + gz::rendering::VisualPtr box = scene->CreateVisual(); box->AddGeometry(scene->CreateBox()); box->SetOrigin(0.0, 0.0, 0.0); box->SetLocalPosition(boxPosition); @@ -132,8 +132,8 @@ void DepthCameraTest::DepthCameraBoxes( auto depthCamera = scene->CreateDepthCamera("DepthCamera"); ASSERT_NE(depthCamera, nullptr); - ignition::math::Pose3d testPose(ignition::math::Vector3d(0, 0, 0), - ignition::math::Quaterniond::Identity); + gz::math::Pose3d testPose(gz::math::Vector3d(0, 0, 0), + gz::math::Quaterniond::Identity); depthCamera->SetLocalPose(testPose); // Configure depth camera @@ -157,7 +157,7 @@ void DepthCameraTest::DepthCameraBoxes( // Set a callback on the camera sensor to get a depth camera frame float *scan = new float[imgHeight_ * imgWidth_]; - ignition::common::ConnectionPtr connection = + gz::common::ConnectionPtr connection = depthCamera->ConnectNewDepthFrame( std::bind(&::OnNewDepthFrame, scan, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, @@ -167,7 +167,7 @@ void DepthCameraTest::DepthCameraBoxes( unsigned int pointCloudChannelCount = 4u; float *pointCloudData = new float[ imgHeight_ * imgWidth_ * pointCloudChannelCount]; - ignition::common::ConnectionPtr connection2 = + gz::common::ConnectionPtr connection2 = depthCamera->ConnectNewRgbPointCloud( std::bind(&::OnNewRgbPointCloud, pointCloudData, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, @@ -200,8 +200,8 @@ void DepthCameraTest::DepthCameraBoxes( * (depthCamera->ImageWidth() * pointCloudChannelCount) - pointCloudChannelCount; - float minVal = -ignition::math::INF_D; - float maxVal = ignition::math::INF_D; + float minVal = -gz::math::INF_D; + float maxVal = gz::math::INF_D; // Verify Depth // Depth sensor should see box in the middle of the image @@ -297,7 +297,7 @@ void DepthCameraTest::DepthCameraBoxes( } // Check that for a box really close it returns it is not seen - ignition::math::Vector3d boxPositionNear( + gz::math::Vector3d boxPositionNear( unitBoxSize * 0.5 + nearDist * 0.5, 0.0, 0.0); box->SetLocalPosition(boxPositionNear); @@ -354,7 +354,7 @@ void DepthCameraTest::DepthCameraBoxes( } // Check that for a box really far it returns max val - ignition::math::Vector3d boxPositionFar( + gz::math::Vector3d boxPositionFar( unitBoxSize * 0.5 + farDist * 1.5, 0.0, 0.0); box->SetLocalPosition(boxPositionFar); @@ -413,7 +413,7 @@ void DepthCameraTest::DepthCameraBoxes( } // Check that the depth values for a box do not warp. - ignition::math::Vector3d boxPositionFillFrame( + gz::math::Vector3d boxPositionFillFrame( unitBoxSize * 0.5 + 0.2, 0.0, 0.0); box->SetLocalPosition(boxPositionFillFrame); @@ -476,10 +476,9 @@ void DepthCameraTest::DepthCameraBoxes( } engine->DestroyScene(scene); - ignition::rendering::unloadEngine(engine->Name()); + gz::rendering::unloadEngine(engine->Name()); } - void DepthCameraTest::DepthCameraParticles( const std::string &_renderEngine) { @@ -790,7 +789,7 @@ TEST_P(DepthCameraTest, DepthCameraParticles) } INSTANTIATE_TEST_CASE_P(DepthCamera, DepthCameraTest, - RENDER_ENGINE_VALUES, ignition::rendering::PrintToStringParam()); + RENDER_ENGINE_VALUES, gz::rendering::PrintToStringParam()); ////////////////////////////////////////////////// int main(int argc, char **argv) diff --git a/test/integration/gpu_rays.cc b/test/integration/gpu_rays.cc index 387dd5e16..6d7b8090f 100644 --- a/test/integration/gpu_rays.cc +++ b/test/integration/gpu_rays.cc @@ -17,19 +17,19 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/GpuRays.hh" -#include "ignition/rendering/Heightmap.hh" -#include "ignition/rendering/ParticleEmitter.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/GpuRays.hh" +#include "gz/rendering/Heightmap.hh" +#include "gz/rendering/ParticleEmitter.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" #define LASER_TOL 2e-4 #define DOUBLE_TOL 1e-6 @@ -39,7 +39,7 @@ #define WAIT_TIME 0.02 -using namespace ignition; +using namespace gz; using namespace rendering; void OnNewGpuRaysFrame(float *_scanDest, const float *_scan, diff --git a/test/integration/render_pass.cc b/test/integration/render_pass.cc index 566784138..61431e795 100644 --- a/test/integration/render_pass.cc +++ b/test/integration/render_pass.cc @@ -17,21 +17,21 @@ #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/DepthCamera.hh" -#include "ignition/rendering/DistortionPass.hh" -#include "ignition/rendering/GaussianNoisePass.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/DepthCamera.hh" +#include "gz/rendering/DistortionPass.hh" +#include "gz/rendering/GaussianNoisePass.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/Scene.hh" #define DOUBLE_TOL 1e-6 unsigned int g_pointCloudCounter = 0; @@ -46,7 +46,7 @@ void OnNewRgbPointCloud(float *_scanDest, const float *_scan, memcpy(_scanDest, _scan, size * sizeof(f)); g_pointCloudCounter++; } -using namespace ignition; +using namespace gz; using namespace rendering; class RenderPassTest: public testing::Test, diff --git a/test/integration/scene.cc b/test/integration/scene.cc index 88485ce8b..1e4a3ed10 100644 --- a/test/integration/scene.cc +++ b/test/integration/scene.cc @@ -17,16 +17,16 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class SceneTest: public testing::Test, diff --git a/test/integration/shadows.cc b/test/integration/shadows.cc index 40dd10d16..f1f7c43f7 100644 --- a/test/integration/shadows.cc +++ b/test/integration/shadows.cc @@ -17,19 +17,19 @@ #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class ShadowsTest: public testing::Test, diff --git a/test/integration/thermal_camera.cc b/test/integration/thermal_camera.cc index 0301da5cf..3153006d2 100644 --- a/test/integration/thermal_camera.cc +++ b/test/integration/thermal_camera.cc @@ -17,21 +17,21 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/ParticleEmitter.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/ThermalCamera.hh" +#include "gz/rendering/ParticleEmitter.hh" +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/ThermalCamera.hh" #define DEPTH_TOL 1e-4 #define DOUBLE_TOL 1e-6 @@ -78,7 +78,7 @@ class ThermalCameraTest: public testing::Test, // Documentation inherited protected: void SetUp() override { - ignition::common::Console::SetVerbosity(4); + gz::common::Console::SetVerbosity(4); } }; @@ -91,7 +91,7 @@ void ThermalCameraTest::ThermalCameraBoxes( double aspectRatio = imgWidth/imgHeight; double unitBoxSize = 1.0; - ignition::math::Vector3d boxPosition(1.8, 0.0, 0.0); + gz::math::Vector3d boxPosition(1.8, 0.0, 0.0); // Optix is not supported if (_renderEngine.compare("optix") == 0) @@ -109,7 +109,7 @@ void ThermalCameraTest::ThermalCameraBoxes( } // Setup ign-rendering with an empty scene - auto *engine = ignition::rendering::engine(_renderEngine); + auto *engine = gz::rendering::engine(_renderEngine); if (!engine) { igndbg << "Engine '" << _renderEngine @@ -117,17 +117,17 @@ void ThermalCameraTest::ThermalCameraBoxes( return; } - ignition::rendering::ScenePtr scene = engine->CreateScene("scene"); + gz::rendering::ScenePtr scene = engine->CreateScene("scene"); // red background scene->SetBackgroundColor(1.0, 0.0, 0.0); // Create an scene with a box in it scene->SetAmbientLight(1.0, 1.0, 1.0); - ignition::rendering::VisualPtr root = scene->RootVisual(); + gz::rendering::VisualPtr root = scene->RootVisual(); // create box visual - ignition::rendering::VisualPtr box = scene->CreateVisual(); + gz::rendering::VisualPtr box = scene->CreateVisual(); box->AddGeometry(scene->CreateBox()); box->SetOrigin(0.0, 0.0, 0.0); box->SetLocalPosition(boxPosition); @@ -160,8 +160,8 @@ void ThermalCameraTest::ThermalCameraBoxes( auto thermalCamera = scene->CreateThermalCamera("ThermalCamera"); ASSERT_NE(thermalCamera, nullptr); - ignition::math::Pose3d testPose(ignition::math::Vector3d(0, 0, 0), - ignition::math::Quaterniond::Identity); + gz::math::Pose3d testPose(gz::math::Vector3d(0, 0, 0), + gz::math::Quaterniond::Identity); thermalCamera->SetLocalPose(testPose); // Configure thermal camera @@ -197,7 +197,7 @@ void ThermalCameraTest::ThermalCameraBoxes( // Set a callback on the camera sensor to get a thermal camera frame uint16_t *thermalData = new uint16_t[imgHeight * imgWidth]; - ignition::common::ConnectionPtr connection = + gz::common::ConnectionPtr connection = thermalCamera->ConnectNewThermalFrame( std::bind(&::OnNewThermalFrame, thermalData, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, @@ -226,7 +226,7 @@ void ThermalCameraTest::ThermalCameraBoxes( // move box in front of near clip plane and verify the thermal // image returns all box temperature values - ignition::math::Vector3d boxPositionNear( + gz::math::Vector3d boxPositionNear( unitBoxSize * 0.5 + nearDist * 0.5, 0.0, 0.0); box->SetLocalPosition(boxPositionNear); thermalCamera->Update(); @@ -246,7 +246,7 @@ void ThermalCameraTest::ThermalCameraBoxes( // move box beyond far clip plane and verify the thermal // image returns all ambient temperature values - ignition::math::Vector3d boxPositionFar( + gz::math::Vector3d boxPositionFar( unitBoxSize * 0.5 + farDist * 1.5, 0.0, 0.0); box->SetLocalPosition(boxPositionFar); thermalCamera->Update(); @@ -267,7 +267,7 @@ void ThermalCameraTest::ThermalCameraBoxes( } engine->DestroyScene(scene); - ignition::rendering::unloadEngine(engine->Name()); + gz::rendering::unloadEngine(engine->Name()); } ////////////////////////////////////////////////// @@ -652,7 +652,7 @@ TEST_P(ThermalCameraTest, ThermalCameraParticles) } INSTANTIATE_TEST_CASE_P(ThermalCamera, ThermalCameraTest, - RENDER_ENGINE_VALUES, ignition::rendering::PrintToStringParam()); + RENDER_ENGINE_VALUES, gz::rendering::PrintToStringParam()); ////////////////////////////////////////////////// int main(int argc, char **argv) diff --git a/test/performance/scene_factory.cc b/test/performance/scene_factory.cc index 99f8aff31..334cd50e6 100644 --- a/test/performance/scene_factory.cc +++ b/test/performance/scene_factory.cc @@ -22,15 +22,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; diff --git a/test/test_config.h.in b/test/test_config.h.in index a8a651cd7..8297d3206 100644 --- a/test/test_config.h.in +++ b/test/test_config.h.in @@ -1,5 +1,5 @@ -#ifndef IGNITION_RENDERING_TEST_CONFIG_HH_ -#define IGNITION_RENDERING_TEST_CONFIG_HH_ +#ifndef GZ_RENDERING_TEST_CONFIG_HH_ +#define GZ_RENDERING_TEST_CONFIG_HH_ #define PROJECT_SOURCE_PATH "${PROJECT_SOURCE_DIR}" #define PROJECT_BUILD_PATH "${PROJECT_BINARY_DIR}" @@ -7,7 +7,7 @@ /// \brief Helper macro to instantiate gtest for different engines #define RENDER_ENGINE_VALUES ::testing::ValuesIn(\ - ignition::rendering::TestValues()) + gz::rendering::TestValues()) /// \todo(anyone) re-enable ogre2 test once ogre 2.2 works on macOS #ifdef __APPLE__ @@ -17,7 +17,7 @@ static const std::vector kRenderEngineTestValues{"ogre2", "optix"} #endif #include -#include +#include namespace ignition { diff --git a/tutorials/03_rendering_plugins.md b/tutorials/03_rendering_plugins.md index 74571add2..0673cc5d9 100644 --- a/tutorials/03_rendering_plugins.md +++ b/tutorials/03_rendering_plugins.md @@ -4,25 +4,25 @@ This is an introduction to different rendering engines and how they are integrat ## Ignition Rendering -The \ref ignition::rendering "Ignition Rendering" library integrates external rendering engines into the Ignition Simulation eco-system. +The \ref gz::rendering "Ignition Rendering" library integrates external rendering engines into the Ignition Simulation eco-system. It allows users to select from multiple supported rendering engines based on their simulation needs. Its plugin interface loads rendering engines at runtime. It is also possible to integrate your own selected rendering engine by writing a compatible plugin interface. #### How to Write Your Own Rendering Engine Plugin -A mocked example of a custom rendering engine plugin can be found [here](https://github.com/ignitionrobotics/ign-rendering/tree/main/examples/hello_world_plugin). In order +A mocked example of a custom rendering engine plugin can be found [here](https://github.com/gazebosim/gz-rendering/tree/main/examples/hello_world_plugin). In order to make your own custom rendering engine, this example is a good starting point. There are a few key things which will need to be done in order for a custom rendering engine to function: * A singleton Render Engine class which implements the pure virtual functions in [`ignition::rendering::BaseRenderEngine`](https://github.com/ignitionrobotics/ign-rendering/blob/main/include/ignition/rendering/base/BaseRenderEngine.hh). * A plugin class which implements the pure virtual functions in [`ignition::rendering::RenderEnginePlugin`](https://github.com/ignitionrobotics/ign-rendering/blob/main/include/ignition/rendering/RenderEnginePlugin.hh) - * Registering the plugin, this line can be seen at the bottom of the [`HelloWorldPlugin`](https://github.com/ignitionrobotics/ign-rendering/tree/main/examples/hello_world_plugin/HelloWorldPlugin.cc) example + * Registering the plugin, this line can be seen at the bottom of the [`HelloWorldPlugin`](https://github.com/gazebosim/gz-rendering/tree/main/examples/hello_world_plugin/HelloWorldPlugin.cc) example -Finally, for your custom rendering engine to actually have any functionality and at minimum, display something in a window, you will need to implement your own `Scene` and `Camera` classes, which inherit from and implement the pure virtual functions of [`ignition::rendering::Scene`](https://github.com/ignitionrobotics/ign-rendering/blob/main/include/ignition/rendering/Scene.hh) and [`ignition::rendering::Camera`](https://github.com/ignitionrobotics/ign-rendering/blob/main/include/ignition/rendering/Camera.hh), respectively. The mocked example simply returns `nullptr` for its `CreateSceneImpl(...)` function, so it may be useful to look at the current `Scene` implementations for the other rendering engines within `ignition::rendering` such as [`OGRE`](https://github.com/ignitionrobotics/ign-rendering/blob/main/ogre/src/OgreScene.cc) or [`OGRE2`](https://github.com/ignitionrobotics/ign-rendering/blob/main/ogre2/src/Ogre2Scene.cc). Likewise, it may be helpful to look at the `Camera` implementations from [`OGRE`](https://github.com/ignitionrobotics/ign-rendering/blob/main/ogre/src/OgreCamera.cc) and [`OGRE2`](https://github.com/ignitionrobotics/ign-rendering/blob/main/ogre2/src/Ogre2Camera.cc) +Finally, for your custom rendering engine to actually have any functionality and at minimum, display something in a window, you will need to implement your own `Scene` and `Camera` classes, which inherit from and implement the pure virtual functions of [`ignition::rendering::Scene`](https://github.com/gazebosim/gz-rendering/blob/main/include/ignition/rendering/Scene.hh) and [`gz::rendering::Camera`](https://github.com/gazebosim/gz-rendering/blob/main/include/ignition/rendering/Camera.hh), respectively. The mocked example simply returns `nullptr` for its `CreateSceneImpl(...)` function, so it may be useful to look at the current `Scene` implementations for the other rendering engines within `ignition::rendering` such as [`OGRE`](https://github.com/gazebosim/gz-rendering/blob/main/ogre/src/OgreScene.cc) or [`OGRE2`](https://github.com/gazebosim/gz-rendering/blob/main/ogre2/src/Ogre2Scene.cc). Likewise, it may be helpful to look at the `Camera` implementations from [`OGRE`](https://github.com/gazebosim/gz-rendering/blob/main/ogre/src/OgreCamera.cc) and [`OGRE2`](https://github.com/gazebosim/gz-rendering/blob/main/ogre2/src/Ogre2Camera.cc) #### Building and Running Your Rendering Engine Plugin with Ignition Gazebo -Once you have your own rendering plugin written, you can build it similarly to how the example is built. It may be helpful to look at the [`CMakeLists.txt`](https://github.com/ignitionrobotics/ign-rendering/tree/main/examples/hello_world_plugin) from the example as it contains the boilerplate code needed to get a custom rendering engine plugin built. +Once you have your own rendering plugin written, you can build it similarly to how the example is built. It may be helpful to look at the [`CMakeLists.txt`](https://github.com/gazebosim/gz-rendering/tree/main/examples/hello_world_plugin) from the example as it contains the boilerplate code needed to get a custom rendering engine plugin built. After you have your plugin built, you will need to set the `IGN_GAZEBO_RENDER_ENGINE_PATH` environment variable to the path in which your built shared library resides. Note that you will need to do this for every command line instance unless you add the line to your startup shell script (`.bashrc`, `.zshrc`, etc.).