2015-04-16 16:55:32 +00:00
|
|
|
#ifndef GUI_HELPER_INTERFACE_H
|
|
|
|
#define GUI_HELPER_INTERFACE_H
|
|
|
|
|
|
|
|
class btRigidBody;
|
|
|
|
class btVector3;
|
|
|
|
class btCollisionObject;
|
|
|
|
class btDiscreteDynamicsWorld;
|
|
|
|
class btCollisionShape;
|
|
|
|
struct Common2dCanvasInterface;
|
|
|
|
struct CommonParameterInterface;
|
|
|
|
struct CommonRenderInterface;
|
|
|
|
struct CommonGraphicsApp;
|
|
|
|
|
2019-06-14 06:24:22 +00:00
|
|
|
struct GUISyncPosition
|
|
|
|
{
|
|
|
|
int m_graphicsInstanceId;
|
|
|
|
float m_pos[4];
|
|
|
|
float m_orn[4];
|
|
|
|
};
|
|
|
|
|
2017-02-22 03:28:49 +00:00
|
|
|
typedef void (*VisualizerFlagCallback)(int flag, bool enable);
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
///The Bullet 2 GraphicsPhysicsBridge let's the graphics engine create graphics representation and synchronize
|
|
|
|
struct GUIHelperInterface
|
|
|
|
{
|
|
|
|
virtual ~GUIHelperInterface() {}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void createRigidBodyGraphicsObject(btRigidBody* body, const btVector3& color) = 0;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj, const btVector3& color) = 0;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape) = 0;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld) = 0;
|
2019-06-14 21:34:56 +00:00
|
|
|
virtual void syncPhysicsToGraphics2(const btDiscreteDynamicsWorld* rbWorld) {}
|
2019-06-14 06:24:22 +00:00
|
|
|
virtual void syncPhysicsToGraphics2(const GUISyncPosition* positions, int numPositions) {}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void render(const btDiscreteDynamicsWorld* rbWorld) = 0;
|
2015-04-20 22:28:52 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void createPhysicsDebugDrawer(btDiscreteDynamicsWorld* rbWorld) = 0;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual int registerTexture(const unsigned char* texels, int width, int height) = 0;
|
|
|
|
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId) = 0;
|
|
|
|
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) = 0;
|
|
|
|
virtual void removeAllGraphicsInstances() = 0;
|
2017-05-05 14:48:05 +00:00
|
|
|
virtual void removeGraphicsInstance(int graphicsUid) {}
|
2017-05-13 16:18:36 +00:00
|
|
|
virtual void changeRGBAColor(int instanceUid, const double rgbaColor[4]) {}
|
2017-06-01 19:32:44 +00:00
|
|
|
virtual void changeSpecularColor(int instanceUid, const double specularColor[3]) {}
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void changeTexture(int textureUniqueId, const unsigned char* rgbTexels, int width, int height) {}
|
2019-08-15 04:06:10 +00:00
|
|
|
virtual void updateShape(int shapeIndex, float* vertices) {}
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual int getShapeIndexFromInstance(int instanceUid) { return -1; }
|
|
|
|
virtual void replaceTexture(int shapeIndex, int textureUid) {}
|
2018-02-22 07:22:16 +00:00
|
|
|
virtual void removeTexture(int textureUid) {}
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual Common2dCanvasInterface* get2dCanvasInterface() = 0;
|
|
|
|
|
|
|
|
virtual CommonParameterInterface* getParameterInterface() = 0;
|
|
|
|
|
|
|
|
virtual CommonRenderInterface* getRenderInterface() = 0;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2017-04-10 18:03:41 +00:00
|
|
|
virtual const CommonRenderInterface* getRenderInterface() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual CommonGraphicsApp* getAppInterface() = 0;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void setUpAxis(int axis) = 0;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX, float camPosY, float camPosZ) = 0;
|
2017-04-10 18:03:41 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual bool getCameraInfo(int* width, int* height, float viewMatrix[16], float projectionMatrix[16], float camUp[3], float camForward[3], float hor[3], float vert[3], float* yaw, float* pitch, float* camDist, float camTarget[3]) const
|
2017-04-10 18:03:41 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void setVisualizerFlag(int flag, int enable){};
|
2016-11-14 15:39:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
|
|
|
|
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
|
|
|
|
float* depthBuffer, int depthBufferSizeInPixels,
|
|
|
|
int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied)
|
|
|
|
{
|
|
|
|
copyCameraImageData(viewMatrix, projectionMatrix, pixelsRGBA, rgbaBufferSizeInPixels,
|
|
|
|
depthBuffer, depthBufferSizeInPixels,
|
|
|
|
0, 0,
|
|
|
|
startPixelIndex, destinationWidth,
|
|
|
|
destinationHeight, numPixelsCopied);
|
|
|
|
}
|
2017-03-16 16:13:33 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
|
|
|
|
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
|
|
|
|
float* depthBuffer, int depthBufferSizeInPixels,
|
|
|
|
int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
|
|
|
|
int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied) = 0;
|
|
|
|
virtual void debugDisplayCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
|
|
|
|
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
|
|
|
|
float* depthBuffer, int depthBufferSizeInPixels,
|
|
|
|
int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
|
|
|
|
int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied) {}
|
|
|
|
|
|
|
|
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]) {}
|
|
|
|
virtual void setProjectiveTexture(bool useProjectiveTexture) {}
|
|
|
|
|
|
|
|
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) = 0;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void drawText3D(const char* txt, float posX, float posY, float posZ, float size) {}
|
|
|
|
virtual void drawText3D(const char* txt, float position[3], float orientation[4], float color[4], float size, int optionFlag) {}
|
|
|
|
|
|
|
|
virtual int addUserDebugText3D(const char* txt, const double positionXYZ[3], const double orientation[4], const double textColorRGB[3], double size, double lifeTime, int trackingVisualShapeIndex, int optionFlags, int replaceItemUid) { return -1; }
|
|
|
|
virtual int addUserDebugLine(const double debugLineFromXYZ[3], const double debugLineToXYZ[3], const double debugLineColorRGB[3], double lineWidth, double lifeTime, int trackingVisualShapeIndex, int replaceItemUid) { return -1; };
|
|
|
|
virtual int addUserDebugParameter(const char* txt, double rangeMin, double rangeMax, double startValue) { return -1; };
|
|
|
|
virtual int readUserDebugParameter(int itemUniqueId, double* value) { return 0; }
|
|
|
|
|
|
|
|
virtual void removeUserDebugItem(int debugItemUniqueId){};
|
|
|
|
virtual void removeAllUserDebugItems(){};
|
|
|
|
virtual void setVisualizerFlagCallback(VisualizerFlagCallback callback) {}
|
|
|
|
|
|
|
|
//empty name stops dumping video
|
|
|
|
virtual void dumpFramesToVideo(const char* mp4FileName){};
|
|
|
|
};
|
2015-04-16 16:55:32 +00:00
|
|
|
|
|
|
|
///the DummyGUIHelper does nothing, so we can test the examples without GUI/graphics (in 'console mode')
|
|
|
|
struct DummyGUIHelper : public GUIHelperInterface
|
|
|
|
{
|
2019-06-14 06:24:22 +00:00
|
|
|
DummyGUIHelper()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual ~DummyGUIHelper() {}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void createRigidBodyGraphicsObject(btRigidBody* body, const btVector3& color) {}
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj, const btVector3& color) {}
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape) {}
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld) {}
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2015-04-20 22:28:52 +00:00
|
|
|
virtual void render(const btDiscreteDynamicsWorld* rbWorld) {}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void createPhysicsDebugDrawer(btDiscreteDynamicsWorld* rbWorld) {}
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual int registerTexture(const unsigned char* texels, int width, int height) { return -1; }
|
|
|
|
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId) { return -1; }
|
|
|
|
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) { return -1; }
|
|
|
|
virtual void removeAllGraphicsInstances() {}
|
|
|
|
virtual void removeGraphicsInstance(int graphicsUid) {}
|
2017-05-13 16:18:36 +00:00
|
|
|
virtual void changeRGBAColor(int instanceUid, const double rgbaColor[4]) {}
|
2017-05-04 00:05:05 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual Common2dCanvasInterface* get2dCanvasInterface()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual CommonParameterInterface* getParameterInterface()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual CommonRenderInterface* getRenderInterface()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual CommonGraphicsApp* getAppInterface()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setUpAxis(int axis)
|
|
|
|
{
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX, float camPosY, float camPosZ)
|
2015-05-01 18:42:14 +00:00
|
|
|
{
|
|
|
|
}
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
|
|
|
|
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
|
|
|
|
float* depthBuffer, int depthBufferSizeInPixels,
|
|
|
|
int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
|
|
|
|
int startPixelIndex, int width, int height, int* numPixelsCopied)
|
|
|
|
|
2016-05-31 17:23:04 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
if (numPixelsCopied)
|
|
|
|
*numPixelsCopied = 0;
|
2016-05-31 17:23:04 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
2018-03-19 01:45:54 +00:00
|
|
|
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])
|
|
|
|
{
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
2018-03-21 04:28:47 +00:00
|
|
|
virtual void setProjectiveTexture(bool useProjectiveTexture)
|
|
|
|
{
|
|
|
|
}
|
2016-05-31 17:23:04 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld)
|
2015-04-16 16:55:32 +00:00
|
|
|
{
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
virtual void drawText3D(const char* txt, float posX, float posZY, float posZ, float size)
|
2015-04-16 16:55:32 +00:00
|
|
|
{
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
virtual void drawText3D(const char* txt, float position[3], float orientation[4], float color[4], float size, int optionFlag)
|
2016-11-14 15:39:34 +00:00
|
|
|
{
|
|
|
|
}
|
Improve debug text/line rendering, can be use to draw frames and text in local coordinate of an object / link.
example:
kuka = p.loadURDF("kuka_iiwa/model.urdf")
p.getNumJoints(kuka)
pybullet.addUserDebugLine([0,0,0],[0,0,0.1],[0,0,1],trackObjectUniqueId=2,trackLinkIndex=6)
pybullet.addUserDebugText("tip", [0,0,0.1],textColorRGB=[1,0,0],trackObjectUniqueId=2,trackLinkIndex=6)
Also allow to render text using a given orientation (instead of pointing to the camera), example:
pybullet.addUserDebugText("tip", [0,0,0.1],textColorRGB=[1,0,0],textOrientation=[0,0,0,1], trackObjectUniqueId=2,trackLinkIndex=6)
Add drawTexturedTriangleMesh, for drawing 3d text.
Expose readSingleInstanceTransformToCPU, to extract position/orientation from graphics index.
updateTexture: allow to not flip texels around up axis
2017-05-24 05:05:26 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual int addUserDebugLine(const double debugLineFromXYZ[3], const double debugLineToXYZ[3], const double debugLineColorRGB[3], double lineWidth, double lifeTime, int trackingVisualShapeIndex, int replaceItemUid)
|
2016-11-14 15:39:34 +00:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void removeUserDebugItem(int debugItemUniqueId)
|
2016-11-14 15:39:34 +00:00
|
|
|
{
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void removeAllUserDebugItems()
|
2016-11-14 15:39:34 +00:00
|
|
|
{
|
|
|
|
}
|
2015-04-16 16:55:32 +00:00
|
|
|
};
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
#endif //GUI_HELPER_INTERFACE_H
|