Updated INSTALL description. This info should go also in Bullet User Manual and Online.
Thanks to ejtttje http://code.google.com/p/bullet/issues/detail?id=248 Use GJK for GImpact triangle test See http://bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=3687 More improvements in GJK degeneracy handling (using second EPA/GJK run) Issue/discussion here http://code.google.com/p/bullet/issues/detail?id=250 CMake improvements Thanks to ejtttje http://code.google.com/p/bullet/issues/detail?id=247 Added basic camera/wall detection for character demo
This commit is contained in:
@@ -237,11 +237,20 @@ void CharacterDemo::clientMoveAndDisplay()
|
||||
btScalar walkVelocity = btScalar(1.1) * 4.0; // 4 km/h -> 1.1 m/s
|
||||
btScalar walkSpeed = walkVelocity * dt;
|
||||
|
||||
//rotate view
|
||||
if (gLeft)
|
||||
walkDirection += strafeDir;
|
||||
{
|
||||
btMatrix3x3 orn = m_ghostObject->getWorldTransform().getBasis();
|
||||
orn *= btMatrix3x3(btQuaternion(btVector3(0,1,0),0.01));
|
||||
m_ghostObject->getWorldTransform ().setBasis(orn);
|
||||
}
|
||||
|
||||
if (gRight)
|
||||
walkDirection -= strafeDir;
|
||||
{
|
||||
btMatrix3x3 orn = m_ghostObject->getWorldTransform().getBasis();
|
||||
orn *= btMatrix3x3(btQuaternion(btVector3(0,1,0),-0.01));
|
||||
m_ghostObject->getWorldTransform ().setBasis(orn);
|
||||
}
|
||||
|
||||
if (gForward)
|
||||
walkDirection += forwardDir;
|
||||
@@ -424,7 +433,29 @@ void CharacterDemo::updateCamera()
|
||||
backward.normalize ();
|
||||
|
||||
m_cameraTargetPosition = characterWorldTrans.getOrigin();
|
||||
m_cameraPosition = m_cameraTargetPosition + up * 2.0 + backward * 12.0;
|
||||
m_cameraPosition = m_cameraTargetPosition + up * 10.0 + backward * 12.0;
|
||||
|
||||
//use the convex sweep test to find a safe position for the camera (not blocked by static geometry)
|
||||
btSphereShape cameraSphere(0.2f);
|
||||
btTransform cameraFrom,cameraTo;
|
||||
cameraFrom.setIdentity();
|
||||
cameraFrom.setOrigin(characterWorldTrans.getOrigin());
|
||||
cameraTo.setIdentity();
|
||||
cameraTo.setOrigin(m_cameraPosition);
|
||||
|
||||
btCollisionWorld::ClosestConvexResultCallback cb( characterWorldTrans.getOrigin(), cameraTo.getOrigin() );
|
||||
cb.m_collisionFilterMask = btBroadphaseProxy::StaticFilter;
|
||||
|
||||
m_dynamicsWorld->convexSweepTest(&cameraSphere,cameraFrom,cameraTo,cb);
|
||||
if (cb.hasHit())
|
||||
{
|
||||
|
||||
btScalar minFraction = cb.m_closestHitFraction;//btMax(btScalar(0.3),cb.m_closestHitFraction);
|
||||
m_cameraPosition.setInterpolate3(cameraFrom.getOrigin(),cameraTo.getOrigin(),minFraction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//update OpenGL camera settings
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 10000.0);
|
||||
|
||||
@@ -15,10 +15,16 @@ subject to the following restrictions:
|
||||
#ifndef CONTINUOUS_CONVEX_COLLISION_DEMO_H
|
||||
#define CONTINUOUS_CONVEX_COLLISION_DEMO_H
|
||||
|
||||
#include "GlutDemoApplication.h"
|
||||
|
||||
|
||||
///ContinuousConvexCollisionDemo shows the working of the continuous collision detection, including linear and angular motion
|
||||
#ifdef _WINDOWS
|
||||
#include "Win32DemoApplication.h"
|
||||
class btContinuousConvexCollisionDemo : public Win32DemoApplication
|
||||
#else
|
||||
#include "GlutDemoApplication.h"
|
||||
class btContinuousConvexCollisionDemo : public GlutDemoApplication
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ btTransform toTrans[maxNumObjects];
|
||||
int screenWidth = 640;
|
||||
int screenHeight = 480;
|
||||
|
||||
|
||||
#ifndef _WINDOWS
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
btContinuousConvexCollisionDemo* ccdDemo = new btContinuousConvexCollisionDemo();
|
||||
@@ -74,6 +74,17 @@ int main(int argc,char** argv)
|
||||
|
||||
return glutmain(argc, argv,screenWidth,screenHeight,"Continuous Convex Collision Demo",ccdDemo);
|
||||
}
|
||||
#else
|
||||
DemoApplication* createDemo()
|
||||
{
|
||||
btContinuousConvexCollisionDemo* ccdDemo = new btContinuousConvexCollisionDemo();
|
||||
|
||||
ccdDemo->setCameraDistance(40.f);
|
||||
return ccdDemo;
|
||||
|
||||
}
|
||||
#endif //_WINDOWS
|
||||
|
||||
|
||||
void btContinuousConvexCollisionDemo::initPhysics()
|
||||
{
|
||||
@@ -280,8 +291,7 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
||||
}
|
||||
}
|
||||
|
||||
glFlush();
|
||||
glutSwapBuffers();
|
||||
swapBuffers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ subject to the following restrictions:
|
||||
#define START_POS_Y 5
|
||||
#define START_POS_Z 0
|
||||
|
||||
#include "BasicDemo3D.h"
|
||||
#include "BasicDemo3d.h"
|
||||
#include "GlutStuff.h"
|
||||
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
@@ -45,7 +45,7 @@ subject to the following restrictions:
|
||||
#undef BT_GPU_PREF
|
||||
#endif
|
||||
|
||||
#include "btGpuDemo3DSharedTypes.h"
|
||||
#include "btGpuDemo3dSharedTypes.h"
|
||||
|
||||
//#define CUDA_DEMO_DYNAMICS_WORLD3D_MAX_BATCHES 20
|
||||
#define CUDA_DEMO_DYNAMICS_WORLD3D_MAX_BATCHES 15
|
||||
|
||||
@@ -13,7 +13,7 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "BasicDemo3D.h"
|
||||
#include "BasicDemo3d.h"
|
||||
#include "GlutStuff.h"
|
||||
#include "GLDebugDrawer.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
@@ -58,4 +58,4 @@ int main(int argc,char** argv)
|
||||
|
||||
//default glut doesn't return from mainloop
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,9 @@ class DemoApplication
|
||||
int m_mouseOldX;
|
||||
int m_mouseOldY;
|
||||
int m_mouseButtons;
|
||||
public:
|
||||
int m_modifierKeys;
|
||||
protected:
|
||||
|
||||
float m_scaleBottom;
|
||||
float m_scaleFactor;
|
||||
|
||||
@@ -25,9 +25,9 @@ subject to the following restrictions:
|
||||
#include <OpenGL/glu.h>
|
||||
#include <GLUT/glut.h>
|
||||
#else
|
||||
#ifndef _WINDOWS
|
||||
|
||||
#include <GL/glut.h>
|
||||
#else
|
||||
#ifndef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
@@ -49,6 +49,8 @@ subject to the following restrictions:
|
||||
#define BT_KEY_PAGEDOWN VK_NEXT
|
||||
#define BT_KEY_END VK_END
|
||||
#define BT_KEY_HOME VK_HOME
|
||||
#define BT_ACTIVE_ALT VK_LMENU
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
@@ -32,7 +32,6 @@ DemoApplication* gDemoApplication = 0;
|
||||
DemoApplication* createDemo();
|
||||
|
||||
|
||||
|
||||
// Function Declarations
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
@@ -86,7 +85,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
gDemoApplication->myinit();
|
||||
//gDemoApplication->reshape(1024, 768);
|
||||
gDemoApplication->initPhysics();
|
||||
gDemoApplication->getDynamicsWorld()->setDebugDrawer(&debugDraw);
|
||||
if (gDemoApplication->getDynamicsWorld())
|
||||
gDemoApplication->getDynamicsWorld()->setDebugDrawer(&debugDraw);
|
||||
|
||||
|
||||
// program main loop
|
||||
@@ -146,10 +146,35 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
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?
|
||||
|
||||
@@ -41,6 +41,12 @@ void Win32DemoApplication::clientResetScene()
|
||||
}
|
||||
#endif
|
||||
|
||||
void Win32DemoApplication::updateModifierKeys()
|
||||
{
|
||||
//not yet
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Win32DemoApplication::specialKeyboard(int key, int x, int y)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
|
||||
void specialKeyboard(int key, int x, int y);
|
||||
|
||||
virtual void updateModifierKeys();
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user