diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index 2bb13623e..dde6ccebd 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -8851,21 +8851,23 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo int instanceUid = m_data->m_guiHelper->registerGraphicsInstance(shapeUid1, position, orientation, color, scaling); psb->setUserIndex(instanceUid); - int texUid2 = m_data->m_pluginManager.getRenderInterface()->registerTexture(meshData.m_textureImage1, meshData.m_textureWidth, meshData.m_textureHeight); - int linkIndex = -1; - int softBodyGraphicsShapeUid = m_data->m_pluginManager.getRenderInterface()->registerShapeAndInstance( - &meshData.m_gfxShape->m_vertices->at(0).xyzw[0], - meshData.m_gfxShape->m_numvertices, - &meshData.m_gfxShape->m_indices->at(0), - meshData.m_gfxShape->m_numIndices, - B3_GL_TRIANGLES, - texUid2, - psb->getBroadphaseHandle()->getUid(), - *bodyUniqueId, - linkIndex); + if (m_data->m_enableTinyRenderer) + { + int texUid2 = m_data->m_pluginManager.getRenderInterface()->registerTexture(meshData.m_textureImage1, meshData.m_textureWidth, meshData.m_textureHeight); + int linkIndex = -1; + int softBodyGraphicsShapeUid = m_data->m_pluginManager.getRenderInterface()->registerShapeAndInstance( + &meshData.m_gfxShape->m_vertices->at(0).xyzw[0], + meshData.m_gfxShape->m_numvertices, + &meshData.m_gfxShape->m_indices->at(0), + meshData.m_gfxShape->m_numIndices, + B3_GL_TRIANGLES, + texUid2, + psb->getBroadphaseHandle()->getUid(), + *bodyUniqueId, + linkIndex); - psb->setUserIndex3(softBodyGraphicsShapeUid); - + psb->setUserIndex3(softBodyGraphicsShapeUid); + } delete meshData.m_gfxShape; meshData.m_gfxShape = 0; } @@ -8892,7 +8894,7 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo } for (int j = 0; j < 2; j++) { - gfxVertices[currentIndex].uv[j] = psb->m_faces[i].m_n[k]->m_x[j]; + gfxVertices[currentIndex].uv[j] = btFabs(btFabs(10. * psb->m_faces[i].m_n[k]->m_x[j])); } indices.push_back(currentIndex); } @@ -8929,16 +8931,18 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo int shapeId = m_data->m_guiHelper->registerGraphicsShape(&gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES, texId); b3Assert(shapeId >= 0); psb->getCollisionShape()->setUserIndex(shapeId); + if (m_data->m_enableTinyRenderer) + { - - int texUid2 = m_data->m_pluginManager.getRenderInterface()->registerTexture(&texels[0], texWidth, texHeight); - int linkIndex = -1; - int softBodyGraphicsShapeUid = m_data->m_pluginManager.getRenderInterface()->registerShapeAndInstance( - &gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES, texUid2, - psb->getBroadphaseHandle()->getUid(), - *bodyUniqueId, - linkIndex); - psb->setUserIndex3(softBodyGraphicsShapeUid); + int texUid2 = m_data->m_pluginManager.getRenderInterface()->registerTexture(&texels[0], texWidth, texHeight); + int linkIndex = -1; + int softBodyGraphicsShapeUid = m_data->m_pluginManager.getRenderInterface()->registerShapeAndInstance( + &gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES, texUid2, + psb->getBroadphaseHandle()->getUid(), + *bodyUniqueId, + linkIndex); + psb->setUserIndex3(softBodyGraphicsShapeUid); + } } } @@ -8965,7 +8969,7 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo } for (int j = 0; j < 2; j++) { - psb->m_renderNodes[currentIndex].m_uv1[j] = psb->m_faces[i].m_n[k]->m_x[j]; + psb->m_renderNodes[currentIndex].m_uv1[j] = btFabs(10*psb->m_faces[i].m_n[k]->m_x[j]); } psb->m_renderNodes[currentIndex].m_uv1[2] = 0; vertices[currentIndex] = psb->m_faces[i].m_n[k]->m_x; @@ -13236,6 +13240,8 @@ bool PhysicsServerCommandProcessor::processUpdateVisualShapeCommand(const struct m_data->m_pluginManager.getRenderInterface()->changeRGBAColor(bodyUniqueId, linkIndex, clientCmd.m_updateVisualShapeDataArguments.m_shapeIndex, clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor); } + int graphicsIndex = bodyHandle->m_softBody->getUserIndex(); + m_data->m_guiHelper->changeRGBAColor(graphicsIndex, clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor); } if (clientCmd.m_updateFlags & CMD_UPDATE_VISUAL_SHAPE_FLAGS) diff --git a/examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp b/examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp index aa441ece1..b2ea2bab6 100644 --- a/examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp +++ b/examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp @@ -937,7 +937,7 @@ int TinyRendererVisualShapeConverter::registerShapeAndInstance(const float* vert } if (numvertices && numIndices) { - TinyRenderObjectData* tinyObj = new TinyRenderObjectData(m_data->m_rgbColorBuffer, m_data->m_depthBuffer, &m_data->m_shadowBuffer, &m_data->m_segmentationMaskBuffer, -1, -1); + TinyRenderObjectData* tinyObj = new TinyRenderObjectData(m_data->m_rgbColorBuffer, m_data->m_depthBuffer, &m_data->m_shadowBuffer, &m_data->m_segmentationMaskBuffer, bodyUniqueId, linkIndex); //those are primary soft bodies, possibly cloth, make them double-sided by default tinyObj->m_doubleSided = true; { diff --git a/examples/pybullet/examples/deformable_torus.py b/examples/pybullet/examples/deformable_torus.py index e2b69667a..45001c531 100644 --- a/examples/pybullet/examples/deformable_torus.py +++ b/examples/pybullet/examples/deformable_torus.py @@ -10,20 +10,22 @@ p.resetSimulation(p.RESET_USE_DEFORMABLE_WORLD) p.setGravity(0, 0, -10) +tex = p.loadTexture("checker_blue.png") planeId = p.loadURDF("plane.urdf", [0,0,-2]) boxId = p.loadURDF("cube.urdf", [0,3,2],useMaximalCoordinates = True) bunnyId = p.loadSoftBody("torus/torus_textured.obj", simFileName="torus.vtk", mass = 3, useNeoHookean = 1, NeoHookeanMu = 180, NeoHookeanLambda = 600, NeoHookeanDamping = 0.01, collisionMargin = 0.006, useSelfCollision = 1, frictionCoeff = 0.5, repulsionStiffness = 800) - -#ballId = p.loadSoftBody("ball.obj", simFileName = "ball.vtk", basePosition = [0,1,-1], scale = 0.5, mass = 4, useNeoHookean = 1, NeoHookeanMu = 400, NeoHookeanLambda = 600, NeoHookeanDamping = 0.001, useSelfCollision = 1, frictionCoeff = .5, collisionMargin = 0.001) +p.changeVisualShape(bunnyId, -1, rgbaColor=[1,1,1,1], textureUniqueId=tex, flags=0) bunny2 = p.loadURDF("torus_deform.urdf", [0,1,0.5], flags=p.URDF_USE_SELF_COLLISION) +p.changeVisualShape(bunny2, -1, rgbaColor=[1,1,1,1], textureUniqueId=tex, flags=0) p.setPhysicsEngineParameter(sparseSdfVoxelSize=0.25) -p.setRealTimeSimulation(1) +p.setRealTimeSimulation(0) while p.isConnected(): + p.stepSimulation() p.getCameraImage(320,200) p.setGravity(0,0,-10)