use of com.badlogic.gdx.math.Vector2 in project libgdx by libgdx.
the class Box2DDebugRenderer method drawJoint.
private void drawJoint(Joint joint) {
Body bodyA = joint.getBodyA();
Body bodyB = joint.getBodyB();
Transform xf1 = bodyA.getTransform();
Transform xf2 = bodyB.getTransform();
Vector2 x1 = xf1.getPosition();
Vector2 x2 = xf2.getPosition();
Vector2 p1 = joint.getAnchorA();
Vector2 p2 = joint.getAnchorB();
if (joint.getType() == JointType.DistanceJoint) {
drawSegment(p1, p2, JOINT_COLOR);
} else if (joint.getType() == JointType.PulleyJoint) {
PulleyJoint pulley = (PulleyJoint) joint;
Vector2 s1 = pulley.getGroundAnchorA();
Vector2 s2 = pulley.getGroundAnchorB();
drawSegment(s1, p1, JOINT_COLOR);
drawSegment(s2, p2, JOINT_COLOR);
drawSegment(s1, s2, JOINT_COLOR);
} else if (joint.getType() == JointType.MouseJoint) {
drawSegment(joint.getAnchorA(), joint.getAnchorB(), JOINT_COLOR);
} else {
drawSegment(x1, p1, JOINT_COLOR);
drawSegment(p1, p2, JOINT_COLOR);
drawSegment(x2, p2, JOINT_COLOR);
}
}
use of com.badlogic.gdx.math.Vector2 in project libgdx by libgdx.
the class Box2DDebugRenderer method drawSolidPolygon.
private void drawSolidPolygon(Vector2[] vertices, int vertexCount, Color color, boolean closed) {
renderer.setColor(color.r, color.g, color.b, color.a);
lv.set(vertices[0]);
f.set(vertices[0]);
for (int i = 1; i < vertexCount; i++) {
Vector2 v = vertices[i];
renderer.line(lv.x, lv.y, v.x, v.y);
lv.set(v);
}
if (closed)
renderer.line(f.x, f.y, lv.x, lv.y);
}
use of com.badlogic.gdx.math.Vector2 in project gdx-skineditor by cobolfoo.
the class Tooltips method showTooltip.
public void showTooltip(Actor actor) {
Vector2 v = new Vector2();
actor.localToStageCoordinates(v);
if (tooltip == null) {
LabelStyle style = new LabelStyle();
style.font = tooltipStyle.font;
style.background = tooltipStyle.background;
style.fontColor = tooltipStyle.fontColor;
tooltip = new Label(tooltips.get(actor), style);
tooltip.setStyle(style);
tooltip.pack();
tooltip.setPosition(v.x + 7.5f, v.y - tooltip.getPrefHeight() - 15);
tooltip.setOriginY(tooltip.getPrefHeight());
tooltip.setColor(1, 1, 1, 0);
tooltip.setScale(1, 0);
tooltip.addAction(parallel(fadeIn(0.15f), scaleTo(1, 1, 0.15f)));
} else {
tooltip.setText(tooltips.get(actor));
tooltip.pack();
tooltip.setPosition(v.x + 7.5f, v.y - tooltip.getPrefHeight() - 15);
}
stage.addActor(tooltip);
}
use of com.badlogic.gdx.math.Vector2 in project commons-gdx by gemserk.
the class ShapeUtils method calculateConvexHull.
/**
* Calculates the Convex Hull of a collection of points, extracted from <a href="http://www.cse.unsw.edu.au/~lambert/java/3d/ConvexHull.html">here</a>
*
* @param points
* An array with the points to be used when building the Convex Hull
* @param convexHullPoints
* An array where the Convex Hull points will be stored.
*/
public static void calculateConvexHull(Array<Vector2> points, Array<Vector2> convexHullPoints) {
if (points.size <= 1)
return;
Vector2 p;
Vector2 bot = points.get(0);
for (int i = 1; i < points.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 < points.size; i++) {
Vector2 point = points.get(i);
if (point != p && area(p, cand, point) > 0)
cand = points.get(i);
}
convexHullPoints.add(cand);
p = cand;
} while (p != bot);
}
use of com.badlogic.gdx.math.Vector2 in project commons-gdx by gemserk.
the class ShapeUtils method translateCircleShape.
/**
* Translates the CircleShape the specified translation.
*
* @param circleShape
* The CircleShape to be translated.
* @param tx
* The translation in x coordinate.
* @param ty
* The translation in y coordinate.
*/
public static void translateCircleShape(CircleShape circleShape, float tx, float ty) {
Vector2 position = circleShape.getPosition();
position.add(tx, ty);
circleShape.setPosition(position);
}
Aggregations