Exemplo n.º 1
0
        public void GetFixtureEdgeCoordTest2()
        {
            Scene scene = new Scene();
            Vector2[] vertices = new Vector2[] {
                new Vector2(0, 0),
                new Vector2(1, 0),
                new Vector2(1, 1),
                new Vector2(0, 1)
            };
            Actor actor = new Actor(scene, vertices);
            actor.SetTransform(new Transform2(new Vector2(), 1, 0, true));
            PolygonCoord polyCoord = new PolygonCoord(0, 0f);
            FixtureCoord fixtureCoord = FixtureExt.GetFixtureEdgeCoord(actor, polyCoord);

            Transform2 expected = PolygonExt.GetTransform(actor.GetWorldVertices(), polyCoord);
            Transform2 result = PolygonExt.GetTransform(fixtureCoord);
            Assert.IsTrue(expected.AlmostEqual(result));
        }
Exemplo n.º 2
0
        public void GetWorldPointsTest3()
        {
            Scene scene = new Scene();
            Vector2[] vertices = new Vector2[] {
                new Vector2(0, 0),
                new Vector2(2.2f, 0),
                new Vector2(1, 1),
                new Vector2(0, 1)
            };
            Actor actor = new Actor(scene, vertices);
            actor.SetTransform(new Transform2(new Vector2(4.2f, -5.5f), -2f, -2f, true));
            PortalCommon.UpdateWorldTransform(scene);
            scene.World.ProcessChanges();

            Vector2[] fixtureVertices = FixtureExt.GetWorldPoints(actor.Body.FixtureList[0]);
            Assert.IsTrue(MathExt.IsIsomorphic(actor.GetWorldVertices(), fixtureVertices, (item0, item1) => (item0 - item1).Length < 0.001f));
        }
Exemplo n.º 3
0
        public void GetWorldVerticesTest0()
        {
            Vector2[] vertices = new Vector2[]
            {
                new Vector2(0, 0),
                new Vector2(1, 0),
                new Vector2(0, 1)
            };
            vertices = PolygonExt.SetNormals(vertices);
            Scene scene = new Scene();
            Actor actor = new Actor(scene, vertices);
            PortalCommon.UpdateWorldTransform(scene);

            actor.SetTransform(new Transform2(new Vector2(), 1, 0, false));
            Assert.IsTrue(PolygonExt.IsInterior(actor.GetWorldVertices()));

            actor.SetTransform(new Transform2(new Vector2(), 1, 0, true));
            Assert.IsTrue(PolygonExt.IsInterior(actor.GetWorldVertices()));

            actor.SetTransform(new Transform2(new Vector2(), -1, 0, false));
            Assert.IsTrue(PolygonExt.IsInterior(actor.GetWorldVertices()));

            actor.SetTransform(new Transform2(new Vector2(), -1, 0, true));
            Assert.IsTrue(PolygonExt.IsInterior(actor.GetWorldVertices()));
        }
Exemplo n.º 4
0
        public void GetWorldPointsTest0()
        {
            Scene scene = new Scene();
            Vector2[] vertices = new Vector2[] {
                new Vector2(0, 0),
                new Vector2(2.2f, 0),
                new Vector2(1, 1),
                new Vector2(0, 1)
            };
            Actor actor = new Actor(scene, vertices);
            PortalCommon.UpdateWorldTransform(scene);

            Vector2[] fixtureVertices = Vector2Ext.ToOtk(((PolygonShape)actor.Body.FixtureList[0].Shape).Vertices);
            Assert.IsTrue(MathExt.IsIsomorphic(actor.GetWorldVertices(), fixtureVertices));
        }
Exemplo n.º 5
0
 public void GetFixtureContourAssert(Actor actor)
 {
     Vector2[] worldVertices = actor.GetWorldVertices().ToArray();
     List<Vector2> fixtureVertices = Actor.GetFixtureContour(actor);
     Assert.IsTrue(worldVertices.SequenceEqual(fixtureVertices));
 }