add a small framework of garments, update the related tests
This commit is contained in:
		| @@ -60,11 +60,31 @@ class TensionMapping : public SpringClothTest | ||||
| public: | ||||
| 	TensionMapping() | ||||
| 	{ | ||||
| 		m_gridClothMesh.vertexCount = m_gridMesh.vertexCount; | ||||
| 		m_gridClothMesh.vertices = m_gridMesh.vertices; | ||||
|  | ||||
| 		m_gridClothMesh.triangleCount = m_gridMesh.triangleCount; | ||||
| 		m_gridClothMesh.triangles = (b3ClothMeshTriangle*)m_gridMesh.triangles; | ||||
|  | ||||
| 		m_gridClothMeshMesh.vertexCount = m_gridClothMesh.vertexCount; | ||||
| 		m_gridClothMeshMesh.startVertex = 0; | ||||
| 		 | ||||
| 		m_gridClothMeshMesh.triangleCount = m_gridClothMesh.triangleCount; | ||||
| 		m_gridClothMeshMesh.startTriangle = 0; | ||||
|  | ||||
| 		m_gridClothMesh.meshCount = 1; | ||||
| 		m_gridClothMesh.meshes = &m_gridClothMeshMesh; | ||||
|  | ||||
| 		m_gridClothMesh.sewingLineCount = 0; | ||||
| 		m_gridClothMesh.sewingLines = nullptr; | ||||
| 		 | ||||
| 		b3SpringClothDef def; | ||||
| 		def.allocator = &m_clothAllocator; | ||||
| 		def.mesh = &m_clothMesh; | ||||
| 		def.mesh = &m_gridClothMesh; | ||||
| 		def.density = 0.2f; | ||||
| 		def.ks = 100000.0f; | ||||
| 		def.ks = 10000.0f; | ||||
| 		def.kd = 0.0f; | ||||
| 		def.r = 0.2f; | ||||
| 		def.gravity.Set(0.0f, -10.0f, 0.0f); | ||||
|  | ||||
| 		m_cloth.Initialize(def); | ||||
| @@ -73,9 +93,9 @@ public: | ||||
| 		aabb.m_lower.Set(-5.0f, -1.0f, -6.0f); | ||||
| 		aabb.m_upper.Set(5.0f, 1.0f, -4.0f); | ||||
|  | ||||
| 		for (u32 i = 0; i < def.mesh->vertexCount; ++i) | ||||
| 		for (u32 i = 0; i < m_cloth.GetMassCount(); ++i) | ||||
| 		{ | ||||
| 			if (aabb.Contains(def.mesh->vertices[i])) | ||||
| 			if (aabb.Contains(m_cloth.GetPosition(i))) | ||||
| 			{ | ||||
| 				m_cloth.SetType(i, b3MassType::e_staticMass); | ||||
| 			} | ||||
| @@ -92,13 +112,13 @@ public: | ||||
| 		b3StackArray<b3Vec3, 100> T; | ||||
| 		m_cloth.GetTension(T); | ||||
|  | ||||
| 		for (u32 i = 0; i < m_clothMesh.triangleCount; ++i) | ||||
| 		for (u32 i = 0; i < m_gridClothMesh.triangleCount; ++i) | ||||
| 		{ | ||||
| 			b3Triangle* t = m_clothMesh.triangles + i; | ||||
| 			b3ClothMeshTriangle* t = m_gridClothMesh.triangles + i; | ||||
|  | ||||
| 			b3Vec3 v1 = m_clothMesh.vertices[t->v1]; | ||||
| 			b3Vec3 v2 = m_clothMesh.vertices[t->v2]; | ||||
| 			b3Vec3 v3 = m_clothMesh.vertices[t->v3]; | ||||
| 			b3Vec3 v1 = m_gridClothMesh.vertices[t->v1]; | ||||
| 			b3Vec3 v2 = m_gridClothMesh.vertices[t->v2]; | ||||
| 			b3Vec3 v3 = m_gridClothMesh.vertices[t->v3]; | ||||
|  | ||||
| 			b3Draw_draw->DrawSegment(v1, v2, b3Color_black); | ||||
| 			b3Draw_draw->DrawSegment(v2, v3, b3Color_black); | ||||
| @@ -142,7 +162,9 @@ public: | ||||
| 		return new TensionMapping(); | ||||
| 	} | ||||
|  | ||||
| 	b3GridMesh<10, 10> m_clothMesh; | ||||
| 	b3GridMesh<10, 10> m_gridMesh; | ||||
| 	b3ClothMeshMesh m_gridClothMeshMesh; | ||||
| 	b3ClothMesh m_gridClothMesh; | ||||
| }; | ||||
|  | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user