Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -4,14 +4,12 @@
|
||||
struct Common2dCanvasInterface
|
||||
{
|
||||
virtual ~Common2dCanvasInterface() {}
|
||||
virtual int createCanvas(const char* canvasName, int width, int height, int xPos, int yPos)=0;
|
||||
virtual void destroyCanvas(int canvasId)=0;
|
||||
virtual void setPixel(int canvasId, int x, int y, unsigned char red, unsigned char green,unsigned char blue, unsigned char alpha)=0;
|
||||
virtual void getPixel(int canvasId, int x, int y, unsigned char& red, unsigned char& green,unsigned char& blue, unsigned char& alpha)=0;
|
||||
|
||||
virtual void refreshImageData(int canvasId)=0;
|
||||
virtual int createCanvas(const char* canvasName, int width, int height, int xPos, int yPos) = 0;
|
||||
virtual void destroyCanvas(int canvasId) = 0;
|
||||
virtual void setPixel(int canvasId, int x, int y, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha) = 0;
|
||||
virtual void getPixel(int canvasId, int x, int y, unsigned char& red, unsigned char& green, unsigned char& blue, unsigned char& alpha) = 0;
|
||||
|
||||
virtual void refreshImageData(int canvasId) = 0;
|
||||
};
|
||||
|
||||
#endif //COMMON_2D_CANVAS_INTERFACE_H
|
||||
|
||||
#endif //COMMON_2D_CANVAS_INTERFACE_H
|
||||
|
||||
@@ -1,47 +1,46 @@
|
||||
#ifndef COMMON_CALLBACKS_H
|
||||
#define COMMON_CALLBACKS_H
|
||||
|
||||
|
||||
typedef void (*b3WheelCallback)(float deltax, float deltay);
|
||||
typedef void (*b3ResizeCallback)( float width, float height);
|
||||
typedef void (*b3MouseMoveCallback)( float x, float y);
|
||||
typedef void (*b3ResizeCallback)(float width, float height);
|
||||
typedef void (*b3MouseMoveCallback)(float x, float y);
|
||||
typedef void (*b3MouseButtonCallback)(int button, int state, float x, float y);
|
||||
typedef void (*b3KeyboardCallback)(int keycode, int state);
|
||||
typedef void (*b3RenderCallback) ();
|
||||
typedef void (*b3RenderCallback)();
|
||||
|
||||
enum {
|
||||
B3G_ESCAPE = 27,
|
||||
B3G_F1 = 0xff00,
|
||||
B3G_F2,
|
||||
B3G_F3,
|
||||
B3G_F4,
|
||||
B3G_F5,
|
||||
B3G_F6,
|
||||
B3G_F7,
|
||||
B3G_F8,
|
||||
B3G_F9,
|
||||
B3G_F10,
|
||||
B3G_F11,
|
||||
B3G_F12,
|
||||
B3G_F13,
|
||||
B3G_F14,
|
||||
B3G_F15,
|
||||
B3G_LEFT_ARROW,
|
||||
B3G_RIGHT_ARROW,
|
||||
B3G_UP_ARROW,
|
||||
B3G_DOWN_ARROW,
|
||||
B3G_PAGE_UP,
|
||||
B3G_PAGE_DOWN,
|
||||
B3G_END,
|
||||
B3G_HOME,
|
||||
B3G_INSERT,
|
||||
B3G_DELETE,
|
||||
B3G_BACKSPACE,
|
||||
B3G_SHIFT,
|
||||
B3G_CONTROL,
|
||||
B3G_ALT,
|
||||
B3G_RETURN
|
||||
enum
|
||||
{
|
||||
B3G_ESCAPE = 27,
|
||||
B3G_F1 = 0xff00,
|
||||
B3G_F2,
|
||||
B3G_F3,
|
||||
B3G_F4,
|
||||
B3G_F5,
|
||||
B3G_F6,
|
||||
B3G_F7,
|
||||
B3G_F8,
|
||||
B3G_F9,
|
||||
B3G_F10,
|
||||
B3G_F11,
|
||||
B3G_F12,
|
||||
B3G_F13,
|
||||
B3G_F14,
|
||||
B3G_F15,
|
||||
B3G_LEFT_ARROW,
|
||||
B3G_RIGHT_ARROW,
|
||||
B3G_UP_ARROW,
|
||||
B3G_DOWN_ARROW,
|
||||
B3G_PAGE_UP,
|
||||
B3G_PAGE_DOWN,
|
||||
B3G_END,
|
||||
B3G_HOME,
|
||||
B3G_INSERT,
|
||||
B3G_DELETE,
|
||||
B3G_BACKSPACE,
|
||||
B3G_SHIFT,
|
||||
B3G_CONTROL,
|
||||
B3G_ALT,
|
||||
B3G_RETURN
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
|
||||
struct CommonCameraInterface
|
||||
{
|
||||
virtual ~CommonCameraInterface(){}
|
||||
virtual void getCameraProjectionMatrix(float m[16])const = 0;
|
||||
virtual ~CommonCameraInterface() {}
|
||||
virtual void getCameraProjectionMatrix(float m[16]) const = 0;
|
||||
virtual void getCameraViewMatrix(float m[16]) const = 0;
|
||||
|
||||
virtual void setVRCamera(const float viewMat[16], const float projectionMatrix[16])=0;
|
||||
virtual void disableVRCamera()=0;
|
||||
virtual bool isVRCamera() const =0;
|
||||
virtual void setVRCameraOffsetTransform(const float offset[16])=0;
|
||||
|
||||
virtual void setVRCamera(const float viewMat[16], const float projectionMatrix[16]) = 0;
|
||||
virtual void disableVRCamera() = 0;
|
||||
virtual bool isVRCamera() const = 0;
|
||||
virtual void setVRCameraOffsetTransform(const float offset[16]) = 0;
|
||||
|
||||
virtual void getCameraTargetPosition(float pos[3]) const = 0;
|
||||
virtual void getCameraPosition(float pos[3]) const = 0;
|
||||
@@ -18,30 +18,29 @@ struct CommonCameraInterface
|
||||
virtual void getCameraTargetPosition(double pos[3]) const = 0;
|
||||
virtual void getCameraPosition(double pos[3]) const = 0;
|
||||
|
||||
virtual void setCameraTargetPosition(float x,float y,float z) = 0;
|
||||
virtual void setCameraDistance(float dist) = 0;
|
||||
virtual float getCameraDistance() const = 0;
|
||||
virtual void setCameraTargetPosition(float x, float y, float z) = 0;
|
||||
virtual void setCameraDistance(float dist) = 0;
|
||||
virtual float getCameraDistance() const = 0;
|
||||
|
||||
virtual void setCameraUpVector(float x,float y, float z) = 0;
|
||||
virtual void getCameraUpVector(float up[3]) const = 0;
|
||||
virtual void getCameraForwardVector(float fwd[3]) const = 0;
|
||||
virtual void setCameraUpVector(float x, float y, float z) = 0;
|
||||
virtual void getCameraUpVector(float up[3]) const = 0;
|
||||
virtual void getCameraForwardVector(float fwd[3]) const = 0;
|
||||
|
||||
///the setCameraUpAxis will call the 'setCameraUpVector' and 'setCameraForwardVector'
|
||||
virtual void setCameraUpAxis(int axis) = 0;
|
||||
virtual int getCameraUpAxis() const = 0;
|
||||
virtual void setCameraUpAxis(int axis) = 0;
|
||||
virtual int getCameraUpAxis() const = 0;
|
||||
|
||||
virtual void setCameraYaw(float yaw) = 0;
|
||||
virtual float getCameraYaw() const = 0;
|
||||
|
||||
virtual void setCameraPitch(float pitch) = 0;
|
||||
virtual float getCameraPitch() const = 0;
|
||||
virtual void setCameraYaw(float yaw) = 0;
|
||||
virtual float getCameraYaw() const = 0;
|
||||
|
||||
virtual void setAspectRatio(float ratio) = 0;
|
||||
virtual float getAspectRatio() const = 0;
|
||||
|
||||
virtual float getCameraFrustumFar() const = 0;
|
||||
virtual float getCameraFrustumNear() const = 0;
|
||||
virtual void setCameraPitch(float pitch) = 0;
|
||||
virtual float getCameraPitch() const = 0;
|
||||
|
||||
virtual void setAspectRatio(float ratio) = 0;
|
||||
virtual float getAspectRatio() const = 0;
|
||||
|
||||
virtual float getCameraFrustumFar() const = 0;
|
||||
virtual float getCameraFrustumNear() const = 0;
|
||||
};
|
||||
|
||||
#endif //COMMON_CAMERA_INTERFACE_H
|
||||
|
||||
#endif //COMMON_CAMERA_INTERFACE_H
|
||||
|
||||
@@ -6,102 +6,91 @@
|
||||
struct CommandProcessorCreationInterface
|
||||
{
|
||||
virtual ~CommandProcessorCreationInterface() {}
|
||||
virtual class CommandProcessorInterface* createCommandProcessor()=0;
|
||||
virtual void deleteCommandProcessor(CommandProcessorInterface*)=0;
|
||||
virtual class CommandProcessorInterface* createCommandProcessor() = 0;
|
||||
virtual void deleteCommandProcessor(CommandProcessorInterface*) = 0;
|
||||
};
|
||||
|
||||
|
||||
struct CommonExampleOptions
|
||||
{
|
||||
struct GUIHelperInterface* m_guiHelper;
|
||||
struct GUIHelperInterface* m_guiHelper;
|
||||
|
||||
//Those are optional, some examples will use them others don't. Each example should work with them being 0.
|
||||
int m_option;
|
||||
int m_option;
|
||||
const char* m_fileName;
|
||||
class SharedMemoryInterface* m_sharedMem;
|
||||
CommandProcessorCreationInterface* m_commandProcessorCreation;
|
||||
bool m_skipGraphicsUpdate;
|
||||
|
||||
CommonExampleOptions(struct GUIHelperInterface* helper, int option=0)
|
||||
:m_guiHelper(helper),
|
||||
m_option(option),
|
||||
m_fileName(0),
|
||||
m_sharedMem(0),
|
||||
m_commandProcessorCreation(0),
|
||||
m_skipGraphicsUpdate(false)
|
||||
bool m_skipGraphicsUpdate;
|
||||
|
||||
CommonExampleOptions(struct GUIHelperInterface* helper, int option = 0)
|
||||
: m_guiHelper(helper),
|
||||
m_option(option),
|
||||
m_fileName(0),
|
||||
m_sharedMem(0),
|
||||
m_commandProcessorCreation(0),
|
||||
m_skipGraphicsUpdate(false)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CommonExampleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
typedef class CommonExampleInterface* (CreateFunc)(CommonExampleOptions& options);
|
||||
typedef class CommonExampleInterface*(CreateFunc)(CommonExampleOptions& options);
|
||||
|
||||
virtual ~CommonExampleInterface()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void initPhysics()=0;
|
||||
virtual void exitPhysics()=0;
|
||||
virtual void updateGraphics(){}
|
||||
virtual void stepSimulation(float deltaTime)=0;
|
||||
virtual void renderScene()=0;
|
||||
virtual void physicsDebugDraw(int debugFlags)=0;//for now we reuse the flags in Bullet/src/LinearMath/btIDebugDraw.h
|
||||
virtual void initPhysics() = 0;
|
||||
virtual void exitPhysics() = 0;
|
||||
virtual void updateGraphics() {}
|
||||
virtual void stepSimulation(float deltaTime) = 0;
|
||||
virtual void renderScene() = 0;
|
||||
virtual void physicsDebugDraw(int debugFlags) = 0; //for now we reuse the flags in Bullet/src/LinearMath/btIDebugDraw.h
|
||||
//reset camera is only called when switching demo. this way you can restart (initPhysics) and watch in a specific location easier
|
||||
virtual void resetCamera(){};
|
||||
virtual bool mouseMoveCallback(float x,float y)=0;
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)=0;
|
||||
virtual bool keyboardCallback(int key, int state)=0;
|
||||
virtual void resetCamera(){};
|
||||
virtual bool mouseMoveCallback(float x, float y) = 0;
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y) = 0;
|
||||
virtual bool keyboardCallback(int key, int state) = 0;
|
||||
|
||||
virtual void vrControllerMoveCallback(int controllerId, float pos[4], float orientation[4], float analogAxis, float auxAnalogAxes[10]) {}
|
||||
virtual void vrControllerButtonCallback(int controllerId, int button, int state, float pos[4], float orientation[4]){}
|
||||
virtual void vrHMDMoveCallback(int controllerId, float pos[4], float orientation[4]){}
|
||||
virtual void vrGenericTrackerMoveCallback(int controllerId, float pos[4], float orientation[4]){}
|
||||
virtual void vrControllerMoveCallback(int controllerId, float pos[4], float orientation[4], float analogAxis, float auxAnalogAxes[10]) {}
|
||||
virtual void vrControllerButtonCallback(int controllerId, int button, int state, float pos[4], float orientation[4]) {}
|
||||
virtual void vrHMDMoveCallback(int controllerId, float pos[4], float orientation[4]) {}
|
||||
virtual void vrGenericTrackerMoveCallback(int controllerId, float pos[4], float orientation[4]) {}
|
||||
|
||||
virtual void processCommandLineArgs(int argc, char* argv[]){};
|
||||
virtual void processCommandLineArgs(int argc, char* argv[]){};
|
||||
};
|
||||
|
||||
class ExampleEntries
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~ExampleEntries() {}
|
||||
|
||||
virtual ~ExampleEntries() {}
|
||||
virtual void initExampleEntries() = 0;
|
||||
|
||||
virtual void initOpenCLExampleEntries() = 0;
|
||||
|
||||
virtual void initExampleEntries()=0;
|
||||
virtual int getNumRegisteredExamples() = 0;
|
||||
|
||||
virtual void initOpenCLExampleEntries()=0;
|
||||
virtual CommonExampleInterface::CreateFunc* getExampleCreateFunc(int index) = 0;
|
||||
|
||||
virtual int getNumRegisteredExamples()=0;
|
||||
virtual const char* getExampleName(int index) = 0;
|
||||
|
||||
virtual CommonExampleInterface::CreateFunc* getExampleCreateFunc(int index)=0;
|
||||
|
||||
virtual const char* getExampleName(int index)=0;
|
||||
|
||||
virtual const char* getExampleDescription(int index)=0;
|
||||
|
||||
virtual int getExampleOption(int index)=0;
|
||||
virtual const char* getExampleDescription(int index) = 0;
|
||||
|
||||
virtual int getExampleOption(int index) = 0;
|
||||
};
|
||||
|
||||
|
||||
CommonExampleInterface* StandaloneExampleCreateFunc(CommonExampleOptions& options);
|
||||
|
||||
#ifdef B3_USE_STANDALONE_EXAMPLE
|
||||
#define B3_STANDALONE_EXAMPLE(ExampleFunc) CommonExampleInterface* StandaloneExampleCreateFunc(CommonExampleOptions& options)\
|
||||
{\
|
||||
return ExampleFunc(options);\
|
||||
#define B3_STANDALONE_EXAMPLE(ExampleFunc) \
|
||||
CommonExampleInterface* StandaloneExampleCreateFunc(CommonExampleOptions& options) \
|
||||
{ \
|
||||
return ExampleFunc(options); \
|
||||
}
|
||||
#else//B3_USE_STANDALONE_EXAMPLE
|
||||
#define B3_STANDALONE_EXAMPLE(ExampleFunc)
|
||||
#endif //B3_USE_STANDALONE_EXAMPLE
|
||||
#else //B3_USE_STANDALONE_EXAMPLE
|
||||
#define B3_STANDALONE_EXAMPLE(ExampleFunc)
|
||||
#endif //B3_USE_STANDALONE_EXAMPLE
|
||||
|
||||
|
||||
|
||||
#endif //COMMON_EXAMPLE_INTERFACE_H
|
||||
#endif //COMMON_EXAMPLE_INTERFACE_H
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef GUI_HELPER_INTERFACE_H
|
||||
#define GUI_HELPER_INTERFACE_H
|
||||
|
||||
|
||||
class btRigidBody;
|
||||
class btVector3;
|
||||
class btCollisionObject;
|
||||
@@ -12,8 +11,6 @@ struct CommonParameterInterface;
|
||||
struct CommonRenderInterface;
|
||||
struct CommonGraphicsApp;
|
||||
|
||||
|
||||
|
||||
typedef void (*VisualizerFlagCallback)(int flag, bool enable);
|
||||
|
||||
///The Bullet 2 GraphicsPhysicsBridge let's the graphics engine create graphics representation and synchronize
|
||||
@@ -21,132 +18,129 @@ struct GUIHelperInterface
|
||||
{
|
||||
virtual ~GUIHelperInterface() {}
|
||||
|
||||
virtual void createRigidBodyGraphicsObject(btRigidBody* body,const btVector3& color) = 0;
|
||||
virtual void createRigidBodyGraphicsObject(btRigidBody* body, const btVector3& color) = 0;
|
||||
|
||||
virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj,const btVector3& color) = 0;
|
||||
virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj, const btVector3& color) = 0;
|
||||
|
||||
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape)=0;
|
||||
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape) = 0;
|
||||
|
||||
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld)=0;
|
||||
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld) = 0;
|
||||
|
||||
virtual void render(const btDiscreteDynamicsWorld* rbWorld)=0;
|
||||
virtual void render(const btDiscreteDynamicsWorld* rbWorld) = 0;
|
||||
|
||||
virtual void createPhysicsDebugDrawer( btDiscreteDynamicsWorld* rbWorld)=0;
|
||||
virtual void createPhysicsDebugDrawer(btDiscreteDynamicsWorld* rbWorld) = 0;
|
||||
|
||||
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;
|
||||
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;
|
||||
virtual void removeGraphicsInstance(int graphicsUid) {}
|
||||
virtual void changeRGBAColor(int instanceUid, const double rgbaColor[4]) {}
|
||||
virtual void changeSpecularColor(int instanceUid, const double specularColor[3]) {}
|
||||
virtual void changeTexture(int textureUniqueId, const unsigned char* rgbTexels, int width, int height){}
|
||||
virtual void changeTexture(int textureUniqueId, const unsigned char* rgbTexels, int width, int height) {}
|
||||
|
||||
virtual int getShapeIndexFromInstance(int instanceUid){return -1;}
|
||||
virtual void replaceTexture(int shapeIndex, int textureUid){}
|
||||
virtual int getShapeIndexFromInstance(int instanceUid) { return -1; }
|
||||
virtual void replaceTexture(int shapeIndex, int textureUid) {}
|
||||
virtual void removeTexture(int textureUid) {}
|
||||
|
||||
|
||||
virtual Common2dCanvasInterface* get2dCanvasInterface()=0;
|
||||
|
||||
virtual CommonParameterInterface* getParameterInterface()=0;
|
||||
|
||||
virtual CommonRenderInterface* getRenderInterface()=0;
|
||||
virtual Common2dCanvasInterface* get2dCanvasInterface() = 0;
|
||||
|
||||
virtual CommonParameterInterface* getParameterInterface() = 0;
|
||||
|
||||
virtual CommonRenderInterface* getRenderInterface() = 0;
|
||||
|
||||
virtual const CommonRenderInterface* getRenderInterface() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual CommonGraphicsApp* getAppInterface()=0;
|
||||
virtual CommonGraphicsApp* getAppInterface() = 0;
|
||||
|
||||
virtual void setUpAxis(int axis)=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 resetCamera(float camDist, float yaw, float pitch, float camPosX, float camPosY, float camPosZ) = 0;
|
||||
|
||||
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
|
||||
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
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void setVisualizerFlag(int flag, int enable){};
|
||||
|
||||
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);
|
||||
}
|
||||
virtual void setVisualizerFlag(int flag, int enable){};
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]){}
|
||||
virtual void setProjectiveTexture(bool useProjectiveTexture){}
|
||||
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 autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) =0;
|
||||
|
||||
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 setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]) {}
|
||||
virtual void setProjectiveTexture(bool useProjectiveTexture) {}
|
||||
|
||||
virtual void removeUserDebugItem( int debugItemUniqueId){};
|
||||
virtual void removeAllUserDebugItems( ){};
|
||||
virtual void setVisualizerFlagCallback(VisualizerFlagCallback callback){}
|
||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) = 0;
|
||||
|
||||
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) {};
|
||||
|
||||
virtual void dumpFramesToVideo(const char* mp4FileName){};
|
||||
};
|
||||
|
||||
|
||||
///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 createRigidBodyGraphicsObject(btRigidBody* body, const btVector3& color) {}
|
||||
|
||||
virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj,const btVector3& color) {}
|
||||
virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj, const btVector3& color) {}
|
||||
|
||||
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape){}
|
||||
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape) {}
|
||||
|
||||
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld){}
|
||||
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld) {}
|
||||
|
||||
virtual void render(const btDiscreteDynamicsWorld* rbWorld) {}
|
||||
|
||||
virtual void createPhysicsDebugDrawer( btDiscreteDynamicsWorld* rbWorld){}
|
||||
virtual void createPhysicsDebugDrawer(btDiscreteDynamicsWorld* rbWorld) {}
|
||||
|
||||
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){}
|
||||
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) {}
|
||||
virtual void changeRGBAColor(int instanceUid, const double rgbaColor[4]) {}
|
||||
|
||||
virtual Common2dCanvasInterface* get2dCanvasInterface()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual CommonParameterInterface* getParameterInterface()
|
||||
{
|
||||
return 0;
|
||||
@@ -156,63 +150,60 @@ struct DummyGUIHelper : public GUIHelperInterface
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual CommonGraphicsApp* getAppInterface()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual void setUpAxis(int axis)
|
||||
{
|
||||
}
|
||||
virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX,float camPosY, float camPosZ)
|
||||
virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX, float camPosY, float camPosZ)
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
{
|
||||
if (numPixelsCopied)
|
||||
*numPixelsCopied = 0;
|
||||
if (numPixelsCopied)
|
||||
*numPixelsCopied = 0;
|
||||
}
|
||||
|
||||
|
||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void setProjectiveTexture(bool useProjectiveTexture)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void drawText3D( const char* txt, float posX, float posZY, float posZ, float size)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void drawText3D( const char* txt, float position[3], float orientation[4], float color[4], float size, int optionFlag)
|
||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld)
|
||||
{
|
||||
}
|
||||
|
||||
virtual int addUserDebugLine(const double debugLineFromXYZ[3], const double debugLineToXYZ[3], const double debugLineColorRGB[3], double lineWidth, double lifeTime , int trackingVisualShapeIndex, int replaceItemUid)
|
||||
virtual void drawText3D(const char* txt, float posX, float posZY, 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 addUserDebugLine(const double debugLineFromXYZ[3], const double debugLineToXYZ[3], const double debugLineColorRGB[3], double lineWidth, double lifeTime, int trackingVisualShapeIndex, int replaceItemUid)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
virtual void removeUserDebugItem( int debugItemUniqueId)
|
||||
virtual void removeUserDebugItem(int debugItemUniqueId)
|
||||
{
|
||||
}
|
||||
virtual void removeAllUserDebugItems( )
|
||||
virtual void removeAllUserDebugItems()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //GUI_HELPER_INTERFACE_H
|
||||
|
||||
#endif //GUI_HELPER_INTERFACE_H
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef COMMON_GRAPHICS_APP_H
|
||||
#define COMMON_GRAPHICS_APP_H
|
||||
|
||||
|
||||
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "CommonRenderInterface.h"
|
||||
#include "CommonWindowInterface.h"
|
||||
@@ -10,26 +8,26 @@
|
||||
|
||||
struct DrawGridData
|
||||
{
|
||||
int gridSize;
|
||||
float upOffset;
|
||||
int upAxis;
|
||||
float gridColor[4];
|
||||
int gridSize;
|
||||
float upOffset;
|
||||
int upAxis;
|
||||
float gridColor[4];
|
||||
|
||||
DrawGridData(int upAxis=1)
|
||||
:gridSize(10),
|
||||
upOffset(0.001f),
|
||||
upAxis(upAxis)
|
||||
{
|
||||
gridColor[0] = 0.6f;
|
||||
gridColor[1] = 0.6f;
|
||||
gridColor[2] = 0.6f;
|
||||
gridColor[3] = 1.f;
|
||||
}
|
||||
DrawGridData(int upAxis = 1)
|
||||
: gridSize(10),
|
||||
upOffset(0.001f),
|
||||
upAxis(upAxis)
|
||||
{
|
||||
gridColor[0] = 0.6f;
|
||||
gridColor[1] = 0.6f;
|
||||
gridColor[2] = 0.6f;
|
||||
gridColor[3] = 1.f;
|
||||
}
|
||||
};
|
||||
|
||||
enum EnumSphereLevelOfDetail
|
||||
{
|
||||
SPHERE_LOD_POINT_SPRITE=0,
|
||||
SPHERE_LOD_POINT_SPRITE = 0,
|
||||
SPHERE_LOD_LOW,
|
||||
SPHERE_LOD_MEDIUM,
|
||||
SPHERE_LOD_HIGH,
|
||||
@@ -39,38 +37,38 @@ struct CommonGraphicsApp
|
||||
{
|
||||
enum drawText3DOption
|
||||
{
|
||||
eDrawText3D_OrtogonalFaceCamera=1,
|
||||
eDrawText3D_TrueType=2,
|
||||
eDrawText3D_TrackObject=4,
|
||||
eDrawText3D_OrtogonalFaceCamera = 1,
|
||||
eDrawText3D_TrueType = 2,
|
||||
eDrawText3D_TrackObject = 4,
|
||||
};
|
||||
class CommonWindowInterface* m_window;
|
||||
struct CommonRenderInterface* m_renderer;
|
||||
struct CommonParameterInterface* m_parameterInterface;
|
||||
struct Common2dCanvasInterface* m_2dCanvasInterface;
|
||||
class CommonWindowInterface* m_window;
|
||||
struct CommonRenderInterface* m_renderer;
|
||||
struct CommonParameterInterface* m_parameterInterface;
|
||||
struct Common2dCanvasInterface* m_2dCanvasInterface;
|
||||
|
||||
bool m_leftMouseButton;
|
||||
bool m_middleMouseButton;
|
||||
bool m_rightMouseButton;
|
||||
bool m_leftMouseButton;
|
||||
bool m_middleMouseButton;
|
||||
bool m_rightMouseButton;
|
||||
float m_wheelMultiplier;
|
||||
float m_mouseMoveMultiplier;
|
||||
float m_mouseXpos;
|
||||
float m_mouseYpos;
|
||||
bool m_mouseInitialized;
|
||||
float m_backgroundColorRGB[3];
|
||||
float m_mouseXpos;
|
||||
float m_mouseYpos;
|
||||
bool m_mouseInitialized;
|
||||
float m_backgroundColorRGB[3];
|
||||
|
||||
CommonGraphicsApp()
|
||||
:m_window(0),
|
||||
m_renderer(0),
|
||||
m_parameterInterface(0),
|
||||
m_2dCanvasInterface(0),
|
||||
m_leftMouseButton(false),
|
||||
m_middleMouseButton(false),
|
||||
m_rightMouseButton(false),
|
||||
m_wheelMultiplier(0.01f),
|
||||
m_mouseMoveMultiplier(0.4f),
|
||||
m_mouseXpos(0.f),
|
||||
m_mouseYpos(0.f),
|
||||
m_mouseInitialized(false)
|
||||
: m_window(0),
|
||||
m_renderer(0),
|
||||
m_parameterInterface(0),
|
||||
m_2dCanvasInterface(0),
|
||||
m_leftMouseButton(false),
|
||||
m_middleMouseButton(false),
|
||||
m_rightMouseButton(false),
|
||||
m_wheelMultiplier(0.01f),
|
||||
m_mouseMoveMultiplier(0.4f),
|
||||
m_mouseXpos(0.f),
|
||||
m_mouseYpos(0.f),
|
||||
m_mouseInitialized(false)
|
||||
{
|
||||
m_backgroundColorRGB[0] = 0.7;
|
||||
m_backgroundColorRGB[1] = 0.7;
|
||||
@@ -80,11 +78,11 @@ struct CommonGraphicsApp
|
||||
{
|
||||
}
|
||||
|
||||
virtual void dumpNextFrameToPng(const char* pngFilename){}
|
||||
virtual void dumpFramesToVideo(const char* mp4Filename){}
|
||||
|
||||
virtual void getScreenPixels(unsigned char* rgbaBuffer, int bufferSizeInBytes, float* depthBuffer, int depthBufferSizeInBytes){}
|
||||
|
||||
virtual void dumpNextFrameToPng(const char* pngFilename) {}
|
||||
virtual void dumpFramesToVideo(const char* mp4Filename) {}
|
||||
|
||||
virtual void getScreenPixels(unsigned char* rgbaBuffer, int bufferSizeInBytes, float* depthBuffer, int depthBufferSizeInBytes) {}
|
||||
|
||||
virtual void getBackgroundColor(float* red, float* green, float* blue) const
|
||||
{
|
||||
if (red)
|
||||
@@ -113,190 +111,175 @@ struct CommonGraphicsApp
|
||||
{
|
||||
m_mouseMoveMultiplier = mult;
|
||||
}
|
||||
|
||||
|
||||
virtual float getMouseMoveMultiplier() const
|
||||
{
|
||||
return m_mouseMoveMultiplier;
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void drawGrid(DrawGridData data=DrawGridData()) = 0;
|
||||
virtual void drawGrid(DrawGridData data = DrawGridData()) = 0;
|
||||
virtual void setUpAxis(int axis) = 0;
|
||||
virtual int getUpAxis() const = 0;
|
||||
|
||||
|
||||
virtual void swapBuffer() = 0;
|
||||
virtual void drawText( const char* txt, int posX, int posY)
|
||||
virtual void drawText(const char* txt, int posX, int posY)
|
||||
{
|
||||
float size=1;
|
||||
float colorRGBA[4]={0,0,0,1};
|
||||
drawText(txt,posX,posY, size, colorRGBA);
|
||||
float size = 1;
|
||||
float colorRGBA[4] = {0, 0, 0, 1};
|
||||
drawText(txt, posX, posY, size, colorRGBA);
|
||||
}
|
||||
|
||||
virtual void drawText( const char* txt, int posX, int posY, float size)
|
||||
virtual void drawText(const char* txt, int posX, int posY, float size)
|
||||
{
|
||||
float colorRGBA[4]={0,0,0,1};
|
||||
drawText(txt,posX,posY,size,colorRGBA);
|
||||
float colorRGBA[4] = {0, 0, 0, 1};
|
||||
drawText(txt, posX, posY, size, colorRGBA);
|
||||
}
|
||||
virtual void drawText( const char* txt, int posX, int posY, float size, float colorRGBA[4]) = 0;
|
||||
virtual void drawText3D( const char* txt, float posX, float posY, float posZ, float size)=0;
|
||||
virtual void drawText3D( const char* txt, float position[3], float orientation[4], float color[4], float size, int optionFlag)=0;
|
||||
virtual void drawTexturedRect(float x0, float y0, float x1, float y1, float color[4], float u0,float v0, float u1, float v1, int useRGBA)=0;
|
||||
virtual int registerCubeShape(float halfExtentsX,float halfExtentsY, float halfExtentsZ, int textureIndex = -1, float textureScaling = 1)=0;
|
||||
virtual int registerGraphicsUnitSphereShape(EnumSphereLevelOfDetail lod, int textureId=-1) = 0;
|
||||
|
||||
virtual void drawText(const char* txt, int posX, int posY, float size, float colorRGBA[4]) = 0;
|
||||
virtual void drawText3D(const char* txt, float posX, float posY, float posZ, float size) = 0;
|
||||
virtual void drawText3D(const char* txt, float position[3], float orientation[4], float color[4], float size, int optionFlag) = 0;
|
||||
virtual void drawTexturedRect(float x0, float y0, float x1, float y1, float color[4], float u0, float v0, float u1, float v1, int useRGBA) = 0;
|
||||
virtual int registerCubeShape(float halfExtentsX, float halfExtentsY, float halfExtentsZ, int textureIndex = -1, float textureScaling = 1) = 0;
|
||||
virtual int registerGraphicsUnitSphereShape(EnumSphereLevelOfDetail lod, int textureId = -1) = 0;
|
||||
|
||||
virtual void registerGrid(int xres, int yres, float color0[4], float color1[4])=0;
|
||||
virtual void registerGrid(int xres, int yres, float color0[4], float color1[4]) = 0;
|
||||
|
||||
void defaultMouseButtonCallback( int button, int state, float x, float y)
|
||||
void defaultMouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
if (button==0)
|
||||
m_leftMouseButton= (state==1);
|
||||
if (button==1)
|
||||
m_middleMouseButton= (state==1);
|
||||
if (button == 0)
|
||||
m_leftMouseButton = (state == 1);
|
||||
if (button == 1)
|
||||
m_middleMouseButton = (state == 1);
|
||||
|
||||
if (button==2)
|
||||
m_rightMouseButton= (state==1);
|
||||
if (button == 2)
|
||||
m_rightMouseButton = (state == 1);
|
||||
|
||||
m_mouseXpos = x;
|
||||
m_mouseYpos = y;
|
||||
m_mouseInitialized = true;
|
||||
}
|
||||
void defaultMouseMoveCallback( float x, float y)
|
||||
void defaultMouseMoveCallback(float x, float y)
|
||||
{
|
||||
|
||||
if (m_window && m_renderer)
|
||||
{
|
||||
CommonCameraInterface* camera = m_renderer->getActiveCamera();
|
||||
|
||||
bool isAltPressed = m_window->isModifierKeyPressed(B3G_ALT);
|
||||
bool isControlPressed = m_window->isModifierKeyPressed(B3G_CONTROL);
|
||||
|
||||
|
||||
|
||||
if (isAltPressed || isControlPressed)
|
||||
{
|
||||
float xDelta = x-m_mouseXpos;
|
||||
float yDelta = y-m_mouseYpos;
|
||||
float xDelta = x - m_mouseXpos;
|
||||
float yDelta = y - m_mouseYpos;
|
||||
float cameraDistance = camera->getCameraDistance();
|
||||
float pitch = camera->getCameraPitch();
|
||||
float yaw = camera->getCameraYaw();
|
||||
|
||||
float targPos[3];
|
||||
float camPos[3];
|
||||
float camPos[3];
|
||||
|
||||
camera->getCameraTargetPosition(targPos);
|
||||
camera->getCameraPosition(camPos);
|
||||
|
||||
b3Vector3 cameraPosition = b3MakeVector3(b3Scalar(camPos[0]),
|
||||
b3Scalar(camPos[1]),
|
||||
b3Scalar(camPos[2]));
|
||||
|
||||
b3Vector3 cameraTargetPosition = b3MakeVector3( b3Scalar(targPos[0]),
|
||||
b3Scalar(targPos[1]),
|
||||
b3Scalar(targPos[2]));
|
||||
b3Vector3 cameraUp = b3MakeVector3(0,0,0);
|
||||
b3Vector3 cameraPosition = b3MakeVector3(b3Scalar(camPos[0]),
|
||||
b3Scalar(camPos[1]),
|
||||
b3Scalar(camPos[2]));
|
||||
|
||||
b3Vector3 cameraTargetPosition = b3MakeVector3(b3Scalar(targPos[0]),
|
||||
b3Scalar(targPos[1]),
|
||||
b3Scalar(targPos[2]));
|
||||
b3Vector3 cameraUp = b3MakeVector3(0, 0, 0);
|
||||
cameraUp[camera->getCameraUpAxis()] = 1.f;
|
||||
|
||||
|
||||
if (m_leftMouseButton)
|
||||
{
|
||||
// if (b3Fabs(xDelta)>b3Fabs(yDelta))
|
||||
// {
|
||||
pitch -= yDelta*m_mouseMoveMultiplier;
|
||||
// } else
|
||||
// {
|
||||
yaw -= xDelta*m_mouseMoveMultiplier;
|
||||
// }
|
||||
// if (b3Fabs(xDelta)>b3Fabs(yDelta))
|
||||
// {
|
||||
pitch -= yDelta * m_mouseMoveMultiplier;
|
||||
// } else
|
||||
// {
|
||||
yaw -= xDelta * m_mouseMoveMultiplier;
|
||||
// }
|
||||
}
|
||||
|
||||
if (m_middleMouseButton)
|
||||
{
|
||||
cameraTargetPosition += cameraUp * yDelta*0.01;
|
||||
cameraTargetPosition += cameraUp * yDelta * 0.01;
|
||||
|
||||
|
||||
b3Vector3 fwd = cameraTargetPosition-cameraPosition;
|
||||
b3Vector3 fwd = cameraTargetPosition - cameraPosition;
|
||||
b3Vector3 side = cameraUp.cross(fwd);
|
||||
side.normalize();
|
||||
cameraTargetPosition += side * xDelta*0.01;
|
||||
|
||||
cameraTargetPosition += side * xDelta * 0.01;
|
||||
}
|
||||
if (m_rightMouseButton)
|
||||
{
|
||||
cameraDistance -= xDelta*0.01f;
|
||||
cameraDistance -= yDelta*0.01f;
|
||||
if (cameraDistance<1)
|
||||
cameraDistance=1;
|
||||
if (cameraDistance>1000)
|
||||
cameraDistance=1000;
|
||||
cameraDistance -= xDelta * 0.01f;
|
||||
cameraDistance -= yDelta * 0.01f;
|
||||
if (cameraDistance < 1)
|
||||
cameraDistance = 1;
|
||||
if (cameraDistance > 1000)
|
||||
cameraDistance = 1000;
|
||||
}
|
||||
camera->setCameraDistance(cameraDistance);
|
||||
camera->setCameraPitch(pitch);
|
||||
camera->setCameraYaw(yaw);
|
||||
camera->setCameraTargetPosition(cameraTargetPosition[0],cameraTargetPosition[1],cameraTargetPosition[2]);
|
||||
|
||||
}
|
||||
camera->setCameraTargetPosition(cameraTargetPosition[0], cameraTargetPosition[1], cameraTargetPosition[2]);
|
||||
}
|
||||
|
||||
} //m_window && m_renderer
|
||||
|
||||
}//m_window && m_renderer
|
||||
|
||||
m_mouseXpos = x;
|
||||
m_mouseYpos = y;
|
||||
m_mouseInitialized = true;
|
||||
}
|
||||
// void defaultKeyboardCallback(int key, int state)
|
||||
// {
|
||||
// }
|
||||
void defaultWheelCallback( float deltax, float deltay)
|
||||
// void defaultKeyboardCallback(int key, int state)
|
||||
// {
|
||||
// }
|
||||
void defaultWheelCallback(float deltax, float deltay)
|
||||
{
|
||||
|
||||
if (m_renderer)
|
||||
{
|
||||
b3Vector3 cameraTargetPosition, cameraPosition, cameraUp = b3MakeVector3(0,0,0);
|
||||
b3Vector3 cameraTargetPosition, cameraPosition, cameraUp = b3MakeVector3(0, 0, 0);
|
||||
cameraUp[getUpAxis()] = 1;
|
||||
CommonCameraInterface* camera = m_renderer->getActiveCamera();
|
||||
|
||||
|
||||
camera->getCameraPosition(cameraPosition);
|
||||
camera->getCameraTargetPosition(cameraTargetPosition);
|
||||
|
||||
|
||||
if (!m_leftMouseButton)
|
||||
{
|
||||
|
||||
float cameraDistance = camera->getCameraDistance();
|
||||
if (deltay<0 || cameraDistance>1)
|
||||
float cameraDistance = camera->getCameraDistance();
|
||||
if (deltay < 0 || cameraDistance > 1)
|
||||
{
|
||||
cameraDistance -= deltay*0.01f;
|
||||
if (cameraDistance<1)
|
||||
cameraDistance=1;
|
||||
cameraDistance -= deltay * 0.01f;
|
||||
if (cameraDistance < 1)
|
||||
cameraDistance = 1;
|
||||
camera->setCameraDistance(cameraDistance);
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
b3Vector3 fwd = cameraTargetPosition-cameraPosition;
|
||||
fwd.normalize();
|
||||
cameraTargetPosition += fwd*deltay*m_wheelMultiplier;//todo: expose it in the GUI?
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (b3Fabs(deltax)>b3Fabs(deltay))
|
||||
else
|
||||
{
|
||||
b3Vector3 fwd = cameraTargetPosition-cameraPosition;
|
||||
b3Vector3 fwd = cameraTargetPosition - cameraPosition;
|
||||
fwd.normalize();
|
||||
cameraTargetPosition += fwd * deltay * m_wheelMultiplier; //todo: expose it in the GUI?
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (b3Fabs(deltax) > b3Fabs(deltay))
|
||||
{
|
||||
b3Vector3 fwd = cameraTargetPosition - cameraPosition;
|
||||
b3Vector3 side = cameraUp.cross(fwd);
|
||||
side.normalize();
|
||||
cameraTargetPosition += side * deltax*m_wheelMultiplier;
|
||||
|
||||
} else
|
||||
cameraTargetPosition += side * deltax * m_wheelMultiplier;
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraTargetPosition -= cameraUp * deltay*m_wheelMultiplier;
|
||||
|
||||
cameraTargetPosition -= cameraUp * deltay * m_wheelMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
camera->setCameraTargetPosition(cameraTargetPosition[0],cameraTargetPosition[1],cameraTargetPosition[2]);
|
||||
camera->setCameraTargetPosition(cameraTargetPosition[0], cameraTargetPosition[1], cameraTargetPosition[2]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //COMMON_GRAPHICS_APP_H
|
||||
#endif //COMMON_GRAPHICS_APP_H
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#ifndef COMMON_MULTI_BODY_SETUP_H
|
||||
#define COMMON_MULTI_BODY_SETUP_H
|
||||
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
#include "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h"
|
||||
@@ -20,32 +19,33 @@
|
||||
|
||||
enum MyFilterModes
|
||||
{
|
||||
FILTER_GROUPAMASKB_AND_GROUPBMASKA2=0,
|
||||
FILTER_GROUPAMASKB_AND_GROUPBMASKA2 = 0,
|
||||
FILTER_GROUPAMASKB_OR_GROUPBMASKA2
|
||||
};
|
||||
|
||||
struct MyOverlapFilterCallback2 : public btOverlapFilterCallback
|
||||
{
|
||||
int m_filterMode;
|
||||
|
||||
|
||||
MyOverlapFilterCallback2()
|
||||
:m_filterMode(FILTER_GROUPAMASKB_AND_GROUPBMASKA2)
|
||||
: m_filterMode(FILTER_GROUPAMASKB_AND_GROUPBMASKA2)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual ~MyOverlapFilterCallback2()
|
||||
{}
|
||||
// return true when pairs need collision
|
||||
virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
|
||||
{
|
||||
if (m_filterMode==FILTER_GROUPAMASKB_AND_GROUPBMASKA2)
|
||||
}
|
||||
// return true when pairs need collision
|
||||
virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) const
|
||||
{
|
||||
if (m_filterMode == FILTER_GROUPAMASKB_AND_GROUPBMASKA2)
|
||||
{
|
||||
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
|
||||
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
|
||||
return collides;
|
||||
}
|
||||
|
||||
if (m_filterMode==FILTER_GROUPAMASKB_OR_GROUPBMASKA2)
|
||||
|
||||
if (m_filterMode == FILTER_GROUPAMASKB_OR_GROUPBMASKA2)
|
||||
{
|
||||
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
|
||||
collides = collides || (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
|
||||
@@ -57,20 +57,20 @@ struct MyOverlapFilterCallback2 : public btOverlapFilterCallback
|
||||
|
||||
struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
{
|
||||
//keep the collision shapes, for deletion/cleanup
|
||||
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||
//keep the collision shapes, for deletion/cleanup
|
||||
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||
MyOverlapFilterCallback2* m_filterCallback;
|
||||
btOverlappingPairCache* m_pairCache;
|
||||
btBroadphaseInterface* m_broadphase;
|
||||
btCollisionDispatcher* m_dispatcher;
|
||||
btMultiBodyConstraintSolver* m_solver;
|
||||
btBroadphaseInterface* m_broadphase;
|
||||
btCollisionDispatcher* m_dispatcher;
|
||||
btMultiBodyConstraintSolver* m_solver;
|
||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||
btMultiBodyDynamicsWorld* m_dynamicsWorld;
|
||||
|
||||
//data for picking objects
|
||||
class btRigidBody* m_pickedBody;
|
||||
class btRigidBody* m_pickedBody;
|
||||
class btTypedConstraint* m_pickedConstraint;
|
||||
class btMultiBodyPoint2Point* m_pickingMultiBodyPoint2Point;
|
||||
class btMultiBodyPoint2Point* m_pickingMultiBodyPoint2Point;
|
||||
|
||||
btVector3 m_oldPickingPos;
|
||||
btVector3 m_hitPos;
|
||||
@@ -80,18 +80,18 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
struct GUIHelperInterface* m_guiHelper;
|
||||
|
||||
CommonMultiBodyBase(GUIHelperInterface* helper)
|
||||
:m_filterCallback(0),
|
||||
m_pairCache(0),
|
||||
m_broadphase(0),
|
||||
m_dispatcher(0),
|
||||
m_solver(0),
|
||||
m_collisionConfiguration(0),
|
||||
m_dynamicsWorld(0),
|
||||
m_pickedBody(0),
|
||||
m_pickedConstraint(0),
|
||||
m_pickingMultiBodyPoint2Point(0),
|
||||
m_prevCanSleep(false),
|
||||
m_guiHelper(helper)
|
||||
: m_filterCallback(0),
|
||||
m_pairCache(0),
|
||||
m_broadphase(0),
|
||||
m_dispatcher(0),
|
||||
m_solver(0),
|
||||
m_collisionConfiguration(0),
|
||||
m_dynamicsWorld(0),
|
||||
m_pickedBody(0),
|
||||
m_pickedConstraint(0),
|
||||
m_pickingMultiBodyPoint2Point(0),
|
||||
m_prevCanSleep(false),
|
||||
m_guiHelper(helper)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -101,15 +101,15 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
//m_collisionConfiguration->setConvexConvexMultipointIterations();
|
||||
m_filterCallback = new MyOverlapFilterCallback2();
|
||||
|
||||
|
||||
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||
|
||||
m_pairCache = new btHashedOverlappingPairCache();
|
||||
|
||||
m_pairCache->setOverlapFilterCallback(m_filterCallback);
|
||||
|
||||
m_broadphase = new btDbvtBroadphase(m_pairCache);//btSimpleBroadphase();
|
||||
|
||||
m_broadphase = new btDbvtBroadphase(m_pairCache); //btSimpleBroadphase();
|
||||
|
||||
m_solver = new btMultiBodyConstraintSolver;
|
||||
|
||||
@@ -118,7 +118,6 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
m_dynamicsWorld->setGravity(btVector3(0, -10, 0));
|
||||
}
|
||||
|
||||
|
||||
virtual void stepSimulation(float deltaTime)
|
||||
{
|
||||
if (m_dynamicsWorld)
|
||||
@@ -127,7 +126,6 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void exitPhysics()
|
||||
{
|
||||
removePickingConstraint();
|
||||
@@ -137,13 +135,12 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
int i;
|
||||
for (i = m_dynamicsWorld->getNumConstraints() - 1; i >= 0; i--)
|
||||
{
|
||||
m_dynamicsWorld->removeConstraint(m_dynamicsWorld->getConstraint(i));
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = m_dynamicsWorld->getNumConstraints() - 1; i >= 0; i--)
|
||||
{
|
||||
m_dynamicsWorld->removeConstraint(m_dynamicsWorld->getConstraint(i));
|
||||
}
|
||||
|
||||
for (i = m_dynamicsWorld->getNumMultiBodyConstraints() - 1; i >= 0; i--)
|
||||
{
|
||||
btMultiBodyConstraint* mbc = m_dynamicsWorld->getMultiBodyConstraint(i);
|
||||
@@ -170,7 +167,7 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
}
|
||||
}
|
||||
//delete collision shapes
|
||||
for (int j = 0; j<m_collisionShapes.size(); j++)
|
||||
for (int j = 0; j < m_collisionShapes.size(); j++)
|
||||
{
|
||||
btCollisionShape* shape = m_collisionShapes[j];
|
||||
delete shape;
|
||||
@@ -181,22 +178,22 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
m_dynamicsWorld = 0;
|
||||
|
||||
delete m_solver;
|
||||
m_solver=0;
|
||||
m_solver = 0;
|
||||
|
||||
delete m_broadphase;
|
||||
m_broadphase=0;
|
||||
m_broadphase = 0;
|
||||
|
||||
delete m_dispatcher;
|
||||
m_dispatcher=0;
|
||||
|
||||
m_dispatcher = 0;
|
||||
|
||||
delete m_pairCache;
|
||||
m_pairCache = 0;
|
||||
|
||||
delete m_filterCallback;
|
||||
m_filterCallback = 0;
|
||||
|
||||
|
||||
delete m_collisionConfiguration;
|
||||
m_collisionConfiguration=0;
|
||||
m_collisionConfiguration = 0;
|
||||
}
|
||||
|
||||
virtual void syncPhysicsToGraphics()
|
||||
@@ -209,76 +206,72 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
|
||||
virtual void renderScene()
|
||||
{
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
m_guiHelper->syncPhysicsToGraphics(m_dynamicsWorld);
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
m_guiHelper->syncPhysicsToGraphics(m_dynamicsWorld);
|
||||
|
||||
m_guiHelper->render(m_dynamicsWorld);
|
||||
}
|
||||
|
||||
m_guiHelper->render(m_dynamicsWorld);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void physicsDebugDraw(int debugDrawFlags)
|
||||
{
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
virtual void physicsDebugDraw(int debugDrawFlags)
|
||||
{
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
if (m_dynamicsWorld->getDebugDrawer())
|
||||
{
|
||||
m_dynamicsWorld->getDebugDrawer()->setDebugMode(debugDrawFlags);
|
||||
}
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
}
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
virtual bool keyboardCallback(int key, int state)
|
||||
virtual bool keyboardCallback(int key, int state)
|
||||
{
|
||||
if ((key==B3G_F3) && state && m_dynamicsWorld)
|
||||
if ((key == B3G_F3) && state && m_dynamicsWorld)
|
||||
{
|
||||
btDefaultSerializer* serializer = new btDefaultSerializer();
|
||||
btDefaultSerializer* serializer = new btDefaultSerializer();
|
||||
m_dynamicsWorld->serialize(serializer);
|
||||
|
||||
FILE* file = fopen("testFile.bullet","wb");
|
||||
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
|
||||
FILE* file = fopen("testFile.bullet", "wb");
|
||||
fwrite(serializer->getBufferPointer(), serializer->getCurrentBufferSize(), 1, file);
|
||||
fclose(file);
|
||||
//b3Printf("btDefaultSerializer wrote testFile.bullet");
|
||||
delete serializer;
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;//don't handle this key
|
||||
return false; //don't handle this key
|
||||
}
|
||||
|
||||
|
||||
btVector3 getRayTo(int x,int y)
|
||||
btVector3 getRayTo(int x, int y)
|
||||
{
|
||||
CommonRenderInterface* renderer = m_guiHelper->getRenderInterface();
|
||||
|
||||
|
||||
if (!renderer)
|
||||
{
|
||||
btAssert(0);
|
||||
return btVector3(0,0,0);
|
||||
return btVector3(0, 0, 0);
|
||||
}
|
||||
|
||||
float top = 1.f;
|
||||
float bottom = -1.f;
|
||||
float nearPlane = 1.f;
|
||||
float tanFov = (top-bottom)*0.5f / nearPlane;
|
||||
float tanFov = (top - bottom) * 0.5f / nearPlane;
|
||||
float fov = btScalar(2.0) * btAtan(tanFov);
|
||||
|
||||
btVector3 camPos,camTarget;
|
||||
btVector3 camPos, camTarget;
|
||||
renderer->getActiveCamera()->getCameraPosition(camPos);
|
||||
renderer->getActiveCamera()->getCameraTargetPosition(camTarget);
|
||||
|
||||
btVector3 rayFrom = camPos;
|
||||
btVector3 rayForward = (camTarget-camPos);
|
||||
btVector3 rayFrom = camPos;
|
||||
btVector3 rayForward = (camTarget - camPos);
|
||||
rayForward.normalize();
|
||||
float farPlane = 10000.f;
|
||||
rayForward*= farPlane;
|
||||
rayForward *= farPlane;
|
||||
|
||||
btVector3 rightOffset;
|
||||
btVector3 cameraUp=btVector3(0,0,0);
|
||||
cameraUp[m_guiHelper->getAppInterface()->getUpAxis()]=1;
|
||||
btVector3 cameraUp = btVector3(0, 0, 0);
|
||||
cameraUp[m_guiHelper->getAppInterface()->getUpAxis()] = 1;
|
||||
|
||||
btVector3 vertical = cameraUp;
|
||||
|
||||
@@ -288,25 +281,22 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
vertical = hor.cross(rayForward);
|
||||
vertical.normalize();
|
||||
|
||||
float tanfov = tanf(0.5f*fov);
|
||||
|
||||
float tanfov = tanf(0.5f * fov);
|
||||
|
||||
hor *= 2.f * farPlane * tanfov;
|
||||
vertical *= 2.f * farPlane * tanfov;
|
||||
|
||||
btScalar aspect;
|
||||
float width = float(renderer->getScreenWidth());
|
||||
float height = float (renderer->getScreenHeight());
|
||||
float height = float(renderer->getScreenHeight());
|
||||
|
||||
aspect = width / height;
|
||||
|
||||
hor*=aspect;
|
||||
aspect = width / height;
|
||||
|
||||
hor *= aspect;
|
||||
|
||||
btVector3 rayToCenter = rayFrom + rayForward;
|
||||
btVector3 dHor = hor * 1.f/width;
|
||||
btVector3 dVert = vertical * 1.f/height;
|
||||
|
||||
btVector3 dHor = hor * 1.f / width;
|
||||
btVector3 dVert = vertical * 1.f / height;
|
||||
|
||||
btVector3 rayTo = rayToCenter - 0.5f * hor + 0.5f * vertical;
|
||||
rayTo += btScalar(x) * dHor;
|
||||
@@ -314,10 +304,10 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
return rayTo;
|
||||
}
|
||||
|
||||
virtual bool mouseMoveCallback(float x,float y)
|
||||
virtual bool mouseMoveCallback(float x, float y)
|
||||
{
|
||||
CommonRenderInterface* renderer = m_guiHelper->getRenderInterface();
|
||||
|
||||
|
||||
if (!renderer)
|
||||
{
|
||||
btAssert(0);
|
||||
@@ -327,41 +317,39 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
btVector3 rayTo = getRayTo(int(x), int(y));
|
||||
btVector3 rayFrom;
|
||||
renderer->getActiveCamera()->getCameraPosition(rayFrom);
|
||||
movePickedBody(rayFrom,rayTo);
|
||||
movePickedBody(rayFrom, rayTo);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
CommonRenderInterface* renderer = m_guiHelper->getRenderInterface();
|
||||
|
||||
|
||||
if (!renderer)
|
||||
{
|
||||
btAssert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CommonWindowInterface* window = m_guiHelper->getAppInterface()->m_window;
|
||||
|
||||
|
||||
if (state==1)
|
||||
if (state == 1)
|
||||
{
|
||||
if(button==0 && (!window->isModifierKeyPressed(B3G_ALT) && !window->isModifierKeyPressed(B3G_CONTROL) ))
|
||||
if (button == 0 && (!window->isModifierKeyPressed(B3G_ALT) && !window->isModifierKeyPressed(B3G_CONTROL)))
|
||||
{
|
||||
btVector3 camPos;
|
||||
renderer->getActiveCamera()->getCameraPosition(camPos);
|
||||
|
||||
btVector3 rayFrom = camPos;
|
||||
btVector3 rayTo = getRayTo(int(x),int(y));
|
||||
btVector3 rayTo = getRayTo(int(x), int(y));
|
||||
|
||||
pickBody(rayFrom, rayTo);
|
||||
|
||||
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (button==0)
|
||||
if (button == 0)
|
||||
{
|
||||
removePickingConstraint();
|
||||
//remove p2p
|
||||
@@ -372,10 +360,9 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
virtual bool pickBody(const btVector3& rayFromWorld, const btVector3& rayToWorld)
|
||||
{
|
||||
if (m_dynamicsWorld==0)
|
||||
if (m_dynamicsWorld == 0)
|
||||
return false;
|
||||
|
||||
btCollisionWorld::ClosestRayResultCallback rayCallback(rayFromWorld, rayToWorld);
|
||||
@@ -383,7 +370,6 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
m_dynamicsWorld->rayTest(rayFromWorld, rayToWorld, rayCallback);
|
||||
if (rayCallback.hasHit())
|
||||
{
|
||||
|
||||
btVector3 pickPos = rayCallback.m_hitPointWorld;
|
||||
btRigidBody* body = (btRigidBody*)btRigidBody::upcast(rayCallback.m_collisionObject);
|
||||
if (body)
|
||||
@@ -403,33 +389,31 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
//very weak constraint for picking
|
||||
p2p->m_setting.m_tau = 0.001f;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
btMultiBodyLinkCollider* multiCol = (btMultiBodyLinkCollider*)btMultiBodyLinkCollider::upcast(rayCallback.m_collisionObject);
|
||||
if (multiCol && multiCol->m_multiBody)
|
||||
{
|
||||
|
||||
m_prevCanSleep = multiCol->m_multiBody->getCanSleep();
|
||||
multiCol->m_multiBody->setCanSleep(false);
|
||||
|
||||
btVector3 pivotInA = multiCol->m_multiBody->worldPosToLocal(multiCol->m_link, pickPos);
|
||||
|
||||
btMultiBodyPoint2Point* p2p = new btMultiBodyPoint2Point(multiCol->m_multiBody,multiCol->m_link,0,pivotInA,pickPos);
|
||||
btMultiBodyPoint2Point* p2p = new btMultiBodyPoint2Point(multiCol->m_multiBody, multiCol->m_link, 0, pivotInA, pickPos);
|
||||
//if you add too much energy to the system, causing high angular velocities, simulation 'explodes'
|
||||
//see also http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=4&t=949
|
||||
//so we try to avoid it by clamping the maximum impulse (force) that the mouse pick can apply
|
||||
//it is not satisfying, hopefully we find a better solution (higher order integrator, using joint friction using a zero-velocity target motor with limited force etc?)
|
||||
btScalar scaling=1;
|
||||
p2p->setMaxAppliedImpulse(2*scaling);
|
||||
|
||||
btMultiBodyDynamicsWorld* world = (btMultiBodyDynamicsWorld*) m_dynamicsWorld;
|
||||
btScalar scaling = 1;
|
||||
p2p->setMaxAppliedImpulse(2 * scaling);
|
||||
|
||||
btMultiBodyDynamicsWorld* world = (btMultiBodyDynamicsWorld*)m_dynamicsWorld;
|
||||
world->addMultiBodyConstraint(p2p);
|
||||
m_pickingMultiBodyPoint2Point =p2p;
|
||||
m_pickingMultiBodyPoint2Point = p2p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// pickObject(pickPos, rayCallback.m_collisionObject);
|
||||
m_oldPickingPos = rayToWorld;
|
||||
m_hitPos = pickPos;
|
||||
@@ -441,14 +425,14 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
}
|
||||
virtual bool movePickedBody(const btVector3& rayFromWorld, const btVector3& rayToWorld)
|
||||
{
|
||||
if (m_pickedBody && m_pickedConstraint)
|
||||
if (m_pickedBody && m_pickedConstraint)
|
||||
{
|
||||
btPoint2PointConstraint* pickCon = static_cast<btPoint2PointConstraint*>(m_pickedConstraint);
|
||||
if (pickCon)
|
||||
{
|
||||
//keep it at the same picking distance
|
||||
|
||||
btVector3 dir = rayToWorld-rayFromWorld;
|
||||
|
||||
btVector3 dir = rayToWorld - rayFromWorld;
|
||||
dir.normalize();
|
||||
dir *= m_oldPickingDist;
|
||||
|
||||
@@ -456,21 +440,20 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
pickCon->setPivotB(newPivotB);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (m_pickingMultiBodyPoint2Point)
|
||||
{
|
||||
//keep it at the same picking distance
|
||||
|
||||
|
||||
btVector3 dir = rayToWorld-rayFromWorld;
|
||||
btVector3 dir = rayToWorld - rayFromWorld;
|
||||
dir.normalize();
|
||||
dir *= m_oldPickingDist;
|
||||
|
||||
btVector3 newPivotB = rayFromWorld + dir;
|
||||
|
||||
|
||||
m_pickingMultiBodyPoint2Point->setPivotInB(newPivotB);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
virtual void removePickingConstraint()
|
||||
@@ -491,22 +474,20 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
if (m_pickingMultiBodyPoint2Point)
|
||||
{
|
||||
m_pickingMultiBodyPoint2Point->getMultiBodyA()->setCanSleep(m_prevCanSleep);
|
||||
btMultiBodyDynamicsWorld* world = (btMultiBodyDynamicsWorld*) m_dynamicsWorld;
|
||||
btMultiBodyDynamicsWorld* world = (btMultiBodyDynamicsWorld*)m_dynamicsWorld;
|
||||
world->removeMultiBodyConstraint(m_pickingMultiBodyPoint2Point);
|
||||
delete m_pickingMultiBodyPoint2Point;
|
||||
m_pickingMultiBodyPoint2Point = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
btBoxShape* createBoxShape(const btVector3& halfExtents)
|
||||
{
|
||||
btBoxShape* box = new btBoxShape(halfExtents);
|
||||
return box;
|
||||
}
|
||||
|
||||
btRigidBody* createRigidBody(float mass, const btTransform& startTransform, btCollisionShape* shape, const btVector4& color = btVector4(1, 0, 0, 1))
|
||||
btRigidBody* createRigidBody(float mass, const btTransform& startTransform, btCollisionShape* shape, const btVector4& color = btVector4(1, 0, 0, 1))
|
||||
{
|
||||
btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE));
|
||||
|
||||
@@ -517,7 +498,7 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
if (isDynamic)
|
||||
shape->calculateLocalInertia(mass, localInertia);
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
|
||||
#define USE_MOTIONSTATE 1
|
||||
#ifdef USE_MOTIONSTATE
|
||||
@@ -531,7 +512,7 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
#else
|
||||
btRigidBody* body = new btRigidBody(mass, 0, shape, localInertia);
|
||||
body->setWorldTransform(startTransform);
|
||||
#endif//
|
||||
#endif //
|
||||
|
||||
body->setUserIndex(-1);
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
@@ -539,5 +520,4 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
}
|
||||
};
|
||||
|
||||
#endif //COMMON_MULTI_BODY_SETUP_H
|
||||
|
||||
#endif //COMMON_MULTI_BODY_SETUP_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef void (*SliderParamChangedCallback) (float newVal, void* userPointer);
|
||||
typedef void (*SliderParamChangedCallback)(float newVal, void* userPointer);
|
||||
#include "LinearMath/btScalar.h"
|
||||
|
||||
struct SliderParams
|
||||
@@ -16,43 +16,42 @@ struct SliderParams
|
||||
btScalar* m_paramValuePointer;
|
||||
void* m_userPointer;
|
||||
bool m_clampToNotches;
|
||||
bool m_clampToIntegers;
|
||||
bool m_showValues;
|
||||
|
||||
bool m_clampToIntegers;
|
||||
bool m_showValues;
|
||||
|
||||
SliderParams(const char* name, btScalar* targetValuePointer)
|
||||
:m_name(name),
|
||||
m_minVal(-100),
|
||||
m_maxVal(100),
|
||||
m_callback(0),
|
||||
m_paramValuePointer(targetValuePointer),
|
||||
m_userPointer(0),
|
||||
m_clampToNotches(false),
|
||||
m_clampToIntegers(false),
|
||||
m_showValues(true)
|
||||
: m_name(name),
|
||||
m_minVal(-100),
|
||||
m_maxVal(100),
|
||||
m_callback(0),
|
||||
m_paramValuePointer(targetValuePointer),
|
||||
m_userPointer(0),
|
||||
m_clampToNotches(false),
|
||||
m_clampToIntegers(false),
|
||||
m_showValues(true)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef void (*ButtonParamChangedCallback) (int buttonId, bool buttonState, void* userPointer);
|
||||
typedef void (*ComboBoxCallback) (int combobox, const char* item, void* userPointer);
|
||||
typedef void (*ButtonParamChangedCallback)(int buttonId, bool buttonState, void* userPointer);
|
||||
typedef void (*ComboBoxCallback)(int combobox, const char* item, void* userPointer);
|
||||
|
||||
struct ButtonParams
|
||||
{
|
||||
const char* m_name;
|
||||
int m_buttonId;
|
||||
void* m_userPointer;
|
||||
bool m_isTrigger;
|
||||
bool m_initialState;
|
||||
bool m_isTrigger;
|
||||
bool m_initialState;
|
||||
|
||||
ButtonParamChangedCallback m_callback;
|
||||
ButtonParams(const char* name, int buttonId, bool isTrigger)
|
||||
:m_name(name),
|
||||
m_buttonId(buttonId),
|
||||
m_userPointer(0),
|
||||
m_isTrigger(isTrigger),
|
||||
m_initialState(false),
|
||||
m_callback(0)
|
||||
: m_name(name),
|
||||
m_buttonId(buttonId),
|
||||
m_userPointer(0),
|
||||
m_isTrigger(isTrigger),
|
||||
m_initialState(false),
|
||||
m_callback(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -64,32 +63,29 @@ struct ComboBoxParams
|
||||
const char** m_items;
|
||||
int m_startItem;
|
||||
ComboBoxCallback m_callback;
|
||||
void* m_userPointer;
|
||||
void* m_userPointer;
|
||||
|
||||
ComboBoxParams()
|
||||
:m_comboboxId(-1),
|
||||
m_numItems(0),
|
||||
m_items(0),
|
||||
m_startItem(0),
|
||||
m_callback(0),
|
||||
m_userPointer(0)
|
||||
: m_comboboxId(-1),
|
||||
m_numItems(0),
|
||||
m_items(0),
|
||||
m_startItem(0),
|
||||
m_callback(0),
|
||||
m_userPointer(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct CommonParameterInterface
|
||||
{
|
||||
|
||||
virtual ~CommonParameterInterface() {}
|
||||
virtual void registerSliderFloatParameter(SliderParams& params)=0;
|
||||
virtual void registerButtonParameter(ButtonParams& params)=0;
|
||||
virtual void registerComboBox(ComboBoxParams& params)=0;
|
||||
|
||||
virtual void syncParameters()=0;
|
||||
virtual void removeAllParameters()=0;
|
||||
virtual void setSliderValue(int sliderIndex, double sliderValue)=0;
|
||||
virtual void registerSliderFloatParameter(SliderParams& params) = 0;
|
||||
virtual void registerButtonParameter(ButtonParams& params) = 0;
|
||||
virtual void registerComboBox(ComboBoxParams& params) = 0;
|
||||
|
||||
virtual void syncParameters() = 0;
|
||||
virtual void removeAllParameters() = 0;
|
||||
virtual void setSliderValue(int sliderIndex, double sliderValue) = 0;
|
||||
};
|
||||
|
||||
#endif //PARAM_INTERFACE_H
|
||||
|
||||
#endif //PARAM_INTERFACE_H
|
||||
|
||||
@@ -9,9 +9,9 @@ enum
|
||||
B3_GL_POINTS
|
||||
};
|
||||
|
||||
enum
|
||||
enum
|
||||
{
|
||||
B3_DEFAULT_RENDERMODE=1,
|
||||
B3_DEFAULT_RENDERMODE = 1,
|
||||
//B3_WIREFRAME_RENDERMODE,
|
||||
B3_CREATE_SHADOWMAP_RENDERMODE,
|
||||
B3_USE_SHADOWMAP_RENDERMODE,
|
||||
@@ -20,120 +20,117 @@ enum
|
||||
B3_USE_PROJECTIVE_TEXTURE_RENDERMODE,
|
||||
};
|
||||
|
||||
|
||||
struct GfxVertexFormat0
|
||||
{
|
||||
float x,y,z,w;
|
||||
float unused0,unused1,unused2,unused3;
|
||||
float u,v;
|
||||
float x, y, z, w;
|
||||
float unused0, unused1, unused2, unused3;
|
||||
float u, v;
|
||||
};
|
||||
|
||||
struct GfxVertexFormat1
|
||||
{
|
||||
float x,y,z,w;
|
||||
float nx,ny,nz;
|
||||
float u,v;
|
||||
float x, y, z, w;
|
||||
float nx, ny, nz;
|
||||
float u, v;
|
||||
};
|
||||
|
||||
|
||||
struct CommonRenderInterface
|
||||
{
|
||||
virtual ~CommonRenderInterface() {}
|
||||
virtual void init()=0;
|
||||
virtual void updateCamera(int upAxis)=0;
|
||||
virtual void init() = 0;
|
||||
virtual void updateCamera(int upAxis) = 0;
|
||||
virtual void removeAllInstances() = 0;
|
||||
virtual void removeGraphicsInstance(int instanceUid) = 0;
|
||||
|
||||
virtual const CommonCameraInterface* getActiveCamera() const =0;
|
||||
virtual CommonCameraInterface* getActiveCamera()=0;
|
||||
virtual void setActiveCamera(CommonCameraInterface* cam)=0;
|
||||
|
||||
virtual const CommonCameraInterface* getActiveCamera() const = 0;
|
||||
virtual CommonCameraInterface* getActiveCamera() = 0;
|
||||
virtual void setActiveCamera(CommonCameraInterface* cam) = 0;
|
||||
|
||||
virtual void setLightPosition(const float lightPos[3]) = 0;
|
||||
virtual void setLightPosition(const double lightPos[3]) = 0;
|
||||
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]){};
|
||||
virtual void setProjectiveTexture(bool useProjectiveTexture){};
|
||||
|
||||
virtual void renderScene()=0;
|
||||
virtual void renderSceneInternal(int renderMode=B3_DEFAULT_RENDERMODE){};
|
||||
virtual void renderScene() = 0;
|
||||
virtual void renderSceneInternal(int renderMode = B3_DEFAULT_RENDERMODE){};
|
||||
virtual int getScreenWidth() = 0;
|
||||
virtual int getScreenHeight() = 0;
|
||||
|
||||
virtual void resize(int width, int height) = 0;
|
||||
virtual void resize(int width, int height) = 0;
|
||||
|
||||
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)=0;
|
||||
virtual int registerGraphicsInstance(int shapeIndex, const double* position, const double* quaternion, const double* color, const double* scaling)=0;
|
||||
virtual void drawLines(const float* positions, const float color[4], int numPoints, int pointStrideInBytes, const unsigned int* indices, int numIndices, float pointDrawSize)=0;
|
||||
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) = 0;
|
||||
virtual int registerGraphicsInstance(int shapeIndex, const double* position, const double* quaternion, const double* color, const double* scaling) = 0;
|
||||
virtual void drawLines(const float* positions, const float color[4], int numPoints, int pointStrideInBytes, const unsigned int* indices, int numIndices, float pointDrawSize) = 0;
|
||||
virtual void drawLine(const float from[4], const float to[4], const float color[4], float lineWidth) = 0;
|
||||
virtual void drawLine(const double from[4], const double to[4], const double color[4], double lineWidth) = 0;
|
||||
virtual void drawPoint(const float* position, const float color[4], float pointDrawSize)=0;
|
||||
virtual void drawPoint(const double* position, const double color[4], double pointDrawSize)=0;
|
||||
virtual void drawTexturedTriangleMesh(float worldPosition[3], float worldOrientation[4], const float* vertices, int numvertices, const unsigned int* indices, int numIndices, float color[4], int textureIndex=-1, int vertexLayout=0)=0;
|
||||
virtual void drawPoint(const float* position, const float color[4], float pointDrawSize) = 0;
|
||||
virtual void drawPoint(const double* position, const double color[4], double pointDrawSize) = 0;
|
||||
virtual void drawTexturedTriangleMesh(float worldPosition[3], float worldOrientation[4], const float* vertices, int numvertices, const unsigned int* indices, int numIndices, float color[4], int textureIndex = -1, int vertexLayout = 0) = 0;
|
||||
|
||||
virtual int registerShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType=B3_GL_TRIANGLES, int textureIndex=-1)=0;
|
||||
virtual void updateShape(int shapeIndex, const float* vertices)=0;
|
||||
|
||||
virtual int registerTexture(const unsigned char* texels, int width, int height, bool flipPixelsY=true)=0;
|
||||
virtual void updateTexture(int textureIndex, const unsigned char* texels, bool flipPixelsY=true)=0;
|
||||
virtual void activateTexture(int textureIndex)=0;
|
||||
virtual int registerShape(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType = B3_GL_TRIANGLES, int textureIndex = -1) = 0;
|
||||
virtual void updateShape(int shapeIndex, const float* vertices) = 0;
|
||||
|
||||
virtual int registerTexture(const unsigned char* texels, int width, int height, bool flipPixelsY = true) = 0;
|
||||
virtual void updateTexture(int textureIndex, const unsigned char* texels, bool flipPixelsY = true) = 0;
|
||||
virtual void activateTexture(int textureIndex) = 0;
|
||||
virtual void replaceTexture(int shapeIndex, int textureIndex){};
|
||||
virtual void removeTexture(int textureIndex) = 0;
|
||||
|
||||
virtual void setPlaneReflectionShapeIndex(int index) {}
|
||||
|
||||
virtual int getShapeIndexFromInstance(int srcIndex) {return -1;}
|
||||
virtual int getShapeIndexFromInstance(int srcIndex) { return -1; }
|
||||
|
||||
virtual bool readSingleInstanceTransformToCPU(float* position, float* orientation, int srcIndex)=0;
|
||||
virtual bool readSingleInstanceTransformToCPU(float* position, float* orientation, int srcIndex) = 0;
|
||||
|
||||
virtual void writeSingleInstanceTransformToCPU(const float* position, const float* orientation, int srcIndex)=0;
|
||||
virtual void writeSingleInstanceTransformToCPU(const double* position, const double* orientation, int srcIndex)=0;
|
||||
virtual void writeSingleInstanceColorToCPU(const float* color, int srcIndex)=0;
|
||||
virtual void writeSingleInstanceColorToCPU(const double* color, int srcIndex)=0;
|
||||
virtual void writeSingleInstanceScaleToCPU(const float* scale, int srcIndex)=0;
|
||||
virtual void writeSingleInstanceScaleToCPU(const double* scale, int srcIndex)=0;
|
||||
virtual void writeSingleInstanceSpecularColorToCPU(const double* specular, int srcIndex)=0;
|
||||
virtual void writeSingleInstanceSpecularColorToCPU(const float* specular, int srcIndex)=0;
|
||||
|
||||
|
||||
virtual int getTotalNumInstances() const = 0;
|
||||
|
||||
virtual void writeTransforms()=0;
|
||||
|
||||
virtual void clearZBuffer()=0;
|
||||
virtual void writeSingleInstanceTransformToCPU(const float* position, const float* orientation, int srcIndex) = 0;
|
||||
virtual void writeSingleInstanceTransformToCPU(const double* position, const double* orientation, int srcIndex) = 0;
|
||||
virtual void writeSingleInstanceColorToCPU(const float* color, int srcIndex) = 0;
|
||||
virtual void writeSingleInstanceColorToCPU(const double* color, int srcIndex) = 0;
|
||||
virtual void writeSingleInstanceScaleToCPU(const float* scale, int srcIndex) = 0;
|
||||
virtual void writeSingleInstanceScaleToCPU(const double* scale, int srcIndex) = 0;
|
||||
virtual void writeSingleInstanceSpecularColorToCPU(const double* specular, int srcIndex) = 0;
|
||||
virtual void writeSingleInstanceSpecularColorToCPU(const float* specular, int srcIndex) = 0;
|
||||
|
||||
virtual int getTotalNumInstances() const = 0;
|
||||
|
||||
virtual void writeTransforms() = 0;
|
||||
|
||||
virtual void clearZBuffer() = 0;
|
||||
|
||||
//This is internal access to OpenGL3+ features, mainly used for OpenCL-OpenGL interop
|
||||
//Only the GLInstancingRenderer supports it, just return 0 otherwise.
|
||||
virtual struct GLInstanceRendererInternalData* getInternalData()=0;
|
||||
virtual struct GLInstanceRendererInternalData* getInternalData() = 0;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline int projectWorldCoordToScreen(T objx, T objy, T objz,
|
||||
const T modelMatrix[16],
|
||||
const T projMatrix[16],
|
||||
const int viewport[4],
|
||||
T *winx, T *winy, T *winz)
|
||||
const T modelMatrix[16],
|
||||
const T projMatrix[16],
|
||||
const int viewport[4],
|
||||
T* winx, T* winy, T* winz)
|
||||
{
|
||||
int i;
|
||||
T in2[4];
|
||||
T tmp[4];
|
||||
|
||||
in2[0]=objx;
|
||||
in2[1]=objy;
|
||||
in2[2]=objz;
|
||||
in2[3]=T(1.0);
|
||||
in2[0] = objx;
|
||||
in2[1] = objy;
|
||||
in2[2] = objz;
|
||||
in2[3] = T(1.0);
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
tmp[i] = in2[0] * modelMatrix[0*4+i] + in2[1] * modelMatrix[1*4+i] +
|
||||
in2[2] * modelMatrix[2*4+i] + in2[3] * modelMatrix[3*4+i];
|
||||
tmp[i] = in2[0] * modelMatrix[0 * 4 + i] + in2[1] * modelMatrix[1 * 4 + i] +
|
||||
in2[2] * modelMatrix[2 * 4 + i] + in2[3] * modelMatrix[3 * 4 + i];
|
||||
}
|
||||
|
||||
T out[4];
|
||||
for (i=0; i<4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
out[i] = tmp[0] * projMatrix[0*4+i] + tmp[1] * projMatrix[1*4+i] + tmp[2] * projMatrix[2*4+i] + tmp[3] * projMatrix[3*4+i];
|
||||
out[i] = tmp[0] * projMatrix[0 * 4 + i] + tmp[1] * projMatrix[1 * 4 + i] + tmp[2] * projMatrix[2 * 4 + i] + tmp[3] * projMatrix[3 * 4 + i];
|
||||
}
|
||||
|
||||
if (out[3] == T(0.0))
|
||||
if (out[3] == T(0.0))
|
||||
return 0;
|
||||
out[0] /= out[3];
|
||||
out[1] /= out[3];
|
||||
@@ -147,11 +144,10 @@ inline int projectWorldCoordToScreen(T objx, T objy, T objz,
|
||||
out[0] = out[0] * viewport[2] + viewport[0];
|
||||
out[1] = out[1] * viewport[3] + viewport[1];
|
||||
|
||||
*winx=out[0];
|
||||
*winy=out[1];
|
||||
*winz=out[2];
|
||||
*winx = out[0];
|
||||
*winy = out[1];
|
||||
*winz = out[2];
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif//COMMON_RENDER_INTERFACE_H
|
||||
|
||||
#endif //COMMON_RENDER_INTERFACE_H
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#ifndef COMMON_RIGID_BODY_BASE_H
|
||||
#define COMMON_RIGID_BODY_BASE_H
|
||||
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "CommonExampleInterface.h"
|
||||
#include "CommonGUIHelperInterface.h"
|
||||
@@ -14,40 +13,39 @@
|
||||
|
||||
struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
{
|
||||
//keep the collision shapes, for deletion/cleanup
|
||||
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||
btBroadphaseInterface* m_broadphase;
|
||||
btCollisionDispatcher* m_dispatcher;
|
||||
btConstraintSolver* m_solver;
|
||||
//keep the collision shapes, for deletion/cleanup
|
||||
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||
btBroadphaseInterface* m_broadphase;
|
||||
btCollisionDispatcher* m_dispatcher;
|
||||
btConstraintSolver* m_solver;
|
||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||
btDiscreteDynamicsWorld* m_dynamicsWorld;
|
||||
|
||||
//data for picking objects
|
||||
class btRigidBody* m_pickedBody;
|
||||
class btRigidBody* m_pickedBody;
|
||||
class btTypedConstraint* m_pickedConstraint;
|
||||
int m_savedState;
|
||||
int m_savedState;
|
||||
btVector3 m_oldPickingPos;
|
||||
btVector3 m_hitPos;
|
||||
btScalar m_oldPickingDist;
|
||||
struct GUIHelperInterface* m_guiHelper;
|
||||
|
||||
CommonRigidBodyBase(struct GUIHelperInterface* helper)
|
||||
:m_broadphase(0),
|
||||
m_dispatcher(0),
|
||||
m_solver(0),
|
||||
m_collisionConfiguration(0),
|
||||
m_dynamicsWorld(0),
|
||||
m_pickedBody(0),
|
||||
m_pickedConstraint(0),
|
||||
m_guiHelper(helper)
|
||||
: m_broadphase(0),
|
||||
m_dispatcher(0),
|
||||
m_solver(0),
|
||||
m_collisionConfiguration(0),
|
||||
m_dynamicsWorld(0),
|
||||
m_pickedBody(0),
|
||||
m_pickedConstraint(0),
|
||||
m_guiHelper(helper)
|
||||
{
|
||||
}
|
||||
virtual ~CommonRigidBodyBase()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
btDiscreteDynamicsWorld* getDynamicsWorld()
|
||||
btDiscreteDynamicsWorld* getDynamicsWorld()
|
||||
{
|
||||
return m_dynamicsWorld;
|
||||
}
|
||||
@@ -59,7 +57,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
//m_collisionConfiguration->setConvexConvexMultipointIterations();
|
||||
|
||||
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||
|
||||
m_broadphase = new btDbvtBroadphase();
|
||||
|
||||
@@ -72,7 +70,6 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
m_dynamicsWorld->setGravity(btVector3(0, -10, 0));
|
||||
}
|
||||
|
||||
|
||||
virtual void stepSimulation(float deltaTime)
|
||||
{
|
||||
if (m_dynamicsWorld)
|
||||
@@ -96,15 +93,14 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
//cleanup in the reverse order of creation/initialization
|
||||
|
||||
//remove the rigidbodies from the dynamics world and delete them
|
||||
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
|
||||
int i;
|
||||
for (i = m_dynamicsWorld->getNumConstraints() - 1; i >= 0; i--)
|
||||
{
|
||||
m_dynamicsWorld->removeConstraint(m_dynamicsWorld->getConstraint(i));
|
||||
}
|
||||
int i;
|
||||
for (i = m_dynamicsWorld->getNumConstraints() - 1; i >= 0; i--)
|
||||
{
|
||||
m_dynamicsWorld->removeConstraint(m_dynamicsWorld->getConstraint(i));
|
||||
}
|
||||
for (i = m_dynamicsWorld->getNumCollisionObjects() - 1; i >= 0; i--)
|
||||
{
|
||||
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
|
||||
@@ -118,7 +114,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
}
|
||||
}
|
||||
//delete collision shapes
|
||||
for (int j = 0; j<m_collisionShapes.size(); j++)
|
||||
for (int j = 0; j < m_collisionShapes.size(); j++)
|
||||
{
|
||||
btCollisionShape* shape = m_collisionShapes[j];
|
||||
delete shape;
|
||||
@@ -126,84 +122,80 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
m_collisionShapes.clear();
|
||||
|
||||
delete m_dynamicsWorld;
|
||||
m_dynamicsWorld=0;
|
||||
m_dynamicsWorld = 0;
|
||||
|
||||
delete m_solver;
|
||||
m_solver=0;
|
||||
m_solver = 0;
|
||||
|
||||
delete m_broadphase;
|
||||
m_broadphase=0;
|
||||
m_broadphase = 0;
|
||||
|
||||
delete m_dispatcher;
|
||||
m_dispatcher=0;
|
||||
m_dispatcher = 0;
|
||||
|
||||
delete m_collisionConfiguration;
|
||||
m_collisionConfiguration=0;
|
||||
m_collisionConfiguration = 0;
|
||||
}
|
||||
|
||||
|
||||
virtual void debugDraw(int debugDrawFlags)
|
||||
{
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
virtual void debugDraw(int debugDrawFlags)
|
||||
{
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
if (m_dynamicsWorld->getDebugDrawer())
|
||||
{
|
||||
m_dynamicsWorld->getDebugDrawer()->setDebugMode(debugDrawFlags);
|
||||
}
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
}
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
virtual bool keyboardCallback(int key, int state)
|
||||
virtual bool keyboardCallback(int key, int state)
|
||||
{
|
||||
if ((key==B3G_F3) && state && m_dynamicsWorld)
|
||||
if ((key == B3G_F3) && state && m_dynamicsWorld)
|
||||
{
|
||||
btDefaultSerializer* serializer = new btDefaultSerializer();
|
||||
btDefaultSerializer* serializer = new btDefaultSerializer();
|
||||
m_dynamicsWorld->serialize(serializer);
|
||||
|
||||
FILE* file = fopen("testFile.bullet","wb");
|
||||
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
|
||||
FILE* file = fopen("testFile.bullet", "wb");
|
||||
fwrite(serializer->getBufferPointer(), serializer->getCurrentBufferSize(), 1, file);
|
||||
fclose(file);
|
||||
//b3Printf("btDefaultSerializer wrote testFile.bullet");
|
||||
delete serializer;
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;//don't handle this key
|
||||
return false; //don't handle this key
|
||||
}
|
||||
|
||||
|
||||
btVector3 getRayTo(int x,int y)
|
||||
btVector3 getRayTo(int x, int y)
|
||||
{
|
||||
CommonRenderInterface* renderer = m_guiHelper->getRenderInterface();
|
||||
|
||||
|
||||
if (!renderer)
|
||||
{
|
||||
btAssert(0);
|
||||
return btVector3(0,0,0);
|
||||
return btVector3(0, 0, 0);
|
||||
}
|
||||
|
||||
float top = 1.f;
|
||||
float bottom = -1.f;
|
||||
float nearPlane = 1.f;
|
||||
float tanFov = (top-bottom)*0.5f / nearPlane;
|
||||
float tanFov = (top - bottom) * 0.5f / nearPlane;
|
||||
float fov = btScalar(2.0) * btAtan(tanFov);
|
||||
|
||||
btVector3 camPos,camTarget;
|
||||
|
||||
btVector3 camPos, camTarget;
|
||||
|
||||
renderer->getActiveCamera()->getCameraPosition(camPos);
|
||||
renderer->getActiveCamera()->getCameraTargetPosition(camTarget);
|
||||
|
||||
btVector3 rayFrom = camPos;
|
||||
btVector3 rayForward = (camTarget-camPos);
|
||||
btVector3 rayFrom = camPos;
|
||||
btVector3 rayForward = (camTarget - camPos);
|
||||
rayForward.normalize();
|
||||
float farPlane = 10000.f;
|
||||
rayForward*= farPlane;
|
||||
rayForward *= farPlane;
|
||||
|
||||
btVector3 rightOffset;
|
||||
btVector3 cameraUp=btVector3(0,0,0);
|
||||
cameraUp[m_guiHelper->getAppInterface()->getUpAxis()]=1;
|
||||
btVector3 cameraUp = btVector3(0, 0, 0);
|
||||
cameraUp[m_guiHelper->getAppInterface()->getUpAxis()] = 1;
|
||||
|
||||
btVector3 vertical = cameraUp;
|
||||
|
||||
@@ -213,25 +205,22 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
vertical = hor.cross(rayForward);
|
||||
vertical.safeNormalize();
|
||||
|
||||
float tanfov = tanf(0.5f*fov);
|
||||
|
||||
float tanfov = tanf(0.5f * fov);
|
||||
|
||||
hor *= 2.f * farPlane * tanfov;
|
||||
vertical *= 2.f * farPlane * tanfov;
|
||||
|
||||
btScalar aspect;
|
||||
float width = float(renderer->getScreenWidth());
|
||||
float height = float (renderer->getScreenHeight());
|
||||
float height = float(renderer->getScreenHeight());
|
||||
|
||||
aspect = width / height;
|
||||
|
||||
hor*=aspect;
|
||||
aspect = width / height;
|
||||
|
||||
hor *= aspect;
|
||||
|
||||
btVector3 rayToCenter = rayFrom + rayForward;
|
||||
btVector3 dHor = hor * 1.f/width;
|
||||
btVector3 dVert = vertical * 1.f/height;
|
||||
|
||||
btVector3 dHor = hor * 1.f / width;
|
||||
btVector3 dVert = vertical * 1.f / height;
|
||||
|
||||
btVector3 rayTo = rayToCenter - 0.5f * hor + 0.5f * vertical;
|
||||
rayTo += btScalar(x) * dHor;
|
||||
@@ -239,10 +228,10 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
return rayTo;
|
||||
}
|
||||
|
||||
virtual bool mouseMoveCallback(float x,float y)
|
||||
virtual bool mouseMoveCallback(float x, float y)
|
||||
{
|
||||
CommonRenderInterface* renderer = m_guiHelper->getRenderInterface();
|
||||
|
||||
|
||||
if (!renderer)
|
||||
{
|
||||
btAssert(0);
|
||||
@@ -252,21 +241,21 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
btVector3 rayTo = getRayTo(int(x), int(y));
|
||||
btVector3 rayFrom;
|
||||
renderer->getActiveCamera()->getCameraPosition(rayFrom);
|
||||
movePickedBody(rayFrom,rayTo);
|
||||
movePickedBody(rayFrom, rayTo);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
CommonRenderInterface* renderer = m_guiHelper->getRenderInterface();
|
||||
|
||||
|
||||
if (!renderer)
|
||||
{
|
||||
btAssert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CommonWindowInterface* window = m_guiHelper->getAppInterface()->m_window;
|
||||
|
||||
#if 0
|
||||
@@ -294,25 +283,23 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
printf("NO CONTROL pressed\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (state==1)
|
||||
|
||||
if (state == 1)
|
||||
{
|
||||
if(button==0 && (!window->isModifierKeyPressed(B3G_ALT) && !window->isModifierKeyPressed(B3G_CONTROL) ))
|
||||
if (button == 0 && (!window->isModifierKeyPressed(B3G_ALT) && !window->isModifierKeyPressed(B3G_CONTROL)))
|
||||
{
|
||||
btVector3 camPos;
|
||||
renderer->getActiveCamera()->getCameraPosition(camPos);
|
||||
|
||||
btVector3 rayFrom = camPos;
|
||||
btVector3 rayTo = getRayTo(int(x),int(y));
|
||||
btVector3 rayTo = getRayTo(int(x), int(y));
|
||||
|
||||
pickBody(rayFrom, rayTo);
|
||||
|
||||
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (button==0)
|
||||
if (button == 0)
|
||||
{
|
||||
removePickingConstraint();
|
||||
//remove p2p
|
||||
@@ -323,10 +310,9 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
virtual bool pickBody(const btVector3& rayFromWorld, const btVector3& rayToWorld)
|
||||
{
|
||||
if (m_dynamicsWorld==0)
|
||||
if (m_dynamicsWorld == 0)
|
||||
return false;
|
||||
|
||||
btCollisionWorld::ClosestRayResultCallback rayCallback(rayFromWorld, rayToWorld);
|
||||
@@ -334,7 +320,6 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
m_dynamicsWorld->rayTest(rayFromWorld, rayToWorld, rayCallback);
|
||||
if (rayCallback.hasHit())
|
||||
{
|
||||
|
||||
btVector3 pickPos = rayCallback.m_hitPointWorld;
|
||||
btRigidBody* body = (btRigidBody*)btRigidBody::upcast(rayCallback.m_collisionObject);
|
||||
if (body)
|
||||
@@ -357,7 +342,6 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// pickObject(pickPos, rayCallback.m_collisionObject);
|
||||
m_oldPickingPos = rayToWorld;
|
||||
m_hitPos = pickPos;
|
||||
@@ -369,7 +353,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
}
|
||||
virtual bool movePickedBody(const btVector3& rayFromWorld, const btVector3& rayToWorld)
|
||||
{
|
||||
if (m_pickedBody && m_pickedConstraint)
|
||||
if (m_pickedBody && m_pickedConstraint)
|
||||
{
|
||||
btPoint2PointConstraint* pickCon = static_cast<btPoint2PointConstraint*>(m_pickedConstraint);
|
||||
if (pickCon)
|
||||
@@ -402,8 +386,6 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
btBoxShape* createBoxShape(const btVector3& halfExtents)
|
||||
{
|
||||
btBoxShape* box = new btBoxShape(halfExtents);
|
||||
@@ -419,10 +401,9 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
btMotionState* ms = body->getMotionState();
|
||||
delete body;
|
||||
delete ms;
|
||||
|
||||
}
|
||||
|
||||
btRigidBody* createRigidBody(float mass, const btTransform& startTransform, btCollisionShape* shape, const btVector4& color = btVector4(1, 0, 0, 1))
|
||||
btRigidBody* createRigidBody(float mass, const btTransform& startTransform, btCollisionShape* shape, const btVector4& color = btVector4(1, 0, 0, 1))
|
||||
{
|
||||
btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE));
|
||||
|
||||
@@ -433,7 +414,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
if (isDynamic)
|
||||
shape->calculateLocalInertia(mass, localInertia);
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
|
||||
#define USE_MOTIONSTATE 1
|
||||
#ifdef USE_MOTIONSTATE
|
||||
@@ -447,28 +428,23 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
#else
|
||||
btRigidBody* body = new btRigidBody(mass, 0, shape, localInertia);
|
||||
body->setWorldTransform(startTransform);
|
||||
#endif//
|
||||
#endif //
|
||||
|
||||
body->setUserIndex(-1);
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void renderScene()
|
||||
{
|
||||
{
|
||||
|
||||
m_guiHelper->syncPhysicsToGraphics(m_dynamicsWorld);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
|
||||
m_guiHelper->render(m_dynamicsWorld);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif //COMMON_RIGID_BODY_SETUP_H
|
||||
|
||||
#endif //COMMON_RIGID_BODY_SETUP_H
|
||||
|
||||
@@ -3,91 +3,86 @@
|
||||
|
||||
#include "CommonCallbacks.h"
|
||||
|
||||
|
||||
struct b3gWindowConstructionInfo
|
||||
{
|
||||
int m_width;
|
||||
int m_height;
|
||||
bool m_fullscreen;
|
||||
int m_colorBitsPerPixel;
|
||||
void* m_windowHandle;
|
||||
const char* m_title;
|
||||
int m_openglVersion;
|
||||
int m_renderDevice;
|
||||
|
||||
int m_width;
|
||||
int m_height;
|
||||
bool m_fullscreen;
|
||||
int m_colorBitsPerPixel;
|
||||
void* m_windowHandle;
|
||||
const char* m_title;
|
||||
int m_openglVersion;
|
||||
int m_renderDevice;
|
||||
|
||||
b3gWindowConstructionInfo(int width=1024, int height=768)
|
||||
:m_width(width),
|
||||
m_height(height),
|
||||
m_fullscreen(false),
|
||||
m_colorBitsPerPixel(32),
|
||||
m_windowHandle(0),
|
||||
m_title("title"),
|
||||
m_openglVersion(3),
|
||||
m_renderDevice(-1)
|
||||
{
|
||||
}
|
||||
b3gWindowConstructionInfo(int width = 1024, int height = 768)
|
||||
: m_width(width),
|
||||
m_height(height),
|
||||
m_fullscreen(false),
|
||||
m_colorBitsPerPixel(32),
|
||||
m_windowHandle(0),
|
||||
m_title("title"),
|
||||
m_openglVersion(3),
|
||||
m_renderDevice(-1)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CommonWindowInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~CommonWindowInterface()
|
||||
{
|
||||
}
|
||||
public:
|
||||
virtual ~CommonWindowInterface()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void createDefaultWindow(int width, int height, const char* title)
|
||||
{
|
||||
b3gWindowConstructionInfo ci(width,height);
|
||||
ci.m_title = title;
|
||||
createWindow(ci);
|
||||
}
|
||||
virtual void createDefaultWindow(int width, int height, const char* title)
|
||||
{
|
||||
b3gWindowConstructionInfo ci(width, height);
|
||||
ci.m_title = title;
|
||||
createWindow(ci);
|
||||
}
|
||||
|
||||
virtual void createWindow(const b3gWindowConstructionInfo& ci)=0;
|
||||
|
||||
virtual void closeWindow()=0;
|
||||
virtual void createWindow(const b3gWindowConstructionInfo& ci) = 0;
|
||||
|
||||
virtual void runMainLoop()=0;
|
||||
virtual float getTimeInSeconds()=0;
|
||||
virtual void closeWindow() = 0;
|
||||
|
||||
virtual bool requestedExit() const = 0;
|
||||
virtual void setRequestExit() = 0;
|
||||
virtual void runMainLoop() = 0;
|
||||
virtual float getTimeInSeconds() = 0;
|
||||
|
||||
virtual void startRendering()=0;
|
||||
virtual bool requestedExit() const = 0;
|
||||
virtual void setRequestExit() = 0;
|
||||
|
||||
virtual void endRendering()=0;
|
||||
virtual void startRendering() = 0;
|
||||
|
||||
virtual bool isModifierKeyPressed(int key) = 0;
|
||||
|
||||
virtual void setMouseMoveCallback(b3MouseMoveCallback mouseCallback)=0;
|
||||
virtual b3MouseMoveCallback getMouseMoveCallback()=0;
|
||||
|
||||
virtual void setMouseButtonCallback(b3MouseButtonCallback mouseCallback)=0;
|
||||
virtual b3MouseButtonCallback getMouseButtonCallback()=0;
|
||||
virtual void endRendering() = 0;
|
||||
|
||||
virtual void setResizeCallback(b3ResizeCallback resizeCallback)=0;
|
||||
virtual b3ResizeCallback getResizeCallback()=0;
|
||||
|
||||
virtual void setWheelCallback(b3WheelCallback wheelCallback)=0;
|
||||
virtual b3WheelCallback getWheelCallback()=0;
|
||||
|
||||
virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback)=0;
|
||||
virtual b3KeyboardCallback getKeyboardCallback()=0;
|
||||
virtual bool isModifierKeyPressed(int key) = 0;
|
||||
|
||||
virtual void setRenderCallback( b3RenderCallback renderCallback) = 0;
|
||||
|
||||
virtual void setWindowTitle(const char* title)=0;
|
||||
virtual void setMouseMoveCallback(b3MouseMoveCallback mouseCallback) = 0;
|
||||
virtual b3MouseMoveCallback getMouseMoveCallback() = 0;
|
||||
|
||||
virtual float getRetinaScale() const =0;
|
||||
virtual void setAllowRetina(bool allow) =0;
|
||||
virtual void setMouseButtonCallback(b3MouseButtonCallback mouseCallback) = 0;
|
||||
virtual b3MouseButtonCallback getMouseButtonCallback() = 0;
|
||||
|
||||
virtual int getWidth() const = 0;
|
||||
virtual int getHeight() const = 0;
|
||||
virtual void setResizeCallback(b3ResizeCallback resizeCallback) = 0;
|
||||
virtual b3ResizeCallback getResizeCallback() = 0;
|
||||
|
||||
virtual int fileOpenDialog(char* fileName, int maxFileNameLength) = 0;
|
||||
|
||||
virtual void setWheelCallback(b3WheelCallback wheelCallback) = 0;
|
||||
virtual b3WheelCallback getWheelCallback() = 0;
|
||||
|
||||
virtual void setKeyboardCallback(b3KeyboardCallback keyboardCallback) = 0;
|
||||
virtual b3KeyboardCallback getKeyboardCallback() = 0;
|
||||
|
||||
virtual void setRenderCallback(b3RenderCallback renderCallback) = 0;
|
||||
|
||||
virtual void setWindowTitle(const char* title) = 0;
|
||||
|
||||
virtual float getRetinaScale() const = 0;
|
||||
virtual void setAllowRetina(bool allow) = 0;
|
||||
|
||||
virtual int getWidth() const = 0;
|
||||
virtual int getHeight() const = 0;
|
||||
|
||||
virtual int fileOpenDialog(char* fileName, int maxFileNameLength) = 0;
|
||||
};
|
||||
|
||||
#endif //B3G_WINDOW_INTERFACE_H
|
||||
#endif //B3G_WINDOW_INTERFACE_H
|
||||
|
||||
Reference in New Issue
Block a user