Expose API to set projective texture instead of using global.
This commit is contained in:
@@ -166,7 +166,7 @@ SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES VERSION ${BULLET_VERSION})
|
|||||||
SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES SOVERSION ${BULLET_VERSION})
|
SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES SOVERSION ${BULLET_VERSION})
|
||||||
|
|
||||||
IF (BUILD_SHARED_LIBS)
|
IF (BUILD_SHARED_LIBS)
|
||||||
TARGET_LINK_LIBRARIES(BulletRobotics BulletInverseDynamicsUtils BulletWorldImporter BulletFileLoader BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamics OpenGLWindow LinearMath Bullet3Common)
|
TARGET_LINK_LIBRARIES(BulletRobotics BulletInverseDynamicsUtils BulletWorldImporter BulletFileLoader BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamics LinearMath Bullet3Common)
|
||||||
ENDIF (BUILD_SHARED_LIBS)
|
ENDIF (BUILD_SHARED_LIBS)
|
||||||
|
|
||||||
IF (INSTALL_EXTRA_LIBS)
|
IF (INSTALL_EXTRA_LIBS)
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ struct GUIHelperInterface
|
|||||||
int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied){}
|
int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied){}
|
||||||
|
|
||||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])=0;
|
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])=0;
|
||||||
|
virtual void setProjectiveTexture(bool useProjectiveTexture)=0;
|
||||||
|
|
||||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) =0;
|
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) =0;
|
||||||
|
|
||||||
@@ -183,6 +184,10 @@ struct DummyGUIHelper : public GUIHelperInterface
|
|||||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])
|
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void setProjectiveTexture(bool useProjectiveTexture)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld)
|
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ struct CommonRenderInterface
|
|||||||
virtual void setLightPosition(const float lightPos[3]) = 0;
|
virtual void setLightPosition(const float lightPos[3]) = 0;
|
||||||
virtual void setLightPosition(const double lightPos[3]) = 0;
|
virtual void setLightPosition(const double lightPos[3]) = 0;
|
||||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]){};
|
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]){};
|
||||||
|
virtual void setProjectiveTexture(bool useProjectiveTexture){};
|
||||||
|
|
||||||
virtual void renderScene()=0;
|
virtual void renderScene()=0;
|
||||||
virtual void renderSceneInternal(int renderMode=B3_DEFAULT_RENDERMODE){};
|
virtual void renderSceneInternal(int renderMode=B3_DEFAULT_RENDERMODE){};
|
||||||
|
|||||||
@@ -1103,6 +1103,11 @@ void OpenGLGuiHelper::setProjectiveTextureMatrices(const float viewMatrix[16], c
|
|||||||
m_data->m_glApp->m_renderer->setProjectiveTextureMatrices(viewMatrix, projectionMatrix);
|
m_data->m_glApp->m_renderer->setProjectiveTextureMatrices(viewMatrix, projectionMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLGuiHelper::setProjectiveTexture(bool useProjectiveTexture)
|
||||||
|
{
|
||||||
|
m_data->m_glApp->m_renderer->setProjectiveTexture(useProjectiveTexture);
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
|
void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
|
||||||
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
|
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
|
||||||
float* depthBuffer, int depthBufferSizeInPixels,
|
float* depthBuffer, int depthBufferSizeInPixels,
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ struct OpenGLGuiHelper : public GUIHelperInterface
|
|||||||
int destinationHeight, int* numPixelsCopied);
|
int destinationHeight, int* numPixelsCopied);
|
||||||
|
|
||||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]);
|
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]);
|
||||||
|
virtual void setProjectiveTexture(bool useProjectiveTexture);
|
||||||
|
|
||||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) ;
|
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) ;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
///todo: make this configurable in the gui
|
///todo: make this configurable in the gui
|
||||||
bool useShadowMap = true;// true;//false;//true;
|
bool useShadowMap = true;// true;//false;//true;
|
||||||
bool useProjectiveTexture = false;
|
|
||||||
int shadowMapWidth= 4096;
|
int shadowMapWidth= 4096;
|
||||||
int shadowMapHeight= 4096;
|
int shadowMapHeight= 4096;
|
||||||
float shadowMapWorldSize=10;
|
float shadowMapWorldSize=10;
|
||||||
@@ -228,6 +227,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
|||||||
GLfloat m_projectiveTextureProjectionMatrix[16];
|
GLfloat m_projectiveTextureProjectionMatrix[16];
|
||||||
GLfloat m_projectiveTextureViewMatrix[16];
|
GLfloat m_projectiveTextureViewMatrix[16];
|
||||||
GLfloat m_viewMatrixInverse[16];
|
GLfloat m_viewMatrixInverse[16];
|
||||||
|
bool m_useProjectiveTexture;
|
||||||
|
|
||||||
b3Vector3 m_lightPos;
|
b3Vector3 m_lightPos;
|
||||||
b3Vector3 m_lightSpecularIntensity;
|
b3Vector3 m_lightSpecularIntensity;
|
||||||
@@ -263,6 +263,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
|||||||
m_projectiveTextureViewMatrix[i]=0;
|
m_projectiveTextureViewMatrix[i]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_useProjectiveTexture = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1479,6 +1480,12 @@ void GLInstancingRenderer::setProjectiveTextureMatrices(const float viewMatrix[1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLInstancingRenderer::setProjectiveTexture(bool useProjectiveTexture)
|
||||||
|
{
|
||||||
|
m_data->m_useProjectiveTexture = useProjectiveTexture;
|
||||||
|
useShadowMap = !useProjectiveTexture;
|
||||||
|
}
|
||||||
|
|
||||||
void GLInstancingRenderer::updateCamera(int upAxis)
|
void GLInstancingRenderer::updateCamera(int upAxis)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1595,7 +1602,7 @@ void GLInstancingRenderer::renderScene()
|
|||||||
renderSceneInternal(B3_USE_SHADOWMAP_RENDERMODE);
|
renderSceneInternal(B3_USE_SHADOWMAP_RENDERMODE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (useProjectiveTexture)
|
else if (m_data->m_useProjectiveTexture)
|
||||||
{
|
{
|
||||||
renderSceneInternal(B3_USE_PROJECTIVE_TEXTURE_RENDERMODE);
|
renderSceneInternal(B3_USE_PROJECTIVE_TEXTURE_RENDERMODE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ public:
|
|||||||
virtual void setLightPosition(const double lightPos[3]);
|
virtual void setLightPosition(const double lightPos[3]);
|
||||||
void setLightSpecularIntensity(const float lightSpecularIntensity[3]);
|
void setLightSpecularIntensity(const float lightSpecularIntensity[3]);
|
||||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]);
|
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]);
|
||||||
|
virtual void setProjectiveTexture(bool useProjectiveTexture);
|
||||||
|
|
||||||
virtual void resize(int width, int height);
|
virtual void resize(int width, int height);
|
||||||
virtual int getScreenWidth()
|
virtual int getScreenWidth()
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ ELSE()
|
|||||||
ENDIF(APPLE)
|
ENDIF(APPLE)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(App_RobotSimulator_NoGUI BulletRobotics BulletFileLoader BulletWorldImporter BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamicsUtils BulletInverseDynamics LinearMath OpenGLWindow Bullet3Common)
|
TARGET_LINK_LIBRARIES(App_RobotSimulator_NoGUI BulletRobotics BulletFileLoader BulletWorldImporter BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamicsUtils BulletInverseDynamics LinearMath Bullet3Common)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ IF (USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
LINK_LIBRARIES(
|
LINK_LIBRARIES(
|
||||||
Bullet3Common BulletWorldImporter BulletFileLoader BulletInverseDynamicsUtils BulletInverseDynamics BulletDynamics BulletCollision LinearMath OpenGLWindow BussIK
|
Bullet3Common BulletWorldImporter BulletFileLoader BulletInverseDynamicsUtils BulletInverseDynamics BulletDynamics BulletCollision LinearMath BussIK
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "PhysicsServerCommandProcessor.h"
|
#include "PhysicsServerCommandProcessor.h"
|
||||||
#include "../CommonInterfaces/CommonRenderInterface.h"
|
#include "../CommonInterfaces/CommonRenderInterface.h"
|
||||||
#include "../OpenGLWindow/GLInstancingRenderer.h"
|
|
||||||
|
|
||||||
#include "../Importers/ImportURDFDemo/BulletUrdfImporter.h"
|
#include "../Importers/ImportURDFDemo/BulletUrdfImporter.h"
|
||||||
#include "../Importers/ImportURDFDemo/MyMultiBodyCreator.h"
|
#include "../Importers/ImportURDFDemo/MyMultiBodyCreator.h"
|
||||||
@@ -3108,8 +3107,6 @@ bool PhysicsServerCommandProcessor::processStateLoggingCommand(const struct Shar
|
|||||||
return hasStatus;
|
return hasStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern bool useShadowMap;
|
|
||||||
extern bool useProjectiveTexture;
|
|
||||||
bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struct SharedMemoryCommand& clientCmd, struct SharedMemoryStatus& serverStatusOut, char* bufferServerToClient, int bufferSizeInBytes)
|
bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struct SharedMemoryCommand& clientCmd, struct SharedMemoryStatus& serverStatusOut, char* bufferServerToClient, int bufferSizeInBytes)
|
||||||
{
|
{
|
||||||
bool hasStatus = true;
|
bool hasStatus = true;
|
||||||
@@ -3195,8 +3192,7 @@ bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struc
|
|||||||
{
|
{
|
||||||
if ((flags & ER_USE_PROJECTIVE_TEXTURE) != 0)
|
if ((flags & ER_USE_PROJECTIVE_TEXTURE) != 0)
|
||||||
{
|
{
|
||||||
useShadowMap = false;
|
this->m_data->m_guiHelper->setProjectiveTexture(true);
|
||||||
useProjectiveTexture = true;
|
|
||||||
if ((clientCmd.m_updateFlags & REQUEST_PIXEL_ARGS_HAS_PROJECTIVE_TEXTURE_MATRICES)!=0)
|
if ((clientCmd.m_updateFlags & REQUEST_PIXEL_ARGS_HAS_PROJECTIVE_TEXTURE_MATRICES)!=0)
|
||||||
{
|
{
|
||||||
for (int i=0;i<16;i++)
|
for (int i=0;i<16;i++)
|
||||||
@@ -3217,8 +3213,7 @@ bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struc
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
useShadowMap = true;
|
this->m_data->m_guiHelper->setProjectiveTexture(false);
|
||||||
useProjectiveTexture = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data->m_guiHelper->copyCameraImageData(viewMat,
|
m_data->m_guiHelper->copyCameraImageData(viewMat,
|
||||||
|
|||||||
@@ -1124,6 +1124,11 @@ public:
|
|||||||
{
|
{
|
||||||
m_childGuiHelper->getAppInterface()->m_renderer->setProjectiveTextureMatrices(viewMatrix, projectionMatrix);
|
m_childGuiHelper->getAppInterface()->m_renderer->setProjectiveTextureMatrices(viewMatrix, projectionMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void setProjectiveTexture(bool useProjectiveTexture)
|
||||||
|
{
|
||||||
|
m_childGuiHelper->getAppInterface()->m_renderer->setProjectiveTexture(useProjectiveTexture);
|
||||||
|
}
|
||||||
|
|
||||||
btDiscreteDynamicsWorld* m_dynamicsWorld;
|
btDiscreteDynamicsWorld* m_dynamicsWorld;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ IF (USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
LINK_LIBRARIES(
|
LINK_LIBRARIES(
|
||||||
BulletInverseDynamicsUtils BulletInverseDynamics BulletFileLoader BulletWorldImporter Bullet3Common BulletDynamics BulletCollision LinearMath gtest OpenGLWindow BussIK
|
BulletInverseDynamicsUtils BulletInverseDynamics BulletFileLoader BulletWorldImporter Bullet3Common BulletDynamics BulletCollision LinearMath gtest BussIK
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (NOT WIN32)
|
IF (NOT WIN32)
|
||||||
|
|||||||
Reference in New Issue
Block a user