/** Constructs a new Transform instance with the given position and orientation * @param position the position * @param orientation where the transform is pointing*/ public Transform (Vector2 position, Vector2 orientation) { setPosition(position); setOrientation(orientation); }
/** Constructs a new Transform instance with the given position and angle * @param position the position * @param angle the angle in radians */ public Transform (Vector2 position, float angle) { setPosition(position); setRotation(angle); } /** Constructs a new Transform instance with the given position and orientation
Transform xf1 = new Transform(new Vector2(), 0.3524f * (float)Math.PI); xf1.setPosition(xf1.mul(new Vector2(1, 0))); vertices[0] = xf1.mul(new Vector2(-1, 0)); vertices[1] = xf1.mul(new Vector2(1, 0)); vertices[2] = xf1.mul(new Vector2(0, 0.5f)); sd1.density = 4.0f; Transform xf2 = new Transform(new Vector2(), -0.3524f * (float)Math.PI); xf2.setPosition(xf2.mul(new Vector2(-1, 0))); vertices[0] = xf2.mul(new Vector2(-1, 0)); vertices[1] = xf2.mul(new Vector2(1, 0)); vertices[2] = xf2.mul(new Vector2(0, 0.5f));
@Override public void render () { if (m_platform.getType() == BodyType.KinematicBody) { Vector2 p = m_platform.getTransform().getPosition(); Vector2 v = m_platform.getLinearVelocity(); if ((p.x < -10 && v.x < 0) || (p.x > 10 && v.x > 0)) { v.x = -v.x; m_platform.setLinearVelocity(v); } } super.render(); // if (renderer.batch != null) { // renderer.batch.begin(); // // renderer.batch.drawText(renderer.font, "Keys: (d) dynamic, (s) static, (k) kinematic", 0, Gdx.app.getGraphics() // // .getHeight(), Color.WHITE); // renderer.batch.end(); // } } }
CircleShape circle = (CircleShape)fixture.getShape(); t.set(circle.getPosition()); transform.mul(t); drawSolidCircle(t, circle.getRadius(), axis.set(transform.vals[Transform.COS], transform.vals[Transform.SIN]), color); edge.getVertex1(vertices[0]); edge.getVertex2(vertices[1]); transform.mul(vertices[0]); transform.mul(vertices[1]); drawSolidPolygon(vertices, 2, color, true); for (int i = 0; i < vertexCount; i++) { chain.getVertex(i, vertices[i]); transform.mul(vertices[i]); for (int i = 0; i < vertexCount; i++) { chain.getVertex(i, vertices[i]); transform.mul(vertices[i]);
public void interpolate(float alpha) { for (Box box : activeBoxes) { Body body = box.getBody(); if(body.isActive()) { Transform transform = body.getTransform(); Vector2 bodyPosition = transform.getPosition(); float bodyAngle = transform.getRotation(); box.x = bodyPosition.x * alpha + box.x * (1.0f - alpha); box.y = bodyPosition.y * alpha + box.y * (1.0f - alpha); box.angle = bodyAngle * alpha + box.angle * (1.0f - alpha); } } }
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); } }
CircleShape circle = (CircleShape)fixture.getShape(); t.set(circle.getPosition()); transform.mul(t); drawSolidCircle(t, circle.getRadius(), axis.set(transform.vals[Transform.COS], transform.vals[Transform.SIN]), color); return; edge.getVertex1(vertices[0]); edge.getVertex2(vertices[1]); transform.mul(vertices[0]); transform.mul(vertices[1]); drawSolidPolygon(vertices, 2, color, true); return; for (int i = 0; i < vertexCount; i++) { chain.getVertex(i, vertices[i]); transform.mul(vertices[i]); for (int i = 0; i < vertexCount; i++) { chain.getVertex(i, vertices[i]); transform.mul(vertices[i]);
Vector2 bodyPosition = bodyTransform.getPosition(); box.x = bodyPosition.x; box.y = bodyPosition.y; box.angle = bodyTransform.getRotation();
/** Constructs a new Transform instance with the given position and orientation * @param position the position * @param orientation where the transform is pointing*/ public Transform (Vector2 position, Vector2 orientation) { setPosition(position); setOrientation(orientation); }
/** Constructs a new Transform instance with the given position and angle * @param position the position * @param angle the angle in radians */ public Transform (Vector2 position, float angle) { setPosition(position); setRotation(angle); } /** Constructs a new Transform instance with the given position and orientation
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); } }
float radius = shape.getRadius(); vertices[0].set(shape.getPosition()); transform.mul(vertices[0]); lower.set(vertices[0].x - radius, vertices[0].y - radius); upper.set(vertices[0].x + radius, vertices[0].y + radius); lower.set(transform.mul(vertices[0])); upper.set(lower); for (int i = 1; i < vertexCount; i++) { shape.getVertex(i, vertices[i]); transform.mul(vertices[i]); lower.x = Math.min(lower.x, vertices[i].x); lower.y = Math.min(lower.y, vertices[i].y);
/** Constructs a new Transform instance with the given position and orientation * @param position the position * @param orientation where the transform is pointing*/ public Transform (Vector2 position, Vector2 orientation) { setPosition(position); setOrientation(orientation); }
/** Constructs a new Transform instance with the given position and angle * @param position the position * @param angle the angle in radians */ public Transform (Vector2 position, float angle) { setPosition(position); setRotation(angle); } /** Constructs a new Transform instance with the given position and orientation
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); } }
float radius = shape.getRadius(); vertices[0].set(shape.getPosition()); transform.mul(vertices[0]); lower.set(vertices[0].x - radius, vertices[0].y - radius); upper.set(vertices[0].x + radius, vertices[0].y + radius); lower.set(transform.mul(vertices[0])); upper.set(lower); for (int i = 1; i < vertexCount; i++) { shape.getVertex(i, vertices[i]); transform.mul(vertices[i]); lower.x = Math.min(lower.x, vertices[i].x); lower.y = Math.min(lower.y, vertices[i].y);
CircleShape circle = (CircleShape)fixture.getShape(); t.set(circle.getPosition()); transform.mul(t); drawSolidCircle(t, circle.getRadius(), axis.set(transform.vals[Transform.COS], transform.vals[Transform.SIN]), color); return; edge.getVertex1(vertices[0]); edge.getVertex2(vertices[1]); transform.mul(vertices[0]); transform.mul(vertices[1]); drawSolidPolygon(vertices, 2, color, true); return; for (int i = 0; i < vertexCount; i++) { chain.getVertex(i, vertices[i]); transform.mul(vertices[i]); for (int i = 0; i < vertexCount; i++) { chain.getVertex(i, vertices[i]); transform.mul(vertices[i]);
float radius = shape.getRadius(); vertices[0].set(shape.getPosition()); transform.mul(vertices[0]); lower.set(vertices[0].x - radius, vertices[0].y - radius); upper.set(vertices[0].x + radius, vertices[0].y + radius); lower.set(transform.mul(vertices[0])); upper.set(lower); for (int i = 1; i < vertexCount; i++) { shape.getVertex(i, vertices[i]); transform.mul(vertices[i]); lower.x = Math.min(lower.x, vertices[i].x); lower.y = Math.min(lower.y, vertices[i].y);