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