Search in sources :

Example 61 with Vector2

use of com.badlogic.gdx.math.Vector2 in project commons-gdx by gemserk.

the class SpatialHierarchicalImpl method setParent.

public void setParent(Spatial parent) {
    Vector2 position = getPosition();
    float angle = getAngle();
    this.parent = parent;
    setPosition(position.x, position.y);
    setAngle(angle);
}
Also used : Vector2(com.badlogic.gdx.math.Vector2)

Example 62 with Vector2

use of com.badlogic.gdx.math.Vector2 in project commons-gdx by gemserk.

the class SpatialPhysicsImpl method setAngle.

@Override
public void setAngle(float angle) {
    // TODO: fix this to update the position if it wasn't correctly set yet.
    Vector2 position = body.getPosition();
    body.setTransform(position.x, position.y, angle * MathUtils.degreesToRadians, false);
}
Also used : Vector2(com.badlogic.gdx.math.Vector2)

Example 63 with Vector2

use of com.badlogic.gdx.math.Vector2 in project commons-gdx by gemserk.

the class ConvexHull2dImpl method recalculate.

@Override
public boolean recalculate() {
    convexHullPoints.clear();
    if (size < 2) {
        size = 0;
        return false;
    }
    Vector2 p;
    Vector2 bot = points.get(0);
    for (int i = 1; i < size; i++) {
        Vector2 point = points.get(i);
        if (point.y < bot.y)
            bot = point;
    }
    convexHullPoints.add(bot);
    p = bot;
    do {
        int i;
        i = points.get(0) == p ? 1 : 0;
        Vector2 cand = points.get(i);
        for (i = i + 1; i < size; i++) {
            Vector2 point = points.get(i);
            if (point != p && area(p, cand, point) > 0)
                cand = points.get(i);
        }
        convexHullPoints.add(cand);
        p = cand;
        // worst case scenario the convex hull should have the same size as the original points array.
        if (convexHullPoints.size == size)
            break;
    } while (p != bot);
    size = 0;
    return true;
}
Also used : Vector2(com.badlogic.gdx.math.Vector2)

Example 64 with Vector2

use of com.badlogic.gdx.math.Vector2 in project commons-gdx by gemserk.

the class ImmediateModeRendererUtils method drawPolygon.

public static void drawPolygon(Vector2[] vertices, float x, float y, float angle, Color color) {
    GL10 gl = Gdx.graphics.getGL10();
    gl.glPushMatrix();
    gl.glTranslatef(x, y, 0f);
    gl.glRotatef(angle, 0f, 0f, 1f);
    ImmediateModeRenderer renderer = getRenderer();
    renderer.begin(getProjectionMatrix(), GL10.GL_LINE_LOOP);
    for (int i = 0; i < vertices.length; i++) {
        Vector2 v = vertices[i];
        renderer.color(color.r, color.g, color.b, color.a);
        renderer.vertex(v.x, v.y, 0);
    }
    renderer.end();
    gl.glPopMatrix();
}
Also used : ImmediateModeRenderer(com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer) GL10(com.badlogic.gdx.graphics.GL10) Vector2(com.badlogic.gdx.math.Vector2)

Example 65 with Vector2

use of com.badlogic.gdx.math.Vector2 in project commons-gdx by gemserk.

the class ContactsTest method setUp.

@Before
public void setUp() {
    contacts = new Contacts();
    box2dcontact = mockery.mock(com.badlogic.gdx.physics.box2d.Contact.class);
    worldManifold = mockery.mock(WorldManifold.class);
    normal = new Vector2(0, 1);
    fixtureA = mockery.mock(Fixture.class, "fixtureA");
    fixtureB = mockery.mock(Fixture.class, "fixtureB");
}
Also used : WorldManifold(com.badlogic.gdx.physics.box2d.WorldManifold) Vector2(com.badlogic.gdx.math.Vector2) Fixture(com.badlogic.gdx.physics.box2d.Fixture) Contact(com.gemserk.commons.gdx.box2d.Contacts.Contact) Before(org.junit.Before)

Aggregations

Vector2 (com.badlogic.gdx.math.Vector2)103 Body (com.badlogic.gdx.physics.box2d.Body)21 BodyDef (com.badlogic.gdx.physics.box2d.BodyDef)14 FixtureDef (com.badlogic.gdx.physics.box2d.FixtureDef)10 PolygonShape (com.badlogic.gdx.physics.box2d.PolygonShape)10 Texture (com.badlogic.gdx.graphics.Texture)7 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)7 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)7 EdgeShape (com.badlogic.gdx.physics.box2d.EdgeShape)7 Vector3 (com.badlogic.gdx.math.Vector3)6 Fixture (com.badlogic.gdx.physics.box2d.Fixture)6 World (com.badlogic.gdx.physics.box2d.World)6 GameEntity (ilargia.egdx.logicbricks.gen.game.GameEntity)6 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)5 CircleShape (com.badlogic.gdx.physics.box2d.CircleShape)5 Test (org.junit.Test)5 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)4 Box2DDebugRenderer (com.badlogic.gdx.physics.box2d.Box2DDebugRenderer)4 Contact (com.badlogic.gdx.physics.box2d.Contact)4 WorldManifold (com.badlogic.gdx.physics.box2d.WorldManifold)4