cloth2

view src/cloth.h @ 0:ef0c22554406

cloth sim test, initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 11 Jan 2016 16:51:16 +0200
parents
children dc15b741486c
line source
1 #ifndef CLOTH_H_
2 #define CLOTH_H_
4 #include <vector>
5 #include <gmath/gmath.h>
6 #include "object.h"
8 using namespace gph;
10 struct ClothMass {
11 Vector3 pos, vel;
12 bool fixed;
13 };
15 class Cloth {
16 private:
17 float mass, elast; // global mass attributes
18 float spring_k; // spring constant for all springs
19 Vector3 grav, forces;
21 std::vector<ClothMass> masses;
22 std::vector<std::vector<float> > conn; // spring lengths, <0 means not connected
24 std::vector<Object*> colliders;
26 bool find_collision(const Ray &ray, HitPoint *hit) const;
28 public:
29 Cloth();
31 void create_rect(int x, int y, float width, float height);
33 void transform(const Matrix4x4 &xform);
35 void add_collider(Object *o);
37 void step(float dt);
39 void draw() const;
40 };
42 #endif // CLOTH_H_