aboutsummaryrefslogtreecommitdiff
path: root/demo/scenes/sdfcollision.h
diff options
context:
space:
mode:
authorMiles Macklin <[email protected]>2017-03-10 14:51:31 +1300
committerMiles Macklin <[email protected]>2017-03-10 14:51:31 +1300
commitad3d90fafe5ee79964bdfe1f1e0704c3ffcdfd5f (patch)
tree4cc6f3288363889d7342f7f8407c0251e6904819 /demo/scenes/sdfcollision.h
downloadflex-ad3d90fafe5ee79964bdfe1f1e0704c3ffcdfd5f.tar.xz
flex-ad3d90fafe5ee79964bdfe1f1e0704c3ffcdfd5f.zip
Initial 1.1.0 binary release
Diffstat (limited to 'demo/scenes/sdfcollision.h')
-rw-r--r--demo/scenes/sdfcollision.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/demo/scenes/sdfcollision.h b/demo/scenes/sdfcollision.h
new file mode 100644
index 0000000..aab2182
--- /dev/null
+++ b/demo/scenes/sdfcollision.h
@@ -0,0 +1,54 @@
+
+class SDFCollision : public Scene
+{
+public:
+
+ SDFCollision(const char* name) : Scene(name)
+ {
+ }
+
+ virtual void Initialize()
+ {
+ const int dim = 128;
+
+ NvFlexDistanceFieldId sdf = CreateSDF(GetFilePathByPlatform("../../data/bunny.ply").c_str(), dim);
+
+ AddSDF(sdf, Vec3(-1.f, 0.0f, 0.0f), QuatFromAxisAngle(Vec3(0.0f, 1.0f, 0.0f), DegToRad(-45.0f)), 0.5f);
+ AddSDF(sdf, Vec3(0.0f, 0.0f, 0.0f), QuatFromAxisAngle(Vec3(0.0f, 1.0f, 0.0f), DegToRad(0.0f)), 1.0f);
+ AddSDF(sdf, Vec3(1.0f, 0.0f, 0.0f), QuatFromAxisAngle(Vec3(0.0f, 1.0f, 0.0f), DegToRad(45.0f)), 2.0f);
+
+ float stretchStiffness = 1.0f;
+ float bendStiffness = 0.8f;
+ float shearStiffness = 0.5f;
+
+ int dimx = 64;
+ int dimz = 64;
+ float radius = 0.05f;
+ int phase = NvFlexMakePhase(0, eNvFlexPhaseSelfCollide | eNvFlexPhaseSelfCollideFilter);
+
+ CreateSpringGrid(Vec3(-0.6f, 2.9f, -0.6f), dimx, dimz, 1, radius*0.75f, phase, stretchStiffness, bendStiffness, shearStiffness, 0.0f, 1.0f);
+
+ Vec3 lower, upper;
+ GetParticleBounds(lower, upper);
+
+ g_params.radius = radius*1.0f;
+ g_params.dynamicFriction = 0.4f;
+ g_params.staticFriction = 0.4f;
+ g_params.particleFriction = 0.25f;
+ g_params.dissipation = 0.0f;
+ g_params.numIterations = 8;
+ g_params.viscosity = 0.0f;
+ g_params.drag = 0.02f;
+ g_params.lift = 0.1f;
+ g_params.collisionDistance = radius*0.5f;
+ g_params.relaxationFactor = 1.3f;
+
+ g_numSubsteps = 3;
+
+ g_windStrength = 0.0f;
+
+ // draw options
+ g_drawPoints = false;
+ g_drawSprings = false;
+ }
+};