some finishing touches for drawing shadows/clusters/textures.
This commit is contained in:
@@ -52,6 +52,9 @@ namespace
|
||||
int gDrawAabb;
|
||||
int gWireFrame;
|
||||
int gDebugContacts;
|
||||
int gDrawTextures=1;
|
||||
int gDrawShadows=0;
|
||||
int gDrawClusters=0;
|
||||
int gDebugNoDeactivation;
|
||||
int gUseWarmstarting;
|
||||
int gRandomizeConstraints;
|
||||
@@ -75,6 +78,10 @@ void setDefaultSettings()
|
||||
gDrawAabb=0;
|
||||
gWireFrame=0;
|
||||
gDebugContacts=0;
|
||||
gDrawTextures=1;
|
||||
gDrawShadows=0;
|
||||
gDrawClusters=0;
|
||||
|
||||
gDebugNoDeactivation = 0;
|
||||
gUseSplitImpulse = 0;
|
||||
gUseWarmstarting = 1;
|
||||
@@ -135,6 +142,10 @@ DemoApplication* CreatDemo(btDemoEntry* entry)
|
||||
if (demo->getDynamicsWorld())
|
||||
{
|
||||
demo->getDynamicsWorld()->setDebugDrawer(new GLDebugDrawer());
|
||||
gDrawTextures = demo->getTexturing();
|
||||
gDrawShadows = demo->getShadows();
|
||||
if (glui)
|
||||
glui->sync_live();
|
||||
}
|
||||
|
||||
#ifndef BT_NO_PROFILE
|
||||
@@ -194,6 +205,9 @@ void SimulationLoop()
|
||||
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawContactPoints));
|
||||
}
|
||||
|
||||
demo->setTexturing(0!=gDrawTextures);
|
||||
demo->setShadows(0!=gDrawShadows);
|
||||
demo->setDrawClusters(0!=gDrawClusters);
|
||||
|
||||
if (gDebugNoDeactivation)
|
||||
{
|
||||
@@ -203,6 +217,9 @@ void SimulationLoop()
|
||||
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_NoDeactivation));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getWorldType() == BT_DISCRETE_DYNAMICS_WORLD)
|
||||
{
|
||||
btDiscreteDynamicsWorld* discreteWorld = (btDiscreteDynamicsWorld*) demo->getDynamicsWorld();
|
||||
@@ -285,7 +302,7 @@ void Keyboard(unsigned char key, int x, int y)
|
||||
|
||||
// Press 'r' to reset.
|
||||
case 'r':
|
||||
if (demo->getDynamicsWorld()->getDebugDrawer())
|
||||
if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getDebugDrawer())
|
||||
delete demo->getDynamicsWorld()->getDebugDrawer();
|
||||
delete demo;
|
||||
demo = CreatDemo(entry);
|
||||
@@ -413,6 +430,13 @@ int main(int argc, char** argv)
|
||||
glui->add_checkbox_to_panel(drawPanel, "AABBs", &gDrawAabb);
|
||||
glui->add_checkbox_to_panel(drawPanel, "Wireframe", &gWireFrame);
|
||||
glui->add_checkbox_to_panel(drawPanel, "Contacts", &gDebugContacts);
|
||||
glui->add_checkbox_to_panel(drawPanel, "Textures", &gDrawTextures);
|
||||
glui->add_checkbox_to_panel(drawPanel, "Shadows", &gDrawShadows);
|
||||
glui->add_checkbox_to_panel(drawPanel, "Clusters", &gDrawClusters);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// glui->add_checkbox_to_panel(drawPanel, "Impulses", &settings.drawImpulses);
|
||||
// glui->add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats);
|
||||
|
||||
@@ -97,11 +97,25 @@ public:
|
||||
return m_dynamicsWorld;
|
||||
}
|
||||
|
||||
virtual void setDrawClusters(bool drawClusters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -110,6 +124,10 @@ public:
|
||||
|
||||
void setDebugMode(int mode);
|
||||
|
||||
void setAzi(float azi)
|
||||
{
|
||||
m_azi = azi;
|
||||
}
|
||||
|
||||
void setCameraUp(const btVector3& camUp)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,10 @@ class GL_ShapeDrawer
|
||||
void drawShadow(btScalar* m, const btVector3& extrusion,const btCollisionShape* shape,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax);
|
||||
|
||||
bool enableTexture(bool enable) { bool p=m_textureenabled;m_textureenabled=enable;return(p); }
|
||||
bool hasTextureEnabled() const
|
||||
{
|
||||
return m_textureenabled;
|
||||
}
|
||||
|
||||
static void drawCylinder(float radius,float halfHeight, int upAxis);
|
||||
static void drawCoordSystem();
|
||||
|
||||
@@ -134,6 +134,9 @@ static void drawSlider(btSliderConstraint* pSlider)
|
||||
|
||||
void SliderConstraintDemo::initPhysics()
|
||||
{
|
||||
setTexturing(true);
|
||||
setShadows(true);
|
||||
|
||||
setCameraDistance(26.f);
|
||||
|
||||
// init world
|
||||
@@ -154,7 +157,8 @@ void SliderConstraintDemo::initPhysics()
|
||||
m_dynamicsWorld = wp;
|
||||
|
||||
// add floor
|
||||
btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
|
||||
//btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
|
||||
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
||||
m_collisionShapes.push_back(groundShape);
|
||||
btTransform groundTransform;
|
||||
groundTransform.setIdentity();
|
||||
|
||||
@@ -1108,6 +1108,7 @@ psb0->appendLinearJoint(lj,psb1);
|
||||
//
|
||||
static void Init_ClusterCar(SoftDemo* pdemo)
|
||||
{
|
||||
pdemo->setAzi(270);
|
||||
const btVector3 origin(100,80,0);
|
||||
const btQuaternion orientation(-SIMD_PI/2,0,0);
|
||||
const btScalar widthf=8;
|
||||
@@ -1446,6 +1447,19 @@ void SoftDemo::renderme()
|
||||
|
||||
}
|
||||
|
||||
void SoftDemo::setDrawClusters(bool drawClusters)
|
||||
{
|
||||
if (drawClusters)
|
||||
{
|
||||
getSoftDynamicsWorld()->setDrawFlags(getSoftDynamicsWorld()->getDrawFlags()|fDrawFlags::Clusters);
|
||||
} else
|
||||
{
|
||||
getSoftDynamicsWorld()->setDrawFlags(getSoftDynamicsWorld()->getDrawFlags()& (~fDrawFlags::Clusters));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SoftDemo::keyboardCallback(unsigned char key, int x, int y)
|
||||
{
|
||||
switch(key)
|
||||
@@ -1580,6 +1594,10 @@ void SoftDemo::initPhysics()
|
||||
{
|
||||
///create concave ground mesh
|
||||
|
||||
//reset and disable motorcontrol at the start
|
||||
motorcontrol.goal = 0;
|
||||
motorcontrol.maxtorque = 0;
|
||||
m_azi = 0;
|
||||
|
||||
btCollisionShape* groundShape = 0;
|
||||
bool useConcaveMesh = false;//not ready yet true;
|
||||
|
||||
@@ -110,14 +110,16 @@ public:
|
||||
return demo;
|
||||
}
|
||||
|
||||
const btSoftRigidDynamicsWorld* getSoftDynamicsWorld() const
|
||||
virtual void setDrawClusters(bool drawClusters);
|
||||
|
||||
virtual const btSoftRigidDynamicsWorld* getSoftDynamicsWorld() const
|
||||
{
|
||||
///just make it a btSoftRigidDynamicsWorld please
|
||||
///or we will add type checking
|
||||
return (btSoftRigidDynamicsWorld*) m_dynamicsWorld;
|
||||
}
|
||||
|
||||
btSoftRigidDynamicsWorld* getSoftDynamicsWorld()
|
||||
virtual btSoftRigidDynamicsWorld* getSoftDynamicsWorld()
|
||||
{
|
||||
///just make it a btSoftRigidDynamicsWorld please
|
||||
///or we will add type checking
|
||||
|
||||
Reference in New Issue
Block a user