示例#1
0
        static void Main(string[] args)
        {
            GroupCollection collection1 = new GroupCollection();
            GroupCollection collection2 = new GroupCollection();

            /* collection1.AddRange(new int[] { 1 });
            *  collection1.AddRange(new int[] {  3 });
            *  collection1.AddRange(new int[] {  2 });*/
            collection1.Add(1);
            collection1.Add(3);
            collection1.Add(2);
            collection2.Add(1);
            Console.WriteLine(GroupCollection.Intersect(collection1, collection2));

            Console.ReadLine();
            return;

            PhysicsEngine engine = new PhysicsEngine();

            engine.BroadPhase = new Physics2DDotNet.Detectors.SelectiveSweepDetector();
            engine.Solver     = new Physics2DDotNet.Solvers.SequentialImpulsesSolver();

            PhysicsTimer timer = new PhysicsTimer(engine.Update, .01f);

            timer.IsRunning = true;



            Coefficients coffecients = new Coefficients(/*restitution*/ 1, /*friction*/ .5f);


            IShape shape1 = new CircleShape(8, 7);
            IShape shape2 = new PolygonShape(VertexHelper.CreateRectangle(20, 10), 3);

            Scalar mass  = 5;
            Body   body1 = new Body(new PhysicsState(), shape1, mass, coffecients, new Lifespan());
            Body   body2 = new Body(new PhysicsState(), shape2, mass, coffecients, new Lifespan());

            engine.AddBody(body1);
            engine.AddBody(body2);
            Joint joint = new HingeJoint(body1, body2, Vector2D.Zero, new Lifespan());

            engine.AddJoint(joint);
            joint.Lifetime.IsExpired = true;

            engine.AddJoint(new HingeJoint(body1, body2, Vector2D.Zero, new Lifespan()));
            engine.Update(0, 0);

            body1.Lifetime.IsExpired = true;

            timer.IsRunning = false;
            engine.AddProxy(body1, body2, Matrix2x2.Identity);
            //  b1.RemoveFromProxy();



            BinaryFormatter formatter = new BinaryFormatter();
            MemoryStream    stream    = new MemoryStream();

            formatter.Serialize(stream, engine);
            stream.Seek(0, SeekOrigin.Begin);
            PhysicsEngine engine2 = (PhysicsEngine)formatter.Deserialize(stream);



            Console.WriteLine();

            /*
             *
             * Vector2D[] vertexes1 = new Vector2D[]
             * {
             *  new Vector2D(-1,1),
             *  new Vector2D(-3,1),
             *  new Vector2D(-3,-1),
             *  new Vector2D(-1,-1),
             * };
             * Vector2D[] vertexes2 = new Vector2D[]
             * {
             *  new Vector2D(1,-1),
             *  new Vector2D(3,-1),
             *  new Vector2D(3,1),
             *  new Vector2D(1,1),
             * };
             * Vector2D[][] polygons = new Vector2D[2][];
             * polygons[0] = vertexes1;
             * polygons[1] = vertexes2;
             * Console.WriteLine(MultiPartPolygon.GetCentroid(polygons));
             * Console.WriteLine(MultiPartPolygon.GetArea(polygons));
             */
            Console.WriteLine("Finished");
            Console.ReadLine();
        }