本文整理汇总了Java中org.jbox2d.dynamics.joints.Joint类的典型用法代码示例。如果您正苦于以下问题:Java Joint类的具体用法?Java Joint怎么用?Java Joint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Joint类属于org.jbox2d.dynamics.joints包,在下文中一共展示了Joint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAll
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
/**
*
* Add/create shapes for all bodies/joints that have not attached shapes.<br>
*
*/
public void addAll(boolean create_bodies, boolean create_joints){
if(create_bodies){
for (Body body = world.getBodyList(); body != null; body = body.getNext()) {
DwBody dwbody = DwWorld.getShape(body);
if(dwbody == null){
add(body);
}
}
}
if(create_joints){
for (Joint joint = world.getJointList(); joint != null; joint = joint.getNext()) {
DwJoint dwjoint = DwWorld.getShape(joint);
if(dwjoint == null){
add(joint);
}
}
}
}
示例2: serialize
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
@Override
public SerializationResult serialize(Joint argJoint, Map<Body, Integer> argBodyIndexMap,
Map<Joint, Integer> argJointIndexMap) {
PbJoint.Builder builder = serializeJoint(argJoint, argBodyIndexMap, argJointIndexMap);
if (builder == null) {
return null;
}
final PbJoint joint = builder.build();
return new SerializationResult() {
@Override
public void writeTo(OutputStream argOutputStream) throws IOException {
joint.writeTo(argOutputStream);
}
@Override
public Object getValue() {
return joint;
}
};
}
示例3: setJoint
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
private Joint setJoint(PartJoint partJoint) {
Body bodyOne = partToBody.get(partJoint.partOne);
Body bodyTwo = partToBody.get(partJoint.partTwo);
RevoluteJointDef jointDef = new RevoluteJointDef();
jointDef.bodyA = bodyOne;
jointDef.bodyB = bodyTwo;
jointDef.localAnchorA = partJoint.partOne.getAnchor(partJoint
.getPercentOne());
jointDef.localAnchorB = partJoint.partTwo.getAnchor(partJoint
.getPercentTwo());
jointDef.lowerAngle = Math.min(partJoint.getPointA(),
partJoint.getPointB());
jointDef.upperAngle = Math.max(partJoint.getPointA(),
partJoint.getPointB());
jointDef.maxMotorTorque = 70.0f;
jointDef.motorSpeed = GeomUtil.circle(partJoint.getAngularVelocity());
jointDef.enableMotor = true;
jointDef.enableLimit = true;
return world.createJoint(jointDef);
}
示例4: init
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
public void init(TestbedModel argModel) {
model = argModel;
destructionListener = new DestructionListener() {
public void sayGoodbye(Fixture fixture) {
}
public void sayGoodbye(Joint joint) {
if (mouseJoint == joint) {
mouseJoint = null;
} else {
jointDestroyed(joint);
}
}
};
Vec2 gravity = new Vec2(0, -10f);
m_world = new World(gravity, true);
bomb = null;
mouseJoint = null;
BodyDef bodyDef = new BodyDef();
groundBody = m_world.createBody(bodyDef);
init(m_world, false);
}
示例5: drawJoint
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
private void drawJoint(Joint joint) {
Body bodyA = joint.getBodyA();
Body bodyB = joint.getBodyB();
Transform xf1 = bodyA.getTransform();
Transform xf2 = bodyB.getTransform();
Vec2 x1 = xf1.p;
Vec2 x2 = xf2.p;
Vec2 p1 = pool.popVec2();
Vec2 p2 = pool.popVec2();
joint.getAnchorA(p1);
joint.getAnchorB(p2);
color.set(0.5f, 0.8f, 0.8f);
switch (joint.getType()) {
// TODO djm write after writing joints
case DISTANCE:
m_debugDraw.drawSegment(p1, p2, color);
break;
case PULLEY: {
PulleyJoint pulley = (PulleyJoint) joint;
Vec2 s1 = pulley.getGroundAnchorA();
Vec2 s2 = pulley.getGroundAnchorB();
m_debugDraw.drawSegment(s1, p1, color);
m_debugDraw.drawSegment(s2, p2, color);
m_debugDraw.drawSegment(s1, s2, color);
}
break;
case CONSTANT_VOLUME:
case MOUSE:
// don't draw this
break;
default:
m_debugDraw.drawSegment(x1, p1, color);
m_debugDraw.drawSegment(p1, p2, color);
m_debugDraw.drawSegment(x2, p2, color);
}
pool.pushVec2(2);
}
示例6: displayJoints
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
static public void displayJoints(PGraphics pg, World world){
pg.beginShape(PConstants.LINES);
for (Joint joint = world.getJointList(); joint != null; joint = joint.getNext()) {
display(pg, joint);
}
pg.endShape();
}
示例7: add
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
/**
*
* Add/create joint-shape, using the given style.<br>
* If this joint-shape already exists it is destroyed first.<br>
*
*/
public DwJoint add(Joint joint, ShapeStyle style){
if(joint == null) return null;
DwJoint child = DwWorld.getShape(joint);
if(child != null){
child.release();
}
child = new DwJoint(this, joint);
childrenJ.add(child);
world.setStyle(joint, style.fill_enabled, style.fill_color, style.stroke_enabled, style.stroke_color, style.stroke_weight);
return child;
}
示例8: DwJoint
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
public DwJoint(DwBodyGroup parent, Joint joint){
this.parent = parent;
this.joint = joint;
JointType type = joint.getType();
// create PShape
// this.shape = parent.papplet.createShape(PConstants.LINE, 0, 0, 1, 0);
// this.shape.setStrokeJoin(PConstants.ROUND);
// this.shape.setStrokeCap(PConstants.ROUND);
// shape = parent.papplet.createShape();
// shape.beginShape(PConstants.QUADS);
// shape.fill(255);
// shape.vertex(0,0);
// shape.vertex(1,0);
// shape.vertex(1,1);
// shape.vertex(0,1);
// shape.endShape();
if(type == JointType.PULLEY){
shape = parent.papplet.createShape(PConstants.GROUP);
shape.addChild(parent.papplet.createShape(PConstants.LINE, 0, 0, 1, 0));
shape.addChild(parent.papplet.createShape(PConstants.LINE, 0, 0, 1, 0));
shape.addChild(parent.papplet.createShape(PConstants.LINE, 0, 0, 1, 0));
} else {
shape = parent.papplet.createShape(PConstants.LINE, 0, 0, 1, 0);
}
// link PShapes
parent.shape.addChild(shape);
joint.setUserData(this);
}
示例9: updateJoints
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
public void updateJoints(){
Vec2 ancA = new Vec2();
Vec2 ancB = new Vec2();
for (Joint joint = super.getJointList(); joint != null; joint = joint.getNext()) {
DwJoint dwjoint = getShape(joint);
if(dwjoint != null){
PShape shape = dwjoint.shape;
JointType type = joint.getType();
joint.getAnchorA(ancA);
joint.getAnchorB(ancB);
// Body bodyA = joint.getBodyA();
// Body bodyB = joint.getBodyB();
// Transform xfA = bodyA.getTransform();
// Transform xfB = bodyB.getTransform();
// Vec2 posA = xfA.p;
// Vec2 posB = xfB.p;
if(type == JointType.PULLEY){
PulleyJoint pulley = (PulleyJoint) joint;
Vec2 gancA = pulley.getGroundAnchorA();
Vec2 gancB = pulley.getGroundAnchorB();
updateLineShape(shape.getChild(0), ancA, gancA);
updateLineShape(shape.getChild(1), ancB, gancB);
updateLineShape(shape.getChild(2), gancA, gancB);
} else {
updateLineShape(shape, ancA, ancB);
}
}
}
}
示例10: setStyle
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
public PShape setStyle(Joint joint
, boolean fill_enabled
, int fill_color
, boolean stroke_enabled
, int stroke_color
, float stroke_weight
){
DwJoint dwjoint = getShape(joint);
return setStyle(dwjoint.shape, fill_enabled, fill_color, stroke_enabled, stroke_color, stroke_weight);
}
示例11: init
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
public void init(int bodyCapacity, int contactCapacity, int jointCapacity, ContactListener listener){
m_bodyCapacity = bodyCapacity;
m_contactCapacity = contactCapacity;
m_jointCapacity = jointCapacity;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_listener = listener;
if(m_bodies == null || m_bodyCapacity > m_bodies.length){
m_bodies = new Body[m_bodyCapacity];
}
if(m_joints == null || m_jointCapacity > m_joints.length){
m_joints = new Joint[m_jointCapacity];
}
if(m_contacts == null || m_contactCapacity > m_contacts.length){
m_contacts = new Contact[m_contactCapacity];
}
// could do some copy stuff, but just a full creation for now
// TODO djm do a copy
if(m_velocities == null || m_bodyCapacity > m_velocities.length){
m_velocities = new Velocity[m_bodyCapacity];
for(int i=0; i<m_velocities.length; i++){
m_velocities[i] = new Velocity();
}
}
// could do some copy stuff, but just a full creation for now
// TODO djm do a copy
if(m_positions == null || m_bodyCapacity > m_positions.length){
m_positions = new Position[m_bodyCapacity];
for(int i=0; i<m_positions.length; i++){
m_positions[i] = new Position();
}
}
}
示例12: drawJoint
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
private void drawJoint(Joint joint) {
Body bodyA = joint.getBodyA();
Body bodyB = joint.getBodyB();
Transform xf1 = bodyA.getTransform();
Transform xf2 = bodyB.getTransform();
Vec2 x1 = xf1.position;
Vec2 x2 = xf2.position;
Vec2 p1 = pool.popVec2();
Vec2 p2 = pool.popVec2();
joint.getAnchorA(p1);
joint.getAnchorB(p2);
color.set(0.5f, 0.8f, 0.8f);
switch (joint.getType()) {
// TODO djm write after writing joints
case DISTANCE :
m_debugDraw.drawSegment(p1, p2, color);
break;
case PULLEY : {
PulleyJoint pulley = (PulleyJoint) joint;
Vec2 s1 = pulley.getGroundAnchorA();
Vec2 s2 = pulley.getGroundAnchorB();
m_debugDraw.drawSegment(s1, p1, color);
m_debugDraw.drawSegment(s2, p2, color);
m_debugDraw.drawSegment(s1, s2, color);
}
break;
case CONSTANT_VOLUME :
case MOUSE :
// don't draw this
break;
default :
m_debugDraw.drawSegment(x1, p1, color);
m_debugDraw.drawSegment(p1, p2, color);
m_debugDraw.drawSegment(x2, p2, color);
}
pool.pushVec2(2);
}
示例13: jointDestroyed
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
public void jointDestroyed(Joint joint) {
for (int i = 0; i < 8; ++i) {
if (m_joints[i] == joint) {
m_joints[i] = null;
break;
}
}
}
示例14: drawJoint
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
private void drawJoint(Joint joint) {
Body bodyA = joint.getBodyA();
Body bodyB = joint.getBodyB();
Transform xf1 = bodyA.getTransform();
Transform xf2 = bodyB.getTransform();
Vector2 x1 = xf1.p;
Vector2 x2 = xf2.p;
Vector2 p1 = pool.popVec2();
Vector2 p2 = pool.popVec2();
joint.getAnchorA(p1);
joint.getAnchorB(p2);
color.set(0.5f, 0.8f, 0.8f);
switch (joint.getType()) {
// TODO djm write after writing joints
case DISTANCE:
m_debugDraw.drawSegment(p1, p2, color);
break;
case PULLEY: {
PulleyJoint pulley = (PulleyJoint) joint;
Vector2 s1 = pulley.getGroundAnchorA();
Vector2 s2 = pulley.getGroundAnchorB();
m_debugDraw.drawSegment(s1, p1, color);
m_debugDraw.drawSegment(s2, p2, color);
m_debugDraw.drawSegment(s1, s2, color);
}
break;
case CONSTANT_VOLUME:
case MOUSE:
// don't draw this
break;
default:
m_debugDraw.drawSegment(x1, p1, color);
m_debugDraw.drawSegment(p1, p2, color);
m_debugDraw.drawSegment(x2, p2, color);
}
pool.pushVec2(2);
}
示例15: init
import org.jbox2d.dynamics.joints.Joint; //导入依赖的package包/类
public void init(int bodyCapacity, int contactCapacity, int jointCapacity, ContactListener listener){
m_bodyCapacity = bodyCapacity;
m_contactCapacity = contactCapacity;
m_jointCapacity = jointCapacity;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_listener = listener;
if(m_bodies == null || m_bodyCapacity >= m_bodies.length){
m_bodies = new Body[m_bodyCapacity];
}
if(m_joints == null || m_jointCapacity > m_joints.length){
m_joints = new Joint[m_jointCapacity];
}
if(m_contacts == null || m_contactCapacity > m_contacts.length){
m_contacts = new Contact[m_contactCapacity];
}
// could do some copy stuff, but just a full creation for now
// TODO djm do a copy
if(m_velocities == null || m_bodyCapacity > m_velocities.length){
m_velocities = new Velocity[m_bodyCapacity];
for(int i=0; i<m_velocities.length; i++){
m_velocities[i] = new Velocity();
}
}
// could do some copy stuff, but just a full creation for now
// TODO djm do a copy
if(m_positions == null || m_bodyCapacity > m_positions.length){
m_positions = new Position[m_bodyCapacity];
for(int i=0; i<m_positions.length; i++){
m_positions[i] = new Position();
}
}
}