minor clarification in UrdfRenderingInterface
This commit is contained in:
@@ -13,14 +13,14 @@ class btTransform;
|
|||||||
struct UrdfRenderingInterface
|
struct UrdfRenderingInterface
|
||||||
{
|
{
|
||||||
///given a URDF link, convert all visual shapes into internal renderer (loading graphics meshes, textures etc)
|
///given a URDF link, convert all visual shapes into internal renderer (loading graphics meshes, textures etc)
|
||||||
///use the shapeUid as a unique identified to remove it
|
///use the collisionObjectUid as a unique identifier to synchronize the world transform and to remove the visual shape.
|
||||||
virtual void convertVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame, const UrdfLink* linkPtr, const UrdfModel* model, int shapeUid, int objectIndex) =0;
|
virtual void convertVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame, const UrdfLink* linkPtr, const UrdfModel* model, int collisionObjectUid, int bodyUniqueId) =0;
|
||||||
|
|
||||||
///remove a visual shapes, based on the shape unique id (shapeUid)
|
///remove a visual shapes, based on the shape unique id (shapeUid)
|
||||||
virtual void removeVisualShape(int shapeUid)=0;
|
virtual void removeVisualShape(int collisionObjectUid)=0;
|
||||||
|
|
||||||
///update the world transform + scaling of the visual shape, using the shapeUid
|
///update the world transform + scaling of the visual shape, using the shapeUid
|
||||||
virtual void syncTransform(int shapeUid, const class btTransform& worldTransform, const class btVector3& localScaling)=0;
|
virtual void syncTransform(int collisionObjectUid, const class btTransform& worldTransform, const class btVector3& localScaling)=0;
|
||||||
|
|
||||||
///return the number of visual shapes, for a particular body unique id
|
///return the number of visual shapes, for a particular body unique id
|
||||||
virtual int getNumVisualShapes(int bodyUniqueId)=0;
|
virtual int getNumVisualShapes(int bodyUniqueId)=0;
|
||||||
@@ -28,8 +28,11 @@ struct UrdfRenderingInterface
|
|||||||
///return the visual shape information, for a particular body unique id and 'shape index'
|
///return the visual shape information, for a particular body unique id and 'shape index'
|
||||||
virtual int getVisualShapesData(int bodyUniqueId, int shapeIndex, struct b3VisualShapeData* shapeData)=0;
|
virtual int getVisualShapesData(int bodyUniqueId, int shapeIndex, struct b3VisualShapeData* shapeData)=0;
|
||||||
|
|
||||||
///change the RGBA color for a body unique id and link index
|
///change the RGBA color for some visual shape.
|
||||||
virtual void changeRGBAColor(int bodyUniqueId, int linkIndex, const double rgbaColor[4])=0;
|
virtual void changeRGBAColor(int bodyUniqueId, int linkIndex, int shapeIndex, const double rgbaColor[4])=0;
|
||||||
|
|
||||||
|
///select a given texture for some visual shape.
|
||||||
|
virtual void changeShapeTexture(int objectUniqueId, int linkIndex, int shapeIndex, int textureUniqueId)=0;
|
||||||
|
|
||||||
///pick the up-axis, either Y (1) or Z (2)
|
///pick the up-axis, either Y (1) or Z (2)
|
||||||
virtual void setUpAxis(int axis)=0;
|
virtual void setUpAxis(int axis)=0;
|
||||||
@@ -88,8 +91,7 @@ struct UrdfRenderingInterface
|
|||||||
///register a texture using an in-memory pixel buffer of a given width and height
|
///register a texture using an in-memory pixel buffer of a given width and height
|
||||||
virtual int registerTexture(unsigned char* texels, int width, int height)=0;
|
virtual int registerTexture(unsigned char* texels, int width, int height)=0;
|
||||||
|
|
||||||
///select a given texture for some visual shape.
|
|
||||||
virtual void activateShapeTexture(int objectUniqueId, int jointIndex, int shapeIndex, int textureUniqueId)=0;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8453,7 +8453,10 @@ bool PhysicsServerCommandProcessor::processUpdateVisualShapeCommand(const struct
|
|||||||
{
|
{
|
||||||
if (m_data->m_pluginManager.getRenderInterface())
|
if (m_data->m_pluginManager.getRenderInterface())
|
||||||
{
|
{
|
||||||
m_data->m_pluginManager.getRenderInterface()->activateShapeTexture(clientCmd.m_updateVisualShapeDataArguments.m_bodyUniqueId, clientCmd.m_updateVisualShapeDataArguments.m_jointIndex, clientCmd.m_updateVisualShapeDataArguments.m_shapeIndex, texHandle->m_tinyRendererTextureId);
|
m_data->m_pluginManager.getRenderInterface()->changeShapeTexture(clientCmd.m_updateVisualShapeDataArguments.m_bodyUniqueId,
|
||||||
|
clientCmd.m_updateVisualShapeDataArguments.m_jointIndex,
|
||||||
|
clientCmd.m_updateVisualShapeDataArguments.m_shapeIndex,
|
||||||
|
texHandle->m_tinyRendererTextureId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8485,12 +8488,15 @@ bool PhysicsServerCommandProcessor::processUpdateVisualShapeCommand(const struct
|
|||||||
{
|
{
|
||||||
if (m_data->m_pluginManager.getRenderInterface())
|
if (m_data->m_pluginManager.getRenderInterface())
|
||||||
{
|
{
|
||||||
m_data->m_pluginManager.getRenderInterface()->changeRGBAColor(bodyUniqueId,linkIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
m_data->m_pluginManager.getRenderInterface()->changeRGBAColor(bodyUniqueId,linkIndex,
|
||||||
|
clientCmd.m_updateVisualShapeDataArguments.m_shapeIndex,
|
||||||
|
clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
||||||
}
|
}
|
||||||
m_data->m_guiHelper->changeRGBAColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
m_data->m_guiHelper->changeRGBAColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
||||||
}
|
}
|
||||||
if (clientCmd.m_updateFlags & CMD_UPDATE_VISUAL_SHAPE_SPECULAR_COLOR)
|
if (clientCmd.m_updateFlags & CMD_UPDATE_VISUAL_SHAPE_SPECULAR_COLOR)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_data->m_guiHelper->changeSpecularColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_specularColor);
|
m_data->m_guiHelper->changeSpecularColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_specularColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8514,7 +8520,8 @@ bool PhysicsServerCommandProcessor::processUpdateVisualShapeCommand(const struct
|
|||||||
{
|
{
|
||||||
if (m_data->m_pluginManager.getRenderInterface())
|
if (m_data->m_pluginManager.getRenderInterface())
|
||||||
{
|
{
|
||||||
m_data->m_pluginManager.getRenderInterface()->changeRGBAColor(bodyUniqueId,linkIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
m_data->m_pluginManager.getRenderInterface()->changeRGBAColor(bodyUniqueId,linkIndex,
|
||||||
|
clientCmd.m_updateVisualShapeDataArguments.m_shapeIndex, clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
||||||
}
|
}
|
||||||
m_data->m_guiHelper->changeRGBAColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
m_data->m_guiHelper->changeRGBAColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
||||||
}
|
}
|
||||||
@@ -8543,7 +8550,8 @@ bool PhysicsServerCommandProcessor::processUpdateVisualShapeCommand(const struct
|
|||||||
{
|
{
|
||||||
if (m_data->m_pluginManager.getRenderInterface())
|
if (m_data->m_pluginManager.getRenderInterface())
|
||||||
{
|
{
|
||||||
m_data->m_pluginManager.getRenderInterface()->changeRGBAColor(bodyUniqueId,linkIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
m_data->m_pluginManager.getRenderInterface()->changeRGBAColor(bodyUniqueId,linkIndex,
|
||||||
|
clientCmd.m_updateVisualShapeDataArguments.m_shapeIndex, clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
||||||
}
|
}
|
||||||
m_data->m_guiHelper->changeRGBAColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
m_data->m_guiHelper->changeRGBAColor(graphicsIndex,clientCmd.m_updateVisualShapeDataArguments.m_rgbaColor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -550,7 +550,7 @@ static btVector4 sColors[4] =
|
|||||||
void TinyRendererVisualShapeConverter::convertVisualShapes(
|
void TinyRendererVisualShapeConverter::convertVisualShapes(
|
||||||
int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame,
|
int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame,
|
||||||
const UrdfLink* linkPtr, const UrdfModel* model,
|
const UrdfLink* linkPtr, const UrdfModel* model,
|
||||||
int shapeUid, int bodyUniqueId)
|
int collisionObjectUniqueId, int bodyUniqueId)
|
||||||
{
|
{
|
||||||
btAssert(linkPtr); // TODO: remove if (not doing it now, because diff will be 50+ lines)
|
btAssert(linkPtr); // TODO: remove if (not doing it now, because diff will be 50+ lines)
|
||||||
if (linkPtr)
|
if (linkPtr)
|
||||||
@@ -627,12 +627,12 @@ void TinyRendererVisualShapeConverter::convertVisualShapes(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TinyRendererObjectArray** visualsPtr = m_data->m_swRenderInstances[shapeUid];
|
TinyRendererObjectArray** visualsPtr = m_data->m_swRenderInstances[collisionObjectUniqueId];
|
||||||
if (visualsPtr==0)
|
if (visualsPtr==0)
|
||||||
{
|
{
|
||||||
m_data->m_swRenderInstances.insert(shapeUid,new TinyRendererObjectArray);
|
m_data->m_swRenderInstances.insert(collisionObjectUniqueId,new TinyRendererObjectArray);
|
||||||
}
|
}
|
||||||
visualsPtr = m_data->m_swRenderInstances[shapeUid];
|
visualsPtr = m_data->m_swRenderInstances[collisionObjectUniqueId];
|
||||||
|
|
||||||
btAssert(visualsPtr);
|
btAssert(visualsPtr);
|
||||||
TinyRendererObjectArray* visuals = *visualsPtr;
|
TinyRendererObjectArray* visuals = *visualsPtr;
|
||||||
@@ -753,7 +753,7 @@ int TinyRendererVisualShapeConverter::getVisualShapesData(int bodyUniqueId, int
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TinyRendererVisualShapeConverter::changeRGBAColor(int bodyUniqueId, int linkIndex, const double rgbaColor[4])
|
void TinyRendererVisualShapeConverter::changeRGBAColor(int bodyUniqueId, int linkIndex, int shapeIndex, const double rgbaColor[4])
|
||||||
{
|
{
|
||||||
int start = -1;
|
int start = -1;
|
||||||
for (int i = 0; i < m_data->m_visualShapes.size(); i++)
|
for (int i = 0; i < m_data->m_visualShapes.size(); i++)
|
||||||
@@ -777,6 +777,8 @@ void TinyRendererVisualShapeConverter::changeRGBAColor(int bodyUniqueId, int lin
|
|||||||
if ((bodyUniqueId == visuals->m_objectUniqueId) && (linkIndex == visuals->m_linkIndex))
|
if ((bodyUniqueId == visuals->m_objectUniqueId) && (linkIndex == visuals->m_linkIndex))
|
||||||
{
|
{
|
||||||
for (int q=0;q<visuals->m_renderObjects.size();q++)
|
for (int q=0;q<visuals->m_renderObjects.size();q++)
|
||||||
|
{
|
||||||
|
if (shapeIndex<0 || q==shapeIndex)
|
||||||
{
|
{
|
||||||
visuals->m_renderObjects[q]->m_model->setColorRGBA(rgba);
|
visuals->m_renderObjects[q]->m_model->setColorRGBA(rgba);
|
||||||
}
|
}
|
||||||
@@ -784,6 +786,8 @@ void TinyRendererVisualShapeConverter::changeRGBAColor(int bodyUniqueId, int lin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TinyRendererVisualShapeConverter::setUpAxis(int axis)
|
void TinyRendererVisualShapeConverter::setUpAxis(int axis)
|
||||||
@@ -832,9 +836,9 @@ void TinyRendererVisualShapeConverter::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TinyRendererVisualShapeConverter::syncTransform(int shapeUid, const btTransform& worldTransform, const btVector3& localScaling)
|
void TinyRendererVisualShapeConverter::syncTransform(int collisionObjectUniqueId, const btTransform& worldTransform, const btVector3& localScaling)
|
||||||
{
|
{
|
||||||
TinyRendererObjectArray** renderObjPtr = m_data->m_swRenderInstances[shapeUid];
|
TinyRendererObjectArray** renderObjPtr = m_data->m_swRenderInstances[collisionObjectUniqueId];
|
||||||
if (renderObjPtr)
|
if (renderObjPtr)
|
||||||
{
|
{
|
||||||
TinyRendererObjectArray* renderObj = *renderObjPtr;
|
TinyRendererObjectArray* renderObj = *renderObjPtr;
|
||||||
@@ -1109,9 +1113,9 @@ void TinyRendererVisualShapeConverter::copyCameraImageData(unsigned char* pixels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TinyRendererVisualShapeConverter::removeVisualShape(int shapeUid)
|
void TinyRendererVisualShapeConverter::removeVisualShape(int collisionObjectUniqueId)
|
||||||
{
|
{
|
||||||
TinyRendererObjectArray** ptrptr = m_data->m_swRenderInstances[shapeUid];
|
TinyRendererObjectArray** ptrptr = m_data->m_swRenderInstances[collisionObjectUniqueId];
|
||||||
if (ptrptr && *ptrptr)
|
if (ptrptr && *ptrptr)
|
||||||
{
|
{
|
||||||
TinyRendererObjectArray* ptr = *ptrptr;
|
TinyRendererObjectArray* ptr = *ptrptr;
|
||||||
@@ -1123,7 +1127,7 @@ void TinyRendererVisualShapeConverter::removeVisualShape(int shapeUid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete ptr;
|
delete ptr;
|
||||||
m_data->m_swRenderInstances.remove(shapeUid);
|
m_data->m_swRenderInstances.remove(collisionObjectUniqueId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1160,7 +1164,7 @@ void TinyRendererVisualShapeConverter::resetAll()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TinyRendererVisualShapeConverter::activateShapeTexture(int objectUniqueId, int jointIndex, int shapeIndex, int textureUniqueId)
|
void TinyRendererVisualShapeConverter::changeShapeTexture(int objectUniqueId, int jointIndex, int shapeIndex, int textureUniqueId)
|
||||||
{
|
{
|
||||||
btAssert(textureUniqueId < m_data->m_textures.size());
|
btAssert(textureUniqueId < m_data->m_textures.size());
|
||||||
if (textureUniqueId >= 0 && textureUniqueId < m_data->m_textures.size())
|
if (textureUniqueId >= 0 && textureUniqueId < m_data->m_textures.size())
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ struct TinyRendererVisualShapeConverter : public UrdfRenderingInterface
|
|||||||
|
|
||||||
virtual int getVisualShapesData(int bodyUniqueId, int shapeIndex, struct b3VisualShapeData* shapeData);
|
virtual int getVisualShapesData(int bodyUniqueId, int shapeIndex, struct b3VisualShapeData* shapeData);
|
||||||
|
|
||||||
virtual void changeRGBAColor(int bodyUniqueId, int linkIndex, const double rgbaColor[4]);
|
virtual void changeRGBAColor(int bodyUniqueId, int linkIndex, int shapeIndex, const double rgbaColor[4]);
|
||||||
|
|
||||||
|
virtual void changeShapeTexture(int objectUniqueId, int linkIndex, int shapeIndex, int textureUniqueId);
|
||||||
|
|
||||||
virtual void removeVisualShape(int shapeUid);
|
virtual void removeVisualShape(int shapeUid);
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ struct TinyRendererVisualShapeConverter : public UrdfRenderingInterface
|
|||||||
virtual int loadTextureFile(const char* filename);
|
virtual int loadTextureFile(const char* filename);
|
||||||
virtual int registerTexture(unsigned char* texels, int width, int height);
|
virtual int registerTexture(unsigned char* texels, int width, int height);
|
||||||
|
|
||||||
virtual void activateShapeTexture(int objectUniqueId, int jointIndex, int shapeIndex, int textureUniqueId);
|
|
||||||
|
|
||||||
virtual void syncTransform(int shapeUid, const class btTransform& worldTransform, const class btVector3& localScaling);
|
virtual void syncTransform(int shapeUid, const class btTransform& worldTransform, const class btVector3& localScaling);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user