Added Height Field Fluid Demo to Bullet. All code stored in the Demos/HeightFieldFluidDemo directory for now.
Please see HfFluidDemo.cpp for examples of how to use the height field fluid along with buoyant collision shapes. The implementation is still lacking in my ways: 1) Need to complete more collision algorithms for buoyant collision shapes 2) Support compound buoyant shapes 3) The buoyancy model isn't that great 4) Fluid volume can be lost over time
This commit is contained in:
@@ -21,6 +21,17 @@ GLDebugDrawer::GLDebugDrawer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& fromColor, const btVector3& toColor)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(fromColor.getX(), fromColor.getY(), fromColor.getZ());
|
||||
glVertex3d(from.getX(), from.getY(), from.getZ());
|
||||
glColor3f(toColor.getX(), toColor.getY(), toColor.getZ());
|
||||
glVertex3d(to.getX(), to.getY(), to.getZ());
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
|
||||
{
|
||||
// if (m_debugMode > 0)
|
||||
@@ -33,6 +44,30 @@ void GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btV
|
||||
}
|
||||
}
|
||||
|
||||
void GLDebugDrawer::drawSphere (const btVector3& p, btScalar radius, const btVector3& color)
|
||||
{
|
||||
glColor4f (color.getX(), color.getY(), color.getZ(), btScalar(1.0f));
|
||||
glPushMatrix ();
|
||||
glTranslatef (p.getX(), p.getY(), p.getZ());
|
||||
glutSolidSphere (radius, 10, 10);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void GLDebugDrawer::drawBox (const btVector3& boxMin, const btVector3& boxMax, const btVector3& color, btScalar alpha)
|
||||
{
|
||||
btVector3 halfExtent = (boxMax - boxMin) * btScalar(0.5f);
|
||||
btVector3 center = (boxMax + boxMin) * btScalar(0.5f);
|
||||
//glEnable(GL_BLEND); // Turn blending On
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glColor4f (color.getX(), color.getY(), color.getZ(), alpha);
|
||||
glPushMatrix ();
|
||||
glTranslatef (center.getX(), center.getY(), center.getZ());
|
||||
glScaled(2*halfExtent[0], 2*halfExtent[1], 2*halfExtent[2]);
|
||||
glutSolidCube(1.0);
|
||||
glPopMatrix ();
|
||||
//glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void GLDebugDrawer::drawTriangle(const btVector3& a,const btVector3& b,const btVector3& c,const btVector3& color,btScalar alpha)
|
||||
{
|
||||
// if (m_debugMode > 0)
|
||||
|
||||
Reference in New Issue
Block a user