Merge branch 'master' of https://github.com/erwincoumans/bullet3
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "../../Demos/SerializeDemo/SerializeSetup.h"
|
||||
#include "../bullet2/MultiBodyDemo/TestJointTorqueSetup.h"
|
||||
#include "../bullet2/CollisionDetection/SupportFuncDemo.h"
|
||||
#include "../bullet2/BasicConcepts/CoordinateSystemDemo.h"
|
||||
|
||||
static BulletDemoInterface* TestJointTorqueCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
@@ -83,6 +84,7 @@ static BulletDemoInterface* MyImportColladaCreateFunc(CommonGraphicsApp* app)
|
||||
|
||||
|
||||
|
||||
|
||||
struct BulletDemoEntry
|
||||
{
|
||||
int m_menuLevel;
|
||||
@@ -94,9 +96,9 @@ struct BulletDemoEntry
|
||||
static BulletDemoEntry allDemos[]=
|
||||
{
|
||||
|
||||
{0,"LowLevel",0},
|
||||
{1,"SupportFunc", &MySupportFuncDemo::CreateFunc},
|
||||
|
||||
{0,"Basic Concepts",0},
|
||||
{1,"Basis Frame", &CoordinateSystemDemo::CreateFunc},
|
||||
{1,"SupportFunc", &MySupportFuncDemo::CreateFunc},
|
||||
//{"emptydemo",EmptyBulletDemo::MyCreateFunc},
|
||||
{0,"API Demos", 0},
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ subject to the following restrictions:
|
||||
#include <stdio.h> //fopen
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include <string>
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "tinyxml/tinyxml.h"
|
||||
|
||||
#include "Bullet3Common/b3FileUtils.h"
|
||||
|
||||
@@ -118,7 +118,7 @@ ATTRIBUTE_ALIGNED16(class) btMatrix4x4
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btMatrix4x4
|
||||
btMatrix4x4::operator*=(const btMatrix4x4& m)
|
||||
operator*=(const btMatrix4x4& m)
|
||||
{
|
||||
setValue(
|
||||
m.tdotx(m_el[0]), m.tdoty(m_el[0]), m.tdotz(m_el[0]),m.tdotw(m_el[0]),
|
||||
|
||||
143
Demos3/bullet2/BasicConcepts/CoordinateSystemDemo.h
Normal file
143
Demos3/bullet2/BasicConcepts/CoordinateSystemDemo.h
Normal file
@@ -0,0 +1,143 @@
|
||||
#ifndef COORDINATE_SYSTEM_DEMO_H
|
||||
#define COORDINATE_SYSTEM_DEMO_H
|
||||
|
||||
#include "Bullet3AppSupport/BulletDemoInterface.h"
|
||||
#include "OpenGLWindow/CommonGraphicsApp.h"
|
||||
|
||||
|
||||
///quick demo showing the right-handed coordinate system and positive rotations around each axis
|
||||
class CoordinateSystemDemo : public BulletDemoInterface
|
||||
{
|
||||
CommonGraphicsApp* m_app;
|
||||
float m_x;
|
||||
float m_y;
|
||||
float m_z;
|
||||
|
||||
public:
|
||||
|
||||
CoordinateSystemDemo(CommonGraphicsApp* app)
|
||||
:m_app(app),
|
||||
m_x(0),
|
||||
m_y(0),
|
||||
m_z(0)
|
||||
{
|
||||
m_app->setUpAxis(2);
|
||||
|
||||
{
|
||||
int boxId = m_app->registerCubeShape(0.1,0.1,0.1);
|
||||
btVector3 pos(0,0,0);
|
||||
btQuaternion orn(0,0,0,1);
|
||||
btVector4 color(0.3,0.3,0.3,1);
|
||||
btVector3 scaling(1,1,1);
|
||||
m_app->m_renderer->registerGraphicsInstance(boxId,pos,orn,color,scaling);
|
||||
}
|
||||
|
||||
m_app->m_renderer->writeTransforms();
|
||||
}
|
||||
virtual ~CoordinateSystemDemo()
|
||||
{
|
||||
m_app->m_renderer->enableBlend(false);
|
||||
}
|
||||
static BulletDemoInterface* CreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new CoordinateSystemDemo(app);
|
||||
}
|
||||
|
||||
virtual void initPhysics()
|
||||
{
|
||||
}
|
||||
virtual void exitPhysics()
|
||||
{
|
||||
|
||||
}
|
||||
virtual void stepSimulation(float deltaTime)
|
||||
{
|
||||
m_x+=0.01f;
|
||||
m_y+=0.01f;
|
||||
m_z+=0.01f;
|
||||
|
||||
}
|
||||
virtual void renderScene()
|
||||
{
|
||||
m_app->m_renderer->renderScene();
|
||||
}
|
||||
|
||||
virtual void drawArc(const btVector3& center, const btVector3& normal, const btVector3& axis, btScalar radiusA, btScalar radiusB, btScalar minAngle, btScalar maxAngle,
|
||||
const btVector3& color, bool drawSect, btScalar stepDegrees = btScalar(10.f))
|
||||
{
|
||||
btScalar lineWidth = 3;
|
||||
const btVector3& vx = axis;
|
||||
btVector3 vy = normal.cross(axis);
|
||||
btScalar step = stepDegrees * SIMD_RADS_PER_DEG;
|
||||
int nSteps = (int)btFabs((maxAngle - minAngle) / step);
|
||||
if(!nSteps) nSteps = 1;
|
||||
btVector3 prev = center + radiusA * vx * btCos(minAngle) + radiusB * vy * btSin(minAngle);
|
||||
if(drawSect)
|
||||
{
|
||||
m_app->m_renderer->drawLine(center, prev, color,lineWidth);
|
||||
}
|
||||
for(int i = 1; i <= nSteps; i++)
|
||||
{
|
||||
btScalar angle = minAngle + (maxAngle - minAngle) * btScalar(i) / btScalar(nSteps);
|
||||
btVector3 next = center + radiusA * vx * btCos(angle) + radiusB * vy * btSin(angle);
|
||||
m_app->m_renderer->drawLine(prev, next, color,lineWidth);
|
||||
prev = next;
|
||||
}
|
||||
if(drawSect)
|
||||
{
|
||||
m_app->m_renderer->drawLine(center, prev, color,lineWidth);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void physicsDebugDraw()
|
||||
{
|
||||
|
||||
btVector3 xUnit(1,0,0);
|
||||
btVector3 yUnit(0,1,0);
|
||||
btVector3 zUnit(0,0,1);
|
||||
|
||||
btScalar lineWidth=3;
|
||||
|
||||
btQuaternion rotAroundX(xUnit,m_x);
|
||||
btQuaternion rotAroundY(yUnit,m_y);
|
||||
btQuaternion rotAroundZ(zUnit,m_z);
|
||||
|
||||
btScalar radius=0.5;
|
||||
btVector3 toX=radius*quatRotate(rotAroundX,yUnit);
|
||||
btVector3 toY=radius*quatRotate(rotAroundY,xUnit);
|
||||
btVector3 toZ=radius*quatRotate(rotAroundZ,xUnit);
|
||||
|
||||
m_app->m_renderer->drawLine(xUnit+toX+quatRotate(rotAroundX,btVector3(0,0.1,-0.2)),xUnit+toX,xUnit,lineWidth);
|
||||
m_app->m_renderer->drawLine(xUnit+toX+quatRotate(rotAroundX,btVector3(0,-0.2,-0.2)),xUnit+toX,xUnit,lineWidth);
|
||||
//draw the letter 'x' on the x-axis
|
||||
//m_app->m_renderer->drawLine(xUnit-0.1*zUnit+0.1*yUnit,xUnit+0.1*zUnit-0.1*yUnit,xUnit,lineWidth);
|
||||
//m_app->m_renderer->drawLine(xUnit+0.1*zUnit+0.1*yUnit,xUnit-0.1*zUnit-0.1*yUnit,xUnit,lineWidth);
|
||||
|
||||
m_app->m_renderer->drawLine(xUnit+toX+quatRotate(rotAroundX,btVector3(0,-0.2,-0.2)),xUnit+toX,xUnit,lineWidth);
|
||||
|
||||
m_app->m_renderer->drawLine(yUnit+toY+quatRotate(rotAroundY,btVector3(-0.2,0,0.2)),yUnit+toY,yUnit,lineWidth);
|
||||
m_app->m_renderer->drawLine(yUnit+toY+quatRotate(rotAroundY,btVector3(0.1,0,0.2)),yUnit+toY,yUnit,lineWidth);
|
||||
m_app->m_renderer->drawLine(zUnit+toZ+quatRotate(rotAroundZ,btVector3(0.1,-0.2,0)),zUnit+toZ,zUnit,lineWidth);
|
||||
m_app->m_renderer->drawLine(zUnit+toZ+quatRotate(rotAroundZ,btVector3(-0.2,-0.2,0)),zUnit+toZ,zUnit,lineWidth);
|
||||
|
||||
|
||||
drawArc(xUnit,xUnit,toX.normalized(),radius,radius,0.4,SIMD_2_PI,xUnit,false);
|
||||
drawArc(yUnit,yUnit,toY.normalized(),radius,radius,0.4,SIMD_2_PI,yUnit,false);
|
||||
drawArc(zUnit,zUnit,toZ.normalized(),radius,radius,0.4,SIMD_2_PI,zUnit,false);
|
||||
}
|
||||
virtual bool mouseMoveCallback(float x,float y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool keyboardCallback(int key, int state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
#endif //COORDINATE_SYSTEM_DEMO_H
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
m_x(0),
|
||||
m_y(0)
|
||||
{
|
||||
m_app->setUpAxis(1);
|
||||
m_sphere = new btSphereShape(1);
|
||||
{
|
||||
int boxId = m_app->registerCubeShape(10,0.1,10);
|
||||
|
||||
@@ -55,6 +55,7 @@ m_pickedConstraint(0),
|
||||
m_pickingMultiBodyPoint2Point(0)
|
||||
|
||||
{
|
||||
app->setUpAxis(1);
|
||||
m_collisionConfiguration = 0;
|
||||
m_dispatcher = 0;
|
||||
m_broadphase = 0;
|
||||
|
||||
@@ -35,6 +35,7 @@ static float friction = 1.;
|
||||
MultiDofDemo::MultiDofDemo(CommonGraphicsApp* app)
|
||||
:FeatherstoneDemo1(app)
|
||||
{
|
||||
app->setUpAxis(1);
|
||||
}
|
||||
MultiDofDemo::~MultiDofDemo()
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ m_bp(0),
|
||||
m_solver(0),
|
||||
m_dynamicsWorld(0)
|
||||
{
|
||||
app->setUpAxis(1);
|
||||
sLuaDemo = this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user