Esempio n. 1
0
        public Matrix3D Con(Transform v)
        {
            var m = new Matrix3D();

            m.M11 = v.rotation[0][0];
            m.M21 = v.rotation[0][1];
            m.M31 = v.rotation[0][2];
            m.M12 = v.rotation[1][0];
            m.M22 = v.rotation[1][1];
            m.M32 = v.rotation[1][2];
            m.M13 = v.rotation[2][0];
            m.M23 = v.rotation[2][1];
            m.M33 = v.rotation[2][2];
            m.Translate(new Vector3D(v.position[0], v.position[1], v.position[2]));
            return(m);
        }
Esempio n. 2
0
        static Scene InitPhysics(List <Box> boxes)
        {
            var scene = new Scene(1 / 100.0, new Vec3(0, -9.8, 0), 10);
            //scene.SetAllowSleep(false);


            // Create the floor
            BodyDef bodyDef = new BodyDef();
            Body    body    = scene.CreateBody(bodyDef);

            BoxDef boxDef = new BoxDef();

            boxDef.SetRestitution(0.5);
            boxDef.SetFriction(0.7);
            Transform tx = Transform.Identity;

            boxDef.Set(tx, new Vec3(50.0, 1.0, 50.0));
            body.AddBox(boxDef);

            bodyDef.bodyType = BodyType.eDynamicBody;
            bodyDef.active   = true;
            bodyDef.awake    = true;
            boxDef.Set(tx, new Vec3(1.0f, 1.0f, 1.0f));

            var r = new Random();

            for (int i = 0; i < 8; ++i)
            {
                for (int j = 0; j < 8; ++j)
                {
                    bodyDef.position.Set(-5.0f + 1.25f * i, 5.0f, -5.0f + 1.25f * j);
                    bodyDef.axis  = new Vec3(0, 0, 1);
                    bodyDef.angle = r.NextDouble() * Math.PI;

                    body = scene.CreateBody(bodyDef);

                    boxes.Add(body.AddBox(boxDef));
                }
            }

            return(scene);
        }