diff --git a/CMakeLists.txt b/CMakeLists.txt index b0c7777d7..cb315e819 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,9 +15,7 @@ set(IGN_CMAKE_VER ${ignition-cmake3_VERSION_MAJOR}) #============================================================================ # Set up the project #============================================================================ -ign_configure_project( - REPLACE_IGNITION_INCLUDE_PATH gz/rendering - VERSION_SUFFIX pre1) +ign_configure_project(VERSION_SUFFIX pre1) #============================================================================ # Set project-specific options diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index f9968f12c..2a7d5cedf 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -31,5 +31,5 @@ if (DOXYGEN_FOUND) COMMENT "Generating API documentation with Doxygen" VERBATIM) install(FILES ${CMAKE_BINARY_DIR}/doc/${PROJECT_NAME_LOWER}.tag.xml - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/gz/${PROJECT_NAME_LOWER}_${PROJECT_VERSION_MINOR}) + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/ignition/${PROJECT_NAME_LOWER}_${PROJECT_VERSION_MINOR}) endif() diff --git a/examples/actor_animation/GlutWindow.cc b/examples/actor_animation/GlutWindow.cc index 8b84a6f21..6f8d49ce4 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" diff --git a/examples/actor_animation/GlutWindow.hh b/examples/actor_animation/GlutWindow.hh index 9ee38c5f2..a96929771 100644 --- a/examples/actor_animation/GlutWindow.hh +++ b/examples/actor_animation/GlutWindow.hh @@ -14,12 +14,12 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" -#include "gz/common/graphics/Types.hh" +#include "ignition/rendering/RenderTypes.hh" +#include "ignition/common/graphics/Types.hh" namespace ir = ignition::rendering; namespace ic = ignition::common; diff --git a/examples/actor_animation/Main.cc b/examples/actor_animation/Main.cc index df03d3342..c204dc88e 100644 --- a/examples/actor_animation/Main.cc +++ b/examples/actor_animation/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" diff --git a/examples/camera_tracking/GlutWindow.cc b/examples/camera_tracking/GlutWindow.cc index a6df026cb..3ed256c0c 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" diff --git a/examples/camera_tracking/GlutWindow.hh b/examples/camera_tracking/GlutWindow.hh index 9526f565d..6396104d8 100644 --- a/examples/camera_tracking/GlutWindow.hh +++ b/examples/camera_tracking/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ #include -#include +#include namespace ir = ignition::rendering; diff --git a/examples/camera_tracking/Main.cc b/examples/camera_tracking/Main.cc index 688b5d09c..6aee947af 100644 --- a/examples/camera_tracking/Main.cc +++ b/examples/camera_tracking/Main.cc @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" using namespace ignition; diff --git a/examples/custom_scene_viewer/DemoWindow.cc b/examples/custom_scene_viewer/DemoWindow.cc index e0e926e97..95907ccd3 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" diff --git a/examples/custom_scene_viewer/DemoWindow.hh b/examples/custom_scene_viewer/DemoWindow.hh index 4313bc0de..46ddacf82 100644 --- a/examples/custom_scene_viewer/DemoWindow.hh +++ b/examples/custom_scene_viewer/DemoWindow.hh @@ -14,8 +14,8 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ #include "TestTypes.hh" diff --git a/examples/custom_scene_viewer/ManualSceneDemo.cc b/examples/custom_scene_viewer/ManualSceneDemo.cc index 726c7f656..2f2bdeb57 100644 --- a/examples/custom_scene_viewer/ManualSceneDemo.cc +++ b/examples/custom_scene_viewer/ManualSceneDemo.cc @@ -25,7 +25,7 @@ #endif #include -#include +#include #include "ManualSceneDemo.hh" #include "SceneBuilder.hh" #include "DemoWindow.hh" diff --git a/examples/custom_scene_viewer/ManualSceneDemo.hh b/examples/custom_scene_viewer/ManualSceneDemo.hh index 7dbc6ddf5..99a316864 100644 --- a/examples/custom_scene_viewer/ManualSceneDemo.hh +++ b/examples/custom_scene_viewer/ManualSceneDemo.hh @@ -14,12 +14,12 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ -#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ +#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ #include #include -#include +#include #include "TestTypes.hh" namespace ignition diff --git a/examples/custom_scene_viewer/SceneBuilder.hh b/examples/custom_scene_viewer/SceneBuilder.hh index 42362ccd9..9901b9c1e 100644 --- a/examples/custom_scene_viewer/SceneBuilder.hh +++ b/examples/custom_scene_viewer/SceneBuilder.hh @@ -14,8 +14,8 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ -#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ +#define IGNITION_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 41e1dd3ed..92c62a468 100644 --- a/examples/custom_scene_viewer/TestTypes.hh +++ b/examples/custom_scene_viewer/TestTypes.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ -#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ +#define IGNITION_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 fc163ea18..d9b359feb 100644 --- a/examples/custom_shaders/custom_shaders.cc +++ b/examples/custom_shaders/custom_shaders.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include -#include -#include +#include +#include +#include #include "example_config.hh" diff --git a/examples/custom_shaders_uniforms/GlutWindow.cc b/examples/custom_shaders_uniforms/GlutWindow.cc index be80661af..f9401780d 100644 --- a/examples/custom_shaders_uniforms/GlutWindow.cc +++ b/examples/custom_shaders_uniforms/GlutWindow.cc @@ -38,11 +38,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/custom_shaders_uniforms/GlutWindow.hh b/examples/custom_shaders_uniforms/GlutWindow.hh index bca604788..b12066e47 100644 --- a/examples/custom_shaders_uniforms/GlutWindow.hh +++ b/examples/custom_shaders_uniforms/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SHADERS_UNIFORMS_DEMO_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_CUSTOM_SHADERS_UNIFORMS_DEMO_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SHADERS_UNIFORMS_DEMO_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SHADERS_UNIFORMS_DEMO_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/custom_shaders_uniforms/Main.cc b/examples/custom_shaders_uniforms/Main.cc index 29add9698..fbc3cf745 100644 --- a/examples/custom_shaders_uniforms/Main.cc +++ b/examples/custom_shaders_uniforms/Main.cc @@ -33,8 +33,8 @@ #include #include -#include -#include +#include +#include #include "example_config.hh" diff --git a/examples/depth_camera/GlutWindow.cc b/examples/depth_camera/GlutWindow.cc index 07cc7a9c6..3f1488f0c 100644 --- a/examples/depth_camera/GlutWindow.cc +++ b/examples/depth_camera/GlutWindow.cc @@ -34,18 +34,18 @@ #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" diff --git a/examples/depth_camera/GlutWindow.hh b/examples/depth_camera/GlutWindow.hh index a8066f460..bf974b13d 100644 --- a/examples/depth_camera/GlutWindow.hh +++ b/examples/depth_camera/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_DEPTH_CAMERA_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_DEPTH_CAMERA_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_DEPTH_CAMERA_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_DEPTH_CAMERA_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/depth_camera/Main.cc b/examples/depth_camera/Main.cc index 2648049e2..d0ef5a9d5 100644 --- a/examples/depth_camera/Main.cc +++ b/examples/depth_camera/Main.cc @@ -28,9 +28,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" diff --git a/examples/gazebo_scene_viewer/CameraWindow.cc b/examples/gazebo_scene_viewer/CameraWindow.cc index 51990290e..f1c3004f4 100644 --- a/examples/gazebo_scene_viewer/CameraWindow.cc +++ b/examples/gazebo_scene_viewer/CameraWindow.cc @@ -33,9 +33,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "CameraWindow.hh" #include "SceneManager.hh" diff --git a/examples/gazebo_scene_viewer/CameraWindow.hh b/examples/gazebo_scene_viewer/CameraWindow.hh index 9b4479955..e751aad19 100644 --- a/examples/gazebo_scene_viewer/CameraWindow.hh +++ b/examples/gazebo_scene_viewer/CameraWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace gz = ignition::rendering; diff --git a/examples/gazebo_scene_viewer/GazeboDemo.cc b/examples/gazebo_scene_viewer/GazeboDemo.cc index 34acaf46b..2d7217f0b 100644 --- a/examples/gazebo_scene_viewer/GazeboDemo.cc +++ b/examples/gazebo_scene_viewer/GazeboDemo.cc @@ -28,11 +28,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "CameraWindow.hh" #include "SceneManager.hh" diff --git a/examples/gazebo_scene_viewer/GazeboWorldDemo.cc b/examples/gazebo_scene_viewer/GazeboWorldDemo.cc index 9d378b787..cf584a168 100644 --- a/examples/gazebo_scene_viewer/GazeboWorldDemo.cc +++ b/examples/gazebo_scene_viewer/GazeboWorldDemo.cc @@ -25,14 +25,14 @@ #endif #include -#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "CameraWindow.hh" #include "SceneManager.hh" diff --git a/examples/gazebo_scene_viewer/SceneManager.cc b/examples/gazebo_scene_viewer/SceneManager.cc index 89aa7249f..bf2840e5c 100644 --- a/examples/gazebo_scene_viewer/SceneManager.cc +++ b/examples/gazebo_scene_viewer/SceneManager.cc @@ -17,14 +17,14 @@ #include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include #include "SceneManager.hh" #include "SceneManagerPrivate.hh" diff --git a/examples/gazebo_scene_viewer/SceneManager.hh b/examples/gazebo_scene_viewer/SceneManager.hh index 8418c99f9..d0aa33e33 100644 --- a/examples/gazebo_scene_viewer/SceneManager.hh +++ b/examples/gazebo_scene_viewer/SceneManager.hh @@ -14,8 +14,8 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_SCENEMANAGER_HH -#define GZ_RENDERING_EXAMPLES_SCENEMANAGER_HH +#ifndef IGNITION_RENDERING_EXAMPLES_SCENEMANAGER_HH +#define IGNITION_RENDERING_EXAMPLES_SCENEMANAGER_HH #if __cplusplus > 201703L #include @@ -27,14 +27,14 @@ #endif #include -#include -#include "gz/rendering/RenderTypes.hh" +#include +#include "ignition/rendering/RenderTypes.hh" namespace ignition { namespace rendering { - /// \class SceneManager SceneManager.hh gz/rendering/SceneManager.hh + /// \class SceneManager SceneManager.hh ignition/rendering/SceneManager.hh /// \brief Manages a collection of scenes. The class provides a single /// interface for modifications, allowing multiple scenes to stay /// synchronized. This class currently consumes Gazebo-specific protobuf diff --git a/examples/gazebo_scene_viewer/SceneManagerPrivate.hh b/examples/gazebo_scene_viewer/SceneManagerPrivate.hh index 711b3988c..f98d1db5f 100644 --- a/examples/gazebo_scene_viewer/SceneManagerPrivate.hh +++ b/examples/gazebo_scene_viewer/SceneManagerPrivate.hh @@ -14,21 +14,21 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_SCENEMANAGERPRIVATE_HH -#define GZ_RENDERING_EXAMPLES_SCENEMANAGERPRIVATE_HH +#ifndef IGNITION_RENDERING_EXAMPLES_SCENEMANAGERPRIVATE_HH +#define IGNITION_RENDERING_EXAMPLES_SCENEMANAGERPRIVATE_HH #include #include #include #include -#include +#include -#include -#include +#include +#include -#include "gz/rendering/RenderTypes.hh" -#include "gz/rendering/ShaderType.hh" +#include "ignition/rendering/RenderTypes.hh" +#include "ignition/rendering/ShaderType.hh" #include "gazebo/transport/Node.hh" namespace ignition diff --git a/examples/heightmap/GlutWindow.cc b/examples/heightmap/GlutWindow.cc index 446d4bf89..7c869502e 100644 --- a/examples/heightmap/GlutWindow.cc +++ b/examples/heightmap/GlutWindow.cc @@ -31,12 +31,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/heightmap/GlutWindow.hh b/examples/heightmap/GlutWindow.hh index 71b4a73e3..2d8349ac3 100644 --- a/examples/heightmap/GlutWindow.hh +++ b/examples/heightmap/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_HEIGHTMAP_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_HEIGHTMAP_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_HEIGHTMAP_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_HEIGHTMAP_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/heightmap/Main.cc b/examples/heightmap/Main.cc index 72f140f43..c99150690 100644 --- a/examples/heightmap/Main.cc +++ b/examples/heightmap/Main.cc @@ -27,11 +27,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" diff --git a/examples/hello_world_plugin/HelloWorldPlugin.cc b/examples/hello_world_plugin/HelloWorldPlugin.cc index 761cede6b..361b43e3f 100644 --- a/examples/hello_world_plugin/HelloWorldPlugin.cc +++ b/examples/hello_world_plugin/HelloWorldPlugin.cc @@ -15,13 +15,13 @@ * */ -#include +#include -#include +#include -#include "gz/rendering/RenderEnginePlugin.hh" -#include "gz/rendering/base/BaseRenderEngine.hh" -#include "gz/rendering/base/BaseRenderTypes.hh" +#include "ignition/rendering/RenderEnginePlugin.hh" +#include "ignition/rendering/base/BaseRenderEngine.hh" +#include "ignition/rendering/base/BaseRenderTypes.hh" namespace mock { diff --git a/examples/lidar_visual/GlutWindow.cc b/examples/lidar_visual/GlutWindow.cc index 09870b5d8..51f51cdb7 100644 --- a/examples/lidar_visual/GlutWindow.cc +++ b/examples/lidar_visual/GlutWindow.cc @@ -34,14 +34,14 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace ignition; using namespace rendering; diff --git a/examples/lidar_visual/GlutWindow.hh b/examples/lidar_visual/GlutWindow.hh index 78ed13726..ea7d26a46 100644 --- a/examples/lidar_visual/GlutWindow.hh +++ b/examples/lidar_visual/GlutWindow.hh @@ -14,12 +14,12 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_LIDAR_VISUAL_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_LIDAR_VISUAL_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_LIDAR_VISUAL_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_LIDAR_VISUAL_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" -#include "gz/common/graphics/Types.hh" +#include "ignition/rendering/RenderTypes.hh" +#include "ignition/common/graphics/Types.hh" namespace ir = ignition::rendering; namespace ic = ignition::common; diff --git a/examples/lidar_visual/Main.cc b/examples/lidar_visual/Main.cc index 420d78db6..7765f45cc 100644 --- a/examples/lidar_visual/Main.cc +++ b/examples/lidar_visual/Main.cc @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" diff --git a/examples/mesh_viewer/GlutWindow.cc b/examples/mesh_viewer/GlutWindow.cc index 13ac9b6b7..d6eccb28d 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" diff --git a/examples/mesh_viewer/GlutWindow.hh b/examples/mesh_viewer/GlutWindow.hh index acd23cb69..6f410018a 100644 --- a/examples/mesh_viewer/GlutWindow.hh +++ b/examples/mesh_viewer/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/mesh_viewer/Main.cc b/examples/mesh_viewer/Main.cc index 154ed9d6a..dc102dba4 100644 --- a/examples/mesh_viewer/Main.cc +++ b/examples/mesh_viewer/Main.cc @@ -27,9 +27,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" diff --git a/examples/mouse_picking/GlutWindow.cc b/examples/mouse_picking/GlutWindow.cc index 382843f07..1cb83339e 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" diff --git a/examples/mouse_picking/GlutWindow.hh b/examples/mouse_picking/GlutWindow.hh index 5ccd67e3c..e81c7d1b1 100644 --- a/examples/mouse_picking/GlutWindow.hh +++ b/examples/mouse_picking/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/mouse_picking/Main.cc b/examples/mouse_picking/Main.cc index cf77c5948..b5fc9c192 100644 --- a/examples/mouse_picking/Main.cc +++ b/examples/mouse_picking/Main.cc @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/ogre2_demo/GlutWindow.cc b/examples/ogre2_demo/GlutWindow.cc index cac85aeea..44aab4f68 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" diff --git a/examples/ogre2_demo/GlutWindow.hh b/examples/ogre2_demo/GlutWindow.hh index c2cd028b2..1942a287e 100644 --- a/examples/ogre2_demo/GlutWindow.hh +++ b/examples/ogre2_demo/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/ogre2_demo/Main.cc b/examples/ogre2_demo/Main.cc index 7642d6739..8f942dc2a 100644 --- a/examples/ogre2_demo/Main.cc +++ b/examples/ogre2_demo/Main.cc @@ -27,9 +27,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" diff --git a/examples/particles_demo/GlutWindow.cc b/examples/particles_demo/GlutWindow.cc index 4225c6927..5a3644be6 100644 --- a/examples/particles_demo/GlutWindow.cc +++ b/examples/particles_demo/GlutWindow.cc @@ -31,12 +31,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/particles_demo/GlutWindow.hh b/examples/particles_demo/GlutWindow.hh index 916f8b91a..6f3395ffc 100644 --- a/examples/particles_demo/GlutWindow.hh +++ b/examples/particles_demo/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_PARTICLES_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_PARTICLES_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_PARTICLES_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_PARTICLES_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/particles_demo/Main.cc b/examples/particles_demo/Main.cc index 202c18375..4a12f32ec 100644 --- a/examples/particles_demo/Main.cc +++ b/examples/particles_demo/Main.cc @@ -27,9 +27,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" diff --git a/examples/render_pass/GlutWindow.cc b/examples/render_pass/GlutWindow.cc index c39c183d9..9887c8c92 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 3f9926476..b1610206c 100644 --- a/examples/render_pass/GlutWindow.hh +++ b/examples/render_pass/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/render_pass/Main.cc b/examples/render_pass/Main.cc index 958bf4c19..76498e7ad 100644 --- a/examples/render_pass/Main.cc +++ b/examples/render_pass/Main.cc @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/segmentation_camera/GlutWindow.cc b/examples/segmentation_camera/GlutWindow.cc index cb5803919..6fa050ffa 100644 --- a/examples/segmentation_camera/GlutWindow.cc +++ b/examples/segmentation_camera/GlutWindow.cc @@ -34,15 +34,15 @@ #include #include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/segmentation_camera/GlutWindow.hh b/examples/segmentation_camera/GlutWindow.hh index 5810db195..9500932dd 100644 --- a/examples/segmentation_camera/GlutWindow.hh +++ b/examples/segmentation_camera/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_SEGMENTATION_CAMERA_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_SEGMENTATION_CAMERA_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_SEGMENTATION_CAMERA_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_SEGMENTATION_CAMERA_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/segmentation_camera/Main.cc b/examples/segmentation_camera/Main.cc index c4853c862..2847b507a 100644 --- a/examples/segmentation_camera/Main.cc +++ b/examples/segmentation_camera/Main.cc @@ -28,9 +28,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" diff --git a/examples/simple_demo/GlutWindow.cc b/examples/simple_demo/GlutWindow.cc index bb13dcba8..4d0c9a27d 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 2b6bd0812..9dc770201 100644 --- a/examples/simple_demo/GlutWindow.hh +++ b/examples/simple_demo/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/simple_demo/Main.cc b/examples/simple_demo/Main.cc index bbf63002a..489d9533e 100644 --- a/examples/simple_demo/Main.cc +++ b/examples/simple_demo/Main.cc @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/simple_demo_qml/IgnitionRenderer.cc b/examples/simple_demo_qml/IgnitionRenderer.cc index 7f1667a72..5b25f3dfb 100644 --- a/examples/simple_demo_qml/IgnitionRenderer.cc +++ b/examples/simple_demo_qml/IgnitionRenderer.cc @@ -23,7 +23,7 @@ #include #include -#include +#include #include diff --git a/examples/simple_demo_qml/IgnitionRenderer.hh b/examples/simple_demo_qml/IgnitionRenderer.hh index 5d2e60bb9..6edd9172d 100644 --- a/examples/simple_demo_qml/IgnitionRenderer.hh +++ b/examples/simple_demo_qml/IgnitionRenderer.hh @@ -15,12 +15,12 @@ * */ -#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_QML_GZ_RENDERER_HH_ -#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_QML_GZ_RENDERER_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_QML_IGNITION_RENDERER_HH_ +#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_QML_IGNITION_RENDERER_HH_ #include -#include +#include /// \brief Ignition renderer class. This manages the initialisation /// and update of an Ignition rendering engine instance and makes the @@ -76,4 +76,4 @@ class IgnitionRenderer private: ignition::rendering::CameraPtr camera; }; -#endif // GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_QML_GZ_RENDERER_HH_ +#endif // IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_QML_IGNITION_RENDERER_HH_ diff --git a/examples/simple_demo_qml/ThreadRenderer.h b/examples/simple_demo_qml/ThreadRenderer.h index 0c66dd6c4..798fe6de4 100644 --- a/examples/simple_demo_qml/ThreadRenderer.h +++ b/examples/simple_demo_qml/ThreadRenderer.h @@ -68,8 +68,8 @@ ** ****************************************************************************/ -#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_QML_THREAD_RENDERER_HH_ -#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_QML_THREAD_RENDERER_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_QML_THREAD_RENDERER_HH_ +#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_QML_THREAD_RENDERER_HH_ #include "IgnitionRenderer.hh" @@ -170,4 +170,4 @@ public slots: RenderThread *renderThread = nullptr; }; -#endif // GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_THREAD_RENDERER_HH_ +#endif // IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_THREAD_RENDERER_HH_ diff --git a/examples/text_geom/GlutWindow.cc b/examples/text_geom/GlutWindow.cc index df485dc9b..9dc6648ef 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 4e28f07d7..070bdfdbd 100644 --- a/examples/text_geom/GlutWindow.hh +++ b/examples/text_geom/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/text_geom/Main.cc b/examples/text_geom/Main.cc index d0d7472d7..d9c0eb408 100644 --- a/examples/text_geom/Main.cc +++ b/examples/text_geom/Main.cc @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/thermal_camera/GlutWindow.cc b/examples/thermal_camera/GlutWindow.cc index d646e4160..2adbc8883 100644 --- a/examples/thermal_camera/GlutWindow.cc +++ b/examples/thermal_camera/GlutWindow.cc @@ -31,13 +31,13 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/thermal_camera/GlutWindow.hh b/examples/thermal_camera/GlutWindow.hh index bcfb981c9..ad5fb3bb1 100644 --- a/examples/thermal_camera/GlutWindow.hh +++ b/examples/thermal_camera/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/thermal_camera/Main.cc b/examples/thermal_camera/Main.cc index e29191d25..aee8e61d1 100644 --- a/examples/thermal_camera/Main.cc +++ b/examples/thermal_camera/Main.cc @@ -27,9 +27,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" diff --git a/examples/transform_control/GlutWindow.cc b/examples/transform_control/GlutWindow.cc index 2469ba2f5..3331cf226 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" diff --git a/examples/transform_control/GlutWindow.hh b/examples/transform_control/GlutWindow.hh index ca547b7e0..b55523c6b 100644 --- a/examples/transform_control/GlutWindow.hh +++ b/examples/transform_control/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/transform_control/Main.cc b/examples/transform_control/Main.cc index 87d000c72..aef627d4d 100644 --- a/examples/transform_control/Main.cc +++ b/examples/transform_control/Main.cc @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/view_control/GlutWindow.cc b/examples/view_control/GlutWindow.cc index 806bbdba9..75724e49c 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" diff --git a/examples/view_control/GlutWindow.hh b/examples/view_control/GlutWindow.hh index 07129b404..9bb9c368c 100644 --- a/examples/view_control/GlutWindow.hh +++ b/examples/view_control/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/view_control/Main.cc b/examples/view_control/Main.cc index b3da5f3c0..478e7ceb4 100644 --- a/examples/view_control/Main.cc +++ b/examples/view_control/Main.cc @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" using namespace ignition; diff --git a/examples/visualization_demo/GlutWindow.cc b/examples/visualization_demo/GlutWindow.cc index e15e91e66..5aae62c70 100644 --- a/examples/visualization_demo/GlutWindow.cc +++ b/examples/visualization_demo/GlutWindow.cc @@ -41,10 +41,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/visualization_demo/GlutWindow.hh b/examples/visualization_demo/GlutWindow.hh index d973a93af..2c636d1a9 100644 --- a/examples/visualization_demo/GlutWindow.hh +++ b/examples/visualization_demo/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_VISUALIZATION_DEMO_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_VISUALIZATION_DEMO_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_VISUALIZATION_DEMO_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_VISUALIZATION_DEMO_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/visualization_demo/Main.cc b/examples/visualization_demo/Main.cc index 5fcddf411..ab709c4a5 100644 --- a/examples/visualization_demo/Main.cc +++ b/examples/visualization_demo/Main.cc @@ -36,8 +36,8 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/waves/GlutWindow.cc b/examples/waves/GlutWindow.cc index 382b29cdb..39867d056 100644 --- a/examples/waves/GlutWindow.cc +++ b/examples/waves/GlutWindow.cc @@ -38,11 +38,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "example_config.hh" diff --git a/examples/waves/GlutWindow.hh b/examples/waves/GlutWindow.hh index 1c7a2e3c4..7b1b2822a 100644 --- a/examples/waves/GlutWindow.hh +++ b/examples/waves/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_WAVES_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_WAVES_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_WAVES_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_WAVES_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/waves/Main.cc b/examples/waves/Main.cc index 6151becab..1bcc27f54 100644 --- a/examples/waves/Main.cc +++ b/examples/waves/Main.cc @@ -33,8 +33,8 @@ #include #include -#include -#include +#include +#include #include "example_config.hh" diff --git a/examples/wide_angle_camera/GlutWindow.cc b/examples/wide_angle_camera/GlutWindow.cc index 13de2a166..e3cda1977 100644 --- a/examples/wide_angle_camera/GlutWindow.cc +++ b/examples/wide_angle_camera/GlutWindow.cc @@ -38,10 +38,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/wide_angle_camera/GlutWindow.hh b/examples/wide_angle_camera/GlutWindow.hh index 694a9b430..94b2b497a 100644 --- a/examples/wide_angle_camera/GlutWindow.hh +++ b/examples/wide_angle_camera/GlutWindow.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef GZ_RENDERING_EXAMPLES_WIDE_ANGLE_CAMERA_GLUTWINDOW_HH_ -#define GZ_RENDERING_EXAMPLES_WIDE_ANGLE_CAMERA_GLUTWINDOW_HH_ +#ifndef IGNITION_RENDERING_EXAMPLES_WIDE_ANGLE_CAMERA_GLUTWINDOW_HH_ +#define IGNITION_RENDERING_EXAMPLES_WIDE_ANGLE_CAMERA_GLUTWINDOW_HH_ #include -#include "gz/rendering/RenderTypes.hh" +#include "ignition/rendering/RenderTypes.hh" namespace ir = ignition::rendering; diff --git a/examples/wide_angle_camera/Main.cc b/examples/wide_angle_camera/Main.cc index 6ae27a5c5..1a107b3f5 100644 --- a/examples/wide_angle_camera/Main.cc +++ b/examples/wide_angle_camera/Main.cc @@ -33,8 +33,8 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 4b2bdd7bb..25ec89762 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,2 +1 @@ -add_subdirectory(gz) -install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) +add_subdirectory(ignition) diff --git a/include/gz/rendering/ArrowVisual.hh b/include/gz/rendering/ArrowVisual.hh deleted file mode 100644 index 118cb639b..000000000 --- a/include/gz/rendering/ArrowVisual.hh +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 gz/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 diff --git a/include/gz/rendering/AxisVisual.hh b/include/gz/rendering/AxisVisual.hh deleted file mode 100644 index 14fe47c2e..000000000 --- a/include/gz/rendering/AxisVisual.hh +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 gz/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 diff --git a/include/gz/rendering/BoundingBox.hh b/include/gz/rendering/BoundingBox.hh deleted file mode 100644 index df99cb1d6..000000000 --- a/include/gz/rendering/BoundingBox.hh +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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_BOUNDINGBOX_HH_ -#define GZ_RENDERING_BOUNDINGBOX_HH_ - -#include - -#include - -#include "gz/rendering/config.hh" -#include "gz/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); - - /// \internal - /// \brief Private data - IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; -} -} -} -#endif diff --git a/include/gz/rendering/BoundingBoxCamera.hh b/include/gz/rendering/BoundingBoxCamera.hh deleted file mode 100644 index 98ef69786..000000000 --- a/include/gz/rendering/BoundingBoxCamera.hh +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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_BOUNDINGBOXCAMERA_HH_ -#define GZ_RENDERING_BOUNDINGBOXCAMERA_HH_ - -#include -#include - -#include -#include -#include - -#include "gz/rendering/BoundingBox.hh" -#include "gz/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 - /// gz/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) - 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/gz/rendering/COMVisual.hh b/include/gz/rendering/COMVisual.hh deleted file mode 100644 index 47a349ca5..000000000 --- a/include/gz/rendering/COMVisual.hh +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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_COMVISUAL_HH_ -#define GZ_RENDERING_COMVISUAL_HH_ - -#include -#include -#include "gz/rendering/config.hh" -#include "gz/rendering/Object.hh" -#include "gz/rendering/RenderTypes.hh" -#include "gz/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - /// \class COMVisual COMVisual.hh - /// gz/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 deleted file mode 100644 index eab4767bd..000000000 --- a/include/gz/rendering/Camera.hh +++ /dev/null @@ -1,352 +0,0 @@ -/* - * 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 gz/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 Get the Metal texture id associated with the render texture - /// used by this camera. A valid Id is obtained only if the underlying - /// render engine is Metal based. - /// The pointer set by this function must be released to an - /// id using CFBridgingRelease. - /// \param[out] _textureIdPtr the address of a void* pointer. - public: virtual void RenderTextureMetalId(void *_textureIdPtr) 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/CameraLens.hh b/include/gz/rendering/CameraLens.hh deleted file mode 100644 index 477538b51..000000000 --- a/include/gz/rendering/CameraLens.hh +++ /dev/null @@ -1,190 +0,0 @@ -/* - * 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_CAMERALENS_HH_ -#define GZ_RENDERING_CAMERALENS_HH_ - -#include - -#include -#include - -#include "gz/rendering/config.hh" -#include "gz/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Enum for mapping function types - enum IGNITION_RENDERING_VISIBLE MappingFunctionType - { - /// \brief Gnomonic - MFT_GNOMONIC = 0, - - /// \brief Stereographic - MFT_STEREOGRAPHIC = 1, - - /// \brief Equidistant - MFT_EQUIDISTANT = 2, - - /// \brief Equisolid angle - MFT_EQUISOLID_ANGLE = 3, - - /// \brief Orthographic - MFT_ORTHOGRAPHIC = 4, - - /// \brief custom - MFT_CUSTOM = 5 - }; - - /// \brief Enum for angle function types - enum IGNITION_RENDERING_VISIBLE AngleFunctionType - { - /// \brief identity - AFT_IDENTITY = 0, - - /// \brief sin - AFT_SIN = 1, - - /// \brief TAN - AFT_TAN = 2 - }; - - /// \brief Describes a lens of a camera - /// as amapping function of type r = c1*f*fun(theta/c2+c3) - class IGNITION_RENDERING_VISIBLE CameraLens - { - /// \brief Constructor - public: CameraLens(); - - /// \brief Destructor - public: virtual ~CameraLens(); - - /// \brief Constructor - /// \param[in] _other The other camera lens - public: explicit CameraLens(const CameraLens &_other); - - /// \brief Set custom camera lens with specified parameters - /// \param[in] _c1 Image scaling factor - /// \param[in] _c2 Angle scaling factor - /// \param[in] _fun Angle transform function - /// \param[in] _f Focal length of the optical system - /// \param[in] _c3 Angle shift parameter, should be 0 in most cases - public: void SetCustomMappingFunction(double _c1, double _c2, - AngleFunctionType _fun, double _f, double _c3); - - /// \brief Get lens projection type - /// \return Lens projection / mapping function type - public: MappingFunctionType Type() const; - - /// \brief Checks if lens type is of the custom type - /// \return True if this->Type() == MFT_CUSTOM - public: bool IsCustom() const; - - /// \brief Gets c1 parameter - /// \return c1 parameter - public: double C1() const; - - /// \brief Gets c2 parameter - /// \return c2 parameter - public: double C2() const; - - /// \brief Gets c3 parameter - /// \return c3 parameter - public: double C3() const; - - /// \brief Gets f parameter - /// \return f parameter - public: double F() const; - - /// \brief Gets angle transform function - /// \return Angle transform function - public: AngleFunctionType AngleFunction() const; - - /// \brief Gets cut off angle - /// \return Cut off angle - public: double CutOffAngle() const; - - /// \brief Checks if image should be scaled to fit horizontal FOV - /// \return True if the image will be scaled - public: bool ScaleToHFOV() const; - - /// \brief Set lens projection type - /// \param[in] _type Lens projection / mapping function type - public: void SetType(MappingFunctionType _type); - - /// \brief Sets c1 parameter - /// \param[in] _c c1 parameter - public: void SetC1(double _c); - - /// \brief Sets c2 parameter - /// \param[in] _c c2 parameter - public: void SetC2(double _c); - - /// \brief Sets c3 parameter - /// \param[in] _c c3 parameter - public: void SetC3(double _c); - - /// \brief Sets f parameter - /// \param[in] _f f parameter - public: void SetF(double _f); - - /// \brief Sets angle transform function - /// \param[in] _fun Angle transform function - public: void SetAngleFunction(AngleFunctionType _fun); - - /// \brief Sets cut-off angle - /// \param[in] _angle cut-off angle - public: void SetCutOffAngle(double _angle); - - /// \brief Sets whether the image should be scaled to fit horizontal FOV - /// If True, the projection will compute a new focal length for achieving - /// the desired FOV - /// \param[in] _scale true if it should, - /// note: c1 and f parameters are ignored in this case - public: void SetScaleToHFOV(bool _scale); - - /// \brief Apply mapping function to input number - /// \param[in] _f Input floating point number to apply the mapping - /// function to. - /// \return Result of the application - public: float ApplyMappingFunction(float _f) const; - - /// \internal - /// \brief Get mapping function as vector3d - /// return unit vector, either unit x, y, or z. - public: math::Vector3d MappingFunctionAsVector3d() const; - - /// \brief Assignment operator - /// \param[in] _other The other camera lens - public: CameraLens &operator=(const CameraLens &_other); - - /// \internal - /// \brief Converts projection type from one of presets to `custom` - private: void ConvertToCustom(); - - /// \internal - /// \brief Private data pointer - IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr) - }; - } - } -} -#endif diff --git a/include/gz/rendering/Capsule.hh b/include/gz/rendering/Capsule.hh deleted file mode 100644 index a9bdfb793..000000000 --- a/include/gz/rendering/Capsule.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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_CAPSULE_HH_ -#define GZ_RENDERING_CAPSULE_HH_ - -#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 Capsule Capsule.hh gz/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 deleted file mode 100644 index 34b210d3e..000000000 --- a/include/gz/rendering/CompositeVisual.hh +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 - /// gz/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 diff --git a/include/gz/rendering/DepthCamera.hh b/include/gz/rendering/DepthCamera.hh deleted file mode 100644 index d0887f047..000000000 --- a/include/gz/rendering/DepthCamera.hh +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 gz/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 diff --git a/include/gz/rendering/DistortionPass.hh b/include/gz/rendering/DistortionPass.hh deleted file mode 100644 index a6960f994..000000000 --- a/include/gz/rendering/DistortionPass.hh +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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_DISTORTIONPASS_HH_ -#define GZ_RENDERING_DISTORTIONPASS_HH_ - -#include -#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 DistortionPass DistortionPass.hh \ - * gz/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 deleted file mode 100644 index 48f2e633b..000000000 --- a/include/gz/rendering/GaussianNoisePass.hh +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 \ - * gz/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 deleted file mode 100644 index 98554aaca..000000000 --- a/include/gz/rendering/Geometry.hh +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 gz/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 diff --git a/include/gz/rendering/GizmoVisual.hh b/include/gz/rendering/GizmoVisual.hh deleted file mode 100644 index ad1296c8f..000000000 --- a/include/gz/rendering/GizmoVisual.hh +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 gz/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 deleted file mode 100644 index 3ca7a2d9a..000000000 --- a/include/gz/rendering/GpuRays.hh +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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 gz/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 diff --git a/include/gz/rendering/GraphicsAPI.hh b/include/gz/rendering/GraphicsAPI.hh deleted file mode 100644 index b7ce2c710..000000000 --- a/include/gz/rendering/GraphicsAPI.hh +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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_GRAPHICSAPI_HH_ -#define GZ_RENDERING_GRAPHICSAPI_HH_ - -#include -#include "gz/rendering/config.hh" -#include "gz/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 deleted file mode 100644 index 3f61864c8..000000000 --- a/include/gz/rendering/Grid.hh +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 gz/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 deleted file mode 100644 index d4eba3e57..000000000 --- a/include/gz/rendering/Heightmap.hh +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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_HEIGHTMAP_HH_ -#define GZ_RENDERING_HEIGHTMAP_HH_ - -#include "gz/rendering/config.hh" -#include "gz/rendering/Geometry.hh" -#include "gz/rendering/HeightmapDescriptor.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Heightmap Heightmap.hh gz/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 deleted file mode 100644 index d7f416517..000000000 --- a/include/gz/rendering/HeightmapDescriptor.hh +++ /dev/null @@ -1,262 +0,0 @@ -/* - * 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_HEIGHTMAPDESCRIPTOR_HH_ -#define GZ_RENDERING_HEIGHTMAPDESCRIPTOR_HH_ - -#include -#include -#include -#include - -#include "gz/rendering/config.hh" -#include "gz/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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_UTILS_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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - - /// \class HeightmapDescriptor HeightmapDescriptor.hh - /// gz/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 final size in world units. - /// \return The heightmap's size. - public: ignition::math::Vector3d Size() const; - - /// \brief Set the heightmap's final size in world units. Defaults to 1x1x1. - /// \param[in] _size 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. - /// \param[in] _position 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; -} -} -} -#endif diff --git a/include/gz/rendering/Image.hh b/include/gz/rendering/Image.hh deleted file mode 100644 index 37214566d..000000000 --- a/include/gz/rendering/Image.hh +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 gz/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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Pointer to the image data - private: DataPtr data = nullptr; - IGN_UTILS_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 deleted file mode 100644 index b9353f6ed..000000000 --- a/include/gz/rendering/InertiaVisual.hh +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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_INERTIAVISUAL_HH_ -#define GZ_RENDERING_INERTIAVISUAL_HH_ - -#include -#include "gz/rendering/config.hh" -#include "gz/rendering/Object.hh" -#include "gz/rendering/RenderTypes.hh" -#include "gz/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - /// \class InertiaVisual InertiaVisual.hh - /// gz/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 deleted file mode 100644 index 369da9131..000000000 --- a/include/gz/rendering/JointVisual.hh +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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_JOINTVISUAL_HH_ -#define GZ_RENDERING_JOINTVISUAL_HH_ - -#include - -#include - -#include "gz/rendering/config.hh" -#include "gz/rendering/Object.hh" -#include "gz/rendering/RenderTypes.hh" -#include "gz/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 - /// gz/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 deleted file mode 100644 index 431ae10dd..000000000 --- a/include/gz/rendering/LidarVisual.hh +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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_LIDARVISUAL_HH_ -#define GZ_RENDERING_LIDARVISUAL_HH_ - -#include -#include -#include -#include "gz/rendering/config.hh" -#include "gz/rendering/Visual.hh" -#include "gz/rendering/Object.hh" -#include "gz/rendering/RenderTypes.hh" -#include "gz/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 gz/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 deleted file mode 100644 index b594603ad..000000000 --- a/include/gz/rendering/Light.hh +++ /dev/null @@ -1,208 +0,0 @@ -/* - * 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 gz/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 gz/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 gz/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 gz/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 diff --git a/include/gz/rendering/LightVisual.hh b/include/gz/rendering/LightVisual.hh deleted file mode 100644 index a53516ae7..000000000 --- a/include/gz/rendering/LightVisual.hh +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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_LIGHTVISUAL_HH_ -#define GZ_RENDERING_LIGHTVISUAL_HH_ - -#include "gz/rendering/config.hh" -#include "gz/rendering/Object.hh" -#include "gz/rendering/RenderTypes.hh" -#include "gz/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 gz/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 deleted file mode 100644 index a7b0f8e7d..000000000 --- a/include/gz/rendering/Marker.hh +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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 "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 gz/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 diff --git a/include/gz/rendering/Material.hh b/include/gz/rendering/Material.hh deleted file mode 100644 index 2da51fcf4..000000000 --- a/include/gz/rendering/Material.hh +++ /dev/null @@ -1,407 +0,0 @@ -/* - * 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 gz/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 diff --git a/include/gz/rendering/Mesh.hh b/include/gz/rendering/Mesh.hh deleted file mode 100644 index dd470a4bb..000000000 --- a/include/gz/rendering/Mesh.hh +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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 gz/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 descriptor - /// \param[in] _desc The new 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 gz/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 diff --git a/include/gz/rendering/MeshDescriptor.hh b/include/gz/rendering/MeshDescriptor.hh deleted file mode 100644 index ad43d5a54..000000000 --- a/include/gz/rendering/MeshDescriptor.hh +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 - /// gz/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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief common::Mesh object - public: const common::Mesh *mesh = nullptr; - - IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Name of the registered Mesh - public: std::string meshName; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - - IGN_UTILS_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_UTILS_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 deleted file mode 100644 index 276ed00d7..000000000 --- a/include/gz/rendering/MoveToHelper.hh +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif diff --git a/include/gz/rendering/Node.hh b/include/gz/rendering/Node.hh deleted file mode 100644 index 5dcb041da..000000000 --- a/include/gz/rendering/Node.hh +++ /dev/null @@ -1,344 +0,0 @@ -/* - * 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 gz/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 diff --git a/include/gz/rendering/Object.hh b/include/gz/rendering/Object.hh deleted file mode 100644 index 24a1bb715..000000000 --- a/include/gz/rendering/Object.hh +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 gz/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 deleted file mode 100644 index 5bbf13686..000000000 --- a/include/gz/rendering/OrbitViewController.hh +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 - /// gz/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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Private data pointer - public: std::unique_ptr dataPtr; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif diff --git a/include/gz/rendering/OrthoViewController.hh b/include/gz/rendering/OrthoViewController.hh deleted file mode 100644 index 47a297f46..000000000 --- a/include/gz/rendering/OrthoViewController.hh +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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_ORTHOVIEWCONTROLLER_HH_ -#define GZ_RENDERING_ORTHOVIEWCONTROLLER_HH_ - -#include -#include -#include - -#include "gz/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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Private data pointer - public: std::unique_ptr dataPtr; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif diff --git a/include/gz/rendering/ParticleEmitter.hh b/include/gz/rendering/ParticleEmitter.hh deleted file mode 100644 index aad003b38..000000000 --- a/include/gz/rendering/ParticleEmitter.hh +++ /dev/null @@ -1,263 +0,0 @@ -/* - * 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_PARTICLEEMITTER_HH_ -#define GZ_RENDERING_PARTICLEEMITTER_HH_ - -#include -#include "gz/math/Color.hh" -#include "gz/math/Pose3.hh" -#include "gz/math/Vector3.hh" -#include "gz/rendering/config.hh" -#include "gz/rendering/Export.hh" -#include "gz/rendering/RenderTypes.hh" -#include "gz/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 - /// gz/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 deleted file mode 100644 index c064c209f..000000000 --- a/include/gz/rendering/PixelFormat.hh +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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 gz/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 gz/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 deleted file mode 100644 index 5faa8ab7b..000000000 --- a/include/gz/rendering/RayQuery.hh +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - public: math::Vector3d point; - IGN_UTILS_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 gz/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 - /// \param[in] _forceSceneUpdate Performance optimization hint - /// When true Ogre2 will update all derived transforms to their - /// latest to get correct results. - /// - /// When false, that step is skipped. It is only safe to - /// set it to false when nothing has changed since the last - /// update (i.e. nothing moved, no new objects created). - /// - /// Ogre will assert if built in Debug mode if this value - /// is set to false when it shouldn't be. - /// - /// See https://ogrecave.github.io/ogre-next/api/2.2/ - /// _ogre20_changes.html#AssersionCachedOutOfDate - /// for more info - /// \return A vector of intersection results - public: virtual RayQueryResult ClosestPoint( - bool _forceSceneUpdate = true) = 0; - }; - } - } -} -#endif diff --git a/include/gz/rendering/RenderEngine.hh b/include/gz/rendering/RenderEngine.hh deleted file mode 100644 index 844433e04..000000000 --- a/include/gz/rendering/RenderEngine.hh +++ /dev/null @@ -1,190 +0,0 @@ -/* - * 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/GraphicsAPI.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 gz/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 Returns the GraphicsAPI currently in use - /// \return GraphicsAPI currently in use - public: virtual rendering::GraphicsAPI GraphicsAPI() const = 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 deleted file mode 100644 index e24d52a89..000000000 --- a/include/gz/rendering/RenderEngineManager.hh +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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 - /// gz/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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief private implementation details - private: std::unique_ptr dataPtr; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief required SingletonT friendship - private: friend class ignition::common::SingletonT; - }; - } - } -} -#endif diff --git a/include/gz/rendering/RenderEnginePlugin.hh b/include/gz/rendering/RenderEnginePlugin.hh deleted file mode 100644 index a6cfd3c66..000000000 --- a/include/gz/rendering/RenderEnginePlugin.hh +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - public: std::unique_ptr dataPtr; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif diff --git a/include/gz/rendering/RenderPass.hh b/include/gz/rendering/RenderPass.hh deleted file mode 100644 index f4ac9f06c..000000000 --- a/include/gz/rendering/RenderPass.hh +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 gz/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 deleted file mode 100644 index 7182532b5..000000000 --- a/include/gz/rendering/RenderPassSystem.hh +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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 \ - * gz/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 \ - * gz/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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: static std::map renderPassMap; - - /// \internal - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - IGN_UTILS_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 diff --git a/include/gz/rendering/RenderTarget.hh b/include/gz/rendering/RenderTarget.hh deleted file mode 100644 index 35c16f5a2..000000000 --- a/include/gz/rendering/RenderTarget.hh +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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 gz/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 \ - * gz/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; - - /// \brief Gets the Metal texture id. A valid Id is obtained only - /// if this is an Metal render texture. - /// The pointer set by this function must be released to an - /// id using CFBridgingRelease. - /// \param[out] _textureIdPtr the address of a void* pointer. - public: virtual void MetalId(void *_textureIdPtr) const = 0; - }; - - /* \class RenderWindow RenderWindow.hh \ - * gz/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 diff --git a/include/gz/rendering/RenderTypes.hh b/include/gz/rendering/RenderTypes.hh deleted file mode 100644 index fa869265a..000000000 --- a/include/gz/rendering/RenderTypes.hh +++ /dev/null @@ -1,433 +0,0 @@ -/* - * 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 WideAngleCamera; - 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 WideAngleCameraPtr - /// \brief Shared pointer to Wide Angle Camera - typedef shared_ptr WideAngleCameraPtr; - - /// \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 SegmentationCameraPtr - /// \brief Shared pointer to const Wide Angle Camera - typedef shared_ptr ConstWideAngleCameraPtr; - - /// \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 deleted file mode 100644 index 13825ee77..000000000 --- a/include/gz/rendering/RenderingIface.hh +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0493e31b1..000000000 --- a/include/gz/rendering/Scene.hh +++ /dev/null @@ -1,1313 +0,0 @@ -/* - * 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 "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 gz/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 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 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 wide angle camera. A unique ID and name will - /// automatically be assigned to the camera. - /// \return The created camera - public: virtual WideAngleCameraPtr CreateWideAngleCamera() = 0; - - /// \brief Create wide angle 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 WideAngleCameraPtr CreateWideAngleCamera( - unsigned int _id) = 0; - - /// \brief Create new wide angle 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 WideAngleCameraPtr CreateWideAngleCamera( - const std::string &_name) = 0; - - /// \brief Create new wide angle 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 WideAngleCameraPtr CreateWideAngleCamera( - 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 deleted file mode 100644 index 565bba1ad..000000000 --- a/include/gz/rendering/SegmentationCamera.hh +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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_SEGMENTATIONCAMERA_HH_ -#define GZ_RENDERING_SEGMENTATIONCAMERA_HH_ - -#include -#include - -#include -#include - -#include "gz/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 - /// gz/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 deleted file mode 100644 index 7415a0c0a..000000000 --- a/include/gz/rendering/Sensor.hh +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 gz/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 deleted file mode 100644 index 21a336768..000000000 --- a/include/gz/rendering/ShaderParam.hh +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} - -#endif diff --git a/include/gz/rendering/ShaderParams.hh b/include/gz/rendering/ShaderParams.hh deleted file mode 100644 index b575d081f..000000000 --- a/include/gz/rendering/ShaderParams.hh +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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 deleted file mode 100644 index 8377dcd51..000000000 --- a/include/gz/rendering/ShaderType.hh +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 gz/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 gz/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 deleted file mode 100644 index 4396dccb1..000000000 --- a/include/gz/rendering/Storage.hh +++ /dev/null @@ -1,386 +0,0 @@ -/* - * 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 gz/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 gz/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 gz/rendering/Storage.hh - /// gz/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 gz/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 deleted file mode 100644 index e443edcbf..000000000 --- a/include/gz/rendering/Text.hh +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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 gz/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 diff --git a/include/gz/rendering/ThermalCamera.hh b/include/gz/rendering/ThermalCamera.hh deleted file mode 100644 index 9a308d5fe..000000000 --- a/include/gz/rendering/ThermalCamera.hh +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 \ - * gz/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 diff --git a/include/gz/rendering/TransformController.hh b/include/gz/rendering/TransformController.hh deleted file mode 100644 index 1a60fbdb1..000000000 --- a/include/gz/rendering/TransformController.hh +++ /dev/null @@ -1,223 +0,0 @@ -/* - * 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 \ - * gz/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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - public: std::unique_ptr dataPtr; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif diff --git a/include/gz/rendering/TransformType.hh b/include/gz/rendering/TransformType.hh deleted file mode 100644 index 158b4d07b..000000000 --- a/include/gz/rendering/TransformType.hh +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 deleted file mode 100644 index cc552d4d1..000000000 --- a/include/gz/rendering/Utils.hh +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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 deleted file mode 100644 index 8c7530e7a..000000000 --- a/include/gz/rendering/ViewController.hh +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 - /// gz/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 diff --git a/include/gz/rendering/Visual.hh b/include/gz/rendering/Visual.hh deleted file mode 100644 index 1d8e5d39e..000000000 --- a/include/gz/rendering/Visual.hh +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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 gz/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 diff --git a/include/gz/rendering/WideAngleCamera.hh b/include/gz/rendering/WideAngleCamera.hh deleted file mode 100644 index dbf60fcf1..000000000 --- a/include/gz/rendering/WideAngleCamera.hh +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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_WIDEANGLECAMERA_HH_ -#define GZ_RENDERING_WIDEANGLECAMERA_HH_ - -#include - -#include - -#include "gz/rendering/Camera.hh" -#include "gz/rendering/CameraLens.hh" -#include "gz/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class WideAngleCamera WideAngleCamera.hh - /// gz/rendering/WideAngleCamera.hh - /// \brief Wide angle camera class - class IGNITION_RENDERING_VISIBLE WideAngleCamera : - public virtual Camera - { - /// \brief Destructor - public: virtual ~WideAngleCamera() { } - - /// \brief Set the camera lens to use for this wide angle camera - /// \param[in] _lens Camera lens to set - public: virtual void SetLens(const CameraLens &_lens) = 0; - - /// \brief Get the camera lens used by this wide angle camera - /// \return Camera lens set to this wide angle camera - public: virtual const CameraLens &Lens() const = 0; - - /// \brief Project 3D world coordinates to screen coordinates - /// \param[in] _pt 3D world coodinates - /// \return Screen coordinates. Z is the distance of point from camera - /// optical center. - public: virtual math::Vector3d Project3d(const math::Vector3d &_pt) const - = 0; - - /// \brief Subscribes a new listener to this camera's new frame event - /// \param[in] _subscriber New camera listener callback - public: virtual common::ConnectionPtr ConnectNewWideAngleFrame( - std::function _subscriber) = 0; - }; - } - } -} -#endif diff --git a/include/gz/rendering/WireBox.hh b/include/gz/rendering/WireBox.hh deleted file mode 100644 index e44b1ff3b..000000000 --- a/include/gz/rendering/WireBox.hh +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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_WIREBOX_HH_ -#define GZ_RENDERING_WIREBOX_HH_ - -#include "gz/rendering/config.hh" -#include "gz/rendering/Geometry.hh" -#include "gz/math/AxisAlignedBox.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class WireBox WireBox.hh gz/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 deleted file mode 100644 index dae000add..000000000 --- a/include/gz/rendering/base/BaseArrowVisual.hh +++ /dev/null @@ -1,214 +0,0 @@ -/* - * 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(); - } - } - } - - ////////////////////////////////////////////////// - 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 deleted file mode 100644 index 691315c97..000000000 --- a/include/gz/rendering/base/BaseAxisVisual.hh +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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(); - } - } - } - - ////////////////////////////////////////////////// - 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 deleted file mode 100644 index fb29a56e3..000000000 --- a/include/gz/rendering/base/BaseBoundingBoxCamera.hh +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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_BASE_BASEBOUNDINGBOXCAMERA_HH_ -#define GZ_RENDERING_BASE_BASEBOUNDINGBOXCAMERA_HH_ - -#include - -#include -#include - -#include "gz/rendering/base/BaseCamera.hh" -#include "gz/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 deleted file mode 100644 index 58ad81e1a..000000000 --- a/include/gz/rendering/base/BaseCOMVisual.hh +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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_BASE_BASECOMVISUAL_HH_ -#define GZ_RENDERING_BASE_BASECOMVISUAL_HH_ - -#include - -#include "gz/common/Console.hh" - -#include "gz/rendering/base/BaseObject.hh" -#include "gz/rendering/base/BaseRenderTypes.hh" -#include "gz/rendering/COMVisual.hh" -#include "gz/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 deleted file mode 100644 index e56b1b758..000000000 --- a/include/gz/rendering/base/BaseCamera.hh +++ /dev/null @@ -1,856 +0,0 @@ -/* - * 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 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 RenderTextureMetalId(void *_textureIdPtr) - 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_UTILS_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_UTILS_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); - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCamera::ImageHeight() const - { - return this->RenderTarget()->Height(); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetImageHeight(const unsigned int _height) - { - this->RenderTarget()->SetHeight(_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.SetDegree(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::RenderTextureMetalId(void *) const - { - ignerr << "RenderTextureMetalId is not supported by current render" - << " engine" << std::endl; - } - - ////////////////////////////////////////////////// - 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 deleted file mode 100644 index cae6d639f..000000000 --- a/include/gz/rendering/base/BaseCapsule.hh +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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_BASECAPSULE_HH_ -#define GZ_RENDERING_BASECAPSULE_HH_ - -#include - -#include "gz/rendering/Capsule.hh" -#include "gz/rendering/Scene.hh" -#include "gz/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 deleted file mode 100644 index 7701517df..000000000 --- a/include/gz/rendering/base/BaseDepthCamera.hh +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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 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 diff --git a/include/gz/rendering/base/BaseDistortionPass.hh b/include/gz/rendering/base/BaseDistortionPass.hh deleted file mode 100644 index ce7c617e6..000000000 --- a/include/gz/rendering/base/BaseDistortionPass.hh +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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_BASEDISTORTIONPASS_HH_ -#define GZ_RENDERING_BASEDISTORTIONPASS_HH_ - -#include "gz/rendering/DistortionPass.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class BaseDistortionPass BaseDistortionPass.hh \ - * gz/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 deleted file mode 100644 index 89fa17bfe..000000000 --- a/include/gz/rendering/base/BaseGaussianNoisePass.hh +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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 \ - * gz/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 diff --git a/include/gz/rendering/base/BaseGeometry.hh b/include/gz/rendering/base/BaseGeometry.hh deleted file mode 100644 index 336034325..000000000 --- a/include/gz/rendering/base/BaseGeometry.hh +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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 deleted file mode 100644 index e9b4cc2a4..000000000 --- a/include/gz/rendering/base/BaseGizmoVisual.hh +++ /dev/null @@ -1,723 +0,0 @@ -/* - * 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 \ - * gz/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_UTILS_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_UTILS_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 deleted file mode 100644 index debd5fff2..000000000 --- a/include/gz/rendering/base/BaseGpuRays.hh +++ /dev/null @@ -1,452 +0,0 @@ -/* - * 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 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 diff --git a/include/gz/rendering/base/BaseGrid.hh b/include/gz/rendering/base/BaseGrid.hh deleted file mode 100644 index 899f703ff..000000000 --- a/include/gz/rendering/base/BaseGrid.hh +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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 deleted file mode 100644 index f023b6028..000000000 --- a/include/gz/rendering/base/BaseHeightmap.hh +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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_BASE_BASEHEIGHTMAP_HH_ -#define GZ_RENDERING_BASE_BASEHEIGHTMAP_HH_ - -#include "gz/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 deleted file mode 100644 index 3f3c18b23..000000000 --- a/include/gz/rendering/base/BaseInertiaVisual.hh +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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_BASE_BASEINERTIAVISUAL_HH_ -#define GZ_RENDERING_BASE_BASEINERTIAVISUAL_HH_ - -#include "gz/common/Console.hh" - -#include "gz/rendering/base/BaseObject.hh" -#include "gz/rendering/base/BaseRenderTypes.hh" -#include "gz/rendering/InertiaVisual.hh" -#include "gz/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 deleted file mode 100644 index 34a4aaf70..000000000 --- a/include/gz/rendering/base/BaseJointVisual.hh +++ /dev/null @@ -1,547 +0,0 @@ -/* - * 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_BASE_BASEJOINTVISUAL_HH_ -#define GZ_RENDERING_BASE_BASEJOINTVISUAL_HH_ - -#include -#include - -#include "gz/common/Console.hh" - -#include "gz/rendering/ArrowVisual.hh" -#include "gz/rendering/AxisVisual.hh" -#include "gz/rendering/JointVisual.hh" -#include "gz/rendering/Scene.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 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; - } - - ///////////////////////////////////////////////// - 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.SetFromAxisAngle(u.Perpendicular(), angle); - else - quat.SetFromAxisAngle((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 deleted file mode 100644 index 62deee791..000000000 --- a/include/gz/rendering/base/BaseLidarVisual.hh +++ /dev/null @@ -1,539 +0,0 @@ -/* - * 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_BASELIDARVISUAL_HH_ -#define GZ_RENDERING_BASELIDARVISUAL_HH_ - -#include - -#include "gz/rendering/LidarVisual.hh" -#include "gz/rendering/base/BaseObject.hh" -#include "gz/rendering/base/BaseRenderTypes.hh" -#include "gz/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 deleted file mode 100644 index 3e467b140..000000000 --- a/include/gz/rendering/base/BaseLight.hh +++ /dev/null @@ -1,249 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2ef69acf1..000000000 --- a/include/gz/rendering/base/BaseLightVisual.hh +++ /dev/null @@ -1,275 +0,0 @@ -/* - * 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_BASE_BASELIGHTVISUAL_HH_ -#define GZ_RENDERING_BASE_BASELIGHTVISUAL_HH_ - -#include - -#include "gz/rendering/base/BaseObject.hh" -#include "gz/rendering/base/BaseRenderTypes.hh" -#include "gz/rendering/LightVisual.hh" -#include "gz/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 deleted file mode 100644 index 8047ded5f..000000000 --- a/include/gz/rendering/base/BaseMarker.hh +++ /dev/null @@ -1,233 +0,0 @@ -/* - * 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 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: std::chrono::steady_clock::duration lifetime = - std::chrono::steady_clock::duration::zero(); - IGN_UTILS_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 diff --git a/include/gz/rendering/base/BaseMaterial.hh b/include/gz/rendering/base/BaseMaterial.hh deleted file mode 100644 index 6d82c173b..000000000 --- a/include/gz/rendering/base/BaseMaterial.hh +++ /dev/null @@ -1,1065 +0,0 @@ -/* - * 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 deleted file mode 100644 index aa5e1a6a0..000000000 --- a/include/gz/rendering/base/BaseMesh.hh +++ /dev/null @@ -1,466 +0,0 @@ -/* - * 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 deleted file mode 100644 index eaca3fc5d..000000000 --- a/include/gz/rendering/base/BaseNode.hh +++ /dev/null @@ -1,698 +0,0 @@ -/* - * 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() - { - T::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) - { - math::Pose3d pose = _pose; - pose.Pos() = pose.Pos() - pose.Rot() * this->origin; - - if (!pose.IsFinite()) - { - ignerr << "Unable to set pose of a node: " - << "non-finite (nan, inf) values detected." << std::endl; - return; - } - - 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) - { - 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) - { - 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) - { - 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 deleted file mode 100644 index e89cd20fb..000000000 --- a/include/gz/rendering/base/BaseObject.hh +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - public virtual std::enable_shared_from_this, - IGN_UTILS_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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: std::string name; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif diff --git a/include/gz/rendering/base/BaseParticleEmitter.hh b/include/gz/rendering/base/BaseParticleEmitter.hh deleted file mode 100644 index 24edf862b..000000000 --- a/include/gz/rendering/base/BaseParticleEmitter.hh +++ /dev/null @@ -1,441 +0,0 @@ -/* - * 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_BASE_BASEPARTICLEEMITTER_HH_ -#define GZ_RENDERING_BASE_BASEPARTICLEEMITTER_HH_ - -#include -#include "gz/rendering/base/BaseScene.hh" -#include "gz/rendering/base/BaseNode.hh" -#include "gz/rendering/ParticleEmitter.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class BaseParticleEmitter BaseParticleEmitter.hh \ - * gz/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 deleted file mode 100644 index ec6d3abde..000000000 --- a/include/gz/rendering/base/BaseRayQuery.hh +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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 - /// gz/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( - bool _forceSceneUpdate = true) 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( - bool /*_forceSceneUpdate*/) // NOLINT - { - // 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 deleted file mode 100644 index 06a73811f..000000000 --- a/include/gz/rendering/base/BaseRenderEngine.hh +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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 rendering::GraphicsAPI GraphicsAPI() const override - { - return GraphicsAPI::UNKNOWN; - } - - // 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_UTILS_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_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif diff --git a/include/gz/rendering/base/BaseRenderPass.hh b/include/gz/rendering/base/BaseRenderPass.hh deleted file mode 100644 index f9dcd44f0..000000000 --- a/include/gz/rendering/base/BaseRenderPass.hh +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 \ - * gz/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 deleted file mode 100644 index e25116c85..000000000 --- a/include/gz/rendering/base/BaseRenderTarget.hh +++ /dev/null @@ -1,366 +0,0 @@ -/* - * 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; - - // Documentation inherited. - public: virtual void MetalId(void *_textureIdPtr) 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; - } - - ////////////////////////////////////////////////// - template - void BaseRenderTexture::MetalId(void *) const - { - } - - ////////////////////////////////////////////////// - // 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 deleted file mode 100644 index bda3c2506..000000000 --- a/include/gz/rendering/base/BaseRenderTypes.hh +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 deleted file mode 100644 index f97f8a104..000000000 --- a/include/gz/rendering/base/BaseScene.hh +++ /dev/null @@ -1,890 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - public std::enable_shared_from_this, - IGN_UTILS_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 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 WideAngleCameraPtr CreateWideAngleCamera() override; - - // Documentation inherited. - public: virtual WideAngleCameraPtr CreateWideAngleCamera( - const unsigned int _id) override; - - // Documentation inherited. - public: virtual WideAngleCameraPtr CreateWideAngleCamera( - const std::string &_name) override; - - // Documentation inherited. - public: virtual WideAngleCameraPtr CreateWideAngleCamera( - 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 a wide angle camera. - /// \param[in] _id Unique id - /// \param[in] _name Name of wide angle camera - /// \return Pointer to wide angle camera - protected: virtual WideAngleCameraPtr CreateWideAngleCameraImpl( - unsigned int _id, - const std::string &_name) - { - // The following two lines will avoid doxygen warnings - (void)_id; - (void)_name; - ignerr << "Wide angle camera not supported by: " - << this->Engine()->Name() << std::endl; - return WideAngleCameraPtr(); - } - - /// \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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: std::string name; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - - 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: NodeStorePtr nodes; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif diff --git a/include/gz/rendering/base/BaseSegmentationCamera.hh b/include/gz/rendering/base/BaseSegmentationCamera.hh deleted file mode 100644 index a9bedb2e6..000000000 --- a/include/gz/rendering/base/BaseSegmentationCamera.hh +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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_BASE_BASESEGMENTATIONCAMERA_HH_ -#define GZ_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_ - -#include - -#include - -#include "gz/rendering/base/BaseCamera.hh" -#include "gz/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 deleted file mode 100644 index d49e95309..000000000 --- a/include/gz/rendering/base/BaseSensor.hh +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 deleted file mode 100644 index b37d009f5..000000000 --- a/include/gz/rendering/base/BaseStorage.hh +++ /dev/null @@ -1,1465 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - public: virtual TPtr Get(const std::string &_key) const; - - public: virtual TPtr GetByIndex(unsigned int _index) const; - IGN_UTILS_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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: TStoreList stores; - IGN_UTILS_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 deleted file mode 100644 index 7f32194ce..000000000 --- a/include/gz/rendering/base/BaseText.hh +++ /dev/null @@ -1,303 +0,0 @@ -/* - * 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 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 diff --git a/include/gz/rendering/base/BaseThermalCamera.hh b/include/gz/rendering/base/BaseThermalCamera.hh deleted file mode 100644 index dc365fe26..000000000 --- a/include/gz/rendering/base/BaseThermalCamera.hh +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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 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 diff --git a/include/gz/rendering/base/BaseVisual.hh b/include/gz/rendering/base/BaseVisual.hh deleted file mode 100644 index 848186eea..000000000 --- a/include/gz/rendering/base/BaseVisual.hh +++ /dev/null @@ -1,555 +0,0 @@ -/* - * 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() - { - T::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/BaseWideAngleCamera.hh b/include/gz/rendering/base/BaseWideAngleCamera.hh deleted file mode 100644 index 70dd17c83..000000000 --- a/include/gz/rendering/base/BaseWideAngleCamera.hh +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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_BASE_BASEWIDEANGLECAMERA_HH_ -#define GZ_RENDERING_BASE_BASEWIDEANGLECAMERA_HH_ - -#include - -#include - -#include "gz/rendering/base/BaseCamera.hh" -#include "gz/rendering/CameraLens.hh" -#include "gz/rendering/WideAngleCamera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - template - class BaseWideAngleCamera : - public virtual WideAngleCamera, - public virtual BaseCamera, - public virtual T - { - /// \brief Constructor - protected: BaseWideAngleCamera(); - - /// \brief Destructor - public: virtual ~BaseWideAngleCamera(); - - // Documentation inherited. - public: virtual void CreateWideAngleTexture(); - - // Documentation inherited. - public: virtual void SetLens(const CameraLens &_lens) override; - - // Documentation inherited. - public: virtual const CameraLens &Lens() const override; - - // Documentation inherited. - public: virtual math::Vector3d Project3d(const math::Vector3d &_pt) const - override; - - // Documentation inherited. - public: virtual common::ConnectionPtr ConnectNewWideAngleFrame( - std::function _subscriber) override; - - /// \brief Camera lens used by this wide angle camera - protected: CameraLens lens; - }; - - ////////////////////////////////////////////////// - template - BaseWideAngleCamera::BaseWideAngleCamera() - { - } - - ////////////////////////////////////////////////// - template - BaseWideAngleCamera::~BaseWideAngleCamera() - { - } - - ////////////////////////////////////////////////// - template - void BaseWideAngleCamera::SetLens(const CameraLens &_lens) - { - this->lens = _lens; - } - - ////////////////////////////////////////////////// - template - const CameraLens &BaseWideAngleCamera::Lens() const - { - return this->lens; - } - - ////////////////////////////////////////////////// - template - void BaseWideAngleCamera::CreateWideAngleTexture() - { - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseWideAngleCamera:: Project3d(const math::Vector3d &) - const - { - ignerr << "Project3d is not supported for " - << "render engine: " << this->Scene()->Engine()->Name() - << std::endl; - return math::Vector3d(); - } - - ////////////////////////////////////////////////// - template - common::ConnectionPtr BaseWideAngleCamera::ConnectNewWideAngleFrame( - std::function) - { - return nullptr; - } - } - } -} -#endif diff --git a/include/gz/rendering/base/BaseWireBox.hh b/include/gz/rendering/base/BaseWireBox.hh deleted file mode 100644 index 4ac7f1061..000000000 --- a/include/gz/rendering/base/BaseWireBox.hh +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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_BASE_WIREBOX_HH_ -#define GZ_RENDERING_BASE_WIREBOX_HH_ - -#include -#include "gz/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/gz/rendering/base/base.hh.in b/include/gz/rendering/base/base.hh.in deleted file mode 100644 index c4092f0cd..000000000 --- a/include/gz/rendering/base/base.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/include/gz/rendering/rendering.hh.in b/include/gz/rendering/rendering.hh.in deleted file mode 100644 index 2602ad19b..000000000 --- a/include/gz/rendering/rendering.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -//#include -${ign_headers} diff --git a/include/gz/CMakeLists.txt b/include/ignition/CMakeLists.txt similarity index 100% rename from include/gz/CMakeLists.txt rename to include/ignition/CMakeLists.txt diff --git a/include/ignition/rendering.hh b/include/ignition/rendering.hh deleted file mode 100644 index 60ce766d6..000000000 --- a/include/ignition/rendering.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/include/ignition/rendering/ArrowVisual.hh b/include/ignition/rendering/ArrowVisual.hh index 2aade9765..2f4696be8 100644 --- a/include/ignition/rendering/ArrowVisual.hh +++ b/include/ignition/rendering/ArrowVisual.hh @@ -14,5 +14,52 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_ARROWVISUAL_HH_ +#define IGNITION_RENDERING_ARROWVISUAL_HH_ -#include +#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 diff --git a/include/ignition/rendering/AxisVisual.hh b/include/ignition/rendering/AxisVisual.hh index 9c15d7b7c..57fe72853 100644 --- a/include/ignition/rendering/AxisVisual.hh +++ b/include/ignition/rendering/AxisVisual.hh @@ -14,5 +14,36 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_AXISVISUAL_HH_ +#define IGNITION_RENDERING_AXISVISUAL_HH_ -#include +#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 diff --git a/include/ignition/rendering/BoundingBox.hh b/include/ignition/rendering/BoundingBox.hh index 0f8125928..9c93ee5a2 100644 --- a/include/ignition/rendering/BoundingBox.hh +++ b/include/ignition/rendering/BoundingBox.hh @@ -14,5 +14,58 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BOUNDINGBOX_HH_ +#define IGNITION_RENDERING_BOUNDINGBOX_HH_ -#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); + + /// \internal + /// \brief Private data + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; +} +} +} +#endif diff --git a/include/ignition/rendering/BoundingBoxCamera.hh b/include/ignition/rendering/BoundingBoxCamera.hh index 44f3d57d0..51b72e2c7 100644 --- a/include/ignition/rendering/BoundingBoxCamera.hh +++ b/include/ignition/rendering/BoundingBoxCamera.hh @@ -14,5 +14,76 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BOUNDINGBOXCAMERA_HH_ +#define IGNITION_RENDERING_BOUNDINGBOXCAMERA_HH_ -#include +#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) + 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/gz/rendering/CMakeLists.txt b/include/ignition/rendering/CMakeLists.txt similarity index 100% rename from include/gz/rendering/CMakeLists.txt rename to include/ignition/rendering/CMakeLists.txt diff --git a/include/ignition/rendering/COMVisual.hh b/include/ignition/rendering/COMVisual.hh index 2fdd9e6e1..a0f811cba 100644 --- a/include/ignition/rendering/COMVisual.hh +++ b/include/ignition/rendering/COMVisual.hh @@ -14,5 +14,53 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_COMVISUAL_HH_ +#define IGNITION_RENDERING_COMVISUAL_HH_ -#include +#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/ignition/rendering/Camera.hh b/include/ignition/rendering/Camera.hh index 3c407324c..0d04cfb24 100644 --- a/include/ignition/rendering/Camera.hh +++ b/include/ignition/rendering/Camera.hh @@ -14,5 +14,339 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_CAMERA_HH_ +#define IGNITION_RENDERING_CAMERA_HH_ -#include +#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 Get the Metal texture id associated with the render texture + /// used by this camera. A valid Id is obtained only if the underlying + /// render engine is Metal based. + /// The pointer set by this function must be released to an + /// id using CFBridgingRelease. + /// \param[out] _textureIdPtr the address of a void* pointer. + public: virtual void RenderTextureMetalId(void *_textureIdPtr) 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/ignition/rendering/CameraLens.hh b/include/ignition/rendering/CameraLens.hh index ec504a3da..64babc9bf 100644 --- a/include/ignition/rendering/CameraLens.hh +++ b/include/ignition/rendering/CameraLens.hh @@ -13,6 +13,178 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#ifndef IGNITION_RENDERING_CAMERALENS_HH_ +#define IGNITION_RENDERING_CAMERALENS_HH_ + +#include + +#include +#include + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Enum for mapping function types + enum IGNITION_RENDERING_VISIBLE MappingFunctionType + { + /// \brief Gnomonic + MFT_GNOMONIC = 0, + + /// \brief Stereographic + MFT_STEREOGRAPHIC = 1, + + /// \brief Equidistant + MFT_EQUIDISTANT = 2, + + /// \brief Equisolid angle + MFT_EQUISOLID_ANGLE = 3, + + /// \brief Orthographic + MFT_ORTHOGRAPHIC = 4, + + /// \brief custom + MFT_CUSTOM = 5 + }; + + /// \brief Enum for angle function types + enum IGNITION_RENDERING_VISIBLE AngleFunctionType + { + /// \brief identity + AFT_IDENTITY = 0, + + /// \brief sin + AFT_SIN = 1, + + /// \brief TAN + AFT_TAN = 2 + }; + + /// \brief Describes a lens of a camera + /// as amapping function of type r = c1*f*fun(theta/c2+c3) + class IGNITION_RENDERING_VISIBLE CameraLens + { + /// \brief Constructor + public: CameraLens(); + + /// \brief Destructor + public: virtual ~CameraLens(); + + /// \brief Constructor + /// \param[in] _other The other camera lens + public: explicit CameraLens(const CameraLens &_other); + + /// \brief Set custom camera lens with specified parameters + /// \param[in] _c1 Image scaling factor + /// \param[in] _c2 Angle scaling factor + /// \param[in] _fun Angle transform function + /// \param[in] _f Focal length of the optical system + /// \param[in] _c3 Angle shift parameter, should be 0 in most cases + public: void SetCustomMappingFunction(double _c1, double _c2, + AngleFunctionType _fun, double _f, double _c3); + + /// \brief Get lens projection type + /// \return Lens projection / mapping function type + public: MappingFunctionType Type() const; + + /// \brief Checks if lens type is of the custom type + /// \return True if this->Type() == MFT_CUSTOM + public: bool IsCustom() const; + + /// \brief Gets c1 parameter + /// \return c1 parameter + public: double C1() const; + + /// \brief Gets c2 parameter + /// \return c2 parameter + public: double C2() const; + + /// \brief Gets c3 parameter + /// \return c3 parameter + public: double C3() const; + + /// \brief Gets f parameter + /// \return f parameter + public: double F() const; + + /// \brief Gets angle transform function + /// \return Angle transform function + public: AngleFunctionType AngleFunction() const; + + /// \brief Gets cut off angle + /// \return Cut off angle + public: double CutOffAngle() const; + + /// \brief Checks if image should be scaled to fit horizontal FOV + /// \return True if the image will be scaled + public: bool ScaleToHFOV() const; + + /// \brief Set lens projection type + /// \param[in] _type Lens projection / mapping function type + public: void SetType(MappingFunctionType _type); + + /// \brief Sets c1 parameter + /// \param[in] _c c1 parameter + public: void SetC1(double _c); + + /// \brief Sets c2 parameter + /// \param[in] _c c2 parameter + public: void SetC2(double _c); + + /// \brief Sets c3 parameter + /// \param[in] _c c3 parameter + public: void SetC3(double _c); + + /// \brief Sets f parameter + /// \param[in] _f f parameter + public: void SetF(double _f); + + /// \brief Sets angle transform function + /// \param[in] _fun Angle transform function + public: void SetAngleFunction(AngleFunctionType _fun); + + /// \brief Sets cut-off angle + /// \param[in] _angle cut-off angle + public: void SetCutOffAngle(double _angle); + + /// \brief Sets whether the image should be scaled to fit horizontal FOV + /// If True, the projection will compute a new focal length for achieving + /// the desired FOV + /// \param[in] _scale true if it should, + /// note: c1 and f parameters are ignored in this case + public: void SetScaleToHFOV(bool _scale); + + /// \brief Apply mapping function to input number + /// \param[in] _f Input floating point number to apply the mapping + /// function to. + /// \return Result of the application + public: float ApplyMappingFunction(float _f) const; + + /// \internal + /// \brief Get mapping function as vector3d + /// return unit vector, either unit x, y, or z. + public: math::Vector3d MappingFunctionAsVector3d() const; + + /// \brief Assignment operator + /// \param[in] _other The other camera lens + public: CameraLens &operator=(const CameraLens &_other); + + /// \internal + /// \brief Converts projection type from one of presets to `custom` + private: void ConvertToCustom(); + + /// \internal + /// \brief Private data pointer + IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr) + }; + } + } +} +#endif diff --git a/include/ignition/rendering/Capsule.hh b/include/ignition/rendering/Capsule.hh index cc4a29394..7423be1d7 100644 --- a/include/ignition/rendering/Capsule.hh +++ b/include/ignition/rendering/Capsule.hh @@ -15,4 +15,39 @@ * */ -#include +#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/ignition/rendering/CompositeVisual.hh b/include/ignition/rendering/CompositeVisual.hh index e3f7c325e..2813f7393 100644 --- a/include/ignition/rendering/CompositeVisual.hh +++ b/include/ignition/rendering/CompositeVisual.hh @@ -14,5 +14,28 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_COMPOSITEVISUAL_HH_ +#define IGNITION_RENDERING_COMPOSITEVISUAL_HH_ -#include +#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 diff --git a/include/ignition/rendering/DepthCamera.hh b/include/ignition/rendering/DepthCamera.hh index 9ccb6499b..a70795458 100644 --- a/include/ignition/rendering/DepthCamera.hh +++ b/include/ignition/rendering/DepthCamera.hh @@ -14,5 +14,69 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_DEPTHCAMERA_HH_ +#define IGNITION_RENDERING_DEPTHCAMERA_HH_ -#include +#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 diff --git a/include/ignition/rendering/DistortionPass.hh b/include/ignition/rendering/DistortionPass.hh index 5e7abaa00..c4d02221d 100644 --- a/include/ignition/rendering/DistortionPass.hh +++ b/include/ignition/rendering/DistortionPass.hh @@ -14,5 +14,84 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_DISTORTIONPASS_HH_ +#define IGNITION_RENDERING_DISTORTIONPASS_HH_ -#include +#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/ignition/rendering/Export.hh b/include/ignition/rendering/Export.hh deleted file mode 100644 index f2cd7f018..000000000 --- a/include/ignition/rendering/Export.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/include/ignition/rendering/GaussianNoisePass.hh b/include/ignition/rendering/GaussianNoisePass.hh index d35190f26..efb3cc7f8 100644 --- a/include/ignition/rendering/GaussianNoisePass.hh +++ b/include/ignition/rendering/GaussianNoisePass.hh @@ -14,5 +14,64 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_GAUSSIANNOISEPASS_HH_ +#define IGNITION_RENDERING_GAUSSIANNOISEPASS_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 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/ignition/rendering/Geometry.hh b/include/ignition/rendering/Geometry.hh index 30b310bd4..d841eaf52 100644 --- a/include/ignition/rendering/Geometry.hh +++ b/include/ignition/rendering/Geometry.hh @@ -14,5 +14,65 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_GEOMETRY_HH_ +#define IGNITION_RENDERING_GEOMETRY_HH_ -#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 { + // + /// \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 diff --git a/include/ignition/rendering/GizmoVisual.hh b/include/ignition/rendering/GizmoVisual.hh index 8334d5bd7..ed50a664f 100644 --- a/include/ignition/rendering/GizmoVisual.hh +++ b/include/ignition/rendering/GizmoVisual.hh @@ -14,5 +14,63 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_GIZMOVISUAL_HH_ +#define IGNITION_RENDERING_GIZMOVISUAL_HH_ -#include +#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 diff --git a/include/ignition/rendering/GpuRays.hh b/include/ignition/rendering/GpuRays.hh index 6eef1b3c0..242eba088 100644 --- a/include/ignition/rendering/GpuRays.hh +++ b/include/ignition/rendering/GpuRays.hh @@ -14,5 +14,184 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_GPURAYS_HH_ +#define IGNITION_RENDERING_GPURAYS_HH_ -#include +#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 diff --git a/include/ignition/rendering/GraphicsAPI.hh b/include/ignition/rendering/GraphicsAPI.hh index 2913f32c6..505e4019d 100644 --- a/include/ignition/rendering/GraphicsAPI.hh +++ b/include/ignition/rendering/GraphicsAPI.hh @@ -14,5 +14,66 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_GRAPHICSAPI_HH_ +#define IGNITION_RENDERING_GRAPHICSAPI_HH_ -#include +#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/ignition/rendering/Grid.hh b/include/ignition/rendering/Grid.hh index bdda075a1..e4f95969d 100644 --- a/include/ignition/rendering/Grid.hh +++ b/include/ignition/rendering/Grid.hh @@ -14,5 +14,56 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_GRID_HH_ +#define IGNITION_RENDERING_GRID_HH_ -#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 { + // + /// \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/ignition/rendering/Heightmap.hh b/include/ignition/rendering/Heightmap.hh index 3930486e4..dbd818b68 100644 --- a/include/ignition/rendering/Heightmap.hh +++ b/include/ignition/rendering/Heightmap.hh @@ -14,5 +14,29 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_HEIGHTMAP_HH_ +#define IGNITION_RENDERING_HEIGHTMAP_HH_ -#include +#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/ignition/rendering/HeightmapDescriptor.hh b/include/ignition/rendering/HeightmapDescriptor.hh index ad13431db..95bb91487 100644 --- a/include/ignition/rendering/HeightmapDescriptor.hh +++ b/include/ignition/rendering/HeightmapDescriptor.hh @@ -14,5 +14,249 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_HEIGHTMAPDESCRIPTOR_HH_ +#define IGNITION_RENDERING_HEIGHTMAPDESCRIPTOR_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 { + 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_UTILS_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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_UTILS_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 final size in world units. + /// \return The heightmap's size. + public: ignition::math::Vector3d Size() const; + + /// \brief Set the heightmap's final size in world units. Defaults to 1x1x1. + /// \param[in] _size 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. + /// \param[in] _position 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; +} +} +} +#endif diff --git a/include/ignition/rendering/Image.hh b/include/ignition/rendering/Image.hh index 1f0da6f9b..00b6f6bc4 100644 --- a/include/ignition/rendering/Image.hh +++ b/include/ignition/rendering/Image.hh @@ -14,5 +14,112 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_IMAGE_HH_ +#define IGNITION_RENDERING_IMAGE_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Pointer to the image data + private: DataPtr data = nullptr; + IGN_UTILS_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/ignition/rendering/InertiaVisual.hh b/include/ignition/rendering/InertiaVisual.hh index d4d617e7e..2b233aef0 100644 --- a/include/ignition/rendering/InertiaVisual.hh +++ b/include/ignition/rendering/InertiaVisual.hh @@ -14,5 +14,46 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_INERTIAVISUAL_HH_ +#define IGNITION_RENDERING_INERTIAVISUAL_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 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/ignition/rendering/JointVisual.hh b/include/ignition/rendering/JointVisual.hh index 249625958..d0cb89664 100644 --- a/include/ignition/rendering/JointVisual.hh +++ b/include/ignition/rendering/JointVisual.hh @@ -14,5 +14,125 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_JOINTVISUAL_HH_ +#define IGNITION_RENDERING_JOINTVISUAL_HH_ -#include +#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/ignition/rendering/LidarVisual.hh b/include/ignition/rendering/LidarVisual.hh index afd68b6c4..a847bdf9c 100644 --- a/include/ignition/rendering/LidarVisual.hh +++ b/include/ignition/rendering/LidarVisual.hh @@ -14,5 +14,182 @@ * 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/ignition/rendering/Light.hh b/include/ignition/rendering/Light.hh index 728a8fbab..e620dcc10 100644 --- a/include/ignition/rendering/Light.hh +++ b/include/ignition/rendering/Light.hh @@ -14,5 +14,195 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_LIGHT_HH_ +#define IGNITION_RENDERING_LIGHT_HH_ -#include +#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 diff --git a/include/ignition/rendering/LightVisual.hh b/include/ignition/rendering/LightVisual.hh index 94119044c..cc8c6090f 100644 --- a/include/ignition/rendering/LightVisual.hh +++ b/include/ignition/rendering/LightVisual.hh @@ -14,5 +14,69 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_LIGHTVISUAL_HH_ +#define IGNITION_RENDERING_LIGHTVISUAL_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 { + + /// \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/ignition/rendering/Marker.hh b/include/ignition/rendering/Marker.hh index 18776c274..d18f00a58 100644 --- a/include/ignition/rendering/Marker.hh +++ b/include/ignition/rendering/Marker.hh @@ -14,5 +14,135 @@ * 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 diff --git a/include/ignition/rendering/Material.hh b/include/ignition/rendering/Material.hh index 7d84d0adb..6dc28e51a 100644 --- a/include/ignition/rendering/Material.hh +++ b/include/ignition/rendering/Material.hh @@ -14,5 +14,394 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_MATERIAL_HH_ +#define IGNITION_RENDERING_MATERIAL_HH_ -#include +#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 diff --git a/include/ignition/rendering/Mesh.hh b/include/ignition/rendering/Mesh.hh index fc660e6de..46de7551d 100644 --- a/include/ignition/rendering/Mesh.hh +++ b/include/ignition/rendering/Mesh.hh @@ -14,5 +14,149 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_MESH_HH_ +#define IGNITION_RENDERING_MESH_HH_ -#include +#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 descriptor + /// \param[in] _desc The new 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 diff --git a/include/ignition/rendering/MeshDescriptor.hh b/include/ignition/rendering/MeshDescriptor.hh index af3c6cc58..88a12d848 100644 --- a/include/ignition/rendering/MeshDescriptor.hh +++ b/include/ignition/rendering/MeshDescriptor.hh @@ -14,5 +14,71 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_MESHDESCRIPTOR_HH_ +#define IGNITION_RENDERING_MESHDESCRIPTOR_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief common::Mesh object + public: const common::Mesh *mesh = nullptr; + + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Name of the registered Mesh + public: std::string meshName; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + + IGN_UTILS_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_UTILS_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/ignition/rendering/MoveToHelper.hh b/include/ignition/rendering/MoveToHelper.hh index 358078858..9b7991ca5 100644 --- a/include/ignition/rendering/MoveToHelper.hh +++ b/include/ignition/rendering/MoveToHelper.hh @@ -13,6 +13,87 @@ * 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 + +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/ignition/rendering/Node.hh b/include/ignition/rendering/Node.hh index f5aba2fc5..077010e79 100644 --- a/include/ignition/rendering/Node.hh +++ b/include/ignition/rendering/Node.hh @@ -14,5 +14,331 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_NODE_HH_ +#define IGNITION_RENDERING_NODE_HH_ -#include +#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 diff --git a/include/ignition/rendering/Object.hh b/include/ignition/rendering/Object.hh index d45bc4ad2..45ce3e894 100644 --- a/include/ignition/rendering/Object.hh +++ b/include/ignition/rendering/Object.hh @@ -14,5 +14,59 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OBJECT_HH_ +#define IGNITION_RENDERING_OBJECT_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 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/ignition/rendering/OrbitViewController.hh b/include/ignition/rendering/OrbitViewController.hh index 210df15eb..42d8ac7a8 100644 --- a/include/ignition/rendering/OrbitViewController.hh +++ b/include/ignition/rendering/OrbitViewController.hh @@ -14,5 +14,77 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_ORBITVIEWCONTROLLER_HH_ +#define IGNITION_RENDERING_ORBITVIEWCONTROLLER_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Private data pointer + public: std::unique_ptr dataPtr; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/ignition/rendering/OrthoViewController.hh b/include/ignition/rendering/OrthoViewController.hh index 8ea0fb60e..d46ebf137 100644 --- a/include/ignition/rendering/OrthoViewController.hh +++ b/include/ignition/rendering/OrthoViewController.hh @@ -13,6 +13,80 @@ * 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 + +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Private data pointer + public: std::unique_ptr dataPtr; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/ignition/rendering/ParticleEmitter.hh b/include/ignition/rendering/ParticleEmitter.hh index 715f25c7c..3cd481b01 100644 --- a/include/ignition/rendering/ParticleEmitter.hh +++ b/include/ignition/rendering/ParticleEmitter.hh @@ -14,5 +14,250 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_PARTICLEEMITTER_HH_ +#define IGNITION_RENDERING_PARTICLEEMITTER_HH_ -#include +#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/ignition/rendering/PixelFormat.hh b/include/ignition/rendering/PixelFormat.hh index 76a345a8e..06f8b1dad 100644 --- a/include/ignition/rendering/PixelFormat.hh +++ b/include/ignition/rendering/PixelFormat.hh @@ -14,5 +14,119 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_PIXELFORMAT_HH_ +#define IGNITION_RENDERING_PIXELFORMAT_HH_ -#include +#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 diff --git a/include/ignition/rendering/RayQuery.hh b/include/ignition/rendering/RayQuery.hh index 520e02147..f6b8e989b 100644 --- a/include/ignition/rendering/RayQuery.hh +++ b/include/ignition/rendering/RayQuery.hh @@ -14,5 +14,100 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_RAYQUERY_HH_ +#define IGNITION_RENDERING_RAYQUERY_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + public: math::Vector3d point; + IGN_UTILS_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 + /// \param[in] _forceSceneUpdate Performance optimization hint + /// When true Ogre2 will update all derived transforms to their + /// latest to get correct results. + /// + /// When false, that step is skipped. It is only safe to + /// set it to false when nothing has changed since the last + /// update (i.e. nothing moved, no new objects created). + /// + /// Ogre will assert if built in Debug mode if this value + /// is set to false when it shouldn't be. + /// + /// See https://ogrecave.github.io/ogre-next/api/2.2/ + /// _ogre20_changes.html#AssersionCachedOutOfDate + /// for more info + /// \return A vector of intersection results + public: virtual RayQueryResult ClosestPoint( + bool _forceSceneUpdate = true) = 0; + }; + } + } +} +#endif diff --git a/include/ignition/rendering/RenderEngine.hh b/include/ignition/rendering/RenderEngine.hh index e834d2bcd..cb478f4d1 100644 --- a/include/ignition/rendering/RenderEngine.hh +++ b/include/ignition/rendering/RenderEngine.hh @@ -14,5 +14,177 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_RENDERENGINE_HH_ +#define IGNITION_RENDERING_RENDERENGINE_HH_ -#include +#include +#include +#include "ignition/rendering/config.hh" +#include "ignition/rendering/GraphicsAPI.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 Returns the GraphicsAPI currently in use + /// \return GraphicsAPI currently in use + public: virtual rendering::GraphicsAPI GraphicsAPI() const = 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/ignition/rendering/RenderEngineManager.hh b/include/ignition/rendering/RenderEngineManager.hh index c0bd0430c..1a73b5b52 100644 --- a/include/ignition/rendering/RenderEngineManager.hh +++ b/include/ignition/rendering/RenderEngineManager.hh @@ -14,5 +14,136 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_RENDERENGINEMANAGER_HH_ +#define IGNITION_RENDERING_RENDERENGINEMANAGER_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief private implementation details + private: std::unique_ptr dataPtr; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief required SingletonT friendship + private: friend class ignition::common::SingletonT; + }; + } + } +} +#endif diff --git a/include/ignition/rendering/RenderEnginePlugin.hh b/include/ignition/rendering/RenderEnginePlugin.hh index edcf3c0c4..c49d6e481 100644 --- a/include/ignition/rendering/RenderEnginePlugin.hh +++ b/include/ignition/rendering/RenderEnginePlugin.hh @@ -15,4 +15,50 @@ * */ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + public: std::unique_ptr dataPtr; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/ignition/rendering/RenderPass.hh b/include/ignition/rendering/RenderPass.hh index 6d0adf380..6d9b611f4 100644 --- a/include/ignition/rendering/RenderPass.hh +++ b/include/ignition/rendering/RenderPass.hh @@ -14,5 +14,38 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_RENDERPASS_HH_ +#define IGNITION_RENDERING_RENDERPASS_HH_ -#include +#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 diff --git a/include/ignition/rendering/RenderPassSystem.hh b/include/ignition/rendering/RenderPassSystem.hh index bdc3df1c1..6919a300e 100644 --- a/include/ignition/rendering/RenderPassSystem.hh +++ b/include/ignition/rendering/RenderPassSystem.hh @@ -14,5 +14,99 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_RENDERPASSSYSTEM_HH_ +#define IGNITION_RENDERING_RENDERPASSSYSTEM_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + private: static std::map renderPassMap; + + /// \internal + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + IGN_UTILS_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 diff --git a/include/ignition/rendering/RenderTarget.hh b/include/ignition/rendering/RenderTarget.hh index 24af82981..532129d99 100644 --- a/include/ignition/rendering/RenderTarget.hh +++ b/include/ignition/rendering/RenderTarget.hh @@ -1,7 +1,7 @@ /* * Copyright (C) 2015 Open Source Robotics Foundation * - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -14,5 +14,147 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_RENDERTARGET_HH_ +#define IGNITION_RENDERING_RENDERTARGET_HH_ -#include +#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; + + /// \brief Gets the Metal texture id. A valid Id is obtained only + /// if this is an Metal render texture. + /// The pointer set by this function must be released to an + /// id using CFBridgingRelease. + /// \param[out] _textureIdPtr the address of a void* pointer. + public: virtual void MetalId(void *_textureIdPtr) 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 diff --git a/include/ignition/rendering/RenderTypes.hh b/include/ignition/rendering/RenderTypes.hh index e4f7df84c..6b6fd05c0 100644 --- a/include/ignition/rendering/RenderTypes.hh +++ b/include/ignition/rendering/RenderTypes.hh @@ -14,5 +14,420 @@ * 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 WideAngleCamera; + 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 WideAngleCameraPtr + /// \brief Shared pointer to Wide Angle Camera + typedef shared_ptr WideAngleCameraPtr; + + /// \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 SegmentationCameraPtr + /// \brief Shared pointer to const Wide Angle Camera + typedef shared_ptr ConstWideAngleCameraPtr; + + /// \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 9ced1bff1..b48fae4d9 100644 --- a/include/ignition/rendering/RenderingIface.hh +++ b/include/ignition/rendering/RenderingIface.hh @@ -14,5 +14,136 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_RENDERINGIFACE_HH_ +#define IGNITION_RENDERING_RENDERINGIFACE_HH_ -#include +#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 diff --git a/include/ignition/rendering/Scene.hh b/include/ignition/rendering/Scene.hh index ecd278ee7..e7bd30cdc 100644 --- a/include/ignition/rendering/Scene.hh +++ b/include/ignition/rendering/Scene.hh @@ -14,5 +14,1300 @@ * 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 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 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 wide angle camera. A unique ID and name will + /// automatically be assigned to the camera. + /// \return The created camera + public: virtual WideAngleCameraPtr CreateWideAngleCamera() = 0; + + /// \brief Create wide angle 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 WideAngleCameraPtr CreateWideAngleCamera( + unsigned int _id) = 0; + + /// \brief Create new wide angle 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 WideAngleCameraPtr CreateWideAngleCamera( + const std::string &_name) = 0; + + /// \brief Create new wide angle 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 WideAngleCameraPtr CreateWideAngleCamera( + 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/ignition/rendering/SegmentationCamera.hh b/include/ignition/rendering/SegmentationCamera.hh index 67b16b6a7..afc69079d 100644 --- a/include/ignition/rendering/SegmentationCamera.hh +++ b/include/ignition/rendering/SegmentationCamera.hh @@ -14,5 +14,109 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_SEGMENTATIONCAMERA_HH_ +#define IGNITION_RENDERING_SEGMENTATIONCAMERA_HH_ -#include +#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/ignition/rendering/Sensor.hh b/include/ignition/rendering/Sensor.hh index bab0e7873..41da10872 100644 --- a/include/ignition/rendering/Sensor.hh +++ b/include/ignition/rendering/Sensor.hh @@ -14,5 +14,36 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_SENSOR_HH_ +#define IGNITION_RENDERING_SENSOR_HH_ -#include +#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 diff --git a/include/ignition/rendering/ShaderParam.hh b/include/ignition/rendering/ShaderParam.hh index c8008db57..15a67aa05 100644 --- a/include/ignition/rendering/ShaderParam.hh +++ b/include/ignition/rendering/ShaderParam.hh @@ -15,4 +15,134 @@ * */ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} + +#endif diff --git a/include/ignition/rendering/ShaderParams.hh b/include/ignition/rendering/ShaderParams.hh index ede4e92f9..adc4a17f5 100644 --- a/include/ignition/rendering/ShaderParams.hh +++ b/include/ignition/rendering/ShaderParams.hh @@ -15,4 +15,120 @@ * */ -#include +#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 diff --git a/include/ignition/rendering/ShaderType.hh b/include/ignition/rendering/ShaderType.hh index 83e93fdb9..a0e55e509 100644 --- a/include/ignition/rendering/ShaderType.hh +++ b/include/ignition/rendering/ShaderType.hh @@ -14,5 +14,76 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_SHADERTYPE_HH_ +#define IGNITION_RENDERING_SHADERTYPE_HH_ -#include +#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 diff --git a/include/ignition/rendering/Storage.hh b/include/ignition/rendering/Storage.hh index 9b8d79257..ff02a5947 100644 --- a/include/ignition/rendering/Storage.hh +++ b/include/ignition/rendering/Storage.hh @@ -14,5 +14,373 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_STORAGE_HH_ +#define IGNITION_RENDERING_STORAGE_HH_ -#include +#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 diff --git a/include/ignition/rendering/Text.hh b/include/ignition/rendering/Text.hh index 6ac966297..bcd7d91e2 100644 --- a/include/ignition/rendering/Text.hh +++ b/include/ignition/rendering/Text.hh @@ -14,5 +14,151 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_TEXT_HH_ +#define IGNITION_RENDERING_TEXT_HH_ -#include +#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 diff --git a/include/ignition/rendering/ThermalCamera.hh b/include/ignition/rendering/ThermalCamera.hh index 30f953e79..643fed05a 100644 --- a/include/ignition/rendering/ThermalCamera.hh +++ b/include/ignition/rendering/ThermalCamera.hh @@ -14,5 +14,112 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_THERMALCAMERA_HH_ +#define IGNITION_RENDERING_THERMALCAMERA_HH_ -#include +#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 diff --git a/include/ignition/rendering/TransformController.hh b/include/ignition/rendering/TransformController.hh index e5f9dfa64..2727bc3e3 100644 --- a/include/ignition/rendering/TransformController.hh +++ b/include/ignition/rendering/TransformController.hh @@ -14,5 +14,210 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_TRANSFORMCONTROLLER_HH_ +#define IGNITION_RENDERING_TRANSFORMCONTROLLER_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + public: std::unique_ptr dataPtr; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/ignition/rendering/TransformType.hh b/include/ignition/rendering/TransformType.hh index ddd5c38f3..faf1f66d5 100644 --- a/include/ignition/rendering/TransformType.hh +++ b/include/ignition/rendering/TransformType.hh @@ -15,4 +15,70 @@ * */ -#include +#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 diff --git a/include/ignition/rendering/Utils.hh b/include/ignition/rendering/Utils.hh index 58b2642af..d1cea0cf8 100644 --- a/include/ignition/rendering/Utils.hh +++ b/include/ignition/rendering/Utils.hh @@ -13,6 +13,91 @@ * 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 + +#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 diff --git a/include/ignition/rendering/ViewController.hh b/include/ignition/rendering/ViewController.hh index 6f299c271..a7245450c 100644 --- a/include/ignition/rendering/ViewController.hh +++ b/include/ignition/rendering/ViewController.hh @@ -14,5 +14,50 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_VIEWCONTROLLER_HH_ +#define IGNITION_RENDERING_VIEWCONTROLLER_HH_ -#include +#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 diff --git a/include/ignition/rendering/Visual.hh b/include/ignition/rendering/Visual.hh index 0a2efcf53..8ce909c0e 100644 --- a/include/ignition/rendering/Visual.hh +++ b/include/ignition/rendering/Visual.hh @@ -14,5 +14,145 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_VISUAL_HH_ +#define IGNITION_RENDERING_VISUAL_HH_ -#include +#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 diff --git a/include/ignition/rendering/WideAngleCamera.hh b/include/ignition/rendering/WideAngleCamera.hh index c3cc71bf3..083c79764 100644 --- a/include/ignition/rendering/WideAngleCamera.hh +++ b/include/ignition/rendering/WideAngleCamera.hh @@ -14,5 +14,54 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_WIDEANGLECAMERA_HH_ +#define IGNITION_RENDERING_WIDEANGLECAMERA_HH_ -#include +#include + +#include + +#include "ignition/rendering/Camera.hh" +#include "ignition/rendering/CameraLens.hh" +#include "ignition/rendering/Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class WideAngleCamera WideAngleCamera.hh + /// ignition/rendering/WideAngleCamera.hh + /// \brief Wide angle camera class + class IGNITION_RENDERING_VISIBLE WideAngleCamera : + public virtual Camera + { + /// \brief Destructor + public: virtual ~WideAngleCamera() { } + + /// \brief Set the camera lens to use for this wide angle camera + /// \param[in] _lens Camera lens to set + public: virtual void SetLens(const CameraLens &_lens) = 0; + + /// \brief Get the camera lens used by this wide angle camera + /// \return Camera lens set to this wide angle camera + public: virtual const CameraLens &Lens() const = 0; + + /// \brief Project 3D world coordinates to screen coordinates + /// \param[in] _pt 3D world coodinates + /// \return Screen coordinates. Z is the distance of point from camera + /// optical center. + public: virtual math::Vector3d Project3d(const math::Vector3d &_pt) const + = 0; + + /// \brief Subscribes a new listener to this camera's new frame event + /// \param[in] _subscriber New camera listener callback + public: virtual common::ConnectionPtr ConnectNewWideAngleFrame( + std::function _subscriber) = 0; + }; + } + } +} +#endif diff --git a/include/ignition/rendering/WireBox.hh b/include/ignition/rendering/WireBox.hh index ffedd1b5a..f4c4ec459 100644 --- a/include/ignition/rendering/WireBox.hh +++ b/include/ignition/rendering/WireBox.hh @@ -14,5 +14,41 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_WIREBOX_HH_ +#define IGNITION_RENDERING_WIREBOX_HH_ -#include +#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/ignition/rendering/base/BaseArrowVisual.hh b/include/ignition/rendering/base/BaseArrowVisual.hh index 0930e06dc..f4e85aa70 100644 --- a/include/ignition/rendering/base/BaseArrowVisual.hh +++ b/include/ignition/rendering/base/BaseArrowVisual.hh @@ -14,5 +14,201 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEARROWVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASEARROWVISUAL_HH_ -#include +#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(); + } + } + } + + ////////////////////////////////////////////////// + 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/ignition/rendering/base/BaseAxisVisual.hh b/include/ignition/rendering/base/BaseAxisVisual.hh index 1889e6d79..ec70445df 100644 --- a/include/ignition/rendering/base/BaseAxisVisual.hh +++ b/include/ignition/rendering/base/BaseAxisVisual.hh @@ -14,5 +14,164 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEAXISVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASEAXISVISUAL_HH_ -#include +#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(); + } + } + } + + ////////////////////////////////////////////////// + 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/ignition/rendering/base/BaseBoundingBoxCamera.hh b/include/ignition/rendering/base/BaseBoundingBoxCamera.hh index 6e04ed9dc..3fcf6f69b 100644 --- a/include/ignition/rendering/base/BaseBoundingBoxCamera.hh +++ b/include/ignition/rendering/base/BaseBoundingBoxCamera.hh @@ -14,5 +14,93 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEBOUNDINGBOXCAMERA_HH_ +#define IGNITION_RENDERING_BASE_BASEBOUNDINGBOXCAMERA_HH_ -#include +#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/ignition/rendering/base/BaseCOMVisual.hh b/include/ignition/rendering/base/BaseCOMVisual.hh index 52d29a43b..29059091d 100644 --- a/include/ignition/rendering/base/BaseCOMVisual.hh +++ b/include/ignition/rendering/base/BaseCOMVisual.hh @@ -14,5 +14,170 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASECOMVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASECOMVISUAL_HH_ -#include +#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/ignition/rendering/base/BaseCamera.hh b/include/ignition/rendering/base/BaseCamera.hh index b4582eff7..69204bf6d 100644 --- a/include/ignition/rendering/base/BaseCamera.hh +++ b/include/ignition/rendering/base/BaseCamera.hh @@ -14,5 +14,843 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASECAMERA_HH_ +#define IGNITION_RENDERING_BASE_BASECAMERA_HH_ -#include +#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 RenderTextureMetalId(void *_textureIdPtr) + 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_UTILS_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_UTILS_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); + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCamera::ImageHeight() const + { + return this->RenderTarget()->Height(); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetImageHeight(const unsigned int _height) + { + this->RenderTarget()->SetHeight(_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.SetDegree(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::RenderTextureMetalId(void *) const + { + ignerr << "RenderTextureMetalId is not supported by current render" + << " engine" << std::endl; + } + + ////////////////////////////////////////////////// + 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/ignition/rendering/base/BaseCapsule.hh b/include/ignition/rendering/base/BaseCapsule.hh index a6f34357d..653be69b5 100644 --- a/include/ignition/rendering/base/BaseCapsule.hh +++ b/include/ignition/rendering/base/BaseCapsule.hh @@ -13,6 +13,127 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/base/BaseDepthCamera.hh b/include/ignition/rendering/base/BaseDepthCamera.hh index ec7999326..1372ac69e 100644 --- a/include/ignition/rendering/base/BaseDepthCamera.hh +++ b/include/ignition/rendering/base/BaseDepthCamera.hh @@ -14,5 +14,87 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEDEPTHCAMERA_HH_ +#define IGNITION_RENDERING_BASE_BASEDEPTHCAMERA_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseDistortionPass.hh b/include/ignition/rendering/base/BaseDistortionPass.hh index fc5710f16..843139e08 100644 --- a/include/ignition/rendering/base/BaseDistortionPass.hh +++ b/include/ignition/rendering/base/BaseDistortionPass.hh @@ -14,5 +14,185 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASEDISTORTIONPASS_HH_ +#define IGNITION_RENDERING_BASEDISTORTIONPASS_HH_ -#include +#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/ignition/rendering/base/BaseGaussianNoisePass.hh b/include/ignition/rendering/base/BaseGaussianNoisePass.hh index 3244bf2fb..03e03930b 100644 --- a/include/ignition/rendering/base/BaseGaussianNoisePass.hh +++ b/include/ignition/rendering/base/BaseGaussianNoisePass.hh @@ -14,5 +14,155 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_ +#define IGNITION_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseGeometry.hh b/include/ignition/rendering/base/BaseGeometry.hh index 0bd6b9980..337262037 100644 --- a/include/ignition/rendering/base/BaseGeometry.hh +++ b/include/ignition/rendering/base/BaseGeometry.hh @@ -14,5 +14,103 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEGEOMETRY_HH_ +#define IGNITION_RENDERING_BASE_BASEGEOMETRY_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseGizmoVisual.hh b/include/ignition/rendering/base/BaseGizmoVisual.hh index a3c7bee9a..65ae0a422 100644 --- a/include/ignition/rendering/base/BaseGizmoVisual.hh +++ b/include/ignition/rendering/base/BaseGizmoVisual.hh @@ -15,4 +15,709 @@ * */ -#include +#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_UTILS_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_UTILS_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/ignition/rendering/base/BaseGpuRays.hh b/include/ignition/rendering/base/BaseGpuRays.hh index 00f6c62a6..ebf1ec694 100644 --- a/include/ignition/rendering/base/BaseGpuRays.hh +++ b/include/ignition/rendering/base/BaseGpuRays.hh @@ -14,5 +14,439 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEGPURAYS_HH_ +#define IGNITION_RENDERING_BASE_BASEGPURAYS_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseGrid.hh b/include/ignition/rendering/base/BaseGrid.hh index 3bd886b7f..26aabc464 100644 --- a/include/ignition/rendering/base/BaseGrid.hh +++ b/include/ignition/rendering/base/BaseGrid.hh @@ -14,5 +14,144 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEGRID_HH_ +#define IGNITION_RENDERING_BASE_BASEGRID_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseHeightmap.hh b/include/ignition/rendering/base/BaseHeightmap.hh index 313631963..cafcf2c5a 100644 --- a/include/ignition/rendering/base/BaseHeightmap.hh +++ b/include/ignition/rendering/base/BaseHeightmap.hh @@ -14,5 +14,68 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEHEIGHTMAP_HH_ +#define IGNITION_RENDERING_BASE_BASEHEIGHTMAP_HH_ -#include +#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/ignition/rendering/base/BaseInertiaVisual.hh b/include/ignition/rendering/base/BaseInertiaVisual.hh index 26ce47b77..9be984395 100644 --- a/include/ignition/rendering/base/BaseInertiaVisual.hh +++ b/include/ignition/rendering/base/BaseInertiaVisual.hh @@ -14,5 +14,119 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEINERTIAVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASEINERTIAVISUAL_HH_ -#include +#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/ignition/rendering/base/BaseJointVisual.hh b/include/ignition/rendering/base/BaseJointVisual.hh index 7f0f6600d..a1a45b156 100644 --- a/include/ignition/rendering/base/BaseJointVisual.hh +++ b/include/ignition/rendering/base/BaseJointVisual.hh @@ -14,5 +14,534 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEJOINTVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASEJOINTVISUAL_HH_ -#include +#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; + } + + ///////////////////////////////////////////////// + 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.SetFromAxisAngle(u.Perpendicular(), angle); + else + quat.SetFromAxisAngle((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/ignition/rendering/base/BaseLidarVisual.hh b/include/ignition/rendering/base/BaseLidarVisual.hh index 25b1b44e4..4e0edb24d 100644 --- a/include/ignition/rendering/base/BaseLidarVisual.hh +++ b/include/ignition/rendering/base/BaseLidarVisual.hh @@ -13,6 +13,527 @@ * 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 + +#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/ignition/rendering/base/BaseLight.hh b/include/ignition/rendering/base/BaseLight.hh index b2b087603..540f0a9a8 100644 --- a/include/ignition/rendering/base/BaseLight.hh +++ b/include/ignition/rendering/base/BaseLight.hh @@ -14,5 +14,236 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASELIGHT_HH_ +#define IGNITION_RENDERING_BASE_BASELIGHT_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseLightVisual.hh b/include/ignition/rendering/base/BaseLightVisual.hh index 7fae37d1a..d36e05280 100644 --- a/include/ignition/rendering/base/BaseLightVisual.hh +++ b/include/ignition/rendering/base/BaseLightVisual.hh @@ -14,5 +14,262 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASELIGHTVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASELIGHTVISUAL_HH_ -#include +#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/ignition/rendering/base/BaseMarker.hh b/include/ignition/rendering/base/BaseMarker.hh index 8cd23b360..a49f1e452 100644 --- a/include/ignition/rendering/base/BaseMarker.hh +++ b/include/ignition/rendering/base/BaseMarker.hh @@ -13,6 +13,221 @@ * 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 + +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: std::chrono::steady_clock::duration lifetime = + std::chrono::steady_clock::duration::zero(); + IGN_UTILS_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 diff --git a/include/ignition/rendering/base/BaseMaterial.hh b/include/ignition/rendering/base/BaseMaterial.hh index 6d5982829..11bb6a11a 100644 --- a/include/ignition/rendering/base/BaseMaterial.hh +++ b/include/ignition/rendering/base/BaseMaterial.hh @@ -14,5 +14,1052 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEMATERIAL_HH_ +#define IGNITION_RENDERING_BASE_BASEMATERIAL_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseMesh.hh b/include/ignition/rendering/base/BaseMesh.hh index 76a9f9d1f..456787770 100644 --- a/include/ignition/rendering/base/BaseMesh.hh +++ b/include/ignition/rendering/base/BaseMesh.hh @@ -14,5 +14,453 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEMESH_HH_ +#define IGNITION_RENDERING_BASE_BASEMESH_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseNode.hh b/include/ignition/rendering/base/BaseNode.hh index df8cd7644..549023d25 100644 --- a/include/ignition/rendering/base/BaseNode.hh +++ b/include/ignition/rendering/base/BaseNode.hh @@ -14,5 +14,685 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASENODE_HH_ +#define IGNITION_RENDERING_BASE_BASENODE_HH_ -#include +#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() + { + T::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) + { + math::Pose3d pose = _pose; + pose.Pos() = pose.Pos() - pose.Rot() * this->origin; + + if (!pose.IsFinite()) + { + ignerr << "Unable to set pose of a node: " + << "non-finite (nan, inf) values detected." << std::endl; + return; + } + + 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) + { + 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) + { + 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) + { + 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/ignition/rendering/base/BaseObject.hh b/include/ignition/rendering/base/BaseObject.hh index 3e0bbed40..956514ea3 100644 --- a/include/ignition/rendering/base/BaseObject.hh +++ b/include/ignition/rendering/base/BaseObject.hh @@ -14,5 +14,56 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEOBJECT_HH_ +#define IGNITION_RENDERING_BASE_BASEOBJECT_HH_ -#include +#include +#include +#include +#include "ignition/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_VISIBLE BaseObject : + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + public virtual std::enable_shared_from_this, + IGN_UTILS_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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: std::string name; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/ignition/rendering/base/BaseParticleEmitter.hh b/include/ignition/rendering/base/BaseParticleEmitter.hh index a65bdeed3..c02395d53 100644 --- a/include/ignition/rendering/base/BaseParticleEmitter.hh +++ b/include/ignition/rendering/base/BaseParticleEmitter.hh @@ -15,4 +15,427 @@ * */ -#include +#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/ignition/rendering/base/BaseRayQuery.hh b/include/ignition/rendering/base/BaseRayQuery.hh index becf4be5b..8d5a6f02f 100644 --- a/include/ignition/rendering/base/BaseRayQuery.hh +++ b/include/ignition/rendering/base/BaseRayQuery.hh @@ -14,5 +14,144 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASERAYQUERY_HH_ +#define IGNITION_RENDERING_BASE_BASERAYQUERY_HH_ -#include +#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( + bool _forceSceneUpdate = true) 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( + bool /*_forceSceneUpdate*/) // NOLINT + { + // TODO(anyone): implement a generic ray query here? + RayQueryResult result; + result.distance = -1; + return result; + } + } + } +} +#endif diff --git a/include/ignition/rendering/base/BaseRenderEngine.hh b/include/ignition/rendering/base/BaseRenderEngine.hh index 18530dbfc..cfb3a4583 100644 --- a/include/ignition/rendering/base/BaseRenderEngine.hh +++ b/include/ignition/rendering/base/BaseRenderEngine.hh @@ -14,5 +14,132 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASERENDERENGINE_HH_ +#define IGNITION_RENDERING_BASE_BASERENDERENGINE_HH_ -#include +#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 rendering::GraphicsAPI GraphicsAPI() const override + { + return GraphicsAPI::UNKNOWN; + } + + // 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_UTILS_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_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/ignition/rendering/base/BaseRenderPass.hh b/include/ignition/rendering/base/BaseRenderPass.hh index 5ee7ba6d4..347cdc211 100644 --- a/include/ignition/rendering/base/BaseRenderPass.hh +++ b/include/ignition/rendering/base/BaseRenderPass.hh @@ -14,5 +14,71 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASERENDERPASS_HH_ +#define IGNITION_RENDERING_BASE_BASERENDERPASS_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseRenderTarget.hh b/include/ignition/rendering/base/BaseRenderTarget.hh index 25221fcaa..6f4f0c0ff 100644 --- a/include/ignition/rendering/base/BaseRenderTarget.hh +++ b/include/ignition/rendering/base/BaseRenderTarget.hh @@ -14,5 +14,353 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASERENDERTARGET_HH_ +#define IGNITION_RENDERING_BASE_BASERENDERTARGET_HH_ -#include +#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; + + // Documentation inherited. + public: virtual void MetalId(void *_textureIdPtr) 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; + } + + ////////////////////////////////////////////////// + template + void BaseRenderTexture::MetalId(void *) const + { + } + + ////////////////////////////////////////////////// + // 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/ignition/rendering/base/BaseRenderTypes.hh b/include/ignition/rendering/base/BaseRenderTypes.hh index f6acf8090..ebc1004cb 100644 --- a/include/ignition/rendering/base/BaseRenderTypes.hh +++ b/include/ignition/rendering/base/BaseRenderTypes.hh @@ -14,5 +14,34 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASERENDERTYPES_HH_ +#define IGNITION_RENDERING_BASE_BASERENDERTYPES_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseScene.hh b/include/ignition/rendering/base/BaseScene.hh index d0afebe8c..893bcc6de 100644 --- a/include/ignition/rendering/base/BaseScene.hh +++ b/include/ignition/rendering/base/BaseScene.hh @@ -14,5 +14,877 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASESCENE_HH_ +#define IGNITION_RENDERING_BASE_BASESCENE_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + public std::enable_shared_from_this, + IGN_UTILS_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 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 WideAngleCameraPtr CreateWideAngleCamera() override; + + // Documentation inherited. + public: virtual WideAngleCameraPtr CreateWideAngleCamera( + const unsigned int _id) override; + + // Documentation inherited. + public: virtual WideAngleCameraPtr CreateWideAngleCamera( + const std::string &_name) override; + + // Documentation inherited. + public: virtual WideAngleCameraPtr CreateWideAngleCamera( + 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 a wide angle camera. + /// \param[in] _id Unique id + /// \param[in] _name Name of wide angle camera + /// \return Pointer to wide angle camera + protected: virtual WideAngleCameraPtr CreateWideAngleCameraImpl( + unsigned int _id, + const std::string &_name) + { + // The following two lines will avoid doxygen warnings + (void)_id; + (void)_name; + ignerr << "Wide angle camera not supported by: " + << this->Engine()->Name() << std::endl; + return WideAngleCameraPtr(); + } + + /// \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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: std::string name; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + + 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + private: NodeStorePtr nodes; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/ignition/rendering/base/BaseSegmentationCamera.hh b/include/ignition/rendering/base/BaseSegmentationCamera.hh index 867c5da2c..c74fea088 100644 --- a/include/ignition/rendering/base/BaseSegmentationCamera.hh +++ b/include/ignition/rendering/base/BaseSegmentationCamera.hh @@ -14,5 +14,185 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_ +#define IGNITION_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_ -#include +#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/ignition/rendering/base/BaseSensor.hh b/include/ignition/rendering/base/BaseSensor.hh index bcb0cb415..676ec3c11 100644 --- a/include/ignition/rendering/base/BaseSensor.hh +++ b/include/ignition/rendering/base/BaseSensor.hh @@ -14,5 +14,62 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASESENSOR_HH_ +#define IGNITION_RENDERING_BASE_BASESENSOR_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseStorage.hh b/include/ignition/rendering/base/BaseStorage.hh index 7350a6ba1..ab7b89333 100644 --- a/include/ignition/rendering/base/BaseStorage.hh +++ b/include/ignition/rendering/base/BaseStorage.hh @@ -14,5 +14,1452 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASESTORAGE_HH_ +#define IGNITION_RENDERING_BASE_BASESTORAGE_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + public: virtual TPtr Get(const std::string &_key) const; + + public: virtual TPtr GetByIndex(unsigned int _index) const; + IGN_UTILS_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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: TStoreList stores; + IGN_UTILS_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/ignition/rendering/base/BaseText.hh b/include/ignition/rendering/base/BaseText.hh index 722fb3470..349848032 100644 --- a/include/ignition/rendering/base/BaseText.hh +++ b/include/ignition/rendering/base/BaseText.hh @@ -14,5 +14,290 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASETEXT_HH_ +#define IGNITION_RENDERING_BASE_BASETEXT_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseThermalCamera.hh b/include/ignition/rendering/base/BaseThermalCamera.hh index ef9b84413..a061a371b 100644 --- a/include/ignition/rendering/base/BaseThermalCamera.hh +++ b/include/ignition/rendering/base/BaseThermalCamera.hh @@ -14,5 +14,198 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASETHERMALCAMERA_HH_ +#define IGNITION_RENDERING_BASE_BASETHERMALCAMERA_HH_ -#include +#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 diff --git a/include/ignition/rendering/base/BaseVisual.hh b/include/ignition/rendering/base/BaseVisual.hh index 4ef4761bb..0391d397c 100644 --- a/include/ignition/rendering/base/BaseVisual.hh +++ b/include/ignition/rendering/base/BaseVisual.hh @@ -14,5 +14,542 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEVISUAL_HH_ +#define IGNITION_RENDERING_BASE_BASEVISUAL_HH_ -#include +#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() + { + T::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/ignition/rendering/base/BaseWideAngleCamera.hh b/include/ignition/rendering/base/BaseWideAngleCamera.hh index 7615095e4..7ee048d46 100644 --- a/include/ignition/rendering/base/BaseWideAngleCamera.hh +++ b/include/ignition/rendering/base/BaseWideAngleCamera.hh @@ -14,5 +14,108 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_BASEWIDEANGLECAMERA_HH_ +#define IGNITION_RENDERING_BASE_BASEWIDEANGLECAMERA_HH_ -#include +#include + +#include + +#include "ignition/rendering/base/BaseCamera.hh" +#include "ignition/rendering/CameraLens.hh" +#include "ignition/rendering/WideAngleCamera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + template + class BaseWideAngleCamera : + public virtual WideAngleCamera, + public virtual BaseCamera, + public virtual T + { + /// \brief Constructor + protected: BaseWideAngleCamera(); + + /// \brief Destructor + public: virtual ~BaseWideAngleCamera(); + + // Documentation inherited. + public: virtual void CreateWideAngleTexture(); + + // Documentation inherited. + public: virtual void SetLens(const CameraLens &_lens) override; + + // Documentation inherited. + public: virtual const CameraLens &Lens() const override; + + // Documentation inherited. + public: virtual math::Vector3d Project3d(const math::Vector3d &_pt) const + override; + + // Documentation inherited. + public: virtual common::ConnectionPtr ConnectNewWideAngleFrame( + std::function _subscriber) override; + + /// \brief Camera lens used by this wide angle camera + protected: CameraLens lens; + }; + + ////////////////////////////////////////////////// + template + BaseWideAngleCamera::BaseWideAngleCamera() + { + } + + ////////////////////////////////////////////////// + template + BaseWideAngleCamera::~BaseWideAngleCamera() + { + } + + ////////////////////////////////////////////////// + template + void BaseWideAngleCamera::SetLens(const CameraLens &_lens) + { + this->lens = _lens; + } + + ////////////////////////////////////////////////// + template + const CameraLens &BaseWideAngleCamera::Lens() const + { + return this->lens; + } + + ////////////////////////////////////////////////// + template + void BaseWideAngleCamera::CreateWideAngleTexture() + { + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseWideAngleCamera:: Project3d(const math::Vector3d &) + const + { + ignerr << "Project3d is not supported for " + << "render engine: " << this->Scene()->Engine()->Name() + << std::endl; + return math::Vector3d(); + } + + ////////////////////////////////////////////////// + template + common::ConnectionPtr BaseWideAngleCamera::ConnectNewWideAngleFrame( + std::function) + { + return nullptr; + } + } + } +} +#endif diff --git a/include/ignition/rendering/base/BaseWireBox.hh b/include/ignition/rendering/base/BaseWireBox.hh index c667b6cc7..db7fe12e9 100644 --- a/include/ignition/rendering/base/BaseWireBox.hh +++ b/include/ignition/rendering/base/BaseWireBox.hh @@ -14,5 +14,92 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_BASE_WIREBOX_HH_ +#define IGNITION_RENDERING_BASE_WIREBOX_HH_ -#include +#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/gz/rendering/base/CMakeLists.txt b/include/ignition/rendering/base/CMakeLists.txt similarity index 100% rename from include/gz/rendering/base/CMakeLists.txt rename to include/ignition/rendering/base/CMakeLists.txt diff --git a/include/ignition/rendering/base/base.hh.in b/include/ignition/rendering/base/base.hh.in new file mode 100644 index 000000000..acfd26ae7 --- /dev/null +++ b/include/ignition/rendering/base/base.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/include/ignition/rendering/config.hh b/include/ignition/rendering/config.hh deleted file mode 100644 index 9c6996b7a..000000000 --- a/include/ignition/rendering/config.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/include/gz/rendering/config.hh.in b/include/ignition/rendering/config.hh.in similarity index 100% rename from include/gz/rendering/config.hh.in rename to include/ignition/rendering/config.hh.in diff --git a/include/ignition/rendering/rendering.hh.in b/include/ignition/rendering/rendering.hh.in new file mode 100644 index 000000000..13484ca76 --- /dev/null +++ b/include/ignition/rendering/rendering.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +//#include +${ign_headers} diff --git a/ogre/include/CMakeLists.txt b/ogre/include/CMakeLists.txt index 4b2bdd7bb..297e254ff 100644 --- a/ogre/include/CMakeLists.txt +++ b/ogre/include/CMakeLists.txt @@ -1,2 +1 @@ -add_subdirectory(gz) -install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) +add_subdirectory(ignition/rendering) diff --git a/ogre/include/gz/CMakeLists.txt b/ogre/include/gz/CMakeLists.txt deleted file mode 100644 index 56597eee8..000000000 --- a/ogre/include/gz/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(rendering) diff --git a/ogre/include/gz/rendering/ogre/OgreArrowVisual.hh b/ogre/include/gz/rendering/ogre/OgreArrowVisual.hh deleted file mode 100644 index 9bdb05a61..000000000 --- a/ogre/include/gz/rendering/ogre/OgreArrowVisual.hh +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 deleted file mode 100644 index aa4277a98..000000000 --- a/ogre/include/gz/rendering/ogre/OgreAxisVisual.hh +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 deleted file mode 100644 index 6f451dea4..000000000 --- a/ogre/include/gz/rendering/ogre/OgreCOMVisual.hh +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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_OGRE_OGRECOMVISUAL_HH_ -#define GZ_RENDERING_OGRE_OGRECOMVISUAL_HH_ - -#include - -#include "gz/rendering/base/BaseCOMVisual.hh" -#include "gz/rendering/ogre/OgreIncludes.hh" -#include "gz/rendering/ogre/OgreMaterial.hh" -#include "gz/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 deleted file mode 100644 index c9ec433b5..000000000 --- a/ogre/include/gz/rendering/ogre/OgreCamera.hh +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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/OgreObjectInterface.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 virtual BaseCamera, - public virtual OgreObjectInterface - { - protected: OgreCamera(); - - public: virtual ~OgreCamera(); - - // 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; - - // Documentation inherited. - public: virtual Ogre::Camera *Camera() const override; - - // 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(); - - 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 deleted file mode 100644 index ef1d035c3..000000000 --- a/ogre/include/gz/rendering/ogre/OgreCapsule.hh +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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_OGRE_OGRECAPSULE_HH_ -#define GZ_RENDERING_OGRE_OGRECAPSULE_HH_ - -#include -#include "gz/rendering/base/BaseCapsule.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 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 deleted file mode 100644 index 1783addda..000000000 --- a/ogre/include/gz/rendering/ogre/OgreConversions.hh +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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 deleted file mode 100644 index 8527a7580..000000000 --- a/ogre/include/gz/rendering/ogre/OgreDepthCamera.hh +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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/OgreObjectInterface.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 virtual BaseDepthCamera, - public virtual OgreObjectInterface - { - /// \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 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; - - // Documentation inherited. - public: virtual Ogre::Camera *Camera() const 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 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 deleted file mode 100644 index be91fa75d..000000000 --- a/ogre/include/gz/rendering/ogre/OgreDistortionPass.hh +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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_OGRE_OGREDISTORTIONPASS_HH_ -#define GZ_RENDERING_OGRE_OGREDISTORTIONPASS_HH_ - -#include -#include - -#include -#include - -#include "gz/rendering/base/BaseDistortionPass.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 DistortionCompositorListener; - - /* \class OgreDistortionPass OgreDistortionPass.hh \ - * gz/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 deleted file mode 100644 index a76bac50e..000000000 --- a/ogre/include/gz/rendering/ogre/OgreDynamicLines.hh +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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 \ - * gz/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 diff --git a/ogre/include/gz/rendering/ogre/OgreDynamicRenderable.hh b/ogre/include/gz/rendering/ogre/OgreDynamicRenderable.hh deleted file mode 100644 index 7596bd94c..000000000 --- a/ogre/include/gz/rendering/ogre/OgreDynamicRenderable.hh +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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 \ - * gz/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 deleted file mode 100644 index 8ef26cefd..000000000 --- a/ogre/include/gz/rendering/ogre/OgreGaussianNoisePass.hh +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 \ - * gz/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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - public: std::shared_ptr - gaussianNoiseCompositorListener; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGeometry.hh b/ogre/include/gz/rendering/ogre/OgreGeometry.hh deleted file mode 100644 index 8ede3a0b2..000000000 --- a/ogre/include/gz/rendering/ogre/OgreGeometry.hh +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: OgreVisualPtr parent; - IGN_UTILS_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 deleted file mode 100644 index c871c3703..000000000 --- a/ogre/include/gz/rendering/ogre/OgreGizmoVisual.hh +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 deleted file mode 100644 index 589283327..000000000 --- a/ogre/include/gz/rendering/ogre/OgreGpuRays.hh +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_UTILS_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 deleted file mode 100644 index 6a577051b..000000000 --- a/ogre/include/gz/rendering/ogre/OgreGrid.hh +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 deleted file mode 100644 index 286edc2bb..000000000 --- a/ogre/include/gz/rendering/ogre/OgreHeightmap.hh +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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_OGRE_OGREHEIGHTMAP_HH_ -#define GZ_RENDERING_OGRE_OGREHEIGHTMAP_HH_ - -#include -#include -#include - -#include "gz/rendering/base/BaseHeightmap.hh" -#include "gz/rendering/ogre/OgreGeometry.hh" -#include "gz/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 deleted file mode 100644 index 74236fafe..000000000 --- a/ogre/include/gz/rendering/ogre/OgreIncludes.hh +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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) -#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 deleted file mode 100644 index 770df2c8a..000000000 --- a/ogre/include/gz/rendering/ogre/OgreInertiaVisual.hh +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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_OGRE_OGREINERTIAVISUAL_HH_ -#define GZ_RENDERING_OGRE_OGREINERTIAVISUAL_HH_ - -#include - -#include "gz/rendering/base/BaseInertiaVisual.hh" -#include "gz/rendering/ogre/OgreIncludes.hh" -#include "gz/rendering/ogre/OgreMaterial.hh" -#include "gz/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 deleted file mode 100644 index 567e6869e..000000000 --- a/ogre/include/gz/rendering/ogre/OgreJointVisual.hh +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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_OGRE_OGREJOINTVISUAL_HH_ -#define GZ_RENDERING_OGRE_OGREJOINTVISUAL_HH_ - -#include "gz/rendering/base/BaseJointVisual.hh" -#include "gz/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 deleted file mode 100644 index 24b616120..000000000 --- a/ogre/include/gz/rendering/ogre/OgreLidarVisual.hh +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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_OGRE_OGRELIDARVISUAL_HH_ -#define GZ_RENDERING_OGRE_OGRELIDARVISUAL_HH_ - -#include -#include -#include "gz/rendering/base/BaseLidarVisual.hh" -#include "gz/rendering/ogre/OgreVisual.hh" -#include "gz/rendering/ogre/OgreIncludes.hh" -#include "gz/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 deleted file mode 100644 index 0274f9139..000000000 --- a/ogre/include/gz/rendering/ogre/OgreLight.hh +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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 deleted file mode 100644 index 9a6305e3d..000000000 --- a/ogre/include/gz/rendering/ogre/OgreLightVisual.hh +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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_OGRE_OGRELIGHTVISUAL_HH_ -#define GZ_RENDERING_OGRE_OGRELIGHTVISUAL_HH_ - -#include - -#include "gz/rendering/base/BaseLightVisual.hh" -#include "gz/rendering/ogre/OgreIncludes.hh" -#include "gz/rendering/ogre/OgreMaterial.hh" -#include "gz/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 deleted file mode 100644 index 14dba9757..000000000 --- a/ogre/include/gz/rendering/ogre/OgreMarker.hh +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 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 diff --git a/ogre/include/gz/rendering/ogre/OgreMaterial.hh b/ogre/include/gz/rendering/ogre/OgreMaterial.hh deleted file mode 100644 index 9627c456f..000000000 --- a/ogre/include/gz/rendering/ogre/OgreMaterial.hh +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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_UTILS_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_UTILS_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 deleted file mode 100644 index 1498adc22..000000000 --- a/ogre/include/gz/rendering/ogre/OgreMaterialSwitcher.hh +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::map colorDict; - IGN_UTILS_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 deleted file mode 100644 index c2328bca8..000000000 --- a/ogre/include/gz/rendering/ogre/OgreMesh.hh +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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 deleted file mode 100644 index 92eb9f041..000000000 --- a/ogre/include/gz/rendering/ogre/OgreMeshFactory.hh +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 deleted file mode 100644 index 558086e89..000000000 --- a/ogre/include/gz/rendering/ogre/OgreNode.hh +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: OgreNodePtr parent; - IGN_UTILS_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 deleted file mode 100644 index b2414e848..000000000 --- a/ogre/include/gz/rendering/ogre/OgreObject.hh +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: OgreScenePtr scene; - IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - - private: friend class OgreScene; - }; - } - } -} -#endif diff --git a/ogre/include/gz/rendering/ogre/OgreObjectInterface.hh b/ogre/include/gz/rendering/ogre/OgreObjectInterface.hh deleted file mode 100644 index a51720d02..000000000 --- a/ogre/include/gz/rendering/ogre/OgreObjectInterface.hh +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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_OGRE_OGREOBJECTINTERFACE_HH_ -#define GZ_RENDERING_OGRE_OGREOBJECTINTERFACE_HH_ - -#include "gz/rendering/config.hh" -#include "gz/rendering/ogre/OgreIncludes.hh" -#include "gz/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - /// \brief Mixin class to provide direct access to Ogre objects. - class IGNITION_RENDERING_OGRE_VISIBLE OgreObjectInterface - { - public: virtual ~OgreObjectInterface(); - - /// \brief Access to an Ogre::MovableObject. - // - /// \param[in] _typename Name of the object type to retrieve. - /// \return A pointer to an Ogre::MovableObject. Has default nullptr. - public: virtual Ogre::MovableObject *OgreMovableObject( - const char* _typename) const; - - /// \brief Access the Ogre::Camera object. - // - /// \return A pointer to an Ogre::Camera. Has default nullptr. - public: virtual Ogre::Camera *Camera() const = 0; - }; - } - } -} -#endif diff --git a/ogre/include/gz/rendering/ogre/OgreParticleEmitter.hh b/ogre/include/gz/rendering/ogre/OgreParticleEmitter.hh deleted file mode 100644 index bb42768a4..000000000 --- a/ogre/include/gz/rendering/ogre/OgreParticleEmitter.hh +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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_OGRE_PARTICLEEMITTER_HH_ -#define GZ_RENDERING_OGRE_PARTICLEEMITTER_HH_ - -#include "gz/rendering/base/BaseParticleEmitter.hh" -#include "gz/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 deleted file mode 100644 index 1e4d1611b..000000000 --- a/ogre/include/gz/rendering/ogre/OgreRTShaderSystem.hh +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 deleted file mode 100644 index df9b9cedf..000000000 --- a/ogre/include/gz/rendering/ogre/OgreRayQuery.hh +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 - /// gz/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( - bool _forceSceneUpdate = true); - - /// \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 deleted file mode 100644 index efcf0e225..000000000 --- a/ogre/include/gz/rendering/ogre/OgreRenderEngine.hh +++ /dev/null @@ -1,191 +0,0 @@ -/* - * 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; - - // Documentation Inherited - public: virtual rendering::GraphicsAPI GraphicsAPI() const 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 deleted file mode 100644 index 8dbe49d0d..000000000 --- a/ogre/include/gz/rendering/ogre/OgreRenderPass.hh +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 \ - * gz/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 deleted file mode 100644 index cbda9cc91..000000000 --- a/ogre/include/gz/rendering/ogre/OgreRenderTarget.hh +++ /dev/null @@ -1,186 +0,0 @@ -/* - * 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 deleted file mode 100644 index 627709d86..000000000 --- a/ogre/include/gz/rendering/ogre/OgreRenderTargetMaterial.hh +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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 deleted file mode 100644 index 752477af0..000000000 --- a/ogre/include/gz/rendering/ogre/OgreRenderTypes.hh +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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 OgreObjectInterface; - 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 OgreWideAngleCamera; - 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 OgreObjectInterfacePtr; - 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 OgreWideAngleCameraPtr; - typedef shared_ptr OgreWireBoxPtr; - } - } -} -#endif diff --git a/ogre/include/gz/rendering/ogre/OgreScene.hh b/ogre/include/gz/rendering/ogre/OgreScene.hh deleted file mode 100644 index 2bcb93f56..000000000 --- a/ogre/include/gz/rendering/ogre/OgreScene.hh +++ /dev/null @@ -1,254 +0,0 @@ -/* - * 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; - - // Documentation inherited - protected: virtual WideAngleCameraPtr CreateWideAngleCameraImpl( - 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 deleted file mode 100644 index 3a6932018..000000000 --- a/ogre/include/gz/rendering/ogre/OgreSelectionBuffer.hh +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 deleted file mode 100644 index af5643099..000000000 --- a/ogre/include/gz/rendering/ogre/OgreSensor.hh +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 deleted file mode 100644 index 50db5882b..000000000 --- a/ogre/include/gz/rendering/ogre/OgreStorage.hh +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7b8cab572..000000000 --- a/ogre/include/gz/rendering/ogre/OgreText.hh +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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 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 diff --git a/ogre/include/gz/rendering/ogre/OgreThermalCamera.hh b/ogre/include/gz/rendering/ogre/OgreThermalCamera.hh deleted file mode 100644 index 54fd1987e..000000000 --- a/ogre/include/gz/rendering/ogre/OgreThermalCamera.hh +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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/OgreObjectInterface.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 virtual BaseThermalCamera, - public virtual OgreObjectInterface - { - /// \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 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; - - // Documentation inherited. - public: virtual Ogre::Camera *Camera() const 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 deleted file mode 100644 index c07fffe52..000000000 --- a/ogre/include/gz/rendering/ogre/OgreVisual.hh +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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 - -#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/OgreWideAngleCamera.hh b/ogre/include/gz/rendering/ogre/OgreWideAngleCamera.hh deleted file mode 100644 index 587f7a55e..000000000 --- a/ogre/include/gz/rendering/ogre/OgreWideAngleCamera.hh +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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_OGRE_WIDEANGLECAMERA_HH_ -#define GZ_RENDERING_OGRE_WIDEANGLECAMERA_HH_ - -#include -#include -#include - -#include - -#include "gz/rendering/base/BaseWideAngleCamera.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" - -namespace Ogre -{ - class Material; - class RenderTarget; - class Viewport; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre implementation of WideAngleCamera - class IGNITION_RENDERING_OGRE_VISIBLE OgreWideAngleCamera : - public BaseWideAngleCamera, - protected Ogre::CompositorInstance::Listener - { - /// \brief Constructor - protected: OgreWideAngleCamera(); - - /// \brief Destructor - public: virtual ~OgreWideAngleCamera(); - - // Documentation inherited - public: virtual void Init() override; - - /// \brief Create a texture - public: virtual void CreateRenderTexture(); - - /// \brief Render the camera - public: virtual void PostRender() override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Gets the environment texture size - /// \return Texture size - public: unsigned int EnvTextureSize() const; - - /// \brief Sets environment texture size - /// \param[in] _size Texture size - public: void SetEnvTextureSize(int _size); - - /// \brief Set the background color of the camera - /// \param[in] _color Color to set the background to - /// \return True if the background color is set successfully, - /// false otherwise - public: bool SetBackgroundColor(const math::Color &_color); - - /// \brief Project 3D world coordinates to screen coordinates - /// \param[in] _pt 3D world coodinates - /// \return Screen coordinates. Z is the distance of point from camera - /// optical center. - public: math::Vector3d Project3d(const math::Vector3d &_pt) const - override; - - /// \brief Get the list of ogre cameras used to create the cube map for - /// generating the wide angle camera image - /// \return A list of OGRE cameras - public: std::vector OgreEnvCameras() const; - - /// \brief Set uniform variables of a shader - /// for the provided material technique pass - /// \param[in] _pass Ogre::Pass used for rendering - /// \param[in] _ratio Frame aspect ratio - /// \param[in] _hfov Horizontal field of view - public: void SetUniformVariables(Ogre::Pass *_pass, - float _ratio, float _hfov); - - // Documentation inherited. - public: virtual void PreRender() override; - - /// \brief Implementation of the render call - public: virtual void Render() override; - - // Documentation inherited - public: common::ConnectionPtr ConnectNewWideAngleFrame( - std::function _subscriber) override; - - // Documentation inherited. - public: virtual void SetVisibilityMask(uint32_t _mask) override; - - /// \brief Set the camera's render target - protected: void CreateWideAngleTexture() override; - - /// \brief Create the camera. - protected: void CreateCamera(); - - /// \brief Creates a set of 6 cameras pointing in different directions - protected: void CreateEnvCameras(); - - /// \brief Callback that is used to set mapping material uniform values, - /// implements Ogre::CompositorInstance::Listener interface - /// \param[in] _pass_id Pass identifier - /// \param[in] _material Material whose parameters should be set - protected: void notifyMaterialRender(Ogre::uint32 _pass_id, - Ogre::MaterialPtr &_material) override; - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - private: friend class OgreScene; - - /// \cond warning - /// \brief Private data pointer - IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr) - /// \endcond - }; - } - } -} -#endif diff --git a/ogre/include/gz/rendering/ogre/OgreWireBox.hh b/ogre/include/gz/rendering/ogre/OgreWireBox.hh deleted file mode 100644 index 1284a3ffd..000000000 --- a/ogre/include/gz/rendering/ogre/OgreWireBox.hh +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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_OGRE_OGREWIREBOX_HH_ -#define GZ_RENDERING_OGRE_OGREWIREBOX_HH_ - -#include -#include "gz/rendering/base/BaseWireBox.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 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 deleted file mode 100644 index c4092f0cd..000000000 --- a/ogre/include/gz/rendering/ogre/ogre.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/ogre/include/gz/rendering/CMakeLists.txt b/ogre/include/ignition/rendering/CMakeLists.txt similarity index 100% rename from ogre/include/gz/rendering/CMakeLists.txt rename to ogre/include/ignition/rendering/CMakeLists.txt diff --git a/ogre/include/ignition/rendering/ogre.hh b/ogre/include/ignition/rendering/ogre.hh deleted file mode 100644 index 78f899898..000000000 --- a/ogre/include/ignition/rendering/ogre.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/ogre/include/ignition/rendering/ogre/Export.hh b/ogre/include/ignition/rendering/ogre/Export.hh deleted file mode 100644 index 1a647d09e..000000000 --- a/ogre/include/ignition/rendering/ogre/Export.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh b/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh index 1619d9cc9..5e1bb8687 100644 --- a/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh @@ -14,5 +14,28 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREARROWVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGREARROWVISUAL_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh b/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh index 5707a56be..2dc439ae1 100644 --- a/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh @@ -14,5 +14,28 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREAXISVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGREAXISVISUAL_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreCOMVisual.hh b/ogre/include/ignition/rendering/ogre/OgreCOMVisual.hh index 6c23e809c..6dda62d99 100644 --- a/ogre/include/ignition/rendering/ogre/OgreCOMVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreCOMVisual.hh @@ -13,6 +13,73 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre/OgreCamera.hh b/ogre/include/ignition/rendering/ogre/OgreCamera.hh index fecaf460d..f21e2c8e5 100644 --- a/ogre/include/ignition/rendering/ogre/OgreCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreCamera.hh @@ -14,5 +14,140 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRECAMERA_HH_ +#define IGNITION_RENDERING_OGRE_OGRECAMERA_HH_ -#include +#include + +#include "ignition/rendering/base/BaseCamera.hh" +#include "ignition/rendering/ogre/OgreRenderTypes.hh" +#include "ignition/rendering/ogre/OgreObjectInterface.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 virtual BaseCamera, + public virtual OgreObjectInterface + { + protected: OgreCamera(); + + public: virtual ~OgreCamera(); + + // 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; + + // Documentation inherited. + public: virtual Ogre::Camera *Camera() const override; + + // 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(); + + 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/ignition/rendering/ogre/OgreCapsule.hh b/ogre/include/ignition/rendering/ogre/OgreCapsule.hh index 2877db0ab..9cbb2a2ee 100644 --- a/ogre/include/ignition/rendering/ogre/OgreCapsule.hh +++ b/ogre/include/ignition/rendering/ogre/OgreCapsule.hh @@ -13,6 +13,68 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre/OgreConversions.hh b/ogre/include/ignition/rendering/ogre/OgreConversions.hh index b5ee364b1..0bb3b632e 100644 --- a/ogre/include/ignition/rendering/ogre/OgreConversions.hh +++ b/ogre/include/ignition/rendering/ogre/OgreConversions.hh @@ -14,5 +14,93 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRECONVERSIONS_HH_ +#define IGNITION_RENDERING_OGRE_OGRECONVERSIONS_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh b/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh index 7d5567a68..d04020dab 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh @@ -13,6 +13,169 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/OgreObjectInterface.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 virtual BaseDepthCamera, + public virtual OgreObjectInterface + { + /// \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 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; + + // Documentation inherited. + public: virtual Ogre::Camera *Camera() const 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 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/ignition/rendering/ogre/OgreDistortionPass.hh b/ogre/include/ignition/rendering/ogre/OgreDistortionPass.hh index ba878e3d5..b8f355a25 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDistortionPass.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDistortionPass.hh @@ -14,5 +14,86 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREDISTORTIONPASS_HH_ +#define IGNITION_RENDERING_OGRE_OGREDISTORTIONPASS_HH_ -#include +#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/ignition/rendering/ogre/OgreDynamicLines.hh b/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh index 3618af370..09dc6f265 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh @@ -13,6 +13,99 @@ * 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 + +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh b/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh index 1cfce8577..f27132405 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh @@ -13,6 +13,99 @@ * 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 +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh b/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh index 6135ccab3..cf0e2513c 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh @@ -14,5 +14,59 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREGAUSSIANNOISEPASS_HH_ +#define IGNITION_RENDERING_OGRE_OGREGAUSSIANNOISEPASS_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + public: std::shared_ptr + gaussianNoiseCompositorListener; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/ogre/include/ignition/rendering/ogre/OgreGeometry.hh b/ogre/include/ignition/rendering/ogre/OgreGeometry.hh index a231efee5..74c284bbd 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGeometry.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGeometry.hh @@ -14,5 +14,47 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREGEOMETRY_HH_ +#define IGNITION_RENDERING_OGRE_OGREGEOMETRY_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: OgreVisualPtr parent; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreVisual; + }; + } + } +} +#endif diff --git a/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh b/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh index 153b629ae..2fdb75e52 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh @@ -14,5 +14,31 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREGIZMOVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGREGIZMOVISUAL_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh b/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh index f54805b0b..435dcd631 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh @@ -13,6 +13,185 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/ignition/rendering/ogre/OgreGrid.hh b/ogre/include/ignition/rendering/ogre/OgreGrid.hh index f3e57c229..b6f188b56 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGrid.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGrid.hh @@ -13,6 +13,69 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreHeightmap.hh b/ogre/include/ignition/rendering/ogre/OgreHeightmap.hh index fdcf89dc5..b75fde249 100644 --- a/ogre/include/ignition/rendering/ogre/OgreHeightmap.hh +++ b/ogre/include/ignition/rendering/ogre/OgreHeightmap.hh @@ -13,6 +13,126 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre/OgreIncludes.hh b/ogre/include/ignition/rendering/ogre/OgreIncludes.hh index 7095c4513..d858b8204 100644 --- a/ogre/include/ignition/rendering/ogre/OgreIncludes.hh +++ b/ogre/include/ignition/rendering/ogre/OgreIncludes.hh @@ -14,5 +14,78 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREINCLUDES_HH_ +#define IGNITION_RENDERING_OGRE_OGREINCLUDES_HH_ -#include +// 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 + +#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/ignition/rendering/ogre/OgreInertiaVisual.hh b/ogre/include/ignition/rendering/ogre/OgreInertiaVisual.hh index 495a3948e..a956823d5 100644 --- a/ogre/include/ignition/rendering/ogre/OgreInertiaVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreInertiaVisual.hh @@ -13,6 +13,77 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre/OgreJointVisual.hh b/ogre/include/ignition/rendering/ogre/OgreJointVisual.hh index d2483b8ae..fb57497cc 100644 --- a/ogre/include/ignition/rendering/ogre/OgreJointVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreJointVisual.hh @@ -14,5 +14,31 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREJOINTVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGREJOINTVISUAL_HH_ -#include +#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/ignition/rendering/ogre/OgreLidarVisual.hh b/ogre/include/ignition/rendering/ogre/OgreLidarVisual.hh index 82fbbc2a9..f9ea3c40c 100644 --- a/ogre/include/ignition/rendering/ogre/OgreLidarVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreLidarVisual.hh @@ -13,6 +13,84 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre/OgreLight.hh b/ogre/include/ignition/rendering/ogre/OgreLight.hh index dfee3cfbb..98c8cc3e1 100644 --- a/ogre/include/ignition/rendering/ogre/OgreLight.hh +++ b/ogre/include/ignition/rendering/ogre/OgreLight.hh @@ -14,5 +14,139 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRELIGHT_HH_ +#define IGNITION_RENDERING_OGRE_OGRELIGHT_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreLightVisual.hh b/ogre/include/ignition/rendering/ogre/OgreLightVisual.hh index 11d1064bc..801049c52 100644 --- a/ogre/include/ignition/rendering/ogre/OgreLightVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreLightVisual.hh @@ -13,6 +13,70 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre/OgreMarker.hh b/ogre/include/ignition/rendering/ogre/OgreMarker.hh index 028d98a61..ef98c16c9 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMarker.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMarker.hh @@ -13,6 +13,81 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreMaterial.hh b/ogre/include/ignition/rendering/ogre/OgreMaterial.hh index 2444134e7..670ecaf8a 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMaterial.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMaterial.hh @@ -14,5 +14,233 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREMATERIAL_HH_ +#define IGNITION_RENDERING_OGRE_OGREMATERIAL_HH_ -#include +#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_UTILS_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_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh b/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh index 2188b81c5..be1b60490 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh @@ -13,6 +13,115 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::map colorDict; + IGN_UTILS_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/ignition/rendering/ogre/OgreMesh.hh b/ogre/include/ignition/rendering/ogre/OgreMesh.hh index ed9895aad..50d8e0b16 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMesh.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMesh.hh @@ -14,5 +14,116 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREMESH_HH_ +#define IGNITION_RENDERING_OGRE_OGREMESH_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh b/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh index 3c5c4d516..6c28369ab 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh @@ -14,5 +14,85 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREMESHFACTORY_HH_ +#define IGNITION_RENDERING_OGRE_OGREMESHFACTORY_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreNode.hh b/ogre/include/ignition/rendering/ogre/OgreNode.hh index d9ae86fae..b7bf342fd 100644 --- a/ogre/include/ignition/rendering/ogre/OgreNode.hh +++ b/ogre/include/ignition/rendering/ogre/OgreNode.hh @@ -14,5 +14,95 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRENODE_HH_ +#define IGNITION_RENDERING_OGRE_OGRENODE_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: OgreNodePtr parent; + IGN_UTILS_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/ignition/rendering/ogre/OgreObject.hh b/ogre/include/ignition/rendering/ogre/OgreObject.hh index c31c16db0..b96e324f7 100644 --- a/ogre/include/ignition/rendering/ogre/OgreObject.hh +++ b/ogre/include/ignition/rendering/ogre/OgreObject.hh @@ -14,5 +14,37 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREOBJECT_HH_ +#define IGNITION_RENDERING_OGRE_OGREOBJECT_HH_ -#include +#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_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: OgreScenePtr scene; + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/ignition/rendering/ogre/OgreObjectInterface.hh b/ogre/include/ignition/rendering/ogre/OgreObjectInterface.hh index bcee4cf37..e5ee2717a 100644 --- a/ogre/include/ignition/rendering/ogre/OgreObjectInterface.hh +++ b/ogre/include/ignition/rendering/ogre/OgreObjectInterface.hh @@ -14,5 +14,37 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREOBJECTINTERFACE_HH_ +#define IGNITION_RENDERING_OGRE_OGREOBJECTINTERFACE_HH_ -#include +#include "ignition/rendering/config.hh" +#include "ignition/rendering/ogre/OgreIncludes.hh" +#include "ignition/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + /// \brief Mixin class to provide direct access to Ogre objects. + class IGNITION_RENDERING_OGRE_VISIBLE OgreObjectInterface + { + public: virtual ~OgreObjectInterface(); + + /// \brief Access to an Ogre::MovableObject. + // + /// \param[in] _typename Name of the object type to retrieve. + /// \return A pointer to an Ogre::MovableObject. Has default nullptr. + public: virtual Ogre::MovableObject *OgreMovableObject( + const char* _typename) const; + + /// \brief Access the Ogre::Camera object. + // + /// \return A pointer to an Ogre::Camera. Has default nullptr. + public: virtual Ogre::Camera *Camera() const = 0; + }; + } + } +} +#endif diff --git a/ogre/include/ignition/rendering/ogre/OgreParticleEmitter.hh b/ogre/include/ignition/rendering/ogre/OgreParticleEmitter.hh index 3ed883106..92604ff78 100644 --- a/ogre/include/ignition/rendering/ogre/OgreParticleEmitter.hh +++ b/ogre/include/ignition/rendering/ogre/OgreParticleEmitter.hh @@ -14,5 +14,31 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_PARTICLEEMITTER_HH_ +#define IGNITION_RENDERING_OGRE_PARTICLEEMITTER_HH_ -#include +#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/ignition/rendering/ogre/OgreRTShaderSystem.hh b/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh index f393a4c88..56450b8fc 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh @@ -14,5 +14,168 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRERTSHADERSYSTEM_HH_ +#define IGNITION_RENDERING_OGRE_OGRERTSHADERSYSTEM_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh b/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh index 379e63c50..dbe8b89c3 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh @@ -14,5 +14,71 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRERAYQUERY_HH_ +#define IGNITION_RENDERING_OGRE_OGRERAYQUERY_HH_ -#include +#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( + bool _forceSceneUpdate = true); + + /// \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/ignition/rendering/ogre/OgreRenderEngine.hh b/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh index 2b06a12d7..053a6364d 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh @@ -14,5 +14,178 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRERENDERENGINE_HH_ +#define IGNITION_RENDERING_OGRE_OGRERENDERENGINE_HH_ -#include +#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; + + // Documentation Inherited + public: virtual rendering::GraphicsAPI GraphicsAPI() const 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/ignition/rendering/ogre/OgreRenderPass.hh b/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh index c46b24099..cbfe312e9 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh @@ -14,5 +14,47 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRERENDERPASS_HH_ +#define IGNITION_RENDERING_OGRE_OGRERENDERPASS_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh index 60ade6617..9fddb44ee 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh @@ -14,5 +14,173 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRERENDERTARGET_HH_ +#define IGNITION_RENDERING_OGRE_OGRERENDERTARGET_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh index 86cc0b45f..e738438e8 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh @@ -14,5 +14,100 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRRENDERTARGETMATERIAL_HH_ +#define IGNITION_RENDERING_OGRE_OGRRENDERTARGETMATERIAL_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh index f7ca3e945..d4d83f71b 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh @@ -14,5 +14,121 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRERENDERTYPES_HH_ +#define IGNITION_RENDERING_OGRE_OGRERENDERTYPES_HH_ -#include +#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 OgreObjectInterface; + 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 OgreWideAngleCamera; + 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 OgreObjectInterfacePtr; + 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 OgreWideAngleCameraPtr; + typedef shared_ptr OgreWireBoxPtr; + } + } +} +#endif diff --git a/ogre/include/ignition/rendering/ogre/OgreScene.hh b/ogre/include/ignition/rendering/ogre/OgreScene.hh index 65747dc95..2631c25dd 100644 --- a/ogre/include/ignition/rendering/ogre/OgreScene.hh +++ b/ogre/include/ignition/rendering/ogre/OgreScene.hh @@ -14,5 +14,241 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRESCENE_HH_ +#define IGNITION_RENDERING_OGRE_OGRESCENE_HH_ -#include +#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; + + // Documentation inherited + protected: virtual WideAngleCameraPtr CreateWideAngleCameraImpl( + 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/ignition/rendering/ogre/OgreSelectionBuffer.hh b/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh index b9278840f..51c76af25 100644 --- a/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh +++ b/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh @@ -13,6 +13,76 @@ * 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 + +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreSensor.hh b/ogre/include/ignition/rendering/ogre/OgreSensor.hh index 61099c554..6f4e6f3c1 100644 --- a/ogre/include/ignition/rendering/ogre/OgreSensor.hh +++ b/ogre/include/ignition/rendering/ogre/OgreSensor.hh @@ -14,5 +14,26 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRESENSOR_HH_ +#define IGNITION_RENDERING_OGRE_OGRESENSOR_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreStorage.hh b/ogre/include/ignition/rendering/ogre/OgreStorage.hh index 5fde14130..bd113c1fb 100644 --- a/ogre/include/ignition/rendering/ogre/OgreStorage.hh +++ b/ogre/include/ignition/rendering/ogre/OgreStorage.hh @@ -14,5 +14,59 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGRESTORAGE_HH_ +#define IGNITION_RENDERING_OGRE_OGRESTORAGE_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreText.hh b/ogre/include/ignition/rendering/ogre/OgreText.hh index 5b888733f..61511d5a0 100644 --- a/ogre/include/ignition/rendering/ogre/OgreText.hh +++ b/ogre/include/ignition/rendering/ogre/OgreText.hh @@ -13,6 +13,98 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh b/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh index b7c23df05..415618539 100644 --- a/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh @@ -13,6 +13,112 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/OgreObjectInterface.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 virtual BaseThermalCamera, + public virtual OgreObjectInterface + { + /// \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 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; + + // Documentation inherited. + public: virtual Ogre::Camera *Camera() const 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/ignition/rendering/ogre/OgreVisual.hh b/ogre/include/ignition/rendering/ogre/OgreVisual.hh index 900d43f7b..ab9843ef1 100644 --- a/ogre/include/ignition/rendering/ogre/OgreVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreVisual.hh @@ -14,5 +14,91 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE_OGREVISUAL_HH_ +#define IGNITION_RENDERING_OGRE_OGREVISUAL_HH_ -#include +#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 diff --git a/ogre/include/ignition/rendering/ogre/OgreWideAngleCamera.hh b/ogre/include/ignition/rendering/ogre/OgreWideAngleCamera.hh index 7f41505dc..94bb31b63 100644 --- a/ogre/include/ignition/rendering/ogre/OgreWideAngleCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreWideAngleCamera.hh @@ -13,6 +13,134 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ +#ifndef IGNITION_RENDERING_OGRE_WIDEANGLECAMERA_HH_ +#define IGNITION_RENDERING_OGRE_WIDEANGLECAMERA_HH_ -#include +#include +#include +#include + +#include + +#include "ignition/rendering/base/BaseWideAngleCamera.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" + +namespace Ogre +{ + class Material; + class RenderTarget; + class Viewport; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre implementation of WideAngleCamera + class IGNITION_RENDERING_OGRE_VISIBLE OgreWideAngleCamera : + public BaseWideAngleCamera, + protected Ogre::CompositorInstance::Listener + { + /// \brief Constructor + protected: OgreWideAngleCamera(); + + /// \brief Destructor + public: virtual ~OgreWideAngleCamera(); + + // Documentation inherited + public: virtual void Init() override; + + /// \brief Create a texture + public: virtual void CreateRenderTexture(); + + /// \brief Render the camera + public: virtual void PostRender() override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Gets the environment texture size + /// \return Texture size + public: unsigned int EnvTextureSize() const; + + /// \brief Sets environment texture size + /// \param[in] _size Texture size + public: void SetEnvTextureSize(int _size); + + /// \brief Set the background color of the camera + /// \param[in] _color Color to set the background to + /// \return True if the background color is set successfully, + /// false otherwise + public: bool SetBackgroundColor(const math::Color &_color); + + /// \brief Project 3D world coordinates to screen coordinates + /// \param[in] _pt 3D world coodinates + /// \return Screen coordinates. Z is the distance of point from camera + /// optical center. + public: math::Vector3d Project3d(const math::Vector3d &_pt) const + override; + + /// \brief Get the list of ogre cameras used to create the cube map for + /// generating the wide angle camera image + /// \return A list of OGRE cameras + public: std::vector OgreEnvCameras() const; + + /// \brief Set uniform variables of a shader + /// for the provided material technique pass + /// \param[in] _pass Ogre::Pass used for rendering + /// \param[in] _ratio Frame aspect ratio + /// \param[in] _hfov Horizontal field of view + public: void SetUniformVariables(Ogre::Pass *_pass, + float _ratio, float _hfov); + + // Documentation inherited. + public: virtual void PreRender() override; + + /// \brief Implementation of the render call + public: virtual void Render() override; + + // Documentation inherited + public: common::ConnectionPtr ConnectNewWideAngleFrame( + std::function _subscriber) override; + + // Documentation inherited. + public: virtual void SetVisibilityMask(uint32_t _mask) override; + + /// \brief Set the camera's render target + protected: void CreateWideAngleTexture() override; + + /// \brief Create the camera. + protected: void CreateCamera(); + + /// \brief Creates a set of 6 cameras pointing in different directions + protected: void CreateEnvCameras(); + + /// \brief Callback that is used to set mapping material uniform values, + /// implements Ogre::CompositorInstance::Listener interface + /// \param[in] _pass_id Pass identifier + /// \param[in] _material Material whose parameters should be set + protected: void notifyMaterialRender(Ogre::uint32 _pass_id, + Ogre::MaterialPtr &_material) override; + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + private: friend class OgreScene; + + /// \cond warning + /// \brief Private data pointer + IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr) + /// \endcond + }; + } + } +} +#endif diff --git a/ogre/include/ignition/rendering/ogre/OgreWireBox.hh b/ogre/include/ignition/rendering/ogre/OgreWireBox.hh index 7bbba0ba8..b22078f19 100644 --- a/ogre/include/ignition/rendering/ogre/OgreWireBox.hh +++ b/ogre/include/ignition/rendering/ogre/OgreWireBox.hh @@ -13,6 +13,70 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre/ogre.hh.in b/ogre/include/ignition/rendering/ogre/ogre.hh.in new file mode 100644 index 000000000..acfd26ae7 --- /dev/null +++ b/ogre/include/ignition/rendering/ogre/ogre.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/ogre2/include/CMakeLists.txt b/ogre2/include/CMakeLists.txt index 4b2bdd7bb..297e254ff 100644 --- a/ogre2/include/CMakeLists.txt +++ b/ogre2/include/CMakeLists.txt @@ -1,2 +1 @@ -add_subdirectory(gz) -install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) +add_subdirectory(ignition/rendering) diff --git a/ogre2/include/gz/CMakeLists.txt b/ogre2/include/gz/CMakeLists.txt deleted file mode 100644 index 56597eee8..000000000 --- a/ogre2/include/gz/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(rendering) diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2ArrowVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2ArrowVisual.hh deleted file mode 100644 index fb57ed538..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2ArrowVisual.hh +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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_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 deleted file mode 100644 index 82725d4fb..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2AxisVisual.hh +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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_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/Ogre2COMVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2COMVisual.hh deleted file mode 100644 index 5c913e89b..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2COMVisual.hh +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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_OGRE_OGRE2COMVISUAL_HH_ -#define GZ_RENDERING_OGRE_OGRE2COMVISUAL_HH_ - -#include - -#include "gz/rendering/base/BaseCOMVisual.hh" -#include "gz/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 deleted file mode 100644 index 788cea6ee..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Camera.hh +++ /dev/null @@ -1,187 +0,0 @@ -/* - * 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/Ogre2ObjectInterface.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 virtual BaseCamera, - public virtual Ogre2ObjectInterface - { - /// \brief Constructor - protected: Ogre2Camera(); - - /// \brief Destructor - public: virtual ~Ogre2Camera(); - - // 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: virtual void RenderTextureMetalId(void *_textureIdPtr) - const override; - - // Documentation inherited. - public: void SetShadowsDirty() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // 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. - public: virtual Ogre::Camera *OgreCamera() const override; - - // 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 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 deleted file mode 100644 index d48f65733..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Capsule.hh +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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_OGRE2_OGRE2CAPSULE_HH_ -#define GZ_RENDERING_OGRE2_OGRE2CAPSULE_HH_ - -#include -#include - -#include "gz/rendering/base/BaseCapsule.hh" -#include "gz/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 deleted file mode 100644 index 1b7afbc44..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Conversions.hh +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7096c22c5..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2DepthCamera.hh +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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/Ogre2ObjectInterface.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 virtual BaseDepthCamera, - public virtual Ogre2ObjectInterface - { - /// \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; - - // Documentation inherited. - public: virtual Ogre::Camera *OgreCamera() const 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; - - /// \brief Make scene our friend so it can create a camera - private: friend class Ogre2Scene; - }; - } - } -} -#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2DynamicRenderable.hh b/ogre2/include/gz/rendering/ogre2/Ogre2DynamicRenderable.hh deleted file mode 100644 index 983772cd9..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2DynamicRenderable.hh +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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 \ - * gz/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 Helper function to generate colors per-vertex. Only applies - /// to points. The colors fill the normal slots on the vertex buffer. - /// \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 GenerateColors(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 deleted file mode 100644 index b67f85c19..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2GaussianNoisePass.hh +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 \ - * gz/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 deleted file mode 100644 index 04f2e2b9b..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Geometry.hh +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 deleted file mode 100644 index 149c06d90..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2GizmoVisual.hh +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 deleted file mode 100644 index 237712e75..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2GpuRays.hh +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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 deleted file mode 100644 index dab992c6b..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Grid.hh +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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/Ogre2GzOgreRenderingMode.hh b/ogre2/include/gz/rendering/ogre2/Ogre2GzOgreRenderingMode.hh deleted file mode 100644 index c307b0a86..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2GzOgreRenderingMode.hh +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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_OGRE2_OGRE2GZOGRERENDERINGMODE_HH_ -#define GZ_RENDERING_OGRE2_OGRE2GZOGRERENDERINGMODE_HH_ - -#include "gz/rendering/config.hh" -#include "gz/rendering/ogre2/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE - { - /// \brief Rendering modes so that IgnHlms implementations - /// follow alternate code paths or extra customizations - /// when they're enabled - enum IgnOgreRenderingMode - { - /// \brief Normal rendering - IORM_NORMAL, - - /// \brief Render a solid color explicit per object. - /// Used by e.g. Segmentation camera mode - IORM_SOLID_COLOR, - - /// \brief Like IORM_SOLID_COLOR, but if CustomParameter 2u - /// is present, raw diffuse texture will be multiplied against - /// the solid colour. - /// - /// Also Unlit will behave as if IORM_NORMAL - /// - /// Used by thermal camera - IORM_SOLID_THERMAL_COLOR_TEXTURED, - - /// \brief Total number of rendering modes - IORM_COUNT, - }; - } // namespace IGNITION_RENDERING_VERSION_NAMESPACE - } // namespace rendering -} // namespace ignition - -#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Heightmap.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Heightmap.hh deleted file mode 100644 index 5d02c98c9..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Heightmap.hh +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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_OGRE2_OGRE2HEIGHTMAP_HH_ -#define GZ_RENDERING_OGRE2_OGRE2HEIGHTMAP_HH_ - -#include - -#include "gz/rendering/base/BaseHeightmap.hh" -#include "gz/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); - - /// \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 deleted file mode 100644 index f5c04839b..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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 deleted file mode 100644 index 14dd0d041..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2InertiaVisual.hh +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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_OGRE2_OGRE2INERTIAVISUAL_HH_ -#define GZ_RENDERING_OGRE2_OGRE2INERTIAVISUAL_HH_ - -#include - -#include "gz/rendering/base/BaseInertiaVisual.hh" -#include "gz/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 deleted file mode 100644 index 985d09d3c..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2JointVisual.hh +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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_OGRE2_OGRE2JOINTVISUAL_HH_ -#define GZ_RENDERING_OGRE2_OGRE2JOINTVISUAL_HH_ - -#include "gz/rendering/base/BaseJointVisual.hh" -#include "gz/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 deleted file mode 100644 index 13ccf6dc3..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2LidarVisual.hh +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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_OGRELIDARVISUAL_HH_ -#define GZ_RENDERING_OGRE2_OGRELIDARVISUAL_HH_ - -#include -#include -#include "gz/rendering/base/BaseLidarVisual.hh" -#include "gz/rendering/ogre2/Ogre2Visual.hh" -#include "gz/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 deleted file mode 100644 index 85eff319e..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Light.hh +++ /dev/null @@ -1,216 +0,0 @@ -/* - * 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 deleted file mode 100644 index c4ff58d7e..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2LightVisual.hh +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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_OGRE2_OGRE2LIGHTVISUAL_HH_ -#define GZ_RENDERING_OGRE2_OGRE2LIGHTVISUAL_HH_ - -#include - -#include "gz/rendering/base/BaseLightVisual.hh" -#include "gz/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 deleted file mode 100644 index 1364e4f94..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Marker.hh +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 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 diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Material.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Material.hh deleted file mode 100644 index b570b4884..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Material.hh +++ /dev/null @@ -1,345 +0,0 @@ -/* - * 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 deleted file mode 100644 index dab051372..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2MaterialSwitcher.hh +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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 -#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: 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 datablock pointer to their original blendblocks - private: std::unordered_map datablockMap; - - /// \brief A map of ogre sub item pointer to their original low level - /// material. - /// Most objects don't use one so it should be almost always empty. - private: - std::vector> materialMap; - - /// \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 deleted file mode 100644 index ef3c8cd03..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Mesh.hh +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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 deleted file mode 100644 index 43ab40d56..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2MeshFactory.hh +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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 deleted file mode 100644 index bcf40ffb3..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Node.hh +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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 deleted file mode 100644 index 50042bfc6..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Object.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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/Ogre2ObjectInterface.hh b/ogre2/include/gz/rendering/ogre2/Ogre2ObjectInterface.hh deleted file mode 100644 index 4950d1bde..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2ObjectInterface.hh +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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_OGRE2_OGRE2OBJECTINTERFACE_HH_ -#define GZ_RENDERING_OGRE2_OGRE2OBJECTINTERFACE_HH_ - -#include "gz/rendering/config.hh" -#include "gz/rendering/ogre2/Ogre2Includes.hh" -#include "gz/rendering/ogre2/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - - /// \brief Mixin class to provide direct access to Ogre objects. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ObjectInterface - { - public: virtual ~Ogre2ObjectInterface(); - - /// \brief Access to an Ogre::MovableObject. - // - /// \param[in] _typename Name of the object type to retrieve. - /// \return A pointer to an Ogre::MovableObject. Has default nullptr. - public: virtual Ogre::MovableObject *OgreMovableObject( - const char* _typename) const; - - /// \brief Access the Ogre::Camera object. - // - /// \return A pointer to an Ogre::Camera. Has default nullptr. - public: virtual Ogre::Camera *OgreCamera() const = 0; - }; - } - } -} -#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2ParticleEmitter.hh b/ogre2/include/gz/rendering/ogre2/Ogre2ParticleEmitter.hh deleted file mode 100644 index 1eaccba7b..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2ParticleEmitter.hh +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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_OGRE2PARTICLEEMITTER_HH_ -#define GZ_RENDERING_OGRE2_OGRE2PARTICLEEMITTER_HH_ - -#include -#include -#include "gz/rendering/base/BaseParticleEmitter.hh" -#include "gz/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 deleted file mode 100644 index 6d77a4642..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2RayQuery.hh +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 - /// gz/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( - bool _forceSceneUpdate = true); - - /// \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( - bool _forceSceneUpdate); - - /// \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 deleted file mode 100644 index aa4b60772..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh +++ /dev/null @@ -1,259 +0,0 @@ -/* - * 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/Ogre2GzOgreRenderingMode.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 Ogre2IgnHlmsSphericalClipMinDistance; - - /// \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); - - // Documentation Inherited - public: virtual rendering::GraphicsAPI GraphicsAPI() const override; - - /// \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 Deprecated. Use SphericalClipMinDistance instead - public: Ogre2IgnHlmsSphericalClipMinDistance IGN_DEPRECATED(7) & - HlmsCustomizations(); - - /// \brief Retrieves Hlms customizations for tweaking them - /// \return Ogre HLMS customizations - public: Ogre2IgnHlmsSphericalClipMinDistance &SphericalClipMinDistance(); - - /// \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 Sets the current rendering mode. See IgnOgreRenderingMode - /// and see Ogre::IgnHlmsPbs - /// \param[in] renderingMode - public: void SetIgnOgreRenderingMode(IgnOgreRenderingMode renderingMode); - - /// \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 deleted file mode 100644 index 0d13e7f32..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2RenderPass.hh +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 \ - * gz/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 deleted file mode 100644 index 281899b71..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2RenderTarget.hh +++ /dev/null @@ -1,314 +0,0 @@ -/* - * 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; - - // Documentation inherited - public: void MetalIdImpl(void *_textureIdPtr) 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 - public: virtual void MetalId(void *_textureIdPtr) 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 deleted file mode 100644 index 6488a3ef6..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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 deleted file mode 100644 index 3dd7d28e8..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2RenderTypes.hh +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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 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 Ogre2ObjectInterface; - 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 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 Ogre2ObjectInterfacePtr; - 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 deleted file mode 100644 index ae1f766d9..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Scene.hh +++ /dev/null @@ -1,448 +0,0 @@ -/* - * 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 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 deleted file mode 100644 index 6f383cdd3..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2SegmentationCamera.hh +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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_OGRE2_OGRE2SEGMENTATIONCAMERA_HH_ -#define GZ_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 "gz/rendering/base/BaseSegmentationCamera.hh" -#include "gz/rendering/ogre2/Ogre2Includes.hh" -#include "gz/rendering/ogre2/Ogre2ObjectInterface.hh" -#include "gz/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 virtual BaseSegmentationCamera, - public virtual Ogre2ObjectInterface - { - /// \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; - - // Documentation inherited. - public: virtual Ogre::Camera *OgreCamera() 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 deleted file mode 100644 index 6aaf3356c..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2SelectionBuffer.hh +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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 deleted file mode 100644 index 00141d7e0..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Sensor.hh +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 deleted file mode 100644 index 6bb732a8b..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Storage.hh +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 deleted file mode 100644 index e42c9843f..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2ThermalCamera.hh +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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/Ogre2ObjectInterface.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 virtual BaseThermalCamera, - public virtual Ogre2ObjectInterface - { - /// \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; - - // Documentation inherited. - public: virtual Ogre::Camera *OgreCamera() const 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; - - /// \brief Make scene our friend so it can create a camera - private: friend class Ogre2Scene; - }; - } - } -} -#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Visual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Visual.hh deleted file mode 100644 index eec1bbdbc..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Visual.hh +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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 deleted file mode 100644 index f26d42605..000000000 --- a/ogre2/include/gz/rendering/ogre2/Ogre2WireBox.hh +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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_OGRE2WIREBOX_HH_ -#define GZ_RENDERING_OGRE2_OGRE2WIREBOX_HH_ - -#include -#include "gz/rendering/base/BaseWireBox.hh" -#include "gz/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 deleted file mode 100644 index c4092f0cd..000000000 --- a/ogre2/include/gz/rendering/ogre2/ogre2.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/ogre2/include/gz/rendering/CMakeLists.txt b/ogre2/include/ignition/rendering/CMakeLists.txt similarity index 100% rename from ogre2/include/gz/rendering/CMakeLists.txt rename to ogre2/include/ignition/rendering/CMakeLists.txt diff --git a/ogre2/include/ignition/rendering/ogre2.hh b/ogre2/include/ignition/rendering/ogre2.hh deleted file mode 100644 index e3826fd92..000000000 --- a/ogre2/include/ignition/rendering/ogre2.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/ogre2/include/ignition/rendering/ogre2/Export.hh b/ogre2/include/ignition/rendering/ogre2/Export.hh deleted file mode 100644 index 3d6d75e98..000000000 --- a/ogre2/include/ignition/rendering/ogre2/Export.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh index 59357cd1e..60dbd73c0 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh @@ -14,5 +14,32 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2ARROWVISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2ARROWVISUAL_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh index 5eb9e970f..e76bde5b8 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh @@ -14,5 +14,32 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2AXISVISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2AXISVISUAL_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2COMVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2COMVisual.hh index 523d0781f..d55afb8b7 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2COMVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2COMVisual.hh @@ -13,6 +13,71 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre2/Ogre2Camera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh index c3e18fdd3..41d857aed 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh @@ -14,5 +14,174 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2CAMERA_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2CAMERA_HH_ -#include +#include + +#include "ignition/rendering/base/BaseCamera.hh" +#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" +#include "ignition/rendering/ogre2/Ogre2Includes.hh" +#include "ignition/rendering/ogre2/Ogre2ObjectInterface.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 virtual BaseCamera, + public virtual Ogre2ObjectInterface + { + /// \brief Constructor + protected: Ogre2Camera(); + + /// \brief Destructor + public: virtual ~Ogre2Camera(); + + // 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: virtual void RenderTextureMetalId(void *_textureIdPtr) + const override; + + // Documentation inherited. + public: void SetShadowsDirty() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // 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. + public: virtual Ogre::Camera *OgreCamera() const override; + + // 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 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/ignition/rendering/ogre2/Ogre2Capsule.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Capsule.hh index c5014fa30..8832c012a 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Capsule.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Capsule.hh @@ -13,6 +13,69 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre2/Ogre2Conversions.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh index 68df00907..ae88820c7 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh @@ -14,5 +14,106 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2CONVERSIONS_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2CONVERSIONS_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh index 8eaf8dc05..84f94ba88 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh @@ -13,6 +13,157 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/Ogre2ObjectInterface.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 virtual BaseDepthCamera, + public virtual Ogre2ObjectInterface + { + /// \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; + + // Documentation inherited. + public: virtual Ogre::Camera *OgreCamera() const 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; + + /// \brief Make scene our friend so it can create a camera + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh index 310188740..502bb3cc4 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh @@ -13,6 +13,145 @@ * 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 + +#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 Helper function to generate colors per-vertex. Only applies + /// to points. The colors fill the normal slots on the vertex buffer. + /// \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 GenerateColors(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/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh index 9cccd0af5..05c65caac 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh @@ -14,5 +14,47 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2GAUSSIANNOISEPASS_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2GAUSSIANNOISEPASS_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh index dac66aba0..fbea7edf5 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh @@ -14,5 +14,55 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2GEOMETRY_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2GEOMETRY_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh index b8e9f1ebf..daf85011d 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh @@ -14,5 +14,31 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2GIZMOVISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2GIZMOVISUAL_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh index 7c4352820..4e609a191 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh @@ -13,6 +13,152 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh index 0269e078d..59538cdc4 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh @@ -13,6 +13,68 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Heightmap.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Heightmap.hh index d877ae3ea..c95544f87 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Heightmap.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Heightmap.hh @@ -13,6 +13,99 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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); + + /// \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/ignition/rendering/ogre2/Ogre2IgnOgreRenderingMode.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2IgnOgreRenderingMode.hh index 4cfb48df9..84e0ff890 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2IgnOgreRenderingMode.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2IgnOgreRenderingMode.hh @@ -14,5 +14,44 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2IGNOGRERENDERINGMODE_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2IGNOGRERENDERINGMODE_HH_ -#include +#include "ignition/rendering/config.hh" +#include "ignition/rendering/ogre2/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE + { + /// \brief Rendering modes so that IgnHlms implementations + /// follow alternate code paths or extra customizations + /// when they're enabled + enum IgnOgreRenderingMode + { + /// \brief Normal rendering + IORM_NORMAL, + + /// \brief Render a solid color explicit per object. + /// Used by e.g. Segmentation camera mode + IORM_SOLID_COLOR, + + /// \brief Like IORM_SOLID_COLOR, but if CustomParameter 2u + /// is present, raw diffuse texture will be multiplied against + /// the solid colour. + /// + /// Also Unlit will behave as if IORM_NORMAL + /// + /// Used by thermal camera + IORM_SOLID_THERMAL_COLOR_TEXTURED, + + /// \brief Total number of rendering modes + IORM_COUNT, + }; + } // namespace IGNITION_RENDERING_VERSION_NAMESPACE + } // namespace rendering +} // namespace ignition + +#endif diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh index d77808390..27d360bf7 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh @@ -14,5 +14,106 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2INCLUDES_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2INCLUDES_HH_ -#include +// 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/ignition/rendering/ogre2/Ogre2InertiaVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2InertiaVisual.hh index 479c80b09..c15a2b112 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2InertiaVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2InertiaVisual.hh @@ -14,5 +14,74 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2INERTIAVISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2INERTIAVISUAL_HH_ -#include +#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/ignition/rendering/ogre2/Ogre2JointVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2JointVisual.hh index 59a243982..4a7879384 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2JointVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2JointVisual.hh @@ -14,5 +14,31 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2JOINTVISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2JOINTVISUAL_HH_ -#include +#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/ignition/rendering/ogre2/Ogre2LidarVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2LidarVisual.hh index f69378f9f..8a3877496 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2LidarVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2LidarVisual.hh @@ -13,6 +13,77 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre2/Ogre2Light.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh index 57ea35043..458a02e66 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh @@ -14,5 +14,203 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2LIGHT_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2LIGHT_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2LightVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2LightVisual.hh index 12ac08d7e..b1bd2281b 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2LightVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2LightVisual.hh @@ -14,5 +14,68 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2LIGHTVISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2LIGHTVISUAL_HH_ -#include +#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/ignition/rendering/ogre2/Ogre2Marker.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh index 722485873..0119aeec2 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh @@ -13,6 +13,80 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh index 2434b36df..dcf4c9fd8 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh @@ -14,5 +14,332 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2MATERIAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2MATERIAL_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh index e2edba50f..9e4472e0f 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh @@ -13,6 +13,98 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#ifndef IGNITION_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_ + +#include +#include +#include +#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 datablock pointer to their original blendblocks + private: std::unordered_map datablockMap; + + /// \brief A map of ogre sub item pointer to their original low level + /// material. + /// Most objects don't use one so it should be almost always empty. + private: + std::vector> materialMap; + + /// \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/ignition/rendering/ogre2/Ogre2Mesh.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh index f0c10737a..cbad21a14 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh @@ -14,5 +14,142 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2MESH_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2MESH_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh index 52e148fb7..202607cea 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh @@ -14,5 +14,137 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh index b382cfac7..5a6be9005 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh @@ -14,5 +14,120 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2NODE_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2NODE_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh index f54faaa09..1efe6b1eb 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh @@ -14,5 +14,40 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2OBJECT_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2OBJECT_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ObjectInterface.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ObjectInterface.hh index e6a0500b2..e58187fdc 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2ObjectInterface.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ObjectInterface.hh @@ -14,5 +14,37 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2OBJECTINTERFACE_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2OBJECTINTERFACE_HH_ -#include +#include "ignition/rendering/config.hh" +#include "ignition/rendering/ogre2/Ogre2Includes.hh" +#include "ignition/rendering/ogre2/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + /// \brief Mixin class to provide direct access to Ogre objects. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ObjectInterface + { + public: virtual ~Ogre2ObjectInterface(); + + /// \brief Access to an Ogre::MovableObject. + // + /// \param[in] _typename Name of the object type to retrieve. + /// \return A pointer to an Ogre::MovableObject. Has default nullptr. + public: virtual Ogre::MovableObject *OgreMovableObject( + const char* _typename) const; + + /// \brief Access the Ogre::Camera object. + // + /// \return A pointer to an Ogre::Camera. Has default nullptr. + public: virtual Ogre::Camera *OgreCamera() const = 0; + }; + } + } +} +#endif diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ParticleEmitter.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ParticleEmitter.hh index f0861ef8b..2280f5b9f 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2ParticleEmitter.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ParticleEmitter.hh @@ -14,5 +14,98 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2PARTICLEEMITTER_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2PARTICLEEMITTER_HH_ -#include +#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/ignition/rendering/ogre2/Ogre2RayQuery.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh index eceb2e4b5..789141346 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh @@ -14,5 +14,60 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2RAYQUERY_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2RAYQUERY_HH_ -#include +#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( + bool _forceSceneUpdate = true); + + /// \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( + bool _forceSceneUpdate); + + /// \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/ignition/rendering/ogre2/Ogre2RenderEngine.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh index e417dd198..cb10b9e17 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh @@ -14,5 +14,246 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERENGINE_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2RENDERENGINE_HH_ -#include +#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/Ogre2IgnOgreRenderingMode.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 Ogre2IgnHlmsSphericalClipMinDistance; + + /// \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); + + // Documentation Inherited + public: virtual rendering::GraphicsAPI GraphicsAPI() const override; + + /// \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 Deprecated. Use SphericalClipMinDistance instead + public: Ogre2IgnHlmsSphericalClipMinDistance IGN_DEPRECATED(7) & + HlmsCustomizations(); + + /// \brief Retrieves Hlms customizations for tweaking them + /// \return Ogre HLMS customizations + public: Ogre2IgnHlmsSphericalClipMinDistance &SphericalClipMinDistance(); + + /// \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 Sets the current rendering mode. See IgnOgreRenderingMode + /// and see Ogre::IgnHlmsPbs + /// \param[in] renderingMode + public: void SetIgnOgreRenderingMode(IgnOgreRenderingMode renderingMode); + + /// \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/ignition/rendering/ogre2/Ogre2RenderPass.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh index ef71b300a..83ae52efd 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh @@ -14,5 +14,67 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERPASS_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2RENDERPASS_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh index 8a4240795..e4df31750 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh @@ -14,5 +14,301 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_ -#include +#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; + + // Documentation inherited + public: void MetalIdImpl(void *_textureIdPtr) 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 + public: virtual void MetalId(void *_textureIdPtr) 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/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh index b7c7c40ed..fcda332d5 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh @@ -14,5 +14,104 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGETMATERIAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGETMATERIAL_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh index c0ab47811..c1cb4de7b 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh @@ -14,5 +14,123 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERTYPES_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2RENDERTYPES_HH_ -#include +#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 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 Ogre2ObjectInterface; + 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 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 Ogre2ObjectInterfacePtr; + 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/ignition/rendering/ogre2/Ogre2Scene.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh index c6deba168..6aeb33aac 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh @@ -14,5 +14,435 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2SCENE_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2SCENE_HH_ -#include +#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 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/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh index d1cd9a749..66cdec820 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh @@ -13,6 +13,104 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/Ogre2ObjectInterface.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 virtual BaseSegmentationCamera, + public virtual Ogre2ObjectInterface + { + /// \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; + + // Documentation inherited. + public: virtual Ogre::Camera *OgreCamera() 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/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh index 4cbbe9334..a41ceea66 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh @@ -13,6 +13,90 @@ * 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 + +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh index 49baa7263..47b7da64d 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh @@ -14,5 +14,29 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2SENSOR_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2SENSOR_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh index 5abf53084..8c193562e 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh @@ -14,5 +14,56 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2STORAGE_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2STORAGE_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh index 505c140f0..1afb11c91 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh @@ -13,6 +13,105 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/Ogre2ObjectInterface.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 virtual BaseThermalCamera, + public virtual Ogre2ObjectInterface + { + /// \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; + + // Documentation inherited. + public: virtual Ogre::Camera *OgreCamera() const 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; + + /// \brief Make scene our friend so it can create a camera + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh index 353a6310c..fd07fdca2 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh @@ -14,5 +14,99 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2VISUAL_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2VISUAL_HH_ -#include +#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 diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2WireBox.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2WireBox.hh index a8eaae4fe..48ed93447 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2WireBox.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2WireBox.hh @@ -13,6 +13,69 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ +*/ -#include +#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/ignition/rendering/ogre2/detail/Export.hh b/ogre2/include/ignition/rendering/ogre2/detail/Export.hh deleted file mode 100644 index e6d0f0430..000000000 --- a/ogre2/include/ignition/rendering/ogre2/detail/Export.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/ogre2/include/ignition/rendering/ogre2/ogre2.hh.in b/ogre2/include/ignition/rendering/ogre2/ogre2.hh.in new file mode 100644 index 000000000..acfd26ae7 --- /dev/null +++ b/ogre2/include/ignition/rendering/ogre2/ogre2.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/ogre2/src/terrain/Terra/CMakeLists.txt b/ogre2/src/terrain/Terra/CMakeLists.txt index 7b56a69ed..83c9ac907 100644 --- a/ogre2/src/terrain/Terra/CMakeLists.txt +++ b/ogre2/src/terrain/Terra/CMakeLists.txt @@ -8,7 +8,7 @@ file( GLOB_RECURSE TERRA_SOURCES add_library(${PROJECT_NAME} STATIC ${TERRA_SOURCES}) -if(IGN_ADD_fPIC_TO_LIBRARIES AND NOT _gz_add_library_INTERFACE) +if(IGN_ADD_fPIC_TO_LIBRARIES AND NOT _ign_add_library_INTERFACE) target_compile_options(${PROJECT_NAME} PRIVATE -fPIC) endif() diff --git a/optix/include/CMakeLists.txt b/optix/include/CMakeLists.txt index 4b2bdd7bb..297e254ff 100644 --- a/optix/include/CMakeLists.txt +++ b/optix/include/CMakeLists.txt @@ -1,2 +1 @@ -add_subdirectory(gz) -install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) +add_subdirectory(ignition/rendering) diff --git a/optix/include/gz/CMakeLists.txt b/optix/include/gz/CMakeLists.txt deleted file mode 100644 index 56597eee8..000000000 --- a/optix/include/gz/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(rendering) diff --git a/optix/include/gz/rendering/optix/OptixArrowVisual.hh b/optix/include/gz/rendering/optix/OptixArrowVisual.hh deleted file mode 100644 index 260fa8dad..000000000 --- a/optix/include/gz/rendering/optix/OptixArrowVisual.hh +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 deleted file mode 100644 index 37f93f619..000000000 --- a/optix/include/gz/rendering/optix/OptixAxisVisual.hh +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 deleted file mode 100644 index 872173cfb..000000000 --- a/optix/include/gz/rendering/optix/OptixBox.hh +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5ac597500..000000000 --- a/optix/include/gz/rendering/optix/OptixCamera.hh +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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 deleted file mode 100644 index d3a4d6352..000000000 --- a/optix/include/gz/rendering/optix/OptixCone.hh +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 deleted file mode 100644 index bc6ac6a91..000000000 --- a/optix/include/gz/rendering/optix/OptixConversions.hh +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 deleted file mode 100644 index 08ac588fc..000000000 --- a/optix/include/gz/rendering/optix/OptixCylinder.hh +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 deleted file mode 100644 index 1f5b2b029..000000000 --- a/optix/include/gz/rendering/optix/OptixGeometry.hh +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 deleted file mode 100644 index 9adbaf707..000000000 --- a/optix/include/gz/rendering/optix/OptixGrid.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 deleted file mode 100644 index 001c7d1ee..000000000 --- a/optix/include/gz/rendering/optix/OptixIncludes.hh +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 deleted file mode 100644 index 82fd02e0a..000000000 --- a/optix/include/gz/rendering/optix/OptixLight.hh +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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 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 diff --git a/optix/include/gz/rendering/optix/OptixLightManager.hh b/optix/include/gz/rendering/optix/OptixLightManager.hh deleted file mode 100644 index 36d321695..000000000 --- a/optix/include/gz/rendering/optix/OptixLightManager.hh +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 deleted file mode 100644 index bfbe04593..000000000 --- a/optix/include/gz/rendering/optix/OptixLightTypes.hh +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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 deleted file mode 100644 index 1caa50378..000000000 --- a/optix/include/gz/rendering/optix/OptixMaterial.hh +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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 deleted file mode 100644 index a9c777029..000000000 --- a/optix/include/gz/rendering/optix/OptixMesh.hh +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 deleted file mode 100644 index fc0681a1a..000000000 --- a/optix/include/gz/rendering/optix/OptixMeshFactory.hh +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5deb803e9..000000000 --- a/optix/include/gz/rendering/optix/OptixNode.hh +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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 deleted file mode 100644 index 6ff746085..000000000 --- a/optix/include/gz/rendering/optix/OptixObject.hh +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 deleted file mode 100644 index 649690aa2..000000000 --- a/optix/include/gz/rendering/optix/OptixPrimitive.hh +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 deleted file mode 100644 index b46c1ccf6..000000000 --- a/optix/include/gz/rendering/optix/OptixRayTypes.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 deleted file mode 100644 index 05635a883..000000000 --- a/optix/include/gz/rendering/optix/OptixRenderEngine.hh +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5beffe443..000000000 --- a/optix/include/gz/rendering/optix/OptixRenderTarget.hh +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 deleted file mode 100644 index 12202c74f..000000000 --- a/optix/include/gz/rendering/optix/OptixRenderTypes.hh +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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 deleted file mode 100644 index 6f94fcff4..000000000 --- a/optix/include/gz/rendering/optix/OptixScene.hh +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7d3f2dc0f..000000000 --- a/optix/include/gz/rendering/optix/OptixSensor.hh +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 deleted file mode 100644 index 9b3092413..000000000 --- a/optix/include/gz/rendering/optix/OptixSphere.hh +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0e4fddd21..000000000 --- a/optix/include/gz/rendering/optix/OptixStorage.hh +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 deleted file mode 100644 index 62b1f3b47..000000000 --- a/optix/include/gz/rendering/optix/OptixTextureFactory.hh +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 deleted file mode 100644 index 990427f22..000000000 --- a/optix/include/gz/rendering/optix/OptixVisual.hh +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 deleted file mode 100644 index c4092f0cd..000000000 --- a/optix/include/gz/rendering/optix/optix.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/optix/include/ignition/optix.hh b/optix/include/ignition/optix.hh deleted file mode 100644 index 7d1f6ce18..000000000 --- a/optix/include/ignition/optix.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/optix/include/gz/rendering/CMakeLists.txt b/optix/include/ignition/rendering/CMakeLists.txt similarity index 100% rename from optix/include/gz/rendering/CMakeLists.txt rename to optix/include/ignition/rendering/CMakeLists.txt diff --git a/optix/include/ignition/rendering/optix/Export.hh b/optix/include/ignition/rendering/optix/Export.hh deleted file mode 100644 index 9fc7ed7ef..000000000 --- a/optix/include/ignition/rendering/optix/Export.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/optix/include/ignition/rendering/optix/OptixArrowVisual.hh b/optix/include/ignition/rendering/optix/OptixArrowVisual.hh index aa929401b..e3e6d19d3 100644 --- a/optix/include/ignition/rendering/optix/OptixArrowVisual.hh +++ b/optix/include/ignition/rendering/optix/OptixArrowVisual.hh @@ -14,5 +14,28 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXARROWVISUAL_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXARROWVISUAL_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixAxisVisual.hh b/optix/include/ignition/rendering/optix/OptixAxisVisual.hh index c8d0d2af6..a4b47bca2 100644 --- a/optix/include/ignition/rendering/optix/OptixAxisVisual.hh +++ b/optix/include/ignition/rendering/optix/OptixAxisVisual.hh @@ -14,5 +14,28 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXAXISVISUAL_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXAXISVISUAL_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixBox.hh b/optix/include/ignition/rendering/optix/OptixBox.hh index cf3c79d80..6073bdf97 100644 --- a/optix/include/ignition/rendering/optix/OptixBox.hh +++ b/optix/include/ignition/rendering/optix/OptixBox.hh @@ -14,5 +14,29 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXBOX_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXBOX_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixCamera.hh b/optix/include/ignition/rendering/optix/OptixCamera.hh index 8cde9744b..5a02e6c12 100644 --- a/optix/include/ignition/rendering/optix/OptixCamera.hh +++ b/optix/include/ignition/rendering/optix/OptixCamera.hh @@ -14,5 +14,81 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXCAMERA_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXCAMERA_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixCone.hh b/optix/include/ignition/rendering/optix/OptixCone.hh index e9e7102a4..35a78afab 100644 --- a/optix/include/ignition/rendering/optix/OptixCone.hh +++ b/optix/include/ignition/rendering/optix/OptixCone.hh @@ -14,5 +14,29 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXCONE_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXCONE_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixConversions.hh b/optix/include/ignition/rendering/optix/OptixConversions.hh index 45b7d6319..646dbee82 100644 --- a/optix/include/ignition/rendering/optix/OptixConversions.hh +++ b/optix/include/ignition/rendering/optix/OptixConversions.hh @@ -14,5 +14,53 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXCONVERSIONS_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXCONVERSIONS_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixCylinder.hh b/optix/include/ignition/rendering/optix/OptixCylinder.hh index dfbbf9b6d..f04d6591d 100644 --- a/optix/include/ignition/rendering/optix/OptixCylinder.hh +++ b/optix/include/ignition/rendering/optix/OptixCylinder.hh @@ -14,5 +14,29 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXCYLINDER_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXCYLINDER_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixGeometry.hh b/optix/include/ignition/rendering/optix/OptixGeometry.hh index 415b69b39..579a1c6c5 100644 --- a/optix/include/ignition/rendering/optix/OptixGeometry.hh +++ b/optix/include/ignition/rendering/optix/OptixGeometry.hh @@ -14,5 +14,41 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXGEOMETRY_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXGEOMETRY_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixGrid.hh b/optix/include/ignition/rendering/optix/OptixGrid.hh index 632692ed6..ded3af240 100644 --- a/optix/include/ignition/rendering/optix/OptixGrid.hh +++ b/optix/include/ignition/rendering/optix/OptixGrid.hh @@ -14,5 +14,40 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXGRID_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXGRID_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixIncludes.hh b/optix/include/ignition/rendering/optix/OptixIncludes.hh index c315c10aa..2966aa3ce 100644 --- a/optix/include/ignition/rendering/optix/OptixIncludes.hh +++ b/optix/include/ignition/rendering/optix/OptixIncludes.hh @@ -14,5 +14,10 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXINCLUDES_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXINCLUDES_HH_ -#include +// #include +#include + +#endif diff --git a/optix/include/ignition/rendering/optix/OptixLight.hh b/optix/include/ignition/rendering/optix/OptixLight.hh index 4d916c04a..39fb91efa 100644 --- a/optix/include/ignition/rendering/optix/OptixLight.hh +++ b/optix/include/ignition/rendering/optix/OptixLight.hh @@ -14,5 +14,152 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXLIGHT_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXLIGHT_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixLightManager.hh b/optix/include/ignition/rendering/optix/OptixLightManager.hh index 5c89ec97b..312c66843 100644 --- a/optix/include/ignition/rendering/optix/OptixLightManager.hh +++ b/optix/include/ignition/rendering/optix/OptixLightManager.hh @@ -14,5 +14,69 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXLIGHTMANAGER_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXLIGHTMANAGER_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixLightTypes.hh b/optix/include/ignition/rendering/optix/OptixLightTypes.hh index e08570d7f..b150ad0f8 100644 --- a/optix/include/ignition/rendering/optix/OptixLightTypes.hh +++ b/optix/include/ignition/rendering/optix/OptixLightTypes.hh @@ -14,5 +14,87 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXLIGHTTYPES_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXLIGHTTYPES_HH_ -#include +#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/ignition/rendering/optix/OptixMaterial.hh b/optix/include/ignition/rendering/optix/OptixMaterial.hh index 7924615d3..0c2605a2f 100644 --- a/optix/include/ignition/rendering/optix/OptixMaterial.hh +++ b/optix/include/ignition/rendering/optix/OptixMaterial.hh @@ -14,5 +14,136 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXMATERIAL_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXMATERIAL_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixMesh.hh b/optix/include/ignition/rendering/optix/OptixMesh.hh index 272cdf1af..778ab54e5 100644 --- a/optix/include/ignition/rendering/optix/OptixMesh.hh +++ b/optix/include/ignition/rendering/optix/OptixMesh.hh @@ -14,5 +14,76 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXMESH_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXMESH_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixMeshFactory.hh b/optix/include/ignition/rendering/optix/OptixMeshFactory.hh index beaa42ce0..4bbe206c1 100644 --- a/optix/include/ignition/rendering/optix/OptixMeshFactory.hh +++ b/optix/include/ignition/rendering/optix/OptixMeshFactory.hh @@ -14,5 +14,86 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXMESHFACTORY_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXMESHFACTORY_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixNode.hh b/optix/include/ignition/rendering/optix/OptixNode.hh index 2e4d7dfa1..56efc518b 100644 --- a/optix/include/ignition/rendering/optix/OptixNode.hh +++ b/optix/include/ignition/rendering/optix/OptixNode.hh @@ -14,5 +14,91 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXNODE_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXNODE_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixObject.hh b/optix/include/ignition/rendering/optix/OptixObject.hh index 00359730e..a7ba45572 100644 --- a/optix/include/ignition/rendering/optix/OptixObject.hh +++ b/optix/include/ignition/rendering/optix/OptixObject.hh @@ -14,5 +14,33 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXOBJECT_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXOBJECT_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixPrimitive.hh b/optix/include/ignition/rendering/optix/OptixPrimitive.hh index 42e5cc0ab..0e0ff3f5b 100644 --- a/optix/include/ignition/rendering/optix/OptixPrimitive.hh +++ b/optix/include/ignition/rendering/optix/OptixPrimitive.hh @@ -14,5 +14,62 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXPRIMITIVE_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXPRIMITIVE_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixRayTypes.hh b/optix/include/ignition/rendering/optix/OptixRayTypes.hh index a69f2024b..bcfc9d966 100644 --- a/optix/include/ignition/rendering/optix/OptixRayTypes.hh +++ b/optix/include/ignition/rendering/optix/OptixRayTypes.hh @@ -14,5 +14,45 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXRAYTYPES_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXRAYTYPES_HH_ -#include +#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/ignition/rendering/optix/OptixRenderEngine.hh b/optix/include/ignition/rendering/optix/OptixRenderEngine.hh index 6cfe01196..f823021f9 100644 --- a/optix/include/ignition/rendering/optix/OptixRenderEngine.hh +++ b/optix/include/ignition/rendering/optix/OptixRenderEngine.hh @@ -14,5 +14,77 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXRENDERENGINE_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXRENDERENGINE_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixRenderTarget.hh b/optix/include/ignition/rendering/optix/OptixRenderTarget.hh index 75a5be849..23ae139b8 100644 --- a/optix/include/ignition/rendering/optix/OptixRenderTarget.hh +++ b/optix/include/ignition/rendering/optix/OptixRenderTarget.hh @@ -14,5 +14,70 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXRENDERTARGET_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXRENDERTARGET_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixRenderTypes.hh b/optix/include/ignition/rendering/optix/OptixRenderTypes.hh index 566085df7..6f876f2cb 100644 --- a/optix/include/ignition/rendering/optix/OptixRenderTypes.hh +++ b/optix/include/ignition/rendering/optix/OptixRenderTypes.hh @@ -14,5 +14,93 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXRENDERTYPES_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXRENDERTYPES_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixScene.hh b/optix/include/ignition/rendering/optix/OptixScene.hh index c15110665..5b69b9fa8 100644 --- a/optix/include/ignition/rendering/optix/OptixScene.hh +++ b/optix/include/ignition/rendering/optix/OptixScene.hh @@ -14,5 +14,189 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXSCENE_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXSCENE_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixSensor.hh b/optix/include/ignition/rendering/optix/OptixSensor.hh index 87e98f48c..8804d5771 100644 --- a/optix/include/ignition/rendering/optix/OptixSensor.hh +++ b/optix/include/ignition/rendering/optix/OptixSensor.hh @@ -14,5 +14,26 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXSENSOR_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXSENSOR_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixSphere.hh b/optix/include/ignition/rendering/optix/OptixSphere.hh index 8cfc10231..e7deb55f1 100644 --- a/optix/include/ignition/rendering/optix/OptixSphere.hh +++ b/optix/include/ignition/rendering/optix/OptixSphere.hh @@ -14,5 +14,29 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXSPHERE_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXSPHERE_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixStorage.hh b/optix/include/ignition/rendering/optix/OptixStorage.hh index 9bf6e77df..f81983810 100644 --- a/optix/include/ignition/rendering/optix/OptixStorage.hh +++ b/optix/include/ignition/rendering/optix/OptixStorage.hh @@ -14,5 +14,53 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXSTORAGE_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXSTORAGE_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixTextureFactory.hh b/optix/include/ignition/rendering/optix/OptixTextureFactory.hh index 9ae930569..fa5f6cd86 100644 --- a/optix/include/ignition/rendering/optix/OptixTextureFactory.hh +++ b/optix/include/ignition/rendering/optix/OptixTextureFactory.hh @@ -14,5 +14,39 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXTEXTUREFACTORY_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXTEXTUREFACTORY_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/OptixVisual.hh b/optix/include/ignition/rendering/optix/OptixVisual.hh index 218ff401b..9b38dd8fe 100644 --- a/optix/include/ignition/rendering/optix/OptixVisual.hh +++ b/optix/include/ignition/rendering/optix/OptixVisual.hh @@ -14,5 +14,49 @@ * limitations under the License. * */ +#ifndef IGNITION_RENDERING_OPTIX_OPTIXVISUAL_HH_ +#define IGNITION_RENDERING_OPTIX_OPTIXVISUAL_HH_ -#include +#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 diff --git a/optix/include/ignition/rendering/optix/detail/Export.hh b/optix/include/ignition/rendering/optix/detail/Export.hh deleted file mode 100644 index 9fc7ed7ef..000000000 --- a/optix/include/ignition/rendering/optix/detail/Export.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/optix/include/ignition/rendering/optix/optix.hh b/optix/include/ignition/rendering/optix/optix.hh deleted file mode 100644 index 3d3b78b0c..000000000 --- a/optix/include/ignition/rendering/optix/optix.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 diff --git a/optix/include/ignition/rendering/optix/optix.hh.in b/optix/include/ignition/rendering/optix/optix.hh.in new file mode 100644 index 000000000..acfd26ae7 --- /dev/null +++ b/optix/include/ignition/rendering/optix/optix.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers}