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);
}
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);
}
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;
}
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();
}
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");
}
Aggregations