Example #1
0
  public Wheel(GameManager base, Vector3 location, String type) {
    this.base = base;

    // If there is no wheel constructor, set it up
    if (this.base.world.getConstructor("wheel" + type) == null) {
      modelLoader = new G3dModelLoader(new JsonReader());
      if (type == "bigtruck")
        wheelData =
            modelLoader.loadModelData(
                Gdx.files.internal("data/vehicles/wheels/bigtruckwheel.g3dj"));
      else
        wheelData =
            modelLoader.loadModelData(Gdx.files.internal("data/vehicles/wheels/policewheel.g3dj"));
      wheelModel = new Model(wheelData, new TextureProvider.FileTextureProvider());
      wheelHalfExtents =
          wheelModel.calculateBoundingBox(new BoundingBox()).getDimensions(new Vector3()).scl(0.5f);

      this.base.world.addConstructor("wheel" + type, new BulletConstructor(wheelModel, 0f, null));
      this.base.disposables.add(wheelModel);

      wheel = this.base.world.add("wheel" + type, location.x, location.y, location.z);
    } else {
      wheel = this.base.world.add("wheel" + type, location.x, location.y, location.z);
      wheelHalfExtents =
          wheel
              .modelInstance
              .model
              .calculateBoundingBox(new BoundingBox())
              .getDimensions(new Vector3())
              .scl(0.5f);
    }
  }
Example #2
0
 protected void calculateBoundingBox(final BoundingBox out, final Node node) {
   for (final NodePart mpm : node.parts)
     mpm.meshPart.mesh.calculateBoundingBox(
         out, mpm.meshPart.indexOffset, mpm.meshPart.numVertices, node.globalTransform);
   for (final Node child : node.children) calculateBoundingBox(out, child);
 }
Example #3
0
 /**
  * Extends the bounding box with the bounds of this model instance. This is a potential slow
  * operation, it is advised to cache the result.
  */
 public BoundingBox extendBoundingBox(final BoundingBox out) {
   for (final Node node : nodes) calculateBoundingBox(out, node);
   return out;
 }
Example #4
0
 /** Creates a btBoxShape with the same dimensions as the shape. */
 public BulletConstructor(final Model model, final float mass) {
   final BoundingBox boundingBox = new BoundingBox();
   model.calculateBoundingBox(boundingBox);
   create(model, mass, boundingBox.getWidth(), boundingBox.getHeight(), boundingBox.getDepth());
 }