aboutsummaryrefslogtreecommitdiff
path: root/demo/scenes/shapechannels.h
blob: 22ee6497480381b96fd8f4dea2654518d12a9c8b (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
// demonstrates how to make particles collide with 
// selected collision shapes based on the channel mask
class ShapeChannels : public Scene
{
public:

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

	void Initialize()
	{
		const float radius = 0.05f;
		
		Vec3 offset = Vec3(-0.25f, 6.0f, -0.25f);

		// layers of particles each set to collide with a different shape channel
		int numLayers = 8;

		for (int i=0; i < numLayers; ++i)
		{
			CreateParticleGrid(offset + Vec3(0.0f, 2.0f*i*radius, 0.0f), 10, 1, 10, radius, Vec3(0.0f), 1.0f, false, 0.0f, NvFlexMakePhaseWithChannels(i, eNvFlexPhaseSelfCollide, eNvFlexPhaseShapeChannel0<<i), 0.0f);
			//CreateParticleGrid(offset + Vec3(0.0f, 2.0f*radius, 0.0f), 10, 1, 10, radius, Vec3(0.0f), 1.0f, false, 0.0f, NvFlexMakePhaseWithChannels(0, eNvFlexPhaseSelfCollide, eNvFlexPhaseShapeChannel1), 0.0f);
			//CreateParticleGrid(offset + Vec3(0.0f, 4.0f*radius, 0.0f), 10, 1, 10, radius, Vec3(0.0f), 1.0f, false, 0.0f, NvFlexMakePhaseWithChannels(0, eNvFlexPhaseSelfCollide, eNvFlexPhaseShapeChannel2), 0.0f);
		
			AddBox(Vec3(0.5f, 0.1f, 0.5f), Vec3(0.0f, 0.5f + i*0.5f, 0.0f), Quat(), false, eNvFlexPhaseShapeChannel0<<i);
		}

		// regular box
		//AddBox(Vec3(0.5f, 0.1f, 0.5f), Vec3(0.0f, 0.5f, 0.0f), Quat(), false, eNvFlexPhaseShapeChannel0);
		//AddBox(Vec3(0.5f, 0.1f, 0.5f), Vec3(0.0f, 1.0f, 0.0f), Quat(), false, eNvFlexPhaseShapeChannel1);
		//AddBox(Vec3(0.5f, 0.1f, 0.5f), Vec3(0.0f, 1.5f, 0.0f), Quat(), false, eNvFlexPhaseShapeChannel2);

		g_params.radius = radius;
		g_params.dynamicFriction = 0.025f;
		g_params.dissipation = 0.0f;
		g_params.restitution = 0.0;
		g_params.numIterations = 4;
		g_params.particleCollisionMargin = g_params.radius*0.05f;

		g_numSubsteps = 1;
	}

	virtual void Update()
	{
		
	}
};