preparation to receive camera image data from physics server

increase shadowmap world size default to 50 units (meter), 10 units (meter) was too small for most examples.
This commit is contained in:
erwin coumans
2016-05-31 10:23:04 -07:00
parent de9bd65c19
commit 14aa666c6f
21 changed files with 301 additions and 22 deletions

View File

@@ -143,6 +143,9 @@ struct OpenGLGuiHelperInternalData
struct CommonGraphicsApp* m_glApp;
class MyDebugDrawer* m_debugDraw;
GL_ShapeDrawer* m_gl2ShapeDrawer;
btAlignedObjectArray<unsigned char> m_rgbaPixelBuffer;
btAlignedObjectArray<float> m_depthBuffer;
};
@@ -323,6 +326,51 @@ void OpenGLGuiHelper::resetCamera(float camDist, float pitch, float yaw, float c
}
void OpenGLGuiHelper::copyCameraImageData(unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, float* depthBuffer, int depthBufferSizeInPixels, int startPixelIndex, int* widthPtr, int* heightPtr, int* numPixelsCopied)
{
int w = m_data->m_glApp->m_window->getWidth();
int h = m_data->m_glApp->m_window->getHeight();
if (widthPtr)
*widthPtr = w;
if (heightPtr)
*heightPtr = h;
if (numPixelsCopied)
*numPixelsCopied = 0;
int numTotalPixels = w*h;
int numRemainingPixels = numTotalPixels - startPixelIndex;
int numBytesPerPixel = 4;//RGBA
int numRequestedPixels = btMin(rgbaBufferSizeInPixels,numRemainingPixels);
if (numRequestedPixels)
{
if (startPixelIndex==0)
{
//quick test: render the scene
getRenderInterface()->renderScene();
//copy the image into our local cache
m_data->m_rgbaPixelBuffer.resize(w*h*numBytesPerPixel);
m_data->m_depthBuffer.resize(w*h);
m_data->m_glApp->getScreenPixels(&(m_data->m_rgbaPixelBuffer[0]),m_data->m_rgbaPixelBuffer.size());
}
for (int i=0;i<numRequestedPixels*numBytesPerPixel;i++)
{
if (pixelsRGBA)
{
pixelsRGBA[i] = m_data->m_rgbaPixelBuffer[i+startPixelIndex*numBytesPerPixel];
}
}
if (numPixelsCopied)
*numPixelsCopied = numRequestedPixels;
}
}
struct MyConvertPointerSizeT