Skip to content

Commit

Permalink
Add Projector (#845)
Browse files Browse the repository at this point in the history
Add support for Projectors - an object that projects a texture onto a surface.

In order to get this new feature in gz-rendering7 in an ABI compatible way, I introduced a new SceneExt class that provides a generic CreateExt function for creating a Projector object. The proper way is to add CreateProjector virtual function in base class and override them in ogre 1.x and 2.x implementation which changes vtable and so breaks ABI. I have added all these functions but they are commented out with a todo not to uncomment them when forward porting to gz-rendering8

* The ogre 1.x implementation is ported from gazebo-classic's Projector class. It uses ogre material projective texturing feature. in addition, I extended the implementation to support visibility flags so that we can toggle the visibility of the projected texture based on the camera's visibility mask.
* The ogre 2.x implementation uses screen space decals (instead of projective texturing) and has a different behavior.
Also added support for setting visibility flags. Note: There is one major caveat with this implementation. The projection is not in the form of a "frustum" (i.e. projection becomes larger at longer distance). It uses ogre 2.x screen space decals. Think of a as a rectangular volume and any surface that intersects with the volume will have the texture mapped onto it. We will need to investigate whether it's possible to change the implementation to match the ogre 1.x behavior in the future. 

---------

Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored May 16, 2023
1 parent 7dc64e5 commit 91f5fe9
Show file tree
Hide file tree
Showing 36 changed files with 2,841 additions and 12 deletions.
40 changes: 40 additions & 0 deletions examples/projector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(gz-rendering-projector)
find_package(gz-rendering7 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(projector Main.cc GlutWindow.cc)

target_link_libraries(projector
${GLUT_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
gz-rendering7::gz-rendering7
gz-rendering7::core
)

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

0 comments on commit 91f5fe9

Please sign in to comment.