当前位置: 首页>>代码示例>>Java>>正文


Java WheelJoint类代码示例

本文整理汇总了Java中com.badlogic.gdx.physics.box2d.joints.WheelJoint的典型用法代码示例。如果您正苦于以下问题:Java WheelJoint类的具体用法?Java WheelJoint怎么用?Java WheelJoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WheelJoint类属于com.badlogic.gdx.physics.box2d.joints包,在下文中一共展示了WheelJoint类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import com.badlogic.gdx.physics.box2d.joints.WheelJoint; //导入依赖的package包/类
protected void process(Entity e) {
  WheelMotion motion = wm.get(e);
  Joints joints = jm.get(e);

  if (joints != null) {
    Collection<Joint> wheelJoints = joints.getJoints(WheelJointConfig.class);
    if (wheelJoints != null) {
      for (Joint joint : wheelJoints) {
        WheelJoint wheelJoint = (WheelJoint) joint.getJoint();
        if (wheelJoint != null) {
          wheelJoint.setMaxMotorTorque(motion.getCurrentTorque());
          wheelJoint.setMotorSpeed(motion.getCurrentVelocity());
        }
      }
    }
  }
}
 
开发者ID:jwang47,项目名称:radial,代码行数:18,代码来源:WheelMotionSystem.java

示例2: test_deserializeBug

import com.badlogic.gdx.physics.box2d.joints.WheelJoint; //导入依赖的package包/类
public void test_deserializeBug(Vector2 pos){
	/*
	Entity e = factory.build("jeep",pos);
	PhysicsComponent p = mappers.physics.get(e);
	WheelJoint j = (WheelJoint) p.getJoint("leftWheelJoint");
	logger.debug("Factory \n anchorA: " + j.getAnchorA() + "\n anchorB:" + j.getAnchorB() + " \n localAxis: "+ j.getLocalAxisA() + " \n damping: " + j.getSpringDampingRatio() + "\n frequency" + j.getSpringFrequencyHz());

	String data = factory.serialize(e);
	removeEntity(e);
	e = factory.deserialize(data);
	p = mappers.physics.get(e);
	j = (WheelJoint) p.getJoint("leftWheelJoint");
	logger.debug("Deserialized \n anchorA: " + j.getAnchorA() + "\n anchorB:" + j.getAnchorB() + " \n localAxis: "+ j.getLocalAxisA() + " \n damping: " + j.getSpringDampingRatio() + "\n frequency" + j.getSpringFrequencyHz());
	
	addEntity(e);
	*/
	World world = App.engine.systems.physics.world;
	BodyDef bd = new BodyDef();
	bd.type = BodyType.DynamicBody;
	
	Body body = world.createBody(bd),
		 wheel = world.createBody(bd);
	
	PolygonShape rect = new PolygonShape();
	rect.setAsBox(2, 1);
	CircleShape circle = new CircleShape();
	circle.setRadius(1);
	
	body.createFixture(rect,1);
	wheel.createFixture(circle,1);
	
	Vector2 localAnchor = new Vector2(0,0),
			localAxis = new Vector2(0,1);
	
	WheelJointDef jd = new WheelJointDef();
	jd.initialize(body, wheel, localAnchor , localAxis);
	WheelJoint joint = (WheelJoint)world.createJoint(jd);

	System.out.println("Local Axis = " + joint.getLocalAxisA());
	System.out.println("Local Anchor A = " + joint.getLocalAnchorA());
	
	//joint.getLocalAxisA() seems to be returning localAnchorA
	
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:45,代码来源:GameEngine.java

示例3: createCar

import com.badlogic.gdx.physics.box2d.joints.WheelJoint; //导入依赖的package包/类
/**
 * Genera un cuerpo con forma de caja
 * @param world El mundo
 * @param x Posici�n x
 * @param y Posici�n y
 * @return El cuerpo creado
 */
public static Body createCar(World world, float x, float y) {
	
	// Definici�n de los cuerpos que definen las 3 partes del coche
	// (Chasis y dos ruedas)
	BodyDef bodyDef = new BodyDef();
	bodyDef.type = BodyType.DynamicBody;
	bodyDef.position.set(x, y);
	
	// Crea lo que sera el cuerpo del chasis del coche
	Body chassis = world.createBody(bodyDef);
	
	// La forma del chasis
	PolygonShape box = new PolygonShape();
	box.setAsBox(30, 10);
	
	// Define las caracter�sticas del chasis
	FixtureDef chassisDef = new FixtureDef();
	// Forma del elemento f�sico
	chassisDef.shape = box;
	// Densidad (kg/m^2)
	chassisDef.density = 10f;
	// Coeficiente de fricci�n (0 - 1)
	chassisDef.friction = 0.4f;
	// Elasticidad (0 - 1)
	chassisDef.restitution = 0.2f;
	// A�ade el elemento f�sico al cuerpo del mundo 2D
	chassis.createFixture(chassisDef);
	
	// La forma de las ruedas
	CircleShape circle = new CircleShape();
	circle.setRadius(6f);
	
	// Define las caracter�sticas de las ruedas
	FixtureDef wheelFixture = new FixtureDef();
	wheelFixture.shape = circle;
	wheelFixture.density = 5f;
	wheelFixture.friction = 0.4f;
	wheelFixture.restitution = 0.7f;
	
	// Rueda izquierda
	Body leftWheel = world.createBody(bodyDef);
	leftWheel.createFixture(wheelFixture);
	
	// Rueda derecha
	Body rightWheel = world.createBody(bodyDef);
	rightWheel.createFixture(wheelFixture);
	
	// Une las ruedas a la carrocer�a con Joints
	WheelJointDef wheelJointDef = new WheelJointDef();
	wheelJointDef.bodyA = chassis;
	wheelJointDef.bodyB = leftWheel;
	// Suspensi�n (mayor valor m�s r�gida)
	wheelJointDef.frequencyHz = 2f;
	// Punto de uni�n con la carrocer�a
	wheelJointDef.localAnchorA.set(-30f / 2.5f, -20f / 2f);
	WheelJoint leftJoint = (WheelJoint) world.createJoint(wheelJointDef);
	
	// Para la uni�n de la otra rueda s�lo es necesario cambiar algunos par�metros
	// Los dem�s son iguales
	wheelJointDef.bodyB = rightWheel;
	wheelJointDef.localAnchorA.x *= -1;
	WheelJoint rightJoint = (WheelJoint) world.createJoint(wheelJointDef);
	
	box.dispose();
	circle.dispose();
	
	return chassis;
}
 
开发者ID:sfaci,项目名称:libgdx,代码行数:76,代码来源:WorldGenerator.java

示例4: getJoint

import com.badlogic.gdx.physics.box2d.joints.WheelJoint; //导入依赖的package包/类
@Override
public WheelJoint getJoint(){return (WheelJoint)joint;}
 
开发者ID:flixel-gdx,项目名称:flixel-gdx-box2d,代码行数:3,代码来源:B2FlxWheelJoint.java

示例5: createProperJoint

import com.badlogic.gdx.physics.box2d.joints.WheelJoint; //导入依赖的package包/类
private long createProperJoint(JointDef paramJointDef)
{
  if (paramJointDef.type == JointDef.JointType.DistanceJoint)
  {
    DistanceJointDef localDistanceJointDef = (DistanceJointDef)paramJointDef;
    return jniCreateDistanceJoint(this.addr, localDistanceJointDef.bodyA.addr, localDistanceJointDef.bodyB.addr, localDistanceJointDef.collideConnected, localDistanceJointDef.localAnchorA.x, localDistanceJointDef.localAnchorA.y, localDistanceJointDef.localAnchorB.x, localDistanceJointDef.localAnchorB.y, localDistanceJointDef.length, localDistanceJointDef.frequencyHz, localDistanceJointDef.dampingRatio);
  }
  if (paramJointDef.type == JointDef.JointType.FrictionJoint)
  {
    FrictionJointDef localFrictionJointDef = (FrictionJointDef)paramJointDef;
    return jniCreateFrictionJoint(this.addr, localFrictionJointDef.bodyA.addr, localFrictionJointDef.bodyB.addr, localFrictionJointDef.collideConnected, localFrictionJointDef.localAnchorA.x, localFrictionJointDef.localAnchorA.y, localFrictionJointDef.localAnchorB.x, localFrictionJointDef.localAnchorB.y, localFrictionJointDef.maxForce, localFrictionJointDef.maxTorque);
  }
  if (paramJointDef.type == JointDef.JointType.GearJoint)
  {
    GearJointDef localGearJointDef = (GearJointDef)paramJointDef;
    return jniCreateGearJoint(this.addr, localGearJointDef.bodyA.addr, localGearJointDef.bodyB.addr, localGearJointDef.collideConnected, localGearJointDef.joint1.addr, localGearJointDef.joint2.addr, localGearJointDef.ratio);
  }
  if (paramJointDef.type == JointDef.JointType.MouseJoint)
  {
    MouseJointDef localMouseJointDef = (MouseJointDef)paramJointDef;
    return jniCreateMouseJoint(this.addr, localMouseJointDef.bodyA.addr, localMouseJointDef.bodyB.addr, localMouseJointDef.collideConnected, localMouseJointDef.target.x, localMouseJointDef.target.y, localMouseJointDef.maxForce, localMouseJointDef.frequencyHz, localMouseJointDef.dampingRatio);
  }
  if (paramJointDef.type == JointDef.JointType.PrismaticJoint)
  {
    PrismaticJointDef localPrismaticJointDef = (PrismaticJointDef)paramJointDef;
    return jniCreatePrismaticJoint(this.addr, localPrismaticJointDef.bodyA.addr, localPrismaticJointDef.bodyB.addr, localPrismaticJointDef.collideConnected, localPrismaticJointDef.localAnchorA.x, localPrismaticJointDef.localAnchorA.y, localPrismaticJointDef.localAnchorB.x, localPrismaticJointDef.localAnchorB.y, localPrismaticJointDef.localAxisA.x, localPrismaticJointDef.localAxisA.y, localPrismaticJointDef.referenceAngle, localPrismaticJointDef.enableLimit, localPrismaticJointDef.lowerTranslation, localPrismaticJointDef.upperTranslation, localPrismaticJointDef.enableMotor, localPrismaticJointDef.maxMotorForce, localPrismaticJointDef.motorSpeed);
  }
  if (paramJointDef.type == JointDef.JointType.PulleyJoint)
  {
    PulleyJointDef localPulleyJointDef = (PulleyJointDef)paramJointDef;
    return jniCreatePulleyJoint(this.addr, localPulleyJointDef.bodyA.addr, localPulleyJointDef.bodyB.addr, localPulleyJointDef.collideConnected, localPulleyJointDef.groundAnchorA.x, localPulleyJointDef.groundAnchorA.y, localPulleyJointDef.groundAnchorB.x, localPulleyJointDef.groundAnchorB.y, localPulleyJointDef.localAnchorA.x, localPulleyJointDef.localAnchorA.y, localPulleyJointDef.localAnchorB.x, localPulleyJointDef.localAnchorB.y, localPulleyJointDef.lengthA, localPulleyJointDef.lengthB, localPulleyJointDef.ratio);
  }
  if (paramJointDef.type == JointDef.JointType.RevoluteJoint)
  {
    RevoluteJointDef localRevoluteJointDef = (RevoluteJointDef)paramJointDef;
    return jniCreateRevoluteJoint(this.addr, localRevoluteJointDef.bodyA.addr, localRevoluteJointDef.bodyB.addr, localRevoluteJointDef.collideConnected, localRevoluteJointDef.localAnchorA.x, localRevoluteJointDef.localAnchorA.y, localRevoluteJointDef.localAnchorB.x, localRevoluteJointDef.localAnchorB.y, localRevoluteJointDef.referenceAngle, localRevoluteJointDef.enableLimit, localRevoluteJointDef.lowerAngle, localRevoluteJointDef.upperAngle, localRevoluteJointDef.enableMotor, localRevoluteJointDef.motorSpeed, localRevoluteJointDef.maxMotorTorque);
  }
  if (paramJointDef.type == JointDef.JointType.WeldJoint)
  {
    WeldJointDef localWeldJointDef = (WeldJointDef)paramJointDef;
    return jniCreateWeldJoint(this.addr, localWeldJointDef.bodyA.addr, localWeldJointDef.bodyB.addr, localWeldJointDef.collideConnected, localWeldJointDef.localAnchorA.x, localWeldJointDef.localAnchorA.y, localWeldJointDef.localAnchorB.x, localWeldJointDef.localAnchorB.y, localWeldJointDef.referenceAngle);
  }
  if (paramJointDef.type == JointDef.JointType.RopeJoint)
  {
    RopeJointDef localRopeJointDef = (RopeJointDef)paramJointDef;
    return jniCreateRopeJoint(this.addr, localRopeJointDef.bodyA.addr, localRopeJointDef.bodyB.addr, localRopeJointDef.collideConnected, localRopeJointDef.localAnchorA.x, localRopeJointDef.localAnchorA.y, localRopeJointDef.localAnchorB.x, localRopeJointDef.localAnchorB.y, localRopeJointDef.maxLength);
  }
  if (paramJointDef.type == JointDef.JointType.WheelJoint)
  {
    WheelJointDef localWheelJointDef = (WheelJointDef)paramJointDef;
    return jniCreateWheelJoint(this.addr, localWheelJointDef.bodyA.addr, localWheelJointDef.bodyB.addr, localWheelJointDef.collideConnected, localWheelJointDef.localAnchorA.x, localWheelJointDef.localAnchorA.y, localWheelJointDef.localAnchorB.x, localWheelJointDef.localAnchorB.y, localWheelJointDef.localAxisA.x, localWheelJointDef.localAxisA.y, localWheelJointDef.enableMotor, localWheelJointDef.maxMotorTorque, localWheelJointDef.motorSpeed, localWheelJointDef.frequencyHz, localWheelJointDef.dampingRatio);
  }
  return 0L;
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:55,代码来源:World.java


注:本文中的com.badlogic.gdx.physics.box2d.joints.WheelJoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。