Skip to content

Commit

Permalink
Merge pull request #496 from ignitionrobotics/ahcorde/6_to_main
Browse files Browse the repository at this point in the history
6 to main
  • Loading branch information
iche033 authored Nov 30, 2021
2 parents a8dcb3a + c47c3ba commit 7f34b67
Show file tree
Hide file tree
Showing 87 changed files with 3,599 additions and 110 deletions.
18 changes: 16 additions & 2 deletions examples/actor_animation/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ void buildScene(ScenePtr _scene, std::vector<VisualPtr> &_visuals,

//////////////////////////////////////////////////
CameraPtr createCamera(const std::string &_engineName,
const std::map<std::string, std::string>& _params,
std::vector<VisualPtr> &_visuals, common::SkeletonPtr &_skel)
{
// create and populate scene
RenderEngine *engine = rendering::engine(_engineName);
RenderEngine *engine = rendering::engine(_engineName, _params);
if (!engine)
{
ignwarn << "Engine '" << _engineName
Expand Down Expand Up @@ -187,6 +188,12 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
}

common::Console::SetVerbosity(4);
std::vector<std::string> engineNames;
std::vector<CameraPtr> cameras;
Expand All @@ -201,7 +208,14 @@ int main(int _argc, char** _argv)
std::cout << "Starting engine [" << engineName << "]" << std::endl;
try
{
CameraPtr camera = createCamera(engineName, visuals, skel);
std::map<std::string, std::string> params;
if (engineName.compare("ogre2") == 0
&& graphicsApi == GraphicsAPI::METAL)
{
params["metal"] = "1";
}

CameraPtr camera = createCamera(engineName, params, visuals, skel);
if (camera)
{
cameras.push_back(camera);
Expand Down
20 changes: 17 additions & 3 deletions examples/camera_tracking/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ NodePtr createMainNode(ScenePtr _scene)
}

//////////////////////////////////////////////////
CameraPtr createCamera(const std::string &_engineName)
CameraPtr createCamera(const std::string &_engineName,
const std::map<std::string, std::string>& _params)
{
// create and populate scene
RenderEngine *engine = rendering::engine(_engineName);
RenderEngine *engine = rendering::engine(_engineName, _params);
if (!engine)
{
std::cout << "Engine '" << _engineName
Expand Down Expand Up @@ -126,6 +127,12 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
}

common::Console::SetVerbosity(4);
std::vector<std::string> engineNames;
std::vector<CameraPtr> cameras;
Expand All @@ -138,7 +145,14 @@ int main(int _argc, char** _argv)
{
try
{
CameraPtr camera = createCamera(engineName);
std::map<std::string, std::string> params;
if (engineName.compare("ogre2") == 0
&& graphicsApi == GraphicsAPI::METAL)
{
params["metal"] = "1";
}

CameraPtr camera = createCamera(engineName, params);
if (camera)
{
cameras.push_back(camera);
Expand Down
20 changes: 17 additions & 3 deletions examples/custom_scene_viewer/ManualSceneDemo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ unsigned int ManualSceneDemo::CameraCount() const
}

//////////////////////////////////////////////////
void ManualSceneDemo::AddCamera(const std::string &_engineName)
void ManualSceneDemo::AddCamera(const std::string &_engineName,
const std::map<std::string, std::string>& _params)
{
RenderEngine *engine = rendering::engine(_engineName);
RenderEngine *engine = rendering::engine(_engineName, _params);
if (!engine)
{
std::cout << "Engine '" << _engineName
Expand Down Expand Up @@ -191,6 +192,19 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
}

std::map<std::string, std::string> params;
if (ogreEngineName.compare("ogre2") == 0
&& graphicsApi == GraphicsAPI::METAL)
{
params["metal"] = "1";
}

common::Console::SetVerbosity(4);
//! [add scenes]
ManualSceneDemoPtr sceneDemo(new ManualSceneDemo);
Expand All @@ -208,7 +222,7 @@ int main(int _argc, char** _argv)
sceneDemo->AddScene(SceneBuilderPtr(new ShadowSceneBuilder(4)));
sceneDemo->AddScene(SceneBuilderPtr(new ShadowSceneBuilder(5)));
//! [add scenes]
sceneDemo->AddCamera(ogreEngineName);
sceneDemo->AddCamera(ogreEngineName, params);
sceneDemo->AddCamera("optix");
sceneDemo->Run();
return 0;
Expand Down
4 changes: 3 additions & 1 deletion examples/custom_scene_viewer/ManualSceneDemo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_
#define IGNITION_RENDERING_EXAMPLES_CUSTOM_SCENE_VIEWER_MANUALSCENEDEMO_HH_

#include <map>
#include <string>
#include <ignition/rendering.hh>
#include "TestTypes.hh"
Expand Down Expand Up @@ -46,7 +47,8 @@ namespace ignition

public: virtual unsigned int CameraCount() const;

public: virtual void AddCamera(const std::string &_engineName);
public: virtual void AddCamera(const std::string &_engineName,
const std::map<std::string, std::string>& _params = {});

public: virtual void PrevCamera();

Expand Down
39 changes: 39 additions & 0 deletions examples/depth_camera/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(ignition-rendering-depth-camera)
find_package(ignition-rendering6 REQUIRED)

include_directories(SYSTEM
${PROJECT_BINARY_DIR}
)

find_package(GLUT REQUIRED)
include_directories(SYSTEM ${GLUT_INCLUDE_DIRS})
link_directories(${GLUT_LIBRARY_DIRS})

find_package(OpenGL REQUIRED)
include_directories(SYSTEM ${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})

if (NOT APPLE)
find_package(GLEW REQUIRED)
include_directories(SYSTEM ${GLEW_INCLUDE_DIRS})
link_directories(${GLEW_LIBRARY_DIRS})
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")

configure_file (example_config.hh.in ${PROJECT_BINARY_DIR}/example_config.hh)

add_executable(depth_camera Main.cc GlutWindow.cc)

target_link_libraries(depth_camera
${GLUT_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
${IGNITION-RENDERING_LIBRARIES}
)

add_custom_command(TARGET depth_camera POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/media
$<TARGET_FILE_DIR:depth_camera>/media)
Loading

0 comments on commit 7f34b67

Please sign in to comment.