refactoring
This commit is contained in:
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2016 Irlan Robson http://www.irlan.net
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef CLOTH_TESH_H
|
||||
#define CLOTH_TESH_H
|
||||
|
||||
class ClothTest : public Test
|
||||
{
|
||||
public:
|
||||
ClothTest()
|
||||
{
|
||||
m_world.SetGravity(b3Vec3(0.0f, -10.0f, 0.0f));
|
||||
m_cloth = nullptr;
|
||||
}
|
||||
|
||||
void Step()
|
||||
{
|
||||
Test::Step();
|
||||
|
||||
m_cloth->Draw();
|
||||
|
||||
if (m_clothDragger.IsDragging() == true)
|
||||
{
|
||||
g_draw->DrawSegment(m_clothDragger.GetPointA(), m_clothDragger.GetPointB(), b3Color_white);
|
||||
}
|
||||
|
||||
extern u32 b3_clothSolverIterations;
|
||||
g_draw->DrawString(b3Color_white, "Iterations = %u", b3_clothSolverIterations);
|
||||
|
||||
float32 E = m_cloth->GetEnergy();
|
||||
g_draw->DrawString(b3Color_white, "E = %f", E);
|
||||
}
|
||||
|
||||
b3Cloth* m_cloth;
|
||||
};
|
||||
|
||||
#endif
|
@ -19,7 +19,7 @@
|
||||
#ifndef PINNED_CLOTH_H
|
||||
#define PINNED_CLOTH_H
|
||||
|
||||
class PinnedCloth : public ClothTest
|
||||
class PinnedCloth : public Test
|
||||
{
|
||||
public:
|
||||
PinnedCloth() : m_rectangleGarment(5.0f, 5.0f)
|
||||
@ -30,21 +30,26 @@ public:
|
||||
// Create 3D mesh
|
||||
m_rectangleClothMesh.Set(&m_rectangleGarmentMesh);
|
||||
|
||||
//
|
||||
b3Mat33 dq = b3Mat33RotationX(0.5f * B3_PI);
|
||||
// Rotate the mesh
|
||||
b3Mat33 rotation = b3Mat33RotationX(0.5f * B3_PI);
|
||||
for (u32 i = 0; i < m_rectangleClothMesh.vertexCount; ++i)
|
||||
{
|
||||
m_rectangleClothMesh.vertices[i] = dq * m_rectangleClothMesh.vertices[i];
|
||||
m_rectangleClothMesh.vertices[i] = rotation * m_rectangleClothMesh.vertices[i];
|
||||
}
|
||||
|
||||
// Create cloth
|
||||
b3ClothDef def;
|
||||
def.mesh = &m_rectangleClothMesh;
|
||||
def.density = 0.2f;
|
||||
def.structural = 100000.0f;
|
||||
def.damping = 0.0f;
|
||||
|
||||
m_cloth = m_world.CreateCloth(def);
|
||||
m_cloth = new b3Cloth(def);
|
||||
|
||||
m_cloth->SetGravity(b3Vec3(0.0f, -9.8f, 0.0f));
|
||||
m_cloth->SetWorld(&m_world);
|
||||
|
||||
// Freeze some particles
|
||||
b3AABB3 aabb1;
|
||||
aabb1.m_lower.Set(-5.0f, -1.0f, -6.0f);
|
||||
aabb1.m_upper.Set(5.0f, 1.0f, -4.0f);
|
||||
@ -65,23 +70,70 @@ public:
|
||||
p->SetType(e_staticParticle);
|
||||
}
|
||||
}
|
||||
|
||||
m_clothDragger = new b3ClothDragger(&m_ray, m_cloth);
|
||||
}
|
||||
|
||||
~PinnedCloth()
|
||||
{
|
||||
delete m_clothDragger;
|
||||
delete m_cloth;
|
||||
}
|
||||
|
||||
void Step()
|
||||
{
|
||||
Test::Step();
|
||||
|
||||
m_cloth->Step(g_testSettings->inv_hertz);
|
||||
|
||||
m_cloth->Draw();
|
||||
|
||||
if (m_clothDragger->IsDragging())
|
||||
{
|
||||
b3BodyDef bd;
|
||||
bd.type = e_dynamicBody;
|
||||
bd.position.Set(0.0f, 5.0f, 0.0f);
|
||||
b3Vec3 pA = m_clothDragger->GetPointA();
|
||||
b3Vec3 pB = m_clothDragger->GetPointB();
|
||||
|
||||
b3Body* b = m_world.CreateBody(bd);
|
||||
g_draw->DrawPoint(pA, 2.0f, b3Color_green);
|
||||
|
||||
b3SphereShape sphere;
|
||||
sphere.m_center.SetZero();
|
||||
sphere.m_radius = 2.0f;
|
||||
g_draw->DrawPoint(pB, 2.0f, b3Color_green);
|
||||
|
||||
b3ShapeDef sd;
|
||||
sd.shape = &sphere;
|
||||
sd.density = 1.0f;
|
||||
g_draw->DrawSegment(pA, pB, b3Color_white);
|
||||
}
|
||||
|
||||
b3Shape* s = b->CreateShape(sd);
|
||||
extern u32 b3_clothSolverIterations;
|
||||
g_draw->DrawString(b3Color_white, "Iterations = %d", b3_clothSolverIterations);
|
||||
|
||||
float32 E = m_cloth->GetEnergy();
|
||||
g_draw->DrawString(b3Color_white, "E = %f", E);
|
||||
}
|
||||
|
||||
void MouseMove(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseMove(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == true)
|
||||
{
|
||||
m_clothDragger->Drag();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftDown(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseLeftDown(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == false)
|
||||
{
|
||||
m_clothDragger->StartDragging();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftUp(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseLeftUp(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == true)
|
||||
{
|
||||
m_clothDragger->StopDragging();
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,6 +145,9 @@ public:
|
||||
b3RectangleGarment m_rectangleGarment;
|
||||
b3GarmentMesh m_rectangleGarmentMesh;
|
||||
b3GarmentClothMesh m_rectangleClothMesh;
|
||||
|
||||
b3Cloth* m_cloth;
|
||||
b3ClothDragger* m_clothDragger;
|
||||
};
|
||||
|
||||
#endif
|
@ -178,8 +178,8 @@ public:
|
||||
|
||||
void CastRay(const b3Vec3 p1, const b3Vec3 p2) const
|
||||
{
|
||||
b3RayCastSingleShapeOutput out;
|
||||
if (m_world.RayCastSingleShape(&out, p1, p2))
|
||||
b3RayCastSingleOutput out;
|
||||
if (m_world.RayCastSingle(&out, p1, p2))
|
||||
{
|
||||
g_draw->DrawSegment(p1, out.point, b3Color_green);
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef SELF_COLLISION_H
|
||||
#define SELF_COLLISION_H
|
||||
|
||||
class SelfCollision : public ClothTest
|
||||
class SelfCollision : public Test
|
||||
{
|
||||
public:
|
||||
SelfCollision() : m_rectangleGarment(5.0f, 5.0f)
|
||||
@ -30,19 +30,24 @@ public:
|
||||
// Create 3D mesh
|
||||
m_rectangleClothMesh.Set(&m_rectangleGarmentMesh);
|
||||
|
||||
b3Mat33 Rx = b3Mat33RotationX(0.5f * B3_PI);
|
||||
// Rotate and translate the mesh
|
||||
b3Mat33 rotation = b3Mat33RotationX(0.5f * B3_PI);
|
||||
for (u32 i = 0; i < m_rectangleClothMesh.vertexCount; ++i)
|
||||
{
|
||||
m_rectangleClothMesh.vertices[i] = Rx * m_rectangleClothMesh.vertices[i];
|
||||
m_rectangleClothMesh.vertices[i] = rotation * m_rectangleClothMesh.vertices[i];
|
||||
m_rectangleClothMesh.vertices[i].y += 5.0f;
|
||||
}
|
||||
|
||||
// Create cloth
|
||||
b3ClothDef def;
|
||||
def.mesh = &m_rectangleClothMesh;
|
||||
def.density = 1.0f;
|
||||
def.structural = 100000.0f;
|
||||
|
||||
m_cloth = m_world.CreateCloth(def);
|
||||
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())
|
||||
{
|
||||
@ -67,6 +72,71 @@ public:
|
||||
|
||||
b->CreateShape(sd);
|
||||
}
|
||||
|
||||
m_clothDragger = new b3ClothDragger(&m_ray, m_cloth);
|
||||
}
|
||||
|
||||
~SelfCollision()
|
||||
{
|
||||
delete m_cloth;
|
||||
delete m_clothDragger;
|
||||
}
|
||||
|
||||
void Step()
|
||||
{
|
||||
Test::Step();
|
||||
|
||||
m_cloth->Step(g_testSettings->inv_hertz);
|
||||
|
||||
m_cloth->Draw();
|
||||
|
||||
if (m_clothDragger->IsDragging())
|
||||
{
|
||||
b3Vec3 pA = m_clothDragger->GetPointA();
|
||||
b3Vec3 pB = m_clothDragger->GetPointB();
|
||||
|
||||
g_draw->DrawPoint(pA, 2.0f, b3Color_green);
|
||||
|
||||
g_draw->DrawPoint(pB, 2.0f, b3Color_green);
|
||||
|
||||
g_draw->DrawSegment(pA, pB, b3Color_white);
|
||||
}
|
||||
|
||||
extern u32 b3_clothSolverIterations;
|
||||
g_draw->DrawString(b3Color_white, "Iterations = %d", b3_clothSolverIterations);
|
||||
|
||||
float32 E = m_cloth->GetEnergy();
|
||||
g_draw->DrawString(b3Color_white, "E = %f", E);
|
||||
}
|
||||
|
||||
void MouseMove(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseMove(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == true)
|
||||
{
|
||||
m_clothDragger->Drag();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftDown(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseLeftDown(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == false)
|
||||
{
|
||||
m_clothDragger->StartDragging();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftUp(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseLeftUp(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == true)
|
||||
{
|
||||
m_clothDragger->StopDragging();
|
||||
}
|
||||
}
|
||||
|
||||
static Test* Create()
|
||||
@ -77,6 +147,9 @@ public:
|
||||
b3RectangleGarment m_rectangleGarment;
|
||||
b3GarmentMesh m_rectangleGarmentMesh;
|
||||
b3GarmentClothMesh m_rectangleClothMesh;
|
||||
};
|
||||
|
||||
b3Cloth* m_cloth;
|
||||
b3ClothDragger* m_clothDragger;
|
||||
};
|
||||
|
||||
#endif
|
@ -19,7 +19,7 @@
|
||||
#ifndef SHIRT_H
|
||||
#define SHIRT_H
|
||||
|
||||
class Shirt : public ClothTest
|
||||
class Shirt : public Test
|
||||
{
|
||||
public:
|
||||
Shirt()
|
||||
@ -57,7 +57,63 @@ public:
|
||||
def.density = 0.2f;
|
||||
def.structural = 10000.0f;
|
||||
|
||||
m_cloth = m_world.CreateCloth(def);
|
||||
m_cloth = new b3Cloth(def);
|
||||
|
||||
m_cloth->SetGravity(b3Vec3(0.0f, -9.8f, 0.0f));
|
||||
m_cloth->SetWorld(&m_world);
|
||||
|
||||
m_clothDragger = new b3ClothDragger(&m_ray, m_cloth);
|
||||
}
|
||||
|
||||
~Shirt()
|
||||
{
|
||||
delete m_clothDragger;
|
||||
delete m_cloth;
|
||||
}
|
||||
|
||||
void Step()
|
||||
{
|
||||
Test::Step();
|
||||
|
||||
m_cloth->Step(g_testSettings->inv_hertz);
|
||||
|
||||
m_cloth->Draw();
|
||||
|
||||
extern u32 b3_clothSolverIterations;
|
||||
g_draw->DrawString(b3Color_white, "Iterations = %d", b3_clothSolverIterations);
|
||||
|
||||
float32 E = m_cloth->GetEnergy();
|
||||
g_draw->DrawString(b3Color_white, "E = %f", E);
|
||||
}
|
||||
|
||||
void MouseMove(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseMove(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == true)
|
||||
{
|
||||
m_clothDragger->Drag();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftDown(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseLeftDown(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == false)
|
||||
{
|
||||
m_clothDragger->StartDragging();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftUp(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseLeftUp(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == true)
|
||||
{
|
||||
m_clothDragger->StopDragging();
|
||||
}
|
||||
}
|
||||
|
||||
static Test* Create()
|
||||
@ -68,6 +124,9 @@ public:
|
||||
b3ShirtGarment m_shirtGarment;
|
||||
b3GarmentMesh m_shirtGarmentMesh;
|
||||
b3GarmentClothMesh m_shirtClothMesh;
|
||||
|
||||
b3Cloth* m_cloth;
|
||||
b3ClothDragger* m_clothDragger;
|
||||
};
|
||||
|
||||
#endif
|
@ -19,7 +19,7 @@
|
||||
#ifndef TABLE_CLOTH_H
|
||||
#define TABLE_CLOTH_H
|
||||
|
||||
class TableCloth : public ClothTest
|
||||
class TableCloth : public Test
|
||||
{
|
||||
public:
|
||||
TableCloth() : m_rectangleGarment(5.0f, 5.0f)
|
||||
@ -30,14 +30,15 @@ public:
|
||||
// Create 3D mesh
|
||||
m_rectangleClothMesh.Set(&m_rectangleGarmentMesh);
|
||||
|
||||
//
|
||||
b3Mat33 dq = b3Mat33RotationX(0.5f * B3_PI);
|
||||
// Rotate the mesh
|
||||
b3Mat33 rotation = b3Mat33RotationX(0.5f * B3_PI);
|
||||
for (u32 i = 0; i < m_rectangleClothMesh.vertexCount; ++i)
|
||||
{
|
||||
m_rectangleClothMesh.vertices[i] = dq * m_rectangleClothMesh.vertices[i];
|
||||
m_rectangleClothMesh.vertices[i] = rotation * m_rectangleClothMesh.vertices[i];
|
||||
m_rectangleClothMesh.vertices[i].y += 5.0f;
|
||||
}
|
||||
|
||||
// Create cloth
|
||||
b3ClothDef def;
|
||||
def.mesh = &m_rectangleClothMesh;
|
||||
def.density = 0.2f;
|
||||
@ -45,7 +46,10 @@ public:
|
||||
def.structural = 10000.0f;
|
||||
def.damping = 0.0f;
|
||||
|
||||
m_cloth = m_world.CreateCloth(def);
|
||||
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())
|
||||
{
|
||||
@ -71,6 +75,71 @@ public:
|
||||
|
||||
b->CreateShape(sd);
|
||||
}
|
||||
|
||||
m_clothDragger = new b3ClothDragger(&m_ray, m_cloth);
|
||||
}
|
||||
|
||||
~TableCloth()
|
||||
{
|
||||
delete m_clothDragger;
|
||||
delete m_cloth;
|
||||
}
|
||||
|
||||
void Step()
|
||||
{
|
||||
Test::Step();
|
||||
|
||||
m_cloth->Step(g_testSettings->inv_hertz);
|
||||
|
||||
m_cloth->Draw();
|
||||
|
||||
if (m_clothDragger->IsDragging())
|
||||
{
|
||||
b3Vec3 pA = m_clothDragger->GetPointA();
|
||||
b3Vec3 pB = m_clothDragger->GetPointB();
|
||||
|
||||
g_draw->DrawPoint(pA, 2.0f, b3Color_green);
|
||||
|
||||
g_draw->DrawPoint(pB, 2.0f, b3Color_green);
|
||||
|
||||
g_draw->DrawSegment(pA, pB, b3Color_white);
|
||||
}
|
||||
|
||||
extern u32 b3_clothSolverIterations;
|
||||
g_draw->DrawString(b3Color_white, "Iterations = %d", b3_clothSolverIterations);
|
||||
|
||||
float32 E = m_cloth->GetEnergy();
|
||||
g_draw->DrawString(b3Color_white, "E = %f", E);
|
||||
}
|
||||
|
||||
void MouseMove(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseMove(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == true)
|
||||
{
|
||||
m_clothDragger->Drag();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftDown(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseLeftDown(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == false)
|
||||
{
|
||||
m_clothDragger->StartDragging();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftUp(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseLeftUp(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == true)
|
||||
{
|
||||
m_clothDragger->StopDragging();
|
||||
}
|
||||
}
|
||||
|
||||
static Test* Create()
|
||||
@ -82,6 +151,9 @@ public:
|
||||
b3GarmentMesh m_rectangleGarmentMesh;
|
||||
b3GarmentClothMesh m_rectangleClothMesh;
|
||||
|
||||
b3Cloth* m_cloth;
|
||||
b3ClothDragger* m_clothDragger;
|
||||
|
||||
b3QHull m_tableHull;
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ static inline b3Color Color(float32 x, float32 a, float32 b)
|
||||
return c;
|
||||
}
|
||||
|
||||
class TensionMapping : public ClothTest
|
||||
class TensionMapping : public Test
|
||||
{
|
||||
public:
|
||||
TensionMapping() : m_rectangleGarment(5.0f, 5.0f)
|
||||
@ -66,20 +66,25 @@ public:
|
||||
// Create 3D mesh
|
||||
m_rectangleClothMesh.Set(&m_rectangleGarmentMesh);
|
||||
|
||||
//
|
||||
b3Mat33 dq = b3Mat33RotationX(0.5f * B3_PI);
|
||||
// Rotate the mesh
|
||||
b3Mat33 rotation = b3Mat33RotationX(0.5f * B3_PI);
|
||||
for (u32 i = 0; i < m_rectangleClothMesh.vertexCount; ++i)
|
||||
{
|
||||
m_rectangleClothMesh.vertices[i] = dq * m_rectangleClothMesh.vertices[i];
|
||||
m_rectangleClothMesh.vertices[i] = rotation * m_rectangleClothMesh.vertices[i];
|
||||
}
|
||||
|
||||
// Create cloth
|
||||
b3ClothDef def;
|
||||
def.mesh = &m_rectangleClothMesh;
|
||||
def.density = 0.2f;
|
||||
def.structural = 10000.0f;
|
||||
|
||||
m_cloth = m_world.CreateCloth(def);
|
||||
m_cloth = new b3Cloth(def);
|
||||
|
||||
m_cloth->SetGravity(b3Vec3(0.0f, -9.8f, 0.0f));
|
||||
m_cloth->SetWorld(&m_world);
|
||||
|
||||
// Freeze some particles
|
||||
b3AABB3 aabb;
|
||||
aabb.m_lower.Set(-5.0f, -1.0f, -6.0f);
|
||||
aabb.m_upper.Set(5.0f, 1.0f, -4.0f);
|
||||
@ -91,12 +96,22 @@ public:
|
||||
p->SetType(e_staticParticle);
|
||||
}
|
||||
}
|
||||
|
||||
m_clothDragger = new b3ClothDragger(&m_ray, m_cloth);
|
||||
}
|
||||
|
||||
~TensionMapping()
|
||||
{
|
||||
delete m_clothDragger;
|
||||
delete m_cloth;
|
||||
}
|
||||
|
||||
void Step()
|
||||
{
|
||||
Test::Step();
|
||||
|
||||
m_cloth->Step(g_testSettings->inv_hertz);
|
||||
|
||||
const b3ClothMesh* mesh = m_cloth->GetMesh();
|
||||
|
||||
b3StackArray<b3Vec3, 256> tension;
|
||||
@ -120,9 +135,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < m_rectangleClothMesh.triangleCount; ++i)
|
||||
for (u32 i = 0; i < mesh->triangleCount; ++i)
|
||||
{
|
||||
b3ClothMeshTriangle* t = m_rectangleClothMesh.triangles + i;
|
||||
b3ClothMeshTriangle* t = mesh->triangles + i;
|
||||
|
||||
b3Vec3 v1 = m_cloth->GetVertexParticle(t->v1)->GetPosition();
|
||||
b3Vec3 v2 = m_cloth->GetVertexParticle(t->v2)->GetPosition();
|
||||
@ -154,18 +169,55 @@ public:
|
||||
g_draw->DrawSolidTriangle(n2, v1, v3, v2, color);
|
||||
}
|
||||
|
||||
if (m_clothDragger.IsDragging() == true)
|
||||
if (m_clothDragger->IsDragging())
|
||||
{
|
||||
g_draw->DrawSegment(m_clothDragger.GetPointA(), m_clothDragger.GetPointB(), b3Color_white);
|
||||
b3Vec3 pA = m_clothDragger->GetPointA();
|
||||
b3Vec3 pB = m_clothDragger->GetPointB();
|
||||
|
||||
g_draw->DrawPoint(pA, 2.0f, b3Color_green);
|
||||
|
||||
g_draw->DrawPoint(pB, 2.0f, b3Color_green);
|
||||
|
||||
g_draw->DrawSegment(pA, pB, b3Color_white);
|
||||
}
|
||||
|
||||
extern u32 b3_clothSolverIterations;
|
||||
g_draw->DrawString(b3Color_white, "Iterations = %u", b3_clothSolverIterations);
|
||||
g_draw->DrawString(b3Color_white, "Iterations = %d", b3_clothSolverIterations);
|
||||
|
||||
float32 E = m_cloth->GetEnergy();
|
||||
g_draw->DrawString(b3Color_white, "E = %f", E);
|
||||
}
|
||||
|
||||
void MouseMove(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseMove(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == true)
|
||||
{
|
||||
m_clothDragger->Drag();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftDown(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseLeftDown(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == false)
|
||||
{
|
||||
m_clothDragger->StartDragging();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftUp(const b3Ray3& pw)
|
||||
{
|
||||
Test::MouseLeftUp(pw);
|
||||
|
||||
if (m_clothDragger->IsDragging() == true)
|
||||
{
|
||||
m_clothDragger->StopDragging();
|
||||
}
|
||||
}
|
||||
|
||||
static Test* Create()
|
||||
{
|
||||
return new TensionMapping();
|
||||
@ -174,6 +226,9 @@ public:
|
||||
b3RectangleGarment m_rectangleGarment;
|
||||
b3GarmentMesh m_rectangleGarmentMesh;
|
||||
b3GarmentClothMesh m_rectangleClothMesh;
|
||||
|
||||
b3Cloth* m_cloth;
|
||||
b3ClothDragger* m_clothDragger;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user