Add default specular when there is not specular map. Add example for adjusting specular coefficient.
This commit is contained in:
@@ -1208,13 +1208,17 @@ int b3GetNumJoints(b3PhysicsClientHandle physClient, int bodyId)
|
|||||||
return cl->getNumJoints(bodyId);
|
return cl->getNumJoints(bodyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int b3GetJointInfo(b3PhysicsClientHandle physClient, int bodyIndex, int jointIndex, struct b3JointInfo* info)
|
int b3GetJointInfo(b3PhysicsClientHandle physClient, int bodyIndex, int jointIndex, struct b3JointInfo* info)
|
||||||
{
|
{
|
||||||
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
||||||
return cl->getJointInfo(bodyIndex, jointIndex, *info);
|
return cl->getJointInfo(bodyIndex, jointIndex, *info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int b3GetDynamicInfo(b3PhysicsClientHandle physClient, int bodyUniqueId, int linkIndex, struct b3DynamicInfo* info)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3InitResetDynamicInfo(b3PhysicsClientHandle physClient)
|
b3SharedMemoryCommandHandle b3InitResetDynamicInfo(b3PhysicsClientHandle physClient)
|
||||||
{
|
{
|
||||||
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ protected:
|
|||||||
int m_canvasDepthIndex;
|
int m_canvasDepthIndex;
|
||||||
int m_canvasSegMaskIndex;
|
int m_canvasSegMaskIndex;
|
||||||
|
|
||||||
|
float m_lightPos[3];
|
||||||
|
float m_specularCoeff;
|
||||||
|
|
||||||
void createButton(const char* name, int id, bool isTrigger );
|
void createButton(const char* name, int id, bool isTrigger );
|
||||||
|
|
||||||
void createButtons();
|
void createButtons();
|
||||||
@@ -257,7 +260,7 @@ void PhysicsClientExample::prepareAndSubmitCommand(int commandId)
|
|||||||
case CMD_LOAD_SDF:
|
case CMD_LOAD_SDF:
|
||||||
{
|
{
|
||||||
#ifdef BT_DEBUG
|
#ifdef BT_DEBUG
|
||||||
b3SharedMemoryCommandHandle commandHandle = b3LoadSdfCommandInit(m_physicsClientHandle, "two_cubes.sdf");
|
b3SharedMemoryCommandHandle commandHandle = b3LoadSdfCommandInit(m_physicsClientHandle, "kuka_iiwa/model.sdf");
|
||||||
#else
|
#else
|
||||||
b3SharedMemoryCommandHandle commandHandle = b3LoadSdfCommandInit(m_physicsClientHandle, "kitchens/1.sdf");//two_cubes.sdf");//kitchens/1.sdf");//kuka_iiwa/model.sdf");
|
b3SharedMemoryCommandHandle commandHandle = b3LoadSdfCommandInit(m_physicsClientHandle, "kitchens/1.sdf");//two_cubes.sdf");//kitchens/1.sdf");//kuka_iiwa/model.sdf");
|
||||||
#endif
|
#endif
|
||||||
@@ -278,6 +281,8 @@ void PhysicsClientExample::prepareAndSubmitCommand(int commandId)
|
|||||||
|
|
||||||
b3RequestCameraImageSetCameraMatrices(commandHandle, viewMatrix,projectionMatrix);
|
b3RequestCameraImageSetCameraMatrices(commandHandle, viewMatrix,projectionMatrix);
|
||||||
b3RequestCameraImageSetPixelResolution(commandHandle, camVisualizerWidth,camVisualizerHeight);
|
b3RequestCameraImageSetPixelResolution(commandHandle, camVisualizerWidth,camVisualizerHeight);
|
||||||
|
b3RequestCameraImageSetLightDirection(commandHandle, m_lightPos);
|
||||||
|
b3RequestCameraImageSetLightSpecularCoeff(commandHandle, m_specularCoeff);
|
||||||
b3SubmitClientCommand(m_physicsClientHandle, commandHandle);
|
b3SubmitClientCommand(m_physicsClientHandle, commandHandle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -522,6 +527,7 @@ m_canvas(0),
|
|||||||
m_canvasRGBIndex(-1),
|
m_canvasRGBIndex(-1),
|
||||||
m_canvasDepthIndex(-1),
|
m_canvasDepthIndex(-1),
|
||||||
m_canvasSegMaskIndex(-1),
|
m_canvasSegMaskIndex(-1),
|
||||||
|
m_specularCoeff(1.0),
|
||||||
m_numMotors(0),
|
m_numMotors(0),
|
||||||
m_options(options),
|
m_options(options),
|
||||||
m_isOptionalServerConnected(false)
|
m_isOptionalServerConnected(false)
|
||||||
@@ -660,6 +666,29 @@ void PhysicsClientExample::createButtons()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SliderParams sliderLightPosX("light source position x",&m_lightPos[0]);
|
||||||
|
SliderParams sliderLightPosY("light source position y",&m_lightPos[1]);
|
||||||
|
SliderParams sliderLightPosZ("light source position z",&m_lightPos[2]);
|
||||||
|
SliderParams sliderSpecularCoeff("specular coefficient",&m_specularCoeff);
|
||||||
|
sliderLightPosX.m_minVal=-1.5;
|
||||||
|
sliderLightPosX.m_maxVal=1.5;
|
||||||
|
sliderLightPosY.m_minVal=-1.5;
|
||||||
|
sliderLightPosY.m_maxVal=1.5;
|
||||||
|
sliderLightPosZ.m_minVal=-1.5;
|
||||||
|
sliderLightPosZ.m_maxVal=1.5;
|
||||||
|
sliderSpecularCoeff.m_minVal=0;
|
||||||
|
sliderSpecularCoeff.m_maxVal=5.0;
|
||||||
|
if (m_guiHelper && m_guiHelper->getParameterInterface())
|
||||||
|
{
|
||||||
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(sliderLightPosX);
|
||||||
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(sliderLightPosY);
|
||||||
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(sliderLightPosZ);
|
||||||
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(sliderSpecularCoeff);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,6 +714,10 @@ void PhysicsClientExample::initPhysics()
|
|||||||
m_selectedBody = -1;
|
m_selectedBody = -1;
|
||||||
m_prevSelectedBody = -1;
|
m_prevSelectedBody = -1;
|
||||||
|
|
||||||
|
m_lightPos[0] = 1.0;
|
||||||
|
m_lightPos[1] = 1.0;
|
||||||
|
m_lightPos[2] = 1.0;
|
||||||
|
|
||||||
{
|
{
|
||||||
m_canvas = m_guiHelper->get2dCanvasInterface();
|
m_canvas = m_guiHelper->get2dCanvasInterface();
|
||||||
if (m_canvas)
|
if (m_canvas)
|
||||||
|
|||||||
@@ -832,6 +832,7 @@ struct SharedMemoryStatus
|
|||||||
struct StateLoggingResultArgs m_stateLoggingResultArgs;
|
struct StateLoggingResultArgs m_stateLoggingResultArgs;
|
||||||
struct b3OpenGLVisualizerCameraInfo m_visualizerCameraResultArgs;
|
struct b3OpenGLVisualizerCameraInfo m_visualizerCameraResultArgs;
|
||||||
struct b3ObjectArgs m_removeObjectArgs;
|
struct b3ObjectArgs m_removeObjectArgs;
|
||||||
|
struct b3DynamicInfo m_dynamicInfo;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ struct b3DynamicInfo
|
|||||||
{
|
{
|
||||||
double m_mass;
|
double m_mass;
|
||||||
double m_localInertialPosition[3];
|
double m_localInertialPosition[3];
|
||||||
|
double m_lateralFrictionCoeff;
|
||||||
};
|
};
|
||||||
|
|
||||||
// copied from btMultiBodyLink.h
|
// copied from btMultiBodyLink.h
|
||||||
|
|||||||
@@ -167,9 +167,13 @@ Vec2f Model::uv(int iface, int nthvert) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float Model::specular(Vec2f uvf) {
|
float Model::specular(Vec2f uvf) {
|
||||||
|
if (specularmap_.get_width() && specularmap_.get_height())
|
||||||
|
{
|
||||||
Vec2i uv(uvf[0]*specularmap_.get_width(), uvf[1]*specularmap_.get_height());
|
Vec2i uv(uvf[0]*specularmap_.get_width(), uvf[1]*specularmap_.get_height());
|
||||||
return specularmap_.get(uv[0], uv[1])[0]/1.f;
|
return specularmap_.get(uv[0], uv[1])[0]/1.f;
|
||||||
}
|
}
|
||||||
|
return 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
Vec3f Model::normal(int iface, int nthvert) {
|
Vec3f Model::normal(int iface, int nthvert) {
|
||||||
int idx = faces_[iface][nthvert][2];
|
int idx = faces_[iface][nthvert][2];
|
||||||
|
|||||||
Reference in New Issue
Block a user