mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-18 21:10:05 +00:00
Expose API to set projective texture instead of using global.
This commit is contained in:
parent
e42a934e16
commit
6b97e1e604
@ -166,7 +166,7 @@ SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES VERSION ${BULLET_VERSION})
|
||||
SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES SOVERSION ${BULLET_VERSION})
|
||||
|
||||
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)
|
||||
|
||||
IF (INSTALL_EXTRA_LIBS)
|
||||
|
@ -95,6 +95,7 @@ struct GUIHelperInterface
|
||||
int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied){}
|
||||
|
||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])=0;
|
||||
virtual void setProjectiveTexture(bool useProjectiveTexture)=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 setProjectiveTexture(bool useProjectiveTexture)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld)
|
||||
{
|
||||
|
@ -50,6 +50,7 @@ struct CommonRenderInterface
|
||||
virtual void setLightPosition(const float lightPos[3]) = 0;
|
||||
virtual void setLightPosition(const double lightPos[3]) = 0;
|
||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]){};
|
||||
virtual void setProjectiveTexture(bool useProjectiveTexture){};
|
||||
|
||||
virtual void renderScene()=0;
|
||||
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);
|
||||
}
|
||||
|
||||
void OpenGLGuiHelper::setProjectiveTexture(bool useProjectiveTexture)
|
||||
{
|
||||
m_data->m_glApp->m_renderer->setProjectiveTexture(useProjectiveTexture);
|
||||
}
|
||||
|
||||
void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
|
||||
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
|
||||
float* depthBuffer, int depthBufferSizeInPixels,
|
||||
|
@ -63,6 +63,7 @@ struct OpenGLGuiHelper : public GUIHelperInterface
|
||||
int destinationHeight, int* numPixelsCopied);
|
||||
|
||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]);
|
||||
virtual void setProjectiveTexture(bool useProjectiveTexture);
|
||||
|
||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) ;
|
||||
|
||||
|
@ -17,7 +17,6 @@ subject to the following restrictions:
|
||||
|
||||
///todo: make this configurable in the gui
|
||||
bool useShadowMap = true;// true;//false;//true;
|
||||
bool useProjectiveTexture = false;
|
||||
int shadowMapWidth= 4096;
|
||||
int shadowMapHeight= 4096;
|
||||
float shadowMapWorldSize=10;
|
||||
@ -228,6 +227,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
||||
GLfloat m_projectiveTextureProjectionMatrix[16];
|
||||
GLfloat m_projectiveTextureViewMatrix[16];
|
||||
GLfloat m_viewMatrixInverse[16];
|
||||
bool m_useProjectiveTexture;
|
||||
|
||||
b3Vector3 m_lightPos;
|
||||
b3Vector3 m_lightSpecularIntensity;
|
||||
@ -263,6 +263,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
||||
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)
|
||||
{
|
||||
|
||||
@ -1595,7 +1602,7 @@ void GLInstancingRenderer::renderScene()
|
||||
renderSceneInternal(B3_USE_SHADOWMAP_RENDERMODE);
|
||||
|
||||
}
|
||||
else if (useProjectiveTexture)
|
||||
else if (m_data->m_useProjectiveTexture)
|
||||
{
|
||||
renderSceneInternal(B3_USE_PROJECTIVE_TEXTURE_RENDERMODE);
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ public:
|
||||
virtual void setLightPosition(const double lightPos[3]);
|
||||
void setLightSpecularIntensity(const float lightSpecularIntensity[3]);
|
||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]);
|
||||
virtual void setProjectiveTexture(bool useProjectiveTexture);
|
||||
|
||||
virtual void resize(int width, int height);
|
||||
virtual int getScreenWidth()
|
||||
|
@ -116,7 +116,7 @@ ELSE()
|
||||
ENDIF(APPLE)
|
||||
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()
|
||||
|
||||
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 "../CommonInterfaces/CommonRenderInterface.h"
|
||||
#include "../OpenGLWindow/GLInstancingRenderer.h"
|
||||
|
||||
#include "../Importers/ImportURDFDemo/BulletUrdfImporter.h"
|
||||
#include "../Importers/ImportURDFDemo/MyMultiBodyCreator.h"
|
||||
@ -3108,8 +3107,6 @@ bool PhysicsServerCommandProcessor::processStateLoggingCommand(const struct Shar
|
||||
return hasStatus;
|
||||
}
|
||||
|
||||
extern bool useShadowMap;
|
||||
extern bool useProjectiveTexture;
|
||||
bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struct SharedMemoryCommand& clientCmd, struct SharedMemoryStatus& serverStatusOut, char* bufferServerToClient, int bufferSizeInBytes)
|
||||
{
|
||||
bool hasStatus = true;
|
||||
@ -3195,8 +3192,7 @@ bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struc
|
||||
{
|
||||
if ((flags & ER_USE_PROJECTIVE_TEXTURE) != 0)
|
||||
{
|
||||
useShadowMap = false;
|
||||
useProjectiveTexture = true;
|
||||
this->m_data->m_guiHelper->setProjectiveTexture(true);
|
||||
if ((clientCmd.m_updateFlags & REQUEST_PIXEL_ARGS_HAS_PROJECTIVE_TEXTURE_MATRICES)!=0)
|
||||
{
|
||||
for (int i=0;i<16;i++)
|
||||
@ -3217,8 +3213,7 @@ bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struc
|
||||
}
|
||||
else
|
||||
{
|
||||
useShadowMap = true;
|
||||
useProjectiveTexture = false;
|
||||
this->m_data->m_guiHelper->setProjectiveTexture(false);
|
||||
}
|
||||
|
||||
m_data->m_guiHelper->copyCameraImageData(viewMat,
|
||||
|
@ -1124,6 +1124,11 @@ public:
|
||||
{
|
||||
m_childGuiHelper->getAppInterface()->m_renderer->setProjectiveTextureMatrices(viewMatrix, projectionMatrix);
|
||||
}
|
||||
|
||||
virtual void setProjectiveTexture(bool useProjectiveTexture)
|
||||
{
|
||||
m_childGuiHelper->getAppInterface()->m_renderer->setProjectiveTexture(useProjectiveTexture);
|
||||
}
|
||||
|
||||
btDiscreteDynamicsWorld* m_dynamicsWorld;
|
||||
|
||||
|
@ -16,7 +16,7 @@ IF (USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD)
|
||||
ENDIF()
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user