aboutsummaryrefslogtreecommitdiff
path: root/demo/scenes/bouyancy.h
blob: 8b51e29e3ee6ced77e0ea8f9da05028aa2362006 (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
66
67
68
69
70
71
72
73
74
class Buoyancy : public Scene
{
public:

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

	virtual void Initialize()
	{	
		float radius = 0.1f;
		float restDistance = radius*0.5f;
		int group = 0;

		int n = 3;
		float spacing = 64*restDistance*0.9f/(2.0f*n);
		float sampling = restDistance*0.8f;
		Vec3 size = sampling*12.0f;

		const float mass[] = {1.0f, 0.25f, 0.005f };

		for (int j=0; j < 1; ++j)
			for (int i=0; i < n; ++i)
				CreateParticleShape(GetFilePathByPlatform("../../data/sphere.ply").c_str(), Vec3(spacing - 0.5f*size.x + i*spacing * 2, 2.0f + j*size.y*1.2f, 0.6f), size, 0.0f, sampling, Vec3(0.0f, 0.0f, 0.0f), mass[i], true, 1.0f, NvFlexMakePhase(group++, 0), true, 0.0001f);
				
		g_numSolidParticles = g_buffers->positions.size();	

		int x = 64;
		int y = 20;
		int z = 32;

		CreateParticleGrid(Vec3(0.0f), x, y, z, restDistance*0.9f, Vec3(0.0f), 1.0f, false, 0.0f, NvFlexMakePhase(group++, eNvFlexPhaseSelfCollide | eNvFlexPhaseFluid));

		g_params.radius = radius;
		g_params.dynamicFriction = 0.1f;
		g_params.viscosity = 2.0f;
		g_params.numIterations = 4;
		g_params.vorticityConfinement = 180.f;
		g_params.fluidRestDistance = restDistance;
		g_params.numPlanes = 5;
		g_params.cohesion = 0.001625f;
		g_params.collisionDistance = restDistance;
		g_params.solidPressure = 0.1f;
		g_params.restitution = 0.0f;
		g_params.relaxationFactor = 1.0f;
		g_params.relaxationMode = eNvFlexRelaxationLocal;

		g_numSubsteps = 2;

		g_maxDiffuseParticles = 64*1024;
		g_diffuseScale = 0.25f;		
		g_diffuseShadow = false;
		g_diffuseColor = 1.5f;
		g_diffuseMotionScale = 1.5f;
		g_params.diffuseBallistic = 35;
		g_params.diffuseThreshold *= 0.1f;
		
		g_drawPlaneBias = g_params.collisionDistance*1.5f;

		g_lightDistance *= 0.65f;
		
		g_fluidColor = Vec4(0.2f, 0.6f, 0.9f, 1.0f);

		// draw options
		g_drawDensity = true;
		g_drawDiffuse = true;
		g_drawEllipsoids = true;
		g_drawPoints = false;

		g_warmup = true;
	}

};