Example #1
0
        public RopeTest()
        {
            const int N = 40;

            Vec2[]   vertices = new Vec2[N];
            float [] masses   = new float [N];

            for (int i = 0; i < N; ++i)
            {
                vertices[i].Set(0.0f, 20.0f - 0.25f * i);
                masses[i] = 1.0f;
            }
            masses[0] = 0.0f;
            masses[1] = 0.0f;

            RopeDef def = new RopeDef();

            def.vertices = new List <Vec2>(vertices);
            def.count    = N;
            def.gravity.Set(0.0f, -10.0f);
            def.masses  = new List <float>(masses);
            def.damping = 0.1f;
            def.k2      = 1.0f;
            def.k3      = 0.5f;

            m_rope.Initialize(def);

            m_angle = 0.0f;
            m_rope.SetAngle(m_angle);
        }
        public RopeTest()
        {
            const int   N        = 20;
            const float L        = 0.5f;
            var         vertices = new Vector2[N];
            var         masses   = new float[N];

            for (var i = 0; i < N; ++i)
            {
                vertices[i].Set(0.0f, L * (N - i));
                masses[i] = 1.0f;
            }

            masses[0] = 0.0f;
            masses[1] = 0.0f;
            Tuning1   = new RopeTuning
            {
                BendHertz        = 30.0f,
                BendDamping      = 4.0f,
                BendStiffness    = 1.0f,
                BendingModel     = BendingModel.PbdTriangleBendingModel,
                Isometric        = true,
                StretchHertz     = 30.0f,
                StretchDamping   = 4.0f,
                StretchStiffness = 1.0f,
                StretchingModel  = StretchingModel.PbdStretchingModel
            };

            Tuning2 = new RopeTuning
            {
                BendHertz        = 30.0f,
                BendDamping      = 0.7f,
                BendStiffness    = 1.0f,
                BendingModel     = BendingModel.PbdHeightBendingModel,
                Isometric        = true,
                StretchHertz     = 30.0f,
                StretchDamping   = 1.0f,
                StretchStiffness = 1.0f,
                StretchingModel  = StretchingModel.PbdStretchingModel
            };

            Position1.Set(-5.0f, 15.0f);
            Position2.Set(5.0f, 15.0f);

            var def = new RopeDef
            {
                Vertices = vertices,
                Count    = N,
                Gravity  = new Vector2(0.0f, -10.0f),
                Masses   = masses,
                Position = Position1,
                Tuning   = Tuning1
            };

            Rope1 = new Rope();
            Rope1.Create(def);

            def.Position = Position2;
            def.Tuning   = Tuning2;
            Rope2        = new Rope();
            Rope2.Create(def);

            Iterations1 = 8;
            Iterations2 = 8;

            Speed = 10.0f;
        }