Esempio n. 1
0
        private void BuildScene()
        {
            physicsSystem.ClearObjects();

            Material <float> material = new Material <float>(1, 0.3f, 0.6f, 0f);

            RigidPhysicsObject <float> ground = new RigidPhysicsObject <float>(new Cuboid <float>(10, 1, 20, new Vector <float>(0, 10, -.9f), Quaternion <float> .Identity), material, isStatic: true);

            physicsSystem.AddBody(ground);

            for (int i = 0; i < 20; i++)
            {
                for (int j = i; j < 20; j++)
                {
                    float x = 0.0f;
                    float y = (j - i * 0.5f) * 1.01f;
                    float z = 0.5f + i * 1.0f;

                    z = z + .1f;

                    Vector <float> position = new Vector <float>(x, y, z);

                    RigidPhysicsObject <float> box = new RigidPhysicsObject <float>(
                        new Cube <float>(.5f, position, Quaternion <float> .Identity),
                        material);

                    physicsSystem.AddBody(box);
                }
            }
        }
Esempio n. 2
0
        private void ShootSphere()
        {
            Vector <float> pos, ang;

            dsGetViewPoint(out pos, out ang);

            Material <float> material = new Material <float>(3, 0.3f, 0.6f, 0f);

            RigidPhysicsObject <float> obj = new RigidPhysicsObject <float>(
                new Sphere <float>(.5f),
                material);

            obj.Velocity = new Vector <float>(
                (float)Math.Cos(ang.X / 180.0f * System.Math.PI),
                (float)Math.Sin(ang.X / 180.0f * System.Math.PI),
                (float)Math.Sin(ang.Y / 180.0f * System.Math.PI)) * 50f;

            physicsSystem.AddBody(obj);
        }