Search in sources :

Example 11 with Vec2

use of org.jbox2d.common.Vec2 in project libgdx by libgdx.

the class ChainShape method getVertex.

/** Returns the vertex at the given position.
	 * @param index the index of the vertex 0 <= index < getVertexCount( )
	 * @param vertex vertex */
public void getVertex(int index, Vector2 vertex) {
    Vec2 v = shape.m_vertices[index];
    vertex.set(v.x, v.y);
}
Also used : Vec2(org.jbox2d.common.Vec2)

Example 12 with Vec2

use of org.jbox2d.common.Vec2 in project libgdx by libgdx.

the class EdgeShape method getVertex2.

public void getVertex2(Vector2 vec) {
    Vec2 v2 = shape.m_vertex2;
    vec.set(v2.x, v2.y);
}
Also used : Vec2(org.jbox2d.common.Vec2)

Example 13 with Vec2

use of org.jbox2d.common.Vec2 in project libgdx by libgdx.

the class PolygonShape method set.

/** Copy vertices from the given float array, taking into account the offset and length. It is assumed the vertices are in x,y
	 * order and define a convex polygon. It is assumed that the exterior is the the right of each edge. */
public void set(float[] vertices, int offset, int len) {
    Vec2[] v = new org.jbox2d.common.Vec2[len / 2];
    for (int i = 0; i < v.length; i++) {
        v[i] = new Vec2(vertices[i * 2], vertices[i * 2 + 1]);
    }
    shape.set(v, v.length);
}
Also used : Vec2(org.jbox2d.common.Vec2)

Example 14 with Vec2

use of org.jbox2d.common.Vec2 in project libgdx by libgdx.

the class PolygonShape method getVertex.

/** Returns the vertex at the given position.
	 * @param index the index of the vertex 0 <= index < getVertexCount( )
	 * @param vertex vertex */
public void getVertex(int index, Vector2 vertex) {
    Vec2 v = shape.m_vertices[index];
    vertex.set(v.x, v.y);
}
Also used : Vec2(org.jbox2d.common.Vec2)

Example 15 with Vec2

use of org.jbox2d.common.Vec2 in project libgdx by libgdx.

the class Body method getWorldPoint.

/** Get the world coordinates of a point given the local coordinates.
	 * @param localPoint a point on the body measured relative to the the body's origin.
	 * @return the same point expressed in world coordinates. */
public Vector2 getWorldPoint(Vector2 localPoint) {
    tmp.set(localPoint.x, localPoint.y);
    Vec2 wp = body.getWorldPoint(tmp);
    return worldPoint.set(wp.x, wp.y);
}
Also used : Vec2(org.jbox2d.common.Vec2)

Aggregations

Vec2 (org.jbox2d.common.Vec2)185 Rot (org.jbox2d.common.Rot)36 Body (org.jbox2d.dynamics.Body)11 World (org.jbox2d.dynamics.World)9 AABB (org.jbox2d.collision.AABB)8 Mat22 (org.jbox2d.common.Mat22)7 Joint (org.jbox2d.dynamics.joints.Joint)7 PulleyJoint (org.jbox2d.dynamics.joints.PulleyJoint)7 ManifoldPoint (org.jbox2d.collision.ManifoldPoint)6 Test (org.junit.jupiter.api.Test)6 PolygonShape (org.jbox2d.collision.shapes.PolygonShape)5 Transform (org.jbox2d.common.Transform)5 Vec3 (org.jbox2d.common.Vec3)5 BodyDef (org.jbox2d.dynamics.BodyDef)5 VelocityConstraintPoint (org.jbox2d.dynamics.contacts.ContactVelocityConstraint.VelocityConstraintPoint)5 CircleShape (org.jbox2d.collision.shapes.CircleShape)4 Test (org.junit.Test)4 AffineTransform (java.awt.geom.AffineTransform)3 Shape (org.jbox2d.collision.shapes.Shape)3 Mat33 (org.jbox2d.common.Mat33)3