本文整理了Java中org.jbox2d.dynamics.Body.getPosition()
方法的一些代码示例,展示了Body.getPosition()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.getPosition()
方法的具体详情如下:
包路径:org.jbox2d.dynamics.Body
类名称:Body
方法名:getPosition
[英]Get the world body origin position. Do not modify.
[中]获取世界实体原点位置。不要修改。
代码示例来源:origin: libgdx/libgdx
@Override
public void getAnchorA(Vec2 out) {
out.set(m_bodyA.getPosition());
}
代码示例来源:origin: libgdx/libgdx
/** Get the world body origin position.
* @return the world position of the body's origin. */
public Vector2 getPosition () {
Vec2 pos = body.getPosition();
position.set(pos.x, pos.y);
return position;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void getAnchorB(Vec2 out) {
out.set(m_bodyB.getPosition());
}
代码示例来源:origin: libgdx/libgdx
public void initialize(Body bA, Body bB) {
bodyA = bA;
bodyB = bB;
Vec2 xB = bodyB.getPosition();
bodyA.getLocalPointToOut(xB, linearOffset);
float angleA = bodyA.getAngle();
float angleB = bodyB.getAngle();
angularOffset = angleB - angleA;
}
}
代码示例来源:origin: jbox2d/jbox2d
@Override
public void getAnchorA(Vec2 out) {
out.set(m_bodyA.getPosition());
}
代码示例来源:origin: jbox2d/jbox2d
@Override
public void getAnchorB(Vec2 out) {
out.set(m_bodyB.getPosition());
}
代码示例来源:origin: jbox2d/jbox2d
public void initialize(Body bA, Body bB) {
bodyA = bA;
bodyB = bB;
Vec2 xB = bodyB.getPosition();
bodyA.getLocalPointToOut(xB, linearOffset);
float angleA = bodyA.getAngle();
float angleB = bodyB.getAngle();
angularOffset = angleB - angleA;
}
}
代码示例来源:origin: jbox2d/jbox2d
@Override
public synchronized void step(TestbedSettings settings) {
super.step(settings);
addTextLine("Keys: left = a, brake = s, right = d, hz down = q, hz up = e");
addTextLine("frequency = " + m_hz + " hz, damping ratio = " + m_zeta);
getCamera().setCamera(m_car.getPosition());
}
}
代码示例来源:origin: konsoletyper/teavm
context.setLineWidth(0.01);
for (Body body = scene.getWorld().getBodyList(); body != null; body = body.getNext()) {
Vec2 center = body.getPosition();
context.save();
context.translate(center.x, center.y);
代码示例来源:origin: jbox2d/jbox2d
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
super.preSolve(contact, oldManifold);
Fixture fixtureA = contact.getFixtureA();
Fixture fixtureB = contact.getFixtureB();
if (fixtureA != m_platform && fixtureA != m_character) {
return;
}
if (fixtureB != m_character && fixtureB != m_character) {
return;
}
Vec2 position = m_character.getBody().getPosition();
if (position.y < m_top + m_radius - 3.0f * Settings.linearSlop) {
contact.setEnabled(false);
}
}
}
代码示例来源:origin: jbox2d/jbox2d
@Override
public void step(TestbedSettings settings) {
super.step(settings);
for (Body b = getWorld().getBodyList(); b != null; b = b.getNext())
{
if (b.getType() != BodyType.DYNAMIC)
{
continue;
}
Vec2 p = b.getPosition();
if (p.x <= -10.0f || 10.0f <= p.x || p.y <= 0.0f || 20.0f <= p.y)
{
p.x += 0.0;
}
}
addTextLine("Press 'c' to create a circle");
}
代码示例来源:origin: jbox2d/jbox2d
@Override
public void step(TestbedSettings settings) {
// TODO Auto-generated method stub
super.step(settings);
// Traverse the contact results. Apply a force on shapes
// that overlap the sensor.
for (int i = 0; i < e_count; ++i) {
if (m_touching[i].tf == false) {
continue;
}
Body body = m_bodies[i];
Body ground = m_sensor.getBody();
CircleShape circle = (CircleShape) m_sensor.getShape();
Vec2 center = ground.getWorldPoint(circle.m_p);
Vec2 position = body.getPosition();
Vec2 d = center.sub(position);
if (d.lengthSquared() < Settings.EPSILON * Settings.EPSILON) {
continue;
}
d.normalize();
Vec2 F = d.mulLocal(100f);
body.applyForce(F, position);
}
}
代码示例来源:origin: HpWens/MeiWidgetView
private float getViewX(View view) {
Body body = (Body) view.getTag(R.id.wd_view_body_tag);
if (null != body) {
//注意换算
return mappingBody2View(body.getPosition().x) - view.getWidth() / 2;
}
return 0;
}
代码示例来源:origin: jbox2d/jbox2d
void Break() {
// Create two bodies from one.
Body body1 = m_piece1.getBody();
Vec2 center = body1.getWorldCenter();
body1.destroyFixture(m_piece2);
m_piece2 = null;
BodyDef bd = new BodyDef();
bd.type = BodyType.DYNAMIC;
bd.position = body1.getPosition();
bd.angle = body1.getAngle();
Body body2 = getWorld().createBody(bd);
m_piece2 = body2.createFixture(m_shape2, 1.0f);
// Compute consistent velocities for new bodies based on
// cached velocity.
Vec2 center1 = body1.getWorldCenter();
Vec2 center2 = body2.getWorldCenter();
Vec2 velocity1 = m_velocity.add(Vec2.cross(m_angularVelocity, center1.sub(center)));
Vec2 velocity2 = m_velocity.add(Vec2.cross(m_angularVelocity, center2.sub(center)));
body1.setAngularVelocity(m_angularVelocity);
body1.setLinearVelocity(velocity1);
body2.setAngularVelocity(m_angularVelocity);
body2.setLinearVelocity(velocity2);
}
代码示例来源:origin: jbox2d/jbox2d
createLeg(1.0f, wheelAnchor);
m_wheel.setTransform(m_wheel.getPosition(), 120.0f * MathUtils.PI / 180.0f);
createLeg(-1.0f, wheelAnchor);
createLeg(1.0f, wheelAnchor);
m_wheel.setTransform(m_wheel.getPosition(), -120.0f * MathUtils.PI / 180.0f);
createLeg(-1.0f, wheelAnchor);
createLeg(1.0f, wheelAnchor);
代码示例来源:origin: jbox2d/jbox2d
rjd.initialize(body, getGroundBody(), body.getPosition());
rjd.motorSpeed = MathUtils.PI;
rjd.maxMotorTorque = 1000000.0f;
代码示例来源:origin: jbox2d/jbox2d
builder.setPosition(vecToPb(argBody.getPosition()));
builder.setAngle(argBody.getAngle());
builder.setLinearVelocity(vecToPb(argBody.getLinearVelocity()));
代码示例来源:origin: jbox2d/jbox2d
jd.initialize(ground, body, body.getPosition());
jd.lowerAngle = -8.0f * MathUtils.PI / 180.0f;
jd.upperAngle = 8.0f * MathUtils.PI / 180.0f;
Vec2 axis = new Vec2(0.0f, 1.0f);
jd.initialize(m_car, m_wheel1, m_wheel1.getPosition(), axis);
jd.motorSpeed = 0.0f;
jd.maxMotorTorque = 20.0f;
m_spring1 = (WheelJoint) m_world.createJoint(jd);
jd.initialize(m_car, m_wheel2, m_wheel2.getPosition(), axis);
jd.motorSpeed = 0.0f;
jd.maxMotorTorque = 10.0f;
代码示例来源:origin: jbox2d/jbox2d
rjd.initialize(body, ground, body.getPosition());
rjd.motorSpeed = MathUtils.PI;
rjd.maxMotorTorque = 1000000.0f;
代码示例来源:origin: jbox2d/jbox2d
rjd.initialize(body, getGroundBody(), body.getPosition());
rjd.motorSpeed = MathUtils.PI;
rjd.maxMotorTorque = 1000000.0f;
内容来源于网络,如有侵权,请联系作者删除!