mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-09-17 15:54:29 +00:00
use white as default undefined color instead of the googley colors.
use loadURDF(..., flags = pybullet.URDF_GOOGLEY_UNDEFINED_COLORS) to get Googley colors when colors are undefined.
This commit is contained in:
@@ -724,7 +724,14 @@ struct BulletMJCFImporterInternalData
|
||||
}
|
||||
|
||||
{
|
||||
geom.m_localMaterial.m_matColor.m_rgbaColor = sGoogleColors[linkIndex & 3];
|
||||
if (m_flags & CUF_GOOGLEY_UNDEFINED_COLORS)
|
||||
{
|
||||
geom.m_localMaterial.m_matColor.m_rgbaColor = sGoogleColors[linkIndex & 3];
|
||||
}
|
||||
else
|
||||
{
|
||||
geom.m_localMaterial.m_matColor.m_rgbaColor.setValue(1, 1, 1, 1);
|
||||
}
|
||||
geom.m_localMaterial.m_matColor.m_specularColor.setValue(1, 1, 1);
|
||||
geom.m_hasLocalMaterial = true;
|
||||
}
|
||||
@@ -1597,7 +1604,8 @@ bool BulletMJCFImporter::getLinkColor2(int linkIndex, struct UrdfMaterialColor&
|
||||
|
||||
if (!hasLinkColor)
|
||||
{
|
||||
matCol.m_rgbaColor = sGoogleColors[linkIndex & 3];
|
||||
|
||||
matCol.m_rgbaColor = (m_data->m_flags & CUF_GOOGLEY_UNDEFINED_COLORS) ? sGoogleColors[linkIndex & 3] : btVector4(1,1,1,1);
|
||||
matCol.m_specularColor.setValue(1, 1, 1);
|
||||
hasLinkColor = true;
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
//static int bodyCollisionFilterMask=btBroadphaseProxy::AllFilter&(~btBroadphaseProxy::CharacterFilter);
|
||||
static bool enableConstraints = true;
|
||||
|
||||
static btVector4 colors[4] =
|
||||
{
|
||||
btVector4(1, 0, 0, 1),
|
||||
btVector4(0, 1, 0, 1),
|
||||
btVector4(0, 1, 1, 1),
|
||||
btVector4(1, 1, 0, 1),
|
||||
static btVector4 gGoogleyColors[4] =
|
||||
{
|
||||
btVector4(60. / 256., 186. / 256., 84. / 256., 1),
|
||||
btVector4(244. / 256., 194. / 256., 13. / 256., 1),
|
||||
btVector4(219. / 256., 50. / 256., 54. / 256., 1),
|
||||
btVector4(72. / 256., 133. / 256., 237. / 256., 1),
|
||||
};
|
||||
|
||||
static btVector4 selectColor2()
|
||||
@@ -36,7 +36,7 @@ static btVector4 selectColor2()
|
||||
sMutex.lock();
|
||||
#endif
|
||||
static int curColor = 0;
|
||||
btVector4 color = colors[curColor];
|
||||
btVector4 color = gGoogleyColors[curColor];
|
||||
curColor++;
|
||||
curColor &= 3;
|
||||
#ifdef BT_THREADSAFE
|
||||
@@ -303,7 +303,8 @@ btTransform ConvertURDF2BulletInternal(
|
||||
if (compoundShape)
|
||||
{
|
||||
UrdfMaterialColor matColor;
|
||||
btVector4 color2 = selectColor2();
|
||||
|
||||
btVector4 color2 = (flags & CUF_GOOGLEY_UNDEFINED_COLORS) ? selectColor2() : btVector4(1, 1, 1, 1);
|
||||
btVector3 specular(0.5, 0.5, 0.5);
|
||||
if (u2b.getLinkColor2(urdfLinkIndex, matColor))
|
||||
{
|
||||
@@ -642,7 +643,7 @@ btTransform ConvertURDF2BulletInternal(
|
||||
}
|
||||
world1->addCollisionObject(col, collisionFilterGroup, collisionFilterMask);
|
||||
|
||||
btVector4 color2 = selectColor2(); //(0.0,0.0,0.5);
|
||||
btVector4 color2 = (flags & CUF_GOOGLEY_UNDEFINED_COLORS) ? selectColor2() : btVector4(1, 1, 1, 1);
|
||||
btVector3 specularColor(1, 1, 1);
|
||||
UrdfMaterialColor matCol;
|
||||
if (u2b.getLinkColor2(urdfLinkIndex, matCol))
|
||||
|
||||
@@ -104,6 +104,7 @@ enum ConvertURDFFlags
|
||||
CUF_IGNORE_VISUAL_SHAPES = 1 << 20,
|
||||
CUF_IGNORE_COLLISION_SHAPES = 1 << 21,
|
||||
CUF_PRINT_URDF_INFO = 1 << 22,
|
||||
CUF_GOOGLEY_UNDEFINED_COLORS = 1 << 23,
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -931,6 +931,7 @@ enum eURDF_Flags
|
||||
URDF_IGNORE_VISUAL_SHAPES = 1 << 20,
|
||||
URDF_IGNORE_COLLISION_SHAPES = 1 << 21,
|
||||
URDF_PRINT_URDF_INFO = 1 << 22,
|
||||
URDF_GOOGLEY_UNDEFINED_COLORS = 1 << 23,
|
||||
};
|
||||
|
||||
enum eUrdfGeomTypes //sync with UrdfParser UrdfGeomTypes
|
||||
|
||||
@@ -646,7 +646,7 @@ static void convertURDFToVisualShape(const UrdfShape* visual, const char* urdfPa
|
||||
delete glmesh;
|
||||
}
|
||||
|
||||
static btVector4 sColors[4] =
|
||||
static btVector4 sGoogleyColors[4] =
|
||||
{
|
||||
btVector4(60. / 256., 186. / 256., 84. / 256., 1),
|
||||
btVector4(244. / 256., 194. / 256., 13. / 256., 1),
|
||||
@@ -705,7 +705,7 @@ int TinyRendererVisualShapeConverter::convertVisualShapes(
|
||||
colorIndex = 0;
|
||||
colorIndex &= 3;
|
||||
btVector4 color;
|
||||
color = sColors[colorIndex];
|
||||
color = (m_data->m_flags & URDF_GOOGLEY_UNDEFINED_COLORS) ? sGoogleyColors[colorIndex] : btVector4(1, 1, 1, 1);
|
||||
float rgbaColor[4] = {(float)color[0], (float)color[1], (float)color[2], (float)color[3]};
|
||||
//if (colObj->getCollisionShape()->getShapeType()==STATIC_PLANE_PROXYTYPE)
|
||||
//{
|
||||
|
||||
@@ -12773,6 +12773,7 @@ initpybullet(void)
|
||||
PyModule_AddIntConstant(m, "URDF_IGNORE_VISUAL_SHAPES", URDF_IGNORE_VISUAL_SHAPES);
|
||||
PyModule_AddIntConstant(m, "URDF_IGNORE_COLLISION_SHAPES",URDF_IGNORE_COLLISION_SHAPES);
|
||||
PyModule_AddIntConstant(m, "URDF_PRINT_URDF_INFO", URDF_PRINT_URDF_INFO);
|
||||
PyModule_AddIntConstant(m, "URDF_GOOGLEY_UNDEFINED_COLORS", URDF_GOOGLEY_UNDEFINED_COLORS);
|
||||
|
||||
PyModule_AddIntConstant(m, "ACTIVATION_STATE_ENABLE_SLEEPING", eActivationStateEnableSleeping);
|
||||
PyModule_AddIntConstant(m, "ACTIVATION_STATE_DISABLE_SLEEPING", eActivationStateDisableSleeping);
|
||||
|
||||
Reference in New Issue
Block a user