public AnimationPart(float x, float y, float z, float w, float h, float d) {
   box = new BoundingBox();
   modelMatrix = new Matrix4();
   FloatArray fa = new FloatArray();
   this.x = x;
   this.y = y;
   this.z = z;
   this.w = w;
   this.h = h;
   this.d = d;
   addTopFace(fa, 0, 0, 0, w, h, d);
   addBotFace(fa, 0, 0, 0, w, h, d);
   addLeftFace(fa, 0, 0, 0, w, h, d);
   addRightFace(fa, 0, 0, 0, w, h, d);
   addFrontFace(fa, 0, 0, 0, w, h, d);
   addBackFace(fa, 0, 0, 0, w, h, d);
   if (fa.size > 0) {
     partMesh =
         new Mesh(
             true,
             fa.size,
             0,
             VertexAttributes.position,
             VertexAttributes.normal,
             VertexAttributes.textureCoords);
     partMesh.setVertices(fa.items);
   }
   setTexture(new Texture(Gdx.files.internal("data/grassmap.png")));
   partMesh.calculateBoundingBox(box);
   updateModelMatrix();
 }
 public void updateModelMatrix() {
   modelMatrix.setToTranslation(x, y, z);
   modelMatrix.rotate(1, 0, 0, rotationX);
   modelMatrix.rotate(0, 0, 1, rotationZ);
   modelMatrix.rotate(0, 1, 0, rotationY);
   partMesh.calculateBoundingBox(box);
 }
 public void rebuild() {
   FloatArray fa = new FloatArray();
   addTopFace(fa, 0, 0, 0, w, h, d);
   addBotFace(fa, 0, 0, 0, w, h, d);
   addLeftFace(fa, 0, 0, 0, w, h, d);
   addRightFace(fa, 0, 0, 0, w, h, d);
   addFrontFace(fa, 0, 0, 0, w, h, d);
   addBackFace(fa, 0, 0, 0, w, h, d);
   if (fa.size > 0) {
     partMesh.setVertices(fa.items);
   }
   partMesh.calculateBoundingBox(box);
   updateModelMatrix();
 }
  public AnimationPart(String str) {
    String[] strings = str.split(" ");
    // x,y,z,w,h,d,rotX,rotZ
    name = strings[0];
    x = Float.parseFloat(strings[1]);
    y = Float.parseFloat(strings[2]);
    z = Float.parseFloat(strings[3]);
    w = Float.parseFloat(strings[4]);
    h = Float.parseFloat(strings[5]);
    d = Float.parseFloat(strings[6]);
    rotationX = Float.parseFloat(strings[7]);
    rotationY = Float.parseFloat(strings[8]);
    rotationZ = Float.parseFloat(strings[9]);

    FloatArray fa = new FloatArray();
    modelMatrix = new Matrix4();
    box = new BoundingBox();
    addTopFace(fa, 0, 0, 0, w, h, d);
    addBotFace(fa, 0, 0, 0, w, h, d);
    addLeftFace(fa, 0, 0, 0, w, h, d);
    addRightFace(fa, 0, 0, 0, w, h, d);
    addFrontFace(fa, 0, 0, 0, w, h, d);
    addBackFace(fa, 0, 0, 0, w, h, d);
    if (fa.size > 0) {
      partMesh =
          new Mesh(
              true,
              fa.size,
              0,
              VertexAttributes.position,
              VertexAttributes.normal,
              VertexAttributes.textureCoords);
      partMesh.setVertices(fa.items);
    }
    setTexture(new Texture(Gdx.files.internal("data/grassmap.png")));
    partMesh.calculateBoundingBox(box);
    updateModelMatrix();
  }
Esempio n. 5
0
 public ConstructInfo(final Mesh mesh, final float mass) {
   final BoundingBox boundingBox = mesh.calculateBoundingBox();
   final Vector3 dimensions = boundingBox.getDimensions();
   create(mesh, mass, dimensions.x, dimensions.y, dimensions.z);
 }