org.jbox2d.dynamics.Body.getLocalCenter()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中org.jbox2d.dynamics.Body.getLocalCenter()方法的一些代码示例,展示了Body.getLocalCenter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.getLocalCenter()方法的具体详情如下:
包路径:org.jbox2d.dynamics.Body
类名称:Body
方法名:getLocalCenter

Body.getLocalCenter介绍

[英]Get the local position of the center of mass. Do not modify.
[中]获取质心的局部位置。不要修改。

代码示例

代码示例来源:origin: libgdx/libgdx

public Vector2 getLocalCenter () {
  Vec2 lc = body.getLocalCenter();
  localCenter.set(lc.x, lc.y);
  return localCenter;
}

代码示例来源:origin: libgdx/libgdx

Vec2 bp = b.getWorldCenter();
float bm = b.getMass();
float bI = b.getInertia() - bm * b.getLocalCenter().lengthSquared();
float invBm = bm > 0 ? 1 / bm : 0;
float invBI = bI > 0 ? 1 / bI : 0;

代码示例来源:origin: jbox2d/jbox2d

@Override
public void step(TestbedSettings settings) {
 super.step(settings);
 addTextLine("Use 'wasd' to move, 'e' and 's' drift.");
 if (getModel().getKeys()['w']) {
  Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f));
  Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(0.0f, 2.0f)));
  m_body.applyForce(f, p);
 } else if (getModel().getKeys()['q']) {
  Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f));
  Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(-.2f, 0f)));
  m_body.applyForce(f, p);
 } else if (getModel().getKeys()['e']) {
  Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f));
  Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(.2f, 0f)));
  m_body.applyForce(f, p);
 } else if (getModel().getKeys()['s']) {
  Vec2 f = m_body.getWorldVector(new Vec2(0.0f, 30.0f));
  Vec2 p = m_body.getWorldCenter();
  m_body.applyForce(f, p);
 }
 if (getModel().getKeys()['a']) {
  m_body.applyTorque(20.0f);
 }
 if (getModel().getKeys()['d']) {
  m_body.applyTorque(-20.0f);
 }
}

代码示例来源:origin: jbox2d/jbox2d

Vec2 bp = b.getWorldCenter();
float bm = b.getMass();
float bI = b.getInertia() - bm * b.getLocalCenter().lengthSquared();
float invBm = bm > 0 ? 1 / bm : 0;
float invBI = bI > 0 ? 1 / bI : 0;

代码示例来源:origin: org.jbox2d/jbox2d-testbed

@Override
public void step(TestbedSettings settings) {
 super.step(settings);
 addTextLine("Use 'wasd' to move, 'e' and 's' drift.");
 if (getModel().getKeys()['w']) {
  Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f));
  Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(0.0f, 2.0f)));
  m_body.applyForce(f, p);
 } else if (getModel().getKeys()['q']) {
  Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f));
  Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(-.2f, 0f)));
  m_body.applyForce(f, p);
 } else if (getModel().getKeys()['e']) {
  Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f));
  Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(.2f, 0f)));
  m_body.applyForce(f, p);
 } else if (getModel().getKeys()['s']) {
  Vec2 f = m_body.getWorldVector(new Vec2(0.0f, 30.0f));
  Vec2 p = m_body.getWorldCenter();
  m_body.applyForce(f, p);
 }
 if (getModel().getKeys()['a']) {
  m_body.applyTorque(20.0f);
 }
 if (getModel().getKeys()['d']) {
  m_body.applyTorque(-20.0f);
 }
}

代码示例来源:origin: andmizi/MobikeTags

Vec2 bp = b.getWorldCenter();
float bm = b.getMass();
float bI = b.getInertia() - bm * b.getLocalCenter().lengthSquared();
float invBm = bm > 0 ? 1 / bm : 0;
float invBI = bI > 0 ? 1 / bI : 0;

代码示例来源:origin: com.github.almasb/fxgl-physics

Vec2 bp = b.getWorldCenter();
float bm = b.getMass();
float bI = b.getInertia() - bm * b.getLocalCenter().lengthSquared();
float invBm = bm > 0 ? 1 / bm : 0;
float invBI = bI > 0 ? 1 / bI : 0;

相关文章