fix: some file didn't have the svn:eol-style native yet
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,246 +1,246 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef DEMO_APPLICATION_H
|
||||
#define DEMO_APPLICATION_H
|
||||
|
||||
|
||||
#include "GlutStuff.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "LinearMath/btMatrix3x3.h"
|
||||
#include "LinearMath/btTransform.h"
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
class btCollisionShape;
|
||||
class btDynamicsWorld;
|
||||
class btRigidBody;
|
||||
class btTypedConstraint;
|
||||
|
||||
|
||||
|
||||
class DemoApplication
|
||||
{
|
||||
void displayProfileString(int xOffset,int yStart,char* message);
|
||||
class CProfileIterator* m_profileIterator;
|
||||
|
||||
protected:
|
||||
#ifdef USE_BT_CLOCK
|
||||
btClock m_clock;
|
||||
#endif //USE_BT_CLOCK
|
||||
|
||||
///this is the most important class
|
||||
btDynamicsWorld* m_dynamicsWorld;
|
||||
|
||||
///constraint for mouse picking
|
||||
btTypedConstraint* m_pickConstraint;
|
||||
|
||||
btCollisionShape* m_shootBoxShape;
|
||||
|
||||
float m_cameraDistance;
|
||||
int m_debugMode;
|
||||
|
||||
float m_ele;
|
||||
float m_azi;
|
||||
btVector3 m_cameraPosition;
|
||||
btVector3 m_cameraTargetPosition;//look at
|
||||
|
||||
int m_mouseOldX;
|
||||
int m_mouseOldY;
|
||||
int m_mouseButtons;
|
||||
public:
|
||||
int m_modifierKeys;
|
||||
protected:
|
||||
|
||||
float m_scaleBottom;
|
||||
float m_scaleFactor;
|
||||
btVector3 m_cameraUp;
|
||||
int m_forwardAxis;
|
||||
|
||||
int m_glutScreenWidth;
|
||||
int m_glutScreenHeight;
|
||||
|
||||
int m_ortho;
|
||||
|
||||
float m_ShootBoxInitialSpeed;
|
||||
|
||||
bool m_stepping;
|
||||
bool m_singleStep;
|
||||
bool m_idle;
|
||||
int m_lastKey;
|
||||
|
||||
void showProfileInfo(int& xOffset,int& yStart, int yIncr);
|
||||
void renderscene(int pass);
|
||||
|
||||
GL_ShapeDrawer* m_shapeDrawer;
|
||||
bool m_enableshadows;
|
||||
btVector3 m_sundirection;
|
||||
btScalar m_defaultContactProcessingThreshold;
|
||||
|
||||
public:
|
||||
|
||||
DemoApplication();
|
||||
|
||||
virtual ~DemoApplication();
|
||||
|
||||
btDynamicsWorld* getDynamicsWorld()
|
||||
{
|
||||
return m_dynamicsWorld;
|
||||
}
|
||||
|
||||
virtual void initPhysics() = 0;
|
||||
|
||||
virtual void setDrawClusters(bool drawClusters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void overrideGLShapeDrawer (GL_ShapeDrawer* shapeDrawer);
|
||||
|
||||
void setOrthographicProjection();
|
||||
void resetPerspectiveProjection();
|
||||
|
||||
bool setTexturing(bool enable) { return(m_shapeDrawer->enableTexture(enable)); }
|
||||
bool setShadows(bool enable) { bool p=m_enableshadows;m_enableshadows=enable;return(p); }
|
||||
bool getTexturing() const
|
||||
{
|
||||
return m_shapeDrawer->hasTextureEnabled();
|
||||
}
|
||||
bool getShadows() const
|
||||
{
|
||||
return m_enableshadows;
|
||||
}
|
||||
|
||||
|
||||
int getDebugMode()
|
||||
{
|
||||
return m_debugMode ;
|
||||
}
|
||||
|
||||
void setDebugMode(int mode);
|
||||
|
||||
void setAzi(float azi)
|
||||
{
|
||||
m_azi = azi;
|
||||
}
|
||||
|
||||
void setCameraUp(const btVector3& camUp)
|
||||
{
|
||||
m_cameraUp = camUp;
|
||||
}
|
||||
void setCameraForwardAxis(int axis)
|
||||
{
|
||||
m_forwardAxis = axis;
|
||||
}
|
||||
|
||||
virtual void myinit();
|
||||
|
||||
void toggleIdle();
|
||||
|
||||
virtual void updateCamera();
|
||||
|
||||
btVector3 getCameraPosition()
|
||||
{
|
||||
return m_cameraPosition;
|
||||
}
|
||||
btVector3 getCameraTargetPosition()
|
||||
{
|
||||
return m_cameraTargetPosition;
|
||||
}
|
||||
|
||||
btScalar getDeltaTimeMicroseconds()
|
||||
{
|
||||
#ifdef USE_BT_CLOCK
|
||||
btScalar dt = (btScalar)m_clock.getTimeMicroseconds();
|
||||
m_clock.reset();
|
||||
return dt;
|
||||
#else
|
||||
return btScalar(16666.);
|
||||
#endif
|
||||
}
|
||||
|
||||
///glut callbacks
|
||||
|
||||
float getCameraDistance();
|
||||
void setCameraDistance(float dist);
|
||||
void moveAndDisplay();
|
||||
|
||||
virtual void clientMoveAndDisplay() = 0;
|
||||
|
||||
virtual void clientResetScene();
|
||||
|
||||
///Demo functions
|
||||
virtual void setShootBoxShape ();
|
||||
virtual void shootBox(const btVector3& destination);
|
||||
|
||||
|
||||
btVector3 getRayTo(int x,int y);
|
||||
|
||||
btRigidBody* localCreateRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape);
|
||||
|
||||
///callback methods by glut
|
||||
|
||||
virtual void keyboardCallback(unsigned char key, int x, int y);
|
||||
|
||||
virtual void keyboardUpCallback(unsigned char key, int x, int y) {}
|
||||
|
||||
virtual void specialKeyboard(int key, int x, int y){}
|
||||
|
||||
virtual void specialKeyboardUp(int key, int x, int y){}
|
||||
|
||||
virtual void reshape(int w, int h);
|
||||
|
||||
virtual void mouseFunc(int button, int state, int x, int y);
|
||||
|
||||
virtual void mouseMotionFunc(int x,int y);
|
||||
|
||||
virtual void displayCallback();
|
||||
|
||||
virtual void renderme();
|
||||
|
||||
virtual void swapBuffers() = 0;
|
||||
|
||||
virtual void updateModifierKeys() = 0;
|
||||
|
||||
void stepLeft();
|
||||
void stepRight();
|
||||
void stepFront();
|
||||
void stepBack();
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
bool isIdle() const
|
||||
{
|
||||
return m_idle;
|
||||
}
|
||||
|
||||
void setIdle(bool idle)
|
||||
{
|
||||
m_idle = idle;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //DEMO_APPLICATION_H
|
||||
|
||||
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef DEMO_APPLICATION_H
|
||||
#define DEMO_APPLICATION_H
|
||||
|
||||
|
||||
#include "GlutStuff.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "LinearMath/btMatrix3x3.h"
|
||||
#include "LinearMath/btTransform.h"
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
class btCollisionShape;
|
||||
class btDynamicsWorld;
|
||||
class btRigidBody;
|
||||
class btTypedConstraint;
|
||||
|
||||
|
||||
|
||||
class DemoApplication
|
||||
{
|
||||
void displayProfileString(int xOffset,int yStart,char* message);
|
||||
class CProfileIterator* m_profileIterator;
|
||||
|
||||
protected:
|
||||
#ifdef USE_BT_CLOCK
|
||||
btClock m_clock;
|
||||
#endif //USE_BT_CLOCK
|
||||
|
||||
///this is the most important class
|
||||
btDynamicsWorld* m_dynamicsWorld;
|
||||
|
||||
///constraint for mouse picking
|
||||
btTypedConstraint* m_pickConstraint;
|
||||
|
||||
btCollisionShape* m_shootBoxShape;
|
||||
|
||||
float m_cameraDistance;
|
||||
int m_debugMode;
|
||||
|
||||
float m_ele;
|
||||
float m_azi;
|
||||
btVector3 m_cameraPosition;
|
||||
btVector3 m_cameraTargetPosition;//look at
|
||||
|
||||
int m_mouseOldX;
|
||||
int m_mouseOldY;
|
||||
int m_mouseButtons;
|
||||
public:
|
||||
int m_modifierKeys;
|
||||
protected:
|
||||
|
||||
float m_scaleBottom;
|
||||
float m_scaleFactor;
|
||||
btVector3 m_cameraUp;
|
||||
int m_forwardAxis;
|
||||
|
||||
int m_glutScreenWidth;
|
||||
int m_glutScreenHeight;
|
||||
|
||||
int m_ortho;
|
||||
|
||||
float m_ShootBoxInitialSpeed;
|
||||
|
||||
bool m_stepping;
|
||||
bool m_singleStep;
|
||||
bool m_idle;
|
||||
int m_lastKey;
|
||||
|
||||
void showProfileInfo(int& xOffset,int& yStart, int yIncr);
|
||||
void renderscene(int pass);
|
||||
|
||||
GL_ShapeDrawer* m_shapeDrawer;
|
||||
bool m_enableshadows;
|
||||
btVector3 m_sundirection;
|
||||
btScalar m_defaultContactProcessingThreshold;
|
||||
|
||||
public:
|
||||
|
||||
DemoApplication();
|
||||
|
||||
virtual ~DemoApplication();
|
||||
|
||||
btDynamicsWorld* getDynamicsWorld()
|
||||
{
|
||||
return m_dynamicsWorld;
|
||||
}
|
||||
|
||||
virtual void initPhysics() = 0;
|
||||
|
||||
virtual void setDrawClusters(bool drawClusters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void overrideGLShapeDrawer (GL_ShapeDrawer* shapeDrawer);
|
||||
|
||||
void setOrthographicProjection();
|
||||
void resetPerspectiveProjection();
|
||||
|
||||
bool setTexturing(bool enable) { return(m_shapeDrawer->enableTexture(enable)); }
|
||||
bool setShadows(bool enable) { bool p=m_enableshadows;m_enableshadows=enable;return(p); }
|
||||
bool getTexturing() const
|
||||
{
|
||||
return m_shapeDrawer->hasTextureEnabled();
|
||||
}
|
||||
bool getShadows() const
|
||||
{
|
||||
return m_enableshadows;
|
||||
}
|
||||
|
||||
|
||||
int getDebugMode()
|
||||
{
|
||||
return m_debugMode ;
|
||||
}
|
||||
|
||||
void setDebugMode(int mode);
|
||||
|
||||
void setAzi(float azi)
|
||||
{
|
||||
m_azi = azi;
|
||||
}
|
||||
|
||||
void setCameraUp(const btVector3& camUp)
|
||||
{
|
||||
m_cameraUp = camUp;
|
||||
}
|
||||
void setCameraForwardAxis(int axis)
|
||||
{
|
||||
m_forwardAxis = axis;
|
||||
}
|
||||
|
||||
virtual void myinit();
|
||||
|
||||
void toggleIdle();
|
||||
|
||||
virtual void updateCamera();
|
||||
|
||||
btVector3 getCameraPosition()
|
||||
{
|
||||
return m_cameraPosition;
|
||||
}
|
||||
btVector3 getCameraTargetPosition()
|
||||
{
|
||||
return m_cameraTargetPosition;
|
||||
}
|
||||
|
||||
btScalar getDeltaTimeMicroseconds()
|
||||
{
|
||||
#ifdef USE_BT_CLOCK
|
||||
btScalar dt = (btScalar)m_clock.getTimeMicroseconds();
|
||||
m_clock.reset();
|
||||
return dt;
|
||||
#else
|
||||
return btScalar(16666.);
|
||||
#endif
|
||||
}
|
||||
|
||||
///glut callbacks
|
||||
|
||||
float getCameraDistance();
|
||||
void setCameraDistance(float dist);
|
||||
void moveAndDisplay();
|
||||
|
||||
virtual void clientMoveAndDisplay() = 0;
|
||||
|
||||
virtual void clientResetScene();
|
||||
|
||||
///Demo functions
|
||||
virtual void setShootBoxShape ();
|
||||
virtual void shootBox(const btVector3& destination);
|
||||
|
||||
|
||||
btVector3 getRayTo(int x,int y);
|
||||
|
||||
btRigidBody* localCreateRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape);
|
||||
|
||||
///callback methods by glut
|
||||
|
||||
virtual void keyboardCallback(unsigned char key, int x, int y);
|
||||
|
||||
virtual void keyboardUpCallback(unsigned char key, int x, int y) {}
|
||||
|
||||
virtual void specialKeyboard(int key, int x, int y){}
|
||||
|
||||
virtual void specialKeyboardUp(int key, int x, int y){}
|
||||
|
||||
virtual void reshape(int w, int h);
|
||||
|
||||
virtual void mouseFunc(int button, int state, int x, int y);
|
||||
|
||||
virtual void mouseMotionFunc(int x,int y);
|
||||
|
||||
virtual void displayCallback();
|
||||
|
||||
virtual void renderme();
|
||||
|
||||
virtual void swapBuffers() = 0;
|
||||
|
||||
virtual void updateModifierKeys() = 0;
|
||||
|
||||
void stepLeft();
|
||||
void stepRight();
|
||||
void stepFront();
|
||||
void stepBack();
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
bool isIdle() const
|
||||
{
|
||||
return m_idle;
|
||||
}
|
||||
|
||||
void setIdle(bool idle)
|
||||
{
|
||||
m_idle = idle;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //DEMO_APPLICATION_H
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,27 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BT_DEBUG_FONT_H
|
||||
#define BT_DEBUG_FONT_H
|
||||
|
||||
#include "LinearMath/btVector3.h"
|
||||
|
||||
void GLDebugDrawStringInternal(int x,int y,const char* string,const btVector3& rgb);
|
||||
void GLDebugDrawString(int x,int y,const char* string);
|
||||
void GLDebugResetFont(int screenWidth,int screenHeight);
|
||||
|
||||
#endif //BT_DEBUG_FONT_H
|
||||
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BT_DEBUG_FONT_H
|
||||
#define BT_DEBUG_FONT_H
|
||||
|
||||
#include "LinearMath/btVector3.h"
|
||||
|
||||
void GLDebugDrawStringInternal(int x,int y,const char* string,const btVector3& rgb);
|
||||
void GLDebugDrawString(int x,int y,const char* string);
|
||||
void GLDebugResetFont(int screenWidth,int screenHeight);
|
||||
|
||||
#endif //BT_DEBUG_FONT_H
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,91 +1,91 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GL_DIALOG_DYNAMICS_WORLD_H
|
||||
#define GL_DIALOG_DYNAMICS_WORLD_H
|
||||
|
||||
class btDiscreteDynamicsWorld;
|
||||
class GL_DialogWindow;
|
||||
class btDefaultCollisionConfiguration;
|
||||
struct btDbvtBroadphase;
|
||||
class btSequentialImpulseConstraintSolver;
|
||||
class btCollisionDispatcher;
|
||||
class btVoronoiSimplexSolver;
|
||||
class btMinkowskiPenetrationDepthSolver;
|
||||
class btCollisionObject;
|
||||
class btTypedConstraint;
|
||||
struct GL_ToggleControl;
|
||||
struct GL_SliderControl;
|
||||
|
||||
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
#include "LinearMath/btVector3.h"
|
||||
|
||||
class GL_DialogDynamicsWorld
|
||||
{
|
||||
|
||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||
btDbvtBroadphase* m_broadphase;
|
||||
btSequentialImpulseConstraintSolver* m_constraintSolver;
|
||||
btCollisionDispatcher* m_dispatcher;
|
||||
btVoronoiSimplexSolver* m_simplexSolver;
|
||||
btMinkowskiPenetrationDepthSolver* m_pdSolver;
|
||||
|
||||
btDiscreteDynamicsWorld* m_dynamicsWorld;
|
||||
|
||||
btCollisionObject* m_lowerBorder;
|
||||
btCollisionObject* m_upperBorder;
|
||||
btCollisionObject* m_leftBorder;
|
||||
btCollisionObject* m_rightBorder;
|
||||
|
||||
btAlignedObjectArray<GL_DialogWindow*> m_dialogs;
|
||||
|
||||
int m_screenWidth;
|
||||
int m_screenHeight;
|
||||
|
||||
|
||||
///for picking
|
||||
int m_mouseOldX;
|
||||
int m_mouseOldY;
|
||||
int m_mouseButtons;
|
||||
///constraint for mouse picking
|
||||
btTypedConstraint* m_pickConstraint;
|
||||
|
||||
btVector3 getRayTo(int x,int y);
|
||||
|
||||
public:
|
||||
|
||||
GL_DialogDynamicsWorld();
|
||||
|
||||
virtual ~GL_DialogDynamicsWorld();
|
||||
|
||||
virtual void setScreenSize(int width, int height);
|
||||
|
||||
virtual GL_DialogWindow* createDialog(int horPos,int vertPos,int dialogWidth,int dialogHeight, const char* dialogTitle );
|
||||
|
||||
GL_ToggleControl* createToggle(GL_DialogWindow* dialog, const char* toggleText);
|
||||
|
||||
GL_SliderControl* createSlider(GL_DialogWindow* dialog, const char* sliderText);
|
||||
|
||||
virtual void draw(btScalar timeStep);
|
||||
|
||||
virtual bool mouseFunc(int button, int state, int x, int y);
|
||||
|
||||
virtual void mouseMotionFunc(int x,int y);
|
||||
|
||||
};
|
||||
|
||||
#endif //GL_DIALOG_DYNAMICS_WORLD_H
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GL_DIALOG_DYNAMICS_WORLD_H
|
||||
#define GL_DIALOG_DYNAMICS_WORLD_H
|
||||
|
||||
class btDiscreteDynamicsWorld;
|
||||
class GL_DialogWindow;
|
||||
class btDefaultCollisionConfiguration;
|
||||
struct btDbvtBroadphase;
|
||||
class btSequentialImpulseConstraintSolver;
|
||||
class btCollisionDispatcher;
|
||||
class btVoronoiSimplexSolver;
|
||||
class btMinkowskiPenetrationDepthSolver;
|
||||
class btCollisionObject;
|
||||
class btTypedConstraint;
|
||||
struct GL_ToggleControl;
|
||||
struct GL_SliderControl;
|
||||
|
||||
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
#include "LinearMath/btVector3.h"
|
||||
|
||||
class GL_DialogDynamicsWorld
|
||||
{
|
||||
|
||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||
btDbvtBroadphase* m_broadphase;
|
||||
btSequentialImpulseConstraintSolver* m_constraintSolver;
|
||||
btCollisionDispatcher* m_dispatcher;
|
||||
btVoronoiSimplexSolver* m_simplexSolver;
|
||||
btMinkowskiPenetrationDepthSolver* m_pdSolver;
|
||||
|
||||
btDiscreteDynamicsWorld* m_dynamicsWorld;
|
||||
|
||||
btCollisionObject* m_lowerBorder;
|
||||
btCollisionObject* m_upperBorder;
|
||||
btCollisionObject* m_leftBorder;
|
||||
btCollisionObject* m_rightBorder;
|
||||
|
||||
btAlignedObjectArray<GL_DialogWindow*> m_dialogs;
|
||||
|
||||
int m_screenWidth;
|
||||
int m_screenHeight;
|
||||
|
||||
|
||||
///for picking
|
||||
int m_mouseOldX;
|
||||
int m_mouseOldY;
|
||||
int m_mouseButtons;
|
||||
///constraint for mouse picking
|
||||
btTypedConstraint* m_pickConstraint;
|
||||
|
||||
btVector3 getRayTo(int x,int y);
|
||||
|
||||
public:
|
||||
|
||||
GL_DialogDynamicsWorld();
|
||||
|
||||
virtual ~GL_DialogDynamicsWorld();
|
||||
|
||||
virtual void setScreenSize(int width, int height);
|
||||
|
||||
virtual GL_DialogWindow* createDialog(int horPos,int vertPos,int dialogWidth,int dialogHeight, const char* dialogTitle );
|
||||
|
||||
GL_ToggleControl* createToggle(GL_DialogWindow* dialog, const char* toggleText);
|
||||
|
||||
GL_SliderControl* createSlider(GL_DialogWindow* dialog, const char* sliderText);
|
||||
|
||||
virtual void draw(btScalar timeStep);
|
||||
|
||||
virtual bool mouseFunc(int button, int state, int x, int y);
|
||||
|
||||
virtual void mouseMotionFunc(int x,int y);
|
||||
|
||||
};
|
||||
|
||||
#endif //GL_DIALOG_DYNAMICS_WORLD_H
|
||||
|
||||
@@ -1,336 +1,336 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "GL_DialogWindow.h"
|
||||
|
||||
|
||||
|
||||
#include "GLDebugFont.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
#define USE_ARRAYS 1
|
||||
|
||||
|
||||
GL_DialogWindow::GL_DialogWindow(int horPos,int vertPos,int dialogWidth,int dialogHeight, btCollisionObject* collisionObject,const char* dialogTitle)
|
||||
:m_dialogHorPos(horPos),
|
||||
m_dialogVertPos(vertPos),
|
||||
m_dialogWidth(dialogWidth),
|
||||
m_dialogHeight(dialogHeight),
|
||||
m_screenWidth(0),
|
||||
m_screenHeight(0),
|
||||
m_dialogTitle(dialogTitle),
|
||||
m_MaxClipPlanes(-1),
|
||||
m_collisionObject(collisionObject)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void GL_DialogWindow::setScreenSize(int width, int height)
|
||||
{
|
||||
m_screenWidth = width;
|
||||
m_screenHeight = height;
|
||||
}
|
||||
GL_DialogWindow::~GL_DialogWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void drawLine(int _X0, int _Y0, int _X1, int _Y1, unsigned int _Color0, unsigned int _Color1)
|
||||
{
|
||||
const GLfloat dx = +0.5f;
|
||||
const GLfloat dy = -0.5f;
|
||||
|
||||
GLfloat vVertices[] = {(GLfloat)_X0+dx,(GLfloat)_Y0+dy,(GLfloat)_X1+dx,(GLfloat)_Y1+dy};
|
||||
|
||||
bool antiAliased = false;
|
||||
if( antiAliased )
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
else
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
#ifdef USE_ARRAYS
|
||||
glColor4ub(GLubyte(_Color0>>16), GLubyte(_Color0>>8), GLubyte(_Color0), GLubyte(_Color0>>24));
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glLineWidth(2.0f);
|
||||
glVertexPointer(2, GL_FLOAT, 0, vVertices);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glDrawArrays(GL_LINES,0,2);
|
||||
#else
|
||||
glLineWidth(13.0f);
|
||||
glBegin(GL_LINES);
|
||||
glColor4ub(GLubyte(_Color0>>16), GLubyte(_Color0>>8), GLubyte(_Color0), GLubyte(_Color0>>24));
|
||||
glVertex2f((GLfloat)_X0+dx, (GLfloat)_Y0+dy);
|
||||
glColor4ub(GLubyte(_Color1>>16), GLubyte(_Color1>>8), GLubyte(_Color1), GLubyte(_Color1>>24));
|
||||
glVertex2f((GLfloat)_X1+dx, (GLfloat)_Y1+dy);
|
||||
glEnd();
|
||||
#endif
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
static void drawRect(int horStart, int vertStart, int horEnd, int vertEnd, unsigned int argbColor00,unsigned int argbColor10,unsigned int argbColor01,unsigned int argbColor11)
|
||||
{
|
||||
float dx = 0;
|
||||
float dy = 0;
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
#ifdef USE_ARRAYS
|
||||
GLfloat verts[] ={
|
||||
0.0f, 1.0f, 0.0f,
|
||||
-1.0f, -1.0f, 0.0f,
|
||||
1.0f, -1.0f, 0.0f,
|
||||
0.f,0.f,0.f
|
||||
};
|
||||
|
||||
glColor4ub(GLubyte(argbColor00>>16), GLubyte(argbColor00>>8), GLubyte(argbColor00), GLubyte(argbColor00>>24));
|
||||
verts[0] = (GLfloat)horStart+dx; verts[1] = (GLfloat)vertStart+dy;
|
||||
verts[2] = (GLfloat)horEnd+dx; verts[3] = (GLfloat)vertStart+dy;
|
||||
verts[4] = (GLfloat)horEnd+dx; verts[5] = (GLfloat)vertEnd+dy;
|
||||
verts[6] = (GLfloat)horStart+dx; verts[7] = (GLfloat)vertEnd+dy;
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
#else
|
||||
glBegin(GL_QUADS);
|
||||
glColor4ub(GLubyte(argbColor00>>16), GLubyte(argbColor00>>8), GLubyte(argbColor00), GLubyte(argbColor00>>24));
|
||||
glVertex2f((GLfloat)horStart+dx, (GLfloat)vertStart+dy);
|
||||
glColor4ub(GLubyte(argbColor10>>16), GLubyte(argbColor10>>8), GLubyte(argbColor10), GLubyte(argbColor10>>24));
|
||||
glVertex2f((GLfloat)horEnd+dx, (GLfloat)vertStart+dy);
|
||||
glColor4ub(GLubyte(argbColor11>>16), GLubyte(argbColor11>>8), GLubyte(argbColor11), GLubyte(argbColor11>>24));
|
||||
glVertex2f((GLfloat)horEnd+dx, (GLfloat)vertEnd+dy);
|
||||
glColor4ub(GLubyte(argbColor01>>16), GLubyte(argbColor01>>8), GLubyte(argbColor01), GLubyte(argbColor01>>24));
|
||||
glVertex2f((GLfloat)horStart+dx, (GLfloat)vertEnd+dy);
|
||||
glEnd();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void GL_DialogWindow::draw(btScalar deltaTime)
|
||||
{
|
||||
if (!m_screenWidth || !m_screenHeight)
|
||||
return;
|
||||
|
||||
m_dialogHorPos = int(m_collisionObject->getWorldTransform().getOrigin()[0]+m_screenWidth/2.f-m_dialogWidth/2.f);
|
||||
|
||||
m_dialogVertPos = int(m_collisionObject->getWorldTransform().getOrigin()[1]+m_screenHeight/2.f-m_dialogHeight/2.f);
|
||||
saveOpenGLState();
|
||||
|
||||
//drawRect(m_dialogHorPos,m_dialogVertPos,m_dialogHorPos+m_dialogWidth,m_dialogVertPos+m_dialogHeight,0xa6000000);
|
||||
unsigned int argbColor = 0x86000000;
|
||||
int charHeight = 16;
|
||||
int charWidth = 10;
|
||||
|
||||
int titleHeight = charHeight + 2;
|
||||
|
||||
drawRect(m_dialogHorPos,m_dialogVertPos,m_dialogHorPos+m_dialogWidth-1,m_dialogVertPos+titleHeight,argbColor,argbColor,argbColor,argbColor);
|
||||
//const unsigned int COL0 = 0x50ffffff;
|
||||
const unsigned int COL0 = 0xffffffff;
|
||||
const unsigned int COL1 = 0xff1f1f1f;
|
||||
|
||||
drawRect(m_dialogHorPos,m_dialogVertPos,m_dialogHorPos+m_dialogWidth-1,m_dialogVertPos+1,COL0,COL0,COL1,COL1);
|
||||
|
||||
argbColor = 0x864f4f4f;
|
||||
drawRect(m_dialogHorPos+1,m_dialogVertPos+titleHeight,m_dialogHorPos+m_dialogWidth-1,m_dialogVertPos+m_dialogHeight,argbColor,argbColor,argbColor,argbColor);
|
||||
|
||||
|
||||
int y = m_dialogVertPos+charHeight+1;
|
||||
glLineWidth(3);
|
||||
drawLine(m_dialogHorPos, y, m_dialogHorPos+m_dialogWidth-1, y, 0x80afafaf,0x80afafaf);
|
||||
|
||||
|
||||
|
||||
unsigned int clight = 0x5FFFFFFF; // bar contour
|
||||
drawLine(m_dialogHorPos, m_dialogVertPos, m_dialogHorPos, m_dialogVertPos+m_dialogHeight, clight,clight);
|
||||
drawLine(m_dialogHorPos, m_dialogVertPos, m_dialogHorPos+m_dialogWidth, m_dialogVertPos, clight,clight);
|
||||
drawLine(m_dialogHorPos+m_dialogWidth, m_dialogVertPos, m_dialogHorPos+m_dialogWidth, m_dialogVertPos+m_dialogHeight, clight,clight);
|
||||
drawLine(m_dialogHorPos, m_dialogVertPos+m_dialogHeight, m_dialogHorPos+m_dialogWidth, m_dialogVertPos+m_dialogHeight, clight,clight);
|
||||
int dshad = 3; // bar shadows
|
||||
|
||||
unsigned int cshad = (((0x40000000>>24)/2)<<24) & 0xFF000000;
|
||||
drawRect(m_dialogHorPos, m_dialogVertPos+m_dialogHeight, m_dialogHorPos+dshad, m_dialogVertPos+m_dialogHeight+dshad, 0, cshad, 0, 0);
|
||||
drawRect(m_dialogHorPos+dshad+1, m_dialogVertPos+m_dialogHeight, m_dialogHorPos+m_dialogWidth-1, m_dialogVertPos+m_dialogHeight+dshad, cshad, cshad, 0, 0);
|
||||
drawRect(m_dialogHorPos+m_dialogWidth, m_dialogVertPos+m_dialogHeight, m_dialogHorPos+m_dialogWidth+dshad, m_dialogVertPos+m_dialogHeight+dshad, cshad, 0, 0, 0);
|
||||
drawRect(m_dialogHorPos+m_dialogWidth, m_dialogVertPos, m_dialogHorPos+m_dialogWidth+dshad, m_dialogVertPos+dshad, 0, 0, cshad, 0);
|
||||
drawRect(m_dialogHorPos+m_dialogWidth, m_dialogVertPos+dshad+1, m_dialogHorPos+m_dialogWidth+dshad, m_dialogVertPos+m_dialogHeight-1, cshad, 0, cshad, 0);
|
||||
|
||||
int yInc = 16;
|
||||
int curHorPos = m_dialogHorPos+5;
|
||||
int curVertPos = m_dialogVertPos;
|
||||
curVertPos += yInc;
|
||||
|
||||
GLDebugDrawString(m_dialogHorPos+m_dialogWidth/2-((int(strlen(m_dialogTitle)/2))*charWidth),m_dialogVertPos+yInc ,m_dialogTitle);
|
||||
curVertPos += 20;
|
||||
|
||||
|
||||
for (int i=0;i<m_controls.size();i++)
|
||||
{
|
||||
m_controls[i]->draw(curHorPos,curVertPos,deltaTime);
|
||||
}
|
||||
|
||||
restoreOpenGLState();
|
||||
}
|
||||
|
||||
|
||||
void GL_DialogWindow::saveOpenGLState()
|
||||
{
|
||||
#if 0
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
|
||||
#endif
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
GLint Vp[4];
|
||||
glGetIntegerv(GL_VIEWPORT, Vp);
|
||||
|
||||
if( m_screenWidth>0 && m_screenHeight>0 )
|
||||
{
|
||||
Vp[0] = 0;
|
||||
Vp[1] = 0;
|
||||
Vp[2] = m_screenWidth-1;
|
||||
Vp[3] = m_screenHeight-1;
|
||||
glViewport(Vp[0], Vp[1], Vp[2], Vp[3]);
|
||||
}
|
||||
glLoadIdentity();
|
||||
glOrtho(Vp[0], Vp[0]+Vp[2], Vp[1]+Vp[3], Vp[1], -1, 1);
|
||||
glGetIntegerv(GL_VIEWPORT, m_ViewportInit);
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, m_ProjMatrixInit);
|
||||
|
||||
glGetFloatv(GL_LINE_WIDTH, &m_PrevLineWidth);
|
||||
// glDisable(GL_POLYGON_STIPPLE);
|
||||
glLineWidth(1);
|
||||
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
// glDisable(GL_LINE_STIPPLE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &m_PrevTexEnv);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
}
|
||||
|
||||
void GL_DialogWindow::restoreOpenGLState()
|
||||
{
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, m_PrevTexEnv);
|
||||
glLineWidth(m_PrevLineWidth);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glPopMatrix();
|
||||
glPopClientAttrib();
|
||||
glPopAttrib();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GL_TextControl::draw(int& parentHorPos,int& parentVertPos,btScalar deltaTime)
|
||||
{
|
||||
for (int i=0;i<m_textLines.size();i++)
|
||||
{
|
||||
GLDebugDrawString(parentHorPos,parentVertPos,m_textLines[i]);
|
||||
parentVertPos+=20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GL_ToggleControl::draw(int& parentHorPos2,int& parentVertPos2,btScalar deltaTime)
|
||||
{
|
||||
|
||||
int controlHorPos = int(m_toggleBody->getWorldTransform().getOrigin()[0]+m_parentWindow->getScreenWidth()/2);
|
||||
int controlVertPos = int(m_toggleBody->getWorldTransform().getOrigin()[1]+m_parentWindow->getScreenHeight()/2);
|
||||
|
||||
int parentHorPos = controlHorPos-8;
|
||||
int parentVertPos = controlVertPos-8;
|
||||
|
||||
unsigned int grey = 0xff6f6f6f;
|
||||
|
||||
drawRect(parentHorPos, parentVertPos, parentHorPos+16, parentVertPos+16, grey, grey, grey, grey);
|
||||
|
||||
int borderSize = 2;
|
||||
unsigned int white = 0xffefefef;
|
||||
drawRect(parentHorPos+borderSize, parentVertPos+borderSize, parentHorPos+16-borderSize, parentVertPos+16-borderSize, white,white,white,white);
|
||||
|
||||
|
||||
if (m_active)
|
||||
{
|
||||
//unsigned int red = 0xff8f0000;
|
||||
// unsigned int white = 0xff8f0000;
|
||||
unsigned int black = 0xff1f1f1f;
|
||||
borderSize = 4;
|
||||
drawRect(parentHorPos+borderSize, parentVertPos+borderSize, parentHorPos+16-borderSize, parentVertPos+16-borderSize, black,black,black,black);
|
||||
}
|
||||
|
||||
btVector3 rgb(1,1,1);
|
||||
|
||||
GLDebugDrawStringInternal(parentHorPos2,parentVertPos+16,m_toggleText,rgb);
|
||||
parentVertPos2+=20;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GL_SliderControl::draw(int& parentHorPos2,int& parentVertPos2,btScalar deltaTime)
|
||||
{
|
||||
|
||||
int controlHorPos = int(m_sliderBody->getWorldTransform().getOrigin()[0]+m_parentWindow->getScreenWidth()/2);
|
||||
int controlVertPos = int(m_sliderBody->getWorldTransform().getOrigin()[1]+m_parentWindow->getScreenHeight()/2);
|
||||
|
||||
int parentHorPos = controlHorPos-8;
|
||||
int parentVertPos = controlVertPos-8;
|
||||
|
||||
unsigned int grey = 0xff6f6f6f;
|
||||
int borderSize = 2;
|
||||
unsigned int white = 0xffefefef;
|
||||
drawRect(parentHorPos2+80+borderSize, parentVertPos2+borderSize, parentHorPos2+m_parentWindow->getDialogWidth()-16-borderSize, parentVertPos2+2-borderSize, white,white,white,white);
|
||||
|
||||
drawRect(parentHorPos, parentVertPos, parentHorPos+16, parentVertPos+16, grey, grey, grey, grey);
|
||||
|
||||
|
||||
|
||||
drawRect(parentHorPos+borderSize, parentVertPos+borderSize, parentHorPos+16-borderSize, parentVertPos+16-borderSize, white,white,white,white);
|
||||
|
||||
|
||||
|
||||
btVector3 rgb(1,1,1);
|
||||
|
||||
GLDebugDrawStringInternal(parentHorPos2,parentVertPos2+8,m_sliderText,rgb);
|
||||
parentVertPos2+=20;
|
||||
|
||||
}
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "GL_DialogWindow.h"
|
||||
|
||||
|
||||
|
||||
#include "GLDebugFont.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
#define USE_ARRAYS 1
|
||||
|
||||
|
||||
GL_DialogWindow::GL_DialogWindow(int horPos,int vertPos,int dialogWidth,int dialogHeight, btCollisionObject* collisionObject,const char* dialogTitle)
|
||||
:m_dialogHorPos(horPos),
|
||||
m_dialogVertPos(vertPos),
|
||||
m_dialogWidth(dialogWidth),
|
||||
m_dialogHeight(dialogHeight),
|
||||
m_screenWidth(0),
|
||||
m_screenHeight(0),
|
||||
m_dialogTitle(dialogTitle),
|
||||
m_MaxClipPlanes(-1),
|
||||
m_collisionObject(collisionObject)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void GL_DialogWindow::setScreenSize(int width, int height)
|
||||
{
|
||||
m_screenWidth = width;
|
||||
m_screenHeight = height;
|
||||
}
|
||||
GL_DialogWindow::~GL_DialogWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void drawLine(int _X0, int _Y0, int _X1, int _Y1, unsigned int _Color0, unsigned int _Color1)
|
||||
{
|
||||
const GLfloat dx = +0.5f;
|
||||
const GLfloat dy = -0.5f;
|
||||
|
||||
GLfloat vVertices[] = {(GLfloat)_X0+dx,(GLfloat)_Y0+dy,(GLfloat)_X1+dx,(GLfloat)_Y1+dy};
|
||||
|
||||
bool antiAliased = false;
|
||||
if( antiAliased )
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
else
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
#ifdef USE_ARRAYS
|
||||
glColor4ub(GLubyte(_Color0>>16), GLubyte(_Color0>>8), GLubyte(_Color0), GLubyte(_Color0>>24));
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glLineWidth(2.0f);
|
||||
glVertexPointer(2, GL_FLOAT, 0, vVertices);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glDrawArrays(GL_LINES,0,2);
|
||||
#else
|
||||
glLineWidth(13.0f);
|
||||
glBegin(GL_LINES);
|
||||
glColor4ub(GLubyte(_Color0>>16), GLubyte(_Color0>>8), GLubyte(_Color0), GLubyte(_Color0>>24));
|
||||
glVertex2f((GLfloat)_X0+dx, (GLfloat)_Y0+dy);
|
||||
glColor4ub(GLubyte(_Color1>>16), GLubyte(_Color1>>8), GLubyte(_Color1), GLubyte(_Color1>>24));
|
||||
glVertex2f((GLfloat)_X1+dx, (GLfloat)_Y1+dy);
|
||||
glEnd();
|
||||
#endif
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
static void drawRect(int horStart, int vertStart, int horEnd, int vertEnd, unsigned int argbColor00,unsigned int argbColor10,unsigned int argbColor01,unsigned int argbColor11)
|
||||
{
|
||||
float dx = 0;
|
||||
float dy = 0;
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
#ifdef USE_ARRAYS
|
||||
GLfloat verts[] ={
|
||||
0.0f, 1.0f, 0.0f,
|
||||
-1.0f, -1.0f, 0.0f,
|
||||
1.0f, -1.0f, 0.0f,
|
||||
0.f,0.f,0.f
|
||||
};
|
||||
|
||||
glColor4ub(GLubyte(argbColor00>>16), GLubyte(argbColor00>>8), GLubyte(argbColor00), GLubyte(argbColor00>>24));
|
||||
verts[0] = (GLfloat)horStart+dx; verts[1] = (GLfloat)vertStart+dy;
|
||||
verts[2] = (GLfloat)horEnd+dx; verts[3] = (GLfloat)vertStart+dy;
|
||||
verts[4] = (GLfloat)horEnd+dx; verts[5] = (GLfloat)vertEnd+dy;
|
||||
verts[6] = (GLfloat)horStart+dx; verts[7] = (GLfloat)vertEnd+dy;
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
#else
|
||||
glBegin(GL_QUADS);
|
||||
glColor4ub(GLubyte(argbColor00>>16), GLubyte(argbColor00>>8), GLubyte(argbColor00), GLubyte(argbColor00>>24));
|
||||
glVertex2f((GLfloat)horStart+dx, (GLfloat)vertStart+dy);
|
||||
glColor4ub(GLubyte(argbColor10>>16), GLubyte(argbColor10>>8), GLubyte(argbColor10), GLubyte(argbColor10>>24));
|
||||
glVertex2f((GLfloat)horEnd+dx, (GLfloat)vertStart+dy);
|
||||
glColor4ub(GLubyte(argbColor11>>16), GLubyte(argbColor11>>8), GLubyte(argbColor11), GLubyte(argbColor11>>24));
|
||||
glVertex2f((GLfloat)horEnd+dx, (GLfloat)vertEnd+dy);
|
||||
glColor4ub(GLubyte(argbColor01>>16), GLubyte(argbColor01>>8), GLubyte(argbColor01), GLubyte(argbColor01>>24));
|
||||
glVertex2f((GLfloat)horStart+dx, (GLfloat)vertEnd+dy);
|
||||
glEnd();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void GL_DialogWindow::draw(btScalar deltaTime)
|
||||
{
|
||||
if (!m_screenWidth || !m_screenHeight)
|
||||
return;
|
||||
|
||||
m_dialogHorPos = int(m_collisionObject->getWorldTransform().getOrigin()[0]+m_screenWidth/2.f-m_dialogWidth/2.f);
|
||||
|
||||
m_dialogVertPos = int(m_collisionObject->getWorldTransform().getOrigin()[1]+m_screenHeight/2.f-m_dialogHeight/2.f);
|
||||
saveOpenGLState();
|
||||
|
||||
//drawRect(m_dialogHorPos,m_dialogVertPos,m_dialogHorPos+m_dialogWidth,m_dialogVertPos+m_dialogHeight,0xa6000000);
|
||||
unsigned int argbColor = 0x86000000;
|
||||
int charHeight = 16;
|
||||
int charWidth = 10;
|
||||
|
||||
int titleHeight = charHeight + 2;
|
||||
|
||||
drawRect(m_dialogHorPos,m_dialogVertPos,m_dialogHorPos+m_dialogWidth-1,m_dialogVertPos+titleHeight,argbColor,argbColor,argbColor,argbColor);
|
||||
//const unsigned int COL0 = 0x50ffffff;
|
||||
const unsigned int COL0 = 0xffffffff;
|
||||
const unsigned int COL1 = 0xff1f1f1f;
|
||||
|
||||
drawRect(m_dialogHorPos,m_dialogVertPos,m_dialogHorPos+m_dialogWidth-1,m_dialogVertPos+1,COL0,COL0,COL1,COL1);
|
||||
|
||||
argbColor = 0x864f4f4f;
|
||||
drawRect(m_dialogHorPos+1,m_dialogVertPos+titleHeight,m_dialogHorPos+m_dialogWidth-1,m_dialogVertPos+m_dialogHeight,argbColor,argbColor,argbColor,argbColor);
|
||||
|
||||
|
||||
int y = m_dialogVertPos+charHeight+1;
|
||||
glLineWidth(3);
|
||||
drawLine(m_dialogHorPos, y, m_dialogHorPos+m_dialogWidth-1, y, 0x80afafaf,0x80afafaf);
|
||||
|
||||
|
||||
|
||||
unsigned int clight = 0x5FFFFFFF; // bar contour
|
||||
drawLine(m_dialogHorPos, m_dialogVertPos, m_dialogHorPos, m_dialogVertPos+m_dialogHeight, clight,clight);
|
||||
drawLine(m_dialogHorPos, m_dialogVertPos, m_dialogHorPos+m_dialogWidth, m_dialogVertPos, clight,clight);
|
||||
drawLine(m_dialogHorPos+m_dialogWidth, m_dialogVertPos, m_dialogHorPos+m_dialogWidth, m_dialogVertPos+m_dialogHeight, clight,clight);
|
||||
drawLine(m_dialogHorPos, m_dialogVertPos+m_dialogHeight, m_dialogHorPos+m_dialogWidth, m_dialogVertPos+m_dialogHeight, clight,clight);
|
||||
int dshad = 3; // bar shadows
|
||||
|
||||
unsigned int cshad = (((0x40000000>>24)/2)<<24) & 0xFF000000;
|
||||
drawRect(m_dialogHorPos, m_dialogVertPos+m_dialogHeight, m_dialogHorPos+dshad, m_dialogVertPos+m_dialogHeight+dshad, 0, cshad, 0, 0);
|
||||
drawRect(m_dialogHorPos+dshad+1, m_dialogVertPos+m_dialogHeight, m_dialogHorPos+m_dialogWidth-1, m_dialogVertPos+m_dialogHeight+dshad, cshad, cshad, 0, 0);
|
||||
drawRect(m_dialogHorPos+m_dialogWidth, m_dialogVertPos+m_dialogHeight, m_dialogHorPos+m_dialogWidth+dshad, m_dialogVertPos+m_dialogHeight+dshad, cshad, 0, 0, 0);
|
||||
drawRect(m_dialogHorPos+m_dialogWidth, m_dialogVertPos, m_dialogHorPos+m_dialogWidth+dshad, m_dialogVertPos+dshad, 0, 0, cshad, 0);
|
||||
drawRect(m_dialogHorPos+m_dialogWidth, m_dialogVertPos+dshad+1, m_dialogHorPos+m_dialogWidth+dshad, m_dialogVertPos+m_dialogHeight-1, cshad, 0, cshad, 0);
|
||||
|
||||
int yInc = 16;
|
||||
int curHorPos = m_dialogHorPos+5;
|
||||
int curVertPos = m_dialogVertPos;
|
||||
curVertPos += yInc;
|
||||
|
||||
GLDebugDrawString(m_dialogHorPos+m_dialogWidth/2-((int(strlen(m_dialogTitle)/2))*charWidth),m_dialogVertPos+yInc ,m_dialogTitle);
|
||||
curVertPos += 20;
|
||||
|
||||
|
||||
for (int i=0;i<m_controls.size();i++)
|
||||
{
|
||||
m_controls[i]->draw(curHorPos,curVertPos,deltaTime);
|
||||
}
|
||||
|
||||
restoreOpenGLState();
|
||||
}
|
||||
|
||||
|
||||
void GL_DialogWindow::saveOpenGLState()
|
||||
{
|
||||
#if 0
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
|
||||
#endif
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
GLint Vp[4];
|
||||
glGetIntegerv(GL_VIEWPORT, Vp);
|
||||
|
||||
if( m_screenWidth>0 && m_screenHeight>0 )
|
||||
{
|
||||
Vp[0] = 0;
|
||||
Vp[1] = 0;
|
||||
Vp[2] = m_screenWidth-1;
|
||||
Vp[3] = m_screenHeight-1;
|
||||
glViewport(Vp[0], Vp[1], Vp[2], Vp[3]);
|
||||
}
|
||||
glLoadIdentity();
|
||||
glOrtho(Vp[0], Vp[0]+Vp[2], Vp[1]+Vp[3], Vp[1], -1, 1);
|
||||
glGetIntegerv(GL_VIEWPORT, m_ViewportInit);
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, m_ProjMatrixInit);
|
||||
|
||||
glGetFloatv(GL_LINE_WIDTH, &m_PrevLineWidth);
|
||||
// glDisable(GL_POLYGON_STIPPLE);
|
||||
glLineWidth(1);
|
||||
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
// glDisable(GL_LINE_STIPPLE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &m_PrevTexEnv);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
}
|
||||
|
||||
void GL_DialogWindow::restoreOpenGLState()
|
||||
{
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, m_PrevTexEnv);
|
||||
glLineWidth(m_PrevLineWidth);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glPopMatrix();
|
||||
glPopClientAttrib();
|
||||
glPopAttrib();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GL_TextControl::draw(int& parentHorPos,int& parentVertPos,btScalar deltaTime)
|
||||
{
|
||||
for (int i=0;i<m_textLines.size();i++)
|
||||
{
|
||||
GLDebugDrawString(parentHorPos,parentVertPos,m_textLines[i]);
|
||||
parentVertPos+=20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GL_ToggleControl::draw(int& parentHorPos2,int& parentVertPos2,btScalar deltaTime)
|
||||
{
|
||||
|
||||
int controlHorPos = int(m_toggleBody->getWorldTransform().getOrigin()[0]+m_parentWindow->getScreenWidth()/2);
|
||||
int controlVertPos = int(m_toggleBody->getWorldTransform().getOrigin()[1]+m_parentWindow->getScreenHeight()/2);
|
||||
|
||||
int parentHorPos = controlHorPos-8;
|
||||
int parentVertPos = controlVertPos-8;
|
||||
|
||||
unsigned int grey = 0xff6f6f6f;
|
||||
|
||||
drawRect(parentHorPos, parentVertPos, parentHorPos+16, parentVertPos+16, grey, grey, grey, grey);
|
||||
|
||||
int borderSize = 2;
|
||||
unsigned int white = 0xffefefef;
|
||||
drawRect(parentHorPos+borderSize, parentVertPos+borderSize, parentHorPos+16-borderSize, parentVertPos+16-borderSize, white,white,white,white);
|
||||
|
||||
|
||||
if (m_active)
|
||||
{
|
||||
//unsigned int red = 0xff8f0000;
|
||||
// unsigned int white = 0xff8f0000;
|
||||
unsigned int black = 0xff1f1f1f;
|
||||
borderSize = 4;
|
||||
drawRect(parentHorPos+borderSize, parentVertPos+borderSize, parentHorPos+16-borderSize, parentVertPos+16-borderSize, black,black,black,black);
|
||||
}
|
||||
|
||||
btVector3 rgb(1,1,1);
|
||||
|
||||
GLDebugDrawStringInternal(parentHorPos2,parentVertPos+16,m_toggleText,rgb);
|
||||
parentVertPos2+=20;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GL_SliderControl::draw(int& parentHorPos2,int& parentVertPos2,btScalar deltaTime)
|
||||
{
|
||||
|
||||
int controlHorPos = int(m_sliderBody->getWorldTransform().getOrigin()[0]+m_parentWindow->getScreenWidth()/2);
|
||||
int controlVertPos = int(m_sliderBody->getWorldTransform().getOrigin()[1]+m_parentWindow->getScreenHeight()/2);
|
||||
|
||||
int parentHorPos = controlHorPos-8;
|
||||
int parentVertPos = controlVertPos-8;
|
||||
|
||||
unsigned int grey = 0xff6f6f6f;
|
||||
int borderSize = 2;
|
||||
unsigned int white = 0xffefefef;
|
||||
drawRect(parentHorPos2+80+borderSize, parentVertPos2+borderSize, parentHorPos2+m_parentWindow->getDialogWidth()-16-borderSize, parentVertPos2+2-borderSize, white,white,white,white);
|
||||
|
||||
drawRect(parentHorPos, parentVertPos, parentHorPos+16, parentVertPos+16, grey, grey, grey, grey);
|
||||
|
||||
|
||||
|
||||
drawRect(parentHorPos+borderSize, parentVertPos+borderSize, parentHorPos+16-borderSize, parentVertPos+16-borderSize, white,white,white,white);
|
||||
|
||||
|
||||
|
||||
btVector3 rgb(1,1,1);
|
||||
|
||||
GLDebugDrawStringInternal(parentHorPos2,parentVertPos2+8,m_sliderText,rgb);
|
||||
parentVertPos2+=20;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,283 +1,283 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef GL_DIALOG_WINDOW_H
|
||||
#define GL_DIALOG_WINDOW_H
|
||||
|
||||
class btCollisionObject;
|
||||
|
||||
|
||||
//think different
|
||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||
#include <TargetConditionals.h>
|
||||
#if (defined (TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || (defined (TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR)
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#define glOrtho glOrthof
|
||||
#else
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#include <GLUT/glut.h>
|
||||
#endif
|
||||
#else
|
||||
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#include "LinearMath/btScalar.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
class btTypedConstraint;
|
||||
|
||||
class GL_DialogWindow;
|
||||
|
||||
enum GL_DIALOG_CONTROL_TYPES
|
||||
{
|
||||
GL_TEXT_CONTROL=1,
|
||||
GL_TOGGLE_CONTROL,
|
||||
GL_SLIDER_CONTROL,
|
||||
GL_CONTROL_MAX_TYPE
|
||||
};
|
||||
|
||||
class GL_DialogControl
|
||||
{
|
||||
protected:
|
||||
int m_type;
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GL_DialogControl()
|
||||
{
|
||||
}
|
||||
virtual void draw(int& parentHorPos,int& parentVertPos,btScalar deltaTime)=0;
|
||||
|
||||
int getType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
};
|
||||
|
||||
struct GL_TextControl : public GL_DialogControl
|
||||
{
|
||||
public:
|
||||
|
||||
btAlignedObjectArray<const char*> m_textLines;
|
||||
|
||||
GL_TextControl()
|
||||
{
|
||||
m_type = GL_TEXT_CONTROL;
|
||||
}
|
||||
|
||||
virtual ~GL_TextControl() {}
|
||||
|
||||
virtual void draw(int& parentHorPos,int& parentVertPos,btScalar deltaTime);
|
||||
};
|
||||
|
||||
|
||||
struct GL_ToggleControl : public GL_DialogControl
|
||||
{
|
||||
btCollisionObject* m_toggleBody;
|
||||
GL_DialogWindow* m_parentWindow;
|
||||
|
||||
const char* m_toggleText;
|
||||
|
||||
public:
|
||||
|
||||
bool m_active;
|
||||
|
||||
|
||||
GL_ToggleControl(const char* toggleText,btCollisionObject* toggleBody, GL_DialogWindow* parentWindow)
|
||||
:m_toggleBody(toggleBody),
|
||||
m_parentWindow(parentWindow),
|
||||
m_toggleText(toggleText),
|
||||
m_active(false)
|
||||
{
|
||||
m_type = GL_TOGGLE_CONTROL;
|
||||
}
|
||||
|
||||
virtual void draw(int& parentHorPos,int& parentVertPos,btScalar deltaTime);
|
||||
};
|
||||
|
||||
struct GL_SliderControl : public GL_DialogControl
|
||||
{
|
||||
btCollisionObject* m_sliderBody;
|
||||
GL_DialogWindow* m_parentWindow;
|
||||
btScalar m_lowerLimit;
|
||||
btScalar m_upperLimit;
|
||||
btTypedConstraint* m_constraint;
|
||||
|
||||
const char* m_sliderText;
|
||||
public:
|
||||
|
||||
GL_SliderControl(const char* sliderText,btCollisionObject* sliderBody, GL_DialogWindow* parentWindow, btScalar lowerLimit,btScalar upperLimit,btTypedConstraint* constaint)
|
||||
:m_sliderBody(sliderBody),
|
||||
m_parentWindow(parentWindow),
|
||||
m_lowerLimit(lowerLimit),
|
||||
m_upperLimit(upperLimit),
|
||||
m_constraint(constaint),
|
||||
m_sliderText(sliderText)
|
||||
{
|
||||
m_type = GL_SLIDER_CONTROL;
|
||||
}
|
||||
|
||||
virtual void draw(int& parentHorPos,int& parentVertPos,btScalar deltaTime);
|
||||
|
||||
btScalar btGetFraction();
|
||||
|
||||
btScalar getLowerLimit()
|
||||
{
|
||||
return m_lowerLimit;
|
||||
}
|
||||
btScalar getUpperLimit()
|
||||
{
|
||||
return m_upperLimit;
|
||||
}
|
||||
btTypedConstraint* getConstraint()
|
||||
{
|
||||
return m_constraint;
|
||||
}
|
||||
};
|
||||
|
||||
///Very basic OpenGL Graphical Userinterface Window with text, toggle, slider control
|
||||
class GL_DialogWindow
|
||||
{
|
||||
|
||||
int m_dialogHorPos;
|
||||
int m_dialogVertPos;
|
||||
int m_dialogWidth;
|
||||
int m_dialogHeight;
|
||||
|
||||
int m_screenWidth;
|
||||
int m_screenHeight;
|
||||
|
||||
const char* m_dialogTitle;
|
||||
|
||||
//saved OpenGL settings
|
||||
GLfloat m_PrevLineWidth;
|
||||
GLint m_PrevTexEnv;
|
||||
GLint m_PrevPolygonMode[2];
|
||||
GLint m_MaxClipPlanes;
|
||||
GLint m_PrevTexture;
|
||||
GLint m_PrevArrayBufferARB;
|
||||
GLint m_PrevElementArrayBufferARB;
|
||||
GLboolean m_PrevVertexProgramARB;
|
||||
GLboolean m_PrevFragmentProgramARB;
|
||||
GLuint m_PrevProgramObjectARB;
|
||||
GLboolean m_PrevTexture3D;
|
||||
GLboolean m_PrevActiveTexture1D[32];
|
||||
GLboolean m_PrevActiveTexture2D[32];
|
||||
GLboolean m_PrevActiveTexture3D[32];
|
||||
GLint m_PrevActiveTextureARB;
|
||||
bool m_SupportTexRect;
|
||||
GLboolean m_PrevTexRectARB;
|
||||
GLint m_PrevBlendEquation;
|
||||
GLint m_PrevBlendEquationRGB;
|
||||
GLint m_PrevBlendEquationAlpha;
|
||||
GLint m_PrevBlendSrcRGB;
|
||||
GLint m_PrevBlendDstRGB;
|
||||
GLint m_PrevBlendSrcAlpha;
|
||||
GLint m_PrevBlendDstAlpha;
|
||||
GLint m_ViewportInit[4];
|
||||
GLfloat m_ProjMatrixInit[16];
|
||||
|
||||
btCollisionObject* m_collisionObject;
|
||||
|
||||
btAlignedObjectArray<GL_DialogControl*> m_controls;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
void saveOpenGLState();
|
||||
void restoreOpenGLState();
|
||||
|
||||
// void drawLine(int _X0, int _Y0, int _X1, int _Y1, unsigned int _Color0, unsigned int _Color1, bool antiAliased);
|
||||
// void drawRect(int horStart, int vertStart, int horEnd, int vertEnd, unsigned int argbColor00,unsigned int argbColor10,unsigned int argbColor01,unsigned int argbColor11);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
GL_DialogWindow(int horPos,int vertPos,int dialogWidth,int dialogHeight,btCollisionObject* colObject, const char* dialogTitle);
|
||||
|
||||
virtual ~GL_DialogWindow();
|
||||
|
||||
void draw(btScalar deltaTime);
|
||||
|
||||
void setScreenSize(int width, int height);
|
||||
|
||||
void setStartPosition(int dialogHorPos,int dialogVertPos);
|
||||
|
||||
void addControl(GL_DialogControl* control)
|
||||
{
|
||||
m_controls.push_back(control);
|
||||
}
|
||||
|
||||
void removeControl(GL_DialogControl* control)
|
||||
{
|
||||
m_controls.remove(control);
|
||||
}
|
||||
|
||||
btCollisionObject* getCollisionObject()
|
||||
{
|
||||
return m_collisionObject;
|
||||
}
|
||||
|
||||
int getDialogHorPos() const
|
||||
{
|
||||
return m_dialogHorPos;
|
||||
}
|
||||
int getDialogVertPos() const
|
||||
{
|
||||
return m_dialogVertPos;
|
||||
}
|
||||
int getDialogWidth() const
|
||||
{
|
||||
return m_dialogWidth;
|
||||
}
|
||||
|
||||
int getDialogHeight() const
|
||||
{
|
||||
return m_dialogHeight;
|
||||
}
|
||||
int getScreenWidth() const
|
||||
{
|
||||
return m_screenWidth;
|
||||
}
|
||||
int getScreenHeight() const
|
||||
{
|
||||
return m_screenHeight;
|
||||
}
|
||||
|
||||
int getNumControls() const
|
||||
{
|
||||
return m_controls.size();
|
||||
}
|
||||
|
||||
const GL_DialogControl* getControl(int index) const
|
||||
{
|
||||
return m_controls[index];
|
||||
}
|
||||
GL_DialogControl* getControl(int index)
|
||||
{
|
||||
return m_controls[index];
|
||||
}
|
||||
};
|
||||
|
||||
#endif //GL_DIALOG_WINDOW_H
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef GL_DIALOG_WINDOW_H
|
||||
#define GL_DIALOG_WINDOW_H
|
||||
|
||||
class btCollisionObject;
|
||||
|
||||
|
||||
//think different
|
||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||
#include <TargetConditionals.h>
|
||||
#if (defined (TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || (defined (TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR)
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#define glOrtho glOrthof
|
||||
#else
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#include <GLUT/glut.h>
|
||||
#endif
|
||||
#else
|
||||
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#include "LinearMath/btScalar.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
class btTypedConstraint;
|
||||
|
||||
class GL_DialogWindow;
|
||||
|
||||
enum GL_DIALOG_CONTROL_TYPES
|
||||
{
|
||||
GL_TEXT_CONTROL=1,
|
||||
GL_TOGGLE_CONTROL,
|
||||
GL_SLIDER_CONTROL,
|
||||
GL_CONTROL_MAX_TYPE
|
||||
};
|
||||
|
||||
class GL_DialogControl
|
||||
{
|
||||
protected:
|
||||
int m_type;
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GL_DialogControl()
|
||||
{
|
||||
}
|
||||
virtual void draw(int& parentHorPos,int& parentVertPos,btScalar deltaTime)=0;
|
||||
|
||||
int getType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
};
|
||||
|
||||
struct GL_TextControl : public GL_DialogControl
|
||||
{
|
||||
public:
|
||||
|
||||
btAlignedObjectArray<const char*> m_textLines;
|
||||
|
||||
GL_TextControl()
|
||||
{
|
||||
m_type = GL_TEXT_CONTROL;
|
||||
}
|
||||
|
||||
virtual ~GL_TextControl() {}
|
||||
|
||||
virtual void draw(int& parentHorPos,int& parentVertPos,btScalar deltaTime);
|
||||
};
|
||||
|
||||
|
||||
struct GL_ToggleControl : public GL_DialogControl
|
||||
{
|
||||
btCollisionObject* m_toggleBody;
|
||||
GL_DialogWindow* m_parentWindow;
|
||||
|
||||
const char* m_toggleText;
|
||||
|
||||
public:
|
||||
|
||||
bool m_active;
|
||||
|
||||
|
||||
GL_ToggleControl(const char* toggleText,btCollisionObject* toggleBody, GL_DialogWindow* parentWindow)
|
||||
:m_toggleBody(toggleBody),
|
||||
m_parentWindow(parentWindow),
|
||||
m_toggleText(toggleText),
|
||||
m_active(false)
|
||||
{
|
||||
m_type = GL_TOGGLE_CONTROL;
|
||||
}
|
||||
|
||||
virtual void draw(int& parentHorPos,int& parentVertPos,btScalar deltaTime);
|
||||
};
|
||||
|
||||
struct GL_SliderControl : public GL_DialogControl
|
||||
{
|
||||
btCollisionObject* m_sliderBody;
|
||||
GL_DialogWindow* m_parentWindow;
|
||||
btScalar m_lowerLimit;
|
||||
btScalar m_upperLimit;
|
||||
btTypedConstraint* m_constraint;
|
||||
|
||||
const char* m_sliderText;
|
||||
public:
|
||||
|
||||
GL_SliderControl(const char* sliderText,btCollisionObject* sliderBody, GL_DialogWindow* parentWindow, btScalar lowerLimit,btScalar upperLimit,btTypedConstraint* constaint)
|
||||
:m_sliderBody(sliderBody),
|
||||
m_parentWindow(parentWindow),
|
||||
m_lowerLimit(lowerLimit),
|
||||
m_upperLimit(upperLimit),
|
||||
m_constraint(constaint),
|
||||
m_sliderText(sliderText)
|
||||
{
|
||||
m_type = GL_SLIDER_CONTROL;
|
||||
}
|
||||
|
||||
virtual void draw(int& parentHorPos,int& parentVertPos,btScalar deltaTime);
|
||||
|
||||
btScalar btGetFraction();
|
||||
|
||||
btScalar getLowerLimit()
|
||||
{
|
||||
return m_lowerLimit;
|
||||
}
|
||||
btScalar getUpperLimit()
|
||||
{
|
||||
return m_upperLimit;
|
||||
}
|
||||
btTypedConstraint* getConstraint()
|
||||
{
|
||||
return m_constraint;
|
||||
}
|
||||
};
|
||||
|
||||
///Very basic OpenGL Graphical Userinterface Window with text, toggle, slider control
|
||||
class GL_DialogWindow
|
||||
{
|
||||
|
||||
int m_dialogHorPos;
|
||||
int m_dialogVertPos;
|
||||
int m_dialogWidth;
|
||||
int m_dialogHeight;
|
||||
|
||||
int m_screenWidth;
|
||||
int m_screenHeight;
|
||||
|
||||
const char* m_dialogTitle;
|
||||
|
||||
//saved OpenGL settings
|
||||
GLfloat m_PrevLineWidth;
|
||||
GLint m_PrevTexEnv;
|
||||
GLint m_PrevPolygonMode[2];
|
||||
GLint m_MaxClipPlanes;
|
||||
GLint m_PrevTexture;
|
||||
GLint m_PrevArrayBufferARB;
|
||||
GLint m_PrevElementArrayBufferARB;
|
||||
GLboolean m_PrevVertexProgramARB;
|
||||
GLboolean m_PrevFragmentProgramARB;
|
||||
GLuint m_PrevProgramObjectARB;
|
||||
GLboolean m_PrevTexture3D;
|
||||
GLboolean m_PrevActiveTexture1D[32];
|
||||
GLboolean m_PrevActiveTexture2D[32];
|
||||
GLboolean m_PrevActiveTexture3D[32];
|
||||
GLint m_PrevActiveTextureARB;
|
||||
bool m_SupportTexRect;
|
||||
GLboolean m_PrevTexRectARB;
|
||||
GLint m_PrevBlendEquation;
|
||||
GLint m_PrevBlendEquationRGB;
|
||||
GLint m_PrevBlendEquationAlpha;
|
||||
GLint m_PrevBlendSrcRGB;
|
||||
GLint m_PrevBlendDstRGB;
|
||||
GLint m_PrevBlendSrcAlpha;
|
||||
GLint m_PrevBlendDstAlpha;
|
||||
GLint m_ViewportInit[4];
|
||||
GLfloat m_ProjMatrixInit[16];
|
||||
|
||||
btCollisionObject* m_collisionObject;
|
||||
|
||||
btAlignedObjectArray<GL_DialogControl*> m_controls;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
void saveOpenGLState();
|
||||
void restoreOpenGLState();
|
||||
|
||||
// void drawLine(int _X0, int _Y0, int _X1, int _Y1, unsigned int _Color0, unsigned int _Color1, bool antiAliased);
|
||||
// void drawRect(int horStart, int vertStart, int horEnd, int vertEnd, unsigned int argbColor00,unsigned int argbColor10,unsigned int argbColor01,unsigned int argbColor11);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
GL_DialogWindow(int horPos,int vertPos,int dialogWidth,int dialogHeight,btCollisionObject* colObject, const char* dialogTitle);
|
||||
|
||||
virtual ~GL_DialogWindow();
|
||||
|
||||
void draw(btScalar deltaTime);
|
||||
|
||||
void setScreenSize(int width, int height);
|
||||
|
||||
void setStartPosition(int dialogHorPos,int dialogVertPos);
|
||||
|
||||
void addControl(GL_DialogControl* control)
|
||||
{
|
||||
m_controls.push_back(control);
|
||||
}
|
||||
|
||||
void removeControl(GL_DialogControl* control)
|
||||
{
|
||||
m_controls.remove(control);
|
||||
}
|
||||
|
||||
btCollisionObject* getCollisionObject()
|
||||
{
|
||||
return m_collisionObject;
|
||||
}
|
||||
|
||||
int getDialogHorPos() const
|
||||
{
|
||||
return m_dialogHorPos;
|
||||
}
|
||||
int getDialogVertPos() const
|
||||
{
|
||||
return m_dialogVertPos;
|
||||
}
|
||||
int getDialogWidth() const
|
||||
{
|
||||
return m_dialogWidth;
|
||||
}
|
||||
|
||||
int getDialogHeight() const
|
||||
{
|
||||
return m_dialogHeight;
|
||||
}
|
||||
int getScreenWidth() const
|
||||
{
|
||||
return m_screenWidth;
|
||||
}
|
||||
int getScreenHeight() const
|
||||
{
|
||||
return m_screenHeight;
|
||||
}
|
||||
|
||||
int getNumControls() const
|
||||
{
|
||||
return m_controls.size();
|
||||
}
|
||||
|
||||
const GL_DialogControl* getControl(int index) const
|
||||
{
|
||||
return m_controls[index];
|
||||
}
|
||||
GL_DialogControl* getControl(int index)
|
||||
{
|
||||
return m_controls[index];
|
||||
}
|
||||
};
|
||||
|
||||
#endif //GL_DIALOG_WINDOW_H
|
||||
|
||||
@@ -1,87 +1,87 @@
|
||||
|
||||
#ifndef _WINDOWS
|
||||
|
||||
#include "GlutDemoApplication.h"
|
||||
|
||||
#include "GlutStuff.h"
|
||||
|
||||
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
|
||||
#include "BulletDynamics/Dynamics/btRigidBody.h"
|
||||
|
||||
void GlutDemoApplication::updateModifierKeys()
|
||||
{
|
||||
m_modifierKeys = 0;
|
||||
if (glutGetModifiers() & GLUT_ACTIVE_ALT)
|
||||
m_modifierKeys |= BT_ACTIVE_ALT;
|
||||
|
||||
if (glutGetModifiers() & GLUT_ACTIVE_CTRL)
|
||||
m_modifierKeys |= BT_ACTIVE_CTRL;
|
||||
|
||||
if (glutGetModifiers() & GLUT_ACTIVE_SHIFT)
|
||||
m_modifierKeys |= BT_ACTIVE_SHIFT;
|
||||
}
|
||||
|
||||
void GlutDemoApplication::specialKeyboard(int key, int x, int y)
|
||||
{
|
||||
(void)x;
|
||||
(void)y;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case GLUT_KEY_F1:
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case GLUT_KEY_F2:
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case GLUT_KEY_END:
|
||||
{
|
||||
int numObj = getDynamicsWorld()->getNumCollisionObjects();
|
||||
if (numObj)
|
||||
{
|
||||
btCollisionObject* obj = getDynamicsWorld()->getCollisionObjectArray()[numObj-1];
|
||||
|
||||
getDynamicsWorld()->removeCollisionObject(obj);
|
||||
btRigidBody* body = btRigidBody::upcast(obj);
|
||||
if (body && body->getMotionState())
|
||||
{
|
||||
delete body->getMotionState();
|
||||
}
|
||||
delete obj;
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GLUT_KEY_LEFT : stepLeft(); break;
|
||||
case GLUT_KEY_RIGHT : stepRight(); break;
|
||||
case GLUT_KEY_UP : stepFront(); break;
|
||||
case GLUT_KEY_DOWN : stepBack(); break;
|
||||
case GLUT_KEY_PAGE_UP : zoomIn(); break;
|
||||
case GLUT_KEY_PAGE_DOWN : zoomOut(); break;
|
||||
case GLUT_KEY_HOME : toggleIdle(); break;
|
||||
default:
|
||||
// std::cout << "unused (special) key : " << key << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
|
||||
}
|
||||
|
||||
void GlutDemoApplication::swapBuffers()
|
||||
{
|
||||
glutSwapBuffers();
|
||||
|
||||
}
|
||||
|
||||
#endif //_WINDOWS
|
||||
|
||||
|
||||
|
||||
#ifndef _WINDOWS
|
||||
|
||||
#include "GlutDemoApplication.h"
|
||||
|
||||
#include "GlutStuff.h"
|
||||
|
||||
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
|
||||
#include "BulletDynamics/Dynamics/btRigidBody.h"
|
||||
|
||||
void GlutDemoApplication::updateModifierKeys()
|
||||
{
|
||||
m_modifierKeys = 0;
|
||||
if (glutGetModifiers() & GLUT_ACTIVE_ALT)
|
||||
m_modifierKeys |= BT_ACTIVE_ALT;
|
||||
|
||||
if (glutGetModifiers() & GLUT_ACTIVE_CTRL)
|
||||
m_modifierKeys |= BT_ACTIVE_CTRL;
|
||||
|
||||
if (glutGetModifiers() & GLUT_ACTIVE_SHIFT)
|
||||
m_modifierKeys |= BT_ACTIVE_SHIFT;
|
||||
}
|
||||
|
||||
void GlutDemoApplication::specialKeyboard(int key, int x, int y)
|
||||
{
|
||||
(void)x;
|
||||
(void)y;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case GLUT_KEY_F1:
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case GLUT_KEY_F2:
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case GLUT_KEY_END:
|
||||
{
|
||||
int numObj = getDynamicsWorld()->getNumCollisionObjects();
|
||||
if (numObj)
|
||||
{
|
||||
btCollisionObject* obj = getDynamicsWorld()->getCollisionObjectArray()[numObj-1];
|
||||
|
||||
getDynamicsWorld()->removeCollisionObject(obj);
|
||||
btRigidBody* body = btRigidBody::upcast(obj);
|
||||
if (body && body->getMotionState())
|
||||
{
|
||||
delete body->getMotionState();
|
||||
}
|
||||
delete obj;
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GLUT_KEY_LEFT : stepLeft(); break;
|
||||
case GLUT_KEY_RIGHT : stepRight(); break;
|
||||
case GLUT_KEY_UP : stepFront(); break;
|
||||
case GLUT_KEY_DOWN : stepBack(); break;
|
||||
case GLUT_KEY_PAGE_UP : zoomIn(); break;
|
||||
case GLUT_KEY_PAGE_DOWN : zoomOut(); break;
|
||||
case GLUT_KEY_HOME : toggleIdle(); break;
|
||||
default:
|
||||
// std::cout << "unused (special) key : " << key << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
|
||||
}
|
||||
|
||||
void GlutDemoApplication::swapBuffers()
|
||||
{
|
||||
glutSwapBuffers();
|
||||
|
||||
}
|
||||
|
||||
#endif //_WINDOWS
|
||||
|
||||
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GLUT_DEMO_APPLICATION_H
|
||||
#define GLUT_DEMO_APPLICATION_H
|
||||
|
||||
#include "DemoApplication.h"
|
||||
|
||||
class GlutDemoApplication : public DemoApplication
|
||||
{
|
||||
public:
|
||||
|
||||
void specialKeyboard(int key, int x, int y);
|
||||
|
||||
virtual void swapBuffers();
|
||||
|
||||
virtual void updateModifierKeys();
|
||||
|
||||
};
|
||||
#endif //GLUT_DEMO_APPLICATION_H
|
||||
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GLUT_DEMO_APPLICATION_H
|
||||
#define GLUT_DEMO_APPLICATION_H
|
||||
|
||||
#include "DemoApplication.h"
|
||||
|
||||
class GlutDemoApplication : public DemoApplication
|
||||
{
|
||||
public:
|
||||
|
||||
void specialKeyboard(int key, int x, int y);
|
||||
|
||||
virtual void swapBuffers();
|
||||
|
||||
virtual void updateModifierKeys();
|
||||
|
||||
};
|
||||
#endif //GLUT_DEMO_APPLICATION_H
|
||||
|
||||
|
||||
@@ -1,402 +1,402 @@
|
||||
#ifdef _WINDOWS
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2010 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <gl/gl.h>
|
||||
|
||||
|
||||
#include "DemoApplication.h"
|
||||
|
||||
#include "GLDebugDrawer.h"
|
||||
#include "GLDebugFont.h"
|
||||
|
||||
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
|
||||
|
||||
/// This Win32AppMain is shared code between all demos.
|
||||
/// The actual demo, derived from DemoApplication is created using 'createDemo', in a separate .cpp file
|
||||
DemoApplication* gDemoApplication = 0;
|
||||
DemoApplication* createDemo();
|
||||
|
||||
|
||||
// Function Declarations
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC);
|
||||
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC);
|
||||
static bool sOpenGLInitialized = false;
|
||||
static int sWidth = 0;
|
||||
static int sHeight =0;
|
||||
static int quitRequest = 0;
|
||||
|
||||
// WinMain
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine, int iCmdShow)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
HWND hWnd;
|
||||
HDC hDC;
|
||||
HGLRC hRC;
|
||||
MSG msg;
|
||||
BOOL quit = FALSE;
|
||||
float theta = 0.0f;
|
||||
|
||||
gDemoApplication = createDemo();
|
||||
|
||||
|
||||
// register window class
|
||||
wc.style = CS_OWNDC;
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
|
||||
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = "BulletPhysics";
|
||||
RegisterClass( &wc );
|
||||
|
||||
// create main window
|
||||
hWnd = CreateWindow(
|
||||
"BulletPhysics", "Bullet Physics Sample. http://bulletphysics.org",
|
||||
WS_CAPTION | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
|
||||
// 0, 0, 640, 480,
|
||||
0, 0, 1024, 768,
|
||||
NULL, NULL, hInstance, NULL );
|
||||
|
||||
// enable OpenGL for the window
|
||||
EnableOpenGL( hWnd, &hDC, &hRC );
|
||||
|
||||
|
||||
GLDebugDrawer debugDraw;
|
||||
gDemoApplication->myinit();
|
||||
//gDemoApplication->reshape(1024, 768);
|
||||
gDemoApplication->initPhysics();
|
||||
if (gDemoApplication->getDynamicsWorld())
|
||||
gDemoApplication->getDynamicsWorld()->setDebugDrawer(&debugDraw);
|
||||
|
||||
gDemoApplication->reshape(sWidth,sHeight);
|
||||
|
||||
// program main loop
|
||||
while ( !quit )
|
||||
{
|
||||
|
||||
// check for messages
|
||||
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
|
||||
{
|
||||
|
||||
// handle or dispatch messages
|
||||
if ( msg.message == WM_QUIT )
|
||||
{
|
||||
quit = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
|
||||
// gDemoApplication->displayCallback();
|
||||
|
||||
|
||||
};
|
||||
|
||||
// OpenGL animation code goes here
|
||||
|
||||
glClearColor( .7f, 0.7f, 0.7f, 1.f );
|
||||
|
||||
gDemoApplication->moveAndDisplay();
|
||||
|
||||
|
||||
SwapBuffers( hDC );
|
||||
|
||||
theta += 1.0f;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// shutdown OpenGL
|
||||
DisableOpenGL( hWnd, hDC, hRC );
|
||||
|
||||
// destroy the window explicitly
|
||||
DestroyWindow( hWnd );
|
||||
|
||||
delete gDemoApplication;
|
||||
|
||||
return msg.wParam;
|
||||
|
||||
}
|
||||
|
||||
// Window Procedure
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch (message)
|
||||
{
|
||||
|
||||
case WM_SYSKEYDOWN:
|
||||
{
|
||||
if (lParam & 1<<29)
|
||||
{
|
||||
gDemoApplication->m_modifierKeys = VK_LMENU;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_SYSKEYUP:
|
||||
{
|
||||
if (lParam & 1<<29)
|
||||
{
|
||||
gDemoApplication->m_modifierKeys = VK_LMENU;
|
||||
} else
|
||||
{
|
||||
gDemoApplication->m_modifierKeys = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case WM_SIZE: // Size Action Has Taken Place
|
||||
|
||||
switch (wParam) // Evaluate Size Action
|
||||
{
|
||||
case SIZE_MINIMIZED: // Was Window Minimized?
|
||||
return 0; // Return
|
||||
|
||||
case SIZE_MAXIMIZED: // Was Window Maximized?
|
||||
sWidth = LOWORD (lParam);
|
||||
sHeight = HIWORD (lParam);
|
||||
if (sOpenGLInitialized)
|
||||
{
|
||||
gDemoApplication->reshape(sWidth,sHeight);
|
||||
}
|
||||
return 0; // Return
|
||||
|
||||
case SIZE_RESTORED: // Was Window Restored?
|
||||
sWidth = LOWORD (lParam);
|
||||
sHeight = HIWORD (lParam);
|
||||
if (sOpenGLInitialized)
|
||||
{
|
||||
gDemoApplication->reshape(sWidth,sHeight);
|
||||
}
|
||||
return 0; // Return
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CREATE:
|
||||
return 0;
|
||||
|
||||
case WM_MBUTTONUP:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(1,1,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
case WM_MBUTTONDOWN:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(1,0,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(0,1,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
case 0x020A://WM_MOUSEWHEEL:
|
||||
{
|
||||
|
||||
int zDelta = (short)HIWORD(wParam);
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
if (zDelta>0)
|
||||
gDemoApplication->zoomIn();
|
||||
else
|
||||
gDemoApplication->zoomOut();
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseMotionFunc(xPos,yPos);
|
||||
break;
|
||||
}
|
||||
case WM_RBUTTONUP:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(2,1,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
case WM_RBUTTONDOWN:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(2,0,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(0,0,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
/*#define WM_LBUTTONUP 0x0202
|
||||
#define WM_LBUTTONDBLCLK 0x0203
|
||||
#define WM_RBUTTONDOWN 0x0204
|
||||
#define WM_RBUTTONUP 0x0205
|
||||
#define WM_RBUTTONDBLCLK 0x0206
|
||||
#define WM_MBUTTONDOWN 0x0207
|
||||
#define WM_MBUTTONUP 0x0208
|
||||
#define WM_MBUTTONDBLCLK 0x0209
|
||||
*/
|
||||
|
||||
|
||||
|
||||
case WM_CLOSE:
|
||||
PostQuitMessage( 0 );
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
return 0;
|
||||
|
||||
case WM_KEYUP:
|
||||
switch ( wParam )
|
||||
{
|
||||
|
||||
case VK_PRIOR:
|
||||
case VK_NEXT:
|
||||
case VK_END:
|
||||
case VK_HOME:
|
||||
case VK_LEFT:
|
||||
case VK_UP:
|
||||
case VK_RIGHT:
|
||||
case VK_DOWN:
|
||||
{
|
||||
if (gDemoApplication)
|
||||
gDemoApplication->specialKeyboardUp(wParam,0,0);
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return DefWindowProc( hWnd, message, wParam, lParam );
|
||||
}
|
||||
|
||||
case WM_KEYDOWN:
|
||||
printf("bla\n");
|
||||
switch ( wParam )
|
||||
{
|
||||
case VK_CONTROL:
|
||||
case VK_PRIOR:
|
||||
case VK_NEXT:
|
||||
case VK_END:
|
||||
case VK_HOME:
|
||||
case VK_LEFT:
|
||||
case VK_UP:
|
||||
case VK_RIGHT:
|
||||
case VK_DOWN:
|
||||
{
|
||||
if (gDemoApplication)
|
||||
gDemoApplication->specialKeyboard(wParam,0,0);
|
||||
break;
|
||||
}
|
||||
|
||||
case ' ':
|
||||
{
|
||||
if (gDemoApplication)
|
||||
gDemoApplication->clientResetScene();
|
||||
break;
|
||||
}
|
||||
case 'Q':
|
||||
case VK_ESCAPE:
|
||||
{
|
||||
quitRequest = 1;
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_CHAR:
|
||||
if (!quitRequest)
|
||||
gDemoApplication->keyboardCallback(wParam,0,0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc( hWnd, message, wParam, lParam );
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Enable OpenGL
|
||||
|
||||
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
int format;
|
||||
|
||||
// get the device context (DC)
|
||||
*hDC = GetDC( hWnd );
|
||||
|
||||
// set the pixel format for the DC
|
||||
ZeroMemory( &pfd, sizeof( pfd ) );
|
||||
pfd.nSize = sizeof( pfd );
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 24;
|
||||
pfd.cDepthBits = 16;
|
||||
pfd.cStencilBits = 1;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
format = ChoosePixelFormat( *hDC, &pfd );
|
||||
SetPixelFormat( *hDC, format, &pfd );
|
||||
|
||||
// create and enable the render context (RC)
|
||||
*hRC = wglCreateContext( *hDC );
|
||||
wglMakeCurrent( *hDC, *hRC );
|
||||
sOpenGLInitialized = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Disable OpenGL
|
||||
|
||||
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC)
|
||||
{
|
||||
sOpenGLInitialized = false;
|
||||
|
||||
wglMakeCurrent( NULL, NULL );
|
||||
wglDeleteContext( hRC );
|
||||
ReleaseDC( hWnd, hDC );
|
||||
}
|
||||
|
||||
#endif //_WINDOWS
|
||||
#ifdef _WINDOWS
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2010 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <gl/gl.h>
|
||||
|
||||
|
||||
#include "DemoApplication.h"
|
||||
|
||||
#include "GLDebugDrawer.h"
|
||||
#include "GLDebugFont.h"
|
||||
|
||||
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
|
||||
|
||||
/// This Win32AppMain is shared code between all demos.
|
||||
/// The actual demo, derived from DemoApplication is created using 'createDemo', in a separate .cpp file
|
||||
DemoApplication* gDemoApplication = 0;
|
||||
DemoApplication* createDemo();
|
||||
|
||||
|
||||
// Function Declarations
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC);
|
||||
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC);
|
||||
static bool sOpenGLInitialized = false;
|
||||
static int sWidth = 0;
|
||||
static int sHeight =0;
|
||||
static int quitRequest = 0;
|
||||
|
||||
// WinMain
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine, int iCmdShow)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
HWND hWnd;
|
||||
HDC hDC;
|
||||
HGLRC hRC;
|
||||
MSG msg;
|
||||
BOOL quit = FALSE;
|
||||
float theta = 0.0f;
|
||||
|
||||
gDemoApplication = createDemo();
|
||||
|
||||
|
||||
// register window class
|
||||
wc.style = CS_OWNDC;
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
|
||||
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = "BulletPhysics";
|
||||
RegisterClass( &wc );
|
||||
|
||||
// create main window
|
||||
hWnd = CreateWindow(
|
||||
"BulletPhysics", "Bullet Physics Sample. http://bulletphysics.org",
|
||||
WS_CAPTION | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
|
||||
// 0, 0, 640, 480,
|
||||
0, 0, 1024, 768,
|
||||
NULL, NULL, hInstance, NULL );
|
||||
|
||||
// enable OpenGL for the window
|
||||
EnableOpenGL( hWnd, &hDC, &hRC );
|
||||
|
||||
|
||||
GLDebugDrawer debugDraw;
|
||||
gDemoApplication->myinit();
|
||||
//gDemoApplication->reshape(1024, 768);
|
||||
gDemoApplication->initPhysics();
|
||||
if (gDemoApplication->getDynamicsWorld())
|
||||
gDemoApplication->getDynamicsWorld()->setDebugDrawer(&debugDraw);
|
||||
|
||||
gDemoApplication->reshape(sWidth,sHeight);
|
||||
|
||||
// program main loop
|
||||
while ( !quit )
|
||||
{
|
||||
|
||||
// check for messages
|
||||
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
|
||||
{
|
||||
|
||||
// handle or dispatch messages
|
||||
if ( msg.message == WM_QUIT )
|
||||
{
|
||||
quit = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
|
||||
// gDemoApplication->displayCallback();
|
||||
|
||||
|
||||
};
|
||||
|
||||
// OpenGL animation code goes here
|
||||
|
||||
glClearColor( .7f, 0.7f, 0.7f, 1.f );
|
||||
|
||||
gDemoApplication->moveAndDisplay();
|
||||
|
||||
|
||||
SwapBuffers( hDC );
|
||||
|
||||
theta += 1.0f;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// shutdown OpenGL
|
||||
DisableOpenGL( hWnd, hDC, hRC );
|
||||
|
||||
// destroy the window explicitly
|
||||
DestroyWindow( hWnd );
|
||||
|
||||
delete gDemoApplication;
|
||||
|
||||
return msg.wParam;
|
||||
|
||||
}
|
||||
|
||||
// Window Procedure
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch (message)
|
||||
{
|
||||
|
||||
case WM_SYSKEYDOWN:
|
||||
{
|
||||
if (lParam & 1<<29)
|
||||
{
|
||||
gDemoApplication->m_modifierKeys = VK_LMENU;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_SYSKEYUP:
|
||||
{
|
||||
if (lParam & 1<<29)
|
||||
{
|
||||
gDemoApplication->m_modifierKeys = VK_LMENU;
|
||||
} else
|
||||
{
|
||||
gDemoApplication->m_modifierKeys = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case WM_SIZE: // Size Action Has Taken Place
|
||||
|
||||
switch (wParam) // Evaluate Size Action
|
||||
{
|
||||
case SIZE_MINIMIZED: // Was Window Minimized?
|
||||
return 0; // Return
|
||||
|
||||
case SIZE_MAXIMIZED: // Was Window Maximized?
|
||||
sWidth = LOWORD (lParam);
|
||||
sHeight = HIWORD (lParam);
|
||||
if (sOpenGLInitialized)
|
||||
{
|
||||
gDemoApplication->reshape(sWidth,sHeight);
|
||||
}
|
||||
return 0; // Return
|
||||
|
||||
case SIZE_RESTORED: // Was Window Restored?
|
||||
sWidth = LOWORD (lParam);
|
||||
sHeight = HIWORD (lParam);
|
||||
if (sOpenGLInitialized)
|
||||
{
|
||||
gDemoApplication->reshape(sWidth,sHeight);
|
||||
}
|
||||
return 0; // Return
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CREATE:
|
||||
return 0;
|
||||
|
||||
case WM_MBUTTONUP:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(1,1,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
case WM_MBUTTONDOWN:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(1,0,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(0,1,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
case 0x020A://WM_MOUSEWHEEL:
|
||||
{
|
||||
|
||||
int zDelta = (short)HIWORD(wParam);
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
if (zDelta>0)
|
||||
gDemoApplication->zoomIn();
|
||||
else
|
||||
gDemoApplication->zoomOut();
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseMotionFunc(xPos,yPos);
|
||||
break;
|
||||
}
|
||||
case WM_RBUTTONUP:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(2,1,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
case WM_RBUTTONDOWN:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(2,0,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
gDemoApplication->mouseFunc(0,0,xPos,yPos);
|
||||
break;
|
||||
}
|
||||
/*#define WM_LBUTTONUP 0x0202
|
||||
#define WM_LBUTTONDBLCLK 0x0203
|
||||
#define WM_RBUTTONDOWN 0x0204
|
||||
#define WM_RBUTTONUP 0x0205
|
||||
#define WM_RBUTTONDBLCLK 0x0206
|
||||
#define WM_MBUTTONDOWN 0x0207
|
||||
#define WM_MBUTTONUP 0x0208
|
||||
#define WM_MBUTTONDBLCLK 0x0209
|
||||
*/
|
||||
|
||||
|
||||
|
||||
case WM_CLOSE:
|
||||
PostQuitMessage( 0 );
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
return 0;
|
||||
|
||||
case WM_KEYUP:
|
||||
switch ( wParam )
|
||||
{
|
||||
|
||||
case VK_PRIOR:
|
||||
case VK_NEXT:
|
||||
case VK_END:
|
||||
case VK_HOME:
|
||||
case VK_LEFT:
|
||||
case VK_UP:
|
||||
case VK_RIGHT:
|
||||
case VK_DOWN:
|
||||
{
|
||||
if (gDemoApplication)
|
||||
gDemoApplication->specialKeyboardUp(wParam,0,0);
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return DefWindowProc( hWnd, message, wParam, lParam );
|
||||
}
|
||||
|
||||
case WM_KEYDOWN:
|
||||
printf("bla\n");
|
||||
switch ( wParam )
|
||||
{
|
||||
case VK_CONTROL:
|
||||
case VK_PRIOR:
|
||||
case VK_NEXT:
|
||||
case VK_END:
|
||||
case VK_HOME:
|
||||
case VK_LEFT:
|
||||
case VK_UP:
|
||||
case VK_RIGHT:
|
||||
case VK_DOWN:
|
||||
{
|
||||
if (gDemoApplication)
|
||||
gDemoApplication->specialKeyboard(wParam,0,0);
|
||||
break;
|
||||
}
|
||||
|
||||
case ' ':
|
||||
{
|
||||
if (gDemoApplication)
|
||||
gDemoApplication->clientResetScene();
|
||||
break;
|
||||
}
|
||||
case 'Q':
|
||||
case VK_ESCAPE:
|
||||
{
|
||||
quitRequest = 1;
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_CHAR:
|
||||
if (!quitRequest)
|
||||
gDemoApplication->keyboardCallback(wParam,0,0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc( hWnd, message, wParam, lParam );
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Enable OpenGL
|
||||
|
||||
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
int format;
|
||||
|
||||
// get the device context (DC)
|
||||
*hDC = GetDC( hWnd );
|
||||
|
||||
// set the pixel format for the DC
|
||||
ZeroMemory( &pfd, sizeof( pfd ) );
|
||||
pfd.nSize = sizeof( pfd );
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 24;
|
||||
pfd.cDepthBits = 16;
|
||||
pfd.cStencilBits = 1;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
format = ChoosePixelFormat( *hDC, &pfd );
|
||||
SetPixelFormat( *hDC, format, &pfd );
|
||||
|
||||
// create and enable the render context (RC)
|
||||
*hRC = wglCreateContext( *hDC );
|
||||
wglMakeCurrent( *hDC, *hRC );
|
||||
sOpenGLInitialized = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Disable OpenGL
|
||||
|
||||
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC)
|
||||
{
|
||||
sOpenGLInitialized = false;
|
||||
|
||||
wglMakeCurrent( NULL, NULL );
|
||||
wglDeleteContext( hRC );
|
||||
ReleaseDC( hWnd, hDC );
|
||||
}
|
||||
|
||||
#endif //_WINDOWS
|
||||
|
||||
@@ -1,79 +1,79 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifdef _WINDOWS
|
||||
|
||||
#include "Win32DemoApplication.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
void Win32DemoApplication::renderme()
|
||||
{
|
||||
}
|
||||
void Win32DemoApplication::setTexturing(bool useTexture)
|
||||
{
|
||||
}
|
||||
|
||||
void Win32DemoApplication::setShadows(bool useShadows)
|
||||
{
|
||||
}
|
||||
|
||||
void Win32DemoApplication::setCameraDistance(float camDist)
|
||||
{
|
||||
}
|
||||
void Win32DemoApplication::clientResetScene()
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void Win32DemoApplication::updateModifierKeys()
|
||||
{
|
||||
//not yet
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Win32DemoApplication::specialKeyboard(int key, int x, int y)
|
||||
{
|
||||
(void)x;
|
||||
(void)y;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case VK_LEFT : stepLeft(); break;
|
||||
case VK_RIGHT : stepRight(); break;
|
||||
case VK_UP : stepFront(); break;
|
||||
case VK_DOWN : stepBack(); break;
|
||||
|
||||
// case GLUT_KEY_PAGE_UP : zoomIn(); break;
|
||||
// case GLUT_KEY_PAGE_DOWN : zoomOut(); break;
|
||||
// case GLUT_KEY_HOME : toggleIdle(); break;
|
||||
|
||||
default:
|
||||
// std::cout << "unused (special) key : " << key << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Win32DemoApplication::swapBuffers()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifdef _WINDOWS
|
||||
|
||||
#include "Win32DemoApplication.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
void Win32DemoApplication::renderme()
|
||||
{
|
||||
}
|
||||
void Win32DemoApplication::setTexturing(bool useTexture)
|
||||
{
|
||||
}
|
||||
|
||||
void Win32DemoApplication::setShadows(bool useShadows)
|
||||
{
|
||||
}
|
||||
|
||||
void Win32DemoApplication::setCameraDistance(float camDist)
|
||||
{
|
||||
}
|
||||
void Win32DemoApplication::clientResetScene()
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void Win32DemoApplication::updateModifierKeys()
|
||||
{
|
||||
//not yet
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Win32DemoApplication::specialKeyboard(int key, int x, int y)
|
||||
{
|
||||
(void)x;
|
||||
(void)y;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case VK_LEFT : stepLeft(); break;
|
||||
case VK_RIGHT : stepRight(); break;
|
||||
case VK_UP : stepFront(); break;
|
||||
case VK_DOWN : stepBack(); break;
|
||||
|
||||
// case GLUT_KEY_PAGE_UP : zoomIn(); break;
|
||||
// case GLUT_KEY_PAGE_DOWN : zoomOut(); break;
|
||||
// case GLUT_KEY_HOME : toggleIdle(); break;
|
||||
|
||||
default:
|
||||
// std::cout << "unused (special) key : " << key << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Win32DemoApplication::swapBuffers()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WIN32_DEMO_APPLICATION_H
|
||||
#define WIN32_DEMO_APPLICATION_H
|
||||
|
||||
|
||||
#include "DemoApplication.h"
|
||||
|
||||
class Win32DemoApplication : public DemoApplication
|
||||
{
|
||||
protected:
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
virtual void swapBuffers();
|
||||
|
||||
void specialKeyboard(int key, int x, int y);
|
||||
|
||||
virtual void updateModifierKeys();
|
||||
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WIN32_DEMO_APPLICATION_H
|
||||
#define WIN32_DEMO_APPLICATION_H
|
||||
|
||||
|
||||
#include "DemoApplication.h"
|
||||
|
||||
class Win32DemoApplication : public DemoApplication
|
||||
{
|
||||
protected:
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
virtual void swapBuffers();
|
||||
|
||||
void specialKeyboard(int key, int x, int y);
|
||||
|
||||
virtual void updateModifierKeys();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //WIN32_DEMO_APPLICATION_H
|
||||
@@ -1,45 +1,45 @@
|
||||
#### Source code Dirs
|
||||
VPATH = ../
|
||||
|
||||
ROOT = ../../..
|
||||
HOST = /usr/include
|
||||
|
||||
#### Library
|
||||
LIBRARY_ppu = bulletopenglsupport.a
|
||||
|
||||
#### Compiler flags
|
||||
CPPFLAGS = -DUSE_LIBSPE2 \
|
||||
-I$(ROOT)/Extras/ConvexHull \
|
||||
-I$(ROOT)/src/ \
|
||||
-I$(SDKINC) \
|
||||
-I$(HOST)
|
||||
|
||||
#### Optimization level flags
|
||||
#CC_OPT_LEVEL = $(CC_OPT_LEVEL_DEBUG)
|
||||
CC_OPT_LEVEL = -O3
|
||||
|
||||
##### Objects to be archived in lib
|
||||
OBJS = \
|
||||
BMF_Api.o \
|
||||
BMF_BitmapFont.o \
|
||||
BMF_font_helv10.o \
|
||||
DemoApplication.o \
|
||||
GLDebugDrawer.o \
|
||||
GL_ShapeDrawer.o \
|
||||
GL_Simplex1to4.o \
|
||||
GlutStuff.o \
|
||||
RenderTexture.o
|
||||
|
||||
#### Install directories
|
||||
INSTALL_DIR = $(ROOT)/lib/ibmsdk/
|
||||
INSTALL_FILES = $(LIBRARY)
|
||||
|
||||
IBM_CELLSDK_VERSION := $(shell if [ -d /opt/cell ]; then echo "3.0"; fi)
|
||||
|
||||
ifeq ("$(IBM_CELLSDK_VERSION)","3.0")
|
||||
CELL_TOP ?= /opt/cell/sdk
|
||||
include $(CELL_TOP)/buildutils/make.footer
|
||||
else
|
||||
CELL_TOP ?= /opt/ibm/cell-sdk/prototype
|
||||
include $(CELL_TOP)/make.footer
|
||||
endif
|
||||
#### Source code Dirs
|
||||
VPATH = ../
|
||||
|
||||
ROOT = ../../..
|
||||
HOST = /usr/include
|
||||
|
||||
#### Library
|
||||
LIBRARY_ppu = bulletopenglsupport.a
|
||||
|
||||
#### Compiler flags
|
||||
CPPFLAGS = -DUSE_LIBSPE2 \
|
||||
-I$(ROOT)/Extras/ConvexHull \
|
||||
-I$(ROOT)/src/ \
|
||||
-I$(SDKINC) \
|
||||
-I$(HOST)
|
||||
|
||||
#### Optimization level flags
|
||||
#CC_OPT_LEVEL = $(CC_OPT_LEVEL_DEBUG)
|
||||
CC_OPT_LEVEL = -O3
|
||||
|
||||
##### Objects to be archived in lib
|
||||
OBJS = \
|
||||
BMF_Api.o \
|
||||
BMF_BitmapFont.o \
|
||||
BMF_font_helv10.o \
|
||||
DemoApplication.o \
|
||||
GLDebugDrawer.o \
|
||||
GL_ShapeDrawer.o \
|
||||
GL_Simplex1to4.o \
|
||||
GlutStuff.o \
|
||||
RenderTexture.o
|
||||
|
||||
#### Install directories
|
||||
INSTALL_DIR = $(ROOT)/lib/ibmsdk/
|
||||
INSTALL_FILES = $(LIBRARY)
|
||||
|
||||
IBM_CELLSDK_VERSION := $(shell if [ -d /opt/cell ]; then echo "3.0"; fi)
|
||||
|
||||
ifeq ("$(IBM_CELLSDK_VERSION)","3.0")
|
||||
CELL_TOP ?= /opt/cell/sdk
|
||||
include $(CELL_TOP)/buildutils/make.footer
|
||||
else
|
||||
CELL_TOP ?= /opt/ibm/cell-sdk/prototype
|
||||
include $(CELL_TOP)/make.footer
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user