Exemple #1
0
        // Aerodynamic forces, 50x1g flyers
        void InitAero()
        {
            const float s        = 2;
            const int   segments = 6;
            const int   count    = 50;
            Random      random   = new Random();

            for (int i = 0; i < count; ++i)
            {
                SoftBody psb = SoftBodyHelpers.CreatePatch(softBodyWorldInfo,
                                                           new Vector3(-s, 0, -s), new Vector3(+s, 0, -s),
                                                           new Vector3(-s, 0, +s), new Vector3(+s, 0, +s),
                                                           segments, segments, 0, true);
                Material pm = psb.AppendMaterial();
                pm.Flags -= FMaterial.DebugDraw;
                psb.GenerateBendingConstraints(2, pm);
                psb.Cfg.LF        = 0.004f;
                psb.Cfg.DG        = 0.0003f;
                psb.Cfg.AeroModel = AeroModel.VTwoSided;
                Matrix     trans = Matrix.Identity;
                Vector3    ra    = 0.1f * GetRandomVector(random);
                Vector3    rp    = 75 * GetRandomVector(random) + new Vector3(-50, 15, 0);
                Quaternion rot   = Quaternion.RotationYawPitchRoll(
                    (float)Math.PI / 8 + ra.X, (float)-Math.PI / 7 + ra.Y, ra.Z);
                trans *= Matrix.RotationQuaternion(rot);
                trans *= Matrix.Translation(rp);
                psb.Transform(trans);
                psb.TotalMass = 0.1f;
                psb.AddForce(new Vector3(0, (float)random.NextDouble(), 0), 0);
                SoftWorld.AddSoftBody(psb);
            }

            CullingEnabled = false;
        }