2006-09-11 05:31:22 +00:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32//for glut.h
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//think different
|
|
|
|
#if defined(__APPLE__) && !defined (VMDMESA)
|
|
|
|
#include <OpenGL/gl.h>
|
|
|
|
#include <OpenGL/glu.h>
|
|
|
|
#include <GLUT/glut.h>
|
|
|
|
#else
|
|
|
|
#include <GL/glut.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
2006-09-27 20:43:51 +00:00
|
|
|
#include "LinearMath/btVector3.h"
|
|
|
|
#include "LinearMath/btMatrix3x3.h"
|
|
|
|
#include "LinearMath/btTransform.h"
|
2006-10-19 05:33:36 +00:00
|
|
|
#include "LinearMath/btQuickprof.h"
|
2006-09-11 05:31:22 +00:00
|
|
|
|
2006-09-27 20:43:51 +00:00
|
|
|
class btCollisionShape;
|
|
|
|
class btDynamicsWorld;
|
|
|
|
class btRigidBody;
|
|
|
|
class btTypedConstraint;
|
2006-09-11 05:31:22 +00:00
|
|
|
|
|
|
|
class DemoApplication
|
|
|
|
{
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
2006-10-18 03:28:42 +00:00
|
|
|
hidden::Clock m_clock;
|
|
|
|
|
2006-09-11 05:31:22 +00:00
|
|
|
///this is the most important class
|
2006-09-27 20:43:51 +00:00
|
|
|
btDynamicsWorld* m_dynamicsWorld;
|
|
|
|
|
2006-09-30 01:36:39 +00:00
|
|
|
///constraint for mouse picking
|
2006-09-27 20:43:51 +00:00
|
|
|
btTypedConstraint* m_pickConstraint;
|
2006-09-11 05:31:22 +00:00
|
|
|
|
|
|
|
float m_cameraDistance;
|
|
|
|
int m_debugMode;
|
|
|
|
|
|
|
|
float m_ele;
|
|
|
|
float m_azi;
|
2006-09-27 20:43:51 +00:00
|
|
|
btVector3 m_cameraPosition;
|
|
|
|
btVector3 m_cameraTargetPosition;//look at
|
2006-09-11 05:31:22 +00:00
|
|
|
|
|
|
|
float m_scaleBottom;
|
|
|
|
float m_scaleFactor;
|
2006-09-27 20:43:51 +00:00
|
|
|
btVector3 m_cameraUp;
|
2006-09-11 05:31:22 +00:00
|
|
|
int m_forwardAxis;
|
|
|
|
|
|
|
|
int m_glutScreenWidth;
|
|
|
|
int m_glutScreenHeight;
|
|
|
|
|
|
|
|
float m_ShootBoxInitialSpeed;
|
|
|
|
|
|
|
|
bool m_stepping;
|
|
|
|
bool m_singleStep;
|
|
|
|
bool m_idle;
|
|
|
|
int m_lastKey;
|
|
|
|
|
2006-09-30 01:36:39 +00:00
|
|
|
public:
|
2006-09-11 05:31:22 +00:00
|
|
|
|
|
|
|
DemoApplication();
|
|
|
|
|
|
|
|
virtual ~DemoApplication();
|
|
|
|
|
2006-09-30 01:36:39 +00:00
|
|
|
btDynamicsWorld* getDynamicsWorld()
|
|
|
|
{
|
|
|
|
return m_dynamicsWorld;
|
|
|
|
}
|
2006-09-11 05:31:22 +00:00
|
|
|
|
2006-11-11 23:59:51 +00:00
|
|
|
void setOrthographicProjection();
|
|
|
|
void resetPerspectiveProjection();
|
|
|
|
|
2006-09-11 05:31:22 +00:00
|
|
|
int getDebugMode()
|
|
|
|
{
|
|
|
|
return m_debugMode ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDebugMode(int mode)
|
|
|
|
{
|
|
|
|
m_debugMode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-27 20:43:51 +00:00
|
|
|
void setCameraUp(const btVector3& camUp)
|
2006-09-11 05:31:22 +00:00
|
|
|
{
|
|
|
|
m_cameraUp = camUp;
|
|
|
|
}
|
|
|
|
void setCameraForwardAxis(int axis)
|
|
|
|
{
|
|
|
|
m_forwardAxis = axis;
|
|
|
|
}
|
|
|
|
|
|
|
|
void myinit();
|
|
|
|
|
|
|
|
void toggleIdle();
|
|
|
|
|
|
|
|
virtual void updateCamera();
|
|
|
|
|
2006-09-27 20:43:51 +00:00
|
|
|
btVector3 getCameraPosition()
|
2006-09-11 05:31:22 +00:00
|
|
|
{
|
|
|
|
return m_cameraPosition;
|
|
|
|
}
|
2006-09-27 20:43:51 +00:00
|
|
|
btVector3 getCameraTargetPosition()
|
2006-09-11 05:31:22 +00:00
|
|
|
{
|
|
|
|
return m_cameraTargetPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///glut callbacks
|
|
|
|
|
|
|
|
float getCameraDistance();
|
|
|
|
void setCameraDistance(float dist);
|
|
|
|
void moveAndDisplay();
|
|
|
|
|
|
|
|
virtual void clientMoveAndDisplay() = 0;
|
|
|
|
|
2006-10-18 03:28:42 +00:00
|
|
|
virtual void clientResetScene();
|
2006-09-11 05:31:22 +00:00
|
|
|
|
|
|
|
///Demo functions
|
2006-09-27 20:43:51 +00:00
|
|
|
void shootBox(const btVector3& destination);
|
|
|
|
|
2006-10-06 05:22:13 +00:00
|
|
|
|
2006-09-28 01:11:16 +00:00
|
|
|
btVector3 getRayTo(int x,int y);
|
2006-09-11 05:31:22 +00:00
|
|
|
|
2006-10-04 23:46:27 +00:00
|
|
|
btRigidBody* localCreateRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape);
|
2006-09-11 05:31:22 +00:00
|
|
|
|
|
|
|
///callback methods by glut
|
|
|
|
|
|
|
|
virtual void keyboardCallback(unsigned char key, int x, int y);
|
|
|
|
|
|
|
|
virtual void specialKeyboard(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();
|
|
|
|
|
|
|
|
|
|
|
|
void stepLeft();
|
|
|
|
void stepRight();
|
|
|
|
void stepFront();
|
|
|
|
void stepBack();
|
|
|
|
void zoomIn();
|
|
|
|
void zoomOut();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2006-09-23 14:51:54 +00:00
|
|
|
#endif //DEMO_APPLICATION_H
|
|
|
|
|