diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a94f2cf8..4b76b9235 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,10 @@ find_package(ignition-cmake2 2.14.0 REQUIRED) #============================================================================ # Set up the project #============================================================================ -ign_configure_project(VERSION_SUFFIX) +ign_configure_project( + REPLACE_IGNITION_INCLUDE_PATH gz/rendering + VERSION_SUFFIX +) #============================================================================ # Set project-specific options diff --git a/examples/actor_animation/GlutWindow.cc b/examples/actor_animation/GlutWindow.cc index 8e5a589b3..fd321cbf9 100644 --- a/examples/actor_animation/GlutWindow.cc +++ b/examples/actor_animation/GlutWindow.cc @@ -33,16 +33,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" @@ -164,7 +164,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -194,7 +194,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) @@ -239,10 +239,10 @@ void handleMouse() ////////////////////////////////////////////////// void updatePose(double _time) { - std::map animFrames; + std::map animFrames; animFrames = g_skelAnim->PoseAt(_time, true); - std::map skinFrames; + std::map skinFrames; for (auto pair : animFrames) { @@ -250,7 +250,7 @@ void updatePose(double _time) auto animTf = pair.second; std::string skinName = g_skel->NodeNameAnimToSkin(g_animIdx, animName); - ignition::math::Matrix4d skinTf = + gz::math::Matrix4d skinTf = g_skel->AlignTranslation(g_animIdx, animName) * animTf * g_skel->AlignRotation(g_animIdx, animName); diff --git a/examples/actor_animation/GlutWindow.hh b/examples/actor_animation/GlutWindow.hh index 319b224d7..c8d8ab3c7 100644 --- a/examples/actor_animation/GlutWindow.hh +++ b/examples/actor_animation/GlutWindow.hh @@ -14,15 +14,15 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_ACTOR_ANIMATION_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/common/graphics/Types.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/common/graphics/Types.hh" -namespace ir = ignition::rendering; -namespace ic = ignition::common; +namespace ir = gz::rendering; +namespace ic = gz::common; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/actor_animation/Main.cc b/examples/actor_animation/Main.cc index bdbc2e789..db431f6e6 100644 --- a/examples/actor_animation/Main.cc +++ b/examples/actor_animation/Main.cc @@ -27,16 +27,16 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; const std::string RESOURCE_PATH = diff --git a/examples/camera_tracking/GlutWindow.cc b/examples/camera_tracking/GlutWindow.cc index e127a528a..b4f66ead2 100644 --- a/examples/camera_tracking/GlutWindow.cc +++ b/examples/camera_tracking/GlutWindow.cc @@ -31,12 +31,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -92,8 +92,8 @@ struct mouseButton struct mouseButton g_mouse; std::mutex g_mouseMutex; -ignition::math::Vector3d g_trackOffset(1.0, 0, 0); -ignition::math::Vector3d g_followOffset(-3, 0, 3); +gz::math::Vector3d g_trackOffset(1.0, 0, 0); +gz::math::Vector3d g_followOffset(-3, 0, 3); ////////////////////////////////////////////////// @@ -158,7 +158,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -188,7 +188,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) @@ -296,21 +296,21 @@ void keyboardCB(unsigned char _key, int, int) if (_key == 'w' || _key == 'W') { node->SetWorldPosition(node->WorldPosition() + - node->WorldRotation() * ignition::math::Vector3d(posIncr, 0, 0)); + node->WorldRotation() * gz::math::Vector3d(posIncr, 0, 0)); } else if (_key == 's' || _key == 'S') { node->SetWorldPosition(node->WorldPosition() + - node->WorldRotation() * ignition::math::Vector3d(-posIncr, 0, 0)); + node->WorldRotation() * gz::math::Vector3d(-posIncr, 0, 0)); } else if (_key == 'a' || _key == 'A') { - node->SetWorldRotation(ignition::math::Quaterniond(0, 0, + node->SetWorldRotation(gz::math::Quaterniond(0, 0, node->WorldRotation().Yaw() + yawIncr)); } else if (_key == 'd' || _key == 'D') { - node->SetWorldRotation(ignition::math::Quaterniond(0, 0, + node->SetWorldRotation(gz::math::Quaterniond(0, 0, node->WorldRotation().Yaw() - yawIncr)); } } @@ -394,14 +394,14 @@ void keyboardCB(unsigned char _key, int, int) if (_key == 't' || _key == 'T') { double trackPGain = 0.005; - double p = ignition::math::equal(cam->TrackPGain(), 1.0) ? + double p = gz::math::equal(cam->TrackPGain(), 1.0) ? trackPGain : 1.0; cam->SetTrackPGain(p); } else if (_key == 'f' || _key == 'F') { double followPGain = 0.01; - double p = ignition::math::equal(cam->FollowPGain(), 1.0) ? + double p = gz::math::equal(cam->FollowPGain(), 1.0) ? followPGain : 1.0; cam->SetFollowPGain(p); } diff --git a/examples/camera_tracking/GlutWindow.hh b/examples/camera_tracking/GlutWindow.hh index 6396104d8..8670a65b8 100644 --- a/examples/camera_tracking/GlutWindow.hh +++ b/examples/camera_tracking/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_CAMERA_TRACKING_GLUTWINDOW_HH_ #include -#include +#include -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/camera_tracking/Main.cc b/examples/camera_tracking/Main.cc index 5b7335812..4dad951fb 100644 --- a/examples/camera_tracking/Main.cc +++ b/examples/camera_tracking/Main.cc @@ -27,11 +27,11 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/custom_scene_viewer/DemoWindow.cc b/examples/custom_scene_viewer/DemoWindow.cc index 9cb9c645b..64b03bd67 100644 --- a/examples/custom_scene_viewer/DemoWindow.cc +++ b/examples/custom_scene_viewer/DemoWindow.cc @@ -32,7 +32,7 @@ #include #include -#include +#include #include "ManualSceneDemo.hh" #include "DemoWindow.hh" @@ -40,7 +40,7 @@ #define KEY_ESC 27 #define KEY_TAB 9 -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/custom_scene_viewer/DemoWindow.hh b/examples/custom_scene_viewer/DemoWindow.hh index 46ddacf82..2c9696032 100644 --- a/examples/custom_scene_viewer/DemoWindow.hh +++ b/examples/custom_scene_viewer/DemoWindow.hh @@ -14,12 +14,12 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_DEMOWINDOW_HH_ #include "TestTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo /// \param[in] _Pointer to demo diff --git a/examples/custom_scene_viewer/ManualSceneDemo.cc b/examples/custom_scene_viewer/ManualSceneDemo.cc index 0678f87ba..68fe501e2 100644 --- a/examples/custom_scene_viewer/ManualSceneDemo.cc +++ b/examples/custom_scene_viewer/ManualSceneDemo.cc @@ -15,12 +15,12 @@ * */ #include -#include +#include #include "ManualSceneDemo.hh" #include "SceneBuilder.hh" #include "DemoWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/custom_scene_viewer/ManualSceneDemo.hh b/examples/custom_scene_viewer/ManualSceneDemo.hh index 57942d90c..cee290d1b 100644 --- a/examples/custom_scene_viewer/ManualSceneDemo.hh +++ b/examples/custom_scene_viewer/ManualSceneDemo.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ -#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ +#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_ #include -#include +#include #include "TestTypes.hh" namespace ignition diff --git a/examples/custom_scene_viewer/SceneBuilder.cc b/examples/custom_scene_viewer/SceneBuilder.cc index a8482becd..c7a318ef2 100644 --- a/examples/custom_scene_viewer/SceneBuilder.cc +++ b/examples/custom_scene_viewer/SceneBuilder.cc @@ -18,7 +18,7 @@ #include "example_config.hh" #include "SceneBuilder.hh" -using namespace ignition; +using namespace gz; using namespace rendering; const std::string RESOURCE_PATH = std::string(PROJECT_BINARY_PATH) + "/media"; diff --git a/examples/custom_scene_viewer/SceneBuilder.hh b/examples/custom_scene_viewer/SceneBuilder.hh index 9901b9c1e..42362ccd9 100644 --- a/examples/custom_scene_viewer/SceneBuilder.hh +++ b/examples/custom_scene_viewer/SceneBuilder.hh @@ -14,8 +14,8 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ -#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ +#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_SCENEBUILDER_HH_ #include #include "TestTypes.hh" diff --git a/examples/custom_scene_viewer/TestTypes.hh b/examples/custom_scene_viewer/TestTypes.hh index 92c62a468..41e1dd3ed 100644 --- a/examples/custom_scene_viewer/TestTypes.hh +++ b/examples/custom_scene_viewer/TestTypes.hh @@ -14,11 +14,11 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ -#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ +#define GZ_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_TESTYPES_HH_ #include -#include +#include namespace ignition { diff --git a/examples/custom_shaders/custom_shaders.cc b/examples/custom_shaders/custom_shaders.cc index de2145914..ec02581c7 100644 --- a/examples/custom_shaders/custom_shaders.cc +++ b/examples/custom_shaders/custom_shaders.cc @@ -14,15 +14,15 @@ * limitations under the License. * */ -#include -#include -#include +#include +#include +#include #include "example_config.hh" -void BuildScene(ignition::rendering::ScenePtr _scene); +void BuildScene(gz::rendering::ScenePtr _scene); -void PresentImage(ignition::rendering::ImagePtr _image, +void PresentImage(gz::rendering::ImagePtr _image, const std::string &_name); @@ -42,15 +42,15 @@ const std::string fragment_shader_file = "fragment_shader.glsl"; ////////////////////////////////////////////////// int main() { - // Initialize ignition::rendering - auto *engine = ignition::rendering::engine("ogre"); + // Initialize gz::rendering + auto *engine = gz::rendering::engine("ogre"); if (!engine) { std::cerr << "Failed to load ogre\n"; return 1; } // Create a scene and add stuff to it - ignition::rendering::ScenePtr scene = engine->CreateScene("scene"); + gz::rendering::ScenePtr scene = engine->CreateScene("scene"); if (!scene) { std::cerr << "Failed to create scene." << std::endl; @@ -58,28 +58,28 @@ int main() } BuildScene(scene); - ignition::rendering::VisualPtr root = scene->RootVisual(); + gz::rendering::VisualPtr root = scene->RootVisual(); // Create a camera - ignition::rendering::CameraPtr camera; + gz::rendering::CameraPtr camera; camera = scene->CreateCamera("example_custom_shaders"); camera->SetImageWidth(width); camera->SetImageHeight(height); camera->SetHFOV(1.05); camera->SetAntiAliasing(2); camera->SetAspectRatio(width / height); - camera->SetImageFormat(ignition::rendering::PF_R8G8B8); + camera->SetImageFormat(gz::rendering::PF_R8G8B8); root->AddChild(camera); // Create a camera for depth image - ignition::rendering::CameraPtr depthCamera; + gz::rendering::CameraPtr depthCamera; depthCamera = scene->CreateCamera("example_custom_shaders_depth"); depthCamera->SetImageWidth(width); depthCamera->SetImageHeight(height); depthCamera->SetHFOV(1.05); depthCamera->SetAntiAliasing(2); depthCamera->SetAspectRatio(width / height); - depthCamera->SetImageFormat(ignition::rendering::PF_R8G8B8); + depthCamera->SetImageFormat(gz::rendering::PF_R8G8B8); root->AddChild(depthCamera); // Render to an in-memory image @@ -94,23 +94,23 @@ int main() IGN_RENDERING_RESOURCE_PATH; // path to look for vertex and fragment shader parameters - std::string depth_vertex_shader_path = ignition::common::joinPaths( + std::string depth_vertex_shader_path = gz::common::joinPaths( resourcePath, "ogre", "media", "materials", "programs", depth_vertex_shader_file); - std::string depth_fragment_shader_path = ignition::common::joinPaths( + std::string depth_fragment_shader_path = gz::common::joinPaths( resourcePath, "ogre", "media", "materials", "programs", depth_fragment_shader_file); - ignition::rendering::MaterialPtr depthMat = scene->CreateMaterial(); + gz::rendering::MaterialPtr depthMat = scene->CreateMaterial(); depthMat->SetVertexShader(depth_vertex_shader_path); depthMat->SetFragmentShader(depth_fragment_shader_path); depthCamera->SetMaterial(depthMat); - ignition::rendering::ImagePtr image = - std::make_shared(camera->CreateImage()); - ignition::rendering::ImagePtr depthImage = - std::make_shared(depthCamera->CreateImage()); + gz::rendering::ImagePtr image = + std::make_shared(camera->CreateImage()); + gz::rendering::ImagePtr depthImage = + std::make_shared(depthCamera->CreateImage()); depthCamera->Capture(*depthImage); PresentImage(depthImage, "depth.png"); @@ -121,14 +121,14 @@ int main() } ////////////////////////////////////////////////// -void PresentImage(ignition::rendering::ImagePtr _image, +void PresentImage(gz::rendering::ImagePtr _image, const std::string &_name) { // Present the data unsigned char *data = _image->Data(); - ignition::common::Image image; - image.SetFromData(data, width, height, ignition::common::Image::RGB_INT8); + gz::common::Image image; + image.SetFromData(data, width, height, gz::common::Image::RGB_INT8); image.SavePNG(_name); @@ -136,14 +136,14 @@ void PresentImage(ignition::rendering::ImagePtr _image, } ////////////////////////////////////////////////// -void BuildScene(ignition::rendering::ScenePtr _scene) +void BuildScene(gz::rendering::ScenePtr _scene) { // initialize _scene _scene->SetAmbientLight(0.3, 0.3, 0.3); - ignition::rendering::VisualPtr root = _scene->RootVisual(); + gz::rendering::VisualPtr root = _scene->RootVisual(); // create directional light - ignition::rendering::DirectionalLightPtr light0 = + gz::rendering::DirectionalLightPtr light0 = _scene->CreateDirectionalLight(); light0->SetDirection(-0.5, 0.5, -1); light0->SetDiffuseColor(0.5, 0.5, 0.5); @@ -151,14 +151,14 @@ void BuildScene(ignition::rendering::ScenePtr _scene) root->AddChild(light0); // create white material - ignition::rendering::MaterialPtr grey = _scene->CreateMaterial(); + gz::rendering::MaterialPtr grey = _scene->CreateMaterial(); grey->SetAmbient(0.5, 0.5, 0.5); grey->SetDiffuse(0.8, 0.8, 0.8); grey->SetReceiveShadows(true); grey->SetReflectivity(0); // create plane visual - ignition::rendering::VisualPtr plane = _scene->CreateVisual(); + gz::rendering::VisualPtr plane = _scene->CreateVisual(); auto geom = _scene->CreatePlane(); plane->AddGeometry(geom); plane->SetLocalScale(5, 8, 1); @@ -173,20 +173,20 @@ void BuildScene(ignition::rendering::ScenePtr _scene) IGN_RENDERING_RESOURCE_PATH; // path to look for vertex and fragment shader parameters - std::string vertex_shader_path = ignition::common::joinPaths( + std::string vertex_shader_path = gz::common::joinPaths( resourcePath, "ogre", "media", "materials", "programs", vertex_shader_file); - std::string fragment_shader_path = ignition::common::joinPaths( + std::string fragment_shader_path = gz::common::joinPaths( resourcePath, "ogre", "media", "materials", "programs", fragment_shader_file); - ignition::rendering::MaterialPtr shader = _scene->CreateMaterial(); + gz::rendering::MaterialPtr shader = _scene->CreateMaterial(); shader->SetVertexShader(vertex_shader_path); shader->SetFragmentShader(fragment_shader_path); // create box visual - ignition::rendering::VisualPtr box = _scene->CreateVisual(); + gz::rendering::VisualPtr box = _scene->CreateVisual(); box->AddGeometry(_scene->CreateBox()); box->SetOrigin(0.0, 0.5, 0.0); box->SetLocalPosition(3, 0, 0); diff --git a/examples/gazebo_scene_viewer/CameraWindow.cc b/examples/gazebo_scene_viewer/CameraWindow.cc index 8f97d4e1b..0a136d1b0 100644 --- a/examples/gazebo_scene_viewer/CameraWindow.cc +++ b/examples/gazebo_scene_viewer/CameraWindow.cc @@ -31,10 +31,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include "SceneManager.hh" @@ -45,11 +45,11 @@ unsigned int imgw = 0; unsigned int imgh = 0; -std::vector g_cameras; -gz::CameraPtr g_camera; -gz::CameraPtr g_currCamera; +std::vector g_cameras; +gz::rendering::CameraPtr g_camera; +gz::rendering::CameraPtr g_currCamera; unsigned int g_cameraIndex = 0; -gz::ImagePtr g_image; +gz::rendering::ImagePtr g_image; bool g_initContext = false; @@ -65,7 +65,7 @@ bool g_initContext = false; double g_offset = 0.0; ////////////////////////////////////////////////// -void GlutRun(std::vector _cameras) +void GlutRun(std::vector _cameras) { #if not (__APPLE__ || _WIN32) g_context = glXGetCurrentContext(); @@ -124,8 +124,8 @@ void GlutIdle() } #endif - ignition::rendering::SceneManager* manager = - ignition::rendering::SceneManager::Instance(); + gz::rendering::SceneManager* manager = + gz::rendering::SceneManager::Instance(); manager->UpdateScenes(); @@ -155,13 +155,13 @@ void GlutReshape(int, int) } ////////////////////////////////////////////////// -void GlutInitCamera(gz::CameraPtr _camera) +void GlutInitCamera(gz::rendering::CameraPtr _camera) { g_camera = _camera; imgw = g_camera->ImageWidth(); imgh = g_camera->ImageHeight(); - gz::Image image = g_camera->CreateImage(); - g_image = std::make_shared(image); + gz::rendering::Image image = g_camera->CreateImage(); + g_image = std::make_shared(image); g_camera->Capture(*g_image); } diff --git a/examples/gazebo_scene_viewer/CameraWindow.hh b/examples/gazebo_scene_viewer/CameraWindow.hh index e751aad19..e5ad4dfb4 100644 --- a/examples/gazebo_scene_viewer/CameraWindow.hh +++ b/examples/gazebo_scene_viewer/CameraWindow.hh @@ -14,15 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_CAMERAWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace gz = ignition::rendering; - -void GlutRun(std::vector _cameras); +void GlutRun(std::vector _cameras); void GlutDisplay(); @@ -32,7 +30,7 @@ void GlutKeyboard(unsigned char _key, int _x, int _y); void GlutReshape(int _width, int _height); -void GlutInitCamera(gz::CameraPtr _camera); +void GlutInitCamera(gz::rendering::CameraPtr _camera); void GlutInitContext(); diff --git a/examples/gazebo_scene_viewer/GazeboDemo.cc b/examples/gazebo_scene_viewer/GazeboDemo.cc index 98dbe304d..d631991d2 100644 --- a/examples/gazebo_scene_viewer/GazeboDemo.cc +++ b/examples/gazebo_scene_viewer/GazeboDemo.cc @@ -18,12 +18,12 @@ #include #include -#include +#include #include "CameraWindow.hh" #include "SceneManager.hh" -using namespace ignition; +using namespace gz; using namespace rendering; void Connect() @@ -32,7 +32,7 @@ void Connect() gazebo::transport::init(); gazebo::transport::run(); - SceneManager* manager = SceneManager::Instance(); + SceneManager *manager = SceneManager::Instance(); manager->Load(); manager->Init(); } diff --git a/examples/gazebo_scene_viewer/GazeboWorldDemo.cc b/examples/gazebo_scene_viewer/GazeboWorldDemo.cc index 32f7a095e..253ffde48 100644 --- a/examples/gazebo_scene_viewer/GazeboWorldDemo.cc +++ b/examples/gazebo_scene_viewer/GazeboWorldDemo.cc @@ -15,15 +15,15 @@ * */ #include -#include +#include #include -#include +#include #include "CameraWindow.hh" #include "SceneManager.hh" -using namespace ignition; +using namespace gz; using namespace rendering; void Connect() diff --git a/examples/gazebo_scene_viewer/SceneManager.cc b/examples/gazebo_scene_viewer/SceneManager.cc index 2494fb0b8..10bfc47cf 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 "SceneManager.hh" #include "SceneManagerPrivate.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// @@ -945,7 +945,7 @@ DirectionalLightPtr SubSceneManager::DirectionalLight( LightPtr light = this->activeScene->LightByName(name); DirectionalLightPtr dirLight = - std::dynamic_pointer_cast(light); + std::dynamic_pointer_cast(light); // check if not found if (!dirLight) @@ -989,7 +989,7 @@ PointLightPtr SubSceneManager::PointLight( std::string name = _lightMsg.name(); LightPtr light = this->activeScene->LightByName(name); PointLightPtr pointLight = - std::dynamic_pointer_cast(light); + std::dynamic_pointer_cast(light); // check if not found if (!pointLight) @@ -1061,7 +1061,7 @@ SpotLightPtr SubSceneManager::SpotLight(const gazebo::msgs::Light &_lightMsg, std::string name = _lightMsg.name(); LightPtr light = this->activeScene->LightByName(name); SpotLightPtr spotLight = - std::dynamic_pointer_cast(light); + std::dynamic_pointer_cast(light); // check if not found if (!spotLight) @@ -1176,7 +1176,7 @@ CameraPtr SubSceneManager::Camera(const gazebo::msgs::Sensor &_sensorMsg, // find existing camera with name std::string name = _sensorMsg.name(); SensorPtr sensor = this->activeScene->SensorByName(name); - CameraPtr camera = std::dynamic_pointer_cast(sensor); + CameraPtr camera = std::dynamic_pointer_cast(sensor); // check if not found if (!camera) diff --git a/examples/gazebo_scene_viewer/SceneManager.hh b/examples/gazebo_scene_viewer/SceneManager.hh index b60a0723a..66ded0344 100644 --- a/examples/gazebo_scene_viewer/SceneManager.hh +++ b/examples/gazebo_scene_viewer/SceneManager.hh @@ -27,8 +27,8 @@ #endif #include -#include -#include "ignition/rendering/RenderTypes.hh" +#include +#include "gz/rendering/RenderTypes.hh" namespace ignition { diff --git a/examples/gazebo_scene_viewer/SceneManagerPrivate.hh b/examples/gazebo_scene_viewer/SceneManagerPrivate.hh index 7c1d0fdbc..cd543b50d 100644 --- a/examples/gazebo_scene_viewer/SceneManagerPrivate.hh +++ b/examples/gazebo_scene_viewer/SceneManagerPrivate.hh @@ -21,13 +21,13 @@ #include #include -#include +#include -#include -#include +#include +#include -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ShaderType.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ShaderType.hh" #include "gazebo/transport/Node.hh" namespace ignition diff --git a/examples/hello_world_plugin/HelloWorldPlugin.cc b/examples/hello_world_plugin/HelloWorldPlugin.cc index 361b43e3f..e3348b912 100644 --- a/examples/hello_world_plugin/HelloWorldPlugin.cc +++ b/examples/hello_world_plugin/HelloWorldPlugin.cc @@ -15,20 +15,20 @@ * */ -#include +#include -#include +#include -#include "ignition/rendering/RenderEnginePlugin.hh" -#include "ignition/rendering/base/BaseRenderEngine.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" +#include "gz/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/base/BaseRenderEngine.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" namespace mock { /// \brief The render engine class which implements a render engine. class HelloWorldRenderEngine : - public virtual ignition::rendering::BaseRenderEngine, - public ignition::common::SingletonT + public virtual gz::rendering::BaseRenderEngine, + public gz::common::SingletonT { // Documentation Inherited. public: virtual bool IsEnabled() const override @@ -59,7 +59,7 @@ namespace mock /// \brief Get a pointer to the list of scenes managed by the render /// engine. /// \return list of scenes - protected: virtual ignition::rendering::SceneStorePtr Scenes() + protected: virtual gz::rendering::SceneStorePtr Scenes() const override { return nullptr; @@ -68,7 +68,7 @@ namespace mock /// \brief Create a scene. /// \param[in] _id Unique scene Id /// \parampin] _name Name of scene - protected: virtual ignition::rendering::ScenePtr + protected: virtual gz::rendering::ScenePtr CreateSceneImpl(unsigned int _id, const std::string &_name) override { @@ -76,12 +76,12 @@ namespace mock } /// \brief Singelton setup. - private: friend class ignition::common::SingletonT; + private: friend class gz::common::SingletonT; }; /// \brief Plugin for loading the HelloWorld render engine. class HelloWorldPlugin : - public ignition::rendering::RenderEnginePlugin + public gz::rendering::RenderEnginePlugin { /// \brief Get the name of the render engine loaded by this plugin. /// \return Name of render engine @@ -92,7 +92,7 @@ namespace mock /// \brief Get a pointer to the render engine loaded by this plugin. /// \return Render engine instance - public: ignition::rendering::RenderEngine *Engine() const override + public: gz::rendering::RenderEngine *Engine() const override { return HelloWorldRenderEngine::Instance(); } @@ -101,4 +101,4 @@ namespace mock // Register this plugin IGNITION_ADD_PLUGIN(mock::HelloWorldPlugin, - ignition::rendering::RenderEnginePlugin) + gz::rendering::RenderEnginePlugin) diff --git a/examples/mesh_viewer/GlutWindow.cc b/examples/mesh_viewer/GlutWindow.cc index d6eccb28d..02413dffd 100644 --- a/examples/mesh_viewer/GlutWindow.cc +++ b/examples/mesh_viewer/GlutWindow.cc @@ -31,12 +31,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -151,7 +151,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -181,7 +181,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) diff --git a/examples/mesh_viewer/GlutWindow.hh b/examples/mesh_viewer/GlutWindow.hh index 6f410018a..7674df2c3 100644 --- a/examples/mesh_viewer/GlutWindow.hh +++ b/examples/mesh_viewer/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_MESH_VIEWER_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/mesh_viewer/Main.cc b/examples/mesh_viewer/Main.cc index 6b96e1fb6..8d444a7ce 100644 --- a/examples/mesh_viewer/Main.cc +++ b/examples/mesh_viewer/Main.cc @@ -27,14 +27,14 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; const std::string RESOURCE_PATH = diff --git a/examples/mouse_picking/GlutWindow.cc b/examples/mouse_picking/GlutWindow.cc index 1cb83339e..43a6dcac6 100644 --- a/examples/mouse_picking/GlutWindow.cc +++ b/examples/mouse_picking/GlutWindow.cc @@ -31,14 +31,14 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -118,7 +118,7 @@ void handleMouse() { // Get visual using Selection Buffer from Camera ir::VisualPtr visual1; - ignition::math::Vector2i mousePosI(g_mouse.x, g_mouse.y); + gz::math::Vector2i mousePosI(g_mouse.x, g_mouse.y); visual1 = rayCamera->VisualAt(mousePosI); if (visual1) { diff --git a/examples/mouse_picking/GlutWindow.hh b/examples/mouse_picking/GlutWindow.hh index e81c7d1b1..5cb582744 100644 --- a/examples/mouse_picking/GlutWindow.hh +++ b/examples/mouse_picking/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_MOUSE_PICKING_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; void run(std::vector _cameras); diff --git a/examples/mouse_picking/Main.cc b/examples/mouse_picking/Main.cc index 5b9db3e5b..b9168a651 100644 --- a/examples/mouse_picking/Main.cc +++ b/examples/mouse_picking/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/ogre2_demo/GlutWindow.cc b/examples/ogre2_demo/GlutWindow.cc index cf40952bc..5906e839f 100644 --- a/examples/ogre2_demo/GlutWindow.cc +++ b/examples/ogre2_demo/GlutWindow.cc @@ -31,13 +31,13 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -154,7 +154,7 @@ void handleMouse() { // Get visual using Selection Buffer from Camera ir::VisualPtr visual; - ignition::math::Vector2i mousePos(g_mouse.x, g_mouse.y); + gz::math::Vector2i mousePos(g_mouse.x, g_mouse.y); visual = rayCamera->VisualAt(mousePos); if (visual) { @@ -174,7 +174,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -204,7 +204,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) @@ -281,8 +281,8 @@ void displayCB() glutSwapBuffers(); // Uncomment to print FPS - // static ignition::common::Time previous; - // auto now = ignition::common::Time::SystemTime(); + // static gz::common::Time previous; + // auto now = gz::common::Time::SystemTime(); // std::cerr << (now - previous).Double() << std::endl; // previous = now; } diff --git a/examples/ogre2_demo/GlutWindow.hh b/examples/ogre2_demo/GlutWindow.hh index 1942a287e..55f47a778 100644 --- a/examples/ogre2_demo/GlutWindow.hh +++ b/examples/ogre2_demo/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_OGRE2_DEMO_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/ogre2_demo/Main.cc b/examples/ogre2_demo/Main.cc index f64cf63a9..6f9dda6bb 100644 --- a/examples/ogre2_demo/Main.cc +++ b/examples/ogre2_demo/Main.cc @@ -27,14 +27,14 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; diff --git a/examples/render_pass/GlutWindow.cc b/examples/render_pass/GlutWindow.cc index 9887c8c92..c39c183d9 100644 --- a/examples/render_pass/GlutWindow.cc +++ b/examples/render_pass/GlutWindow.cc @@ -31,11 +31,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/render_pass/GlutWindow.hh b/examples/render_pass/GlutWindow.hh index b1610206c..ef9893513 100644 --- a/examples/render_pass/GlutWindow.hh +++ b/examples/render_pass/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/render_pass/Main.cc b/examples/render_pass/Main.cc index d12feab6d..5ef88c2d7 100644 --- a/examples/render_pass/Main.cc +++ b/examples/render_pass/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/simple_demo/GlutWindow.cc b/examples/simple_demo/GlutWindow.cc index 50dd96ade..0542b5e79 100644 --- a/examples/simple_demo/GlutWindow.cc +++ b/examples/simple_demo/GlutWindow.cc @@ -31,10 +31,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/simple_demo/GlutWindow.hh b/examples/simple_demo/GlutWindow.hh index 9dc770201..3b757b280 100644 --- a/examples/simple_demo/GlutWindow.hh +++ b/examples/simple_demo/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/simple_demo/Main.cc b/examples/simple_demo/Main.cc index 09358186e..b1f1dd9ad 100644 --- a/examples/simple_demo/Main.cc +++ b/examples/simple_demo/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/text_geom/GlutWindow.cc b/examples/text_geom/GlutWindow.cc index 9dc6648ef..df485dc9b 100644 --- a/examples/text_geom/GlutWindow.cc +++ b/examples/text_geom/GlutWindow.cc @@ -31,10 +31,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include "GlutWindow.hh" diff --git a/examples/text_geom/GlutWindow.hh b/examples/text_geom/GlutWindow.hh index 070bdfdbd..2aaf4f11e 100644 --- a/examples/text_geom/GlutWindow.hh +++ b/examples/text_geom/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_SIMPLE_DEMO_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/text_geom/Main.cc b/examples/text_geom/Main.cc index 9e07e3b70..1b208a64b 100644 --- a/examples/text_geom/Main.cc +++ b/examples/text_geom/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/thermal_camera/GlutWindow.cc b/examples/thermal_camera/GlutWindow.cc index cee056897..51b547ef5 100644 --- a/examples/thermal_camera/GlutWindow.cc +++ b/examples/thermal_camera/GlutWindow.cc @@ -31,11 +31,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -50,7 +50,7 @@ std::vector g_cameras; ir::CameraPtr g_camera; unsigned int g_cameraIndex = 0; ir::ImagePtr g_image; -ignition::common::ConnectionPtr g_connection; +gz::common::ConnectionPtr g_connection; bool g_initContext = false; @@ -88,7 +88,7 @@ void OnNewThermalFrame(const uint16_t *_scan, // convert temperature to grayscale image double range = static_cast(max - min); - if (ignition::math::equal(range, 0.0)) + if (gz::math::equal(range, 0.0)) range = 1.0; unsigned char *data = g_image->Data(); for (unsigned int i = 0; i < _height; ++i) diff --git a/examples/thermal_camera/GlutWindow.hh b/examples/thermal_camera/GlutWindow.hh index ad5fb3bb1..d16b9b537 100644 --- a/examples/thermal_camera/GlutWindow.hh +++ b/examples/thermal_camera/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_THERMAL_CAMERA_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/thermal_camera/Main.cc b/examples/thermal_camera/Main.cc index 064e81d9c..2e4f7da91 100644 --- a/examples/thermal_camera/Main.cc +++ b/examples/thermal_camera/Main.cc @@ -27,14 +27,14 @@ #include #include -#include -#include -#include +#include +#include +#include #include "example_config.hh" #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; const std::string RESOURCE_PATH = diff --git a/examples/transform_control/GlutWindow.cc b/examples/transform_control/GlutWindow.cc index 3331cf226..23466b249 100644 --- a/examples/transform_control/GlutWindow.cc +++ b/examples/transform_control/GlutWindow.cc @@ -31,13 +31,13 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -168,14 +168,14 @@ void handleTransform() if (g_mouse.state == GLUT_DOWN) { // get the visual at mouse position - ignition::math::Vector2i mousePos(g_mouse.x, g_mouse.y); + gz::math::Vector2i mousePos(g_mouse.x, g_mouse.y); ir::VisualPtr visual = rayCamera->VisualAt(mousePos); if (visual) { // check if the visual is an axis in the gizmo visual - ignition::math::Vector3d axis = + gz::math::Vector3d axis = g_transformControl.AxisById(visual->Id()); - if (axis != ignition::math::Vector3d::Zero) + if (axis != gz::math::Vector3d::Zero) { // start the transform process g_transformControl.SetActiveAxis(axis); @@ -207,23 +207,23 @@ void handleTransform() double ny = 1.0 - 2.0 * g_mouse.y / imageHeight; double nxEnd = 2.0 * g_mouse.motionX / imageWidth - 1.0; double nyEnd = 1.0 - 2.0 * g_mouse.motionY / imageHeight; - ignition::math::Vector2d start(nx, ny); - ignition::math::Vector2d end(nxEnd, nyEnd); + gz::math::Vector2d start(nx, ny); + gz::math::Vector2d end(nxEnd, nyEnd); // get the currect active axis - ignition::math::Vector3d axis = g_transformControl.ActiveAxis(); + gz::math::Vector3d axis = g_transformControl.ActiveAxis(); // compute 3d transformation from 2d mouse movement if (g_transformControl.Mode() == ir::TransformMode::TM_TRANSLATION) { - ignition::math::Vector3d distance = + gz::math::Vector3d distance = g_transformControl.TranslationFrom2d(axis, start, end); g_transformControl.Translate(distance); g_mouse.motionDirty = false; } else if (g_transformControl.Mode() == ir::TransformMode::TM_ROTATION) { - ignition::math::Quaterniond rotation = + gz::math::Quaterniond rotation = g_transformControl.RotationFrom2d(axis, start, end); g_transformControl.Rotate(rotation); g_mouse.motionDirty = false; @@ -231,7 +231,7 @@ void handleTransform() else if (g_transformControl.Mode() == ir::TransformMode::TM_SCALE) { // note: scaling is limited to local space - ignition::math::Vector3d scale = + gz::math::Vector3d scale = g_transformControl.ScaleFrom2d(axis, start, end); g_transformControl.Scale(scale); g_mouse.motionDirty = false; @@ -263,7 +263,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -293,7 +293,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) diff --git a/examples/transform_control/GlutWindow.hh b/examples/transform_control/GlutWindow.hh index b55523c6b..f162a70e6 100644 --- a/examples/transform_control/GlutWindow.hh +++ b/examples/transform_control/GlutWindow.hh @@ -14,13 +14,13 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_TRANSFORMCONTROL_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene diff --git a/examples/transform_control/Main.cc b/examples/transform_control/Main.cc index 61b1a5634..ccde86e62 100644 --- a/examples/transform_control/Main.cc +++ b/examples/transform_control/Main.cc @@ -27,12 +27,12 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/examples/view_control/GlutWindow.cc b/examples/view_control/GlutWindow.cc index c074783f6..a33a45ab1 100644 --- a/examples/view_control/GlutWindow.cc +++ b/examples/view_control/GlutWindow.cc @@ -31,12 +31,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "GlutWindow.hh" @@ -151,7 +151,7 @@ void handleMouse() 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); - g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_rayQuery->SetFromCamera(rayCamera, gz::math::Vector2d(nx, ny)); g_target = g_rayQuery->ClosestPoint(); if (!g_target) { @@ -181,7 +181,7 @@ void handleMouse() if (g_mouse.motionDirty) { g_mouse.motionDirty = false; - auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + auto drag = gz::math::Vector2d(g_mouse.dragX, g_mouse.dragY); // left mouse button pan if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) diff --git a/examples/view_control/GlutWindow.hh b/examples/view_control/GlutWindow.hh index 9bb9c368c..8451263aa 100644 --- a/examples/view_control/GlutWindow.hh +++ b/examples/view_control/GlutWindow.hh @@ -14,16 +14,16 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ -#define IGNITION_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ +#ifndef GZ_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ +#define GZ_RENDERING_EXAMPLES_VIEW_CONTROL_GLUTWINDOW_HH_ #include -#include "ignition/rendering/RenderTypes.hh" +#include "gz/rendering/RenderTypes.hh" -namespace ir = ignition::rendering; +namespace ir = gz::rendering; /// \brief Run the demo and render the scene from the cameras /// \param[in] _cameras Cameras in the scene -void run(std::vector _cameras); +void run(std::vector _cameras); #endif diff --git a/examples/view_control/Main.cc b/examples/view_control/Main.cc index 8b87c373c..0eedbe5f3 100644 --- a/examples/view_control/Main.cc +++ b/examples/view_control/Main.cc @@ -27,11 +27,11 @@ #include #include -#include -#include +#include +#include #include "GlutWindow.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 25ec89762..4b2bdd7bb 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(ignition) +add_subdirectory(gz) +install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) diff --git a/include/ignition/CMakeLists.txt b/include/gz/CMakeLists.txt similarity index 100% rename from include/ignition/CMakeLists.txt rename to include/gz/CMakeLists.txt diff --git a/include/gz/rendering/ArrowVisual.hh b/include/gz/rendering/ArrowVisual.hh new file mode 100644 index 000000000..303b4121d --- /dev/null +++ b/include/gz/rendering/ArrowVisual.hh @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_ARROWVISUAL_HH_ +#define GZ_RENDERING_ARROWVISUAL_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/CompositeVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class ArrowVisual ArrowVisual.hh ignition/rendering/ArrowVisual.hh + /// \brief Represents a arrow composite visual + class IGNITION_RENDERING_VISIBLE ArrowVisual : + public virtual CompositeVisual + { + /// \brief Deconstructor + public: virtual ~ArrowVisual() { } + + /// \brief Get arrow-head visual + /// \return The arrow-head visual + public: virtual VisualPtr Head() const = 0; + + /// \brief Get arrow-shaft visual + /// \return The arrow-shaft visual + public: virtual VisualPtr Shaft() const = 0; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/AxisVisual.hh b/include/gz/rendering/AxisVisual.hh new file mode 100644 index 000000000..e2147ee22 --- /dev/null +++ b/include/gz/rendering/AxisVisual.hh @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_AXISVISUAL_HH_ +#define GZ_RENDERING_AXISVISUAL_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/CompositeVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class AxisVisual AxisVisual.hh ignition/rendering/AxisVisual.hh + /// \brief Represents a axis composite visual + class IGNITION_RENDERING_VISIBLE AxisVisual : + public virtual CompositeVisual + { + /// \brief Deconstructor + public: virtual ~AxisVisual() { } + }; + } + } +} +#endif diff --git a/include/ignition/rendering/CMakeLists.txt b/include/gz/rendering/CMakeLists.txt similarity index 100% rename from include/ignition/rendering/CMakeLists.txt rename to include/gz/rendering/CMakeLists.txt diff --git a/include/gz/rendering/Camera.hh b/include/gz/rendering/Camera.hh new file mode 100644 index 000000000..66d4074b8 --- /dev/null +++ b/include/gz/rendering/Camera.hh @@ -0,0 +1,305 @@ +/* + * 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 { + // + /// \class Camera Camera.hh ignition/rendering/Camera.hh + /// \brief Posable camera used for rendering the scene graph + class IGNITION_RENDERING_VISIBLE Camera : + public virtual Sensor + { + /// \brief Callback function for new frame render event listeners + public: typedef std::function NewFrameListener; + + /// \brief Deconstructor + public: virtual ~Camera() { } + + /// \brief Get the image width in pixels + /// \return The image width in pixels + public: virtual unsigned int ImageWidth() const = 0; + + /// \brief Set the image width in pixels + /// \param[in] _width New image width in pixels + public: virtual void SetImageWidth(unsigned int _width) = 0; + + /// \brief Get the image height in pixels + /// \return The image height in pixels + public: virtual unsigned int ImageHeight() const = 0; + + /// \brief Set the image height in pixels + /// \param[in] _height New image height in pixels + public: virtual void SetImageHeight(unsigned int _height) = 0; + + /// \brief Get the image pixel format. If the image pixel format has not + /// been set with a valid value, PF_UNKNOWN will be returned. + /// \return The image pixel format + public: virtual PixelFormat ImageFormat() const = 0; + + /// \brief Set the image pixel format + /// \param[in] _format New image pixel format + public: virtual void SetImageFormat(PixelFormat _format) = 0; + + /// \brief Get the total image memory size in bytes + /// \return The image memory size in bytes + public: virtual unsigned int ImageMemorySize() const = 0; + + /// \brief Get the camera's horizontal field-of-view + /// \return Angle containing the camera's horizontal field-of-view + public: virtual math::Angle HFOV() const = 0; + + /// \brief Set the camera's horizontal field-of-view + /// \param[in] _hfov Desired horizontal field-of-view + public: virtual void SetHFOV(const math::Angle &_hfov) = 0; + + /// \brief Get the camera's aspect ratio + /// \return The camera's aspect ratio + public: virtual double AspectRatio() const = 0; + + /// \brief Set the camera's aspect ratio. This value determines the + /// cameras vertical field-of-view. It is often the \code image_height / + /// image_width \endcode but this is not necessarily true. + /// \return The camera's aspect ratio + public: virtual void SetAspectRatio(const double _ratio) = 0; + + // TODO(anyone): add auto-aspect ratio + + /// \brief Get the level of anti-aliasing used during rendering + /// \return The level of anti-aliasing used during rendering + public: virtual unsigned int AntiAliasing() const = 0; + + /// \brief Set the level of anti-aliasing used during rendering. If a + /// value of 0 is given, no anti-aliasing will be performed. Higher values + /// can significantly slow-down rendering times, depending on the + /// underlying render engine. + /// \param[in] _aa Level of anti-aliasing used during rendering + public: virtual void SetAntiAliasing(const unsigned int _aa) = 0; + + /// \brief Get the camera's far clipping plane distance + /// \return Far clipping plane distance + public: virtual double FarClipPlane() const = 0; + + /// \brief Set the camera's far clipping plane distance + /// \param[in] _far Far clipping plane distance + public: virtual void SetFarClipPlane(const double _far) = 0; + + /// \brief Get the camera's near clipping plane distance + /// \return Near clipping plane distance + public: virtual double NearClipPlane() const = 0; + + /// \brief Set the camera's near clipping plane distance + /// \param[in] _near Near clipping plane distance + public: virtual void SetNearClipPlane(const double _near) = 0; + + /// \brief Renders the current scene using this camera. This function + /// assumes PreRender() has already been called on the parent Scene, + /// allowing the camera and the scene itself to prepare for rendering. + public: virtual void Render() = 0; + + /// \brief Preforms any necessary final rendering work. Once rendering is + /// complete the camera will alert any listeners of the new frame event. + /// This function should only be called after a call to Render has + /// successfully been executed. + public: virtual void PostRender() = 0; + + /// \brief Get the visual for a given mouse position + /// param[in] _mousePos mouse position + // \return visual for that position, null if no visual was found + public: virtual VisualPtr VisualAt(const gz::math::Vector2i + &_mousePos) = 0; + + /// \brief Renders a new frame. + /// This is a convenience function for single-camera scenes. It wraps the + /// pre-render, render, and post-render into a single + /// function. This should be used in applications with multiple cameras + /// or multiple consumers of a single camera's images. + public: virtual void Update() = 0; + + /// \brief Created an empty image buffer for capturing images. The + /// resulting image will have sufficient memory allocated for subsequent + /// calls to this camera's Capture function. However, any changes to this + /// cameras properties may invalidate the condition. + /// \return A newly allocated Image for storing this cameras images + public: virtual Image CreateImage() const = 0; + + /// \brief Renders a new frame and writes the results to the given image. + /// This is a convenience function for single-camera scenes. It wraps the + /// pre-render, render, post-render, and get-image calls into a single + /// function. This should be used in applications with multiple cameras + /// or multiple consumers of a single camera's images. + /// \param[out] _image Output image buffer + public: virtual void Capture(Image &_image) = 0; + + /// \brief Writes the last rendered image to the given image buffer. This + /// function can be called multiple times after PostRender has been + /// called, without rendering the scene again. Calling this function + /// before a single image has been rendered will have undefined behavior. + /// \param[out] _image Output image buffer + public: virtual void Copy(Image &_image) const = 0; + + /// \brief Writes the previously rendered frame to a file. This function + /// can be called multiple times after PostRender has been called, + /// without rendering the scene again. Calling this function before a + /// single image has been rendered will have undefined behavior. + /// \param[in] _name Name of the output file + public: virtual bool SaveFrame(const std::string &_name) = 0; + + /// \brief Subscribes a new listener to this camera's new frame event + /// \param[in] _listener New camera listener callback + public: virtual common::ConnectionPtr ConnectNewImageFrame( + NewFrameListener _listener) = 0; + + /// \brief Create a render window. + /// \return A pointer to the render window. + public: virtual RenderWindowPtr CreateRenderWindow() = 0; + + /// \brief Get the projection matrix for this camera + /// \return Camera projection matrix + public: virtual math::Matrix4d ProjectionMatrix() const = 0; + + /// \brief Get the view matrix for this camera + /// \return Camera view matrix + public: virtual math::Matrix4d ViewMatrix() const = 0; + + /// \brief Set a node for camera to track. The camera will automatically + /// change its orientation to face the target being tracked. If null is + /// specified, tracking is disabled. In contrast to SetFollowTarget + /// the camera does not change its position when tracking is enabled. + /// \param[in] _target Target node to track + /// \param[in] _offset Track a point that is at an offset relative + /// to target. + /// \param[in] _worldFrame If true, the offset point to track will be + /// treated in world frame and its position relative to the target + /// node remains fixed regardless of the target node's rotation. Default + /// is false, which means the camera tracks the point in target node's + /// local frame. + public: virtual void SetTrackTarget(const NodePtr &_target, + const math::Vector3d &_offset = math::Vector3d::Zero, + const bool _worldFrame = false) = 0; + + /// \brief Get the target node being tracked + /// \return Target node being tracked. + public: virtual NodePtr TrackTarget() const = 0; + + /// \brief Set track offset. Camera will track a point that's at an + /// offset from the target node. The offset will be in the frame + /// that is specified at the time the track target is set. + /// \param[in] _offset Point offset to track + public: virtual void SetTrackOffset(const math::Vector3d &_offset) = 0; + + /// \brief Get the track offset vector in the frame specified at the time + /// the track target is set. + /// \return Point offset from target. + public: virtual math::Vector3d TrackOffset() const = 0; + + /// \brief Set track P Gain. Determines how fast the camera rotates + /// to look at the target node. Valid range: [0-1] + /// \param[in] _pGain P gain for camera tracking + public: virtual void SetTrackPGain(const double _pGain) = 0; + + /// \brief Get the camera track rotation P gain. + /// \return P gain for camera tracking + public: virtual double TrackPGain() const = 0; + + /// \brief Set a node for camera to follow. The camera will automatically + /// update its position to keep itself at the specified offset distance + /// from the target being followed. If null is specified, camera follow is + /// disabled. In contrast to SetTrackTarget, the camera does not change + /// its orientation when following is enabled. + /// \param[in] _target Target node to follow + /// \param[in] _offset Tether the camera at an offset distance from the + /// target node. + /// \param[in] _worldFrame True to follow the target node at a + /// distance that's fixed in world frame. Default is false which means + /// the camera follows at fixed distance in target node's local frame. + public: virtual void SetFollowTarget(const NodePtr &_target, + const math::Vector3d &_offset = math::Vector3d::Zero, + const bool _worldFrame = false) = 0; + + /// \brief Get the target node being followed + /// \return Target node being tracked. + public: virtual NodePtr FollowTarget() const = 0; + + /// \brief Set offset of camera from target node being followed. The + /// offset will be in the frame that is specified at the time the follow + /// target is set. + /// \param[in] _offset Offset distance from target node. + public: virtual void SetFollowOffset(const math::Vector3d &_offset) = 0; + + /// \brief Get the follow offset vector in the frame specified at the + /// time the follow target is set. + /// \return Offset of camera from target. + public: virtual math::Vector3d FollowOffset() const = 0; + + /// \brief Set follow P Gain. Determines how fast the camera moves + /// to follow the target node. Valid range: [0-1] + /// \param[in] _pGain P gain for camera following + public: virtual void SetFollowPGain(const double _pGain) = 0; + + /// \brief Get the camera follow movement P gain. + /// \return P gain for camera following + public: virtual double FollowPGain() const = 0; + + /// \brief Set a material that the camera should see on all objects + /// \param[in] _material a material instance + public: virtual void SetMaterial(const MaterialPtr &_material) = 0; + + /// \brief Get the OpenGL texture id associated with the render texture + /// used by this camera. A valid id is returned only if the underlying + /// render engine is OpenGL based. + /// \return Texture Id of type GLuint. + public: virtual unsigned int RenderTextureGLId() const = 0; + + /// \brief Add a render pass to the camera + /// \param[in] _pass New render pass to add + public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0; + + /// \brief Remove a render pass from the camera + /// \param[in] _pass render pass to remove + public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) = 0; + + /// \brief Get the number of render passes applied to the camera + /// \return Number of render passes applied + public: virtual unsigned int RenderPassCount() const = 0; + + /// \brief Get a render passes by index + /// \return Render pass at the specified index + public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) + const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/CompositeVisual.hh b/include/gz/rendering/CompositeVisual.hh new file mode 100644 index 000000000..05c307337 --- /dev/null +++ b/include/gz/rendering/CompositeVisual.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_COMPOSITEVISUAL_HH_ +#define GZ_RENDERING_COMPOSITEVISUAL_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class CompositeVisual CompositeVisual.hh + /// ignition/rendering/CompositeVisual.hh + /// \brief Represents a predefined collection of geometries and visuals + class IGNITION_RENDERING_VISIBLE CompositeVisual : + public virtual Visual + { + /// \brief Deconstructor + public: virtual ~CompositeVisual() { } + }; + } + } +} +#endif diff --git a/include/gz/rendering/DepthCamera.hh b/include/gz/rendering/DepthCamera.hh new file mode 100644 index 000000000..f86c935c6 --- /dev/null +++ b/include/gz/rendering/DepthCamera.hh @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_DEPTHCAMERA_HH_ +#define GZ_RENDERING_DEPTHCAMERA_HH_ + +#include + +#include +#include "gz/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \class Camera Camera.hh ignition/rendering/Camera.hh + /// \brief Poseable depth camera used for rendering the scene graph. + /// This camera is designed to produced depth data, instead of a 2D + /// image. + class IGNITION_RENDERING_VISIBLE DepthCamera : + public virtual Camera + { + /// \brief Callback function for new frame render event listeners + public: typedef std::function NewFrameListener; + + /// \brief Destructor + public: virtual ~DepthCamera() { } + + /// \brief Create a texture which will hold the depth data + public: virtual void CreateDepthTexture() = 0; + + /// \brief All things needed to get back z buffer for depth data + /// \return The z-buffer as a float array + public: virtual const float *DepthData() const = 0; + + /// \brief Connect to the new depth image signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewDepthFrame( + std::function _subscriber) = 0; + + /// \brief Connect to the new rgb point cloud signal. + /// \param[in] _subscriber Subscriber callback function + /// The arguments of the callback function are: + /// _pointCloud Point cloud data. Each point is represented by four + /// 32 bit floating point values [X, Y, Z, RGBA]. The last + /// field can be decoded into 4 unsigned 8 bit color values: + /// uint32_t *rgba = reinterpret_cast(&_rgba) + /// r = static_cast(*rgba >> 24 & 0xFF); + /// g = static_cast(*rgba >> 16 & 0xFF); + /// b = static_cast(*rgba >> 8 & 0xFF); + /// a = static_cast(*rgba >> 0 & 0xFF); + /// _width Point cloud image width + /// _height Point cloud image height + /// _depth Point cloud image depth + /// _format Point cloud image format + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewRgbPointCloud( + std::function _subscriber) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/GaussianNoisePass.hh b/include/gz/rendering/GaussianNoisePass.hh new file mode 100644 index 000000000..4abaf9b7a --- /dev/null +++ b/include/gz/rendering/GaussianNoisePass.hh @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_GAUSSIANNOISEPASS_HH_ +#define GZ_RENDERING_GAUSSIANNOISEPASS_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" +#include "gz/rendering/RenderPass.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class GaussianNoisePass GaussianNoisePass.hh \ + * ignition/rendering/GaussianNoisePass.hh + */ + /// \brief A render pass that applies Gaussian noise to the render target + class IGNITION_RENDERING_VISIBLE GaussianNoisePass + : public virtual RenderPass + { + /// \brief Constructor + public: GaussianNoisePass(); + + /// \brief Destructor + public: virtual ~GaussianNoisePass(); + + /// \brief Accessor for mean. + /// \return Mean of Gaussian noise. + public: virtual double Mean() const = 0; + + /// \brief Accessor for stddev. + /// \return Standard deviation of Gaussian noise. + public: virtual double StdDev() const = 0; + + /// \brief Accessor for bias. + /// \return Bias on output. + public: virtual double Bias() const = 0; + + /// \brief Set mean. + /// \param[in] _mean Mean of Gaussian noise. + public: virtual void SetMean(double _mean) = 0; + + /// \brief Set stddev. + /// \param[in] _stdDev Standard deviation of Gaussian noise. + public: virtual void SetStdDev(double _stdDev) = 0; + + /// \brief Set the mean of the bias value. Bias is computed based on + /// the bias mean and bias standard deviation. + /// \sa SetBiasStdDev + public: virtual void SetBiasMean(double _biasMean) = 0; + + /// \brief Set the standard deviation of the bias value. Bias is computed + /// based on the bias mean and bias standard deviation. + /// \sa SetBiasMean + public: virtual void SetBiasStdDev(double _biasStdDev) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Geometry.hh b/include/gz/rendering/Geometry.hh new file mode 100644 index 000000000..6702576bb --- /dev/null +++ b/include/gz/rendering/Geometry.hh @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_GEOMETRY_HH_ +#define GZ_RENDERING_GEOMETRY_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Object.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Geometry Geometry.hh ignition/rendering/Geometry.hh + /// \brief Represents a geometric shape to be rendered + class IGNITION_RENDERING_VISIBLE Geometry : + public virtual Object + { + /// \brief Deconstructor + public: virtual ~Geometry() { } + + /// \brief Determine if this Geometry is attached to a Visual + /// \return True if this Geometry has a parent Visual + public: virtual bool HasParent() const = 0; + + /// \brief Get the parent Visual + /// \return the parent Visual + public: virtual VisualPtr Parent() const = 0; + + /// \brief Detach this Geometry from its parent Visual. If this + /// Geometry does not have a parent, no work will be done. + public: virtual void RemoveParent() = 0; + + /// \brief Set the materials of this Geometry. The specified material + /// will be retrieved from the parent Scene. If no material is registered + /// by the given name, no work will be done. + /// \param[in] _name Name of registered Material + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetMaterial(const std::string &_name, + bool _unique = true) = 0; + + /// \brief Set the materials of this Geometry + /// \param[in] _material New Material to be assigned + /// \param[in] _unique True if the given material should be cloned + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true) = 0; + + /// \brief Get the material of this geometry + /// \return Material used by this geometry + public: virtual MaterialPtr Material() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/GizmoVisual.hh b/include/gz/rendering/GizmoVisual.hh new file mode 100644 index 000000000..bc7bba0c6 --- /dev/null +++ b/include/gz/rendering/GizmoVisual.hh @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_GIZMOVISUAL_HH_ +#define GZ_RENDERING_GIZMOVISUAL_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/CompositeVisual.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Export.hh" +#include "gz/rendering/TransformType.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class GizmoVisual GizmoVisual.hh ignition/rendering/GizmoVisual.hh + /// \brief A gizmo that contains rotate, translate, and scale visuals + class IGNITION_RENDERING_VISIBLE GizmoVisual : + public virtual CompositeVisual + { + /// \brief Destructor + public: virtual ~GizmoVisual() { } + + /// \brief Set the transform mode of the gizmo. This controls the visual + /// appearance of the gizmo. Only the visuals in the specified mode will + /// be visible, e.g. if set to TM_TRANSLATION mode, then only the + /// translation axis visuals will be visible. + /// \param[in] _mode Transform mode to set the gizmo to + /// \sa GizmoMode + public: virtual void SetTransformMode(TransformMode _mode) = 0; + + /// \brief Get the current transform mode. + /// \return Transform mode + /// \sa SetTransformMode + public: virtual TransformMode Mode() const = 0; + + /// \brief Set the active axis in the gizmo visual + /// \param[in] _axis Axis to be set active + public: virtual void SetActiveAxis(const math::Vector3d &_axis) = 0; + + /// \brief Get the current active axis. + /// \return Active axis + /// \sa SetActiveAxis + public: virtual math::Vector3d ActiveAxis() const = 0; + + /// \brief Get the Transform axis associated with the given id. + /// \param[in] _id Id of the visual associated with a transform axis + /// \return Transform axis with the given id + public: virtual TransformAxis AxisById(unsigned int _id) const = 0; + + /// \brief Get the child visual by axis + /// \return Visual representing the specified transform axis or transform + /// mode + /// \sa TransformAxis, TransformMode + public: virtual VisualPtr ChildByAxis(unsigned int _axis) const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/GpuRays.hh b/include/gz/rendering/GpuRays.hh new file mode 100644 index 000000000..080a73220 --- /dev/null +++ b/include/gz/rendering/GpuRays.hh @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_GPURAYS_HH_ +#define GZ_RENDERING_GPURAYS_HH_ + +#include + +#include + +#include "gz/rendering/Image.hh" +#include "gz/rendering/Sensor.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class GpuRays GpuRays.hh ignition/rendering/GpuRays.hh + /// \brief Generate depth ray data. + class IGNITION_RENDERING_VISIBLE GpuRays : + public virtual Camera + { + /// \brief Callback function for new frame render event listeners + public: typedef std::function NewFrameListener; + + /// \brief Destructor + public: virtual ~GpuRays() { } + + /// \brief All things needed to get back z buffer for gpu rays data. + /// \return Array of gpu rays data. + public: virtual const float *Data() const = 0; + + /// \brief Copy to the specified memory direction the gpu rays data. + public: virtual void Copy(float *_data) = 0; + + /// \brief Configure behaviour for data values outside of camera range + /// \param[in] _clamp True to clamp data to camera clip distances, + // false to leave data values as +/-inf when out of camera range + public: virtual void SetClamp(const bool _clamp) = 0; + + /// \brief Get behaviour for data values outside of camera range + /// \return True if data values are clampped to camera clip distances, + // false if data values outside of camera range are returned as +/-inf + public: virtual bool Clamp() const = 0; + + /// \brief Connect to a gpu rays frame signal + /// \param[in] _subscriber Callback that is called when a new image is + /// generated. The callback function parameters are: + /// _frame: Image frame is an array of floats. Size is equal + /// to width * height * channels + /// Each gpu rays reading occupies 3 floats + /// Index 0: depth value + /// Index 1: retro value + /// Index 2: 0. Not used + /// _width: Width of image, i.e. number of data in the horizonal scan + /// _height: Height o image, i.e. number of scans in vertical direction + /// _channels: Number of channels, i.e. 3 floats per gpu rays reading + /// _format: Pixel format of the image frame. + /// \return A pointer to the connection. This must be kept in scope. + public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( + std::function _subscriber) = 0; + + /// \brief Set sensor horizontal or vertical + /// \param[in] _horizontal True if horizontal, false if not + public: virtual void SetIsHorizontal(const bool _horizontal) = 0; + + /// \brief Gets if sensor is horizontal + /// \return True if horizontal, false if not + public: virtual bool IsHorizontal() const = 0; + + /// \brief Get the vertical field-of-view. + /// \return The vertical field of view of the gpu rays. + public: virtual math::Angle VFOV() const = 0; + + /// \brief Get the ray count ratio (equivalent to aspect ratio) + /// \return The ray count ratio (equivalent to aspect ratio) + public: virtual double RayCountRatio() const = 0; + + /// \brief Get the ray count ratio (equivalent to aspect ratio) + /// \return The ray count ratio (equivalent to aspect ratio) + public: virtual double RangeCountRatio() const = 0; + + /// \brief Sets the ray count ratio (equivalent to aspect ratio) + /// \param[in] _rayCountRatio ray count ratio (equivalent to aspect ratio) + public: virtual void SetRayCountRatio(const double _rayCountRatio) = 0; + + /// \brief Get minimal horizontal angle value + // \return minimal horizontal angle value + public: virtual gz::math::Angle AngleMin() const = 0; + + /// \brief Set minimal horizontal angle value + public: virtual void SetAngleMin(double _angle) = 0; + + /// \brief Get maximal horizontal angle value + // \return maximal horizontal angle value + public: virtual gz::math::Angle AngleMax() const = 0; + + /// \brief Set maximal horizontal angle value + public: virtual void SetAngleMax(double _angle) = 0; + + /// \brief Get horizontal quantity of rays + // \return horizontal quantity of rays + public: virtual int RayCount() const = 0; + + /// \brief Set horizontal quantity of rays + public: virtual void SetRayCount(int _samples) = 0; + + /// \brief Get hoizontal range count, i.e. ray count * horz resolution + // \return horizontal range count + public: virtual int RangeCount() const = 0; + + /// \brief Get vertical quantity of rays + // \return vertical quantity of rays + public: virtual int VerticalRayCount() const = 0; + + /// \brief Set vertical quantity of rays + public: virtual void SetVerticalRayCount(int _samples) = 0; + + /// \brief Get vertical range count, i.e. ray count * vert resolution + // \return Vertical range count + public: virtual int VerticalRangeCount() const = 0; + + /// \brief Get minimal vertical angle value + // \return minimal vertical angle value + public: virtual gz::math::Angle VerticalAngleMin() const = 0; + + /// \brief Set minimal vertical angle value + public: virtual void SetVerticalAngleMin(const double _angle) = 0; + + /// \brief Get maximal vertical angle value + // \return maximal vertical angle value + public: virtual gz::math::Angle VerticalAngleMax() const = 0; + + /// \brief Set maximal vertical angle value + // \return minimal vertical angle value + public: virtual void SetVerticalAngleMax(const double _angle) = 0; + + /// \brief Get the number of channels used to store the ray data. + /// \return Channel count. + public: virtual unsigned int Channels() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Grid.hh b/include/gz/rendering/Grid.hh new file mode 100644 index 000000000..70fa66019 --- /dev/null +++ b/include/gz/rendering/Grid.hh @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_GRID_HH_ +#define GZ_RENDERING_GRID_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Grid Grid.hh ignition/rendering/Grid + /// \brief Represents a grid geometry drawn along the XY plane. + /// If vertical cell count is specified then the grid becomes 3D. + class IGNITION_RENDERING_VISIBLE Grid : + public virtual Geometry + { + /// \brief Destructor + public: virtual ~Grid() { } + + /// \brief Set the number of cells on a planar grid + /// \param[in] _count The number of cells + public: virtual void SetCellCount(const unsigned int _count) = 0; + + /// \brief Get the number of cells on a planar grid + /// \return Number of cells + public: virtual unsigned int CellCount() const = 0; + + /// \brief Set the cell length in one direction. + /// The cells are assumed to be square. + /// \param[in] _len The cell length + public: virtual void SetCellLength(const double _len) = 0; + + /// \brief Get the cell length + /// \return The cell length + public: virtual double CellLength() const = 0; + + /// \brief Set the vertical cell count of the grid. This makes the grid 3D + /// \param[in] _count Number of cells in vertical direction. + public: virtual void SetVerticalCellCount(const unsigned int _count) = 0; + + /// \brief Get the vertical cell count + /// \return The vertical cell count. + public: virtual unsigned int VerticalCellCount() const = 0; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/Image.hh b/include/gz/rendering/Image.hh new file mode 100644 index 000000000..249c34b0c --- /dev/null +++ b/include/gz/rendering/Image.hh @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_IMAGE_HH_ +#define GZ_RENDERING_IMAGE_HH_ + +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Image Image.hh ignition/rendering/Image.hh + /// \brief Encapsulates a raw image buffer and relevant properties + class IGNITION_RENDERING_VISIBLE Image + { + /// \brief Shared pointer to raw image buffer + typedef std::shared_ptr DataPtr; + + /// \brief Default constructor + public: Image() = default; + + /// \brief Constructor + /// \param[in] _width Image width in pixels + /// \param[in] _height Image height in pixels + /// \param[in] _format Image pixel format + public: Image(unsigned int _width, unsigned int _height, + PixelFormat _format); + + /// \brief Deconstructor + public: ~Image(); + + /// \brief Get image width in pixels + /// \return The image width in pixels + public: unsigned int Width() const; + + /// \brief Get image height in pixels + /// \return The image height in pixels + public: unsigned int Height() const; + + /// \brief Get image pixel format + /// \return The image pixel format + public: PixelFormat Format() const; + + /// \brief Get image channel depth + /// \return The image channel depth + public: unsigned int Depth() const; + + /// \brief Get image channel depth + /// \return The image channel depth + public: unsigned int MemorySize() const; + + /// \brief Get a const pointer to image data + /// \return The const pointer to image data + public: const void *Data() const; + + /// \brief Get a pointer to image data + /// \return The pointer to image data + public: void *Data(); + + /// \brief Get a const pointer to image data. The returned image buffer + /// will be statically cast to the given template type T. + /// \return The const pointer to image data + public: template + const T *Data() const; + + /// \brief Get a pointer to image data. The returned image buffer will be + /// statically cast to the given template type T. + /// \return The pointer to image data + public: template + T *Data(); + + /// \brief Image width in pixels + private: unsigned int width = 0; + + /// \brief Image height in pixels + private: unsigned int height = 0; + + /// \brief Image pixel format + private: PixelFormat format = PF_UNKNOWN; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Pointer to the image data + private: DataPtr data = nullptr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + + ////////////////////////////////////////////////// + template + const T *Image::Data() const + { + return static_cast(this->data.get()); + } + + ////////////////////////////////////////////////// + template + T *Image::Data() + { + return static_cast(this->data.get()); + } + } + } +} +#endif diff --git a/include/gz/rendering/Light.hh b/include/gz/rendering/Light.hh new file mode 100644 index 000000000..a908a98a5 --- /dev/null +++ b/include/gz/rendering/Light.hh @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_LIGHT_HH_ +#define GZ_RENDERING_LIGHT_HH_ + +#include "gz/math/Color.hh" +#include "gz/rendering/config.hh" +#include "gz/rendering/Node.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Light Light.hh ignition/rendering/Light.hh + /// \brief Represents a light source in the scene graph + class IGNITION_RENDERING_VISIBLE Light : + public virtual Node + { + /// \brief Deconstructor + public: virtual ~Light() { } + + /// \brief Get the diffuse color + /// \return The diffuse color + public: virtual math::Color DiffuseColor() const = 0; + + /// \brief Set the diffuse color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetDiffuseColor(double _r, double _g, double _b, + double _a = 1.0) = 0; + + /// \brief Set the diffuse color + /// \param[in] _color New diffuse color + public: virtual void SetDiffuseColor(const math::Color &_color) = 0; + + /// \brief Get the specular color + /// \return The specular color + public: virtual math::Color SpecularColor() const = 0; + + /// \brief Set the specular color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetSpecularColor(double _r, double _g, double _b, + double _a = 1.0) = 0; + + /// \brief Set the specular color + /// \param[in] _color New specular color + public: virtual void SetSpecularColor(const math::Color &_color) = 0; + + /// \brief Get the attenuation constant value + /// \return The attenuation constant value + public: virtual double AttenuationConstant() const = 0; + + /// \brief Set the attenuation constant value + /// \param[in] _value New attenuation constant value + public: virtual void SetAttenuationConstant(double _value) = 0; + + /// \brief Get the attenuation linear value + /// \return The attenuation linear value + public: virtual double AttenuationLinear() const = 0; + + /// \brief Set the attenuation linear value + /// \param[in] _value New attenuation linear value + public: virtual void SetAttenuationLinear(double _value) = 0; + + /// \brief Get the attenuation quadratic value + /// \return The attenuation quadratic value + public: virtual double AttenuationQuadratic() const = 0; + + /// \brief Set the attenuation quadratic value + /// \param[in] _value New attenuation quadratic value + public: virtual void SetAttenuationQuadratic(double _value) = 0; + + /// \brief Get the attenuation range + /// \return The attenuation range + public: virtual double AttenuationRange() const = 0; + + /// \brief Set the attenuation range + /// \param[in] _range New attenuation range + public: virtual void SetAttenuationRange(double _range) = 0; + + /// \brief Determine if this light cast shadows + /// \return True if this light cast shadows + public: virtual bool CastShadows() const = 0; + + /// \brief Specify if this light should cast shadows + /// \param[in] _castShadows True if this light cast shadows + public: virtual void SetCastShadows(bool _castShadows) = 0; + }; + + /// \class DirectionalLight Light.hh ignition/rendering/Light.hh + /// \brief Represents a infinite directional light + class IGNITION_RENDERING_VISIBLE DirectionalLight : + public virtual Light + { + /// \brief Destructor + public: virtual ~DirectionalLight() { } + + /// \brief Get the direction of the light + /// \return The direction of the light + public: virtual math::Vector3d Direction() const = 0; + + /// \brief Set the direction of the light + /// \param[in] _x X-component of direction vector + /// \param[in] _y Y-component of direction vector + /// \param[in] _z Z-component of direction vector + public: virtual void SetDirection(double _x, double _y, double _z) = 0; + + /// \brief Set the direction of the light + /// \param[in] _dir New direction vector + public: virtual void SetDirection(const math::Vector3d &_dir) = 0; + }; + + /// \class PointLight Light.hh ignition/rendering/Light.hh + /// \brief Represents a point light + class IGNITION_RENDERING_VISIBLE PointLight : + public virtual Light + { + /// \brief Deconstructor + public: virtual ~PointLight() { } + }; + + /// \class SpotLight Light.hh ignition/rendering/Light.hh + /// \brief Represents a spotlight + class IGNITION_RENDERING_VISIBLE SpotLight : + public virtual Light + { + /// \brief Deconstructor + public: virtual ~SpotLight() { } + + /// \brief Get direction of the light + /// \return The direction of the light + public: virtual math::Vector3d Direction() const = 0; + + /// \brief Set the direction of the light + /// \param[in] _x X-component of direction vector + /// \param[in] _y Y-component of direction vector + /// \param[in] _z Z-component of direction vector + public: virtual void SetDirection(double _x, double _y, double _z) = 0; + + /// \brief Set the direction of the light + /// \param[in] _dir New direction vector + public: virtual void SetDirection(const math::Vector3d &_dir) = 0; + + /// \brief Get the inner angle of the spotlight + /// \return The inner angle of the spotlight + public: virtual math::Angle InnerAngle() const = 0; + + /// \brief Set the inner angle of the spotlight + /// \param[in] _radians New inner angle of the spotlight in radians + public: virtual void SetInnerAngle(double _radians) = 0; + + /// \brief Set the inner angle of the spotlight + /// \param[in] _angle New inner angle of the spotlight + public: virtual void SetInnerAngle(const math::Angle &_angle) = 0; + + /// \brief Get the outer angle of the spotlight + /// \return The outer angle of the spotlight + public: virtual math::Angle OuterAngle() const = 0; + + /// \brief Set the outer angle of the spotlight + /// \param[in] _radians New outer angle of the spotlight in radians + public: virtual void SetOuterAngle(double _radians) = 0; + + /// \brief Set the outer angle of the spotlight + /// \param[in] _angle New outer angle of the spotlight + public: virtual void SetOuterAngle(const math::Angle &_angle) = 0; + + /// \brief Get the falloff of the spotlight + /// \return The falloff of the spotlight + public: virtual double Falloff() const = 0; + + /// \brief Set the falloff of the spotlight + /// \param[in] _falloff New falloff of the spotlight + public: virtual void SetFalloff(double _falloff) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Marker.hh b/include/gz/rendering/Marker.hh new file mode 100644 index 000000000..f5e166821 --- /dev/null +++ b/include/gz/rendering/Marker.hh @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_MARKER_HH_ +#define GZ_RENDERING_MARKER_HH_ + +#include +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/Object.hh" +#include "gz/rendering/RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Enum for marker types + enum IGNITION_RENDERING_VISIBLE MarkerType + { + /// \brief No type + MT_NONE = 0, + + /// \brief Box geometry + MT_BOX = 1, + + /// \brief Cylinder geometry + MT_CYLINDER = 2, + + /// \brief Line strip primitive + MT_LINE_STRIP = 3, + + /// \brief Line list primitive + MT_LINE_LIST = 4, + + /// \brief Points primitive + MT_POINTS = 5, + + /// \brief Sphere geometry + MT_SPHERE = 6, + + /// \brief Text geometry + MT_TEXT = 7, + + /// \brief Triangle fan primitive + MT_TRIANGLE_FAN = 8, + + /// \brief Triangle list primitive + MT_TRIANGLE_LIST = 9, + + /// \brief Triangle strip primitive + MT_TRIANGLE_STRIP = 10 + }; + + /// \class Marker Marker.hh ignition/rendering/Marker + /// \brief A marker geometry class. The marker's visual appearance is based + /// on the marker type specified. + class IGNITION_RENDERING_VISIBLE Marker : + public virtual Geometry + { + protected: Marker(); + + /// \brief Destructor + public: virtual ~Marker(); + + /// \brief Set the lifetime of this Marker + /// \param[in] _lifetime The time at which the marker will be removed + public: virtual void SetLifetime( + const std::chrono::steady_clock::duration &_lifetime) = 0; + + /// \brief Get the lifetime of this Marker + /// \return The time at which the marker will be removed + public: virtual std::chrono::steady_clock::duration Lifetime() const = 0; + + /// \brief Set the layer of this Marker + /// \param[in] _layer Layer at which the marker will reside + public: virtual void SetLayer(int32_t _layer) = 0; + + /// \brief Get the layer of this Marker + /// \return The layer of the marker + public: virtual int32_t Layer() const = 0; + + /// \brief Set the render type of this Marker + /// \param[in] _markerType The desired render type + public: virtual void SetType( + const gz::rendering::MarkerType _markerType) = 0; + + /// \brief Get the render type of this Marker + /// \return The render type of the marker + public: virtual gz::rendering::MarkerType Type() const = 0; + + /// \brief Clear the points of the marker, if applicable + public: virtual void ClearPoints() = 0; + + /// \brief Add a point with its respective color to the marker + /// \param[in] _x X coordinate + /// \param[in] _y Y coordinate + /// \param[in] _z Z coordinate + /// \param[in] _color The color the point is set to + public: virtual void AddPoint(double _x, + double _y, double _z, + const gz::math::Color &_color) = 0; + + /// \brief Add a point with its respective color to the marker + /// \param[in] _pt A vector containing the position of the point + /// \param[in] _color The color the point is set to + public: virtual void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color) = 0; + + /// \brief Set an existing point's vector + /// \param[in] _index The index of the point + /// \param[in] _value The new positional vector of the point + public: virtual void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value) = 0; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/Material.hh b/include/gz/rendering/Material.hh new file mode 100644 index 000000000..086185f4f --- /dev/null +++ b/include/gz/rendering/Material.hh @@ -0,0 +1,356 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_MATERIAL_HH_ +#define GZ_RENDERING_MATERIAL_HH_ + +#include +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Object.hh" +#include "gz/rendering/ShaderType.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief An enum for the type of material + enum IGNITION_RENDERING_VISIBLE MaterialType + { + /// \brief Classic shading, i.e. variants of Phong + MT_CLASSIC = 0, + + /// \brief Physically Based Shading + MT_PBS = 1 + }; + + /// \class Material Material.hh ignition/rendering/Material.hh + /// \brief Represents a surface material of a Geometry + class IGNITION_RENDERING_VISIBLE Material : + public virtual Object + { + /// \brief Deconstructor + public: virtual ~Material() { } + + /// \brief Determine if lighting affects this material + /// \return True if lighting affects this material + public: virtual bool LightingEnabled() const = 0; + + /// \brief Specify if lighting affects this material + /// \param[in] _enabled True if lighting affects this material + public: virtual void SetLightingEnabled(const bool _enabled) = 0; + + /// \brief Specify if depth buffer checking is enabled + /// \param[in] _enabled True if depth check is enabled + public: virtual void SetDepthCheckEnabled(bool _enabled) = 0; + + /// \brief Determine if depth buffer checking is enabled + /// \return True if depth check is enabled + public: virtual bool DepthCheckEnabled() const = 0; + + /// \brief Specify if depth buffer writing is enabled + /// \param[in] _enabled True if depth buffer writing is enabled + public: virtual void SetDepthWriteEnabled(bool _enabled) = 0; + + /// \brief Determine if depth buffer writing is enabled + /// \return True if depth buffer writing is enabled + public: virtual bool DepthWriteEnabled() const = 0; + + /// \brief Get the ambient color + /// \return The ambient color + public: virtual math::Color Ambient() const = 0; + + /// \brief Set the ambient color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetAmbient(const double _r, const double _g, + const double _b, const double _a = 1.0) = 0; + + /// \brief Set the ambient color + /// \param[in] _color New ambient color + public: virtual void SetAmbient(const math::Color &_color) = 0; + + /// \brief Get the diffuse color + /// \return The diffuse color + public: virtual math::Color Diffuse() const = 0; + + /// \brief Set the diffuse color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetDiffuse(const double _r, const double _g, + const double _b, const double _a = 1.0) = 0; + + /// \brief Set the diffuse color + /// \param[in] _color New diffuse color + public: virtual void SetDiffuse(const math::Color &_color) = 0; + + /// \brief Get the specular color + /// \return The specular color + public: virtual math::Color Specular() const = 0; + + /// \brief Set the specular color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetSpecular(const double _r, const double _g, + const double _b, const double _a = 1.0) = 0; + + /// \brief Set the specular color + /// \param[in] _color New specular color + public: virtual void SetSpecular(const math::Color &_color) = 0; + + /// \brief Get the emissive color + /// \return The emissive color + public: virtual math::Color Emissive() const = 0; + + /// \brief Set the emissive color + /// \param[in] _r Red value + /// \param[in] _g Green value + /// \param[in] _b Blue value + /// \param[in] _a Alpha value + public: virtual void SetEmissive(const double _r, const double _g, + const double _b, const double _a = 1.0) = 0; + + /// \brief Set the emissive color + /// \param[in] _color New emissive color + public: virtual void SetEmissive(const math::Color &_color) = 0; + + /// \brief Get the shininess value + /// \return The shininess value + public: virtual double Shininess() const = 0; + + /// \brief Set the shininess value + /// \param[in] _shininess New shininess value + public: virtual void SetShininess(const double _shininess) = 0; + + /// \brief Get the transparency value + /// \return The transparency value + public: virtual double Transparency() const = 0; + + /// \brief Configuration for Depth Material + /// \param[in] far Far distance for normalized output + /// \param[in] near Near distance for normalized output + public: virtual void SetDepthMaterial(const double far, + const double near) = 0; + + /// \brief Set the transparency value + /// \param[in] _transparency New transparency value + public: virtual void SetTransparency(const double _transparency) = 0; + + /// \brief 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 Set the roughness value. Only affects material of type MT_PBS + /// \param[in] _roughness Roughness to set to + public: virtual void SetRoughness(const float _roughness) = 0; + + /// \brief Get the roughness value of this material. + /// \return Material roughness + public: virtual float Roughness() const = 0; + + /// \brief Set the metalness value. Only affects material of type MT_PBS + /// \param[in] _metalness Metalness to set to + public: virtual void SetMetalness(const float _metalness) = 0; + + /// \brief Get the metalness value of this material + /// \return Material metalness + public: virtual float Metalness() const = 0; + + /// \brief Removes any metalness map mapped to this material + public: virtual enum MaterialType Type() const = 0; + + /// \brief Get the ShaderType value + /// \return The ShaderType value + public: virtual enum ShaderType ShaderType() const = 0; + + /// \brief Set the ShaderType value + /// \param[in] _type New ShaderType value + public: virtual void SetShaderType(enum ShaderType _type) = 0; + + /// \brief Clone this material + /// \return New cloned material + public: virtual MaterialPtr Clone(const std::string &_name = "") + const = 0; + + /// \brief Copy properties from given Material + /// \param[in] _material Source Material to be copied from + public: virtual void CopyFrom(ConstMaterialPtr _material) = 0; + + /// \brief Copy properties from given Material + /// \param[in] _material Source Material to be copied from + public: virtual void CopyFrom(const common::Material &_material) = 0; + + /// \brief Get path to the vertex shader + /// \return Path to vertex shader + public: virtual std::string VertexShader() const = 0; + + /// \brief Get params for the vertex shader + /// \return editable parameters + public: virtual ShaderParamsPtr VertexShaderParams() = 0; + + /// \brief Set the vertex shader + /// \param[in] _path path to a file containing a glsl shader + public: virtual void SetVertexShader(const std::string &_path) = 0; + + /// \brief Get path to the fragment shader + /// \return Path to fragment shader + public: virtual std::string FragmentShader() const = 0; + + /// \brief Get params for the fragment shader + /// \return editable parameters + public: virtual ShaderParamsPtr FragmentShaderParams() = 0; + + /// \brief Set the fragment shader + /// \param[in] _path path to a file containing a glsl shader + public: virtual void SetFragmentShader(const std::string &_path) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Mesh.hh b/include/gz/rendering/Mesh.hh new file mode 100644 index 000000000..4abafd126 --- /dev/null +++ b/include/gz/rendering/Mesh.hh @@ -0,0 +1,118 @@ +/* + * 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 "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 Mesh Mesh.hh ignition/rendering/Mesh + /// \brief Represents a collection of mesh geometries + class IGNITION_RENDERING_VISIBLE Mesh : + public virtual Geometry + { + /// \brief Destructor + public: virtual ~Mesh() { } + + /// \brief Check whether the mesh has skeleton + /// \return True if the mesh has skeleton + public: virtual bool HasSkeleton() const = 0; + + /// \brief Get the skeleton local transforms + /// \return Map of skeleton local transformations + /// * Map holding: + /// * Skeleton node names + /// * Local transformations of the skeleton nodes + public: virtual std::map + SkeletonLocalTransforms() const = 0; + + /// \brief Set transforms for the skeleton + /// \param[in] _tfs Map of skeleton local transformations + /// * Map holding: + /// * Skeleton node names + /// * Local transformations of the skeleton nodes + /// \return True if all the transformations are set to the skeleton + public: virtual void SetSkeletonLocalTransforms( + const std::map &_tfs) = 0; + + /// \brief Get 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; + }; + + /// \class SubMesh Mesh.hh ignition/rendering/Mesh.hh + /// \brief Represents a single mesh geometry + class IGNITION_RENDERING_VISIBLE SubMesh : + public virtual Object + { + /// \brief Deconstructor + public: virtual ~SubMesh() { } + + /// \brief Get the currently assigned material + /// \return The currently assigned material + public: virtual MaterialPtr Material() const = 0; + + /// \brief Set the materials of this SubMesh. The specified material + /// will be retrieved from the parent Scene. If no material is registered + /// by the given name, no work will be done. + /// \param[in] _name Name of registered Material + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetMaterial(const std::string &_name, + bool _unique = true) = 0; + + /// \brief Set the materials of this SubMesh + /// \param[in] _material New Material to be assigned + /// \param[in] _unique True if the given material should be cloned + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/MeshDescriptor.hh b/include/gz/rendering/MeshDescriptor.hh new file mode 100644 index 000000000..2dc15b0dd --- /dev/null +++ b/include/gz/rendering/MeshDescriptor.hh @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_MESHDESCRIPTOR_HH_ +#define GZ_RENDERING_MESHDESCRIPTOR_HH_ + +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace common + { + class Mesh; + } +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \struct MeshDescriptor MeshDescriptor.hh + /// ignition/rendering/MeshDescriptor.hh + /// \brief Describes how a Mesh should be loaded + struct IGNITION_RENDERING_VISIBLE MeshDescriptor + { + /// \brief Constructor + public: MeshDescriptor(); + + /// \brief Constructor. A common::Mesh will be retrieved from the + /// MeshManager by the given name upon a call to Normalize. + /// \param[in] _meshName Name of the mesh to load + public: explicit MeshDescriptor(const std::string &_meshName); + + /// \brief Constructor + /// \param[in] _mesh Mesh to load + public: explicit MeshDescriptor(const common::Mesh *_mesh); + + /// \brief Ensures both the meshName and mesh member variables have been + /// assigned. If mesh is not null, it will be used to override the value + /// of meshName. + public: void Load(); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief common::Mesh object + public: const common::Mesh *mesh = nullptr; + + /// \brief Name of the registered Mesh + public: std::string meshName; + + /// \brief Name of the sub-mesh to be loaded. An empty string signifies + /// all sub-meshes should be loaded. + public: std::string subMeshName; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Denotes if the loaded sub-mesh vertices should be centered + public: bool centerSubMesh = false; + }; + } + } +} +#endif diff --git a/include/gz/rendering/MoveToHelper.hh b/include/gz/rendering/MoveToHelper.hh new file mode 100644 index 000000000..d6ca753eb --- /dev/null +++ b/include/gz/rendering/MoveToHelper.hh @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_MOVETOHELPER_HH_ +#define GZ_RENDERING_MOVETOHELPER_HH_ + +#include + +#include +#include + +#include +#include + +#include "gz/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + // Inline bracket to help doxygen filtering. + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // forward declaration + class MoveToHelperPrivate; + + /// \brief Helper class for animating a user camera to move to a target + /// entity + class IGNITION_RENDERING_VISIBLE MoveToHelper + { + public: MoveToHelper(); + + public: ~MoveToHelper(); + + /// \brief Move the camera to look at the specified target + /// param[in] _camera Camera to be moved + /// param[in] _target Target to look at + /// param[in] _duration Duration of the move to animation, in seconds. + /// param[in] _onAnimationComplete Callback function when animation is + /// complete + public: void MoveTo(const rendering::CameraPtr &_camera, + const rendering::NodePtr &_target, double _duration, + std::function _onAnimationComplete); + + /// \brief Move the camera to the specified pose. + /// param[in] _camera Camera to be moved + /// param[in] _target Pose to move to + /// param[in] _duration Duration of the move to animation, in seconds. + /// param[in] _onAnimationComplete Callback function when animation is + /// complete + public: void MoveTo(const rendering::CameraPtr &_camera, + const math::Pose3d &_target, double _duration, + std::function _onAnimationComplete); + + /// \brief Move the camera to look at the specified target + /// param[in] _camera Camera to be moved + /// param[in] _direction The pose to assume relative to the + /// entit(y/ies), (0, 0, 0) indicates to return the camera back to the + /// home pose originally loaded in from the sdf. + /// param[in] _duration Duration of the move to animation, in seconds. + /// param[in] _onAnimationComplete Callback function when animation is + /// complete + public: void LookDirection(const rendering::CameraPtr &_camera, + const math::Vector3d &_direction, const math::Vector3d &_lookAt, + double _duration, std::function _onAnimationComplete); + + /// \brief Add time to the animation. + /// \param[in] _time Time to add in seconds + public: void AddTime(double _time); + + /// \brief Get whether the move to helper is idle, i.e. no animation + /// is being executed. + /// \return True if idle, false otherwise + public: bool Idle() const; + + /// \brief Set the initial camera pose + /// param[in] _pose The init pose of the camera + public: void SetInitCameraPose(const math::Pose3d &_pose); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/Node.hh b/include/gz/rendering/Node.hh new file mode 100644 index 000000000..3e1fce508 --- /dev/null +++ b/include/gz/rendering/Node.hh @@ -0,0 +1,309 @@ +/* + * 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 "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 Node Node.hh ignition/rendering/Node.hh + /// \brief Represents a single posable node in the scene graph + class IGNITION_RENDERING_VISIBLE Node : + public virtual Object + { + /// \brief Deconstructor + public: virtual ~Node() { } + + /// \brief Determine if this Node is attached to another Node. + /// \return True if this Node has a parent Node + public: virtual bool HasParent() const = 0; + + /// \brief Get the parent Node + /// \return the parent Node + public: virtual NodePtr Parent() const = 0; + + /// \brief Detach this Node from its parent. If this + /// Node does not have a parent, no work will be done. + public: virtual void RemoveParent() = 0; + + /// \brief Get the local pose + /// \return The local pose + public: virtual math::Pose3d LocalPose() const = 0; + + /// \brief Set the local pose + /// \param[in] _pose New local pose + public: virtual void SetLocalPose(const math::Pose3d &_pose) = 0; + + /// \brief Get the local position + /// \return The local position + public: virtual math::Vector3d LocalPosition() const = 0; + + /// \brief Set the local position + /// \param[in] _x X-coordinate + /// \param[in] _y Y-coordinate + /// \param[in] _z Z-coordinate + public: virtual void SetLocalPosition(double _x, double _y, + double _z) = 0; + + /// \brief Set the local position + /// \param[in] _position New local position + public: virtual void SetLocalPosition( + const math::Vector3d &_position) = 0; + + /// \brief Get the local rotation + /// \return The local rotation + public: virtual math::Quaterniond LocalRotation() const = 0; + + /// \brief Set the local rotation + /// \param[in] _r roll + /// \param[in] _p pitch + /// \param[in] _y yaw + public: virtual void SetLocalRotation(double _r, double _p, + double _y) = 0; + + /// \brief Set the local rotation + /// \param[in] _w W-coordinate + /// \param[in] _x X-coordinate + /// \param[in] _y Y-coordinate + /// \param[in] _z Z-coordinate + public: virtual void SetLocalRotation(double _w, double _x, double _y, + double _z) = 0; + + /// \brief Set the local rotation + /// \param[in] _rotation New local rotation + public: virtual void SetLocalRotation( + const math::Quaterniond &_rotation) = 0; + + /// \brief Get the world pose + /// \return The world pose + public: virtual math::Pose3d WorldPose() const = 0; + + /// \brief Set the world pose + /// \param[in] _pose New world pose + public: virtual void SetWorldPose(const math::Pose3d &_pose) = 0; + + /// \brief Get the world position + /// \return The world position + public: virtual math::Vector3d WorldPosition() const = 0; + + /// \brief Set the world position + /// \param[in] _x X-coordinate + /// \param[in] _y Y-coordinate + /// \param[in] _z Z-coordinate + public: virtual void SetWorldPosition(double _x, double _y, + double _z) = 0; + + /// \brief Set the world position + /// \param[in] _position New world position + public: virtual void SetWorldPosition( + const math::Vector3d &_position) = 0; + + /// \brief Get the world rotation + /// \return The world rotation + public: virtual math::Quaterniond WorldRotation() const = 0; + + /// \brief Set the world rotation + /// \param[in] _r roll + /// \param[in] _p pitch + /// \param[in] _y yaw + public: virtual void SetWorldRotation(double _r, double _p, + double _y) = 0; + + /// \brief Set the world rotation + /// \param[in] _w W-coordinate + /// \param[in] _x X-coordinate + /// \param[in] _y Y-coordinate + /// \param[in] _z Z-coordinate + public: virtual void SetWorldRotation(double _w, double _x, double _y, + double _z) = 0; + + /// \brief Set the world rotation + /// \param[in] _rotation New world rotation + public: virtual void SetWorldRotation( + const math::Quaterniond &_rotation) = 0; + + /// \brief Convert given world pose to local pose + /// \param[in] _pose World pose to be converted + public: virtual math::Pose3d WorldToLocal( + const math::Pose3d &_pose) const = 0; + + /// \brief Get position of origin + /// \return The position of the origin + public: virtual math::Vector3d Origin() const = 0; + + /// \brief Set position of origin. The position should be relative to the + /// original origin of the geometry. + /// \param[in] _x X-coordinate + /// \param[in] _y Y-coordinate + /// \param[in] _z Z-coordinate + public: virtual void SetOrigin(double _x, double _y, double _z) = 0; + + /// \brief Set position of origin. The position should be relative to the + /// original origin of the geometry. + /// \param[in] _origin New origin position + public: virtual void SetOrigin(const math::Vector3d &_origin) = 0; + + /// \brief Get the local scale + /// \return The local scale + public: virtual math::Vector3d LocalScale() const = 0; + + /// \brief Set the local scale. The given scale will be assigned to the + /// x, y, and z coordinates. + /// \param[in] _scale New local scale + public: virtual void SetLocalScale(double _scale) = 0; + + /// \brief Set the local scale + /// \param[in] _x New x-coordinate scale + /// \param[in] _y New y-coordinate scale + /// \param[in] _z New z-coordinate scale + public: virtual void SetLocalScale(double _x, double _y, double _z) = 0; + + /// \brief Set the local scale + /// \param[in] _scale New local scale + public: virtual void SetLocalScale(const math::Vector3d &_scale) = 0; + + /// \brief Get the world scale + /// \return The world scale + public: virtual math::Vector3d WorldScale() const = 0; + + /// \brief Set the world scale. The given scale will be assigned to the + /// x, y, and z coordinates. + /// \param[in] _scale New world scale + public: virtual void SetWorldScale(double _scale) = 0; + + /// \brief Set the world scale + /// \param[in] _x New x-coordinate scale + /// \param[in] _y New y-coordinate scale + /// \param[in] _z New z-coordinate scale + public: virtual void SetWorldScale(double _x, double _y, double _z) = 0; + + /// \brief Set the world scale + /// \param[in] _scale New world scale + public: virtual void SetWorldScale(const math::Vector3d &_scale) = 0; + + /// \brief Scale the current scale by the given scalar. The given scalar + /// will be assigned to the x, y, and z coordinates. + /// \param[in] _scale Scalar to alter the current scale + public: virtual void Scale(double _scale) = 0; + + /// \brief Scale the current scale by the given scalars + /// \param[in] _x Scalar to alter the current x-coordinate scale + /// \param[in] _y Scalar to alter the current y-coordinate scale + /// \param[in] _z Scalar to alter the current z-coordinate scale + public: virtual void Scale(double _x, double _y, double _z) = 0; + + /// \brief Scale the current scale by the given scalars + /// \param[in] _scale Scalars to alter the current scale + public: virtual void Scale(const math::Vector3d &_scale) = 0; + + /// \brief Determine if this visual inherits scale from this parent + /// \return True if this visual inherits scale from this parent + public: virtual bool InheritScale() const = 0; + + /// \brief Specify if this visual inherits scale from its parent + /// \param[in] _inherit True if this visual inherits scale from its parent + public: virtual void SetInheritScale(bool _inherit) = 0; + + /// \brief Get number of child nodes + /// \return The number of child nodes + public: virtual unsigned int ChildCount() const = 0; + + /// \brief Determine if given node is an attached child + /// \return True if given node is an attached child + public: virtual bool HasChild(ConstNodePtr _child) const = 0; + + /// \brief Determine if node with given ID is an attached child + /// \param[in] _id ID of the node in question + /// \return True if node with given ID is an attached child + public: virtual bool HasChildId(unsigned int _id) const = 0; + + /// \brief Determine if node with given name is an attached child + /// \param[in] _name Name of the node in question + /// \return True if node with given name is an attached child + public: virtual bool HasChildName(const std::string &_name) const = 0; + + /// \brief Get node with given ID. If no child exists with given ID, NULL + /// will be returned. + /// \param[in] _id ID of the desired node + /// \return The specified node + public: virtual NodePtr ChildById(unsigned int _id) const = 0; + + /// \brief Get node with given name. If no child exists with given name, + /// NULL will be returned. + /// \param[in] _name Name of the desired node + /// \return The specified node + public: virtual NodePtr ChildByName( + const std::string &_name) const = 0; + + /// \brief Get node at given index. If no child exists at given index, + /// NULL will be returned. + /// \param[in] _index Index of the desired node + /// \return The specified node + public: virtual NodePtr ChildByIndex(unsigned int _index) const = 0; + + /// \brief Add the given node to this node. If the given node is + /// already a child, no work will be done. + /// \param[in] _child Child node to be added + public: virtual void AddChild(NodePtr _child) = 0; + + /// \brief Remove (detach) the given node from this node. If the given + /// node is not a child of this node, no work will be done. + /// \param[in] _child Child node to be removed + /// \return The removed child node + public: virtual NodePtr RemoveChild(NodePtr _child) = 0; + + /// \brief Remove (detach) the node with the given ID from this node. + /// If the specified node is not a child of this node, no work will be + /// done. + /// \param[in] _id ID of the child node to be removed + /// \return The removed child node + public: virtual NodePtr RemoveChildById(unsigned int _id) = 0; + + /// \brief Remove (detach) the node with the given name from this node. + /// If the specified node is not a child of this node, no work will be + /// done. + /// \param[in] _name Name of the child node to be removed + /// \return The removed child node + public: virtual NodePtr RemoveChildByName(const std::string &_name) = 0; + + /// \brief Remove (detach) the node at the given index from this node. + /// If the specified node is not a child of this node, no work will be + /// done. + /// \param[in] _index Index of the child node to be removed + /// \return The removed child node + public: virtual NodePtr RemoveChildByIndex(unsigned int _index) = 0; + + /// \brief Remove all child nodes from this node + /// This detaches all the child nodes but does not destroy them + public: virtual void RemoveChildren() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Object.hh b/include/gz/rendering/Object.hh new file mode 100644 index 000000000..1d33a29b5 --- /dev/null +++ b/include/gz/rendering/Object.hh @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OBJECT_HH_ +#define GZ_RENDERING_OBJECT_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Object Object.hh ignition/rendering/Object.hh + /// \brief Represents an object present in the scene graph. This includes + /// sub-meshes, materials, render targets, as well as posable nodes. + class IGNITION_RENDERING_VISIBLE Object + { + /// \brief Destructor + public: virtual ~Object() { } + + /// \brief Get the object ID. This ID will be unique across all objects + /// inside a given scene, but necessarily true for objects across + /// different scenes. + /// \return The object ID + public: virtual unsigned int Id() const = 0; + + /// \brief Get the object name. This name will be unique across all + /// objects inside a given scene, but necessarily true for objects across + /// different scenes. + /// \return The object name + public: virtual std::string Name() const = 0; + + /// \brief Get the Scene that created this object. + /// \return The parent scene + public: virtual ScenePtr Scene() const = 0; + + /// \brief Prepare this object and any of its children for rendering. + /// This should be called for each object in a scene just before + /// rendering, which can be achieved by a single call to Scene::PreRender + public: virtual void PreRender() = 0; + + /// \brief Post process this object and any of its children after + /// rendering. + public: virtual void PostRender() = 0; + + /// \brief Destroy any resources associated with this object. Invoking + /// any other functions after destroying an object will result in + /// undefined behavior. + public: virtual void Destroy() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/OrbitViewController.hh b/include/gz/rendering/OrbitViewController.hh new file mode 100644 index 000000000..d10b8fd48 --- /dev/null +++ b/include/gz/rendering/OrbitViewController.hh @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_ORBITVIEWCONTROLLER_HH_ +#define GZ_RENDERING_ORBITVIEWCONTROLLER_HH_ + +#include + +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/ViewController.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations + class OrbitViewControllerPrivate; + + /// \class OrbitViewController OrbitViewController.hh + /// ignition/rendering/OrbitViewController.hh + /// \brief A camera view controller + class IGNITION_RENDERING_VISIBLE OrbitViewController + : public virtual ViewController + { + /// \brief Deconstructor + public: OrbitViewController(); + + /// \brief Deconstructor + public: explicit OrbitViewController(const CameraPtr &_camera); + + /// \brief Deconstructor + public: virtual ~OrbitViewController(); + + /// \brief Set the camera that will be controlled by this view controller. + /// \param[in] _camera Camera to control + public: virtual void SetCamera(const CameraPtr &_camera); + + /// \brief Get the camera that is controlled by this view controller. + /// \return Camera being controlled + public: virtual CameraPtr Camera() const; + + /// \brief Set target point for pan, zoom, oribit + /// \param[in] _target Target point in world coordinates + public: virtual void SetTarget(const math::Vector3d &_target); + + /// \brief Get target point for pan, zoom, oribit + /// \return target point in world coordinates + public: virtual math::Vector3d Target() const; + + /// \brief Set zoom amount + /// \param[in] _value Camera zoon value, e.g. mouse scroll delta + public: virtual void Zoom(const double _value); + + /// \brief Set camera pan (translational movement) around target point. + /// \param[in] _value Pan amount in image plane, e.g. mouse drag delta. + public: virtual void Pan(const math::Vector2d &_value); + + /// \brief Set camera orbit (rotational movement) around target point. + /// \param[in] _value robit amount in image plane, e.g. mouse drag delta + public: virtual void Orbit(const math::Vector2d &_value); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief Private data pointer + public: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/PixelFormat.hh b/include/gz/rendering/PixelFormat.hh new file mode 100644 index 000000000..6542a321d --- /dev/null +++ b/include/gz/rendering/PixelFormat.hh @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_PIXELFORMAT_HH_ +#define GZ_RENDERING_PIXELFORMAT_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \enum PixelFormat PixelFormat.hh ignition/rendering/PixelFormat.hh + /// \brief Image pixel format types + enum IGNITION_RENDERING_VISIBLE PixelFormat + { + /// < Unknown or errant type + PF_UNKNOWN = 0, + /// < Grayscale, 1-byte per channel + PF_L8 = 1, + /// < RGB, 1-byte per channel + PF_R8G8B8 = 2, + /// < BGR, 1-byte per channel + PF_B8G8R8 = 3, + /// < Bayer RGGB, 1-byte per channel + PF_BAYER_RGGB8 = 4, + /// < Bayer BGGR, 1-byte per channel + PF_BAYER_BGGR8 = 5, + /// < Bayer GBGR, 1-byte per channel + PF_BAYER_GBGR8 = 6, + /// < Bayer GRGB, 1-byte per channel + PF_BAYER_GRGB8 = 7, + // Float32 format one channel + PF_FLOAT32_R = 8, + // Float32 format and RGB + PF_FLOAT32_RGBA = 9, + // Float32 format and RGB + PF_FLOAT32_RGB = 10, + // 16 bit single channel + PF_L16 = 11, + /// < Number of pixel format types + PF_COUNT = 12 + }; + + /// \class PixelUtil PixelFormat.hh ignition/rendering/PixelFormat.hh + /// \brief Provides supporting functions for PixelFormat enum + class IGNITION_RENDERING_VISIBLE PixelUtil + { + /// \brief Determine if given format is valid PixelFormat enum + /// \param[in] _format Enum value to be evaluated + public: static bool IsValid(PixelFormat _format); + + /// \brief Sanitize given format. If the given value is invalid, + /// PF_UNKNOWN will be returned, otherwise input will be returned + /// unchanged. + /// \param[in] _format Image pixel format to be sanitized + /// \return The sanitized pixel format + public: static PixelFormat Sanitize(PixelFormat _format); + + /// \brief Get human-readable name for pixel format value. + /// \param[in] _format Image pixel format + /// \return The format name + public: static std::string Name(PixelFormat _format); + + /// \brief Get number of channels for given format. If an invalid format + /// is given, 0 will be returned. + /// \param[in] _format Image pixel format + /// \return The channel count + public: static unsigned int ChannelCount(PixelFormat _format); + + /// \brief Get number of bytes per channel for given format. If an invalid + /// format is given, 0 will be returned. + /// \param[in] _format Image pixel format + /// \return The number of bytes per channel + public: static unsigned int BytesPerChannel(PixelFormat _format); + + /// \brief Get number of bytes per pixel for given format. If an invalid + /// format is given, 0 will be returned. This is simply the product of + /// GetChannelCount and GetBytesPerChannel. + /// \return The number of bytes per pixel + public: static unsigned int BytesPerPixel(PixelFormat _format); + + /// \brief Get total memory size in bytes for an image with the given + /// format and dimensions. If an invalid format is given, 0 will be + /// returned. This is simply the product of GetBytesPerPixel, _width, + /// and, _height. + /// \param[in] _format Image pixel format + /// \param[in] _width Image width in pixels + /// \param[in] _height Image height in pixels + /// \return The number of bytes per pixel + public: static unsigned int MemorySize(PixelFormat _format, + unsigned int _width, unsigned int _height); + + /// \brief Get enum value by human-readable name. The given string should + /// match watch is returned by GetName. If an invalid name is given, + /// PF_UNKNOWN will be returned. + /// \param[in] _name Name of the pixel format to be retrieved + /// \return The specified PixelFormat enum value + public: static PixelFormat Enum(const std::string &_name); + + /// \brief Array of human-readable names for each PixelFormat + private: static const char *names[PF_COUNT]; + + /// \brief Array of channel counts for each PixelFormat + private: static const unsigned char channelCounts[PF_COUNT]; + + /// \brief Array of bytes per channel for each PixelFormat + private: static const unsigned char channelByteCounts[PF_COUNT]; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RayQuery.hh b/include/gz/rendering/RayQuery.hh new file mode 100644 index 000000000..4beca9b6c --- /dev/null +++ b/include/gz/rendering/RayQuery.hh @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RAYQUERY_HH_ +#define GZ_RENDERING_RAYQUERY_HH_ + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief A class that stores ray query intersection results. + class IGNITION_RENDERING_VISIBLE RayQueryResult + { + /// \brief Intersection distance + public: double distance = -1; + + /// \brief Intersection point in 3d space + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public: math::Vector3d point; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Intersected object id + public: unsigned int objectId = 0; + + /// \brief Returns false if result is not valid + public: operator bool() const + { + return distance > 0; + } + + /// \brief Returns false if result is not valid + public: operator bool() + { + return distance > 0; + } + }; + + /// \class RayQuery RayQuery.hh ignition/rendering/RayQuery.hh + /// \brief A Ray Query class used for computing ray object intersections + class IGNITION_RENDERING_VISIBLE RayQuery + : public virtual Object + { + /// \brief Destructor + public: virtual ~RayQuery() { } + + /// \brief Set ray origin + /// \param[in] _origin Ray origin + public: virtual void SetOrigin(const math::Vector3d &_origin) = 0; + + /// \brief Get ray origin + /// \return Ray origin + public: virtual math::Vector3d Origin() const = 0; + + /// \brief Set ray direction + /// \param[in] _dir Ray origin + public: virtual void SetDirection(const math::Vector3d &_dir) = 0; + + /// \brief Get ray direction + /// \return Ray direction. + public: virtual math::Vector3d Direction() const = 0; + + /// \brief Create the ray query from camera + /// \param[in] _camera Camera to construct ray + /// \param[in] _coord normalized device coords [-1, +1] + public: virtual void SetFromCamera(const CameraPtr &_camera, + const math::Vector2d &_coord) = 0; + + /// \brief Compute intersections + /// \return A vector of intersection results + public: virtual RayQueryResult ClosestPoint() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderEngine.hh b/include/gz/rendering/RenderEngine.hh new file mode 100644 index 000000000..6255a218f --- /dev/null +++ b/include/gz/rendering/RenderEngine.hh @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERENGINE_HH_ +#define GZ_RENDERING_RENDERENGINE_HH_ + +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class RenderEngine RenderEngine.hh ignition/rendering/RenderEngine.hh + /// \brief An abstract interface to a concrete render-engine. A + /// RenderEngine is responsible for initializing a render-engine as well as + /// creating, storing, and destroying scenes. + class IGNITION_RENDERING_VISIBLE RenderEngine + { + /// \brief Deconstructor + public: virtual ~RenderEngine() { } + + /// \brief Load any necessary resources to set up render-engine. This + /// should called before any other function. + /// \param[in] _params Parameters to be passed to the underlying + /// rendering engine. + /// \return True if the render-engine was successfully loaded + public: virtual bool Load( + const std::map &_params = {}) = 0; + + /// \brief Initialize the render-engine. This should be called immediately + /// after a successful call to Load. + /// \return True if the render-engine was successfully initialized + public: virtual bool Init() = 0; + + /// \brief Destroys all scenes created by render-engine and releases all + /// loaded resources. This should be called when the given render-engine + /// will no longer be used during runtime. + /// \return True if the render-engine was successfully destroyed + public: virtual void Destroy() = 0; + + // TODO(anyone): merge with Destroy + public: virtual bool Fini() = 0; + + /// \brief Determines if the render-engine has been loaded. + /// \return True if the render-engine is loaded + public: virtual bool IsLoaded() const = 0; + + /// \brief Determines if the render-engine has been initialized. + /// \return True if the render-engine is initialized + public: virtual bool IsInitialized() const = 0; + + /// \brief Determines if the render-engine can be used. Despite loading + /// and initializing the render-engine, it may not be possible to use due + /// to hardware capabilities of the runtime system. + /// \return True if the render-engine can be used + public: virtual bool IsEnabled() const = 0; + + /// \brief Get name of the render-engine. + /// \return The render-engine name + public: virtual std::string Name() const = 0; + + /// \brief Get the number of scenes actively managed by this + /// render-engine + /// \return The number of active scenes + public: virtual unsigned int SceneCount() const = 0; + + /// \brief Determine if the given scene is actively managed by this + /// render-engine + /// \param[in] _scene Scene in question + /// \return True if the scene is managed by this render-engine + public: virtual bool HasScene(ConstScenePtr _scene) const = 0; + + /// \brief Determine if this render-engine manages a scene with the + /// given ID. + /// \param[in] _id ID of scene in question + /// \return True if this render-engine manages the specified scene + public: virtual bool HasSceneId(unsigned int _id) const = 0; + + /// \brief Determine if this render-engine manages a scene with the + /// given name. + /// \param[in] _name Name of scene in question + /// \return True if this render-engine manages the specified scene + public: virtual bool HasSceneName(const std::string &_name) const = 0; + + /// \brief Get the scene with the given ID. If no scenes exist with the + /// given ID, NULL will be returned. + /// \param[in] _id ID of scene to be retrieved + /// \return The specified scene + public: virtual ScenePtr SceneById(unsigned int _id) const = 0; + + /// \brief Get the scene with the given name. If no scenes exist with the + /// given name, NULL will be returned. + /// \param[in] _name Name of scene to be retrieved + /// \return The specified scene + public: virtual ScenePtr SceneByName( + const std::string &_name) const = 0; + + /// \brief Get the scene at the given index. If no scenes exist at the + /// given index, NULL will be returned. + /// \param[in] _index Index of scene, which is a number from 0 to + /// SceneCount() - 1. Note that the index for a specific scene might + /// change as other scenes are destroyed. + /// \return The specified scene + public: virtual ScenePtr SceneByIndex(unsigned int _index) const = 0; + + /// \brief Destroy the given scene. If the given scene is not managed by + /// this render-engine, no work will be done. + /// \param[in] _scene Scene to be destroyed + public: virtual void DestroyScene(ScenePtr _scene) = 0; + + /// \brief Destroy the scene with the given ID. If no scenes exist with + /// the given ID, no work will be done. + /// \param[in] _id ID of the scene to destroy + public: virtual void DestroySceneById(unsigned int _id) = 0; + + /// \brief Destroy the scene with the given name. If no scenes exist with + /// the given name, no work will be done. + /// \param[in] _name Name of the scene to destroy + public: virtual void DestroySceneByName(const std::string &_name) = 0; + + /// \brief Destroy the scene at the given index. If no scenes exist at the + /// given index, no work will be done. + /// \param[in] _index Index of the scene to destroy + public: virtual void DestroySceneByIndex(unsigned int _index) = 0; + + /// \brief Destroy all scenes managed by this render-engine + public: virtual void DestroyScenes() = 0; + + /// \brief Create a new scene with the given name. The given name should + /// be unique across all scenes managed by this render-engine. If a + /// duplicate name is given, NULL will be returned. An unique ID will + /// automatically be assigned to the created scene. + /// \param[in] _name Name of the new scene + /// \return The created scene + public: virtual ScenePtr CreateScene(const std::string &_name) = 0; + + /// \brief Create a new scene with the given ID. The given ID should + /// be unique across all scenes managed by this render-engine. If a + /// duplicate ID is given, NULL will be returned. An unique name will + /// automatically be assigned to the created scene. + /// \param[in] _id ID of the new scene + /// \param[in] _name Name of the new scene + /// \return The created scene + public: virtual ScenePtr CreateScene(unsigned int _id, + const std::string &_name) = 0; + + /// \brief Add path to media resource location + /// \param[in] _path Absolute path to resource location + public: virtual void AddResourcePath(const std::string &_path) = 0; + + /// \brief Get the render pass system for this engine. + public: virtual RenderPassSystemPtr RenderPassSystem() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderEngineManager.hh b/include/gz/rendering/RenderEngineManager.hh new file mode 100644 index 000000000..d7391338b --- /dev/null +++ b/include/gz/rendering/RenderEngineManager.hh @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERENGINEMANAGER_HH_ +#define GZ_RENDERING_RENDERENGINEMANAGER_HH_ + +#include +#include +#include +#include +#include +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations. + class RenderEngine; + class RenderEngineManagerPrivate; + + /// \class RenderEngineManager RenderEngineManager.hh + /// ignition/rendering/RenderEngineManager.hh + /// \brief Collection of render-engines. This provides access to all the + /// render-engines available at runtime. RenderEngine objects should not + /// be access directly, but instead via the RenderEngineManager to maintain + /// a flexible render-engine agnostic design. + class IGNITION_RENDERING_VISIBLE RenderEngineManager : + public virtual common::SingletonT + { + /// \brief Constructor + public: RenderEngineManager(); + + /// \brief Deconstructor + public: ~RenderEngineManager(); + + /// \brief Get the number of available render-engines + /// \return the number of available render-engines + public: unsigned int EngineCount() const; + + /// \brief Determine if a render-engine with the given name is avaiable. + /// It also checks the list of default engines supplied by ign-rendering. + /// \param[in] _name Name of the desired render-engine + /// \return True if the specified render-engine is available + public: bool HasEngine(const std::string &_name) const; + + /// \brief Determine if a render-engine with the given name is already + /// loaded. + /// \param[in] _name Name of the desired render-engine + /// \return True if the specified render-engine is loaded. + public: bool IsEngineLoaded(const std::string &_name) const; + + /// \brief Get the list of all engines already loaded. + /// \return Names of all loaded engines. + public: std::vector LoadedEngines() const; + + /// \brief Get the render-engine with the given name. If the no + /// render-engine is registered under the given name, NULL will be + /// returned. + /// \param[in] _name Name of the desired render-engine + /// \param[in] _params Parameters to be passed to the render engine. + /// \param[in] _path Another search path for rendering engine plugin. + /// \return The specified render-engine + public: RenderEngine *Engine(const std::string &_name, + const std::map &_params = {}, + const std::string &_path = ""); + + /// \brief Get the render-engine at the given index. If no + /// render-engine is exists at the given index, NULL will be returned. + /// \param[in] _index Index of the desired render-engine + /// \param[in] _params Parameters to be passed to the render engine. + /// \param[in] _path Another search path for rendering engine plugin. + /// \return The specified render-engine + public: RenderEngine *EngineAt(unsigned int _index, + const std::map &_params = {}, + const std::string &_path = ""); + + /// \brief Unload the render-engine with the given name. If the no + /// render-engine is registered under the given name, false will be + /// returned. + /// \param[in] _name Name of the desired render-engine + /// \return True if the engine is unloaded + public: bool UnloadEngine(const std::string &_name); + + /// \brief Unload the render-engine at the given index. If the no + /// render-engine is registered under the given name, false will be + /// returned. + /// \param[in] _index Index of the desired render-engine + /// \return True if the engine is unloaded + public: bool UnloadEngineAt(unsigned int _index); + + /// \brief Register a new render-engine under the given name. If the + /// given name is already in use, the render-engine will not be + /// registered. + /// \param[in] _name Name the render-engine will be registered under + /// \param[in] _engine Render-engine to be registered + public: void RegisterEngine(const std::string &_name, + RenderEngine *_engine); + + /// \brief Unregister a render-engine registered under the given name. + /// If no render-engine is registered under the given name no work + /// will be done. + /// \param[in] _name Name of the render-engine to unregister + public: void UnregisterEngine(const std::string &_name); + + /// \brief Unregister the given render-engine. If the given render-engine + /// is not currently registered, no work will be done. + /// \param[in] _engine Render-engine to unregister + public: void UnregisterEngine(RenderEngine *_engine); + + /// \brief Unregister a render-engine at the given index. If the no + /// render-engine is registered at the given index, no work will be done. + /// \param[in] _index Index of the render-engine to unregister + public: void UnregisterEngineAt(unsigned int _index); + + /// \brief Set the plugin paths from which render engines can be loaded. + /// \param[in] _paths The list of the plugin paths + public: void SetPluginPaths(const std::list &_paths); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief private implementation details + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief required SingletonT friendship + private: friend class gz::common::SingletonT; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderEnginePlugin.hh b/include/gz/rendering/RenderEnginePlugin.hh new file mode 100644 index 000000000..7afe29ed4 --- /dev/null +++ b/include/gz/rendering/RenderEnginePlugin.hh @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GZ_RENDERING_RENDERENGINEPLUGIN_HH_ +#define GZ_RENDERING_RENDERENGINEPLUGIN_HH_ + +#include +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declarations + class RenderEngine; + class RenderEnginePluginPrivate; + + /// \brief Base plugin class for render engines + class IGNITION_RENDERING_VISIBLE RenderEnginePlugin + { + /// \brief Constructor + public: RenderEnginePlugin(); + + /// \brief Destructor + public: virtual ~RenderEnginePlugin(); + + /// \brief Get the name of render engine + /// \return Name of render engine + public: virtual std::string Name() const = 0; + + /// \brief Get a pointer to the render engine + /// \return Render engine instance + public: virtual RenderEngine *Engine() const = 0; + + /// \brief Pointer to private data class + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderPass.hh b/include/gz/rendering/RenderPass.hh new file mode 100644 index 000000000..e012285b0 --- /dev/null +++ b/include/gz/rendering/RenderPass.hh @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERPASS_HH_ +#define GZ_RENDERING_RENDERPASS_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/Object.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class RenderPass RenderPass.hh ignition/rendering/RenderPass.hh + /// \brief A render pass can be added to a camera to affect how the scene + /// is rendered. It can be used to add post-processing effects. Multiple + /// passes can be chained together. + class IGNITION_RENDERING_VISIBLE RenderPass + : public virtual Object + { + /// \brief Destructor + public: virtual ~RenderPass() { } + + /// \brief Set to enable or disable the render pass + /// \param[in] _enabled True to enable the render pass, false to disable. + public: virtual void SetEnabled(bool _enabled) = 0; + + /// \brief Get whether or not the render pass is enabled + /// \return True if the render pass is enabled, false otherwise. + public: virtual bool IsEnabled() const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderPassSystem.hh b/include/gz/rendering/RenderPassSystem.hh new file mode 100644 index 000000000..271d76f2e --- /dev/null +++ b/include/gz/rendering/RenderPassSystem.hh @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERPASSSYSTEM_HH_ +#define GZ_RENDERING_RENDERPASSSYSTEM_HH_ + +#include +#include +#include +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" +#include "gz/rendering/RenderPass.hh" +#include "gz/rendering/RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class RenderPassSystemPrivate; + + /* \class RenderPassFactory RenderPassSystem.hh \ + * ignition/rendering/RenderPassSystem.hh + */ + /// \brief A factory interface for creating render passes + class IGNITION_RENDERING_VISIBLE RenderPassFactory + { + /// \brief Instantiate new render pass + /// \return New render pass + public: virtual RenderPass *New() const = 0; + }; + + /* \class RenderPassSystem RenderPassSystem.hh \ + * ignition/rendering/RenderPassSystem.hh + */ + /// \brief A class for creating and managing render passes + class IGNITION_RENDERING_VISIBLE RenderPassSystem + { + /// \brief Constructor + public: RenderPassSystem(); + + /// \brief Destructor + public: virtual ~RenderPassSystem(); + + /// \brief Templated function for creating render passes + /// \return Pointer to the render pass created + public: template RenderPassPtr Create() + { + return this->CreateImpl(typeid(T).name()); + } + + /// \brief Register a render pass factory to the system + /// \param[in] _type Render pass type, i.e. type id of render pass class + /// \param[in] _factory Factory used to create the render pass + public: static void Register(const std::string &_type, + RenderPassFactory *_factory); + + /// \brief Implementation for creating render passes + /// \param[in] _type Render pass type, i.e. type id of render pass class + /// \return Pointer to the render pass created + private: RenderPassPtr CreateImpl(const std::string &_type); + + /// \brief A map of render pass type id name to its factory class + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: static std::map renderPassMap; + + /// \internal + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + + /// \brief Render pass registration macro + /// + /// Use this macro to register render pass with the render pass factory. + #define IGN_RENDERING_REGISTER_RENDER_PASS(classname, interface) \ + class classname##Factory : public gz::rendering::RenderPassFactory \ + { \ + public: classname##Factory() \ + { \ + gz::rendering::RenderPassSystem::Register( \ + typeid(interface).name(), this); \ + } \ + public: RenderPass *New() const override \ + { \ + return new classname(); \ + } \ + }; \ + static classname##Factory global_##classname##Factory; + } + } +} +#endif diff --git a/include/gz/rendering/RenderTarget.hh b/include/gz/rendering/RenderTarget.hh new file mode 100644 index 000000000..1a30a7786 --- /dev/null +++ b/include/gz/rendering/RenderTarget.hh @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License") = 0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERTARGET_HH_ +#define GZ_RENDERING_RENDERTARGET_HH_ + +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class RenderTarget RenderTarget.hh ignition/rendering/RenderTarget.hh + /// \brief Represents a render-target to which cameras can render images. + class IGNITION_RENDERING_VISIBLE RenderTarget : + public virtual Object + { + /// \brief Destructor + public: virtual ~RenderTarget() { } + + /// \brief Get render target width in pixels + /// \return The render target width in pixels + public: virtual unsigned int Width() const = 0; + + /// \brief Get render target height in pixels + /// \return The Render target height in pixels + public: virtual unsigned int Height() const = 0; + + /// \brief Set the render target width in pixels + /// \param[in] _width New render target width in pixels + public: virtual void SetWidth(const unsigned int _width) = 0; + + /// \brief Set the render target height in pixels + /// \param[in] _height New render target height in pixels + public: virtual void SetHeight(const unsigned int _height) = 0; + + /// \brief Set the render target image format + /// \return Render target format + public: virtual PixelFormat Format() const = 0; + + /// \brief Set the render target image format + /// \param[in] _format New target format + public: virtual void SetFormat(PixelFormat _format) = 0; + + /// \brief Write rendered image to given Image. The RenderTarget will + /// convert the underlying image to the specified format listed in the + /// given Image. However if the given image is not of the correct size no + /// work will be done. Calling this function before an image has been + /// rendered will result in undefined behavior. + /// \param[out] _image Image to which output will be written + public: virtual void Copy(Image &_image) const = 0; + + /// \brief Get the background color of the render target. + /// This should be the same as the scene background color. + /// \return Render target background color. + public: virtual math::Color BackgroundColor() const = 0; + + /// \brief Add a render pass to the render target + /// \param[in] _pass New render pass to add + public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0; + + /// \brief Remove a render pass from the render target + /// \param[in] _pass render pass to remove + public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) = 0; + + /// \brief Get the number of render passes applied to the render target + /// \return Number of render passes applied + public: virtual unsigned int RenderPassCount() const = 0; + + /// \brief Get a render pass by index + /// \return Render pass at the specified index + public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) + const = 0; + }; + + /* \class RenderTexture RenderTexture.hh \ + * ignition/rendering/RenderTexture.hh + */ + /// \brief Represents a off-screen render-texture to which cameras can + /// render images. + class IGNITION_RENDERING_VISIBLE RenderTexture : + public virtual RenderTarget + { + /// \brief Deconstructor + public: virtual ~RenderTexture() { } + + /// \brief Returns the OpenGL texture Id. A valid Id is returned only + // if this is an OpenGL render texture + public: virtual unsigned int GLId() const = 0; + }; + + /* \class RenderWindow RenderWindow.hh \ + * ignition/rendering/RenderWindow.hh + */ + /// \brief Represents a on-screen render-window to which cameras can + /// render images. + class IGNITION_RENDERING_VISIBLE RenderWindow : + public virtual RenderTarget + { + /// \brief Deconstructor + public: virtual ~RenderWindow() { } + + /// \brief Get the window handle that the render window is attached to. + /// \return Window handle + public: virtual std::string Handle() const = 0; + + /// \brief Set the window handle to attach the render window to + /// \param[in] _handle Window handle + public: virtual void SetHandle(const std::string &_handle) = 0; + + /// \brief Get the device to pixel ratio + /// \return Device to pixel ratio + public: virtual double DevicePixelRatio() const = 0; + + /// \brief Set the device to pixel ratio + /// \param[in] _ratio Device to pixel ratio + public: virtual void SetDevicePixelRatio(const double _ratio) = 0; + + /// \brief Alert the window of a window resize event + /// \param[in] _width New window width in pixels + /// \param[in] _height New window height in pixels + public: virtual void OnResize(unsigned int _width, + unsigned int _height) = 0; + + /// \brief Alert the window of a window move event + public: virtual void OnMove() = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/RenderTypes.hh b/include/gz/rendering/RenderTypes.hh new file mode 100644 index 000000000..dab356b62 --- /dev/null +++ b/include/gz/rendering/RenderTypes.hh @@ -0,0 +1,348 @@ +/* + * 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 Camera; + class DepthCamera; + class DirectionalLight; + class GaussianNoisePass; + class Geometry; + class GizmoVisual; + class GpuRays; + class Grid; + class JointVisual; + class Image; + class Light; + class Material; + class Marker; + class Mesh; + class Node; + class Object; + class ObjectFactory; + class PointLight; + class RayQuery; + class RenderEngine; + class RenderPass; + class RenderPassSystem; + class RenderTarget; + class RenderTexture; + class RenderWindow; + class Scene; + class Sensor; + class ShaderParams; + class SpotLight; + class SubMesh; + class Text; + class ThermalCamera; + class Visual; + + /// \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 GpuRaysPtr + /// \brief Shared pointer to GpuRays + typedef shared_ptr GpuRaysPtr; + + /// \typedef DirectionalLightPtr + /// \brief Shared pointer to DirectionalLight + typedef shared_ptr DirectionalLightPtr; + + /// \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 GridPtr + /// \brief Shared pointer to Grid + typedef shared_ptr GridPtr; + + /// \typedef JointVisualPtr + /// \brief Shared pointer to JointVisual + typedef shared_ptr JointVisualPtr; + + /// \typedef ImagePtr + /// \brief Shared pointer to Image + typedef shared_ptr ImagePtr; + + /// \typedef LightPtr + /// \brief Shared pointer to Light + typedef shared_ptr LightPtr; + + /// \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 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 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 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 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 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 PointLightPtr + /// \brief Shared pointer to const PointLight + typedef shared_ptr ConstPointLightPtr; + + /// \typedef RayQueryPtr + /// \brief Shared pointer to RayQuery + typedef shared_ptr ConstRayQueryPtr; + + /// \typedef const RenderPassPtr + /// \brief Shared pointer to const RenderPass + typedef shared_ptr ConstRenderPassPtr; + + /// \typedef const RenderPassSystemPtr + /// \brief Shared pointer to const RenderPassSystem + typedef shared_ptr ConstRenderPassSystemPtr; + + /// \typedef const RenderTargetPtr + /// \brief Shared pointer to const RenderTarget + typedef shared_ptr ConstRenderTargetPtr; + + /// \typedef const RenderTexturePtr + /// \brief Shared pointer to const RenderTexture + typedef shared_ptr ConstRenderTexturePtr; + + /// \typedef const RenderWindowPtr + /// \brief Shared pointer to const RenderWindow + typedef shared_ptr ConstRenderWindowPtr; + + /// \typedef const ScenePtr + /// \brief Shared pointer to const Scene + typedef shared_ptr ConstScenePtr; + + /// \typedef const SensorPtr + /// \brief Shared pointer to const Sensor + typedef shared_ptr ConstSensorPtr; + + /// \brief Shared pointer to const ShaderParams + typedef shared_ptr ConstShaderParamsPtr; + + /// \typedef const SpotLightPtr + /// \brief Shared pointer to const SpotLight + typedef shared_ptr ConstSpotLightPtr; + + /// \typedef const SubMeshPtr + /// \brief Shared pointer to const SubMesh + typedef shared_ptr ConstSubMeshPtr; + + /// \typedef const SubMeshPtr + /// \brief Shared pointer to const SubMesh + typedef shared_ptr ConstTextPtr; + + /// \typedef const VisualPtr + /// \brief Shared pointer to const Visual + typedef shared_ptr ConstVisualPtr; + } + } +} +#endif diff --git a/include/gz/rendering/RenderingIface.hh b/include/gz/rendering/RenderingIface.hh new file mode 100644 index 000000000..13825ee77 --- /dev/null +++ b/include/gz/rendering/RenderingIface.hh @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_RENDERINGIFACE_HH_ +#define GZ_RENDERING_RENDERINGIFACE_HH_ + +#include +#include +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" +#include "gz/rendering/RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class RenderEngine; + + /// \brief Load shared render-engine resources + /// \return True if successful + IGNITION_RENDERING_VISIBLE + bool load(); + + /// \brief Initialized shared render-engine features + /// \return True if successful + IGNITION_RENDERING_VISIBLE + bool init(); + + /// \brief Destroy all render-engines and related resources + /// \return True if successful + IGNITION_RENDERING_VISIBLE + bool fini(); + + /// \brief Get the number of available render-engines. + /// \return The number of available render-engines + IGNITION_RENDERING_VISIBLE + unsigned int engineCount(); + + /// \brief Determine if a render-engine is registered under the given name + /// \param[in] _name Name of the desired render-engine + /// \return True if a render-engine is registered under the given name + IGNITION_RENDERING_VISIBLE + bool hasEngine(const std::string &_name); + + /// \brief Determine if a render-engine is already loaded. + /// \param[in] _name Name of the desired render-engine + /// \return True if a render-engine is loaded under the given name + IGNITION_RENDERING_VISIBLE + bool isEngineLoaded(const std::string &_name); + + /// \brief Get the names of all engines currently loaded. + /// \return All the engines currently loaded. + IGNITION_RENDERING_VISIBLE + std::vector loadedEngines(); + + /// \brief Get the render-engine registered under the given name. If no + /// render-engine is registered under the given name, NULL will be + /// returned. + /// If the engine is registered, but not loaded, this function will load it. + /// \param[in] _name Name of the desired render-engine + /// \param[in] _params Parameters to be passed to the render engine. + /// \param[in] _path Another search path for rendering engine plugin. + /// \return The specified render-engine + IGNITION_RENDERING_VISIBLE + RenderEngine *engine(const std::string &_name, + const std::map &_params = {}, + const std::string &_path = ""); + + /// \brief Get the render-engine registered at the given index. If no + /// render-engine is registered at the given index, NULL will be returned. + /// If the engine is registered, but not loaded, this function will load it. + /// \param[in] _index Index of the desired render-engine + /// \param[in] _params Parameters to be passed to the render engine. + /// \param[in] _path Another search path for rendering engine plugin. + /// \return The specified render-engine + IGNITION_RENDERING_VISIBLE + RenderEngine *engine(const unsigned int _index, + const std::map &_params = {}, + const std::string &_path = ""); + + /// \brief Unload the render-engine registered under the given name. + /// \param[in] _name Name of the desired render-engine + /// \return True if the engine is unloaded + IGNITION_RENDERING_VISIBLE + bool unloadEngine(const std::string &_name); + + /// \brief Register a new render-engine under the given name. If the given + /// name is already in use, the render-engine will not be registered. + /// \param[in] _name Name the render-engine will be registered under + /// \param[in] _engine Render-engine to be registered + IGNITION_RENDERING_VISIBLE + void registerEngine(const std::string &_name, RenderEngine *_engine); + + /// \brief Unregister a render-engine registered under the given name. + /// If the no render-engine is registered under the given name no work + /// will be done. + /// \param[in] _name Name of the render-engine to unregister + IGNITION_RENDERING_VISIBLE + void unregisterEngine(const std::string &_name); + + /// \brief Unregister the given render-engine. If the given render-engine + /// is not currently registered, no work will be done. + /// \param[in] _engine Render-engine to unregister + IGNITION_RENDERING_VISIBLE + void unregisterEngine(RenderEngine *_engine); + + /// \brief Unregister a render-engine at the given index. If the no + /// render-engine is registered at the given index, no work will be done. + /// \param[in] _index Index of the render-engine to unregister + IGNITION_RENDERING_VISIBLE + void unregisterEngine(const unsigned int _index); + + /// \brief Set the plugin paths from which render engines can be loaded. + /// \param[in] _paths The list of the plugin paths + IGNITION_RENDERING_VISIBLE + void setPluginPaths(const std::list &_paths); + + /// \brief Most applications will only have one rendering engine loaded + /// at a time, and only one scene within that. This helper function gets + /// the first scene that can be found in the first loaded rendering engine. + /// + /// It's not recommended to call this function when there's more than one + /// engine or scene. + /// + /// \return Pointer to a scene that was found, null if no scene is loaded. + IGNITION_RENDERING_VISIBLE + ScenePtr sceneFromFirstRenderEngine(); + } + } +} +#endif diff --git a/include/gz/rendering/Scene.hh b/include/gz/rendering/Scene.hh new file mode 100644 index 000000000..11759e2f4 --- /dev/null +++ b/include/gz/rendering/Scene.hh @@ -0,0 +1,902 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_SCENE_HH_ +#define GZ_RENDERING_SCENE_HH_ + +#include +#include +#include + +#include +#include +#include + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/MeshDescriptor.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/Storage.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class RenderEngine; + + /// \class Scene Scene.hh ignition/rendering/Scene.hh + /// \brief Manages a single scene-graph. This class updates scene-wide + /// properties and holds the root scene node. A Scene also serves as a + /// factory for all scene objects. + class IGNITION_RENDERING_VISIBLE Scene + { + /// \brief Deconstructor + public: virtual ~Scene() { } + + /// \brief Load scene-specific resources + public: virtual void Load() = 0; + + /// \brief Initialize the scene + public: virtual void Init() = 0; + + // TODO(anyone): merge with Destroy + public: virtual void Fini() = 0; + + /// \brief Determine if the scene is initialized + /// \return True if the scene is initialized + public: virtual bool IsInitialized() const = 0; + + /// \brief Get the ID of the scene + /// \return The scene ID + public: virtual unsigned int Id() const = 0; + + /// \brief Get the name of the scene + /// \return The scene name + public: virtual std::string Name() const = 0; + + /// \brief Get the creating render-engine of the scene + /// \return The creating render-engine + public: virtual RenderEngine *Engine() const = 0; + + /// \brief Get the last simulation update time + /// \return The last simulation update time + public: virtual common::Time SimTime() const = 0; + + /// \brief Set the last simulation update time + /// \param[in] _time Latest simulation update time + public: virtual void SetSimTime(const common::Time &_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 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 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 box geometry + /// \return The created box + public: virtual GeometryPtr CreateBox() = 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 geometry + /// \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 marker geometry. + /// \return The created marker + public: virtual MarkerPtr CreateMarker() = 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 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 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/Sensor.hh b/include/gz/rendering/Sensor.hh new file mode 100644 index 000000000..e997e02c5 --- /dev/null +++ b/include/gz/rendering/Sensor.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_SENSOR_HH_ +#define GZ_RENDERING_SENSOR_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/Node.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Sensor Sensor.hh ignition/rendering/Sensor.hh + /// \brief Represents a scene sensor. The most obvious example is a camera, + /// but it can be anything that generates output from the scene. + class IGNITION_RENDERING_VISIBLE Sensor : + public virtual Node + { + /// \brief Sensor + public: virtual ~Sensor() { } + }; + } + } +} +#endif diff --git a/include/gz/rendering/ShaderParam.hh b/include/gz/rendering/ShaderParam.hh new file mode 100644 index 000000000..a146bb0b4 --- /dev/null +++ b/include/gz/rendering/ShaderParam.hh @@ -0,0 +1,99 @@ +/* + * 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 "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 param + PARAM_FLOAT = 1, + + /// \brief Integer type param + PARAM_INT = 2, + }; + + /// \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 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 param + /// \param[in] _value Value to set this param to. + public: void operator=(const float _value); + + /// \brief Set this to be an integer param; + /// \param[in] _value Value to set this param to. + public: void operator=(const int _value); + + /// \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 param 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 param is the expected type + public: bool Value(int *_value) const; + + /// \brief private implementation + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} + +#endif diff --git a/include/gz/rendering/ShaderParams.hh b/include/gz/rendering/ShaderParams.hh new file mode 100644 index 000000000..b575d081f --- /dev/null +++ b/include/gz/rendering/ShaderParams.hh @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GZ_RENDERING_SHADERPARAMS_HH_ +#define GZ_RENDERING_SHADERPARAMS_HH_ + +#include +#include +#include + +#include "gz/rendering/Export.hh" +#include "gz/rendering/ShaderParam.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief forward declaration + class ShaderParamsPrivate; + + /// \brief a map that holds params to be passed to a shader + class IGNITION_RENDERING_VISIBLE ShaderParams + { + /// \brief forward declaration + class IteratorPrivate; + + /// \brief Iterator for looping through params + /// \remarks implements a forward-iterator + class IGNITION_RENDERING_VISIBLE Iterator + { + /// \brief Default constructor + public: Iterator(); + + /// \brief Special constructor used by ShaderParams implementation + /// \param[in] _dataPtr Pointer to private data. + public: explicit Iterator(std::unique_ptr _dataPtr); + + /// \brief Copy constructor + /// \param[in] _iter Another iterator + public: Iterator(const Iterator &_iter); + + /// \brief Copy assignment + /// \param[in] _iter Another iterator + /// \return this + Iterator& operator=(const Iterator &_iter); + + /// \brief Destructor + public: ~Iterator(); + + /// \brief Equality operator + /// \param[in] _iter Another iterator + /// \return True if input interator equal to this one, false otherwise. + public: bool operator==(const Iterator &_iter); + + /// \brief Inequality operator + /// \param[in] _iter Another iterator + /// \return True if input interator is equal to this one, + /// false otherwise + public: bool operator!=(const Iterator &_iter); + + /// \brief Dereference operator + public: const std::pair &operator*(); + + /// \brief Arrow dereference operator + public: const std::pair *operator->(); + + /// \brief prefix increment + public: Iterator &operator++(); + + /// \brief postfix increment + public: Iterator operator++(int); + + private: std::unique_ptr dataPtr; + }; + + /// \brief constructor + public: ShaderParams(); + + /// \brief destructor + public: ~ShaderParams(); + + /// \brief Access a param with a given name + /// \param[in] _name Identifier for the parameter + /// \returns parameter reference + public: ShaderParam &operator[](const std::string &_name); + + /// \brief Access a param with a given name + /// \param[in] _name Identifier for the parameter + /// \returns const parameter reference + public: const ShaderParam &operator[](const std::string &_name) const; + + /// \brief Iterator to first parameter + /// \remarks Necessary for range-base for loop support + /// \return Iterator pointing to first parameter. + public: Iterator begin() const; + + /// \brief Iterator to one past last param + /// \remarks Necessary for range-base for loop support + /// \return Iterator pointing to one past last parameter. + public: Iterator end() const; + + /// \brief Have the params changed? + /// \internal + /// \returns true if the parameters have changed + public: bool IsDirty() const; + + /// \brief Resets the dirty flag + /// \internal + public: void ClearDirty(); + + /// \brief private implementation + private: std::unique_ptr dataPtr; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/ShaderType.hh b/include/gz/rendering/ShaderType.hh new file mode 100644 index 000000000..f4d87ccc4 --- /dev/null +++ b/include/gz/rendering/ShaderType.hh @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_SHADERTYPE_HH_ +#define GZ_RENDERING_SHADERTYPE_HH_ + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \enum ShaderType ShaderType.hh ignition/rendering/ShaderType.hh + /// \brief Available types of shaders. Note that not all rendering-engines + /// will be able to use each type. They will instead default to the closest + /// alternative. + enum IGNITION_RENDERING_VISIBLE ShaderType + { + /// \brief Unknown or errant type + ST_UNKNOWN = 0, + + /// \brief Per pixel lighting shader + ST_PIXEL = 1, + + /// \brief Per vertex lighting shader + ST_VERTEX = 2, + + /// \brief Object-space normal map shader + ST_NORM_OBJ = 3, + + /// \brief Tangent-space normal map shader + ST_NORM_TAN = 4, + + /// \brief Total number of shader types + ST_COUNT = 5, + }; + + /// \class ShaderUtil ShaderType.hh ignition/rendering/ShaderType.hh + /// \brief Provides supporting functions for ShaderType enum + class IGNITION_RENDERING_VISIBLE ShaderUtil + { + /// \brief Determine if given type is valid ShaderType enum + /// \param[in] _type Enum value to be evaluated + /// \return True if the given type is valid + public: static bool IsValid(ShaderType _type); + + /// \brief Sanitize given type. If the given value is invalid, + /// ST_UNKNOWN will be returned, otherwise input will be returned + /// unchanged. + /// \param[in] _type Shader type to be sanitized + /// \return The santized shader type + public: static ShaderType Sanitize(ShaderType _type); + + /// \brief Get human-readable name for shader type value. + /// \param[in] _type Shader type enum value + /// \return The type name + public: static std::string Name(ShaderType _type); + + /// \brief Get enum value by human-readable name. The given string should + /// match watch is returned by GetName. If an invalid name is given, + /// ST_UNKNOWN will be returned. + /// \param[in] _name Name of the shader type to be retrieved + /// \return The specified ShaderType enum value + public: static ShaderType Enum(const std::string &_name); + + /// \brief Array of human-readable names for each ShaderType + private: static const char *names[ST_COUNT]; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Storage.hh b/include/gz/rendering/Storage.hh new file mode 100644 index 000000000..8a94e1f3f --- /dev/null +++ b/include/gz/rendering/Storage.hh @@ -0,0 +1,386 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_STORAGE_HH_ +#define GZ_RENDERING_STORAGE_HH_ + +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Node.hh" +#include "gz/rendering/Light.hh" +#include "gz/rendering/Sensor.hh" +#include "gz/rendering/Visual.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/Material.hh" +#include "gz/rendering/Mesh.hh" +#include "gz/rendering/Export.hh" + +// An X11 header file defines a macro that conflicts with our function name, +// so undefine it here +#ifdef DestroyAll +#undef DestroyAll +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class Map Storage.hh ignition/rendering/Storage.hh + /// \brief Storage map from std::string to template class T + /// \tparam T The storage element type + template + class IGNITION_RENDERING_VISIBLE Map + { + /// \typedef TPtr + /// \brief Shared pointer to T + typedef std::shared_ptr TPtr; + + /// \typedef const TPtr + /// \brief Shared pointer to const T + typedef std::shared_ptr ConstTPtr; + + /// \brief Deconstructor + public: virtual ~Map() { } + + /// \brief Get the number of elements in this map + /// \return The number of elements in this map + public: virtual unsigned int Size() const = 0; + + /// \brief Determine if an elements is mapped to the given key + /// \param[in] _key Key of the element in question + /// \return True if an elements is mapped to the given key + public: virtual bool ContainsKey(const std::string &_key) const = 0; + + /// \brief Determine if the given element exists in this map + /// \param[in] _value Element in question + /// \return True if the given element exists in this map + public: virtual bool ContainsValue(ConstTPtr _value) const = 0; + + /// \brief Get the element mapped to the given key + /// \param[in] _key Key of the element in question + /// \return The element mapped to the given key + public: virtual TPtr Get(const std::string &_key) const = 0; + + /// \brief Get the element at the given index + /// \param[in] _index Index of the element in question + /// \return The element at the given index + public: virtual TPtr GetByIndex(unsigned int _index) const = 0; + + /// \brief Map to given element to the given key. If the given key is + /// already in use, no work will be done. + /// \param[in] _key Key of the new element + /// \param[in] _value Element to be mapped + /// \return True if successful + public: virtual bool Put(const std::string &_key, TPtr _value) = 0; + + /// \brief Remove the element mapped to the given key. If the specified + /// element does not exists, no work will be done. + /// \param[in] _key Key of the element in question + public: virtual void Remove(const std::string &_key) = 0; + + /// \brief Remove the given element. If the given element does not exist + /// no work will be done. + /// \param[in] _value Key of the element in question + public: virtual void Remove(TPtr _value) = 0; + + /// \brief Remove all elements from this map + public: virtual void RemoveAll() = 0; + }; + + /// \class Store Storage.hh ignition/rendering/Storage.hh + /// \brief Multi-access storage structure of template class T. Template + /// class T is expected to have functions GetId, GetName(), Destroy() which + /// return unsigned int, std::string, and void respectively. This store + /// will ensure that each element's name and ID are unique. + /// \tparam T The storage element type + template + class IGNITION_RENDERING_VISIBLE Store + { + /// \typedef TPtr + /// \brief Shared pointer to T + typedef std::shared_ptr TPtr; + + /// \typedef const TPtr + /// \brief Shared pointer to const T + typedef std::shared_ptr ConstTPtr; + + /// \brief Deconstructor + public: virtual ~Store() { } + + /// \brief Get number of elements in this store + /// \return The number of elements in this store + public: virtual unsigned int Size() const = 0; + + /// \brief Determine if store contains the given element + /// \param[in] _object The element in question + /// \return True if this store contains the given element + public: virtual bool Contains(ConstTPtr _object) const = 0; + + /// \brief Determine if store contains the element with the given ID + /// \param[in] _id ID of the element in question + /// \return True if this store contains the specified element + public: virtual bool ContainsId(unsigned int _id) const = 0; + + /// \brief Determine if store contains the element with the given name + /// \param[in] _name Name of the element in question + /// \return True if this store contains the specified element + public: virtual bool ContainsName(const std::string &_name) const = 0; + + /// \brief Get element with the given ID + /// \param[in] _id ID of the desired element + /// \return The specified element + public: virtual TPtr GetById(unsigned int _id) const = 0; + + /// \brief Get element with the given name + /// \param[in] _name Name of the desired element + /// \return The specified element + public: virtual TPtr GetByName(const std::string &_name) const = 0; + + /// \brief Get element at the given index + /// \param[in] _index Index of the desired element + /// \return The specified element + public: virtual TPtr GetByIndex(unsigned int _index) const = 0; + + /// \brief Add given element. If the element has already been added + /// or its name or ID conflict with other existing elements, then no + /// work will be done. + /// \param[in] _object Element to be added + /// \return True if successful + public: virtual bool Add(TPtr _object) = 0; + + /// \brief Remove given element. If the given element does not exists + /// in this store, then no work will be done. + /// \param[in] _object Element to be removed + /// \return The removed element + public: virtual TPtr Remove(TPtr _object) = 0; + + /// \brief Remove element with the given ID. If the specified element + /// does not exists in this store, then no work will be done. + /// \param[in] _id ID of the element to be removed + /// \return The removed element + public: virtual TPtr RemoveById(unsigned int _id) = 0; + + /// \brief Remove element with the given name. If the specified element + /// does not exists in this store, then no work will be done. + /// \param[in] _name Name of the element to be removed + /// \return The removed element + public: virtual TPtr RemoveByName(const std::string &_name) = 0; + + /// \brief Remove element at the given index. If the specified element + /// does not exists in this store, then no work will be done. + /// \param[in] _index Index of the element to be removed + /// \return The removed element + public: virtual TPtr RemoveByIndex(unsigned int _index) = 0; + + /// \brief Remove all elements from store + public: virtual void RemoveAll() = 0; + + /// \brief Remove and destroy given element. If the given element does + /// not exists, in this store, then no work will be done. + /// \param[in] _object Element to be removed + public: virtual void Destroy(TPtr _object) = 0; + + /// \brief Remove and destroy element with the given ID. If the specified + /// element does not exists in this store, then no work will be done. + /// \param[in] _id ID of the element to be removed + public: virtual void DestroyById(unsigned int _id) = 0; + + /// \brief Remove and destroy element with the given name. If the + /// specified element does not exists in this store, then no work + /// will be done. + /// \param[in] _name Name of the element to be removed + public: virtual void DestroyByName(const std::string &_name) = 0; + + /// \brief Remove and destroy element at the given index. If the + /// specified element does not exists in this store, then no work + /// will be done. + /// \param[in] _index Index of the element to be removed + public: virtual void DestroyByIndex(unsigned int _index) = 0; + + /// \brief Remove and destroy all elements in store + public: virtual void DestroyAll() = 0; + }; + + /// \class CompositeStore Storage.hh ignition/rendering/Storage.hh + /// ignition/rendering/CompositeStore.hh + /// \brief Represents a collection of Store objects, collectively working as + /// a single composite store. + /// \tparam T The storage element type + template + class IGNITION_RENDERING_VISIBLE CompositeStore : + public Store + { + /// \typedef TPtr + /// \brief Shared pointer to T + typedef std::shared_ptr TPtr; + + /// \typedef TPtr + /// \brief Store of T + typedef Store TStore; + + /// \typedef TStorePtr + /// \brief Shared pointer to TStore + typedef std::shared_ptr TStorePtr; + + /// \typedef const TStorePtr + /// \brief Shared pointer to const TStore + typedef std::shared_ptr ConstTStorePtr; + + /// \brief Deconstructor + public: virtual ~CompositeStore() { } + + /// \brief Get number of Stores + /// \return The number of Stores + public: virtual unsigned int GetStoreCount() const = 0; + + /// \brief Determine if given store exists + /// \param[in] _store Store in question + /// \return True if given store exists + public: virtual bool ContainsStore(ConstTStorePtr _store) const = 0; + + /// \brief Add the given store. If the given store already exists, then + /// no work will be done. + /// \param[in] _store Store to be added + /// \return True if successful + public: virtual bool AddStore(TStorePtr _store) = 0; + + /// \brief Get store at the given index. If no such store exists NULL + /// will be returned. + /// \param[in] _index Index of the desired store + /// \return The specified store + public: virtual TStorePtr GetStore(unsigned int _index) const = 0; + + /// \brief Remove given store. If no such store exists no + /// work will be done and NULL will be returned. + /// \param[in] _store Store to be removed + /// \return The removed store + public: virtual TStorePtr RemoveStore(TStorePtr _store) = 0; + + /// \brief Remove store at the given index. If no such store exists no + /// work will be done and NULL will be returned. + /// \param[in] _index Index of the store to be removed + /// \return The removed store + public: virtual TStorePtr RemoveStore(unsigned int _index) = 0; + }; + + /// \class StoreWrapper Storage.hh ignition/rendering/StoreWrapper.hh + /// \brief Simple wrapper class that allows a Store of type Derived to be + /// treated as a Store of type Base, where Derived is some class derived + /// from Base. This is useful in storing Stores of different derived types + /// in a single CompositeStore instance. + /// \tparam T New storage type + /// \tparam U Some derived class of T + template + class IGNITION_RENDERING_VISIBLE StoreWrapper : + public Store + { + public: virtual ~StoreWrapper() { } + }; + +// armhf failed to build with this code. It can not be removed for the rest +// of arches to keep ABI but should be removed in major versions unreleased +// see https://github.com/ignitionrobotics/ign-rendering/pull/457 +#ifndef __ARM_PCS_VFP + template class Store; + template class Store; + template class Store; + template class Store; + template class Store; + template class Store; + template class Store; + template class Map; + template class CompositeStore; +#endif + + /// \def SceneStore + /// \brief Store of Scene + typedef Store SceneStore; + + /// \def NodeStore + /// \brief Store of Node + typedef Store NodeStore; + + /// \def LightStore + /// \brief Store of Light + typedef Store LightStore; + + /// \def SensorStore + /// \brief Store of Sensor + typedef Store SensorStore; + + /// \def VisualStore + /// \brief Store of Visual + typedef Store VisualStore; + + /// \def GeometryStore + /// \brief Store of Geometry + typedef Store GeometryStore; + + /// \def SubMeshStore + /// \brief Store of SubMesh + typedef Store SubMeshStore; + + /// \def MaterialMap + /// \brief Material Map + typedef Map MaterialMap; + + /// \def NodeCompositeStore + /// \brief Node Composite Store + typedef CompositeStore NodeCompositeStore; + + /// \def SceneStorePtr + /// \brief Shared pointer to SceneStore + typedef std::shared_ptr SceneStorePtr; + + /// \def NodeStorePtr + /// \brief Shared pointer to NodeStore + typedef std::shared_ptr NodeStorePtr; + + /// \def LightStorePtr + /// \brief Shared pointer to LightStore + typedef std::shared_ptr LightStorePtr; + + /// \def SensorStorePtr + /// \brief Shared pointer to SensorStore + typedef std::shared_ptr SensorStorePtr; + + /// \def VisualStorePtr + /// \brief Shared pointer to VisualStore + typedef std::shared_ptr VisualStorePtr; + + /// \def GeometryStorePtr + /// \brief Shared pointer to GeometryStore + typedef std::shared_ptr GeometryStorePtr; + + /// \def SubMeshStorePtr + /// \brief Shared pointer to SubMeshStore + typedef std::shared_ptr SubMeshStorePtr; + + /// \def MaterialMapPtr + /// \brief Shared pointer to MaterialMap + typedef std::shared_ptr MaterialMapPtr; + + /// \def NodeCompositeStorePtr + /// \brief Shared pointer to NodeCompositeStore + typedef std::shared_ptr NodeCompositeStorePtr; + } + } +} +#endif diff --git a/include/gz/rendering/Text.hh b/include/gz/rendering/Text.hh new file mode 100644 index 000000000..96e8bc228 --- /dev/null +++ b/include/gz/rendering/Text.hh @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_TEXT_HH_ +#define GZ_RENDERING_TEXT_HH_ + +#include + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \enum TextHorizontalAlign + /// \brief Text Horizontal alignment + enum class TextHorizontalAlign + { + /// \brief Left alignment + LEFT = 0, + /// \brief Center alignment + CENTER = 1, + /// \brief Right alignment + RIGHT = 2 + }; + + /// \enum TextVerticalAlign + /// \brief Text vertical alignment + enum class TextVerticalAlign + { + /// \brief Align bottom + BOTTOM = 0, + /// \brief Align center + CENTER = 1, + /// \brief Align top + TOP = 2 + }; + + /// \class Text Text.hh ignition/rendering/Text + /// \brief Represents a billboard text geometry that is always facing the + /// camera. + class IGNITION_RENDERING_VISIBLE Text : + public virtual Geometry + { + /// \brief Constructor + public: Text() = default; + + /// \brief Destructor + public: virtual ~Text() = default; + + /// \brief Set the font. + /// \param[in] _font Name of the font + /// \sa FontName() + public: virtual void SetFontName(const std::string &_font) = 0; + + /// \brief Get the font name. + /// \return The font name. + /// \sa SetFontName() + public: virtual std::string FontName() const = 0; + + /// \brief Set the text to display. + /// \param[in] _text The text to display. + /// \sa Text() + public: virtual void SetTextString(const std::string &_text) = 0; + + /// \brief Get the displayed text. + /// \return The displayed text. + /// \sa SetText() + public: virtual std::string TextString() const = 0; + + /// \brief Set the text color. + /// \param[in] _color Text color. + /// \sa Color() + public: virtual void SetColor(const gz::math::Color &_color) = 0; + + /// \brief Get the text color. + /// \return Text color. + /// \sa SetColor() + public: virtual gz::math::Color Color() const = 0; + + /// \brief Set the height of the character in meters. + /// \param[in] _height Height of the characters. + /// \sa CharHeight() + public: virtual void SetCharHeight(const float _height) = 0; + + /// \brief Get the height of the characters in meters + /// return Height of the characters. + /// \sa SetCharHeight() + public: virtual float CharHeight() const = 0; + + /// \brief Set the width of spaces between words. + /// \param[in] _width Space width + /// \sa SpaceWidth() + public: virtual void SetSpaceWidth(const float _width) = 0; + + /// \brief Get the width of spaces between words. + /// \return Space width + /// \sa SetSpaceWidth() + public: virtual float SpaceWidth() const = 0; + + /// \brief Set the alignment of the text + /// \param[in] _hAlign Horizontal alignment + /// \param[in] _vAlign Vertical alignment + public: virtual void SetTextAlignment(const TextHorizontalAlign &_hAlign, + const TextVerticalAlign &_vAlign) = 0; + + /// \brief Get the horizontal alignment of the text + /// \return Text horizontal alignment + public: virtual TextHorizontalAlign HorizontalAlignment() const = 0; + + /// \brief Get the vertical alignment of the text + /// \return Text verical alignment + public: virtual TextVerticalAlign VerticalAlignment() const = 0; + + /// \brief Set the baseline height of the text + /// \param[in] _baseline Baseline height + /// \sa Baseline() + public: virtual void SetBaseline(const float _baseline) = 0; + + /// \brief Get the baseline height in meters. + /// \return Baseline height + /// \sa SetBaseline() + public: virtual float Baseline() const = 0; + + /// \brief True = text always is displayed ontop. + /// \param[in] _onTop Set to true to render the text on top of + /// all other drawables. + /// \sa ShowOnTop() + public: virtual void SetShowOnTop(const bool _onTop) = 0; + + /// \brief Get whether the is displayed above other objects. + /// \return True if it is on top. + /// \sa SetShowOnTop() + public: virtual bool ShowOnTop() const = 0; + + /// \brief Get the axis aligned bounding box of the text. + /// \return The axis aligned bounding box. + public: virtual gz::math::AxisAlignedBox AABB() const = 0; + }; + } + } +} + +#endif diff --git a/include/gz/rendering/ThermalCamera.hh b/include/gz/rendering/ThermalCamera.hh new file mode 100644 index 000000000..077c9a3a9 --- /dev/null +++ b/include/gz/rendering/ThermalCamera.hh @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_THERMALCAMERA_HH_ +#define GZ_RENDERING_THERMALCAMERA_HH_ + +#include +#include "gz/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /* \class ThermalCamera ThermalCamera.hh \ + * ignition/rendering/ThermalCamera.hh + */ + /// \brief Thermal camera that produces temperature data. + /// An object's temperature can be set through the Visual class + /// using SetUserData with the key "temperature". Ambient temperature + /// is returned for object that do not have this property set. Note that + /// temperature variations for the environment and objects can be set using + /// the Set*Range functions in this class. For simplicity, the variations + /// are modeled as a function of depth (which is not how a real thermal + /// sensor works). Ideally we support heatmaps for visuals in order to + /// produce more realistic temperature output. + class IGNITION_RENDERING_VISIBLE ThermalCamera : + public virtual Camera + { + /// \brief Destructor + public: virtual ~ThermalCamera() { } + + /// \brief Set the ambient temperature of the environment + /// \param[in] _ambient Ambient temperature in kelvin + /// \sa AmbientTemperature + public: virtual void SetAmbientTemperature(float _ambient) = 0; + + /// \brief Get the ambient temperature of the environment + /// \return Ambient temperature in kelvin + /// \sa SetAmbientTemperature + public: virtual float AmbientTemperature() const = 0; + + /// \brief Set the range of ambient temperature + /// \param[in] _range The ambient temperature ranges from + /// (ambient - range/2) to (ambient + range/2). + /// \sa AmbientTemperatureRange + public: virtual void SetAmbientTemperatureRange(float _range) = 0; + + /// \brief Get the range of ambient temperature + /// \return The ambient temperature range. Ambient temperature ranges + /// from (ambient - range/2) to (ambient - range/2) + /// \sa SetAmbientTemperatureRange + public: virtual float AmbientTemperatureRange() const = 0; + + /// \brief Set the minimum temperature the sensor can detect + /// \param[in] _min Min temperature in kelvin + /// \sa MinTemperature + public: virtual void SetMinTemperature(float _min) = 0; + + /// \brief Get the minimum temperature the sensor can detect + /// \return Min temperature in kelvin + /// \sa SetMinTemperature + public: virtual float MinTemperature() const = 0; + + /// \brief Set the maximum temperature the sensor can detect + /// \param[in] _max Max temperature in kelvin + /// \sa MaxTemperature + public: virtual void SetMaxTemperature(float _max) = 0; + + /// \brief Get the maximum temperature the sensor can detect + /// \return Max temperature in kelvin + /// \sa SetMaxTemperature + public: virtual float MaxTemperature() const = 0; + + /// \brief Set the temperature linear resolution. The thermal image data + /// returned will be temperature in kelvin / resolution. + /// Typical values are 0.01 (10mK), 0.1 (100mK), or 0.04 to simulate + /// 14 bit format. + /// \param[in] _resolution Temperature linear resolution + /// \sa LinearResolution + public: virtual void SetLinearResolution(float _resolution) = 0; + + /// \brief Get the temperature linear resolution + /// \return Temperature linear resolution + /// \sa SetLinearResolution + public: virtual float LinearResolution() const = 0; + + /// \brief Get the range of temperature variation for all heat sources. + /// \return Temperature variation range + /// \sa SetHeatSourceTemperatureRange + public: virtual float HeatSourceTemperatureRange() const = 0; + + /// \brief Set the range of temperature variation for all heat sources. + /// If set, the temperature reading of heat sources will vary within + /// a temperature of +/- range/2 instead of returning a fixed uniform + /// temperature for the entire heat source + /// \param[in] _range Temperature variation range + /// \sa HeatSourceTemperatureRange + public: virtual void SetHeatSourceTemperatureRange(float _range) = 0; + + /// \brief Connect to the new thermal image event + /// \param[in] _subscriber Subscriber callback function. The callback + /// function arguments are: + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewThermalFrame( + std::function _subscriber) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/TransformController.hh b/include/gz/rendering/TransformController.hh new file mode 100644 index 000000000..9e35d6cef --- /dev/null +++ b/include/gz/rendering/TransformController.hh @@ -0,0 +1,223 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_TRANSFORMCONTROLLER_HH_ +#define GZ_RENDERING_TRANSFORMCONTROLLER_HH_ + +#include + +#include + +#include +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GizmoVisual.hh" +#include "gz/rendering/TransformType.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations + class TransformControllerPrivate; + + /* \class TransformController TransformController.hh \ + * ignition/rendering/TransformController.hh + */ + /// \brief An transform tool for translating, rotating, and scaling objects. + class IGNITION_RENDERING_VISIBLE TransformController + { + /// \brief Constructor + public: TransformController(); + + /// \brief Destructor + public: virtual ~TransformController(); + + /// \brief Update the transform controller. Its visual is updated based + /// on the current transform mode, space, and axis. + public: virtual void Update(); + + /// \brief Set the camera. + /// \param[in] _camera Camera + public: virtual void SetCamera(const CameraPtr &_camera); + + /// \brief get the camera that is controlled by this view controller. + /// \return camera being controlled + public: virtual CameraPtr Camera() const; + + /// \brief Get the attached node + /// \return The node which is being transformed, nullptr if there is no + /// node attached. + public: virtual NodePtr Node() const; + + /// \brief Attach the transform controller to the specified node + /// \param[in] _node Node that will be transformed + public: virtual void Attach(NodePtr _node); + + /// \brief Detach the transform controller from the currently attached + /// node + public: virtual void Detach(); + + /// \brief Set the transform mode + /// \param[in] _mode Transform mode to set to + public: virtual void SetTransformMode(TransformMode _mode); + + /// \brief Get the current transform mode + /// \return Transform mode + public: virtual TransformMode Mode() const; + + /// \brief Set the transform space + /// \param[in] _space Transform space to set to + public: virtual void SetTransformSpace(TransformSpace _space); + + /// \brief Get the transform space + /// \return Transform space + public: virtual TransformSpace Space() const; + + /// \brief Set the active transform axis. This highlights the axis visual + /// \param[in] _axis Transform axis vector + public: virtual void SetActiveAxis(const math::Vector3d &_axis); + + /// \brief Get the current highlighted active axis of transform + /// \return Active axis of transform + public: virtual math::Vector3d ActiveAxis() const; + + /// \brief Get the axis of transform represented by the given node id + /// \param[in] _id Id of the node to check + /// \return Transform axis + public: virtual math::Vector3d AxisById(unsigned int _id) const; + + /// \brief Translate the attached node + /// \param[in] _translation Translation in the current transform space + /// \param[in] _snap True to snap the final position to fixed increments + /// \sa SetTransformSpace + public: virtual void Translate(const math::Vector3d &_translation, + bool _snap = false); + + /// \brief Rotate the attached node + /// \param[in] _rotation Rotation in the current transform space + /// \param[in] _snap True to snap rotation angle to fixed increments + /// \sa SetTransformSpace + public: virtual void Rotate(const math::Quaterniond &_rotation, + bool _snap = false); + + /// \brief Scale the attached node. + /// \param[in] _scale Scale in the current transform space + /// \param[in] _snap True to snap scale to fixed increments + /// \sa SetTransformSpace + public: virtual void Scale(const math::Vector3d &_scale, + bool _snap = false); + + /// \brief Snap a point at intervals of a fixed distance. Currently used + /// to give a snapping behavior when transforming objects + /// \param[in] _point Input point. + /// \param[in] _interval Fixed distance interval at which the point + /// is snapped. + /// \param[in] _sensitivity Sensitivity of point snapping, in terms of a + /// percentage of the interval. + /// \return Snapped 3D point. + public: static gz::math::Vector3d SnapPoint( + const gz::math::Vector3d &_point, const double _interval = 1.0, + const double _sensitivity = 0.4); + + /// \brief Start the transform process. To be used with helper functions + /// that computions transforms from 2d movements. + /// \sa Stop + public: virtual void Start(); + + /// \brief Stop the transform process. To be used with helper functions + /// that computions transforms from 2d movements. + /// \sa Stop + public: virtual void Stop(); + + /// \brief Check if the transform process is active + /// \return True if node is being transformed + public: virtual bool Active() const; + + /// \brief Helper function to compute 3d translation from 2d translation + /// movement. Useful for converting 2d mouse drag motion to displacement + /// in world frame. Note that the camera must be set and Start() must be + /// called before using this function. + /// \param[in] _axis Axis of 3d translation. The resulting 3d vector + /// is constrained to this axis. + /// \param[in] _start Starting position of the 2d translation movement + /// \param[in] _end End position of the 2d translation movement + /// \return 3d translation vector in the current transform space + public: math::Vector3d TranslationFrom2d(const math::Vector3d &_axis, + const math::Vector2d &_start, const math::Vector2d &_end); + + /// \brief Helper function to compute 3d rotation from 2d translation + /// movement. Useful for converting 2d mouse drag motion to rotation angle + /// in world frame. Note that the camera must be set and Start() must be + /// called before using this function. + /// \param[in] _axis Axis of 3d rotation. The resulting rotation is + /// is constrained to this axis. + /// \param[in] _start Starting position of the 2d translation movement + /// \param[in] _end End position of the 2d translation movement + /// \return Rotation in the current transform space + public: math::Quaterniond RotationFrom2d(const math::Vector3d &_axis, + const math::Vector2d &_start, const math::Vector2d &_end); + + /// \brief Helper function to compute 3d scale from 2d translation + /// movement. Useful for converting 2d mouse drag motion to scale vector + /// in world frame. Note that the camera must be set and Start() must be + /// called before using this function. + /// \param[in] _axis Axis of scale. The resulting 3d vector + /// is constrained to this axis. + /// \param[in] _start Starting position of the 2d translation movement + /// \param[in] _end End position of the 2d translation movement + /// \return 3d scale vector in the current transform space + public: math::Vector3d ScaleFrom2d(const math::Vector3d &_axis, + const math::Vector2d &_start, const math::Vector2d &_end); + + /// \brief Convert a TransformAxis to a vector type + /// \param[in] _axis Transform axis + /// \return 3d axis vector + public: static math::Vector3d ToAxis(TransformAxis _axis); + + /// \brief Helper function to create a plane for transfomation. + /// The plane is chosen based on the current transform mode and the + /// transform axis specified. + /// \param[in] _axis Transformation axis used to identify the plane for + /// projection. + /// \param[in] _pt2d 2d point to help fine tune the plane created. + /// \return Plane created for transform + protected: math::Planed CreatePlaneForTransform( + const math::Vector3d &_axis, const math::Vector2d &_pt2d); + + /// \brief Helper function to compute ray plane intersection + /// \param[in] _ray Input ray + /// \param[in] _plane Plane to check for intersection + /// \param[out] _result Intersection point + /// \return True if intersection point exist, false if ray is parallel + /// to plane + protected: bool RayPlaneIntersection(RayQueryPtr _ray, + const math::Planed &_plane, math::Vector3d &_result); + + /// \brief Private data pointer + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/TransformType.hh b/include/gz/rendering/TransformType.hh new file mode 100644 index 000000000..158b4d07b --- /dev/null +++ b/include/gz/rendering/TransformType.hh @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GZ_RENDERING_TRANSFORMTYPE_HH_ +#define GZ_RENDERING_TRANSFORMTYPE_HH_ + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \enum TransformAxis + /// \brief Unique identifiers for transformation axes. + enum IGNITION_RENDERING_VISIBLE TransformAxis + { + /// \brief No axis + TA_NONE = 0, + /// \brief Translation in x + TA_TRANSLATION_X = 0x00000001, + /// \brief Translation in y + TA_TRANSLATION_Y = 0x00000002, + /// \brief Translation in z + TA_TRANSLATION_Z = 0x00000004, + /// \brief Rotation in x + TA_ROTATION_X = 0x00000010, + /// \brief Rotation in y + TA_ROTATION_Y = 0x00000020, + /// \brief Rotation in z + TA_ROTATION_Z = 0x00000040, + /// \brief Scale in x + TA_SCALE_X = 0x00000100, + /// \brief Scale in y + TA_SCALE_Y = 0x00000200, + /// \brief Scale in z + TA_SCALE_Z = 0x00000400 + }; + + /// \enum TransformMode + /// \brief Unique identifiers for transformation modes. + enum IGNITION_RENDERING_VISIBLE TransformMode + { + /// \brief Inactive state + TM_NONE = 0, + /// \brief Translation mode + TM_TRANSLATION = TA_TRANSLATION_X | TA_TRANSLATION_Y | TA_TRANSLATION_Z, + /// \brief Rotation mode + TM_ROTATION = TA_ROTATION_X | TA_ROTATION_Y | TA_ROTATION_Z, + /// \brief Scale mode + TM_SCALE = TA_SCALE_X | TA_SCALE_Y, TA_SCALEZ, + }; + + /// \enum TransformSpace + /// \brief Unique identifiers for transformation spaces. + enum IGNITION_RENDERING_VISIBLE TransformSpace + { + /// \brief transformation in local frame + TS_LOCAL, + /// \brief transformation in world frame + TS_WORLD + }; + } + } +} +#endif diff --git a/include/gz/rendering/Utils.hh b/include/gz/rendering/Utils.hh new file mode 100644 index 000000000..b2819201e --- /dev/null +++ b/include/gz/rendering/Utils.hh @@ -0,0 +1,89 @@ +/* + * 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 "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(); + } + } +} +#endif diff --git a/include/gz/rendering/ViewController.hh b/include/gz/rendering/ViewController.hh new file mode 100644 index 000000000..dbde046e0 --- /dev/null +++ b/include/gz/rendering/ViewController.hh @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_VIEWCONTROLLER_HH_ +#define GZ_RENDERING_VIEWCONTROLLER_HH_ + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/Camera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class ViewController ViewController.hh + /// ignition/rendering/ViewController.hh + /// \brief A camera view controller + class IGNITION_RENDERING_VISIBLE ViewController + { + /// \brief Deconstructor + public: virtual ~ViewController() { } + + /// \brief Set the camera that will be controlled by this view controller. + /// \param[in] _camera Camera to control + public: virtual void SetCamera(const CameraPtr &_camera) = 0; + + /// \brief Set target point for pan, zoom, oribit + /// \param[in] _target Target point in world coordinates + public: virtual void SetTarget(const math::Vector3d &_target) = 0; + + /// \brief Set zoom amount + /// \param[in] _value Camera zoon value, e.g. mouse scroll delta + public: virtual void Zoom(const double _value) = 0; + + /// \brief Set camera pan (translational movement) around target point. + /// \param[in] _value Pan amount in image plane, e.g. mouse drag delta. + public: virtual void Pan(const math::Vector2d &_value) = 0; + + /// \brief Set camera orbit (rotational movement) around target point. + /// \param[in] _value robit amount in image plane, e.g. mouse drag delta + public: virtual void Orbit(const math::Vector2d &_value) = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/Visual.hh b/include/gz/rendering/Visual.hh new file mode 100644 index 000000000..d085b66a4 --- /dev/null +++ b/include/gz/rendering/Visual.hh @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_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 { + // + using Variant = std::variant; + + /// \class Visual Visual.hh ignition/rendering/Visual.hh + /// \brief Represents a visual node in a scene graph. A Visual is the only + /// node that can have Geometry and other Visual children. + class IGNITION_RENDERING_VISIBLE Visual : + public virtual Node + { + /// \brief Deconstructor + public: virtual ~Visual() { } + + /// \brief Get the number of geometries attached to this visual + /// \return The number of geometries attached to this visual + public: virtual unsigned int GeometryCount() const = 0; + + /// \brief Determine if given geometry is attached to this visual + /// \param[in] _geometry Geometry in question + /// \return True if given node is attached to this visual + public: virtual bool HasGeometry(ConstGeometryPtr _geometry) const = 0; + + /// \brief Get geometry at given index. If no geometry exists at given + /// index, NULL will be returned. + /// \param[in] _index Index of the desired geometry + /// \return The specified geometry + public: virtual GeometryPtr GeometryByIndex( + unsigned int _index) const = 0; + + /// \brief Add the given geometry to this visual. If the given node is + /// already attached, no work will be done. + /// \param[in] _geometry Geometry to be added + public: virtual void AddGeometry(GeometryPtr _geometry) = 0; + + /// \brief Remove the given geometry from this visual. If the given node + /// is not a child of this visual, no work will be done. + /// \param[in] _geometry Geometry to be removed + /// \return The removed geometry + public: virtual GeometryPtr RemoveGeometry(GeometryPtr _geometry) = 0; + + /// \brief Remove the geometry at the given index from this visual. If the + /// specified node is not attached this visual, no work will be done. + /// \param[in] _index Index of the geometry to be removed + /// \return The removed geometry + public: virtual GeometryPtr RemoveGeometryByIndex( + unsigned int _index) = 0; + + /// \brief Remove all attached geometries from this visual + public: virtual void RemoveGeometries() = 0; + + /// \brief Set the material for all attached visuals and geometries. The + /// specified material will be retrieved from Scene::Material using + /// the given material name. If no material is registered with the given + /// name, no work will be done. + /// \param[in] _name Name of the material to be assigned + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetMaterial(const std::string &_name, + bool _unique = true) = 0; + + /// \brief Set the material for all attached visuals and geometries + /// \param[in] _material Name of the material to be assigned + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true) = 0; + + /// \brief Set the material for all attached visuals only + /// \param[in] _material Name of the material to be assigned + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetChildMaterial(MaterialPtr _material, + bool _unique = true) = 0; + + /// \brief Set the material for all attached geometries only + /// \param[in] _material Name of the material to be assigned + /// \param[in] _unique True if the specified material should be cloned + public: virtual void SetGeometryMaterial(MaterialPtr _material, + bool _unique = true) = 0; + + /// \brief Get the material assigned to attached visuals and geometries. + /// \return the Pointer to the material assigned to this visual. If the + /// material is cloned at the time it is set to this visual, the cloned + /// material will be returned. + public: virtual MaterialPtr Material() = 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 Store any custom data associated with this visual + /// \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 visual + /// \param[in] _key Unique key + /// \return Data associated with the key. + public: virtual Variant UserData(const std::string &_key) const = 0; + }; + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseArrowVisual.hh b/include/gz/rendering/base/BaseArrowVisual.hh new file mode 100644 index 000000000..3ea5c8ae2 --- /dev/null +++ b/include/gz/rendering/base/BaseArrowVisual.hh @@ -0,0 +1,96 @@ +/* + * 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 "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 + { + protected: BaseArrowVisual(); + + public: virtual ~BaseArrowVisual(); + + public: virtual VisualPtr Head() const; + + public: virtual VisualPtr Shaft() const; + + protected: virtual void Init(); + }; + + ////////////////////////////////////////////////// + template + BaseArrowVisual::BaseArrowVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseArrowVisual::~BaseArrowVisual() + { + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseArrowVisual::Head() const + { + return std::dynamic_pointer_cast(this->ChildByIndex(0)); + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseArrowVisual::Shaft() const + { + return std::dynamic_pointer_cast(this->ChildByIndex(1)); + } + + ////////////////////////////////////////////////// + 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); + + this->SetOrigin(0, 0, -0.5); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseAxisVisual.hh b/include/gz/rendering/base/BaseAxisVisual.hh new file mode 100644 index 000000000..b7cffb664 --- /dev/null +++ b/include/gz/rendering/base/BaseAxisVisual.hh @@ -0,0 +1,81 @@ +/* + * 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(); + }; + + ////////////////////////////////////////////////// + template + BaseAxisVisual::BaseAxisVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseAxisVisual::~BaseAxisVisual() + { + } + + ////////////////////////////////////////////////// + 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); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseCamera.hh b/include/gz/rendering/base/BaseCamera.hh new file mode 100644 index 000000000..2d02fa9f2 --- /dev/null +++ b/include/gz/rendering/base/BaseCamera.hh @@ -0,0 +1,741 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASECAMERA_HH_ +#define GZ_RENDERING_BASE_BASECAMERA_HH_ + +#include + +#include +#include + +#include +#include +#include + +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/base/BaseRenderTarget.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + template + class BaseDepthCamera; + + template + class BaseCamera : + public virtual Camera, + public virtual T + { + protected: BaseCamera(); + + public: virtual ~BaseCamera(); + + public: virtual unsigned int ImageWidth() const override; + + public: virtual void SetImageWidth(const unsigned int _width) override; + + public: virtual unsigned int ImageHeight() const override; + + public: virtual void SetImageHeight(const unsigned int _height) override; + + public: virtual PixelFormat ImageFormat() const override; + + public: virtual unsigned int ImageMemorySize() const override; + + public: virtual void SetImageFormat(PixelFormat _format) override; + + public: virtual math::Angle HFOV() const override; + + public: virtual void SetHFOV(const math::Angle &_hfov) override; + + public: virtual double AspectRatio() const override; + + public: virtual void SetAspectRatio(const double _ratio) override; + + public: virtual unsigned int AntiAliasing() const override; + + public: virtual void SetAntiAliasing(const unsigned int _aa) override; + + public: virtual double FarClipPlane() const override; + + public: virtual void SetFarClipPlane(const double _far) override; + + public: virtual double NearClipPlane() const override; + + public: virtual void SetNearClipPlane(const double _near) override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void PostRender() override; + + public: virtual void Update() override; + + public: virtual Image CreateImage() const override; + + public: virtual void Capture(Image &_image) override; + + public: virtual void Copy(Image &_image) const override; + + public: virtual bool SaveFrame(const std::string &_name) override; + + public: virtual common::ConnectionPtr ConnectNewImageFrame( + Camera::NewFrameListener _listener) override; + + public: virtual RenderWindowPtr CreateRenderWindow() override; + + // Documentation inherited. + public: virtual VisualPtr VisualAt(const gz::math::Vector2i + &_mousePos) override; + + // Documentation inherited. + public: virtual math::Matrix4d ProjectionMatrix() const override; + + // Documentation inherited. + public: virtual math::Matrix4d ViewMatrix() const override; + + // Documentation inherited. + // \sa Camera::SetMaterial(const MaterialPtr &) override; + public: virtual void SetMaterial(const MaterialPtr &_material) + override; + + // Documentation inherited. + public: virtual void SetTrackTarget(const NodePtr &_target, + const math::Vector3d &_offset, + const bool _worldFrame) override; + + // Documentation inherited. + public: virtual NodePtr TrackTarget() const override; + + // Documentation inherited. + public: virtual void SetTrackOffset(const math::Vector3d &_offset) + override; + + // Documentation inherited. + public: virtual math::Vector3d TrackOffset() const override; + + // Documentation inherited. + public: virtual void SetTrackPGain(const double _pGain) override; + + // Documentation inherited. + public: virtual double TrackPGain() const override; + + // Documentation inherited. + public: virtual void SetFollowTarget(const NodePtr &_target, + const math::Vector3d &_Offset, const bool _worldFrame) + override; + + // Documentation inherited. + public: virtual NodePtr FollowTarget() const override; + + // Documentation inherited. + public: virtual void SetFollowOffset(const math::Vector3d &_offset) + override; + + // Documentation inherited. + public: virtual math::Vector3d FollowOffset() const override; + + // Documentation inherited. + public: virtual void SetFollowPGain(const double _pGain) override; + + // Documentation inherited. + public: virtual double FollowPGain() const override; + + // Documentation inherited. + public: virtual unsigned int RenderTextureGLId() const override; + + // Documentation inherited. + public: virtual void AddRenderPass(const RenderPassPtr &_pass) override; + + // Documentation inherited. + public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) + override; + + // Documentation inherited. + public: virtual unsigned int RenderPassCount() const override; + + // Documentation inherited. + public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) + const override; + + protected: virtual void *CreateImageBuffer() const; + + protected: virtual void Load() override; + + protected: virtual void Reset(); + + protected: virtual RenderTargetPtr RenderTarget() const = 0; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: common::EventT newFrameEvent; + + protected: ImagePtr imageBuffer; + + /// \brief Near clipping plane distance + protected: double nearClip = 0.01; + + /// \brief Far clipping plane distance + protected: double farClip = 1000.0; + + /// \brief Aspect ratio + protected: double aspect = 1.3333333; + + /// \brief Horizontal camera field of view + protected: math::Angle hfov; + + /// \brief Anti-aliasing + protected: unsigned int antiAliasing = 0u; + + /// \brief Target node to track if camera tracking is on. + protected: NodePtr trackNode; + + /// \brief Track point relative to target in world frame. + protected: bool trackWorldFrame = false; + + /// \brief Set camera to track a point offset in target node's local or + /// world frame depending on trackWorldFrame. + protected: math::Vector3d trackOffset; + + /// \brief P gain for tracking. Determines how fast the camera rotates + /// to look at the target node. Valid range: [0-1] + protected: double trackPGain = 1.0; + + /// \brief Target node to follow + protected: NodePtr followNode; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Follow target in world frame. + protected: bool followWorldFrame = false; + + /// \brief P gain for follow mode. Determines how fast the camera moves + /// to follow the target node. Valid range: [0-1] + protected: double followPGain = 1.0; + + /// \brief Offset distance between camera and target node being followed + protected: math::Vector3d followOffset; + + 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(); + + 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(); + } + + 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(); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::Capture(Image &_image) + { + this->Update(); + this->Copy(_image); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::Copy(Image &_image) const + { + this->RenderTarget()->Copy(_image); + } + + ////////////////////////////////////////////////// + template + bool BaseCamera::SaveFrame(const std::string &/*_name*/) + { + return false; + } + + ////////////////////////////////////////////////// + template + common::ConnectionPtr BaseCamera::ConnectNewImageFrame( + Camera::NewFrameListener _listener) + { + return newFrameEvent.Connect(_listener); + } + + ////////////////////////////////////////////////// + template + void *BaseCamera::CreateImageBuffer() const + { + // TODO(anyone): determine proper type + unsigned int size = this->ImageMemorySize(); + return new unsigned char *[size]; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::Load() + { + T::Load(); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::Reset() + { + math::Angle fov; + fov.Degree(60); + this->SetImageWidth(1); + this->SetImageHeight(1); + this->SetImageFormat(PF_R8G8B8); + this->SetAspectRatio(1.33333); + this->SetAntiAliasing(0u); + this->SetHFOV(fov); + this->SetNearClipPlane(0.01); + this->SetFarClipPlane(1000); + } + + ////////////////////////////////////////////////// + template + RenderWindowPtr BaseCamera::CreateRenderWindow() + { + // Does nothing by default + ignerr << "Render window not supported for render engine: " << + this->Scene()->Engine()->Name() << std::endl; + return RenderWindowPtr(); + } + + ////////////////////////////////////////////////// + template + math::Matrix4d BaseCamera::ProjectionMatrix() const + { + // perspective projection + 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; + math::Matrix4d result; + 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; + + // TODO(anyone): compute projection matrix for orthographic camera + + return result; + } + + ////////////////////////////////////////////////// + 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 + math::Angle BaseCamera::HFOV() const + { + return this->hfov; + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseCamera::VisualAt(const gz::math::Vector2i + &/*_mousePos*/) + { + ignerr << "VisualAt not implemented for the render engine" << std::endl; + return VisualPtr(); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetHFOV(const math::Angle &_hfov) + { + this->hfov = _hfov; + } + + ////////////////////////////////////////////////// + template + double BaseCamera::AspectRatio() const + { + return this->aspect; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetAspectRatio(const double _aspect) + { + this->aspect = _aspect; + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCamera::AntiAliasing() const + { + return this->antiAliasing; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetAntiAliasing(const unsigned int _aa) + { + this->antiAliasing = _aa; + } + + ////////////////////////////////////////////////// + template + double BaseCamera::FarClipPlane() const + { + return this->farClip; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetFarClipPlane(const double _far) + { + this->farClip = _far; + } + + ////////////////////////////////////////////////// + template + double BaseCamera::NearClipPlane() const + { + return this->nearClip; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetNearClipPlane(const double _near) + { + this->nearClip = _near; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetTrackTarget(const NodePtr &_target, + const math::Vector3d &_offset, const bool _worldFrame) + { + this->trackNode = _target; + this->trackWorldFrame = _worldFrame; + this->trackOffset = _offset; + } + + ////////////////////////////////////////////////// + template + NodePtr BaseCamera::TrackTarget() const + { + return this->trackNode; + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseCamera::TrackOffset() const + { + return this->trackOffset; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetTrackOffset(const math::Vector3d &_offset) + { + this->trackOffset = _offset; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetTrackPGain(const double _pGain) + { + this->trackPGain = math::clamp(_pGain, 0.0, 1.0); + } + + ////////////////////////////////////////////////// + template + double BaseCamera::TrackPGain() const + { + return this->trackPGain; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetFollowTarget(const NodePtr &_target, + const math::Vector3d &_offset, const bool _worldFrame) + { + this->followNode = _target; + this->followWorldFrame = _worldFrame; + this->followOffset = _offset; + } + + ////////////////////////////////////////////////// + template + NodePtr BaseCamera::FollowTarget() const + { + return this->followNode; + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseCamera::FollowOffset() const + { + return this->followOffset; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetFollowOffset(const math::Vector3d &_offset) + { + this->followOffset = _offset; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetFollowPGain(const double _pGain) + { + this->followPGain = math::clamp(_pGain, 0.0, 1.0); + } + + ////////////////////////////////////////////////// + template + double BaseCamera::FollowPGain() const + { + return this->followPGain; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::SetMaterial(const MaterialPtr &/*_material*/) + { + ignerr << "SetMaterial not implemented for current render" + << " engine" << std::endl; + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCamera::RenderTextureGLId() const + { + ignerr << "RenderTextureGLId is not supported by current render" + << " engine" << std::endl; + return 0u; + } + + ////////////////////////////////////////////////// + template + void BaseCamera::AddRenderPass(const RenderPassPtr &_pass) + { + this->RenderTarget()->AddRenderPass(_pass); + } + + ////////////////////////////////////////////////// + template + void BaseCamera::RemoveRenderPass(const RenderPassPtr &_pass) + { + this->RenderTarget()->RemoveRenderPass(_pass); + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCamera::RenderPassCount() const + { + return this->RenderTarget()->RenderPassCount(); + } + + ////////////////////////////////////////////////// + template + RenderPassPtr BaseCamera::RenderPassByIndex(unsigned int _index) const + { + return this->RenderTarget()->RenderPassByIndex(_index); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseDepthCamera.hh b/include/gz/rendering/base/BaseDepthCamera.hh new file mode 100644 index 000000000..9781fae90 --- /dev/null +++ b/include/gz/rendering/base/BaseDepthCamera.hh @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEDEPTHCAMERA_HH_ +#define GZ_RENDERING_BASE_BASEDEPTHCAMERA_HH_ + +#include + +#include + +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/DepthCamera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + template + class BaseDepthCamera : + public virtual DepthCamera, + public virtual BaseCamera, + public virtual T + { + protected: BaseDepthCamera(); + + public: virtual ~BaseDepthCamera(); + + public: virtual void CreateDepthTexture(); + + public: virtual const float *DepthData() const; + + public: virtual gz::common::ConnectionPtr ConnectNewDepthFrame( + std::function _subscriber); + + public: virtual gz::common::ConnectionPtr ConnectNewRGBPointCloud( + std::function _subscriber); + }; + + ////////////////////////////////////////////////// + template + BaseDepthCamera::BaseDepthCamera() + { + } + + ////////////////////////////////////////////////// + template + BaseDepthCamera::~BaseDepthCamera() + { + } + + ////////////////////////////////////////////////// + template + void BaseDepthCamera::CreateDepthTexture() + { + } + + ////////////////////////////////////////////////// + template + const float *BaseDepthCamera::DepthData() const + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + gz::common::ConnectionPtr BaseDepthCamera::ConnectNewDepthFrame( + std::function) + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + gz::common::ConnectionPtr BaseDepthCamera::ConnectNewRGBPointCloud( + std::function) + { + return nullptr; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseGaussianNoisePass.hh b/include/gz/rendering/base/BaseGaussianNoisePass.hh new file mode 100644 index 000000000..82a99c014 --- /dev/null +++ b/include/gz/rendering/base/BaseGaussianNoisePass.hh @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_ +#define GZ_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_ + +#include +#include + +#include "gz/rendering/GaussianNoisePass.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class BaseGaussianNoisePass BaseGaussianNoisePass.hh \ + * ignition/rendering/base/BaseGaussianNoisePass.hh + */ + /// \brief Base Gaussian noise render pass. + template + class BaseGaussianNoisePass : + public virtual GaussianNoisePass, + public virtual T + { + /// \brief Constructor + protected: BaseGaussianNoisePass(); + + /// \brief Destructor + public: virtual ~BaseGaussianNoisePass(); + + // Documentation inherited. + public: double Mean() const; + + // Documentation inherited. + public: double StdDev() const; + + // Documentation inherited. + public: double Bias() const; + + // Documentation inherited. + public: void SetMean(double _mean); + + // Documentation inherited. + public: void SetStdDev(double _stdDev); + + // Documentation inherited. + public: void SetBiasMean(double _biasMean); + + // Documentation inherited. + public: void SetBiasStdDev(double _biasStdDev); + + // Sample the bias from bias mean and bias standard deviation + protected: void SampleBias(); + + /// \brief Gaussian noise mean. + protected: double mean = 0.0; + + /// \brief Standard deviation of Gaussian noise + protected: double stdDev = 0.0; + + /// \brief Gaussian noise bias. + protected: double bias = 0.0; + + /// \brief The mean of the Gaussian distribution from which bias values + /// are drawn. + protected: double biasMean = 0; + + /// \brief The standard deviation of the Gaussian distribution from + /// which bias values are drawn. + protected: double biasStdDev = 0; + }; + + ////////////////////////////////////////////////// + // BaseGaussianNoisePass + ////////////////////////////////////////////////// + template + BaseGaussianNoisePass::BaseGaussianNoisePass() + { + } + + ////////////////////////////////////////////////// + template + BaseGaussianNoisePass::~BaseGaussianNoisePass() + { + } + + ////////////////////////////////////////////////// + template + double BaseGaussianNoisePass::Mean() const + { + return this->mean; + } + + ////////////////////////////////////////////////// + template + double BaseGaussianNoisePass::StdDev() const + { + return this->stdDev; + } + + ////////////////////////////////////////////////// + template + double BaseGaussianNoisePass::Bias() const + { + return this->bias; + } + + ////////////////////////////////////////////////// + template + void BaseGaussianNoisePass::SetMean(double _mean) + { + this->mean = _mean; + } + + ////////////////////////////////////////////////// + template + void BaseGaussianNoisePass::SetStdDev(double _stdDev) + { + this->stdDev = _stdDev; + } + + ////////////////////////////////////////////////// + template + void BaseGaussianNoisePass::SetBiasMean(double _biasMean) + { + this->biasMean = _biasMean; + this->SampleBias(); + } + + ////////////////////////////////////////////////// + template + void BaseGaussianNoisePass::SetBiasStdDev(double _biasStdDev) + { + this->biasStdDev = _biasStdDev; + this->SampleBias(); + } + + ////////////////////////////////////////////////// + template + void BaseGaussianNoisePass::SampleBias() + { + this->bias = + gz::math::Rand::DblNormal(this->biasMean, this->biasStdDev); + // With equal probability, we pick a negative bias (by convention, + // rateBiasMean should be positive, though it would work fine if + // negative). + if (gz::math::Rand::DblUniform() < 0.5) + this->bias = -this->bias; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseGeometry.hh b/include/gz/rendering/base/BaseGeometry.hh new file mode 100644 index 000000000..e21e3ce3b --- /dev/null +++ b/include/gz/rendering/base/BaseGeometry.hh @@ -0,0 +1,102 @@ +/* + * 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 "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 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 + void BaseGeometry::Destroy() + { + T::Destroy(); + this->RemoveParent(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseGizmoVisual.hh b/include/gz/rendering/base/BaseGizmoVisual.hh new file mode 100644 index 000000000..ccc329941 --- /dev/null +++ b/include/gz/rendering/base/BaseGizmoVisual.hh @@ -0,0 +1,723 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GZ_RENDERING_BASE_BASEGIZMOVISUAL_HH_ +#define GZ_RENDERING_BASE_BASEGIZMOVISUAL_HH_ + +#include +#include +#include +#include + +#include "gz/rendering/base/BaseScene.hh" +#include "gz/rendering/base/BaseNode.hh" +#include "gz/rendering/ArrowVisual.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GizmoVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class BaseGizmoVisual BaseGizmoVisuall.hh \ + * ignition/rendering/base/BaseGizmoVisual.hh + */ + /// \brief A base implementation of the GizmoVisual class + template + class BaseGizmoVisual : + public virtual GizmoVisual, + public virtual T + { + /// \brief Constructor + protected: BaseGizmoVisual(); + + /// \brief Destructor + public: virtual ~BaseGizmoVisual(); + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void SetTransformMode(TransformMode _mode) override; + + // Documentation inherited + public: virtual TransformMode Mode() const override; + + // Documentation inherited + public: virtual void SetActiveAxis(const math::Vector3d &_axis) override; + + // Documentation inherited + public: virtual math::Vector3d ActiveAxis() const override; + + // Documentation inherited + public: virtual TransformAxis AxisById(unsigned int _id) const override; + + // Documentation inherited + public: virtual VisualPtr ChildByAxis(unsigned int _axis) const override; + + /// \brief Reset the gizmo visual state + public: virtual void Reset(); + + /// \brief Create materials used by the gizmo visual + protected: void CreateMaterials(); + + /// \brief Create gizmo visual for translation + protected: void CreateTranslationVisual(); + + /// \brief Create gizmo visual for rotation + protected: void CreateRotationVisual(); + + /// \brief Create gizmo visual for scale + protected: void CreateScaleVisual(); + + /// \brief Current gizmo mode + protected: TransformMode mode = TransformMode::TM_NONE; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief A map of gizmo axis and their visuals + protected: std::map visuals; + + /// \brief A map of gizmo axis and their handle visuals + protected: std::map handles; + + /// \brief Currently active visual. + protected: VisualPtr activeVis; + + /// \brief Flag to indicate the mode has changed. + protected: bool modeDirty = false; + + /// \brief Active axis + protected: math::Vector3d axis = math::Vector3d::Zero; + + /// \brief A map of axis enums to materials + protected: std::map materials; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Material used by axes + protected: enum AxisMaterial + { + /// \brief X axis + AM_X, + /// \brief Y axis + AM_Y, + /// \brief Z axis + AM_Z, + /// \brief Active axis + AM_ACTIVE, + /// \brief Origin + AM_O, + /// \brief handle + AM_HANDLE + }; + + /// \brief Only the scene can create a GizmoVisual + private: friend class BaseScene; + }; + + ////////////////////////////////////////////////// + template + BaseGizmoVisual::BaseGizmoVisual() + { + } + + ////////////////////////////////////////////////// + template + BaseGizmoVisual::~BaseGizmoVisual() + { + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::Init() + { + T::Init(); + + this->CreateMaterials(); + this->CreateTranslationVisual(); + this->CreateRotationVisual(); + this->CreateScaleVisual(); + + for (auto v : this->visuals) + v.second->SetVisible(false); + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::Reset() + { + this->visuals[TransformAxis::TA_TRANSLATION_X]->SetMaterial( + this->materials[AM_X], false); + this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( + this->materials[AM_Y], false); + this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( + this->materials[AM_Z], false); + this->visuals[TransformAxis::TA_ROTATION_X]->SetMaterial( + this->materials[AM_X], false); + this->visuals[TransformAxis::TA_ROTATION_Y]->SetMaterial( + this->materials[AM_Y], false); + this->visuals[TransformAxis::TA_ROTATION_Z]->SetMaterial( + this->materials[AM_Z], false); + this->visuals[TransformAxis::TA_SCALE_X]->SetMaterial( + this->materials[AM_X], false); + this->visuals[TransformAxis::TA_SCALE_Y]->SetMaterial( + this->materials[AM_Y], false); + this->visuals[TransformAxis::TA_SCALE_Z]->SetMaterial( + this->materials[AM_Z], false); + + this->handles[TransformAxis::TA_TRANSLATION_X]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + + this->handles[TransformAxis::TA_ROTATION_X]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_ROTATION_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_ROTATION_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + + this->handles[TransformAxis::TA_SCALE_X]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_SCALE_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + this->handles[TransformAxis::TA_SCALE_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + + for (auto v : this->visuals) + v.second->SetVisible(false); + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::PreRender() + { + if (!this->modeDirty) + return; + + this->Reset(); + + if (this->mode == TransformMode::TM_NONE) + { + this->modeDirty = false; + return; + } + + if (this->mode & TransformMode::TM_TRANSLATION) + { + this->visuals[TransformAxis::TA_TRANSLATION_X]->SetVisible(true); + this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetVisible(true); + this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetVisible(true); + this->visuals[TransformAxis::TA_TRANSLATION_Z << 1]->SetVisible(true); + if (this->axis.X() > 0) + { + this->visuals[TransformAxis::TA_TRANSLATION_X]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_TRANSLATION_X]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Y() > 0) + { + this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Z() > 0) + { + this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + } + } + else if (this->mode & TransformMode::TM_ROTATION) + { + this->visuals[TransformAxis::TA_ROTATION_X]->SetVisible(true); + this->visuals[TransformAxis::TA_ROTATION_Y]->SetVisible(true); + this->visuals[TransformAxis::TA_ROTATION_Z]->SetVisible(true); + this->visuals[TransformAxis::TA_ROTATION_Z << 1]->SetVisible(true); + if (this->axis.X() > 0) + { + this->visuals[TransformAxis::TA_ROTATION_X]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_ROTATION_X]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Y() > 0) + { + this->visuals[TransformAxis::TA_ROTATION_Y]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_ROTATION_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Z() > 0) + { + this->visuals[TransformAxis::TA_ROTATION_Z]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_ROTATION_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + } + } + else if (this->mode & TransformMode::TM_SCALE) + { + this->visuals[TransformAxis::TA_SCALE_X]->SetVisible(true); + this->visuals[TransformAxis::TA_SCALE_Y]->SetVisible(true); + this->visuals[TransformAxis::TA_SCALE_Z]->SetVisible(true); + if (this->axis.X() > 0) + { + this->visuals[TransformAxis::TA_SCALE_X]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_SCALE_X]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Y() > 0) + { + this->visuals[TransformAxis::TA_SCALE_Y]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_SCALE_Y]->SetMaterial( + this->materials[AM_HANDLE], false); + } + if (this->axis.Z() > 0) + { + this->visuals[TransformAxis::TA_SCALE_Z]->SetMaterial( + this->materials[AM_ACTIVE], false); + this->handles[TransformAxis::TA_SCALE_Z]->SetMaterial( + this->materials[AM_HANDLE], false); + } + } + + this->modeDirty = false; + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::SetTransformMode(TransformMode _mode) + { + if (this->mode == _mode) + return; + + this->mode = _mode; + // clear active axis when mode changes + this->axis = math::Vector3d::Zero; + this->modeDirty = true; + } + + ////////////////////////////////////////////////// + template + TransformMode BaseGizmoVisual::Mode() const + { + return this->mode; + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::SetActiveAxis(const math::Vector3d &_axis) + { + if (this->axis == _axis) + return; + + this->axis = _axis; + this->modeDirty = true; + } + + ////////////////////////////////////////////////// + template + math::Vector3d BaseGizmoVisual::ActiveAxis() const + { + return this->axis; + } + + ////////////////////////////////////////////////// + template + TransformAxis BaseGizmoVisual::AxisById(unsigned int _id) const + { + for (auto v : this->visuals) + { + // each axis visual has a child handle so also check children for + // matching id + if (v.second->Id() == _id || v.second->ChildById(_id)) + return static_cast(v.first); + } + return TransformAxis::TA_NONE; + } + + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::CreateMaterials() + { + MaterialPtr xMat = this->Scene()->Material("Default/TransRed")->Clone(); + MaterialPtr yMat = this->Scene()->Material("Default/TransGreen")->Clone(); + MaterialPtr zMat = this->Scene()->Material("Default/TransBlue")->Clone(); + MaterialPtr activeMat = + this->Scene()->Material("Default/TransYellow")->Clone(); + + // disable depth checking and writing, make them overlays + xMat->SetDepthWriteEnabled(false); + xMat->SetDepthCheckEnabled(false); + yMat->SetDepthWriteEnabled(false); + yMat->SetDepthCheckEnabled(false); + zMat->SetDepthWriteEnabled(false); + zMat->SetDepthCheckEnabled(false); + activeMat->SetDepthWriteEnabled(false); + activeMat->SetDepthCheckEnabled(false); + + MaterialPtr oMat = this->Scene()->Material("GizmoGray"); + if (!oMat) + { + oMat = this->Scene()->CreateMaterial("GizmoGray"); + oMat->SetAmbient(0.5, 0.5, 0.5); + oMat->SetDiffuse(0.5, 0.5, 0.5); + oMat->SetEmissive(0.5, 0.5, 0.5); + oMat->SetTransparency(0.5); + oMat->SetCastShadows(false); + oMat->SetReceiveShadows(false); + oMat->SetLightingEnabled(false); + oMat->SetDepthWriteEnabled(false); + oMat->SetDepthCheckEnabled(false); + } + + MaterialPtr handleMat = this->Scene()->Material("GizmoHandle"); + if (!handleMat) + { + handleMat = this->Scene()->CreateMaterial("GizmoHandle"); + handleMat->SetAmbient(0.0, 0.0, 0.0); + handleMat->SetDiffuse(0.0, 0.0, 0.0); + handleMat->SetEmissive(0.0, 0.0, 0.0); + handleMat->SetTransparency(1.0); + handleMat->SetCastShadows(false); + handleMat->SetReceiveShadows(false); + handleMat->SetLightingEnabled(false); + handleMat->SetDepthWriteEnabled(false); + handleMat->SetDepthCheckEnabled(false); + } + + this->materials[AM_X] = xMat; + this->materials[AM_Y] = yMat; + this->materials[AM_Z] = zMat; + this->materials[AM_ACTIVE] = activeMat; + this->materials[AM_O] = oMat; + this->materials[AM_HANDLE] = handleMat; + } + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::CreateTranslationVisual() + { + VisualPtr transVis = this->Scene()->CreateVisual(); + + // trans x + VisualPtr transXVis = this->Scene()->CreateVisual(); + VisualPtr transShaftXVis = this->Scene()->CreateVisual(); + transShaftXVis->AddGeometry(this->Scene()->CreateCylinder()); + transShaftXVis->SetOrigin(0, 0, 0.5); + transShaftXVis->SetLocalPosition(0, 0, 0.5); + transShaftXVis->SetLocalScale(0.02, 0.02, 0.45); + transXVis->AddChild(transShaftXVis); + + VisualPtr transHeadXVis = this->Scene()->CreateVisual(); + transHeadXVis->AddGeometry(this->Scene()->CreateCone()); + transHeadXVis->SetOrigin(0, 0, -0.5); + transHeadXVis->SetLocalPosition(0, 0, 0.5); + transHeadXVis->SetLocalScale(0.07, 0.07, 0.2); + transXVis->AddChild(transHeadXVis); + + transXVis->SetMaterial(this->materials[AM_X], false); + transXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); + transVis->AddChild(transXVis); + + // trans y + VisualPtr transYVis = this->Scene()->CreateVisual(); + VisualPtr transShaftYVis = this->Scene()->CreateVisual(); + transShaftYVis->AddGeometry(this->Scene()->CreateCylinder()); + transShaftYVis->SetOrigin(0, 0, 0.5); + transShaftYVis->SetLocalPosition(0, 0, 0.5); + transShaftYVis->SetLocalScale(0.02, 0.02, 0.45); + transYVis->AddChild(transShaftYVis); + + VisualPtr transHeadYVis = this->Scene()->CreateVisual(); + transHeadYVis->AddGeometry(this->Scene()->CreateCone()); + transHeadYVis->SetOrigin(0, 0, -0.5); + transHeadYVis->SetLocalPosition(0, 0, 0.5); + transHeadYVis->SetLocalScale(0.07, 0.07, 0.2); + transYVis->AddChild(transHeadYVis); + + transYVis->SetMaterial(this->materials[AM_Y], false); + transYVis->SetLocalRotation(-IGN_PI * 0.5, 0, 0); + transVis->AddChild(transYVis); + + // trans z + VisualPtr transZVis = this->Scene()->CreateVisual(); + VisualPtr transShaftZVis = this->Scene()->CreateVisual(); + transShaftZVis->AddGeometry(this->Scene()->CreateCylinder()); + transShaftZVis->SetOrigin(0, 0, 0.5); + transShaftZVis->SetLocalPosition(0, 0, 0.5); + transShaftZVis->SetLocalScale(0.02, 0.02, 0.45); + transZVis->AddChild(transShaftZVis); + + VisualPtr transHeadZVis = this->Scene()->CreateVisual(); + transHeadZVis->AddGeometry(this->Scene()->CreateCone()); + transHeadZVis->SetOrigin(0, 0, -0.5); + transHeadZVis->SetLocalPosition(0, 0, 0.5); + transHeadZVis->SetLocalScale(0.07, 0.07, 0.2); + transZVis->AddChild(transHeadZVis); + + transZVis->SetMaterial(this->materials[AM_Z], false); + transVis->AddChild(transZVis); + + // trans origin + VisualPtr transOrigin = this->Scene()->CreateVisual(); + transOrigin->AddGeometry(this->Scene()->CreateSphere()); + transOrigin->SetLocalScale(0.05, 0.05, 0.05); + transOrigin->SetMaterial(this->materials[AM_O], false); + transVis->AddChild(transOrigin); + + this->visuals[TransformAxis::TA_TRANSLATION_X] = transXVis; + this->visuals[TransformAxis::TA_TRANSLATION_Y] = transYVis; + this->visuals[TransformAxis::TA_TRANSLATION_Z] = transZVis; + this->visuals[TransformAxis::TA_TRANSLATION_Z << 1] = transOrigin; + + // translation handles + VisualPtr transHandleXVis = this->Scene()->CreateVisual(); + transHandleXVis->AddGeometry(this->Scene()->CreateCylinder()); + transHandleXVis->SetLocalPosition(0, 0, 0.35); + transHandleXVis->SetLocalScale(0.11, 0.11, 0.7); + transHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); + transXVis->AddChild(transHandleXVis); + + VisualPtr transHandleYVis = this->Scene()->CreateVisual(); + transHandleYVis->AddGeometry(this->Scene()->CreateCylinder()); + transHandleYVis->SetLocalPosition(0, 0, 0.35); + transHandleYVis->SetLocalScale(0.11, 0.11, 0.7); + transHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); + transYVis->AddChild(transHandleYVis); + + VisualPtr transHandleZVis = this->Scene()->CreateVisual(); + transHandleZVis->AddGeometry(this->Scene()->CreateCylinder()); + transHandleZVis->SetLocalPosition(0, 0, 0.35); + transHandleZVis->SetLocalScale(0.11, 0.11, 0.7); + transHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); + transZVis->AddChild(transHandleZVis); + + this->handles[TransformAxis::TA_TRANSLATION_X] = transHandleXVis; + this->handles[TransformAxis::TA_TRANSLATION_Y] = transHandleYVis; + this->handles[TransformAxis::TA_TRANSLATION_Z] = transHandleZVis; + + this->AddChild(transVis); + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::CreateRotationVisual() + { + common::MeshManager *meshMgr = common::MeshManager::Instance(); + std::string rotMeshName = "gizmo_rotate"; + if (!meshMgr->HasMesh(rotMeshName)) + meshMgr->CreateTube(rotMeshName, 1.0f, 1.02f, 0.02f, 1, 64, IGN_PI); + + std::string rotFullMeshName = "gizmo_rotate_full"; + if (!meshMgr->HasMesh(rotFullMeshName)) + { + meshMgr->CreateTube(rotFullMeshName, 1.0f, 1.02f, 0.02f, 1, 64, + 2 * IGN_PI); + } + + std::string rotHandleMeshName = "gizmo_rotate_handle"; + if (!meshMgr->HasMesh(rotHandleMeshName)) + { + meshMgr->CreateTube(rotHandleMeshName, 0.95f, 1.07f, 0.1f, 1, 64, + IGN_PI); + } + + VisualPtr rotVis = this->Scene()->CreateVisual(); + + // rotation x + VisualPtr rotXVis = this->Scene()->CreateVisual(); + rotXVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); + rotXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); + rotXVis->SetLocalScale(0.5, 0.5, 0.5); + rotXVis->SetMaterial(this->materials[AM_X], false); + rotVis->AddChild(rotXVis); + + // rotation y + VisualPtr rotYVis = this->Scene()->CreateVisual(); + rotYVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); + rotYVis->SetLocalRotation(IGN_PI * 0.5, 0, 0); + rotYVis->SetLocalScale(0.5, 0.5, 0.5); + rotYVis->SetMaterial(this->materials[AM_Y], false); + rotVis->AddChild(rotYVis); + + // rotation z + VisualPtr rotZVis = this->Scene()->CreateVisual(); + rotZVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); + rotZVis->SetLocalScale(0.5, 0.5, 0.5); + rotZVis->SetMaterial(this->materials[AM_Z], false); + rotVis->AddChild(rotZVis); + + // rotation origin + VisualPtr rotFullVis = this->Scene()->CreateVisual(); + rotFullVis->AddGeometry(this->Scene()->CreateMesh(rotFullMeshName)); + rotFullVis->SetLocalScale(0.5, 0.5, 0.5); + rotFullVis->SetMaterial(this->materials[AM_O], false); + rotVis->AddChild(rotFullVis); + + this->visuals[TransformAxis::TA_ROTATION_X] = rotXVis; + this->visuals[TransformAxis::TA_ROTATION_Y] = rotYVis; + this->visuals[TransformAxis::TA_ROTATION_Z] = rotZVis; + this->visuals[TransformAxis::TA_ROTATION_Z << 1] = rotFullVis; + + // rotation handles + VisualPtr rotHandleXVis = this->Scene()->CreateVisual(); + rotHandleXVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); + rotHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); + rotXVis->AddChild(rotHandleXVis); + + VisualPtr rotHandleYVis = this->Scene()->CreateVisual(); + rotHandleYVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); + rotHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); + rotYVis->AddChild(rotHandleYVis); + + VisualPtr rotHandleZVis = this->Scene()->CreateVisual(); + rotHandleZVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); + rotHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); + rotZVis->AddChild(rotHandleZVis); + + this->handles[TransformAxis::TA_ROTATION_X] = rotHandleXVis; + this->handles[TransformAxis::TA_ROTATION_Y] = rotHandleYVis; + this->handles[TransformAxis::TA_ROTATION_Z] = rotHandleZVis; + + this->AddChild(rotVis); + } + + ////////////////////////////////////////////////// + template + void BaseGizmoVisual::CreateScaleVisual() + { + VisualPtr scaleVis = this->Scene()->CreateVisual(); + + // scale x + VisualPtr scaleXVis = this->Scene()->CreateVisual(); + VisualPtr scaleShaftXVis = this->Scene()->CreateVisual(); + scaleShaftXVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleShaftXVis->SetOrigin(0, 0, 0.5); + scaleShaftXVis->SetLocalPosition(0, 0, 0.5); + scaleShaftXVis->SetLocalScale(0.02, 0.02, 0.5); + scaleXVis->AddChild(scaleShaftXVis); + + VisualPtr scaleHeadXVis = this->Scene()->CreateVisual(); + scaleHeadXVis->AddGeometry(this->Scene()->CreateBox()); + scaleHeadXVis->SetOrigin(0, 0, -0.5); + scaleHeadXVis->SetLocalPosition(0, 0, 0.5); + scaleHeadXVis->SetLocalScale(0.07, 0.07, 0.07); + scaleXVis->AddChild(scaleHeadXVis); + + scaleXVis->SetMaterial(this->materials[AM_X], false); + scaleXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); + scaleVis->AddChild(scaleXVis); + + // scale y + VisualPtr scaleYVis = this->Scene()->CreateVisual(); + VisualPtr scaleShaftYVis = this->Scene()->CreateVisual(); + scaleShaftYVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleShaftYVis->SetOrigin(0, 0, 0.5); + scaleShaftYVis->SetLocalPosition(0, 0, 0.5); + scaleShaftYVis->SetLocalScale(0.02, 0.02, 0.5); + scaleYVis->AddChild(scaleShaftYVis); + + VisualPtr scaleHeadYVis = this->Scene()->CreateVisual(); + scaleHeadYVis->AddGeometry(this->Scene()->CreateBox()); + scaleHeadYVis->SetOrigin(0, 0, -0.5); + scaleHeadYVis->SetLocalPosition(0, 0, 0.5); + scaleHeadYVis->SetLocalScale(0.07, 0.07, 0.07); + scaleYVis->AddChild(scaleHeadYVis); + + scaleYVis->SetMaterial(this->materials[AM_Y], false); + scaleYVis->SetLocalRotation(-IGN_PI * 0.5, 0, 0); + scaleVis->AddChild(scaleYVis); + + // scale z + VisualPtr scaleZVis = this->Scene()->CreateVisual(); + VisualPtr scaleShaftZVis = this->Scene()->CreateVisual(); + scaleShaftZVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleShaftZVis->SetOrigin(0, 0, 0.5); + scaleShaftZVis->SetLocalPosition(0, 0, 0.5); + scaleShaftZVis->SetLocalScale(0.02, 0.02, 0.5); + scaleZVis->AddChild(scaleShaftZVis); + + VisualPtr scaleHeadZVis = this->Scene()->CreateVisual(); + scaleHeadZVis->AddGeometry(this->Scene()->CreateBox()); + scaleHeadZVis->SetOrigin(0, 0, -0.5); + scaleHeadZVis->SetLocalPosition(0, 0, 0.5); + scaleHeadZVis->SetLocalScale(0.07, 0.07, 0.07); + scaleZVis->AddChild(scaleHeadZVis); + + scaleZVis->SetMaterial(this->materials[AM_Z], false); + scaleVis->AddChild(scaleZVis); + + this->visuals[TransformAxis::TA_SCALE_X] = scaleXVis; + this->visuals[TransformAxis::TA_SCALE_Y] = scaleYVis; + this->visuals[TransformAxis::TA_SCALE_Z] = scaleZVis; + + // scale handles + VisualPtr scaleHandleXVis = this->Scene()->CreateVisual(); + scaleHandleXVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleHandleXVis->SetLocalPosition(0, 0, 0.285); + scaleHandleXVis->SetLocalScale(0.11, 0.11, 0.57); + scaleHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); + scaleXVis->AddChild(scaleHandleXVis); + + VisualPtr scaleHandleYVis = this->Scene()->CreateVisual(); + scaleHandleYVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleHandleYVis->SetLocalPosition(0, 0, 0.285); + scaleHandleYVis->SetLocalScale(0.11, 0.11, 0.57); + scaleHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); + scaleYVis->AddChild(scaleHandleYVis); + + VisualPtr scaleHandleZVis = this->Scene()->CreateVisual(); + scaleHandleZVis->AddGeometry(this->Scene()->CreateCylinder()); + scaleHandleZVis->SetLocalPosition(0, 0, 0.285); + scaleHandleZVis->SetLocalScale(0.11, 0.11, 0.57); + scaleHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); + scaleZVis->AddChild(scaleHandleZVis); + + this->handles[TransformAxis::TA_SCALE_X] = scaleHandleXVis; + this->handles[TransformAxis::TA_SCALE_Y] = scaleHandleYVis; + this->handles[TransformAxis::TA_SCALE_Z] = scaleHandleZVis; + + this->AddChild(scaleVis); + } + + ////////////////////////////////////////////////// + template + VisualPtr BaseGizmoVisual::ChildByAxis(unsigned int _axis) const + { + auto it = this->visuals.find(_axis); + if (it != this->visuals.end()) + return it->second; + + return VisualPtr(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseGpuRays.hh b/include/gz/rendering/base/BaseGpuRays.hh new file mode 100644 index 000000000..54f84e8d5 --- /dev/null +++ b/include/gz/rendering/base/BaseGpuRays.hh @@ -0,0 +1,412 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEGPURAYS_HH_ +#define GZ_RENDERING_BASE_BASEGPURAYS_HH_ + +#include + +#include +#include + +#include "gz/rendering/GpuRays.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/base/BaseRenderTarget.hh" +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/Visual.hh" +#include "gz/rendering/RenderTypes.hh" + + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseGpuRays : + public virtual GpuRays, + public virtual BaseCamera, + public virtual T + { + /// \brief Constructor + protected: BaseGpuRays(); + + /// \brief Destructor + public: virtual ~BaseGpuRays(); + + // Documentation inherited. + public: virtual const float *Data() const override; + + // Documentation inherited. + public: virtual void Copy(float *_data) override; + + // Documentation inherited. + public: virtual void SetClamp(bool _enable) override; + + // Documentation inherited. + public: virtual bool Clamp() const override; + + // Documentation inherited. + public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( + std::function _subscriber) override; + + /// \brief Pointer to the render target + public: virtual RenderTargetPtr RenderTarget() const override = 0; + + // Documentation inherited. + public: virtual void SetIsHorizontal(const bool _horizontal) override; + + // Documentation inherited. + public: virtual bool IsHorizontal() const override; + + /// \brief Set the vertical fov + /// \param[in] _vfov vertical fov + public: virtual void SetVFOV(const math::Angle &_vfov); + + // Documentation inherited. + public: virtual math::Angle VFOV() const override; + + // Documentation inherited. + public: virtual double RayCountRatio() const override; + + // Documentation inherited. + public: virtual double RangeCountRatio() const override; + + // Documentation inherited. + public: virtual void SetRayCountRatio( + const double _rayCountRatio) override; + + // Documentation inherited. + public: virtual gz::math::Angle AngleMin() const override; + + // Documentation inherited. + public: virtual void SetAngleMin(double _angle) override; + + // Documentation inherited. + public: virtual gz::math::Angle AngleMax() const override; + + // Documentation inherited. + public: virtual void SetAngleMax(double _angle) override; + + // Documentation inherited. + public: virtual void SetVerticalRayCount(int _samples) override; + + // Documentation inherited. + public: virtual void SetRayCount(int _samples) override; + + // Documentation inherited. + public: virtual int RayCount() const override; + + // Documentation inherited. + public: virtual int RangeCount() const override; + + // Documentation inherited. + public: virtual int VerticalRayCount() const override; + + // Documentation inherited. + public: virtual int VerticalRangeCount() const override; + + // Documentation inherited. + public: virtual gz::math::Angle VerticalAngleMin() const override; + + // Documentation inherited. + public: virtual void SetVerticalAngleMin(const double _angle) override; + + // Documentation inherited. + public: virtual gz::math::Angle VerticalAngleMax() const override; + + // Documentation inherited. + public: virtual void SetVerticalAngleMax(const double _angle) override; + + // Documentation inherited. + public: virtual unsigned int Channels() const override; + + /// \brief maximum value used for data outside sensor range + public: float dataMaxVal = gz::math::INF_D; + + /// \brief minimum value used for data outside sensor range + public: float dataMinVal = -gz::math::INF_D; + + /// \brief True if data values are clamped to camera clip distances, + // false if data outside of camera range is +/- inf + public: bool clamping = false; + + /// \brief Ray count ratio. + protected: double rayCountRatio = 0; + + /// \brief Range count ratio. + protected: double rangeCountRatio = 0; + + /// \brief Vertical field-of-view. + protected: math::Angle vfov; + + /// \brief True if the sensor is horizontal only. + protected: bool isHorizontal = true; + + /// \brief Horizontal minimal angle + protected: double minAngle = 0; + + /// \brief Horizontal maximal angle + protected: double maxAngle = 0; + + /// \brief Vertical minimal angle + protected: double vMinAngle = 0; + + /// \brief Vertical maximal angle + protected: double vMaxAngle = 0; + + /// \brief Quantity of horizontal rays + protected: int hSamples = 0; + + /// \brief Quantity of verical rays + protected: int vSamples = 0; + + /// \brief Resolution of horizontal rays + protected: int hResolution = 1; + + /// \brief Resolution of vertical rays + protected: int vResolution = 1; + + /// \brief Number of channels used to store the data + protected: unsigned int channels = 1u; + + private: friend class OgreScene; + }; + + ////////////////////////////////////////////////// + template + BaseGpuRays::BaseGpuRays() + { + } + + ////////////////////////////////////////////////// + template + BaseGpuRays::~BaseGpuRays() + { + } + + ////////////////////////////////////////////////// + template + const float *BaseGpuRays::Data() const + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + void BaseGpuRays::Copy(float *_dataDest) + { + // Unused + (void)_dataDest; + } + + ////////////////////////////////////////////////// + template + void BaseGpuRays::SetClamp(bool _enable) + { + this->clamping = _enable; + + if (this->clamping) + { + this->dataMinVal = this->NearClipPlane(); + this->dataMaxVal = this->FarClipPlane(); + } + else + { + this->dataMinVal = -gz::math::INF_D; + this->dataMaxVal = gz::math::INF_D; + } + } + + ////////////////////////////////////////////////// + template + bool BaseGpuRays::Clamp() const + + { + return this->clamping; + } + + ////////////////////////////////////////////////// + template + gz::common::ConnectionPtr BaseGpuRays::ConnectNewGpuRaysFrame( + std::function) + { + return nullptr; + } + + ////////////////////////////////////////////////// + template + void BaseGpuRays::SetIsHorizontal(const bool _horizontal) + { + this->isHorizontal = _horizontal; + } + + ////////////////////////////////////////////////// + template + bool BaseGpuRays::IsHorizontal() const + { + return this->isHorizontal; + } + + ////////////////////////////////////////////////// + template + double BaseGpuRays::RayCountRatio() const + { + return this->rayCountRatio; + } + + ////////////////////////////////////////////////// + template + void BaseGpuRays::SetRayCountRatio(const double _rayCountRatio) + { + this->rayCountRatio = _rayCountRatio; + } + + ////////////////////////////////////////////////// + template + double BaseGpuRays::RangeCountRatio() const + { + return this->rangeCountRatio; + } + + ////////////////////////////////////////////////// + template + math::Angle BaseGpuRays::VFOV() const + { + return this->vfov; + } + + ////////////////////////////////////////////////// + template + void BaseGpuRays::SetVFOV(const math::Angle &_vfov) + { + this->vfov = _vfov; + } + + template + ////////////////////////////////////////////////// + gz::math::Angle BaseGpuRays::AngleMin() const + { + return this->minAngle; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetAngleMin(double _angle) + { + this->minAngle = _angle; + } + + template + ////////////////////////////////////////////////// + gz::math::Angle BaseGpuRays::AngleMax() const + { + return this->maxAngle; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetAngleMax(double _angle) + { + this->maxAngle = _angle; + } + + template + ////////////////////////////////////////////////// + int BaseGpuRays::RayCount() const + { + return this->hSamples; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetRayCount(int _samples) + { + this->hSamples = _samples; + } + + template + ////////////////////////////////////////////////// + int BaseGpuRays::RangeCount() const + { + return 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 this->VerticalRayCount() * this->vResolution; + } + + template + ////////////////////////////////////////////////// + gz::math::Angle BaseGpuRays::VerticalAngleMin() const + { + return this->vMinAngle; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetVerticalAngleMin(const double _angle) + { + this->vMinAngle = _angle; + } + + template + ////////////////////////////////////////////////// + gz::math::Angle BaseGpuRays::VerticalAngleMax() const + { + return this->vMaxAngle; + } + + template + ////////////////////////////////////////////////// + void BaseGpuRays::SetVerticalAngleMax(const double _angle) + { + this->vMaxAngle = _angle; + } + + template + ////////////////////////////////////////////////// + unsigned int BaseGpuRays::Channels() const + { + return this->channels; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseGrid.hh b/include/gz/rendering/base/BaseGrid.hh new file mode 100644 index 000000000..899f703ff --- /dev/null +++ b/include/gz/rendering/base/BaseGrid.hh @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEGRID_HH_ +#define GZ_RENDERING_BASE_BASEGRID_HH_ + +#include +#include "gz/rendering/Grid.hh" +#include "gz/rendering/base/BaseObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of a grid geometry + template + class BaseGrid : + public virtual Grid, + public virtual T + { + /// \brief Constructor + protected: BaseGrid(); + + /// \brief Destructor + public: virtual ~BaseGrid(); + + // Documentation inherited. + public: virtual void PreRender(); + + // Documentation inherited. + public: virtual void Destroy(); + + // Documentation inherited. + public: virtual unsigned int CellCount() const; + + // Documentation inherited. + public: virtual void SetCellCount(const unsigned int _count); + + // Documentation inherited. + public: virtual double CellLength() const; + + // Documentation inherited. + public: virtual void SetCellLength(const double _len); + + // Documentation inherited. + public: virtual unsigned int VerticalCellCount() const; + + // Documentation inherited. + public: virtual void SetVerticalCellCount(const unsigned int _count); + + /// \brief Number of cells in grid + protected: unsigned int cellCount = 10u; + + /// \brief Length of a single cell + protected: double cellLength = 1.0; + + /// \brief Number of cells in vertical direction + protected: unsigned int verticalCellCount = 0; + + /// \brief vertical offset of the XY plane from origin + protected: double heightOffset = 0.0; + + /// \brief Flag to indicate grid properties have changed + protected: bool gridDirty = false; + }; + + ////////////////////////////////////////////////// + // BaseGrid + ////////////////////////////////////////////////// + template + BaseGrid::BaseGrid() + { + } + + ////////////////////////////////////////////////// + template + BaseGrid::~BaseGrid() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseGrid::CellCount() const + { + return this->cellCount; + } + + ////////////////////////////////////////////////// + template + void BaseGrid::SetCellCount(const unsigned int _count) + { + this->cellCount = _count; + this->gridDirty = true; + } + + ////////////////////////////////////////////////// + template + double BaseGrid::CellLength() const + { + return this->cellLength; + } + + ////////////////////////////////////////////////// + template + void BaseGrid::SetCellLength(const double _len) + { + this->cellLength = _len; + this->gridDirty = true; + } + + ////////////////////////////////////////////////// + template + unsigned int BaseGrid::VerticalCellCount() const + { + return this->verticalCellCount; + } + + ////////////////////////////////////////////////// + template + void BaseGrid::SetVerticalCellCount(const unsigned int _count) + { + this->verticalCellCount = _count; + this->gridDirty = true; + } + + ////////////////////////////////////////////////// + template + void BaseGrid::PreRender() + { + T::PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseGrid::Destroy() + { + T::Destroy(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseLight.hh b/include/gz/rendering/base/BaseLight.hh new file mode 100644 index 000000000..6993fb235 --- /dev/null +++ b/include/gz/rendering/base/BaseLight.hh @@ -0,0 +1,248 @@ +/* + * 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); + } + + ////////////////////////////////////////////////// + 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/BaseMarker.hh b/include/gz/rendering/base/BaseMarker.hh new file mode 100644 index 000000000..3ecd3ab54 --- /dev/null +++ b/include/gz/rendering/base/BaseMarker.hh @@ -0,0 +1,209 @@ +/* + * 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 SetLayer(int32_t _layer) override; + + // Documentation inherited + public: virtual int32_t Layer() const override; + + // Documentation inherited + public: virtual void ClearPoints() override; + + // Documentation inherited + public: virtual void AddPoint(double _x, + double _y, double _z, + const gz::math::Color &_color) override; + + // Documentation inherited + public: virtual void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color) override; + + // Documentation inherited + public: virtual void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value) override; + + /// \brief Life time of a marker + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: std::chrono::steady_clock::duration lifetime = + std::chrono::steady_clock::duration::zero(); + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Layer at which the marker will reside + protected: int32_t layer = 0; + + /// \brief Flag to indicate if marker needs to be updated + protected: bool markerDirty = false; + + /// \brief Marker type + protected: MarkerType markerType = + gz::rendering::MarkerType::MT_NONE; + }; + + ///////////////////////////////////////////////// + // 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::PreRender() + { + T::PreRender(); + } + + ///////////////////////////////////////////////// + template + void BaseMarker::Destroy() + { + T::Destroy(); + } + + ///////////////////////////////////////////////// + template + void BaseMarker::ClearPoints() + { + // no op + } + + ///////////////////////////////////////////////// + template + void BaseMarker::AddPoint(const gz::math::Vector3d &, + const gz::math::Color &) + { + // no op + } + + ///////////////////////////////////////////////// + template + void BaseMarker::AddPoint(double _x, double _y, double _z, + const gz::math::Color &_color) + { + this->AddPoint(gz::math::Vector3d(_x, _y, _z), _color); + } + + ///////////////////////////////////////////////// + template + void BaseMarker::SetPoint(unsigned int, + const gz::math::Vector3d &) + { + // no op + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseMaterial.hh b/include/gz/rendering/base/BaseMaterial.hh new file mode 100644 index 000000000..a7213c21b --- /dev/null +++ b/include/gz/rendering/base/BaseMaterial.hh @@ -0,0 +1,926 @@ +/* + * 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 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 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 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::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 + 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 + 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 + 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->SetShininess(_material->Shininess()); + 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->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()); + // 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()); + } + + ////////////////////////////////////////////////// + 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->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->SetRoughness(kDefaultPbr.Roughness()); + this->SetMetalness(kDefaultPbr.Metalness()); + this->SetShaderType(ST_PIXEL); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseMesh.hh b/include/gz/rendering/base/BaseMesh.hh new file mode 100644 index 000000000..7ae3304a4 --- /dev/null +++ b/include/gz/rendering/base/BaseMesh.hh @@ -0,0 +1,337 @@ +/* + * 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 "gz/rendering/Mesh.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; + + 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 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; + }; + + ////////////////////////////////////////////////// + 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 + 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 + void BaseMesh::Destroy() + { + T::Destroy(); + this->SubMeshes()->DestroyAll(); + if (this->material && this->ownsMaterial) + this->Scene()->DestroyMaterial(this->material); + this->material.reset(); + } + + ////////////////////////////////////////////////// + // BaseSubMesh + ////////////////////////////////////////////////// + template + BaseSubMesh::BaseSubMesh() + { + } + + ////////////////////////////////////////////////// + template + BaseSubMesh::~BaseSubMesh() + { + } + + ////////////////////////////////////////////////// + template + void BaseSubMesh::Destroy() + { + T::Destroy(); + if (this->material && this->ownsMaterial) + this->Scene()->DestroyMaterial(this->material); + this->material.reset(); + } + + + ////////////////////////////////////////////////// + template + void BaseSubMesh::SetMaterial(const std::string &_name, bool _unique) + { + MaterialPtr mat = this->Scene()->Material(_name); + if (mat) this->SetMaterial(mat, _unique); + } + + ////////////////////////////////////////////////// + template + void BaseSubMesh::SetMaterial(MaterialPtr _material, bool _unique) + { + _material = (_unique) ? _material->Clone() : _material; + + MaterialPtr origMaterial = this->material; + bool origUnique = this->ownsMaterial; + + this->SetMaterialImpl(_material); + + if (origMaterial && origUnique) + this->Scene()->DestroyMaterial(origMaterial); + + this->material = _material; + this->ownsMaterial = _unique; + } + + ////////////////////////////////////////////////// + template + MaterialPtr BaseSubMesh::Material() const + { + return this->material; + } + + ////////////////////////////////////////////////// + template + void BaseSubMesh::PreRender() + { + T::PreRender(); + if (this->Material()) + this->Material()->PreRender(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseNode.hh b/include/gz/rendering/base/BaseNode.hh new file mode 100644 index 000000000..8309d7b3d --- /dev/null +++ b/include/gz/rendering/base/BaseNode.hh @@ -0,0 +1,636 @@ +/* + * 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 "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; + + 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; + + 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; + }; + + ////////////////////////////////////////////////// + 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; + } + + this->SetRawLocalPose(pose); + } + + ////////////////////////////////////////////////// + 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 pose + parent->WorldPose(); + } + + ////////////////////////////////////////////////// + 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); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseObject.hh b/include/gz/rendering/base/BaseObject.hh new file mode 100644 index 000000000..65f61c9d5 --- /dev/null +++ b/include/gz/rendering/base/BaseObject.hh @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASEOBJECT_HH_ +#define GZ_RENDERING_BASE_BASEOBJECT_HH_ + +#include +#include +#include +#include "gz/rendering/Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_VISIBLE BaseObject : + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public virtual std::enable_shared_from_this, + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + public virtual Object + { + protected: BaseObject(); + + public: virtual ~BaseObject(); + + public: virtual unsigned int Id() const override; + + public: virtual std::string Name() const override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void PostRender() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // TODO(anyone): make pure virtual + protected: virtual void Load(); + + // TODO(anyone): make pure virtual + protected: virtual void Init(); + + protected: unsigned int id; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: std::string name; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseRayQuery.hh b/include/gz/rendering/base/BaseRayQuery.hh new file mode 100644 index 000000000..7648b8d48 --- /dev/null +++ b/include/gz/rendering/base/BaseRayQuery.hh @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASERAYQUERY_HH_ +#define GZ_RENDERING_BASE_BASERAYQUERY_HH_ + +#include +#include + +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/Scene.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \class BaseRayQuery BaseRayQuery.hh + /// ignition/rendering/base/BaseRayQuery.hh + /// \brief A Ray Query class used for computing ray object intersections + template + class BaseRayQuery : + public virtual RayQuery, + public T + { + /// \brief Constructor + protected: BaseRayQuery(); + + /// \brief Destructor + public: virtual ~BaseRayQuery() override; + + // Documentation inherited + public: virtual void SetOrigin(const math::Vector3d &_origin) override; + + // Documentation inherited + public: virtual math::Vector3d Origin() const override; + + // Documentation inherited + public: virtual void SetDirection(const math::Vector3d &_dir) override; + + // Documentation inherited + public: virtual math::Vector3d Direction() const override; + + // Documentation inherited + public: virtual void SetFromCamera(const CameraPtr &_camera, + const math::Vector2d &_coord) override; + + // Documentation inherited + public: virtual RayQueryResult ClosestPoint() override; + + /// \brief Ray origin + protected: math::Vector3d origin; + + /// \brief Ray direction + protected: math::Vector3d direction; + }; + + ////////////////////////////////////////////////// + template + BaseRayQuery::BaseRayQuery() + { + } + + ////////////////////////////////////////////////// + template + BaseRayQuery::~BaseRayQuery() + { + } + + ////////////////////////////////////////////////// + template + void BaseRayQuery::SetOrigin(const math::Vector3d &_origin) + { + this->origin = _origin; + } + + ////////////////////////////////////////////////// + template + gz::math::Vector3d BaseRayQuery::Origin() const + { + return this->origin; + } + + ////////////////////////////////////////////////// + template + void BaseRayQuery::SetDirection(const math::Vector3d &_dir) + { + this->direction = _dir; + } + + ////////////////////////////////////////////////// + template + gz::math::Vector3d BaseRayQuery::Direction() const + { + return this->direction; + } + + ////////////////////////////////////////////////// + template + void BaseRayQuery::SetFromCamera(const CameraPtr &_camera, + const gz::math::Vector2d &_coord) + { + math::Matrix4d projectionMatrix = _camera->ProjectionMatrix(); + math::Matrix4d viewMatrix = _camera->ViewMatrix(); + math::Vector3d start(_coord.X(), _coord.Y(), -1.0); + math::Vector3d end(_coord.X(), _coord.Y(), 0.0); + math::Matrix4d viewProjInv = (projectionMatrix * viewMatrix).Inverse(); + + // rotate start and end + // ign math does not support matrix4 * vec4 + // so calc homogeneous coordinate w ourselves + double startw = viewProjInv(3, 0) * start[0] + + viewProjInv(3, 1) * start[1] + + viewProjInv(3, 2) * start[2] + viewProjInv(3, 3); + double endw = viewProjInv(3, 0) * end[0] + + viewProjInv(3, 1) * end[1] + + viewProjInv(3, 2) * end[2] + viewProjInv(3, 3); + start = viewProjInv * start; + end = viewProjInv * end; + // normalize + start = start / startw; + end = end / endw; + math::Vector3d dir = (end - start).Normalize(); + + this->origin = start; + this->direction = dir; + } + + ////////////////////////////////////////////////// + template + RayQueryResult BaseRayQuery::ClosestPoint() + { + // TODO(anyone): implement a generic ray query here? + RayQueryResult result; + result.distance = -1; + return result; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseRenderEngine.hh b/include/gz/rendering/base/BaseRenderEngine.hh new file mode 100644 index 000000000..e3aa072c0 --- /dev/null +++ b/include/gz/rendering/base/BaseRenderEngine.hh @@ -0,0 +1,128 @@ +/* + * 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 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: unsigned int nextSceneId; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + /// \brief a list of paths that render engines use to locate their + /// resources + protected: std::vector resourcePaths; + + /// \brief Render pass system for this render engine. + protected: RenderPassSystemPtr renderPassSystem; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseRenderPass.hh b/include/gz/rendering/base/BaseRenderPass.hh new file mode 100644 index 000000000..d380f67e1 --- /dev/null +++ b/include/gz/rendering/base/BaseRenderPass.hh @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASERENDERPASS_HH_ +#define GZ_RENDERING_BASE_BASERENDERPASS_HH_ + +#include +#include "gz/rendering/RenderPass.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class BaseRenderPass BaseRenderPass.hh \ + * ignition/rendering/base/BaseRenderPass.hh + */ + /// \brief Base render pass that can be applied to a render target + template + class BaseRenderPass: + public virtual RenderPass, + public T + { + /// \brief Constructor + protected: BaseRenderPass(); + + /// \brief Destructor + public: virtual ~BaseRenderPass(); + + // Documentation inherited + public: virtual void SetEnabled(bool _enabled) override; + + // Documentation inherited + public: virtual bool IsEnabled() const override; + + /// \brief Flag to indicate if render pass is enabled or not + protected: bool enabled = true; + }; + + ////////////////////////////////////////////////// + // BaseRenderPass + ////////////////////////////////////////////////// + template + BaseRenderPass::BaseRenderPass() + { + } + + ////////////////////////////////////////////////// + template + BaseRenderPass::~BaseRenderPass() + { + } + + ////////////////////////////////////////////////// + template + void BaseRenderPass::SetEnabled(bool _enabled) + { + this->enabled = _enabled; + } + + ////////////////////////////////////////////////// + template + bool BaseRenderPass::IsEnabled() const + { + return this->enabled; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseRenderTarget.hh b/include/gz/rendering/base/BaseRenderTarget.hh new file mode 100644 index 000000000..adaf34869 --- /dev/null +++ b/include/gz/rendering/base/BaseRenderTarget.hh @@ -0,0 +1,357 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASERENDERTARGET_HH_ +#define GZ_RENDERING_BASE_BASERENDERTARGET_HH_ + +#include +#include + +#include "gz/rendering/RenderPass.hh" +#include "gz/rendering/RenderTarget.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template + class BaseRenderTarget : + public virtual RenderTarget, + public virtual T + { + public: BaseRenderTarget(); + + public: virtual ~BaseRenderTarget(); + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void PostRender() override; + + public: virtual unsigned int Width() const override; + + public: virtual void SetWidth(const unsigned int _width) override; + + public: virtual unsigned int Height() const override; + + public: virtual void SetHeight(const unsigned int _height) override; + + public: virtual PixelFormat Format() const override; + + public: virtual void SetFormat(PixelFormat _format) override; + + // Documentation inherited + public: virtual math::Color BackgroundColor() const override; + + // Documentation inherited + public: virtual void AddRenderPass(const RenderPassPtr &_pass) override; + + // Documentation inherited + public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) + override; + + // Documentation inherited + public: virtual unsigned int RenderPassCount() const override; + + // Documentation inherited + public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) + const override; + + protected: virtual void Rebuild(); + + protected: virtual void RebuildImpl() = 0; + + protected: PixelFormat format = PF_UNKNOWN; + + protected: bool targetDirty = true; + + /// \brief Flag to indicate if render pass need to be rebuilt + protected: bool renderPassDirty = false; + + protected: unsigned int width = 0u; + + protected: unsigned int height = 0u; + + /// \brief A chain of render passes applied to the render target + protected: std::vector renderPasses; + }; + + template + class BaseRenderTexture : + public virtual RenderTexture, + public virtual T + { + public: BaseRenderTexture(); + + public: virtual ~BaseRenderTexture(); + + // Documentation inherited. + public: virtual unsigned int GLId() const override; + }; + + template + class BaseRenderWindow : + public virtual RenderWindow, + public virtual T + { + public: BaseRenderWindow(); + + public: virtual ~BaseRenderWindow(); + + public: virtual std::string Handle() const; + + public: virtual void SetHandle(const std::string &_handle); + + public: virtual double DevicePixelRatio() const; + + public: virtual void SetDevicePixelRatio(const double _ratio); + + public: virtual void OnResize(const unsigned int _width, + const unsigned int _height); + + public: virtual void OnMove(); + + protected: std::string handle; + + protected: double ratio = 1.0; + }; + + ////////////////////////////////////////////////// + // BaseRenderTarget + ////////////////////////////////////////////////// + template + BaseRenderTarget::BaseRenderTarget() + { + } + + ////////////////////////////////////////////////// + template + BaseRenderTarget::~BaseRenderTarget() + { + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::PreRender() + { + T::PreRender(); + this->Rebuild(); + for (auto &pass : this->renderPasses) + pass->PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::PostRender() + { + T::PostRender(); + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::Rebuild() + { + if (this->targetDirty) + { + this->RebuildImpl(); + this->targetDirty = false; + } + } + + ////////////////////////////////////////////////// + template + unsigned int BaseRenderTarget::Width() const + { + return this->width; + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::SetWidth(const unsigned int _width) + { + this->width = _width; + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + unsigned int BaseRenderTarget::Height() const + { + return this->height; + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::SetHeight(const unsigned int _height) + { + this->height = _height; + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + PixelFormat BaseRenderTarget::Format() const + { + return this->format; + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::SetFormat(PixelFormat _format) + { + this->format = PixelUtil::Sanitize(_format); + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + math::Color BaseRenderTarget::BackgroundColor() const + { + return this->Scene()->BackgroundColor(); + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::AddRenderPass(const RenderPassPtr &_pass) + { + this->renderPasses.push_back(_pass); + this->renderPassDirty = true; + } + + ////////////////////////////////////////////////// + template + void BaseRenderTarget::RemoveRenderPass(const RenderPassPtr &_pass) + { + auto it = std::find(this->renderPasses.begin(), this->renderPasses.end(), + _pass); + if (it != this->renderPasses.end()) + { + (*it)->Destroy(); + this->renderPasses.erase(it); + this->renderPassDirty = true; + } + } + + ////////////////////////////////////////////////// + template + unsigned int BaseRenderTarget::RenderPassCount() const + { + return this->renderPasses.size(); + } + + ////////////////////////////////////////////////// + template + RenderPassPtr BaseRenderTarget::RenderPassByIndex(unsigned int _index) + const + { + if (_index > this->renderPasses.size()) + { + ignerr << "RenderPass index out of range: " << _index << std::endl; + return RenderPassPtr(); + } + return this->renderPasses[_index]; + } + + ////////////////////////////////////////////////// + // BaseRenderTexture + ////////////////////////////////////////////////// + template + BaseRenderTexture::BaseRenderTexture() + { + } + + ////////////////////////////////////////////////// + template + BaseRenderTexture::~BaseRenderTexture() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseRenderTexture::GLId() const + { + return 0u; + } + + ////////////////////////////////////////////////// + // BaseRenderWindow + ////////////////////////////////////////////////// + template + BaseRenderWindow::BaseRenderWindow() + { + } + + ////////////////////////////////////////////////// + template + BaseRenderWindow::~BaseRenderWindow() + { + } + + ////////////////////////////////////////////////// + template + std::string BaseRenderWindow::Handle() const + { + return this->handle; + } + + ////////////////////////////////////////////////// + template + void BaseRenderWindow::SetHandle(const std::string &_handle) + { + this->handle = _handle; + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + double BaseRenderWindow::DevicePixelRatio() const + { + return this->ratio; + } + + ////////////////////////////////////////////////// + template + void BaseRenderWindow::SetDevicePixelRatio(const double _ratio) + { + this->ratio = _ratio; + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + void BaseRenderWindow::OnResize(const unsigned int _width, + const unsigned int _height) + { + this->width = _width; + this->height = _height; + this->targetDirty = true; + } + + ////////////////////////////////////////////////// + template + void BaseRenderWindow::OnMove() + { + this->targetDirty = true; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseRenderTypes.hh b/include/gz/rendering/base/BaseRenderTypes.hh new file mode 100644 index 000000000..bda3c2506 --- /dev/null +++ b/include/gz/rendering/base/BaseRenderTypes.hh @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASERENDERTYPES_HH_ +#define GZ_RENDERING_BASE_BASERENDERTYPES_HH_ + +#include + +#include "gz/rendering/RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class BaseNodeCompositeStore; + typedef shared_ptr BaseNodeCompositeStorePtr; + + class BaseObject; + typedef std::shared_ptr BaseObjectPtr; + + template class BaseSceneStore; + template class BaseNodeStore; + template class BaseLightStore; + template class BaseSensorStore; + template class BaseVisualStore; + template class BaseGeometryStore; + template class BaseSubMeshStore; + template class BaseMaterialMap; + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseScene.hh b/include/gz/rendering/base/BaseScene.hh new file mode 100644 index 000000000..8e8e805ed --- /dev/null +++ b/include/gz/rendering/base/BaseScene.hh @@ -0,0 +1,596 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASESCENE_HH_ +#define GZ_RENDERING_BASE_BASESCENE_HH_ + +#include +#include +#include + +#include +#include + +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_VISIBLE BaseScene : + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public std::enable_shared_from_this, + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + public virtual Scene + { + protected: BaseScene(unsigned int _id, const std::string &_name); + + public: virtual ~BaseScene(); + + public: virtual void Load() override; + + public: virtual void Init() override; + + public: virtual void Fini() override; + + public: virtual bool IsLoaded() const; + + public: virtual bool IsInitialized() const override; + + public: virtual unsigned int Id() const override; + + public: virtual std::string Name() const override; + + public: virtual common::Time SimTime() const override; + + public: virtual void SetSimTime(const common::Time &_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; + + public: virtual unsigned int NodeCount() const override; + + public: virtual bool HasNode(ConstNodePtr _node) const override; + + public: virtual bool HasNodeId(unsigned int _id) const override; + + public: virtual bool HasNodeName(const std::string &_name) const override; + + public: virtual NodePtr NodeById(unsigned int _id) const override; + + public: virtual NodePtr NodeByName(const std::string &_name) const + override; + + public: virtual NodePtr NodeByIndex(unsigned int _index) const override; + + // Documentation inherited. + public: virtual void DestroyNode(NodePtr _node, bool _recursive = false) + override; + + public: virtual void DestroyNodeById(unsigned int _id) override; + + public: virtual void DestroyNodeByName(const std::string &_name) override; + + public: virtual void DestroyNodeByIndex(unsigned int _index) override; + + public: virtual void DestroyNodes() override; + + public: virtual unsigned int LightCount() const override; + + public: virtual bool HasLight(ConstLightPtr _light) const override; + + public: virtual bool HasLightId(unsigned int _id) const override; + + public: virtual bool HasLightName(const std::string &_name) const + override; + + public: virtual LightPtr LightById(unsigned int _id) const override; + + public: virtual LightPtr LightByName(const std::string &_name) const + override; + + public: virtual LightPtr LightByIndex(unsigned int _index) const override; + + // Documentation inherited. + public: virtual void DestroyLight(LightPtr _light, + bool _recursive = false) override; + + public: virtual void DestroyLightById(unsigned int _id) override; + + public: virtual void DestroyLightByName(const std::string &_name) + override; + + public: virtual void DestroyLightByIndex(unsigned int _index) override; + + public: virtual void DestroyLights() override; + + public: virtual unsigned int SensorCount() const override; + + public: virtual bool HasSensor(ConstSensorPtr _sensor) const override; + + public: virtual bool HasSensorId(unsigned int _id) const override; + + public: virtual bool HasSensorName(const std::string &_name) const + override; + + public: virtual SensorPtr SensorById(unsigned int _id) const override; + + public: virtual SensorPtr SensorByName(const std::string &_name) const + override; + + public: virtual SensorPtr SensorByIndex(unsigned int _index) const + override; + + // Documentation inherited. + public: virtual void DestroySensor(SensorPtr _sensor, + bool _recursive = false) override; + + public: virtual void DestroySensorById(unsigned int _id) override; + + public: virtual void DestroySensorByName(const std::string &_name) + override; + + public: virtual void DestroySensorByIndex(unsigned int _index) override; + + public: virtual void DestroySensors() override; + + public: virtual unsigned int VisualCount() const override; + + public: virtual bool HasVisual(ConstVisualPtr _visual) const override; + + public: virtual bool HasVisualId(unsigned int _id) const override; + + public: virtual bool HasVisualName(const std::string &_name) const + override; + + public: virtual VisualPtr VisualById(unsigned int _id) const override; + + public: virtual VisualPtr VisualByName(const std::string &_name) const + override; + + public: virtual VisualPtr VisualByIndex(unsigned int _index) const + override; + + // Documentation inherited + public: virtual VisualPtr VisualAt(const CameraPtr &_camera, + const gz::math::Vector2i &_mousePos) override; + + // Documentation inherited. + public: virtual void DestroyVisual(VisualPtr _visual, + bool _recursive = false) override; + + public: virtual void DestroyVisualById(unsigned int _id) override; + + public: virtual void DestroyVisualByName(const std::string &_name) + override; + + public: virtual void DestroyVisualByIndex(unsigned int _index) override; + + public: virtual void DestroyVisuals() override; + + public: virtual bool MaterialRegistered(const std::string &_name) const + override; + + public: virtual MaterialPtr Material(const std::string &_name) const + override; + + public: virtual void RegisterMaterial(const std::string &_name, + MaterialPtr _material) override; + + public: virtual void UnregisterMaterial(const std::string &_name) + override; + + public: virtual void UnregisterMaterials() override; + + // Documentation inherited + public: virtual void DestroyMaterial(MaterialPtr _material) override; + + // Documentation inherited + public: virtual void DestroyMaterials() override; + + public: virtual DirectionalLightPtr CreateDirectionalLight() override; + + public: virtual DirectionalLightPtr CreateDirectionalLight( + unsigned int _id) override; + + public: virtual DirectionalLightPtr CreateDirectionalLight( + const std::string &_name) override; + + public: virtual DirectionalLightPtr CreateDirectionalLight( + unsigned int _id, const std::string &_name) override; + + public: virtual PointLightPtr CreatePointLight() override; + + public: virtual PointLightPtr CreatePointLight(unsigned int _id) override; + + public: virtual PointLightPtr CreatePointLight(const std::string &_name) + override; + + public: virtual PointLightPtr CreatePointLight(unsigned int _id, + const std::string &_name) override; + + 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 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 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 GridPtr CreateGrid() override; + + // Documentation inherited. + public: virtual MarkerPtr CreateMarker() 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; + + public: virtual void PreRender() override; + + public: virtual void Clear() override; + + public: virtual void Destroy() 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 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 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 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; + + protected: virtual LightStorePtr Lights() const = 0; + + protected: virtual SensorStorePtr Sensors() const = 0; + + protected: virtual VisualStorePtr Visuals() const = 0; + + protected: virtual MaterialMapPtr Materials() const = 0; + + protected: virtual bool LoadImpl() = 0; + + protected: virtual bool InitImpl() = 0; + + private: virtual void CreateNodeStore(); + + private: virtual void CreateMaterials(); + + /// \brief Helper function to recursively destory nodes while checking + /// for loops. + /// \param[in] _node Node to be destroyed + /// \param[in] _nodeId Holds all node ids that have been visited in the + /// tree during the destroy process. Used for loop detection. + private: void DestroyNodeRecursive(NodePtr _node, + std::set &_nodeIds); + + protected: unsigned int id; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: std::string name; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + protected: common::Time simTime; + + 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; + + private: unsigned int nextObjectId; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: NodeStorePtr nodes; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseSensor.hh b/include/gz/rendering/base/BaseSensor.hh new file mode 100644 index 000000000..6c52be724 --- /dev/null +++ b/include/gz/rendering/base/BaseSensor.hh @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_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(); + }; + + ////////////////////////////////////////////////// + template + BaseSensor::BaseSensor() + { + } + + ////////////////////////////////////////////////// + template + BaseSensor::~BaseSensor() + { + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseStorage.hh b/include/gz/rendering/base/BaseStorage.hh new file mode 100644 index 000000000..89b8785b6 --- /dev/null +++ b/include/gz/rendering/base/BaseStorage.hh @@ -0,0 +1,1465 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASESTORAGE_HH_ +#define GZ_RENDERING_BASE_BASESTORAGE_HH_ + +#include +#include +#include +#include + +#include +#include + +#include "gz/rendering/Storage.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + ////////////////////////////////////////////////// + template + class BaseMap : + public Map + { + typedef std::shared_ptr TPtr; + + typedef std::shared_ptr ConstTPtr; + + typedef std::shared_ptr UPtr; + + typedef std::map UMap; + + typedef typename UMap::iterator UIter; + + typedef typename UMap::const_iterator ConstUIter; + + public: BaseMap(); + + public: virtual ~BaseMap(); + + public: virtual unsigned int Size() const; + + public: virtual bool ContainsKey(const std::string &_key) const; + + public: virtual bool ContainsValue(ConstTPtr _value) const; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public: virtual TPtr Get(const std::string &_key) const; + + public: virtual TPtr GetByIndex(unsigned int _index) const; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + public: virtual bool Put(const std::string &_key, TPtr _value); + + public: virtual void Remove(const std::string &_key); + + public: virtual void Remove(TPtr _value); + + public: virtual void RemoveAll(); + + public: virtual UPtr Derived(const std::string &_key) const; + + public: virtual UPtr DerivedByIndex(unsigned int _index) const; + + protected: virtual bool IsValidIter(ConstUIter _iter) const; + + protected: UMap map; + }; + + ////////////////////////////////////////////////// + template + class BaseStore : + public Store + { + typedef std::shared_ptr TPtr; + + typedef std::shared_ptr ConstTPtr; + + typedef std::shared_ptr UPtr; + + typedef std::map UStore; + + typedef typename UStore::iterator UIter; + + typedef typename UStore::const_iterator ConstUIter; + + public: BaseStore(); + + public: virtual ~BaseStore(); + + public: virtual unsigned int Size() const; + + public: virtual bool Contains(ConstTPtr _object) const; + + public: virtual bool ContainsId(unsigned int _id) const; + + public: virtual bool ContainsName(const std::string &_name) const; + + public: virtual TPtr GetById(unsigned int _id) const; + + public: virtual TPtr GetByName(const std::string &_name) const; + + public: virtual TPtr GetByIndex(unsigned int _index) const; + + public: virtual bool Add(TPtr _object); + + public: virtual TPtr Remove(TPtr _object); + + public: virtual TPtr RemoveById(unsigned int _id); + + public: virtual TPtr RemoveByName(const std::string &_name); + + public: virtual TPtr RemoveByIndex(unsigned int _index); + + public: virtual void RemoveAll(); + + public: virtual void Destroy(TPtr _object); + + public: virtual void DestroyById(unsigned int _id); + + public: virtual void DestroyByName(const std::string &_name); + + public: virtual void DestroyByIndex(unsigned int _index); + + public: virtual void DestroyAll(); + + public: virtual UPtr DerivedById(unsigned int _id) const; + + public: virtual UPtr DerivedByName(const std::string &_name) const; + + public: virtual UPtr DerivedByIndex(unsigned int _index) const; + + public: virtual bool AddDerived(UPtr _object); + + public: virtual UPtr RemoveDerived(UPtr _object); + + public: virtual UPtr RemoveDerivedById(unsigned int _id); + + public: virtual UPtr RemoveDerivedByName(const std::string &_name); + + public: virtual UPtr RemoveDerivedByIndex(unsigned int _index); + + /// \brief Return an iterator to the beginning + /// \returns Iterator to beginning + public: virtual UIter Begin(); + + /// \brief Return an iterator to the end + /// \returns Iterator to end + public: virtual UIter End(); + + protected: virtual ConstUIter ConstIter(ConstTPtr _object) const; + + protected: virtual ConstUIter ConstIterById(unsigned int _id) const; + + protected: virtual ConstUIter ConstIterByName( + const std::string &_name) const; + + protected: virtual ConstUIter ConstIterByIndex(unsigned int _index) const; + + protected: virtual UIter Iter(ConstTPtr _object); + + protected: virtual UIter IterById(unsigned int _id); + + protected: virtual UIter IterByName(const std::string &_name); + + protected: virtual UIter IterByIndex(unsigned int _index); + + protected: virtual bool AddImpl(UPtr _object); + + protected: virtual UPtr RemoveImpl(UIter _iter); + + protected: virtual void DestroyImpl(UIter _iter); + + protected: virtual bool IsValidIter(ConstUIter _iter) const; + + protected: virtual UIter RemoveConstness(ConstUIter _iter); + + protected: UStore store; + }; + + ////////////////////////////////////////////////// + template + class BaseCompositeStore : + public CompositeStore + { + typedef std::shared_ptr TPtr; + + typedef std::shared_ptr ConstTPtr; + + typedef Store TStore; + + typedef std::shared_ptr TStorePtr; + + typedef std::shared_ptr ConstTStorePtr; + + typedef std::vector TStoreList; + + typedef typename TStoreList::iterator TStoreIter; + + public: BaseCompositeStore(); + + public: virtual ~BaseCompositeStore(); + + public: virtual unsigned int Size() const; + + public: virtual bool Contains(ConstTPtr _object) const; + + public: virtual bool ContainsId(unsigned int _id) const; + + public: virtual bool ContainsName(const std::string &_name) const; + + public: virtual TPtr GetById(unsigned int _id) const; + + public: virtual TPtr GetByName(const std::string &_name) const; + + public: virtual TPtr GetByIndex(unsigned int _index) const; + + public: virtual bool Add(TPtr _object); + + public: virtual TPtr Remove(TPtr _object); + + public: virtual TPtr RemoveById(unsigned int _id); + + public: virtual TPtr RemoveByName(const std::string &_name); + + public: virtual TPtr RemoveByIndex(unsigned int _index); + + public: virtual void RemoveAll(); + + public: virtual void Destroy(TPtr _object); + + public: virtual void DestroyById(unsigned int _id); + + public: virtual void DestroyByName(const std::string &_name); + + public: virtual void DestroyByIndex(unsigned int _index); + + public: virtual void DestroyAll(); + + public: virtual unsigned int GetStoreCount() const; + + public: virtual bool ContainsStore(ConstTStorePtr _store) const; + + public: virtual TStorePtr GetStore(unsigned int _index) const; + + public: virtual bool AddStore(TStorePtr _store); + + public: virtual TStorePtr RemoveStore(TStorePtr _store); + + public: virtual TStorePtr RemoveStore(unsigned int _index); + + public: virtual TStorePtr RemoveStoreImpl(TStoreIter _iter); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: TStoreList stores; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + + ////////////////////////////////////////////////// + template + class BaseStoreWrapper : + public StoreWrapper + { + typedef std::shared_ptr TPtr; + + typedef std::shared_ptr ConstTPtr; + + typedef std::shared_ptr UPtr; + + typedef std::shared_ptr ConstUPtr; + + typedef Store UStore; + + typedef std::shared_ptr UStorePtr; + + public: explicit BaseStoreWrapper(UStorePtr _store); + + public: virtual ~BaseStoreWrapper(); + + public: virtual unsigned int Size() const; + + public: virtual bool Contains(ConstTPtr _object) const; + + public: virtual bool ContainsId(unsigned int _id) const; + + public: virtual bool ContainsName(const std::string &_name) const; + + public: virtual TPtr GetById(unsigned int _id) const; + + public: virtual TPtr GetByName(const std::string &_name) const; + + public: virtual TPtr GetByIndex(unsigned int _index) const; + + public: virtual bool Add(TPtr _object); + + public: virtual TPtr Remove(TPtr _object); + + public: virtual TPtr RemoveById(unsigned int _id); + + public: virtual TPtr RemoveByName(const std::string &_name); + + public: virtual TPtr RemoveByIndex(unsigned int _index); + + public: virtual void RemoveAll(); + + public: virtual void Destroy(TPtr _object); + + public: virtual void DestroyById(unsigned int _id); + + public: virtual void DestroyByName(const std::string &_name); + + public: virtual void DestroyByIndex(unsigned int _index); + + public: virtual void DestroyAll(); + + protected: UStorePtr store; + }; + + ////////////////////////////////////////////////// + class BaseNodeCompositeStore : + public BaseCompositeStore + { + }; + + template + class BaseSceneStore : + public BaseStore + { + }; + + template + class BaseNodeStore : + public BaseStore + { + }; + + template + class BaseLightStore : + public BaseStore + { + }; + + template + class BaseSensorStore : + public BaseStore + { + }; + + template + class BaseVisualStore : + public BaseStore + { + }; + + template + class BaseGeometryStore : + public BaseStore + { + }; + + template + class BaseSubMeshStore : + public BaseStore + { + }; + + template + class BaseMaterialMap : + public BaseMap + { + }; + + ////////////////////////////////////////////////// + template + BaseMap::BaseMap() + { + } + + ////////////////////////////////////////////////// + template + BaseMap::~BaseMap() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseMap::Size() const + { + return this->map.size(); + } + + ////////////////////////////////////////////////// + template + bool BaseMap::ContainsKey(const std::string &_key) const + { + return this->map.count(_key) > 0; + } + + ////////////////////////////////////////////////// + template + bool BaseMap::ContainsValue(ConstTPtr _value) const + { + for (auto pair : this->map) + { + if (pair.second == _value) return true; + } + + return false; + } + + ////////////////////////////////////////////////// + template + typename BaseMap::TPtr + BaseMap::Get(const std::string &_key) const + { + return this->Derived(_key); + } + + ////////////////////////////////////////////////// + template + typename BaseMap::TPtr + BaseMap::GetByIndex(unsigned int _index) const + { + return this->DerivedByIndex(_index); + } + + ////////////////////////////////////////////////// + template + bool BaseMap::Put(const std::string &_key, TPtr _value) + { + if (_key.empty()) + { + ignerr << "Cannot store item with empty key" << std::endl; + return false; + } + + if (!_value) + { + ignerr << "Cannot store null pointer value" << std::endl; + return false; + } + + if (this->ContainsKey(_key)) + { + ignerr << "Item already registered with key: " << _key << std::endl; + return false; + } + + UPtr derived = std::dynamic_pointer_cast(_value); + + if (!derived) + { + ignerr << "Cannot add item created by another render-engine" + << std::endl; + + return false; + } + + this->map[_key] = derived; + return true; + } + + ////////////////////////////////////////////////// + template + void BaseMap::Remove(const std::string &_key) + { + auto iter = this->map.find(_key); + + if (this->IsValidIter(iter)) + { + this->map.erase(iter); + } + } + + ////////////////////////////////////////////////// + template + void BaseMap::Remove(TPtr _value) + { + auto iter = this->map.begin(); + + while (this->IsValidIter(iter)) + { + if (iter->second == _value) + { + this->map.erase(iter); + continue; + } + + ++iter; + } + } + + ////////////////////////////////////////////////// + template + void BaseMap::RemoveAll() + { + this->map.clear(); + } + + ////////////////////////////////////////////////// + template + typename BaseMap::UPtr + BaseMap::Derived(const std::string &_key) const + { + auto iter = this->map.find(_key); + return (this->IsValidIter(iter)) ? iter->second : nullptr; + } + + ////////////////////////////////////////////////// + template + typename BaseMap::UPtr + BaseMap::DerivedByIndex(unsigned int _index) const + { + if (_index >= this->Size()) + { + ignerr << "Invalid index: " << _index << std::endl; + return nullptr; + } + + auto iter = this->map.begin(); + std::advance(iter, _index); + return iter->second; + } + + ////////////////////////////////////////////////// + template + bool BaseMap::IsValidIter(ConstUIter _iter) const + { + return _iter != this->map.end(); + } + + ////////////////////////////////////////////////// + template + BaseStore::BaseStore() + { + } + + ////////////////////////////////////////////////// + template + BaseStore::~BaseStore() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseStore::Size() const + { + return this->store.size(); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::Begin() + { + return this->store.begin(); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::End() + { + return this->store.end(); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::Contains(ConstTPtr _object) const + { + auto iter = this->ConstIter(_object); + return this->IsValidIter(iter); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::ContainsId(unsigned int _id) const + { + auto iter = this->ConstIterById(_id); + return this->IsValidIter(iter); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::ContainsName(const std::string &_name) const + { + auto iter = this->ConstIterByName(_name); + return this->IsValidIter(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::GetById(unsigned int _id) const + { + return this->DerivedById(_id); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::GetByName(const std::string &_name) const + { + return this->DerivedByName(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::GetByIndex(unsigned int _index) const + { + return this->DerivedByIndex(_index); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::Add(TPtr _object) + { + if (!_object) + { + ignerr << "Cannot add null pointer" << std::endl; + return false; + } + + UPtr derived = std::dynamic_pointer_cast(_object); + + if (!derived) + { + ignerr << "Cannot add item created by another render-engine" + << std::endl; + + return false; + } + + return this->AddImpl(derived); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::Remove(TPtr _object) + { + auto iter = this->Iter(_object); + return this->RemoveImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::RemoveById(unsigned int _id) + { + return this->RemoveDerivedById(_id); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::RemoveByName(const std::string &_name) + { + return this->RemoveDerivedByName(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::TPtr + BaseStore::RemoveByIndex(unsigned int _index) + { + return this->RemoveDerivedByIndex(_index); + } + + ////////////////////////////////////////////////// + template + void BaseStore::RemoveAll() + { + this->store.clear(); + } + + ////////////////////////////////////////////////// + template + void BaseStore::Destroy(TPtr _object) + { + auto iter = this->Iter(_object); + this->DestroyImpl(iter); + } + + ////////////////////////////////////////////////// + template + void BaseStore::DestroyById(unsigned int _id) + { + auto iter = this->IterById(_id); + this->DestroyImpl(iter); + } + + ////////////////////////////////////////////////// + template + void BaseStore::DestroyByName(const std::string &_name) + { + auto iter = this->IterByName(_name); + this->DestroyImpl(iter); + } + + ////////////////////////////////////////////////// + template + void BaseStore::DestroyByIndex(unsigned int _index) + { + auto iter = this->IterByIndex(_index); + this->DestroyImpl(iter); + } + + ////////////////////////////////////////////////// + template + void BaseStore::DestroyAll() + { + unsigned int i = this->Size(); + + while (i > 0) + { + this->DestroyByIndex(--i); + } + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::DerivedById(unsigned int _id) const + { + auto iter = this->ConstIterById(_id); + return (this->IsValidIter(iter)) ? iter->second : nullptr; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::DerivedByName(const std::string &_name) const + { + auto iter = this->ConstIterByName(_name); + return (this->IsValidIter(iter)) ? iter->second : nullptr; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::DerivedByIndex(unsigned int _index) const + { + auto iter = this->ConstIterByIndex(_index); + return (this->IsValidIter(iter)) ? iter->second : nullptr; + } + + ////////////////////////////////////////////////// + template + bool BaseStore::AddDerived(UPtr _object) + { + if (!_object) + { + ignerr << "Cannot add null pointer" << std::endl; + return false; + } + + return this->AddImpl(_object); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::RemoveDerived(UPtr _object) + { + auto iter = this->Iter(_object); + return this->RemoveImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::RemoveDerivedById(unsigned int _id) + { + auto iter = this->IterById(_id); + return this->RemoveImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::RemoveDerivedByName(const std::string &_name) + { + auto iter = this->IterByName(_name); + return this->RemoveImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::RemoveDerivedByIndex(unsigned int _index) + { + auto iter = this->IterByIndex(_index); + return this->RemoveImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::ConstUIter + BaseStore::ConstIter(ConstTPtr _object) const + { + auto begin = this->store.begin(); + auto end = this->store.end(); + + for (auto iter = begin; iter != end; ++iter) + { + if (iter->second == _object) + { + return iter; + } + } + + return end; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::ConstUIter + BaseStore::ConstIterById(unsigned int _id) const + { + auto begin = this->store.begin(); + auto end = this->store.end(); + + for (auto iter = begin; iter != end; ++iter) + { + if (iter->second->Id() == _id) + { + return iter; + } + } + + return end; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::ConstUIter + BaseStore::ConstIterByName(const std::string &_name) const + { + return this->store.find(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::ConstUIter + BaseStore::ConstIterByIndex(unsigned int _index) const + { + if (_index >= this->Size()) + { + ignerr << "Invalid index: " << _index << std::endl; + return this->store.end(); + } + + auto iter = this->store.begin(); + std::advance(iter, _index); + return iter; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::Iter(ConstTPtr _object) + { + auto iter = this->ConstIter(_object); + return this->RemoveConstness(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::IterById(unsigned int _id) + { + auto iter = this->ConstIterById(_id); + return this->RemoveConstness(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::IterByName(const std::string &_name) + { + auto iter = this->ConstIterByName(_name); + return this->RemoveConstness(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::IterByIndex(unsigned int _index) + { + auto iter = this->ConstIterByIndex(_index); + return this->RemoveConstness(iter); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::AddImpl(UPtr _object) + { + unsigned int id = _object->Id(); + std::string name = _object->Name(); + + if (this->ContainsId(id)) + { + ignerr << "Another item already exists with id: " << id << std::endl; + return false; + } + + if (this->ContainsName(name)) + { + ignerr << "Another item already exists with name: " << name + << std::endl; + return false; + } + + this->store[name] = _object; + return true; + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UPtr + BaseStore::RemoveImpl(UIter _iter) + { + if (!this->IsValidIter(_iter)) + { + return nullptr; + } + + UPtr result = _iter->second; + this->store.erase(_iter); + return result; + } + + ////////////////////////////////////////////////// + template + void BaseStore::DestroyImpl(UIter _iter) + { + UPtr result = this->RemoveImpl(_iter); + if (result) result->Destroy(); + } + + ////////////////////////////////////////////////// + template + bool BaseStore::IsValidIter(ConstUIter _iter) const + { + return _iter != this->store.end(); + } + + ////////////////////////////////////////////////// + template + typename BaseStore::UIter + BaseStore::RemoveConstness(ConstUIter _iter) + { + return (this->IsValidIter(_iter)) ? + this->store.erase(_iter, _iter) : this->store.end(); + } + + ////////////////////////////////////////////////// + template + BaseCompositeStore::BaseCompositeStore() + { + } + + ////////////////////////////////////////////////// + template + BaseCompositeStore::~BaseCompositeStore() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCompositeStore::Size() const + { + unsigned int size = 0; + + for (auto store : this->stores) + { + size += store->Size(); + } + + return size; + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::Contains(ConstTPtr _object) const + { + for (auto store : this->stores) + { + if (store->Contains(_object)) return true; + } + + return false; + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::ContainsId(unsigned int _id) const + { + for (auto store : this->stores) + { + if (store->ContainsId(_id)) return true; + } + + return false; + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::ContainsName(const std::string &_name) const + { + for (auto store : this->stores) + { + if (store->ContainsName(_name)) return true; + } + + return false; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::GetById(unsigned int _id) const + { + for (auto store : this->stores) + { + TPtr object = store->GetById(_id); + if (object) return object; + } + + return nullptr; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::GetByName(const std::string &_name) const + { + for (auto store : this->stores) + { + TPtr object = store->GetByName(_name); + if (object) return object; + } + + return nullptr; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::GetByIndex(unsigned int _index) const + { + unsigned int origIndex = _index; + + for (auto store : this->stores) + { + unsigned int size = store->Size(); + if (_index < size) + return store->GetByIndex(_index); + _index -= size; + } + + ignerr << "Invalid index: " << origIndex << std::endl; + return nullptr; + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::Add(TPtr) + { + ignerr << "Adding to BaseCompositeStore not supported" << std::endl; + return false; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::Remove(TPtr _object) + { + TPtr result = nullptr; + + for (auto store : this->stores) + { + TPtr temp = store->Remove(_object); + if (!result) result = temp; + } + + return result; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::RemoveById(unsigned int _id) + { + TPtr result = nullptr; + + for (auto store : this->stores) + { + TPtr temp = store->RemoveById(_id); + if (!result) result = temp; + } + + return result; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::RemoveByName(const std::string &_name) + { + TPtr result = nullptr; + + for (auto store : this->stores) + { + TPtr temp = store->RemoveByName(_name); + if (!result) result = temp; + } + + return result; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TPtr + BaseCompositeStore::RemoveByIndex(unsigned int _index) + { + TPtr result = nullptr; + + for (auto store : this->stores) + { + TPtr temp = store->RemoveByIndex(_index); + if (!result) result = temp; + } + + return result; + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::RemoveAll() + { + for (auto store : this->stores) + { + store->RemoveAll(); + } + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::Destroy(TPtr _object) + { + for (auto store : this->stores) + { + if (store->Contains(_object)) + { + store->Destroy(_object); + return; + } + } + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::DestroyById(unsigned int _id) + { + for (auto store : this->stores) + { + store->DestroyById(_id); + } + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::DestroyByName(const std::string &_name) + { + for (auto store : this->stores) + { + store->DestroyByName(_name); + } + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::DestroyByIndex(unsigned int _index) + { + for (auto store : this->stores) + { + store->DestroyByIndex(_index); + } + } + + ////////////////////////////////////////////////// + template + void BaseCompositeStore::DestroyAll() + { + for (auto store : this->stores) + { + store->DestroyAll(); + } + } + + ////////////////////////////////////////////////// + template + unsigned int BaseCompositeStore::GetStoreCount() const + { + return this->stores.size(); + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::ContainsStore(ConstTStorePtr _store) const + { + auto begin = this->stores.begin(); + auto end = this->stores.end(); + auto iter = std::find(begin, end, _store); + return iter != end; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TStorePtr + BaseCompositeStore::GetStore(unsigned int _index) const + { + if (_index >= this->GetStoreCount()) + { + ignerr << "Invalid store index: " << _index << std::endl; + return nullptr; + } + + return this->stores[_index]; + } + + ////////////////////////////////////////////////// + template + bool BaseCompositeStore::AddStore(TStorePtr _store) + { + if (!_store) + { + ignerr << "Cannot all null store pointer" << std::endl; + return false; + } + + if (this->ContainsStore(_store)) + { + ignerr << "Store has already been added" << std::endl; + return false; + } + + this->stores.push_back(_store); + return true; + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TStorePtr + BaseCompositeStore::RemoveStore(TStorePtr _store) + { + auto begin = this->stores.begin(); + auto end = this->stores.end(); + auto iter = std::find(begin, end, _store); + return this->RemoveStoreImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TStorePtr + BaseCompositeStore::RemoveStore(unsigned int _index) + { + if (_index >= this->GetStoreCount()) + { + ignerr << "Invalid store index: " << _index << std::endl; + return nullptr; + } + + auto iter = this->stores.begin(); + std::advance(iter, _index); + return this->RemoveStoreImpl(iter); + } + + ////////////////////////////////////////////////// + template + typename BaseCompositeStore::TStorePtr + BaseCompositeStore::RemoveStoreImpl(TStoreIter _iter) + { + if (_iter == this->stores.end()) + { + return nullptr; + } + + TStorePtr result = *_iter; + this->stores.erase(_iter); + return result; + } + + ////////////////////////////////////////////////// + template + BaseStoreWrapper::BaseStoreWrapper(UStorePtr _store) : + store(_store) + { + } + + ////////////////////////////////////////////////// + template + BaseStoreWrapper::~BaseStoreWrapper() + { + } + + ////////////////////////////////////////////////// + template + unsigned int BaseStoreWrapper::Size() const + { + return this->store->Size(); + } + + ////////////////////////////////////////////////// + template + bool BaseStoreWrapper::Contains(ConstTPtr _object) const + { + ConstUPtr derived = std::dynamic_pointer_cast(_object); + return this->store->Contains(derived); + } + + ////////////////////////////////////////////////// + template + bool BaseStoreWrapper::ContainsId(unsigned int _id) const + { + return this->store->ContainsId(_id); + } + + ////////////////////////////////////////////////// + template + bool BaseStoreWrapper::ContainsName(const std::string &_name) const + { + return this->store->ContainsName(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::GetById(unsigned int _id) const + { + return this->store->GetById(_id); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::GetByName(const std::string &_name) const + { + return this->store->GetByName(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::GetByIndex(unsigned int _index) const + { + return this->store->GetByIndex(_index); + } + + ////////////////////////////////////////////////// + template + bool BaseStoreWrapper::Add(TPtr _object) + { + UPtr derived = std::dynamic_pointer_cast(_object); + return this->store->Add(derived); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::Remove(TPtr _object) + { + UPtr derived = std::dynamic_pointer_cast(_object); + return this->store->Remove(derived); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::RemoveById(unsigned int _id) + { + return this->store->RemoveById(_id); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::RemoveByName(const std::string &_name) + { + return this->store->RemoveByName(_name); + } + + ////////////////////////////////////////////////// + template + typename BaseStoreWrapper::TPtr + BaseStoreWrapper::RemoveByIndex(unsigned int _index) + { + return this->store->RemoveByIndex(_index); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::RemoveAll() + { + this->store->RemoveAll(); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::Destroy(TPtr _object) + { + UPtr derived = std::dynamic_pointer_cast(_object); + this->store->Destroy(derived); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::DestroyById(unsigned int _id) + { + this->store->DestroyById(_id); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::DestroyByName(const std::string &_name) + { + this->store->DestroyByName(_name); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::DestroyByIndex(unsigned int _index) + { + this->store->DestroyByIndex(_index); + } + + ////////////////////////////////////////////////// + template + void BaseStoreWrapper::DestroyAll() + { + this->store->DestroyAll(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseText.hh b/include/gz/rendering/base/BaseText.hh new file mode 100644 index 000000000..0f5774da2 --- /dev/null +++ b/include/gz/rendering/base/BaseText.hh @@ -0,0 +1,303 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASETEXT_HH_ +#define GZ_RENDERING_BASE_BASETEXT_HH_ + +#include +#include "gz/rendering/Text.hh" +#include "gz/rendering/base/BaseObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of a text geometry + template + class BaseText : + public virtual Text, + public virtual T + { + /// \brief Constructor + protected: BaseText(); + + /// \brief Destructor + public: virtual ~BaseText(); + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: void SetFontName(const std::string &_font) override; + + // Documentation inherited. + public: std::string FontName() const override; + + // Documentation inherited. + public: virtual void SetTextString(const std::string &_text) override; + + // Documentation inherited. + public: virtual std::string TextString() const override; + + // Documentation inherited. + public: virtual void SetColor(const gz::math::Color &_color) + override; + + // Documentation inherited. + public: virtual gz::math::Color Color() const override; + + // Documentation inherited. + public: virtual void SetCharHeight(const float _height) override; + + // Documentation inherited. + public: virtual float CharHeight() const override; + + // Documentation inherited. + public: virtual void SetSpaceWidth(const float _width) override; + + // Documentation inherited. + public: virtual float SpaceWidth() const override; + + // Documentation inherited. + public: virtual void SetTextAlignment(const TextHorizontalAlign &_hAlign, + const TextVerticalAlign &_vAlign) override; + // Documentation inherited. + public: virtual TextHorizontalAlign HorizontalAlignment() const override; + + // Documentation inherited. + public: virtual TextVerticalAlign VerticalAlignment() const override; + + // Documentation inherited. + public: virtual void SetBaseline(const float _baseline) override; + + // Documentation inherited. + public: virtual float Baseline() const override; + + // Documentation inherited. + public: void SetShowOnTop(const bool _onTop) override; + + // Documentation inherited. + public: virtual bool ShowOnTop() const override; + + // Documentation inherited. + public: virtual gz::math::AxisAlignedBox AABB() const override; + + /// \brief Font name, such as "Liberation Sans" + protected: std::string fontName = "Liberation Sans"; + + /// \brief Text being displayed + protected: std::string text; + + /// \brief Text color + protected: gz::math::Color color = gz::math::Color::White; + + /// \brief Character height in meters + protected: float charHeight = 1.0; + + /// \brief Width of space between letters + protected: float spaceWidth = 0; + + /// \brief Horizontal alignment + protected: TextHorizontalAlign horizontalAlign = + TextHorizontalAlign::LEFT; + + /// \brief Vertical alignment + protected: TextVerticalAlign verticalAlign = TextVerticalAlign::BOTTOM; + + /// \brief Baseline height in meters. + protected: float baseline = 0; + + /// \brief True for text to be displayed on top of other objects in the + /// scene. + protected: bool onTop = false; + + /// \brief Flag to indicate text properties have changed + protected: bool textDirty = false; + }; + + ////////////////////////////////////////////////// + // BaseText + ////////////////////////////////////////////////// + template + BaseText::BaseText() + { + } + + ////////////////////////////////////////////////// + template + BaseText::~BaseText() + { + } + + ////////////////////////////////////////////////// + template + std::string BaseText::FontName() const + { + return this->fontName; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetFontName(const std::string &_font) + { + this->fontName = _font; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + std::string BaseText::TextString() const + { + return this->text; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetTextString(const std::string &_text) + { + this->text = _text; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + gz::math::Color BaseText::Color() const + { + return this->color; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetColor(const gz::math::Color &_color) + { + this->color = _color; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + float BaseText::CharHeight() const + { + return this->charHeight; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetCharHeight(const float _height) + { + this->charHeight = _height; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + float BaseText::SpaceWidth() const + { + return this->spaceWidth; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetSpaceWidth(const float _width) + { + this->spaceWidth = _width; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + TextHorizontalAlign BaseText::HorizontalAlignment() const + { + return this->horizontalAlign; + } + + ////////////////////////////////////////////////// + template + TextVerticalAlign BaseText::VerticalAlignment() const + { + return this->verticalAlign; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetTextAlignment(const TextHorizontalAlign &_horzAlign, + const TextVerticalAlign &_vertAlign) + { + this->horizontalAlign = _horzAlign; + this->verticalAlign = _vertAlign; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + float BaseText::Baseline() const + { + return this->baseline; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetBaseline(const float _baseline) + { + this->baseline = _baseline; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + bool BaseText::ShowOnTop() const + { + return this->onTop; + } + + ////////////////////////////////////////////////// + template + void BaseText::SetShowOnTop(const bool _onTop) + { + this->onTop = _onTop; + this->textDirty = true; + } + + ////////////////////////////////////////////////// + template + gz::math::AxisAlignedBox BaseText::AABB() const + { + math::AxisAlignedBox box; + return box; + } + + ////////////////////////////////////////////////// + template + void BaseText::PreRender() + { + T::PreRender(); + } + + ////////////////////////////////////////////////// + template + void BaseText::Destroy() + { + T::Destroy(); + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseThermalCamera.hh b/include/gz/rendering/base/BaseThermalCamera.hh new file mode 100644 index 000000000..a0bee4984 --- /dev/null +++ b/include/gz/rendering/base/BaseThermalCamera.hh @@ -0,0 +1,211 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_BASE_BASETHERMALCAMERA_HH_ +#define GZ_RENDERING_BASE_BASETHERMALCAMERA_HH_ + +#include + +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/ThermalCamera.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Base implementation of the ThermalCamera class + template + class BaseThermalCamera : + public virtual ThermalCamera, + public virtual BaseCamera, + public virtual T + { + /// \brief Constructor + protected: BaseThermalCamera(); + + /// \brief Destructor + public: virtual ~BaseThermalCamera(); + + // Documentation inherited. + public: virtual void SetAmbientTemperature(float _ambient) override; + + // Documentation inherited. + public: virtual float AmbientTemperature() const override; + + // Documentation inherited. + public: virtual void SetAmbientTemperatureRange(float _range) override; + + // Documentation inherited. + public: virtual float AmbientTemperatureRange() const override; + + // Documentation inherited. + public: virtual void SetMinTemperature(float _min) override; + + // Documentation inherited. + public: virtual float MinTemperature() const override; + + // Documentation inherited. + public: virtual void SetMaxTemperature(float _max) override; + + // Documentation inherited. + public: virtual float MaxTemperature() const override; + + // Documentation inherited. + public: virtual void SetLinearResolution(float _max) override; + + // Documentation inherited. + public: virtual float LinearResolution() const override; + + // Documentation inherited. + public: virtual float HeatSourceTemperatureRange() const override; + + // Documentation inherited. + public: virtual void SetHeatSourceTemperatureRange(float _range) override; + + // Documentation inherted. + public: virtual gz::common::ConnectionPtr ConnectNewThermalFrame( + std::function _subscriber) override; + + /// \brief Ambient temperature of the environment + protected: float ambient = 0.0f; + + /// \brief Ambient temperature range + protected: float ambientRange = 0.0f; + + /// \brief Minimum temperature + protected: float minTemp = -gz::math::INF_F; + + /// \brief Maximum temperature + protected: float maxTemp = gz::math::INF_F; + + /// \brief Linear resolution. Defaults to 10mK. + protected: float resolution = 0.01f; + + /// \brief Range of heat source temperature variation + protected: float heatSourceTempRange = 0.0f; + }; + + ////////////////////////////////////////////////// + template + BaseThermalCamera::BaseThermalCamera() + { + } + + ////////////////////////////////////////////////// + template + BaseThermalCamera::~BaseThermalCamera() + { + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetAmbientTemperature(float _ambient) + { + this->ambient = _ambient; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::AmbientTemperature() const + { + return this->ambient; + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetAmbientTemperatureRange(float _range) + { + this->ambientRange = _range; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::AmbientTemperatureRange() const + { + return this->ambientRange; + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetMinTemperature(float _min) + { + this->minTemp = _min; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::MinTemperature() const + { + return this->minTemp; + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetMaxTemperature(float _max) + { + this->maxTemp = _max; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::MaxTemperature() const + { + return this->maxTemp; + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetLinearResolution(float _resolution) + { + this->resolution = _resolution; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::LinearResolution() const + { + return this->resolution; + } + + ////////////////////////////////////////////////// + template + void BaseThermalCamera::SetHeatSourceTemperatureRange(float _range) + { + this->heatSourceTempRange = _range; + } + + ////////////////////////////////////////////////// + template + float BaseThermalCamera::HeatSourceTemperatureRange() const + { + return this->heatSourceTempRange; + } + + ////////////////////////////////////////////////// + template + common::ConnectionPtr BaseThermalCamera::ConnectNewThermalFrame( + std::function) + { + return nullptr; + } + } + } +} +#endif diff --git a/include/gz/rendering/base/BaseVisual.hh b/include/gz/rendering/base/BaseVisual.hh new file mode 100644 index 000000000..050006e36 --- /dev/null +++ b/include/gz/rendering/base/BaseVisual.hh @@ -0,0 +1,352 @@ +/* + * 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 "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() override; + + // Documentation inherited. + public: virtual void SetVisible(bool _visible) override; + + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void Destroy() 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; + + 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 A map of custom key value data + protected: std::map userData; + }; + + ////////////////////////////////////////////////// + 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() + { + 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 + void BaseVisual::SetVisible(bool _visible) + { + ignerr << "SetVisible(" << _visible << ") not supported for " + << "render engine: " << this->Scene()->Engine()->Name() + << std::endl; + } + + ////////////////////////////////////////////////// + template + void BaseVisual::SetUserData(const std::string &_key, Variant _value) + { + this->userData[_key] = _value; + } + + ////////////////////////////////////////////////// + template + Variant BaseVisual::UserData(const std::string &_key) const + { + Variant value; + auto it = this->userData.find(_key); + if (it != this->userData.end()) + value = it->second; + return value; + } + } + } +} +#endif diff --git a/include/ignition/rendering/base/CMakeLists.txt b/include/gz/rendering/base/CMakeLists.txt similarity index 100% rename from include/ignition/rendering/base/CMakeLists.txt rename to include/gz/rendering/base/CMakeLists.txt diff --git a/include/gz/rendering/base/base.hh.in b/include/gz/rendering/base/base.hh.in new file mode 100644 index 000000000..c4092f0cd --- /dev/null +++ b/include/gz/rendering/base/base.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/include/ignition/rendering/config.hh.in b/include/gz/rendering/config.hh.in similarity index 93% rename from include/ignition/rendering/config.hh.in rename to include/gz/rendering/config.hh.in index fd052ebf6..0a74f1205 100644 --- a/include/ignition/rendering/config.hh.in +++ b/include/gz/rendering/config.hh.in @@ -24,3 +24,12 @@ #cmakedefine HAVE_OPTIX 1 #cmakedefine HAVE_GAZEBO 1 #cmakedefine INCLUDE_RTSHADER 1 + +namespace ignition +{ +} + +namespace gz +{ + using namespace ignition; +} diff --git a/include/gz/rendering/rendering.hh.in b/include/gz/rendering/rendering.hh.in new file mode 100644 index 000000000..2602ad19b --- /dev/null +++ b/include/gz/rendering/rendering.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +//#include +${ign_headers} diff --git a/include/ignition/rendering.hh b/include/ignition/rendering.hh new file mode 100644 index 000000000..c7494084f --- /dev/null +++ b/include/ignition/rendering.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/include/ignition/rendering/ArrowVisual.hh b/include/ignition/rendering/ArrowVisual.hh index 1b38de0f4..b8fb951af 100644 --- a/include/ignition/rendering/ArrowVisual.hh +++ b/include/ignition/rendering/ArrowVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,36 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_ARROWVISUAL_HH_ -#define IGNITION_RENDERING_ARROWVISUAL_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/CompositeVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class ArrowVisual ArrowVisual.hh ignition/rendering/ArrowVisual.hh - /// \brief Represents a arrow composite visual - class IGNITION_RENDERING_VISIBLE ArrowVisual : - public virtual CompositeVisual - { - /// \brief Deconstructor - public: virtual ~ArrowVisual() { } - - /// \brief Get arrow-head visual - /// \return The arrow-head visual - public: virtual VisualPtr Head() const = 0; - - /// \brief Get arrow-shaft visual - /// \return The arrow-shaft visual - public: virtual VisualPtr Shaft() const = 0; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/AxisVisual.hh b/include/ignition/rendering/AxisVisual.hh index 52595e4aa..58a952c7c 100644 --- a/include/ignition/rendering/AxisVisual.hh +++ b/include/ignition/rendering/AxisVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,27 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_AXISVISUAL_HH_ -#define IGNITION_RENDERING_AXISVISUAL_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/CompositeVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class AxisVisual AxisVisual.hh ignition/rendering/AxisVisual.hh - /// \brief Represents a axis composite visual - class IGNITION_RENDERING_VISIBLE AxisVisual : - public virtual CompositeVisual - { - /// \brief Deconstructor - public: virtual ~AxisVisual() { } - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Camera.hh b/include/ignition/rendering/Camera.hh index a34cd28d1..009827525 100644 --- a/include/ignition/rendering/Camera.hh +++ b/include/ignition/rendering/Camera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,292 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_CAMERA_HH_ -#define IGNITION_RENDERING_CAMERA_HH_ -#include - -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/Sensor.hh" -#include "ignition/rendering/Scene.hh" - - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Camera Camera.hh ignition/rendering/Camera.hh - /// \brief Posable camera used for rendering the scene graph - class IGNITION_RENDERING_VISIBLE Camera : - public virtual Sensor - { - /// \brief Callback function for new frame render event listeners - public: typedef std::function NewFrameListener; - - /// \brief Deconstructor - public: virtual ~Camera() { } - - /// \brief Get the image width in pixels - /// \return The image width in pixels - public: virtual unsigned int ImageWidth() const = 0; - - /// \brief Set the image width in pixels - /// \param[in] _width New image width in pixels - public: virtual void SetImageWidth(unsigned int _width) = 0; - - /// \brief Get the image height in pixels - /// \return The image height in pixels - public: virtual unsigned int ImageHeight() const = 0; - - /// \brief Set the image height in pixels - /// \param[in] _height New image height in pixels - public: virtual void SetImageHeight(unsigned int _height) = 0; - - /// \brief Get the image pixel format. If the image pixel format has not - /// been set with a valid value, PF_UNKNOWN will be returned. - /// \return The image pixel format - public: virtual PixelFormat ImageFormat() const = 0; - - /// \brief Set the image pixel format - /// \param[in] _format New image pixel format - public: virtual void SetImageFormat(PixelFormat _format) = 0; - - /// \brief Get the total image memory size in bytes - /// \return The image memory size in bytes - public: virtual unsigned int ImageMemorySize() const = 0; - - /// \brief Get the camera's horizontal field-of-view - /// \return Angle containing the camera's horizontal field-of-view - public: virtual math::Angle HFOV() const = 0; - - /// \brief Set the camera's horizontal field-of-view - /// \param[in] _hfov Desired horizontal field-of-view - public: virtual void SetHFOV(const math::Angle &_hfov) = 0; - - /// \brief Get the camera's aspect ratio - /// \return The camera's aspect ratio - public: virtual double AspectRatio() const = 0; - - /// \brief Set the camera's aspect ratio. This value determines the - /// cameras vertical field-of-view. It is often the \code image_height / - /// image_width \endcode but this is not necessarily true. - /// \return The camera's aspect ratio - public: virtual void SetAspectRatio(const double _ratio) = 0; - - // TODO(anyone): add auto-aspect ratio - - /// \brief Get the level of anti-aliasing used during rendering - /// \return The level of anti-aliasing used during rendering - public: virtual unsigned int AntiAliasing() const = 0; - - /// \brief Set the level of anti-aliasing used during rendering. If a - /// value of 0 is given, no anti-aliasing will be performed. Higher values - /// can significantly slow-down rendering times, depending on the - /// underlying render engine. - /// \param[in] _aa Level of anti-aliasing used during rendering - public: virtual void SetAntiAliasing(const unsigned int _aa) = 0; - - /// \brief Get the camera's far clipping plane distance - /// \return Far clipping plane distance - public: virtual double FarClipPlane() const = 0; - - /// \brief Set the camera's far clipping plane distance - /// \param[in] _far Far clipping plane distance - public: virtual void SetFarClipPlane(const double _far) = 0; - - /// \brief Get the camera's near clipping plane distance - /// \return Near clipping plane distance - public: virtual double NearClipPlane() const = 0; - - /// \brief Set the camera's near clipping plane distance - /// \param[in] _near Near clipping plane distance - public: virtual void SetNearClipPlane(const double _near) = 0; - - /// \brief Renders the current scene using this camera. This function - /// assumes PreRender() has already been called on the parent Scene, - /// allowing the camera and the scene itself to prepare for rendering. - public: virtual void Render() = 0; - - /// \brief Preforms any necessary final rendering work. Once rendering is - /// complete the camera will alert any listeners of the new frame event. - /// This function should only be called after a call to Render has - /// successfully been executed. - public: virtual void PostRender() = 0; - - /// \brief Get the visual for a given mouse position - /// param[in] _mousePos mouse position - // \return visual for that position, null if no visual was found - public: virtual VisualPtr VisualAt(const 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 be used in applications with multiple cameras - /// or multiple consumers of a single camera's images. - public: virtual void Update() = 0; - - /// \brief Created an empty image buffer for capturing images. The - /// resulting image will have sufficient memory allocated for subsequent - /// calls to this camera's Capture function. However, any changes to this - /// cameras properties may invalidate the condition. - /// \return A newly allocated Image for storing this cameras images - public: virtual Image CreateImage() const = 0; - - /// \brief Renders a new frame and writes the results to the given image. - /// This is a convenience function for single-camera scenes. It wraps the - /// pre-render, render, post-render, and get-image calls into a single - /// function. This should be used in applications with multiple cameras - /// or multiple consumers of a single camera's images. - /// \param[out] _image Output image buffer - public: virtual void Capture(Image &_image) = 0; - - /// \brief Writes the last rendered image to the given image buffer. This - /// function can be called multiple times after PostRender has been - /// called, without rendering the scene again. Calling this function - /// before a single image has been rendered will have undefined behavior. - /// \param[out] _image Output image buffer - public: virtual void Copy(Image &_image) const = 0; - - /// \brief Writes the previously rendered frame to a file. This function - /// can be called multiple times after PostRender has been called, - /// without rendering the scene again. Calling this function before a - /// single image has been rendered will have undefined behavior. - /// \param[in] _name Name of the output file - public: virtual bool SaveFrame(const std::string &_name) = 0; - - /// \brief Subscribes a new listener to this camera's new frame event - /// \param[in] _listener New camera listener callback - public: virtual common::ConnectionPtr ConnectNewImageFrame( - NewFrameListener _listener) = 0; - - /// \brief Create a render window. - /// \return A pointer to the render window. - public: virtual RenderWindowPtr CreateRenderWindow() = 0; - - /// \brief Get the projection matrix for this camera - /// \return Camera projection matrix - public: virtual math::Matrix4d ProjectionMatrix() const = 0; - - /// \brief Get the view matrix for this camera - /// \return Camera view matrix - public: virtual math::Matrix4d ViewMatrix() const = 0; - - /// \brief Set a node for camera to track. The camera will automatically - /// change its orientation to face the target being tracked. If null is - /// specified, tracking is disabled. In contrast to SetFollowTarget - /// the camera does not change its position when tracking is enabled. - /// \param[in] _target Target node to track - /// \param[in] _offset Track a point that is at an offset relative - /// to target. - /// \param[in] _worldFrame If true, the offset point to track will be - /// treated in world frame and its position relative to the target - /// node remains fixed regardless of the target node's rotation. Default - /// is false, which means the camera tracks the point in target node's - /// local frame. - public: virtual void SetTrackTarget(const NodePtr &_target, - const math::Vector3d &_offset = math::Vector3d::Zero, - const bool _worldFrame = false) = 0; - - /// \brief Get the target node being tracked - /// \return Target node being tracked. - public: virtual NodePtr TrackTarget() const = 0; - - /// \brief Set track offset. Camera will track a point that's at an - /// offset from the target node. The offset will be in the frame - /// that is specified at the time the track target is set. - /// \param[in] _offset Point offset to track - public: virtual void SetTrackOffset(const math::Vector3d &_offset) = 0; - - /// \brief Get the track offset vector in the frame specified at the time - /// the track target is set. - /// \return Point offset from target. - public: virtual math::Vector3d TrackOffset() const = 0; - - /// \brief Set track P Gain. Determines how fast the camera rotates - /// to look at the target node. Valid range: [0-1] - /// \param[in] _pGain P gain for camera tracking - public: virtual void SetTrackPGain(const double _pGain) = 0; - - /// \brief Get the camera track rotation P gain. - /// \return P gain for camera tracking - public: virtual double TrackPGain() const = 0; - - /// \brief Set a node for camera to follow. The camera will automatically - /// update its position to keep itself at the specified offset distance - /// from the target being followed. If null is specified, camera follow is - /// disabled. In contrast to SetTrackTarget, the camera does not change - /// its orientation when following is enabled. - /// \param[in] _target Target node to follow - /// \param[in] _offset Tether the camera at an offset distance from the - /// target node. - /// \param[in] _worldFrame True to follow the target node at a - /// distance that's fixed in world frame. Default is false which means - /// the camera follows at fixed distance in target node's local frame. - public: virtual void SetFollowTarget(const NodePtr &_target, - const math::Vector3d &_offset = math::Vector3d::Zero, - const bool _worldFrame = false) = 0; - - /// \brief Get the target node being followed - /// \return Target node being tracked. - public: virtual NodePtr FollowTarget() const = 0; - - /// \brief Set offset of camera from target node being followed. The - /// offset will be in the frame that is specified at the time the follow - /// target is set. - /// \param[in] _offset Offset distance from target node. - public: virtual void SetFollowOffset(const math::Vector3d &_offset) = 0; - - /// \brief Get the follow offset vector in the frame specified at the - /// time the follow target is set. - /// \return Offset of camera from target. - public: virtual math::Vector3d FollowOffset() const = 0; - - /// \brief Set follow P Gain. Determines how fast the camera moves - /// to follow the target node. Valid range: [0-1] - /// \param[in] _pGain P gain for camera following - public: virtual void SetFollowPGain(const double _pGain) = 0; - - /// \brief Get the camera follow movement P gain. - /// \return P gain for camera following - public: virtual double FollowPGain() const = 0; - - /// \brief Set a material that the camera should see on all objects - /// \param[in] _material a material instance - public: virtual void SetMaterial(const MaterialPtr &_material) = 0; - - /// \brief Get the OpenGL texture id associated with the render texture - /// used by this camera. A valid id is returned only if the underlying - /// render engine is OpenGL based. - /// \return Texture Id of type GLuint. - public: virtual unsigned int RenderTextureGLId() const = 0; - - /// \brief Add a render pass to the camera - /// \param[in] _pass New render pass to add - public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0; - - /// \brief Remove a render pass from the camera - /// \param[in] _pass render pass to remove - public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) = 0; - - /// \brief Get the number of render passes applied to the camera - /// \return Number of render passes applied - public: virtual unsigned int RenderPassCount() const = 0; - - /// \brief Get a render passes by index - /// \return Render pass at the specified index - public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) - const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/CompositeVisual.hh b/include/ignition/rendering/CompositeVisual.hh index ff7f1fbc1..e64586d0a 100644 --- a/include/ignition/rendering/CompositeVisual.hh +++ b/include/ignition/rendering/CompositeVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_COMPOSITEVISUAL_HH_ -#define IGNITION_RENDERING_COMPOSITEVISUAL_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class CompositeVisual CompositeVisual.hh - /// ignition/rendering/CompositeVisual.hh - /// \brief Represents a predefined collection of geometries and visuals - class IGNITION_RENDERING_VISIBLE CompositeVisual : - public virtual Visual - { - /// \brief Deconstructor - public: virtual ~CompositeVisual() { } - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/DepthCamera.hh b/include/ignition/rendering/DepthCamera.hh index a70795458..ee904b7d1 100644 --- a/include/ignition/rendering/DepthCamera.hh +++ b/include/ignition/rendering/DepthCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,69 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_DEPTHCAMERA_HH_ -#define IGNITION_RENDERING_DEPTHCAMERA_HH_ -#include - -#include -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \class Camera Camera.hh ignition/rendering/Camera.hh - /// \brief Poseable depth camera used for rendering the scene graph. - /// This camera is designed to produced depth data, instead of a 2D - /// image. - class IGNITION_RENDERING_VISIBLE DepthCamera : - public virtual Camera - { - /// \brief Callback function for new frame render event listeners - public: typedef std::function NewFrameListener; - - /// \brief Destructor - public: virtual ~DepthCamera() { } - - /// \brief Create a texture which will hold the depth data - public: virtual void CreateDepthTexture() = 0; - - /// \brief All things needed to get back z buffer for depth data - /// \return The z-buffer as a float array - public: virtual const float *DepthData() const = 0; - - /// \brief Connect to the new depth image signal - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewDepthFrame( - std::function _subscriber) = 0; - - /// \brief Connect to the new rgb point cloud signal. - /// \param[in] _subscriber Subscriber callback function - /// The arguments of the callback function are: - /// _pointCloud Point cloud data. Each point is represented by four - /// 32 bit floating point values [X, Y, Z, RGBA]. The last - /// field can be decoded into 4 unsigned 8 bit color values: - /// uint32_t *rgba = reinterpret_cast(&_rgba) - /// r = static_cast(*rgba >> 24 & 0xFF); - /// g = static_cast(*rgba >> 16 & 0xFF); - /// b = static_cast(*rgba >> 8 & 0xFF); - /// a = static_cast(*rgba >> 0 & 0xFF); - /// _width Point cloud image width - /// _height Point cloud image height - /// _depth Point cloud image depth - /// _format Point cloud image format - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewRgbPointCloud( - std::function _subscriber) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Export.hh b/include/ignition/rendering/Export.hh new file mode 100644 index 000000000..d6119ebf2 --- /dev/null +++ b/include/ignition/rendering/Export.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/include/ignition/rendering/GaussianNoisePass.hh b/include/ignition/rendering/GaussianNoisePass.hh index efb3cc7f8..6e296ef88 100644 --- a/include/ignition/rendering/GaussianNoisePass.hh +++ b/include/ignition/rendering/GaussianNoisePass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,64 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GAUSSIANNOISEPASS_HH_ -#define IGNITION_RENDERING_GAUSSIANNOISEPASS_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/RenderPass.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class GaussianNoisePass GaussianNoisePass.hh \ - * ignition/rendering/GaussianNoisePass.hh - */ - /// \brief A render pass that applies Gaussian noise to the render target - class IGNITION_RENDERING_VISIBLE GaussianNoisePass - : public virtual RenderPass - { - /// \brief Constructor - public: GaussianNoisePass(); - - /// \brief Destructor - public: virtual ~GaussianNoisePass(); - - /// \brief Accessor for mean. - /// \return Mean of Gaussian noise. - public: virtual double Mean() const = 0; - - /// \brief Accessor for stddev. - /// \return Standard deviation of Gaussian noise. - public: virtual double StdDev() const = 0; - - /// \brief Accessor for bias. - /// \return Bias on output. - public: virtual double Bias() const = 0; - - /// \brief Set mean. - /// \param[in] _mean Mean of Gaussian noise. - public: virtual void SetMean(double _mean) = 0; - - /// \brief Set stddev. - /// \param[in] _stdDev Standard deviation of Gaussian noise. - public: virtual void SetStdDev(double _stdDev) = 0; - - /// \brief Set the mean of the bias value. Bias is computed based on - /// the bias mean and bias standard deviation. - /// \sa SetBiasStdDev - public: virtual void SetBiasMean(double _biasMean) = 0; - - /// \brief Set the standard deviation of the bias value. Bias is computed - /// based on the bias mean and bias standard deviation. - /// \sa SetBiasMean - public: virtual void SetBiasStdDev(double _biasStdDev) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Geometry.hh b/include/ignition/rendering/Geometry.hh index 02037ebd7..185a2afe3 100644 --- a/include/ignition/rendering/Geometry.hh +++ b/include/ignition/rendering/Geometry.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,60 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GEOMETRY_HH_ -#define IGNITION_RENDERING_GEOMETRY_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Geometry Geometry.hh ignition/rendering/Geometry.hh - /// \brief Represents a geometric shape to be rendered - class IGNITION_RENDERING_VISIBLE Geometry : - public virtual Object - { - /// \brief Deconstructor - public: virtual ~Geometry() { } - - /// \brief Determine if this Geometry is attached to a Visual - /// \return True if this Geometry has a parent Visual - public: virtual bool HasParent() const = 0; - - /// \brief Get the parent Visual - /// \return the parent Visual - public: virtual VisualPtr Parent() const = 0; - - /// \brief Detach this Geometry from its parent Visual. If this - /// Geometry does not have a parent, no work will be done. - public: virtual void RemoveParent() = 0; - - /// \brief Set the materials of this Geometry. The specified material - /// will be retrieved from the parent Scene. If no material is registered - /// by the given name, no work will be done. - /// \param[in] _name Name of registered Material - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetMaterial(const std::string &_name, - bool _unique = true) = 0; - - /// \brief Set the materials of this Geometry - /// \param[in] _material New Material to be assigned - /// \param[in] _unique True if the given material should be cloned - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true) = 0; - - /// \brief Get the material of this geometry - /// \return Material used by this geometry - public: virtual MaterialPtr Material() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/GizmoVisual.hh b/include/ignition/rendering/GizmoVisual.hh index ed50a664f..040a54a40 100644 --- a/include/ignition/rendering/GizmoVisual.hh +++ b/include/ignition/rendering/GizmoVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,63 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GIZMOVISUAL_HH_ -#define IGNITION_RENDERING_GIZMOVISUAL_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/CompositeVisual.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/TransformType.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class GizmoVisual GizmoVisual.hh ignition/rendering/GizmoVisual.hh - /// \brief A gizmo that contains rotate, translate, and scale visuals - class IGNITION_RENDERING_VISIBLE GizmoVisual : - public virtual CompositeVisual - { - /// \brief Destructor - public: virtual ~GizmoVisual() { } - - /// \brief Set the transform mode of the gizmo. This controls the visual - /// appearance of the gizmo. Only the visuals in the specified mode will - /// be visible, e.g. if set to TM_TRANSLATION mode, then only the - /// translation axis visuals will be visible. - /// \param[in] _mode Transform mode to set the gizmo to - /// \sa GizmoMode - public: virtual void SetTransformMode(TransformMode _mode) = 0; - - /// \brief Get the current transform mode. - /// \return Transform mode - /// \sa SetTransformMode - public: virtual TransformMode Mode() const = 0; - - /// \brief Set the active axis in the gizmo visual - /// \param[in] _axis Axis to be set active - public: virtual void SetActiveAxis(const math::Vector3d &_axis) = 0; - - /// \brief Get the current active axis. - /// \return Active axis - /// \sa SetActiveAxis - public: virtual math::Vector3d ActiveAxis() const = 0; - - /// \brief Get the Transform axis associated with the given id. - /// \param[in] _id Id of the visual associated with a transform axis - /// \return Transform axis with the given id - public: virtual TransformAxis AxisById(unsigned int _id) const = 0; - - /// \brief Get the child visual by axis - /// \return Visual representing the specified transform axis or transform - /// mode - /// \sa TransformAxis, TransformMode - public: virtual VisualPtr ChildByAxis(unsigned int _axis) const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/GpuRays.hh b/include/ignition/rendering/GpuRays.hh index 0d0e8f6dd..2ac4b0b29 100644 --- a/include/ignition/rendering/GpuRays.hh +++ b/include/ignition/rendering/GpuRays.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,152 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GPURAYS_HH_ -#define IGNITION_RENDERING_GPURAYS_HH_ -#include - -#include - -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/Sensor.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class GpuRays GpuRays.hh ignition/rendering/GpuRays.hh - /// \brief Generate depth ray data. - class IGNITION_RENDERING_VISIBLE GpuRays : - public virtual Camera - { - /// \brief Callback function for new frame render event listeners - public: typedef std::function NewFrameListener; - - /// \brief Destructor - public: virtual ~GpuRays() { } - - /// \brief All things needed to get back z buffer for gpu rays data. - /// \return Array of gpu rays data. - public: virtual const float *Data() const = 0; - - /// \brief Copy to the specified memory direction the gpu rays data. - public: virtual void Copy(float *_data) = 0; - - /// \brief Configure behaviour for data values outside of camera range - /// \param[in] _clamp True to clamp data to camera clip distances, - // false to leave data values as +/-inf when out of camera range - public: virtual void SetClamp(const bool _clamp) = 0; - - /// \brief Get behaviour for data values outside of camera range - /// \return True if data values are clampped to camera clip distances, - // false if data values outside of camera range are returned as +/-inf - public: virtual bool Clamp() const = 0; - - /// \brief Connect to a gpu rays frame signal - /// \param[in] _subscriber Callback that is called when a new image is - /// generated. The callback function parameters are: - /// _frame: Image frame is an array of floats. Size is equal - /// to width * height * channels - /// Each gpu rays reading occupies 3 floats - /// Index 0: depth value - /// Index 1: retro value - /// Index 2: 0. Not used - /// _width: Width of image, i.e. number of data in the horizonal scan - /// _height: Height o image, i.e. number of scans in vertical direction - /// _channels: Number of channels, i.e. 3 floats per gpu rays reading - /// _format: Pixel format of the image frame. - /// \return A pointer to the connection. This must be kept in scope. - public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( - std::function _subscriber) = 0; - - /// \brief Set sensor horizontal or vertical - /// \param[in] _horizontal True if horizontal, false if not - public: virtual void SetIsHorizontal(const bool _horizontal) = 0; - - /// \brief Gets if sensor is horizontal - /// \return True if horizontal, false if not - public: virtual bool IsHorizontal() const = 0; - - /// \brief Get the vertical field-of-view. - /// \return The vertical field of view of the gpu rays. - public: virtual math::Angle VFOV() const = 0; - - /// \brief Get the ray count ratio (equivalent to aspect ratio) - /// \return The ray count ratio (equivalent to aspect ratio) - public: virtual double RayCountRatio() const = 0; - - /// \brief Get the ray count ratio (equivalent to aspect ratio) - /// \return The ray count ratio (equivalent to aspect ratio) - public: virtual double RangeCountRatio() const = 0; - - /// \brief Sets the ray count ratio (equivalent to aspect ratio) - /// \param[in] _rayCountRatio ray count ratio (equivalent to aspect ratio) - public: virtual void SetRayCountRatio(const double _rayCountRatio) = 0; - - /// \brief Get minimal horizontal angle value - // \return minimal horizontal angle value - public: virtual ignition::math::Angle AngleMin() const = 0; - - /// \brief Set minimal horizontal angle value - public: virtual void SetAngleMin(double _angle) = 0; - - /// \brief Get maximal horizontal angle value - // \return maximal horizontal angle value - public: virtual ignition::math::Angle AngleMax() const = 0; - - /// \brief Set maximal horizontal angle value - public: virtual void SetAngleMax(double _angle) = 0; - - /// \brief Get horizontal quantity of rays - // \return horizontal quantity of rays - public: virtual int RayCount() const = 0; - - /// \brief Set horizontal quantity of rays - public: virtual void SetRayCount(int _samples) = 0; - - /// \brief Get hoizontal range count, i.e. ray count * horz resolution - // \return horizontal range count - public: virtual int RangeCount() const = 0; - - /// \brief Get vertical quantity of rays - // \return vertical quantity of rays - public: virtual int VerticalRayCount() const = 0; - - /// \brief Set vertical quantity of rays - public: virtual void SetVerticalRayCount(int _samples) = 0; - - /// \brief Get vertical range count, i.e. ray count * vert resolution - // \return Vertical range count - public: virtual int VerticalRangeCount() const = 0; - - /// \brief Get minimal vertical angle value - // \return minimal vertical angle value - public: virtual ignition::math::Angle VerticalAngleMin() const = 0; - - /// \brief Set minimal vertical angle value - public: virtual void SetVerticalAngleMin(const double _angle) = 0; - - /// \brief Get maximal vertical angle value - // \return maximal vertical angle value - public: virtual ignition::math::Angle VerticalAngleMax() const = 0; - - /// \brief Set maximal vertical angle value - // \return minimal vertical angle value - public: virtual void SetVerticalAngleMax(const double _angle) = 0; - - /// \brief Get the number of channels used to store the ray data. - /// \return Channel count. - public: virtual unsigned int Channels() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Grid.hh b/include/ignition/rendering/Grid.hh index e4f95969d..4f77236cc 100644 --- a/include/ignition/rendering/Grid.hh +++ b/include/ignition/rendering/Grid.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,56 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_GRID_HH_ -#define IGNITION_RENDERING_GRID_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Grid Grid.hh ignition/rendering/Grid - /// \brief Represents a grid geometry drawn along the XY plane. - /// If vertical cell count is specified then the grid becomes 3D. - class IGNITION_RENDERING_VISIBLE Grid : - public virtual Geometry - { - /// \brief Destructor - public: virtual ~Grid() { } - - /// \brief Set the number of cells on a planar grid - /// \param[in] _count The number of cells - public: virtual void SetCellCount(const unsigned int _count) = 0; - - /// \brief Get the number of cells on a planar grid - /// \return Number of cells - public: virtual unsigned int CellCount() const = 0; - - /// \brief Set the cell length in one direction. - /// The cells are assumed to be square. - /// \param[in] _len The cell length - public: virtual void SetCellLength(const double _len) = 0; - - /// \brief Get the cell length - /// \return The cell length - public: virtual double CellLength() const = 0; - - /// \brief Set the vertical cell count of the grid. This makes the grid 3D - /// \param[in] _count Number of cells in vertical direction. - public: virtual void SetVerticalCellCount(const unsigned int _count) = 0; - - /// \brief Get the vertical cell count - /// \return The vertical cell count. - public: virtual unsigned int VerticalCellCount() const = 0; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/Image.hh b/include/ignition/rendering/Image.hh index 27c85e732..c618e023a 100644 --- a/include/ignition/rendering/Image.hh +++ b/include/ignition/rendering/Image.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,112 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_IMAGE_HH_ -#define IGNITION_RENDERING_IMAGE_HH_ -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Image Image.hh ignition/rendering/Image.hh - /// \brief Encapsulates a raw image buffer and relevant properties - class IGNITION_RENDERING_VISIBLE Image - { - /// \brief Shared pointer to raw image buffer - typedef std::shared_ptr DataPtr; - - /// \brief Default constructor - public: Image() = default; - - /// \brief Constructor - /// \param[in] _width Image width in pixels - /// \param[in] _height Image height in pixels - /// \param[in] _format Image pixel format - public: Image(unsigned int _width, unsigned int _height, - PixelFormat _format); - - /// \brief Deconstructor - public: ~Image(); - - /// \brief Get image width in pixels - /// \return The image width in pixels - public: unsigned int Width() const; - - /// \brief Get image height in pixels - /// \return The image height in pixels - public: unsigned int Height() const; - - /// \brief Get image pixel format - /// \return The image pixel format - public: PixelFormat Format() const; - - /// \brief Get image channel depth - /// \return The image channel depth - public: unsigned int Depth() const; - - /// \brief Get image channel depth - /// \return The image channel depth - public: unsigned int MemorySize() const; - - /// \brief Get a const pointer to image data - /// \return The const pointer to image data - public: const void *Data() const; - - /// \brief Get a pointer to image data - /// \return The pointer to image data - public: void *Data(); - - /// \brief Get a const pointer to image data. The returned image buffer - /// will be statically cast to the given template type T. - /// \return The const pointer to image data - public: template - const T *Data() const; - - /// \brief Get a pointer to image data. The returned image buffer will be - /// statically cast to the given template type T. - /// \return The pointer to image data - public: template - T *Data(); - - /// \brief Image width in pixels - private: unsigned int width = 0; - - /// \brief Image height in pixels - private: unsigned int height = 0; - - /// \brief Image pixel format - private: PixelFormat format = PF_UNKNOWN; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Pointer to the image data - private: DataPtr data = nullptr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - - ////////////////////////////////////////////////// - template - const T *Image::Data() const - { - return static_cast(this->data.get()); - } - - ////////////////////////////////////////////////// - template - T *Image::Data() - { - return static_cast(this->data.get()); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Light.hh b/include/ignition/rendering/Light.hh index 1cd0b943e..9e884a192 100644 --- a/include/ignition/rendering/Light.hh +++ b/include/ignition/rendering/Light.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,187 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_LIGHT_HH_ -#define IGNITION_RENDERING_LIGHT_HH_ -#include "ignition/math/Color.hh" -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Node.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Light Light.hh ignition/rendering/Light.hh - /// \brief Represents a light source in the scene graph - class IGNITION_RENDERING_VISIBLE Light : - public virtual Node - { - /// \brief Deconstructor - public: virtual ~Light() { } - - /// \brief Get the diffuse color - /// \return The diffuse color - public: virtual math::Color DiffuseColor() const = 0; - - /// \brief Set the diffuse color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetDiffuseColor(double _r, double _g, double _b, - double _a = 1.0) = 0; - - /// \brief Set the diffuse color - /// \param[in] _color New diffuse color - public: virtual void SetDiffuseColor(const math::Color &_color) = 0; - - /// \brief Get the specular color - /// \return The specular color - public: virtual math::Color SpecularColor() const = 0; - - /// \brief Set the specular color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetSpecularColor(double _r, double _g, double _b, - double _a = 1.0) = 0; - - /// \brief Set the specular color - /// \param[in] _color New specular color - public: virtual void SetSpecularColor(const math::Color &_color) = 0; - - /// \brief Get the attenuation constant value - /// \return The attenuation constant value - public: virtual double AttenuationConstant() const = 0; - - /// \brief Set the attenuation constant value - /// \param[in] _value New attenuation constant value - public: virtual void SetAttenuationConstant(double _value) = 0; - - /// \brief Get the attenuation linear value - /// \return The attenuation linear value - public: virtual double AttenuationLinear() const = 0; - - /// \brief Set the attenuation linear value - /// \param[in] _value New attenuation linear value - public: virtual void SetAttenuationLinear(double _value) = 0; - - /// \brief Get the attenuation quadratic value - /// \return The attenuation quadratic value - public: virtual double AttenuationQuadratic() const = 0; - - /// \brief Set the attenuation quadratic value - /// \param[in] _value New attenuation quadratic value - public: virtual void SetAttenuationQuadratic(double _value) = 0; - - /// \brief Get the attenuation range - /// \return The attenuation range - public: virtual double AttenuationRange() const = 0; - - /// \brief Set the attenuation range - /// \param[in] _range New attenuation range - public: virtual void SetAttenuationRange(double _range) = 0; - - /// \brief Determine if this light cast shadows - /// \return True if this light cast shadows - public: virtual bool CastShadows() const = 0; - - /// \brief Specify if this light should cast shadows - /// \param[in] _castShadows True if this light cast shadows - public: virtual void SetCastShadows(bool _castShadows) = 0; - }; - - /// \class DirectionalLight Light.hh ignition/rendering/Light.hh - /// \brief Represents a infinite directional light - class IGNITION_RENDERING_VISIBLE DirectionalLight : - public virtual Light - { - /// \brief Destructor - public: virtual ~DirectionalLight() { } - - /// \brief Get the direction of the light - /// \return The direction of the light - public: virtual math::Vector3d Direction() const = 0; - - /// \brief Set the direction of the light - /// \param[in] _x X-component of direction vector - /// \param[in] _y Y-component of direction vector - /// \param[in] _z Z-component of direction vector - public: virtual void SetDirection(double _x, double _y, double _z) = 0; - - /// \brief Set the direction of the light - /// \param[in] _dir New direction vector - public: virtual void SetDirection(const math::Vector3d &_dir) = 0; - }; - - /// \class PointLight Light.hh ignition/rendering/Light.hh - /// \brief Represents a point light - class IGNITION_RENDERING_VISIBLE PointLight : - public virtual Light - { - /// \brief Deconstructor - public: virtual ~PointLight() { } - }; - - /// \class SpotLight Light.hh ignition/rendering/Light.hh - /// \brief Represents a spotlight - class IGNITION_RENDERING_VISIBLE SpotLight : - public virtual Light - { - /// \brief Deconstructor - public: virtual ~SpotLight() { } - - /// \brief Get direction of the light - /// \return The direction of the light - public: virtual math::Vector3d Direction() const = 0; - - /// \brief Set the direction of the light - /// \param[in] _x X-component of direction vector - /// \param[in] _y Y-component of direction vector - /// \param[in] _z Z-component of direction vector - public: virtual void SetDirection(double _x, double _y, double _z) = 0; - - /// \brief Set the direction of the light - /// \param[in] _dir New direction vector - public: virtual void SetDirection(const math::Vector3d &_dir) = 0; - - /// \brief Get the inner angle of the spotlight - /// \return The inner angle of the spotlight - public: virtual math::Angle InnerAngle() const = 0; - - /// \brief Set the inner angle of the spotlight - /// \param[in] _radians New inner angle of the spotlight in radians - public: virtual void SetInnerAngle(double _radians) = 0; - - /// \brief Set the inner angle of the spotlight - /// \param[in] _angle New inner angle of the spotlight - public: virtual void SetInnerAngle(const math::Angle &_angle) = 0; - - /// \brief Get the outer angle of the spotlight - /// \return The outer angle of the spotlight - public: virtual math::Angle OuterAngle() const = 0; - - /// \brief Set the outer angle of the spotlight - /// \param[in] _radians New outer angle of the spotlight in radians - public: virtual void SetOuterAngle(double _radians) = 0; - - /// \brief Set the outer angle of the spotlight - /// \param[in] _angle New outer angle of the spotlight - public: virtual void SetOuterAngle(const math::Angle &_angle) = 0; - - /// \brief Get the falloff of the spotlight - /// \return The falloff of the spotlight - public: virtual double Falloff() const = 0; - - /// \brief Set the falloff of the spotlight - /// \param[in] _falloff New falloff of the spotlight - public: virtual void SetFalloff(double _falloff) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Marker.hh b/include/ignition/rendering/Marker.hh index ae42e3939..662658c4a 100644 --- a/include/ignition/rendering/Marker.hh +++ b/include/ignition/rendering/Marker.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,123 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_MARKER_HH_ -#define IGNITION_RENDERING_MARKER_HH_ -#include -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Enum for marker types - enum IGNITION_RENDERING_VISIBLE MarkerType - { - /// \brief No type - MT_NONE = 0, - - /// \brief Box geometry - MT_BOX = 1, - - /// \brief Cylinder geometry - MT_CYLINDER = 2, - - /// \brief Line strip primitive - MT_LINE_STRIP = 3, - - /// \brief Line list primitive - MT_LINE_LIST = 4, - - /// \brief Points primitive - MT_POINTS = 5, - - /// \brief Sphere geometry - MT_SPHERE = 6, - - /// \brief Text geometry - MT_TEXT = 7, - - /// \brief Triangle fan primitive - MT_TRIANGLE_FAN = 8, - - /// \brief Triangle list primitive - MT_TRIANGLE_LIST = 9, - - /// \brief Triangle strip primitive - MT_TRIANGLE_STRIP = 10 - }; - - /// \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 Clear the points of the marker, if applicable - public: virtual void ClearPoints() = 0; - - /// \brief Add a point with its respective color to the marker - /// \param[in] _x X coordinate - /// \param[in] _y Y coordinate - /// \param[in] _z Z coordinate - /// \param[in] _color The color the point is set to - public: virtual void AddPoint(double _x, - double _y, double _z, - const ignition::math::Color &_color) = 0; - - /// \brief Add a point with its respective color to the marker - /// \param[in] _pt A vector containing the position of the point - /// \param[in] _color The color the point is set to - public: virtual void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color) = 0; - - /// \brief Set an existing point's vector - /// \param[in] _index The index of the point - /// \param[in] _value The new positional vector of the point - public: virtual void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value) = 0; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/Material.hh b/include/ignition/rendering/Material.hh index 114dc6a08..ea472d9ba 100644 --- a/include/ignition/rendering/Material.hh +++ b/include/ignition/rendering/Material.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,343 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_MATERIAL_HH_ -#define IGNITION_RENDERING_MATERIAL_HH_ -#include -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/ShaderType.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief An enum for the type of material - enum IGNITION_RENDERING_VISIBLE MaterialType - { - /// \brief Classic shading, i.e. variants of Phong - MT_CLASSIC = 0, - - /// \brief Physically Based Shading - MT_PBS = 1 - }; - - /// \class Material Material.hh ignition/rendering/Material.hh - /// \brief Represents a surface material of a Geometry - class IGNITION_RENDERING_VISIBLE Material : - public virtual Object - { - /// \brief Deconstructor - public: virtual ~Material() { } - - /// \brief Determine if lighting affects this material - /// \return True if lighting affects this material - public: virtual bool LightingEnabled() const = 0; - - /// \brief Specify if lighting affects this material - /// \param[in] _enabled True if lighting affects this material - public: virtual void SetLightingEnabled(const bool _enabled) = 0; - - /// \brief Specify if depth buffer checking is enabled - /// \param[in] _enabled True if depth check is enabled - public: virtual void SetDepthCheckEnabled(bool _enabled) = 0; - - /// \brief Determine if depth buffer checking is enabled - /// \return True if depth check is enabled - public: virtual bool DepthCheckEnabled() const = 0; - - /// \brief Specify if depth buffer writing is enabled - /// \param[in] _enabled True if depth buffer writing is enabled - public: virtual void SetDepthWriteEnabled(bool _enabled) = 0; - - /// \brief Determine if depth buffer writing is enabled - /// \return True if depth buffer writing is enabled - public: virtual bool DepthWriteEnabled() const = 0; - - /// \brief Get the ambient color - /// \return The ambient color - public: virtual math::Color Ambient() const = 0; - - /// \brief Set the ambient color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetAmbient(const double _r, const double _g, - const double _b, const double _a = 1.0) = 0; - - /// \brief Set the ambient color - /// \param[in] _color New ambient color - public: virtual void SetAmbient(const math::Color &_color) = 0; - - /// \brief Get the diffuse color - /// \return The diffuse color - public: virtual math::Color Diffuse() const = 0; - - /// \brief Set the diffuse color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetDiffuse(const double _r, const double _g, - const double _b, const double _a = 1.0) = 0; - - /// \brief Set the diffuse color - /// \param[in] _color New diffuse color - public: virtual void SetDiffuse(const math::Color &_color) = 0; - - /// \brief Get the specular color - /// \return The specular color - public: virtual math::Color Specular() const = 0; - - /// \brief Set the specular color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetSpecular(const double _r, const double _g, - const double _b, const double _a = 1.0) = 0; - - /// \brief Set the specular color - /// \param[in] _color New specular color - public: virtual void SetSpecular(const math::Color &_color) = 0; - - /// \brief Get the emissive color - /// \return The emissive color - public: virtual math::Color Emissive() const = 0; - - /// \brief Set the emissive color - /// \param[in] _r Red value - /// \param[in] _g Green value - /// \param[in] _b Blue value - /// \param[in] _a Alpha value - public: virtual void SetEmissive(const double _r, const double _g, - const double _b, const double _a = 1.0) = 0; - - /// \brief Set the emissive color - /// \param[in] _color New emissive color - public: virtual void SetEmissive(const math::Color &_color) = 0; - - /// \brief Get the shininess value - /// \return The shininess value - public: virtual double Shininess() const = 0; - - /// \brief Set the shininess value - /// \param[in] _shininess New shininess value - public: virtual void SetShininess(const double _shininess) = 0; - - /// \brief Get the transparency value - /// \return The transparency value - public: virtual double Transparency() const = 0; - - /// \brief Configuration for Depth Material - /// \param[in] far Far distance for normalized output - /// \param[in] near Near distance for normalized output - public: virtual void SetDepthMaterial(const double far, - const double near) = 0; - - /// \brief Set the transparency value - /// \param[in] _transparency New transparency value - public: virtual void SetTransparency(const double _transparency) = 0; - - /// \brief 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 Set the roughness value. Only affects material of type MT_PBS - /// \param[in] _roughness Roughness to set to - public: virtual void SetRoughness(const float _roughness) = 0; - - /// \brief Get the roughness value of this material. - /// \return Material roughness - public: virtual float Roughness() const = 0; - - /// \brief Set the metalness value. Only affects material of type MT_PBS - /// \param[in] _metalness Metalness to set to - public: virtual void SetMetalness(const float _metalness) = 0; - - /// \brief Get the metalness value of this material - /// \return Material metalness - public: virtual float Metalness() const = 0; - - /// \brief Removes any metalness map mapped to this material - public: virtual enum MaterialType Type() const = 0; - - /// \brief Get the ShaderType value - /// \return The ShaderType value - public: virtual enum ShaderType ShaderType() const = 0; - - /// \brief Set the ShaderType value - /// \param[in] _type New ShaderType value - public: virtual void SetShaderType(enum ShaderType _type) = 0; - - /// \brief Clone this material - /// \return New cloned material - public: virtual MaterialPtr Clone(const std::string &_name = "") - const = 0; - - /// \brief Copy properties from given Material - /// \param[in] _material Source Material to be copied from - public: virtual void CopyFrom(ConstMaterialPtr _material) = 0; - - /// \brief Copy properties from given Material - /// \param[in] _material Source Material to be copied from - public: virtual void CopyFrom(const common::Material &_material) = 0; - - /// \brief Get path to the vertex shader - /// \return Path to vertex shader - public: virtual std::string VertexShader() const = 0; - - /// \brief Get params for the vertex shader - /// \return editable parameters - public: virtual ShaderParamsPtr VertexShaderParams() = 0; - - /// \brief Set the vertex shader - /// \param[in] _path path to a file containing a glsl shader - public: virtual void SetVertexShader(const std::string &_path) = 0; - - /// \brief Get path to the fragment shader - /// \return Path to fragment shader - public: virtual std::string FragmentShader() const = 0; - - /// \brief Get params for the fragment shader - /// \return editable parameters - public: virtual ShaderParamsPtr FragmentShaderParams() = 0; - - /// \brief Set the fragment shader - /// \param[in] _path path to a file containing a glsl shader - public: virtual void SetFragmentShader(const std::string &_path) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Mesh.hh b/include/ignition/rendering/Mesh.hh index 59c194b93..83406d35f 100644 --- a/include/ignition/rendering/Mesh.hh +++ b/include/ignition/rendering/Mesh.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,105 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_MESH_HH_ -#define IGNITION_RENDERING_MESH_HH_ -#include -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Mesh Mesh.hh ignition/rendering/Mesh - /// \brief Represents a collection of mesh geometries - class IGNITION_RENDERING_VISIBLE Mesh : - public virtual Geometry - { - /// \brief Destructor - public: virtual ~Mesh() { } - - /// \brief Check whether the mesh has skeleton - /// \return True if the mesh has skeleton - public: virtual bool HasSkeleton() const = 0; - - /// \brief Get the skeleton local transforms - /// \return Map of skeleton local transformations - /// * Map holding: - /// * Skeleton node names - /// * Local transformations of the skeleton nodes - public: virtual std::map - SkeletonLocalTransforms() const = 0; - - /// \brief Set transforms for the skeleton - /// \param[in] _tfs Map of skeleton local transformations - /// * Map holding: - /// * Skeleton node names - /// * Local transformations of the skeleton nodes - /// \return True if all the transformations are set to the skeleton - public: virtual void SetSkeletonLocalTransforms( - const std::map &_tfs) = 0; - - /// \brief Get 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; - }; - - /// \class SubMesh Mesh.hh ignition/rendering/Mesh.hh - /// \brief Represents a single mesh geometry - class IGNITION_RENDERING_VISIBLE SubMesh : - public virtual Object - { - /// \brief Deconstructor - public: virtual ~SubMesh() { } - - /// \brief Get the currently assigned material - /// \return The currently assigned material - public: virtual MaterialPtr Material() const = 0; - - /// \brief Set the materials of this SubMesh. The specified material - /// will be retrieved from the parent Scene. If no material is registered - /// by the given name, no work will be done. - /// \param[in] _name Name of registered Material - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetMaterial(const std::string &_name, - bool _unique = true) = 0; - - /// \brief Set the materials of this SubMesh - /// \param[in] _material New Material to be assigned - /// \param[in] _unique True if the given material should be cloned - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/MeshDescriptor.hh b/include/ignition/rendering/MeshDescriptor.hh index e7b9f9831..f22291457 100644 --- a/include/ignition/rendering/MeshDescriptor.hh +++ b/include/ignition/rendering/MeshDescriptor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,68 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_MESHDESCRIPTOR_HH_ -#define IGNITION_RENDERING_MESHDESCRIPTOR_HH_ -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace common - { - class Mesh; - } -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \struct MeshDescriptor MeshDescriptor.hh - /// ignition/rendering/MeshDescriptor.hh - /// \brief Describes how a Mesh should be loaded - struct IGNITION_RENDERING_VISIBLE MeshDescriptor - { - /// \brief Constructor - public: MeshDescriptor(); - - /// \brief Constructor. A common::Mesh will be retrieved from the - /// MeshManager by the given name upon a call to Normalize. - /// \param[in] _meshName Name of the mesh to load - public: explicit MeshDescriptor(const std::string &_meshName); - - /// \brief Constructor - /// \param[in] _mesh Mesh to load - public: explicit MeshDescriptor(const common::Mesh *_mesh); - - /// \brief Ensures both the meshName and mesh member variables have been - /// assigned. If mesh is not null, it will be used to override the value - /// of meshName. - public: void Load(); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief common::Mesh object - public: const common::Mesh *mesh = nullptr; - - /// \brief Name of the registered Mesh - public: std::string meshName; - - /// \brief Name of the sub-mesh to be loaded. An empty string signifies - /// all sub-meshes should be loaded. - public: std::string subMeshName; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Denotes if the loaded sub-mesh vertices should be centered - public: bool centerSubMesh = false; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/MoveToHelper.hh b/include/ignition/rendering/MoveToHelper.hh index d14f9da1a..7fb4bab57 100644 --- a/include/ignition/rendering/MoveToHelper.hh +++ b/include/ignition/rendering/MoveToHelper.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,87 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_MOVETOHELPER_HH_ -#define IGNITION_RENDERING_MOVETOHELPER_HH_ + */ -#include - -#include -#include - -#include -#include - -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - // Inline bracket to help doxygen filtering. - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // forward declaration - class MoveToHelperPrivate; - - /// \brief Helper class for animating a user camera to move to a target - /// entity - class IGNITION_RENDERING_VISIBLE MoveToHelper - { - public: MoveToHelper(); - - public: ~MoveToHelper(); - - /// \brief Move the camera to look at the specified target - /// param[in] _camera Camera to be moved - /// param[in] _target Target to look at - /// param[in] _duration Duration of the move to animation, in seconds. - /// param[in] _onAnimationComplete Callback function when animation is - /// complete - public: void MoveTo(const rendering::CameraPtr &_camera, - const rendering::NodePtr &_target, double _duration, - std::function _onAnimationComplete); - - /// \brief Move the camera to the specified pose. - /// param[in] _camera Camera to be moved - /// param[in] _target Pose to move to - /// param[in] _duration Duration of the move to animation, in seconds. - /// param[in] _onAnimationComplete Callback function when animation is - /// complete - public: void MoveTo(const rendering::CameraPtr &_camera, - const math::Pose3d &_target, double _duration, - std::function _onAnimationComplete); - - /// \brief Move the camera to look at the specified target - /// param[in] _camera Camera to be moved - /// param[in] _direction The pose to assume relative to the - /// entit(y/ies), (0, 0, 0) indicates to return the camera back to the - /// home pose originally loaded in from the sdf. - /// param[in] _duration Duration of the move to animation, in seconds. - /// param[in] _onAnimationComplete Callback function when animation is - /// complete - public: void LookDirection(const rendering::CameraPtr &_camera, - const math::Vector3d &_direction, const math::Vector3d &_lookAt, - double _duration, std::function _onAnimationComplete); - - /// \brief Add time to the animation. - /// \param[in] _time Time to add in seconds - public: void AddTime(double _time); - - /// \brief Get whether the move to helper is idle, i.e. no animation - /// is being executed. - /// \return True if idle, false otherwise - public: bool Idle() const; - - /// \brief Set the initial camera pose - /// param[in] _pose The init pose of the camera - public: void SetInitCameraPose(const math::Pose3d &_pose); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Node.hh b/include/ignition/rendering/Node.hh index 4ec5da2e1..f9defde3b 100644 --- a/include/ignition/rendering/Node.hh +++ b/include/ignition/rendering/Node.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,296 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_NODE_HH_ -#define IGNITION_RENDERING_NODE_HH_ -#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 { - // - /// \class Node Node.hh ignition/rendering/Node.hh - /// \brief Represents a single posable node in the scene graph - class IGNITION_RENDERING_VISIBLE Node : - public virtual Object - { - /// \brief Deconstructor - public: virtual ~Node() { } - - /// \brief Determine if this Node is attached to another Node. - /// \return True if this Node has a parent Node - public: virtual bool HasParent() const = 0; - - /// \brief Get the parent Node - /// \return the parent Node - public: virtual NodePtr Parent() const = 0; - - /// \brief Detach this Node from its parent. If this - /// Node does not have a parent, no work will be done. - public: virtual void RemoveParent() = 0; - - /// \brief Get the local pose - /// \return The local pose - public: virtual math::Pose3d LocalPose() const = 0; - - /// \brief Set the local pose - /// \param[in] _pose New local pose - public: virtual void SetLocalPose(const math::Pose3d &_pose) = 0; - - /// \brief Get the local position - /// \return The local position - public: virtual math::Vector3d LocalPosition() const = 0; - - /// \brief Set the local position - /// \param[in] _x X-coordinate - /// \param[in] _y Y-coordinate - /// \param[in] _z Z-coordinate - public: virtual void SetLocalPosition(double _x, double _y, - double _z) = 0; - - /// \brief Set the local position - /// \param[in] _position New local position - public: virtual void SetLocalPosition( - const math::Vector3d &_position) = 0; - - /// \brief Get the local rotation - /// \return The local rotation - public: virtual math::Quaterniond LocalRotation() const = 0; - - /// \brief Set the local rotation - /// \param[in] _r roll - /// \param[in] _p pitch - /// \param[in] _y yaw - public: virtual void SetLocalRotation(double _r, double _p, - double _y) = 0; - - /// \brief Set the local rotation - /// \param[in] _w W-coordinate - /// \param[in] _x X-coordinate - /// \param[in] _y Y-coordinate - /// \param[in] _z Z-coordinate - public: virtual void SetLocalRotation(double _w, double _x, double _y, - double _z) = 0; - - /// \brief Set the local rotation - /// \param[in] _rotation New local rotation - public: virtual void SetLocalRotation( - const math::Quaterniond &_rotation) = 0; - - /// \brief Get the world pose - /// \return The world pose - public: virtual math::Pose3d WorldPose() const = 0; - - /// \brief Set the world pose - /// \param[in] _pose New world pose - public: virtual void SetWorldPose(const math::Pose3d &_pose) = 0; - - /// \brief Get the world position - /// \return The world position - public: virtual math::Vector3d WorldPosition() const = 0; - - /// \brief Set the world position - /// \param[in] _x X-coordinate - /// \param[in] _y Y-coordinate - /// \param[in] _z Z-coordinate - public: virtual void SetWorldPosition(double _x, double _y, - double _z) = 0; - - /// \brief Set the world position - /// \param[in] _position New world position - public: virtual void SetWorldPosition( - const math::Vector3d &_position) = 0; - - /// \brief Get the world rotation - /// \return The world rotation - public: virtual math::Quaterniond WorldRotation() const = 0; - - /// \brief Set the world rotation - /// \param[in] _r roll - /// \param[in] _p pitch - /// \param[in] _y yaw - public: virtual void SetWorldRotation(double _r, double _p, - double _y) = 0; - - /// \brief Set the world rotation - /// \param[in] _w W-coordinate - /// \param[in] _x X-coordinate - /// \param[in] _y Y-coordinate - /// \param[in] _z Z-coordinate - public: virtual void SetWorldRotation(double _w, double _x, double _y, - double _z) = 0; - - /// \brief Set the world rotation - /// \param[in] _rotation New world rotation - public: virtual void SetWorldRotation( - const math::Quaterniond &_rotation) = 0; - - /// \brief Convert given world pose to local pose - /// \param[in] _pose World pose to be converted - public: virtual math::Pose3d WorldToLocal( - const math::Pose3d &_pose) const = 0; - - /// \brief Get position of origin - /// \return The position of the origin - public: virtual math::Vector3d Origin() const = 0; - - /// \brief Set position of origin. The position should be relative to the - /// original origin of the geometry. - /// \param[in] _x X-coordinate - /// \param[in] _y Y-coordinate - /// \param[in] _z Z-coordinate - public: virtual void SetOrigin(double _x, double _y, double _z) = 0; - - /// \brief Set position of origin. The position should be relative to the - /// original origin of the geometry. - /// \param[in] _origin New origin position - public: virtual void SetOrigin(const math::Vector3d &_origin) = 0; - - /// \brief Get the local scale - /// \return The local scale - public: virtual math::Vector3d LocalScale() const = 0; - - /// \brief Set the local scale. The given scale will be assigned to the - /// x, y, and z coordinates. - /// \param[in] _scale New local scale - public: virtual void SetLocalScale(double _scale) = 0; - - /// \brief Set the local scale - /// \param[in] _x New x-coordinate scale - /// \param[in] _y New y-coordinate scale - /// \param[in] _z New z-coordinate scale - public: virtual void SetLocalScale(double _x, double _y, double _z) = 0; - - /// \brief Set the local scale - /// \param[in] _scale New local scale - public: virtual void SetLocalScale(const math::Vector3d &_scale) = 0; - - /// \brief Get the world scale - /// \return The world scale - public: virtual math::Vector3d WorldScale() const = 0; - - /// \brief Set the world scale. The given scale will be assigned to the - /// x, y, and z coordinates. - /// \param[in] _scale New world scale - public: virtual void SetWorldScale(double _scale) = 0; - - /// \brief Set the world scale - /// \param[in] _x New x-coordinate scale - /// \param[in] _y New y-coordinate scale - /// \param[in] _z New z-coordinate scale - public: virtual void SetWorldScale(double _x, double _y, double _z) = 0; - - /// \brief Set the world scale - /// \param[in] _scale New world scale - public: virtual void SetWorldScale(const math::Vector3d &_scale) = 0; - - /// \brief Scale the current scale by the given scalar. The given scalar - /// will be assigned to the x, y, and z coordinates. - /// \param[in] _scale Scalar to alter the current scale - public: virtual void Scale(double _scale) = 0; - - /// \brief Scale the current scale by the given scalars - /// \param[in] _x Scalar to alter the current x-coordinate scale - /// \param[in] _y Scalar to alter the current y-coordinate scale - /// \param[in] _z Scalar to alter the current z-coordinate scale - public: virtual void Scale(double _x, double _y, double _z) = 0; - - /// \brief Scale the current scale by the given scalars - /// \param[in] _scale Scalars to alter the current scale - public: virtual void Scale(const math::Vector3d &_scale) = 0; - - /// \brief Determine if this visual inherits scale from this parent - /// \return True if this visual inherits scale from this parent - public: virtual bool InheritScale() const = 0; - - /// \brief Specify if this visual inherits scale from its parent - /// \param[in] _inherit True if this visual inherits scale from its parent - public: virtual void SetInheritScale(bool _inherit) = 0; - - /// \brief Get number of child nodes - /// \return The number of child nodes - public: virtual unsigned int ChildCount() const = 0; - - /// \brief Determine if given node is an attached child - /// \return True if given node is an attached child - public: virtual bool HasChild(ConstNodePtr _child) const = 0; - - /// \brief Determine if node with given ID is an attached child - /// \param[in] _id ID of the node in question - /// \return True if node with given ID is an attached child - public: virtual bool HasChildId(unsigned int _id) const = 0; - - /// \brief Determine if node with given name is an attached child - /// \param[in] _name Name of the node in question - /// \return True if node with given name is an attached child - public: virtual bool HasChildName(const std::string &_name) const = 0; - - /// \brief Get node with given ID. If no child exists with given ID, NULL - /// will be returned. - /// \param[in] _id ID of the desired node - /// \return The specified node - public: virtual NodePtr ChildById(unsigned int _id) const = 0; - - /// \brief Get node with given name. If no child exists with given name, - /// NULL will be returned. - /// \param[in] _name Name of the desired node - /// \return The specified node - public: virtual NodePtr ChildByName( - const std::string &_name) const = 0; - - /// \brief Get node at given index. If no child exists at given index, - /// NULL will be returned. - /// \param[in] _index Index of the desired node - /// \return The specified node - public: virtual NodePtr ChildByIndex(unsigned int _index) const = 0; - - /// \brief Add the given node to this node. If the given node is - /// already a child, no work will be done. - /// \param[in] _child Child node to be added - public: virtual void AddChild(NodePtr _child) = 0; - - /// \brief Remove (detach) the given node from this node. If the given - /// node is not a child of this node, no work will be done. - /// \param[in] _child Child node to be removed - /// \return The removed child node - public: virtual NodePtr RemoveChild(NodePtr _child) = 0; - - /// \brief Remove (detach) the node with the given ID from this node. - /// If the specified node is not a child of this node, no work will be - /// done. - /// \param[in] _id ID of the child node to be removed - /// \return The removed child node - public: virtual NodePtr RemoveChildById(unsigned int _id) = 0; - - /// \brief Remove (detach) the node with the given name from this node. - /// If the specified node is not a child of this node, no work will be - /// done. - /// \param[in] _name Name of the child node to be removed - /// \return The removed child node - public: virtual NodePtr RemoveChildByName(const std::string &_name) = 0; - - /// \brief Remove (detach) the node at the given index from this node. - /// If the specified node is not a child of this node, no work will be - /// done. - /// \param[in] _index Index of the child node to be removed - /// \return The removed child node - public: virtual NodePtr RemoveChildByIndex(unsigned int _index) = 0; - - /// \brief Remove all child nodes from this node - /// This detaches all the child nodes but does not destroy them - public: virtual void RemoveChildren() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Object.hh b/include/ignition/rendering/Object.hh index 45ce3e894..a3a6bcac7 100644 --- a/include/ignition/rendering/Object.hh +++ b/include/ignition/rendering/Object.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,59 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OBJECT_HH_ -#define IGNITION_RENDERING_OBJECT_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Object Object.hh ignition/rendering/Object.hh - /// \brief Represents an object present in the scene graph. This includes - /// sub-meshes, materials, render targets, as well as posable nodes. - class IGNITION_RENDERING_VISIBLE Object - { - /// \brief Destructor - public: virtual ~Object() { } - - /// \brief Get the object ID. This ID will be unique across all objects - /// inside a given scene, but necessarily true for objects across - /// different scenes. - /// \return The object ID - public: virtual unsigned int Id() const = 0; - - /// \brief Get the object name. This name will be unique across all - /// objects inside a given scene, but necessarily true for objects across - /// different scenes. - /// \return The object name - public: virtual std::string Name() const = 0; - - /// \brief Get the Scene that created this object. - /// \return The parent scene - public: virtual ScenePtr Scene() const = 0; - - /// \brief Prepare this object and any of its children for rendering. - /// This should be called for each object in a scene just before - /// rendering, which can be achieved by a single call to Scene::PreRender - public: virtual void PreRender() = 0; - - /// \brief Post process this object and any of its children after - /// rendering. - public: virtual void PostRender() = 0; - - /// \brief Destroy any resources associated with this object. Invoking - /// any other functions after destroying an object will result in - /// undefined behavior. - public: virtual void Destroy() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/OrbitViewController.hh b/include/ignition/rendering/OrbitViewController.hh index e1443405e..d464bddb2 100644 --- a/include/ignition/rendering/OrbitViewController.hh +++ b/include/ignition/rendering/OrbitViewController.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,77 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_ORBITVIEWCONTROLLER_HH_ -#define IGNITION_RENDERING_ORBITVIEWCONTROLLER_HH_ -#include - -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/ViewController.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations - class OrbitViewControllerPrivate; - - /// \class OrbitViewController OrbitViewController.hh - /// ignition/rendering/OrbitViewController.hh - /// \brief A camera view controller - class IGNITION_RENDERING_VISIBLE OrbitViewController - : public virtual ViewController - { - /// \brief Deconstructor - public: OrbitViewController(); - - /// \brief Deconstructor - public: explicit OrbitViewController(const CameraPtr &_camera); - - /// \brief Deconstructor - public: virtual ~OrbitViewController(); - - /// \brief Set the camera that will be controlled by this view controller. - /// \param[in] _camera Camera to control - public: virtual void SetCamera(const CameraPtr &_camera); - - /// \brief Get the camera that is controlled by this view controller. - /// \return Camera being controlled - public: virtual CameraPtr Camera() const; - - /// \brief Set target point for pan, zoom, oribit - /// \param[in] _target Target point in world coordinates - public: virtual void SetTarget(const math::Vector3d &_target); - - /// \brief Get target point for pan, zoom, oribit - /// \return target point in world coordinates - public: virtual math::Vector3d Target() const; - - /// \brief Set zoom amount - /// \param[in] _value Camera zoon value, e.g. mouse scroll delta - public: virtual void Zoom(const double _value); - - /// \brief Set camera pan (translational movement) around target point. - /// \param[in] _value Pan amount in image plane, e.g. mouse drag delta. - public: virtual void Pan(const math::Vector2d &_value); - - /// \brief Set camera orbit (rotational movement) around target point. - /// \param[in] _value robit amount in image plane, e.g. mouse drag delta - public: virtual void Orbit(const math::Vector2d &_value); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Private data pointer - public: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/PixelFormat.hh b/include/ignition/rendering/PixelFormat.hh index cf0832092..d01a8eb86 100644 --- a/include/ignition/rendering/PixelFormat.hh +++ b/include/ignition/rendering/PixelFormat.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,117 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_PIXELFORMAT_HH_ -#define IGNITION_RENDERING_PIXELFORMAT_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \enum PixelFormat PixelFormat.hh ignition/rendering/PixelFormat.hh - /// \brief Image pixel format types - enum IGNITION_RENDERING_VISIBLE PixelFormat - { - /// < Unknown or errant type - PF_UNKNOWN = 0, - /// < Grayscale, 1-byte per channel - PF_L8 = 1, - /// < RGB, 1-byte per channel - PF_R8G8B8 = 2, - /// < BGR, 1-byte per channel - PF_B8G8R8 = 3, - /// < Bayer RGGB, 1-byte per channel - PF_BAYER_RGGB8 = 4, - /// < Bayer BGGR, 1-byte per channel - PF_BAYER_BGGR8 = 5, - /// < Bayer GBGR, 1-byte per channel - PF_BAYER_GBGR8 = 6, - /// < Bayer GRGB, 1-byte per channel - PF_BAYER_GRGB8 = 7, - // Float32 format one channel - PF_FLOAT32_R = 8, - // Float32 format and RGB - PF_FLOAT32_RGBA = 9, - // Float32 format and RGB - PF_FLOAT32_RGB = 10, - // 16 bit single channel - PF_L16 = 11, - /// < Number of pixel format types - PF_COUNT = 12 - }; - - /// \class PixelUtil PixelFormat.hh ignition/rendering/PixelFormat.hh - /// \brief Provides supporting functions for PixelFormat enum - class IGNITION_RENDERING_VISIBLE PixelUtil - { - /// \brief Determine if given format is valid PixelFormat enum - /// \param[in] _format Enum value to be evaluated - public: static bool IsValid(PixelFormat _format); - - /// \brief Sanitize given format. If the given value is invalid, - /// PF_UNKNOWN will be returned, otherwise input will be returned - /// unchanged. - /// \param[in] _format Image pixel format to be sanitized - /// \return The sanitized pixel format - public: static PixelFormat Sanitize(PixelFormat _format); - - /// \brief Get human-readable name for pixel format value. - /// \param[in] _format Image pixel format - /// \return The format name - public: static std::string Name(PixelFormat _format); - - /// \brief Get number of channels for given format. If an invalid format - /// is given, 0 will be returned. - /// \param[in] _format Image pixel format - /// \return The channel count - public: static unsigned int ChannelCount(PixelFormat _format); - - /// \brief Get number of bytes per channel for given format. If an invalid - /// format is given, 0 will be returned. - /// \param[in] _format Image pixel format - /// \return The number of bytes per channel - public: static unsigned int BytesPerChannel(PixelFormat _format); - - /// \brief Get number of bytes per pixel for given format. If an invalid - /// format is given, 0 will be returned. This is simply the product of - /// GetChannelCount and GetBytesPerChannel. - /// \return The number of bytes per pixel - public: static unsigned int BytesPerPixel(PixelFormat _format); - - /// \brief Get total memory size in bytes for an image with the given - /// format and dimensions. If an invalid format is given, 0 will be - /// returned. This is simply the product of GetBytesPerPixel, _width, - /// and, _height. - /// \param[in] _format Image pixel format - /// \param[in] _width Image width in pixels - /// \param[in] _height Image height in pixels - /// \return The number of bytes per pixel - public: static unsigned int MemorySize(PixelFormat _format, - unsigned int _width, unsigned int _height); - - /// \brief Get enum value by human-readable name. The given string should - /// match watch is returned by GetName. If an invalid name is given, - /// PF_UNKNOWN will be returned. - /// \param[in] _name Name of the pixel format to be retrieved - /// \return The specified PixelFormat enum value - public: static PixelFormat Enum(const std::string &_name); - - /// \brief Array of human-readable names for each PixelFormat - private: static const char *names[PF_COUNT]; - - /// \brief Array of channel counts for each PixelFormat - private: static const unsigned char channelCounts[PF_COUNT]; - - /// \brief Array of bytes per channel for each PixelFormat - private: static const unsigned char channelByteCounts[PF_COUNT]; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RayQuery.hh b/include/ignition/rendering/RayQuery.hh index b1402075e..b4c6174f9 100644 --- a/include/ignition/rendering/RayQuery.hh +++ b/include/ignition/rendering/RayQuery.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,85 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RAYQUERY_HH_ -#define IGNITION_RENDERING_RAYQUERY_HH_ -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief A class that stores ray query intersection results. - class IGNITION_RENDERING_VISIBLE RayQueryResult - { - /// \brief Intersection distance - public: double distance = -1; - - /// \brief Intersection point in 3d space - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public: math::Vector3d point; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Intersected object id - public: unsigned int objectId = 0; - - /// \brief Returns false if result is not valid - public: operator bool() const - { - return distance > 0; - } - - /// \brief Returns false if result is not valid - public: operator bool() - { - return distance > 0; - } - }; - - /// \class RayQuery RayQuery.hh ignition/rendering/RayQuery.hh - /// \brief A Ray Query class used for computing ray object intersections - class IGNITION_RENDERING_VISIBLE RayQuery - : public virtual Object - { - /// \brief Destructor - public: virtual ~RayQuery() { } - - /// \brief Set ray origin - /// \param[in] _origin Ray origin - public: virtual void SetOrigin(const math::Vector3d &_origin) = 0; - - /// \brief Get ray origin - /// \return Ray origin - public: virtual math::Vector3d Origin() const = 0; - - /// \brief Set ray direction - /// \param[in] _dir Ray origin - public: virtual void SetDirection(const math::Vector3d &_dir) = 0; - - /// \brief Get ray direction - /// \return Ray direction. - public: virtual math::Vector3d Direction() const = 0; - - /// \brief Create the ray query from camera - /// \param[in] _camera Camera to construct ray - /// \param[in] _coord normalized device coords [-1, +1] - public: virtual void SetFromCamera(const CameraPtr &_camera, - const math::Vector2d &_coord) = 0; - - /// \brief Compute intersections - /// \return A vector of intersection results - public: virtual RayQueryResult ClosestPoint() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderEngine.hh b/include/ignition/rendering/RenderEngine.hh index a40dc44e6..e76cf64ba 100644 --- a/include/ignition/rendering/RenderEngine.hh +++ b/include/ignition/rendering/RenderEngine.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,163 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERENGINE_HH_ -#define IGNITION_RENDERING_RENDERENGINE_HH_ -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class RenderEngine RenderEngine.hh ignition/rendering/RenderEngine.hh - /// \brief An abstract interface to a concrete render-engine. A - /// RenderEngine is responsible for initializing a render-engine as well as - /// creating, storing, and destroying scenes. - class IGNITION_RENDERING_VISIBLE RenderEngine - { - /// \brief Deconstructor - public: virtual ~RenderEngine() { } - - /// \brief Load any necessary resources to set up render-engine. This - /// should called before any other function. - /// \param[in] _params Parameters to be passed to the underlying - /// rendering engine. - /// \return True if the render-engine was successfully loaded - public: virtual bool Load( - const std::map &_params = {}) = 0; - - /// \brief Initialize the render-engine. This should be called immediately - /// after a successful call to Load. - /// \return True if the render-engine was successfully initialized - public: virtual bool Init() = 0; - - /// \brief Destroys all scenes created by render-engine and releases all - /// loaded resources. This should be called when the given render-engine - /// will no longer be used during runtime. - /// \return True if the render-engine was successfully destroyed - public: virtual void Destroy() = 0; - - // TODO(anyone): merge with Destroy - public: virtual bool Fini() = 0; - - /// \brief Determines if the render-engine has been loaded. - /// \return True if the render-engine is loaded - public: virtual bool IsLoaded() const = 0; - - /// \brief Determines if the render-engine has been initialized. - /// \return True if the render-engine is initialized - public: virtual bool IsInitialized() const = 0; - - /// \brief Determines if the render-engine can be used. Despite loading - /// and initializing the render-engine, it may not be possible to use due - /// to hardware capabilities of the runtime system. - /// \return True if the render-engine can be used - public: virtual bool IsEnabled() const = 0; - - /// \brief Get name of the render-engine. - /// \return The render-engine name - public: virtual std::string Name() const = 0; - - /// \brief Get the number of scenes actively managed by this - /// render-engine - /// \return The number of active scenes - public: virtual unsigned int SceneCount() const = 0; - - /// \brief Determine if the given scene is actively managed by this - /// render-engine - /// \param[in] _scene Scene in question - /// \return True if the scene is managed by this render-engine - public: virtual bool HasScene(ConstScenePtr _scene) const = 0; - - /// \brief Determine if this render-engine manages a scene with the - /// given ID. - /// \param[in] _id ID of scene in question - /// \return True if this render-engine manages the specified scene - public: virtual bool HasSceneId(unsigned int _id) const = 0; - - /// \brief Determine if this render-engine manages a scene with the - /// given name. - /// \param[in] _name Name of scene in question - /// \return True if this render-engine manages the specified scene - public: virtual bool HasSceneName(const std::string &_name) const = 0; - - /// \brief Get the scene with the given ID. If no scenes exist with the - /// given ID, NULL will be returned. - /// \param[in] _id ID of scene to be retrieved - /// \return The specified scene - public: virtual ScenePtr SceneById(unsigned int _id) const = 0; - - /// \brief Get the scene with the given name. If no scenes exist with the - /// given name, NULL will be returned. - /// \param[in] _name Name of scene to be retrieved - /// \return The specified scene - public: virtual ScenePtr SceneByName( - const std::string &_name) const = 0; - - /// \brief Get the scene at the given index. If no scenes exist at the - /// given index, NULL will be returned. - /// \param[in] _index Index of scene, which is a number from 0 to - /// SceneCount() - 1. Note that the index for a specific scene might - /// change as other scenes are destroyed. - /// \return The specified scene - public: virtual ScenePtr SceneByIndex(unsigned int _index) const = 0; - - /// \brief Destroy the given scene. If the given scene is not managed by - /// this render-engine, no work will be done. - /// \param[in] _scene Scene to be destroyed - public: virtual void DestroyScene(ScenePtr _scene) = 0; - - /// \brief Destroy the scene with the given ID. If no scenes exist with - /// the given ID, no work will be done. - /// \param[in] _id ID of the scene to destroy - public: virtual void DestroySceneById(unsigned int _id) = 0; - - /// \brief Destroy the scene with the given name. If no scenes exist with - /// the given name, no work will be done. - /// \param[in] _name Name of the scene to destroy - public: virtual void DestroySceneByName(const std::string &_name) = 0; - - /// \brief Destroy the scene at the given index. If no scenes exist at the - /// given index, no work will be done. - /// \param[in] _index Index of the scene to destroy - public: virtual void DestroySceneByIndex(unsigned int _index) = 0; - - /// \brief Destroy all scenes managed by this render-engine - public: virtual void DestroyScenes() = 0; - - /// \brief Create a new scene with the given name. The given name should - /// be unique across all scenes managed by this render-engine. If a - /// duplicate name is given, NULL will be returned. An unique ID will - /// automatically be assigned to the created scene. - /// \param[in] _name Name of the new scene - /// \return The created scene - public: virtual ScenePtr CreateScene(const std::string &_name) = 0; - - /// \brief Create a new scene with the given ID. The given ID should - /// be unique across all scenes managed by this render-engine. If a - /// duplicate ID is given, NULL will be returned. An unique name will - /// automatically be assigned to the created scene. - /// \param[in] _id ID of the new scene - /// \param[in] _name Name of the new scene - /// \return The created scene - public: virtual ScenePtr CreateScene(unsigned int _id, - const std::string &_name) = 0; - - /// \brief Add path to media resource location - /// \param[in] _path Absolute path to resource location - public: virtual void AddResourcePath(const std::string &_path) = 0; - - /// \brief Get the render pass system for this engine. - public: virtual RenderPassSystemPtr RenderPassSystem() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderEngineManager.hh b/include/ignition/rendering/RenderEngineManager.hh index d0d797b20..162ba7f0b 100644 --- a/include/ignition/rendering/RenderEngineManager.hh +++ b/include/ignition/rendering/RenderEngineManager.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,136 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERENGINEMANAGER_HH_ -#define IGNITION_RENDERING_RENDERENGINEMANAGER_HH_ -#include -#include -#include -#include -#include -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations. - class RenderEngine; - class RenderEngineManagerPrivate; - - /// \class RenderEngineManager RenderEngineManager.hh - /// ignition/rendering/RenderEngineManager.hh - /// \brief Collection of render-engines. This provides access to all the - /// render-engines available at runtime. RenderEngine objects should not - /// be access directly, but instead via the RenderEngineManager to maintain - /// a flexible render-engine agnostic design. - class IGNITION_RENDERING_VISIBLE RenderEngineManager : - public virtual common::SingletonT - { - /// \brief Constructor - public: RenderEngineManager(); - - /// \brief Deconstructor - public: ~RenderEngineManager(); - - /// \brief Get the number of available render-engines - /// \return the number of available render-engines - public: unsigned int EngineCount() const; - - /// \brief Determine if a render-engine with the given name is avaiable. - /// It also checks the list of default engines supplied by ign-rendering. - /// \param[in] _name Name of the desired render-engine - /// \return True if the specified render-engine is available - public: bool HasEngine(const std::string &_name) const; - - /// \brief Determine if a render-engine with the given name is already - /// loaded. - /// \param[in] _name Name of the desired render-engine - /// \return True if the specified render-engine is loaded. - public: bool IsEngineLoaded(const std::string &_name) const; - - /// \brief Get the list of all engines already loaded. - /// \return Names of all loaded engines. - public: std::vector LoadedEngines() const; - - /// \brief Get the render-engine with the given name. If the no - /// render-engine is registered under the given name, NULL will be - /// returned. - /// \param[in] _name Name of the desired render-engine - /// \param[in] _params Parameters to be passed to the render engine. - /// \param[in] _path Another search path for rendering engine plugin. - /// \return The specified render-engine - public: RenderEngine *Engine(const std::string &_name, - const std::map &_params = {}, - const std::string &_path = ""); - - /// \brief Get the render-engine at the given index. If no - /// render-engine is exists at the given index, NULL will be returned. - /// \param[in] _index Index of the desired render-engine - /// \param[in] _params Parameters to be passed to the render engine. - /// \param[in] _path Another search path for rendering engine plugin. - /// \return The specified render-engine - public: RenderEngine *EngineAt(unsigned int _index, - const std::map &_params = {}, - const std::string &_path = ""); - - /// \brief Unload the render-engine with the given name. If the no - /// render-engine is registered under the given name, false will be - /// returned. - /// \param[in] _name Name of the desired render-engine - /// \return True if the engine is unloaded - public: bool UnloadEngine(const std::string &_name); - - /// \brief Unload the render-engine at the given index. If the no - /// render-engine is registered under the given name, false will be - /// returned. - /// \param[in] _index Index of the desired render-engine - /// \return True if the engine is unloaded - public: bool UnloadEngineAt(unsigned int _index); - - /// \brief Register a new render-engine under the given name. If the - /// given name is already in use, the render-engine will not be - /// registered. - /// \param[in] _name Name the render-engine will be registered under - /// \param[in] _engine Render-engine to be registered - public: void RegisterEngine(const std::string &_name, - RenderEngine *_engine); - - /// \brief Unregister a render-engine registered under the given name. - /// If no render-engine is registered under the given name no work - /// will be done. - /// \param[in] _name Name of the render-engine to unregister - public: void UnregisterEngine(const std::string &_name); - - /// \brief Unregister the given render-engine. If the given render-engine - /// is not currently registered, no work will be done. - /// \param[in] _engine Render-engine to unregister - public: void UnregisterEngine(RenderEngine *_engine); - - /// \brief Unregister a render-engine at the given index. If the no - /// render-engine is registered at the given index, no work will be done. - /// \param[in] _index Index of the render-engine to unregister - public: void UnregisterEngineAt(unsigned int _index); - - /// \brief Set the plugin paths from which render engines can be loaded. - /// \param[in] _paths The list of the plugin paths - public: void SetPluginPaths(const std::list &_paths); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief private implementation details - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief required SingletonT friendship - private: friend class ignition::common::SingletonT; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderEnginePlugin.hh b/include/ignition/rendering/RenderEnginePlugin.hh index c64c9558f..cdb9d5a3e 100644 --- a/include/ignition/rendering/RenderEnginePlugin.hh +++ b/include/ignition/rendering/RenderEnginePlugin.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,50 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_RENDERENGINEPLUGIN_HH_ -#define IGNITION_RENDERING_RENDERENGINEPLUGIN_HH_ - -#include -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declarations - class RenderEngine; - class RenderEnginePluginPrivate; - - /// \brief Base plugin class for render engines - class IGNITION_RENDERING_VISIBLE RenderEnginePlugin - { - /// \brief Constructor - public: RenderEnginePlugin(); - - /// \brief Destructor - public: virtual ~RenderEnginePlugin(); - - /// \brief Get the name of render engine - /// \return Name of render engine - public: virtual std::string Name() const = 0; - - /// \brief Get a pointer to the render engine - /// \return Render engine instance - public: virtual RenderEngine *Engine() const = 0; - - /// \brief Pointer to private data class - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderPass.hh b/include/ignition/rendering/RenderPass.hh index 6d9b611f4..41028ee1a 100644 --- a/include/ignition/rendering/RenderPass.hh +++ b/include/ignition/rendering/RenderPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,38 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERPASS_HH_ -#define IGNITION_RENDERING_RENDERPASS_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Object.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class RenderPass RenderPass.hh ignition/rendering/RenderPass.hh - /// \brief A render pass can be added to a camera to affect how the scene - /// is rendered. It can be used to add post-processing effects. Multiple - /// passes can be chained together. - class IGNITION_RENDERING_VISIBLE RenderPass - : public virtual Object - { - /// \brief Destructor - public: virtual ~RenderPass() { } - - /// \brief Set to enable or disable the render pass - /// \param[in] _enabled True to enable the render pass, false to disable. - public: virtual void SetEnabled(bool _enabled) = 0; - - /// \brief Get whether or not the render pass is enabled - /// \return True if the render pass is enabled, false otherwise. - public: virtual bool IsEnabled() const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderPassSystem.hh b/include/ignition/rendering/RenderPassSystem.hh index 3bcb5466c..a45a54c08 100644 --- a/include/ignition/rendering/RenderPassSystem.hh +++ b/include/ignition/rendering/RenderPassSystem.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,99 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERPASSSYSTEM_HH_ -#define IGNITION_RENDERING_RENDERPASSSYSTEM_HH_ -#include -#include -#include -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/RenderPass.hh" -#include "ignition/rendering/RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class RenderPassSystemPrivate; - - /* \class RenderPassFactory RenderPassSystem.hh \ - * ignition/rendering/RenderPassSystem.hh - */ - /// \brief A factory interface for creating render passes - class IGNITION_RENDERING_VISIBLE RenderPassFactory - { - /// \brief Instantiate new render pass - /// \return New render pass - public: virtual RenderPass *New() const = 0; - }; - - /* \class RenderPassSystem RenderPassSystem.hh \ - * ignition/rendering/RenderPassSystem.hh - */ - /// \brief A class for creating and managing render passes - class IGNITION_RENDERING_VISIBLE RenderPassSystem - { - /// \brief Constructor - public: RenderPassSystem(); - - /// \brief Destructor - public: virtual ~RenderPassSystem(); - - /// \brief Templated function for creating render passes - /// \return Pointer to the render pass created - public: template RenderPassPtr Create() - { - return this->CreateImpl(typeid(T).name()); - } - - /// \brief Register a render pass factory to the system - /// \param[in] _type Render pass type, i.e. type id of render pass class - /// \param[in] _factory Factory used to create the render pass - public: static void Register(const std::string &_type, - RenderPassFactory *_factory); - - /// \brief Implementation for creating render passes - /// \param[in] _type Render pass type, i.e. type id of render pass class - /// \return Pointer to the render pass created - private: RenderPassPtr CreateImpl(const std::string &_type); - - /// \brief A map of render pass type id name to its factory class - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: static std::map renderPassMap; - - /// \internal - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - - /// \brief Render pass registration macro - /// - /// Use this macro to register render pass with the render pass factory. - #define IGN_RENDERING_REGISTER_RENDER_PASS(classname, interface) \ - class classname##Factory : public ignition::rendering::RenderPassFactory \ - { \ - public: classname##Factory() \ - { \ - ignition::rendering::RenderPassSystem::Register( \ - typeid(interface).name(), this); \ - } \ - public: RenderPass *New() const override \ - { \ - return new classname(); \ - } \ - }; \ - static classname##Factory global_##classname##Factory; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderTarget.hh b/include/ignition/rendering/RenderTarget.hh index 271e0b406..00b7b0f6a 100644 --- a/include/ignition/rendering/RenderTarget.hh +++ b/include/ignition/rendering/RenderTarget.hh @@ -1,7 +1,7 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * - * Licensed under the Apache License, Version 2.0 (the "License") = 0; + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -14,140 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERTARGET_HH_ -#define IGNITION_RENDERING_RENDERTARGET_HH_ -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class RenderTarget RenderTarget.hh ignition/rendering/RenderTarget.hh - /// \brief Represents a render-target to which cameras can render images. - class IGNITION_RENDERING_VISIBLE RenderTarget : - public virtual Object - { - /// \brief Destructor - public: virtual ~RenderTarget() { } - - /// \brief Get render target width in pixels - /// \return The render target width in pixels - public: virtual unsigned int Width() const = 0; - - /// \brief Get render target height in pixels - /// \return The Render target height in pixels - public: virtual unsigned int Height() const = 0; - - /// \brief Set the render target width in pixels - /// \param[in] _width New render target width in pixels - public: virtual void SetWidth(const unsigned int _width) = 0; - - /// \brief Set the render target height in pixels - /// \param[in] _height New render target height in pixels - public: virtual void SetHeight(const unsigned int _height) = 0; - - /// \brief Set the render target image format - /// \return Render target format - public: virtual PixelFormat Format() const = 0; - - /// \brief Set the render target image format - /// \param[in] _format New target format - public: virtual void SetFormat(PixelFormat _format) = 0; - - /// \brief Write rendered image to given Image. The RenderTarget will - /// convert the underlying image to the specified format listed in the - /// given Image. However if the given image is not of the correct size no - /// work will be done. Calling this function before an image has been - /// rendered will result in undefined behavior. - /// \param[out] _image Image to which output will be written - public: virtual void Copy(Image &_image) const = 0; - - /// \brief Get the background color of the render target. - /// This should be the same as the scene background color. - /// \return Render target background color. - public: virtual math::Color BackgroundColor() const = 0; - - /// \brief Add a render pass to the render target - /// \param[in] _pass New render pass to add - public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0; - - /// \brief Remove a render pass from the render target - /// \param[in] _pass render pass to remove - public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) = 0; - - /// \brief Get the number of render passes applied to the render target - /// \return Number of render passes applied - public: virtual unsigned int RenderPassCount() const = 0; - - /// \brief Get a render pass by index - /// \return Render pass at the specified index - public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) - const = 0; - }; - - /* \class RenderTexture RenderTexture.hh \ - * ignition/rendering/RenderTexture.hh - */ - /// \brief Represents a off-screen render-texture to which cameras can - /// render images. - class IGNITION_RENDERING_VISIBLE RenderTexture : - public virtual RenderTarget - { - /// \brief Deconstructor - public: virtual ~RenderTexture() { } - - /// \brief Returns the OpenGL texture Id. A valid Id is returned only - // if this is an OpenGL render texture - public: virtual unsigned int GLId() const = 0; - }; - - /* \class RenderWindow RenderWindow.hh \ - * ignition/rendering/RenderWindow.hh - */ - /// \brief Represents a on-screen render-window to which cameras can - /// render images. - class IGNITION_RENDERING_VISIBLE RenderWindow : - public virtual RenderTarget - { - /// \brief Deconstructor - public: virtual ~RenderWindow() { } - - /// \brief Get the window handle that the render window is attached to. - /// \return Window handle - public: virtual std::string Handle() const = 0; - - /// \brief Set the window handle to attach the render window to - /// \param[in] _handle Window handle - public: virtual void SetHandle(const std::string &_handle) = 0; - - /// \brief Get the device to pixel ratio - /// \return Device to pixel ratio - public: virtual double DevicePixelRatio() const = 0; - - /// \brief Set the device to pixel ratio - /// \param[in] _ratio Device to pixel ratio - public: virtual void SetDevicePixelRatio(const double _ratio) = 0; - - /// \brief Alert the window of a window resize event - /// \param[in] _width New window width in pixels - /// \param[in] _height New window height in pixels - public: virtual void OnResize(unsigned int _width, - unsigned int _height) = 0; - - /// \brief Alert the window of a window move event - public: virtual void OnMove() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/RenderTypes.hh b/include/ignition/rendering/RenderTypes.hh index 44c106181..7a3a038b4 100644 --- a/include/ignition/rendering/RenderTypes.hh +++ b/include/ignition/rendering/RenderTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,335 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERTYPES_HH_ -#define IGNITION_RENDERING_RENDERTYPES_HH_ -#include +#include #include - - -/// \typedef IGN_VISIBILITY_ALL -/// \brief Render everything visibility mask. -#define IGN_VISIBILITY_ALL 0x0FFFFFFF - -/// \typedef IGN_VISIBILITY_SELECTION -/// \brief Renders only objects that can be selected. -#define IGN_VISIBILITY_SELECTION 0x10000000 - -/// \typedef IGN_VISIBILITY_GUI -/// \brief Render GUI visuals mask. -#define IGN_VISIBILITY_GUI 0x00000001 - -/// \typedef IGN_VISIBILITY_SELECTABLE -/// \brief Render visuals that are selectable mask. -#define IGN_VISIBILITY_SELECTABLE 0x00000002 - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - using shared_ptr = std::shared_ptr; - - class ArrowVisual; - class AxisVisual; - class Camera; - class DepthCamera; - class DirectionalLight; - class GaussianNoisePass; - class Geometry; - class GizmoVisual; - class GpuRays; - class Grid; - class JointVisual; - class Image; - class Light; - class Material; - class Marker; - class Mesh; - class Node; - class Object; - class ObjectFactory; - class PointLight; - class RayQuery; - class RenderEngine; - class RenderPass; - class RenderPassSystem; - class RenderTarget; - class RenderTexture; - class RenderWindow; - class Scene; - class Sensor; - class ShaderParams; - class SpotLight; - class SubMesh; - class Text; - class ThermalCamera; - class Visual; - - /// \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 GpuRaysPtr - /// \brief Shared pointer to GpuRays - typedef shared_ptr GpuRaysPtr; - - /// \typedef DirectionalLightPtr - /// \brief Shared pointer to DirectionalLight - typedef shared_ptr DirectionalLightPtr; - - /// \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 GridPtr - /// \brief Shared pointer to Grid - typedef shared_ptr GridPtr; - - /// \typedef JointVisualPtr - /// \brief Shared pointer to JointVisual - typedef shared_ptr JointVisualPtr; - - /// \typedef ImagePtr - /// \brief Shared pointer to Image - typedef shared_ptr ImagePtr; - - /// \typedef LightPtr - /// \brief Shared pointer to Light - typedef shared_ptr LightPtr; - - /// \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 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 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 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 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 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 PointLightPtr - /// \brief Shared pointer to const PointLight - typedef shared_ptr ConstPointLightPtr; - - /// \typedef RayQueryPtr - /// \brief Shared pointer to RayQuery - typedef shared_ptr ConstRayQueryPtr; - - /// \typedef const RenderPassPtr - /// \brief Shared pointer to const RenderPass - typedef shared_ptr ConstRenderPassPtr; - - /// \typedef const RenderPassSystemPtr - /// \brief Shared pointer to const RenderPassSystem - typedef shared_ptr ConstRenderPassSystemPtr; - - /// \typedef const RenderTargetPtr - /// \brief Shared pointer to const RenderTarget - typedef shared_ptr ConstRenderTargetPtr; - - /// \typedef const RenderTexturePtr - /// \brief Shared pointer to const RenderTexture - typedef shared_ptr ConstRenderTexturePtr; - - /// \typedef const RenderWindowPtr - /// \brief Shared pointer to const RenderWindow - typedef shared_ptr ConstRenderWindowPtr; - - /// \typedef const ScenePtr - /// \brief Shared pointer to const Scene - typedef shared_ptr ConstScenePtr; - - /// \typedef const SensorPtr - /// \brief Shared pointer to const Sensor - typedef shared_ptr ConstSensorPtr; - - /// \brief Shared pointer to const ShaderParams - typedef shared_ptr ConstShaderParamsPtr; - - /// \typedef const SpotLightPtr - /// \brief Shared pointer to const SpotLight - typedef shared_ptr ConstSpotLightPtr; - - /// \typedef const SubMeshPtr - /// \brief Shared pointer to const SubMesh - typedef shared_ptr ConstSubMeshPtr; - - /// \typedef const SubMeshPtr - /// \brief Shared pointer to const SubMesh - typedef shared_ptr ConstTextPtr; - - /// \typedef const VisualPtr - /// \brief Shared pointer to const Visual - typedef shared_ptr ConstVisualPtr; - } - } -} -#endif diff --git a/include/ignition/rendering/RenderingIface.hh b/include/ignition/rendering/RenderingIface.hh index b48fae4d9..ab8fd158e 100644 --- a/include/ignition/rendering/RenderingIface.hh +++ b/include/ignition/rendering/RenderingIface.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,136 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_RENDERINGIFACE_HH_ -#define IGNITION_RENDERING_RENDERINGIFACE_HH_ -#include -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class RenderEngine; - - /// \brief Load shared render-engine resources - /// \return True if successful - IGNITION_RENDERING_VISIBLE - bool load(); - - /// \brief Initialized shared render-engine features - /// \return True if successful - IGNITION_RENDERING_VISIBLE - bool init(); - - /// \brief Destroy all render-engines and related resources - /// \return True if successful - IGNITION_RENDERING_VISIBLE - bool fini(); - - /// \brief Get the number of available render-engines. - /// \return The number of available render-engines - IGNITION_RENDERING_VISIBLE - unsigned int engineCount(); - - /// \brief Determine if a render-engine is registered under the given name - /// \param[in] _name Name of the desired render-engine - /// \return True if a render-engine is registered under the given name - IGNITION_RENDERING_VISIBLE - bool hasEngine(const std::string &_name); - - /// \brief Determine if a render-engine is already loaded. - /// \param[in] _name Name of the desired render-engine - /// \return True if a render-engine is loaded under the given name - IGNITION_RENDERING_VISIBLE - bool isEngineLoaded(const std::string &_name); - - /// \brief Get the names of all engines currently loaded. - /// \return All the engines currently loaded. - IGNITION_RENDERING_VISIBLE - std::vector loadedEngines(); - - /// \brief Get the render-engine registered under the given name. If no - /// render-engine is registered under the given name, NULL will be - /// returned. - /// If the engine is registered, but not loaded, this function will load it. - /// \param[in] _name Name of the desired render-engine - /// \param[in] _params Parameters to be passed to the render engine. - /// \param[in] _path Another search path for rendering engine plugin. - /// \return The specified render-engine - IGNITION_RENDERING_VISIBLE - RenderEngine *engine(const std::string &_name, - const std::map &_params = {}, - const std::string &_path = ""); - - /// \brief Get the render-engine registered at the given index. If no - /// render-engine is registered at the given index, NULL will be returned. - /// If the engine is registered, but not loaded, this function will load it. - /// \param[in] _index Index of the desired render-engine - /// \param[in] _params Parameters to be passed to the render engine. - /// \param[in] _path Another search path for rendering engine plugin. - /// \return The specified render-engine - IGNITION_RENDERING_VISIBLE - RenderEngine *engine(const unsigned int _index, - const std::map &_params = {}, - const std::string &_path = ""); - - /// \brief Unload the render-engine registered under the given name. - /// \param[in] _name Name of the desired render-engine - /// \return True if the engine is unloaded - IGNITION_RENDERING_VISIBLE - bool unloadEngine(const std::string &_name); - - /// \brief Register a new render-engine under the given name. If the given - /// name is already in use, the render-engine will not be registered. - /// \param[in] _name Name the render-engine will be registered under - /// \param[in] _engine Render-engine to be registered - IGNITION_RENDERING_VISIBLE - void registerEngine(const std::string &_name, RenderEngine *_engine); - - /// \brief Unregister a render-engine registered under the given name. - /// If the no render-engine is registered under the given name no work - /// will be done. - /// \param[in] _name Name of the render-engine to unregister - IGNITION_RENDERING_VISIBLE - void unregisterEngine(const std::string &_name); - - /// \brief Unregister the given render-engine. If the given render-engine - /// is not currently registered, no work will be done. - /// \param[in] _engine Render-engine to unregister - IGNITION_RENDERING_VISIBLE - void unregisterEngine(RenderEngine *_engine); - - /// \brief Unregister a render-engine at the given index. If the no - /// render-engine is registered at the given index, no work will be done. - /// \param[in] _index Index of the render-engine to unregister - IGNITION_RENDERING_VISIBLE - void unregisterEngine(const unsigned int _index); - - /// \brief Set the plugin paths from which render engines can be loaded. - /// \param[in] _paths The list of the plugin paths - IGNITION_RENDERING_VISIBLE - void setPluginPaths(const std::list &_paths); - - /// \brief Most applications will only have one rendering engine loaded - /// at a time, and only one scene within that. This helper function gets - /// the first scene that can be found in the first loaded rendering engine. - /// - /// It's not recommended to call this function when there's more than one - /// engine or scene. - /// - /// \return Pointer to a scene that was found, null if no scene is loaded. - IGNITION_RENDERING_VISIBLE - ScenePtr sceneFromFirstRenderEngine(); - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Scene.hh b/include/ignition/rendering/Scene.hh index bbe71a31f..210d489e4 100644 --- a/include/ignition/rendering/Scene.hh +++ b/include/ignition/rendering/Scene.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,889 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_SCENE_HH_ -#define IGNITION_RENDERING_SCENE_HH_ -#include -#include -#include - -#include -#include -#include - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/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 Deconstructor - public: virtual ~Scene() { } - - /// \brief Load scene-specific resources - public: virtual void Load() = 0; - - /// \brief Initialize the scene - public: virtual void Init() = 0; - - // TODO(anyone): merge with Destroy - public: virtual void Fini() = 0; - - /// \brief Determine if the scene is initialized - /// \return True if the scene is initialized - public: virtual bool IsInitialized() const = 0; - - /// \brief Get the ID of the scene - /// \return The scene ID - public: virtual unsigned int Id() const = 0; - - /// \brief Get the name of the scene - /// \return The scene name - public: virtual std::string Name() const = 0; - - /// \brief Get the creating render-engine of the scene - /// \return The creating render-engine - public: virtual RenderEngine *Engine() const = 0; - - /// \brief Get the last simulation update time - /// \return The last simulation update time - public: virtual common::Time SimTime() const = 0; - - /// \brief Set the last simulation update time - /// \param[in] _time Latest simulation update time - public: virtual void SetSimTime(const common::Time &_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 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 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 box geometry - /// \return The created box - public: virtual GeometryPtr CreateBox() = 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 geometry - /// \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 marker geometry. - /// \return The created marker - public: virtual MarkerPtr CreateMarker() = 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 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 Remove and destroy all objects from the scene graph. This does - /// not completely destroy scene resources, so new objects can be created - /// and added to the scene afterwards. - public: virtual void Clear() = 0; - - /// \brief Completely destroy the scene an all its resources. Continued - /// use of this scene after its destruction will result in undefined - /// behavior. - public: virtual void Destroy() = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Sensor.hh b/include/ignition/rendering/Sensor.hh index 373b2c9bf..91c77a516 100644 --- a/include/ignition/rendering/Sensor.hh +++ b/include/ignition/rendering/Sensor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_SENSOR_HH_ -#define IGNITION_RENDERING_SENSOR_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Node.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Sensor Sensor.hh ignition/rendering/Sensor.hh - /// \brief Represents a scene sensor. The most obvious example is a camera, - /// but it can be anything that generates output from the scene. - class IGNITION_RENDERING_VISIBLE Sensor : - public virtual Node - { - /// \brief Sensor - public: virtual ~Sensor() { } - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/ShaderParam.hh b/include/ignition/rendering/ShaderParam.hh index eb9abb0c2..c4cb1ab8c 100644 --- a/include/ignition/rendering/ShaderParam.hh +++ b/include/ignition/rendering/ShaderParam.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,85 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_SHADERPARAM_HH_ -#define IGNITION_RENDERING_SHADERPARAM_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 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 param - PARAM_FLOAT = 1, - - /// \brief Integer type param - PARAM_INT = 2, - }; - - /// \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 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 param - /// \param[in] _value Value to set this param to. - public: void operator=(const float _value); - - /// \brief Set this to be an integer param; - /// \param[in] _value Value to set this param to. - public: void operator=(const int _value); - - /// \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 param 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 param is the expected type - public: bool Value(int *_value) const; - - /// \brief private implementation - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/ShaderParams.hh b/include/ignition/rendering/ShaderParams.hh index adc4a17f5..cf358abe5 100644 --- a/include/ignition/rendering/ShaderParams.hh +++ b/include/ignition/rendering/ShaderParams.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,120 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_SHADERPARAMS_HH_ -#define IGNITION_RENDERING_SHADERPARAMS_HH_ - -#include -#include -#include - -#include "ignition/rendering/Export.hh" -#include "ignition/rendering/ShaderParam.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief forward declaration - class ShaderParamsPrivate; - - /// \brief a map that holds params to be passed to a shader - class IGNITION_RENDERING_VISIBLE ShaderParams - { - /// \brief forward declaration - class IteratorPrivate; - - /// \brief Iterator for looping through params - /// \remarks implements a forward-iterator - class IGNITION_RENDERING_VISIBLE Iterator - { - /// \brief Default constructor - public: Iterator(); - - /// \brief Special constructor used by ShaderParams implementation - /// \param[in] _dataPtr Pointer to private data. - public: explicit Iterator(std::unique_ptr _dataPtr); - - /// \brief Copy constructor - /// \param[in] _iter Another iterator - public: Iterator(const Iterator &_iter); - - /// \brief Copy assignment - /// \param[in] _iter Another iterator - /// \return this - Iterator& operator=(const Iterator &_iter); - - /// \brief Destructor - public: ~Iterator(); - - /// \brief Equality operator - /// \param[in] _iter Another iterator - /// \return True if input interator equal to this one, false otherwise. - public: bool operator==(const Iterator &_iter); - - /// \brief Inequality operator - /// \param[in] _iter Another iterator - /// \return True if input interator is equal to this one, - /// false otherwise - public: bool operator!=(const Iterator &_iter); - - /// \brief Dereference operator - public: const std::pair &operator*(); - - /// \brief Arrow dereference operator - public: const std::pair *operator->(); - - /// \brief prefix increment - public: Iterator &operator++(); - - /// \brief postfix increment - public: Iterator operator++(int); - - private: std::unique_ptr dataPtr; - }; - - /// \brief constructor - public: ShaderParams(); - - /// \brief destructor - public: ~ShaderParams(); - - /// \brief Access a param with a given name - /// \param[in] _name Identifier for the parameter - /// \returns parameter reference - public: ShaderParam &operator[](const std::string &_name); - - /// \brief Access a param with a given name - /// \param[in] _name Identifier for the parameter - /// \returns const parameter reference - public: const ShaderParam &operator[](const std::string &_name) const; - - /// \brief Iterator to first parameter - /// \remarks Necessary for range-base for loop support - /// \return Iterator pointing to first parameter. - public: Iterator begin() const; - - /// \brief Iterator to one past last param - /// \remarks Necessary for range-base for loop support - /// \return Iterator pointing to one past last parameter. - public: Iterator end() const; - - /// \brief Have the params changed? - /// \internal - /// \returns true if the parameters have changed - public: bool IsDirty() const; - - /// \brief Resets the dirty flag - /// \internal - public: void ClearDirty(); - - /// \brief private implementation - private: std::unique_ptr dataPtr; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/ShaderType.hh b/include/ignition/rendering/ShaderType.hh index a0e55e509..43013005b 100644 --- a/include/ignition/rendering/ShaderType.hh +++ b/include/ignition/rendering/ShaderType.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,76 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_SHADERTYPE_HH_ -#define IGNITION_RENDERING_SHADERTYPE_HH_ -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \enum ShaderType ShaderType.hh ignition/rendering/ShaderType.hh - /// \brief Available types of shaders. Note that not all rendering-engines - /// will be able to use each type. They will instead default to the closest - /// alternative. - enum IGNITION_RENDERING_VISIBLE ShaderType - { - /// \brief Unknown or errant type - ST_UNKNOWN = 0, - - /// \brief Per pixel lighting shader - ST_PIXEL = 1, - - /// \brief Per vertex lighting shader - ST_VERTEX = 2, - - /// \brief Object-space normal map shader - ST_NORM_OBJ = 3, - - /// \brief Tangent-space normal map shader - ST_NORM_TAN = 4, - - /// \brief Total number of shader types - ST_COUNT = 5, - }; - - /// \class ShaderUtil ShaderType.hh ignition/rendering/ShaderType.hh - /// \brief Provides supporting functions for ShaderType enum - class IGNITION_RENDERING_VISIBLE ShaderUtil - { - /// \brief Determine if given type is valid ShaderType enum - /// \param[in] _type Enum value to be evaluated - /// \return True if the given type is valid - public: static bool IsValid(ShaderType _type); - - /// \brief Sanitize given type. If the given value is invalid, - /// ST_UNKNOWN will be returned, otherwise input will be returned - /// unchanged. - /// \param[in] _type Shader type to be sanitized - /// \return The santized shader type - public: static ShaderType Sanitize(ShaderType _type); - - /// \brief Get human-readable name for shader type value. - /// \param[in] _type Shader type enum value - /// \return The type name - public: static std::string Name(ShaderType _type); - - /// \brief Get enum value by human-readable name. The given string should - /// match watch is returned by GetName. If an invalid name is given, - /// ST_UNKNOWN will be returned. - /// \param[in] _name Name of the shader type to be retrieved - /// \return The specified ShaderType enum value - public: static ShaderType Enum(const std::string &_name); - - /// \brief Array of human-readable names for each ShaderType - private: static const char *names[ST_COUNT]; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Storage.hh b/include/ignition/rendering/Storage.hh index 653269932..9fdeb0b9c 100644 --- a/include/ignition/rendering/Storage.hh +++ b/include/ignition/rendering/Storage.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,373 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_STORAGE_HH_ -#define IGNITION_RENDERING_STORAGE_HH_ -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Node.hh" -#include "ignition/rendering/Light.hh" -#include "ignition/rendering/Sensor.hh" -#include "ignition/rendering/Visual.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Material.hh" -#include "ignition/rendering/Mesh.hh" -#include "ignition/rendering/Export.hh" - -// An X11 header file defines a macro that conflicts with our function name, -// so undefine it here -#ifdef DestroyAll -#undef DestroyAll -#endif - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class Map Storage.hh ignition/rendering/Storage.hh - /// \brief Storage map from std::string to template class T - /// \tparam T The storage element type - template - class IGNITION_RENDERING_VISIBLE Map - { - /// \typedef TPtr - /// \brief Shared pointer to T - typedef std::shared_ptr TPtr; - - /// \typedef const TPtr - /// \brief Shared pointer to const T - typedef std::shared_ptr ConstTPtr; - - /// \brief Deconstructor - public: virtual ~Map() { } - - /// \brief Get the number of elements in this map - /// \return The number of elements in this map - public: virtual unsigned int Size() const = 0; - - /// \brief Determine if an elements is mapped to the given key - /// \param[in] _key Key of the element in question - /// \return True if an elements is mapped to the given key - public: virtual bool ContainsKey(const std::string &_key) const = 0; - - /// \brief Determine if the given element exists in this map - /// \param[in] _value Element in question - /// \return True if the given element exists in this map - public: virtual bool ContainsValue(ConstTPtr _value) const = 0; - - /// \brief Get the element mapped to the given key - /// \param[in] _key Key of the element in question - /// \return The element mapped to the given key - public: virtual TPtr Get(const std::string &_key) const = 0; - - /// \brief Get the element at the given index - /// \param[in] _index Index of the element in question - /// \return The element at the given index - public: virtual TPtr GetByIndex(unsigned int _index) const = 0; - - /// \brief Map to given element to the given key. If the given key is - /// already in use, no work will be done. - /// \param[in] _key Key of the new element - /// \param[in] _value Element to be mapped - /// \return True if successful - public: virtual bool Put(const std::string &_key, TPtr _value) = 0; - - /// \brief Remove the element mapped to the given key. If the specified - /// element does not exists, no work will be done. - /// \param[in] _key Key of the element in question - public: virtual void Remove(const std::string &_key) = 0; - - /// \brief Remove the given element. If the given element does not exist - /// no work will be done. - /// \param[in] _value Key of the element in question - public: virtual void Remove(TPtr _value) = 0; - - /// \brief Remove all elements from this map - public: virtual void RemoveAll() = 0; - }; - - /// \class Store Storage.hh ignition/rendering/Storage.hh - /// \brief Multi-access storage structure of template class T. Template - /// class T is expected to have functions GetId, GetName(), Destroy() which - /// return unsigned int, std::string, and void respectively. This store - /// will ensure that each element's name and ID are unique. - /// \tparam T The storage element type - template - class IGNITION_RENDERING_VISIBLE Store - { - /// \typedef TPtr - /// \brief Shared pointer to T - typedef std::shared_ptr TPtr; - - /// \typedef const TPtr - /// \brief Shared pointer to const T - typedef std::shared_ptr ConstTPtr; - - /// \brief Deconstructor - public: virtual ~Store() { } - - /// \brief Get number of elements in this store - /// \return The number of elements in this store - public: virtual unsigned int Size() const = 0; - - /// \brief Determine if store contains the given element - /// \param[in] _object The element in question - /// \return True if this store contains the given element - public: virtual bool Contains(ConstTPtr _object) const = 0; - - /// \brief Determine if store contains the element with the given ID - /// \param[in] _id ID of the element in question - /// \return True if this store contains the specified element - public: virtual bool ContainsId(unsigned int _id) const = 0; - - /// \brief Determine if store contains the element with the given name - /// \param[in] _name Name of the element in question - /// \return True if this store contains the specified element - public: virtual bool ContainsName(const std::string &_name) const = 0; - - /// \brief Get element with the given ID - /// \param[in] _id ID of the desired element - /// \return The specified element - public: virtual TPtr GetById(unsigned int _id) const = 0; - - /// \brief Get element with the given name - /// \param[in] _name Name of the desired element - /// \return The specified element - public: virtual TPtr GetByName(const std::string &_name) const = 0; - - /// \brief Get element at the given index - /// \param[in] _index Index of the desired element - /// \return The specified element - public: virtual TPtr GetByIndex(unsigned int _index) const = 0; - - /// \brief Add given element. If the element has already been added - /// or its name or ID conflict with other existing elements, then no - /// work will be done. - /// \param[in] _object Element to be added - /// \return True if successful - public: virtual bool Add(TPtr _object) = 0; - - /// \brief Remove given element. If the given element does not exists - /// in this store, then no work will be done. - /// \param[in] _object Element to be removed - /// \return The removed element - public: virtual TPtr Remove(TPtr _object) = 0; - - /// \brief Remove element with the given ID. If the specified element - /// does not exists in this store, then no work will be done. - /// \param[in] _id ID of the element to be removed - /// \return The removed element - public: virtual TPtr RemoveById(unsigned int _id) = 0; - - /// \brief Remove element with the given name. If the specified element - /// does not exists in this store, then no work will be done. - /// \param[in] _name Name of the element to be removed - /// \return The removed element - public: virtual TPtr RemoveByName(const std::string &_name) = 0; - - /// \brief Remove element at the given index. If the specified element - /// does not exists in this store, then no work will be done. - /// \param[in] _index Index of the element to be removed - /// \return The removed element - public: virtual TPtr RemoveByIndex(unsigned int _index) = 0; - - /// \brief Remove all elements from store - public: virtual void RemoveAll() = 0; - - /// \brief Remove and destroy given element. If the given element does - /// not exists, in this store, then no work will be done. - /// \param[in] _object Element to be removed - public: virtual void Destroy(TPtr _object) = 0; - - /// \brief Remove and destroy element with the given ID. If the specified - /// element does not exists in this store, then no work will be done. - /// \param[in] _id ID of the element to be removed - public: virtual void DestroyById(unsigned int _id) = 0; - - /// \brief Remove and destroy element with the given name. If the - /// specified element does not exists in this store, then no work - /// will be done. - /// \param[in] _name Name of the element to be removed - public: virtual void DestroyByName(const std::string &_name) = 0; - - /// \brief Remove and destroy element at the given index. If the - /// specified element does not exists in this store, then no work - /// will be done. - /// \param[in] _index Index of the element to be removed - public: virtual void DestroyByIndex(unsigned int _index) = 0; - - /// \brief Remove and destroy all elements in store - public: virtual void DestroyAll() = 0; - }; - - /// \class CompositeStore Storage.hh ignition/rendering/Storage.hh - /// ignition/rendering/CompositeStore.hh - /// \brief Represents a collection of Store objects, collectively working as - /// a single composite store. - /// \tparam T The storage element type - template - class IGNITION_RENDERING_VISIBLE CompositeStore : - public Store - { - /// \typedef TPtr - /// \brief Shared pointer to T - typedef std::shared_ptr TPtr; - - /// \typedef TPtr - /// \brief Store of T - typedef Store TStore; - - /// \typedef TStorePtr - /// \brief Shared pointer to TStore - typedef std::shared_ptr TStorePtr; - - /// \typedef const TStorePtr - /// \brief Shared pointer to const TStore - typedef std::shared_ptr ConstTStorePtr; - - /// \brief Deconstructor - public: virtual ~CompositeStore() { } - - /// \brief Get number of Stores - /// \return The number of Stores - public: virtual unsigned int GetStoreCount() const = 0; - - /// \brief Determine if given store exists - /// \param[in] _store Store in question - /// \return True if given store exists - public: virtual bool ContainsStore(ConstTStorePtr _store) const = 0; - - /// \brief Add the given store. If the given store already exists, then - /// no work will be done. - /// \param[in] _store Store to be added - /// \return True if successful - public: virtual bool AddStore(TStorePtr _store) = 0; - - /// \brief Get store at the given index. If no such store exists NULL - /// will be returned. - /// \param[in] _index Index of the desired store - /// \return The specified store - public: virtual TStorePtr GetStore(unsigned int _index) const = 0; - - /// \brief Remove given store. If no such store exists no - /// work will be done and NULL will be returned. - /// \param[in] _store Store to be removed - /// \return The removed store - public: virtual TStorePtr RemoveStore(TStorePtr _store) = 0; - - /// \brief Remove store at the given index. If no such store exists no - /// work will be done and NULL will be returned. - /// \param[in] _index Index of the store to be removed - /// \return The removed store - public: virtual TStorePtr RemoveStore(unsigned int _index) = 0; - }; - - /// \class StoreWrapper Storage.hh ignition/rendering/StoreWrapper.hh - /// \brief Simple wrapper class that allows a Store of type Derived to be - /// treated as a Store of type Base, where Derived is some class derived - /// from Base. This is useful in storing Stores of different derived types - /// in a single CompositeStore instance. - /// \tparam T New storage type - /// \tparam U Some derived class of T - template - class IGNITION_RENDERING_VISIBLE StoreWrapper : - public Store - { - public: virtual ~StoreWrapper() { } - }; - -// armhf failed to build with this code. It can not be removed for the rest -// of arches to keep ABI but should be removed in major versions unreleased -// see https://github.com/ignitionrobotics/ign-rendering/pull/457 -#ifndef __ARM_PCS_VFP - template class Store; - template class Store; - template class Store; - template class Store; - template class Store; - template class Store; - template class Store; - template class Map; - template class CompositeStore; -#endif - - /// \def SceneStore - /// \brief Store of Scene - typedef Store SceneStore; - - /// \def NodeStore - /// \brief Store of Node - typedef Store NodeStore; - - /// \def LightStore - /// \brief Store of Light - typedef Store LightStore; - - /// \def SensorStore - /// \brief Store of Sensor - typedef Store SensorStore; - - /// \def VisualStore - /// \brief Store of Visual - typedef Store VisualStore; - - /// \def GeometryStore - /// \brief Store of Geometry - typedef Store GeometryStore; - - /// \def SubMeshStore - /// \brief Store of SubMesh - typedef Store SubMeshStore; - - /// \def MaterialMap - /// \brief Material Map - typedef Map MaterialMap; - - /// \def NodeCompositeStore - /// \brief Node Composite Store - typedef CompositeStore NodeCompositeStore; - - /// \def SceneStorePtr - /// \brief Shared pointer to SceneStore - typedef std::shared_ptr SceneStorePtr; - - /// \def NodeStorePtr - /// \brief Shared pointer to NodeStore - typedef std::shared_ptr NodeStorePtr; - - /// \def LightStorePtr - /// \brief Shared pointer to LightStore - typedef std::shared_ptr LightStorePtr; - - /// \def SensorStorePtr - /// \brief Shared pointer to SensorStore - typedef std::shared_ptr SensorStorePtr; - - /// \def VisualStorePtr - /// \brief Shared pointer to VisualStore - typedef std::shared_ptr VisualStorePtr; - - /// \def GeometryStorePtr - /// \brief Shared pointer to GeometryStore - typedef std::shared_ptr GeometryStorePtr; - - /// \def SubMeshStorePtr - /// \brief Shared pointer to SubMeshStore - typedef std::shared_ptr SubMeshStorePtr; - - /// \def MaterialMapPtr - /// \brief Shared pointer to MaterialMap - typedef std::shared_ptr MaterialMapPtr; - - /// \def NodeCompositeStorePtr - /// \brief Shared pointer to NodeCompositeStore - typedef std::shared_ptr NodeCompositeStorePtr; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Text.hh b/include/ignition/rendering/Text.hh index bcd7d91e2..be58413fc 100644 --- a/include/ignition/rendering/Text.hh +++ b/include/ignition/rendering/Text.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,151 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_TEXT_HH_ -#define IGNITION_RENDERING_TEXT_HH_ -#include - -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \enum TextHorizontalAlign - /// \brief Text Horizontal alignment - enum class TextHorizontalAlign - { - /// \brief Left alignment - LEFT = 0, - /// \brief Center alignment - CENTER = 1, - /// \brief Right alignment - RIGHT = 2 - }; - - /// \enum TextVerticalAlign - /// \brief Text vertical alignment - enum class TextVerticalAlign - { - /// \brief Align bottom - BOTTOM = 0, - /// \brief Align center - CENTER = 1, - /// \brief Align top - TOP = 2 - }; - - /// \class Text Text.hh ignition/rendering/Text - /// \brief Represents a billboard text geometry that is always facing the - /// camera. - class IGNITION_RENDERING_VISIBLE Text : - public virtual Geometry - { - /// \brief Constructor - public: Text() = default; - - /// \brief Destructor - public: virtual ~Text() = default; - - /// \brief Set the font. - /// \param[in] _font Name of the font - /// \sa FontName() - public: virtual void SetFontName(const std::string &_font) = 0; - - /// \brief Get the font name. - /// \return The font name. - /// \sa SetFontName() - public: virtual std::string FontName() const = 0; - - /// \brief Set the text to display. - /// \param[in] _text The text to display. - /// \sa Text() - public: virtual void SetTextString(const std::string &_text) = 0; - - /// \brief Get the displayed text. - /// \return The displayed text. - /// \sa SetText() - public: virtual std::string TextString() const = 0; - - /// \brief Set the text color. - /// \param[in] _color Text color. - /// \sa Color() - public: virtual void SetColor(const ignition::math::Color &_color) = 0; - - /// \brief Get the text color. - /// \return Text color. - /// \sa SetColor() - public: virtual ignition::math::Color Color() const = 0; - - /// \brief Set the height of the character in meters. - /// \param[in] _height Height of the characters. - /// \sa CharHeight() - public: virtual void SetCharHeight(const float _height) = 0; - - /// \brief Get the height of the characters in meters - /// return Height of the characters. - /// \sa SetCharHeight() - public: virtual float CharHeight() const = 0; - - /// \brief Set the width of spaces between words. - /// \param[in] _width Space width - /// \sa SpaceWidth() - public: virtual void SetSpaceWidth(const float _width) = 0; - - /// \brief Get the width of spaces between words. - /// \return Space width - /// \sa SetSpaceWidth() - public: virtual float SpaceWidth() const = 0; - - /// \brief Set the alignment of the text - /// \param[in] _hAlign Horizontal alignment - /// \param[in] _vAlign Vertical alignment - public: virtual void SetTextAlignment(const TextHorizontalAlign &_hAlign, - const TextVerticalAlign &_vAlign) = 0; - - /// \brief Get the horizontal alignment of the text - /// \return Text horizontal alignment - public: virtual TextHorizontalAlign HorizontalAlignment() const = 0; - - /// \brief Get the vertical alignment of the text - /// \return Text verical alignment - public: virtual TextVerticalAlign VerticalAlignment() const = 0; - - /// \brief Set the baseline height of the text - /// \param[in] _baseline Baseline height - /// \sa Baseline() - public: virtual void SetBaseline(const float _baseline) = 0; - - /// \brief Get the baseline height in meters. - /// \return Baseline height - /// \sa SetBaseline() - public: virtual float Baseline() const = 0; - - /// \brief True = text always is displayed ontop. - /// \param[in] _onTop Set to true to render the text on top of - /// all other drawables. - /// \sa ShowOnTop() - public: virtual void SetShowOnTop(const bool _onTop) = 0; - - /// \brief Get whether the is displayed above other objects. - /// \return True if it is on top. - /// \sa SetShowOnTop() - public: virtual bool ShowOnTop() const = 0; - - /// \brief Get the axis aligned bounding box of the text. - /// \return The axis aligned bounding box. - public: virtual ignition::math::AxisAlignedBox AABB() const = 0; - }; - } - } -} - -#endif +#include +#include diff --git a/include/ignition/rendering/ThermalCamera.hh b/include/ignition/rendering/ThermalCamera.hh index 643fed05a..8e7a4b5b2 100644 --- a/include/ignition/rendering/ThermalCamera.hh +++ b/include/ignition/rendering/ThermalCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,112 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_THERMALCAMERA_HH_ -#define IGNITION_RENDERING_THERMALCAMERA_HH_ -#include -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /* \class ThermalCamera ThermalCamera.hh \ - * ignition/rendering/ThermalCamera.hh - */ - /// \brief Thermal camera that produces temperature data. - /// An object's temperature can be set through the Visual class - /// using SetUserData with the key "temperature". Ambient temperature - /// is returned for object that do not have this property set. Note that - /// temperature variations for the environment and objects can be set using - /// the Set*Range functions in this class. For simplicity, the variations - /// are modeled as a function of depth (which is not how a real thermal - /// sensor works). Ideally we support heatmaps for visuals in order to - /// produce more realistic temperature output. - class IGNITION_RENDERING_VISIBLE ThermalCamera : - public virtual Camera - { - /// \brief Destructor - public: virtual ~ThermalCamera() { } - - /// \brief Set the ambient temperature of the environment - /// \param[in] _ambient Ambient temperature in kelvin - /// \sa AmbientTemperature - public: virtual void SetAmbientTemperature(float _ambient) = 0; - - /// \brief Get the ambient temperature of the environment - /// \return Ambient temperature in kelvin - /// \sa SetAmbientTemperature - public: virtual float AmbientTemperature() const = 0; - - /// \brief Set the range of ambient temperature - /// \param[in] _range The ambient temperature ranges from - /// (ambient - range/2) to (ambient + range/2). - /// \sa AmbientTemperatureRange - public: virtual void SetAmbientTemperatureRange(float _range) = 0; - - /// \brief Get the range of ambient temperature - /// \return The ambient temperature range. Ambient temperature ranges - /// from (ambient - range/2) to (ambient - range/2) - /// \sa SetAmbientTemperatureRange - public: virtual float AmbientTemperatureRange() const = 0; - - /// \brief Set the minimum temperature the sensor can detect - /// \param[in] _min Min temperature in kelvin - /// \sa MinTemperature - public: virtual void SetMinTemperature(float _min) = 0; - - /// \brief Get the minimum temperature the sensor can detect - /// \return Min temperature in kelvin - /// \sa SetMinTemperature - public: virtual float MinTemperature() const = 0; - - /// \brief Set the maximum temperature the sensor can detect - /// \param[in] _max Max temperature in kelvin - /// \sa MaxTemperature - public: virtual void SetMaxTemperature(float _max) = 0; - - /// \brief Get the maximum temperature the sensor can detect - /// \return Max temperature in kelvin - /// \sa SetMaxTemperature - public: virtual float MaxTemperature() const = 0; - - /// \brief Set the temperature linear resolution. The thermal image data - /// returned will be temperature in kelvin / resolution. - /// Typical values are 0.01 (10mK), 0.1 (100mK), or 0.04 to simulate - /// 14 bit format. - /// \param[in] _resolution Temperature linear resolution - /// \sa LinearResolution - public: virtual void SetLinearResolution(float _resolution) = 0; - - /// \brief Get the temperature linear resolution - /// \return Temperature linear resolution - /// \sa SetLinearResolution - public: virtual float LinearResolution() const = 0; - - /// \brief Get the range of temperature variation for all heat sources. - /// \return Temperature variation range - /// \sa SetHeatSourceTemperatureRange - public: virtual float HeatSourceTemperatureRange() const = 0; - - /// \brief Set the range of temperature variation for all heat sources. - /// If set, the temperature reading of heat sources will vary within - /// a temperature of +/- range/2 instead of returning a fixed uniform - /// temperature for the entire heat source - /// \param[in] _range Temperature variation range - /// \sa HeatSourceTemperatureRange - public: virtual void SetHeatSourceTemperatureRange(float _range) = 0; - - /// \brief Connect to the new thermal image event - /// \param[in] _subscriber Subscriber callback function. The callback - /// function arguments are: - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewThermalFrame( - std::function _subscriber) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/TransformController.hh b/include/ignition/rendering/TransformController.hh index 8f0be4f8c..7b40c38a1 100644 --- a/include/ignition/rendering/TransformController.hh +++ b/include/ignition/rendering/TransformController.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,210 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_TRANSFORMCONTROLLER_HH_ -#define IGNITION_RENDERING_TRANSFORMCONTROLLER_HH_ -#include - -#include - -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GizmoVisual.hh" -#include "ignition/rendering/TransformType.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations - class TransformControllerPrivate; - - /* \class TransformController TransformController.hh \ - * ignition/rendering/TransformController.hh - */ - /// \brief An transform tool for translating, rotating, and scaling objects. - class IGNITION_RENDERING_VISIBLE TransformController - { - /// \brief Constructor - public: TransformController(); - - /// \brief Destructor - public: virtual ~TransformController(); - - /// \brief Update the transform controller. Its visual is updated based - /// on the current transform mode, space, and axis. - public: virtual void Update(); - - /// \brief Set the camera. - /// \param[in] _camera Camera - public: virtual void SetCamera(const CameraPtr &_camera); - - /// \brief get the camera that is controlled by this view controller. - /// \return camera being controlled - public: virtual CameraPtr Camera() const; - - /// \brief Get the attached node - /// \return The node which is being transformed, nullptr if there is no - /// node attached. - public: virtual NodePtr Node() const; - - /// \brief Attach the transform controller to the specified node - /// \param[in] _node Node that will be transformed - public: virtual void Attach(NodePtr _node); - - /// \brief Detach the transform controller from the currently attached - /// node - public: virtual void Detach(); - - /// \brief Set the transform mode - /// \param[in] _mode Transform mode to set to - public: virtual void SetTransformMode(TransformMode _mode); - - /// \brief Get the current transform mode - /// \return Transform mode - public: virtual TransformMode Mode() const; - - /// \brief Set the transform space - /// \param[in] _space Transform space to set to - public: virtual void SetTransformSpace(TransformSpace _space); - - /// \brief Get the transform space - /// \return Transform space - public: virtual TransformSpace Space() const; - - /// \brief Set the active transform axis. This highlights the axis visual - /// \param[in] _axis Transform axis vector - public: virtual void SetActiveAxis(const math::Vector3d &_axis); - - /// \brief Get the current highlighted active axis of transform - /// \return Active axis of transform - public: virtual math::Vector3d ActiveAxis() const; - - /// \brief Get the axis of transform represented by the given node id - /// \param[in] _id Id of the node to check - /// \return Transform axis - public: virtual math::Vector3d AxisById(unsigned int _id) const; - - /// \brief Translate the attached node - /// \param[in] _translation Translation in the current transform space - /// \param[in] _snap True to snap the final position to fixed increments - /// \sa SetTransformSpace - public: virtual void Translate(const math::Vector3d &_translation, - bool _snap = false); - - /// \brief Rotate the attached node - /// \param[in] _rotation Rotation in the current transform space - /// \param[in] _snap True to snap rotation angle to fixed increments - /// \sa SetTransformSpace - public: virtual void Rotate(const math::Quaterniond &_rotation, - bool _snap = false); - - /// \brief Scale the attached node. - /// \param[in] _scale Scale in the current transform space - /// \param[in] _snap True to snap scale to fixed increments - /// \sa SetTransformSpace - public: virtual void Scale(const math::Vector3d &_scale, - bool _snap = false); - - /// \brief Snap a point at intervals of a fixed distance. Currently used - /// to give a snapping behavior when transforming objects - /// \param[in] _point Input point. - /// \param[in] _interval Fixed distance interval at which the point - /// is snapped. - /// \param[in] _sensitivity Sensitivity of point snapping, in terms of a - /// percentage of the interval. - /// \return Snapped 3D point. - public: static ignition::math::Vector3d SnapPoint( - const ignition::math::Vector3d &_point, const double _interval = 1.0, - const double _sensitivity = 0.4); - - /// \brief Start the transform process. To be used with helper functions - /// that computions transforms from 2d movements. - /// \sa Stop - public: virtual void Start(); - - /// \brief Stop the transform process. To be used with helper functions - /// that computions transforms from 2d movements. - /// \sa Stop - public: virtual void Stop(); - - /// \brief Check if the transform process is active - /// \return True if node is being transformed - public: virtual bool Active() const; - - /// \brief Helper function to compute 3d translation from 2d translation - /// movement. Useful for converting 2d mouse drag motion to displacement - /// in world frame. Note that the camera must be set and Start() must be - /// called before using this function. - /// \param[in] _axis Axis of 3d translation. The resulting 3d vector - /// is constrained to this axis. - /// \param[in] _start Starting position of the 2d translation movement - /// \param[in] _end End position of the 2d translation movement - /// \return 3d translation vector in the current transform space - public: math::Vector3d TranslationFrom2d(const math::Vector3d &_axis, - const math::Vector2d &_start, const math::Vector2d &_end); - - /// \brief Helper function to compute 3d rotation from 2d translation - /// movement. Useful for converting 2d mouse drag motion to rotation angle - /// in world frame. Note that the camera must be set and Start() must be - /// called before using this function. - /// \param[in] _axis Axis of 3d rotation. The resulting rotation is - /// is constrained to this axis. - /// \param[in] _start Starting position of the 2d translation movement - /// \param[in] _end End position of the 2d translation movement - /// \return Rotation in the current transform space - public: math::Quaterniond RotationFrom2d(const math::Vector3d &_axis, - const math::Vector2d &_start, const math::Vector2d &_end); - - /// \brief Helper function to compute 3d scale from 2d translation - /// movement. Useful for converting 2d mouse drag motion to scale vector - /// in world frame. Note that the camera must be set and Start() must be - /// called before using this function. - /// \param[in] _axis Axis of scale. The resulting 3d vector - /// is constrained to this axis. - /// \param[in] _start Starting position of the 2d translation movement - /// \param[in] _end End position of the 2d translation movement - /// \return 3d scale vector in the current transform space - public: math::Vector3d ScaleFrom2d(const math::Vector3d &_axis, - const math::Vector2d &_start, const math::Vector2d &_end); - - /// \brief Convert a TransformAxis to a vector type - /// \param[in] _axis Transform axis - /// \return 3d axis vector - public: static math::Vector3d ToAxis(TransformAxis _axis); - - /// \brief Helper function to create a plane for transfomation. - /// The plane is chosen based on the current transform mode and the - /// transform axis specified. - /// \param[in] _axis Transformation axis used to identify the plane for - /// projection. - /// \param[in] _pt2d 2d point to help fine tune the plane created. - /// \return Plane created for transform - protected: math::Planed CreatePlaneForTransform( - const math::Vector3d &_axis, const math::Vector2d &_pt2d); - - /// \brief Helper function to compute ray plane intersection - /// \param[in] _ray Input ray - /// \param[in] _plane Plane to check for intersection - /// \param[out] _result Intersection point - /// \return True if intersection point exist, false if ray is parallel - /// to plane - protected: bool RayPlaneIntersection(RayQueryPtr _ray, - const math::Planed &_plane, math::Vector3d &_result); - - /// \brief Private data pointer - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/TransformType.hh b/include/ignition/rendering/TransformType.hh index faf1f66d5..cdf69c53d 100644 --- a/include/ignition/rendering/TransformType.hh +++ b/include/ignition/rendering/TransformType.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,70 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_TRANSFORMTYPE_HH_ -#define IGNITION_RENDERING_TRANSFORMTYPE_HH_ - -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \enum TransformAxis - /// \brief Unique identifiers for transformation axes. - enum IGNITION_RENDERING_VISIBLE TransformAxis - { - /// \brief No axis - TA_NONE = 0, - /// \brief Translation in x - TA_TRANSLATION_X = 0x00000001, - /// \brief Translation in y - TA_TRANSLATION_Y = 0x00000002, - /// \brief Translation in z - TA_TRANSLATION_Z = 0x00000004, - /// \brief Rotation in x - TA_ROTATION_X = 0x00000010, - /// \brief Rotation in y - TA_ROTATION_Y = 0x00000020, - /// \brief Rotation in z - TA_ROTATION_Z = 0x00000040, - /// \brief Scale in x - TA_SCALE_X = 0x00000100, - /// \brief Scale in y - TA_SCALE_Y = 0x00000200, - /// \brief Scale in z - TA_SCALE_Z = 0x00000400 - }; - - /// \enum TransformMode - /// \brief Unique identifiers for transformation modes. - enum IGNITION_RENDERING_VISIBLE TransformMode - { - /// \brief Inactive state - TM_NONE = 0, - /// \brief Translation mode - TM_TRANSLATION = TA_TRANSLATION_X | TA_TRANSLATION_Y | TA_TRANSLATION_Z, - /// \brief Rotation mode - TM_ROTATION = TA_ROTATION_X | TA_ROTATION_Y | TA_ROTATION_Z, - /// \brief Scale mode - TM_SCALE = TA_SCALE_X | TA_SCALE_Y, TA_SCALEZ, - }; - - /// \enum TransformSpace - /// \brief Unique identifiers for transformation spaces. - enum IGNITION_RENDERING_VISIBLE TransformSpace - { - /// \brief transformation in local frame - TS_LOCAL, - /// \brief transformation in world frame - TS_WORLD - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Utils.hh b/include/ignition/rendering/Utils.hh index 5f87a3ea5..78bcf3746 100644 --- a/include/ignition/rendering/Utils.hh +++ b/include/ignition/rendering/Utils.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,77 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_UTILS_HH_ -#define IGNITION_RENDERING_UTILS_HH_ + */ -#include -#include -#include - -#include "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(); - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/ViewController.hh b/include/ignition/rendering/ViewController.hh index d0b7e5161..8fd982496 100644 --- a/include/ignition/rendering/ViewController.hh +++ b/include/ignition/rendering/ViewController.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,50 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_VIEWCONTROLLER_HH_ -#define IGNITION_RENDERING_VIEWCONTROLLER_HH_ -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Camera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class ViewController ViewController.hh - /// ignition/rendering/ViewController.hh - /// \brief A camera view controller - class IGNITION_RENDERING_VISIBLE ViewController - { - /// \brief Deconstructor - public: virtual ~ViewController() { } - - /// \brief Set the camera that will be controlled by this view controller. - /// \param[in] _camera Camera to control - public: virtual void SetCamera(const CameraPtr &_camera) = 0; - - /// \brief Set target point for pan, zoom, oribit - /// \param[in] _target Target point in world coordinates - public: virtual void SetTarget(const math::Vector3d &_target) = 0; - - /// \brief Set zoom amount - /// \param[in] _value Camera zoon value, e.g. mouse scroll delta - public: virtual void Zoom(const double _value) = 0; - - /// \brief Set camera pan (translational movement) around target point. - /// \param[in] _value Pan amount in image plane, e.g. mouse drag delta. - public: virtual void Pan(const math::Vector2d &_value) = 0; - - /// \brief Set camera orbit (rotational movement) around target point. - /// \param[in] _value robit amount in image plane, e.g. mouse drag delta - public: virtual void Orbit(const math::Vector2d &_value) = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/Visual.hh b/include/ignition/rendering/Visual.hh index 12838afa4..0ac2c26ab 100644 --- a/include/ignition/rendering/Visual.hh +++ b/include/ignition/rendering/Visual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,117 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_VISUAL_HH_ -#define IGNITION_RENDERING_VISUAL_HH_ -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/Node.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - using Variant = std::variant; - - /// \class Visual Visual.hh ignition/rendering/Visual.hh - /// \brief Represents a visual node in a scene graph. A Visual is the only - /// node that can have Geometry and other Visual children. - class IGNITION_RENDERING_VISIBLE Visual : - public virtual Node - { - /// \brief Deconstructor - public: virtual ~Visual() { } - - /// \brief Get the number of geometries attached to this visual - /// \return The number of geometries attached to this visual - public: virtual unsigned int GeometryCount() const = 0; - - /// \brief Determine if given geometry is attached to this visual - /// \param[in] _geometry Geometry in question - /// \return True if given node is attached to this visual - public: virtual bool HasGeometry(ConstGeometryPtr _geometry) const = 0; - - /// \brief Get geometry at given index. If no geometry exists at given - /// index, NULL will be returned. - /// \param[in] _index Index of the desired geometry - /// \return The specified geometry - public: virtual GeometryPtr GeometryByIndex( - unsigned int _index) const = 0; - - /// \brief Add the given geometry to this visual. If the given node is - /// already attached, no work will be done. - /// \param[in] _geometry Geometry to be added - public: virtual void AddGeometry(GeometryPtr _geometry) = 0; - - /// \brief Remove the given geometry from this visual. If the given node - /// is not a child of this visual, no work will be done. - /// \param[in] _geometry Geometry to be removed - /// \return The removed geometry - public: virtual GeometryPtr RemoveGeometry(GeometryPtr _geometry) = 0; - - /// \brief Remove the geometry at the given index from this visual. If the - /// specified node is not attached this visual, no work will be done. - /// \param[in] _index Index of the geometry to be removed - /// \return The removed geometry - public: virtual GeometryPtr RemoveGeometryByIndex( - unsigned int _index) = 0; - - /// \brief Remove all attached geometries from this visual - public: virtual void RemoveGeometries() = 0; - - /// \brief Set the material for all attached visuals and geometries. The - /// specified material will be retrieved from Scene::Material using - /// the given material name. If no material is registered with the given - /// name, no work will be done. - /// \param[in] _name Name of the material to be assigned - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetMaterial(const std::string &_name, - bool _unique = true) = 0; - - /// \brief Set the material for all attached visuals and geometries - /// \param[in] _material Name of the material to be assigned - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true) = 0; - - /// \brief Set the material for all attached visuals only - /// \param[in] _material Name of the material to be assigned - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetChildMaterial(MaterialPtr _material, - bool _unique = true) = 0; - - /// \brief Set the material for all attached geometries only - /// \param[in] _material Name of the material to be assigned - /// \param[in] _unique True if the specified material should be cloned - public: virtual void SetGeometryMaterial(MaterialPtr _material, - bool _unique = true) = 0; - - /// \brief Get the material assigned to attached visuals and geometries. - /// \return the Pointer to the material assigned to this visual. If the - /// material is cloned at the time it is set to this visual, the cloned - /// material will be returned. - public: virtual MaterialPtr Material() = 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 Store any custom data associated with this visual - /// \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 visual - /// \param[in] _key Unique key - /// \return Data associated with the key. - public: virtual Variant UserData(const std::string &_key) const = 0; - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseArrowVisual.hh b/include/ignition/rendering/base/BaseArrowVisual.hh index 0418aa7fe..0c5e64329 100644 --- a/include/ignition/rendering/base/BaseArrowVisual.hh +++ b/include/ignition/rendering/base/BaseArrowVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,83 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEARROWVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASEARROWVISUAL_HH_ -#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 - { - protected: BaseArrowVisual(); - - public: virtual ~BaseArrowVisual(); - - public: virtual VisualPtr Head() const; - - public: virtual VisualPtr Shaft() const; - - protected: virtual void Init(); - }; - - ////////////////////////////////////////////////// - template - BaseArrowVisual::BaseArrowVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseArrowVisual::~BaseArrowVisual() - { - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseArrowVisual::Head() const - { - return std::dynamic_pointer_cast(this->ChildByIndex(0)); - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseArrowVisual::Shaft() const - { - return std::dynamic_pointer_cast(this->ChildByIndex(1)); - } - - ////////////////////////////////////////////////// - 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); - - this->SetOrigin(0, 0, -0.5); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseAxisVisual.hh b/include/ignition/rendering/base/BaseAxisVisual.hh index 486971236..706e8b0c2 100644 --- a/include/ignition/rendering/base/BaseAxisVisual.hh +++ b/include/ignition/rendering/base/BaseAxisVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,68 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEAXISVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASEAXISVISUAL_HH_ -#include "ignition/rendering/AxisVisual.hh" -#include "ignition/rendering/ArrowVisual.hh" -#include "ignition/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseAxisVisual : - public virtual AxisVisual, - public virtual T - { - protected: BaseAxisVisual(); - - public: virtual ~BaseAxisVisual(); - - public: virtual void Init(); - }; - - ////////////////////////////////////////////////// - template - BaseAxisVisual::BaseAxisVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseAxisVisual::~BaseAxisVisual() - { - } - - ////////////////////////////////////////////////// - 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); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseCamera.hh b/include/ignition/rendering/base/BaseCamera.hh index 9f28c43db..75d1fe0b6 100644 --- a/include/ignition/rendering/base/BaseCamera.hh +++ b/include/ignition/rendering/base/BaseCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,728 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASECAMERA_HH_ -#define IGNITION_RENDERING_BASE_BASECAMERA_HH_ -#include - -#include -#include - -#include -#include -#include - -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/base/BaseRenderTarget.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - template - class BaseDepthCamera; - - template - class BaseCamera : - public virtual Camera, - public virtual T - { - protected: BaseCamera(); - - public: virtual ~BaseCamera(); - - public: virtual unsigned int ImageWidth() const override; - - public: virtual void SetImageWidth(const unsigned int _width) override; - - public: virtual unsigned int ImageHeight() const override; - - public: virtual void SetImageHeight(const unsigned int _height) override; - - public: virtual PixelFormat ImageFormat() const override; - - public: virtual unsigned int ImageMemorySize() const override; - - public: virtual void SetImageFormat(PixelFormat _format) override; - - public: virtual math::Angle HFOV() const override; - - public: virtual void SetHFOV(const math::Angle &_hfov) override; - - public: virtual double AspectRatio() const override; - - public: virtual void SetAspectRatio(const double _ratio) override; - - public: virtual unsigned int AntiAliasing() const override; - - public: virtual void SetAntiAliasing(const unsigned int _aa) override; - - public: virtual double FarClipPlane() const override; - - public: virtual void SetFarClipPlane(const double _far) override; - - public: virtual double NearClipPlane() const override; - - public: virtual void SetNearClipPlane(const double _near) override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - public: virtual void Update() override; - - public: virtual Image CreateImage() const override; - - public: virtual void Capture(Image &_image) override; - - public: virtual void Copy(Image &_image) const override; - - public: virtual bool SaveFrame(const std::string &_name) override; - - public: virtual common::ConnectionPtr ConnectNewImageFrame( - Camera::NewFrameListener _listener) override; - - public: virtual RenderWindowPtr CreateRenderWindow() override; - - // Documentation inherited. - public: virtual VisualPtr VisualAt(const ignition::math::Vector2i - &_mousePos) override; - - // Documentation inherited. - public: virtual math::Matrix4d ProjectionMatrix() const override; - - // Documentation inherited. - public: virtual math::Matrix4d ViewMatrix() const override; - - // Documentation inherited. - // \sa Camera::SetMaterial(const MaterialPtr &) override; - public: virtual void SetMaterial(const MaterialPtr &_material) - override; - - // Documentation inherited. - public: virtual void SetTrackTarget(const NodePtr &_target, - const math::Vector3d &_offset, - const bool _worldFrame) override; - - // Documentation inherited. - public: virtual NodePtr TrackTarget() const override; - - // Documentation inherited. - public: virtual void SetTrackOffset(const math::Vector3d &_offset) - override; - - // Documentation inherited. - public: virtual math::Vector3d TrackOffset() const override; - - // Documentation inherited. - public: virtual void SetTrackPGain(const double _pGain) override; - - // Documentation inherited. - public: virtual double TrackPGain() const override; - - // Documentation inherited. - public: virtual void SetFollowTarget(const NodePtr &_target, - const math::Vector3d &_Offset, const bool _worldFrame) - override; - - // Documentation inherited. - public: virtual NodePtr FollowTarget() const override; - - // Documentation inherited. - public: virtual void SetFollowOffset(const math::Vector3d &_offset) - override; - - // Documentation inherited. - public: virtual math::Vector3d FollowOffset() const override; - - // Documentation inherited. - public: virtual void SetFollowPGain(const double _pGain) override; - - // Documentation inherited. - public: virtual double FollowPGain() const override; - - // Documentation inherited. - public: virtual unsigned int RenderTextureGLId() const override; - - // Documentation inherited. - public: virtual void AddRenderPass(const RenderPassPtr &_pass) override; - - // Documentation inherited. - public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) - override; - - // Documentation inherited. - public: virtual unsigned int RenderPassCount() const override; - - // Documentation inherited. - public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) - const override; - - protected: virtual void *CreateImageBuffer() const; - - protected: virtual void Load() override; - - protected: virtual void Reset(); - - protected: virtual RenderTargetPtr RenderTarget() const = 0; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: common::EventT newFrameEvent; - - protected: ImagePtr imageBuffer; - - /// \brief Near clipping plane distance - protected: double nearClip = 0.01; - - /// \brief Far clipping plane distance - protected: double farClip = 1000.0; - - /// \brief Aspect ratio - protected: double aspect = 1.3333333; - - /// \brief Horizontal camera field of view - protected: math::Angle hfov; - - /// \brief Anti-aliasing - protected: unsigned int antiAliasing = 0u; - - /// \brief Target node to track if camera tracking is on. - protected: NodePtr trackNode; - - /// \brief Track point relative to target in world frame. - protected: bool trackWorldFrame = false; - - /// \brief Set camera to track a point offset in target node's local or - /// world frame depending on trackWorldFrame. - protected: math::Vector3d trackOffset; - - /// \brief P gain for tracking. Determines how fast the camera rotates - /// to look at the target node. Valid range: [0-1] - protected: double trackPGain = 1.0; - - /// \brief Target node to follow - protected: NodePtr followNode; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Follow target in world frame. - protected: bool followWorldFrame = false; - - /// \brief P gain for follow mode. Determines how fast the camera moves - /// to follow the target node. Valid range: [0-1] - protected: double followPGain = 1.0; - - /// \brief Offset distance between camera and target node being followed - protected: math::Vector3d followOffset; - - 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(); - - 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(); - } - - 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(); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::Capture(Image &_image) - { - this->Update(); - this->Copy(_image); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::Copy(Image &_image) const - { - this->RenderTarget()->Copy(_image); - } - - ////////////////////////////////////////////////// - template - bool BaseCamera::SaveFrame(const std::string &/*_name*/) - { - return false; - } - - ////////////////////////////////////////////////// - template - common::ConnectionPtr BaseCamera::ConnectNewImageFrame( - Camera::NewFrameListener _listener) - { - return newFrameEvent.Connect(_listener); - } - - ////////////////////////////////////////////////// - template - void *BaseCamera::CreateImageBuffer() const - { - // TODO(anyone): determine proper type - unsigned int size = this->ImageMemorySize(); - return new unsigned char *[size]; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::Load() - { - T::Load(); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::Reset() - { - math::Angle fov; - fov.Degree(60); - this->SetImageWidth(1); - this->SetImageHeight(1); - this->SetImageFormat(PF_R8G8B8); - this->SetAspectRatio(1.33333); - this->SetAntiAliasing(0u); - this->SetHFOV(fov); - this->SetNearClipPlane(0.01); - this->SetFarClipPlane(1000); - } - - ////////////////////////////////////////////////// - template - RenderWindowPtr BaseCamera::CreateRenderWindow() - { - // Does nothing by default - ignerr << "Render window not supported for render engine: " << - this->Scene()->Engine()->Name() << std::endl; - return RenderWindowPtr(); - } - - ////////////////////////////////////////////////// - template - math::Matrix4d BaseCamera::ProjectionMatrix() const - { - // perspective projection - 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; - math::Matrix4d result; - 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; - - // TODO(anyone): compute projection matrix for orthographic camera - - return result; - } - - ////////////////////////////////////////////////// - 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 - math::Angle BaseCamera::HFOV() const - { - return this->hfov; - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseCamera::VisualAt(const ignition::math::Vector2i - &/*_mousePos*/) - { - ignerr << "VisualAt not implemented for the render engine" << std::endl; - return VisualPtr(); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetHFOV(const math::Angle &_hfov) - { - this->hfov = _hfov; - } - - ////////////////////////////////////////////////// - template - double BaseCamera::AspectRatio() const - { - return this->aspect; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetAspectRatio(const double _aspect) - { - this->aspect = _aspect; - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCamera::AntiAliasing() const - { - return this->antiAliasing; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetAntiAliasing(const unsigned int _aa) - { - this->antiAliasing = _aa; - } - - ////////////////////////////////////////////////// - template - double BaseCamera::FarClipPlane() const - { - return this->farClip; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetFarClipPlane(const double _far) - { - this->farClip = _far; - } - - ////////////////////////////////////////////////// - template - double BaseCamera::NearClipPlane() const - { - return this->nearClip; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetNearClipPlane(const double _near) - { - this->nearClip = _near; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetTrackTarget(const NodePtr &_target, - const math::Vector3d &_offset, const bool _worldFrame) - { - this->trackNode = _target; - this->trackWorldFrame = _worldFrame; - this->trackOffset = _offset; - } - - ////////////////////////////////////////////////// - template - NodePtr BaseCamera::TrackTarget() const - { - return this->trackNode; - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseCamera::TrackOffset() const - { - return this->trackOffset; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetTrackOffset(const math::Vector3d &_offset) - { - this->trackOffset = _offset; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetTrackPGain(const double _pGain) - { - this->trackPGain = math::clamp(_pGain, 0.0, 1.0); - } - - ////////////////////////////////////////////////// - template - double BaseCamera::TrackPGain() const - { - return this->trackPGain; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetFollowTarget(const NodePtr &_target, - const math::Vector3d &_offset, const bool _worldFrame) - { - this->followNode = _target; - this->followWorldFrame = _worldFrame; - this->followOffset = _offset; - } - - ////////////////////////////////////////////////// - template - NodePtr BaseCamera::FollowTarget() const - { - return this->followNode; - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseCamera::FollowOffset() const - { - return this->followOffset; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetFollowOffset(const math::Vector3d &_offset) - { - this->followOffset = _offset; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetFollowPGain(const double _pGain) - { - this->followPGain = math::clamp(_pGain, 0.0, 1.0); - } - - ////////////////////////////////////////////////// - template - double BaseCamera::FollowPGain() const - { - return this->followPGain; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::SetMaterial(const MaterialPtr &/*_material*/) - { - ignerr << "SetMaterial not implemented for current render" - << " engine" << std::endl; - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCamera::RenderTextureGLId() const - { - ignerr << "RenderTextureGLId is not supported by current render" - << " engine" << std::endl; - return 0u; - } - - ////////////////////////////////////////////////// - template - void BaseCamera::AddRenderPass(const RenderPassPtr &_pass) - { - this->RenderTarget()->AddRenderPass(_pass); - } - - ////////////////////////////////////////////////// - template - void BaseCamera::RemoveRenderPass(const RenderPassPtr &_pass) - { - this->RenderTarget()->RemoveRenderPass(_pass); - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCamera::RenderPassCount() const - { - return this->RenderTarget()->RenderPassCount(); - } - - ////////////////////////////////////////////////// - template - RenderPassPtr BaseCamera::RenderPassByIndex(unsigned int _index) const - { - return this->RenderTarget()->RenderPassByIndex(_index); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseDepthCamera.hh b/include/ignition/rendering/base/BaseDepthCamera.hh index 1372ac69e..dc4993072 100644 --- a/include/ignition/rendering/base/BaseDepthCamera.hh +++ b/include/ignition/rendering/base/BaseDepthCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,87 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEDEPTHCAMERA_HH_ -#define IGNITION_RENDERING_BASE_BASEDEPTHCAMERA_HH_ -#include - -#include - -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/DepthCamera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - template - class BaseDepthCamera : - public virtual DepthCamera, - public virtual BaseCamera, - public virtual T - { - protected: BaseDepthCamera(); - - public: virtual ~BaseDepthCamera(); - - public: virtual void CreateDepthTexture(); - - public: virtual const float *DepthData() const; - - public: virtual ignition::common::ConnectionPtr ConnectNewDepthFrame( - std::function _subscriber); - - public: virtual ignition::common::ConnectionPtr ConnectNewRGBPointCloud( - std::function _subscriber); - }; - - ////////////////////////////////////////////////// - template - BaseDepthCamera::BaseDepthCamera() - { - } - - ////////////////////////////////////////////////// - template - BaseDepthCamera::~BaseDepthCamera() - { - } - - ////////////////////////////////////////////////// - template - void BaseDepthCamera::CreateDepthTexture() - { - } - - ////////////////////////////////////////////////// - template - const float *BaseDepthCamera::DepthData() const - { - return nullptr; - } - - ////////////////////////////////////////////////// - template - ignition::common::ConnectionPtr BaseDepthCamera::ConnectNewDepthFrame( - std::function) - { - return nullptr; - } - - ////////////////////////////////////////////////// - template - ignition::common::ConnectionPtr BaseDepthCamera::ConnectNewRGBPointCloud( - std::function) - { - return nullptr; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseGaussianNoisePass.hh b/include/ignition/rendering/base/BaseGaussianNoisePass.hh index 03e03930b..b8fd713db 100644 --- a/include/ignition/rendering/base/BaseGaussianNoisePass.hh +++ b/include/ignition/rendering/base/BaseGaussianNoisePass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,155 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_ -#define IGNITION_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_ -#include -#include - -#include "ignition/rendering/GaussianNoisePass.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class BaseGaussianNoisePass BaseGaussianNoisePass.hh \ - * ignition/rendering/base/BaseGaussianNoisePass.hh - */ - /// \brief Base Gaussian noise render pass. - template - class BaseGaussianNoisePass : - public virtual GaussianNoisePass, - public virtual T - { - /// \brief Constructor - protected: BaseGaussianNoisePass(); - - /// \brief Destructor - public: virtual ~BaseGaussianNoisePass(); - - // Documentation inherited. - public: double Mean() const; - - // Documentation inherited. - public: double StdDev() const; - - // Documentation inherited. - public: double Bias() const; - - // Documentation inherited. - public: void SetMean(double _mean); - - // Documentation inherited. - public: void SetStdDev(double _stdDev); - - // Documentation inherited. - public: void SetBiasMean(double _biasMean); - - // Documentation inherited. - public: void SetBiasStdDev(double _biasStdDev); - - // Sample the bias from bias mean and bias standard deviation - protected: void SampleBias(); - - /// \brief Gaussian noise mean. - protected: double mean = 0.0; - - /// \brief Standard deviation of Gaussian noise - protected: double stdDev = 0.0; - - /// \brief Gaussian noise bias. - protected: double bias = 0.0; - - /// \brief The mean of the Gaussian distribution from which bias values - /// are drawn. - protected: double biasMean = 0; - - /// \brief The standard deviation of the Gaussian distribution from - /// which bias values are drawn. - protected: double biasStdDev = 0; - }; - - ////////////////////////////////////////////////// - // BaseGaussianNoisePass - ////////////////////////////////////////////////// - template - BaseGaussianNoisePass::BaseGaussianNoisePass() - { - } - - ////////////////////////////////////////////////// - template - BaseGaussianNoisePass::~BaseGaussianNoisePass() - { - } - - ////////////////////////////////////////////////// - template - double BaseGaussianNoisePass::Mean() const - { - return this->mean; - } - - ////////////////////////////////////////////////// - template - double BaseGaussianNoisePass::StdDev() const - { - return this->stdDev; - } - - ////////////////////////////////////////////////// - template - double BaseGaussianNoisePass::Bias() const - { - return this->bias; - } - - ////////////////////////////////////////////////// - template - void BaseGaussianNoisePass::SetMean(double _mean) - { - this->mean = _mean; - } - - ////////////////////////////////////////////////// - template - void BaseGaussianNoisePass::SetStdDev(double _stdDev) - { - this->stdDev = _stdDev; - } - - ////////////////////////////////////////////////// - template - void BaseGaussianNoisePass::SetBiasMean(double _biasMean) - { - this->biasMean = _biasMean; - this->SampleBias(); - } - - ////////////////////////////////////////////////// - template - void BaseGaussianNoisePass::SetBiasStdDev(double _biasStdDev) - { - this->biasStdDev = _biasStdDev; - this->SampleBias(); - } - - ////////////////////////////////////////////////// - template - void BaseGaussianNoisePass::SampleBias() - { - this->bias = - ignition::math::Rand::DblNormal(this->biasMean, this->biasStdDev); - // With equal probability, we pick a negative bias (by convention, - // rateBiasMean should be positive, though it would work fine if - // negative). - if (ignition::math::Rand::DblUniform() < 0.5) - this->bias = -this->bias; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseGeometry.hh b/include/ignition/rendering/base/BaseGeometry.hh index 6460f52dd..1ce00859c 100644 --- a/include/ignition/rendering/base/BaseGeometry.hh +++ b/include/ignition/rendering/base/BaseGeometry.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,89 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEGEOMETRY_HH_ -#define IGNITION_RENDERING_BASE_BASEGEOMETRY_HH_ -#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 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 - void BaseGeometry::Destroy() - { - T::Destroy(); - this->RemoveParent(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseGizmoVisual.hh b/include/ignition/rendering/base/BaseGizmoVisual.hh index c517f861f..9ea5f4cdc 100644 --- a/include/ignition/rendering/base/BaseGizmoVisual.hh +++ b/include/ignition/rendering/base/BaseGizmoVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,709 +15,5 @@ * */ -#ifndef IGNITION_RENDERING_BASE_BASEGIZMOVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASEGIZMOVISUAL_HH_ - -#include -#include -#include -#include - -#include "ignition/rendering/base/BaseScene.hh" -#include "ignition/rendering/base/BaseNode.hh" -#include "ignition/rendering/ArrowVisual.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GizmoVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class BaseGizmoVisual BaseGizmoVisuall.hh \ - * ignition/rendering/base/BaseGizmoVisual.hh - */ - /// \brief A base implementation of the GizmoVisual class - template - class BaseGizmoVisual : - public virtual GizmoVisual, - public virtual T - { - /// \brief Constructor - protected: BaseGizmoVisual(); - - /// \brief Destructor - public: virtual ~BaseGizmoVisual(); - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void SetTransformMode(TransformMode _mode) override; - - // Documentation inherited - public: virtual TransformMode Mode() const override; - - // Documentation inherited - public: virtual void SetActiveAxis(const math::Vector3d &_axis) override; - - // Documentation inherited - public: virtual math::Vector3d ActiveAxis() const override; - - // Documentation inherited - public: virtual TransformAxis AxisById(unsigned int _id) const override; - - // Documentation inherited - public: virtual VisualPtr ChildByAxis(unsigned int _axis) const override; - - /// \brief Reset the gizmo visual state - public: virtual void Reset(); - - /// \brief Create materials used by the gizmo visual - protected: void CreateMaterials(); - - /// \brief Create gizmo visual for translation - protected: void CreateTranslationVisual(); - - /// \brief Create gizmo visual for rotation - protected: void CreateRotationVisual(); - - /// \brief Create gizmo visual for scale - protected: void CreateScaleVisual(); - - /// \brief Current gizmo mode - protected: TransformMode mode = TransformMode::TM_NONE; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief A map of gizmo axis and their visuals - protected: std::map visuals; - - /// \brief A map of gizmo axis and their handle visuals - protected: std::map handles; - - /// \brief Currently active visual. - protected: VisualPtr activeVis; - - /// \brief Flag to indicate the mode has changed. - protected: bool modeDirty = false; - - /// \brief Active axis - protected: math::Vector3d axis = math::Vector3d::Zero; - - /// \brief A map of axis enums to materials - protected: std::map materials; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Material used by axes - protected: enum AxisMaterial - { - /// \brief X axis - AM_X, - /// \brief Y axis - AM_Y, - /// \brief Z axis - AM_Z, - /// \brief Active axis - AM_ACTIVE, - /// \brief Origin - AM_O, - /// \brief handle - AM_HANDLE - }; - - /// \brief Only the scene can create a GizmoVisual - private: friend class BaseScene; - }; - - ////////////////////////////////////////////////// - template - BaseGizmoVisual::BaseGizmoVisual() - { - } - - ////////////////////////////////////////////////// - template - BaseGizmoVisual::~BaseGizmoVisual() - { - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::Init() - { - T::Init(); - - this->CreateMaterials(); - this->CreateTranslationVisual(); - this->CreateRotationVisual(); - this->CreateScaleVisual(); - - for (auto v : this->visuals) - v.second->SetVisible(false); - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::Reset() - { - this->visuals[TransformAxis::TA_TRANSLATION_X]->SetMaterial( - this->materials[AM_X], false); - this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( - this->materials[AM_Y], false); - this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( - this->materials[AM_Z], false); - this->visuals[TransformAxis::TA_ROTATION_X]->SetMaterial( - this->materials[AM_X], false); - this->visuals[TransformAxis::TA_ROTATION_Y]->SetMaterial( - this->materials[AM_Y], false); - this->visuals[TransformAxis::TA_ROTATION_Z]->SetMaterial( - this->materials[AM_Z], false); - this->visuals[TransformAxis::TA_SCALE_X]->SetMaterial( - this->materials[AM_X], false); - this->visuals[TransformAxis::TA_SCALE_Y]->SetMaterial( - this->materials[AM_Y], false); - this->visuals[TransformAxis::TA_SCALE_Z]->SetMaterial( - this->materials[AM_Z], false); - - this->handles[TransformAxis::TA_TRANSLATION_X]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - - this->handles[TransformAxis::TA_ROTATION_X]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_ROTATION_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_ROTATION_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - - this->handles[TransformAxis::TA_SCALE_X]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_SCALE_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - this->handles[TransformAxis::TA_SCALE_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - - for (auto v : this->visuals) - v.second->SetVisible(false); - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::PreRender() - { - if (!this->modeDirty) - return; - - this->Reset(); - - if (this->mode == TransformMode::TM_NONE) - { - this->modeDirty = false; - return; - } - - if (this->mode & TransformMode::TM_TRANSLATION) - { - this->visuals[TransformAxis::TA_TRANSLATION_X]->SetVisible(true); - this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetVisible(true); - this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetVisible(true); - this->visuals[TransformAxis::TA_TRANSLATION_Z << 1]->SetVisible(true); - if (this->axis.X() > 0) - { - this->visuals[TransformAxis::TA_TRANSLATION_X]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_TRANSLATION_X]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Y() > 0) - { - this->visuals[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_TRANSLATION_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Z() > 0) - { - this->visuals[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_TRANSLATION_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - } - } - else if (this->mode & TransformMode::TM_ROTATION) - { - this->visuals[TransformAxis::TA_ROTATION_X]->SetVisible(true); - this->visuals[TransformAxis::TA_ROTATION_Y]->SetVisible(true); - this->visuals[TransformAxis::TA_ROTATION_Z]->SetVisible(true); - this->visuals[TransformAxis::TA_ROTATION_Z << 1]->SetVisible(true); - if (this->axis.X() > 0) - { - this->visuals[TransformAxis::TA_ROTATION_X]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_ROTATION_X]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Y() > 0) - { - this->visuals[TransformAxis::TA_ROTATION_Y]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_ROTATION_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Z() > 0) - { - this->visuals[TransformAxis::TA_ROTATION_Z]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_ROTATION_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - } - } - else if (this->mode & TransformMode::TM_SCALE) - { - this->visuals[TransformAxis::TA_SCALE_X]->SetVisible(true); - this->visuals[TransformAxis::TA_SCALE_Y]->SetVisible(true); - this->visuals[TransformAxis::TA_SCALE_Z]->SetVisible(true); - if (this->axis.X() > 0) - { - this->visuals[TransformAxis::TA_SCALE_X]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_SCALE_X]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Y() > 0) - { - this->visuals[TransformAxis::TA_SCALE_Y]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_SCALE_Y]->SetMaterial( - this->materials[AM_HANDLE], false); - } - if (this->axis.Z() > 0) - { - this->visuals[TransformAxis::TA_SCALE_Z]->SetMaterial( - this->materials[AM_ACTIVE], false); - this->handles[TransformAxis::TA_SCALE_Z]->SetMaterial( - this->materials[AM_HANDLE], false); - } - } - - this->modeDirty = false; - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::SetTransformMode(TransformMode _mode) - { - if (this->mode == _mode) - return; - - this->mode = _mode; - // clear active axis when mode changes - this->axis = math::Vector3d::Zero; - this->modeDirty = true; - } - - ////////////////////////////////////////////////// - template - TransformMode BaseGizmoVisual::Mode() const - { - return this->mode; - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::SetActiveAxis(const math::Vector3d &_axis) - { - if (this->axis == _axis) - return; - - this->axis = _axis; - this->modeDirty = true; - } - - ////////////////////////////////////////////////// - template - math::Vector3d BaseGizmoVisual::ActiveAxis() const - { - return this->axis; - } - - ////////////////////////////////////////////////// - template - TransformAxis BaseGizmoVisual::AxisById(unsigned int _id) const - { - for (auto v : this->visuals) - { - // each axis visual has a child handle so also check children for - // matching id - if (v.second->Id() == _id || v.second->ChildById(_id)) - return static_cast(v.first); - } - return TransformAxis::TA_NONE; - } - - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::CreateMaterials() - { - MaterialPtr xMat = this->Scene()->Material("Default/TransRed")->Clone(); - MaterialPtr yMat = this->Scene()->Material("Default/TransGreen")->Clone(); - MaterialPtr zMat = this->Scene()->Material("Default/TransBlue")->Clone(); - MaterialPtr activeMat = - this->Scene()->Material("Default/TransYellow")->Clone(); - - // disable depth checking and writing, make them overlays - xMat->SetDepthWriteEnabled(false); - xMat->SetDepthCheckEnabled(false); - yMat->SetDepthWriteEnabled(false); - yMat->SetDepthCheckEnabled(false); - zMat->SetDepthWriteEnabled(false); - zMat->SetDepthCheckEnabled(false); - activeMat->SetDepthWriteEnabled(false); - activeMat->SetDepthCheckEnabled(false); - - MaterialPtr oMat = this->Scene()->Material("GizmoGray"); - if (!oMat) - { - oMat = this->Scene()->CreateMaterial("GizmoGray"); - oMat->SetAmbient(0.5, 0.5, 0.5); - oMat->SetDiffuse(0.5, 0.5, 0.5); - oMat->SetEmissive(0.5, 0.5, 0.5); - oMat->SetTransparency(0.5); - oMat->SetCastShadows(false); - oMat->SetReceiveShadows(false); - oMat->SetLightingEnabled(false); - oMat->SetDepthWriteEnabled(false); - oMat->SetDepthCheckEnabled(false); - } - - MaterialPtr handleMat = this->Scene()->Material("GizmoHandle"); - if (!handleMat) - { - handleMat = this->Scene()->CreateMaterial("GizmoHandle"); - handleMat->SetAmbient(0.0, 0.0, 0.0); - handleMat->SetDiffuse(0.0, 0.0, 0.0); - handleMat->SetEmissive(0.0, 0.0, 0.0); - handleMat->SetTransparency(1.0); - handleMat->SetCastShadows(false); - handleMat->SetReceiveShadows(false); - handleMat->SetLightingEnabled(false); - handleMat->SetDepthWriteEnabled(false); - handleMat->SetDepthCheckEnabled(false); - } - - this->materials[AM_X] = xMat; - this->materials[AM_Y] = yMat; - this->materials[AM_Z] = zMat; - this->materials[AM_ACTIVE] = activeMat; - this->materials[AM_O] = oMat; - this->materials[AM_HANDLE] = handleMat; - } - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::CreateTranslationVisual() - { - VisualPtr transVis = this->Scene()->CreateVisual(); - - // trans x - VisualPtr transXVis = this->Scene()->CreateVisual(); - VisualPtr transShaftXVis = this->Scene()->CreateVisual(); - transShaftXVis->AddGeometry(this->Scene()->CreateCylinder()); - transShaftXVis->SetOrigin(0, 0, 0.5); - transShaftXVis->SetLocalPosition(0, 0, 0.5); - transShaftXVis->SetLocalScale(0.02, 0.02, 0.45); - transXVis->AddChild(transShaftXVis); - - VisualPtr transHeadXVis = this->Scene()->CreateVisual(); - transHeadXVis->AddGeometry(this->Scene()->CreateCone()); - transHeadXVis->SetOrigin(0, 0, -0.5); - transHeadXVis->SetLocalPosition(0, 0, 0.5); - transHeadXVis->SetLocalScale(0.07, 0.07, 0.2); - transXVis->AddChild(transHeadXVis); - - transXVis->SetMaterial(this->materials[AM_X], false); - transXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); - transVis->AddChild(transXVis); - - // trans y - VisualPtr transYVis = this->Scene()->CreateVisual(); - VisualPtr transShaftYVis = this->Scene()->CreateVisual(); - transShaftYVis->AddGeometry(this->Scene()->CreateCylinder()); - transShaftYVis->SetOrigin(0, 0, 0.5); - transShaftYVis->SetLocalPosition(0, 0, 0.5); - transShaftYVis->SetLocalScale(0.02, 0.02, 0.45); - transYVis->AddChild(transShaftYVis); - - VisualPtr transHeadYVis = this->Scene()->CreateVisual(); - transHeadYVis->AddGeometry(this->Scene()->CreateCone()); - transHeadYVis->SetOrigin(0, 0, -0.5); - transHeadYVis->SetLocalPosition(0, 0, 0.5); - transHeadYVis->SetLocalScale(0.07, 0.07, 0.2); - transYVis->AddChild(transHeadYVis); - - transYVis->SetMaterial(this->materials[AM_Y], false); - transYVis->SetLocalRotation(-IGN_PI * 0.5, 0, 0); - transVis->AddChild(transYVis); - - // trans z - VisualPtr transZVis = this->Scene()->CreateVisual(); - VisualPtr transShaftZVis = this->Scene()->CreateVisual(); - transShaftZVis->AddGeometry(this->Scene()->CreateCylinder()); - transShaftZVis->SetOrigin(0, 0, 0.5); - transShaftZVis->SetLocalPosition(0, 0, 0.5); - transShaftZVis->SetLocalScale(0.02, 0.02, 0.45); - transZVis->AddChild(transShaftZVis); - - VisualPtr transHeadZVis = this->Scene()->CreateVisual(); - transHeadZVis->AddGeometry(this->Scene()->CreateCone()); - transHeadZVis->SetOrigin(0, 0, -0.5); - transHeadZVis->SetLocalPosition(0, 0, 0.5); - transHeadZVis->SetLocalScale(0.07, 0.07, 0.2); - transZVis->AddChild(transHeadZVis); - - transZVis->SetMaterial(this->materials[AM_Z], false); - transVis->AddChild(transZVis); - - // trans origin - VisualPtr transOrigin = this->Scene()->CreateVisual(); - transOrigin->AddGeometry(this->Scene()->CreateSphere()); - transOrigin->SetLocalScale(0.05, 0.05, 0.05); - transOrigin->SetMaterial(this->materials[AM_O], false); - transVis->AddChild(transOrigin); - - this->visuals[TransformAxis::TA_TRANSLATION_X] = transXVis; - this->visuals[TransformAxis::TA_TRANSLATION_Y] = transYVis; - this->visuals[TransformAxis::TA_TRANSLATION_Z] = transZVis; - this->visuals[TransformAxis::TA_TRANSLATION_Z << 1] = transOrigin; - - // translation handles - VisualPtr transHandleXVis = this->Scene()->CreateVisual(); - transHandleXVis->AddGeometry(this->Scene()->CreateCylinder()); - transHandleXVis->SetLocalPosition(0, 0, 0.35); - transHandleXVis->SetLocalScale(0.11, 0.11, 0.7); - transHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); - transXVis->AddChild(transHandleXVis); - - VisualPtr transHandleYVis = this->Scene()->CreateVisual(); - transHandleYVis->AddGeometry(this->Scene()->CreateCylinder()); - transHandleYVis->SetLocalPosition(0, 0, 0.35); - transHandleYVis->SetLocalScale(0.11, 0.11, 0.7); - transHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); - transYVis->AddChild(transHandleYVis); - - VisualPtr transHandleZVis = this->Scene()->CreateVisual(); - transHandleZVis->AddGeometry(this->Scene()->CreateCylinder()); - transHandleZVis->SetLocalPosition(0, 0, 0.35); - transHandleZVis->SetLocalScale(0.11, 0.11, 0.7); - transHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); - transZVis->AddChild(transHandleZVis); - - this->handles[TransformAxis::TA_TRANSLATION_X] = transHandleXVis; - this->handles[TransformAxis::TA_TRANSLATION_Y] = transHandleYVis; - this->handles[TransformAxis::TA_TRANSLATION_Z] = transHandleZVis; - - this->AddChild(transVis); - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::CreateRotationVisual() - { - common::MeshManager *meshMgr = common::MeshManager::Instance(); - std::string rotMeshName = "gizmo_rotate"; - if (!meshMgr->HasMesh(rotMeshName)) - meshMgr->CreateTube(rotMeshName, 1.0f, 1.02f, 0.02f, 1, 64, IGN_PI); - - std::string rotFullMeshName = "gizmo_rotate_full"; - if (!meshMgr->HasMesh(rotFullMeshName)) - { - meshMgr->CreateTube(rotFullMeshName, 1.0f, 1.02f, 0.02f, 1, 64, - 2 * IGN_PI); - } - - std::string rotHandleMeshName = "gizmo_rotate_handle"; - if (!meshMgr->HasMesh(rotHandleMeshName)) - { - meshMgr->CreateTube(rotHandleMeshName, 0.95f, 1.07f, 0.1f, 1, 64, - IGN_PI); - } - - VisualPtr rotVis = this->Scene()->CreateVisual(); - - // rotation x - VisualPtr rotXVis = this->Scene()->CreateVisual(); - rotXVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); - rotXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); - rotXVis->SetLocalScale(0.5, 0.5, 0.5); - rotXVis->SetMaterial(this->materials[AM_X], false); - rotVis->AddChild(rotXVis); - - // rotation y - VisualPtr rotYVis = this->Scene()->CreateVisual(); - rotYVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); - rotYVis->SetLocalRotation(IGN_PI * 0.5, 0, 0); - rotYVis->SetLocalScale(0.5, 0.5, 0.5); - rotYVis->SetMaterial(this->materials[AM_Y], false); - rotVis->AddChild(rotYVis); - - // rotation z - VisualPtr rotZVis = this->Scene()->CreateVisual(); - rotZVis->AddGeometry(this->Scene()->CreateMesh(rotMeshName)); - rotZVis->SetLocalScale(0.5, 0.5, 0.5); - rotZVis->SetMaterial(this->materials[AM_Z], false); - rotVis->AddChild(rotZVis); - - // rotation origin - VisualPtr rotFullVis = this->Scene()->CreateVisual(); - rotFullVis->AddGeometry(this->Scene()->CreateMesh(rotFullMeshName)); - rotFullVis->SetLocalScale(0.5, 0.5, 0.5); - rotFullVis->SetMaterial(this->materials[AM_O], false); - rotVis->AddChild(rotFullVis); - - this->visuals[TransformAxis::TA_ROTATION_X] = rotXVis; - this->visuals[TransformAxis::TA_ROTATION_Y] = rotYVis; - this->visuals[TransformAxis::TA_ROTATION_Z] = rotZVis; - this->visuals[TransformAxis::TA_ROTATION_Z << 1] = rotFullVis; - - // rotation handles - VisualPtr rotHandleXVis = this->Scene()->CreateVisual(); - rotHandleXVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); - rotHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); - rotXVis->AddChild(rotHandleXVis); - - VisualPtr rotHandleYVis = this->Scene()->CreateVisual(); - rotHandleYVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); - rotHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); - rotYVis->AddChild(rotHandleYVis); - - VisualPtr rotHandleZVis = this->Scene()->CreateVisual(); - rotHandleZVis->AddGeometry(this->Scene()->CreateMesh(rotHandleMeshName)); - rotHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); - rotZVis->AddChild(rotHandleZVis); - - this->handles[TransformAxis::TA_ROTATION_X] = rotHandleXVis; - this->handles[TransformAxis::TA_ROTATION_Y] = rotHandleYVis; - this->handles[TransformAxis::TA_ROTATION_Z] = rotHandleZVis; - - this->AddChild(rotVis); - } - - ////////////////////////////////////////////////// - template - void BaseGizmoVisual::CreateScaleVisual() - { - VisualPtr scaleVis = this->Scene()->CreateVisual(); - - // scale x - VisualPtr scaleXVis = this->Scene()->CreateVisual(); - VisualPtr scaleShaftXVis = this->Scene()->CreateVisual(); - scaleShaftXVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleShaftXVis->SetOrigin(0, 0, 0.5); - scaleShaftXVis->SetLocalPosition(0, 0, 0.5); - scaleShaftXVis->SetLocalScale(0.02, 0.02, 0.5); - scaleXVis->AddChild(scaleShaftXVis); - - VisualPtr scaleHeadXVis = this->Scene()->CreateVisual(); - scaleHeadXVis->AddGeometry(this->Scene()->CreateBox()); - scaleHeadXVis->SetOrigin(0, 0, -0.5); - scaleHeadXVis->SetLocalPosition(0, 0, 0.5); - scaleHeadXVis->SetLocalScale(0.07, 0.07, 0.07); - scaleXVis->AddChild(scaleHeadXVis); - - scaleXVis->SetMaterial(this->materials[AM_X], false); - scaleXVis->SetLocalRotation(0, IGN_PI * 0.5, 0); - scaleVis->AddChild(scaleXVis); - - // scale y - VisualPtr scaleYVis = this->Scene()->CreateVisual(); - VisualPtr scaleShaftYVis = this->Scene()->CreateVisual(); - scaleShaftYVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleShaftYVis->SetOrigin(0, 0, 0.5); - scaleShaftYVis->SetLocalPosition(0, 0, 0.5); - scaleShaftYVis->SetLocalScale(0.02, 0.02, 0.5); - scaleYVis->AddChild(scaleShaftYVis); - - VisualPtr scaleHeadYVis = this->Scene()->CreateVisual(); - scaleHeadYVis->AddGeometry(this->Scene()->CreateBox()); - scaleHeadYVis->SetOrigin(0, 0, -0.5); - scaleHeadYVis->SetLocalPosition(0, 0, 0.5); - scaleHeadYVis->SetLocalScale(0.07, 0.07, 0.07); - scaleYVis->AddChild(scaleHeadYVis); - - scaleYVis->SetMaterial(this->materials[AM_Y], false); - scaleYVis->SetLocalRotation(-IGN_PI * 0.5, 0, 0); - scaleVis->AddChild(scaleYVis); - - // scale z - VisualPtr scaleZVis = this->Scene()->CreateVisual(); - VisualPtr scaleShaftZVis = this->Scene()->CreateVisual(); - scaleShaftZVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleShaftZVis->SetOrigin(0, 0, 0.5); - scaleShaftZVis->SetLocalPosition(0, 0, 0.5); - scaleShaftZVis->SetLocalScale(0.02, 0.02, 0.5); - scaleZVis->AddChild(scaleShaftZVis); - - VisualPtr scaleHeadZVis = this->Scene()->CreateVisual(); - scaleHeadZVis->AddGeometry(this->Scene()->CreateBox()); - scaleHeadZVis->SetOrigin(0, 0, -0.5); - scaleHeadZVis->SetLocalPosition(0, 0, 0.5); - scaleHeadZVis->SetLocalScale(0.07, 0.07, 0.07); - scaleZVis->AddChild(scaleHeadZVis); - - scaleZVis->SetMaterial(this->materials[AM_Z], false); - scaleVis->AddChild(scaleZVis); - - this->visuals[TransformAxis::TA_SCALE_X] = scaleXVis; - this->visuals[TransformAxis::TA_SCALE_Y] = scaleYVis; - this->visuals[TransformAxis::TA_SCALE_Z] = scaleZVis; - - // scale handles - VisualPtr scaleHandleXVis = this->Scene()->CreateVisual(); - scaleHandleXVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleHandleXVis->SetLocalPosition(0, 0, 0.285); - scaleHandleXVis->SetLocalScale(0.11, 0.11, 0.57); - scaleHandleXVis->SetMaterial(this->materials[AM_HANDLE], false); - scaleXVis->AddChild(scaleHandleXVis); - - VisualPtr scaleHandleYVis = this->Scene()->CreateVisual(); - scaleHandleYVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleHandleYVis->SetLocalPosition(0, 0, 0.285); - scaleHandleYVis->SetLocalScale(0.11, 0.11, 0.57); - scaleHandleYVis->SetMaterial(this->materials[AM_HANDLE], false); - scaleYVis->AddChild(scaleHandleYVis); - - VisualPtr scaleHandleZVis = this->Scene()->CreateVisual(); - scaleHandleZVis->AddGeometry(this->Scene()->CreateCylinder()); - scaleHandleZVis->SetLocalPosition(0, 0, 0.285); - scaleHandleZVis->SetLocalScale(0.11, 0.11, 0.57); - scaleHandleZVis->SetMaterial(this->materials[AM_HANDLE], false); - scaleZVis->AddChild(scaleHandleZVis); - - this->handles[TransformAxis::TA_SCALE_X] = scaleHandleXVis; - this->handles[TransformAxis::TA_SCALE_Y] = scaleHandleYVis; - this->handles[TransformAxis::TA_SCALE_Z] = scaleHandleZVis; - - this->AddChild(scaleVis); - } - - ////////////////////////////////////////////////// - template - VisualPtr BaseGizmoVisual::ChildByAxis(unsigned int _axis) const - { - auto it = this->visuals.find(_axis); - if (it != this->visuals.end()) - return it->second; - - return VisualPtr(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseGpuRays.hh b/include/ignition/rendering/base/BaseGpuRays.hh index 81589af62..c4d48806b 100644 --- a/include/ignition/rendering/base/BaseGpuRays.hh +++ b/include/ignition/rendering/base/BaseGpuRays.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,399 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEGPURAYS_HH_ -#define IGNITION_RENDERING_BASE_BASEGPURAYS_HH_ -#include - -#include -#include - -#include "ignition/rendering/GpuRays.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/base/BaseRenderTarget.hh" -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/Visual.hh" -#include "ignition/rendering/RenderTypes.hh" - - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseGpuRays : - public virtual GpuRays, - public virtual BaseCamera, - public virtual T - { - /// \brief Constructor - protected: BaseGpuRays(); - - /// \brief Destructor - public: virtual ~BaseGpuRays(); - - // Documentation inherited. - public: virtual const float *Data() const override; - - // Documentation inherited. - public: virtual void Copy(float *_data) override; - - // Documentation inherited. - public: virtual void SetClamp(bool _enable) override; - - // Documentation inherited. - public: virtual bool Clamp() const override; - - // Documentation inherited. - public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( - std::function _subscriber) override; - - /// \brief Pointer to the render target - public: virtual RenderTargetPtr RenderTarget() const override = 0; - - // Documentation inherited. - public: virtual void SetIsHorizontal(const bool _horizontal) override; - - // Documentation inherited. - public: virtual bool IsHorizontal() const override; - - /// \brief Set the vertical fov - /// \param[in] _vfov vertical fov - public: virtual void SetVFOV(const math::Angle &_vfov); - - // Documentation inherited. - public: virtual math::Angle VFOV() const override; - - // Documentation inherited. - public: virtual double RayCountRatio() const override; - - // Documentation inherited. - public: virtual double RangeCountRatio() const override; - - // Documentation inherited. - public: virtual void SetRayCountRatio( - const double _rayCountRatio) override; - - // Documentation inherited. - public: virtual ignition::math::Angle AngleMin() const override; - - // Documentation inherited. - public: virtual void SetAngleMin(double _angle) override; - - // Documentation inherited. - public: virtual ignition::math::Angle AngleMax() const override; - - // Documentation inherited. - public: virtual void SetAngleMax(double _angle) override; - - // Documentation inherited. - public: virtual void SetVerticalRayCount(int _samples) override; - - // Documentation inherited. - public: virtual void SetRayCount(int _samples) override; - - // Documentation inherited. - public: virtual int RayCount() const override; - - // Documentation inherited. - public: virtual int RangeCount() const override; - - // Documentation inherited. - public: virtual int VerticalRayCount() const override; - - // Documentation inherited. - public: virtual int VerticalRangeCount() const override; - - // Documentation inherited. - public: virtual ignition::math::Angle VerticalAngleMin() const override; - - // Documentation inherited. - public: virtual void SetVerticalAngleMin(const double _angle) override; - - // Documentation inherited. - public: virtual ignition::math::Angle VerticalAngleMax() const override; - - // Documentation inherited. - public: virtual void SetVerticalAngleMax(const double _angle) override; - - // Documentation inherited. - public: virtual unsigned int Channels() const override; - - /// \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: int hResolution = 1; - - /// \brief Resolution of vertical rays - protected: int 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 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 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; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseGrid.hh b/include/ignition/rendering/base/BaseGrid.hh index 26aabc464..9b6de6e41 100644 --- a/include/ignition/rendering/base/BaseGrid.hh +++ b/include/ignition/rendering/base/BaseGrid.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,144 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEGRID_HH_ -#define IGNITION_RENDERING_BASE_BASEGRID_HH_ -#include -#include "ignition/rendering/Grid.hh" -#include "ignition/rendering/base/BaseObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of a grid geometry - template - class BaseGrid : - public virtual Grid, - public virtual T - { - /// \brief Constructor - protected: BaseGrid(); - - /// \brief Destructor - public: virtual ~BaseGrid(); - - // Documentation inherited. - public: virtual void PreRender(); - - // Documentation inherited. - public: virtual void Destroy(); - - // Documentation inherited. - public: virtual unsigned int CellCount() const; - - // Documentation inherited. - public: virtual void SetCellCount(const unsigned int _count); - - // Documentation inherited. - public: virtual double CellLength() const; - - // Documentation inherited. - public: virtual void SetCellLength(const double _len); - - // Documentation inherited. - public: virtual unsigned int VerticalCellCount() const; - - // Documentation inherited. - public: virtual void SetVerticalCellCount(const unsigned int _count); - - /// \brief Number of cells in grid - protected: unsigned int cellCount = 10u; - - /// \brief Length of a single cell - protected: double cellLength = 1.0; - - /// \brief Number of cells in vertical direction - protected: unsigned int verticalCellCount = 0; - - /// \brief vertical offset of the XY plane from origin - protected: double heightOffset = 0.0; - - /// \brief Flag to indicate grid properties have changed - protected: bool gridDirty = false; - }; - - ////////////////////////////////////////////////// - // BaseGrid - ////////////////////////////////////////////////// - template - BaseGrid::BaseGrid() - { - } - - ////////////////////////////////////////////////// - template - BaseGrid::~BaseGrid() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseGrid::CellCount() const - { - return this->cellCount; - } - - ////////////////////////////////////////////////// - template - void BaseGrid::SetCellCount(const unsigned int _count) - { - this->cellCount = _count; - this->gridDirty = true; - } - - ////////////////////////////////////////////////// - template - double BaseGrid::CellLength() const - { - return this->cellLength; - } - - ////////////////////////////////////////////////// - template - void BaseGrid::SetCellLength(const double _len) - { - this->cellLength = _len; - this->gridDirty = true; - } - - ////////////////////////////////////////////////// - template - unsigned int BaseGrid::VerticalCellCount() const - { - return this->verticalCellCount; - } - - ////////////////////////////////////////////////// - template - void BaseGrid::SetVerticalCellCount(const unsigned int _count) - { - this->verticalCellCount = _count; - this->gridDirty = true; - } - - ////////////////////////////////////////////////// - template - void BaseGrid::PreRender() - { - T::PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseGrid::Destroy() - { - T::Destroy(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseLight.hh b/include/ignition/rendering/base/BaseLight.hh index 0994a75ea..4aab8ac8c 100644 --- a/include/ignition/rendering/base/BaseLight.hh +++ b/include/ignition/rendering/base/BaseLight.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,235 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASELIGHT_HH_ -#define IGNITION_RENDERING_BASE_BASELIGHT_HH_ -#include "ignition/rendering/Light.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseLight : - public virtual Light, - public virtual T - { - protected: BaseLight(); - - public: virtual ~BaseLight(); - - // Documentation inherited - public: virtual void SetDiffuseColor(double _r, double _g, double _b, - double _a = 1.0); - - // Documentation inherited. - public: virtual void SetDiffuseColor(const math::Color &_color) = 0; - - // Documentation inherited. - public: virtual void SetSpecularColor(double _r, double _g, double _b, - double _a = 1.0); - - // Documentation inherited. - public: virtual void SetSpecularColor(const math::Color &_color) = 0; - - // Documentation inherited. - public: virtual void SetAttenuationConstant(double _value) = 0; - - // Documentation inherited. - public: virtual void SetAttenuationLinear(double _value) = 0; - - // Documentation inherited. - public: virtual void SetAttenuationQuadratic(double _value) = 0; - - // Documentation inherited. - public: virtual void SetAttenuationRange(double _range) = 0; - - // Documentation inherited. - public: virtual void SetCastShadows(bool _castShadows) = 0; - - // Documentation inherited. - protected: virtual void Reset(); - }; - - template - class BaseDirectionalLight : - public virtual DirectionalLight, - public virtual T - { - protected: BaseDirectionalLight(); - - public: virtual ~BaseDirectionalLight(); - - public: virtual void SetDirection(double _x, double _y, double _z); - - public: virtual void SetDirection(const math::Vector3d &_dir) = 0; - - protected: virtual void Reset(); - }; - - template - class BasePointLight : - public virtual PointLight, - public virtual T - { - protected: BasePointLight(); - - public: virtual ~BasePointLight(); - }; - - template - class BaseSpotLight : - public virtual SpotLight, - public virtual T - { - protected: BaseSpotLight(); - - public: virtual ~BaseSpotLight(); - - public: virtual void SetDirection(double _x, double _y, double _z); - - public: virtual void SetDirection(const math::Vector3d &_dir) = 0; - - public: virtual void SetInnerAngle(double _radians); - - public: virtual void SetInnerAngle(const math::Angle &_angle) = 0; - - public: virtual void SetOuterAngle(double _radians); - - public: virtual void SetOuterAngle(const math::Angle &_angle) = 0; - - public: virtual void SetFalloff(double _falloff) = 0; - - protected: virtual void Reset(); - }; - - ////////////////////////////////////////////////// - template - BaseLight::BaseLight() - { - } - - ////////////////////////////////////////////////// - template - BaseLight::~BaseLight() - { - } - - ////////////////////////////////////////////////// - template - void BaseLight::SetDiffuseColor(double _r, double _g, double _b, - double _a) - { - this->SetDiffuseColor(math::Color(_r, _g, _b, _a)); - } - - ////////////////////////////////////////////////// - template - void BaseLight::SetSpecularColor(double _r, double _g, double _b, - double _a) - { - this->SetSpecularColor(math::Color(_r, _g, _b, _a)); - } - - ////////////////////////////////////////////////// - template - void BaseLight::Reset() - { - this->SetDiffuseColor(math::Color::White); - this->SetSpecularColor(math::Color::White); - this->SetAttenuationConstant(1); - this->SetAttenuationLinear(0); - this->SetAttenuationQuadratic(0); - this->SetAttenuationRange(100); - this->SetCastShadows(true); - } - - ////////////////////////////////////////////////// - template - BaseDirectionalLight::BaseDirectionalLight() - { - } - - ////////////////////////////////////////////////// - template - BaseDirectionalLight::~BaseDirectionalLight() - { - } - - ////////////////////////////////////////////////// - template - void BaseDirectionalLight::SetDirection(double _x, double _y, double _z) - { - this->SetDirection(math::Vector3d(_x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseDirectionalLight::Reset() - { - T::Reset(); - this->SetDirection(0, 0, -1); - } - - ////////////////////////////////////////////////// - template - BasePointLight::BasePointLight() - { - } - - ////////////////////////////////////////////////// - template - BasePointLight::~BasePointLight() - { - } - - ////////////////////////////////////////////////// - template - BaseSpotLight::BaseSpotLight() - { - } - - ////////////////////////////////////////////////// - template - BaseSpotLight::~BaseSpotLight() - { - } - - ////////////////////////////////////////////////// - template - void BaseSpotLight::SetDirection(double _x, double _y, double _z) - { - this->SetDirection(math::Vector3d(_x, _y, _z)); - } - - ////////////////////////////////////////////////// - template - void BaseSpotLight::SetInnerAngle(double _radians) - { - this->SetInnerAngle(math::Angle(_radians)); - } - - ////////////////////////////////////////////////// - template - void BaseSpotLight::SetOuterAngle(double _radians) - { - this->SetOuterAngle(math::Angle(_radians)); - } - - ////////////////////////////////////////////////// - template - void BaseSpotLight::Reset() - { - T::Reset(); - this->SetDirection(0, 0, -1); - this->SetInnerAngle(IGN_PI / 4.5); - this->SetOuterAngle(IGN_PI / 4.0); - this->SetFalloff(1.0); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseMarker.hh b/include/ignition/rendering/base/BaseMarker.hh index 7f5f83d2a..bcff5773d 100644 --- a/include/ignition/rendering/base/BaseMarker.hh +++ b/include/ignition/rendering/base/BaseMarker.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,197 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_BASEMARKER_HH_ -#define IGNITION_RENDERING_BASEMARKER_HH_ + */ -#include - -#include "ignition/rendering/Marker.hh" -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \brief Base implementation of a Marker geometry - template - class BaseMarker : - public virtual Marker, - public virtual T - { - /// \brief Constructor. - protected: BaseMarker(); - - /// \brief Destructor. - public: virtual ~BaseMarker(); - - /// \brief PreRender function - public: virtual void PreRender() override; - - /// \brief Destroy function - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void SetLifetime(const - std::chrono::steady_clock::duration &_lifetime) override; - - // Documentation inherited - public: virtual std::chrono::steady_clock::duration Lifetime() - const override; - - // Documentation inherited - public: virtual void SetType(const MarkerType _markerType) override; - - // Documentation inherited - public: virtual MarkerType Type() const override; - - // Documentation inherited - public: virtual void SetLayer(int32_t _layer) override; - - // Documentation inherited - public: virtual int32_t Layer() const override; - - // Documentation inherited - public: virtual void ClearPoints() override; - - // Documentation inherited - public: virtual void AddPoint(double _x, - double _y, double _z, - const ignition::math::Color &_color) override; - - // Documentation inherited - public: virtual void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color) override; - - // Documentation inherited - public: virtual void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value) override; - - /// \brief Life time of a marker - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: std::chrono::steady_clock::duration lifetime = - std::chrono::steady_clock::duration::zero(); - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Layer at which the marker will reside - protected: int32_t layer = 0; - - /// \brief Flag to indicate if marker needs to be updated - protected: bool markerDirty = false; - - /// \brief Marker type - protected: MarkerType markerType = - ignition::rendering::MarkerType::MT_NONE; - }; - - ///////////////////////////////////////////////// - // 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::PreRender() - { - T::PreRender(); - } - - ///////////////////////////////////////////////// - template - void BaseMarker::Destroy() - { - T::Destroy(); - } - - ///////////////////////////////////////////////// - template - void BaseMarker::ClearPoints() - { - // no op - } - - ///////////////////////////////////////////////// - template - void BaseMarker::AddPoint(const ignition::math::Vector3d &, - const ignition::math::Color &) - { - // no op - } - - ///////////////////////////////////////////////// - template - void BaseMarker::AddPoint(double _x, double _y, double _z, - const ignition::math::Color &_color) - { - this->AddPoint(ignition::math::Vector3d(_x, _y, _z), _color); - } - - ///////////////////////////////////////////////// - template - void BaseMarker::SetPoint(unsigned int, - const ignition::math::Vector3d &) - { - // no op - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseMaterial.hh b/include/ignition/rendering/base/BaseMaterial.hh index c6c2861e5..449fbe372 100644 --- a/include/ignition/rendering/base/BaseMaterial.hh +++ b/include/ignition/rendering/base/BaseMaterial.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,913 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEMATERIAL_HH_ -#define IGNITION_RENDERING_BASE_BASEMATERIAL_HH_ -#include - -#include "ignition/common/Console.hh" - -#include "ignition/rendering/Material.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/ShaderType.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Default pbr material properties - static const common::Pbr kDefaultPbr; - - template - class BaseMaterial : - public virtual Material, - public virtual T - { - protected: BaseMaterial(); - - public: virtual ~BaseMaterial(); - - // Documentation inherited - public: virtual MaterialPtr Clone(const std::string &_name = "") const - override; - - // Documentation inherited - public: virtual void SetAmbient(const double _r, const double _g, - const double _b, const double _a = 1.0) override; - - // Documentation inherited - public: virtual void SetAmbient(const math::Color &_color) override; - - // Documentation inherited - public: virtual void SetDiffuse(const double _r, const double _g, - const double _b, const double _a = 1.0) override; - - // Documentation inherited - public: virtual void SetDiffuse(const math::Color &_color) override; - - // Documentation inherited - public: virtual void SetSpecular(const double _r, const double _g, - const double _b, const double _a = 1.0) override; - - // Documentation inherited - public: virtual void SetSpecular(const math::Color &_color) override; - - // Documentation inherited - public: virtual void SetEmissive(const double _r, const double _g, - const double _b, const double _a = 1.0) override; - - // Documentation inherited - public: virtual void SetEmissive(const math::Color &_color) override; - - // Documentation inherited - public: virtual void SetTransparency(const double _transparency) override; - - // Documentation inherited - public: virtual void 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 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 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::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 - 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 - 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 - 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->SetShininess(_material->Shininess()); - 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->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()); - // 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()); - } - - ////////////////////////////////////////////////// - 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->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->SetRoughness(kDefaultPbr.Roughness()); - this->SetMetalness(kDefaultPbr.Metalness()); - this->SetShaderType(ST_PIXEL); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseMesh.hh b/include/ignition/rendering/base/BaseMesh.hh index c8b4d5808..f2faa8de0 100644 --- a/include/ignition/rendering/base/BaseMesh.hh +++ b/include/ignition/rendering/base/BaseMesh.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,324 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEMESH_HH_ -#define IGNITION_RENDERING_BASE_BASEMESH_HH_ -#include -#include -#include "ignition/rendering/Mesh.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; - - 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 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; - }; - - ////////////////////////////////////////////////// - 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 - 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 - void BaseMesh::Destroy() - { - T::Destroy(); - this->SubMeshes()->DestroyAll(); - if (this->material && this->ownsMaterial) - this->Scene()->DestroyMaterial(this->material); - this->material.reset(); - } - - ////////////////////////////////////////////////// - // BaseSubMesh - ////////////////////////////////////////////////// - template - BaseSubMesh::BaseSubMesh() - { - } - - ////////////////////////////////////////////////// - template - BaseSubMesh::~BaseSubMesh() - { - } - - ////////////////////////////////////////////////// - template - void BaseSubMesh::Destroy() - { - T::Destroy(); - if (this->material && this->ownsMaterial) - this->Scene()->DestroyMaterial(this->material); - this->material.reset(); - } - - - ////////////////////////////////////////////////// - template - void BaseSubMesh::SetMaterial(const std::string &_name, bool _unique) - { - MaterialPtr mat = this->Scene()->Material(_name); - if (mat) this->SetMaterial(mat, _unique); - } - - ////////////////////////////////////////////////// - template - void BaseSubMesh::SetMaterial(MaterialPtr _material, bool _unique) - { - _material = (_unique) ? _material->Clone() : _material; - - MaterialPtr origMaterial = this->material; - bool origUnique = this->ownsMaterial; - - this->SetMaterialImpl(_material); - - if (origMaterial && origUnique) - this->Scene()->DestroyMaterial(origMaterial); - - this->material = _material; - this->ownsMaterial = _unique; - } - - ////////////////////////////////////////////////// - template - MaterialPtr BaseSubMesh::Material() const - { - return this->material; - } - - ////////////////////////////////////////////////// - template - void BaseSubMesh::PreRender() - { - T::PreRender(); - if (this->Material()) - this->Material()->PreRender(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseNode.hh b/include/ignition/rendering/base/BaseNode.hh index eb76ba456..7737eed80 100644 --- a/include/ignition/rendering/base/BaseNode.hh +++ b/include/ignition/rendering/base/BaseNode.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,623 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASENODE_HH_ -#define IGNITION_RENDERING_BASE_BASENODE_HH_ -#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; - - 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; - - 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; - }; - - ////////////////////////////////////////////////// - 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; - } - - this->SetRawLocalPose(pose); - } - - ////////////////////////////////////////////////// - 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 pose + parent->WorldPose(); - } - - ////////////////////////////////////////////////// - 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); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseObject.hh b/include/ignition/rendering/base/BaseObject.hh index 73f670ddf..1ce9353b5 100644 --- a/include/ignition/rendering/base/BaseObject.hh +++ b/include/ignition/rendering/base/BaseObject.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,56 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEOBJECT_HH_ -#define IGNITION_RENDERING_BASE_BASEOBJECT_HH_ -#include -#include -#include -#include "ignition/rendering/Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_VISIBLE BaseObject : - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public virtual std::enable_shared_from_this, - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - public virtual Object - { - protected: BaseObject(); - - public: virtual ~BaseObject(); - - public: virtual unsigned int Id() const override; - - public: virtual std::string Name() const override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // TODO(anyone): make pure virtual - protected: virtual void Load(); - - // TODO(anyone): make pure virtual - protected: virtual void Init(); - - protected: unsigned int id; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: std::string name; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseRayQuery.hh b/include/ignition/rendering/base/BaseRayQuery.hh index efef2bdee..0d1b88803 100644 --- a/include/ignition/rendering/base/BaseRayQuery.hh +++ b/include/ignition/rendering/base/BaseRayQuery.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,142 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASERAYQUERY_HH_ -#define IGNITION_RENDERING_BASE_BASERAYQUERY_HH_ -#include -#include - -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/Scene.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \class BaseRayQuery BaseRayQuery.hh - /// ignition/rendering/base/BaseRayQuery.hh - /// \brief A Ray Query class used for computing ray object intersections - template - class BaseRayQuery : - public virtual RayQuery, - public T - { - /// \brief Constructor - protected: BaseRayQuery(); - - /// \brief Destructor - public: virtual ~BaseRayQuery() override; - - // Documentation inherited - public: virtual void SetOrigin(const math::Vector3d &_origin) override; - - // Documentation inherited - public: virtual math::Vector3d Origin() const override; - - // Documentation inherited - public: virtual void SetDirection(const math::Vector3d &_dir) override; - - // Documentation inherited - public: virtual math::Vector3d Direction() const override; - - // Documentation inherited - public: virtual void SetFromCamera(const CameraPtr &_camera, - const math::Vector2d &_coord) override; - - // Documentation inherited - public: virtual RayQueryResult ClosestPoint() override; - - /// \brief Ray origin - protected: math::Vector3d origin; - - /// \brief Ray direction - protected: math::Vector3d direction; - }; - - ////////////////////////////////////////////////// - template - BaseRayQuery::BaseRayQuery() - { - } - - ////////////////////////////////////////////////// - template - BaseRayQuery::~BaseRayQuery() - { - } - - ////////////////////////////////////////////////// - template - void BaseRayQuery::SetOrigin(const math::Vector3d &_origin) - { - this->origin = _origin; - } - - ////////////////////////////////////////////////// - template - ignition::math::Vector3d BaseRayQuery::Origin() const - { - return this->origin; - } - - ////////////////////////////////////////////////// - template - void BaseRayQuery::SetDirection(const math::Vector3d &_dir) - { - this->direction = _dir; - } - - ////////////////////////////////////////////////// - template - ignition::math::Vector3d BaseRayQuery::Direction() const - { - return this->direction; - } - - ////////////////////////////////////////////////// - template - void BaseRayQuery::SetFromCamera(const CameraPtr &_camera, - const ignition::math::Vector2d &_coord) - { - math::Matrix4d projectionMatrix = _camera->ProjectionMatrix(); - math::Matrix4d viewMatrix = _camera->ViewMatrix(); - math::Vector3d start(_coord.X(), _coord.Y(), -1.0); - math::Vector3d end(_coord.X(), _coord.Y(), 0.0); - math::Matrix4d viewProjInv = (projectionMatrix * viewMatrix).Inverse(); - - // rotate start and end - // ign math does not support matrix4 * vec4 - // so calc homogeneous coordinate w ourselves - double startw = viewProjInv(3, 0) * start[0] + - viewProjInv(3, 1) * start[1] + - viewProjInv(3, 2) * start[2] + viewProjInv(3, 3); - double endw = viewProjInv(3, 0) * end[0] + - viewProjInv(3, 1) * end[1] + - viewProjInv(3, 2) * end[2] + viewProjInv(3, 3); - start = viewProjInv * start; - end = viewProjInv * end; - // normalize - start = start / startw; - end = end / endw; - math::Vector3d dir = (end - start).Normalize(); - - this->origin = start; - this->direction = dir; - } - - ////////////////////////////////////////////////// - template - RayQueryResult BaseRayQuery::ClosestPoint() - { - // TODO(anyone): implement a generic ray query here? - RayQueryResult result; - result.distance = -1; - return result; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseRenderEngine.hh b/include/ignition/rendering/base/BaseRenderEngine.hh index c41fb03a5..0202704c4 100644 --- a/include/ignition/rendering/base/BaseRenderEngine.hh +++ b/include/ignition/rendering/base/BaseRenderEngine.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,115 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASERENDERENGINE_HH_ -#define IGNITION_RENDERING_BASE_BASERENDERENGINE_HH_ -#include -#include -#include -#include -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/Storage.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_VISIBLE BaseRenderEngine : - public virtual RenderEngine - { - protected: BaseRenderEngine(); - - public: virtual ~BaseRenderEngine(); - - // Documentation Inherited. - public: virtual bool Load( - const std::map &_params = {}) override; - - public: virtual bool Init() override; - - public: virtual bool Fini() override; - - public: virtual bool IsLoaded() const override; - - public: virtual bool IsInitialized() const override; - - public: virtual bool IsEnabled() const override; - - public: virtual unsigned int SceneCount() const override; - - public: virtual bool HasScene(ConstScenePtr _scene) const override; - - public: virtual bool HasSceneId(unsigned int _id) const override; - - public: virtual bool HasSceneName(const std::string &_name) const - override; - - public: virtual ScenePtr SceneById(unsigned int _id) const override; - - public: virtual ScenePtr SceneByName(const std::string &_name) const - override; - - public: virtual ScenePtr SceneByIndex(unsigned int _index) const override; - - public: virtual void DestroyScene(ScenePtr _scene) override; - - public: virtual void DestroySceneById(unsigned int _id) override; - - public: virtual void DestroySceneByName(const std::string &_name) - override; - - public: virtual void DestroySceneByIndex(unsigned int _index) override; - - public: virtual void DestroyScenes() override; - - public: virtual ScenePtr CreateScene(const std::string &_name) override; - - public: virtual ScenePtr CreateScene(unsigned int _id, - const std::string &_name) override; - - public: virtual void Destroy() override; - - // Documentation Inherited - public: virtual void AddResourcePath(const std::string &_path) override; - - // Documentation Inherited - public: virtual 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: unsigned int nextSceneId; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief a list of paths that render engines use to locate their - /// resources - protected: std::vector resourcePaths; - - /// \brief Render pass system for this render engine. - protected: RenderPassSystemPtr renderPassSystem; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseRenderPass.hh b/include/ignition/rendering/base/BaseRenderPass.hh index 347cdc211..b758dfe90 100644 --- a/include/ignition/rendering/base/BaseRenderPass.hh +++ b/include/ignition/rendering/base/BaseRenderPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,71 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASERENDERPASS_HH_ -#define IGNITION_RENDERING_BASE_BASERENDERPASS_HH_ -#include -#include "ignition/rendering/RenderPass.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class BaseRenderPass BaseRenderPass.hh \ - * ignition/rendering/base/BaseRenderPass.hh - */ - /// \brief Base render pass that can be applied to a render target - template - class BaseRenderPass: - public virtual RenderPass, - public T - { - /// \brief Constructor - protected: BaseRenderPass(); - - /// \brief Destructor - public: virtual ~BaseRenderPass(); - - // Documentation inherited - public: virtual void SetEnabled(bool _enabled) override; - - // Documentation inherited - public: virtual bool IsEnabled() const override; - - /// \brief Flag to indicate if render pass is enabled or not - protected: bool enabled = true; - }; - - ////////////////////////////////////////////////// - // BaseRenderPass - ////////////////////////////////////////////////// - template - BaseRenderPass::BaseRenderPass() - { - } - - ////////////////////////////////////////////////// - template - BaseRenderPass::~BaseRenderPass() - { - } - - ////////////////////////////////////////////////// - template - void BaseRenderPass::SetEnabled(bool _enabled) - { - this->enabled = _enabled; - } - - ////////////////////////////////////////////////// - template - bool BaseRenderPass::IsEnabled() const - { - return this->enabled; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseRenderTarget.hh b/include/ignition/rendering/base/BaseRenderTarget.hh index c0c795c79..546ad2f48 100644 --- a/include/ignition/rendering/base/BaseRenderTarget.hh +++ b/include/ignition/rendering/base/BaseRenderTarget.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,344 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASERENDERTARGET_HH_ -#define IGNITION_RENDERING_BASE_BASERENDERTARGET_HH_ -#include -#include - -#include "ignition/rendering/RenderPass.hh" -#include "ignition/rendering/RenderTarget.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseRenderTarget : - public virtual RenderTarget, - public virtual T - { - public: BaseRenderTarget(); - - public: virtual ~BaseRenderTarget(); - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - public: virtual unsigned int Width() const override; - - public: virtual void SetWidth(const unsigned int _width) override; - - public: virtual unsigned int Height() const override; - - public: virtual void SetHeight(const unsigned int _height) override; - - public: virtual PixelFormat Format() const override; - - public: virtual void SetFormat(PixelFormat _format) override; - - // Documentation inherited - public: virtual math::Color BackgroundColor() const override; - - // Documentation inherited - public: virtual void AddRenderPass(const RenderPassPtr &_pass) override; - - // Documentation inherited - public: virtual void RemoveRenderPass(const RenderPassPtr &_pass) - override; - - // Documentation inherited - public: virtual unsigned int RenderPassCount() const override; - - // Documentation inherited - public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index) - const override; - - protected: virtual void Rebuild(); - - protected: virtual void RebuildImpl() = 0; - - protected: PixelFormat format = PF_UNKNOWN; - - protected: bool targetDirty = true; - - /// \brief Flag to indicate if render pass need to be rebuilt - protected: bool renderPassDirty = false; - - protected: unsigned int width = 0u; - - protected: unsigned int height = 0u; - - /// \brief A chain of render passes applied to the render target - protected: std::vector renderPasses; - }; - - template - class BaseRenderTexture : - public virtual RenderTexture, - public virtual T - { - public: BaseRenderTexture(); - - public: virtual ~BaseRenderTexture(); - - // Documentation inherited. - public: virtual unsigned int GLId() const override; - }; - - template - class BaseRenderWindow : - public virtual RenderWindow, - public virtual T - { - public: BaseRenderWindow(); - - public: virtual ~BaseRenderWindow(); - - public: virtual std::string Handle() const; - - public: virtual void SetHandle(const std::string &_handle); - - public: virtual double DevicePixelRatio() const; - - public: virtual void SetDevicePixelRatio(const double _ratio); - - public: virtual void OnResize(const unsigned int _width, - const unsigned int _height); - - public: virtual void OnMove(); - - protected: std::string handle; - - protected: double ratio = 1.0; - }; - - ////////////////////////////////////////////////// - // BaseRenderTarget - ////////////////////////////////////////////////// - template - BaseRenderTarget::BaseRenderTarget() - { - } - - ////////////////////////////////////////////////// - template - BaseRenderTarget::~BaseRenderTarget() - { - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::PreRender() - { - T::PreRender(); - this->Rebuild(); - for (auto &pass : this->renderPasses) - pass->PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::PostRender() - { - T::PostRender(); - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::Rebuild() - { - if (this->targetDirty) - { - this->RebuildImpl(); - this->targetDirty = false; - } - } - - ////////////////////////////////////////////////// - template - unsigned int BaseRenderTarget::Width() const - { - return this->width; - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::SetWidth(const unsigned int _width) - { - this->width = _width; - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - unsigned int BaseRenderTarget::Height() const - { - return this->height; - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::SetHeight(const unsigned int _height) - { - this->height = _height; - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - PixelFormat BaseRenderTarget::Format() const - { - return this->format; - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::SetFormat(PixelFormat _format) - { - this->format = PixelUtil::Sanitize(_format); - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - math::Color BaseRenderTarget::BackgroundColor() const - { - return this->Scene()->BackgroundColor(); - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::AddRenderPass(const RenderPassPtr &_pass) - { - this->renderPasses.push_back(_pass); - this->renderPassDirty = true; - } - - ////////////////////////////////////////////////// - template - void BaseRenderTarget::RemoveRenderPass(const RenderPassPtr &_pass) - { - auto it = std::find(this->renderPasses.begin(), this->renderPasses.end(), - _pass); - if (it != this->renderPasses.end()) - { - (*it)->Destroy(); - this->renderPasses.erase(it); - this->renderPassDirty = true; - } - } - - ////////////////////////////////////////////////// - template - unsigned int BaseRenderTarget::RenderPassCount() const - { - return this->renderPasses.size(); - } - - ////////////////////////////////////////////////// - template - RenderPassPtr BaseRenderTarget::RenderPassByIndex(unsigned int _index) - const - { - if (_index > this->renderPasses.size()) - { - ignerr << "RenderPass index out of range: " << _index << std::endl; - return RenderPassPtr(); - } - return this->renderPasses[_index]; - } - - ////////////////////////////////////////////////// - // BaseRenderTexture - ////////////////////////////////////////////////// - template - BaseRenderTexture::BaseRenderTexture() - { - } - - ////////////////////////////////////////////////// - template - BaseRenderTexture::~BaseRenderTexture() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseRenderTexture::GLId() const - { - return 0u; - } - - ////////////////////////////////////////////////// - // BaseRenderWindow - ////////////////////////////////////////////////// - template - BaseRenderWindow::BaseRenderWindow() - { - } - - ////////////////////////////////////////////////// - template - BaseRenderWindow::~BaseRenderWindow() - { - } - - ////////////////////////////////////////////////// - template - std::string BaseRenderWindow::Handle() const - { - return this->handle; - } - - ////////////////////////////////////////////////// - template - void BaseRenderWindow::SetHandle(const std::string &_handle) - { - this->handle = _handle; - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - double BaseRenderWindow::DevicePixelRatio() const - { - return this->ratio; - } - - ////////////////////////////////////////////////// - template - void BaseRenderWindow::SetDevicePixelRatio(const double _ratio) - { - this->ratio = _ratio; - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - void BaseRenderWindow::OnResize(const unsigned int _width, - const unsigned int _height) - { - this->width = _width; - this->height = _height; - this->targetDirty = true; - } - - ////////////////////////////////////////////////// - template - void BaseRenderWindow::OnMove() - { - this->targetDirty = true; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseRenderTypes.hh b/include/ignition/rendering/base/BaseRenderTypes.hh index ebc1004cb..578bc4af8 100644 --- a/include/ignition/rendering/base/BaseRenderTypes.hh +++ b/include/ignition/rendering/base/BaseRenderTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,34 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASERENDERTYPES_HH_ -#define IGNITION_RENDERING_BASE_BASERENDERTYPES_HH_ -#include - -#include "ignition/rendering/RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class BaseNodeCompositeStore; - typedef shared_ptr BaseNodeCompositeStorePtr; - - class BaseObject; - typedef std::shared_ptr BaseObjectPtr; - - template class BaseSceneStore; - template class BaseNodeStore; - template class BaseLightStore; - template class BaseSensorStore; - template class BaseVisualStore; - template class BaseGeometryStore; - template class BaseSubMeshStore; - template class BaseMaterialMap; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseScene.hh b/include/ignition/rendering/base/BaseScene.hh index 41da6508f..a27964e73 100644 --- a/include/ignition/rendering/base/BaseScene.hh +++ b/include/ignition/rendering/base/BaseScene.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,583 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASESCENE_HH_ -#define IGNITION_RENDERING_BASE_BASESCENE_HH_ -#include -#include -#include - -#include -#include - -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_VISIBLE BaseScene : - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public std::enable_shared_from_this, - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - public virtual Scene - { - protected: BaseScene(unsigned int _id, const std::string &_name); - - public: virtual ~BaseScene(); - - public: virtual void Load() override; - - public: virtual void Init() override; - - public: virtual void Fini() override; - - public: virtual bool IsLoaded() const; - - public: virtual bool IsInitialized() const override; - - public: virtual unsigned int Id() const override; - - public: virtual std::string Name() const override; - - public: virtual common::Time SimTime() const override; - - public: virtual void SetSimTime(const common::Time &_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; - - 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; - - 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 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 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 GridPtr CreateGrid() override; - - // Documentation inherited. - public: virtual MarkerPtr CreateMarker() 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; - - public: virtual void PreRender() override; - - public: virtual void Clear() override; - - public: virtual void Destroy() 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 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 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 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; - - protected: virtual LightStorePtr Lights() const = 0; - - protected: virtual SensorStorePtr Sensors() const = 0; - - protected: virtual VisualStorePtr Visuals() const = 0; - - protected: virtual MaterialMapPtr Materials() const = 0; - - protected: virtual bool LoadImpl() = 0; - - protected: virtual bool InitImpl() = 0; - - private: virtual void CreateNodeStore(); - - private: virtual void CreateMaterials(); - - /// \brief Helper function to recursively destory nodes while checking - /// for loops. - /// \param[in] _node Node to be destroyed - /// \param[in] _nodeId Holds all node ids that have been visited in the - /// tree during the destroy process. Used for loop detection. - private: void DestroyNodeRecursive(NodePtr _node, - std::set &_nodeIds); - - protected: unsigned int id; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: std::string name; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - protected: common::Time simTime; - - 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; - - private: unsigned int nextObjectId; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: NodeStorePtr nodes; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseSensor.hh b/include/ignition/rendering/base/BaseSensor.hh index 416251f48..0f41bad9e 100644 --- a/include/ignition/rendering/base/BaseSensor.hh +++ b/include/ignition/rendering/base/BaseSensor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,39 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASESENSOR_HH_ -#define IGNITION_RENDERING_BASE_BASESENSOR_HH_ -#include "ignition/rendering/Sensor.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template - class BaseSensor : - public virtual Sensor, - public virtual T - { - protected: BaseSensor(); - - public: virtual ~BaseSensor(); - }; - - ////////////////////////////////////////////////// - template - BaseSensor::BaseSensor() - { - } - - ////////////////////////////////////////////////// - template - BaseSensor::~BaseSensor() - { - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseStorage.hh b/include/ignition/rendering/base/BaseStorage.hh index c3068d8c9..97ddef866 100644 --- a/include/ignition/rendering/base/BaseStorage.hh +++ b/include/ignition/rendering/base/BaseStorage.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,1452 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASESTORAGE_HH_ -#define IGNITION_RENDERING_BASE_BASESTORAGE_HH_ -#include -#include -#include -#include - -#include -#include - -#include "ignition/rendering/Storage.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - ////////////////////////////////////////////////// - template - class BaseMap : - public Map - { - typedef std::shared_ptr TPtr; - - typedef std::shared_ptr ConstTPtr; - - typedef std::shared_ptr UPtr; - - typedef std::map UMap; - - typedef typename UMap::iterator UIter; - - typedef typename UMap::const_iterator ConstUIter; - - public: BaseMap(); - - public: virtual ~BaseMap(); - - public: virtual unsigned int Size() const; - - public: virtual bool ContainsKey(const std::string &_key) const; - - public: virtual bool ContainsValue(ConstTPtr _value) const; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public: virtual TPtr Get(const std::string &_key) const; - - public: virtual TPtr GetByIndex(unsigned int _index) const; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - public: virtual bool Put(const std::string &_key, TPtr _value); - - public: virtual void Remove(const std::string &_key); - - public: virtual void Remove(TPtr _value); - - public: virtual void RemoveAll(); - - public: virtual UPtr Derived(const std::string &_key) const; - - public: virtual UPtr DerivedByIndex(unsigned int _index) const; - - protected: virtual bool IsValidIter(ConstUIter _iter) const; - - protected: UMap map; - }; - - ////////////////////////////////////////////////// - template - class BaseStore : - public Store - { - typedef std::shared_ptr TPtr; - - typedef std::shared_ptr ConstTPtr; - - typedef std::shared_ptr UPtr; - - typedef std::map UStore; - - typedef typename UStore::iterator UIter; - - typedef typename UStore::const_iterator ConstUIter; - - public: BaseStore(); - - public: virtual ~BaseStore(); - - public: virtual unsigned int Size() const; - - public: virtual bool Contains(ConstTPtr _object) const; - - public: virtual bool ContainsId(unsigned int _id) const; - - public: virtual bool ContainsName(const std::string &_name) const; - - public: virtual TPtr GetById(unsigned int _id) const; - - public: virtual TPtr GetByName(const std::string &_name) const; - - public: virtual TPtr GetByIndex(unsigned int _index) const; - - public: virtual bool Add(TPtr _object); - - public: virtual TPtr Remove(TPtr _object); - - public: virtual TPtr RemoveById(unsigned int _id); - - public: virtual TPtr RemoveByName(const std::string &_name); - - public: virtual TPtr RemoveByIndex(unsigned int _index); - - public: virtual void RemoveAll(); - - public: virtual void Destroy(TPtr _object); - - public: virtual void DestroyById(unsigned int _id); - - public: virtual void DestroyByName(const std::string &_name); - - public: virtual void DestroyByIndex(unsigned int _index); - - public: virtual void DestroyAll(); - - public: virtual UPtr DerivedById(unsigned int _id) const; - - public: virtual UPtr DerivedByName(const std::string &_name) const; - - public: virtual UPtr DerivedByIndex(unsigned int _index) const; - - public: virtual bool AddDerived(UPtr _object); - - public: virtual UPtr RemoveDerived(UPtr _object); - - public: virtual UPtr RemoveDerivedById(unsigned int _id); - - public: virtual UPtr RemoveDerivedByName(const std::string &_name); - - public: virtual UPtr RemoveDerivedByIndex(unsigned int _index); - - /// \brief Return an iterator to the beginning - /// \returns Iterator to beginning - public: virtual UIter Begin(); - - /// \brief Return an iterator to the end - /// \returns Iterator to end - public: virtual UIter End(); - - protected: virtual ConstUIter ConstIter(ConstTPtr _object) const; - - protected: virtual ConstUIter ConstIterById(unsigned int _id) const; - - protected: virtual ConstUIter ConstIterByName( - const std::string &_name) const; - - protected: virtual ConstUIter ConstIterByIndex(unsigned int _index) const; - - protected: virtual UIter Iter(ConstTPtr _object); - - protected: virtual UIter IterById(unsigned int _id); - - protected: virtual UIter IterByName(const std::string &_name); - - protected: virtual UIter IterByIndex(unsigned int _index); - - protected: virtual bool AddImpl(UPtr _object); - - protected: virtual UPtr RemoveImpl(UIter _iter); - - protected: virtual void DestroyImpl(UIter _iter); - - protected: virtual bool IsValidIter(ConstUIter _iter) const; - - protected: virtual UIter RemoveConstness(ConstUIter _iter); - - protected: UStore store; - }; - - ////////////////////////////////////////////////// - template - class BaseCompositeStore : - public CompositeStore - { - typedef std::shared_ptr TPtr; - - typedef std::shared_ptr ConstTPtr; - - typedef Store TStore; - - typedef std::shared_ptr TStorePtr; - - typedef std::shared_ptr ConstTStorePtr; - - typedef std::vector TStoreList; - - typedef typename TStoreList::iterator TStoreIter; - - public: BaseCompositeStore(); - - public: virtual ~BaseCompositeStore(); - - public: virtual unsigned int Size() const; - - public: virtual bool Contains(ConstTPtr _object) const; - - public: virtual bool ContainsId(unsigned int _id) const; - - public: virtual bool ContainsName(const std::string &_name) const; - - public: virtual TPtr GetById(unsigned int _id) const; - - public: virtual TPtr GetByName(const std::string &_name) const; - - public: virtual TPtr GetByIndex(unsigned int _index) const; - - public: virtual bool Add(TPtr _object); - - public: virtual TPtr Remove(TPtr _object); - - public: virtual TPtr RemoveById(unsigned int _id); - - public: virtual TPtr RemoveByName(const std::string &_name); - - public: virtual TPtr RemoveByIndex(unsigned int _index); - - public: virtual void RemoveAll(); - - public: virtual void Destroy(TPtr _object); - - public: virtual void DestroyById(unsigned int _id); - - public: virtual void DestroyByName(const std::string &_name); - - public: virtual void DestroyByIndex(unsigned int _index); - - public: virtual void DestroyAll(); - - public: virtual unsigned int GetStoreCount() const; - - public: virtual bool ContainsStore(ConstTStorePtr _store) const; - - public: virtual TStorePtr GetStore(unsigned int _index) const; - - public: virtual bool AddStore(TStorePtr _store); - - public: virtual TStorePtr RemoveStore(TStorePtr _store); - - public: virtual TStorePtr RemoveStore(unsigned int _index); - - public: virtual TStorePtr RemoveStoreImpl(TStoreIter _iter); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: TStoreList stores; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - - ////////////////////////////////////////////////// - template - class BaseStoreWrapper : - public StoreWrapper - { - typedef std::shared_ptr TPtr; - - typedef std::shared_ptr ConstTPtr; - - typedef std::shared_ptr UPtr; - - typedef std::shared_ptr ConstUPtr; - - typedef Store UStore; - - typedef std::shared_ptr UStorePtr; - - public: explicit BaseStoreWrapper(UStorePtr _store); - - public: virtual ~BaseStoreWrapper(); - - public: virtual unsigned int Size() const; - - public: virtual bool Contains(ConstTPtr _object) const; - - public: virtual bool ContainsId(unsigned int _id) const; - - public: virtual bool ContainsName(const std::string &_name) const; - - public: virtual TPtr GetById(unsigned int _id) const; - - public: virtual TPtr GetByName(const std::string &_name) const; - - public: virtual TPtr GetByIndex(unsigned int _index) const; - - public: virtual bool Add(TPtr _object); - - public: virtual TPtr Remove(TPtr _object); - - public: virtual TPtr RemoveById(unsigned int _id); - - public: virtual TPtr RemoveByName(const std::string &_name); - - public: virtual TPtr RemoveByIndex(unsigned int _index); - - public: virtual void RemoveAll(); - - public: virtual void Destroy(TPtr _object); - - public: virtual void DestroyById(unsigned int _id); - - public: virtual void DestroyByName(const std::string &_name); - - public: virtual void DestroyByIndex(unsigned int _index); - - public: virtual void DestroyAll(); - - protected: UStorePtr store; - }; - - ////////////////////////////////////////////////// - class BaseNodeCompositeStore : - public BaseCompositeStore - { - }; - - template - class BaseSceneStore : - public BaseStore - { - }; - - template - class BaseNodeStore : - public BaseStore - { - }; - - template - class BaseLightStore : - public BaseStore - { - }; - - template - class BaseSensorStore : - public BaseStore - { - }; - - template - class BaseVisualStore : - public BaseStore - { - }; - - template - class BaseGeometryStore : - public BaseStore - { - }; - - template - class BaseSubMeshStore : - public BaseStore - { - }; - - template - class BaseMaterialMap : - public BaseMap - { - }; - - ////////////////////////////////////////////////// - template - BaseMap::BaseMap() - { - } - - ////////////////////////////////////////////////// - template - BaseMap::~BaseMap() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseMap::Size() const - { - return this->map.size(); - } - - ////////////////////////////////////////////////// - template - bool BaseMap::ContainsKey(const std::string &_key) const - { - return this->map.count(_key) > 0; - } - - ////////////////////////////////////////////////// - template - bool BaseMap::ContainsValue(ConstTPtr _value) const - { - for (auto pair : this->map) - { - if (pair.second == _value) return true; - } - - return false; - } - - ////////////////////////////////////////////////// - template - typename BaseMap::TPtr - BaseMap::Get(const std::string &_key) const - { - return this->Derived(_key); - } - - ////////////////////////////////////////////////// - template - typename BaseMap::TPtr - BaseMap::GetByIndex(unsigned int _index) const - { - return this->DerivedByIndex(_index); - } - - ////////////////////////////////////////////////// - template - bool BaseMap::Put(const std::string &_key, TPtr _value) - { - if (_key.empty()) - { - ignerr << "Cannot store item with empty key" << std::endl; - return false; - } - - if (!_value) - { - ignerr << "Cannot store null pointer value" << std::endl; - return false; - } - - if (this->ContainsKey(_key)) - { - ignerr << "Item already registered with key: " << _key << std::endl; - return false; - } - - UPtr derived = std::dynamic_pointer_cast(_value); - - if (!derived) - { - ignerr << "Cannot add item created by another render-engine" - << std::endl; - - return false; - } - - this->map[_key] = derived; - return true; - } - - ////////////////////////////////////////////////// - template - void BaseMap::Remove(const std::string &_key) - { - auto iter = this->map.find(_key); - - if (this->IsValidIter(iter)) - { - this->map.erase(iter); - } - } - - ////////////////////////////////////////////////// - template - void BaseMap::Remove(TPtr _value) - { - auto iter = this->map.begin(); - - while (this->IsValidIter(iter)) - { - if (iter->second == _value) - { - this->map.erase(iter); - continue; - } - - ++iter; - } - } - - ////////////////////////////////////////////////// - template - void BaseMap::RemoveAll() - { - this->map.clear(); - } - - ////////////////////////////////////////////////// - template - typename BaseMap::UPtr - BaseMap::Derived(const std::string &_key) const - { - auto iter = this->map.find(_key); - return (this->IsValidIter(iter)) ? iter->second : nullptr; - } - - ////////////////////////////////////////////////// - template - typename BaseMap::UPtr - BaseMap::DerivedByIndex(unsigned int _index) const - { - if (_index >= this->Size()) - { - ignerr << "Invalid index: " << _index << std::endl; - return nullptr; - } - - auto iter = this->map.begin(); - std::advance(iter, _index); - return iter->second; - } - - ////////////////////////////////////////////////// - template - bool BaseMap::IsValidIter(ConstUIter _iter) const - { - return _iter != this->map.end(); - } - - ////////////////////////////////////////////////// - template - BaseStore::BaseStore() - { - } - - ////////////////////////////////////////////////// - template - BaseStore::~BaseStore() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseStore::Size() const - { - return this->store.size(); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::Begin() - { - return this->store.begin(); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::End() - { - return this->store.end(); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::Contains(ConstTPtr _object) const - { - auto iter = this->ConstIter(_object); - return this->IsValidIter(iter); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::ContainsId(unsigned int _id) const - { - auto iter = this->ConstIterById(_id); - return this->IsValidIter(iter); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::ContainsName(const std::string &_name) const - { - auto iter = this->ConstIterByName(_name); - return this->IsValidIter(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::GetById(unsigned int _id) const - { - return this->DerivedById(_id); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::GetByName(const std::string &_name) const - { - return this->DerivedByName(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::GetByIndex(unsigned int _index) const - { - return this->DerivedByIndex(_index); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::Add(TPtr _object) - { - if (!_object) - { - ignerr << "Cannot add null pointer" << std::endl; - return false; - } - - UPtr derived = std::dynamic_pointer_cast(_object); - - if (!derived) - { - ignerr << "Cannot add item created by another render-engine" - << std::endl; - - return false; - } - - return this->AddImpl(derived); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::Remove(TPtr _object) - { - auto iter = this->Iter(_object); - return this->RemoveImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::RemoveById(unsigned int _id) - { - return this->RemoveDerivedById(_id); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::RemoveByName(const std::string &_name) - { - return this->RemoveDerivedByName(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::TPtr - BaseStore::RemoveByIndex(unsigned int _index) - { - return this->RemoveDerivedByIndex(_index); - } - - ////////////////////////////////////////////////// - template - void BaseStore::RemoveAll() - { - this->store.clear(); - } - - ////////////////////////////////////////////////// - template - void BaseStore::Destroy(TPtr _object) - { - auto iter = this->Iter(_object); - this->DestroyImpl(iter); - } - - ////////////////////////////////////////////////// - template - void BaseStore::DestroyById(unsigned int _id) - { - auto iter = this->IterById(_id); - this->DestroyImpl(iter); - } - - ////////////////////////////////////////////////// - template - void BaseStore::DestroyByName(const std::string &_name) - { - auto iter = this->IterByName(_name); - this->DestroyImpl(iter); - } - - ////////////////////////////////////////////////// - template - void BaseStore::DestroyByIndex(unsigned int _index) - { - auto iter = this->IterByIndex(_index); - this->DestroyImpl(iter); - } - - ////////////////////////////////////////////////// - template - void BaseStore::DestroyAll() - { - unsigned int i = this->Size(); - - while (i > 0) - { - this->DestroyByIndex(--i); - } - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::DerivedById(unsigned int _id) const - { - auto iter = this->ConstIterById(_id); - return (this->IsValidIter(iter)) ? iter->second : nullptr; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::DerivedByName(const std::string &_name) const - { - auto iter = this->ConstIterByName(_name); - return (this->IsValidIter(iter)) ? iter->second : nullptr; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::DerivedByIndex(unsigned int _index) const - { - auto iter = this->ConstIterByIndex(_index); - return (this->IsValidIter(iter)) ? iter->second : nullptr; - } - - ////////////////////////////////////////////////// - template - bool BaseStore::AddDerived(UPtr _object) - { - if (!_object) - { - ignerr << "Cannot add null pointer" << std::endl; - return false; - } - - return this->AddImpl(_object); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::RemoveDerived(UPtr _object) - { - auto iter = this->Iter(_object); - return this->RemoveImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::RemoveDerivedById(unsigned int _id) - { - auto iter = this->IterById(_id); - return this->RemoveImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::RemoveDerivedByName(const std::string &_name) - { - auto iter = this->IterByName(_name); - return this->RemoveImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::RemoveDerivedByIndex(unsigned int _index) - { - auto iter = this->IterByIndex(_index); - return this->RemoveImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::ConstUIter - BaseStore::ConstIter(ConstTPtr _object) const - { - auto begin = this->store.begin(); - auto end = this->store.end(); - - for (auto iter = begin; iter != end; ++iter) - { - if (iter->second == _object) - { - return iter; - } - } - - return end; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::ConstUIter - BaseStore::ConstIterById(unsigned int _id) const - { - auto begin = this->store.begin(); - auto end = this->store.end(); - - for (auto iter = begin; iter != end; ++iter) - { - if (iter->second->Id() == _id) - { - return iter; - } - } - - return end; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::ConstUIter - BaseStore::ConstIterByName(const std::string &_name) const - { - return this->store.find(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::ConstUIter - BaseStore::ConstIterByIndex(unsigned int _index) const - { - if (_index >= this->Size()) - { - ignerr << "Invalid index: " << _index << std::endl; - return this->store.end(); - } - - auto iter = this->store.begin(); - std::advance(iter, _index); - return iter; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::Iter(ConstTPtr _object) - { - auto iter = this->ConstIter(_object); - return this->RemoveConstness(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::IterById(unsigned int _id) - { - auto iter = this->ConstIterById(_id); - return this->RemoveConstness(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::IterByName(const std::string &_name) - { - auto iter = this->ConstIterByName(_name); - return this->RemoveConstness(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::IterByIndex(unsigned int _index) - { - auto iter = this->ConstIterByIndex(_index); - return this->RemoveConstness(iter); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::AddImpl(UPtr _object) - { - unsigned int id = _object->Id(); - std::string name = _object->Name(); - - if (this->ContainsId(id)) - { - ignerr << "Another item already exists with id: " << id << std::endl; - return false; - } - - if (this->ContainsName(name)) - { - ignerr << "Another item already exists with name: " << name - << std::endl; - return false; - } - - this->store[name] = _object; - return true; - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UPtr - BaseStore::RemoveImpl(UIter _iter) - { - if (!this->IsValidIter(_iter)) - { - return nullptr; - } - - UPtr result = _iter->second; - this->store.erase(_iter); - return result; - } - - ////////////////////////////////////////////////// - template - void BaseStore::DestroyImpl(UIter _iter) - { - UPtr result = this->RemoveImpl(_iter); - if (result) result->Destroy(); - } - - ////////////////////////////////////////////////// - template - bool BaseStore::IsValidIter(ConstUIter _iter) const - { - return _iter != this->store.end(); - } - - ////////////////////////////////////////////////// - template - typename BaseStore::UIter - BaseStore::RemoveConstness(ConstUIter _iter) - { - return (this->IsValidIter(_iter)) ? - this->store.erase(_iter, _iter) : this->store.end(); - } - - ////////////////////////////////////////////////// - template - BaseCompositeStore::BaseCompositeStore() - { - } - - ////////////////////////////////////////////////// - template - BaseCompositeStore::~BaseCompositeStore() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCompositeStore::Size() const - { - unsigned int size = 0; - - for (auto store : this->stores) - { - size += store->Size(); - } - - return size; - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::Contains(ConstTPtr _object) const - { - for (auto store : this->stores) - { - if (store->Contains(_object)) return true; - } - - return false; - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::ContainsId(unsigned int _id) const - { - for (auto store : this->stores) - { - if (store->ContainsId(_id)) return true; - } - - return false; - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::ContainsName(const std::string &_name) const - { - for (auto store : this->stores) - { - if (store->ContainsName(_name)) return true; - } - - return false; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::GetById(unsigned int _id) const - { - for (auto store : this->stores) - { - TPtr object = store->GetById(_id); - if (object) return object; - } - - return nullptr; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::GetByName(const std::string &_name) const - { - for (auto store : this->stores) - { - TPtr object = store->GetByName(_name); - if (object) return object; - } - - return nullptr; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::GetByIndex(unsigned int _index) const - { - unsigned int origIndex = _index; - - for (auto store : this->stores) - { - unsigned int size = store->Size(); - if (_index < size) - return store->GetByIndex(_index); - _index -= size; - } - - ignerr << "Invalid index: " << origIndex << std::endl; - return nullptr; - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::Add(TPtr) - { - ignerr << "Adding to BaseCompositeStore not supported" << std::endl; - return false; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::Remove(TPtr _object) - { - TPtr result = nullptr; - - for (auto store : this->stores) - { - TPtr temp = store->Remove(_object); - if (!result) result = temp; - } - - return result; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::RemoveById(unsigned int _id) - { - TPtr result = nullptr; - - for (auto store : this->stores) - { - TPtr temp = store->RemoveById(_id); - if (!result) result = temp; - } - - return result; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::RemoveByName(const std::string &_name) - { - TPtr result = nullptr; - - for (auto store : this->stores) - { - TPtr temp = store->RemoveByName(_name); - if (!result) result = temp; - } - - return result; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TPtr - BaseCompositeStore::RemoveByIndex(unsigned int _index) - { - TPtr result = nullptr; - - for (auto store : this->stores) - { - TPtr temp = store->RemoveByIndex(_index); - if (!result) result = temp; - } - - return result; - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::RemoveAll() - { - for (auto store : this->stores) - { - store->RemoveAll(); - } - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::Destroy(TPtr _object) - { - for (auto store : this->stores) - { - if (store->Contains(_object)) - { - store->Destroy(_object); - return; - } - } - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::DestroyById(unsigned int _id) - { - for (auto store : this->stores) - { - store->DestroyById(_id); - } - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::DestroyByName(const std::string &_name) - { - for (auto store : this->stores) - { - store->DestroyByName(_name); - } - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::DestroyByIndex(unsigned int _index) - { - for (auto store : this->stores) - { - store->DestroyByIndex(_index); - } - } - - ////////////////////////////////////////////////// - template - void BaseCompositeStore::DestroyAll() - { - for (auto store : this->stores) - { - store->DestroyAll(); - } - } - - ////////////////////////////////////////////////// - template - unsigned int BaseCompositeStore::GetStoreCount() const - { - return this->stores.size(); - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::ContainsStore(ConstTStorePtr _store) const - { - auto begin = this->stores.begin(); - auto end = this->stores.end(); - auto iter = std::find(begin, end, _store); - return iter != end; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TStorePtr - BaseCompositeStore::GetStore(unsigned int _index) const - { - if (_index >= this->GetStoreCount()) - { - ignerr << "Invalid store index: " << _index << std::endl; - return nullptr; - } - - return this->stores[_index]; - } - - ////////////////////////////////////////////////// - template - bool BaseCompositeStore::AddStore(TStorePtr _store) - { - if (!_store) - { - ignerr << "Cannot all null store pointer" << std::endl; - return false; - } - - if (this->ContainsStore(_store)) - { - ignerr << "Store has already been added" << std::endl; - return false; - } - - this->stores.push_back(_store); - return true; - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TStorePtr - BaseCompositeStore::RemoveStore(TStorePtr _store) - { - auto begin = this->stores.begin(); - auto end = this->stores.end(); - auto iter = std::find(begin, end, _store); - return this->RemoveStoreImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TStorePtr - BaseCompositeStore::RemoveStore(unsigned int _index) - { - if (_index >= this->GetStoreCount()) - { - ignerr << "Invalid store index: " << _index << std::endl; - return nullptr; - } - - auto iter = this->stores.begin(); - std::advance(iter, _index); - return this->RemoveStoreImpl(iter); - } - - ////////////////////////////////////////////////// - template - typename BaseCompositeStore::TStorePtr - BaseCompositeStore::RemoveStoreImpl(TStoreIter _iter) - { - if (_iter == this->stores.end()) - { - return nullptr; - } - - TStorePtr result = *_iter; - this->stores.erase(_iter); - return result; - } - - ////////////////////////////////////////////////// - template - BaseStoreWrapper::BaseStoreWrapper(UStorePtr _store) : - store(_store) - { - } - - ////////////////////////////////////////////////// - template - BaseStoreWrapper::~BaseStoreWrapper() - { - } - - ////////////////////////////////////////////////// - template - unsigned int BaseStoreWrapper::Size() const - { - return this->store->Size(); - } - - ////////////////////////////////////////////////// - template - bool BaseStoreWrapper::Contains(ConstTPtr _object) const - { - ConstUPtr derived = std::dynamic_pointer_cast(_object); - return this->store->Contains(derived); - } - - ////////////////////////////////////////////////// - template - bool BaseStoreWrapper::ContainsId(unsigned int _id) const - { - return this->store->ContainsId(_id); - } - - ////////////////////////////////////////////////// - template - bool BaseStoreWrapper::ContainsName(const std::string &_name) const - { - return this->store->ContainsName(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::GetById(unsigned int _id) const - { - return this->store->GetById(_id); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::GetByName(const std::string &_name) const - { - return this->store->GetByName(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::GetByIndex(unsigned int _index) const - { - return this->store->GetByIndex(_index); - } - - ////////////////////////////////////////////////// - template - bool BaseStoreWrapper::Add(TPtr _object) - { - UPtr derived = std::dynamic_pointer_cast(_object); - return this->store->Add(derived); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::Remove(TPtr _object) - { - UPtr derived = std::dynamic_pointer_cast(_object); - return this->store->Remove(derived); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::RemoveById(unsigned int _id) - { - return this->store->RemoveById(_id); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::RemoveByName(const std::string &_name) - { - return this->store->RemoveByName(_name); - } - - ////////////////////////////////////////////////// - template - typename BaseStoreWrapper::TPtr - BaseStoreWrapper::RemoveByIndex(unsigned int _index) - { - return this->store->RemoveByIndex(_index); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::RemoveAll() - { - this->store->RemoveAll(); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::Destroy(TPtr _object) - { - UPtr derived = std::dynamic_pointer_cast(_object); - this->store->Destroy(derived); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::DestroyById(unsigned int _id) - { - this->store->DestroyById(_id); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::DestroyByName(const std::string &_name) - { - this->store->DestroyByName(_name); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::DestroyByIndex(unsigned int _index) - { - this->store->DestroyByIndex(_index); - } - - ////////////////////////////////////////////////// - template - void BaseStoreWrapper::DestroyAll() - { - this->store->DestroyAll(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseText.hh b/include/ignition/rendering/base/BaseText.hh index 349848032..10be4ecd5 100644 --- a/include/ignition/rendering/base/BaseText.hh +++ b/include/ignition/rendering/base/BaseText.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,290 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASETEXT_HH_ -#define IGNITION_RENDERING_BASE_BASETEXT_HH_ -#include -#include "ignition/rendering/Text.hh" -#include "ignition/rendering/base/BaseObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of a text geometry - template - class BaseText : - public virtual Text, - public virtual T - { - /// \brief Constructor - protected: BaseText(); - - /// \brief Destructor - public: virtual ~BaseText(); - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: void SetFontName(const std::string &_font) override; - - // Documentation inherited. - public: std::string FontName() const override; - - // Documentation inherited. - public: virtual void SetTextString(const std::string &_text) override; - - // Documentation inherited. - public: virtual std::string TextString() const override; - - // Documentation inherited. - public: virtual void SetColor(const ignition::math::Color &_color) - override; - - // Documentation inherited. - public: virtual ignition::math::Color Color() const override; - - // Documentation inherited. - public: virtual void SetCharHeight(const float _height) override; - - // Documentation inherited. - public: virtual float CharHeight() const override; - - // Documentation inherited. - public: virtual void SetSpaceWidth(const float _width) override; - - // Documentation inherited. - public: virtual float SpaceWidth() const override; - - // Documentation inherited. - public: virtual void SetTextAlignment(const TextHorizontalAlign &_hAlign, - const TextVerticalAlign &_vAlign) override; - // Documentation inherited. - public: virtual TextHorizontalAlign HorizontalAlignment() const override; - - // Documentation inherited. - public: virtual TextVerticalAlign VerticalAlignment() const override; - - // Documentation inherited. - public: virtual void SetBaseline(const float _baseline) override; - - // Documentation inherited. - public: virtual float Baseline() const override; - - // Documentation inherited. - public: void SetShowOnTop(const bool _onTop) override; - - // Documentation inherited. - public: virtual bool ShowOnTop() const override; - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox AABB() const override; - - /// \brief Font name, such as "Liberation Sans" - protected: std::string fontName = "Liberation Sans"; - - /// \brief Text being displayed - protected: std::string text; - - /// \brief Text color - protected: ignition::math::Color color = ignition::math::Color::White; - - /// \brief Character height in meters - protected: float charHeight = 1.0; - - /// \brief Width of space between letters - protected: float spaceWidth = 0; - - /// \brief Horizontal alignment - protected: TextHorizontalAlign horizontalAlign = - TextHorizontalAlign::LEFT; - - /// \brief Vertical alignment - protected: TextVerticalAlign verticalAlign = TextVerticalAlign::BOTTOM; - - /// \brief Baseline height in meters. - protected: float baseline = 0; - - /// \brief True for text to be displayed on top of other objects in the - /// scene. - protected: bool onTop = false; - - /// \brief Flag to indicate text properties have changed - protected: bool textDirty = false; - }; - - ////////////////////////////////////////////////// - // BaseText - ////////////////////////////////////////////////// - template - BaseText::BaseText() - { - } - - ////////////////////////////////////////////////// - template - BaseText::~BaseText() - { - } - - ////////////////////////////////////////////////// - template - std::string BaseText::FontName() const - { - return this->fontName; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetFontName(const std::string &_font) - { - this->fontName = _font; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - std::string BaseText::TextString() const - { - return this->text; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetTextString(const std::string &_text) - { - this->text = _text; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - ignition::math::Color BaseText::Color() const - { - return this->color; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetColor(const ignition::math::Color &_color) - { - this->color = _color; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - float BaseText::CharHeight() const - { - return this->charHeight; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetCharHeight(const float _height) - { - this->charHeight = _height; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - float BaseText::SpaceWidth() const - { - return this->spaceWidth; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetSpaceWidth(const float _width) - { - this->spaceWidth = _width; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - TextHorizontalAlign BaseText::HorizontalAlignment() const - { - return this->horizontalAlign; - } - - ////////////////////////////////////////////////// - template - TextVerticalAlign BaseText::VerticalAlignment() const - { - return this->verticalAlign; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetTextAlignment(const TextHorizontalAlign &_horzAlign, - const TextVerticalAlign &_vertAlign) - { - this->horizontalAlign = _horzAlign; - this->verticalAlign = _vertAlign; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - float BaseText::Baseline() const - { - return this->baseline; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetBaseline(const float _baseline) - { - this->baseline = _baseline; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - bool BaseText::ShowOnTop() const - { - return this->onTop; - } - - ////////////////////////////////////////////////// - template - void BaseText::SetShowOnTop(const bool _onTop) - { - this->onTop = _onTop; - this->textDirty = true; - } - - ////////////////////////////////////////////////// - template - ignition::math::AxisAlignedBox BaseText::AABB() const - { - math::AxisAlignedBox box; - return box; - } - - ////////////////////////////////////////////////// - template - void BaseText::PreRender() - { - T::PreRender(); - } - - ////////////////////////////////////////////////// - template - void BaseText::Destroy() - { - T::Destroy(); - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseThermalCamera.hh b/include/ignition/rendering/base/BaseThermalCamera.hh index a061a371b..5c1699e4f 100644 --- a/include/ignition/rendering/base/BaseThermalCamera.hh +++ b/include/ignition/rendering/base/BaseThermalCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,198 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASETHERMALCAMERA_HH_ -#define IGNITION_RENDERING_BASE_BASETHERMALCAMERA_HH_ -#include - -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/ThermalCamera.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Base implementation of the ThermalCamera class - template - class BaseThermalCamera : - public virtual ThermalCamera, - public virtual BaseCamera, - public virtual T - { - /// \brief Constructor - protected: BaseThermalCamera(); - - /// \brief Destructor - public: virtual ~BaseThermalCamera(); - - // Documentation inherited. - public: virtual void SetAmbientTemperature(float _ambient) override; - - // Documentation inherited. - public: virtual float AmbientTemperature() const override; - - // Documentation inherited. - public: virtual void SetAmbientTemperatureRange(float _range) override; - - // Documentation inherited. - public: virtual float AmbientTemperatureRange() const override; - - // Documentation inherited. - public: virtual void SetMinTemperature(float _min) override; - - // Documentation inherited. - public: virtual float MinTemperature() const override; - - // Documentation inherited. - public: virtual void SetMaxTemperature(float _max) override; - - // Documentation inherited. - public: virtual float MaxTemperature() const override; - - // Documentation inherited. - public: virtual void SetLinearResolution(float _max) override; - - // Documentation inherited. - public: virtual float LinearResolution() const override; - - // Documentation inherited. - public: virtual float HeatSourceTemperatureRange() const override; - - // Documentation inherited. - public: virtual void SetHeatSourceTemperatureRange(float _range) override; - - // Documentation inherted. - public: virtual ignition::common::ConnectionPtr ConnectNewThermalFrame( - std::function _subscriber) override; - - /// \brief Ambient temperature of the environment - protected: float ambient = 0.0f; - - /// \brief Ambient temperature range - protected: float ambientRange = 0.0f; - - /// \brief Minimum temperature - protected: float minTemp = -ignition::math::INF_F; - - /// \brief Maximum temperature - protected: float maxTemp = ignition::math::INF_F; - - /// \brief Linear resolution. Defaults to 10mK. - protected: float resolution = 0.01f; - - /// \brief Range of heat source temperature variation - protected: float heatSourceTempRange = 0.0f; - }; - - ////////////////////////////////////////////////// - template - BaseThermalCamera::BaseThermalCamera() - { - } - - ////////////////////////////////////////////////// - template - BaseThermalCamera::~BaseThermalCamera() - { - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetAmbientTemperature(float _ambient) - { - this->ambient = _ambient; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::AmbientTemperature() const - { - return this->ambient; - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetAmbientTemperatureRange(float _range) - { - this->ambientRange = _range; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::AmbientTemperatureRange() const - { - return this->ambientRange; - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetMinTemperature(float _min) - { - this->minTemp = _min; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::MinTemperature() const - { - return this->minTemp; - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetMaxTemperature(float _max) - { - this->maxTemp = _max; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::MaxTemperature() const - { - return this->maxTemp; - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetLinearResolution(float _resolution) - { - this->resolution = _resolution; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::LinearResolution() const - { - return this->resolution; - } - - ////////////////////////////////////////////////// - template - void BaseThermalCamera::SetHeatSourceTemperatureRange(float _range) - { - this->heatSourceTempRange = _range; - } - - ////////////////////////////////////////////////// - template - float BaseThermalCamera::HeatSourceTemperatureRange() const - { - return this->heatSourceTempRange; - } - - ////////////////////////////////////////////////// - template - common::ConnectionPtr BaseThermalCamera::ConnectNewThermalFrame( - std::function) - { - return nullptr; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/BaseVisual.hh b/include/ignition/rendering/base/BaseVisual.hh index c16f09db2..e03cd87b9 100644 --- a/include/ignition/rendering/base/BaseVisual.hh +++ b/include/ignition/rendering/base/BaseVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,339 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_BASE_BASEVISUAL_HH_ -#define IGNITION_RENDERING_BASE_BASEVISUAL_HH_ -#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() override; - - // Documentation inherited. - public: virtual void SetVisible(bool _visible) override; - - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void Destroy() 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; - - 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 A map of custom key value data - protected: std::map userData; - }; - - ////////////////////////////////////////////////// - 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() - { - 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 - void BaseVisual::SetVisible(bool _visible) - { - ignerr << "SetVisible(" << _visible << ") not supported for " - << "render engine: " << this->Scene()->Engine()->Name() - << std::endl; - } - - ////////////////////////////////////////////////// - template - void BaseVisual::SetUserData(const std::string &_key, Variant _value) - { - this->userData[_key] = _value; - } - - ////////////////////////////////////////////////// - template - Variant BaseVisual::UserData(const std::string &_key) const - { - Variant value; - auto it = this->userData.find(_key); - if (it != this->userData.end()) - value = it->second; - return value; - } - } - } -} -#endif +#include +#include diff --git a/include/ignition/rendering/base/base.hh.in b/include/ignition/rendering/base/base.hh.in deleted file mode 100644 index acfd26ae7..000000000 --- a/include/ignition/rendering/base/base.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/include/ignition/rendering/config.hh b/include/ignition/rendering/config.hh new file mode 100644 index 000000000..6dd936c31 --- /dev/null +++ b/include/ignition/rendering/config.hh @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef IGNITION_RENDERING__CONFIG_HH_ +#define IGNITION_RENDERING__CONFIG_HH_ + +#include + +/* Version number */ +// #define IGNITION_RENDERING_MAJOR_VERSION GZ_RENDERING_MAJOR_VERSION +// #define IGNITION_RENDERING_MINOR_VERSION GZ_RENDERING_MINOR_VERSION +// #define IGNITION_RENDERING_PATCH_VERSION GZ_RENDERING_PATCH_VERSION + +// #define IGNITION_RENDERING_VERSION GZ_RENDERING_VERSION +// #define IGNITION_RENDERING_VERSION_FULL GZ_RENDERING_VERSION_FULL + +// #define IGNITION_RENDERING_VERSION_NAMESPACE GZ_RENDERING_VERSION_NAMESPACE + +// #define IGNITION_RENDERING_VERSION_HEADER GZ_RENDERING_VERSION_HEADER + +// #define IGN_RENDERING_RESOURCE_PATH GZ_RENDERING_RESOURCE_PATH + +// #define IGNITION_RENDERING_ENGINE_INSTALL_DIR GZ_RENDERING_ENGINE_INSTALL_DIR + +/* #undef BUILD_TYPE_PROFILE */ +/* #undef BUILD_TYPE_DEBUG */ +/* #undef BUILD_TYPE_RELEASE */ +// #define HAVE_OGRE 1 +/* #undef HAVE_OGRE2 */ +/* #undef HAVE_OPTIX */ +/* #undef HAVE_GAZEBO */ +/* #undef INCLUDE_RTSHADER */ + +#endif diff --git a/include/ignition/rendering/rendering.hh.in b/include/ignition/rendering/rendering.hh.in deleted file mode 100644 index 13484ca76..000000000 --- a/include/ignition/rendering/rendering.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -//#include -${ign_headers} diff --git a/ogre/include/CMakeLists.txt b/ogre/include/CMakeLists.txt index 297e254ff..a7479f53e 100644 --- a/ogre/include/CMakeLists.txt +++ b/ogre/include/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(ignition/rendering) +add_subdirectory(gz/rendering) +install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) diff --git a/ogre/include/ignition/rendering/CMakeLists.txt b/ogre/include/gz/rendering/CMakeLists.txt similarity index 100% rename from ogre/include/ignition/rendering/CMakeLists.txt rename to ogre/include/gz/rendering/CMakeLists.txt diff --git a/ogre/include/gz/rendering/ogre/OgreArrowVisual.hh b/ogre/include/gz/rendering/ogre/OgreArrowVisual.hh new file mode 100644 index 000000000..9bdb05a61 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreArrowVisual.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREARROWVISUAL_HH_ +#define GZ_RENDERING_OGRE_OGREARROWVISUAL_HH_ + +#include "gz/rendering/base/BaseArrowVisual.hh" +#include "gz/rendering/ogre/OgreVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreArrowVisual : + public BaseArrowVisual + { + protected: OgreArrowVisual(); + + public: virtual ~OgreArrowVisual(); + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreAxisVisual.hh b/ogre/include/gz/rendering/ogre/OgreAxisVisual.hh new file mode 100644 index 000000000..aa4277a98 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreAxisVisual.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREAXISVISUAL_HH_ +#define GZ_RENDERING_OGRE_OGREAXISVISUAL_HH_ + +#include "gz/rendering/base/BaseAxisVisual.hh" +#include "gz/rendering/ogre/OgreVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreAxisVisual : + public BaseAxisVisual + { + protected: OgreAxisVisual(); + + public: virtual ~OgreAxisVisual(); + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreCamera.hh b/ogre/include/gz/rendering/ogre/OgreCamera.hh new file mode 100644 index 000000000..feced1ee3 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreCamera.hh @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRECAMERA_HH_ +#define GZ_RENDERING_OGRE_OGRECAMERA_HH_ + +#include + +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreSensor.hh" +#include "gz/rendering/ogre/OgreSelectionBuffer.hh" + +namespace Ogre +{ + class Camera; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreSelectionBuffer; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreCamera : + public BaseCamera + { + protected: OgreCamera(); + + public: virtual ~OgreCamera(); + + // Documentation inherited. + public: virtual 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 math::Matrix4d ViewMatrix() const override; + + public: void SetVFOV(double cameraVFOV) const; + + /// \brief Get the near clip distance + /// \return Near clip distance + public: double NearClip() const; + + /// \brief Get the far clip distance + /// \return Far clip distance + public: double FarClip() const; + + // Documentation inherited + public: virtual VisualPtr VisualAt(const gz::math::Vector2i + &_mousePos) override; + + // Documentation Inherited. + // \sa Camera::SetMaterial(const MaterialPtr &) + public: virtual void SetMaterial( + const MaterialPtr &_material) override; + + // Documentation inherited. + public: virtual unsigned int RenderTextureGLId() const override; + + // Documentation inherited. + public: virtual void Destroy() override; + + 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/OgreConversions.hh b/ogre/include/gz/rendering/ogre/OgreConversions.hh new file mode 100644 index 000000000..1783addda --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreConversions.hh @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRECONVERSIONS_HH_ +#define GZ_RENDERING_OGRE_OGRECONVERSIONS_HH_ + +#include +#include +#include +#include + +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \addtogroup ign_rendering + /// \{ + + /// \brief Conversions Conversions.hh rendering/Conversions.hh + /// \brief A set of utility function to convert between Gazebo and Ogre + /// data types + class IGNITION_RENDERING_OGRE_VISIBLE OgreConversions + { + /// \brief Return the equivalent ogre color + /// \param[in] _color ign-math color to convert + /// \return Ogre color value + public: static Ogre::ColourValue Convert( + const math::Color &_color); + + /// \brief Return the equivalent ign-math color + /// \param[in] _color Ogre color to convert + /// \return ign-math color value + public: static math::Color Convert( + const Ogre::ColourValue &_color); + + /// \brief return Ogre Vector from ign-math Vector3 + /// \param[in] _vector ign-math vector + /// \return Ogre vector + public: static Ogre::Vector3 Convert(const math::Vector3d &_vector); + + /// \brief return ign-math Vector from ogre Vector3 + /// \param[in] _vector Ogre vector + /// \return ign-math vector + public: static math::Vector3d Convert(const Ogre::Vector3 &_vector); + + /// \brief Ign-math quaternion to Ogre quaternion + /// \param[in] _quat ign-math quaternion + /// \return Ogre quaternion + public: static Ogre::Quaternion Convert(const math::Quaterniond &_quat); + + /// \brief Ogre quaternion to ign-math quaternion + /// \param[in] _quat Ogre quaternion + /// return ign-math quaternion + public: static math::Quaterniond Convert(const Ogre::Quaternion &_quat); + + /// \brief Ign-math angle to Ogre angle + /// \param[in] _angle ign-math angle + /// \return Ogre angle + public: static Ogre::Radian Convert(const math::Angle &_angle); + + /// \brief Ogre angle to ign-math angle + /// \param[in] _angle Ogre angle + /// return Ign-math angle + public: static math::Angle Convert(const Ogre::Radian &_angle); + + /// \brief Ogre Matrix4 to ignition math Matrix4d + /// \param[in] _m Ogre Matrix4 + /// \return ignition math Matrix4d + public: static math::Matrix4d Convert(const Ogre::Matrix4 &_m); + + /// \brief Ignition math Matrix4d to Ogre Matrix4 + /// \param[in] _m ignition math Matrix4d + /// \return Ogre Matrix4 + public: static Ogre::Matrix4 Convert(const math::Matrix4d &_m); + + /// \brief Ign-rendering PixelFormat to Ogre PixelFormat + /// \param[in] _format Ign-rendering PixelFormat + /// return Ogre PixelFormat + public: static Ogre::PixelFormat Convert(PixelFormat _format); + + private: static const Ogre::PixelFormat ogrePixelFormats[PF_COUNT]; + }; + /// \} + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreDepthCamera.hh b/ogre/include/gz/rendering/ogre/OgreDepthCamera.hh new file mode 100644 index 000000000..7fa9c1950 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreDepthCamera.hh @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGREDEPTHCAMERA_HH_ +#define GZ_RENDERING_OGRE_OGREDEPTHCAMERA_HH_ + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +#include +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/base/BaseDepthCamera.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreSensor.hh" +#include "gz/rendering/ogre/OgreSelectionBuffer.hh" + +#include "gz/common/Event.hh" +#include "gz/common/Console.hh" + + +namespace Ogre +{ + class Material; + class RenderTarget; + class Texture; + class Viewport; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreDepthCameraPrivate; + + /** \class OgreDepthCamera OgreDepthCamera.hh\ + * rendering/ogre/OgreDepthCamera.hh + **/ + /// \brief Depth camera used to render depth data into an image buffer + class IGNITION_RENDERING_OGRE_VISIBLE OgreDepthCamera : + public BaseDepthCamera + { + /// \brief Constructor + protected: OgreDepthCamera(); + + /// \brief Destructor + public: virtual ~OgreDepthCamera(); + + /// \brief Initialize the camera + public: virtual void Init() override; + + /// \brief Create a texture which will hold the depth data + public: virtual void CreateDepthTexture() override; + + /// \brief Render the camera + public: virtual void PostRender() override; + + /// \brief All things needed to get back z buffer for depth data + /// \return The z-buffer as a float array + public: virtual const float *DepthData() const override; + + /// \brief Connect a to the new depth image signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewDepthFrame( + std::function _subscriber) override; + + /// \brief Connect a to the new rgb point cloud signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewRgbPointCloud( + std::function _subscriber) override; + + // Documentation inherited. + public: virtual void PreRender() override; + + /// \brief Implementation of the render call + public: virtual void Render() override; + + /// \brief Set the far clip distance + /// \param[in] _far far clip distance + public: virtual void SetFarClipPlane(const double _far) override; + + /// \brief Set the near clip distance + /// \param[in] _near Near clip distance + public: virtual void SetNearClipPlane(const double _near) override; + + /// \brief Get the near clip distance + /// \return Near clip distance. A value of zero is returned if the + /// ogre camera has not been created. + public: double NearClipPlane() const override; + + /// \brief Get the far clip distance + /// \return Far clip distance. A value of zero is returned if the + /// ogre camera has not been created. + public: double FarClipPlane() const override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Update a render target + /// \param[in] _target Render target to update + /// \param[in] _material Material to use + /// \param[in] _matName Material name + protected: void UpdateRenderTarget(OgreRenderTexturePtr _target, + Ogre::Material *_material, + const std::string &_matName); + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Limit field of view taking care of using a valid value for + /// an OGRE camera. + /// \param[in] _fov expected field of view + /// \return valid field of view + protected: static double LimitFOV(const double _fov); + + /// \brief Create the camera. + protected: void CreateCamera(); + + /// \brief Create point cloud texture. This stores xyz rgb data + private: void CreatePointCloudTexture(); + + /// \brief 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/OgreDynamicLines.hh b/ogre/include/gz/rendering/ogre/OgreDynamicLines.hh new file mode 100644 index 000000000..490f02963 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreDynamicLines.hh @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_OGRE_OGREDYNAMICLINES_HH_ +#define GZ_RENDERING_OGRE_OGREDYNAMICLINES_HH_ + +#include +#include +#include +#include + +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreDynamicRenderable.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /// \brief Forward declaration + class OgreDynamicLinesPrivate; + + /* \class OgreDynamicLines OgreDynamicLines.hh \ + * ignition/rendering/ogre/OgreDynamicLines.hh + */ + /// \brief Class for drawing lines that can change + class IGNITION_RENDERING_OGRE_VISIBLE OgreDynamicLines : + public OgreDynamicRenderable + { + /// \brief Constructor + /// \param[in] _opType The type of Line + public: explicit OgreDynamicLines( + MarkerType _opType = MT_LINE_STRIP); + + /// \brief Destructor + public: virtual ~OgreDynamicLines(); + + /// \brief Add a point to the point list + /// \param[in] _pt gz::math::Vector3d point + /// \param[in] _color gz::math::Color Point color + public: void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color = gz::math::Color::White); + + /// \brief Add a point to the point list. + /// \param[in] _x X position + /// \param[in] _y Y position + /// \param[in] _z Z position + /// \param[in] _color gz::math::Color Point color + public: void AddPoint(const double _x, const double _y, const double _z, + const gz::math::Color &_color = gz::math::Color::White); + + /// \brief Change the location of an existing point in the point list + /// \param[in] _index Index of the point to set + /// \param[in] _value gz::math::Vector3d value to set the point to + public: void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value); + + /// \brief Change the color of an existing point in the point list + /// \param[in] _index Index of the point to set + /// \param[in] _color gz::math::Color Pixelcolor color to set the + /// point to + public: void SetColor(unsigned int _index, + const gz::math::Color &_color); + + /// \brief Return the location of an existing point in the point list + /// \param[in] _index Number of the point to return + /// \return gz::math::Vector3d value of the point. A vector of + /// [gz::math::INF_D, gz::math::INF_D, gz::math::INF_D] + /// is returned when then the _index is out of bounds. + /// gz::math::INF_D==std::numeric_limits::infinity() + public: gz::math::Vector3d Point(unsigned int _index) const; + + /// \brief Return the total number of points in the point list + /// \return Number of points + public: unsigned int PointCount() const; + + /// \brief Remove all points from the point list + public: void Clear(); + + /// \brief Call this to update the hardware buffer after making changes. + public: void Update(); + + /// \brief Implementation DynamicRenderable, + /// creates a simple vertex-only decl + private: virtual void CreateVertexDeclaration(); + + /// \brief Implementation DynamicRenderable, pushes point + /// list out to hardware memory + private: virtual void FillHardwareBuffers(); + + /// \brief private implementation + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreDynamicRenderable.hh b/ogre/include/gz/rendering/ogre/OgreDynamicRenderable.hh new file mode 100644 index 000000000..73a28cfa9 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreDynamicRenderable.hh @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_OGRE_OGREDYNAMICRENDERABLE_HH_ +#define GZ_RENDERING_OGRE_OGREDYNAMICRENDERABLE_HH_ + +#include +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/Marker.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + /* \class OgreDynamicRenderable OgreDynamicRenderable.hh \ + * ignition/rendering/ogre/OgreDynamicRenderable.hh + */ + /// \brief Abstract base class providing mechanisms for dynamically + /// growing hardware buffers. + class IGNITION_RENDERING_OGRE_VISIBLE OgreDynamicRenderable : + public Ogre::SimpleRenderable + { + /// \brief Constructor + public: OgreDynamicRenderable(); + + /// \brief Virtual destructor + public: virtual ~OgreDynamicRenderable(); + + /// \brief Initializes the dynamic renderable. + /// \remarks This function should only be called once. It initializes the + /// render operation, and calls the abstract function + /// CreateVertexDeclaration(). + /// \param[in] _opType The type of render operation to perform. + /// \param[in] _useIndices Specifies whether to use indices to + /// determine the vertices to use as input. + public: void Init(MarkerType _opType, bool _useIndices = false); + + /// \brief Set the render operation type + /// \param[in] _opType The type of render operation to perform. + public: void SetOperationType(MarkerType _opType); + + /// \brief Get the render operation type + /// \return The render operation type. + public: MarkerType OperationType() const; + + /// \brief Implementation of Ogre::SimpleRenderable + /// \return The bounding radius + public: virtual Ogre::Real getBoundingRadius() const; + + /// \brief Implementation of Ogre::SimpleRenderable + /// \param[in] _cam Pointer to the Ogre camera that views the + /// renderable. + /// \return The squared depth in the Camera's view + public: virtual Ogre::Real getSquaredViewDepth( + const Ogre::Camera *_cam) const; + + /// \brief Creates the vertex declaration. @remarks Override and set + /// mRenderOp.vertexData->vertexDeclaration here. mRenderOp.vertexData + /// will be created for you before this method is called. + protected: virtual void CreateVertexDeclaration() = 0; + + /// \brief Prepares the hardware buffers for the requested vertex and + /// index counts. + /// \remarks + /// This function must be called before locking the buffers in + /// fillHardwareBuffers(). It guarantees that the hardware buffers + /// are large enough to hold at least the requested number of + /// vertices and indices (if using indices). The buffers are + /// possibly reallocated to achieve this. + /// \par The vertex and index count in the render operation are set to + /// the values of vertexCount and indexCount respectively. + /// \param[in] _vertexCount The number of vertices the buffer must hold. + /// \param[in] _indexCount The number of indices the buffer must hold. + /// This parameter is ignored if not using indices. + protected: void PrepareHardwareBuffers(size_t _vertexCount, + size_t _indexCount); + + /// \brief Fills the hardware vertex and index buffers with data. + /// @remarks + /// This function must call prepareHardwareBuffers() before locking the + /// buffers to ensure the they are large enough for the data to be + /// written. Afterwards the vertex and index buffers (if using indices) + /// can be locked, and data can be written to them. + protected: virtual void FillHardwareBuffers() = 0; + + /// \brief Maximum capacity of the currently allocated vertex buffer. + protected: size_t vertexBufferCapacity = 0; + + /// \brief Maximum capacity of the currently allocated index buffer. + protected: size_t indexBufferCapacity = 0; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGaussianNoisePass.hh b/ogre/include/gz/rendering/ogre/OgreGaussianNoisePass.hh new file mode 100644 index 000000000..453ee2a50 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreGaussianNoisePass.hh @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREGAUSSIANNOISEPASS_HH_ +#define GZ_RENDERING_OGRE_OGREGAUSSIANNOISEPASS_HH_ + +#include + +#include + +#include "gz/rendering/base/BaseGaussianNoisePass.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderPass.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class GaussianNoiseCompositorListener; + + /* \class OgreGaussianNoisePass OgreGaussianNoisePass.hh \ + * ignition/rendering/ogre/OgreGaussianNoisePass.hh + */ + /// \brief Ogre implementation of the GaussianNoisePass class + class IGNITION_RENDERING_OGRE_VISIBLE OgreGaussianNoisePass : + public BaseGaussianNoisePass + { + /// \brief Constructor + public: OgreGaussianNoisePass(); + + /// \brief Destructor + public: virtual ~OgreGaussianNoisePass(); + + // Documentation inherited + public: void PreRender() override; + + // Documentation inherited + public: void Destroy() override; + + // Documentation inherited + public: void CreateRenderPass() override; + + /// \brief Gaussian noise compositor. + public: Ogre::CompositorInstance *gaussianNoiseInstance = nullptr; + + /// \brief Gaussian noise compositor listener + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + public: std::shared_ptr + gaussianNoiseCompositorListener; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGeometry.hh b/ogre/include/gz/rendering/ogre/OgreGeometry.hh new file mode 100644 index 000000000..55e3ad4bd --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreGeometry.hh @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREGEOMETRY_HH_ +#define GZ_RENDERING_OGRE_OGREGEOMETRY_HH_ + +#include + +#include "gz/rendering/base/BaseGeometry.hh" +#include "gz/rendering/ogre/OgreObject.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreGeometry : + public BaseGeometry + { + protected: OgreGeometry(); + + public: virtual ~OgreGeometry(); + + public: virtual bool HasParent() const; + + public: virtual VisualPtr Parent() const; + + public: virtual Ogre::MovableObject *OgreObject() const = 0; + + protected: virtual void SetParent(OgreVisualPtr _parent); + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: OgreVisualPtr parent; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreVisual; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGizmoVisual.hh b/ogre/include/gz/rendering/ogre/OgreGizmoVisual.hh new file mode 100644 index 000000000..c871c3703 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreGizmoVisual.hh @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREGIZMOVISUAL_HH_ +#define GZ_RENDERING_OGRE_OGREGIZMOVISUAL_HH_ + +#include "gz/rendering/base/BaseGizmoVisual.hh" +#include "gz/rendering/ogre/OgreVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreGizmoVisual : + public BaseGizmoVisual + { + /// \brief Constructor + protected: OgreGizmoVisual(); + + /// \brief Destructor + public: virtual ~OgreGizmoVisual(); + + /// \brief Only the ogre scene can instanstiate this class + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGpuRays.hh b/ogre/include/gz/rendering/ogre/OgreGpuRays.hh new file mode 100644 index 000000000..ce1a12ffd --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreGpuRays.hh @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGREGPURAYS_HH_ +#define GZ_RENDERING_OGRE_OGREGPURAYS_HH_ + +#include +#include +#include +#include + +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/base/BaseGpuRays.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreSensor.hh" + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class OgreGpuRaysPrivate; + + /** \class OgreGpuRays OgreGpuRays.hh\ + * rendering/ogre/OgreGpuRays.hh + **/ + /// \brief Gpu Rays used to render depth data into an image buffer + class IGNITION_RENDERING_OGRE_VISIBLE OgreGpuRays : + public BaseGpuRays, public Ogre::RenderObjectListener + { + /// \brief Constructor + protected: OgreGpuRays(); + + /// \brief Destructor + public: virtual ~OgreGpuRays(); + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Create dummy render texture. Needed to satisfy inheritance + public: virtual void CreateRenderTexture(); + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void PostRender() override; + + // Documentation inherited + public: virtual const float *Data() const override; + + // Documentation inherited. + public: virtual void Copy(float *_data) override; + + // Documentation inherited. + public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( + std::function _subscriber) override; + + // Documentation inherited. + public: virtual RenderTargetPtr RenderTarget() const override; + + /// \internal + /// \brief Implementation of Ogre::RenderObjectListener + public: virtual void notifyRenderSingleObject(Ogre::Renderable *_rend, + const Ogre::Pass *_p, const Ogre::AutoParamDataSource *_s, + const Ogre::LightList *_ll, bool _supp) override; + + /// \brief Set the number of samples in the width and height for the + /// first pass texture. + /// \param[in] _w Number of samples in the horizontal sweep + /// \param[in] _h Number of samples in the vertical sweep + private: virtual void Set1stTextureSize(const unsigned int _w, + const unsigned int _h = 1); + + /// \brief Set the number of samples in the width and height for the + /// second pass texture. + /// \param[in] _w Number of samples in the horizontal sweep + /// \param[in] _h Number of samples in the vertical sweep + private: virtual void SetRangeCount(const unsigned int _w, + const unsigned int _h = 1); + + // Documentation inherited. + private: virtual void Render() override; + + /// \brief Configure cameras. + private: void ConfigureCameras(); + + /// \brief Create a mesh. + private: void CreateMesh(); + + /// \brief Create a canvas. + private: void CreateCanvas(); + + /// \brief Create an ortho camera. + private: void CreateOrthoCam(); + + /// \brief Create an ortho camera. + private: void CreateCamera(); + + /// \brief Create the texture which is used to render gpu rays data. + private: virtual void CreateGpuRaysTextures(); + + /// \brief Builds scaled Orthogonal Matrix from parameters. + /// \param[in] _left Left clip. + /// \param[in] _right Right clip. + /// \param[in] _bottom Bottom clip. + /// \param[in] _top Top clip. + /// \param[in] _near Near clip. + /// \param[in] _far Far clip. + /// \return The Scaled orthogonal Ogre::Matrix4 + private: Ogre::Matrix4 BuildScaledOrthoMatrix(const float _left, + const float _right, const float _bottom, const float _top, + const float _near, const float _far); + + private: void UpdateRenderTarget(Ogre::RenderTarget *_target, + Ogre::Material *_material, + Ogre::Camera *_cam, + const bool _updateTex); + + /// \brief Get Cos Horz field-of-view + /// \return 2 * atan(tan(this->hfov/2) / cos(this->vfov/2)) + private: virtual double CosHorzFOV() const; + + /// \brief Set the Cos Horz FOV + /// \param[in] _chfov Cos Horz FOV + private: virtual void SetCosHorzFOV(const double _chfov); + + /// \brief Get Cos Vert field-of-view + /// \return 2 * atan(tan(this->vfov/2) / cos(this->hfov/2)) + private: virtual double CosVertFOV() const; + + /// \brief Set the Cos Horz FOV + /// \param[in] _cvfov Cos Horz FOV + private: virtual void SetCosVertFOV(const double _cvfov); + + /// \brief Get (horizontal_max_angle + horizontal_min_angle) * 0.5 + /// \return (horizontal_max_angle + horizontal_min_angle) * 0.5 + private: virtual double HorzHalfAngle() const; + + /// \brief Get (vertical_max_angle + vertical_min_angle) * 0.5 + /// \return (vertical_max_angle + vertical_min_angle) * 0.5 + private: virtual double VertHalfAngle() const; + + /// \brief Set the horizontal half angle + /// \param[in] _angle horizontal half angle + private: virtual void SetHorzHalfAngle(const double _angle); + + /// \brief Set the vertical half angle + /// \param[in] _angle vertical half angle + private: virtual void SetVertHalfAngle(const double _angle); + + /// \internal + /// \brief Pointer to private data. + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreGrid.hh b/ogre/include/gz/rendering/ogre/OgreGrid.hh new file mode 100644 index 000000000..6a577051b --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreGrid.hh @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGREGRID_HH_ +#define GZ_RENDERING_OGRE_OGREGRID_HH_ + +#include +#include "gz/rendering/base/BaseGrid.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class OgreGridPrivate; + + /// \brief Ogre implementation of a grid geometry. + class IGNITION_RENDERING_OGRE_VISIBLE OgreGrid + : public BaseGrid + { + /// \brief Constructor + protected: OgreGrid(); + + /// \brief Destructor + public: virtual ~OgreGrid(); + + // Documentation inherited. + public: virtual void Init(); + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const; + + // Documentation inherited. + public: virtual void PreRender(); + + // Documentation inherited. + public: virtual MaterialPtr Material() const; + + // Documentation inherited. + public: virtual void SetMaterial(MaterialPtr _material, bool _unique); + + /// \brief Set material to grid geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); + + /// \brief Create the grid geometry in ogre + private: void Create(); + + /// \brief Grid should only be created by scene. + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreIncludes.hh b/ogre/include/gz/rendering/ogre/OgreIncludes.hh new file mode 100644 index 000000000..1e7dc45a4 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreIncludes.hh @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREINCLUDES_HH_ +#define GZ_RENDERING_OGRE_OGREINCLUDES_HH_ + +// This disables warning messages for OGRE +#ifndef _MSC_VER + #pragma GCC system_header +#else + #pragma warning(push, 0) + #pragma warning(disable:4275) + #pragma warning(disable:4005) +#endif + +// This prevents some deprecation #warning messages on OSX 10.9 +#pragma clang diagnostic ignored "-W#warnings" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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/OgreLight.hh b/ogre/include/gz/rendering/ogre/OgreLight.hh new file mode 100644 index 000000000..a8c537d52 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreLight.hh @@ -0,0 +1,145 @@ +/* + * 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; + + public: virtual void SetDiffuseColor(const math::Color &_color); + + public: virtual math::Color SpecularColor() const; + + public: virtual void SetSpecularColor(const 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); + + public: virtual Ogre::Light *Light() const; + + public: virtual void Destroy(); + + protected: virtual void Init(); + + 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/OgreMarker.hh b/ogre/include/gz/rendering/ogre/OgreMarker.hh new file mode 100644 index 000000000..3c0a4bd51 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreMarker.hh @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGREMARKER_HH_ +#define GZ_RENDERING_OGRE_OGREMARKER_HH_ + +#include +#include "gz/rendering/base/BaseMarker.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class OgreMarkerPrivate; + + /// \brief Ogre implementation of a marker geometry. + class IGNITION_RENDERING_OGRE_VISIBLE OgreMarker + : public BaseMarker + { + /// \brief Constructor + protected: OgreMarker(); + + /// \brief Destructor + public: virtual ~OgreMarker(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial( + MaterialPtr _material, bool _unique) override; + + // Documentation inherited + public: virtual void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value) override; + + // Documentation inherited + public: virtual void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color) override; + + // Documentation inherited + public: virtual void ClearPoints() override; + + // Documentation inherited + public: virtual void SetType(const MarkerType _markerType) override; + + // Documentation inherited + public: virtual MarkerType Type() const override; + + /// \brief Create the marker geometry in ogre + private: void Create(); + + /// \brief Marker should only be created by scene. + private: friend class OgreScene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreMaterial.hh b/ogre/include/gz/rendering/ogre/OgreMaterial.hh new file mode 100644 index 000000000..f29cc596d --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreMaterial.hh @@ -0,0 +1,233 @@ +/* + * 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; + + 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; + + public: virtual bool ReflectionEnabled() const override; + + public: virtual void SetReflectionEnabled(const bool _enabled) override; + + public: virtual bool HasTexture() const override; + + public: virtual std::string Texture() const override; + + // Documentation inherited. + public: virtual void SetTexture(const std::string &_texture) override; + + public: virtual void ClearTexture() override; + + public: virtual bool HasNormalMap() const override; + + public: virtual std::string NormalMap() const override; + + // Documentation inherited. + public: virtual void SetNormalMap(const std::string &_normalMap) override; + + public: virtual void ClearNormalMap() override; + + public: virtual enum ShaderType ShaderType() const override; + + // Documentation inherited. + public: virtual void SetShaderType(enum ShaderType _type) override; + + public: virtual Ogre::MaterialPtr Material() const; + + // Documentation inherited. + // \sa Material::Set3DMaterial() + public: virtual void SetDepthMaterial(const double far, + const double near) override; + + // Documentation inherited. + // \sa Material::SetVertexShader(const std::string &) + public: virtual void SetVertexShader(const std::string &_path) override; + + // Documentation inherited. + // \sa Material::VertexShader() const + public: virtual std::string VertexShader() const override; + + // Documentation inherited. + // \sa Material::VertexShaderParams() + public: virtual ShaderParamsPtr VertexShaderParams() override; + + // Documentation inherited. + // \sa Material::SetFragmentShader(const std::string &) + public: virtual void SetFragmentShader(const std::string &_path) + override; + + // Documentation inherited. + // \sa Material::FragmentShader() const + public: virtual std::string FragmentShader() const override; + + // Documentation inherited. + // \sa Material::FragmentShaderParams() + public: virtual ShaderParamsPtr FragmentShaderParams() override; + + // Documentation inherited. + // \sa BaseMaterial::PreRender() + public: virtual void PreRender() override; + + protected: virtual void LoadOneImage(const std::string &_name, + Ogre::Image &_image); + + /// \brief Set the texture for this material + /// \param[in] _texture Name of the texture. + protected: virtual void SetTextureImpl(const std::string &_texture); + + protected: virtual Ogre::TexturePtr Texture(const std::string &_name); + + protected: virtual Ogre::TexturePtr CreateTexture( + const std::string &_name); + + protected: virtual void UpdateTransparency(); + + protected: virtual void UpdateColorOperation(); + + /// \brief bind shader parameters that have changed + protected: void UpdateShaderParams(); + + /// \brief Transfer params from ign-rendering type to ogre type + /// \param[in] _params ignition rendering params + /// \param[out] _ogreParams ogre type for holding params + protected: void UpdateShaderParams(ConstShaderParamsPtr _params, + Ogre::GpuProgramParametersSharedPtr _ogreParams); + + protected: virtual void Init() override; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: Ogre::MaterialPtr ogreMaterial; + + protected: Ogre::Technique *ogreTechnique = nullptr; + + protected: Ogre::Pass *ogrePass = nullptr; + + protected: Ogre::TextureUnitState *ogreTexState = nullptr; + + protected: Ogre::String ogreGroup; + +#if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR <= 7 + protected: math::Color emissiveColor; +#endif + protected: std::string textureName; + + protected: std::string normalMapName; + + protected: enum ShaderType shaderType = ST_PIXEL; + + /// \brief Path to vertex shader program. + protected: std::string vertexShaderPath; + + /// \brief Path to fragment shader program. + protected: std::string fragmentShaderPath; + + /// \brief Parameters to be bound to the vertex shader + protected: ShaderParamsPtr vertexShaderParams; + + /// \brief Parameters to be bound to the fragment shader + protected: ShaderParamsPtr fragmentShaderParams; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreMaterialSwitcher.hh b/ogre/include/gz/rendering/ogre/OgreMaterialSwitcher.hh new file mode 100644 index 000000000..141cfff4f --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreMaterialSwitcher.hh @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGREMATERIALSWITCHER_HH_ +#define GZ_RENDERING_OGRE_OGREMATERIALSWITCHER_HH_ + +#include +#include + +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations + class OgreSelectionBuffer; + + /// \brief Helper class to assign unique colors to renderables + class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterialSwitcher : +// Ogre::MaterialManager::Listener isn't a dll-interface class, this may cause +// issues +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4275) +#endif + public Ogre::MaterialManager::Listener, +#ifdef _MSC_VER + #pragma warning(pop) +#endif + Ogre::RenderTargetListener + { + /// \brief Constructor + public: OgreMaterialSwitcher(); + + /// \brief Destructor + public: ~OgreMaterialSwitcher(); + + /// \brief Get the entity with a specific color + /// \param[in] _color The entity's color. + public: std::string EntityName( + const gz::math::Color &_color) const; + + /// \brief Reset the color value incrementor + public: void Reset(); + + /// \brief Ogre callback that assigns colors to new renderables when the + /// requested scheme is not found + /// \param[in] _schemeIndex Index of scheme requested + /// \param[in] _schemeName Name of scheme requested + /// \param[in] _originalMaterial Orignal material that does not contain + /// the requested scheme + /// \param[in] _lodIndex The material level-of-detail + /// \param[in] _rend Pointer to the Ogre::Renderable object requesting + /// the use of the techinique + /// \return The Ogre material technique to use when scheme is not found. + public: virtual Ogre::Technique *handleSchemeNotFound( + uint16_t _schemeIndex, const Ogre::String &_schemeName, + Ogre::Material *_originalMaterial, uint16_t _lodIndex, + const Ogre::Renderable *_rend); + + /// \brief Ogre's pre render update callback + /// \param[in] _evt Ogre render target event containing information about + /// the source render target. + public: virtual void preRenderTargetUpdate( + const Ogre::RenderTargetEvent &_evt); + + /// \brief Ogre's post render update callback + /// \param[in] _evt Ogre render target event containing information about + /// the source render target. + public: virtual void postRenderTargetUpdate( + const Ogre::RenderTargetEvent &_evt); + + /// \brief Current unique color value + private: gz::math::Color currentColor; + + /// \brief last entity assigned an unique color value + private: std::string lastEntity; + + /// \brief last technique assigned to an entity. + private: Ogre::Technique *lastTechnique = nullptr; + + /// \brief Color dictionary that maps the unique color value to + /// renderable name + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + private: std::map colorDict; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + /// \brief Increment unique color value that will be assigned to the + /// next renderable + private: void NextColor(); + + /// \brief Selection Buffer class that make use of this class for + /// selecting entitiies + public: friend class OgreSelectionBuffer; + + /// \brief Plain material technique + private: Ogre::Technique *plainTechnique = nullptr; + + /// \brief Overlay material technique + private: Ogre::Technique *overlayTechnique = nullptr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreMesh.hh b/ogre/include/gz/rendering/ogre/OgreMesh.hh new file mode 100644 index 000000000..fb8165fdb --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreMesh.hh @@ -0,0 +1,101 @@ +/* + * 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 "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 { + // + 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; + + 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; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreSubMesh : + public BaseSubMesh + { + protected: OgreSubMesh(); + + public: virtual ~OgreSubMesh(); + + public: virtual Ogre::SubEntity *OgreSubEntity() const; + + public: virtual void Destroy() override; + + // Documentation inherited + protected: virtual void SetMaterialImpl(MaterialPtr _material) override; + + protected: virtual void Init() override; + + protected: Ogre::SubEntity *ogreSubEntity; + + private: friend class OgreScene; + + private: friend class OgreSubMeshStoreFactory; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreMeshFactory.hh b/ogre/include/gz/rendering/ogre/OgreMeshFactory.hh new file mode 100644 index 000000000..9c6aaf8f7 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreMeshFactory.hh @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_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); + + protected: OgreScenePtr scene; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreSubMeshStoreFactory + { + typedef std::vector NameList; + + public: OgreSubMeshStoreFactory(OgreScenePtr _scene, + Ogre::Entity *_entity); + + public: virtual ~OgreSubMeshStoreFactory(); + + public: virtual OgreSubMeshStorePtr Create(); + + protected: virtual OgreSubMeshPtr CreateSubMesh(unsigned int _index); + + protected: virtual void CreateNameList(); + + protected: virtual void PopulateDefaultNames(); + + protected: virtual void PopulateGivenNames(); + + protected: OgreScenePtr scene; + + protected: Ogre::Entity *ogreEntity; + + protected: NameList names; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreNode.hh b/ogre/include/gz/rendering/ogre/OgreNode.hh new file mode 100644 index 000000000..28c641680 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreNode.hh @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRENODE_HH_ +#define GZ_RENDERING_OGRE_OGRENODE_HH_ + +#include + +#include "gz/rendering/base/BaseNode.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreObject.hh" + +namespace Ogre +{ + class SceneNode; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreNode : + public BaseNode + { + protected: OgreNode(); + + public: virtual ~OgreNode(); + + public: virtual bool HasParent() const override; + + public: virtual NodePtr Parent() const override; + + public: virtual Ogre::SceneNode *Node() const; + + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual math::Vector3d LocalScale() const override; + + // Documentation inherited. + public: virtual bool InheritScale() const override; + + // Documentation inherited. + public: virtual void SetInheritScale(bool _inherit) override; + + // Documentation inherited. + protected: virtual void SetLocalScaleImpl( + const math::Vector3d &_scale) override; + + protected: virtual NodeStorePtr Children() const override; + + protected: virtual bool AttachChild(NodePtr _child) override; + + protected: virtual bool DetachChild(NodePtr _child) override; + + protected: virtual math::Pose3d RawLocalPose() const override; + + protected: virtual void SetRawLocalPose(const math::Pose3d &_Pose3d) + override; + + protected: virtual math::Vector3d RawLocalPosition() const; + + protected: virtual void SetRawLocalPosition( + const math::Vector3d &_position); + + protected: virtual math::Quaterniond RawLocalRotation() const; + + protected: virtual void SetRawLocalRotation( + const math::Quaterniond &_rotation); + + protected: virtual void SetParent(OgreNodePtr _parent); + + protected: virtual void Load() override; + + protected: virtual void Init() override; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: OgreNodePtr parent; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + protected: Ogre::SceneNode *ogreNode = nullptr; + + protected: OgreNodeStorePtr children; + + private: OgreNodePtr SharedThis(); + + // TODO(anyone): remove the need for a visual friend class + private: friend class OgreVisual; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreObject.hh b/ogre/include/gz/rendering/ogre/OgreObject.hh new file mode 100644 index 000000000..4acc1acc1 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreObject.hh @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGREOBJECT_HH_ +#define GZ_RENDERING_OGRE_OGREOBJECT_HH_ + +#include + +#include "gz/rendering/base/BaseObject.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreObject : + public BaseObject + { + protected: OgreObject(); + + public: virtual ~OgreObject(); + + public: virtual ScenePtr Scene() const; + + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + protected: OgreScenePtr scene; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRTShaderSystem.hh b/ogre/include/gz/rendering/ogre/OgreRTShaderSystem.hh new file mode 100644 index 000000000..1e4d1611b --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRTShaderSystem.hh @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRERTSHADERSYSTEM_HH_ +#define GZ_RENDERING_OGRE_OGRERTSHADERSYSTEM_HH_ + +#include +#include + +#include +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreRTShaderSystemPrivate; + + /// \addtogroup ign_rendering + /// \{ + + /// \class OgreRTShaderSystem OgreRTShaderSystem.hh rendering/rendering.hh + /// \brief Implements Ogre's Run-Time Shader system. + /// + /// This class allows Gazebo to generate per-pixel shaders for every + /// material at run-time. + class IGNITION_RENDERING_OGRE_VISIBLE OgreRTShaderSystem : + public common::SingletonT + { + /// \enum LightingModel + /// \brief The type of lighting + public: enum LightingModel + { + /// \brief Per-Vertex lighting: best performance. + SSLM_PerVertexLighting, + /// \brief Per-Pixel lighting: best look. + SSLM_PerPixelLighting, + /// \brief Normal Map lighting: lighting calculations have + /// been stored in a light map (texture) using tangent space. + SSLM_NormalMapLightingTangentSpace, + /// \brief Normal Map lighting: lighting calculations have + /// been stored in a light map (texture) using object space. + SSLM_NormalMapLightingObjectSpace + }; + + /// \brief Constructor. + private: OgreRTShaderSystem(); + + /// \brief Destructor. + private: virtual ~OgreRTShaderSystem(); + + /// \brief Initialize the run time shader system. + /// \return True if the run time shader system is initialized + /// successfully. + public: bool Init(); + + /// \brief Finalize the shader system + public: void Fini(); + + /// \brief Clear the shader system + public: void Clear(); + + /// \brief Add a scene manager + /// \param[in] _scene The scene to process + public: void AddScene(OgreScenePtr _scene); + + /// \brief Remove a scene + /// \param[in] _scene The scene to remove + public: void RemoveScene(OgreScenePtr _scene); + + /// \brief Remove a scene + /// \param[in] _scene Name of the scene to remove. + public: void RemoveScene(const std::string &_scene); + + /// \brief Update the shaders. This should not be called frequently. + public: void UpdateShaders(); + + /// \brief Set an Ogre::Entity to use RT shaders. + /// \param[in] _vis OgreSubMesh that will use the OgreRTShaderSystem. + public: void AttachEntity(OgreSubMesh *_vis); + + /// \brief Remove and entity. + /// \param[in] _vis Remove this visual. + public: void DetachEntity(OgreSubMesh *_vis); + + /// \brief Set a viewport to use shaders. + /// \param[in] _viewport The viewport to add. + /// \param[in] _scene The scene that the viewport uses. + public: static void AttachViewport(Ogre::Viewport *_viewport, + OgreScenePtr _scene); + + /// \brief Set a viewport to not use shaders. + /// \param[in] _viewport The viewport to remove. + /// \param[in] _scene The scene that the viewport uses. + public: static void DetachViewport(Ogre::Viewport *_viewport, + OgreScenePtr _scene); + + /// \brief Set the lighting model to per pixel or per vertex. + /// \param[in] _set True means to use per-pixel shaders. + public: void SetPerPixelLighting(bool _set); + + /// \brief Generate shaders for an entity + /// \param[in] _subMesh The submesh to remove shaders for. + public: void RemoveShaders(OgreSubMesh *_subMesh); + + /// \brief Generate shaders for an entity + /// \param[in] _subMesh The submesh to generate shaders for. + public: void GenerateShaders(OgreSubMesh *_subMesh); + + /// \brief Apply shadows to a scene. + /// \param[in] _scene The scene to receive shadows. + public: void ApplyShadows(OgreScenePtr _scene); + + /// \brief Remove shadows from a scene. + /// \param[in] _scene The scene to remove shadows from. + public: void RemoveShadows(OgreScenePtr _scene); + + /// \brief Get the Ogre PSSM Shadows camera setup. + /// \return The Ogre PSSM Shadows camera setup. + public: Ogre::PSSMShadowCameraSetup *PSSMShadowCameraSetup() const; + + /// \brief Get paths for the shader system + /// \param[out] _coreLibsPath Path to the core libraries. + /// \param[out] _cachePath Path to where the generated shaders are + /// stored. + private: bool Paths(std::string &_coreLibsPath, + std::string &_cachePath); + + /// \brief Set the shadow texture size. + /// \param[in] _size Size of shadow texture to set to. This must be a + /// power of 2. The default size is 1024. + /// \return True if size is set successfully, false otherwise. + public: bool SetShadowTextureSize(const unsigned int _size); + + /// \brief Get the shadow texture size. + /// \return Size of the shadow texture. The default size is 1024. + public: unsigned int ShadowTextureSize() const; + + /// \brief Get if RTShaderSystem is initialized or not + /// \return True if intialized. + public: bool IsInitialized() const; + + /// \brief Update the RT shaders. The call will only take effect if + /// shadow properties changed, e.g. texture size, or the shaders + /// have been marked dirty by UpdateShaders, e.g. when entities are + /// added. The function reapplies shadows if properties have changed, + /// and iterates through all entities added to RTShaderSystem + /// and regenerates shader programs for each entity if shaders are dirty. + /// This function is currently called by OgreScene::PreRender + /// \sa OgreScene::PreRender + public: void Update(); + + /// \brief Make the RTShader system a singleton. + private: friend class common::SingletonT; + + /// \brief Pointer to private data class + private: std::unique_ptr dataPtr; + }; + /// \} + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRayQuery.hh b/ogre/include/gz/rendering/ogre/OgreRayQuery.hh new file mode 100644 index 000000000..1e3c527b0 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRayQuery.hh @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRERAYQUERY_HH_ +#define GZ_RENDERING_OGRE_OGRERAYQUERY_HH_ + +#include + +#include "gz/rendering/base/BaseRayQuery.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreObject.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreRayQueryPrivate; + + /// \class OgreRayQuery OgreRayQuery.hh + /// ignition/rendering/base/OgreRayQuery.hh + /// \brief A Ray Query class used for computing ray object intersections + class IGNITION_RENDERING_OGRE_VISIBLE OgreRayQuery : + public BaseRayQuery + { + /// \brief Constructor + protected: OgreRayQuery(); + + /// \brief Destructor + public: virtual ~OgreRayQuery(); + + // Documentation inherited + public: virtual void SetFromCamera(const CameraPtr &_camera, + const math::Vector2d &_coord); + + // Documentation inherited + public: virtual RayQueryResult ClosestPoint(); + + /// \brief Get the mesh information for the given mesh. + /// \param[in] _mesh Mesh to get info about. + /// \param[out] _vertexCount Number of vertices in the mesh. + /// \param[out] _vertices Array of the vertices. + /// \param[out] _indexCount Number if indices. + /// \param[out] _indices Array of the indices. + /// \param[in] _position Position of the mesh. + /// \param[in] _orient Orientation of the mesh. + /// \param[in] _scale Scale of the mesh + // Code found in Wiki: www.ogre3d.org/wiki/index.php/RetrieveVertexData + private: void MeshInformation(const Ogre::Mesh *_mesh, + size_t &_vertexCount, + Ogre::Vector3* &_vertices, + size_t &_indexCount, + uint64_t* &_indices, + const math::Vector3d &_position, + const math::Quaterniond &_orient, + const math::Vector3d &_scale); + + /// \brief Private data pointer + private: std::unique_ptr dataPtr; + + /// \brief Pointer to friend scene class for creating ray query + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRenderEngine.hh b/ogre/include/gz/rendering/ogre/OgreRenderEngine.hh new file mode 100644 index 000000000..dd168a5cf --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRenderEngine.hh @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRERENDERENGINE_HH_ +#define GZ_RENDERING_OGRE_OGRERENDERENGINE_HH_ + +#include +#include +#include +#include + +#include + +#include "gz/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/base/BaseRenderEngine.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace Ogre +{ + class LogManager; + class Root; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreRenderEnginePrivate; + + /// \brief Plugin for loading ogre render engine + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderEnginePlugin : + public RenderEnginePlugin + { + /// \brief Constructor + public: OgreRenderEnginePlugin(); + + /// \brief Destructor + public: ~OgreRenderEnginePlugin() = default; + + /// \brief Get the name of the render engine loaded by this plugin. + /// \return Name of render engine + public: std::string Name() const; + + /// \brief Get a pointer to the render engine loaded by this plugin. + /// \return Render engine instance + public: RenderEngine *Engine() const; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderEngine : + public virtual BaseRenderEngine, + public common::SingletonT + { + /// \enum OgreRenderPathType + /// \brief The type of rendering path used by the rendering engine. + public: enum OgreRenderPathType + { + /// \brief No rendering is done. + NONE = 0, + /// \brief Most basic rendering, with least fidelity. + VERTEX = 1, + /// \brief Utilizes the RTT shader system. + FORWARD = 2, + /// \brief Utilizes deferred rendering. Best fidelity. + DEFERRED = 3, + /// \brief Count of the rendering path enums. + RENDER_PATH_COUNT + }; + + /// \brief Constructor + private: OgreRenderEngine(); + + public: virtual ~OgreRenderEngine(); + + public: virtual void Destroy() override; + + public: virtual bool IsEnabled() const override; + + public: virtual std::string Name() const override; + + public: OgreRenderPathType RenderPathType() const; + + public: void AddResourcePath(const std::string &_uri) override; + + public: virtual Ogre::Root *OgreRoot() const; + + public: std::string CreateRenderWindow(const std::string &_handle, + const unsigned int _width, const unsigned int _height, + const double _ratio, const unsigned int _antiAliasing); + + /// \brief Get a list of all supported FSAA levels for this render system + /// \return a list of FSAA levels + public: std::vector FSAALevels() const; + + protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual SceneStorePtr Scenes() const override; + + /// \brief Engine implementation of Load function. + /// \param[in] _params Parameters to be passed to the render engine. + /// Current accepts the following parameters and values: + /// "useCurrentGLContext" : "1" or "0". Use current OpenGL context for + /// rendering + protected: virtual bool LoadImpl( + const std::map &_params) override; + + protected: virtual bool InitImpl() override; + + private: void LoadAttempt(); + + private: void CreateLogger(); + + private: void CreateContext(); + + private: void CreateRoot(); + + private: void CreateOverlay(); + + private: void LoadPlugins(); + + private: void CreateRenderSystem(); + + private: void CreateResources(); + + private: void CreateRenderWindow(); + + private: void CheckCapabilities(); + + private: void InitAttempt(); + +#if (OGRE_VERSION >= ((1 << 16) | (9 << 8) | 0)) + /// \internal + /// \brief Get a pointer to the Ogre overlay system. + /// \return Pointer to the OGRE overlay system. + public: Ogre::OverlaySystem *OverlaySystem() const; + + private: Ogre::OverlaySystem *ogreOverlaySystem = nullptr; + +#endif + private: OgreSceneStorePtr scenes; + + private: OgreRenderPathType renderPathType; + + private: Ogre::Root *ogreRoot = nullptr; + + private: Ogre::LogManager *ogreLogManager = nullptr; + + /// \brief Paths to ogre plugins + private: std::vector ogrePaths; + +#if !defined(__APPLE__) && !defined(_WIN32) + private: void *dummyDisplay = nullptr; + + private: void *dummyContext = nullptr; +#endif + + private: uint64_t dummyWindowId = 0u; + + /// \brief True to use the current opengl context + private: bool useCurrentGLContext = false; + + private: std::unique_ptr dataPtr; + + private: friend class common::SingletonT; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRenderPass.hh b/ogre/include/gz/rendering/ogre/OgreRenderPass.hh new file mode 100644 index 000000000..629045cb4 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRenderPass.hh @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRERENDERPASS_HH_ +#define GZ_RENDERING_OGRE_OGRERENDERPASS_HH_ + +#include "gz/rendering/base/BaseRenderPass.hh" +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \class OgreRenderPass OgreRenderPass.hh \ + * ignition/rendering/ogre/OgreRenderPass.hh + */ + /// \brief Ogre implementation of the RenderPass class + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderPass : + public BaseRenderPass + { + /// \brief Constructor + protected: OgreRenderPass(); + + /// \brief Destructor + public: virtual ~OgreRenderPass(); + + /// \brief Set the ogre camera that the render pass applies to + /// \param[in] _camera Pointer to the ogre camera. + public: virtual void SetCamera(Ogre::Camera *_camera); + + // Documentation inherited. + public: void Destroy() override; + + /// \brief Create the render pass using ogre compositor + public: virtual void CreateRenderPass(); + + /// \brief Pointer to the ogre camera + protected: Ogre::Camera *ogreCamera = nullptr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRenderTarget.hh b/ogre/include/gz/rendering/ogre/OgreRenderTarget.hh new file mode 100644 index 000000000..f66a37317 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRenderTarget.hh @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_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); + + 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; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTexture : + public virtual BaseRenderTexture + { + protected: OgreRenderTexture(); + + public: virtual ~OgreRenderTexture(); + + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void PostRender() override; + + // Documentation inherited. + public: virtual unsigned int GLId(); + + public: virtual void Buffer(float *buffer); + + public: virtual Ogre::RenderTarget *RenderTarget() const override; + + protected: virtual void RebuildTarget() override; + + protected: virtual void DestroyTarget(); + + protected: virtual void BuildTarget(); + + protected: Ogre::Texture *ogreTexture = nullptr; + + private: friend class OgreScene; + }; + + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderWindow : + public virtual BaseRenderWindow + { + protected: OgreRenderWindow(); + + public: virtual ~OgreRenderWindow(); + + public: virtual void Destroy(); + + protected: virtual Ogre::RenderTarget *RenderTarget() const; + + protected: virtual void RebuildTarget(); + + protected: virtual void BuildTarget(); + + protected: Ogre::RenderTarget *ogreRenderWindow = nullptr; + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRenderTargetMaterial.hh b/ogre/include/gz/rendering/ogre/OgreRenderTargetMaterial.hh new file mode 100644 index 000000000..627709d86 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRenderTargetMaterial.hh @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRRENDERTARGETMATERIAL_HH_ +#define GZ_RENDERING_OGRE_OGRRENDERTARGETMATERIAL_HH_ + +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/Export.hh" + +// Ogre::MaterialManager::Listener isn't a dll-interface class, this may cause +// issues +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4275) +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Causes all objects in a scene to be rendered with the same + /// material when rendered by a given RenderTarget. + /// \internal + /// + /// On construction it registers as an Ogre::RenderTargetListener + /// on the provided Ogre::RenderTarget, and sets the material scheme name + /// to a value that is unlikely to exist. + /// When the target is about to be rendered it adds itself as an + /// Ogre::MaterialManager::Listener. + /// Every time ogre tries to get a technique for a material it will call + /// handleSchemeNotFound which returns the first supported technique on the + /// material provided to this class's constructor. + class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTargetMaterial : + public Ogre::RenderTargetListener, + public Ogre::MaterialManager::Listener + { + /// \brief constructor + /// \param[in] _scene the scene manager responsible for rendering + /// \param[in] _renderTarget the RenderTarget this should apply to + /// \param[in] _material the material to apply to all renderables + public: OgreRenderTargetMaterial(OgreScenePtr _scene, + Ogre::RenderTarget *_renderTarget, Ogre::Material *_material); + + /// \brief destructor + public: ~OgreRenderTargetMaterial(); + + /// \brief Callback when a render target is about to be rendered + /// \param[in] _evt Ogre render target event containing information about + /// the source render target. + private: virtual void preRenderTargetUpdate( + const Ogre::RenderTargetEvent &_evt) override; + + /// \brief Callback when a render target is finisned being rendered + /// \param[in] _evt Ogre render target event containing information about + /// the source render target. + private: virtual void postRenderTargetUpdate( + const Ogre::RenderTargetEvent &_evt) override; + + /// \brief Ogre callback that assigned same material to all renderables + /// when the requested scheme is not found + /// \param[in] _schemeIndex Index of scheme requested + /// \param[in] _schemeName Name of scheme requested + /// \param[in] _originalMaterial Orignal material that does not contain + /// the requested scheme + /// \param[in] _lodIndex The material level-of-detail + /// \param[in] _rend Pointer to the Ogre::Renderable object requesting + /// the use of the techinique + /// \return The Ogre material technique to use when scheme is not found. + public: virtual Ogre::Technique *handleSchemeNotFound( + uint16_t _schemeIndex, const Ogre::String &_schemeName, + Ogre::Material *_originalMaterial, uint16_t _lodIndex, + const Ogre::Renderable *_rend) override; + + /// \brief scene manager responsible for rendering + private: OgreScenePtr scene; + + /// \brief render target that should see a uniform material + private: Ogre::RenderTarget *renderTarget; + + /// \brief material that should be applied to all objects + private: Ogre::Material *material; + + /// \brief name of the material scheme used by this applicator + private: Ogre::String schemeName; + }; + } + } +} + +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreRenderTypes.hh b/ogre/include/gz/rendering/ogre/OgreRenderTypes.hh new file mode 100644 index 000000000..da5a955b0 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreRenderTypes.hh @@ -0,0 +1,112 @@ +/* + * 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 OgreDepthCamera; + class OgreDirectionalLight; + class OgreGeometry; + class OgreGizmoVisual; + class OgreGpuRays; + class OgreGrid; + class OgreJointVisual; + class OgreLight; + class OgreMaterial; + class OgreMarker; + class OgreMesh; + class OgreMeshFactory; + class OgreNode; + class OgreObject; + 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; + + 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 OgreDepthCameraPtr; + typedef shared_ptr OgreDirectionalLightPtr; + typedef shared_ptr OgreGeometryPtr; + typedef shared_ptr OgreGizmoVisualPtr; + typedef shared_ptr OgreGpuRaysPtr; + typedef shared_ptr OgreGridPtr; + typedef shared_ptr OgreJointVisualPtr; + typedef shared_ptr OgreLightPtr; + typedef shared_ptr OgreMaterialPtr; + typedef shared_ptr OgreMarkerPtr; + typedef shared_ptr OgreMeshPtr; + typedef shared_ptr OgreMeshFactoryPtr; + typedef shared_ptr OgreNodePtr; + typedef shared_ptr OgreObjectPtr; + typedef shared_ptr OgrePointLightPtr; + typedef shared_ptr OgreRayQueryPtr; + typedef shared_ptr OgreRenderEnginePtr; + typedef shared_ptr OgreRenderTargetPtr; + typedef shared_ptr OgreRenderTexturePtr; + typedef shared_ptr OgreRenderWindowPtr; + typedef shared_ptr OgreScenePtr; + typedef shared_ptr OgreSensorPtr; + typedef shared_ptr OgreSpotLightPtr; + typedef shared_ptr OgreSubMeshPtr; + typedef shared_ptr OgreTextPtr; + typedef shared_ptr OgreVisualPtr; + typedef shared_ptr OgreSceneStorePtr; + typedef shared_ptr OgreNodeStorePtr; + typedef shared_ptr OgreLightStorePtr; + typedef shared_ptr OgreSensorStorePtr; + typedef shared_ptr OgreVisualStorePtr; + typedef shared_ptr OgreGeometryStorePtr; + typedef shared_ptr OgreSubMeshStorePtr; + typedef shared_ptr OgreMaterialMapPtr; + typedef shared_ptr OgreRenderTargetMaterialPtr; + typedef shared_ptr OgreThermalCameraPtr; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreScene.hh b/ogre/include/gz/rendering/ogre/OgreScene.hh new file mode 100644 index 000000000..02b4f8dd8 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreScene.hh @@ -0,0 +1,204 @@ +/* + * 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(); + + 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 Ogre::SceneManager *OgreSceneManager() const; + + 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( + const unsigned int _id, + const std::string &_name); + + // Documentation inherited + protected: virtual ThermalCameraPtr CreateThermalCameraImpl( + const unsigned int _id, + const std::string &_name); + + protected: virtual GpuRaysPtr CreateGpuRaysImpl( + const unsigned int _id, + const std::string &_name); + + 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); + + // Documentation inherited + protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(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); + + // Documentation inherited + protected: virtual MarkerPtr CreateMarkerImpl(unsigned int _id, + const std::string &_name); + + // Documentation inherited + protected: virtual TextPtr CreateTextImpl(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(OgreObjectPtr _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; + + private: void CreateContext(); + + private: void CreateRootVisual(); + + private: void CreateMeshFactory(); + + private: void CreateStores(); + + private: OgreScenePtr SharedThis(); + + protected: OgreVisualPtr rootVisual; + + protected: OgreMeshFactoryPtr meshFactory; + + protected: OgreLightStorePtr lights; + + protected: OgreSensorStorePtr sensors; + + protected: OgreVisualStorePtr visuals; + + protected: OgreMaterialMapPtr materials; + + protected: Ogre::Root *ogreRoot; + + protected: Ogre::SceneManager *ogreSceneManager; + + private: friend class OgreRenderEngine; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreSelectionBuffer.hh b/ogre/include/gz/rendering/ogre/OgreSelectionBuffer.hh new file mode 100644 index 000000000..3a6932018 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreSelectionBuffer.hh @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +#ifndef GZ_RENDERING_OGRE_OGRESELECTIONBUFFER_HH_ +#define GZ_RENDERING_OGRE_OGRESELECTIONBUFFER_HH_ + +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace Ogre +{ + class Entity; + class RenderTarget; + class SceneManager; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreSelectionBufferPrivate; + + /// \brief Generates a selection buffer object for a given camera. + /// The selection buffer is used of entity selection. On setup, a unique + /// color is assigned to each entity. Whenever a selection request is made, + /// the selection buffer camera renders to a 1x1 sized offscreen buffer. + /// The color value of that pixel gives the identity of the entity. + class IGNITION_RENDERING_OGRE_VISIBLE OgreSelectionBuffer + { + /// \brief Constructor + /// \param[in] _cameraName Name of the camera to generate a selection + /// buffer for. + /// \param[in] _mgr Pointer to the scene manager. + public: OgreSelectionBuffer(const std::string &_cameraName, + Ogre::SceneManager *_mgr); + + /// \brief Destructor + public: ~OgreSelectionBuffer(); + + /// \brief Handle on mouse click + /// \param[in] _x X coordinate in pixels. + /// \param[in] _y Y coordinate in pixels. + /// \return Returns the Ogre entity at the coordinate. + public: Ogre::Entity *OnSelectionClick(const int _x, const int _y); + + /// \brief Debug show overlay + /// \param[in] _show True to show the selection buffer in an overlay. + public: void ShowOverlay(const bool _show); + + /// \brief Call this to update the selection buffer contents + public: void Update(); + + /// \brief Delete the render texture + private: void DeleteRTTBuffer(); + + /// \brief Create the render texture + private: void CreateRTTBuffer(); + + /// \brief Create the selection buffer offscreen render texture. + private: void CreateRTTOverlays(); + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreSensor.hh b/ogre/include/gz/rendering/ogre/OgreSensor.hh new file mode 100644 index 000000000..af5643099 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreSensor.hh @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRESENSOR_HH_ +#define GZ_RENDERING_OGRE_OGRESENSOR_HH_ + +#include "gz/rendering/base/BaseSensor.hh" +#include "gz/rendering/ogre/OgreNode.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreSensor : + public BaseSensor + { + protected: OgreSensor(); + + public: virtual ~OgreSensor(); + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreStorage.hh b/ogre/include/gz/rendering/ogre/OgreStorage.hh new file mode 100644 index 000000000..50db5882b --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreStorage.hh @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE_OGRESTORAGE_HH_ +#define GZ_RENDERING_OGRE_OGRESTORAGE_HH_ + +#include +#include "gz/rendering/base/BaseStorage.hh" + +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreLight.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreMesh.hh" +#include "gz/rendering/ogre/OgreNode.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreSensor.hh" +#include "gz/rendering/ogre/OgreVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + +// armhf failed to build with this code. It can not be removed for the rest +// of arches to keep ABI but should be removed in major versions unreleased +// see https://github.com/ignitionrobotics/ign-rendering/pull/457 +#ifndef __ARM_PCS_VFP + template class BaseSceneStore; + template class BaseNodeStore; + template class BaseLightStore; + template class BaseSensorStore; + template class BaseVisualStore; + template class BaseGeometryStore; + template class BaseSubMeshStore; + template class BaseMaterialMap; +#endif + + typedef BaseSceneStore OgreSceneStore; + typedef BaseNodeStore OgreNodeStore; + typedef BaseLightStore OgreLightStore; + typedef BaseSensorStore OgreSensorStore; + typedef BaseVisualStore OgreVisualStore; + typedef BaseGeometryStore OgreGeometryStore; + typedef BaseSubMeshStore OgreSubMeshStore; + typedef BaseMaterialMap OgreMaterialMap; + + typedef std::shared_ptr OgreSceneStorePtr; + typedef std::shared_ptr OgreNodeStorePtr; + typedef std::shared_ptr OgreLightStorePtr; + typedef std::shared_ptr OgreSensorStorePtr; + typedef std::shared_ptr OgreVisualStorePtr; + typedef std::shared_ptr OgreGeometryStorePtr; + typedef std::shared_ptr OgreSubMeshStorePtr; + typedef std::shared_ptr OgreMaterialMapPtr; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreText.hh b/ogre/include/gz/rendering/ogre/OgreText.hh new file mode 100644 index 000000000..fdda47cf1 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreText.hh @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGRETEXT_HH_ +#define GZ_RENDERING_OGRE_OGRETEXT_HH_ + +#include +#include + +#include +#include + +#include "gz/rendering/base/BaseText.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class OgreMovableText; + class OgreTextPrivate; + + /// \brief Ogre implementation of text geometry + class IGNITION_RENDERING_OGRE_VISIBLE OgreText + : public BaseText + { + /// \brief Constructor + protected: OgreText(); + + /// \brief Destructor + public: virtual ~OgreText(); + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual Ogre::MovableObject *OgreObject() const override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial(MaterialPtr _material, bool _unique) + override; + + // Documentation inherited. + public: virtual void SetFontName(const std::string &_font) override; + + // Documentation inherited. + public: virtual void SetTextString(const std::string &_text) override; + + // Documentation inherited. + public: virtual void SetColor(const gz::math::Color &_color) + override; + + // Documentation inherited. + public: virtual void SetCharHeight(const float _height) override; + + // Documentation inherited. + public: virtual void SetSpaceWidth(const float _width) override; + + // Documentation inherited. + public: virtual void SetTextAlignment( + const TextHorizontalAlign &_horizAlign, + const TextVerticalAlign &_vertAlign) override; + // Documentation inherited. + public: virtual void SetBaseline(const float _baseline) override; + + // Documentation inherited. + public: virtual void SetShowOnTop(const bool _onTop) override; + + // Documentation inherited. + public: virtual gz::math::AxisAlignedBox AABB() const override; + + /// \brief Set material to text geometry. + /// \param[in] _material Ogre material. + protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); + + /// \brief Text should only be created by scene. + private: friend class OgreScene; + + /// \internal + /// \brief Private data pointer + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreThermalCamera.hh b/ogre/include/gz/rendering/ogre/OgreThermalCamera.hh new file mode 100644 index 000000000..28acb3dd2 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreThermalCamera.hh @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE_OGRETHERMALCAMERA_HH_ +#define GZ_RENDERING_OGRE_OGRETHERMALCAMERA_HH_ + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +#include +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/base/BaseThermalCamera.hh" +#include "gz/rendering/ogre/Export.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreSensor.hh" + +#include "gz/common/Event.hh" +#include "gz/common/Console.hh" + + +namespace Ogre +{ + class Material; + class Camera; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class OgreThermalCameraPrivate; + + /** \class OgreThermalCamera OgreThermalCamera.hh\ + * rendering/ogre/OgreThermalCamera.hh + **/ + /// \brief Depth camera used to render thermal data into an image buffer + class IGNITION_RENDERING_OGRE_VISIBLE OgreThermalCamera : + public BaseThermalCamera + { + /// \brief Constructor + protected: OgreThermalCamera(); + + /// \brief Destructor + public: virtual ~OgreThermalCamera(); + + /// \brief Initialize the camera + public: virtual void Init() override; + + /// \brief Create a texture + public: virtual void CreateRenderTexture(); + + /// \brief Render the camera + public: virtual void PostRender() override; + + /// \brief Connect to the new thermal image signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewThermalFrame( + std::function _subscriber) override; + + // Documentation inherited. + public: virtual void PreRender() override; + + /// \brief Implementation of the render call + public: virtual void Render() override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Create the camera. + protected: void CreateCamera(); + + /// \brief Create thermal texture. This stores temperature data + private: void CreateThermalTexture(); + + /// \brief Pointer to the ogre camera + protected: Ogre::Camera *ogreCamera = nullptr; + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/OgreVisual.hh b/ogre/include/gz/rendering/ogre/OgreVisual.hh new file mode 100644 index 000000000..f24fda216 --- /dev/null +++ b/ogre/include/gz/rendering/ogre/OgreVisual.hh @@ -0,0 +1,57 @@ +/* + * 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 "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 { + // + class IGNITION_RENDERING_OGRE_VISIBLE OgreVisual : + public BaseVisual + { + protected: OgreVisual(); + + public: virtual ~OgreVisual(); + + // Documentation inherited. + public: virtual void SetVisible(bool _visible); + + protected: virtual GeometryStorePtr Geometries() const; + + protected: virtual bool AttachGeometry(GeometryPtr _geometry); + + protected: virtual bool DetachGeometry(GeometryPtr _geometry); + + protected: virtual void Init(); + + protected: OgreGeometryStorePtr geometries; + + private: OgreVisualPtr SharedThis(); + + private: friend class OgreScene; + }; + } + } +} +#endif diff --git a/ogre/include/gz/rendering/ogre/ogre.hh.in b/ogre/include/gz/rendering/ogre/ogre.hh.in new file mode 100644 index 000000000..c4092f0cd --- /dev/null +++ b/ogre/include/gz/rendering/ogre/ogre.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/ogre/include/ignition/rendering/ogre.hh b/ogre/include/ignition/rendering/ogre.hh new file mode 100644 index 000000000..4e6486152 --- /dev/null +++ b/ogre/include/ignition/rendering/ogre.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/Export.hh b/ogre/include/ignition/rendering/ogre/Export.hh new file mode 100644 index 000000000..e47fd1851 --- /dev/null +++ b/ogre/include/ignition/rendering/ogre/Export.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh b/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh index 5e1bb8687..90e1bca8e 100644 --- a/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreArrowVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREARROWVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREARROWVISUAL_HH_ -#include "ignition/rendering/base/BaseArrowVisual.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreArrowVisual : - public BaseArrowVisual - { - protected: OgreArrowVisual(); - - public: virtual ~OgreArrowVisual(); - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh b/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh index 2dc439ae1..4cfcbd33a 100644 --- a/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreAxisVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREAXISVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREAXISVISUAL_HH_ -#include "ignition/rendering/base/BaseAxisVisual.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreAxisVisual : - public BaseAxisVisual - { - protected: OgreAxisVisual(); - - public: virtual ~OgreAxisVisual(); - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreCamera.hh b/ogre/include/ignition/rendering/ogre/OgreCamera.hh index a648ece20..6e81e2112 100644 --- a/ogre/include/ignition/rendering/ogre/OgreCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,121 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRECAMERA_HH_ -#define IGNITION_RENDERING_OGRE_OGRECAMERA_HH_ -#include - -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreSensor.hh" -#include "ignition/rendering/ogre/OgreSelectionBuffer.hh" - -namespace Ogre -{ - class Camera; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreSelectionBuffer; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreCamera : - public BaseCamera - { - protected: OgreCamera(); - - public: virtual ~OgreCamera(); - - // Documentation inherited. - public: virtual 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 math::Matrix4d ViewMatrix() const 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; - - 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 +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreConversions.hh b/ogre/include/ignition/rendering/ogre/OgreConversions.hh index 0bb3b632e..88adfcdaa 100644 --- a/ogre/include/ignition/rendering/ogre/OgreConversions.hh +++ b/ogre/include/ignition/rendering/ogre/OgreConversions.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,93 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRECONVERSIONS_HH_ -#define IGNITION_RENDERING_OGRE_OGRECONVERSIONS_HH_ -#include -#include -#include -#include - -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \addtogroup ign_rendering - /// \{ - - /// \brief Conversions Conversions.hh rendering/Conversions.hh - /// \brief A set of utility function to convert between Gazebo and Ogre - /// data types - class IGNITION_RENDERING_OGRE_VISIBLE OgreConversions - { - /// \brief Return the equivalent ogre color - /// \param[in] _color ign-math color to convert - /// \return Ogre color value - public: static Ogre::ColourValue Convert( - const math::Color &_color); - - /// \brief Return the equivalent ign-math color - /// \param[in] _color Ogre color to convert - /// \return ign-math color value - public: static math::Color Convert( - const Ogre::ColourValue &_color); - - /// \brief return Ogre Vector from ign-math Vector3 - /// \param[in] _vector ign-math vector - /// \return Ogre vector - public: static Ogre::Vector3 Convert(const math::Vector3d &_vector); - - /// \brief return ign-math Vector from ogre Vector3 - /// \param[in] _vector Ogre vector - /// \return ign-math vector - public: static math::Vector3d Convert(const Ogre::Vector3 &_vector); - - /// \brief Ign-math quaternion to Ogre quaternion - /// \param[in] _quat ign-math quaternion - /// \return Ogre quaternion - public: static Ogre::Quaternion Convert(const math::Quaterniond &_quat); - - /// \brief Ogre quaternion to ign-math quaternion - /// \param[in] _quat Ogre quaternion - /// return ign-math quaternion - public: static math::Quaterniond Convert(const Ogre::Quaternion &_quat); - - /// \brief Ign-math angle to Ogre angle - /// \param[in] _angle ign-math angle - /// \return Ogre angle - public: static Ogre::Radian Convert(const math::Angle &_angle); - - /// \brief Ogre angle to ign-math angle - /// \param[in] _angle Ogre angle - /// return Ign-math angle - public: static math::Angle Convert(const Ogre::Radian &_angle); - - /// \brief Ogre Matrix4 to ignition math Matrix4d - /// \param[in] _m Ogre Matrix4 - /// \return ignition math Matrix4d - public: static math::Matrix4d Convert(const Ogre::Matrix4 &_m); - - /// \brief Ignition math Matrix4d to Ogre Matrix4 - /// \param[in] _m ignition math Matrix4d - /// \return Ogre Matrix4 - public: static Ogre::Matrix4 Convert(const math::Matrix4d &_m); - - /// \brief Ign-rendering PixelFormat to Ogre PixelFormat - /// \param[in] _format Ign-rendering PixelFormat - /// return Ogre PixelFormat - public: static Ogre::PixelFormat Convert(PixelFormat _format); - - private: static const Ogre::PixelFormat ogrePixelFormats[PF_COUNT]; - }; - /// \} - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh b/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh index c989136ca..879bc7296 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,164 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREDEPTHCAMERA_HH_ -#define IGNITION_RENDERING_OGRE_OGREDEPTHCAMERA_HH_ - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -#include -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/base/BaseDepthCamera.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreSensor.hh" -#include "ignition/rendering/ogre/OgreSelectionBuffer.hh" - -#include "ignition/common/Event.hh" -#include "ignition/common/Console.hh" - - -namespace Ogre -{ - class Material; - class RenderTarget; - class Texture; - class Viewport; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreDepthCameraPrivate; - - /** \class OgreDepthCamera OgreDepthCamera.hh\ - * rendering/ogre/OgreDepthCamera.hh - **/ - /// \brief Depth camera used to render depth data into an image buffer - class IGNITION_RENDERING_OGRE_VISIBLE OgreDepthCamera : - public BaseDepthCamera - { - /// \brief Constructor - protected: OgreDepthCamera(); - - /// \brief Destructor - public: virtual ~OgreDepthCamera(); - - /// \brief Initialize the camera - public: virtual void Init() override; - - /// \brief Create a texture which will hold the depth data - public: virtual void CreateDepthTexture() override; - - /// \brief Render the camera - public: virtual void PostRender() override; - - /// \brief All things needed to get back z buffer for depth data - /// \return The z-buffer as a float array - public: virtual const float *DepthData() const override; - - /// \brief Connect a to the new depth image signal - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewDepthFrame( - std::function _subscriber) override; - - /// \brief Connect a to the new rgb point cloud signal - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewRgbPointCloud( - std::function _subscriber) override; - - // Documentation inherited. - public: virtual void PreRender() override; - - /// \brief Implementation of the render call - public: virtual void Render() override; - - /// \brief Set the far clip distance - /// \param[in] _far far clip distance - public: virtual void SetFarClipPlane(const double _far) override; - - /// \brief Set the near clip distance - /// \param[in] _near Near clip distance - public: virtual void SetNearClipPlane(const double _near) override; - - /// \brief Get the near clip distance - /// \return Near clip distance. A value of zero is returned if the - /// ogre camera has not been created. - public: double NearClipPlane() const override; - - /// \brief Get the far clip distance - /// \return Far clip distance. A value of zero is returned if the - /// ogre camera has not been created. - public: double FarClipPlane() const override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Update a render target - /// \param[in] _target Render target to update - /// \param[in] _material Material to use - /// \param[in] _matName Material name - protected: void UpdateRenderTarget(OgreRenderTexturePtr _target, - Ogre::Material *_material, - const std::string &_matName); - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Limit field of view taking care of using a valid value for - /// an OGRE camera. - /// \param[in] _fov expected field of view - /// \return valid field of view - protected: static double LimitFOV(const double _fov); - - /// \brief Create the camera. - protected: void CreateCamera(); - - /// \brief Create point cloud texture. This stores xyz rgb data - private: void CreatePointCloudTexture(); - - /// \brief Communicates that a frams was rendered - protected: bool newData = false; - - protected: bool captureData = false; - - /// \brief Pointer to the depth texture - protected: OgreRenderTexturePtr depthTexture; - - /// \brief Pointer to the depth viewport - protected: Ogre::Viewport *depthViewport = nullptr; - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera; - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - private: friend class OgreScene; - private: friend class OgreRayQuery; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh b/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh index 09dc6f265..1f909473b 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDynamicLines.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,99 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_OGRE_OGREDYNAMICLINES_HH_ -#define IGNITION_RENDERING_OGRE_OGREDYNAMICLINES_HH_ + */ -#include -#include -#include -#include - -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreDynamicRenderable.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /// \brief Forward declaration - class OgreDynamicLinesPrivate; - - /* \class OgreDynamicLines OgreDynamicLines.hh \ - * ignition/rendering/ogre/OgreDynamicLines.hh - */ - /// \brief Class for drawing lines that can change - class IGNITION_RENDERING_OGRE_VISIBLE OgreDynamicLines : - public OgreDynamicRenderable - { - /// \brief Constructor - /// \param[in] _opType The type of Line - public: explicit OgreDynamicLines( - MarkerType _opType = MT_LINE_STRIP); - - /// \brief Destructor - public: virtual ~OgreDynamicLines(); - - /// \brief Add a point to the point list - /// \param[in] _pt ignition::math::Vector3d point - /// \param[in] _color ignition::math::Color Point color - public: void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color = ignition::math::Color::White); - - /// \brief Add a point to the point list. - /// \param[in] _x X position - /// \param[in] _y Y position - /// \param[in] _z Z position - /// \param[in] _color ignition::math::Color Point color - public: void AddPoint(const double _x, const double _y, const double _z, - const ignition::math::Color &_color = ignition::math::Color::White); - - /// \brief Change the location of an existing point in the point list - /// \param[in] _index Index of the point to set - /// \param[in] _value ignition::math::Vector3d value to set the point to - public: void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value); - - /// \brief Change the color of an existing point in the point list - /// \param[in] _index Index of the point to set - /// \param[in] _color ignition::math::Color Pixelcolor color to set the - /// point to - public: void SetColor(unsigned int _index, - const ignition::math::Color &_color); - - /// \brief Return the location of an existing point in the point list - /// \param[in] _index Number of the point to return - /// \return ignition::math::Vector3d value of the point. A vector of - /// [ignition::math::INF_D, ignition::math::INF_D, ignition::math::INF_D] - /// is returned when then the _index is out of bounds. - /// ignition::math::INF_D==std::numeric_limits::infinity() - public: ignition::math::Vector3d Point(unsigned int _index) const; - - /// \brief Return the total number of points in the point list - /// \return Number of points - public: unsigned int PointCount() const; - - /// \brief Remove all points from the point list - public: void Clear(); - - /// \brief Call this to update the hardware buffer after making changes. - public: void Update(); - - /// \brief Implementation DynamicRenderable, - /// creates a simple vertex-only decl - private: virtual void CreateVertexDeclaration(); - - /// \brief Implementation DynamicRenderable, pushes point - /// list out to hardware memory - private: virtual void FillHardwareBuffers(); - - /// \brief private implementation - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh b/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh index f27132405..3c800846e 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDynamicRenderable.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,99 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_OGRE_OGREDYNAMICRENDERABLE_HH_ -#define IGNITION_RENDERING_OGRE_OGREDYNAMICRENDERABLE_HH_ + */ -#include -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/Marker.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - /* \class OgreDynamicRenderable OgreDynamicRenderable.hh \ - * ignition/rendering/ogre/OgreDynamicRenderable.hh - */ - /// \brief Abstract base class providing mechanisms for dynamically - /// growing hardware buffers. - class IGNITION_RENDERING_OGRE_VISIBLE OgreDynamicRenderable : - public Ogre::SimpleRenderable - { - /// \brief Constructor - public: OgreDynamicRenderable(); - - /// \brief Virtual destructor - public: virtual ~OgreDynamicRenderable(); - - /// \brief Initializes the dynamic renderable. - /// \remarks This function should only be called once. It initializes the - /// render operation, and calls the abstract function - /// CreateVertexDeclaration(). - /// \param[in] _opType The type of render operation to perform. - /// \param[in] _useIndices Specifies whether to use indices to - /// determine the vertices to use as input. - public: void Init(MarkerType _opType, bool _useIndices = false); - - /// \brief Set the render operation type - /// \param[in] _opType The type of render operation to perform. - public: void SetOperationType(MarkerType _opType); - - /// \brief Get the render operation type - /// \return The render operation type. - public: MarkerType OperationType() const; - - /// \brief Implementation of Ogre::SimpleRenderable - /// \return The bounding radius - public: virtual Ogre::Real getBoundingRadius() const; - - /// \brief Implementation of Ogre::SimpleRenderable - /// \param[in] _cam Pointer to the Ogre camera that views the - /// renderable. - /// \return The squared depth in the Camera's view - public: virtual Ogre::Real getSquaredViewDepth( - const Ogre::Camera *_cam) const; - - /// \brief Creates the vertex declaration. @remarks Override and set - /// mRenderOp.vertexData->vertexDeclaration here. mRenderOp.vertexData - /// will be created for you before this method is called. - protected: virtual void CreateVertexDeclaration() = 0; - - /// \brief Prepares the hardware buffers for the requested vertex and - /// index counts. - /// \remarks - /// This function must be called before locking the buffers in - /// fillHardwareBuffers(). It guarantees that the hardware buffers - /// are large enough to hold at least the requested number of - /// vertices and indices (if using indices). The buffers are - /// possibly reallocated to achieve this. - /// \par The vertex and index count in the render operation are set to - /// the values of vertexCount and indexCount respectively. - /// \param[in] _vertexCount The number of vertices the buffer must hold. - /// \param[in] _indexCount The number of indices the buffer must hold. - /// This parameter is ignored if not using indices. - protected: void PrepareHardwareBuffers(size_t _vertexCount, - size_t _indexCount); - - /// \brief Fills the hardware vertex and index buffers with data. - /// @remarks - /// This function must call prepareHardwareBuffers() before locking the - /// buffers to ensure the they are large enough for the data to be - /// written. Afterwards the vertex and index buffers (if using indices) - /// can be locked, and data can be written to them. - protected: virtual void FillHardwareBuffers() = 0; - - /// \brief Maximum capacity of the currently allocated vertex buffer. - protected: size_t vertexBufferCapacity = 0; - - /// \brief Maximum capacity of the currently allocated index buffer. - protected: size_t indexBufferCapacity = 0; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh b/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh index 93c5ddee3..35c88ee26 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,59 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREGAUSSIANNOISEPASS_HH_ -#define IGNITION_RENDERING_OGRE_OGREGAUSSIANNOISEPASS_HH_ -#include - -#include - -#include "ignition/rendering/base/BaseGaussianNoisePass.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderPass.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class GaussianNoiseCompositorListener; - - /* \class OgreGaussianNoisePass OgreGaussianNoisePass.hh \ - * ignition/rendering/ogre/OgreGaussianNoisePass.hh - */ - /// \brief Ogre implementation of the GaussianNoisePass class - class IGNITION_RENDERING_OGRE_VISIBLE OgreGaussianNoisePass : - public BaseGaussianNoisePass - { - /// \brief Constructor - public: OgreGaussianNoisePass(); - - /// \brief Destructor - public: virtual ~OgreGaussianNoisePass(); - - // Documentation inherited - public: void PreRender() override; - - // Documentation inherited - public: void Destroy() override; - - // Documentation inherited - public: void CreateRenderPass() override; - - /// \brief Gaussian noise compositor. - public: Ogre::CompositorInstance *gaussianNoiseInstance = nullptr; - - /// \brief Gaussian noise compositor listener - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - public: std::shared_ptr - gaussianNoiseCompositorListener; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreGeometry.hh b/ogre/include/ignition/rendering/ogre/OgreGeometry.hh index 2700d3c97..263043a72 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGeometry.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGeometry.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,47 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREGEOMETRY_HH_ -#define IGNITION_RENDERING_OGRE_OGREGEOMETRY_HH_ -#include - -#include "ignition/rendering/base/BaseGeometry.hh" -#include "ignition/rendering/ogre/OgreObject.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreGeometry : - public BaseGeometry - { - protected: OgreGeometry(); - - public: virtual ~OgreGeometry(); - - public: virtual bool HasParent() const; - - public: virtual VisualPtr Parent() const; - - public: virtual Ogre::MovableObject *OgreObject() const = 0; - - protected: virtual void SetParent(OgreVisualPtr _parent); - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: OgreVisualPtr parent; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - private: friend class OgreVisual; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh b/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh index 2fdb75e52..6ecdbe616 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGizmoVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREGIZMOVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREGIZMOVISUAL_HH_ -#include "ignition/rendering/base/BaseGizmoVisual.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreGizmoVisual : - public BaseGizmoVisual - { - /// \brief Constructor - protected: OgreGizmoVisual(); - - /// \brief Destructor - public: virtual ~OgreGizmoVisual(); - - /// \brief Only the ogre scene can instanstiate this class - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh b/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh index fa39bee88..3a7cfcc2b 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,185 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREGPURAYS_HH_ -#define IGNITION_RENDERING_OGRE_OGREGPURAYS_HH_ - -#include -#include -#include -#include - -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/base/BaseGpuRays.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreSensor.hh" - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class OgreGpuRaysPrivate; - - /** \class OgreGpuRays OgreGpuRays.hh\ - * rendering/ogre/OgreGpuRays.hh - **/ - /// \brief Gpu Rays used to render depth data into an image buffer - class IGNITION_RENDERING_OGRE_VISIBLE OgreGpuRays : - public BaseGpuRays, public Ogre::RenderObjectListener - { - /// \brief Constructor - protected: OgreGpuRays(); - - /// \brief Destructor - public: virtual ~OgreGpuRays(); - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Create dummy render texture. Needed to satisfy inheritance - public: virtual void CreateRenderTexture(); - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void PostRender() override; - - // Documentation inherited - public: virtual const float *Data() const override; - - // Documentation inherited. - public: virtual void Copy(float *_data) override; - - // Documentation inherited. - public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( - std::function _subscriber) override; - - // Documentation inherited. - public: virtual RenderTargetPtr RenderTarget() const override; - - /// \internal - /// \brief Implementation of Ogre::RenderObjectListener - public: virtual void notifyRenderSingleObject(Ogre::Renderable *_rend, - const Ogre::Pass *_p, const Ogre::AutoParamDataSource *_s, - const Ogre::LightList *_ll, bool _supp) override; - - /// \brief Set the number of samples in the width and height for the - /// first pass texture. - /// \param[in] _w Number of samples in the horizontal sweep - /// \param[in] _h Number of samples in the vertical sweep - private: virtual void Set1stTextureSize(const unsigned int _w, - const unsigned int _h = 1); - - /// \brief Set the number of samples in the width and height for the - /// second pass texture. - /// \param[in] _w Number of samples in the horizontal sweep - /// \param[in] _h Number of samples in the vertical sweep - private: virtual void SetRangeCount(const unsigned int _w, - const unsigned int _h = 1); - - // Documentation inherited. - private: virtual void Render() override; - - /// \brief Configure cameras. - private: void ConfigureCameras(); - - /// \brief Create a mesh. - private: void CreateMesh(); - - /// \brief Create a canvas. - private: void CreateCanvas(); - - /// \brief Create an ortho camera. - private: void CreateOrthoCam(); - - /// \brief Create an ortho camera. - private: void CreateCamera(); - - /// \brief Create the texture which is used to render gpu rays data. - private: virtual void CreateGpuRaysTextures(); - - /// \brief Builds scaled Orthogonal Matrix from parameters. - /// \param[in] _left Left clip. - /// \param[in] _right Right clip. - /// \param[in] _bottom Bottom clip. - /// \param[in] _top Top clip. - /// \param[in] _near Near clip. - /// \param[in] _far Far clip. - /// \return The Scaled orthogonal Ogre::Matrix4 - private: Ogre::Matrix4 BuildScaledOrthoMatrix(const float _left, - const float _right, const float _bottom, const float _top, - const float _near, const float _far); - - private: void UpdateRenderTarget(Ogre::RenderTarget *_target, - Ogre::Material *_material, - Ogre::Camera *_cam, - const bool _updateTex); - - /// \brief Get Cos Horz field-of-view - /// \return 2 * atan(tan(this->hfov/2) / cos(this->vfov/2)) - private: virtual double CosHorzFOV() const; - - /// \brief Set the Cos Horz FOV - /// \param[in] _chfov Cos Horz FOV - private: virtual void SetCosHorzFOV(const double _chfov); - - /// \brief Get Cos Vert field-of-view - /// \return 2 * atan(tan(this->vfov/2) / cos(this->hfov/2)) - private: virtual double CosVertFOV() const; - - /// \brief Set the Cos Horz FOV - /// \param[in] _cvfov Cos Horz FOV - private: virtual void SetCosVertFOV(const double _cvfov); - - /// \brief Get (horizontal_max_angle + horizontal_min_angle) * 0.5 - /// \return (horizontal_max_angle + horizontal_min_angle) * 0.5 - private: virtual double HorzHalfAngle() const; - - /// \brief Get (vertical_max_angle + vertical_min_angle) * 0.5 - /// \return (vertical_max_angle + vertical_min_angle) * 0.5 - private: virtual double VertHalfAngle() const; - - /// \brief Set the horizontal half angle - /// \param[in] _angle horizontal half angle - private: virtual void SetHorzHalfAngle(const double _angle); - - /// \brief Set the vertical half angle - /// \param[in] _angle vertical half angle - private: virtual void SetVertHalfAngle(const double _angle); - - /// \internal - /// \brief Pointer to private data. - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreGrid.hh b/ogre/include/ignition/rendering/ogre/OgreGrid.hh index b6f188b56..13e5c30cb 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGrid.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGrid.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,69 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREGRID_HH_ -#define IGNITION_RENDERING_OGRE_OGREGRID_HH_ - -#include -#include "ignition/rendering/base/BaseGrid.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class OgreGridPrivate; - - /// \brief Ogre implementation of a grid geometry. - class IGNITION_RENDERING_OGRE_VISIBLE OgreGrid - : public BaseGrid - { - /// \brief Constructor - protected: OgreGrid(); - - /// \brief Destructor - public: virtual ~OgreGrid(); - - // Documentation inherited. - public: virtual void Init(); - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const; - - // Documentation inherited. - public: virtual void PreRender(); - - // Documentation inherited. - public: virtual MaterialPtr Material() const; - - // Documentation inherited. - public: virtual void SetMaterial(MaterialPtr _material, bool _unique); - - /// \brief Set material to grid geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); - - /// \brief Create the grid geometry in ogre - private: void Create(); - - /// \brief Grid should only be created by scene. - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreIncludes.hh b/ogre/include/ignition/rendering/ogre/OgreIncludes.hh index cd9568f1c..4cbddfd32 100644 --- a/ogre/include/ignition/rendering/ogre/OgreIncludes.hh +++ b/ogre/include/ignition/rendering/ogre/OgreIncludes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,79 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREINCLUDES_HH_ -#define IGNITION_RENDERING_OGRE_OGREINCLUDES_HH_ -#if defined(__clang__) - // This prevents some deprecation #warning messages on OSX 10.9 - #pragma clang diagnostic ignored "-W#warnings" -#elif defined(__GNUC__) || defined(__GNUG__) - #pragma GCC system_header -#elif defined(_MSC_VER) - // This disables warning messages for OGRE - #pragma warning(push) - #pragma warning(disable: 4275) - #pragma warning(disable: 4005) -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#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 - -#if defined(_MSC_VER) - #pragma warning(pop) -#endif - -#endif // IGNITION_RENDERING_OGRE_OGREINCLUDES_HH_ +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreLight.hh b/ogre/include/ignition/rendering/ogre/OgreLight.hh index d8db210b1..50f9315f1 100644 --- a/ogre/include/ignition/rendering/ogre/OgreLight.hh +++ b/ogre/include/ignition/rendering/ogre/OgreLight.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,132 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRELIGHT_HH_ -#define IGNITION_RENDERING_OGRE_OGRELIGHT_HH_ -#include "ignition/rendering/base/BaseLight.hh" -#include "ignition/rendering/ogre/OgreNode.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -namespace Ogre -{ - class Light; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreLight : - public BaseLight - { - protected: OgreLight(); - - public: virtual ~OgreLight(); - - public: virtual math::Color DiffuseColor() const; - - public: virtual void SetDiffuseColor(const math::Color &_color); - - public: virtual math::Color SpecularColor() const; - - public: virtual void SetSpecularColor(const 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); - - public: virtual Ogre::Light *Light() const; - - public: virtual void Destroy(); - - protected: virtual void Init(); - - private: void CreateLight(); - - private: void UpdateAttenuation(); - - protected: double attenConstant; - - protected: double attenLinear; - - protected: double attenQuadratic; - - protected: double attenRange; - - protected: Ogre::Light *ogreLight; - - protected: Ogre::Light::LightTypes ogreLightType; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreDirectionalLight : - public BaseDirectionalLight - { - protected: OgreDirectionalLight(); - - public: virtual ~OgreDirectionalLight(); - - public: virtual math::Vector3d Direction() const; - - public: virtual void SetDirection(const math::Vector3d &_dir); - - private: friend class OgreScene; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgrePointLight : - public BasePointLight - { - protected: OgrePointLight(); - - public: virtual ~OgrePointLight(); - - private: friend class OgreScene; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreSpotLight : - public BaseSpotLight - { - protected: OgreSpotLight(); - - public: virtual ~OgreSpotLight(); - - public: virtual math::Vector3d Direction() const; - - public: virtual void SetDirection(const math::Vector3d &_dir); - - public: virtual math::Angle InnerAngle() const; - - public: virtual void SetInnerAngle(const math::Angle &_angle); - - public: virtual math::Angle OuterAngle() const; - - public: virtual void SetOuterAngle(const math::Angle &_angle); - - public: virtual double Falloff() const; - - public: virtual void SetFalloff(double _falloff); - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreMarker.hh b/ogre/include/ignition/rendering/ogre/OgreMarker.hh index ef98c16c9..2eb74ea3f 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMarker.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMarker.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,81 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREMARKER_HH_ -#define IGNITION_RENDERING_OGRE_OGREMARKER_HH_ - -#include -#include "ignition/rendering/base/BaseMarker.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class OgreMarkerPrivate; - - /// \brief Ogre implementation of a marker geometry. - class IGNITION_RENDERING_OGRE_VISIBLE OgreMarker - : public BaseMarker - { - /// \brief Constructor - protected: OgreMarker(); - - /// \brief Destructor - public: virtual ~OgreMarker(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial( - MaterialPtr _material, bool _unique) override; - - // Documentation inherited - public: virtual void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value) override; - - // Documentation inherited - public: virtual void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color) override; - - // Documentation inherited - public: virtual void ClearPoints() override; - - // Documentation inherited - public: virtual void SetType(const MarkerType _markerType) override; - - // Documentation inherited - public: virtual MarkerType Type() const override; - - /// \brief Create the marker geometry in ogre - private: void Create(); - - /// \brief Marker should only be created by scene. - private: friend class OgreScene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreMaterial.hh b/ogre/include/ignition/rendering/ogre/OgreMaterial.hh index d9cffa5e2..8cbfc0fce 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMaterial.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMaterial.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,220 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREMATERIAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREMATERIAL_HH_ -#include - -#include - -#include "ignition/rendering/base/BaseMaterial.hh" -#include "ignition/rendering/ogre/OgreObject.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // TODO(anyone): use a better way to find shader configurations - const std::string depth_vertex_shader_file = - "depth_vertex_shader.glsl"; - const std::string depth_fragment_shader_file = - "depth_fragment_shader.glsl"; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterial : - public BaseMaterial - { - protected: OgreMaterial(); - - public: virtual ~OgreMaterial(); - - // Documentation inherited - public: virtual void Destroy() override; - - public: virtual bool LightingEnabled() const override; - - public: virtual void SetLightingEnabled(const bool _enabled) override; - - // Documentation inherited - public: virtual bool DepthCheckEnabled() const override; - - // Documentation inherited - public: virtual void SetDepthCheckEnabled(bool _enabled) override; - - // Documentation inherited - public: virtual bool DepthWriteEnabled() const override; - - // Documentation inherited - public: virtual void SetDepthWriteEnabled(bool _enabled) override; - - public: virtual math::Color Ambient() const override; - - public: virtual void SetAmbient(const math::Color &_color) override; - - public: virtual math::Color Diffuse() const override; - - public: virtual void SetDiffuse(const math::Color &_color) override; - - public: virtual math::Color Specular() const override; - - public: virtual void SetSpecular(const math::Color &_color) override; - - public: virtual math::Color Emissive() const override; - - public: virtual void SetEmissive(const math::Color &_color) override; - - public: virtual double Shininess() const override; - - public: virtual void SetShininess(const double _shininess) override; - - public: virtual double Transparency() const override; - - public: virtual void SetTransparency(const double _transparency) - override; - - 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; - - public: virtual bool ReflectionEnabled() const override; - - public: virtual void SetReflectionEnabled(const bool _enabled) override; - - public: virtual bool HasTexture() const override; - - public: virtual std::string Texture() const override; - - // Documentation inherited. - public: virtual void SetTexture(const std::string &_texture) override; - - public: virtual void ClearTexture() override; - - public: virtual bool HasNormalMap() const override; - - public: virtual std::string NormalMap() const override; - - // Documentation inherited. - public: virtual void SetNormalMap(const std::string &_normalMap) override; - - public: virtual void ClearNormalMap() override; - - public: virtual enum ShaderType ShaderType() const override; - - // Documentation inherited. - public: virtual void SetShaderType(enum ShaderType _type) override; - - public: virtual Ogre::MaterialPtr Material() const; - - // Documentation inherited. - // \sa Material::Set3DMaterial() - public: virtual void SetDepthMaterial(const double far, - const double near) override; - - // Documentation inherited. - // \sa Material::SetVertexShader(const std::string &) - public: virtual void SetVertexShader(const std::string &_path) override; - - // Documentation inherited. - // \sa Material::VertexShader() const - public: virtual std::string VertexShader() const override; - - // Documentation inherited. - // \sa Material::VertexShaderParams() - public: virtual ShaderParamsPtr VertexShaderParams() override; - - // Documentation inherited. - // \sa Material::SetFragmentShader(const std::string &) - public: virtual void SetFragmentShader(const std::string &_path) - override; - - // Documentation inherited. - // \sa Material::FragmentShader() const - public: virtual std::string FragmentShader() const override; - - // Documentation inherited. - // \sa Material::FragmentShaderParams() - public: virtual ShaderParamsPtr FragmentShaderParams() override; - - // Documentation inherited. - // \sa BaseMaterial::PreRender() - public: virtual void PreRender() override; - - protected: virtual void LoadOneImage(const std::string &_name, - Ogre::Image &_image); - - /// \brief Set the texture for this material - /// \param[in] _texture Name of the texture. - protected: virtual void SetTextureImpl(const std::string &_texture); - - protected: virtual Ogre::TexturePtr Texture(const std::string &_name); - - protected: virtual Ogre::TexturePtr CreateTexture( - const std::string &_name); - - protected: virtual void UpdateTransparency(); - - protected: virtual void UpdateColorOperation(); - - /// \brief bind shader parameters that have changed - protected: void UpdateShaderParams(); - - /// \brief Transfer params from ign-rendering type to ogre type - /// \param[in] _params ignition rendering params - /// \param[out] _ogreParams ogre type for holding params - protected: void UpdateShaderParams(ConstShaderParamsPtr _params, - Ogre::GpuProgramParametersSharedPtr _ogreParams); - - protected: virtual void Init() override; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: Ogre::MaterialPtr ogreMaterial; - - protected: Ogre::Technique *ogreTechnique = nullptr; - - protected: Ogre::Pass *ogrePass = nullptr; - - protected: Ogre::TextureUnitState *ogreTexState = nullptr; - - protected: Ogre::String ogreGroup; - -#if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR <= 7 - protected: math::Color emissiveColor; -#endif - protected: std::string textureName; - - protected: std::string normalMapName; - - protected: enum ShaderType shaderType = ST_PIXEL; - - /// \brief Path to vertex shader program. - protected: std::string vertexShaderPath; - - /// \brief Path to fragment shader program. - protected: std::string fragmentShaderPath; - - /// \brief Parameters to be bound to the vertex shader - protected: ShaderParamsPtr vertexShaderParams; - - /// \brief Parameters to be bound to the fragment shader - protected: ShaderParamsPtr fragmentShaderParams; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh b/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh index b893dd058..239381654 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,115 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGREMATERIALSWITCHER_HH_ -#define IGNITION_RENDERING_OGRE_OGREMATERIALSWITCHER_HH_ - -#include -#include - -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations - class OgreSelectionBuffer; - - /// \brief Helper class to assign unique colors to renderables - class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterialSwitcher : -// Ogre::MaterialManager::Listener isn't a dll-interface class, this may cause -// issues -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable:4275) -#endif - public Ogre::MaterialManager::Listener, -#ifdef _MSC_VER - #pragma warning(pop) -#endif - Ogre::RenderTargetListener - { - /// \brief Constructor - public: OgreMaterialSwitcher(); - - /// \brief Destructor - public: ~OgreMaterialSwitcher(); - - /// \brief Get the entity with a specific color - /// \param[in] _color The entity's color. - public: std::string EntityName( - const ignition::math::Color &_color) const; - - /// \brief Reset the color value incrementor - public: void Reset(); - - /// \brief Ogre callback that assigns colors to new renderables when the - /// requested scheme is not found - /// \param[in] _schemeIndex Index of scheme requested - /// \param[in] _schemeName Name of scheme requested - /// \param[in] _originalMaterial Orignal material that does not contain - /// the requested scheme - /// \param[in] _lodIndex The material level-of-detail - /// \param[in] _rend Pointer to the Ogre::Renderable object requesting - /// the use of the techinique - /// \return The Ogre material technique to use when scheme is not found. - public: virtual Ogre::Technique *handleSchemeNotFound( - uint16_t _schemeIndex, const Ogre::String &_schemeName, - Ogre::Material *_originalMaterial, uint16_t _lodIndex, - const Ogre::Renderable *_rend); - - /// \brief Ogre's pre render update callback - /// \param[in] _evt Ogre render target event containing information about - /// the source render target. - public: virtual void preRenderTargetUpdate( - const Ogre::RenderTargetEvent &_evt); - - /// \brief Ogre's post render update callback - /// \param[in] _evt Ogre render target event containing information about - /// the source render target. - public: virtual void postRenderTargetUpdate( - const Ogre::RenderTargetEvent &_evt); - - /// \brief Current unique color value - private: ignition::math::Color currentColor; - - /// \brief last entity assigned an unique color value - private: std::string lastEntity; - - /// \brief last technique assigned to an entity. - private: Ogre::Technique *lastTechnique = nullptr; - - /// \brief Color dictionary that maps the unique color value to - /// renderable name - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::map colorDict; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief Increment unique color value that will be assigned to the - /// next renderable - private: void NextColor(); - - /// \brief Selection Buffer class that make use of this class for - /// selecting entitiies - public: friend class OgreSelectionBuffer; - - /// \brief Plain material technique - private: Ogre::Technique *plainTechnique = nullptr; - - /// \brief Overlay material technique - private: Ogre::Technique *overlayTechnique = nullptr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreMesh.hh b/ogre/include/ignition/rendering/ogre/OgreMesh.hh index cb4b50998..157be78c8 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMesh.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMesh.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,88 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREMESH_HH_ -#define IGNITION_RENDERING_OGRE_OGREMESH_HH_ -#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 { - // - 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; - - 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; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreSubMesh : - public BaseSubMesh - { - protected: OgreSubMesh(); - - public: virtual ~OgreSubMesh(); - - public: virtual Ogre::SubEntity *OgreSubEntity() const; - - public: virtual void Destroy() override; - - // Documentation inherited - protected: virtual void SetMaterialImpl(MaterialPtr _material) override; - - protected: virtual void Init() override; - - protected: Ogre::SubEntity *ogreSubEntity; - - private: friend class OgreScene; - - private: friend class OgreSubMeshStoreFactory; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh b/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh index ceecd1916..9427ded93 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMeshFactory.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,77 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREMESHFACTORY_HH_ -#define IGNITION_RENDERING_OGRE_OGREMESHFACTORY_HH_ -#include -#include - -#include "ignition/rendering/MeshDescriptor.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace Ogre -{ - class Entity; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreMeshFactory - { - public: explicit OgreMeshFactory(OgreScenePtr _scene); - - public: virtual ~OgreMeshFactory(); - - public: virtual OgreMeshPtr Create(const MeshDescriptor &_desc); - - protected: virtual Ogre::Entity *OgreEntity( - const MeshDescriptor &_desc); - - protected: virtual bool Load(const MeshDescriptor &_desc); - - protected: virtual bool IsLoaded(const MeshDescriptor &_desc); - - protected: virtual bool LoadImpl(const MeshDescriptor &_desc); - - protected: virtual std::string MeshName(const MeshDescriptor &_desc); - - protected: virtual bool Validate(const MeshDescriptor &_desc); - - protected: OgreScenePtr scene; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreSubMeshStoreFactory - { - typedef std::vector NameList; - - public: OgreSubMeshStoreFactory(OgreScenePtr _scene, - Ogre::Entity *_entity); - - public: virtual ~OgreSubMeshStoreFactory(); - - public: virtual OgreSubMeshStorePtr Create(); - - protected: virtual OgreSubMeshPtr CreateSubMesh(unsigned int _index); - - protected: virtual void CreateNameList(); - - protected: virtual void PopulateDefaultNames(); - - protected: virtual void PopulateGivenNames(); - - protected: OgreScenePtr scene; - - protected: Ogre::Entity *ogreEntity; - - protected: NameList names; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreNode.hh b/ogre/include/ignition/rendering/ogre/OgreNode.hh index a68e5a12f..1a912d5ec 100644 --- a/ogre/include/ignition/rendering/ogre/OgreNode.hh +++ b/ogre/include/ignition/rendering/ogre/OgreNode.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,95 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRENODE_HH_ -#define IGNITION_RENDERING_OGRE_OGRENODE_HH_ -#include - -#include "ignition/rendering/base/BaseNode.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreObject.hh" - -namespace Ogre -{ - class SceneNode; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreNode : - public BaseNode - { - protected: OgreNode(); - - public: virtual ~OgreNode(); - - public: virtual bool HasParent() const override; - - public: virtual NodePtr Parent() const override; - - public: virtual Ogre::SceneNode *Node() const; - - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual math::Vector3d LocalScale() const override; - - // Documentation inherited. - public: virtual bool InheritScale() const override; - - // Documentation inherited. - public: virtual void SetInheritScale(bool _inherit) override; - - // Documentation inherited. - protected: virtual void SetLocalScaleImpl( - const math::Vector3d &_scale) override; - - protected: virtual NodeStorePtr Children() const override; - - protected: virtual bool AttachChild(NodePtr _child) override; - - protected: virtual bool DetachChild(NodePtr _child) override; - - protected: virtual math::Pose3d RawLocalPose() const override; - - protected: virtual void SetRawLocalPose(const math::Pose3d &_Pose3d) - override; - - protected: virtual math::Vector3d RawLocalPosition() const; - - protected: virtual void SetRawLocalPosition( - const math::Vector3d &_position); - - protected: virtual math::Quaterniond RawLocalRotation() const; - - protected: virtual void SetRawLocalRotation( - const math::Quaterniond &_rotation); - - protected: virtual void SetParent(OgreNodePtr _parent); - - protected: virtual void Load() override; - - protected: virtual void Init() override; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: OgreNodePtr parent; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - protected: Ogre::SceneNode *ogreNode = nullptr; - - protected: OgreNodeStorePtr children; - - private: OgreNodePtr SharedThis(); - - // TODO(anyone): remove the need for a visual friend class - private: friend class OgreVisual; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreObject.hh b/ogre/include/ignition/rendering/ogre/OgreObject.hh index e8d691516..475e12b5a 100644 --- a/ogre/include/ignition/rendering/ogre/OgreObject.hh +++ b/ogre/include/ignition/rendering/ogre/OgreObject.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,37 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREOBJECT_HH_ -#define IGNITION_RENDERING_OGRE_OGREOBJECT_HH_ -#include - -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreObject : - public BaseObject - { - protected: OgreObject(); - - public: virtual ~OgreObject(); - - public: virtual ScenePtr Scene() const; - - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - protected: OgreScenePtr scene; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh b/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh index 56450b8fc..06d2a35ad 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,168 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERTSHADERSYSTEM_HH_ -#define IGNITION_RENDERING_OGRE_OGRERTSHADERSYSTEM_HH_ -#include -#include - -#include -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreRTShaderSystemPrivate; - - /// \addtogroup ign_rendering - /// \{ - - /// \class OgreRTShaderSystem OgreRTShaderSystem.hh rendering/rendering.hh - /// \brief Implements Ogre's Run-Time Shader system. - /// - /// This class allows Gazebo to generate per-pixel shaders for every - /// material at run-time. - class IGNITION_RENDERING_OGRE_VISIBLE OgreRTShaderSystem : - public common::SingletonT - { - /// \enum LightingModel - /// \brief The type of lighting - public: enum LightingModel - { - /// \brief Per-Vertex lighting: best performance. - SSLM_PerVertexLighting, - /// \brief Per-Pixel lighting: best look. - SSLM_PerPixelLighting, - /// \brief Normal Map lighting: lighting calculations have - /// been stored in a light map (texture) using tangent space. - SSLM_NormalMapLightingTangentSpace, - /// \brief Normal Map lighting: lighting calculations have - /// been stored in a light map (texture) using object space. - SSLM_NormalMapLightingObjectSpace - }; - - /// \brief Constructor. - private: OgreRTShaderSystem(); - - /// \brief Destructor. - private: virtual ~OgreRTShaderSystem(); - - /// \brief Initialize the run time shader system. - /// \return True if the run time shader system is initialized - /// successfully. - public: bool Init(); - - /// \brief Finalize the shader system - public: void Fini(); - - /// \brief Clear the shader system - public: void Clear(); - - /// \brief Add a scene manager - /// \param[in] _scene The scene to process - public: void AddScene(OgreScenePtr _scene); - - /// \brief Remove a scene - /// \param[in] _scene The scene to remove - public: void RemoveScene(OgreScenePtr _scene); - - /// \brief Remove a scene - /// \param[in] _scene Name of the scene to remove. - public: void RemoveScene(const std::string &_scene); - - /// \brief Update the shaders. This should not be called frequently. - public: void UpdateShaders(); - - /// \brief Set an Ogre::Entity to use RT shaders. - /// \param[in] _vis OgreSubMesh that will use the OgreRTShaderSystem. - public: void AttachEntity(OgreSubMesh *_vis); - - /// \brief Remove and entity. - /// \param[in] _vis Remove this visual. - public: void DetachEntity(OgreSubMesh *_vis); - - /// \brief Set a viewport to use shaders. - /// \param[in] _viewport The viewport to add. - /// \param[in] _scene The scene that the viewport uses. - public: static void AttachViewport(Ogre::Viewport *_viewport, - OgreScenePtr _scene); - - /// \brief Set a viewport to not use shaders. - /// \param[in] _viewport The viewport to remove. - /// \param[in] _scene The scene that the viewport uses. - public: static void DetachViewport(Ogre::Viewport *_viewport, - OgreScenePtr _scene); - - /// \brief Set the lighting model to per pixel or per vertex. - /// \param[in] _set True means to use per-pixel shaders. - public: void SetPerPixelLighting(bool _set); - - /// \brief Generate shaders for an entity - /// \param[in] _subMesh The submesh to remove shaders for. - public: void RemoveShaders(OgreSubMesh *_subMesh); - - /// \brief Generate shaders for an entity - /// \param[in] _subMesh The submesh to generate shaders for. - public: void GenerateShaders(OgreSubMesh *_subMesh); - - /// \brief Apply shadows to a scene. - /// \param[in] _scene The scene to receive shadows. - public: void ApplyShadows(OgreScenePtr _scene); - - /// \brief Remove shadows from a scene. - /// \param[in] _scene The scene to remove shadows from. - public: void RemoveShadows(OgreScenePtr _scene); - - /// \brief Get the Ogre PSSM Shadows camera setup. - /// \return The Ogre PSSM Shadows camera setup. - public: Ogre::PSSMShadowCameraSetup *PSSMShadowCameraSetup() const; - - /// \brief Get paths for the shader system - /// \param[out] _coreLibsPath Path to the core libraries. - /// \param[out] _cachePath Path to where the generated shaders are - /// stored. - private: bool Paths(std::string &_coreLibsPath, - std::string &_cachePath); - - /// \brief Set the shadow texture size. - /// \param[in] _size Size of shadow texture to set to. This must be a - /// power of 2. The default size is 1024. - /// \return True if size is set successfully, false otherwise. - public: bool SetShadowTextureSize(const unsigned int _size); - - /// \brief Get the shadow texture size. - /// \return Size of the shadow texture. The default size is 1024. - public: unsigned int ShadowTextureSize() const; - - /// \brief Get if RTShaderSystem is initialized or not - /// \return True if intialized. - public: bool IsInitialized() const; - - /// \brief Update the RT shaders. The call will only take effect if - /// shadow properties changed, e.g. texture size, or the shaders - /// have been marked dirty by UpdateShaders, e.g. when entities are - /// added. The function reapplies shadows if properties have changed, - /// and iterates through all entities added to RTShaderSystem - /// and regenerates shader programs for each entity if shaders are dirty. - /// This function is currently called by OgreScene::PreRender - /// \sa OgreScene::PreRender - public: void Update(); - - /// \brief Make the RTShader system a singleton. - private: friend class common::SingletonT; - - /// \brief Pointer to private data class - private: std::unique_ptr dataPtr; - }; - /// \} - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh b/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh index 9d766082e..9b8060d87 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRayQuery.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,70 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERAYQUERY_HH_ -#define IGNITION_RENDERING_OGRE_OGRERAYQUERY_HH_ -#include - -#include "ignition/rendering/base/BaseRayQuery.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreObject.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreRayQueryPrivate; - - /// \class OgreRayQuery OgreRayQuery.hh - /// ignition/rendering/base/OgreRayQuery.hh - /// \brief A Ray Query class used for computing ray object intersections - class IGNITION_RENDERING_OGRE_VISIBLE OgreRayQuery : - public BaseRayQuery - { - /// \brief Constructor - protected: OgreRayQuery(); - - /// \brief Destructor - public: virtual ~OgreRayQuery(); - - // Documentation inherited - public: virtual void SetFromCamera(const CameraPtr &_camera, - const math::Vector2d &_coord); - - // Documentation inherited - public: virtual RayQueryResult ClosestPoint(); - - /// \brief Get the mesh information for the given mesh. - /// \param[in] _mesh Mesh to get info about. - /// \param[out] _vertexCount Number of vertices in the mesh. - /// \param[out] _vertices Array of the vertices. - /// \param[out] _indexCount Number if indices. - /// \param[out] _indices Array of the indices. - /// \param[in] _position Position of the mesh. - /// \param[in] _orient Orientation of the mesh. - /// \param[in] _scale Scale of the mesh - // Code found in Wiki: www.ogre3d.org/wiki/index.php/RetrieveVertexData - private: void MeshInformation(const Ogre::Mesh *_mesh, - size_t &_vertexCount, - Ogre::Vector3* &_vertices, - size_t &_indexCount, - uint64_t* &_indices, - const math::Vector3d &_position, - const math::Quaterniond &_orient, - const math::Vector3d &_scale); - - /// \brief Private data pointer - private: std::unique_ptr dataPtr; - - /// \brief Pointer to friend scene class for creating ray query - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh b/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh index 6003fbc3b..8ada49d91 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,175 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERENDERENGINE_HH_ -#define IGNITION_RENDERING_OGRE_OGRERENDERENGINE_HH_ -#include -#include -#include -#include - -#include - -#include "ignition/rendering/RenderEnginePlugin.hh" -#include "ignition/rendering/base/BaseRenderEngine.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace Ogre -{ - class LogManager; - class Root; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreRenderEnginePrivate; - - /// \brief Plugin for loading ogre render engine - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderEnginePlugin : - public RenderEnginePlugin - { - /// \brief Constructor - public: OgreRenderEnginePlugin(); - - /// \brief Destructor - public: ~OgreRenderEnginePlugin() = default; - - /// \brief Get the name of the render engine loaded by this plugin. - /// \return Name of render engine - public: std::string Name() const; - - /// \brief Get a pointer to the render engine loaded by this plugin. - /// \return Render engine instance - public: RenderEngine *Engine() const; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderEngine : - public virtual BaseRenderEngine, - public common::SingletonT - { - /// \enum OgreRenderPathType - /// \brief The type of rendering path used by the rendering engine. - public: enum OgreRenderPathType - { - /// \brief No rendering is done. - NONE = 0, - /// \brief Most basic rendering, with least fidelity. - VERTEX = 1, - /// \brief Utilizes the RTT shader system. - FORWARD = 2, - /// \brief Utilizes deferred rendering. Best fidelity. - DEFERRED = 3, - /// \brief Count of the rendering path enums. - RENDER_PATH_COUNT - }; - - /// \brief Constructor - private: OgreRenderEngine(); - - public: virtual ~OgreRenderEngine(); - - public: virtual void Destroy() override; - - public: virtual bool IsEnabled() const override; - - public: virtual std::string Name() const override; - - public: OgreRenderPathType RenderPathType() const; - - public: void AddResourcePath(const std::string &_uri) override; - - public: virtual Ogre::Root *OgreRoot() const; - - public: std::string CreateRenderWindow(const std::string &_handle, - const unsigned int _width, const unsigned int _height, - const double _ratio, const unsigned int _antiAliasing); - - /// \brief Get a list of all supported FSAA levels for this render system - /// \return a list of FSAA levels - public: std::vector FSAALevels() const; - - protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual SceneStorePtr Scenes() const override; - - /// \brief Engine implementation of Load function. - /// \param[in] _params Parameters to be passed to the render engine. - /// Current accepts the following parameters and values: - /// "useCurrentGLContext" : "1" or "0". Use current OpenGL context for - /// rendering - protected: virtual bool LoadImpl( - const std::map &_params) override; - - protected: virtual bool InitImpl() override; - - private: void LoadAttempt(); - - private: void CreateLogger(); - - private: void CreateContext(); - - private: void CreateRoot(); - - private: void CreateOverlay(); - - private: void LoadPlugins(); - - private: void CreateRenderSystem(); - - private: void CreateResources(); - - private: void CreateRenderWindow(); - - private: void CheckCapabilities(); - - private: void InitAttempt(); - -#if (OGRE_VERSION >= ((1 << 16) | (9 << 8) | 0)) - /// \internal - /// \brief Get a pointer to the Ogre overlay system. - /// \return Pointer to the OGRE overlay system. - public: Ogre::OverlaySystem *OverlaySystem() const; - - private: Ogre::OverlaySystem *ogreOverlaySystem = nullptr; - -#endif - private: OgreSceneStorePtr scenes; - - private: OgreRenderPathType renderPathType; - - private: Ogre::Root *ogreRoot = nullptr; - - private: Ogre::LogManager *ogreLogManager = nullptr; - - /// \brief Paths to ogre plugins - private: std::vector ogrePaths; - -#if !defined(__APPLE__) && !defined(_WIN32) - private: void *dummyDisplay = nullptr; - - private: void *dummyContext = nullptr; -#endif - - private: uint64_t dummyWindowId = 0u; - - /// \brief True to use the current opengl context - private: bool useCurrentGLContext = false; - - private: std::unique_ptr dataPtr; - - private: friend class common::SingletonT; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh b/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh index cbfe312e9..8499a6950 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,47 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERENDERPASS_HH_ -#define IGNITION_RENDERING_OGRE_OGRERENDERPASS_HH_ -#include "ignition/rendering/base/BaseRenderPass.hh" -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \class OgreRenderPass OgreRenderPass.hh \ - * ignition/rendering/ogre/OgreRenderPass.hh - */ - /// \brief Ogre implementation of the RenderPass class - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderPass : - public BaseRenderPass - { - /// \brief Constructor - protected: OgreRenderPass(); - - /// \brief Destructor - public: virtual ~OgreRenderPass(); - - /// \brief Set the ogre camera that the render pass applies to - /// \param[in] _camera Pointer to the ogre camera. - public: virtual void SetCamera(Ogre::Camera *_camera); - - // Documentation inherited. - public: void Destroy() override; - - /// \brief Create the render pass using ogre compositor - public: virtual void CreateRenderPass(); - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera = nullptr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh index 26d18064f..19c800a2f 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTarget.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,165 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERENDERTARGET_HH_ -#define IGNITION_RENDERING_OGRE_OGRERENDERTARGET_HH_ -#include - -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/base/BaseRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreObject.hh" -#include "ignition/rendering/ogre/OgreRenderTargetMaterial.hh" - -namespace Ogre -{ - class Camera; - class RenderTarget; - class Texture; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTarget : - public virtual BaseRenderTarget - { - protected: OgreRenderTarget(); - - public: virtual ~OgreRenderTarget(); - - public: virtual unsigned int AntiAliasing() const; - - public: virtual void SetAntiAliasing(unsigned int _aa); - - public: virtual void Copy(Image &_image) const override; - - public: virtual Ogre::Camera *Camera() const; - - public: virtual void SetCamera(Ogre::Camera *_camera); - - // Documentation inherited - public: virtual math::Color BackgroundColor() const override; - - public: virtual void SetBackgroundColor(math::Color _color); - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - public: virtual void Render(); - - public: virtual void Destroy() override = 0; - - /// \brief Set a material to render on every object. This method is used - /// for special cases like the render target of a depth camera. - /// \param[in] _material The material to render - public: void SetMaterial(MaterialPtr _material); - - public: virtual Ogre::RenderTarget *RenderTarget() const = 0; - - public: Ogre::Viewport *AddViewport(Ogre::Camera *_viewport); - - public: Ogre::Viewport *Viewport(const int _viewportId) const; - - public: void SetUpdate(const bool _value); - - public: void SetAutoUpdated(const bool _value); - - 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; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTexture : - public virtual BaseRenderTexture - { - protected: OgreRenderTexture(); - - public: virtual ~OgreRenderTexture(); - - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void PostRender() override; - - // Documentation inherited. - public: virtual unsigned int GLId(); - - public: virtual void Buffer(float *buffer); - - public: virtual Ogre::RenderTarget *RenderTarget() const override; - - protected: virtual void RebuildTarget() override; - - protected: virtual void DestroyTarget(); - - protected: virtual void BuildTarget(); - - protected: Ogre::Texture *ogreTexture = nullptr; - - private: friend class OgreScene; - }; - - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderWindow : - public virtual BaseRenderWindow - { - protected: OgreRenderWindow(); - - public: virtual ~OgreRenderWindow(); - - public: virtual void Destroy(); - - protected: virtual Ogre::RenderTarget *RenderTarget() const; - - protected: virtual void RebuildTarget(); - - protected: virtual void BuildTarget(); - - protected: Ogre::RenderTarget *ogreRenderWindow = nullptr; - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh index e738438e8..e2dceb240 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,100 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRRENDERTARGETMATERIAL_HH_ -#define IGNITION_RENDERING_OGRE_OGRRENDERTARGETMATERIAL_HH_ -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/Export.hh" - -// Ogre::MaterialManager::Listener isn't a dll-interface class, this may cause -// issues -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable:4275) -#endif - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Causes all objects in a scene to be rendered with the same - /// material when rendered by a given RenderTarget. - /// \internal - /// - /// On construction it registers as an Ogre::RenderTargetListener - /// on the provided Ogre::RenderTarget, and sets the material scheme name - /// to a value that is unlikely to exist. - /// When the target is about to be rendered it adds itself as an - /// Ogre::MaterialManager::Listener. - /// Every time ogre tries to get a technique for a material it will call - /// handleSchemeNotFound which returns the first supported technique on the - /// material provided to this class's constructor. - class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTargetMaterial : - public Ogre::RenderTargetListener, - public Ogre::MaterialManager::Listener - { - /// \brief constructor - /// \param[in] _scene the scene manager responsible for rendering - /// \param[in] _renderTarget the RenderTarget this should apply to - /// \param[in] _material the material to apply to all renderables - public: OgreRenderTargetMaterial(OgreScenePtr _scene, - Ogre::RenderTarget *_renderTarget, Ogre::Material *_material); - - /// \brief destructor - public: ~OgreRenderTargetMaterial(); - - /// \brief Callback when a render target is about to be rendered - /// \param[in] _evt Ogre render target event containing information about - /// the source render target. - private: virtual void preRenderTargetUpdate( - const Ogre::RenderTargetEvent &_evt) override; - - /// \brief Callback when a render target is finisned being rendered - /// \param[in] _evt Ogre render target event containing information about - /// the source render target. - private: virtual void postRenderTargetUpdate( - const Ogre::RenderTargetEvent &_evt) override; - - /// \brief Ogre callback that assigned same material to all renderables - /// when the requested scheme is not found - /// \param[in] _schemeIndex Index of scheme requested - /// \param[in] _schemeName Name of scheme requested - /// \param[in] _originalMaterial Orignal material that does not contain - /// the requested scheme - /// \param[in] _lodIndex The material level-of-detail - /// \param[in] _rend Pointer to the Ogre::Renderable object requesting - /// the use of the techinique - /// \return The Ogre material technique to use when scheme is not found. - public: virtual Ogre::Technique *handleSchemeNotFound( - uint16_t _schemeIndex, const Ogre::String &_schemeName, - Ogre::Material *_originalMaterial, uint16_t _lodIndex, - const Ogre::Renderable *_rend) override; - - /// \brief scene manager responsible for rendering - private: OgreScenePtr scene; - - /// \brief render target that should see a uniform material - private: Ogre::RenderTarget *renderTarget; - - /// \brief material that should be applied to all objects - private: Ogre::Material *material; - - /// \brief name of the material scheme used by this applicator - private: Ogre::String schemeName; - }; - } - } -} - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh index 7a29b2169..a7984f454 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,99 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRERENDERTYPES_HH_ -#define IGNITION_RENDERING_OGRE_OGRERENDERTYPES_HH_ -#include -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class OgreArrowVisual; - class OgreAxisVisual; - class OgreCamera; - class OgreDepthCamera; - class OgreDirectionalLight; - class OgreGeometry; - class OgreGizmoVisual; - class OgreGpuRays; - class OgreGrid; - class OgreJointVisual; - class OgreLight; - class OgreMaterial; - class OgreMarker; - class OgreMesh; - class OgreMeshFactory; - class OgreNode; - class OgreObject; - 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; - - 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 OgreDepthCameraPtr; - typedef shared_ptr OgreDirectionalLightPtr; - typedef shared_ptr OgreGeometryPtr; - typedef shared_ptr OgreGizmoVisualPtr; - typedef shared_ptr OgreGpuRaysPtr; - typedef shared_ptr OgreGridPtr; - typedef shared_ptr OgreJointVisualPtr; - typedef shared_ptr OgreLightPtr; - typedef shared_ptr OgreMaterialPtr; - typedef shared_ptr OgreMarkerPtr; - typedef shared_ptr OgreMeshPtr; - typedef shared_ptr OgreMeshFactoryPtr; - typedef shared_ptr OgreNodePtr; - typedef shared_ptr OgreObjectPtr; - typedef shared_ptr OgrePointLightPtr; - typedef shared_ptr OgreRayQueryPtr; - typedef shared_ptr OgreRenderEnginePtr; - typedef shared_ptr OgreRenderTargetPtr; - typedef shared_ptr OgreRenderTexturePtr; - typedef shared_ptr OgreRenderWindowPtr; - typedef shared_ptr OgreScenePtr; - typedef shared_ptr OgreSensorPtr; - typedef shared_ptr OgreSpotLightPtr; - typedef shared_ptr OgreSubMeshPtr; - typedef shared_ptr OgreTextPtr; - typedef shared_ptr OgreVisualPtr; - typedef shared_ptr OgreSceneStorePtr; - typedef shared_ptr OgreNodeStorePtr; - typedef shared_ptr OgreLightStorePtr; - typedef shared_ptr OgreSensorStorePtr; - typedef shared_ptr OgreVisualStorePtr; - typedef shared_ptr OgreGeometryStorePtr; - typedef shared_ptr OgreSubMeshStorePtr; - typedef shared_ptr OgreMaterialMapPtr; - typedef shared_ptr OgreRenderTargetMaterialPtr; - typedef shared_ptr OgreThermalCameraPtr; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreScene.hh b/ogre/include/ignition/rendering/ogre/OgreScene.hh index 9f9ada4e6..57d7e3386 100644 --- a/ogre/include/ignition/rendering/ogre/OgreScene.hh +++ b/ogre/include/ignition/rendering/ogre/OgreScene.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,191 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRESCENE_HH_ -#define IGNITION_RENDERING_OGRE_OGRESCENE_HH_ -#include -#include -#include "ignition/rendering/base/BaseScene.hh" -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" - - -namespace Ogre -{ - class Root; - class SceneManager; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreScene : - public BaseScene - { - protected: OgreScene(unsigned int _id, const std::string &_name); - - public: virtual ~OgreScene(); - - public: virtual void Fini(); - - 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 Ogre::SceneManager *OgreSceneManager() const; - - 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( - const unsigned int _id, - const std::string &_name); - - // Documentation inherited - protected: virtual ThermalCameraPtr CreateThermalCameraImpl( - const unsigned int _id, - const std::string &_name); - - protected: virtual GpuRaysPtr CreateGpuRaysImpl( - const unsigned int _id, - const std::string &_name); - - 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); - - // Documentation inherited - protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(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); - - // Documentation inherited - protected: virtual MarkerPtr CreateMarkerImpl(unsigned int _id, - const std::string &_name); - - // Documentation inherited - protected: virtual TextPtr CreateTextImpl(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(OgreObjectPtr _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; - - private: void CreateContext(); - - private: void CreateRootVisual(); - - private: void CreateMeshFactory(); - - private: void CreateStores(); - - private: OgreScenePtr SharedThis(); - - protected: OgreVisualPtr rootVisual; - - protected: OgreMeshFactoryPtr meshFactory; - - protected: OgreLightStorePtr lights; - - protected: OgreSensorStorePtr sensors; - - protected: OgreVisualStorePtr visuals; - - protected: OgreMaterialMapPtr materials; - - protected: Ogre::Root *ogreRoot; - - protected: Ogre::SceneManager *ogreSceneManager; - - private: friend class OgreRenderEngine; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh b/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh index 51c76af25..1368dace4 100644 --- a/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh +++ b/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,76 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_OGRE_OGRESELECTIONBUFFER_HH_ -#define IGNITION_RENDERING_OGRE_OGRESELECTIONBUFFER_HH_ + */ -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace Ogre -{ - class Entity; - class RenderTarget; - class SceneManager; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreSelectionBufferPrivate; - - /// \brief Generates a selection buffer object for a given camera. - /// The selection buffer is used of entity selection. On setup, a unique - /// color is assigned to each entity. Whenever a selection request is made, - /// the selection buffer camera renders to a 1x1 sized offscreen buffer. - /// The color value of that pixel gives the identity of the entity. - class IGNITION_RENDERING_OGRE_VISIBLE OgreSelectionBuffer - { - /// \brief Constructor - /// \param[in] _cameraName Name of the camera to generate a selection - /// buffer for. - /// \param[in] _mgr Pointer to the scene manager. - public: OgreSelectionBuffer(const std::string &_cameraName, - Ogre::SceneManager *_mgr); - - /// \brief Destructor - public: ~OgreSelectionBuffer(); - - /// \brief Handle on mouse click - /// \param[in] _x X coordinate in pixels. - /// \param[in] _y Y coordinate in pixels. - /// \return Returns the Ogre entity at the coordinate. - public: Ogre::Entity *OnSelectionClick(const int _x, const int _y); - - /// \brief Debug show overlay - /// \param[in] _show True to show the selection buffer in an overlay. - public: void ShowOverlay(const bool _show); - - /// \brief Call this to update the selection buffer contents - public: void Update(); - - /// \brief Delete the render texture - private: void DeleteRTTBuffer(); - - /// \brief Create the render texture - private: void CreateRTTBuffer(); - - /// \brief Create the selection buffer offscreen render texture. - private: void CreateRTTOverlays(); - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreSensor.hh b/ogre/include/ignition/rendering/ogre/OgreSensor.hh index 6f4e6f3c1..4bb39d0b8 100644 --- a/ogre/include/ignition/rendering/ogre/OgreSensor.hh +++ b/ogre/include/ignition/rendering/ogre/OgreSensor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,26 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRESENSOR_HH_ -#define IGNITION_RENDERING_OGRE_OGRESENSOR_HH_ -#include "ignition/rendering/base/BaseSensor.hh" -#include "ignition/rendering/ogre/OgreNode.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreSensor : - public BaseSensor - { - protected: OgreSensor(); - - public: virtual ~OgreSensor(); - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreStorage.hh b/ogre/include/ignition/rendering/ogre/OgreStorage.hh index bd113c1fb..4dcf7e553 100644 --- a/ogre/include/ignition/rendering/ogre/OgreStorage.hh +++ b/ogre/include/ignition/rendering/ogre/OgreStorage.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,59 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGRESTORAGE_HH_ -#define IGNITION_RENDERING_OGRE_OGRESTORAGE_HH_ -#include -#include "ignition/rendering/base/BaseStorage.hh" - -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreLight.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreMesh.hh" -#include "ignition/rendering/ogre/OgreNode.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreSensor.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - -// armhf failed to build with this code. It can not be removed for the rest -// of arches to keep ABI but should be removed in major versions unreleased -// see https://github.com/ignitionrobotics/ign-rendering/pull/457 -#ifndef __ARM_PCS_VFP - template class BaseSceneStore; - template class BaseNodeStore; - template class BaseLightStore; - template class BaseSensorStore; - template class BaseVisualStore; - template class BaseGeometryStore; - template class BaseSubMeshStore; - template class BaseMaterialMap; -#endif - - typedef BaseSceneStore OgreSceneStore; - typedef BaseNodeStore OgreNodeStore; - typedef BaseLightStore OgreLightStore; - typedef BaseSensorStore OgreSensorStore; - typedef BaseVisualStore OgreVisualStore; - typedef BaseGeometryStore OgreGeometryStore; - typedef BaseSubMeshStore OgreSubMeshStore; - typedef BaseMaterialMap OgreMaterialMap; - - typedef std::shared_ptr OgreSceneStorePtr; - typedef std::shared_ptr OgreNodeStorePtr; - typedef std::shared_ptr OgreLightStorePtr; - typedef std::shared_ptr OgreSensorStorePtr; - typedef std::shared_ptr OgreVisualStorePtr; - typedef std::shared_ptr OgreGeometryStorePtr; - typedef std::shared_ptr OgreSubMeshStorePtr; - typedef std::shared_ptr OgreMaterialMapPtr; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreText.hh b/ogre/include/ignition/rendering/ogre/OgreText.hh index 61511d5a0..6bca24fdf 100644 --- a/ogre/include/ignition/rendering/ogre/OgreText.hh +++ b/ogre/include/ignition/rendering/ogre/OgreText.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,98 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGRETEXT_HH_ -#define IGNITION_RENDERING_OGRE_OGRETEXT_HH_ - -#include -#include - -#include -#include - -#include "ignition/rendering/base/BaseText.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class OgreMovableText; - class OgreTextPrivate; - - /// \brief Ogre implementation of text geometry - class IGNITION_RENDERING_OGRE_VISIBLE OgreText - : public BaseText - { - /// \brief Constructor - protected: OgreText(); - - /// \brief Destructor - public: virtual ~OgreText(); - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual Ogre::MovableObject *OgreObject() const override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial(MaterialPtr _material, bool _unique) - override; - - // Documentation inherited. - public: virtual void SetFontName(const std::string &_font) override; - - // Documentation inherited. - public: virtual void SetTextString(const std::string &_text) override; - - // Documentation inherited. - public: virtual void SetColor(const ignition::math::Color &_color) - override; - - // Documentation inherited. - public: virtual void SetCharHeight(const float _height) override; - - // Documentation inherited. - public: virtual void SetSpaceWidth(const float _width) override; - - // Documentation inherited. - public: virtual void SetTextAlignment( - const TextHorizontalAlign &_horizAlign, - const TextVerticalAlign &_vertAlign) override; - // Documentation inherited. - public: virtual void SetBaseline(const float _baseline) override; - - // Documentation inherited. - public: virtual void SetShowOnTop(const bool _onTop) override; - - // Documentation inherited. - public: virtual ignition::math::AxisAlignedBox AABB() const override; - - /// \brief Set material to text geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(OgreMaterialPtr _material); - - /// \brief Text should only be created by scene. - private: friend class OgreScene; - - /// \internal - /// \brief Private data pointer - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh b/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh index 35e763aff..ee3696e49 100644 --- a/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,107 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE_OGRETHERMALCAMERA_HH_ -#define IGNITION_RENDERING_OGRE_OGRETHERMALCAMERA_HH_ - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -#include -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/base/BaseThermalCamera.hh" -#include "ignition/rendering/ogre/Export.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreSensor.hh" - -#include "ignition/common/Event.hh" -#include "ignition/common/Console.hh" - - -namespace Ogre -{ - class Material; - class Camera; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class OgreThermalCameraPrivate; - - /** \class OgreThermalCamera OgreThermalCamera.hh\ - * rendering/ogre/OgreThermalCamera.hh - **/ - /// \brief Depth camera used to render thermal data into an image buffer - class IGNITION_RENDERING_OGRE_VISIBLE OgreThermalCamera : - public BaseThermalCamera - { - /// \brief Constructor - protected: OgreThermalCamera(); - - /// \brief Destructor - public: virtual ~OgreThermalCamera(); - - /// \brief Initialize the camera - public: virtual void Init() override; - - /// \brief Create a texture - public: virtual void CreateRenderTexture(); - - /// \brief Render the camera - public: virtual void PostRender() override; - - /// \brief Connect to the new thermal image signal - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewThermalFrame( - std::function _subscriber) override; - - // Documentation inherited. - public: virtual void PreRender() override; - - /// \brief Implementation of the render call - public: virtual void Render() override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Create the camera. - protected: void CreateCamera(); - - /// \brief Create thermal texture. This stores temperature data - private: void CreateThermalTexture(); - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera = nullptr; - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/OgreVisual.hh b/ogre/include/ignition/rendering/ogre/OgreVisual.hh index 228137b67..97b23807e 100644 --- a/ogre/include/ignition/rendering/ogre/OgreVisual.hh +++ b/ogre/include/ignition/rendering/ogre/OgreVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,44 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE_OGREVISUAL_HH_ -#define IGNITION_RENDERING_OGRE_OGREVISUAL_HH_ -#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 { - // - class IGNITION_RENDERING_OGRE_VISIBLE OgreVisual : - public BaseVisual - { - protected: OgreVisual(); - - public: virtual ~OgreVisual(); - - // Documentation inherited. - public: virtual void SetVisible(bool _visible); - - protected: virtual GeometryStorePtr Geometries() const; - - protected: virtual bool AttachGeometry(GeometryPtr _geometry); - - protected: virtual bool DetachGeometry(GeometryPtr _geometry); - - protected: virtual void Init(); - - protected: OgreGeometryStorePtr geometries; - - private: OgreVisualPtr SharedThis(); - - private: friend class OgreScene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre/include/ignition/rendering/ogre/ogre.hh.in b/ogre/include/ignition/rendering/ogre/ogre.hh.in deleted file mode 100644 index acfd26ae7..000000000 --- a/ogre/include/ignition/rendering/ogre/ogre.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/ogre/src/OgreArrowVisual.cc b/ogre/src/OgreArrowVisual.cc index d32693a05..809ec73ae 100644 --- a/ogre/src/OgreArrowVisual.cc +++ b/ogre/src/OgreArrowVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreArrowVisual.hh" +#include "gz/rendering/ogre/OgreArrowVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreAxisVisual.cc b/ogre/src/OgreAxisVisual.cc index 22e98e888..e612276cd 100644 --- a/ogre/src/OgreAxisVisual.cc +++ b/ogre/src/OgreAxisVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreAxisVisual.hh" +#include "gz/rendering/ogre/OgreAxisVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreCamera.cc b/ogre/src/OgreCamera.cc index e6fa9f78b..9e8fa830a 100644 --- a/ogre/src/OgreCamera.cc +++ b/ogre/src/OgreCamera.cc @@ -15,16 +15,16 @@ * */ -#include "ignition/rendering/ogre/OgreCamera.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreSelectionBuffer.hh" -#include "ignition/rendering/Utils.hh" - -using namespace ignition; +#include "gz/rendering/ogre/OgreCamera.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreSelectionBuffer.hh" +#include "gz/rendering/Utils.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreConversions.cc b/ogre/src/OgreConversions.cc index e03e5ea4e..1362cfe38 100644 --- a/ogre/src/OgreConversions.cc +++ b/ogre/src/OgreConversions.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreConversions.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreDepthCamera.cc b/ogre/src/OgreDepthCamera.cc index 44b937986..12658d8ad 100644 --- a/ogre/src/OgreDepthCamera.cc +++ b/ogre/src/OgreDepthCamera.cc @@ -22,13 +22,13 @@ #endif #include #endif -#include -#include "ignition/rendering/ogre/OgreDepthCamera.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" +#include +#include "gz/rendering/ogre/OgreDepthCamera.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" /// \internal /// \brief Private data for the OgreDepthCamera class -class ignition::rendering::OgreDepthCameraPrivate +class gz::rendering::OgreDepthCameraPrivate { /// \brief The depth buffer public: float *depthBuffer = nullptr; @@ -58,23 +58,23 @@ class ignition::rendering::OgreDepthCameraPrivate public: bool outputPoints = false; /// \brief maximum value used for data outside sensor range - public: float dataMaxVal = ignition::math::INF_D; + public: float dataMaxVal = gz::math::INF_D; /// \brief minimum value used for data outside sensor range - public: float dataMinVal = -ignition::math::INF_D; + public: float dataMinVal = -gz::math::INF_D; /// \brief Event used to signal rgb point cloud data - public: ignition::common::EventT newRgbPointCloud; /// \brief Event used to signal depth data - public: ignition::common::EventT newDepthFrame; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreDynamicLines.cc b/ogre/src/OgreDynamicLines.cc index 0c3b7be18..a9a11ec88 100644 --- a/ogre/src/OgreDynamicLines.cc +++ b/ogre/src/OgreDynamicLines.cc @@ -18,19 +18,19 @@ #include #include -#include +#include -#include "ignition/common/Console.hh" -#include "ignition/rendering/ogre/OgreDynamicLines.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/ogre/OgreDynamicLines.hh" -using namespace ignition; +using namespace gz; using namespace rendering; enum {POSITION_BINDING, TEXCOORD_BINDING}; /// \brief Private implementation -class ignition::rendering::OgreDynamicLinesPrivate +class gz::rendering::OgreDynamicLinesPrivate { /// \brief list of colors at each point public: std::vector colors; diff --git a/ogre/src/OgreDynamicRenderable.cc b/ogre/src/OgreDynamicRenderable.cc index cca6792da..c0e8be934 100644 --- a/ogre/src/OgreDynamicRenderable.cc +++ b/ogre/src/OgreDynamicRenderable.cc @@ -15,10 +15,10 @@ * */ -#include "ignition/common/Console.hh" -#include "ignition/rendering/ogre/OgreDynamicRenderable.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/ogre/OgreDynamicRenderable.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreGaussianNoisePass.cc b/ogre/src/OgreGaussianNoisePass.cc index 082c89f18..0f81ab498 100644 --- a/ogre/src/OgreGaussianNoisePass.cc +++ b/ogre/src/OgreGaussianNoisePass.cc @@ -16,11 +16,11 @@ */ -#include +#include -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreGaussianNoisePass.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreGaussianNoisePass.hh" namespace ignition { @@ -55,9 +55,9 @@ namespace ignition // Sample three values within the range [0,1.0] and set them for use in // the fragment shader, which will interpret them as offsets from (0,0) // to use when computing pseudo-random values. - Ogre::Vector3 offsets(ignition::math::Rand::DblUniform(0.0, 1.0), - ignition::math::Rand::DblUniform(0.0, 1.0), - ignition::math::Rand::DblUniform(0.0, 1.0)); + Ogre::Vector3 offsets(gz::math::Rand::DblUniform(0.0, 1.0), + gz::math::Rand::DblUniform(0.0, 1.0), + gz::math::Rand::DblUniform(0.0, 1.0)); // These calls are setting parameters that are declared in two places: // 1. media/materials/scripts/gaussian_noise.material, in // fragment_program GaussianNoiseFS @@ -89,7 +89,7 @@ namespace ignition } } -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreGeometry.cc b/ogre/src/OgreGeometry.cc index 821967c35..787dff754 100644 --- a/ogre/src/OgreGeometry.cc +++ b/ogre/src/OgreGeometry.cc @@ -14,12 +14,12 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreGizmoVisual.cc b/ogre/src/OgreGizmoVisual.cc index 8cbfc67ff..6e3310acf 100644 --- a/ogre/src/OgreGizmoVisual.cc +++ b/ogre/src/OgreGizmoVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreGizmoVisual.hh" +#include "gz/rendering/ogre/OgreGizmoVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreGpuRays.cc b/ogre/src/OgreGpuRays.cc index 56bbd907b..e15fd870d 100644 --- a/ogre/src/OgreGpuRays.cc +++ b/ogre/src/OgreGpuRays.cc @@ -15,21 +15,21 @@ * */ -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre/OgreCamera.hh" -#include "ignition/rendering/ogre/OgreGpuRays.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre/OgreCamera.hh" +#include "gz/rendering/ogre/OgreGpuRays.hh" /// \internal /// \brief Private data for the OgreGpuRays class -class ignition::rendering::OgreGpuRaysPrivate +class gz::rendering::OgreGpuRaysPrivate { /// \brief Event triggered when new gpu rays range data are available. /// \param[in] _frame New frame containing raw gpu rays data. @@ -37,7 +37,7 @@ class ignition::rendering::OgreGpuRaysPrivate /// \param[in] _height Height of frame. /// \param[in] _channels Number of channels /// \param[in] _format Format of frame. - public: ignition::common::EventT newGpuRaysFrame; @@ -126,7 +126,7 @@ class ignition::rendering::OgreGpuRaysPrivate public: unsigned int cameraCount = 1; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreGrid.cc b/ogre/src/OgreGrid.cc index 168ab96ea..bf80ebea1 100644 --- a/ogre/src/OgreGrid.cc +++ b/ogre/src/OgreGrid.cc @@ -15,13 +15,13 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreGrid.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreGrid.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreScene.hh" -class ignition::rendering::OgreGridPrivate +class gz::rendering::OgreGridPrivate { /// \brief Grid materal public: OgreMaterialPtr material; @@ -30,7 +30,7 @@ class ignition::rendering::OgreGridPrivate public: Ogre::ManualObject *manualObject = nullptr; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreLight.cc b/ogre/src/OgreLight.cc index 6022de883..960d4586f 100644 --- a/ogre/src/OgreLight.cc +++ b/ogre/src/OgreLight.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreLight.hh" +#include "gz/rendering/ogre/OgreLight.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreMarker.cc b/ogre/src/OgreMarker.cc index 43de0a0bc..539adc065 100644 --- a/ogre/src/OgreMarker.cc +++ b/ogre/src/OgreMarker.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreDynamicLines.hh" -#include "ignition/rendering/ogre/OgreMarker.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreMesh.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreDynamicLines.hh" +#include "gz/rendering/ogre/OgreMarker.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreMesh.hh" +#include "gz/rendering/ogre/OgreScene.hh" -class ignition::rendering::OgreMarkerPrivate +class gz::rendering::OgreMarkerPrivate { /// \brief Marker material public: OgreMaterialPtr material = nullptr; @@ -35,7 +35,7 @@ class ignition::rendering::OgreMarkerPrivate public: OgreMeshPtr mesh = nullptr; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreMaterial.cc b/ogre/src/OgreMaterial.cc index dfef22767..c0bf523ca 100644 --- a/ogre/src/OgreMaterial.cc +++ b/ogre/src/OgreMaterial.cc @@ -15,17 +15,17 @@ * */ -#include -#include +#include +#include -#include "ignition/rendering/ShaderParams.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ShaderParams.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" +#include "gz/rendering/ogre/OgreScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreMaterialSwitcher.cc b/ogre/src/OgreMaterialSwitcher.cc index f7b692534..2814146cf 100644 --- a/ogre/src/OgreMaterialSwitcher.cc +++ b/ogre/src/OgreMaterialSwitcher.cc @@ -15,12 +15,12 @@ * */ -#include "ignition/common/Console.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterialSwitcher.hh" -#include "ignition/rendering/RenderTypes.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreMaterialSwitcher.hh" +#include "gz/rendering/RenderTypes.hh" -using namespace ignition; +using namespace gz; using namespace rendering; diff --git a/ogre/src/OgreMesh.cc b/ogre/src/OgreMesh.cc index 213ff3e9c..b408181da 100644 --- a/ogre/src/OgreMesh.cc +++ b/ogre/src/OgreMesh.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreMesh.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" +#include "gz/rendering/ogre/OgreMesh.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreMeshFactory.cc b/ogre/src/OgreMeshFactory.cc index 365eef9bc..faf18ef08 100644 --- a/ogre/src/OgreMeshFactory.cc +++ b/ogre/src/OgreMeshFactory.cc @@ -18,22 +18,22 @@ #include -#include -#include -#include -#include -#include - -#include - -#include "ignition/rendering/ogre/OgreMeshFactory.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreMesh.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" - -using namespace ignition; +#include +#include +#include +#include +#include + +#include + +#include "gz/rendering/ogre/OgreMeshFactory.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreMesh.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreNode.cc b/ogre/src/OgreNode.cc index 2a3196549..36ed82c4a 100644 --- a/ogre/src/OgreNode.cc +++ b/ogre/src/OgreNode.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreNode.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/ogre/OgreNode.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreObject.cc b/ogre/src/OgreObject.cc index 2b2fed8b7..c543ea6cf 100644 --- a/ogre/src/OgreObject.cc +++ b/ogre/src/OgreObject.cc @@ -14,11 +14,11 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreObject.hh" +#include "gz/rendering/ogre/OgreObject.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRTShaderSystem.cc b/ogre/src/OgreRTShaderSystem.cc index 5be5d2e1b..286edf0b0 100644 --- a/ogre/src/OgreRTShaderSystem.cc +++ b/ogre/src/OgreRTShaderSystem.cc @@ -24,18 +24,18 @@ #include #include -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreMesh.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" - -class ignition::rendering::OgreRTShaderSystemPrivate +#include +#include +#include + +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreMesh.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" + +class gz::rendering::OgreRTShaderSystemPrivate { /// \brief The shader generator. public: Ogre::RTShader::ShaderGenerator *shaderGenerator = nullptr; @@ -72,7 +72,7 @@ class ignition::rendering::OgreRTShaderSystemPrivate public: bool resetShadows = false; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRayQuery.cc b/ogre/src/OgreRayQuery.cc index e5e54b117..50bd66354 100644 --- a/ogre/src/OgreRayQuery.cc +++ b/ogre/src/OgreRayQuery.cc @@ -17,21 +17,21 @@ #include -#include +#include -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreCamera.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreRayQuery.hh" -#include "ignition/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreCamera.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreRayQuery.hh" +#include "gz/rendering/ogre/OgreScene.hh" -class ignition::rendering::OgreRayQueryPrivate +class gz::rendering::OgreRayQueryPrivate { /// \brief Ogre ray scene query object for computing intersection. public: Ogre::RaySceneQuery *rayQuery = nullptr; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRenderEngine.cc b/ogre/src/OgreRenderEngine.cc index 3279710a5..543748ddb 100644 --- a/ogre/src/OgreRenderEngine.cc +++ b/ogre/src/OgreRenderEngine.cc @@ -30,21 +30,21 @@ # include -#include +#include -#include -#include -#include +#include +#include +#include -#include "ignition/rendering/RenderEngineManager.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreRenderTypes.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/RenderEngineManager.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreRenderTypes.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreStorage.hh" -class ignition::rendering::OgreRenderEnginePrivate +class gz::rendering::OgreRenderEnginePrivate { #if !defined(__APPLE__) && !defined(_WIN32) public: XVisualInfo *dummyVisual = nullptr; @@ -54,7 +54,7 @@ class ignition::rendering::OgreRenderEnginePrivate public: std::vector fsaaLevels; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRenderPass.cc b/ogre/src/OgreRenderPass.cc index ce36cd804..0146a499d 100644 --- a/ogre/src/OgreRenderPass.cc +++ b/ogre/src/OgreRenderPass.cc @@ -14,10 +14,10 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreRenderPass.hh" +#include "gz/rendering/ogre/OgreRenderPass.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRenderTarget.cc b/ogre/src/OgreRenderTarget.cc index 35695036f..d997e789f 100644 --- a/ogre/src/OgreRenderTarget.cc +++ b/ogre/src/OgreRenderTarget.cc @@ -33,21 +33,21 @@ #endif -#include +#include -#include "ignition/rendering/Material.hh" +#include "gz/rendering/Material.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreRenderPass.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreCamera.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreRenderPass.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreCamera.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreRenderTargetMaterial.cc b/ogre/src/OgreRenderTargetMaterial.cc index b3f9ed84b..9215ea996 100644 --- a/ogre/src/OgreRenderTargetMaterial.cc +++ b/ogre/src/OgreRenderTargetMaterial.cc @@ -15,10 +15,10 @@ * */ -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreRenderTargetMaterial.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreRenderTargetMaterial.hh" -using namespace ignition::rendering; +using namespace gz::rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreScene.cc b/ogre/src/OgreScene.cc index 094576830..bf979443c 100644 --- a/ogre/src/OgreScene.cc +++ b/ogre/src/OgreScene.cc @@ -15,30 +15,30 @@ * */ -#include - -#include "ignition/rendering/ogre/OgreArrowVisual.hh" -#include "ignition/rendering/ogre/OgreAxisVisual.hh" -#include "ignition/rendering/ogre/OgreCamera.hh" -#include "ignition/rendering/ogre/OgreDepthCamera.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreGeometry.hh" -#include "ignition/rendering/ogre/OgreGizmoVisual.hh" -#include "ignition/rendering/ogre/OgreGpuRays.hh" -#include "ignition/rendering/ogre/OgreGrid.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreText.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreMarker.hh" -#include "ignition/rendering/ogre/OgreMeshFactory.hh" -#include "ignition/rendering/ogre/OgreRayQuery.hh" -#include "ignition/rendering/ogre/OgreRenderEngine.hh" -#include "ignition/rendering/ogre/OgreRenderTarget.hh" -#include "ignition/rendering/ogre/OgreRTShaderSystem.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" -#include "ignition/rendering/ogre/OgreThermalCamera.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" +#include + +#include "gz/rendering/ogre/OgreArrowVisual.hh" +#include "gz/rendering/ogre/OgreAxisVisual.hh" +#include "gz/rendering/ogre/OgreCamera.hh" +#include "gz/rendering/ogre/OgreDepthCamera.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreGeometry.hh" +#include "gz/rendering/ogre/OgreGizmoVisual.hh" +#include "gz/rendering/ogre/OgreGpuRays.hh" +#include "gz/rendering/ogre/OgreGrid.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreText.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreMarker.hh" +#include "gz/rendering/ogre/OgreMeshFactory.hh" +#include "gz/rendering/ogre/OgreRayQuery.hh" +#include "gz/rendering/ogre/OgreRenderEngine.hh" +#include "gz/rendering/ogre/OgreRenderTarget.hh" +#include "gz/rendering/ogre/OgreRTShaderSystem.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/ogre/OgreThermalCamera.hh" +#include "gz/rendering/ogre/OgreVisual.hh" namespace ignition { @@ -119,7 +119,7 @@ namespace ignition } } -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreSelectionBuffer.cc b/ogre/src/OgreSelectionBuffer.cc index 09a41083b..49815dd0e 100644 --- a/ogre/src/OgreSelectionBuffer.cc +++ b/ogre/src/OgreSelectionBuffer.cc @@ -16,18 +16,18 @@ */ #include -#include +#include -#include "ignition/common/Console.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre/OgreIncludes.hh" -#include "ignition/rendering/ogre/OgreMaterialSwitcher.hh" -#include "ignition/rendering/ogre/OgreSelectionBuffer.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre/OgreIncludes.hh" +#include "gz/rendering/ogre/OgreMaterialSwitcher.hh" +#include "gz/rendering/ogre/OgreSelectionBuffer.hh" -using namespace ignition; +using namespace gz; using namespace rendering; -class ignition::rendering::OgreSelectionBufferPrivate +class gz::rendering::OgreSelectionBufferPrivate { /// \brief This is a material listener and a RenderTargetListener. /// The material switcher is applied to only the selection camera diff --git a/ogre/src/OgreSensor.cc b/ogre/src/OgreSensor.cc index 58c965834..b45f5978a 100644 --- a/ogre/src/OgreSensor.cc +++ b/ogre/src/OgreSensor.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre/OgreSensor.hh" +#include "gz/rendering/ogre/OgreSensor.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreText.cc b/ogre/src/OgreText.cc index 1d2841a44..d2edd4c3f 100644 --- a/ogre/src/OgreText.cc +++ b/ogre/src/OgreText.cc @@ -20,17 +20,17 @@ #include #endif -#include -#include +#include +#include -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreScene.hh" -#include "ignition/rendering/ogre/OgreText.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreScene.hh" +#include "gz/rendering/ogre/OgreText.hh" #define POS_TEX_BINDING 0 #define COLOUR_BINDING 1 -class ignition::rendering::OgreMovableText +class gz::rendering::OgreMovableText : public Ogre::MovableObject, public Ogre::Renderable { /// \brief Constructor @@ -50,7 +50,7 @@ class ignition::rendering::OgreMovableText /// \brief Set the text color. /// \param[in] _color Text color. - public: void SetColor(const ignition::math::Color &_color); + public: void SetColor(const gz::math::Color &_color); /// \brief Set the height of the character in meters. /// \param[in] _height Height of the characters. @@ -77,7 +77,7 @@ class ignition::rendering::OgreMovableText /// \brief Get the axis aligned bounding box of the text. /// \return The axis aligned bounding box. - public: ignition::math::AxisAlignedBox AABB() const; + public: gz::math::AxisAlignedBox AABB() const; /// \brief Setup the geometry based on input text string. public: void SetupGeometry(); @@ -187,7 +187,7 @@ class ignition::rendering::OgreMovableText private: std::string text; /// \brief Text color - private: ignition::math::Color color; + private: gz::math::Color color; /// \brief Character height in meters private: float charHeight = 0.0; @@ -210,7 +210,7 @@ class ignition::rendering::OgreMovableText }; /// \brief Private data for the OgreText class. -class ignition::rendering::OgreTextPrivate +class gz::rendering::OgreTextPrivate { /// \brief Text materal public: OgreMaterialPtr material; @@ -219,7 +219,7 @@ class ignition::rendering::OgreTextPrivate public: std::unique_ptr ogreObj; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre/src/OgreThermalCamera.cc b/ogre/src/OgreThermalCamera.cc index 84d6a76f8..68c468e9a 100644 --- a/ogre/src/OgreThermalCamera.cc +++ b/ogre/src/OgreThermalCamera.cc @@ -25,11 +25,11 @@ #include -#include -#include "ignition/rendering/ShaderParams.hh" -#include "ignition/rendering/ogre/OgreThermalCamera.hh" -#include "ignition/rendering/ogre/OgreMaterial.hh" -#include "ignition/rendering/ogre/OgreVisual.hh" +#include +#include "gz/rendering/ShaderParams.hh" +#include "gz/rendering/ogre/OgreThermalCamera.hh" +#include "gz/rendering/ogre/OgreMaterial.hh" +#include "gz/rendering/ogre/OgreVisual.hh" namespace ignition { @@ -90,7 +90,7 @@ class OgreThermalCameraMaterialSwitcher : public Ogre::RenderTargetListener, /// \internal /// \brief Private data for the OgreThermalCamera class -class ignition::rendering::OgreThermalCameraPrivate +class gz::rendering::OgreThermalCameraPrivate { /// \brief The thermal material public: Ogre::MaterialPtr thermalMaterial; @@ -123,7 +123,7 @@ class ignition::rendering::OgreThermalCameraPrivate public: uint16_t dataMinVal = 0u; /// \brief Event used to signal thermal image data - public: ignition::common::EventT newThermalFrame; @@ -132,7 +132,7 @@ class ignition::rendering::OgreThermalCameraPrivate thermalMaterialSwitcher; }; -using namespace ignition; +using namespace gz; using namespace rendering; diff --git a/ogre/src/OgreVisual.cc b/ogre/src/OgreVisual.cc index 8f5fdfe09..a40c922b8 100644 --- a/ogre/src/OgreVisual.cc +++ b/ogre/src/OgreVisual.cc @@ -15,13 +15,13 @@ * */ -#include +#include -#include "ignition/rendering/ogre/OgreVisual.hh" -#include "ignition/rendering/ogre/OgreConversions.hh" -#include "ignition/rendering/ogre/OgreStorage.hh" +#include "gz/rendering/ogre/OgreVisual.hh" +#include "gz/rendering/ogre/OgreConversions.hh" +#include "gz/rendering/ogre/OgreStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/include/CMakeLists.txt b/ogre2/include/CMakeLists.txt index 297e254ff..a7479f53e 100644 --- a/ogre2/include/CMakeLists.txt +++ b/ogre2/include/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(ignition/rendering) +add_subdirectory(gz/rendering) +install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) diff --git a/ogre2/include/ignition/rendering/CMakeLists.txt b/ogre2/include/gz/rendering/CMakeLists.txt similarity index 100% rename from ogre2/include/ignition/rendering/CMakeLists.txt rename to ogre2/include/gz/rendering/CMakeLists.txt diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2ArrowVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2ArrowVisual.hh new file mode 100644 index 000000000..e97e08830 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2ArrowVisual.hh @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2ARROWVISUAL_HH_ +#define GZ_RENDERING_OGRE2_OGRE2ARROWVISUAL_HH_ + +#include "gz/rendering/base/BaseArrowVisual.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ArrowVisual : + public BaseArrowVisual + { + /// \brief Constructor + protected: Ogre2ArrowVisual(); + + /// \brief Destructor + public: virtual ~Ogre2ArrowVisual(); + + /// \brief Only the ogre scene can instanstiate this class + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2AxisVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2AxisVisual.hh new file mode 100644 index 000000000..756d4d5ac --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2AxisVisual.hh @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2AXISVISUAL_HH_ +#define GZ_RENDERING_OGRE2_OGRE2AXISVISUAL_HH_ + +#include "gz/rendering/base/BaseAxisVisual.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2AxisVisual : + public BaseAxisVisual + { + /// \brief Constructor + protected: Ogre2AxisVisual(); + + /// \brief Destructor + public: virtual ~Ogre2AxisVisual(); + + /// \brief Only the ogre scene can instanstiate this class + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Camera.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Camera.hh new file mode 100644 index 000000000..c2ec52d31 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Camera.hh @@ -0,0 +1,140 @@ +/* + * 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 "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" + +namespace Ogre +{ + class Camera; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2SelectionBuffer; + + /// \brief Ogre2.x implementation of the camera class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Camera : + public BaseCamera + { + /// \brief Constructor + protected: Ogre2Camera(); + + /// \brief Destructor + public: virtual ~Ogre2Camera(); + + // Documenation inherited. + public: virtual void SetHFOV(const math::Angle &_hfov) override; + + // Documenation inherited. + public: virtual double AspectRatio() const override; + + // Documenation inherited. + public: virtual void SetAspectRatio(const double _ratio) override; + + // Documenation inherited. + public: virtual unsigned int AntiAliasing() const override; + + // Documenation inherited. + public: virtual void SetAntiAliasing(const unsigned int _aa) override; + + // Documenation inherited. + public: virtual void SetFarClipPlane(const double _far) override; + + // Documenation inherited. + public: virtual void SetNearClipPlane(const double _near) override; + + public: virtual math::Color BackgroundColor() const; + + public: virtual void SetBackgroundColor(const math::Color &_color); + + // Documenation inherited. + public: virtual void Render() override; + + // Documenation inherited. + public: virtual RenderWindowPtr CreateRenderWindow() override; + + // Documenation inherited. + public: virtual math::Matrix4d ProjectionMatrix() const override; + + // Documenation inherited. + public: virtual math::Matrix4d ViewMatrix() const override; + + // Documentation inherited + public: virtual VisualPtr VisualAt(const gz::math::Vector2i + &_mousePos) override; + + // Documentation Inherited. + // \sa Camera::SetMaterial(const MaterialPtr &) + public: virtual void SetMaterial( + const MaterialPtr &_material) override; + + // Documentation inherited. + public: virtual unsigned int RenderTextureGLId() const override; + + // Documentation inherited. + public: virtual void Destroy() override; + + public: Ogre::Camera *OgreCamera() const; + + // Documenation inherited. + protected: virtual RenderTargetPtr RenderTarget() const override; + + // Documenation 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 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 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/Ogre2Conversions.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Conversions.hh new file mode 100644 index 000000000..63ea87942 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Conversions.hh @@ -0,0 +1,108 @@ +/* + * 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/Ogre2Includes.hh" +#include "gz/rendering/ogre2/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 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::PixelFormat Convert(PixelFormat _format); + + /// \brief A list of ogre pixel formats + private: static const Ogre::PixelFormat ogrePixelFormats[PF_COUNT]; + }; + /// \} + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2DepthCamera.hh b/ogre2/include/gz/rendering/ogre2/Ogre2DepthCamera.hh new file mode 100644 index 000000000..6e1aafcdd --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2DepthCamera.hh @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE2_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/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" + +#include "gz/common/Event.hh" +#include "gz/common/Console.hh" + +namespace Ogre +{ + class Material; + class RenderTarget; + class Texture; + class Viewport; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2DepthCameraPrivate; + + /// \brief Depth camera used to render depth data into an image buffer + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DepthCamera : + public BaseDepthCamera + { + /// \brief Constructor + protected: Ogre2DepthCamera(); + + /// \brief Destructor + public: virtual ~Ogre2DepthCamera(); + + /// \brief Initialize the camera + public: virtual void Init() override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Create dummy render texture. Needed to satisfy inheritance + public: virtual void CreateRenderTexture(); + + /// \brief Create a texture which will hold the depth data + /// \brief Set up 1st pass material, texture, and compositor + public: virtual void CreateDepthTexture() override; + + // Documentation inherited + public: virtual void PreRender() override; + + /// \brief Render the camera + public: virtual void PostRender() override; + + /// \brief All things needed to get back z buffer for depth data + /// \return The z-buffer as a float array + public: virtual const float *DepthData() const override; + + /// \brief Connect a to the new depth image signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewDepthFrame( + std::function _subscriber) override; + + /// \brief Connect a to the new rgb point cloud signal + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewRgbPointCloud( + std::function _subscriber) override; + + /// \brief Implementation of the render call + public: virtual void Render() override; + + /// \brief Set the far clip distance + /// \param[in] _far far clip distance + public: virtual void SetFarClipPlane(const double _far) override; + + /// \brief Set the near clip distance + /// \param[in] _near Near clip distance + public: virtual void SetNearClipPlane(const double _near) override; + + /// \brief Get the near clip distance + /// \return Near clip distance. A value of zero is returned if the + /// ogre camera has not been created. + public: double NearClipPlane() const override; + + /// \brief Get the far clip distance + /// \return Far clip distance. A value of zero is returned if the + /// ogre camera has not been created. + public: double FarClipPlane() const override; + + // Documentation inherited. + public: void AddRenderPass(const RenderPassPtr &_pass) override; + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Limit field of view taking care of using a valid value for + /// an OGRE camera. + /// \param[in] _fov expected field of view + /// \return valid field of view + protected: static double LimitFOV(const double _fov); + + /// \brief Create the camera. + protected: void CreateCamera(); + + /// \brief Pointer to the ogre camera + protected: Ogre::Camera *ogreCamera; + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2DynamicRenderable.hh b/ogre2/include/gz/rendering/ogre2/Ogre2DynamicRenderable.hh new file mode 100644 index 000000000..44deed64a --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2DynamicRenderable.hh @@ -0,0 +1,137 @@ +/* + * 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/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/Marker.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declarations + class Ogre2DynamicRenderablePrivate; + + /* \class Ogre2DynamicRenderable Ogre2DynamicRenderable.hh \ + * ignition/rendering/ogre2/Ogre2DynamicRenderable.hh + */ + /// \brief Dynamic renderable class that manages hardware buffers for + /// a dynamic geometry + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DynamicRenderable + { + /// \brief Constructor + /// \param[in] _scene Pointer to scene + public: explicit Ogre2DynamicRenderable(ScenePtr _scene); + + /// \brief Virtual destructor + public: virtual ~Ogre2DynamicRenderable(); + + /// \brief Set the render operation type + /// \param[in] _opType The type of render operation to perform. + public: void SetOperationType(MarkerType _opType); + + /// \brief Get the render operation type + /// \return The render operation type. + public: MarkerType OperationType() const; + + /// \brief Update the dynamic renderable + public: void Update(); + + /// \brief Get the ogre object associated with this dynamic renderable + public: Ogre::MovableObject *OgreObject() const; + + /// \brief Add a point to the point list + /// \param[in] _pt gz::math::Vector3d point + /// \param[in] _color gz::math::Color Point color + public: void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color = gz::math::Color::White); + + /// \brief Add a point to the point list. + /// \param[in] _x X position + /// \param[in] _y Y position + /// \param[in] _z Z position + /// \param[in] _color Point color + public: void AddPoint(const double _x, const double _y, const double _z, + const gz::math::Color &_color = gz::math::Color::White); + + /// \brief Change the location of an existing point in the point list + /// \param[in] _index Index of the point to set + /// \param[in] _value Position of the point + public: void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value); + + /// \brief Change the color of an existing point in the point list + /// \param[in] _index Index of the point to set + /// \param[in] _color color to set the point to + public: void SetColor(unsigned int _index, + const gz::math::Color &_color); + + /// \brief Return the position of an existing point in the point list + /// \param[in] _index Get the point at this index + /// \return position of point. A vector of + /// [gz::math::INF_D, gz::math::INF_D, gz::math::INF_D] + /// is returned when then the _index is out of bounds. + /// gz::math::INF_D==std::numeric_limits::infinity() + public: gz::math::Vector3d Point(unsigned int _index) const; + + /// \brief Return the total number of points in the point list + /// \return Number of points + public: unsigned int PointCount() const; + + /// \brief Remove all points from the point list + public: void Clear(); + + /// \brief Destroy the dynamic renderable + public: void Destroy(); + + /// \brief Set the material for this dynamic renderable + /// \param[in] _material New Material to be assigned + /// \param[in] _unique True if the given material should be cloned + public: void SetMaterial(MaterialPtr _material, bool _unique = true); + + /// \brief Create the dynamic mesh + private: void CreateDynamicMesh(); + + /// \brief Update vertex buffer if vertices have changes + private: void UpdateBuffer(); + + /// \brief Helper function to generate normals + /// \param[in] _opType Ogre render operation type + /// \param[in] _vertices a list of vertices + /// \param[in,out] _vbuffer vertex buffer to be filled + private: void GenerateNormals(Ogre::OperationType _opType, + const std::vector &_vertices, float *_vbuffer); + + /// \brief Destroy the vertex buffer + private: void DestroyBuffer(); + + /// \brief Pointer to private data + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2GaussianNoisePass.hh b/ogre2/include/gz/rendering/ogre2/Ogre2GaussianNoisePass.hh new file mode 100644 index 000000000..41892184f --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2GaussianNoisePass.hh @@ -0,0 +1,56 @@ +/* + * 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 "gz/rendering/base/BaseGaussianNoisePass.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderPass.hh" +#include "gz/rendering/ogre2/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \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 the Gaussian noise ogre material + private: Ogre::Material *gaussianNoiseMat = nullptr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Geometry.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Geometry.hh new file mode 100644 index 000000000..04f2e2b9b --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Geometry.hh @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2GEOMETRY_HH_ +#define GZ_RENDERING_OGRE2_OGRE2GEOMETRY_HH_ + +#include "gz/rendering/base/BaseGeometry.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" + +namespace Ogre +{ + class MovableObject; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre2.x implementation of the geometry class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Geometry : + public BaseGeometry + { + /// \brief Constructor + protected: Ogre2Geometry(); + + /// \brief Destructor + public: virtual ~Ogre2Geometry(); + + // Documentation inherited. + public: virtual bool HasParent() const override; + + // Documentation inherited. + public: virtual VisualPtr Parent() const override; + + /// \brief Get the ogre object representing this geometry + /// \return Pointer to an ogre movable object + public: virtual Ogre::MovableObject *OgreObject() const = 0; + + /// \brief Set the parent of this ogre geometry + /// \param[in] _parent Parent visual + protected: virtual void SetParent(Ogre2VisualPtr _parent); + + /// \brief Parent visual + protected: Ogre2VisualPtr parent; + + /// \brief Make ogre2 visual our friend so it can it can access function + /// for setting the parent of this geometry + private: friend class Ogre2Visual; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2GizmoVisual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2GizmoVisual.hh new file mode 100644 index 000000000..149c06d90 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2GizmoVisual.hh @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2GIZMOVISUAL_HH_ +#define GZ_RENDERING_OGRE2_OGRE2GIZMOVISUAL_HH_ + +#include "gz/rendering/base/BaseGizmoVisual.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2GizmoVisual : + public BaseGizmoVisual + { + /// \brief Constructor + protected: Ogre2GizmoVisual(); + + /// \brief Destructor + public: virtual ~Ogre2GizmoVisual(); + + /// \brief Only the ogre scene can instanstiate this class + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2GpuRays.hh b/ogre2/include/gz/rendering/ogre2/Ogre2GpuRays.hh new file mode 100644 index 000000000..c02725e56 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2GpuRays.hh @@ -0,0 +1,165 @@ +/* + * 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/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" + +#include "gz/common/Event.hh" +#include "gz/common/Console.hh" + +namespace Ogre +{ + class Material; + class RenderTarget; + class Texture; + class Viewport; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2GpuRaysPrivate; + + /// \brief Gpu Rays used to render range data into an image buffer + /// The ogre2 implementation takes a 2 pass process to generate + /// the final range data. + /// 1st Pass: Creates a cubemap of range data. The cubemap is created from + /// six cameras looking in all directions. Depending on the min/max angles + /// specified, not all cameras need to be created. Internally in the 1st + /// pass shaders, we reconstruct 3d viewspace pos from depth buffer data + /// then convert them into ranges, i.e. length(pos.xyz). + /// 2nd Pass: Samples range data from cubemap using predefined rays. The + /// rays are generated based on the specified vertical and horizontal + /// min/max angles and no. of samples. Each ray is a direction vector that + /// is used to sample/lookup the range data stored in the faces of the + /// cubemap. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2GpuRays : + public BaseGpuRays + { + /// \brief Constructor + protected: Ogre2GpuRays(); + + /// \brief Destructor + public: virtual ~Ogre2GpuRays(); + + // Documentation inherited + public: virtual void Init() override; + + // Documentation inherited + public: virtual void Destroy() override; + + /// \brief Create dummy render texture. Needed to satisfy inheritance + public: virtual void CreateRenderTexture(); + + // Documentation inherited + public: virtual void PreRender() override; + + // Documentation inherited + public: virtual void PostRender() override; + + // Documentation inherited + public: virtual const float *Data() const override; + + // Documentation inherited. + public: virtual void Copy(float *_data) override; + + // Documentation inherited. + public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( + std::function _subscriber) override; + + // Documentation inherited. + public: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Set the number of samples in the width and height for the + /// first pass texture. + /// \param[in] _w Number of samples in the horizontal sweep + /// \param[in] _h Number of samples in the vertical sweep + private: virtual void Set1stTextureSize(const unsigned int _w, + const unsigned int _h = 1); + + /// \brief Set the number of samples in the width and height for the + /// second pass texture. + /// \param[in] _w Number of samples in the horizontal sweep + /// \param[in] _h Number of samples in the vertical sweep + private: virtual void SetRangeCount(const unsigned int _w, + const unsigned int _h = 1); + + // Documentation inherited. + private: virtual void Render() override; + + /// \brief Configure camera. + private: void ConfigureCamera(); + + /// \brief Create an ortho camera. + private: void CreateCamera(); + + /// \brief Create the texture which is used to render gpu rays data. + private: virtual void CreateGpuRaysTextures(); + + /// \brief Update the render targets in the 1st pass + private: void UpdateRenderTarget1stPass(); + + /// \brief Update the 2nd pass render target + private: void UpdateRenderTarget2ndPass(); + + /// \brief Create texture that store cubemap uv coordinates and + /// cubemap face index data + private: void CreateSampleTexture(); + + /// \brief Set up 1st pass material, texture, and compositor + private: void Setup1stPass(); + + /// \brief Set up 2nd pass material, texture, and compositor + private: void Setup2ndPass(); + + /// \brief Helper function to convert a direction vector to the + /// index number of a cubemap face and texture uv coordinates on that face + /// \param[in] _v Direction vector + /// \param[out] _faceIndex Index of face to sample + /// \return Texture UV coordinates on the face indicated by _faceIndex + private: math::Vector2d SampleCubemap(const math::Vector3d &_v, + unsigned int &_faceIndex); + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + /// \brief Only the scene can create a GpuRays sensor + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Grid.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Grid.hh new file mode 100644 index 000000000..4f9867178 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Grid.hh @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE2_OGRE2GRID_HH_ +#define GZ_RENDERING_OGRE2_OGRE2GRID_HH_ + +#include +#include "gz/rendering/base/BaseGrid.hh" +#include "gz/rendering/ogre2/Ogre2Geometry.hh" +#include "gz/rendering/ogre2/Ogre2Includes.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/Ogre2Includes.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh new file mode 100644 index 000000000..0319a04da --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh @@ -0,0 +1,106 @@ +/* + * 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 + +// 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/Ogre2Light.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Light.hh new file mode 100644 index 000000000..12f27d80e --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Light.hh @@ -0,0 +1,195 @@ +/* + * 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 "gz/rendering/base/BaseLight.hh" +#include "gz/rendering/ogre2/Ogre2Node.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" + +namespace Ogre +{ + class Light; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \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; + + /// \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 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/Ogre2Marker.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Marker.hh new file mode 100644 index 000000000..0b320e836 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Marker.hh @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE2_OGREMARKER_HH_ +#define GZ_RENDERING_OGRE2_OGREMARKER_HH_ + +#include +#include "gz/rendering/base/BaseMarker.hh" +#include "gz/rendering/ogre2/Ogre2Geometry.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2MarkerPrivate; + + /// \brief Ogre 2.x implementation of a marker geometry. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Marker + : public BaseMarker + { + /// \brief Constructor + protected: Ogre2Marker(); + + /// \brief Destructor + public: virtual ~Ogre2Marker(); + + // Documentation inherited. + public: virtual void Init() override; + + // Documentation inherited. + public: virtual void PreRender() override; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual Ogre::MovableObject *OgreObject() const override; + + // Documentation inherited. + public: virtual MaterialPtr Material() const override; + + // Documentation inherited. + public: virtual void SetMaterial( + MaterialPtr _material, bool _unique) override; + + // Documentation inherited + public: virtual void SetPoint(unsigned int _index, + const gz::math::Vector3d &_value) override; + + // Documentation inherited + public: virtual void AddPoint(const gz::math::Vector3d &_pt, + const gz::math::Color &_color) override; + + // Documentation inherited + public: virtual void ClearPoints() override; + + // Documentation inherited + public: virtual void SetType(const MarkerType _markerType) override; + + // Documentation inherited + public: virtual MarkerType Type() const override; + + /// \brief Create the marker geometry in ogre + private: void Create(); + + /// \brief Marker should only be created by scene. + private: friend class Ogre2Scene; + + /// \brief Private data class + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Material.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Material.hh new file mode 100644 index 000000000..6f9787170 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Material.hh @@ -0,0 +1,242 @@ +/* + * 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 "gz/rendering/base/BaseMaterial.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \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 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 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 datablock + /// \return Ogre Hlms datablock + public: virtual Ogre::HlmsPbsDatablock *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; + + /// \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::TexturePtr 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 Ogre material. Mainly used for render targets. + protected: Ogre::MaterialPtr ogreMaterial; + + /// \brief Ogre data block containing all material properties + protected: Ogre::HlmsPbsDatablock *ogreDatablock = 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 Unique id assigned to ogre hlms datablock + protected: std::string ogreDatablockId; + + /// \brief Only an ogre scene can create an ogre material + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2MaterialSwitcher.hh b/ogre2/include/gz/rendering/ogre2/Ogre2MaterialSwitcher.hh new file mode 100644 index 000000000..a673161f9 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2MaterialSwitcher.hh @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_ +#define GZ_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_ + +#include +#include + +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/ogre2/Export.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" + +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::RenderTargetListener + { + /// \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 gz::math::Color &_color) const; + + /// \brief Reset the color value incrementor + public: void Reset(); + + /// \brief Ogre's pre render update callback + /// \param[in] _evt Ogre render target event containing information about + /// the source render target. + public: virtual void preRenderTargetUpdate( + const Ogre::RenderTargetEvent &_evt); + + /// \brief Ogre's post render update callback + /// \param[in] _evt Ogre render target event containing information about + /// the source render target. + public: virtual void postRenderTargetUpdate( + const Ogre::RenderTargetEvent &_evt); + + /// \brief Current unique color value + private: gz::math::Color currentColor; + + /// \brief Color dictionary that maps the unique color value to + /// renderable name + private: std::map colorDict; + + /// \brief A map of ogre sub item pointer to their original hlms material + private: std::map datablockMap; + + /// \brief Ogre v1 material consisting of a shader that changes the + /// appearance of item to use a unique color for mouse picking + private: Ogre::MaterialPtr plainMaterial; + + /// \brief Ogre v1 material consisting of a shader that changes the + /// appearance of item to use a unique color for mouse picking. In + /// addition, the depth check and depth write properties disabled. + private: Ogre::MaterialPtr plainOverlayMaterial; + + /// \brief Increment unique color value that will be assigned to the + /// next renderable + private: void NextColor(); + + /// \brief Selection Buffer class that make use of this class for + /// selecting entitiies + public: friend class Ogre2SelectionBuffer; + + /// \brief Plain material technique + private: Ogre2ScenePtr scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Mesh.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Mesh.hh new file mode 100644 index 000000000..f9b76493a --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Mesh.hh @@ -0,0 +1,116 @@ +/* + * 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 "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 { + // + /// \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 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 Ogre2.x implementation of the submesh class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SubMesh : + public BaseSubMesh + { + /// \brief Constructor + protected: Ogre2SubMesh(); + + /// \brief Destructor + public: virtual ~Ogre2SubMesh(); + + /// \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); + + /// \brief Initialize the submesh + protected: virtual void Init(); + + /// \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; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2MeshFactory.hh b/ogre2/include/gz/rendering/ogre2/Ogre2MeshFactory.hh new file mode 100644 index 000000000..a6478000f --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2MeshFactory.hh @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_ +#define GZ_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_ + +#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 { + // + /// \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 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; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Node.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Node.hh new file mode 100644 index 000000000..bcf40ffb3 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Node.hh @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2NODE_HH_ +#define GZ_RENDERING_OGRE2_OGRE2NODE_HH_ + +#include "gz/rendering/base/BaseNode.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" + +namespace Ogre +{ + class SceneNode; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre2.x implementation of the Node class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Node : + public BaseNode + { + /// \brief Constructor + protected: Ogre2Node(); + + /// \brief Destructor + public: virtual ~Ogre2Node(); + + // Documentation inherited. + public: virtual bool HasParent() const override; + + // Documentation inherited. + public: virtual NodePtr Parent() const override; + + /// \brief Get a pointer to the underlying scene node + /// \return Ogre scene node pointer + public: virtual Ogre::SceneNode *Node() const; + + // Documentation inherited. + public: virtual void Destroy() override; + + // Documentation inherited. + public: virtual math::Vector3d LocalScale() const override; + + // Documentation inherited. + public: virtual bool InheritScale() const override; + + // Documentation inherited. + public: virtual void SetInheritScale(bool _inherit) override; + + // Documentation inherited. + protected: virtual void SetLocalScaleImpl( + const math::Vector3d &_scale) override; + + // Documentation inherited. + protected: virtual NodeStorePtr Children() const override; + + // Documentation inherited. + protected: virtual bool AttachChild(NodePtr _child) override; + + // Documentation inherited. + protected: virtual bool DetachChild(NodePtr _child) override; + + // Documentation inherited. + protected: virtual math::Pose3d RawLocalPose() const override; + + // Documentation inherited. + protected: virtual void SetRawLocalPose(const math::Pose3d &_Pose3d) + override; + + /// \brief Get the raw local position of the node + /// \return Local position + protected: virtual math::Vector3d RawLocalPosition() const; + + /// \brief Set the raw local position of the node + /// \param[in] _position Local position to set the node to + protected: virtual void SetRawLocalPosition( + const math::Vector3d &_position); + + /// \brief Get the raw local rotation of the node + /// \return Local rotation + protected: virtual math::Quaterniond RawLocalRotation() const; + + /// \brief Set the raw local rotation of the node + /// \param[in] _rotation Local rotation to set the node to + protected: virtual void SetRawLocalRotation( + const math::Quaterniond &_rotation); + + /// \brief Set the parent node + /// \param[in] _parent The parent ogre node + protected: virtual void SetParent(Ogre2NodePtr _parent); + + // Documentation inherited. + protected: virtual void Load() override; + + // Documentation inherited. + protected: virtual void Init() override; + + /// \brief get a shared pointer to this + private: Ogre2NodePtr SharedThis(); + + /// \brief Pointer to the parent ogre node + protected: Ogre2NodePtr parent; + + /// \brief The underlying ogre scene node + protected: Ogre::SceneNode *ogreNode = nullptr; + + /// \brief A list of child nodes + protected: Ogre2NodeStorePtr children; + + // TODO(anyone): remove the need for a visual friend class + private: friend class Ogre2Visual; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Object.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Object.hh new file mode 100644 index 000000000..50042bfc6 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Object.hh @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2OBJECT_HH_ +#define GZ_RENDERING_OGRE2_OGRE2OBJECT_HH_ + +#include "gz/rendering/config.hh" +#include "gz/rendering/base/BaseObject.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre2.x implementation of the Object class + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Object : + public BaseObject + { + /// \brief Constructor + protected: Ogre2Object(); + + /// \brief Destructor + public: virtual ~Ogre2Object(); + + // Documentation inherited + public: virtual ScenePtr Scene() const override; + + /// \brief Pointer to the ogre scene + protected: Ogre2ScenePtr scene; + + /// \brief Make ogre scene our friend so it is able to create objects + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RayQuery.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RayQuery.hh new file mode 100644 index 000000000..ad0ae0c37 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RayQuery.hh @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2RAYQUERY_HH_ +#define GZ_RENDERING_OGRE2_OGRE2RAYQUERY_HH_ + +#include + +#include "gz/rendering/base/BaseRayQuery.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2RayQueryPrivate; + + /// \class Ogre2RayQuery Ogre2RayQuery.hh + /// ignition/rendering/ogre2/Ogre2RayQuery.hh + /// \brief A Ray Query class used for computing ray object intersections + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RayQuery : + public BaseRayQuery + { + /// \brief Constructor + protected: Ogre2RayQuery(); + + /// \brief Destructor + public: virtual ~Ogre2RayQuery(); + + // Documentation inherited + public: virtual void SetFromCamera(const CameraPtr &_camera, + const math::Vector2d &_coord); + + // Documentation inherited + public: virtual RayQueryResult ClosestPoint(); + + /// \brief Private data pointer + private: std::unique_ptr dataPtr; + + /// \brief Pointer to friend scene class for creating ray query + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh new file mode 100644 index 000000000..8513defe3 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh @@ -0,0 +1,207 @@ +/* + * 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/RenderEnginePlugin.hh" +#include "gz/rendering/base/BaseRenderEngine.hh" +#include "gz/rendering/base/BaseRenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Export.hh" + +namespace Ogre +{ + class LogManager; + class Root; + namespace v1 + { + class OverlaySystem; + } +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // forward declaration + class Ogre2RenderEnginePrivate; + + /// \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 resourcea in ogre2's resource manager + /// \param[in] _uri Reousrce path in the form of an uri + public: void AddResourcePath(const std::string &_uri) override; + + /// \brief Get the ogre2 root object + /// \return ogre2 root object + public: virtual Ogre::Root *OgreRoot() const; + + /// \brief Create a render window + /// \param[in] _handle Handle of native window which the render window + /// will attach + /// \param[in] _width Width of render window + /// \param[in] _height Height of render window + /// \param[in] _ratio Device pixel ratio (typically needed for retina + /// displays) + /// \param[in] _antiAliasing Anti-aliasing level + public: std::string CreateRenderWindow(const std::string &_handle, + const unsigned int _width, const unsigned int _height, + const double _ratio, const unsigned int _antiAliasing); + + /// \brief 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 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; + + /// \internal + /// \brief Get a pointer to the Ogre overlay system. + /// \return Pointer to the ogre overlay system. + public: Ogre::v1::OverlaySystem *OverlaySystem() 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 True to use the current opengl context + private: bool useCurrentGLContext = false; + + /// \brief Pointer to private data + private: std::unique_ptr dataPtr; + + /// \brief Singleton setup + private: friend class common::SingletonT; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderPass.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderPass.hh new file mode 100644 index 000000000..580b64c97 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderPass.hh @@ -0,0 +1,74 @@ +/* + * 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 "gz/rendering/base/BaseRenderPass.hh" +#include "gz/rendering/ogre2/Export.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /* \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; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderTarget.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTarget.hh new file mode 100644 index 000000000..e34b0c092 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTarget.hh @@ -0,0 +1,253 @@ +/* + * 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 "gz/rendering/base/BaseRenderTypes.hh" +#include "gz/rendering/base/BaseRenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" +#include "gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh" + +namespace Ogre +{ + class Camera; + class RenderTarget; + class Texture; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \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); + + // 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); + + /// \brief Get a pointer to the ogre render target + public: virtual Ogre::RenderTarget *RenderTarget() const = 0; + + /// \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); + + /// \brief Update the background color + protected: virtual void UpdateBackgroundColor(); + + /// \brief Update the render pass chain + protected: virtual void UpdateRenderPassChain(); + + /// \brief Create a compositor shadow node with the same number of shadow + /// textures as the number of shadow casting lights + protected: void UpdateShadowNode(); + + /// \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 comopsitor + 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 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); + + /// \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 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 Anti-aliasing level + protected: unsigned int antiAliasing = 4; + }; + + /// \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 Ogre::RenderTarget *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 Pointer to the internal ogre render texture object + protected: Ogre::Texture *ogreTexture = nullptr; + + /// \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 Ogre::RenderTarget *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::RenderTarget *ogreRenderWindow = nullptr; + + /// \brief Make scene our friend so it can create a ogre2 render window + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh new file mode 100644 index 000000000..b699ef3da --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh @@ -0,0 +1,101 @@ +/* + * 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/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Export.hh" + +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::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: Ogre2RenderTargetMaterial(Ogre::SceneManager *_scene, + Ogre::RenderTarget *_renderTarget, Ogre::Material *_material); + + /// \brief destructor + public: ~Ogre2RenderTargetMaterial(); + + /// \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: Ogre::SceneManager *scene = nullptr; + + /// \brief render target that should see a uniform material + private: Ogre::RenderTarget *renderTarget = 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; + }; + } + } +} + +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderTypes.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTypes.hh new file mode 100644 index 000000000..53217d620 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderTypes.hh @@ -0,0 +1,113 @@ +/* + * 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 Ogre2DepthCamera; + class Ogre2DirectionalLight; + class Ogre2Geometry; + class Ogre2GizmoVisual; + class Ogre2GpuRays; + class Ogre2Grid; + class Ogre2Light; + class Ogre2Marker; + class Ogre2Material; + class Ogre2Mesh; + class Ogre2MeshFactory; + class Ogre2Node; + class Ogre2Object; + class Ogre2PointLight; + class Ogre2RayQuery; + class Ogre2RenderEngine; + class Ogre2RenderTarget; + class Ogre2RenderTargetMaterial; + class Ogre2RenderTexture; + class Ogre2RenderWindow; + class Ogre2Scene; + class Ogre2Sensor; + class Ogre2SpotLight; + class Ogre2SubMesh; + class Ogre2ThermalCamera; + class Ogre2Visual; + + 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 Ogre2DepthCameraPtr; + typedef shared_ptr Ogre2DirectionalLightPtr; + typedef shared_ptr Ogre2GeometryPtr; + typedef shared_ptr Ogre2GizmoVisualPtr; + typedef shared_ptr Ogre2GpuRaysPtr; + typedef shared_ptr Ogre2GridPtr; + typedef shared_ptr Ogre2LightPtr; + 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 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 Ogre2SensorPtr; + typedef shared_ptr Ogre2SpotLightPtr; + typedef shared_ptr Ogre2SubMeshPtr; + typedef shared_ptr Ogre2ThermalCameraPtr; + typedef shared_ptr Ogre2VisualPtr; + + typedef shared_ptr Ogre2GeometryStorePtr; + typedef shared_ptr Ogre2LightStorePtr; + typedef shared_ptr Ogre2NodeStorePtr; + typedef shared_ptr Ogre2RenderTargetMaterialPtr; + typedef shared_ptr Ogre2SceneStorePtr; + typedef shared_ptr Ogre2SensorStorePtr; + typedef shared_ptr Ogre2SubMeshStorePtr; + typedef shared_ptr Ogre2VisualStorePtr; + + typedef shared_ptr Ogre2MaterialMapPtr; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Scene.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Scene.hh new file mode 100644 index 000000000..f49ddb974 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Scene.hh @@ -0,0 +1,264 @@ +/* + * 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 "gz/rendering/Storage.hh" +#include "gz/rendering/base/BaseScene.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" + +#include "gz/rendering/ogre2/Export.hh" + +namespace Ogre +{ + class Root; + class SceneManager; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \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 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; + + /// \brief Get a pointer to the ogre scene manager + /// \return Pointer to the ogre scene manager + public: virtual Ogre::SceneManager *OgreSceneManager() const; + + /// \cond PRIVATE + /// \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 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 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 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 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; + + /// \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); + + // 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 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 Pointer to the ogre scene manager + protected: Ogre::SceneManager *ogreSceneManager = nullptr; + + /// \brief Make the render engine our friend + private: friend class Ogre2RenderEngine; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2SelectionBuffer.hh b/ogre2/include/gz/rendering/ogre2/Ogre2SelectionBuffer.hh new file mode 100644 index 000000000..3acbd2474 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2SelectionBuffer.hh @@ -0,0 +1,84 @@ +/* + * 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 + public: Ogre2SelectionBuffer(const std::string &_cameraName, + Ogre2ScenePtr _scene); + + /// \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 Call this to update the selection buffer contents + public: void Update(); + + /// \brief Delete the render texture + private: void DeleteRTTBuffer(); + + /// \brief Create the render texture + private: void CreateRTTBuffer(); + + /// \brief Create the selection buffer offscreen render texture. + // private: void CreateRTTOverlays(); + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Sensor.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Sensor.hh new file mode 100644 index 000000000..00141d7e0 --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Sensor.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2SENSOR_HH_ +#define GZ_RENDERING_OGRE2_OGRE2SENSOR_HH_ + +#include "gz/rendering/base/BaseSensor.hh" +#include "gz/rendering/ogre2/Ogre2Node.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Ogre2.x implementation of the sensor classs + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Sensor : + public BaseSensor + { + /// \brief Constructor + protected: Ogre2Sensor(); + + /// \brief Destructor + public: virtual ~Ogre2Sensor(); + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Storage.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Storage.hh new file mode 100644 index 000000000..a3cb09b9e --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Storage.hh @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_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/Ogre2Node.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + +// armhf failed to build with this code. It can not be removed for the rest +// of arches to keep ABI but should be removed in major versions unreleased +// see https://github.com/ignitionrobotics/ign-rendering/pull/457 +#ifndef __ARM_PCS_VFP + template class BaseGeometryStore; + template class BaseLightStore; + template class BaseNodeStore; + template class BaseSceneStore; + template class BaseSensorStore; + template class BaseSubMeshStore; + template class BaseVisualStore; +#endif + + typedef BaseGeometryStore Ogre2GeometryStore; + typedef BaseLightStore Ogre2LightStore; + typedef BaseNodeStore Ogre2NodeStore; + typedef BaseSceneStore Ogre2SceneStore; + typedef BaseSensorStore Ogre2SensorStore; + typedef BaseSubMeshStore Ogre2SubMeshStore; + typedef BaseVisualStore Ogre2VisualStore; + + typedef std::shared_ptr Ogre2GeometryStorePtr; + typedef std::shared_ptr Ogre2LightStorePtr; + typedef std::shared_ptr Ogre2NodeStorePtr; + typedef std::shared_ptr Ogre2SceneStorePtr; + typedef std::shared_ptr Ogre2SensorStorePtr; + typedef std::shared_ptr Ogre2SubMeshStorePtr; + typedef std::shared_ptr Ogre2VisualStorePtr; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2ThermalCamera.hh b/ogre2/include/gz/rendering/ogre2/Ogre2ThermalCamera.hh new file mode 100644 index 000000000..48438bb6a --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2ThermalCamera.hh @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_RENDERING_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/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" + +#include "gz/common/Event.hh" +#include "gz/common/Console.hh" + +namespace Ogre +{ + class Material; + class RenderTarget; + class Texture; + class Viewport; +} + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + // Forward declaration + class Ogre2ThermalCameraPrivate; + + /// \brief Thermal camera used to render thermal data into an image buffer + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ThermalCamera : + public BaseThermalCamera + { + /// \brief Constructor + protected: Ogre2ThermalCamera(); + + /// \brief Destructor + public: virtual ~Ogre2ThermalCamera(); + + /// \brief Initialize the camera + public: virtual void Init() override; + + // Documentation inherited + public: virtual void Destroy() override; + + // Documentation inherited + public: virtual void PreRender() override; + + /// \brief Render the camera + public: virtual void PostRender() override; + + /// \brief Connect to the new thermal image event + /// \param[in] _subscriber Subscriber callback function + /// \return Pointer to the new Connection. This must be kept in scope + public: virtual gz::common::ConnectionPtr ConnectNewThermalFrame( + std::function _subscriber) override; + + /// \brief Implementation of the render call + public: virtual void Render() override; + + /// \brief Get a pointer to the render target. + /// \return Pointer to the render target + protected: virtual RenderTargetPtr RenderTarget() const override; + + /// \brief Create the camera. + protected: void CreateCamera(); + + /// \brief Create dummy render texture. Needed to satisfy inheritance + protected: virtual void CreateRenderTexture(); + + /// \brief Create thermal texture + protected: virtual void CreateThermalTexture(); + + /// \brief Pointer to the ogre camera + protected: Ogre::Camera *ogreCamera = nullptr; + + /// \internal + /// \brief Pointer to private data. + private: std::unique_ptr dataPtr; + + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Visual.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Visual.hh new file mode 100644 index 000000000..11ebc123a --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Visual.hh @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2018 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OGRE2_OGRE2VISUAL_HH_ +#define GZ_RENDERING_OGRE2_OGRE2VISUAL_HH_ + +#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 { + // + /// \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 SetVisible(bool _visible) override; + + // 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 Make scene our friend so it can create ogre2 visuals + private: friend class Ogre2Scene; + }; + } + } +} +#endif diff --git a/ogre2/include/gz/rendering/ogre2/ogre2.hh.in b/ogre2/include/gz/rendering/ogre2/ogre2.hh.in new file mode 100644 index 000000000..c4092f0cd --- /dev/null +++ b/ogre2/include/gz/rendering/ogre2/ogre2.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/ogre2/include/ignition/rendering/ogre2.hh b/ogre2/include/ignition/rendering/ogre2.hh new file mode 100644 index 000000000..d1fc687de --- /dev/null +++ b/ogre2/include/ignition/rendering/ogre2.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh index 3a646db40..b8140cae0 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ArrowVisual.hh @@ -14,31 +14,5 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2ARROWVISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2ARROWVISUAL_HH_ - -#include "ignition/rendering/base/BaseArrowVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ArrowVisual : - public BaseArrowVisual - { - /// \brief Constructor - protected: Ogre2ArrowVisual(); - - /// \brief Destructor - public: virtual ~Ogre2ArrowVisual(); - - /// \brief Only the ogre scene can instanstiate this class - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh index 2605c6f2a..198898c66 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2AxisVisual.hh @@ -14,31 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2AXISVISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2AXISVISUAL_HH_ -#include "ignition/rendering/base/BaseAxisVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2AxisVisual : - public BaseAxisVisual - { - /// \brief Constructor - protected: Ogre2AxisVisual(); - - /// \brief Destructor - public: virtual ~Ogre2AxisVisual(); - - /// \brief Only the ogre scene can instanstiate this class - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh index 41052fee5..c4f5bfede 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,127 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2CAMERA_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2CAMERA_HH_ -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" - -namespace Ogre -{ - class Camera; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2SelectionBuffer; - - /// \brief Ogre2.x implementation of the camera class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Camera : - public BaseCamera - { - /// \brief Constructor - protected: Ogre2Camera(); - - /// \brief Destructor - public: virtual ~Ogre2Camera(); - - // Documenation inherited. - public: virtual void SetHFOV(const math::Angle &_hfov) override; - - // Documenation inherited. - public: virtual double AspectRatio() const override; - - // Documenation inherited. - public: virtual void SetAspectRatio(const double _ratio) override; - - // Documenation inherited. - public: virtual unsigned int AntiAliasing() const override; - - // Documenation inherited. - public: virtual void SetAntiAliasing(const unsigned int _aa) override; - - // Documenation inherited. - public: virtual void SetFarClipPlane(const double _far) override; - - // Documenation inherited. - public: virtual void SetNearClipPlane(const double _near) override; - - public: virtual math::Color BackgroundColor() const; - - public: virtual void SetBackgroundColor(const math::Color &_color); - - // Documenation inherited. - public: virtual void Render() override; - - // Documenation inherited. - public: virtual RenderWindowPtr CreateRenderWindow() override; - - // Documenation inherited. - public: virtual math::Matrix4d ProjectionMatrix() const override; - - // Documenation inherited. - public: virtual math::Matrix4d ViewMatrix() const 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 Destroy() override; - - public: Ogre::Camera *OgreCamera() const; - - // Documenation inherited. - protected: virtual RenderTargetPtr RenderTarget() const override; - - // Documenation 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 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 Make scene our friend so it can create a camera - private: friend class Ogre2Scene; - - /// \brief Make ray query our friend so it can use the internal ogre - /// camera to execute queries - private: friend class Ogre2RayQuery; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh index dc9d4fed5..9a53f0a7e 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,95 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2CONVERSIONS_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2CONVERSIONS_HH_ -#include -#include -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/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 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::PixelFormat Convert(PixelFormat _format); - - /// \brief A list of ogre pixel formats - private: static const Ogre::PixelFormat ogrePixelFormats[PF_COUNT]; - }; - /// \} - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh index 7a31f1ad9..a82872719 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,138 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2DEPTHCAMERA_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2DEPTHCAMERA_HH_ - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -#include -#include - -#include "ignition/rendering/base/BaseDepthCamera.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" - -#include "ignition/common/Event.hh" -#include "ignition/common/Console.hh" - -namespace Ogre -{ - class Material; - class RenderTarget; - class Texture; - class Viewport; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2DepthCameraPrivate; - - /// \brief Depth camera used to render depth data into an image buffer - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DepthCamera : - public BaseDepthCamera - { - /// \brief Constructor - protected: Ogre2DepthCamera(); - - /// \brief Destructor - public: virtual ~Ogre2DepthCamera(); - - /// \brief Initialize the camera - public: virtual void Init() override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Create dummy render texture. Needed to satisfy inheritance - public: virtual void CreateRenderTexture(); - - /// \brief Create a texture which will hold the depth data - /// \brief Set up 1st pass material, texture, and compositor - public: virtual void CreateDepthTexture() override; - - // 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 AddRenderPass(const RenderPassPtr &_pass) override; - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Limit field of view taking care of using a valid value for - /// an OGRE camera. - /// \param[in] _fov expected field of view - /// \return valid field of view - protected: static double LimitFOV(const double _fov); - - /// \brief Create the camera. - protected: void CreateCamera(); - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera; - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh index e348538e7..53e199aff 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,125 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2DYNAMICRENDERABLE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2DYNAMICRENDERABLE_HH_ + */ -#include -#include -#include - -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/Marker.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declarations - class Ogre2DynamicRenderablePrivate; - - /* \class Ogre2DynamicRenderable Ogre2DynamicRenderable.hh \ - * ignition/rendering/ogre2/Ogre2DynamicRenderable.hh - */ - /// \brief Dynamic renderable class that manages hardware buffers for - /// a dynamic geometry - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DynamicRenderable - { - /// \brief Constructor - /// \param[in] _scene Pointer to scene - public: explicit Ogre2DynamicRenderable(ScenePtr _scene); - - /// \brief Virtual destructor - public: virtual ~Ogre2DynamicRenderable(); - - /// \brief Set the render operation type - /// \param[in] _opType The type of render operation to perform. - public: void SetOperationType(MarkerType _opType); - - /// \brief Get the render operation type - /// \return The render operation type. - public: MarkerType OperationType() const; - - /// \brief Update the dynamic renderable - public: void Update(); - - /// \brief Get the ogre object associated with this dynamic renderable - public: Ogre::MovableObject *OgreObject() const; - - /// \brief Add a point to the point list - /// \param[in] _pt ignition::math::Vector3d point - /// \param[in] _color ignition::math::Color Point color - public: void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color = ignition::math::Color::White); - - /// \brief Add a point to the point list. - /// \param[in] _x X position - /// \param[in] _y Y position - /// \param[in] _z Z position - /// \param[in] _color Point color - public: void AddPoint(const double _x, const double _y, const double _z, - const ignition::math::Color &_color = ignition::math::Color::White); - - /// \brief Change the location of an existing point in the point list - /// \param[in] _index Index of the point to set - /// \param[in] _value Position of the point - public: void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value); - - /// \brief Change the color of an existing point in the point list - /// \param[in] _index Index of the point to set - /// \param[in] _color color to set the point to - public: void SetColor(unsigned int _index, - const ignition::math::Color &_color); - - /// \brief Return the position of an existing point in the point list - /// \param[in] _index Get the point at this index - /// \return position of point. A vector of - /// [ignition::math::INF_D, ignition::math::INF_D, ignition::math::INF_D] - /// is returned when then the _index is out of bounds. - /// ignition::math::INF_D==std::numeric_limits::infinity() - public: ignition::math::Vector3d Point(unsigned int _index) const; - - /// \brief Return the total number of points in the point list - /// \return Number of points - public: unsigned int PointCount() const; - - /// \brief Remove all points from the point list - public: void Clear(); - - /// \brief Destroy the dynamic renderable - public: void Destroy(); - - /// \brief Set the material for this dynamic renderable - /// \param[in] _material New Material to be assigned - /// \param[in] _unique True if the given material should be cloned - public: void SetMaterial(MaterialPtr _material, bool _unique = true); - - /// \brief Create the dynamic mesh - private: void CreateDynamicMesh(); - - /// \brief Update vertex buffer if vertices have changes - private: void UpdateBuffer(); - - /// \brief Helper function to generate normals - /// \param[in] _opType Ogre render operation type - /// \param[in] _vertices a list of vertices - /// \param[in,out] _vbuffer vertex buffer to be filled - private: void GenerateNormals(Ogre::OperationType _opType, - const std::vector &_vertices, float *_vbuffer); - - /// \brief Destroy the vertex buffer - private: void DestroyBuffer(); - - /// \brief Pointer to private data - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh index e708c5725..50ddf972a 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,43 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2GAUSSIANNOISEPASS_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2GAUSSIANNOISEPASS_HH_ -#include "ignition/rendering/base/BaseGaussianNoisePass.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderPass.hh" -#include "ignition/rendering/ogre2/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \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 the Gaussian noise ogre material - private: Ogre::Material *gaussianNoiseMat = nullptr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh index fbea7edf5..8951eb047 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Geometry.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,55 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2GEOMETRY_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2GEOMETRY_HH_ -#include "ignition/rendering/base/BaseGeometry.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre2.x implementation of the geometry class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Geometry : - public BaseGeometry - { - /// \brief Constructor - protected: Ogre2Geometry(); - - /// \brief Destructor - public: virtual ~Ogre2Geometry(); - - // Documentation inherited. - public: virtual bool HasParent() const override; - - // Documentation inherited. - public: virtual VisualPtr Parent() const override; - - /// \brief Get the ogre object representing this geometry - /// \return Pointer to an ogre movable object - public: virtual Ogre::MovableObject *OgreObject() const = 0; - - /// \brief Set the parent of this ogre geometry - /// \param[in] _parent Parent visual - protected: virtual void SetParent(Ogre2VisualPtr _parent); - - /// \brief Parent visual - protected: Ogre2VisualPtr parent; - - /// \brief Make ogre2 visual our friend so it can it can access function - /// for setting the parent of this geometry - private: friend class Ogre2Visual; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh index daf85011d..b082ccdc7 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2GizmoVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2GIZMOVISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2GIZMOVISUAL_HH_ -#include "ignition/rendering/base/BaseGizmoVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2GizmoVisual : - public BaseGizmoVisual - { - /// \brief Constructor - protected: Ogre2GizmoVisual(); - - /// \brief Destructor - public: virtual ~Ogre2GizmoVisual(); - - /// \brief Only the ogre scene can instanstiate this class - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh index 58506ed56..b524a3744 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,153 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2GPURAYS_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2GPURAYS_HH_ - -#include -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/base/BaseGpuRays.hh" -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" - -#include "ignition/common/Event.hh" -#include "ignition/common/Console.hh" - -namespace Ogre -{ - class Material; - class RenderTarget; - class Texture; - class Viewport; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2GpuRaysPrivate; - - /// \brief Gpu Rays used to render range data into an image buffer - /// The ogre2 implementation takes a 2 pass process to generate - /// the final range data. - /// 1st Pass: Creates a cubemap of range data. The cubemap is created from - /// six cameras looking in all directions. Depending on the min/max angles - /// specified, not all cameras need to be created. Internally in the 1st - /// pass shaders, we reconstruct 3d viewspace pos from depth buffer data - /// then convert them into ranges, i.e. length(pos.xyz). - /// 2nd Pass: Samples range data from cubemap using predefined rays. The - /// rays are generated based on the specified vertical and horizontal - /// min/max angles and no. of samples. Each ray is a direction vector that - /// is used to sample/lookup the range data stored in the faces of the - /// cubemap. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2GpuRays : - public BaseGpuRays - { - /// \brief Constructor - protected: Ogre2GpuRays(); - - /// \brief Destructor - public: virtual ~Ogre2GpuRays(); - - // Documentation inherited - public: virtual void Init() override; - - // Documentation inherited - public: virtual void Destroy() override; - - /// \brief Create dummy render texture. Needed to satisfy inheritance - public: virtual void CreateRenderTexture(); - - // Documentation inherited - public: virtual void PreRender() override; - - // Documentation inherited - public: virtual void PostRender() override; - - // Documentation inherited - public: virtual const float *Data() const override; - - // Documentation inherited. - public: virtual void Copy(float *_data) override; - - // Documentation inherited. - public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame( - std::function _subscriber) override; - - // Documentation inherited. - public: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Set the number of samples in the width and height for the - /// first pass texture. - /// \param[in] _w Number of samples in the horizontal sweep - /// \param[in] _h Number of samples in the vertical sweep - private: virtual void Set1stTextureSize(const unsigned int _w, - const unsigned int _h = 1); - - /// \brief Set the number of samples in the width and height for the - /// second pass texture. - /// \param[in] _w Number of samples in the horizontal sweep - /// \param[in] _h Number of samples in the vertical sweep - private: virtual void SetRangeCount(const unsigned int _w, - const unsigned int _h = 1); - - // Documentation inherited. - private: virtual void Render() override; - - /// \brief Configure camera. - private: void ConfigureCamera(); - - /// \brief Create an ortho camera. - private: void CreateCamera(); - - /// \brief Create the texture which is used to render gpu rays data. - private: virtual void CreateGpuRaysTextures(); - - /// \brief Update the render targets in the 1st pass - private: void UpdateRenderTarget1stPass(); - - /// \brief Update the 2nd pass render target - private: void UpdateRenderTarget2ndPass(); - - /// \brief Create texture that store cubemap uv coordinates and - /// cubemap face index data - private: void CreateSampleTexture(); - - /// \brief Set up 1st pass material, texture, and compositor - private: void Setup1stPass(); - - /// \brief Set up 2nd pass material, texture, and compositor - private: void Setup2ndPass(); - - /// \brief Helper function to convert a direction vector to the - /// index number of a cubemap face and texture uv coordinates on that face - /// \param[in] _v Direction vector - /// \param[out] _faceIndex Index of face to sample - /// \return Texture UV coordinates on the face indicated by _faceIndex - private: math::Vector2d SampleCubemap(const math::Vector3d &_v, - unsigned int &_faceIndex); - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - /// \brief Only the scene can create a GpuRays sensor - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh index b7f8b4d8f..81e386ec3 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,69 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2GRID_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2GRID_HH_ - -#include -#include "ignition/rendering/base/BaseGrid.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" - -namespace Ogre -{ - class MovableObject; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2GridPrivate; - - /// \brief Ogre2 implementation of a grid geometry. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Grid - : public BaseGrid - { - /// \brief Constructor - protected: Ogre2Grid(); - - /// \brief Destructor - public: virtual ~Ogre2Grid(); - - // Documentation inherited. - public: virtual void Init(); - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const; - - // Documentation inherited. - public: virtual void PreRender(); - - // Documentation inherited. - public: virtual MaterialPtr Material() const; - - // Documentation inherited. - public: virtual void SetMaterial(MaterialPtr _material, bool _unique); - - /// \brief Set material to grid geometry. - /// \param[in] _material Ogre material. - protected: virtual void SetMaterialImpl(Ogre2MaterialPtr _material); - - /// \brief Create the grid geometry in ogre - private: void Create(); - - /// \brief Grid should only be created by scene. - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh index 8d2ce9e79..06eb4d78e 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,96 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2INCLUDES_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2INCLUDES_HH_ -#if defined(__clang__) - // This prevents some deprecation #warning messages on OSX 10.9 - #pragma clang diagnostic ignored "-W#warnings" -#elif defined(__GNUC__) || defined(__GNUG__) - #pragma GCC system_header -#elif defined(_MSC_VER) - // This disables warning messages for OGRE - #pragma warning(push) - #pragma warning(disable: 4275) - #pragma warning(disable: 4005) - #pragma warning(disable: 5033) -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#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 - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - -#endif // IGNITION_RENDERING_OGRE2_OGRE2INCLUDES_HH_ +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh index b7f641eb0..f8b328717 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,182 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2LIGHT_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2LIGHT_HH_ -#include "ignition/rendering/base/BaseLight.hh" -#include "ignition/rendering/ogre2/Ogre2Node.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" - -namespace Ogre -{ - class Light; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \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; - - /// \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 Ogre 2.x implementation of the directional light class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DirectionalLight : - public BaseDirectionalLight - { - /// \brief Constructor - protected: Ogre2DirectionalLight(); - - /// \brief Destructor - public: virtual ~Ogre2DirectionalLight(); - - // Documentation Inherited - public: virtual math::Vector3d Direction() const override; - - // Documentation Inherited - public: virtual void SetDirection(const math::Vector3d &_dir) override; - - /// \brief Ogre 2.x implementation of the directional light class - private: friend class Ogre2Scene; - }; - - /// \brief Ogre 2.x implementation of the point light class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2PointLight : - public BasePointLight - { - /// \brief Constructor - protected: Ogre2PointLight(); - - /// \brief Destructor - public: virtual ~Ogre2PointLight(); - - /// \brief Only an ogre scene can create an ogre point light - private: friend class Ogre2Scene; - }; - - /// \brief Ogre 2.x implementation of the spot light class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SpotLight : - public BaseSpotLight - { - /// \brief Constructor - protected: Ogre2SpotLight(); - - /// \brief Destructor - public: virtual ~Ogre2SpotLight(); - - // Documentation inherited. - public: virtual math::Vector3d Direction() const override; - - // Documentation Inherited - public: virtual void SetDirection(const math::Vector3d &_dir) override; - - // Documentation Inherited - public: virtual math::Angle InnerAngle() const override; - - // Documentation Inherited - public: virtual void SetInnerAngle(const math::Angle &_angle) override; - - // Documentation Inherited - public: virtual math::Angle OuterAngle() const override; - - // Documentation Inherited - public: virtual void SetOuterAngle(const math::Angle &_angle) override; - - // Documentation Inherited - public: virtual double Falloff() const override; - - // Documentation Inherited - public: virtual void SetFalloff(double _falloff) override; - - /// \brief Only an ogre scene can create an ogre spot light - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh index fb1ce3f27..ecfb2ce75 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,81 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGREMARKER_HH_ -#define IGNITION_RENDERING_OGRE2_OGREMARKER_HH_ - -#include -#include "ignition/rendering/base/BaseMarker.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2MarkerPrivate; - - /// \brief Ogre 2.x implementation of a marker geometry. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Marker - : public BaseMarker - { - /// \brief Constructor - protected: Ogre2Marker(); - - /// \brief Destructor - public: virtual ~Ogre2Marker(); - - // Documentation inherited. - public: virtual void Init() override; - - // Documentation inherited. - public: virtual void PreRender() override; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual Ogre::MovableObject *OgreObject() const override; - - // Documentation inherited. - public: virtual MaterialPtr Material() const override; - - // Documentation inherited. - public: virtual void SetMaterial( - MaterialPtr _material, bool _unique) override; - - // Documentation inherited - public: virtual void SetPoint(unsigned int _index, - const ignition::math::Vector3d &_value) override; - - // Documentation inherited - public: virtual void AddPoint(const ignition::math::Vector3d &_pt, - const ignition::math::Color &_color) override; - - // Documentation inherited - public: virtual void ClearPoints() override; - - // Documentation inherited - public: virtual void SetType(const MarkerType _markerType) override; - - // Documentation inherited - public: virtual MarkerType Type() const override; - - /// \brief Create the marker geometry in ogre - private: void Create(); - - /// \brief Marker should only be created by scene. - private: friend class Ogre2Scene; - - /// \brief Private data class - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh index 3b8c0b2c2..23f14cb05 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,229 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2MATERIAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2MATERIAL_HH_ -#include - -#include "ignition/rendering/base/BaseMaterial.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \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 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 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 datablock - /// \return Ogre Hlms datablock - public: virtual Ogre::HlmsPbsDatablock *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; - - /// \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::TexturePtr 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 Ogre material. Mainly used for render targets. - protected: Ogre::MaterialPtr ogreMaterial; - - /// \brief Ogre data block containing all material properties - protected: Ogre::HlmsPbsDatablock *ogreDatablock = 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 Unique id assigned to ogre hlms datablock - protected: std::string ogreDatablockId; - - /// \brief Only an ogre scene can create an ogre material - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh index de8471190..4cced0f3d 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,90 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2MATERIALSWITCHER_HH_ - -#include -#include - -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" - -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::RenderTargetListener - { - /// \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] _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 Color dictionary that maps the unique color value to - /// renderable name - private: std::map colorDict; - - /// \brief A map of ogre sub item pointer to their original hlms material - private: std::map datablockMap; - - /// \brief Ogre v1 material consisting of a shader that changes the - /// appearance of item to use a unique color for mouse picking - private: Ogre::MaterialPtr plainMaterial; - - /// \brief Ogre v1 material consisting of a shader that changes the - /// appearance of item to use a unique color for mouse picking. In - /// addition, the depth check and depth write properties disabled. - private: Ogre::MaterialPtr plainOverlayMaterial; - - /// \brief Increment unique color value that will be assigned to the - /// next renderable - private: void NextColor(); - - /// \brief Selection Buffer class that make use of this class for - /// selecting entitiies - public: friend class Ogre2SelectionBuffer; - - /// \brief Plain material technique - private: Ogre2ScenePtr scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh index 9900a3f17..7c1ae35fa 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,103 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2MESH_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2MESH_HH_ -#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 { - // - /// \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 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 Ogre2.x implementation of the submesh class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SubMesh : - public BaseSubMesh - { - /// \brief Constructor - protected: Ogre2SubMesh(); - - /// \brief Destructor - public: virtual ~Ogre2SubMesh(); - - /// \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); - - /// \brief Initialize the submesh - protected: virtual void Init(); - - /// \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; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh index 98af92317..51202d304 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,123 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_ -#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 { - // - /// \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 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; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh index 5a6be9005..2553e4f60 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,120 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2NODE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2NODE_HH_ -#include "ignition/rendering/base/BaseNode.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" - -namespace Ogre -{ - class SceneNode; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre2.x implementation of the Node class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Node : - public BaseNode - { - /// \brief Constructor - protected: Ogre2Node(); - - /// \brief Destructor - public: virtual ~Ogre2Node(); - - // Documentation inherited. - public: virtual bool HasParent() const override; - - // Documentation inherited. - public: virtual NodePtr Parent() const override; - - /// \brief Get a pointer to the underlying scene node - /// \return Ogre scene node pointer - public: virtual Ogre::SceneNode *Node() const; - - // Documentation inherited. - public: virtual void Destroy() override; - - // Documentation inherited. - public: virtual math::Vector3d LocalScale() const override; - - // Documentation inherited. - public: virtual bool InheritScale() const override; - - // Documentation inherited. - public: virtual void SetInheritScale(bool _inherit) override; - - // Documentation inherited. - protected: virtual void SetLocalScaleImpl( - const math::Vector3d &_scale) override; - - // Documentation inherited. - protected: virtual NodeStorePtr Children() const override; - - // Documentation inherited. - protected: virtual bool AttachChild(NodePtr _child) override; - - // Documentation inherited. - protected: virtual bool DetachChild(NodePtr _child) override; - - // Documentation inherited. - protected: virtual math::Pose3d RawLocalPose() const override; - - // Documentation inherited. - protected: virtual void SetRawLocalPose(const math::Pose3d &_Pose3d) - override; - - /// \brief Get the raw local position of the node - /// \return Local position - protected: virtual math::Vector3d RawLocalPosition() const; - - /// \brief Set the raw local position of the node - /// \param[in] _position Local position to set the node to - protected: virtual void SetRawLocalPosition( - const math::Vector3d &_position); - - /// \brief Get the raw local rotation of the node - /// \return Local rotation - protected: virtual math::Quaterniond RawLocalRotation() const; - - /// \brief Set the raw local rotation of the node - /// \param[in] _rotation Local rotation to set the node to - protected: virtual void SetRawLocalRotation( - const math::Quaterniond &_rotation); - - /// \brief Set the parent node - /// \param[in] _parent The parent ogre node - protected: virtual void SetParent(Ogre2NodePtr _parent); - - // Documentation inherited. - protected: virtual void Load() override; - - // Documentation inherited. - protected: virtual void Init() override; - - /// \brief get a shared pointer to this - private: Ogre2NodePtr SharedThis(); - - /// \brief Pointer to the parent ogre node - protected: Ogre2NodePtr parent; - - /// \brief The underlying ogre scene node - protected: Ogre::SceneNode *ogreNode = nullptr; - - /// \brief A list of child nodes - protected: Ogre2NodeStorePtr children; - - // TODO(anyone): remove the need for a visual friend class - private: friend class Ogre2Visual; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh index 1efe6b1eb..dd261d565 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Object.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,40 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2OBJECT_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2OBJECT_HH_ -#include "ignition/rendering/config.hh" -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre2.x implementation of the Object class - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Object : - public BaseObject - { - /// \brief Constructor - protected: Ogre2Object(); - - /// \brief Destructor - public: virtual ~Ogre2Object(); - - // Documentation inherited - public: virtual ScenePtr Scene() const override; - - /// \brief Pointer to the ogre scene - protected: Ogre2ScenePtr scene; - - /// \brief Make ogre scene our friend so it is able to create objects - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh index 96a1e9f44..3ce9ed7df 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,51 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RAYQUERY_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RAYQUERY_HH_ -#include - -#include "ignition/rendering/base/BaseRayQuery.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2RayQueryPrivate; - - /// \class Ogre2RayQuery Ogre2RayQuery.hh - /// ignition/rendering/ogre2/Ogre2RayQuery.hh - /// \brief A Ray Query class used for computing ray object intersections - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RayQuery : - public BaseRayQuery - { - /// \brief Constructor - protected: Ogre2RayQuery(); - - /// \brief Destructor - public: virtual ~Ogre2RayQuery(); - - // Documentation inherited - public: virtual void SetFromCamera(const CameraPtr &_camera, - const math::Vector2d &_coord); - - // Documentation inherited - public: virtual RayQueryResult ClosestPoint(); - - /// \brief Private data pointer - private: std::unique_ptr dataPtr; - - /// \brief Pointer to friend scene class for creating ray query - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh index c6f212e7a..79ac0655c 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,194 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERENGINE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RENDERENGINE_HH_ -#include -#include -#include -#include - -#include - -#include "ignition/rendering/RenderEnginePlugin.hh" -#include "ignition/rendering/base/BaseRenderEngine.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Export.hh" - -namespace Ogre -{ - class LogManager; - class Root; - namespace v1 - { - class OverlaySystem; - } -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - class Ogre2RenderEnginePrivate; - - /// \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 resourcea in ogre2's resource manager - /// \param[in] _uri Reousrce path in the form of an uri - public: void AddResourcePath(const std::string &_uri) override; - - /// \brief Get the ogre2 root object - /// \return ogre2 root object - public: virtual Ogre::Root *OgreRoot() const; - - /// \brief Create a render window - /// \param[in] _handle Handle of native window which the render window - /// will attach - /// \param[in] _width Width of render window - /// \param[in] _height Height of render window - /// \param[in] _ratio Device pixel ratio (typically needed for retina - /// displays) - /// \param[in] _antiAliasing Anti-aliasing level - public: std::string CreateRenderWindow(const std::string &_handle, - const unsigned int _width, const unsigned int _height, - const double _ratio, const unsigned int _antiAliasing); - - /// \brief 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 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; - - /// \internal - /// \brief Get a pointer to the Ogre overlay system. - /// \return Pointer to the ogre overlay system. - public: Ogre::v1::OverlaySystem *OverlaySystem() 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 True to use the current opengl context - private: bool useCurrentGLContext = false; - - /// \brief Pointer to private data - private: std::unique_ptr dataPtr; - - /// \brief Singleton setup - private: friend class common::SingletonT; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh index f54f67db1..2f07a5006 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,61 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERPASS_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RENDERPASS_HH_ -#include - -#include "ignition/rendering/base/BaseRenderPass.hh" -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /* \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; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh index 60970d203..1842e0ff1 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,240 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_ -#include -#include -#include - -#include "ignition/rendering/base/BaseRenderTypes.hh" -#include "ignition/rendering/base/BaseRenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh" - -namespace Ogre -{ - class Camera; - class RenderTarget; - class Texture; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \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); - - // 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); - - /// \brief Get a pointer to the ogre render target - public: virtual Ogre::RenderTarget *RenderTarget() const = 0; - - /// \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); - - /// \brief Update the background color - protected: virtual void UpdateBackgroundColor(); - - /// \brief Update the render pass chain - protected: virtual void UpdateRenderPassChain(); - - /// \brief Create a compositor shadow node with the same number of shadow - /// textures as the number of shadow casting lights - protected: void UpdateShadowNode(); - - /// \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 comopsitor - 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 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); - - /// \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 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 Anti-aliasing level - protected: unsigned int antiAliasing = 4; - }; - - /// \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 Ogre::RenderTarget *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 Pointer to the internal ogre render texture object - protected: Ogre::Texture *ogreTexture = nullptr; - - /// \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 Ogre::RenderTarget *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::RenderTarget *ogreRenderWindow = nullptr; - - /// \brief Make scene our friend so it can create a ogre2 render window - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh index 4f5eb1369..49cf9ca38 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,88 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGETMATERIAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RENDERTARGETMATERIAL_HH_ -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Export.hh" - -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::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: Ogre2RenderTargetMaterial(Ogre::SceneManager *_scene, - Ogre::RenderTarget *_renderTarget, Ogre::Material *_material); - - /// \brief destructor - public: ~Ogre2RenderTargetMaterial(); - - /// \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: Ogre::SceneManager *scene = nullptr; - - /// \brief render target that should see a uniform material - private: Ogre::RenderTarget *renderTarget = 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; - }; - } - } -} - -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh index 53d7ec89e..fca4ffa0c 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,100 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERTYPES_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2RENDERTYPES_HH_ -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class Ogre2ArrowVisual; - class Ogre2AxisVisual; - class Ogre2Camera; - class Ogre2DepthCamera; - class Ogre2DirectionalLight; - class Ogre2Geometry; - class Ogre2GizmoVisual; - class Ogre2GpuRays; - class Ogre2Grid; - class Ogre2Light; - class Ogre2Marker; - class Ogre2Material; - class Ogre2Mesh; - class Ogre2MeshFactory; - class Ogre2Node; - class Ogre2Object; - class Ogre2PointLight; - class Ogre2RayQuery; - class Ogre2RenderEngine; - class Ogre2RenderTarget; - class Ogre2RenderTargetMaterial; - class Ogre2RenderTexture; - class Ogre2RenderWindow; - class Ogre2Scene; - class Ogre2Sensor; - class Ogre2SpotLight; - class Ogre2SubMesh; - class Ogre2ThermalCamera; - class Ogre2Visual; - - 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 Ogre2DepthCameraPtr; - typedef shared_ptr Ogre2DirectionalLightPtr; - typedef shared_ptr Ogre2GeometryPtr; - typedef shared_ptr Ogre2GizmoVisualPtr; - typedef shared_ptr Ogre2GpuRaysPtr; - typedef shared_ptr Ogre2GridPtr; - typedef shared_ptr Ogre2LightPtr; - 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 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 Ogre2SensorPtr; - typedef shared_ptr Ogre2SpotLightPtr; - typedef shared_ptr Ogre2SubMeshPtr; - typedef shared_ptr Ogre2ThermalCameraPtr; - typedef shared_ptr Ogre2VisualPtr; - - typedef shared_ptr Ogre2GeometryStorePtr; - typedef shared_ptr Ogre2LightStorePtr; - typedef shared_ptr Ogre2NodeStorePtr; - typedef shared_ptr Ogre2RenderTargetMaterialPtr; - typedef shared_ptr Ogre2SceneStorePtr; - typedef shared_ptr Ogre2SensorStorePtr; - typedef shared_ptr Ogre2SubMeshStorePtr; - typedef shared_ptr Ogre2VisualStorePtr; - - typedef shared_ptr Ogre2MaterialMapPtr; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh index a6dbe26cd..efc13e0b2 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,251 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2SCENE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2SCENE_HH_ -#include - -#include "ignition/rendering/Storage.hh" -#include "ignition/rendering/base/BaseScene.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" - -#include "ignition/rendering/ogre2/Export.hh" - -namespace Ogre -{ - class Root; - class SceneManager; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \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 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; - - /// \brief Get a pointer to the ogre scene manager - /// \return Pointer to the ogre scene manager - public: virtual Ogre::SceneManager *OgreSceneManager() const; - - /// \cond PRIVATE - /// \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 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 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 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 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; - - /// \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); - - // 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 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 Pointer to the ogre scene manager - protected: Ogre::SceneManager *ogreSceneManager = nullptr; - - /// \brief Make the render engine our friend - private: friend class Ogre2RenderEngine; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh index 0afec5482..7ae7df2c9 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,72 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2SELECTIONBUFFER_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2SELECTIONBUFFER_HH_ + */ -#include -#include - -#include "ignition/rendering/config.hh" -#include "ignition/rendering/ogre2/Export.hh" - -namespace Ogre -{ - class Item; - class RenderTarget; - class SceneManager; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // forward declaration - struct Ogre2SelectionBufferPrivate; - - /// \brief Generates a selection buffer object for a given camera. - /// The selection buffer is used of entity selection. On setup, a unique - /// color is assigned to each entity. Whenever a selection request is made, - /// the selection buffer camera renders to a 1x1 sized offscreen buffer. - /// The color value of that pixel gives the identity of the entity. - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SelectionBuffer - { - /// \brief Constructor - /// \param[in] _cameraName Name of the camera to generate a selection - /// buffer for. - /// \param[in] _scene Pointer to the scene - public: Ogre2SelectionBuffer(const std::string &_cameraName, - Ogre2ScenePtr _scene); - - /// \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 Call this to update the selection buffer contents - public: void Update(); - - /// \brief Delete the render texture - private: void DeleteRTTBuffer(); - - /// \brief Create the render texture - private: void CreateRTTBuffer(); - - /// \brief Create the selection buffer offscreen render texture. - // private: void CreateRTTOverlays(); - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh index 47b7da64d..7bdae889b 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Sensor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2SENSOR_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2SENSOR_HH_ -#include "ignition/rendering/base/BaseSensor.hh" -#include "ignition/rendering/ogre2/Ogre2Node.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Ogre2.x implementation of the sensor classs - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Sensor : - public BaseSensor - { - /// \brief Constructor - protected: Ogre2Sensor(); - - /// \brief Destructor - public: virtual ~Ogre2Sensor(); - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh index 318cf7da5..b5a1da7b8 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,55 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2STORAGE_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2STORAGE_HH_ -#include - -#include "ignition/rendering/base/BaseStorage.hh" - -#include "ignition/rendering/ogre2/Ogre2Light.hh" -#include "ignition/rendering/ogre2/Ogre2Mesh.hh" -#include "ignition/rendering/ogre2/Ogre2Node.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - -// armhf failed to build with this code. It can not be removed for the rest -// of arches to keep ABI but should be removed in major versions unreleased -// see https://github.com/ignitionrobotics/ign-rendering/pull/457 -#ifndef __ARM_PCS_VFP - template class BaseGeometryStore; - template class BaseLightStore; - template class BaseNodeStore; - template class BaseSceneStore; - template class BaseSensorStore; - template class BaseSubMeshStore; - template class BaseVisualStore; -#endif - - typedef BaseGeometryStore Ogre2GeometryStore; - typedef BaseLightStore Ogre2LightStore; - typedef BaseNodeStore Ogre2NodeStore; - typedef BaseSceneStore Ogre2SceneStore; - typedef BaseSensorStore Ogre2SensorStore; - typedef BaseSubMeshStore Ogre2SubMeshStore; - typedef BaseVisualStore Ogre2VisualStore; - - typedef std::shared_ptr Ogre2GeometryStorePtr; - typedef std::shared_ptr Ogre2LightStorePtr; - typedef std::shared_ptr Ogre2NodeStorePtr; - typedef std::shared_ptr Ogre2SceneStorePtr; - typedef std::shared_ptr Ogre2SensorStorePtr; - typedef std::shared_ptr Ogre2SubMeshStorePtr; - typedef std::shared_ptr Ogre2VisualStorePtr; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh index bbdfc4f21..9f2377831 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,100 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2THERMALCAMERA_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2THERMALCAMERA_HH_ - -#ifdef _WIN32 - // Ensure that Winsock2.h is included before Windows.h, which can get - // pulled in by anybody (e.g., Boost). - #include -#endif - -#include -#include - -#include "ignition/rendering/base/BaseThermalCamera.hh" -#include "ignition/rendering/ogre2/Export.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" - -#include "ignition/common/Event.hh" -#include "ignition/common/Console.hh" - -namespace Ogre -{ - class Material; - class RenderTarget; - class Texture; - class Viewport; -} - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - // Forward declaration - class Ogre2ThermalCameraPrivate; - - /// \brief Thermal camera used to render thermal data into an image buffer - class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ThermalCamera : - public BaseThermalCamera - { - /// \brief Constructor - protected: Ogre2ThermalCamera(); - - /// \brief Destructor - public: virtual ~Ogre2ThermalCamera(); - - /// \brief Initialize the camera - public: virtual void Init() override; - - // Documentation inherited - public: virtual void Destroy() override; - - // Documentation inherited - public: virtual void PreRender() override; - - /// \brief Render the camera - public: virtual void PostRender() override; - - /// \brief Connect to the new thermal image event - /// \param[in] _subscriber Subscriber callback function - /// \return Pointer to the new Connection. This must be kept in scope - public: virtual ignition::common::ConnectionPtr ConnectNewThermalFrame( - std::function _subscriber) override; - - /// \brief Implementation of the render call - public: virtual void Render() override; - - /// \brief Get a pointer to the render target. - /// \return Pointer to the render target - protected: virtual RenderTargetPtr RenderTarget() const override; - - /// \brief Create the camera. - protected: void CreateCamera(); - - /// \brief Create dummy render texture. Needed to satisfy inheritance - protected: virtual void CreateRenderTexture(); - - /// \brief Create thermal texture - protected: virtual void CreateThermalTexture(); - - /// \brief Pointer to the ogre camera - protected: Ogre::Camera *ogreCamera = nullptr; - - /// \internal - /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh index 94a8779fe..82e2f07e5 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,55 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OGRE2_OGRE2VISUAL_HH_ -#define IGNITION_RENDERING_OGRE2_OGRE2VISUAL_HH_ -#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 { - // - /// \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 SetVisible(bool _visible) override; - - // 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 Make scene our friend so it can create ogre2 visuals - private: friend class Ogre2Scene; - }; - } - } -} -#endif +#include +#include diff --git a/ogre2/include/ignition/rendering/ogre2/ogre2.hh.in b/ogre2/include/ignition/rendering/ogre2/ogre2.hh.in deleted file mode 100644 index acfd26ae7..000000000 --- a/ogre2/include/ignition/rendering/ogre2/ogre2.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/ogre2/src/Ogre2Camera.cc b/ogre2/src/Ogre2Camera.cc index 2d5f21d08..3309c90c1 100644 --- a/ogre2/src/Ogre2Camera.cc +++ b/ogre2/src/Ogre2Camera.cc @@ -15,16 +15,16 @@ * */ -#include "ignition/rendering/ogre2/Ogre2Camera.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -// #include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2SelectionBuffer.hh" -#include "ignition/rendering/Utils.hh" - -using namespace ignition; +#include "gz/rendering/ogre2/Ogre2Camera.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +// #include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2SelectionBuffer.hh" +#include "gz/rendering/Utils.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Conversions.cc b/ogre2/src/Ogre2Conversions.cc index 6ba9e2a7e..eb79d70db 100644 --- a/ogre2/src/Ogre2Conversions.cc +++ b/ogre2/src/Ogre2Conversions.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2DepthCamera.cc b/ogre2/src/Ogre2DepthCamera.cc index e95153a5b..838e1a12c 100644 --- a/ogre2/src/Ogre2DepthCamera.cc +++ b/ogre2/src/Ogre2DepthCamera.cc @@ -24,18 +24,18 @@ #endif #include -#include +#include -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2DepthCamera.hh" -#include "ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2DepthCamera.hh" +#include "gz/rendering/ogre2/Ogre2GaussianNoisePass.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" namespace ignition @@ -72,7 +72,7 @@ class Ogre2DepthGaussianNoisePass : public Ogre2GaussianNoisePass /// \internal /// \brief Private data for the Ogre2DepthCamera class -class ignition::rendering::Ogre2DepthCameraPrivate +class gz::rendering::Ogre2DepthCameraPrivate { /// \brief The depth buffer public: float *depthBuffer = nullptr; @@ -84,10 +84,10 @@ class ignition::rendering::Ogre2DepthCameraPrivate public: float *pointCloudImage = nullptr; /// \brief maximum value used for data outside sensor range - public: float dataMaxVal = ignition::math::INF_D; + public: float dataMaxVal = gz::math::INF_D; /// \brief minimum value used for data outside sensor range - public: float dataMinVal = -ignition::math::INF_D; + public: float dataMinVal = -gz::math::INF_D; /// \brief 1st pass compositor workspace definition public: std::string ogreCompositorWorkspaceDef; @@ -120,17 +120,17 @@ class ignition::rendering::Ogre2DepthCameraPrivate public: bool renderPassDirty = false; /// \brief Event used to signal rgb point cloud data - public: ignition::common::EventT newRgbPointCloud; /// \brief Event used to signal depth data - public: ignition::common::EventT newDepthFrame; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2DynamicRenderable.cc b/ogre2/src/Ogre2DynamicRenderable.cc index a95ffa08b..426cdbee6 100644 --- a/ogre2/src/Ogre2DynamicRenderable.cc +++ b/ogre2/src/Ogre2DynamicRenderable.cc @@ -26,21 +26,21 @@ #pragma warning(pop) #endif -#include "ignition/common/Console.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2DynamicRenderable.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2DynamicRenderable.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" /// \brief Private implementation -class ignition::rendering::Ogre2DynamicRenderablePrivate +class gz::rendering::Ogre2DynamicRenderablePrivate { /// \brief list of colors at each point - public: std::vector colors; + public: std::vector colors; /// \brief List of vertices for the mesh - public: std::vector vertices; + public: std::vector vertices; /// \brief Used to indicate if the lines require an update public: bool dirty = false; @@ -81,7 +81,7 @@ class ignition::rendering::Ogre2DynamicRenderablePrivate }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2GaussianNoisePass.cc b/ogre2/src/Ogre2GaussianNoisePass.cc index 92f22f653..878ec2ebc 100644 --- a/ogre2/src/Ogre2GaussianNoisePass.cc +++ b/ogre2/src/Ogre2GaussianNoisePass.cc @@ -16,14 +16,14 @@ */ -#include +#include -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2GaussianNoisePass.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Geometry.cc b/ogre2/src/Ogre2Geometry.cc index 007b1f7e4..24f309d94 100644 --- a/ogre2/src/Ogre2Geometry.cc +++ b/ogre2/src/Ogre2Geometry.cc @@ -14,12 +14,12 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" +#include "gz/rendering/ogre2/Ogre2Geometry.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2GizmoVisual.cc b/ogre2/src/Ogre2GizmoVisual.cc index 5c7b2eba7..f5d3be24a 100644 --- a/ogre2/src/Ogre2GizmoVisual.cc +++ b/ogre2/src/Ogre2GizmoVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre2/Ogre2GizmoVisual.hh" +#include "gz/rendering/ogre2/Ogre2GizmoVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2GpuRays.cc b/ogre2/src/Ogre2GpuRays.cc index f45ccaf95..93af54961 100644 --- a/ogre2/src/Ogre2GpuRays.cc +++ b/ogre2/src/Ogre2GpuRays.cc @@ -15,23 +15,23 @@ * */ -#include -#include - -#include -#include - -#include "ignition/rendering/ogre2/Ogre2Camera.hh" -#include "ignition/rendering/ogre2/Ogre2GpuRays.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" +#include +#include + +#include +#include + +#include "gz/rendering/ogre2/Ogre2Camera.hh" +#include "gz/rendering/ogre2/Ogre2GpuRays.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" namespace ignition { @@ -83,7 +83,7 @@ class Ogre2LaserRetroMaterialSwitcher : public Ogre::RenderTargetListener /// \internal /// \brief Private data for the Ogre2GpuRays class -class ignition::rendering::Ogre2GpuRaysPrivate +class gz::rendering::Ogre2GpuRaysPrivate { /// \brief Event triggered when new gpu rays range data are available. /// \param[in] _frame New frame containing raw gpu rays data. @@ -91,7 +91,7 @@ class ignition::rendering::Ogre2GpuRaysPrivate /// \param[in] _height Height of frame. /// \param[in] _channel Number of channels /// \param[in] _format Format of frame. - public: ignition::common::EventT newGpuRaysFrame; @@ -164,7 +164,7 @@ class ignition::rendering::Ogre2GpuRaysPrivate laserRetroMaterialSwitcher[6]; }; -using namespace ignition; +using namespace gz; using namespace rendering; diff --git a/ogre2/src/Ogre2Grid.cc b/ogre2/src/Ogre2Grid.cc index a2f2c49ac..63078c3ed 100644 --- a/ogre2/src/Ogre2Grid.cc +++ b/ogre2/src/Ogre2Grid.cc @@ -15,17 +15,17 @@ * */ -#include +#include -#include "ignition/rendering/ogre2/Ogre2Grid.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2DynamicRenderable.hh" +#include "gz/rendering/ogre2/Ogre2Grid.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2DynamicRenderable.hh" -using namespace ignition; +using namespace gz; using namespace rendering; -class ignition::rendering::Ogre2GridPrivate +class gz::rendering::Ogre2GridPrivate { /// \brief Grid materal public: Ogre2MaterialPtr material; diff --git a/ogre2/src/Ogre2Light.cc b/ogre2/src/Ogre2Light.cc index 6e0295663..461fb6251 100644 --- a/ogre2/src/Ogre2Light.cc +++ b/ogre2/src/Ogre2Light.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre2/Ogre2Light.hh" +#include "gz/rendering/ogre2/Ogre2Light.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Marker.cc b/ogre2/src/Ogre2Marker.cc index ae0579d62..aad765675 100644 --- a/ogre2/src/Ogre2Marker.cc +++ b/ogre2/src/Ogre2Marker.cc @@ -15,16 +15,16 @@ * */ -#include +#include -#include "ignition/rendering/ogre2/Ogre2DynamicRenderable.hh" -#include "ignition/rendering/ogre2/Ogre2Marker.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2Mesh.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" +#include "gz/rendering/ogre2/Ogre2DynamicRenderable.hh" +#include "gz/rendering/ogre2/Ogre2Marker.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2Mesh.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" -class ignition::rendering::Ogre2MarkerPrivate +class gz::rendering::Ogre2MarkerPrivate { /// \brief Marker material public: Ogre2MaterialPtr material = nullptr; @@ -40,7 +40,7 @@ class ignition::rendering::Ogre2MarkerPrivate public: std::shared_ptr dynamicRenderable; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Material.cc b/ogre2/src/Ogre2Material.cc index 4924ca3fe..cd6cb9ba5 100644 --- a/ogre2/src/Ogre2Material.cc +++ b/ogre2/src/Ogre2Material.cc @@ -27,17 +27,17 @@ #pragma warning(pop) #endif -#include -#include +#include +#include -#include "ignition/rendering/ShaderParams.hh" -#include "ignition/rendering/ShaderType.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ShaderParams.hh" +#include "gz/rendering/ShaderType.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2MaterialSwitcher.cc b/ogre2/src/Ogre2MaterialSwitcher.cc index 45a2f9176..9dd8bdcec 100644 --- a/ogre2/src/Ogre2MaterialSwitcher.cc +++ b/ogre2/src/Ogre2MaterialSwitcher.cc @@ -15,13 +15,13 @@ * */ -#include "ignition/common/Console.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/RenderTypes.hh" +#include "gz/common/Console.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2MaterialSwitcher.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/RenderTypes.hh" -using namespace ignition; +using namespace gz; using namespace rendering; diff --git a/ogre2/src/Ogre2Mesh.cc b/ogre2/src/Ogre2Mesh.cc index c061bfe94..36c83a46a 100644 --- a/ogre2/src/Ogre2Mesh.cc +++ b/ogre2/src/Ogre2Mesh.cc @@ -27,15 +27,15 @@ #pragma warning(pop) #endif -#include +#include -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Mesh.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2Storage.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Mesh.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2Storage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2MeshFactory.cc b/ogre2/src/Ogre2MeshFactory.cc index 4ac753df7..4b5943d05 100644 --- a/ogre2/src/Ogre2MeshFactory.cc +++ b/ogre2/src/Ogre2MeshFactory.cc @@ -18,23 +18,23 @@ #include -#include -#include -#include -#include -#include - -#include - -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Mesh.hh" -#include "ignition/rendering/ogre2/Ogre2MeshFactory.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Storage.hh" - -using namespace ignition; +#include +#include +#include +#include +#include + +#include + +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Mesh.hh" +#include "gz/rendering/ogre2/Ogre2MeshFactory.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Storage.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Node.cc b/ogre2/src/Ogre2Node.cc index e8b919469..d1c08080c 100644 --- a/ogre2/src/Ogre2Node.cc +++ b/ogre2/src/Ogre2Node.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre2/Ogre2Node.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Storage.hh" +#include "gz/rendering/ogre2/Ogre2Node.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Storage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Object.cc b/ogre2/src/Ogre2Object.cc index 35db61317..1c4d2890d 100644 --- a/ogre2/src/Ogre2Object.cc +++ b/ogre2/src/Ogre2Object.cc @@ -15,11 +15,11 @@ * */ -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Object.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Object.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2RayQuery.cc b/ogre2/src/Ogre2RayQuery.cc index 553a113c7..cbeb4a85f 100644 --- a/ogre2/src/Ogre2RayQuery.cc +++ b/ogre2/src/Ogre2RayQuery.cc @@ -15,25 +15,25 @@ * */ -#include -#include -#include -#include +#include +#include +#include +#include -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Camera.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2RayQuery.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Camera.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2RayQuery.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" /// \brief Private data class for Ogre2RayQuery -class ignition::rendering::Ogre2RayQueryPrivate +class gz::rendering::Ogre2RayQueryPrivate { /// \brief Ogre ray scene query object for computing intersection. public: Ogre::RaySceneQuery *rayQuery = nullptr; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index 049f7e07e..5039ce61a 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -27,21 +27,21 @@ // pulled in by anybody (e.g., Boost). #include #endif -#include -#include -#include +#include +#include +#include -#include +#include -#include "ignition/rendering/RenderEngineManager.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Storage.hh" +#include "gz/rendering/RenderEngineManager.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Storage.hh" -class ignition::rendering::Ogre2RenderEnginePrivate +class gz::rendering::Ogre2RenderEnginePrivate { #if !defined(__APPLE__) && !defined(_WIN32) public: XVisualInfo *dummyVisual = nullptr; @@ -51,7 +51,7 @@ class ignition::rendering::Ogre2RenderEnginePrivate public: std::vector fsaaLevels; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2RenderPass.cc b/ogre2/src/Ogre2RenderPass.cc index e7add222c..2b17f8e92 100644 --- a/ogre2/src/Ogre2RenderPass.cc +++ b/ogre2/src/Ogre2RenderPass.cc @@ -14,10 +14,10 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre2/Ogre2RenderPass.hh" +#include "gz/rendering/ogre2/Ogre2RenderPass.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2RenderTarget.cc b/ogre2/src/Ogre2RenderTarget.cc index 220c51bc9..cbe557194 100644 --- a/ogre2/src/Ogre2RenderTarget.cc +++ b/ogre2/src/Ogre2RenderTarget.cc @@ -27,19 +27,19 @@ #pragma warning(pop) #endif -#include +#include -#include "ignition/rendering/Material.hh" +#include "gz/rendering/Material.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderPass.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderPass.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2RenderTargetMaterial.cc b/ogre2/src/Ogre2RenderTargetMaterial.cc index cfcd8c515..036597b15 100644 --- a/ogre2/src/Ogre2RenderTargetMaterial.cc +++ b/ogre2/src/Ogre2RenderTargetMaterial.cc @@ -15,9 +15,9 @@ * */ -#include "ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh" +#include "gz/rendering/ogre2/Ogre2RenderTargetMaterial.hh" -using namespace ignition::rendering; +using namespace gz::rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Scene.cc b/ogre2/src/Ogre2Scene.cc index e87b7e90a..2d13c4349 100644 --- a/ogre2/src/Ogre2Scene.cc +++ b/ogre2/src/Ogre2Scene.cc @@ -15,32 +15,32 @@ * */ -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2ArrowVisual.hh" -#include "ignition/rendering/ogre2/Ogre2AxisVisual.hh" -#include "ignition/rendering/ogre2/Ogre2Camera.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2DepthCamera.hh" -#include "ignition/rendering/ogre2/Ogre2GizmoVisual.hh" -#include "ignition/rendering/ogre2/Ogre2GpuRays.hh" -#include "ignition/rendering/ogre2/Ogre2Grid.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2Light.hh" -#include "ignition/rendering/ogre2/Ogre2Marker.hh" -#include "ignition/rendering/ogre2/Ogre2Material.hh" -#include "ignition/rendering/ogre2/Ogre2MeshFactory.hh" -#include "ignition/rendering/ogre2/Ogre2Node.hh" -#include "ignition/rendering/ogre2/Ogre2RayQuery.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2ThermalCamera.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" - -using namespace ignition; +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2ArrowVisual.hh" +#include "gz/rendering/ogre2/Ogre2AxisVisual.hh" +#include "gz/rendering/ogre2/Ogre2Camera.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2DepthCamera.hh" +#include "gz/rendering/ogre2/Ogre2GizmoVisual.hh" +#include "gz/rendering/ogre2/Ogre2GpuRays.hh" +#include "gz/rendering/ogre2/Ogre2Grid.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2Light.hh" +#include "gz/rendering/ogre2/Ogre2Marker.hh" +#include "gz/rendering/ogre2/Ogre2Material.hh" +#include "gz/rendering/ogre2/Ogre2MeshFactory.hh" +#include "gz/rendering/ogre2/Ogre2Node.hh" +#include "gz/rendering/ogre2/Ogre2RayQuery.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2ThermalCamera.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" + +using namespace gz; using namespace rendering; // TODO(anyone) make this a member variable in ign-rendering4 diff --git a/ogre2/src/Ogre2SelectionBuffer.cc b/ogre2/src/Ogre2SelectionBuffer.cc index 31ab51c0b..cca97e276 100644 --- a/ogre2/src/Ogre2SelectionBuffer.cc +++ b/ogre2/src/Ogre2SelectionBuffer.cc @@ -16,21 +16,21 @@ */ #include -#include - -#include "ignition/common/Console.hh" -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2SelectionBuffer.hh" - -using namespace ignition; +#include + +#include "gz/common/Console.hh" +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2MaterialSwitcher.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2SelectionBuffer.hh" + +using namespace gz; using namespace rendering; -struct ignition::rendering::Ogre2SelectionBufferPrivate +struct gz::rendering::Ogre2SelectionBufferPrivate { /// \brief This is a material listener and a RenderTargetListener. /// The material switcher is applied to only the selection camera diff --git a/ogre2/src/Ogre2Sensor.cc b/ogre2/src/Ogre2Sensor.cc index 7c919314b..b5a3c831b 100644 --- a/ogre2/src/Ogre2Sensor.cc +++ b/ogre2/src/Ogre2Sensor.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2ThermalCamera.cc b/ogre2/src/Ogre2ThermalCamera.cc index 65ae9d91f..124053443 100644 --- a/ogre2/src/Ogre2ThermalCamera.cc +++ b/ogre2/src/Ogre2ThermalCamera.cc @@ -26,19 +26,19 @@ #include #include -#include -#include - -#include "ignition/rendering/RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Includes.hh" -#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Scene.hh" -#include "ignition/rendering/ogre2/Ogre2Sensor.hh" -#include "ignition/rendering/ogre2/Ogre2ThermalCamera.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" +#include +#include + +#include "gz/rendering/RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Includes.hh" +#include "gz/rendering/ogre2/Ogre2RenderEngine.hh" +#include "gz/rendering/ogre2/Ogre2RenderTarget.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Scene.hh" +#include "gz/rendering/ogre2/Ogre2Sensor.hh" +#include "gz/rendering/ogre2/Ogre2ThermalCamera.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" namespace ignition { @@ -90,7 +90,7 @@ class Ogre2ThermalCameraMaterialSwitcher : public Ogre::RenderTargetListener /// \internal /// \brief Private data for the Ogre2ThermalCamera class -class ignition::rendering::Ogre2ThermalCameraPrivate +class gz::rendering::Ogre2ThermalCameraPrivate { /// \brief The thermal buffer public: uint16_t *thermalBuffer = nullptr; @@ -123,7 +123,7 @@ class ignition::rendering::Ogre2ThermalCameraPrivate public: Ogre::MaterialPtr thermalMaterial; /// \brief Event used to signal thermal image data - public: ignition::common::EventT newThermalFrame; @@ -132,7 +132,7 @@ class ignition::rendering::Ogre2ThermalCameraPrivate thermalMaterialSwitcher = nullptr; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Visual.cc b/ogre2/src/Ogre2Visual.cc index fca7cc54d..a3a4419de 100644 --- a/ogre2/src/Ogre2Visual.cc +++ b/ogre2/src/Ogre2Visual.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/ogre2/Ogre2Conversions.hh" -#include "ignition/rendering/ogre2/Ogre2Geometry.hh" -#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" -#include "ignition/rendering/ogre2/Ogre2Storage.hh" -#include "ignition/rendering/ogre2/Ogre2Visual.hh" +#include "gz/rendering/ogre2/Ogre2Conversions.hh" +#include "gz/rendering/ogre2/Ogre2Geometry.hh" +#include "gz/rendering/ogre2/Ogre2RenderTypes.hh" +#include "gz/rendering/ogre2/Ogre2Storage.hh" +#include "gz/rendering/ogre2/Ogre2Visual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/include/CMakeLists.txt b/optix/include/CMakeLists.txt index 297e254ff..a7479f53e 100644 --- a/optix/include/CMakeLists.txt +++ b/optix/include/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(ignition/rendering) +add_subdirectory(gz/rendering) +install(DIRECTORY ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL}) diff --git a/optix/include/ignition/rendering/CMakeLists.txt b/optix/include/gz/rendering/CMakeLists.txt similarity index 100% rename from optix/include/ignition/rendering/CMakeLists.txt rename to optix/include/gz/rendering/CMakeLists.txt diff --git a/optix/include/gz/rendering/optix/OptixArrowVisual.hh b/optix/include/gz/rendering/optix/OptixArrowVisual.hh new file mode 100644 index 000000000..260fa8dad --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixArrowVisual.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXARROWVISUAL_HH_ +#define GZ_RENDERING_OPTIX_OPTIXARROWVISUAL_HH_ + +#include "gz/rendering/base/BaseArrowVisual.hh" +#include "gz/rendering/optix/OptixVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixArrowVisual : + public BaseArrowVisual + { + protected: OptixArrowVisual(); + + public: virtual ~OptixArrowVisual(); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixAxisVisual.hh b/optix/include/gz/rendering/optix/OptixAxisVisual.hh new file mode 100644 index 000000000..37f93f619 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixAxisVisual.hh @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXAXISVISUAL_HH_ +#define GZ_RENDERING_OPTIX_OPTIXAXISVISUAL_HH_ + +#include "gz/rendering/base/BaseAxisVisual.hh" +#include "gz/rendering/optix/OptixVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixAxisVisual : + public BaseAxisVisual + { + protected: OptixAxisVisual(); + + public: virtual ~OptixAxisVisual(); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixBox.hh b/optix/include/gz/rendering/optix/OptixBox.hh new file mode 100644 index 000000000..872173cfb --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixBox.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXBOX_HH_ +#define GZ_RENDERING_OPTIX_OPTIXBOX_HH_ + +#include "gz/rendering/optix/OptixPrimitive.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixBox : + public OptixPrimitive + { + protected: OptixBox(); + + public: virtual ~OptixBox(); + + public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixCamera.hh b/optix/include/gz/rendering/optix/OptixCamera.hh new file mode 100644 index 000000000..5ac597500 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixCamera.hh @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXCAMERA_HH_ +#define GZ_RENDERING_OPTIX_OPTIXCAMERA_HH_ + +#include +#include "gz/rendering/base/BaseCamera.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixSensor.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixCamera : + public BaseCamera + { + protected: OptixCamera(); + + public: virtual ~OptixCamera(); + + public: virtual void SetHFOV(const math::Angle &_hfov); + + public: virtual void SetAspectRatio(const double _ratio); + + public: virtual void SetAntiAliasing(const unsigned int _aa); + + public: virtual void PreRender(); + + public: virtual void Render(); + + protected: virtual RenderTargetPtr RenderTarget() const; + + protected: virtual void WriteCameraToDevice(); + + protected: virtual void WriteCameraToDeviceImpl(); + + protected: virtual void WritePoseToDeviceImpl(); + + protected: virtual void Init(); + + protected: virtual void CreateRenderTexture(); + + // Documentation inherited. + protected: virtual RenderWindowPtr CreateRenderWindow(); + + protected: virtual void CreateRenderProgram(); + + protected: virtual void CreateClearProgram(); + + protected: virtual void CreateErrorProgram(); + + protected: optix::Program optixRenderProgram; + + protected: optix::Program optixClearProgram; + + protected: optix::Program optixErrorProgram; + + protected: OptixRenderTexturePtr renderTexture; + + protected: bool cameraDirty; + + protected: unsigned int traceId; + + protected: unsigned int clearId; + + private: static const std::string PTX_BASE_NAME; + + private: static const std::string PTX_RENDER_FUNCTION; + + private: static const std::string PTX_CLEAR_FUNCTION; + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixCone.hh b/optix/include/gz/rendering/optix/OptixCone.hh new file mode 100644 index 000000000..d3a4d6352 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixCone.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXCONE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXCONE_HH_ + +#include "gz/rendering/optix/OptixPrimitive.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixCone : + public OptixPrimitive + { + protected: OptixCone(); + + public: virtual ~OptixCone(); + + public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixConversions.hh b/optix/include/gz/rendering/optix/OptixConversions.hh new file mode 100644 index 000000000..bc6ac6a91 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixConversions.hh @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXCONVERSIONS_HH_ +#define GZ_RENDERING_OPTIX_OPTIXCONVERSIONS_HH_ + +#include +#include +#include + +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \addtogroup ign_rendering + /// \{ + + /// \brief Conversions Conversions.hh rendering/Conversions.hh + /// \brief A set of utility function to convert between Gazebo and Optix + /// data types + class IGNITION_RENDERING_OPTIX_VISIBLE OptixConversions + { + /// \brief Return the equivalent optix color + /// \param[in] _color Gazebo color to convert + /// \return Optix color value + public: static float4 ConvertColor(const math::Color &_color); + + /// \brief Return the equivalent ign-math color + /// \param[in] _color Optix color to convert + /// \return Gazebo color value + public: static math::Color ConvertColor(const float4 &_color); + + /// \brief return Optix Vector from Gazebo Vector3 + /// \param[in] _vector Gazebo vector + /// \return Optix vector + public: static float3 ConvertVector(const math::Vector3d &_vector); + + /// \brief return ign-math Vector from optix Vector3 + /// \param[in] _vector Optix vector + /// \return Gazebo vector + public: static math::Vector3d ConvertVector(const float3 &_vector); + }; + /// \} + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixCylinder.hh b/optix/include/gz/rendering/optix/OptixCylinder.hh new file mode 100644 index 000000000..08ac588fc --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixCylinder.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXCYLINDER_HH_ +#define GZ_RENDERING_OPTIX_OPTIXCYLINDER_HH_ + +#include "gz/rendering/optix/OptixPrimitive.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixCylinder : + public OptixPrimitive + { + protected: OptixCylinder(); + + public: virtual ~OptixCylinder(); + + public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixGeometry.hh b/optix/include/gz/rendering/optix/OptixGeometry.hh new file mode 100644 index 000000000..1f5b2b029 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixGeometry.hh @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXGEOMETRY_HH_ +#define GZ_RENDERING_OPTIX_OPTIXGEOMETRY_HH_ + +#include "gz/rendering/base/BaseGeometry.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixGeometry : + public BaseGeometry + { + protected: OptixGeometry(); + + public: virtual ~OptixGeometry(); + + public: virtual bool HasParent() const; + + public: virtual VisualPtr Parent() const; + + public: virtual optix::GeometryGroup OptixGeometryGroup() const = 0; + + protected: virtual void SetParent(OptixVisualPtr _parent); + + protected: virtual void SetScale(math::Vector3d _scale); + + protected: OptixVisualPtr parent; + + private: friend class OptixVisual; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixGrid.hh b/optix/include/gz/rendering/optix/OptixGrid.hh new file mode 100644 index 000000000..9adbaf707 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixGrid.hh @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXGRID_HH_ +#define GZ_RENDERING_OPTIX_OPTIXGRID_HH_ + +#include +#include +#include "gz/rendering/base/BaseGrid.hh" +#include "gz/rendering/optix/OptixPrimitive.hh" +#include "gz/rendering/optix/OptixObject.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// TODO Not implemented yet! + /// \brief Optix implementation of a grid geometry + class IGNITION_RENDERING_OPTIX_VISIBLE OptixGrid + : public BaseGrid + { + /// \brief Constructor + protected: OptixGrid(); + + /// \brief Destructor + public: virtual ~OptixGrid(); + + // Documentation inherited. + public: virtual void PreRender(); + + /// \brief Grids can only be created by scene + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixIncludes.hh b/optix/include/gz/rendering/optix/OptixIncludes.hh new file mode 100644 index 000000000..001c7d1ee --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixIncludes.hh @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXINCLUDES_HH_ +#define GZ_RENDERING_OPTIX_OPTIXINCLUDES_HH_ + +// #include +#include + +#endif diff --git a/optix/include/gz/rendering/optix/OptixLight.hh b/optix/include/gz/rendering/optix/OptixLight.hh new file mode 100644 index 000000000..cfc519a3d --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixLight.hh @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXLIGHT_HH_ +#define GZ_RENDERING_OPTIX_OPTIXLIGHT_HH_ + +#include "gz/rendering/base/BaseLight.hh" +#include "gz/rendering/optix/OptixNode.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixLightTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixLight : + public BaseLight + { + protected: OptixLight(); + + public: virtual ~OptixLight(); + + public: virtual gz::math::Color DiffuseColor() const; + + public: virtual void SetDiffuseColor( + const gz::math::Color &_color); + + public: virtual gz::math::Color SpecularColor() const; + + public: virtual void SetSpecularColor( + const gz::math::Color &_color); + + public: virtual double AttenuationConstant() const; + + public: virtual void SetAttenuationConstant(double _value); + + public: virtual double AttenuationLinear() const; + + public: virtual void SetAttenuationLinear(double _value); + + public: virtual double AttenuationQuadratic() const; + + public: virtual void SetAttenuationQuadratic(double _value); + + public: virtual double AttenuationRange() const; + + public: virtual void SetAttenuationRange(double _range); + + public: virtual bool CastShadows() const; + + public: virtual void SetCastShadows(bool _castShadows); + + protected: virtual void WritePoseToDeviceImpl(); + + protected: virtual OptixCommonLightData &CommonData() = 0; + + protected: virtual const OptixCommonLightData &CommonData() const = 0; + + protected: virtual void Init(); + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixDirectionalLight : + public BaseDirectionalLight + { + protected: OptixDirectionalLight(); + + public: virtual ~OptixDirectionalLight(); + + public: virtual gz::math::Vector3d Direction() const; + + public: virtual void SetDirection(const gz::math::Vector3d &_dir); + + public: virtual OptixDirectionalLightData Data() const; + + public: virtual void PreRender(); + + protected: virtual OptixCommonLightData &CommonData(); + + protected: virtual const OptixCommonLightData &CommonData() const; + + protected: OptixDirectionalLightData data; + + private: OptixDirectionalLightPtr SharedThis(); + + private: friend class OptixScene; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixPointLight : + public BasePointLight + { + protected: OptixPointLight(); + + public: virtual ~OptixPointLight(); + + public: virtual OptixPointLightData Data() const; + + public: virtual void PreRender(); + + protected: virtual OptixCommonLightData &CommonData(); + + protected: virtual const OptixCommonLightData &CommonData() const; + + protected: OptixPointLightData data; + + private: OptixPointLightPtr SharedThis(); + + private: friend class OptixScene; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixSpotLight : + public BaseSpotLight + { + protected: OptixSpotLight(); + + public: virtual ~OptixSpotLight(); + + public: virtual gz::math::Vector3d Direction() const; + + public: virtual void SetDirection(const gz::math::Vector3d &_dir); + + public: virtual gz::math::Angle InnerAngle() const; + + public: virtual void SetInnerAngle(const gz::math::Angle &_angle); + + public: virtual gz::math::Angle OuterAngle() const; + + public: virtual void SetOuterAngle(const gz::math::Angle &_angle); + + public: virtual double Falloff() const; + + public: virtual void SetFalloff(double _falloff); + + public: virtual OptixSpotLightData Data() const; + + public: virtual void PreRender(); + + protected: virtual OptixCommonLightData &CommonData(); + + protected: virtual const OptixCommonLightData &CommonData() const; + + protected: OptixSpotLightData data; + + private: OptixSpotLightPtr SharedThis(); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixLightManager.hh b/optix/include/gz/rendering/optix/OptixLightManager.hh new file mode 100644 index 000000000..36d321695 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixLightManager.hh @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXLIGHTMANAGER_HH_ +#define GZ_RENDERING_OPTIX_OPTIXLIGHTMANAGER_HH_ + +#include +#include +#include "gz/rendering/config.hh" +#include "gz/rendering/optix/OptixLightTypes.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixLightManager + { + public: explicit OptixLightManager(OptixScenePtr _scene); + + public: virtual ~OptixLightManager(); + + public: virtual void AddDirectionalLight(OptixDirectionalLightPtr _light); + + public: virtual void AddPointLight(OptixPointLightPtr _light); + + public: virtual void AddSpotLight(OptixSpotLightPtr _light); + + public: virtual void PreRender(); + + public: virtual void Clear(); + + protected: virtual void WriteDirectionalBuffer(); + + protected: virtual void WritePointBuffer(); + + protected: virtual void WriteSpotBuffer(); + + protected: template + void WriteBuffer(optix::Buffer _buffer, + const std::vector &_data); + + private: void CreateBuffers(); + + private: template + optix::Buffer CreateBuffer(const std::string &_name); + + protected: OptixScenePtr scene; + + protected: std::vector directionalData; + + protected: std::vector pointData; + + protected: std::vector spotData; + + protected: optix::Buffer directionalBuffer; + + protected: optix::Buffer pointBuffer; + + protected: optix::Buffer spotBuffer; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixLightTypes.hh b/optix/include/gz/rendering/optix/OptixLightTypes.hh new file mode 100644 index 000000000..bfbe04593 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixLightTypes.hh @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXLIGHTTYPES_HH_ +#define GZ_RENDERING_OPTIX_OPTIXLIGHTTYPES_HH_ + +#include + +#ifndef __CUDA_ARCH__ +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // +#endif + + typedef enum OptixLightType_t + { + LT_DIRECTIONAL = 0, + LT_POINT = 1, + LT_SPOT = 2, + LT_COUNT = 3, + } OptixLightType; + + struct OptixLightColor + { + float4 diffuse; + float4 specular; + }; + + struct OptixLightAttenuation + { + // cppcheck-suppress unusedStructMember + float range; + // cppcheck-suppress unusedStructMember + float constant; + // cppcheck-suppress unusedStructMember + float linear; + // cppcheck-suppress unusedStructMember + float quadratic; + }; + + struct OptixLightSpot + { + // cppcheck-suppress unusedStructMember + float innerAngle; + // cppcheck-suppress unusedStructMember + float outerAngle; + // cppcheck-suppress unusedStructMember + float falloff; + }; + + struct OptixCommonLightData + { + float3 position; + OptixLightColor color; + OptixLightAttenuation atten; + // cppcheck-suppress unusedStructMember + bool castShadows; + }; + + struct OptixDirectionalLightData + { + OptixCommonLightData common; + float3 direction; + }; + + struct OptixPointLightData + { + OptixCommonLightData common; + }; + + struct OptixSpotLightData + { + OptixCommonLightData common; + float3 direction; + OptixLightSpot spot; + }; + +#ifndef __CUDA_ARCH__ + } + } +} +#endif + +#endif diff --git a/optix/include/gz/rendering/optix/OptixMaterial.hh b/optix/include/gz/rendering/optix/OptixMaterial.hh new file mode 100644 index 000000000..1caa50378 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixMaterial.hh @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXMATERIAL_HH_ +#define GZ_RENDERING_OPTIX_OPTIXMATERIAL_HH_ + +#include +#include "gz/rendering/base/BaseMaterial.hh" +#include "gz/rendering/optix/OptixObject.hh" +#include "gz/rendering/optix/OptixIncludes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixMaterial : + public BaseMaterial + { + protected: OptixMaterial(); + + public: virtual ~OptixMaterial(); + + public: virtual bool LightingEnabled() const; + + public: virtual void SetLightingEnabled(const bool _enabled); + + public: virtual math::Color Ambient() const; + + public: virtual void SetAmbient(const math::Color &_color); + + public: virtual math::Color Diffuse() const; + + public: virtual void SetDiffuse(const math::Color &_color); + + public: virtual math::Color Specular() const; + + public: virtual void SetSpecular(const math::Color &_color); + + public: virtual math::Color Emissive() const; + + public: virtual void SetEmissive(const math::Color &_color); + + public: virtual double Shininess() const; + + public: virtual void SetShininess(const double _shininess); + + public: virtual double Transparency() const; + + public: virtual void SetTransparency(const double _transparency); + + public: virtual double Reflectivity() const; + + public: virtual void SetReflectivity(const double _reflectivity); + + public: virtual bool CastShadows() const; + + public: virtual void SetCastShadows(const bool _castShadows); + + public: virtual bool ReceiveShadows() const; + + public: virtual void SetReceiveShadows(const bool _receiveShadows); + + public: virtual bool ReflectionEnabled() const; + + public: virtual void SetReflectionEnabled(const bool _enabled); + + public: virtual bool HasTexture() const; + + public: virtual std::string Texture() const; + + public: virtual void SetTexture(const std::string &_texture); + + public: virtual void ClearTexture(); + + public: virtual bool HasNormalMap() const; + + public: virtual std::string NormalMap() const; + + public: virtual void SetNormalMap(const std::string &_normalMap); + + public: virtual void ClearNormalMap(); + + public: virtual void PreRender(); + + public: virtual void Destroy(); + + public: virtual optix::Material Material() const; + + protected: virtual void WriteColorToDevice(); + + protected: virtual void WriteTextureToDevice(); + + protected: virtual void WriteNormalMapToDevice(); + + protected: virtual void WriteColorToDeviceImpl(); + + protected: virtual void WriteTextureToDeviceImpl(); + + protected: virtual void WriteNormalMapToDeviceImpl(); + + protected: virtual void Init(); + + protected: bool colorDirty = true; + + protected: bool textureDirty = true; + + protected: bool normalMapDirty = true; + + protected: std::string textureName; + + protected: std::string normalMapName; + + protected: enum ShaderType shaderType; + + protected: optix::Material optixMaterial; + + protected: optix::TextureSampler optixTexture; + + protected: optix::TextureSampler optixNormalMap; + + protected: optix::TextureSampler optixEmptyTexture; + + private: static const std::string PTX_FILE_BASE; + + private: static const std::string PTX_CLOSEST_HIT_FUNC; + + private: static const std::string PTX_ANY_HIT_FUNC; + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixMesh.hh b/optix/include/gz/rendering/optix/OptixMesh.hh new file mode 100644 index 000000000..a9c777029 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixMesh.hh @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXMESH_HH_ +#define GZ_RENDERING_OPTIX_OPTIXMESH_HH_ + +#include +#include +#include "gz/rendering/base/BaseMesh.hh" +#include "gz/rendering/optix/OptixGeometry.hh" +#include "gz/rendering/optix/OptixObject.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixMesh : + public BaseMesh + { + typedef std::vector NameList; + + protected: OptixMesh(); + + public: virtual ~OptixMesh(); + + public: virtual optix::GeometryGroup OptixGeometryGroup() const; + + public: virtual optix::Acceleration OptixAccel() const; + + protected: virtual SubMeshStorePtr SubMeshes() const; + + protected: OptixSubMeshStorePtr subMeshes; + + protected: optix::GeometryGroup optixGeomGroup; + + protected: optix::Acceleration optixAccel; + + private: friend class OptixScene; + + private: friend class OptixMeshFactory; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixSubMesh : + public BaseSubMesh + { + protected: OptixSubMesh(); + + public: virtual ~OptixSubMesh(); + + public: virtual optix::GeometryInstance OptixGeometryInstance() const; + + protected: virtual void SetMaterialImpl(MaterialPtr _material) override; + + protected: optix::GeometryInstance optixGeomInstance; + + protected: optix::Geometry optixGeometry; + + protected: optix::Buffer optixVertexBuffer; + + protected: optix::Buffer optixNormalBuffer; + + protected: optix::Buffer optixTexCoordBuffer; + + protected: optix::Buffer optixIndexBuffer; + + private: friend class OptixScene; + + private: friend class OptixSubMeshStoreFactory; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixMeshFactory.hh b/optix/include/gz/rendering/optix/OptixMeshFactory.hh new file mode 100644 index 000000000..fc0681a1a --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixMeshFactory.hh @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXMESHFACTORY_HH_ +#define GZ_RENDERING_OPTIX_OPTIXMESHFACTORY_HH_ + +#include +#include +#include + +#include "gz/rendering/MeshDescriptor.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixMesh.hh" +#include "gz/rendering/optix/OptixIncludes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixSubMeshStoreFactory + { + // cppcheck-suppress noExplicitConstructor + public: OptixSubMeshStoreFactory(OptixScenePtr _scene); + + public: virtual ~OptixSubMeshStoreFactory(); + + public: virtual OptixSubMeshStorePtr Create(const MeshDescriptor &_desc); + + protected: virtual optix::Geometry Geometry( + const MeshDescriptor &_desc, unsigned int _subMeshIndex); + + protected: virtual std::string KeyName(const MeshDescriptor &_desc, + unsigned int _subMeshIndex); + + protected: std::map geometries; + + protected: OptixScenePtr scene; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixMeshFactory + { + // cppcheck-suppress noExplicitConstructor + public: OptixMeshFactory(OptixScenePtr _scene); + + public: virtual ~OptixMeshFactory(); + + public: virtual OptixMeshPtr Create(const MeshDescriptor &_desc); + + protected: virtual OptixMeshPtr Create(OptixSubMeshStorePtr _subMeshes); + + protected: OptixSubMeshStoreFactory subMeshStoreFactory; + + protected: OptixScenePtr scene; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixMeshGeometryFactory + { + public: OptixMeshGeometryFactory(OptixScenePtr _scene, + const common::SubMesh &_subMesh); + + public: virtual ~OptixMeshGeometryFactory(); + + public: virtual optix::Geometry Create(); + + protected: virtual void CreateGeometry(); + + protected: virtual optix::Buffer CreateVertexBuffer(); + + protected: virtual optix::Buffer CreateNormalBuffer(); + + protected: virtual optix::Buffer CreateTexCoordBuffer(); + + protected: virtual optix::Buffer CreateIndexBuffer(); + + protected: OptixScenePtr scene; + + protected: const common::SubMesh &subMesh; + + protected: optix::Geometry optixGeometry; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixNode.hh b/optix/include/gz/rendering/optix/OptixNode.hh new file mode 100644 index 000000000..5deb803e9 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixNode.hh @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXNODE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXNODE_HH_ + +#include "gz/rendering/base/BaseNode.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixNode : + public BaseNode + { + protected: OptixNode(); + + public: virtual ~OptixNode(); + + public: virtual bool HasParent() const override; + + public: virtual NodePtr Parent() const override; + + public: virtual void PreRender() override; + + public: virtual optix::Transform OptixTransform() const; + + // Documentation inherited. + public: virtual math::Vector3d LocalScale() const override; + + // Documentation inherited. + public: virtual bool InheritScale() const override; + + // Documentation inherited. + public: virtual void SetInheritScale(bool _inherit) override; + + // Documentation inherited. + protected: virtual void SetLocalScaleImpl( + const math::Vector3d &_scale) override; + + protected: virtual math::Pose3d RawLocalPose() const override; + + protected: virtual void SetRawLocalPose(const math::Pose3d &_pose) + override; + + protected: virtual void WritePoseToDevice(); + + protected: virtual void WritePoseToDeviceImpl(); + + protected: virtual void SetParent(OptixNodePtr _parent); + + protected: virtual void Init() override; + + protected: virtual NodeStorePtr Children() const override; + + protected: virtual bool AttachChild(NodePtr _child) override; + + protected: virtual bool DetachChild(NodePtr _child) override; + + protected: OptixNodePtr parent; + + protected: optix::Transform optixTransform; + + protected: optix::Group optixGroup; + + protected: optix::Acceleration optixAccel; + + protected: math::Pose3d pose; + + protected: bool poseDirty; + + protected: OptixNodeStorePtr children; + + protected: math::Vector3d scale = math::Vector3d::One; + + protected: bool inheritScale = true; + + private: OptixNodePtr SharedThis(); + + // TODO remove the need for a visual friend class + private: friend class OptixVisual; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixObject.hh b/optix/include/gz/rendering/optix/OptixObject.hh new file mode 100644 index 000000000..6ff746085 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixObject.hh @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXOBJECT_HH_ +#define GZ_RENDERING_OPTIX_OPTIXOBJECT_HH_ + +#include "gz/rendering/base/BaseObject.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixObject : + public BaseObject + { + protected: OptixObject(); + + public: virtual ~OptixObject(); + + public: virtual ScenePtr Scene() const; + + protected: OptixScenePtr scene; + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixPrimitive.hh b/optix/include/gz/rendering/optix/OptixPrimitive.hh new file mode 100644 index 000000000..649690aa2 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixPrimitive.hh @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXPRIMITIVE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXPRIMITIVE_HH_ + +#include +#include "gz/rendering/optix/OptixGeometry.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixPrimitive : + public OptixGeometry + { + protected: OptixPrimitive(); + + public: virtual ~OptixPrimitive(); + + public: virtual MaterialPtr Material() const; + + public: virtual void SetMaterial(MaterialPtr _material, + bool _unique = true); + + public: virtual optix::GeometryGroup OptixGeometryGroup() const; + + public: virtual optix::Acceleration OptixAccel() const; + + public: virtual optix::GeometryInstance OptixGeometryInstance() const; + + public: virtual optix::Geometry OptixGeometry() const; + + public: virtual void PreRender(); + + protected: virtual void SetMaterialImpl(OptixMaterialPtr _material); + + protected: virtual void Init(); + + protected: static optix::Geometry CreateOptixGeometry( + OptixScenePtr _scene, const std::string &_ptxFile); + + protected: MaterialPtr material; + + protected: optix::GeometryGroup optixGeomGroup; + + protected: optix::Acceleration optixAccel; + + protected: optix::GeometryInstance optixGeomInstance; + + protected: optix::Geometry optixGeometry; + + protected: static const std::string PTX_INTERSECT_FUNC; + + protected: static const std::string PTX_BOUNDS_FUNC; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixRayTypes.hh b/optix/include/gz/rendering/optix/OptixRayTypes.hh new file mode 100644 index 000000000..b46c1ccf6 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixRayTypes.hh @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXRAYTYPES_HH_ +#define GZ_RENDERING_OPTIX_OPTIXRAYTYPES_HH_ + +#include + +#ifndef __CUDA_ARCH__ +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // +#endif + + typedef enum OptixRayType_t + { + RT_RADIANCE = 0, + RT_SHADOW = 1, + RT_COUNT = 2, + } OptixRayType; + + struct OptixRadianceRayData + { + float3 color; + // cppcheck-suppress unusedStructMember + float importance; + // cppcheck-suppress unusedStructMember + int depth; + }; + + struct OptixShadowRayData + { + float3 attenuation; + }; + +#ifndef __CUDA_ARCH__ + } + } +} +#endif + +#endif diff --git a/optix/include/gz/rendering/optix/OptixRenderEngine.hh b/optix/include/gz/rendering/optix/OptixRenderEngine.hh new file mode 100644 index 000000000..05635a883 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixRenderEngine.hh @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXRENDERENGINE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXRENDERENGINE_HH_ + +#include +#include +#include + +#include "gz/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/base/BaseRenderEngine.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Plugin for loading optix render engine + class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderEnginePlugin : + public RenderEnginePlugin + { + /// \brief Constructor + public: OptixRenderEnginePlugin(); + + /// \brief Destructor + public: ~OptixRenderEnginePlugin() = default; + + /// \brief Get the name of the render engine loaded by this plugin. + /// \return Name of render engine + public: std::string Name() const; + + /// \brief Get a pointer to the render engine loaded by this plugin. + /// \return Render engine instance + public: RenderEngine *Engine() const; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderEngine : + public virtual BaseRenderEngine, + public common::SingletonT + { + /// \brief Constructor + private: OptixRenderEngine(); + + public: virtual ~OptixRenderEngine(); + + public: virtual bool Fini(); + + public: virtual std::string Name() const; + + public: std::string PtxFile(const std::string& _fileBase) const; + + protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, + const std::string &_name); + + protected: virtual SceneStorePtr Scenes() const; + + // Documentation Inherited + protected: virtual bool LoadImpl( + const std::map &_params) override; + + protected: virtual bool InitImpl(); + + private: OptixSceneStorePtr scenes; + + private: static const std::string PTX_PREFIX; + + private: static const std::string PTX_SUFFIX; + + private: friend class SingletonT; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixRenderTarget.hh b/optix/include/gz/rendering/optix/OptixRenderTarget.hh new file mode 100644 index 000000000..5beffe443 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixRenderTarget.hh @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXRENDERTARGET_HH_ +#define GZ_RENDERING_OPTIX_OPTIXRENDERTARGET_HH_ + +#include "gz/rendering/base/BaseRenderTarget.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixObject.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderTarget : + public virtual BaseRenderTarget + { + protected: OptixRenderTarget(); + + public: virtual ~OptixRenderTarget(); + + public: virtual void Copy(Image &_image) const; + + public: virtual optix::Buffer OptixBuffer() const = 0; + + protected: unsigned int MemorySize() const; + + protected: float *hostData; + }; + + class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderTexture : + public virtual BaseRenderTexture + { + protected: OptixRenderTexture(); + + public: virtual ~OptixRenderTexture(); + + public: virtual void Destroy(); + + public: virtual optix::Buffer OptixBuffer() const; + + protected: virtual void RebuildImpl(); + + protected: optix::Buffer optixBuffer; + + protected: virtual void Init(); + + private: friend class OptixScene; + }; + + /// \brief Render window mocked using a render texture. + class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderWindow : + public virtual BaseRenderWindow + { + /// \brief Constructor + protected: OptixRenderWindow(); + + /// \brief Destructor + public: virtual ~OptixRenderWindow(); + + /// \brief Render windows should only be created by the scene class + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixRenderTypes.hh b/optix/include/gz/rendering/optix/OptixRenderTypes.hh new file mode 100644 index 000000000..12202c74f --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixRenderTypes.hh @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXRENDERTYPES_HH_ +#define GZ_RENDERING_OPTIX_OPTIXRENDERTYPES_HH_ + +#include "gz/rendering/base/BaseRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class OptixArrowVisual; + class OptixAxisVisual; + class OptixBox; + class OptixCamera; + class OptixCone; + class OptixCylinder; + class OptixDirectionalLight; + class OptixGeometry; + class OptixGrid; + class OptixJointVisual; + class OptixLight; + class OptixMaterial; + class OptixMesh; + class OptixMeshFactory; + class OptixNode; + class OptixObject; + class OptixObjectFactory; + class OptixPointLight; + class OptixRenderEngine; + class OptixScene; + class OptixSensor; + class OptixSphere; + class OptixSpotLight; + class OptixSubMesh; + class OptixVisual; + class OptixRenderTarget; + class OptixRenderTexture; + class OptixRenderWindow; + class OptixLightManager; + + typedef BaseSceneStore OptixSceneStore; + typedef BaseNodeStore OptixNodeStore; + typedef BaseLightStore OptixLightStore; + typedef BaseSensorStore OptixSensorStore; + typedef BaseVisualStore OptixVisualStore; + typedef BaseGeometryStore OptixGeometryStore; + typedef BaseSubMeshStore OptixSubMeshStore; + typedef BaseMaterialMap OptixMaterialMap; + + typedef shared_ptr OptixArrowVisualPtr; + typedef shared_ptr OptixAxisVisualPtr; + typedef shared_ptr OptixBoxPtr; + typedef shared_ptr OptixCameraPtr; + typedef shared_ptr OptixConePtr; + typedef shared_ptr OptixCylinderPtr; + typedef shared_ptr OptixDirectionalLightPtr; + typedef shared_ptr OptixGeometryPtr; + typedef shared_ptr OptixGridPtr; + typedef shared_ptr OptixJointVisualPtr; + typedef shared_ptr OptixLightPtr; + typedef shared_ptr OptixMaterialPtr; + typedef shared_ptr OptixMeshPtr; + typedef shared_ptr OptixMeshFactoryPtr; + typedef shared_ptr OptixNodePtr; + typedef shared_ptr OptixObjectPtr; + typedef shared_ptr OptixObjectFactoryPtr; + typedef shared_ptr OptixPointLightPtr; + typedef shared_ptr OptixScenePtr; + typedef shared_ptr OptixSensorPtr; + typedef shared_ptr OptixSpherePtr; + typedef shared_ptr OptixSpotLightPtr; + typedef shared_ptr OptixSubMeshPtr; + typedef shared_ptr OptixVisualPtr; + typedef shared_ptr OptixSceneStorePtr; + typedef shared_ptr OptixNodeStorePtr; + typedef shared_ptr OptixLightStorePtr; + typedef shared_ptr OptixSensorStorePtr; + typedef shared_ptr OptixVisualStorePtr; + typedef shared_ptr OptixGeometryStorePtr; + typedef shared_ptr OptixSubMeshStorePtr; + typedef shared_ptr OptixMaterialMapPtr; + typedef shared_ptr OptixRenderTargetPtr; + typedef shared_ptr OptixRenderTexturePtr; + typedef shared_ptr OptixRenderWindowPtr; + typedef shared_ptr OptixLightManagerPtr; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixScene.hh b/optix/include/gz/rendering/optix/OptixScene.hh new file mode 100644 index 000000000..6f94fcff4 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixScene.hh @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXSCENE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXSCENE_HH_ + +#include + +#include "gz/rendering/base/BaseScene.hh" + +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixScene : + public BaseScene + { + protected: OptixScene(unsigned int _id, const std::string &_name); + + public: virtual ~OptixScene(); + + public: virtual void Fini(); + + public: virtual RenderEngine *Engine() const; + + public: virtual VisualPtr RootVisual() const; + + public: virtual math::Color AmbientLight() const; + + public: virtual void SetAmbientLight(const math::Color &_color); + + public: virtual void SetBackgroundColor(const math::Color &_color); + + // Documentation inherited. + public: virtual void SetGradientBackgroundColor( + const std::array &_colors); + + // Documentation inherited. + public: virtual void RemoveGradientBackgroundColor(); + + public: virtual void PreRender(); + + public: virtual void Clear(); + + public: virtual void Destroy(); + + public: virtual OptixLightManagerPtr LightManager() const; + + public: virtual optix::Context OptixContext() const; + + public: virtual optix::Program CreateOptixProgram( + const std::string &_fileBase, const std::string &_function); + + protected: virtual bool LoadImpl(); + + protected: virtual bool InitImpl(); + + protected: virtual DirectionalLightPtr CreateDirectionalLightImpl( + unsigned int _id, const std::string &_name); + + protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id, + const std::string &_name); + + protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id, + const std::string &_name); + + protected: virtual CameraPtr CreateCameraImpl(unsigned int _id, + const std::string &_name); + + // Documentation inherited + protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id, + const std::string &_name) override; + + protected: virtual VisualPtr CreateVisualImpl(unsigned int _id, + const std::string &_name); + + protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id, + const std::string &_name); + + protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id, + const std::string &_name); + + protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id, + const std::string &_name); + + protected: virtual GeometryPtr CreateConeImpl(unsigned int _id, + const std::string &_name); + + protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id, + const std::string &_name); + + protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id, + const std::string &_name); + + protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id, + const std::string &_name); + + protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, + const std::string &_name, const std::string &_meshName); + + protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, + const std::string &_name, const MeshDescriptor &_desc); + + // Documentation inherited. + protected: virtual GridPtr CreateGridImpl(unsigned int _id, + const std::string &_name); + + protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id, + const std::string &_name); + + protected: virtual RenderTexturePtr CreateRenderTextureImpl( + unsigned int _id, const std::string &_name); + + // Documentation inherited. + protected: virtual RenderWindowPtr CreateRenderWindowImpl( + unsigned int _id, const std::string &_name); + + protected: virtual RayQueryPtr CreateRayQueryImpl( + unsigned int _id, const std::string &_name); + + protected: virtual bool InitObject(OptixObjectPtr _object, + unsigned int _id, const std::string &_name); + + protected: virtual LightStorePtr Lights() const; + + protected: virtual SensorStorePtr Sensors() const; + + protected: virtual VisualStorePtr Visuals() const; + + protected: virtual MaterialMapPtr Materials() const; + + protected: virtual unsigned int NextEntryId(); + + private: void CreateContext(); + + private: void CreateRootVisual(); + + private: void CreateLightManager(); + + private: void CreateMeshFactory(); + + private: void CreateStores(); + + private: OptixScenePtr SharedThis(); + + protected: OptixVisualPtr rootVisual; + + protected: OptixLightManagerPtr lightManager; + + protected: OptixMeshFactoryPtr meshFactory; + + protected: OptixLightStorePtr lights; + + protected: OptixSensorStorePtr sensors; + + protected: OptixVisualStorePtr visuals; + + protected: OptixMaterialMapPtr materials; + + protected: optix::Context optixContext; + + protected: optix::Group optixRootGroup; + + protected: optix::Acceleration optixRootAccel; + + protected: optix::Program optixMissProgram; + + protected: optix::Geometry optixBoxGeometry; + + protected: optix::Geometry optixConeGeometry; + + protected: optix::Geometry optixCylinderGeometry; + + protected: optix::Geometry optixSphereGeometry; + + protected: math::Color ambientLight; + + private: friend class OptixRenderEngine; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixSensor.hh b/optix/include/gz/rendering/optix/OptixSensor.hh new file mode 100644 index 000000000..7d3f2dc0f --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixSensor.hh @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXSENSOR_HH_ +#define GZ_RENDERING_OPTIX_OPTIXSENSOR_HH_ + +#include "gz/rendering/base/BaseSensor.hh" +#include "gz/rendering/optix/OptixNode.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixSensor : + public BaseSensor + { + protected: OptixSensor(); + + public: virtual ~OptixSensor(); + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixSphere.hh b/optix/include/gz/rendering/optix/OptixSphere.hh new file mode 100644 index 000000000..9b3092413 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixSphere.hh @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXSPHERE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXSPHERE_HH_ + +#include "gz/rendering/optix/OptixPrimitive.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixSphere : + public OptixPrimitive + { + protected: OptixSphere(); + + public: virtual ~OptixSphere(); + + public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixStorage.hh b/optix/include/gz/rendering/optix/OptixStorage.hh new file mode 100644 index 000000000..0e4fddd21 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixStorage.hh @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXSTORAGE_HH_ +#define GZ_RENDERING_OPTIX_OPTIXSTORAGE_HH_ + +#include "gz/rendering/base/BaseStorage.hh" + +#include "gz/rendering/optix/OptixGeometry.hh" +#include "gz/rendering/optix/OptixLight.hh" +#include "gz/rendering/optix/OptixMaterial.hh" +#include "gz/rendering/optix/OptixMesh.hh" +#include "gz/rendering/optix/OptixNode.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixSensor.hh" +#include "gz/rendering/optix/OptixVisual.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + template class BaseSceneStore; + template class BaseNodeStore; + template class BaseLightStore; + template class BaseSensorStore; + template class BaseVisualStore; + template class BaseGeometryStore; + template class BaseSubMeshStore; + template class BaseMaterialMap; + + typedef BaseSceneStore OptixSceneStore; + typedef BaseNodeStore OptixNodeStore; + typedef BaseLightStore OptixLightStore; + typedef BaseSensorStore OptixSensorStore; + typedef BaseVisualStore OptixVisualStore; + typedef BaseGeometryStore OptixGeometryStore; + typedef BaseSubMeshStore OptixSubMeshStore; + typedef BaseMaterialMap OptixMaterialMap; + + typedef std::shared_ptr OptixSceneStorePtr; + typedef std::shared_ptr OptixNodeStorePtr; + typedef std::shared_ptr OptixLightStorePtr; + typedef std::shared_ptr OptixSensorStorePtr; + typedef std::shared_ptr OptixVisualStorePtr; + typedef std::shared_ptr OptixGeometryStorePtr; + typedef std::shared_ptr OptixSubMeshStorePtr; + typedef std::shared_ptr OptixMaterialMapPtr; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixTextureFactory.hh b/optix/include/gz/rendering/optix/OptixTextureFactory.hh new file mode 100644 index 000000000..62b1f3b47 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixTextureFactory.hh @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXTEXTUREFACTORY_HH_ +#define GZ_RENDERING_OPTIX_OPTIXTEXTUREFACTORY_HH_ + +#include +#include "gz/rendering/optix/OptixRenderTypes.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixTextureFactory + { + public: explicit OptixTextureFactory(OptixScenePtr _scene); + + public: virtual ~OptixTextureFactory(); + + public: optix::TextureSampler Create(const std::string &_filename); + + public: optix::TextureSampler Create(); + + protected: optix::Buffer CreateBuffer(const std::string &_filename); + + protected: optix::Buffer CreateBuffer(); + + protected: optix::TextureSampler CreateSampler(optix::Buffer _buffer); + + protected: OptixScenePtr scene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/OptixVisual.hh b/optix/include/gz/rendering/optix/OptixVisual.hh new file mode 100644 index 000000000..990427f22 --- /dev/null +++ b/optix/include/gz/rendering/optix/OptixVisual.hh @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2015 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GZ_RENDERING_OPTIX_OPTIXVISUAL_HH_ +#define GZ_RENDERING_OPTIX_OPTIXVISUAL_HH_ + +#include "gz/rendering/base/BaseVisual.hh" +#include "gz/rendering/optix/OptixNode.hh" +#include "gz/rendering/optix/OptixRenderTypes.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + class IGNITION_RENDERING_OPTIX_VISIBLE OptixVisual : + public BaseVisual + { + protected: OptixVisual(); + + public: virtual ~OptixVisual(); + + public: virtual optix::Group OptixGroup() const; + + public: virtual optix::Acceleration OptixAccel() const; + + public: virtual void PreRender(); + + protected: virtual GeometryStorePtr Geometries() const; + + protected: virtual bool AttachGeometry(GeometryPtr _geometry); + + protected: virtual bool DetachGeometry(GeometryPtr _geometry); + + protected: virtual void Init(); + + private: void CreateStorage(); + + private: OptixVisualPtr SharedThis(); + + protected: OptixGeometryStorePtr geometries; + + private: friend class OptixScene; + }; + } + } +} +#endif diff --git a/optix/include/gz/rendering/optix/optix.hh.in b/optix/include/gz/rendering/optix/optix.hh.in new file mode 100644 index 000000000..c4092f0cd --- /dev/null +++ b/optix/include/gz/rendering/optix/optix.hh.in @@ -0,0 +1,3 @@ +// Automatically generated +#include +${ign_headers} diff --git a/optix/include/ignition/rendering/optix.hh b/optix/include/ignition/rendering/optix.hh new file mode 100644 index 000000000..130fc6f6d --- /dev/null +++ b/optix/include/ignition/rendering/optix.hh @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixArrowVisual.hh b/optix/include/ignition/rendering/optix/OptixArrowVisual.hh index e3e6d19d3..933329946 100644 --- a/optix/include/ignition/rendering/optix/OptixArrowVisual.hh +++ b/optix/include/ignition/rendering/optix/OptixArrowVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXARROWVISUAL_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXARROWVISUAL_HH_ -#include "ignition/rendering/base/BaseArrowVisual.hh" -#include "ignition/rendering/optix/OptixVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixArrowVisual : - public BaseArrowVisual - { - protected: OptixArrowVisual(); - - public: virtual ~OptixArrowVisual(); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixAxisVisual.hh b/optix/include/ignition/rendering/optix/OptixAxisVisual.hh index a4b47bca2..88ba6d763 100644 --- a/optix/include/ignition/rendering/optix/OptixAxisVisual.hh +++ b/optix/include/ignition/rendering/optix/OptixAxisVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXAXISVISUAL_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXAXISVISUAL_HH_ -#include "ignition/rendering/base/BaseAxisVisual.hh" -#include "ignition/rendering/optix/OptixVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixAxisVisual : - public BaseAxisVisual - { - protected: OptixAxisVisual(); - - public: virtual ~OptixAxisVisual(); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixBox.hh b/optix/include/ignition/rendering/optix/OptixBox.hh index 6073bdf97..b43db3020 100644 --- a/optix/include/ignition/rendering/optix/OptixBox.hh +++ b/optix/include/ignition/rendering/optix/OptixBox.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXBOX_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXBOX_HH_ -#include "ignition/rendering/optix/OptixPrimitive.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixBox : - public OptixPrimitive - { - protected: OptixBox(); - - public: virtual ~OptixBox(); - - public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixCamera.hh b/optix/include/ignition/rendering/optix/OptixCamera.hh index 5a02e6c12..5659c12e5 100644 --- a/optix/include/ignition/rendering/optix/OptixCamera.hh +++ b/optix/include/ignition/rendering/optix/OptixCamera.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,81 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXCAMERA_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXCAMERA_HH_ -#include -#include "ignition/rendering/base/BaseCamera.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixSensor.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixCamera : - public BaseCamera - { - protected: OptixCamera(); - - public: virtual ~OptixCamera(); - - public: virtual void SetHFOV(const math::Angle &_hfov); - - public: virtual void SetAspectRatio(const double _ratio); - - public: virtual void SetAntiAliasing(const unsigned int _aa); - - public: virtual void PreRender(); - - public: virtual void Render(); - - protected: virtual RenderTargetPtr RenderTarget() const; - - protected: virtual void WriteCameraToDevice(); - - protected: virtual void WriteCameraToDeviceImpl(); - - protected: virtual void WritePoseToDeviceImpl(); - - protected: virtual void Init(); - - protected: virtual void CreateRenderTexture(); - - // Documentation inherited. - protected: virtual RenderWindowPtr CreateRenderWindow(); - - protected: virtual void CreateRenderProgram(); - - protected: virtual void CreateClearProgram(); - - protected: virtual void CreateErrorProgram(); - - protected: optix::Program optixRenderProgram; - - protected: optix::Program optixClearProgram; - - protected: optix::Program optixErrorProgram; - - protected: OptixRenderTexturePtr renderTexture; - - protected: bool cameraDirty; - - protected: unsigned int traceId; - - protected: unsigned int clearId; - - private: static const std::string PTX_BASE_NAME; - - private: static const std::string PTX_RENDER_FUNCTION; - - private: static const std::string PTX_CLEAR_FUNCTION; - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixCone.hh b/optix/include/ignition/rendering/optix/OptixCone.hh index 35a78afab..f2d0e9bf1 100644 --- a/optix/include/ignition/rendering/optix/OptixCone.hh +++ b/optix/include/ignition/rendering/optix/OptixCone.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXCONE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXCONE_HH_ -#include "ignition/rendering/optix/OptixPrimitive.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixCone : - public OptixPrimitive - { - protected: OptixCone(); - - public: virtual ~OptixCone(); - - public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixConversions.hh b/optix/include/ignition/rendering/optix/OptixConversions.hh index 646dbee82..cfc237f61 100644 --- a/optix/include/ignition/rendering/optix/OptixConversions.hh +++ b/optix/include/ignition/rendering/optix/OptixConversions.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,53 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXCONVERSIONS_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXCONVERSIONS_HH_ -#include -#include -#include - -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \addtogroup ign_rendering - /// \{ - - /// \brief Conversions Conversions.hh rendering/Conversions.hh - /// \brief A set of utility function to convert between Gazebo and Optix - /// data types - class IGNITION_RENDERING_OPTIX_VISIBLE OptixConversions - { - /// \brief Return the equivalent optix color - /// \param[in] _color Gazebo color to convert - /// \return Optix color value - public: static float4 ConvertColor(const math::Color &_color); - - /// \brief Return the equivalent ign-math color - /// \param[in] _color Optix color to convert - /// \return Gazebo color value - public: static math::Color ConvertColor(const float4 &_color); - - /// \brief return Optix Vector from Gazebo Vector3 - /// \param[in] _vector Gazebo vector - /// \return Optix vector - public: static float3 ConvertVector(const math::Vector3d &_vector); - - /// \brief return ign-math Vector from optix Vector3 - /// \param[in] _vector Optix vector - /// \return Gazebo vector - public: static math::Vector3d ConvertVector(const float3 &_vector); - }; - /// \} - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixCylinder.hh b/optix/include/ignition/rendering/optix/OptixCylinder.hh index f04d6591d..c34683269 100644 --- a/optix/include/ignition/rendering/optix/OptixCylinder.hh +++ b/optix/include/ignition/rendering/optix/OptixCylinder.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXCYLINDER_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXCYLINDER_HH_ -#include "ignition/rendering/optix/OptixPrimitive.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixCylinder : - public OptixPrimitive - { - protected: OptixCylinder(); - - public: virtual ~OptixCylinder(); - - public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixGeometry.hh b/optix/include/ignition/rendering/optix/OptixGeometry.hh index 579a1c6c5..0757681dd 100644 --- a/optix/include/ignition/rendering/optix/OptixGeometry.hh +++ b/optix/include/ignition/rendering/optix/OptixGeometry.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,41 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXGEOMETRY_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXGEOMETRY_HH_ -#include "ignition/rendering/base/BaseGeometry.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixGeometry : - public BaseGeometry - { - protected: OptixGeometry(); - - public: virtual ~OptixGeometry(); - - public: virtual bool HasParent() const; - - public: virtual VisualPtr Parent() const; - - public: virtual optix::GeometryGroup OptixGeometryGroup() const = 0; - - protected: virtual void SetParent(OptixVisualPtr _parent); - - protected: virtual void SetScale(math::Vector3d _scale); - - protected: OptixVisualPtr parent; - - private: friend class OptixVisual; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixGrid.hh b/optix/include/ignition/rendering/optix/OptixGrid.hh index ded3af240..4ff8ad710 100644 --- a/optix/include/ignition/rendering/optix/OptixGrid.hh +++ b/optix/include/ignition/rendering/optix/OptixGrid.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,40 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXGRID_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXGRID_HH_ -#include -#include -#include "ignition/rendering/base/BaseGrid.hh" -#include "ignition/rendering/optix/OptixPrimitive.hh" -#include "ignition/rendering/optix/OptixObject.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// TODO Not implemented yet! - /// \brief Optix implementation of a grid geometry - class IGNITION_RENDERING_OPTIX_VISIBLE OptixGrid - : public BaseGrid - { - /// \brief Constructor - protected: OptixGrid(); - - /// \brief Destructor - public: virtual ~OptixGrid(); - - // Documentation inherited. - public: virtual void PreRender(); - - /// \brief Grids can only be created by scene - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixIncludes.hh b/optix/include/ignition/rendering/optix/OptixIncludes.hh index 2966aa3ce..0d9bfc38f 100644 --- a/optix/include/ignition/rendering/optix/OptixIncludes.hh +++ b/optix/include/ignition/rendering/optix/OptixIncludes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,10 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXINCLUDES_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXINCLUDES_HH_ -// #include -#include - -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixLight.hh b/optix/include/ignition/rendering/optix/OptixLight.hh index 39fb91efa..f323a078a 100644 --- a/optix/include/ignition/rendering/optix/OptixLight.hh +++ b/optix/include/ignition/rendering/optix/OptixLight.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,152 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXLIGHT_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXLIGHT_HH_ -#include "ignition/rendering/base/BaseLight.hh" -#include "ignition/rendering/optix/OptixNode.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixLightTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixLight : - public BaseLight - { - protected: OptixLight(); - - public: virtual ~OptixLight(); - - public: virtual ignition::math::Color DiffuseColor() const; - - public: virtual void SetDiffuseColor( - const ignition::math::Color &_color); - - public: virtual ignition::math::Color SpecularColor() const; - - public: virtual void SetSpecularColor( - const ignition::math::Color &_color); - - public: virtual double AttenuationConstant() const; - - public: virtual void SetAttenuationConstant(double _value); - - public: virtual double AttenuationLinear() const; - - public: virtual void SetAttenuationLinear(double _value); - - public: virtual double AttenuationQuadratic() const; - - public: virtual void SetAttenuationQuadratic(double _value); - - public: virtual double AttenuationRange() const; - - public: virtual void SetAttenuationRange(double _range); - - public: virtual bool CastShadows() const; - - public: virtual void SetCastShadows(bool _castShadows); - - protected: virtual void WritePoseToDeviceImpl(); - - protected: virtual OptixCommonLightData &CommonData() = 0; - - protected: virtual const OptixCommonLightData &CommonData() const = 0; - - protected: virtual void Init(); - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixDirectionalLight : - public BaseDirectionalLight - { - protected: OptixDirectionalLight(); - - public: virtual ~OptixDirectionalLight(); - - public: virtual ignition::math::Vector3d Direction() const; - - public: virtual void SetDirection(const ignition::math::Vector3d &_dir); - - public: virtual OptixDirectionalLightData Data() const; - - public: virtual void PreRender(); - - protected: virtual OptixCommonLightData &CommonData(); - - protected: virtual const OptixCommonLightData &CommonData() const; - - protected: OptixDirectionalLightData data; - - private: OptixDirectionalLightPtr SharedThis(); - - private: friend class OptixScene; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixPointLight : - public BasePointLight - { - protected: OptixPointLight(); - - public: virtual ~OptixPointLight(); - - public: virtual OptixPointLightData Data() const; - - public: virtual void PreRender(); - - protected: virtual OptixCommonLightData &CommonData(); - - protected: virtual const OptixCommonLightData &CommonData() const; - - protected: OptixPointLightData data; - - private: OptixPointLightPtr SharedThis(); - - private: friend class OptixScene; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixSpotLight : - public BaseSpotLight - { - protected: OptixSpotLight(); - - public: virtual ~OptixSpotLight(); - - public: virtual ignition::math::Vector3d Direction() const; - - public: virtual void SetDirection(const ignition::math::Vector3d &_dir); - - public: virtual ignition::math::Angle InnerAngle() const; - - public: virtual void SetInnerAngle(const ignition::math::Angle &_angle); - - public: virtual ignition::math::Angle OuterAngle() const; - - public: virtual void SetOuterAngle(const ignition::math::Angle &_angle); - - public: virtual double Falloff() const; - - public: virtual void SetFalloff(double _falloff); - - public: virtual OptixSpotLightData Data() const; - - public: virtual void PreRender(); - - protected: virtual OptixCommonLightData &CommonData(); - - protected: virtual const OptixCommonLightData &CommonData() const; - - protected: OptixSpotLightData data; - - private: OptixSpotLightPtr SharedThis(); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixLightManager.hh b/optix/include/ignition/rendering/optix/OptixLightManager.hh index 312c66843..e0dc46dad 100644 --- a/optix/include/ignition/rendering/optix/OptixLightManager.hh +++ b/optix/include/ignition/rendering/optix/OptixLightManager.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,69 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXLIGHTMANAGER_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXLIGHTMANAGER_HH_ -#include -#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/optix/OptixLightTypes.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixLightManager - { - public: explicit OptixLightManager(OptixScenePtr _scene); - - public: virtual ~OptixLightManager(); - - public: virtual void AddDirectionalLight(OptixDirectionalLightPtr _light); - - public: virtual void AddPointLight(OptixPointLightPtr _light); - - public: virtual void AddSpotLight(OptixSpotLightPtr _light); - - public: virtual void PreRender(); - - public: virtual void Clear(); - - protected: virtual void WriteDirectionalBuffer(); - - protected: virtual void WritePointBuffer(); - - protected: virtual void WriteSpotBuffer(); - - protected: template - void WriteBuffer(optix::Buffer _buffer, - const std::vector &_data); - - private: void CreateBuffers(); - - private: template - optix::Buffer CreateBuffer(const std::string &_name); - - protected: OptixScenePtr scene; - - protected: std::vector directionalData; - - protected: std::vector pointData; - - protected: std::vector spotData; - - protected: optix::Buffer directionalBuffer; - - protected: optix::Buffer pointBuffer; - - protected: optix::Buffer spotBuffer; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixLightTypes.hh b/optix/include/ignition/rendering/optix/OptixLightTypes.hh index b150ad0f8..bb2b1dc2e 100644 --- a/optix/include/ignition/rendering/optix/OptixLightTypes.hh +++ b/optix/include/ignition/rendering/optix/OptixLightTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,87 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXLIGHTTYPES_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXLIGHTTYPES_HH_ -#include - -#ifndef __CUDA_ARCH__ -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // -#endif - - typedef enum OptixLightType_t - { - LT_DIRECTIONAL = 0, - LT_POINT = 1, - LT_SPOT = 2, - LT_COUNT = 3, - } OptixLightType; - - struct OptixLightColor - { - float4 diffuse; - float4 specular; - }; - - struct OptixLightAttenuation - { - // cppcheck-suppress unusedStructMember - float range; - // cppcheck-suppress unusedStructMember - float constant; - // cppcheck-suppress unusedStructMember - float linear; - // cppcheck-suppress unusedStructMember - float quadratic; - }; - - struct OptixLightSpot - { - // cppcheck-suppress unusedStructMember - float innerAngle; - // cppcheck-suppress unusedStructMember - float outerAngle; - // cppcheck-suppress unusedStructMember - float falloff; - }; - - struct OptixCommonLightData - { - float3 position; - OptixLightColor color; - OptixLightAttenuation atten; - // cppcheck-suppress unusedStructMember - bool castShadows; - }; - - struct OptixDirectionalLightData - { - OptixCommonLightData common; - float3 direction; - }; - - struct OptixPointLightData - { - OptixCommonLightData common; - }; - - struct OptixSpotLightData - { - OptixCommonLightData common; - float3 direction; - OptixLightSpot spot; - }; - -#ifndef __CUDA_ARCH__ - } - } -} -#endif - -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixMaterial.hh b/optix/include/ignition/rendering/optix/OptixMaterial.hh index 0c2605a2f..0a17cad23 100644 --- a/optix/include/ignition/rendering/optix/OptixMaterial.hh +++ b/optix/include/ignition/rendering/optix/OptixMaterial.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,136 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXMATERIAL_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXMATERIAL_HH_ -#include -#include "ignition/rendering/base/BaseMaterial.hh" -#include "ignition/rendering/optix/OptixObject.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixMaterial : - public BaseMaterial - { - protected: OptixMaterial(); - - public: virtual ~OptixMaterial(); - - public: virtual bool LightingEnabled() const; - - public: virtual void SetLightingEnabled(const bool _enabled); - - public: virtual math::Color Ambient() const; - - public: virtual void SetAmbient(const math::Color &_color); - - public: virtual math::Color Diffuse() const; - - public: virtual void SetDiffuse(const math::Color &_color); - - public: virtual math::Color Specular() const; - - public: virtual void SetSpecular(const math::Color &_color); - - public: virtual math::Color Emissive() const; - - public: virtual void SetEmissive(const math::Color &_color); - - public: virtual double Shininess() const; - - public: virtual void SetShininess(const double _shininess); - - public: virtual double Transparency() const; - - public: virtual void SetTransparency(const double _transparency); - - public: virtual double Reflectivity() const; - - public: virtual void SetReflectivity(const double _reflectivity); - - public: virtual bool CastShadows() const; - - public: virtual void SetCastShadows(const bool _castShadows); - - public: virtual bool ReceiveShadows() const; - - public: virtual void SetReceiveShadows(const bool _receiveShadows); - - public: virtual bool ReflectionEnabled() const; - - public: virtual void SetReflectionEnabled(const bool _enabled); - - public: virtual bool HasTexture() const; - - public: virtual std::string Texture() const; - - public: virtual void SetTexture(const std::string &_texture); - - public: virtual void ClearTexture(); - - public: virtual bool HasNormalMap() const; - - public: virtual std::string NormalMap() const; - - public: virtual void SetNormalMap(const std::string &_normalMap); - - public: virtual void ClearNormalMap(); - - public: virtual void PreRender(); - - public: virtual void Destroy(); - - public: virtual optix::Material Material() const; - - protected: virtual void WriteColorToDevice(); - - protected: virtual void WriteTextureToDevice(); - - protected: virtual void WriteNormalMapToDevice(); - - protected: virtual void WriteColorToDeviceImpl(); - - protected: virtual void WriteTextureToDeviceImpl(); - - protected: virtual void WriteNormalMapToDeviceImpl(); - - protected: virtual void Init(); - - protected: bool colorDirty = true; - - protected: bool textureDirty = true; - - protected: bool normalMapDirty = true; - - protected: std::string textureName; - - protected: std::string normalMapName; - - protected: enum ShaderType shaderType; - - protected: optix::Material optixMaterial; - - protected: optix::TextureSampler optixTexture; - - protected: optix::TextureSampler optixNormalMap; - - protected: optix::TextureSampler optixEmptyTexture; - - private: static const std::string PTX_FILE_BASE; - - private: static const std::string PTX_CLOSEST_HIT_FUNC; - - private: static const std::string PTX_ANY_HIT_FUNC; - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixMesh.hh b/optix/include/ignition/rendering/optix/OptixMesh.hh index 778ab54e5..615bcdfba 100644 --- a/optix/include/ignition/rendering/optix/OptixMesh.hh +++ b/optix/include/ignition/rendering/optix/OptixMesh.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,76 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXMESH_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXMESH_HH_ -#include -#include -#include "ignition/rendering/base/BaseMesh.hh" -#include "ignition/rendering/optix/OptixGeometry.hh" -#include "ignition/rendering/optix/OptixObject.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixMesh : - public BaseMesh - { - typedef std::vector NameList; - - protected: OptixMesh(); - - public: virtual ~OptixMesh(); - - public: virtual optix::GeometryGroup OptixGeometryGroup() const; - - public: virtual optix::Acceleration OptixAccel() const; - - protected: virtual SubMeshStorePtr SubMeshes() const; - - protected: OptixSubMeshStorePtr subMeshes; - - protected: optix::GeometryGroup optixGeomGroup; - - protected: optix::Acceleration optixAccel; - - private: friend class OptixScene; - - private: friend class OptixMeshFactory; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixSubMesh : - public BaseSubMesh - { - protected: OptixSubMesh(); - - public: virtual ~OptixSubMesh(); - - public: virtual optix::GeometryInstance OptixGeometryInstance() const; - - protected: virtual void SetMaterialImpl(MaterialPtr _material) override; - - protected: optix::GeometryInstance optixGeomInstance; - - protected: optix::Geometry optixGeometry; - - protected: optix::Buffer optixVertexBuffer; - - protected: optix::Buffer optixNormalBuffer; - - protected: optix::Buffer optixTexCoordBuffer; - - protected: optix::Buffer optixIndexBuffer; - - private: friend class OptixScene; - - private: friend class OptixSubMeshStoreFactory; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixMeshFactory.hh b/optix/include/ignition/rendering/optix/OptixMeshFactory.hh index 4bbe206c1..4ef7d2847 100644 --- a/optix/include/ignition/rendering/optix/OptixMeshFactory.hh +++ b/optix/include/ignition/rendering/optix/OptixMeshFactory.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,86 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXMESHFACTORY_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXMESHFACTORY_HH_ -#include -#include -#include - -#include "ignition/rendering/MeshDescriptor.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixMesh.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixSubMeshStoreFactory - { - // cppcheck-suppress noExplicitConstructor - public: OptixSubMeshStoreFactory(OptixScenePtr _scene); - - public: virtual ~OptixSubMeshStoreFactory(); - - public: virtual OptixSubMeshStorePtr Create(const MeshDescriptor &_desc); - - protected: virtual optix::Geometry Geometry( - const MeshDescriptor &_desc, unsigned int _subMeshIndex); - - protected: virtual std::string KeyName(const MeshDescriptor &_desc, - unsigned int _subMeshIndex); - - protected: std::map geometries; - - protected: OptixScenePtr scene; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixMeshFactory - { - // cppcheck-suppress noExplicitConstructor - public: OptixMeshFactory(OptixScenePtr _scene); - - public: virtual ~OptixMeshFactory(); - - public: virtual OptixMeshPtr Create(const MeshDescriptor &_desc); - - protected: virtual OptixMeshPtr Create(OptixSubMeshStorePtr _subMeshes); - - protected: OptixSubMeshStoreFactory subMeshStoreFactory; - - protected: OptixScenePtr scene; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixMeshGeometryFactory - { - public: OptixMeshGeometryFactory(OptixScenePtr _scene, - const common::SubMesh &_subMesh); - - public: virtual ~OptixMeshGeometryFactory(); - - public: virtual optix::Geometry Create(); - - protected: virtual void CreateGeometry(); - - protected: virtual optix::Buffer CreateVertexBuffer(); - - protected: virtual optix::Buffer CreateNormalBuffer(); - - protected: virtual optix::Buffer CreateTexCoordBuffer(); - - protected: virtual optix::Buffer CreateIndexBuffer(); - - protected: OptixScenePtr scene; - - protected: const common::SubMesh &subMesh; - - protected: optix::Geometry optixGeometry; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixNode.hh b/optix/include/ignition/rendering/optix/OptixNode.hh index 56efc518b..313f68011 100644 --- a/optix/include/ignition/rendering/optix/OptixNode.hh +++ b/optix/include/ignition/rendering/optix/OptixNode.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,91 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXNODE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXNODE_HH_ -#include "ignition/rendering/base/BaseNode.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixNode : - public BaseNode - { - protected: OptixNode(); - - public: virtual ~OptixNode(); - - public: virtual bool HasParent() const override; - - public: virtual NodePtr Parent() const override; - - public: virtual void PreRender() override; - - public: virtual optix::Transform OptixTransform() const; - - // Documentation inherited. - public: virtual math::Vector3d LocalScale() const override; - - // Documentation inherited. - public: virtual bool InheritScale() const override; - - // Documentation inherited. - public: virtual void SetInheritScale(bool _inherit) override; - - // Documentation inherited. - protected: virtual void SetLocalScaleImpl( - const math::Vector3d &_scale) override; - - protected: virtual math::Pose3d RawLocalPose() const override; - - protected: virtual void SetRawLocalPose(const math::Pose3d &_pose) - override; - - protected: virtual void WritePoseToDevice(); - - protected: virtual void WritePoseToDeviceImpl(); - - protected: virtual void SetParent(OptixNodePtr _parent); - - protected: virtual void Init() override; - - protected: virtual NodeStorePtr Children() const override; - - protected: virtual bool AttachChild(NodePtr _child) override; - - protected: virtual bool DetachChild(NodePtr _child) override; - - protected: OptixNodePtr parent; - - protected: optix::Transform optixTransform; - - protected: optix::Group optixGroup; - - protected: optix::Acceleration optixAccel; - - protected: math::Pose3d pose; - - protected: bool poseDirty; - - protected: OptixNodeStorePtr children; - - protected: math::Vector3d scale = math::Vector3d::One; - - protected: bool inheritScale = true; - - private: OptixNodePtr SharedThis(); - - // TODO remove the need for a visual friend class - private: friend class OptixVisual; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixObject.hh b/optix/include/ignition/rendering/optix/OptixObject.hh index a7ba45572..f39eb1b2d 100644 --- a/optix/include/ignition/rendering/optix/OptixObject.hh +++ b/optix/include/ignition/rendering/optix/OptixObject.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,33 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXOBJECT_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXOBJECT_HH_ -#include "ignition/rendering/base/BaseObject.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixObject : - public BaseObject - { - protected: OptixObject(); - - public: virtual ~OptixObject(); - - public: virtual ScenePtr Scene() const; - - protected: OptixScenePtr scene; - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixPrimitive.hh b/optix/include/ignition/rendering/optix/OptixPrimitive.hh index 0e0ff3f5b..7a729f4e4 100644 --- a/optix/include/ignition/rendering/optix/OptixPrimitive.hh +++ b/optix/include/ignition/rendering/optix/OptixPrimitive.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,62 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXPRIMITIVE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXPRIMITIVE_HH_ -#include -#include "ignition/rendering/optix/OptixGeometry.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixPrimitive : - public OptixGeometry - { - protected: OptixPrimitive(); - - public: virtual ~OptixPrimitive(); - - public: virtual MaterialPtr Material() const; - - public: virtual void SetMaterial(MaterialPtr _material, - bool _unique = true); - - public: virtual optix::GeometryGroup OptixGeometryGroup() const; - - public: virtual optix::Acceleration OptixAccel() const; - - public: virtual optix::GeometryInstance OptixGeometryInstance() const; - - public: virtual optix::Geometry OptixGeometry() const; - - public: virtual void PreRender(); - - protected: virtual void SetMaterialImpl(OptixMaterialPtr _material); - - protected: virtual void Init(); - - protected: static optix::Geometry CreateOptixGeometry( - OptixScenePtr _scene, const std::string &_ptxFile); - - protected: MaterialPtr material; - - protected: optix::GeometryGroup optixGeomGroup; - - protected: optix::Acceleration optixAccel; - - protected: optix::GeometryInstance optixGeomInstance; - - protected: optix::Geometry optixGeometry; - - protected: static const std::string PTX_INTERSECT_FUNC; - - protected: static const std::string PTX_BOUNDS_FUNC; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixRayTypes.hh b/optix/include/ignition/rendering/optix/OptixRayTypes.hh index bcfc9d966..e82e5f651 100644 --- a/optix/include/ignition/rendering/optix/OptixRayTypes.hh +++ b/optix/include/ignition/rendering/optix/OptixRayTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,45 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXRAYTYPES_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXRAYTYPES_HH_ -#include - -#ifndef __CUDA_ARCH__ -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // -#endif - - typedef enum OptixRayType_t - { - RT_RADIANCE = 0, - RT_SHADOW = 1, - RT_COUNT = 2, - } OptixRayType; - - struct OptixRadianceRayData - { - float3 color; - // cppcheck-suppress unusedStructMember - float importance; - // cppcheck-suppress unusedStructMember - int depth; - }; - - struct OptixShadowRayData - { - float3 attenuation; - }; - -#ifndef __CUDA_ARCH__ - } - } -} -#endif - -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixRenderEngine.hh b/optix/include/ignition/rendering/optix/OptixRenderEngine.hh index f823021f9..5f3b3ea56 100644 --- a/optix/include/ignition/rendering/optix/OptixRenderEngine.hh +++ b/optix/include/ignition/rendering/optix/OptixRenderEngine.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,77 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXRENDERENGINE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXRENDERENGINE_HH_ -#include -#include -#include - -#include "ignition/rendering/RenderEnginePlugin.hh" -#include "ignition/rendering/base/BaseRenderEngine.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - /// \brief Plugin for loading optix render engine - class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderEnginePlugin : - public RenderEnginePlugin - { - /// \brief Constructor - public: OptixRenderEnginePlugin(); - - /// \brief Destructor - public: ~OptixRenderEnginePlugin() = default; - - /// \brief Get the name of the render engine loaded by this plugin. - /// \return Name of render engine - public: std::string Name() const; - - /// \brief Get a pointer to the render engine loaded by this plugin. - /// \return Render engine instance - public: RenderEngine *Engine() const; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderEngine : - public virtual BaseRenderEngine, - public common::SingletonT - { - /// \brief Constructor - private: OptixRenderEngine(); - - public: virtual ~OptixRenderEngine(); - - public: virtual bool Fini(); - - public: virtual std::string Name() const; - - public: std::string PtxFile(const std::string& _fileBase) const; - - protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, - const std::string &_name); - - protected: virtual SceneStorePtr Scenes() const; - - // Documentation Inherited - protected: virtual bool LoadImpl( - const std::map &_params) override; - - protected: virtual bool InitImpl(); - - private: OptixSceneStorePtr scenes; - - private: static const std::string PTX_PREFIX; - - private: static const std::string PTX_SUFFIX; - - private: friend class SingletonT; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixRenderTarget.hh b/optix/include/ignition/rendering/optix/OptixRenderTarget.hh index 23ae139b8..78c4a22a8 100644 --- a/optix/include/ignition/rendering/optix/OptixRenderTarget.hh +++ b/optix/include/ignition/rendering/optix/OptixRenderTarget.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,70 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXRENDERTARGET_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXRENDERTARGET_HH_ -#include "ignition/rendering/base/BaseRenderTarget.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixObject.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderTarget : - public virtual BaseRenderTarget - { - protected: OptixRenderTarget(); - - public: virtual ~OptixRenderTarget(); - - public: virtual void Copy(Image &_image) const; - - public: virtual optix::Buffer OptixBuffer() const = 0; - - protected: unsigned int MemorySize() const; - - protected: float *hostData; - }; - - class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderTexture : - public virtual BaseRenderTexture - { - protected: OptixRenderTexture(); - - public: virtual ~OptixRenderTexture(); - - public: virtual void Destroy(); - - public: virtual optix::Buffer OptixBuffer() const; - - protected: virtual void RebuildImpl(); - - protected: optix::Buffer optixBuffer; - - protected: virtual void Init(); - - private: friend class OptixScene; - }; - - /// \brief Render window mocked using a render texture. - class IGNITION_RENDERING_OPTIX_VISIBLE OptixRenderWindow : - public virtual BaseRenderWindow - { - /// \brief Constructor - protected: OptixRenderWindow(); - - /// \brief Destructor - public: virtual ~OptixRenderWindow(); - - /// \brief Render windows should only be created by the scene class - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixRenderTypes.hh b/optix/include/ignition/rendering/optix/OptixRenderTypes.hh index 6f876f2cb..5135414b5 100644 --- a/optix/include/ignition/rendering/optix/OptixRenderTypes.hh +++ b/optix/include/ignition/rendering/optix/OptixRenderTypes.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,93 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXRENDERTYPES_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXRENDERTYPES_HH_ -#include "ignition/rendering/base/BaseRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class OptixArrowVisual; - class OptixAxisVisual; - class OptixBox; - class OptixCamera; - class OptixCone; - class OptixCylinder; - class OptixDirectionalLight; - class OptixGeometry; - class OptixGrid; - class OptixJointVisual; - class OptixLight; - class OptixMaterial; - class OptixMesh; - class OptixMeshFactory; - class OptixNode; - class OptixObject; - class OptixObjectFactory; - class OptixPointLight; - class OptixRenderEngine; - class OptixScene; - class OptixSensor; - class OptixSphere; - class OptixSpotLight; - class OptixSubMesh; - class OptixVisual; - class OptixRenderTarget; - class OptixRenderTexture; - class OptixRenderWindow; - class OptixLightManager; - - typedef BaseSceneStore OptixSceneStore; - typedef BaseNodeStore OptixNodeStore; - typedef BaseLightStore OptixLightStore; - typedef BaseSensorStore OptixSensorStore; - typedef BaseVisualStore OptixVisualStore; - typedef BaseGeometryStore OptixGeometryStore; - typedef BaseSubMeshStore OptixSubMeshStore; - typedef BaseMaterialMap OptixMaterialMap; - - typedef shared_ptr OptixArrowVisualPtr; - typedef shared_ptr OptixAxisVisualPtr; - typedef shared_ptr OptixBoxPtr; - typedef shared_ptr OptixCameraPtr; - typedef shared_ptr OptixConePtr; - typedef shared_ptr OptixCylinderPtr; - typedef shared_ptr OptixDirectionalLightPtr; - typedef shared_ptr OptixGeometryPtr; - typedef shared_ptr OptixGridPtr; - typedef shared_ptr OptixJointVisualPtr; - typedef shared_ptr OptixLightPtr; - typedef shared_ptr OptixMaterialPtr; - typedef shared_ptr OptixMeshPtr; - typedef shared_ptr OptixMeshFactoryPtr; - typedef shared_ptr OptixNodePtr; - typedef shared_ptr OptixObjectPtr; - typedef shared_ptr OptixObjectFactoryPtr; - typedef shared_ptr OptixPointLightPtr; - typedef shared_ptr OptixScenePtr; - typedef shared_ptr OptixSensorPtr; - typedef shared_ptr OptixSpherePtr; - typedef shared_ptr OptixSpotLightPtr; - typedef shared_ptr OptixSubMeshPtr; - typedef shared_ptr OptixVisualPtr; - typedef shared_ptr OptixSceneStorePtr; - typedef shared_ptr OptixNodeStorePtr; - typedef shared_ptr OptixLightStorePtr; - typedef shared_ptr OptixSensorStorePtr; - typedef shared_ptr OptixVisualStorePtr; - typedef shared_ptr OptixGeometryStorePtr; - typedef shared_ptr OptixSubMeshStorePtr; - typedef shared_ptr OptixMaterialMapPtr; - typedef shared_ptr OptixRenderTargetPtr; - typedef shared_ptr OptixRenderTexturePtr; - typedef shared_ptr OptixRenderWindowPtr; - typedef shared_ptr OptixLightManagerPtr; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixScene.hh b/optix/include/ignition/rendering/optix/OptixScene.hh index 5b69b9fa8..8f7c7e061 100644 --- a/optix/include/ignition/rendering/optix/OptixScene.hh +++ b/optix/include/ignition/rendering/optix/OptixScene.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,189 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXSCENE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXSCENE_HH_ -#include - -#include "ignition/rendering/base/BaseScene.hh" - -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixScene : - public BaseScene - { - protected: OptixScene(unsigned int _id, const std::string &_name); - - public: virtual ~OptixScene(); - - public: virtual void Fini(); - - public: virtual RenderEngine *Engine() const; - - public: virtual VisualPtr RootVisual() const; - - public: virtual math::Color AmbientLight() const; - - public: virtual void SetAmbientLight(const math::Color &_color); - - public: virtual void SetBackgroundColor(const math::Color &_color); - - // Documentation inherited. - public: virtual void SetGradientBackgroundColor( - const std::array &_colors); - - // Documentation inherited. - public: virtual void RemoveGradientBackgroundColor(); - - public: virtual void PreRender(); - - public: virtual void Clear(); - - public: virtual void Destroy(); - - public: virtual OptixLightManagerPtr LightManager() const; - - public: virtual optix::Context OptixContext() const; - - public: virtual optix::Program CreateOptixProgram( - const std::string &_fileBase, const std::string &_function); - - protected: virtual bool LoadImpl(); - - protected: virtual bool InitImpl(); - - protected: virtual DirectionalLightPtr CreateDirectionalLightImpl( - unsigned int _id, const std::string &_name); - - protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id, - const std::string &_name); - - protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id, - const std::string &_name); - - protected: virtual CameraPtr CreateCameraImpl(unsigned int _id, - const std::string &_name); - - // Documentation inherited - protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id, - const std::string &_name) override; - - protected: virtual VisualPtr CreateVisualImpl(unsigned int _id, - const std::string &_name); - - protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id, - const std::string &_name); - - protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id, - const std::string &_name); - - protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id, - const std::string &_name); - - protected: virtual GeometryPtr CreateConeImpl(unsigned int _id, - const std::string &_name); - - protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id, - const std::string &_name); - - protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id, - const std::string &_name); - - protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id, - const std::string &_name); - - protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, - const std::string &_name, const std::string &_meshName); - - protected: virtual MeshPtr CreateMeshImpl(unsigned int _id, - const std::string &_name, const MeshDescriptor &_desc); - - // Documentation inherited. - protected: virtual GridPtr CreateGridImpl(unsigned int _id, - const std::string &_name); - - protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id, - const std::string &_name); - - protected: virtual RenderTexturePtr CreateRenderTextureImpl( - unsigned int _id, const std::string &_name); - - // Documentation inherited. - protected: virtual RenderWindowPtr CreateRenderWindowImpl( - unsigned int _id, const std::string &_name); - - protected: virtual RayQueryPtr CreateRayQueryImpl( - unsigned int _id, const std::string &_name); - - protected: virtual bool InitObject(OptixObjectPtr _object, - unsigned int _id, const std::string &_name); - - protected: virtual LightStorePtr Lights() const; - - protected: virtual SensorStorePtr Sensors() const; - - protected: virtual VisualStorePtr Visuals() const; - - protected: virtual MaterialMapPtr Materials() const; - - protected: virtual unsigned int NextEntryId(); - - private: void CreateContext(); - - private: void CreateRootVisual(); - - private: void CreateLightManager(); - - private: void CreateMeshFactory(); - - private: void CreateStores(); - - private: OptixScenePtr SharedThis(); - - protected: OptixVisualPtr rootVisual; - - protected: OptixLightManagerPtr lightManager; - - protected: OptixMeshFactoryPtr meshFactory; - - protected: OptixLightStorePtr lights; - - protected: OptixSensorStorePtr sensors; - - protected: OptixVisualStorePtr visuals; - - protected: OptixMaterialMapPtr materials; - - protected: optix::Context optixContext; - - protected: optix::Group optixRootGroup; - - protected: optix::Acceleration optixRootAccel; - - protected: optix::Program optixMissProgram; - - protected: optix::Geometry optixBoxGeometry; - - protected: optix::Geometry optixConeGeometry; - - protected: optix::Geometry optixCylinderGeometry; - - protected: optix::Geometry optixSphereGeometry; - - protected: math::Color ambientLight; - - private: friend class OptixRenderEngine; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixSensor.hh b/optix/include/ignition/rendering/optix/OptixSensor.hh index 8804d5771..b296f55b5 100644 --- a/optix/include/ignition/rendering/optix/OptixSensor.hh +++ b/optix/include/ignition/rendering/optix/OptixSensor.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,26 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXSENSOR_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXSENSOR_HH_ -#include "ignition/rendering/base/BaseSensor.hh" -#include "ignition/rendering/optix/OptixNode.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixSensor : - public BaseSensor - { - protected: OptixSensor(); - - public: virtual ~OptixSensor(); - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixSphere.hh b/optix/include/ignition/rendering/optix/OptixSphere.hh index e7deb55f1..5fefd0c50 100644 --- a/optix/include/ignition/rendering/optix/OptixSphere.hh +++ b/optix/include/ignition/rendering/optix/OptixSphere.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXSPHERE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXSPHERE_HH_ -#include "ignition/rendering/optix/OptixPrimitive.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixSphere : - public OptixPrimitive - { - protected: OptixSphere(); - - public: virtual ~OptixSphere(); - - public: static optix::Geometry CreateOptixGeometry(OptixScenePtr _scene); - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixStorage.hh b/optix/include/ignition/rendering/optix/OptixStorage.hh index f81983810..02dc0ab8d 100644 --- a/optix/include/ignition/rendering/optix/OptixStorage.hh +++ b/optix/include/ignition/rendering/optix/OptixStorage.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,53 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXSTORAGE_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXSTORAGE_HH_ -#include "ignition/rendering/base/BaseStorage.hh" - -#include "ignition/rendering/optix/OptixGeometry.hh" -#include "ignition/rendering/optix/OptixLight.hh" -#include "ignition/rendering/optix/OptixMaterial.hh" -#include "ignition/rendering/optix/OptixMesh.hh" -#include "ignition/rendering/optix/OptixNode.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixSensor.hh" -#include "ignition/rendering/optix/OptixVisual.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - template class BaseSceneStore; - template class BaseNodeStore; - template class BaseLightStore; - template class BaseSensorStore; - template class BaseVisualStore; - template class BaseGeometryStore; - template class BaseSubMeshStore; - template class BaseMaterialMap; - - typedef BaseSceneStore OptixSceneStore; - typedef BaseNodeStore OptixNodeStore; - typedef BaseLightStore OptixLightStore; - typedef BaseSensorStore OptixSensorStore; - typedef BaseVisualStore OptixVisualStore; - typedef BaseGeometryStore OptixGeometryStore; - typedef BaseSubMeshStore OptixSubMeshStore; - typedef BaseMaterialMap OptixMaterialMap; - - typedef std::shared_ptr OptixSceneStorePtr; - typedef std::shared_ptr OptixNodeStorePtr; - typedef std::shared_ptr OptixLightStorePtr; - typedef std::shared_ptr OptixSensorStorePtr; - typedef std::shared_ptr OptixVisualStorePtr; - typedef std::shared_ptr OptixGeometryStorePtr; - typedef std::shared_ptr OptixSubMeshStorePtr; - typedef std::shared_ptr OptixMaterialMapPtr; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixTextureFactory.hh b/optix/include/ignition/rendering/optix/OptixTextureFactory.hh index fa5f6cd86..266b65ad7 100644 --- a/optix/include/ignition/rendering/optix/OptixTextureFactory.hh +++ b/optix/include/ignition/rendering/optix/OptixTextureFactory.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,39 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXTEXTUREFACTORY_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXTEXTUREFACTORY_HH_ -#include -#include "ignition/rendering/optix/OptixRenderTypes.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/Export.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixTextureFactory - { - public: explicit OptixTextureFactory(OptixScenePtr _scene); - - public: virtual ~OptixTextureFactory(); - - public: optix::TextureSampler Create(const std::string &_filename); - - public: optix::TextureSampler Create(); - - protected: optix::Buffer CreateBuffer(const std::string &_filename); - - protected: optix::Buffer CreateBuffer(); - - protected: optix::TextureSampler CreateSampler(optix::Buffer _buffer); - - protected: OptixScenePtr scene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/OptixVisual.hh b/optix/include/ignition/rendering/optix/OptixVisual.hh index 9b38dd8fe..7ed4d7380 100644 --- a/optix/include/ignition/rendering/optix/OptixVisual.hh +++ b/optix/include/ignition/rendering/optix/OptixVisual.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,49 +14,6 @@ * limitations under the License. * */ -#ifndef IGNITION_RENDERING_OPTIX_OPTIXVISUAL_HH_ -#define IGNITION_RENDERING_OPTIX_OPTIXVISUAL_HH_ -#include "ignition/rendering/base/BaseVisual.hh" -#include "ignition/rendering/optix/OptixNode.hh" -#include "ignition/rendering/optix/OptixRenderTypes.hh" - -namespace ignition -{ - namespace rendering - { - inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // - class IGNITION_RENDERING_OPTIX_VISIBLE OptixVisual : - public BaseVisual - { - protected: OptixVisual(); - - public: virtual ~OptixVisual(); - - public: virtual optix::Group OptixGroup() const; - - public: virtual optix::Acceleration OptixAccel() const; - - public: virtual void PreRender(); - - protected: virtual GeometryStorePtr Geometries() const; - - protected: virtual bool AttachGeometry(GeometryPtr _geometry); - - protected: virtual bool DetachGeometry(GeometryPtr _geometry); - - protected: virtual void Init(); - - private: void CreateStorage(); - - private: OptixVisualPtr SharedThis(); - - protected: OptixGeometryStorePtr geometries; - - private: friend class OptixScene; - }; - } - } -} -#endif +#include +#include diff --git a/optix/include/ignition/rendering/optix/optix.hh.in b/optix/include/ignition/rendering/optix/optix.hh.in deleted file mode 100644 index acfd26ae7..000000000 --- a/optix/include/ignition/rendering/optix/optix.hh.in +++ /dev/null @@ -1,3 +0,0 @@ -// Automatically generated -#include -${ign_headers} diff --git a/optix/src/OptixArrowVisual.cc b/optix/src/OptixArrowVisual.cc index 107b24f17..5492e1668 100644 --- a/optix/src/OptixArrowVisual.cc +++ b/optix/src/OptixArrowVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixArrowVisual.hh" +#include "gz/rendering/optix/OptixArrowVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixAxisVisual.cc b/optix/src/OptixAxisVisual.cc index e3b6d9f62..e12593d77 100644 --- a/optix/src/OptixAxisVisual.cc +++ b/optix/src/OptixAxisVisual.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixAxisVisual.hh" +#include "gz/rendering/optix/OptixAxisVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixBox.cc b/optix/src/OptixBox.cc index 0138980c1..2d51ee2a9 100644 --- a/optix/src/OptixBox.cc +++ b/optix/src/OptixBox.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixBox.hh" +#include "gz/rendering/optix/OptixBox.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixCamera.cc b/optix/src/OptixCamera.cc index caf345b39..b0bc8d9cb 100644 --- a/optix/src/OptixCamera.cc +++ b/optix/src/OptixCamera.cc @@ -14,14 +14,14 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixCamera.hh" +#include "gz/rendering/optix/OptixCamera.hh" -#include -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixRenderTarget.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixRenderTarget.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixCamera.cu b/optix/src/OptixCamera.cu index 70b8021b3..370239064 100644 --- a/optix/src/OptixCamera.cu +++ b/optix/src/OptixCamera.cu @@ -16,7 +16,7 @@ */ #include #include -#include +#include // camera variables rtDeclareVariable(float3, eye, , ); diff --git a/optix/src/OptixCone.cc b/optix/src/OptixCone.cc index 6ab546321..a5f731bca 100644 --- a/optix/src/OptixCone.cc +++ b/optix/src/OptixCone.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixCone.hh" +#include "gz/rendering/optix/OptixCone.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixConversions.cc b/optix/src/OptixConversions.cc index 27fa476ce..3f7193947 100644 --- a/optix/src/OptixConversions.cc +++ b/optix/src/OptixConversions.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixConversions.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixCylinder.cc b/optix/src/OptixCylinder.cc index 69a0939e9..be0539d05 100644 --- a/optix/src/OptixCylinder.cc +++ b/optix/src/OptixCylinder.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixCylinder.hh" +#include "gz/rendering/optix/OptixCylinder.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixGeometry.cc b/optix/src/OptixGeometry.cc index 03721eea4..4d703df24 100644 --- a/optix/src/OptixGeometry.cc +++ b/optix/src/OptixGeometry.cc @@ -15,12 +15,12 @@ * */ -#include "ignition/rendering/optix/OptixGeometry.hh" +#include "gz/rendering/optix/OptixGeometry.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixVisual.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixGrid.cc b/optix/src/OptixGrid.cc index 6d2c438bb..1ec8f0cd8 100644 --- a/optix/src/OptixGrid.cc +++ b/optix/src/OptixGrid.cc @@ -15,11 +15,11 @@ * */ -#include "ignition/rendering/optix/OptixGrid.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixVisual.hh" +#include "gz/rendering/optix/OptixGrid.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixLight.cc b/optix/src/OptixLight.cc index ab759dad6..64e7df818 100644 --- a/optix/src/OptixLight.cc +++ b/optix/src/OptixLight.cc @@ -14,14 +14,14 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixLight.hh" +#include "gz/rendering/optix/OptixLight.hh" -#include "ignition/rendering/optix/OptixConversions.hh" -#include "ignition/rendering/optix/OptixLightManager.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixLightManager.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixLightManager.cc b/optix/src/OptixLightManager.cc index a7ee354af..ea12678c8 100644 --- a/optix/src/OptixLightManager.cc +++ b/optix/src/OptixLightManager.cc @@ -14,13 +14,13 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixLightManager.hh" +#include "gz/rendering/optix/OptixLightManager.hh" -#include "ignition/rendering/optix/OptixLight.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixVisual.hh" +#include "gz/rendering/optix/OptixLight.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixVisual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixMaterial.cc b/optix/src/OptixMaterial.cc index a9b0561c8..9218c73d8 100644 --- a/optix/src/OptixMaterial.cc +++ b/optix/src/OptixMaterial.cc @@ -14,14 +14,14 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixMaterial.hh" -#include "ignition/rendering/optix/OptixConversions.hh" -#include "ignition/rendering/optix/OptixRayTypes.hh" -#include "ignition/rendering/optix/OptixRenderEngine.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixTextureFactory.hh" - -using namespace ignition; +#include "gz/rendering/optix/OptixMaterial.hh" +#include "gz/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixRayTypes.hh" +#include "gz/rendering/optix/OptixRenderEngine.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixTextureFactory.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixMaterial.cu b/optix/src/OptixMaterial.cu index 7539048fd..46ec0fa62 100644 --- a/optix/src/OptixMaterial.cu +++ b/optix/src/OptixMaterial.cu @@ -17,8 +17,8 @@ #include #include #include -#include "ignition/rendering/optix/OptixRayTypes.hh" -#include "ignition/rendering/optix/OptixLightTypes.hh" +#include "gz/rendering/optix/OptixRayTypes.hh" +#include "gz/rendering/optix/OptixLightTypes.hh" // scene variables rtDeclareVariable(float3, ambientLightColor, , ); diff --git a/optix/src/OptixMesh.cc b/optix/src/OptixMesh.cc index 8e0e0aa6b..39df3fcbb 100644 --- a/optix/src/OptixMesh.cc +++ b/optix/src/OptixMesh.cc @@ -15,14 +15,14 @@ * */ -#include +#include -#include "ignition/rendering/optix/OptixMesh.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixMaterial.hh" -#include "ignition/rendering/optix/OptixStorage.hh" +#include "gz/rendering/optix/OptixMesh.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixMaterial.hh" +#include "gz/rendering/optix/OptixStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixMeshFactory.cc b/optix/src/OptixMeshFactory.cc index 8788a3f2c..d7e0cc687 100644 --- a/optix/src/OptixMeshFactory.cc +++ b/optix/src/OptixMeshFactory.cc @@ -14,15 +14,15 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixMeshFactory.hh" +#include "gz/rendering/optix/OptixMeshFactory.hh" #include -#include -#include -#include "ignition/rendering/optix/OptixMesh.hh" -#include "ignition/rendering/optix/OptixStorage.hh" +#include +#include +#include "gz/rendering/optix/OptixMesh.hh" +#include "gz/rendering/optix/OptixStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixMissProgram.cu b/optix/src/OptixMissProgram.cu index 55a003a73..800b55b29 100644 --- a/optix/src/OptixMissProgram.cu +++ b/optix/src/OptixMissProgram.cu @@ -16,7 +16,7 @@ */ #include #include -#include "ignition/rendering/optix/OptixRayTypes.hh" +#include "gz/rendering/optix/OptixRayTypes.hh" rtDeclareVariable(float3, color, , ); rtDeclareVariable(OptixRadianceRayData, payload, rtPayload, ); diff --git a/optix/src/OptixNode.cc b/optix/src/OptixNode.cc index 9cbea0566..1e28cc737 100644 --- a/optix/src/OptixNode.cc +++ b/optix/src/OptixNode.cc @@ -14,13 +14,13 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixNode.hh" -#include "ignition/rendering/optix/OptixConversions.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixStorage.hh" +#include "gz/rendering/optix/OptixNode.hh" +#include "gz/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixObject.cc b/optix/src/OptixObject.cc index d30572cd9..07f25a4ab 100644 --- a/optix/src/OptixObject.cc +++ b/optix/src/OptixObject.cc @@ -14,11 +14,11 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixObject.hh" +#include "gz/rendering/optix/OptixObject.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixPrimitive.cc b/optix/src/OptixPrimitive.cc index 82eec6b7c..003d0401b 100644 --- a/optix/src/OptixPrimitive.cc +++ b/optix/src/OptixPrimitive.cc @@ -15,13 +15,13 @@ * */ -#include +#include -#include "ignition/rendering/optix/OptixPrimitive.hh" -#include "ignition/rendering/optix/OptixMaterial.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixPrimitive.hh" +#include "gz/rendering/optix/OptixMaterial.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixRenderEngine.cc b/optix/src/OptixRenderEngine.cc index 5c2d5e45e..fc9218295 100644 --- a/optix/src/OptixRenderEngine.cc +++ b/optix/src/OptixRenderEngine.cc @@ -17,15 +17,15 @@ #include -#include +#include -#include "ignition/rendering/RenderEngineManager.hh" -#include "ignition/rendering/optix/OptixIncludes.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixStorage.hh" -#include "ignition/rendering/optix/OptixRenderEngine.hh" +#include "gz/rendering/RenderEngineManager.hh" +#include "gz/rendering/optix/OptixIncludes.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixStorage.hh" +#include "gz/rendering/optix/OptixRenderEngine.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixRenderTarget.cc b/optix/src/OptixRenderTarget.cc index 890d31958..5f03ce7ed 100644 --- a/optix/src/OptixRenderTarget.cc +++ b/optix/src/OptixRenderTarget.cc @@ -15,14 +15,14 @@ * */ -#include +#include -#include "ignition/rendering/optix/OptixRenderTarget.hh" +#include "gz/rendering/optix/OptixRenderTarget.hh" -#include "ignition/rendering/optix/OptixConversions.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixScene.cc b/optix/src/OptixScene.cc index d7e97063c..46dcae5d5 100644 --- a/optix/src/OptixScene.cc +++ b/optix/src/OptixScene.cc @@ -13,27 +13,27 @@ * */ -#include - -#include "ignition/rendering/optix/OptixArrowVisual.hh" -#include "ignition/rendering/optix/OptixAxisVisual.hh" -#include "ignition/rendering/optix/OptixBox.hh" -#include "ignition/rendering/optix/OptixCamera.hh" -#include "ignition/rendering/optix/OptixCone.hh" -#include "ignition/rendering/optix/OptixCylinder.hh" -#include "ignition/rendering/optix/OptixGeometry.hh" -#include "ignition/rendering/optix/OptixGrid.hh" -#include "ignition/rendering/optix/OptixLightManager.hh" -#include "ignition/rendering/optix/OptixMeshFactory.hh" -#include "ignition/rendering/optix/OptixRayTypes.hh" -#include "ignition/rendering/optix/OptixRenderEngine.hh" -#include "ignition/rendering/optix/OptixRenderTarget.hh" -#include "ignition/rendering/optix/OptixScene.hh" -#include "ignition/rendering/optix/OptixSphere.hh" -#include "ignition/rendering/optix/OptixStorage.hh" -#include "ignition/rendering/optix/OptixVisual.hh" - -using namespace ignition; +#include + +#include "gz/rendering/optix/OptixArrowVisual.hh" +#include "gz/rendering/optix/OptixAxisVisual.hh" +#include "gz/rendering/optix/OptixBox.hh" +#include "gz/rendering/optix/OptixCamera.hh" +#include "gz/rendering/optix/OptixCone.hh" +#include "gz/rendering/optix/OptixCylinder.hh" +#include "gz/rendering/optix/OptixGeometry.hh" +#include "gz/rendering/optix/OptixGrid.hh" +#include "gz/rendering/optix/OptixLightManager.hh" +#include "gz/rendering/optix/OptixMeshFactory.hh" +#include "gz/rendering/optix/OptixRayTypes.hh" +#include "gz/rendering/optix/OptixRenderEngine.hh" +#include "gz/rendering/optix/OptixRenderTarget.hh" +#include "gz/rendering/optix/OptixScene.hh" +#include "gz/rendering/optix/OptixSphere.hh" +#include "gz/rendering/optix/OptixStorage.hh" +#include "gz/rendering/optix/OptixVisual.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixSensor.cc b/optix/src/OptixSensor.cc index 59d3d69bf..6efeb9203 100644 --- a/optix/src/OptixSensor.cc +++ b/optix/src/OptixSensor.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixSensor.hh" +#include "gz/rendering/optix/OptixSensor.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixSphere.cc b/optix/src/OptixSphere.cc index da64723db..45f7e8943 100644 --- a/optix/src/OptixSphere.cc +++ b/optix/src/OptixSphere.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/optix/OptixSphere.hh" +#include "gz/rendering/optix/OptixSphere.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/optix/src/OptixTextureFactory.cc b/optix/src/OptixTextureFactory.cc index 29b369d1f..039e692eb 100644 --- a/optix/src/OptixTextureFactory.cc +++ b/optix/src/OptixTextureFactory.cc @@ -15,13 +15,13 @@ */ #include -#include +#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/optix/OptixTextureFactory.hh" -#include "ignition/rendering/optix/OptixScene.hh" +#include "gz/rendering/config.hh" +#include "gz/rendering/optix/OptixTextureFactory.hh" +#include "gz/rendering/optix/OptixScene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; // TODO: clone texture sampler, reuse texture buffers diff --git a/optix/src/OptixVisual.cc b/optix/src/OptixVisual.cc index 3596a1551..cb51a1d27 100644 --- a/optix/src/OptixVisual.cc +++ b/optix/src/OptixVisual.cc @@ -15,13 +15,13 @@ * */ -#include +#include -#include "ignition/rendering/optix/OptixVisual.hh" -#include "ignition/rendering/optix/OptixConversions.hh" -#include "ignition/rendering/optix/OptixStorage.hh" +#include "gz/rendering/optix/OptixVisual.hh" +#include "gz/rendering/optix/OptixConversions.hh" +#include "gz/rendering/optix/OptixStorage.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/ArrowVisual_TEST.cc b/src/ArrowVisual_TEST.cc index b9c4ca073..5679b453d 100644 --- a/src/ArrowVisual_TEST.cc +++ b/src/ArrowVisual_TEST.cc @@ -22,10 +22,10 @@ #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/ArrowVisual.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/ArrowVisual.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" using namespace ignition; using namespace rendering; diff --git a/src/Camera_TEST.cc b/src/Camera_TEST.cc index 85809497b..24bea7f5f 100644 --- a/src/Camera_TEST.cc +++ b/src/Camera_TEST.cc @@ -17,17 +17,17 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GaussianNoisePass.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/Scene.hh" - -using namespace ignition; +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GaussianNoisePass.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/Scene.hh" + +using namespace gz; using namespace rendering; class CameraTest : public testing::Test, diff --git a/src/GaussianNoisePass.cc b/src/GaussianNoisePass.cc index 9fed44dbc..231225416 100644 --- a/src/GaussianNoisePass.cc +++ b/src/GaussianNoisePass.cc @@ -16,9 +16,9 @@ */ -#include "ignition/rendering/GaussianNoisePass.hh" +#include "gz/rendering/GaussianNoisePass.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/GaussianNoisePass_TEST.cc b/src/GaussianNoisePass_TEST.cc index 51d362ab8..a20e72cf3 100644 --- a/src/GaussianNoisePass_TEST.cc +++ b/src/GaussianNoisePass_TEST.cc @@ -18,15 +18,15 @@ #include #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/GaussianNoisePass.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderPassSystem.hh" +#include "gz/rendering/GaussianNoisePass.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderPassSystem.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class GaussianNoisePassTest : public testing::Test, diff --git a/src/GizmoVisual_TEST.cc b/src/GizmoVisual_TEST.cc index 12e13a935..8d0fbcac7 100644 --- a/src/GizmoVisual_TEST.cc +++ b/src/GizmoVisual_TEST.cc @@ -18,16 +18,16 @@ #include #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/GizmoVisual.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/GizmoVisual.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class GizmoVisualTest : public testing::Test, diff --git a/src/Grid_TEST.cc b/src/Grid_TEST.cc index 5968d74d5..d83ff34c9 100644 --- a/src/Grid_TEST.cc +++ b/src/Grid_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Grid.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Grid.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class GridTest : public testing::Test, diff --git a/src/Image.cc b/src/Image.cc index a2ad9cc43..983022e66 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/Image.hh" +#include "gz/rendering/Image.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/Light_TEST.cc b/src/Light_TEST.cc index 4001636aa..bb24051d3 100644 --- a/src/Light_TEST.cc +++ b/src/Light_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Light.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Light.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class LightTest : public testing::Test, diff --git a/src/Marker.cc b/src/Marker.cc index d83c181df..71481eabe 100644 --- a/src/Marker.cc +++ b/src/Marker.cc @@ -16,9 +16,9 @@ */ -#include "ignition/rendering/Marker.hh" +#include "gz/rendering/Marker.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/Marker_TEST.cc b/src/Marker_TEST.cc index a5a42091e..3ae7efda1 100644 --- a/src/Marker_TEST.cc +++ b/src/Marker_TEST.cc @@ -16,15 +16,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Marker.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Marker.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; using namespace std::chrono_literals; diff --git a/src/Material_TEST.cc b/src/Material_TEST.cc index 097827bbb..03a9b5aa2 100644 --- a/src/Material_TEST.cc +++ b/src/Material_TEST.cc @@ -18,19 +18,19 @@ #include #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Material.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/ShaderType.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Material.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/ShaderType.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class MaterialTest : public testing::Test, diff --git a/src/MeshDescriptor.cc b/src/MeshDescriptor.cc index f1a9d0690..3d0d2f13d 100644 --- a/src/MeshDescriptor.cc +++ b/src/MeshDescriptor.cc @@ -15,13 +15,13 @@ * */ -#include -#include -#include +#include +#include +#include -#include "ignition/rendering/MeshDescriptor.hh" +#include "gz/rendering/MeshDescriptor.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/MeshDescriptor_TEST.cc b/src/MeshDescriptor_TEST.cc index ed3d5c285..3254e355b 100644 --- a/src/MeshDescriptor_TEST.cc +++ b/src/MeshDescriptor_TEST.cc @@ -18,18 +18,18 @@ #include #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/MeshDescriptor.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/MeshDescriptor.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class MeshDescriptorTest : public testing::Test, diff --git a/src/Mesh_TEST.cc b/src/Mesh_TEST.cc index e8164cb6b..eefa8ad12 100644 --- a/src/Mesh_TEST.cc +++ b/src/Mesh_TEST.cc @@ -18,19 +18,19 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Mesh.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Mesh.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class MeshTest : public testing::Test, diff --git a/src/MoveToHelper.cc b/src/MoveToHelper.cc index f5467b9fe..ed4c3e475 100644 --- a/src/MoveToHelper.cc +++ b/src/MoveToHelper.cc @@ -15,17 +15,17 @@ * */ -#include "ignition/rendering/MoveToHelper.hh" +#include "gz/rendering/MoveToHelper.hh" #include -#include -#include -#include +#include +#include +#include -#include "ignition/rendering/Camera.hh" +#include "gz/rendering/Camera.hh" -class ignition::rendering::MoveToHelperPrivate +class gz::rendering::MoveToHelperPrivate { /// \brief Pose animation object public: std::unique_ptr poseAnim; @@ -40,7 +40,7 @@ class ignition::rendering::MoveToHelperPrivate public: math::Pose3d initCameraPose; }; -using namespace ignition; +using namespace gz; using namespace rendering; //////////////////////////////////////////////// diff --git a/src/MoveToHelper_TEST.cc b/src/MoveToHelper_TEST.cc index c386bbaca..11960476e 100644 --- a/src/MoveToHelper_TEST.cc +++ b/src/MoveToHelper_TEST.cc @@ -19,16 +19,16 @@ #include #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class MoveToHelperTest : public testing::Test, diff --git a/src/Node_TEST.cc b/src/Node_TEST.cc index 8bea71c14..2fa2573c2 100644 --- a/src/Node_TEST.cc +++ b/src/Node_TEST.cc @@ -18,17 +18,17 @@ #include #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Node.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Visual.hh" +#include "gz/rendering/Node.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Visual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class NodeTest : public testing::Test, diff --git a/src/OrbitViewController.cc b/src/OrbitViewController.cc index 6a63b1732..37206ad0b 100644 --- a/src/OrbitViewController.cc +++ b/src/OrbitViewController.cc @@ -15,13 +15,13 @@ * */ -#include +#include -#include "ignition/rendering/OrbitViewController.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Visual.hh" +#include "gz/rendering/OrbitViewController.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Visual.hh" -class ignition::rendering::OrbitViewControllerPrivate +class gz::rendering::OrbitViewControllerPrivate { /// \brief Pointer to camera public: CameraPtr camera; @@ -30,7 +30,7 @@ class ignition::rendering::OrbitViewControllerPrivate public: math::Vector3d target; }; -using namespace ignition; +using namespace gz; using namespace rendering; static const float PITCH_LIMIT_LOW = -static_cast(IGN_PI)*0.5f + 0.001f; diff --git a/src/OrbitViewController_TEST.cc b/src/OrbitViewController_TEST.cc index 2e611bd11..2d86e8ece 100644 --- a/src/OrbitViewController_TEST.cc +++ b/src/OrbitViewController_TEST.cc @@ -17,16 +17,16 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/OrbitViewController.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/OrbitViewController.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class OrbitViewControllerTest : public testing::Test, diff --git a/src/PixelFormat.cc b/src/PixelFormat.cc index 1d42c0531..75fa8dd95 100644 --- a/src/PixelFormat.cc +++ b/src/PixelFormat.cc @@ -15,11 +15,11 @@ * */ -#include +#include -#include "ignition/rendering/PixelFormat.hh" +#include "gz/rendering/PixelFormat.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/PixelFormat_TEST.cc b/src/PixelFormat_TEST.cc index ee6e8c05f..c62d1524d 100644 --- a/src/PixelFormat_TEST.cc +++ b/src/PixelFormat_TEST.cc @@ -19,9 +19,9 @@ #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/PixelFormat.hh" +#include "gz/rendering/PixelFormat.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ///////////////////////////////////////////////// diff --git a/src/RayQuery_TEST.cc b/src/RayQuery_TEST.cc index a7608648c..f0e35d389 100644 --- a/src/RayQuery_TEST.cc +++ b/src/RayQuery_TEST.cc @@ -17,17 +17,17 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class RayQueryTest : public testing::Test, diff --git a/src/RenderEngineManager.cc b/src/RenderEngineManager.cc index 04883baf5..f604b82d1 100644 --- a/src/RenderEngineManager.cc +++ b/src/RenderEngineManager.cc @@ -18,15 +18,15 @@ #include #include -#include -#include +#include +#include -#include +#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderEngineManager.hh" -#include "ignition/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderEngineManager.hh" +#include "gz/rendering/RenderEnginePlugin.hh" /// \brief Holds information about an engine struct EngineInfo @@ -36,11 +36,11 @@ struct EngineInfo std::string name; /// \brief The pointer to the render engine. - ignition::rendering::RenderEngine *engine; + gz::rendering::RenderEngine *engine; }; /// \brief Private implementation of the RenderEngineManager class. -class ignition::rendering::RenderEngineManagerPrivate +class gz::rendering::RenderEngineManagerPrivate { /// \brief EngineMap that maps engine name to an engine pointer. typedef std::map EngineMap; @@ -93,7 +93,7 @@ class ignition::rendering::RenderEngineManagerPrivate public: std::map enginePlugins; /// \brief Plugin loader for managing render engine plugin libraries. - public: ignition::plugin::Loader pluginLoader; + public: gz::plugin::Loader pluginLoader; /// \brief List which holds paths to look for engine plugins. public: std::list pluginPaths; @@ -102,7 +102,7 @@ class ignition::rendering::RenderEngineManagerPrivate public: std::recursive_mutex enginesMutex; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/RenderEnginePlugin.cc b/src/RenderEnginePlugin.cc index e14d7aa06..7f89fa2b5 100644 --- a/src/RenderEnginePlugin.cc +++ b/src/RenderEnginePlugin.cc @@ -15,13 +15,13 @@ * */ -#include "ignition/rendering/RenderEnginePlugin.hh" +#include "gz/rendering/RenderEnginePlugin.hh" -class ignition::rendering::RenderEnginePluginPrivate +class gz::rendering::RenderEnginePluginPrivate { }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/RenderEngine_TEST.cc b/src/RenderEngine_TEST.cc index fd05abc7b..e88d1def7 100644 --- a/src/RenderEngine_TEST.cc +++ b/src/RenderEngine_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class RenderEngineTest : public testing::Test, diff --git a/src/RenderPassSystem.cc b/src/RenderPassSystem.cc index 5d4116d39..ef16bca0d 100644 --- a/src/RenderPassSystem.cc +++ b/src/RenderPassSystem.cc @@ -15,15 +15,15 @@ * */ -#include +#include -#include "ignition/rendering/RenderPassSystem.hh" +#include "gz/rendering/RenderPassSystem.hh" -using namespace ignition; +using namespace gz; using namespace rendering; /// \brief Private implementation of the RenderPassSystem class -class ignition::rendering::RenderPassSystemPrivate +class gz::rendering::RenderPassSystemPrivate { }; diff --git a/src/RenderPassSystem_TEST.cc b/src/RenderPassSystem_TEST.cc index 4443b154a..941d6406b 100644 --- a/src/RenderPassSystem_TEST.cc +++ b/src/RenderPassSystem_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/GaussianNoisePass.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderPassSystem.hh" +#include "gz/rendering/GaussianNoisePass.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderPassSystem.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class RenderPassSystemTest : public testing::Test, diff --git a/src/RenderTarget_TEST.cc b/src/RenderTarget_TEST.cc index dae01de4a..8b300bc1c 100644 --- a/src/RenderTarget_TEST.cc +++ b/src/RenderTarget_TEST.cc @@ -17,19 +17,19 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GaussianNoisePass.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/RenderTarget.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GaussianNoisePass.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/RenderTarget.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class RenderTargetTest : public testing::Test, diff --git a/src/RenderingIface.cc b/src/RenderingIface.cc index b4b586670..48b6727ce 100644 --- a/src/RenderingIface.cc +++ b/src/RenderingIface.cc @@ -15,12 +15,12 @@ * */ -#include "ignition/common/Console.hh" +#include "gz/common/Console.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderEngineManager.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderEngineManager.hh" +#include "gz/rendering/Scene.hh" namespace ignition { @@ -129,7 +129,7 @@ void setPluginPaths(const std::list &_paths) ////////////////////////////////////////////////// ScenePtr sceneFromFirstRenderEngine() { - auto loadedEngNames = ignition::rendering::loadedEngines(); + auto loadedEngNames = gz::rendering::loadedEngines(); if (loadedEngNames.empty()) { igndbg << "No rendering engine is loaded yet" << std::endl; @@ -143,7 +143,7 @@ ScenePtr sceneFromFirstRenderEngine() << "Using engine [" << engineName << "]" << std::endl; } - auto engine = ignition::rendering::engine(engineName); + auto engine = gz::rendering::engine(engineName); if (!engine) { ignerr << "Internal error: failed to load engine [" << engineName diff --git a/src/RenderingIface_TEST.cc b/src/RenderingIface_TEST.cc index 999ff536d..971afd4fb 100644 --- a/src/RenderingIface_TEST.cc +++ b/src/RenderingIface_TEST.cc @@ -19,13 +19,13 @@ #include "test_config.h" // NOLINT(build/include) -#include +#include -#include "ignition/rendering/config.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" +#include "gz/rendering/config.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ///////////////////////////////////////////////// diff --git a/src/Scene_TEST.cc b/src/Scene_TEST.cc index c825f3fe9..55170ef22 100644 --- a/src/Scene_TEST.cc +++ b/src/Scene_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderTarget.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderTarget.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class SceneTest : public testing::Test, diff --git a/src/ShaderParam.cc b/src/ShaderParam.cc index a4c7c6f80..1aac74bb9 100644 --- a/src/ShaderParam.cc +++ b/src/ShaderParam.cc @@ -15,12 +15,12 @@ * */ -#include "ignition/rendering/ShaderParam.hh" +#include "gz/rendering/ShaderParam.hh" -using namespace ignition::rendering; +using namespace gz::rendering; -class ignition::rendering::ShaderParamPrivate +class gz::rendering::ShaderParamPrivate { /// \brief Type of parameter held public: ShaderParam::ParamType type = ShaderParam::PARAM_NONE; diff --git a/src/ShaderParam_TEST.cc b/src/ShaderParam_TEST.cc index 7965f976b..3c736834c 100644 --- a/src/ShaderParam_TEST.cc +++ b/src/ShaderParam_TEST.cc @@ -17,9 +17,9 @@ #include -#include "ignition/rendering/ShaderParam.hh" +#include "gz/rendering/ShaderParam.hh" -using namespace ignition::rendering; +using namespace gz::rendering; ///////////////////////////////////////////////// diff --git a/src/ShaderParams.cc b/src/ShaderParams.cc index 3f59c08cb..336473a49 100644 --- a/src/ShaderParams.cc +++ b/src/ShaderParams.cc @@ -15,14 +15,14 @@ * */ -#include "ignition/rendering/ShaderParams.hh" +#include "gz/rendering/ShaderParams.hh" #include -using namespace ignition::rendering; +using namespace gz::rendering; -class ignition::rendering::ShaderParamsPrivate +class gz::rendering::ShaderParamsPrivate { /// \brief collection of parameters public: std::unordered_map parameters; @@ -32,7 +32,7 @@ class ignition::rendering::ShaderParamsPrivate }; -class ignition::rendering::ShaderParams::IteratorPrivate +class gz::rendering::ShaderParams::IteratorPrivate { /// \brief Iterator from the map in ShaderParamsPrivate public: std::unordered_map::const_iterator iter; diff --git a/src/ShaderParams_TEST.cc b/src/ShaderParams_TEST.cc index 01b84a8c6..31e7acbec 100644 --- a/src/ShaderParams_TEST.cc +++ b/src/ShaderParams_TEST.cc @@ -17,9 +17,9 @@ #include -#include "ignition/rendering/ShaderParams.hh" +#include "gz/rendering/ShaderParams.hh" -using namespace ignition::rendering; +using namespace gz::rendering; ///////////////////////////////////////////////// diff --git a/src/ShaderType.cc b/src/ShaderType.cc index 5b175a3b3..81b3c2c17 100644 --- a/src/ShaderType.cc +++ b/src/ShaderType.cc @@ -15,11 +15,11 @@ * */ -#include +#include -#include "ignition/rendering/ShaderType.hh" +#include "gz/rendering/ShaderType.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/Text_TEST.cc b/src/Text_TEST.cc index 63f44f396..1eafe7472 100644 --- a/src/Text_TEST.cc +++ b/src/Text_TEST.cc @@ -16,15 +16,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Text.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Text.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class TextTest : public testing::Test, diff --git a/src/ThermalCamera_TEST.cc b/src/ThermalCamera_TEST.cc index 29a57724a..fdbe14dc5 100644 --- a/src/ThermalCamera_TEST.cc +++ b/src/ThermalCamera_TEST.cc @@ -17,15 +17,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/ThermalCamera.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/ThermalCamera.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class ThermalCameraTest : public testing::Test, diff --git a/src/TransformController.cc b/src/TransformController.cc index 03ba26385..c9a1cf4a3 100644 --- a/src/TransformController.cc +++ b/src/TransformController.cc @@ -15,17 +15,17 @@ * */ -#include -#include +#include +#include -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/GizmoVisual.hh" -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/TransformController.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/GizmoVisual.hh" +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/TransformController.hh" /// \brief Private data class for TransformController -class ignition::rendering::TransformControllerPrivate +class gz::rendering::TransformControllerPrivate { /// \brief Gizmo visual that provides translation, rotation, and scale /// tandles for transformation @@ -48,21 +48,21 @@ class ignition::rendering::TransformControllerPrivate public: RayQueryPtr ray; /// \brief Current active axis of transformation - public: ignition::math::Vector3d axis; + public: gz::math::Vector3d axis; /// \brief Flag to indicate that transfomation is in progress. public: bool active = false; /// \brief Initial pose of the node being transformed. /// This is set in Start(); - public: ignition::math::Pose3d nodeStartPose; + public: gz::math::Pose3d nodeStartPose; /// \brief Initial scale of the node being transformed. /// This is set in Start(); - public: ignition::math::Vector3d nodeStartScale; + public: gz::math::Vector3d nodeStartScale; }; -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/TransformController_TEST.cc b/src/TransformController_TEST.cc index eb25bdfdb..9b71e8185 100644 --- a/src/TransformController_TEST.cc +++ b/src/TransformController_TEST.cc @@ -17,17 +17,17 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/TransformController.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/TransformController.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class TransformControllerTest : public testing::Test, diff --git a/src/Utils.cc b/src/Utils.cc index cd6de8286..08e00cb67 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -20,13 +20,13 @@ #include #endif -#include "ignition/math/Plane.hh" -#include "ignition/math/Vector2.hh" -#include "ignition/math/Vector3.hh" +#include "gz/math/Plane.hh" +#include "gz/math/Vector2.hh" +#include "gz/math/Vector3.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/Utils.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/Utils.hh" namespace ignition { @@ -91,7 +91,7 @@ math::Vector3d screenToPlane( _rayQuery->SetFromCamera( _camera, math::Vector2d(nx, ny)); - ignition::math::Planed plane(ignition::math::Vector3d(0, 0, 1), offset); + gz::math::Planed plane(gz::math::Vector3d(0, 0, 1), offset); math::Vector3d origin = _rayQuery->Origin(); math::Vector3d direction = _rayQuery->Direction(); diff --git a/src/Utils_TEST.cc b/src/Utils_TEST.cc index 43e3a1e7c..f2ed38024 100644 --- a/src/Utils_TEST.cc +++ b/src/Utils_TEST.cc @@ -15,19 +15,19 @@ */ #include -#include +#include -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Utils.hh" -#include "ignition/rendering/Visual.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Utils.hh" +#include "gz/rendering/Visual.hh" #include "test_config.h" // NOLINT(build/include) -using namespace ignition; +using namespace gz; using namespace rendering; class UtilTest : public testing::Test, diff --git a/src/Visual_TEST.cc b/src/Visual_TEST.cc index 2234d112a..6c2f7a021 100644 --- a/src/Visual_TEST.cc +++ b/src/Visual_TEST.cc @@ -18,17 +18,17 @@ #include #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Geometry.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" -#include "ignition/rendering/Visual.hh" +#include "gz/rendering/Geometry.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" +#include "gz/rendering/Visual.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class VisualTest : public testing::Test, diff --git a/src/base/BaseObject.cc b/src/base/BaseObject.cc index d27bcaa67..b00a5e987 100644 --- a/src/base/BaseObject.cc +++ b/src/base/BaseObject.cc @@ -14,9 +14,9 @@ * limitations under the License. * */ -#include "ignition/rendering/base/BaseObject.hh" +#include "gz/rendering/base/BaseObject.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/base/BaseRenderEngine.cc b/src/base/BaseRenderEngine.cc index 5a0c26cca..53e9c44d2 100644 --- a/src/base/BaseRenderEngine.cc +++ b/src/base/BaseRenderEngine.cc @@ -15,12 +15,12 @@ * */ -#include +#include -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/base/BaseRenderEngine.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/base/BaseRenderEngine.hh" -using namespace ignition; +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/src/base/BaseScene.cc b/src/base/BaseScene.cc index da781814b..80eb9fbd7 100644 --- a/src/base/BaseScene.cc +++ b/src/base/BaseScene.cc @@ -17,30 +17,30 @@ #include -#include - -#include -#include -#include - -#include "ignition/common/Time.hh" - -#include "ignition/rendering/ArrowVisual.hh" -#include "ignition/rendering/AxisVisual.hh" -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/DepthCamera.hh" -#include "ignition/rendering/GizmoVisual.hh" -#include "ignition/rendering/GpuRays.hh" -#include "ignition/rendering/Grid.hh" -#include "ignition/rendering/RayQuery.hh" -#include "ignition/rendering/RenderTarget.hh" -#include "ignition/rendering/Text.hh" -#include "ignition/rendering/ThermalCamera.hh" -#include "ignition/rendering/Visual.hh" -#include "ignition/rendering/base/BaseStorage.hh" -#include "ignition/rendering/base/BaseScene.hh" - -using namespace ignition; +#include + +#include +#include +#include + +#include "gz/common/Time.hh" + +#include "gz/rendering/ArrowVisual.hh" +#include "gz/rendering/AxisVisual.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/DepthCamera.hh" +#include "gz/rendering/GizmoVisual.hh" +#include "gz/rendering/GpuRays.hh" +#include "gz/rendering/Grid.hh" +#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/RenderTarget.hh" +#include "gz/rendering/Text.hh" +#include "gz/rendering/ThermalCamera.hh" +#include "gz/rendering/Visual.hh" +#include "gz/rendering/base/BaseStorage.hh" +#include "gz/rendering/base/BaseScene.hh" + +using namespace gz; using namespace rendering; ////////////////////////////////////////////////// diff --git a/test/integration/camera.cc b/test/integration/camera.cc index 6763dcba5..50c880cb4 100644 --- a/test/integration/camera.cc +++ b/test/integration/camera.cc @@ -17,16 +17,16 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class CameraTest: public testing::Test, diff --git a/test/integration/deprecated_TEST.cc b/test/integration/deprecated_TEST.cc new file mode 100644 index 000000000..c38c5ad83 --- /dev/null +++ b/test/integration/deprecated_TEST.cc @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include +#include + +///////////////////////////////////////////////// +// Make sure the ignition namespace still works +TEST(Deprecated, IgnitionNamespace) +{ + ignition::camera::Camera camera; +} diff --git a/test/integration/depth_camera.cc b/test/integration/depth_camera.cc index 38a1388b4..85c37bb5a 100644 --- a/test/integration/depth_camera.cc +++ b/test/integration/depth_camera.cc @@ -17,16 +17,16 @@ #include -#include -#include -#include +#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/DepthCamera.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/DepthCamera.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" #define DEPTH_TOL 1e-4 #define DOUBLE_TOL 1e-6 @@ -71,7 +71,7 @@ void DepthCameraTest::DepthCameraBoxes( double aspectRatio_ = imgWidth_/imgHeight_; double unitBoxSize = 1.0; - ignition::math::Vector3d boxPosition(1.8, 0.0, 0.0); + gz::math::Vector3d boxPosition(1.8, 0.0, 0.0); // Optix is not supported if (_renderEngine.compare("optix") == 0) @@ -82,7 +82,7 @@ void DepthCameraTest::DepthCameraBoxes( } // Setup ign-rendering with an empty scene - auto *engine = ignition::rendering::engine(_renderEngine); + auto *engine = gz::rendering::engine(_renderEngine); if (!engine) { igndbg << "Engine '" << _renderEngine @@ -90,23 +90,23 @@ void DepthCameraTest::DepthCameraBoxes( return; } - ignition::rendering::ScenePtr scene = engine->CreateScene("scene"); + gz::rendering::ScenePtr scene = engine->CreateScene("scene"); // red background scene->SetBackgroundColor(1.0, 0.0, 0.0); // Create an scene with a box in it scene->SetAmbientLight(1.0, 1.0, 1.0); - ignition::rendering::VisualPtr root = scene->RootVisual(); + gz::rendering::VisualPtr root = scene->RootVisual(); // create blue material - ignition::rendering::MaterialPtr blue = scene->CreateMaterial(); + gz::rendering::MaterialPtr blue = scene->CreateMaterial(); blue->SetAmbient(0.0, 0.0, 1.0); blue->SetDiffuse(0.0, 0.0, 1.0); blue->SetSpecular(0.0, 0.0, 1.0); // create box visual - ignition::rendering::VisualPtr box = scene->CreateVisual(); + gz::rendering::VisualPtr box = scene->CreateVisual(); box->AddGeometry(scene->CreateBox()); box->SetOrigin(0.0, 0.0, 0.0); box->SetLocalPosition(boxPosition); @@ -122,8 +122,8 @@ void DepthCameraTest::DepthCameraBoxes( auto depthCamera = scene->CreateDepthCamera("DepthCamera"); ASSERT_NE(depthCamera, nullptr); - ignition::math::Pose3d testPose(ignition::math::Vector3d(0, 0, 0), - ignition::math::Quaterniond::Identity); + gz::math::Pose3d testPose(gz::math::Vector3d(0, 0, 0), + gz::math::Quaterniond::Identity); depthCamera->SetLocalPose(testPose); // Configure depth camera @@ -147,7 +147,7 @@ void DepthCameraTest::DepthCameraBoxes( // Set a callback on the camera sensor to get a depth camera frame float *scan = new float[imgHeight_ * imgWidth_]; - ignition::common::ConnectionPtr connection = + gz::common::ConnectionPtr connection = depthCamera->ConnectNewDepthFrame( std::bind(&::OnNewDepthFrame, scan, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, @@ -157,7 +157,7 @@ void DepthCameraTest::DepthCameraBoxes( unsigned int pointCloudChannelCount = 4u; float *pointCloudData = new float[ imgHeight_ * imgWidth_ * pointCloudChannelCount]; - ignition::common::ConnectionPtr connection2 = + gz::common::ConnectionPtr connection2 = depthCamera->ConnectNewRgbPointCloud( std::bind(&::OnNewRgbPointCloud, pointCloudData, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, @@ -189,8 +189,8 @@ void DepthCameraTest::DepthCameraBoxes( * (depthCamera->ImageWidth() * pointCloudChannelCount) - pointCloudChannelCount; - float minVal = -ignition::math::INF_D; - float maxVal = ignition::math::INF_D; + float minVal = -gz::math::INF_D; + float maxVal = gz::math::INF_D; // Verify Depth // Depth sensor should see box in the middle of the image @@ -289,7 +289,7 @@ void DepthCameraTest::DepthCameraBoxes( } // Check that for a box really close it returns it is not seen - ignition::math::Vector3d boxPositionNear( + gz::math::Vector3d boxPositionNear( unitBoxSize * 0.5 + nearDist * 0.5, 0.0, 0.0); box->SetLocalPosition(boxPositionNear); @@ -345,7 +345,7 @@ void DepthCameraTest::DepthCameraBoxes( } // Check that for a box really far it returns max val - ignition::math::Vector3d boxPositionFar( + gz::math::Vector3d boxPositionFar( unitBoxSize * 0.5 + farDist * 1.5, 0.0, 0.0); box->SetLocalPosition(boxPositionFar); @@ -403,7 +403,7 @@ void DepthCameraTest::DepthCameraBoxes( } // Check that the depth values for a box do not warp. - ignition::math::Vector3d boxPositionFillFrame( + gz::math::Vector3d boxPositionFillFrame( unitBoxSize * 0.5 + 0.2, 0.0, 0.0); box->SetLocalPosition(boxPositionFillFrame); @@ -468,7 +468,7 @@ void DepthCameraTest::DepthCameraBoxes( } engine->DestroyScene(scene); - ignition::rendering::unloadEngine(engine->Name()); + gz::rendering::unloadEngine(engine->Name()); } TEST_P(DepthCameraTest, DepthCameraBoxes) @@ -477,7 +477,7 @@ TEST_P(DepthCameraTest, DepthCameraBoxes) } INSTANTIATE_TEST_CASE_P(DepthCamera, DepthCameraTest, - RENDER_ENGINE_VALUES, ignition::rendering::PrintToStringParam()); + RENDER_ENGINE_VALUES, gz::rendering::PrintToStringParam()); ////////////////////////////////////////////////// int main(int argc, char **argv) diff --git a/test/integration/gpu_rays.cc b/test/integration/gpu_rays.cc index a2b3946e5..3c9c7f882 100644 --- a/test/integration/gpu_rays.cc +++ b/test/integration/gpu_rays.cc @@ -17,16 +17,16 @@ #include -#include -#include -#include +#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/GpuRays.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/GpuRays.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" #define LASER_TOL 2e-4 #define DOUBLE_TOL 1e-6 @@ -36,7 +36,7 @@ #define WAIT_TIME 0.02 -using namespace ignition; +using namespace gz; using namespace rendering; void OnNewGpuRaysFrame(float *_scanDest, const float *_scan, diff --git a/test/integration/render_pass.cc b/test/integration/render_pass.cc index abee56692..543d23f23 100644 --- a/test/integration/render_pass.cc +++ b/test/integration/render_pass.cc @@ -17,20 +17,20 @@ #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/DepthCamera.hh" -#include "ignition/rendering/GaussianNoisePass.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/RenderPassSystem.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/DepthCamera.hh" +#include "gz/rendering/GaussianNoisePass.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/RenderPassSystem.hh" +#include "gz/rendering/Scene.hh" #define DOUBLE_TOL 1e-6 unsigned int g_pointCloudCounter = 0; @@ -45,7 +45,7 @@ void OnNewRgbPointCloud(float *_scanDest, const float *_scan, memcpy(_scanDest, _scan, size * sizeof(f)); g_pointCloudCounter++; } -using namespace ignition; +using namespace gz; using namespace rendering; class RenderPassTest: public testing::Test, diff --git a/test/integration/scene.cc b/test/integration/scene.cc index ab0a631ce..889551e79 100644 --- a/test/integration/scene.cc +++ b/test/integration/scene.cc @@ -17,16 +17,16 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class SceneTest: public testing::Test, diff --git a/test/integration/shadows.cc b/test/integration/shadows.cc index 40dd10d16..f1f7c43f7 100644 --- a/test/integration/shadows.cc +++ b/test/integration/shadows.cc @@ -17,19 +17,19 @@ #include -#include -#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/Camera.hh" -#include "ignition/rendering/Image.hh" -#include "ignition/rendering/PixelFormat.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/Camera.hh" +#include "gz/rendering/Image.hh" +#include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; class ShadowsTest: public testing::Test, diff --git a/test/integration/thermal_camera.cc b/test/integration/thermal_camera.cc index 08ebb92a1..e74bed75c 100644 --- a/test/integration/thermal_camera.cc +++ b/test/integration/thermal_camera.cc @@ -17,16 +17,16 @@ #include -#include -#include -#include +#include +#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/ThermalCamera.hh" -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/ThermalCamera.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" #define DEPTH_TOL 1e-4 #define DOUBLE_TOL 1e-6 @@ -59,7 +59,7 @@ class ThermalCameraTest: public testing::Test, // Documentation inherited protected: void SetUp() override { - ignition::common::Console::SetVerbosity(4); + gz::common::Console::SetVerbosity(4); } }; @@ -72,7 +72,7 @@ void ThermalCameraTest::ThermalCameraBoxes( double aspectRatio = imgWidth/imgHeight; double unitBoxSize = 1.0; - ignition::math::Vector3d boxPosition(1.8, 0.0, 0.0); + gz::math::Vector3d boxPosition(1.8, 0.0, 0.0); // Optix is not supported if (_renderEngine.compare("optix") == 0) @@ -83,7 +83,7 @@ void ThermalCameraTest::ThermalCameraBoxes( } // Setup ign-rendering with an empty scene - auto *engine = ignition::rendering::engine(_renderEngine); + auto *engine = gz::rendering::engine(_renderEngine); if (!engine) { igndbg << "Engine '" << _renderEngine @@ -91,17 +91,17 @@ void ThermalCameraTest::ThermalCameraBoxes( return; } - ignition::rendering::ScenePtr scene = engine->CreateScene("scene"); + gz::rendering::ScenePtr scene = engine->CreateScene("scene"); // red background scene->SetBackgroundColor(1.0, 0.0, 0.0); // Create an scene with a box in it scene->SetAmbientLight(1.0, 1.0, 1.0); - ignition::rendering::VisualPtr root = scene->RootVisual(); + gz::rendering::VisualPtr root = scene->RootVisual(); // create box visual - ignition::rendering::VisualPtr box = scene->CreateVisual(); + gz::rendering::VisualPtr box = scene->CreateVisual(); box->AddGeometry(scene->CreateBox()); box->SetOrigin(0.0, 0.0, 0.0); box->SetLocalPosition(boxPosition); @@ -123,8 +123,8 @@ void ThermalCameraTest::ThermalCameraBoxes( auto thermalCamera = scene->CreateThermalCamera("ThermalCamera"); ASSERT_NE(thermalCamera, nullptr); - ignition::math::Pose3d testPose(ignition::math::Vector3d(0, 0, 0), - ignition::math::Quaterniond::Identity); + gz::math::Pose3d testPose(gz::math::Vector3d(0, 0, 0), + gz::math::Quaterniond::Identity); thermalCamera->SetLocalPose(testPose); // Configure thermal camera @@ -160,7 +160,7 @@ void ThermalCameraTest::ThermalCameraBoxes( // Set a callback on the camera sensor to get a thermal camera frame uint16_t *thermalData = new uint16_t[imgHeight * imgWidth]; - ignition::common::ConnectionPtr connection = + gz::common::ConnectionPtr connection = thermalCamera->ConnectNewThermalFrame( std::bind(&::OnNewThermalFrame, thermalData, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, @@ -189,7 +189,7 @@ void ThermalCameraTest::ThermalCameraBoxes( // move box in front of near clip plane and verify the thermal // image returns all box temperature values - ignition::math::Vector3d boxPositionNear( + gz::math::Vector3d boxPositionNear( unitBoxSize * 0.5 + nearDist * 0.5, 0.0, 0.0); box->SetLocalPosition(boxPositionNear); thermalCamera->Update(); @@ -209,7 +209,7 @@ void ThermalCameraTest::ThermalCameraBoxes( // move box beyond far clip plane and verify the thermal // image returns all ambient temperature values - ignition::math::Vector3d boxPositionFar( + gz::math::Vector3d boxPositionFar( unitBoxSize * 0.5 + farDist * 1.5, 0.0, 0.0); box->SetLocalPosition(boxPositionFar); thermalCamera->Update(); @@ -230,7 +230,7 @@ void ThermalCameraTest::ThermalCameraBoxes( } engine->DestroyScene(scene); - ignition::rendering::unloadEngine(engine->Name()); + gz::rendering::unloadEngine(engine->Name()); } TEST_P(ThermalCameraTest, ThermalCameraBoxes) @@ -239,7 +239,7 @@ TEST_P(ThermalCameraTest, ThermalCameraBoxes) } INSTANTIATE_TEST_CASE_P(ThermalCamera, ThermalCameraTest, - RENDER_ENGINE_VALUES, ignition::rendering::PrintToStringParam()); + RENDER_ENGINE_VALUES, gz::rendering::PrintToStringParam()); ////////////////////////////////////////////////// int main(int argc, char **argv) diff --git a/test/performance/scene_factory.cc b/test/performance/scene_factory.cc index 99f8aff31..334cd50e6 100644 --- a/test/performance/scene_factory.cc +++ b/test/performance/scene_factory.cc @@ -22,15 +22,15 @@ #include -#include +#include #include "test_config.h" // NOLINT(build/include) -#include "ignition/rendering/RenderEngine.hh" -#include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Scene.hh" +#include "gz/rendering/RenderEngine.hh" +#include "gz/rendering/RenderingIface.hh" +#include "gz/rendering/Scene.hh" -using namespace ignition; +using namespace gz; using namespace rendering; diff --git a/test/test_config.h.in b/test/test_config.h.in index b78b67897..d75a726ef 100644 --- a/test/test_config.h.in +++ b/test/test_config.h.in @@ -1,5 +1,5 @@ -#ifndef IGNITION_RENDERING_TEST_CONFIG_HH_ -#define IGNITION_RENDERING_TEST_CONFIG_HH_ +#ifndef GZ_RENDERING_TEST_CONFIG_HH_ +#define GZ_RENDERING_TEST_CONFIG_HH_ #define PROJECT_SOURCE_PATH "${PROJECT_SOURCE_DIR}" #define PROJECT_BUILD_PATH "${PROJECT_BINARY_DIR}" @@ -7,12 +7,12 @@ /// \brief Helper macro to instantiate gtest for different engines #define RENDER_ENGINE_VALUES ::testing::ValuesIn(\ - ignition::rendering::TestValues()) + gz::rendering::TestValues()) static const std::vector kRenderEngineTestValues{"ogre2", "optix"}; #include -#include +#include namespace ignition { diff --git a/tutorials/03_rendering_plugins.md b/tutorials/03_rendering_plugins.md index 6ede6dfca..feafbd78b 100644 --- a/tutorials/03_rendering_plugins.md +++ b/tutorials/03_rendering_plugins.md @@ -4,7 +4,7 @@ This is an introduction to different rendering engines and how they are integrat ## Ignition Rendering -The \ref ignition::rendering "Ignition Rendering" library integrates external rendering engines into the Ignition Simulation eco-system. +The \ref gz::rendering "Ignition Rendering" library integrates external rendering engines into the Ignition Simulation eco-system. It allows users to select from multiple supported rendering engines based on their simulation needs. Its plugin interface loads rendering engines at runtime. It is also possible to integrate your own selected rendering engine by writing a compatible plugin interface. @@ -14,11 +14,11 @@ It is also possible to integrate your own selected rendering engine by writing a A mocked example of a custom rendering engine plugin can be found [here](https://github.com/ignitionrobotics/ign-rendering/tree/ign-rendering3/examples/hello_world_plugin). In order to make your own custom rendering engine, this example is a good starting point. There are a few key things which will need to be done in order for a custom rendering engine to function: - * A singleton Render Engine class which implements the pure virtual functions in [`ignition::rendering::BaseRenderEngine`](https://github.com/ignitionrobotics/ign-rendering/blob/main/include/ignition/rendering/base/BaseRenderEngine.hh). - * A plugin class which implements the pure virtual functions in [`ignition::rendering::RenderEnginePlugin`](https://github.com/ignitionrobotics/ign-rendering/blob/main/include/ignition/rendering/RenderEnginePlugin.hh) + * A singleton Render Engine class which implements the pure virtual functions in [`gz::rendering::BaseRenderEngine`](https://github.com/ignitionrobotics/ign-rendering/blob/main/include/ignition/rendering/base/BaseRenderEngine.hh). + * A plugin class which implements the pure virtual functions in [`gz::rendering::RenderEnginePlugin`](https://github.com/ignitionrobotics/ign-rendering/blob/main/include/ignition/rendering/RenderEnginePlugin.hh) * Registering the plugin, this line can be seen at the bottom of the [`HelloWorldPlugin`](https://github.com/ignitionrobotics/ign-rendering/tree/ign-rendering3/examples/hello_world_plugin/HelloWorldPlugin.cc) example -Finally, for your custom rendering engine to actually have any functionality and at minimum, display something in a window, you will need to implement your own `Scene` and `Camera` classes, which inherit from and implement the pure virtual functions of [`ignition::rendering::Scene`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/include/ignition/rendering/Scene.hh) and [`ignition::rendering::Camera`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/include/ignition/rendering/Camera.hh), respectively. The mocked example simply returns `nullptr` for its `CreateSceneImpl(...)` function, so it may be useful to look at the current `Scene` implementations for the other rendering engines within `ignition::rendering` such as [`OGRE`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/ogre/src/OgreScene.cc) or [`OGRE2`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/ogre2/src/Ogre2Scene.cc). Likewise, it may be helpful to look at the `Camera` implementations from [`OGRE`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/ogre/src/OgreCamera.cc) and [`OGRE2`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/ogre2/src/Ogre2Camera.cc) +Finally, for your custom rendering engine to actually have any functionality and at minimum, display something in a window, you will need to implement your own `Scene` and `Camera` classes, which inherit from and implement the pure virtual functions of [`gz::rendering::Scene`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/include/ignition/rendering/Scene.hh) and [`gz::rendering::Camera`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/include/ignition/rendering/Camera.hh), respectively. The mocked example simply returns `nullptr` for its `CreateSceneImpl(...)` function, so it may be useful to look at the current `Scene` implementations for the other rendering engines within `ignition::rendering` such as [`OGRE`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/ogre/src/OgreScene.cc) or [`OGRE2`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/ogre2/src/Ogre2Scene.cc). Likewise, it may be helpful to look at the `Camera` implementations from [`OGRE`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/ogre/src/OgreCamera.cc) and [`OGRE2`](https://github.com/ignitionrobotics/ign-rendering/blob/ign-rendering3/ogre2/src/Ogre2Camera.cc) #### Building and Running Your Rendering Engine Plugin with Ignition Gazebo