aboutsummaryrefslogtreecommitdiff
path: root/demo/scenes/thinbox.h
blob: d9005c930ffd16b341c1c7bb324da6eaef867cd2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class ThinBox : public Scene
{
public:

	ThinBox(const char* name) : Scene(name) {}

	int base;
	int width;
	int height;
	int depth;

	virtual void Initialize()
	{
		float radius = 0.03f;

		width = 16;
		height = 8;
		depth = 8;

		base = 4;

		float sep = radius;

		CreateParticleGrid(Vec3(0.0f, radius, 0.0f), width, height, depth, sep, Vec3(0.0f), 1.0f, false, 0.0f, NvFlexMakePhase(0, eNvFlexPhaseSelfCollide), 0.0f);

		Vec3 upper;
		Vec3 lower;
		GetParticleBounds(lower, upper);
		lower -= Vec3(radius*0.5f);
		upper += Vec3(radius*0.5f);

		Vec3 center = 0.5f*(upper + lower);

		float width = (upper - lower).x*0.5f;
		float depth = (upper - lower).z*0.5f;
		float edge = 0.0075f*0.5f;
		float height = 8 * radius;

		AddBox(Vec3(edge, height, depth), center + Vec3(-width, height / 2, 0.0f));
		AddBox(Vec3(edge, height, depth), center + Vec3(width, height / 2, 0.0f));
		AddBox(Vec3(width - edge, height, edge), center + Vec3(0.0f, height / 2, (depth - edge)));
		AddBox(Vec3(width - edge, height, edge), center + Vec3(0.0f, height / 2, -(depth - edge)));
		AddBox(Vec3(width, edge, depth), Vec3(center.x, lower.y, center.z));

		g_params.gravity[1] = -9.f;
		g_params.radius = radius;
		g_params.dynamicFriction = 0.0f;
		g_params.numIterations = 5;
		g_params.numPlanes = 1;
		g_params.restitution = 0.0f;
		g_params.collisionDistance = radius;
		g_params.particleCollisionMargin = radius*0.5f;

		g_params.relaxationFactor = 0.0f;
		g_numSubsteps = 2;

		g_lightDistance *= 0.85f;

		// draw options
		g_drawPoints = true;
		g_warmup = false;
	}
};