Add b3GridClothMesh. Set particle friction to global cloth friction. Update the tests. Also simplified some code.

This commit is contained in:
Irlan
2019-06-21 10:58:04 -03:00
parent 66ec7309e5
commit 7c1a72c572
11 changed files with 161 additions and 132 deletions

View File

@ -22,41 +22,28 @@
class TableCloth : public Test
{
public:
TableCloth() : m_rectangleGarment(5.0f, 5.0f)
TableCloth()
{
// Generate 2D mesh
m_rectangleGarmentMesh.Set(&m_rectangleGarment, 1.0f);
// Create 3D mesh
m_rectangleClothMesh.Set(&m_rectangleGarmentMesh);
// Rotate the mesh
b3Mat33 rotation = b3Mat33RotationX(0.5f * B3_PI);
for (u32 i = 0; i < m_rectangleClothMesh.vertexCount; ++i)
// Translate the mesh
for (u32 i = 0; i < m_clothMesh.vertexCount; ++i)
{
m_rectangleClothMesh.vertices[i] = rotation * m_rectangleClothMesh.vertices[i];
m_rectangleClothMesh.vertices[i].y += 5.0f;
m_clothMesh.vertices[i].y += 5.0f;
}
// Create cloth
b3ClothDef def;
def.mesh = &m_rectangleClothMesh;
def.mesh = &m_clothMesh;
def.density = 0.2f;
//def.bending = 10000.0f;
def.structural = 10000.0f;
def.damping = 0.0f;
def.thickness = 0.2f;
def.friction = 0.1f;
m_cloth = new b3Cloth(def);
m_cloth->SetGravity(b3Vec3(0.0f, -9.8f, 0.0f));
m_cloth->SetWorld(&m_world);
for (b3Particle* p = m_cloth->GetParticleList().m_head; p; p = p->GetNext())
{
p->SetRadius(0.1f);
p->SetFriction(0.2f);
}
{
b3BodyDef bd;
bd.type = e_staticBody;
@ -146,9 +133,7 @@ public:
return new TableCloth();
}
b3RectangleGarment m_rectangleGarment;
b3GarmentMesh m_rectangleGarmentMesh;
b3GarmentClothMesh m_rectangleClothMesh;
b3GridClothMesh<10, 10> m_clothMesh;
b3Cloth* m_cloth;
b3ClothDragger* m_clothDragger;