\r
/** Draws a line. The {@link ShapeType} passed to begin has to be {@link ShapeType#Line}. */\r
public final void line (float x, float y, float z, float x2, float y2, float z2) {\r
-\r
line(x, y, z, x2, y2, z2, color, color);\r
}\r
\r
/** Draws a line. The {@link ShapeType} passed to begin has to be {@link ShapeType#Line}. Lazy method that "just" calls the\r
* "other" method and unpacks the Vector3 for you */\r
public final void line (Vector3 v0, Vector3 v1) {\r
-\r
line(v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, color, color);\r
}\r
\r
/** Draws a line in the x/y plane. The {@link ShapeType} passed to begin has to be {@link ShapeType#Line}. */\r
public final void line (float x, float y, float x2, float y2) {\r
-\r
line(x, y, 0.0f, x2, y2, 0.0f, color, color);\r
}\r
\r
/** Draws a line. The {@link ShapeType} passed to begin has to be {@link ShapeType#Line}. Lazy method that "just" calls the\r
* "other" method and unpacks the Vector2 for you */\r
public final void line (Vector2 v0, Vector2 v1) {\r
-\r
line(v0.x, v0.y, 0.0f, v1.x, v1.y, 0.0f, color, color);\r
}\r
\r
* @param c1 Color at start of the line\r
* @param c2 Color at end of the line */\r
public final void line (float x, float y, float x2, float y2, Color c1, Color c2) {\r
-\r
line(x, y, 0.0f, x2, y2, 0.0f, c1, c2);\r
}\r
\r
return currType;\r
}\r
\r
+ public ImmediateModeRenderer getRenderer () {\r
+ return renderer;\r
+ }\r
+\r
public void dispose () {\r
renderer.dispose();\r
}\r
*
* @param p1 The first polygon.
* @param p2 The second polygon.
- * @param mtv A Minimum Translation Vector to fill in the case of a collision (optional).
+ * @param mtv A Minimum Translation Vector to fill in the case of a collision, or null (optional).
* @return Whether polygons overlap. */
public static boolean overlapConvexPolygons (Polygon p1, Polygon p2, MinimumTranslationVector mtv) {
return overlapConvexPolygons(p1.getTransformedVertices(), p2.getTransformedVertices(), mtv);
*
* @param verts1 Vertices of the first polygon.
* @param verts2 Vertices of the second polygon.
- * @param mtv A Minimum Translation Vector to fill in the case of a collision (optional).
+ * @param mtv A Minimum Translation Vector to fill in the case of a collision, or null (optional).
* @return Whether polygons overlap. */
public static boolean overlapConvexPolygons (float[] verts1, float[] verts2, MinimumTranslationVector mtv) {
float overlap = Float.MAX_VALUE;
\r
package com.badlogic.gdx.math;\r
\r
-/** Encapsulates a 2D polygon defined by it's vertices relative \r
- * to an origin point (default of 0, 0). */\r
+/** Encapsulates a 2D polygon defined by it's vertices relative to an origin point (default of 0, 0). */\r
public class Polygon {\r
private float[] localVertices;\r
private float[] worldVertices;\r
private float scaleX = 1, scaleY = 1;\r
private boolean dirty = true;\r
private Rectangle bounds;\r
- \r
+\r
/** Constructs a new polygon with no vertices. */\r
public Polygon () {\r
this.localVertices = new float[0];\r
}\r
\r
- /** Constructs a new polygon from a float array of parts of vertex points. \r
+ /** Constructs a new polygon from a float array of parts of vertex points.\r
* \r
- * @param vertices an array where every even element represents the horizontal\r
- * part of a point, and the following element representing the vertical part\r
+ * @param vertices an array where every even element represents the horizontal part of a point, and the following element\r
+ * representing the vertical part\r
* \r
- * @throws IllegalArgumentException if less than 6 elements, \r
- * representing 3 points, are provided\r
- */\r
+ * @throws IllegalArgumentException if less than 6 elements, representing 3 points, are provided */\r
public Polygon (float[] vertices) {\r
if (vertices.length < 6) throw new IllegalArgumentException("polygons must contain at least 3 points.");\r
this.localVertices = vertices;\r
}\r
\r
- /** Returns the polygon's local vertices without scaling or rotation and \r
- * without being offset by the polygon position. */\r
+ /** Returns the polygon's local vertices without scaling or rotation and without being offset by the polygon position. */\r
public float[] getVertices () {\r
return localVertices;\r
}\r
\r
- /** Calculates and returns the vertices of the polygon after scaling, rotation,\r
- * and positional translations have been applied, as they are position within the world.\r
+ /** Calculates and returns the vertices of the polygon after scaling, rotation, and positional translations have been applied,\r
+ * as they are position within the world.\r
* \r
* @return vertices scaled, rotated, and offset by the polygon position. */\r
public float[] getTransformedVertices () {\r
this.y = y;\r
dirty = true;\r
}\r
- \r
- /** Sets the polygon's local vertices relative to the origin point,\r
- * without any scaling, rotating or translations being applied.\r
+\r
+ /** Sets the polygon's local vertices relative to the origin point, without any scaling, rotating or translations being applied.\r
* \r
- * @param vertices float array where every even element represents the\r
- * x-coordinate of a vertex, and the proceeding element representing the\r
- * y-coordinate.\r
- * @throws IllegalArgumentException if less than 6 elements, \r
- * representing 3 points, are provided\r
- */\r
+ * @param vertices float array where every even element represents the x-coordinate of a vertex, and the proceeding element\r
+ * representing the y-coordinate.\r
+ * @throws IllegalArgumentException if less than 6 elements, representing 3 points, are provided */\r
public void setVertices (float[] vertices) {\r
if (vertices.length < 6) throw new IllegalArgumentException("polygons must contain at least 3 points.");\r
- \r
+\r
// if the provided vertices are the same length, we can copy them into localVertices\r
if (localVertices.length == vertices.length) {\r
for (int i = 0; i < localVertices.length; i++) {\r
dirty = true;\r
}\r
\r
- /** Sets the polygon's world vertices to be recalculated when calling \r
- * {@link #getTransformedVertices() getTransformedVertices}. \r
- */\r
+ /** Sets the polygon's world vertices to be recalculated when calling {@link #getTransformedVertices() getTransformedVertices}. */\r
public void dirty () {\r
dirty = true;\r
}\r
return area;\r
}\r
\r
- /** Returns an axis-aligned bounding box of this polygon. \r
+ /** Returns an axis-aligned bounding box of this polygon.\r
* \r
- * Note the returned Rectangle is cached in this polygon, and will\r
- * be reused if this Polygon is changed.\r
+ * Note the returned Rectangle is cached in this polygon, and will be reused if this Polygon is changed.\r
* \r
- * @return this polygon's bounding box {@link Rectangle}\r
- */\r
+ * @return this polygon's bounding box {@link Rectangle} */\r
public Rectangle getBoundingRectangle () {\r
float[] vertices = getTransformedVertices();\r
\r
\r
return bounds;\r
}\r
- \r
+\r
/** Returns whether an x, y pair is contained within the polygon. */\r
public boolean contains (float x, float y) {\r
final float[] vertices = getTransformedVertices();\r
return rotation;\r
}\r
\r
- /** Returns the total horizontal scaling applied to the polygon. */ \r
+ /** Returns the total horizontal scaling applied to the polygon. */\r
public float getScaleX () {\r
return scaleX;\r
}\r