List of usage examples for com.badlogic.gdx.physics.box2d.joints PrismaticJointDef PrismaticJointDef
public PrismaticJointDef()
From source file:com.badlogic.gdx.tests.box2d.BodyTypes.java
License:Apache License
@Override protected void createWorld(World world) { Body ground;/*from w w w .j av a 2s . co m*/ { BodyDef bd = new BodyDef(); ground = world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vector2(-20, 0), new Vector2(20, 0)); FixtureDef fd = new FixtureDef(); fd.shape = shape; ground.createFixture(fd); shape.dispose(); } { BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; bd.position.set(0, 3.0f); m_attachment = world.createBody(bd); PolygonShape shape = new PolygonShape(); shape.setAsBox(0.5f, 2.0f); m_attachment.createFixture(shape, 2.0f); shape.dispose(); } { BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; bd.position.set(-4.0f, 5.0f); m_platform = world.createBody(bd); PolygonShape shape = new PolygonShape(); shape.setAsBox(0.5f, 4.0f, new Vector2(4.0f, 0), 0.5f * (float) Math.PI); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.friction = 0.6f; fd.density = 2.0f; m_platform.createFixture(fd); shape.dispose(); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(m_attachment, m_platform, new Vector2(0, 5.0f)); rjd.maxMotorTorque = 50.0f; rjd.enableMotor = true; world.createJoint(rjd); PrismaticJointDef pjd = new PrismaticJointDef(); pjd.initialize(ground, m_platform, new Vector2(0, 5.0f), new Vector2(1, 0)); pjd.maxMotorForce = 1000.0f; pjd.enableMotor = true; pjd.lowerTranslation = -10f; pjd.upperTranslation = 10.0f; pjd.enableLimit = true; world.createJoint(pjd); m_speed = 3.0f; } { BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; bd.position.set(0, 8.0f); Body body = world.createBody(bd); PolygonShape shape = new PolygonShape(); shape.setAsBox(0.75f, 0.75f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.friction = 0.6f; fd.density = 2.0f; body.createFixture(fd); shape.dispose(); } }
From source file:com.badlogic.gdx.tests.box2d.CollisionFiltering.java
License:Apache License
@Override protected void createWorld(World world) { {// www.j a va2 s.c o m EdgeShape shape = new EdgeShape(); shape.set(new Vector2(-40.0f, 0), new Vector2(40, 0)); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.friction = 0.3f; BodyDef bd = new BodyDef(); Body ground = world.createBody(bd); ground.createFixture(fd); shape.dispose(); } Vector2[] vertices = new Vector2[3]; vertices[0] = new Vector2(-1, 0); vertices[1] = new Vector2(1, 0); vertices[2] = new Vector2(0, 2); PolygonShape polygon = new PolygonShape(); polygon.set(vertices); FixtureDef triangleShapeDef = new FixtureDef(); triangleShapeDef.shape = polygon; triangleShapeDef.density = 1.0f; triangleShapeDef.filter.groupIndex = k_smallGroup; triangleShapeDef.filter.categoryBits = k_triangleCategory; triangleShapeDef.filter.maskBits = k_triangleMask; BodyDef triangleBodyDef = new BodyDef(); triangleBodyDef.type = BodyType.DynamicBody; triangleBodyDef.position.set(-5, 2); Body body1 = world.createBody(triangleBodyDef); body1.createFixture(triangleShapeDef); vertices[0].scl(2); vertices[1].scl(2); vertices[2].scl(2); polygon.set(vertices); triangleShapeDef.filter.groupIndex = k_largeGroup; triangleBodyDef.position.set(-5, 6); triangleBodyDef.fixedRotation = true; Body body2 = world.createBody(triangleBodyDef); body2.createFixture(triangleShapeDef); { BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; bd.position.set(-5, 10); Body body = world.createBody(bd); PolygonShape p = new PolygonShape(); p.setAsBox(0.5f, 1.0f); body.createFixture(p, 1); PrismaticJointDef jd = new PrismaticJointDef(); jd.bodyA = body2; jd.bodyB = body; jd.enableLimit = true; jd.localAnchorA.set(0, 4); jd.localAnchorB.set(0, 0); jd.localAxisA.set(0, 1); jd.lowerTranslation = -1; jd.upperTranslation = 1; world.createJoint(jd); p.dispose(); } polygon.setAsBox(1, 0.5f); FixtureDef boxShapeDef = new FixtureDef(); boxShapeDef.shape = polygon; boxShapeDef.density = 1; boxShapeDef.restitution = 0.1f; boxShapeDef.filter.groupIndex = k_smallGroup; boxShapeDef.filter.categoryBits = k_boxCategory; boxShapeDef.filter.maskBits = k_boxMask; BodyDef boxBodyDef = new BodyDef(); boxBodyDef.type = BodyType.DynamicBody; boxBodyDef.position.set(0, 2); Body body3 = world.createBody(boxBodyDef); body3.createFixture(boxShapeDef); polygon.setAsBox(2, 1); boxShapeDef.filter.groupIndex = k_largeGroup; boxBodyDef.position.set(0, 6); Body body4 = world.createBody(boxBodyDef); body4.createFixture(boxShapeDef); CircleShape circle = new CircleShape(); circle.setRadius(1); FixtureDef circleShapeDef = new FixtureDef(); circleShapeDef.shape = circle; circleShapeDef.density = 1.0f; circleShapeDef.filter.groupIndex = k_smallGroup; circleShapeDef.filter.categoryBits = k_circleCategory; circleShapeDef.filter.maskBits = k_circleMask; BodyDef circleBodyDef = new BodyDef(); circleBodyDef.type = BodyType.DynamicBody; circleBodyDef.position.set(5, 2); Body body5 = world.createBody(circleBodyDef); body5.createFixture(circleShapeDef); circle.setRadius(2); circleShapeDef.filter.groupIndex = k_largeGroup; circleBodyDef.position.set(5, 6); Body body6 = world.createBody(circleBodyDef); body6.createFixture(circleShapeDef); }
From source file:com.badlogic.gdx.tests.box2d.Prismatic.java
License:Apache License
@Override protected void createWorld(World world) { Body ground;/*from ww w . ja v a 2s . c o m*/ { BodyDef bd = new BodyDef(); ground = world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vector2(-40, 0), new Vector2(40, 0)); ground.createFixture(shape, 0); shape.dispose(); } { PolygonShape shape = new PolygonShape(); shape.setAsBox(2, 5); BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; bd.position.set(-10, 10); bd.angle = 0.5f * (float) Math.PI; bd.allowSleep = false; Body body = world.createBody(bd); body.createFixture(shape, 5.0f); PrismaticJointDef pjd = new PrismaticJointDef(); Vector2 axis = new Vector2(2, 1); axis.nor(); pjd.initialize(ground, body, new Vector2(0, 0), axis); pjd.motorSpeed = 10.0f; pjd.maxMotorForce = 10000.0f; pjd.enableMotor = true; pjd.lowerTranslation = 0; pjd.upperTranslation = 20.0f; pjd.enableLimit = true; m_joint = (PrismaticJoint) world.createJoint(pjd); } }
From source file:com.cafeitvn.myballgame.screen.Box2DMapObjectParser.java
License:Apache License
/** * creates a {@link Joint} from a {@link MapObject} * @param mapObject the {@link Joint} which to parse * @return the parsed {@link Joint}// w ww . ja v a2 s. c o m */ public Joint createJoint(MapObject mapObject) { MapProperties properties = mapObject.getProperties(); JointDef jointDef = null; String type = properties.get("type", String.class); if (!type.equals(aliases.joint)) throw new IllegalArgumentException( "type of " + mapObject + " is \"" + type + "\" instead of \"" + aliases.joint + "\""); String jointType = properties.get(aliases.jointType, String.class); // get all possible values if (jointType.equals(aliases.distanceJoint)) { DistanceJointDef distanceJointDef = new DistanceJointDef(); distanceJointDef.dampingRatio = (Float) getProperty(properties, aliases.dampingRatio, distanceJointDef.dampingRatio, Float.class); distanceJointDef.frequencyHz = (Float) getProperty(properties, aliases.frequencyHz, distanceJointDef.frequencyHz, Float.class); distanceJointDef.length = (Float) getProperty(properties, aliases.length, distanceJointDef.length, Float.class) * (tileWidth + tileHeight) / 2 * unitScale; distanceJointDef.localAnchorA.set( (Float) getProperty(properties, aliases.localAnchorAX, distanceJointDef.localAnchorA.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorAY, distanceJointDef.localAnchorA.y, Float.class) * tileHeight * unitScale); distanceJointDef.localAnchorB.set( (Float) getProperty(properties, aliases.localAnchorBX, distanceJointDef.localAnchorB.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorBY, distanceJointDef.localAnchorB.y, Float.class) * tileHeight * unitScale); jointDef = distanceJointDef; } else if (jointType.equals(aliases.frictionJoint)) { FrictionJointDef frictionJointDef = new FrictionJointDef(); frictionJointDef.localAnchorA.set( (Float) getProperty(properties, aliases.localAnchorAX, frictionJointDef.localAnchorA.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorAY, frictionJointDef.localAnchorA.y, Float.class) * tileHeight * unitScale); frictionJointDef.localAnchorB.set( (Float) getProperty(properties, aliases.localAnchorBX, frictionJointDef.localAnchorB.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorBY, frictionJointDef.localAnchorB.y, Float.class) * tileHeight * unitScale); frictionJointDef.maxForce = (Float) getProperty(properties, aliases.maxForce, frictionJointDef.maxForce, Float.class); frictionJointDef.maxTorque = (Float) getProperty(properties, aliases.maxTorque, frictionJointDef.maxTorque, Float.class); jointDef = frictionJointDef; } else if (jointType.equals(aliases.gearJoint)) { GearJointDef gearJointDef = new GearJointDef(); gearJointDef.joint1 = joints.get(properties.get(aliases.joint1, String.class)); gearJointDef.joint2 = joints.get(properties.get(aliases.joint2, String.class)); gearJointDef.ratio = (Float) getProperty(properties, aliases.ratio, gearJointDef.ratio, Float.class); jointDef = gearJointDef; } else if (jointType.equals(aliases.mouseJoint)) { MouseJointDef mouseJointDef = new MouseJointDef(); mouseJointDef.dampingRatio = (Float) getProperty(properties, aliases.dampingRatio, mouseJointDef.dampingRatio, Float.class); mouseJointDef.frequencyHz = (Float) getProperty(properties, aliases.frequencyHz, mouseJointDef.frequencyHz, Float.class); mouseJointDef.maxForce = (Float) getProperty(properties, aliases.maxForce, mouseJointDef.maxForce, Float.class); mouseJointDef.target.set( (Float) getProperty(properties, aliases.targetX, mouseJointDef.target.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.targetY, mouseJointDef.target.y, Float.class) * tileHeight * unitScale); jointDef = mouseJointDef; } else if (jointType.equals(aliases.prismaticJoint)) { PrismaticJointDef prismaticJointDef = new PrismaticJointDef(); prismaticJointDef.enableLimit = (Boolean) getProperty(properties, aliases.enableLimit, prismaticJointDef.enableLimit, Boolean.class); prismaticJointDef.enableMotor = (Boolean) getProperty(properties, aliases.enableMotor, prismaticJointDef.enableMotor, Boolean.class); prismaticJointDef.localAnchorA.set( (Float) getProperty(properties, aliases.localAnchorAX, prismaticJointDef.localAnchorA.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorAY, prismaticJointDef.localAnchorA.y, Float.class) * tileHeight * unitScale); prismaticJointDef.localAnchorB.set( (Float) getProperty(properties, aliases.localAnchorBX, prismaticJointDef.localAnchorB.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorBY, prismaticJointDef.localAnchorB.y, Float.class) * tileHeight * unitScale); prismaticJointDef.localAxisA.set( (Float) getProperty(properties, aliases.localAxisAX, prismaticJointDef.localAxisA.x, Float.class), (Float) getProperty(properties, aliases.localAxisAY, prismaticJointDef.localAxisA.y, Float.class)); prismaticJointDef.lowerTranslation = (Float) getProperty(properties, aliases.lowerTranslation, prismaticJointDef.lowerTranslation, Float.class) * (tileWidth + tileHeight) / 2 * unitScale; prismaticJointDef.maxMotorForce = (Float) getProperty(properties, aliases.maxMotorForce, prismaticJointDef.maxMotorForce, Float.class); prismaticJointDef.motorSpeed = (Float) getProperty(properties, aliases.motorSpeed, prismaticJointDef.motorSpeed, Float.class); prismaticJointDef.referenceAngle = (Float) getProperty(properties, aliases.referenceAngle, prismaticJointDef.referenceAngle, Float.class); prismaticJointDef.upperTranslation = (Float) getProperty(properties, aliases.upperTranslation, prismaticJointDef.upperTranslation, Float.class) * (tileWidth + tileHeight) / 2 * unitScale; jointDef = prismaticJointDef; } else if (jointType.equals(aliases.pulleyJoint)) { PulleyJointDef pulleyJointDef = new PulleyJointDef(); pulleyJointDef.groundAnchorA.set( (Float) getProperty(properties, aliases.groundAnchorAX, pulleyJointDef.groundAnchorA.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.groundAnchorAY, pulleyJointDef.groundAnchorA.y, Float.class) * tileHeight * unitScale); pulleyJointDef.groundAnchorB.set( (Float) getProperty(properties, aliases.groundAnchorBX, pulleyJointDef.groundAnchorB.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.groundAnchorBY, pulleyJointDef.groundAnchorB.y, Float.class) * tileHeight * unitScale); pulleyJointDef.lengthA = (Float) getProperty(properties, aliases.lengthA, pulleyJointDef.lengthA, Float.class) * (tileWidth + tileHeight) / 2 * unitScale; pulleyJointDef.lengthB = (Float) getProperty(properties, aliases.lengthB, pulleyJointDef.lengthB, Float.class) * (tileWidth + tileHeight) / 2 * unitScale; pulleyJointDef.localAnchorA.set( (Float) getProperty(properties, aliases.localAnchorAX, pulleyJointDef.localAnchorA.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorAY, pulleyJointDef.localAnchorA.y, Float.class) * tileHeight * unitScale); pulleyJointDef.localAnchorB.set( (Float) getProperty(properties, aliases.localAnchorBX, pulleyJointDef.localAnchorB.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorBY, pulleyJointDef.localAnchorB.y, Float.class) * tileHeight * unitScale); pulleyJointDef.ratio = (Float) getProperty(properties, aliases.ratio, pulleyJointDef.ratio, Float.class); jointDef = pulleyJointDef; } else if (jointType.equals(aliases.revoluteJoint)) { RevoluteJointDef revoluteJointDef = new RevoluteJointDef(); revoluteJointDef.enableLimit = (Boolean) getProperty(properties, aliases.enableLimit, revoluteJointDef.enableLimit, Boolean.class); revoluteJointDef.enableMotor = (Boolean) getProperty(properties, aliases.enableMotor, revoluteJointDef.enableMotor, Boolean.class); revoluteJointDef.localAnchorA.set( (Float) getProperty(properties, aliases.localAnchorAX, revoluteJointDef.localAnchorA.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorAY, revoluteJointDef.localAnchorA.y, Float.class) * tileHeight * unitScale); revoluteJointDef.localAnchorB.set( (Float) getProperty(properties, aliases.localAnchorBX, revoluteJointDef.localAnchorB.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorBY, revoluteJointDef.localAnchorB.y, Float.class) * tileHeight * unitScale); revoluteJointDef.lowerAngle = (Float) getProperty(properties, aliases.lowerAngle, revoluteJointDef.lowerAngle, Float.class); revoluteJointDef.maxMotorTorque = (Float) getProperty(properties, aliases.maxMotorTorque, revoluteJointDef.maxMotorTorque, Float.class); revoluteJointDef.motorSpeed = (Float) getProperty(properties, aliases.motorSpeed, revoluteJointDef.motorSpeed, Float.class); revoluteJointDef.referenceAngle = (Float) getProperty(properties, aliases.referenceAngle, revoluteJointDef.referenceAngle, Float.class); revoluteJointDef.upperAngle = (Float) getProperty(properties, aliases.upperAngle, revoluteJointDef.upperAngle, Float.class); jointDef = revoluteJointDef; } else if (jointType.equals(aliases.ropeJoint)) { RopeJointDef ropeJointDef = new RopeJointDef(); ropeJointDef.localAnchorA.set( (Float) getProperty(properties, aliases.localAnchorAX, ropeJointDef.localAnchorA.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorAY, ropeJointDef.localAnchorA.y, Float.class) * tileHeight * unitScale); ropeJointDef.localAnchorB.set( (Float) getProperty(properties, aliases.localAnchorBX, ropeJointDef.localAnchorB.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorBY, ropeJointDef.localAnchorB.y, Float.class) * tileHeight * unitScale); ropeJointDef.maxLength = (Float) getProperty(properties, aliases.maxLength, ropeJointDef.maxLength, Float.class) * (tileWidth + tileHeight) / 2 * unitScale; jointDef = ropeJointDef; } else if (jointType.equals(aliases.weldJoint)) { WeldJointDef weldJointDef = new WeldJointDef(); weldJointDef.localAnchorA.set( (Float) getProperty(properties, aliases.localAnchorAX, weldJointDef.localAnchorA.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorAY, weldJointDef.localAnchorA.y, Float.class) * tileHeight * unitScale); weldJointDef.localAnchorB.set( (Float) getProperty(properties, aliases.localAnchorBX, weldJointDef.localAnchorB.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorBY, weldJointDef.localAnchorB.y, Float.class) * tileHeight * unitScale); weldJointDef.referenceAngle = (Float) getProperty(properties, aliases.referenceAngle, weldJointDef.referenceAngle, Float.class); jointDef = weldJointDef; } else if (jointType.equals(aliases.wheelJoint)) { WheelJointDef wheelJointDef = new WheelJointDef(); wheelJointDef.dampingRatio = (Float) getProperty(properties, aliases.dampingRatio, wheelJointDef.dampingRatio, Float.class); wheelJointDef.enableMotor = (Boolean) getProperty(properties, aliases.enableMotor, wheelJointDef.enableMotor, Boolean.class); wheelJointDef.frequencyHz = (Float) getProperty(properties, aliases.frequencyHz, wheelJointDef.frequencyHz, Float.class); wheelJointDef.localAnchorA.set( (Float) getProperty(properties, aliases.localAnchorAX, wheelJointDef.localAnchorA.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorAY, wheelJointDef.localAnchorA.y, Float.class) * tileHeight * unitScale); wheelJointDef.localAnchorB.set( (Float) getProperty(properties, aliases.localAnchorBX, wheelJointDef.localAnchorB.x, Float.class) * tileWidth * unitScale, (Float) getProperty(properties, aliases.localAnchorBY, wheelJointDef.localAnchorB.y, Float.class) * tileHeight * unitScale); wheelJointDef.localAxisA.set( (Float) getProperty(properties, aliases.localAxisAX, wheelJointDef.localAxisA.x, Float.class), (Float) getProperty(properties, aliases.localAxisAY, wheelJointDef.localAxisA.y, Float.class)); wheelJointDef.maxMotorTorque = (Float) getProperty(properties, aliases.maxMotorTorque, wheelJointDef.maxMotorTorque, Float.class); wheelJointDef.motorSpeed = (Float) getProperty(properties, aliases.motorSpeed, wheelJointDef.motorSpeed, Float.class); jointDef = wheelJointDef; } jointDef.bodyA = bodies.get(properties.get(aliases.bodyA, String.class)); jointDef.bodyB = bodies.get(properties.get(aliases.bodyB, String.class)); jointDef.collideConnected = (Boolean) getProperty(properties, aliases.collideConnected, jointDef.collideConnected, Boolean.class); Joint joint = jointDef.bodyA.getWorld().createJoint(jointDef); String name = mapObject.getName(); if (joints.containsKey(name)) { int duplicate = 1; while (joints.containsKey(name + duplicate)) duplicate++; name += duplicate; } joints.put(name, joint); return joint; }
From source file:com.laex.cg2d.render.util.ProtoBufTypeConversionUtil.java
License:Open Source License
/** * As primastic joint def.//from ww w . java2 s .c o m * * @param bodyA the body a * @param bodyB the body b * @param _j the _j * @return the prismatic joint def */ public static PrismaticJointDef asPrimasticJointDef(Body bodyA, Body bodyB, CGJoint _j) { PrismaticJointDef jdef = new PrismaticJointDef(); jdef.collideConnected = _j.getPrismaticJointDef().getCollideConnected(); jdef.enableLimit = _j.getPrismaticJointDef().getEnableLimit(); jdef.enableMotor = _j.getPrismaticJointDef().getEnableMotor(); jdef.referenceAngle = _j.getPrismaticJointDef().getReferenceAngle(); jdef.lowerTranslation = _j.getPrismaticJointDef().getLowerTranslation(); jdef.maxMotorForce = _j.getPrismaticJointDef().getMaxMotorForce(); jdef.upperTranslation = _j.getPrismaticJointDef().getUpperTranslation(); jdef.motorSpeed = _j.getPrismaticJointDef().getMotorSpeed(); jdef.initialize(bodyA, bodyB, ProtoBufTypeConversionUtil.asVector2(_j.getPrismaticJointDef().getAnchor()), ProtoBufTypeConversionUtil.asVector2(_j.getPrismaticJointDef().getAxis())); if (_j.getUseLocalAnchors()) { jdef.localAnchorA.set(Vector2Adapter.asVector2(_j.getLocalAnchorA())); jdef.localAnchorB.set(Vector2Adapter.asVector2(_j.getLocalAnchorB())); } return jdef; }
From source file:com.rubentxu.juegos.core.utils.dermetfan.box2d.Box2DMapObjectParser.java
License:Apache License
/** * creates a {@link Joint} from a {@link MapObject} * * @param mapObject the {@link Joint} to parse * @return the parsed {@link Joint}//w w w . j a v a2 s . co m */ public Joint createJoint(MapObject mapObject) { MapProperties properties = mapObject.getProperties(); JointDef jointDef = null; String type = properties.get("type", String.class); if (!type.equals(aliases.joint)) throw new IllegalArgumentException( "type of " + mapObject + " is \"" + type + "\" instead of \"" + aliases.joint + "\""); String jointType = properties.get(aliases.jointType, String.class); // get all possible values if (jointType.equals(aliases.distanceJoint)) { DistanceJointDef distanceJointDef = new DistanceJointDef(); distanceJointDef.dampingRatio = getProperty(properties, aliases.dampingRatio, distanceJointDef.dampingRatio); distanceJointDef.frequencyHz = getProperty(properties, aliases.frequencyHz, distanceJointDef.frequencyHz); distanceJointDef.length = getProperty(properties, aliases.length, distanceJointDef.length) * (tileWidth + tileHeight) / 2 * unitScale; distanceJointDef.localAnchorA.set( getProperty(properties, aliases.localAnchorAX, distanceJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, distanceJointDef.localAnchorA.y) * tileHeight * unitScale); distanceJointDef.localAnchorB.set( getProperty(properties, aliases.localAnchorBX, distanceJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, distanceJointDef.localAnchorB.y) * tileHeight * unitScale); jointDef = distanceJointDef; } else if (jointType.equals(aliases.frictionJoint)) { FrictionJointDef frictionJointDef = new FrictionJointDef(); frictionJointDef.localAnchorA.set( getProperty(properties, aliases.localAnchorAX, frictionJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, frictionJointDef.localAnchorA.y) * tileHeight * unitScale); frictionJointDef.localAnchorB.set( getProperty(properties, aliases.localAnchorBX, frictionJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, frictionJointDef.localAnchorB.y) * tileHeight * unitScale); frictionJointDef.maxForce = getProperty(properties, aliases.maxForce, frictionJointDef.maxForce); frictionJointDef.maxTorque = getProperty(properties, aliases.maxTorque, frictionJointDef.maxTorque); jointDef = frictionJointDef; } else if (jointType.equals(aliases.gearJoint)) { GearJointDef gearJointDef = new GearJointDef(); gearJointDef.joint1 = joints.get(properties.get(aliases.joint1, String.class)); gearJointDef.joint2 = joints.get(properties.get(aliases.joint2, String.class)); gearJointDef.ratio = getProperty(properties, aliases.ratio, gearJointDef.ratio); jointDef = gearJointDef; } else if (jointType.equals(aliases.mouseJoint)) { MouseJointDef mouseJointDef = new MouseJointDef(); mouseJointDef.dampingRatio = getProperty(properties, aliases.dampingRatio, mouseJointDef.dampingRatio); mouseJointDef.frequencyHz = getProperty(properties, aliases.frequencyHz, mouseJointDef.frequencyHz); mouseJointDef.maxForce = getProperty(properties, aliases.maxForce, mouseJointDef.maxForce); mouseJointDef.target.set( getProperty(properties, aliases.targetX, mouseJointDef.target.x) * tileWidth * unitScale, getProperty(properties, aliases.targetY, mouseJointDef.target.y) * tileHeight * unitScale); jointDef = mouseJointDef; } else if (jointType.equals(aliases.prismaticJoint)) { PrismaticJointDef prismaticJointDef = new PrismaticJointDef(); prismaticJointDef.enableLimit = getProperty(properties, aliases.enableLimit, prismaticJointDef.enableLimit); prismaticJointDef.enableMotor = getProperty(properties, aliases.enableMotor, prismaticJointDef.enableMotor); prismaticJointDef.localAnchorA.set( getProperty(properties, aliases.localAnchorAX, prismaticJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, prismaticJointDef.localAnchorA.y) * tileHeight * unitScale); prismaticJointDef.localAnchorB.set( getProperty(properties, aliases.localAnchorBX, prismaticJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, prismaticJointDef.localAnchorB.y) * tileHeight * unitScale); prismaticJointDef.localAxisA.set( getProperty(properties, aliases.localAxisAX, prismaticJointDef.localAxisA.x), getProperty(properties, aliases.localAxisAY, prismaticJointDef.localAxisA.y)); prismaticJointDef.lowerTranslation = getProperty(properties, aliases.lowerTranslation, prismaticJointDef.lowerTranslation) * (tileWidth + tileHeight) / 2 * unitScale; prismaticJointDef.maxMotorForce = getProperty(properties, aliases.maxMotorForce, prismaticJointDef.maxMotorForce); prismaticJointDef.motorSpeed = getProperty(properties, aliases.motorSpeed, prismaticJointDef.motorSpeed); prismaticJointDef.referenceAngle = getProperty(properties, aliases.referenceAngle, prismaticJointDef.referenceAngle); prismaticJointDef.upperTranslation = getProperty(properties, aliases.upperTranslation, prismaticJointDef.upperTranslation) * (tileWidth + tileHeight) / 2 * unitScale; jointDef = prismaticJointDef; } else if (jointType.equals(aliases.pulleyJoint)) { PulleyJointDef pulleyJointDef = new PulleyJointDef(); pulleyJointDef.groundAnchorA.set( getProperty(properties, aliases.groundAnchorAX, pulleyJointDef.groundAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.groundAnchorAY, pulleyJointDef.groundAnchorA.y) * tileHeight * unitScale); pulleyJointDef.groundAnchorB.set( getProperty(properties, aliases.groundAnchorBX, pulleyJointDef.groundAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.groundAnchorBY, pulleyJointDef.groundAnchorB.y) * tileHeight * unitScale); pulleyJointDef.lengthA = getProperty(properties, aliases.lengthA, pulleyJointDef.lengthA) * (tileWidth + tileHeight) / 2 * unitScale; pulleyJointDef.lengthB = getProperty(properties, aliases.lengthB, pulleyJointDef.lengthB) * (tileWidth + tileHeight) / 2 * unitScale; pulleyJointDef.localAnchorA.set( getProperty(properties, aliases.localAnchorAX, pulleyJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, pulleyJointDef.localAnchorA.y) * tileHeight * unitScale); pulleyJointDef.localAnchorB.set( getProperty(properties, aliases.localAnchorBX, pulleyJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, pulleyJointDef.localAnchorB.y) * tileHeight * unitScale); pulleyJointDef.ratio = getProperty(properties, aliases.ratio, pulleyJointDef.ratio); jointDef = pulleyJointDef; } else if (jointType.equals(aliases.revoluteJoint)) { RevoluteJointDef revoluteJointDef = new RevoluteJointDef(); revoluteJointDef.enableLimit = getProperty(properties, aliases.enableLimit, revoluteJointDef.enableLimit); revoluteJointDef.enableMotor = getProperty(properties, aliases.enableMotor, revoluteJointDef.enableMotor); revoluteJointDef.localAnchorA.set( getProperty(properties, aliases.localAnchorAX, revoluteJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, revoluteJointDef.localAnchorA.y) * tileHeight * unitScale); revoluteJointDef.localAnchorB.set( getProperty(properties, aliases.localAnchorBX, revoluteJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, revoluteJointDef.localAnchorB.y) * tileHeight * unitScale); revoluteJointDef.lowerAngle = getProperty(properties, aliases.lowerAngle, revoluteJointDef.lowerAngle); revoluteJointDef.maxMotorTorque = getProperty(properties, aliases.maxMotorTorque, revoluteJointDef.maxMotorTorque); revoluteJointDef.motorSpeed = getProperty(properties, aliases.motorSpeed, revoluteJointDef.motorSpeed); revoluteJointDef.referenceAngle = getProperty(properties, aliases.referenceAngle, revoluteJointDef.referenceAngle); revoluteJointDef.upperAngle = getProperty(properties, aliases.upperAngle, revoluteJointDef.upperAngle); jointDef = revoluteJointDef; } else if (jointType.equals(aliases.ropeJoint)) { RopeJointDef ropeJointDef = new RopeJointDef(); ropeJointDef.localAnchorA.set( getProperty(properties, aliases.localAnchorAX, ropeJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, ropeJointDef.localAnchorA.y) * tileHeight * unitScale); ropeJointDef.localAnchorB.set( getProperty(properties, aliases.localAnchorBX, ropeJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, ropeJointDef.localAnchorB.y) * tileHeight * unitScale); ropeJointDef.maxLength = getProperty(properties, aliases.maxLength, ropeJointDef.maxLength) * (tileWidth + tileHeight) / 2 * unitScale; jointDef = ropeJointDef; } else if (jointType.equals(aliases.weldJoint)) { WeldJointDef weldJointDef = new WeldJointDef(); weldJointDef.localAnchorA.set( getProperty(properties, aliases.localAnchorAX, weldJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, weldJointDef.localAnchorA.y) * tileHeight * unitScale); weldJointDef.localAnchorB.set( getProperty(properties, aliases.localAnchorBX, weldJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, weldJointDef.localAnchorB.y) * tileHeight * unitScale); weldJointDef.referenceAngle = getProperty(properties, aliases.referenceAngle, weldJointDef.referenceAngle); jointDef = weldJointDef; } else if (jointType.equals(aliases.wheelJoint)) { WheelJointDef wheelJointDef = new WheelJointDef(); wheelJointDef.dampingRatio = getProperty(properties, aliases.dampingRatio, wheelJointDef.dampingRatio); wheelJointDef.enableMotor = getProperty(properties, aliases.enableMotor, wheelJointDef.enableMotor); wheelJointDef.frequencyHz = getProperty(properties, aliases.frequencyHz, wheelJointDef.frequencyHz); wheelJointDef.localAnchorA.set( getProperty(properties, aliases.localAnchorAX, wheelJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, wheelJointDef.localAnchorA.y) * tileHeight * unitScale); wheelJointDef.localAnchorB.set( getProperty(properties, aliases.localAnchorBX, wheelJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, wheelJointDef.localAnchorB.y) * tileHeight * unitScale); wheelJointDef.localAxisA.set(getProperty(properties, aliases.localAxisAX, wheelJointDef.localAxisA.x), getProperty(properties, aliases.localAxisAY, wheelJointDef.localAxisA.y)); wheelJointDef.maxMotorTorque = getProperty(properties, aliases.maxMotorTorque, wheelJointDef.maxMotorTorque); wheelJointDef.motorSpeed = getProperty(properties, aliases.motorSpeed, wheelJointDef.motorSpeed); jointDef = wheelJointDef; } jointDef.bodyA = bodies.get(properties.get(aliases.bodyA, String.class)); jointDef.bodyB = bodies.get(properties.get(aliases.bodyB, String.class)); jointDef.collideConnected = getProperty(properties, aliases.collideConnected, jointDef.collideConnected); Joint joint = jointDef.bodyA.getWorld().createJoint(jointDef); String name = mapObject.getName(); if (joints.containsKey(name)) { int duplicate = 1; while (joints.containsKey(name + duplicate)) duplicate++; name += duplicate; } joints.put(name, joint); return joint; }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DMapObjectParser.java
License:Apache License
/** creates a {@link Joint} from a {@link MapObject} * @param mapObject the {@link Joint} to parse * @return the parsed {@link Joint} */ public Joint createJoint(MapObject mapObject) { if ((mapObject = listener.createJoint(mapObject)) == null) return null; MapProperties properties = mapObject.getProperties(); JointDef jointDef;// ww w. j av a2 s.co m String jointType = getProperty(properties, aliases.jointType, ""); if (jointType.equals(aliases.distanceJoint)) { DistanceJointDef distanceJointDef = new DistanceJointDef(); assignProperties(distanceJointDef, heritage); assignProperties(distanceJointDef, mapProperties); assignProperties(distanceJointDef, layerProperties); assignProperties(distanceJointDef, properties); jointDef = distanceJointDef; } else if (jointType.equals(aliases.frictionJoint)) { FrictionJointDef frictionJointDef = new FrictionJointDef(); assignProperties(frictionJointDef, heritage); assignProperties(frictionJointDef, mapProperties); assignProperties(frictionJointDef, layerProperties); assignProperties(frictionJointDef, properties); jointDef = frictionJointDef; } else if (jointType.equals(aliases.gearJoint)) { GearJointDef gearJointDef = new GearJointDef(); assignProperties(gearJointDef, heritage); assignProperties(gearJointDef, mapProperties); assignProperties(gearJointDef, layerProperties); assignProperties(gearJointDef, properties); jointDef = gearJointDef; } else if (jointType.equals(aliases.mouseJoint)) { MouseJointDef mouseJointDef = new MouseJointDef(); assignProperties(mouseJointDef, heritage); assignProperties(mouseJointDef, mapProperties); assignProperties(mouseJointDef, layerProperties); assignProperties(mouseJointDef, properties); jointDef = mouseJointDef; } else if (jointType.equals(aliases.prismaticJoint)) { PrismaticJointDef prismaticJointDef = new PrismaticJointDef(); assignProperties(prismaticJointDef, heritage); assignProperties(prismaticJointDef, mapProperties); assignProperties(prismaticJointDef, layerProperties); assignProperties(prismaticJointDef, properties); jointDef = prismaticJointDef; } else if (jointType.equals(aliases.pulleyJoint)) { PulleyJointDef pulleyJointDef = new PulleyJointDef(); assignProperties(pulleyJointDef, heritage); assignProperties(pulleyJointDef, mapProperties); assignProperties(pulleyJointDef, layerProperties); assignProperties(pulleyJointDef, properties); jointDef = pulleyJointDef; } else if (jointType.equals(aliases.revoluteJoint)) { RevoluteJointDef revoluteJointDef = new RevoluteJointDef(); assignProperties(revoluteJointDef, heritage); assignProperties(revoluteJointDef, mapProperties); assignProperties(revoluteJointDef, layerProperties); assignProperties(revoluteJointDef, properties); jointDef = revoluteJointDef; } else if (jointType.equals(aliases.ropeJoint)) { RopeJointDef ropeJointDef = new RopeJointDef(); assignProperties(ropeJointDef, heritage); assignProperties(ropeJointDef, mapProperties); assignProperties(ropeJointDef, layerProperties); assignProperties(ropeJointDef, properties); jointDef = ropeJointDef; } else if (jointType.equals(aliases.weldJoint)) { WeldJointDef weldJointDef = new WeldJointDef(); assignProperties(weldJointDef, heritage); assignProperties(weldJointDef, mapProperties); assignProperties(weldJointDef, layerProperties); assignProperties(weldJointDef, properties); jointDef = weldJointDef; } else if (jointType.equals(aliases.wheelJoint)) { WheelJointDef wheelJointDef = new WheelJointDef(); assignProperties(wheelJointDef, heritage); assignProperties(wheelJointDef, mapProperties); assignProperties(wheelJointDef, layerProperties); assignProperties(wheelJointDef, properties); jointDef = wheelJointDef; } else throw new IllegalArgumentException( ClassReflection.getSimpleName(JointType.class) + " " + jointType + " is unknown"); assignProperties(jointDef, properties); Joint joint = jointDef.bodyA.getWorld().createJoint(jointDef); joint.setUserData(getProperty(properties, aliases.userData, joint.getUserData())); joints.put(findAvailableName(mapObject.getName(), joints), joint); listener.created(joint, mapObject); return joint; }
From source file:com.tnf.ptm.entities.ship.ShipBuilder.java
License:Apache License
private PrismaticJoint createDoorJoint(Body shipBody, World w, Vector2 shipPos, Vector2 doorRelPos, float shipAngle) { Body doorBody = createDoorBody(w, shipPos, doorRelPos, shipAngle); PrismaticJointDef jd = new PrismaticJointDef(); jd.initialize(shipBody, doorBody, shipPos, Vector2.Zero); jd.localAxisA.set(1, 0);//from ww w. j av a 2 s . c om jd.collideConnected = false; jd.enableLimit = true; jd.enableMotor = true; jd.lowerTranslation = 0; jd.upperTranslation = Door.DOOR_LEN; jd.maxMotorForce = 2; return (PrismaticJoint) w.createJoint(jd); }
From source file:de.fhkoeln.game.utils.Box2DMapObjectParser.java
License:Apache License
/** creates a {@link com.badlogic.gdx.physics.box2d.Joint} from a {@link com.badlogic.gdx.maps.MapObject} * @param mapObject the {@link com.badlogic.gdx.physics.box2d.Joint} to parse * @return the parsed {@link com.badlogic.gdx.physics.box2d.Joint} */ public Joint createJoint(MapObject mapObject) { if ((mapObject = listener.createJoint(mapObject)) == null) return null; MapProperties properties = mapObject.getProperties(); JointDef jointDef;//from w w w . j a v a 2s.c om String jointType = getProperty(properties, aliases.jointType, ""); if (jointType.equals(aliases.distanceJoint)) { DistanceJointDef distanceJointDef = new DistanceJointDef(); assignProperties(distanceJointDef, heritage); assignProperties(distanceJointDef, mapProperties); assignProperties(distanceJointDef, layerProperties); assignProperties(distanceJointDef, properties); jointDef = distanceJointDef; } else if (jointType.equals(aliases.frictionJoint)) { FrictionJointDef frictionJointDef = new FrictionJointDef(); assignProperties(frictionJointDef, heritage); assignProperties(frictionJointDef, mapProperties); assignProperties(frictionJointDef, layerProperties); assignProperties(frictionJointDef, properties); jointDef = frictionJointDef; } else if (jointType.equals(aliases.gearJoint)) { GearJointDef gearJointDef = new GearJointDef(); assignProperties(gearJointDef, heritage); assignProperties(gearJointDef, mapProperties); assignProperties(gearJointDef, layerProperties); assignProperties(gearJointDef, properties); jointDef = gearJointDef; } else if (jointType.equals(aliases.mouseJoint)) { MouseJointDef mouseJointDef = new MouseJointDef(); assignProperties(mouseJointDef, heritage); assignProperties(mouseJointDef, mapProperties); assignProperties(mouseJointDef, layerProperties); assignProperties(mouseJointDef, properties); jointDef = mouseJointDef; } else if (jointType.equals(aliases.prismaticJoint)) { PrismaticJointDef prismaticJointDef = new PrismaticJointDef(); assignProperties(prismaticJointDef, heritage); assignProperties(prismaticJointDef, mapProperties); assignProperties(prismaticJointDef, layerProperties); assignProperties(prismaticJointDef, properties); jointDef = prismaticJointDef; } else if (jointType.equals(aliases.pulleyJoint)) { PulleyJointDef pulleyJointDef = new PulleyJointDef(); assignProperties(pulleyJointDef, heritage); assignProperties(pulleyJointDef, mapProperties); assignProperties(pulleyJointDef, layerProperties); assignProperties(pulleyJointDef, properties); jointDef = pulleyJointDef; } else if (jointType.equals(aliases.revoluteJoint)) { RevoluteJointDef revoluteJointDef = new RevoluteJointDef(); assignProperties(revoluteJointDef, heritage); assignProperties(revoluteJointDef, mapProperties); assignProperties(revoluteJointDef, layerProperties); assignProperties(revoluteJointDef, properties); jointDef = revoluteJointDef; } else if (jointType.equals(aliases.ropeJoint)) { RopeJointDef ropeJointDef = new RopeJointDef(); assignProperties(ropeJointDef, heritage); assignProperties(ropeJointDef, mapProperties); assignProperties(ropeJointDef, layerProperties); assignProperties(ropeJointDef, properties); jointDef = ropeJointDef; } else if (jointType.equals(aliases.weldJoint)) { WeldJointDef weldJointDef = new WeldJointDef(); assignProperties(weldJointDef, heritage); assignProperties(weldJointDef, mapProperties); assignProperties(weldJointDef, layerProperties); assignProperties(weldJointDef, properties); jointDef = weldJointDef; } else if (jointType.equals(aliases.wheelJoint)) { WheelJointDef wheelJointDef = new WheelJointDef(); assignProperties(wheelJointDef, heritage); assignProperties(wheelJointDef, mapProperties); assignProperties(wheelJointDef, layerProperties); assignProperties(wheelJointDef, properties); jointDef = wheelJointDef; } else throw new IllegalArgumentException(JointType.class.getSimpleName() + " " + jointType + " is unknown"); assignProperties(jointDef, properties); Joint joint = jointDef.bodyA.getWorld().createJoint(jointDef); joint.setUserData(getProperty(properties, aliases.userData, joint.getUserData())); joints.put(findAvailableName(mapObject.getName(), joints), joint); listener.created(joint, mapObject); return joint; }
From source file:net.dermetfan.utils.libgdx.box2d.Box2DMapObjectParser.java
License:Apache License
/** creates a {@link Joint} from a {@link MapObject} * @param mapObject the {@link Joint} to parse * @return the parsed {@link Joint} */ public Joint createJoint(MapObject mapObject) { MapProperties properties = mapObject.getProperties(); JointDef jointDef = null;/*from www .java 2 s . c om*/ String jointType = getProperty(properties, aliases.jointType, ""); if (jointType.equals(aliases.distanceJoint)) { DistanceJointDef distanceJointDef = new DistanceJointDef(); assignProperties(distanceJointDef, heritage); assignProperties(distanceJointDef, mapProperties); assignProperties(distanceJointDef, layerProperties); assignProperties(distanceJointDef, properties); jointDef = distanceJointDef; } else if (jointType.equals(aliases.frictionJoint)) { FrictionJointDef frictionJointDef = new FrictionJointDef(); assignProperties(frictionJointDef, heritage); assignProperties(frictionJointDef, mapProperties); assignProperties(frictionJointDef, layerProperties); assignProperties(frictionJointDef, properties); jointDef = frictionJointDef; } else if (jointType.equals(aliases.gearJoint)) { GearJointDef gearJointDef = new GearJointDef(); assignProperties(gearJointDef, heritage); assignProperties(gearJointDef, mapProperties); assignProperties(gearJointDef, layerProperties); assignProperties(gearJointDef, properties); jointDef = gearJointDef; } else if (jointType.equals(aliases.mouseJoint)) { MouseJointDef mouseJointDef = new MouseJointDef(); assignProperties(mouseJointDef, heritage); assignProperties(mouseJointDef, mapProperties); assignProperties(mouseJointDef, layerProperties); assignProperties(mouseJointDef, properties); jointDef = mouseJointDef; } else if (jointType.equals(aliases.prismaticJoint)) { PrismaticJointDef prismaticJointDef = new PrismaticJointDef(); assignProperties(prismaticJointDef, heritage); assignProperties(prismaticJointDef, mapProperties); assignProperties(prismaticJointDef, layerProperties); assignProperties(prismaticJointDef, properties); jointDef = prismaticJointDef; } else if (jointType.equals(aliases.pulleyJoint)) { PulleyJointDef pulleyJointDef = new PulleyJointDef(); assignProperties(pulleyJointDef, heritage); assignProperties(pulleyJointDef, mapProperties); assignProperties(pulleyJointDef, layerProperties); assignProperties(pulleyJointDef, properties); jointDef = pulleyJointDef; } else if (jointType.equals(aliases.revoluteJoint)) { RevoluteJointDef revoluteJointDef = new RevoluteJointDef(); assignProperties(revoluteJointDef, heritage); assignProperties(revoluteJointDef, mapProperties); assignProperties(revoluteJointDef, layerProperties); assignProperties(revoluteJointDef, properties); jointDef = revoluteJointDef; } else if (jointType.equals(aliases.ropeJoint)) { RopeJointDef ropeJointDef = new RopeJointDef(); assignProperties(ropeJointDef, heritage); assignProperties(ropeJointDef, mapProperties); assignProperties(ropeJointDef, layerProperties); assignProperties(ropeJointDef, properties); jointDef = ropeJointDef; } else if (jointType.equals(aliases.weldJoint)) { WeldJointDef weldJointDef = new WeldJointDef(); assignProperties(weldJointDef, heritage); assignProperties(weldJointDef, mapProperties); assignProperties(weldJointDef, layerProperties); assignProperties(weldJointDef, properties); jointDef = weldJointDef; } else if (jointType.equals(aliases.wheelJoint)) { WheelJointDef wheelJointDef = new WheelJointDef(); assignProperties(wheelJointDef, heritage); assignProperties(wheelJointDef, mapProperties); assignProperties(wheelJointDef, layerProperties); assignProperties(wheelJointDef, properties); jointDef = wheelJointDef; } jointDef.bodyA = bodies.get(getProperty(properties, aliases.bodyA, "")); jointDef.bodyB = bodies.get(getProperty(properties, aliases.bodyB, "")); jointDef.collideConnected = getProperty(properties, aliases.collideConnected, jointDef.collideConnected); Joint joint = jointDef.bodyA.getWorld().createJoint(jointDef); joint.setUserData(getProperty(properties, aliases.userData, joint.getUserData())); joints.put(findAvailableName(mapObject.getName(), joints), joint); return joint; }