/** Called when the tick is finished and collisions need to be resolved and move events fired */
  public void resolve() {
    if (Spout.debugMode()) {
      //	System.out.println("COLLISION DEBUGGING");
      //	System.out.println("Current Collision: " + this.collision.toString());
    }

    List<CollisionVolume> colliding =
        ((SpoutWorld) collisionPoint.getWorld()).getCollidingObject(this.collision);

    Vector3 offset = this.lastTransform.getPosition().subtract(collisionPoint);
    for (CollisionVolume box : colliding) {
      if (Spout.debugMode()) {
        //	System.out.println("Colliding box: " + box.toString());
      }
      Vector3 collision = this.collision.resolve(box);
      if (Spout.debugMode()) {
        //	System.out.println("Collision vector: " + collision.toString());
      }
      if (collision != null) {
        collision = collision.subtract(collisionPoint);
        if (Spout.debugMode()) {
          //	System.out.println("Collision point: " + collision.toString() + " Collision vector: " +
          // collision);
        }

        if (collision.getX() != 0F) {
          offset = new Vector3(collision.getX(), offset.getY(), offset.getZ());
        }
        if (collision.getY() != 0F) {
          offset = new Vector3(offset.getX(), collision.getY(), offset.getZ());
        }
        if (collision.getZ() != 0F) {
          offset = new Vector3(offset.getX(), offset.getY(), collision.getZ());
        }

        if (Spout.debugMode()) {
          //	System.out.println("Collision offset: " + offset.toString());
        }
        if (this.getCollision().getStrategy() == CollisionStrategy.SOLID
            && box.getStrategy() == CollisionStrategy.SOLID) {
          this.setPosition(collisionPoint.add(offset));
          if (Spout.debugMode()) {
            //	System.out.println("New Position: " + this.getPosition());
          }
        }

        controllerLive.get().onCollide(getWorld().getBlock(box.getPosition()));
      }
    }

    // Check to see if we should fire off a Move event
  }
 @Override
 protected Point[] generatePoints(Point center, int number) {
   Vector3f offset = Point.FORWARD.mul(radius);
   int angle = number == 0 ? 0 : (360 / number);
   Matrix3f rotate = Matrix3f.createRotation(Quaternionf.fromAngleDegAxis(angle, 0, 1, 0));
   if (halfRotate) {
     offset =
         Matrix3f.createRotation(Quaternionf.fromAngleDegAxis(angle * 0.5f, 0, 1, 0))
             .transform(offset);
   }
   Point[] points = new Point[number];
   for (int i = 0; i < number; i++) {
     points[i] = center.add(offset);
     offset = rotate.transform(offset);
   }
   return points;
 }
Exemple #3
0
 @Override
 public void onTick(float dt) {
   Point pos = this.getOwner().getTransform().getPosition();
   BlockMaterial material =
       pos.getWorld().getBlockMaterial(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ());
   if (isObstacle(material)) {
     pos.getWorld()
         .setBlockMaterial(
             pos.getBlockX(),
             pos.getBlockY(),
             pos.getBlockZ(),
             getMaterial(),
             getMaterial().getData(),
             getMaterial().toCause(pos));
     this.getOwner().remove();
   } else {
     this.getOwner().getTransform().setPosition(pos.add(0, fallSpeed, 0F));
     fallSpeed = Math.max(-1F, fallSpeed - dt);
   }
 }
  @Override
  public Point[] generatePoints(Point center, int number) {

    float angle = 0;
    float distance = 1;

    Point[] points = new Point[number];

    points[0] = center;

    for (int i = 1; i < number; i++) {
      distance = (float) Math.sqrt(i);

      Vector3 offset = Point.FORWARD.transform(MathHelper.rotateY(angle));
      offset = offset.multiply(distance).multiply(scaleRadius);

      points[i] = center.add(offset);

      angle += scaleCircumference * 360.0 / (Math.PI * distance);
    }

    return points;
  }
 public void offsetPosition(int x, int y, int z) {
   position = position.add(x, y, z);
 }