From e2d29d40488d8fa7a2c01bfda99886d79385f8c6 Mon Sep 17 00:00:00 2001 From: erwincoumans Date: Fri, 17 Nov 2017 13:33:27 -0800 Subject: [PATCH] also enable depth and segmentation mask preview window in example browser/pybullet You can disable/enable all preview windows using: p.configureDebugVisualizer(p.COV_ENABLE_RGB_BUFFER_PREVIEW,0/1) p.configureDebugVisualizer(p.COV_ENABLE_DEPTH_BUFFER_PREVIEW,0/1) p.configureDebugVisualizer(p.COV_ENABLE_SEGMENTATION_MASK_PREVIEW,0/1) --- .../SharedMemory/PhysicsServerExample.cpp | 58 ++++++++++++++++++- examples/SharedMemory/SharedMemoryPublic.h | 4 ++ examples/pybullet/pybullet.c | 3 + 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/examples/SharedMemory/PhysicsServerExample.cpp b/examples/SharedMemory/PhysicsServerExample.cpp index 39766cc48..4f051e42b 100644 --- a/examples/SharedMemory/PhysicsServerExample.cpp +++ b/examples/SharedMemory/PhysicsServerExample.cpp @@ -1752,8 +1752,8 @@ void PhysicsServerExample::initPhysics() m_canvasRGBIndex = m_canvas->createCanvas("Synthetic Camera RGB data",gCamVisualizerWidth, gCamVisualizerHeight); - //m_canvasDepthIndex = m_canvas->createCanvas("Synthetic Camera Depth data",gCamVisualizerWidth, gCamVisualizerHeight); - //m_canvasSegMaskIndex = m_canvas->createCanvas("Synthetic Camera Segmentation Mask",gCamVisualizerWidth, gCamVisualizerHeight); + m_canvasDepthIndex = m_canvas->createCanvas("Synthetic Camera Depth data",gCamVisualizerWidth, gCamVisualizerHeight); + m_canvasSegMaskIndex = m_canvas->createCanvas("Synthetic Camera Segmentation Mask",gCamVisualizerWidth, gCamVisualizerHeight); for (int i=0;im_visualizerFlag; int enable = m_multiThreadedHelper->m_visualizerEnable; + if (flag == COV_ENABLE_RGB_BUFFER_PREVIEW) + { + if (enable) + { + if (m_canvasRGBIndex<0) + { + m_canvasRGBIndex = m_canvas->createCanvas("Synthetic Camera RGB data",gCamVisualizerWidth, gCamVisualizerHeight); + } + } else + { + if (m_canvasRGBIndex>=0) + { + m_canvas->destroyCanvas(m_canvasRGBIndex); + m_canvasRGBIndex = -1; + } + } + } + + if (flag == COV_ENABLE_DEPTH_BUFFER_PREVIEW) + { + if (enable) + { + if (m_canvasDepthIndex<0) + { + m_canvasDepthIndex = m_canvas->createCanvas("Synthetic Camera Depth data",gCamVisualizerWidth, gCamVisualizerHeight); + } + } else + { + if (m_canvasDepthIndex>=0) + { + m_canvas->destroyCanvas(m_canvasDepthIndex); + m_canvasDepthIndex = -1; + } + } + } + + if (flag == COV_ENABLE_SEGMENTATION_MARK_PREVIEW) + { + if (enable) + { + if (m_canvasSegMaskIndex<0) + { + m_canvasSegMaskIndex = m_canvas->createCanvas("Synthetic Camera Segmentation Mask",gCamVisualizerWidth, gCamVisualizerHeight); + } + } else + { + if (m_canvasSegMaskIndex>=0) + { + m_canvas->destroyCanvas(m_canvasSegMaskIndex); + m_canvasSegMaskIndex = -1; + } + } + } + if (flag==COV_ENABLE_VR_TELEPORTING) { gEnableTeleporting = (enable!=0); diff --git a/examples/SharedMemory/SharedMemoryPublic.h b/examples/SharedMemory/SharedMemoryPublic.h index a1f59ae45..fc8fa9c7c 100644 --- a/examples/SharedMemory/SharedMemoryPublic.h +++ b/examples/SharedMemory/SharedMemoryPublic.h @@ -600,6 +600,10 @@ enum b3ConfigureDebugVisualizerEnum COV_ENABLE_MOUSE_PICKING, COV_ENABLE_Y_AXIS_UP, COV_ENABLE_TINY_RENDERER, + COV_ENABLE_RGB_BUFFER_PREVIEW, + COV_ENABLE_DEPTH_BUFFER_PREVIEW, + COV_ENABLE_SEGMENTATION_MARK_PREVIEW, + }; enum b3AddUserDebugItemEnum diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index afb3fd895..b11fcdc25 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -8209,6 +8209,9 @@ initpybullet(void) PyModule_AddIntConstant(m, "COV_ENABLE_KEYBOARD_SHORTCUTS", COV_ENABLE_KEYBOARD_SHORTCUTS); PyModule_AddIntConstant(m, "COV_ENABLE_MOUSE_PICKING", COV_ENABLE_MOUSE_PICKING); + PyModule_AddIntConstant(m, "COV_ENABLE_RGB_BUFFER_PREVIEW", COV_ENABLE_RGB_BUFFER_PREVIEW); + PyModule_AddIntConstant(m, "COV_ENABLE_DEPTH_BUFFER_PREVIEW", COV_ENABLE_DEPTH_BUFFER_PREVIEW); + PyModule_AddIntConstant(m, "COV_ENABLE_SEGMENTATION_MARK_PREVIEW", COV_ENABLE_SEGMENTATION_MARK_PREVIEW); PyModule_AddIntConstant(m, "ER_TINY_RENDERER", ER_TINY_RENDERER); PyModule_AddIntConstant(m, "ER_BULLET_HARDWARE_OPENGL", ER_BULLET_HARDWARE_OPENGL);