diff --git a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp index 62cd73147..4fa27685c 100644 --- a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp +++ b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp @@ -1326,7 +1326,7 @@ void OpenGLExampleBrowser::update(float deltaTime) float camPos[3]; s_guiHelper->getRenderInterface()->getActiveCamera()->getCameraPosition(camPos); s_guiHelper->getRenderInterface()->getActiveCamera()->getCameraTargetPosition(camTarget); - sprintf(msg,"camPos=%f,%f,%f, dist=%f, pitch=%f, yaw=%f,target=%f,%f,%f", camPos[0],camPos[1],camPos[2],camDist,pitch,yaw,camTarget[0],camTarget[1],camTarget[2]); + sprintf(msg,"camTargetPos=%2.2f,%2.2f,%2.2f, dist=%2.2f, pitch=%2.2f, yaw=%2.2f", camPos[0],camPos[1],camPos[2],camDist,pitch,yaw); gui2->setStatusBarMessage(msg, true); } diff --git a/examples/SharedMemory/PhysicsServerExample.cpp b/examples/SharedMemory/PhysicsServerExample.cpp index 32ce41d36..ebadcad29 100644 --- a/examples/SharedMemory/PhysicsServerExample.cpp +++ b/examples/SharedMemory/PhysicsServerExample.cpp @@ -2096,8 +2096,9 @@ void PhysicsServerExample::updateGraphics() int startSegIndex = m_multiThreadedHelper->m_startPixelIndex; int endSegIndex = startSegIndex + (*m_multiThreadedHelper->m_numPixelsCopied); - btScalar frustumZNear = m_multiThreadedHelper->m_projectionMatrix[14]/(m_multiThreadedHelper->m_projectionMatrix[10]-1); - btScalar frustumZFar = 20;//m_multiThreadedHelper->m_projectionMatrix[14]/(m_multiThreadedHelper->m_projectionMatrix[10]+1); + //btScalar frustumZNear = m_multiThreadedHelper->m_projectionMatrix[14]/(m_multiThreadedHelper->m_projectionMatrix[10]-1); + //btScalar frustumZFar = m_multiThreadedHelper->m_projectionMatrix[14]/(m_multiThreadedHelper->m_projectionMatrix[10]+1); + for (int i=0;i-1e20) { int rgb = 0; - btScalar minDepthValue = 0.98;//todo: compute more reasonably min/max depth range - btScalar maxDepthValue = 1; + btScalar frustumZNear = 0.1; + btScalar frustumZFar = 30; + btScalar minDepthValue = frustumZNear;//todo: compute more reasonably min/max depth range + btScalar maxDepthValue = frustumZFar; - if (maxDepthValue!=minDepthValue) - { - rgb = (depthValue-minDepthValue)*(255. / (btFabs(maxDepthValue-minDepthValue))); - if (rgb<0 || rgb>255) - { - //printf("rgb=%d\n",rgb); - } - } + float depth = depthValue; + double linearDepth = 255.*(2.0 * frustumZNear) / (frustumZFar + frustumZNear - depth * (frustumZFar - frustumZNear)); + btClamp(linearDepth, btScalar(0),btScalar(255)); + rgb = linearDepth; + m_canvas->setPixel(m_canvasDepthIndex,i,j, rgb, rgb,