示例#1
0
        void InitClusterCombine()
        {
            Vector3  sz   = new Vector3(2, 4, 2);
            SoftBody psb0 = CreateClusterTorus(new Vector3(0, 8, 0), new Vector3((float)Math.PI / 2, 0, (float)Math.PI / 2), sz);
            SoftBody psb1 = CreateClusterTorus(new Vector3(0, 8, 10), new Vector3((float)Math.PI / 2, 0, (float)Math.PI / 2), sz);

            foreach (var psb in new[] { psb0, psb1 })
            {
                psb.Cfg.DF                  = 1;
                psb.Cfg.DP                  = 0;
                psb.Cfg.PIterations         = 1;
                psb.Clusters[0].Matching    = 0.05f;
                psb.Clusters[0].NodeDamping = 0.05f;
            }

            using (var aj = new AJoint.Specs())
            {
                aj.Axis    = new Vector3(0, 0, 1);
                aj.Control = motorControl;
                psb0.AppendAngularJoint(aj, psb1);
            }

            using (var lj = new LJoint.Specs())
            {
                lj.Position = new Vector3(0, 8, 5);
                psb0.AppendLinearJoint(lj, psb1);
            }
        }
        void Init_ClusterHinge()
        {
            SoftBody  psb = Create_ClusterTorus(Vector3.Zero, new Vector3((float)Math.PI / 2, 0, (float)Math.PI / 2));
            RigidBody prb = Create_BigPlate(50, 8);

            psb.Cfg.DF = 1;
            AJoint.Specs aj = new AJoint.Specs();
            aj.Axis = new Vector3(0, 0, 1);
            psb.AppendAngularJoint(aj, new Body(prb));
        }
        void Init_ClusterCombine()
        {
            Vector3  sz   = new Vector3(2, 4, 2);
            SoftBody psb0 = Create_ClusterTorus(new Vector3(0, 8, 0), new Vector3((float)Math.PI / 2, 0, (float)Math.PI / 2), sz);
            SoftBody psb1 = Create_ClusterTorus(new Vector3(0, 8, 10), new Vector3((float)Math.PI / 2, 0, (float)Math.PI / 2), sz);

            SoftBody[] psbs = new SoftBody[] { psb0, psb1 };
            for (int j = 0; j < 2; ++j)
            {
                psbs[j].Cfg.DF                  = 1;
                psbs[j].Cfg.DP                  = 0;
                psbs[j].Cfg.PIterations         = 1;
                psbs[j].Clusters[0].Matching    = 0.05f;
                psbs[j].Clusters[0].NodeDamping = 0.05f;
            }
            AJoint.Specs aj = new AJoint.Specs();
            aj.Axis    = new Vector3(0, 0, 1);
            aj.Control = motorControl;
            psb0.AppendAngularJoint(aj, psb1);

            LJoint.Specs lj = new LJoint.Specs();
            lj.Position = new Vector3(0, 8, 5);
            psb0.AppendLinearJoint(lj, psb1);
        }
示例#4
0
        void InitClusterCar()
        {
            //SetAzi(180);
            Vector3     origin      = new Vector3(100, 80, 0);
            Quaternion  orientation = Quaternion.RotationYawPitchRoll(-(float)Math.PI / 2, 0, 0);
            const float widthf      = 8;
            const float widthr      = 9;
            const float length      = 8;
            const float height      = 4;

            Vector3[] wheels =
            {
                new Vector3(+widthf, -height, +length), // Front left
                new Vector3(-widthf, -height, +length), // Front right
                new Vector3(+widthr, -height, -length), // Rear left
                new Vector3(-widthr, -height, -length), // Rear right
            };
            SoftBody pa  = CreateClusterBunny(Vector3.Zero, Vector3.Zero);
            SoftBody pfl = CreateClusterTorus(wheels[0], new Vector3(0, 0, (float)Math.PI / 2), new Vector3(2, 4, 2));
            SoftBody pfr = CreateClusterTorus(wheels[1], new Vector3(0, 0, (float)Math.PI / 2), new Vector3(2, 4, 2));
            SoftBody prl = CreateClusterTorus(wheels[2], new Vector3(0, 0, (float)Math.PI / 2), new Vector3(2, 5, 2));
            SoftBody prr = CreateClusterTorus(wheels[3], new Vector3(0, 0, (float)Math.PI / 2), new Vector3(2, 5, 2));

            pfl.Cfg.DF             =
                pfr.Cfg.DF         =
                    prl.Cfg.DF     =
                        prr.Cfg.DF = 1;

            using (var lspecs = new LJoint.Specs())
            {
                lspecs.Cfm      = 1;
                lspecs.Erp      = 1;
                lspecs.Position = wheels[0]; pa.AppendLinearJoint(lspecs, pfl);
                lspecs.Position = wheels[1]; pa.AppendLinearJoint(lspecs, pfr);
                lspecs.Position = wheels[2]; pa.AppendLinearJoint(lspecs, prl);
                lspecs.Position = wheels[3]; pa.AppendLinearJoint(lspecs, prr);
            }

            using (var aspecs = new AJoint.Specs())
            {
                aspecs.Cfm  = 1;
                aspecs.Erp  = 1;
                aspecs.Axis = new Vector3(1, 0, 0);

                aspecs.Control = steerControlF;
                pa.AppendAngularJoint(aspecs, pfl);
                pa.AppendAngularJoint(aspecs, pfr);

                aspecs.Control = motorControl;
                pa.AppendAngularJoint(aspecs, prl);
                pa.AppendAngularJoint(aspecs, prr);
            }

            pa.Rotate(orientation);
            pfl.Rotate(orientation);
            pfr.Rotate(orientation);
            prl.Rotate(orientation);
            prr.Rotate(orientation);
            pa.Translate(origin);
            pfl.Translate(origin);
            pfr.Translate(origin);
            prl.Translate(origin);
            prr.Translate(origin);
            pfl.Cfg.PIterations                     =
                pfr.Cfg.PIterations                 =
                    prl.Cfg.PIterations             =
                        prr.Cfg.PIterations         = 1;
            pfl.Clusters[0].Matching                =
                pfr.Clusters[0].Matching            =
                    prl.Clusters[0].Matching        =
                        prr.Clusters[0].Matching    = 0.05f;
            pfl.Clusters[0].NodeDamping             =
                pfr.Clusters[0].NodeDamping         =
                    prl.Clusters[0].NodeDamping     =
                        prr.Clusters[0].NodeDamping = 0.05f;

            CreateStairs(20, new Vector3(0, -8, 0), new Vector3(3, 2, 40));
            CreateRigidBodyStack(50);
        }