SoftBody CreateClusterBunny(Vector3 x, Vector3 a) { SoftBody psb = SoftBodyHelpers.CreateFromTriMesh(softBodyWorldInfo, BunnyMesh.Vertices, BunnyMesh.Indices); Material pm = psb.AppendMaterial(); pm.Lst = 1; pm.Flags -= FMaterial.DebugDraw; psb.GenerateBendingConstraints(2, pm); psb.Cfg.PIterations = 2; psb.Cfg.DF = 1; psb.Cfg.Collisions = FCollisions.CLSS | FCollisions.CLRS; psb.RandomizeConstraints(); Matrix m = Matrix.RotationYawPitchRoll(a.X, a.Y, a.Z) * Matrix.Translation(x); psb.Transform(m); psb.Scale(new Vector3(8, 8, 8)); psb.SetTotalMass(150, true); psb.GenerateClusters(1); SoftWorld.AddSoftBody(psb); return(psb); }
void InitCollide2() { for (int i = 0; i < 3; ++i) { SoftBody psb = SoftBodyHelpers.CreateFromTriMesh(softBodyWorldInfo, BunnyMesh.Vertices, BunnyMesh.Indices); Material pm = psb.AppendMaterial(); pm.Lst = 0.5f; pm.Flags -= FMaterial.DebugDraw; psb.GenerateBendingConstraints(2, pm); psb.Cfg.PIterations = 2; psb.Cfg.DF = 0.5f; psb.Cfg.Collisions |= FCollisions.VFSS; psb.RandomizeConstraints(); Matrix m = Matrix.RotationYawPitchRoll((float)Math.PI / 2 * (i & 1), 0, 0) * Matrix.Translation(0, -1 + 5 * i, 0); psb.Transform(m); psb.Scale(new Vector3(6, 6, 6)); psb.SetTotalMass(100, true); SoftWorld.AddSoftBody(psb); } cutting = true; }
/// <summary> /// Apply these SoftBody settings to this SoftBody /// </summary> /// <param name="softBody"></param> public void ConfigureSoftBody(SoftBody softBody) { softBody.Scale(scale.ToBullet()); BulletSharp.SoftBody.Material pm = softBody.Materials[0]; sBMaterial.SetSBMaterial(pm); config.CopyToBulletSBConfig(softBody.Cfg); if (allNodeBendingConstraints) { for (int i = 0; i < softBody.Nodes.Count - 1; ++i) { softBody.GenerateBendingConstraints(1 + i); } } else { softBody.GenerateBendingConstraints(bendingConstraintDistance, pm); } if (randomizeConstraints) { softBody.RandomizeConstraints(); } if (generateClusters) { softBody.GenerateClusters(0); } softBody.SetTotalMass(totalMass, fromFaces); softBody.SetPose(bvolume, bframe); }