add a small framework of garments, update the related tests
This commit is contained in:
69
include/bounce/dynamics/cloth/cloth_mesh.h
Normal file
69
include/bounce/dynamics/cloth/cloth_mesh.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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 B3_CLOTH_MESH_H
|
||||
#define B3_CLOTH_MESH_H
|
||||
|
||||
#include <bounce/common/math/vec2.h>
|
||||
#include <bounce/common/math/vec3.h>
|
||||
|
||||
struct b3ClothMeshTriangle
|
||||
{
|
||||
u32 v1, v2, v3;
|
||||
};
|
||||
|
||||
struct b3ClothMeshMesh
|
||||
{
|
||||
u32 vertexCount;
|
||||
u32 startVertex;
|
||||
u32 triangleCount;
|
||||
u32 startTriangle;
|
||||
};
|
||||
|
||||
struct b3ClothMeshSewingLine
|
||||
{
|
||||
u32 s1, s2;
|
||||
u32 v1, v2;
|
||||
};
|
||||
|
||||
struct b3ClothMesh
|
||||
{
|
||||
u32 vertexCount;
|
||||
b3Vec3* vertices;
|
||||
u32 triangleCount;
|
||||
b3ClothMeshTriangle* triangles;
|
||||
u32 meshCount;
|
||||
b3ClothMeshMesh* meshes;
|
||||
u32 sewingLineCount;
|
||||
b3ClothMeshSewingLine* sewingLines;
|
||||
};
|
||||
|
||||
struct b3GarmentMesh;
|
||||
|
||||
// Convenience structure.
|
||||
struct b3GarmentClothMesh : public b3ClothMesh
|
||||
{
|
||||
b3GarmentClothMesh();
|
||||
~b3GarmentClothMesh();
|
||||
|
||||
// Maps a given garment mesh to this mesh.
|
||||
// This garment mesh must be empty.
|
||||
void Set(const b3GarmentMesh* garment);
|
||||
};
|
||||
|
||||
#endif
|
@@ -29,7 +29,7 @@ class b3StackAllocator;
|
||||
|
||||
class b3Shape;
|
||||
|
||||
struct b3Mesh;
|
||||
struct b3ClothMesh;
|
||||
|
||||
struct b3SpringClothDef
|
||||
{
|
||||
@@ -49,7 +49,7 @@ struct b3SpringClothDef
|
||||
b3StackAllocator* allocator;
|
||||
|
||||
// Cloth mesh
|
||||
b3Mesh* mesh;
|
||||
b3ClothMesh* mesh;
|
||||
|
||||
// Cloth density in kg/m^3
|
||||
float32 density;
|
||||
@@ -64,8 +64,8 @@ struct b3SpringClothDef
|
||||
float32 kd;
|
||||
|
||||
// Mass radius
|
||||
// Typically this is value is small and is intended for correcting visual artifacts when
|
||||
// the cloth is colliding against a solid.
|
||||
// This should be a small value. It can be used for correcting visual artifacts when
|
||||
// the masses are colliding against a solid.
|
||||
float32 r;
|
||||
|
||||
// Acceleration due to gravity (m/s^2)
|
||||
@@ -75,7 +75,8 @@ struct b3SpringClothDef
|
||||
enum b3SpringType
|
||||
{
|
||||
e_strechSpring,
|
||||
e_bendSpring
|
||||
e_bendSpring,
|
||||
// e_sewingSpring
|
||||
};
|
||||
|
||||
struct b3Spring
|
||||
@@ -138,7 +139,7 @@ public:
|
||||
void Initialize(const b3SpringClothDef& def);
|
||||
|
||||
// Return the cloth mesh used to initialize this cloth.
|
||||
b3Mesh* GetMesh() const;
|
||||
b3ClothMesh* GetMesh() const;
|
||||
|
||||
// Set the gravitational acceleration applied to this cloth.
|
||||
// Units are m/s^2.
|
||||
@@ -210,7 +211,7 @@ protected:
|
||||
|
||||
b3StackAllocator* m_allocator;
|
||||
|
||||
b3Mesh* m_mesh;
|
||||
b3ClothMesh* m_mesh;
|
||||
float32 m_r;
|
||||
|
||||
b3Vec3 m_gravity;
|
||||
@@ -237,7 +238,7 @@ protected:
|
||||
b3SpringClothStep m_step;
|
||||
};
|
||||
|
||||
inline b3Mesh* b3SpringCloth::GetMesh() const
|
||||
inline b3ClothMesh* b3SpringCloth::GetMesh() const
|
||||
{
|
||||
return m_mesh;
|
||||
}
|
||||
|
Reference in New Issue
Block a user