protected void SetConfig(SoftBody sb)
        {
            sb.Cfg.AeroModel = this.AeroModel;
            sb.Cfg.DF = this.DynamicFrictionCoefficient;
            sb.Cfg.DP = this.DampingCoefficient;
            sb.Cfg.PR = this.PressureCoefficient;
            sb.Cfg.LF = this.LiftCoefficient;
            sb.Cfg.VC = this.VolumeConservation;
            sb.Cfg.Collisions |= FCollisions.VFSS;

            sb.Cfg.Chr = this.RigidContactHardness;
            sb.Cfg.Shr = this.SoftContactHardness;

            sb.Cfg.DG = this.DragCoefficient;
            sb.Cfg.Ahr = this.AnchorHardness;
            if (this.IsVolumeMass)
            {
                sb.SetVolumeMass(this.Mass);
            }
            else
            {
                sb.SetTotalMass(this.Mass, false);
            }

            if (this.GenerateBendingConstraints)
            {
                sb.GenerateBendingConstraints(this.BendingDistance);
            }
        }
Exemplo n.º 2
0
        /// <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.SetConfig(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);
        }