small refactor of LinkVisualShapesConverter / TinyRendererVisualShapeConverter, it allows to use it in a Python module and in a PyBullet plugin.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
#include"../../ThirdPartyLibs/Wavefront/tiny_obj_loader.h"
|
||||
#include "../ImportMeshUtility/b3ImportMeshUtility.h"
|
||||
|
||||
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
||||
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btBoxShape.h"
|
||||
@@ -2277,7 +2277,7 @@ void BulletMJCFImporter::convertLinkVisualShapes2(int linkIndex, int urdfIndex,
|
||||
if (m_data->m_customVisualShapesConverter)
|
||||
{
|
||||
const UrdfLink* link = m_data->getLink(m_data->m_activeModel, urdfIndex);
|
||||
m_data->m_customVisualShapesConverter->convertVisualShapes(linkIndex,pathPrefix,inertialFrame, link, 0, colObj, objectIndex);
|
||||
m_data->m_customVisualShapesConverter->convertVisualShapes(linkIndex,pathPrefix,inertialFrame, link, 0, colObj->getBroadphaseHandle()->getUid(), objectIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1248,7 +1248,7 @@ void BulletURDFImporter::convertLinkVisualShapes2(int linkIndex, int urdfIndex,
|
||||
UrdfLink*const* linkPtr = model.m_links.getAtIndex(urdfIndex);
|
||||
if (linkPtr)
|
||||
{
|
||||
m_data->m_customVisualShapesConverter->convertVisualShapes(linkIndex,pathPrefix,localInertiaFrame, *linkPtr, &model, colObj, bodyUniqueId);
|
||||
m_data->m_customVisualShapesConverter->convertVisualShapes(linkIndex,pathPrefix,localInertiaFrame, *linkPtr, &model, colObj->getBroadphaseHandle()->getUid(), bodyUniqueId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,46 @@ class btCollisionObject;
|
||||
|
||||
struct LinkVisualShapesConverter
|
||||
{
|
||||
virtual void convertVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame, const UrdfLink* linkPtr, const UrdfModel* model, class btCollisionObject* colShape, int objectIndex) =0;
|
||||
virtual void convertVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame, const UrdfLink* linkPtr, const UrdfModel* model, int shapeUid, int objectIndex) =0;
|
||||
|
||||
virtual void removeVisualShape(class btCollisionObject* colObj)=0;
|
||||
virtual void removeVisualShape(int shapeUid)=0;
|
||||
|
||||
virtual void syncTransform(int shapeUid, const class btTransform& worldTransform, const class btVector3& localScaling)=0;
|
||||
|
||||
virtual int getNumVisualShapes(int bodyUniqueId)=0;
|
||||
|
||||
virtual int getVisualShapesData(int bodyUniqueId, int shapeIndex, struct b3VisualShapeData* shapeData)=0;
|
||||
|
||||
virtual void changeRGBAColor(int bodyUniqueId, int linkIndex, const double rgbaColor[4])=0;
|
||||
|
||||
virtual void setUpAxis(int axis)=0;
|
||||
|
||||
virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX,float camPosY, float camPosZ)=0;
|
||||
|
||||
virtual void clearBuffers(struct TGAColor& clearColor)=0;
|
||||
|
||||
virtual void resetAll()=0;
|
||||
|
||||
virtual void getWidthAndHeight(int& width, int& height)=0;
|
||||
virtual void setWidthAndHeight(int width, int height)=0;
|
||||
virtual void setLightDirection(float x, float y, float z)=0;
|
||||
virtual void setLightColor(float x, float y, float z)=0;
|
||||
virtual void setLightDistance(float dist)=0;
|
||||
virtual void setLightAmbientCoeff(float ambientCoeff)=0;
|
||||
virtual void setLightDiffuseCoeff(float diffuseCoeff)=0;
|
||||
virtual void setLightSpecularCoeff(float specularCoeff)=0;
|
||||
virtual void setShadow(bool hasShadow)=0;
|
||||
virtual void setFlags(int flags)=0;
|
||||
|
||||
virtual void copyCameraImageData(unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, float* depthBuffer, int depthBufferSizeInPixels,int* segmentationMaskBuffer, int segmentationMaskSizeInPixels, int startPixelIndex, int* widthPtr, int* heightPtr, int* numPixelsCopied)=0;
|
||||
|
||||
virtual void render()=0;
|
||||
virtual void render(const float viewMat[16], const float projMat[16])=0;
|
||||
|
||||
virtual int loadTextureFile(const char* filename)=0;
|
||||
virtual int registerTexture(unsigned char* texels, int width, int height)=0;
|
||||
|
||||
virtual void activateShapeTexture(int objectUniqueId, int jointIndex, int shapeIndex, int textureUniqueId)=0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -566,7 +566,9 @@ void ConvertURDF2BulletInternal(
|
||||
}
|
||||
} else
|
||||
{
|
||||
//u2b.convertLinkVisualShapes2(urdfLinkIndex,urdfIndex,pathPrefix,localInertialFrame,compoundShape);
|
||||
int mbLinkIndex =cache.getMbIndexFromUrdfIndex(urdfLinkIndex);
|
||||
//u2b.convertLinkVisualShapes2(mbLinkIndex, urdfLinkIndex, pathPrefix, localInertialFrame, col, u2b.getBodyUniqueId());
|
||||
u2b.convertLinkVisualShapes2(-1,urdfLinkIndex,pathPrefix,localInertialFrame,linkRigidBody,u2b.getBodyUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user