/** Get the sleeping state of this body. * @return true if the body is sleeping. */ public boolean isAwake () { return body.isAwake(); }
/** * Apply an angular impulse. * * @param impulse the angular impulse in units of kg*m*m/s */ public void applyAngularImpulse(float impulse) { if (m_type != BodyType.DYNAMIC) { return; } if (isAwake() == false) { setAwake(true); } m_angularVelocity += m_invI * impulse; }
/** * Apply a torque. This affects the angular velocity without affecting the linear velocity of the * center of mass. This wakes up the body. * * @param torque about the z-axis (out of the screen), usually in N-m. */ public final void applyTorque(float torque) { if (m_type != BodyType.DYNAMIC) { return; } if (isAwake() == false) { setAwake(true); } m_torque += torque; }
/** * Apply a force to the center of mass. This wakes up the body. * * @param force the world force vector, usually in Newtons (N). */ public final void applyForceToCenter(Vec2 force) { if (m_type != BodyType.DYNAMIC) { return; } if (isAwake() == false) { setAwake(true); } m_force.x += force.x; m_force.y += force.y; }
/** * Apply a force at a world point. If the force is not applied at the center of mass, it will * generate a torque and affect the angular velocity. This wakes up the body. * * @param force the world force vector, usually in Newtons (N). * @param point the world position of the point of application. */ public final void applyForce(Vec2 force, Vec2 point) { if (m_type != BodyType.DYNAMIC) { return; } if (isAwake() == false) { setAwake(true); } // m_force.addLocal(force); // Vec2 temp = tltemp.get(); // temp.set(point).subLocal(m_sweep.c); // m_torque += Vec2.cross(temp, force); m_force.x += force.x; m_force.y += force.y; m_torque += (point.x - m_sweep.c.x) * force.y - (point.y - m_sweep.c.y) * force.x; }
/** * Apply an impulse at a point. This immediately modifies the velocity. It also modifies the * angular velocity if the point of application is not at the center of mass. This wakes up the * body if 'wake' is set to true. If the body is sleeping and 'wake' is false, then there is no * effect. * * @param impulse the world impulse vector, usually in N-seconds or kg-m/s. * @param point the world position of the point of application. * @param wake also wake up the body */ public final void applyLinearImpulse(Vec2 impulse, Vec2 point, boolean wake) { if (m_type != BodyType.DYNAMIC) { return; } if (!isAwake()) { if (wake) { setAwake(true); } else { return; } } m_linearVelocity.x += impulse.x * m_invMass; m_linearVelocity.y += impulse.y * m_invMass; m_angularVelocity += m_invI * ((point.x - m_sweep.c.x) * impulse.y - (point.y - m_sweep.c.y) * impulse.x); }
public void setTarget(Vec2 target) { if (m_bodyB.isAwake() == false) { m_bodyB.setAwake(true); } m_targetA.set(target); }
/** * Apply a force to the center of mass. This wakes up the body. * * @param force the world force vector, usually in Newtons (N). */ public final void applyForceToCenter(Vec2 force) { if (m_type != BodyType.DYNAMIC) { return; } if (isAwake() == false) { setAwake(true); } m_force.x += force.x; m_force.y += force.y; }
/** * Apply an angular impulse. * * @param impulse the angular impulse in units of kg*m*m/s */ public void applyAngularImpulse(float impulse) { if (m_type != BodyType.DYNAMIC) { return; } if (isAwake() == false) { setAwake(true); } m_angularVelocity += m_invI * impulse; }
/** * Apply a torque. This affects the angular velocity without affecting the linear velocity of the * center of mass. This wakes up the body. * * @param torque about the z-axis (out of the screen), usually in N-m. */ public final void applyTorque(float torque) { if (m_type != BodyType.DYNAMIC) { return; } if (isAwake() == false) { setAwake(true); } m_torque += torque; }
/** * Apply a force at a world point. If the force is not applied at the center of mass, it will * generate a torque and affect the angular velocity. This wakes up the body. * * @param force the world force vector, usually in Newtons (N). * @param point the world position of the point of application. */ public final void applyForce(Vec2 force, Vec2 point) { if (m_type != BodyType.DYNAMIC) { return; } if (isAwake() == false) { setAwake(true); } // m_force.addLocal(force); // Vec2 temp = tltemp.get(); // temp.set(point).subLocal(m_sweep.c); // m_torque += Vec2.cross(temp, force); m_force.x += force.x; m_force.y += force.y; m_torque += (point.x - m_sweep.c.x) * force.y - (point.y - m_sweep.c.y) * force.x; }
/** * Apply an impulse at a point. This immediately modifies the velocity. It also modifies the * angular velocity if the point of application is not at the center of mass. This wakes up the * body if 'wake' is set to true. If the body is sleeping and 'wake' is false, then there is no * effect. * * @param impulse the world impulse vector, usually in N-seconds or kg-m/s. * @param point the world position of the point of application. * @param wake also wake up the body */ public final void applyLinearImpulse(Vec2 impulse, Vec2 point, boolean wake) { if (m_type != BodyType.DYNAMIC) { return; } if (!isAwake()) { if (wake) { setAwake(true); } else { return; } } m_linearVelocity.x += impulse.x * m_invMass; m_linearVelocity.y += impulse.y * m_invMass; m_angularVelocity += m_invI * ((point.x - m_sweep.c.x) * impulse.y - (point.y - m_sweep.c.y) * impulse.x); }
public void setTarget(Vec2 target) { if (m_bodyB.isAwake() == false) { m_bodyB.setAwake(true); } m_targetA.set(target); }
if (seed.isAwake() == false || seed.isActive() == false) { continue;
color.set(0.5f, 0.5f, 0.9f); drawShape(f, xf, color, wireframe); } else if (b.isAwake() == false) { color.set(0.5f, 0.5f, 0.5f); drawShape(f, xf, color, wireframe);
builder.setAwake(argBody.isAwake()); builder.setActive(argBody.isActive()); builder.setFixedRotation(argBody.isFixedRotation());
color.set(0.5f, 0.5f, 0.9f); drawShape(f, xf, color, wireframe); } else if (b.isAwake() == false) { color.set(0.5f, 0.5f, 0.5f); drawShape(f, xf, color, wireframe);