implement specular, URDF non-standard specular part (see sphere2.urdf) and SDF specular support.
pybullet.changeVisualShape(obUid,linkIndex,specularColor=[R,G,B]) and Bullet C-API b3UpdateVisualShapeSpecularColor Bug fixes in b3ResourcePath::findResourcePath resolution. add stadium.sdf and roboschool/models_outdoor/stadium assets https://github.com/openai/roboschool/tree/master/roboschool/models_outdoor/stadium minor fixes to obj2sdf
This commit is contained in:
@@ -2452,6 +2452,21 @@ void b3UpdateVisualShapeRGBAColor(b3SharedMemoryCommandHandle commandHandle, dou
|
||||
}
|
||||
}
|
||||
|
||||
void b3UpdateVisualShapeSpecularColor(b3SharedMemoryCommandHandle commandHandle, double specularColor[3])
|
||||
{
|
||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
||||
b3Assert(command);
|
||||
b3Assert(command->m_type == CMD_UPDATE_VISUAL_SHAPE);
|
||||
|
||||
if (command->m_type == CMD_UPDATE_VISUAL_SHAPE)
|
||||
{
|
||||
command->m_updateVisualShapeDataArguments.m_specularColor[0] = specularColor[0];
|
||||
command->m_updateVisualShapeDataArguments.m_specularColor[1] = specularColor[1];
|
||||
command->m_updateVisualShapeDataArguments.m_specularColor[2] = specularColor[2];
|
||||
command->m_updateFlags |= CMD_UPDATE_VISUAL_SHAPE_SPECULAR_COLOR;
|
||||
}
|
||||
}
|
||||
|
||||
b3SharedMemoryCommandHandle b3ApplyExternalForceCommandInit(b3PhysicsClientHandle physClient)
|
||||
{
|
||||
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
||||
|
||||
@@ -210,6 +210,8 @@ void b3GetVisualShapeInformation(b3PhysicsClientHandle physClient, struct b3Visu
|
||||
b3SharedMemoryCommandHandle b3InitLoadTexture(b3PhysicsClientHandle physClient, const char* filename);
|
||||
b3SharedMemoryCommandHandle b3InitUpdateVisualShape(b3PhysicsClientHandle physClient, int bodyUniqueId, int jointIndex, int shapeIndex, int textureUniqueId);
|
||||
void b3UpdateVisualShapeRGBAColor(b3SharedMemoryCommandHandle commandHandle, double rgbaColor[4]);
|
||||
void b3UpdateVisualShapeSpecularColor(b3SharedMemoryCommandHandle commandHandle, double specularColor[3]);
|
||||
|
||||
|
||||
b3SharedMemoryCommandHandle b3InitPhysicsParamCommand(b3PhysicsClientHandle physClient);
|
||||
int b3PhysicsParamSetGravity(b3SharedMemoryCommandHandle commandHandle, double gravx,double gravy, double gravz);
|
||||
|
||||
@@ -5664,7 +5664,6 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
||||
}
|
||||
}
|
||||
|
||||
if (clientCmd.m_updateFlags & CMD_UPDATE_VISUAL_SHAPE_RGBA_COLOR)
|
||||
{
|
||||
int bodyUniqueId = clientCmd.m_updateVisualShapeDataArguments.m_bodyUniqueId;
|
||||
int linkIndex = clientCmd.m_updateVisualShapeDataArguments.m_jointIndex;
|
||||
@@ -5680,7 +5679,15 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
||||
{
|
||||
//m_data->m_visualConverter.changeRGBAColor(...)
|
||||
int graphicsIndex = bodyHandle->m_multiBody->getBaseCollider()->getUserIndex();
|
||||
m_data->m_guiHelper->changeRGBAColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
||||
if (clientCmd.m_updateFlags & CMD_UPDATE_VISUAL_SHAPE_RGBA_COLOR)
|
||||
{
|
||||
m_data->m_guiHelper->changeRGBAColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
||||
}
|
||||
if (clientCmd.m_updateFlags & CMD_UPDATE_VISUAL_SHAPE_SPECULAR_COLOR)
|
||||
{
|
||||
m_data->m_guiHelper->changeSpecularColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_specularColor);
|
||||
}
|
||||
|
||||
}
|
||||
} else
|
||||
{
|
||||
@@ -5690,7 +5697,15 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
||||
{
|
||||
//m_data->m_visualConverter.changeRGBAColor(...)
|
||||
int graphicsIndex = bodyHandle->m_multiBody->getLink(linkIndex).m_collider->getUserIndex();
|
||||
m_data->m_guiHelper->changeRGBAColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
||||
if (clientCmd.m_updateFlags & CMD_UPDATE_VISUAL_SHAPE_RGBA_COLOR)
|
||||
{
|
||||
m_data->m_guiHelper->changeRGBAColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
||||
}
|
||||
if (clientCmd.m_updateFlags & CMD_UPDATE_VISUAL_SHAPE_SPECULAR_COLOR)
|
||||
{
|
||||
m_data->m_guiHelper->changeSpecularColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_specularColor);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ enum MultiThreadedGUIHelperCommunicationEnums
|
||||
eGUIDumpFramesToVideo,
|
||||
eGUIHelperRemoveGraphicsInstance,
|
||||
eGUIHelperChangeGraphicsInstanceRGBAColor,
|
||||
eGUIHelperChangeGraphicsInstanceSpecularColor,
|
||||
eGUIHelperSetVisualizerFlag,
|
||||
};
|
||||
|
||||
@@ -918,6 +919,19 @@ public:
|
||||
workerThreadWait();
|
||||
}
|
||||
|
||||
double m_specularColor[3];
|
||||
int m_graphicsInstanceChangeSpecular;
|
||||
virtual void changeSpecularColor(int instanceUid, const double specularColor[3])
|
||||
{
|
||||
m_graphicsInstanceChangeSpecular = instanceUid;
|
||||
m_specularColor[0] = specularColor[0];
|
||||
m_specularColor[1] = specularColor[1];
|
||||
m_specularColor[2] = specularColor[2];
|
||||
m_cs->lock();
|
||||
m_cs->setSharedParam(1,eGUIHelperChangeGraphicsInstanceSpecularColor);
|
||||
workerThreadWait();
|
||||
}
|
||||
|
||||
virtual Common2dCanvasInterface* get2dCanvasInterface()
|
||||
{
|
||||
return 0;
|
||||
@@ -1734,6 +1748,13 @@ void PhysicsServerExample::updateGraphics()
|
||||
m_multiThreadedHelper->mainThreadRelease();
|
||||
break;
|
||||
}
|
||||
case eGUIHelperChangeGraphicsInstanceSpecularColor:
|
||||
{
|
||||
m_multiThreadedHelper->m_childGuiHelper->changeSpecularColor(m_multiThreadedHelper->m_graphicsInstanceChangeSpecular,m_multiThreadedHelper->m_specularColor);
|
||||
m_multiThreadedHelper->mainThreadRelease();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case eGUIHelperCopyCameraImageData:
|
||||
{
|
||||
|
||||
@@ -255,6 +255,7 @@ enum EnumUpdateVisualShapeData
|
||||
{
|
||||
CMD_UPDATE_VISUAL_SHAPE_TEXTURE=1,
|
||||
CMD_UPDATE_VISUAL_SHAPE_RGBA_COLOR=2,
|
||||
CMD_UPDATE_VISUAL_SHAPE_SPECULAR_COLOR=4,
|
||||
};
|
||||
|
||||
struct UpdateVisualShapeDataArgs
|
||||
@@ -264,6 +265,7 @@ struct UpdateVisualShapeDataArgs
|
||||
int m_shapeIndex;
|
||||
int m_textureUniqueId;
|
||||
double m_rgbaColor[4];
|
||||
double m_specularColor[3];
|
||||
};
|
||||
|
||||
struct LoadTextureArgs
|
||||
|
||||
@@ -179,10 +179,10 @@ void convertURDFToVisualShape(const UrdfShape* visual, const char* urdfPathPrefi
|
||||
visualShapeOut.m_dimensions[2] = 0;
|
||||
visualShapeOut.m_meshAssetFileName[0] = 0;
|
||||
if (visual->m_geometry.m_hasLocalMaterial) {
|
||||
visualShapeOut.m_rgbaColor[0] = visual->m_geometry.m_localMaterial.m_rgbaColor[0];
|
||||
visualShapeOut.m_rgbaColor[1] = visual->m_geometry.m_localMaterial.m_rgbaColor[1];
|
||||
visualShapeOut.m_rgbaColor[2] = visual->m_geometry.m_localMaterial.m_rgbaColor[2];
|
||||
visualShapeOut.m_rgbaColor[3] = visual->m_geometry.m_localMaterial.m_rgbaColor[3];
|
||||
visualShapeOut.m_rgbaColor[0] = visual->m_geometry.m_localMaterial.m_matColor.m_rgbaColor[0];
|
||||
visualShapeOut.m_rgbaColor[1] = visual->m_geometry.m_localMaterial.m_matColor.m_rgbaColor[1];
|
||||
visualShapeOut.m_rgbaColor[2] = visual->m_geometry.m_localMaterial.m_matColor.m_rgbaColor[2];
|
||||
visualShapeOut.m_rgbaColor[3] = visual->m_geometry.m_localMaterial.m_matColor.m_rgbaColor[3];
|
||||
}
|
||||
|
||||
GLInstanceGraphicsShape* glmesh = 0;
|
||||
@@ -555,7 +555,7 @@ void TinyRendererVisualShapeConverter::convertVisualShapes(
|
||||
{
|
||||
for (int i=0; i<4; i++)
|
||||
{
|
||||
rgbaColor[i] = (*matPtr)->m_rgbaColor[i];
|
||||
rgbaColor[i] = (*matPtr)->m_matColor.m_rgbaColor[i];
|
||||
}
|
||||
//printf("UrdfMaterial %s, rgba = %f,%f,%f,%f\n",mat->m_name.c_str(),mat->m_rgbaColor[0],mat->m_rgbaColor[1],mat->m_rgbaColor[2],mat->m_rgbaColor[3]);
|
||||
//m_data->m_linkColors.insert(linkIndex,mat->m_rgbaColor);
|
||||
|
||||
Reference in New Issue
Block a user