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;
|
|
|
|
|
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() {}
|
|
|
|
|
|
|
|
virtual void createRigidBodyGraphicsObject(btRigidBody* body,const btVector3& color) = 0;
|
|
|
|
|
|
|
|
virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj,const btVector3& color) = 0;
|
|
|
|
|
|
|
|
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape)=0;
|
|
|
|
|
|
|
|
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld)=0;
|
|
|
|
|
2015-04-20 22:28:52 +00:00
|
|
|
virtual void render(const btDiscreteDynamicsWorld* rbWorld)=0;
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual void createPhysicsDebugDrawer( btDiscreteDynamicsWorld* rbWorld)=0;
|
|
|
|
|
2016-07-08 02:24:44 +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;
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) =0;
|
2016-07-08 02:24:44 +00:00
|
|
|
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]) {}
|
2017-07-01 02:11:43 +00:00
|
|
|
virtual void changeTexture(int textureUniqueId, const unsigned char* rgbTexels, int width, int height){}
|
2017-06-01 19:32:44 +00:00
|
|
|
|
2017-06-30 20:35:07 +00:00
|
|
|
virtual int getShapeIndexFromInstance(int instanceUid){return -1;}
|
|
|
|
virtual void replaceTexture(int shapeIndex, int textureUid){}
|
|
|
|
|
2017-05-13 16:18:36 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual Common2dCanvasInterface* get2dCanvasInterface()=0;
|
|
|
|
|
|
|
|
virtual CommonParameterInterface* getParameterInterface()=0;
|
|
|
|
|
|
|
|
virtual CommonRenderInterface* getRenderInterface()=0;
|
|
|
|
|
2017-04-10 18:03:41 +00:00
|
|
|
virtual const CommonRenderInterface* getRenderInterface() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual CommonGraphicsApp* getAppInterface()=0;
|
|
|
|
|
|
|
|
virtual void setUpAxis(int axis)=0;
|
|
|
|
|
2017-06-01 22:30:37 +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
|
|
|
|
2017-06-03 01:24:51 +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;
|
|
|
|
}
|
|
|
|
|
2017-02-22 01:36:54 +00:00
|
|
|
virtual void setVisualizerFlag(int flag, int enable){};
|
|
|
|
|
2016-08-11 21:55:30 +00:00
|
|
|
virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
|
2016-08-12 21:18:46 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
|
2016-08-11 21:55:30 +00:00
|
|
|
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
|
|
|
|
float* depthBuffer, int depthBufferSizeInPixels,
|
|
|
|
int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
|
|
|
|
int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied)=0;
|
2017-06-13 17:53:24 +00:00
|
|
|
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){}
|
|
|
|
|
2016-05-31 17:23:04 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) =0;
|
|
|
|
|
2017-05-25 02:30:06 +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){}
|
2016-11-14 15:39:34 +00:00
|
|
|
|
2017-10-25 15:15:01 +00:00
|
|
|
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;}
|
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
|
|
|
virtual int addUserDebugLine(const double debugLineFromXYZ[3], const double debugLineToXYZ[3], const double debugLineColorRGB[3], double lineWidth, double lifeTime , int trackingVisualShapeIndex){return -1;};
|
2017-01-17 23:42:32 +00:00
|
|
|
virtual int addUserDebugParameter(const char* txt, double rangeMin, double rangeMax, double startValue){return -1;};
|
|
|
|
virtual int readUserDebugParameter(int itemUniqueId, double* value) { return 0;}
|
|
|
|
|
2017-01-12 19:40:43 +00:00
|
|
|
virtual void removeUserDebugItem( int debugItemUniqueId){};
|
|
|
|
virtual void removeAllUserDebugItems( ){};
|
2017-02-22 03:28:49 +00:00
|
|
|
virtual void setVisualizerFlagCallback(VisualizerFlagCallback callback){}
|
2016-11-14 15:39:34 +00:00
|
|
|
|
2017-03-16 16:13:33 +00:00
|
|
|
//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
|
|
|
|
{
|
|
|
|
DummyGUIHelper() {}
|
|
|
|
virtual ~DummyGUIHelper() {}
|
|
|
|
|
|
|
|
virtual void createRigidBodyGraphicsObject(btRigidBody* body,const btVector3& color){}
|
|
|
|
|
|
|
|
virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj,const btVector3& color) {}
|
|
|
|
|
|
|
|
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape){}
|
|
|
|
|
|
|
|
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld){}
|
|
|
|
|
2015-04-20 22:28:52 +00:00
|
|
|
virtual void render(const btDiscreteDynamicsWorld* rbWorld) {}
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual void createPhysicsDebugDrawer( btDiscreteDynamicsWorld* rbWorld){}
|
|
|
|
|
2016-07-08 02:24:44 +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(){}
|
2017-05-04 00:05: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-05-04 00:05:05 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual Common2dCanvasInterface* get2dCanvasInterface()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual CommonParameterInterface* getParameterInterface()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual CommonRenderInterface* getRenderInterface()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual CommonGraphicsApp* getAppInterface()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void setUpAxis(int axis)
|
|
|
|
{
|
|
|
|
}
|
2017-06-01 22:30:37 +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
|
|
|
|
2016-08-11 21:55:30 +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
|
|
|
{
|
|
|
|
if (numPixelsCopied)
|
|
|
|
*numPixelsCopied = 0;
|
|
|
|
}
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void drawText3D( const char* txt, float posX, float posZY, float posZ, float size)
|
|
|
|
{
|
|
|
|
}
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
virtual int addUserDebugLine(const double debugLineFromXYZ[3], const double debugLineToXYZ[3], const double debugLineColorRGB[3], double lineWidth, double lifeTime , int trackingVisualShapeIndex)
|
2016-11-14 15:39:34 +00:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virtual void removeUserDebugItem( int debugItemUniqueId)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
virtual void removeAllUserDebugItems( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //GUI_HELPER_INTERFACE_H
|
|
|
|
|