Example #1
0
 public void drawSphere(int scaleX, int scaleY, int scaleZ, int posX, int posY, int posZ) {
   Vector3f axe = new Vector3f(0, 0, 0);
   axe.x = posX;
   axe.y = posY;
   axe.z = posZ;
   Sphere.drawSphere(false, 0, scaleX, scaleY, scaleZ, axe);
 }
  /**
   * Calculates an intersection with the face of a block defined by 3 points.
   *
   * @param blockPos The position of the block to intersect with
   * @param v0 Point 1
   * @param v1 Point 2
   * @param v2 Point 3
   * @param origin Origin of the intersection ray
   * @param ray Direction of the intersection ray
   * @return Ray-face-intersection
   */
  private static RayBoxIntersection rayFaceIntersection(
      Vector3f blockPos, Vector3f v0, Vector3f v1, Vector3f v2, Vector3f origin, Vector3f ray) {

    // Calculate the plane to intersect with
    Vector3f a = Vector3f.sub(v1, v0, null);
    Vector3f b = Vector3f.sub(v2, v0, null);
    Vector3f norm = Vector3f.cross(a, b, null);

    float d = -(norm.x * v0.x + norm.y * v0.y + norm.z * v0.z);

    /** Calculate the distance on the ray, where the intersection occurs. */
    float t =
        -(norm.x * origin.x + norm.y * origin.y + norm.z * origin.z + d)
            / (Vector3f.dot(ray, norm));

    if (t < 0) {
      return null;
    }

    /** Calc. the point of intersection. */
    Vector3f intersectPoint = VectorPool.getVector(ray.x * t, ray.y * t, ray.z * t);
    Vector3f.add(intersectPoint, origin, intersectPoint);

    if (intersectPoint.x >= v0.x
        && intersectPoint.x <= v2.x
        && intersectPoint.y >= v0.y
        && intersectPoint.y <= v2.y
        && intersectPoint.z >= v0.z
        && intersectPoint.z <= v2.z) {
      return new RayBoxIntersection(blockPos, v0, v1, v2, d, t, origin, ray, intersectPoint);
    }

    return null;
  }
Example #3
0
  /**
   * Transforms position of a block, so that it get's rendered at correct point. If you wish to draw
   * a block at a point, pass it to this method once you have called pushTransformMatrix() and draw
   * it at the result instead
   *
   * @param vec bottom-left corner of the place where you want to draw
   * @param result result is stored here: coordinates that you should use so the rotation matrix
   *     moves it to correct place. Use null to create new vector.
   * @return result
   */
  public Vector3f transform(Vector3f vec, Vector3f result) {
    if (result == null) result = new Vector3f();

    result.set(vec.x + .5f, vec.y + .5f, vec.z + .5f);
    MathUtils.multiplyPos(invertedRotation, result);
    result.set(result.x - .5f, result.y - .5f, result.z - .5f);
    return result;
  }
Example #4
0
 public void fillSphere(
     int texture, int scaleX, int scaleY, int scaleZ, int posX, int posY, int posZ) {
   Vector3f axe = new Vector3f(0, 0, 0);
   axe.x = posX;
   axe.y = posY;
   axe.z = posZ;
   Sphere.drawSphere(true, texture, scaleX, scaleY, scaleZ, axe);
 }
Example #5
0
 private void calculateCameraPosition(float horizDistance, float verticDistance) {
   float theta = player.getRotY() + angleAroundPlayer;
   float offsetX = (float) (horizDistance * Math.sin(Math.toRadians(theta)));
   float offsetZ = (float) (horizDistance * Math.cos(Math.toRadians(theta)));
   position.x = player.getPosition().x - offsetX;
   position.z = player.getPosition().z - offsetZ;
   position.y = player.getPosition().y + verticDistance;
 }
Example #6
0
 public EntityRotator() {
   // System.out.println("Initializer called");
   rotForward.normalise();
   rotUp.normalise();
   Vector3f.cross(rotForward, rotUp, rotRight);
   rotRight.normalise();
   // L.d(rotRight + "");
 }
 public Vector3f getRGB(int x, int y) {
   Vector3f c = new Vector3f();
   int i = x + y * getWidth();
   c.x = (pixels[i] & 0xff0000) >> 16;
   c.y = (pixels[i] & 0xff00) >> 8;
   c.z = (pixels[i] & 0xff);
   return c;
 }
Example #8
0
  public AbstractEntity(Model m) {

    super(m.getBounds());
    this.m = m;
    Vector3f myMin = b.getMin();
    this.origin = new Vector3f(-myMin.getX(), -myMin.getY(), -myMin.getZ());
    this.angle = 0;
  }
Example #9
0
 private void emitParticle(Vector3f center) {
   float dirX = (float) Math.random() * 2f - 1f;
   float dirZ = (float) Math.random() * 2f - 1f;
   Vector3f velocity = new Vector3f(dirX, 1, dirZ);
   velocity.normalise();
   velocity.scale(speed);
   new Particle(new Vector3f(center), velocity, gravityComplient, lifeLength, 0, 1);
 }
Example #10
0
 private Vector3f calculateNormal(int x, int z, BufferedImage image) {
   float heightL = getHeight(x - 1, z, image);
   float heightR = getHeight(x + 1, z, image);
   float heightD = getHeight(x, z - 1, image);
   float heightU = getHeight(x, z + 1, image);
   Vector3f normal = new Vector3f(heightL - heightR, 2f, heightD - heightU);
   normal.normalise();
   return normal;
 }
Example #11
0
  private static Vector3f calculateSpherePoint(float x, float y) {
    Vector3f result = new Vector3f(x, y, 0);

    float sqrZ = 1 - Vector3f.dot(result, result);

    if (sqrZ > 0) result.z = (float) Math.sqrt(sqrZ);
    else result.normalise();

    return result;
  }
Example #12
0
 public void lookThrough() {
   position.setX(position.getX() + velocity.getX());
   position.setY(position.getY() + velocity.getY());
   position.setZ(position.getZ() + velocity.getZ());
   GL11.glRotatef(pitch, 1.0f, 0.0f, 0.0f);
   GL11.glRotatef(yaw, 0.0f, 1.0f, 0.0f);
   GL11.glTranslatef(position.x, position.y, position.z);
 }
Example #13
0
 private void launchSecondPellet() {
   DoublePellet second_pellet = new DoublePellet();
   second_pellet.pos.set(this.pos);
   second_pellet.vel.set(this.vel);
   second_pellet.vel.scale(.5f);
   Vector3f move_forward = this.vel;
   move_forward.normalise();
   move_forward.scale(this.radius * 2 * 2);
   Vector3f.add(second_pellet.pos, move_forward, second_pellet.pos);
   second_pellet.is_first_pellet = false;
   Main.new_pellets_to_add_to_world.add(second_pellet);
 }
Example #14
0
  private void setupLightViewMatrix() {

    viewMatrix = new Matrix4f();

    Matrix4f.rotate((float) (Math.PI / 2), new Vector3f(1, 0, 0), viewMatrix, viewMatrix);

    Matrix4f.translate(
        new Vector3f(
            lightSourcePosition.getX(), -lightSourcePosition.getY(), lightSourcePosition.getZ()),
        viewMatrix,
        viewMatrix);
  }
Example #15
0
  private void setupViewMatrix(boolean reverseY) {

    viewMatrix = new Matrix4f();

    Matrix4f.rotate(
        (reverseY ? -1 : 1) * cameraAngle.getY(), new Vector3f(1, 0, 0), viewMatrix, viewMatrix);

    Matrix4f.rotate(cameraAngle.getX(), new Vector3f(0, 1, 0), viewMatrix, viewMatrix);

    Matrix4f.translate(
        reverseY ? new Vector3f(cameraPos.getX(), -cameraPos.getY(), cameraPos.getZ()) : cameraPos,
        viewMatrix,
        viewMatrix);
  }
Example #16
0
  private void billboardRotation(Camera camera) {
    Matrix4f matrix =
        Maths.createTransformationMatrix(
            new Vector3f(
                camera.getPosition().x,
                camera.getPosition().y + DayNightCycle.getSunY(),
                camera.getPosition().z + DayNightCycle.getSunZ()),
            0,
            0,
            0,
            DayNightCycle.getSunScale());

    Vector3f objToCamProj, objToCam;
    float angleCosine;

    objToCamProj = new Vector3f(0, 0, DayNightCycle.getSunZ());
    /*lookAt = new Vector3f(0,0,1);

    try{
    	objToCamProj.normalise();
    	lookAt.normalise();
    	angleCosine = Vector3f.dot(lookAt, objToCamProj);
    	if((angleCosine < 1f) && (angleCosine > -1f)){
    		if(objToCamProj.x > 0)
    			matrix.rotate((float)(Math.acos(angleCosine)), new Vector3f(0,1,0));
    		else
    			matrix.rotate((float)(Math.acos(angleCosine)), new Vector3f(0,-1,0));
    	}
    }catch(Exception e){

    }*/

    objToCam = new Vector3f(0, -DayNightCycle.getSunY(), -DayNightCycle.getSunZ());

    try {
      objToCamProj.normalise();
      objToCam.normalise();

      angleCosine = Vector3f.dot(objToCamProj, objToCam);
      if ((angleCosine < 1) && (angleCosine > -1)) {
        if (objToCam.y < 0) matrix.rotate((float) (Math.acos(angleCosine)), new Vector3f(1, 0, 0));
        else matrix.rotate((float) (Math.acos(angleCosine)), new Vector3f(-1, 0, 0));
      }
    } catch (Exception e) {

    }

    shader.loadTransformationMatrix(matrix);
  }
Example #17
0
  private void renderModels() {

    Shader.getCurrentShader().setProjectionMatrix(projectionMatrix);
    Shader.getCurrentShader().setViewMatrix(viewMatrix);

    for (int x = -10; x < 10; x += 8) {
      for (int z = -10; z < 10; z += 8) {
        Matrix4f m = new Matrix4f();
        m = m.translate(new Vector3f(x, 0, z));
        m = m.rotate(modelAngle.getY(), new Vector3f(0, 1, 0));
        Shader.getCurrentShader().setModelMatrix(m);
        bunny.draw();
      }
    }

    /*for (int x=-10; x<10; x+=10) {
        for (int z=-10; z<10; z+=10) {
            Matrix4f m=new Matrix4f();
            m=m.translate(new Vector3f(x, 0f, z));
            m=m.rotate(modelAngle.getY()+((x+10)*20+z)*0.1f, new Vector3f(0, 1, 0));
            Shader.getCurrentShader()
                    .setUniformMat4f(Shader.getCurrentShader().modelMatrixUniformId, m);
            bunny.draw();
        }
    }*/

    Shader.getCurrentShader().setModelMatrix(identity);
    terrain.draw();
  }
Example #18
0
 public void drawColorSphere(
     int texture,
     int scaleX,
     int scaleY,
     int scaleZ,
     int posX,
     int posY,
     int posZ,
     float r,
     float g,
     float b) {
   Vector3f axe = new Vector3f(0, 0, 0);
   axe.x = posX;
   axe.y = posY;
   axe.z = posZ;
   Sphere.drawColorSphere(true, texture, scaleX, scaleY, scaleZ, axe, r, g, b);
 }
Example #19
0
  public void lookAt(Vector3f eye, Vector3f at, Vector3f up) {
    Vector3f forward = new Vector3f();
    Vector3f side = new Vector3f();
    Vector3f.sub(at, eye, forward);
    forward.normalise();
    Vector3f.cross(forward, up, side);
    side.normalise();
    Vector3f upCopy = new Vector3f(up);
    Vector3f.cross(side, forward, upCopy);
    getModel().setIdentity();
    getModel().m00 = side.x;
    getModel().m01 = side.y;
    getModel().m02 = side.z;
    getModel().m10 = upCopy.x;
    getModel().m11 = upCopy.y;
    getModel().m12 = upCopy.z;
    getModel().m20 = -forward.x;
    getModel().m21 = -forward.y;
    getModel().m22 = -forward.z;
    getModel().transpose();

    getModel().translate(new Vector3f(-eye.x, -eye.y, -eye.z));
    //        Matrix4f translation = new Matrix4f();
    //        translation.translate((Vector3f) eye.negate());
    //        eye.negate();
    //        Matrix4f.mul(getModel(), translation, getModel());
  }
Example #20
0
  public static void loadDataContainer(
      TerrainDataContainer dest, float[][] map, int x, int y, int size) {
    float[][] harray = new float[size - 2][size - 2];
    float q = Chunk.CHUNK_SIZE / (float) (size - 3);
    int bSize = (size - 2) * (size - 2);
    FloatBuffer vBuff = BufferUtils.createFloatBuffer(bSize * 4);
    FloatBuffer tBuff = BufferUtils.createFloatBuffer(bSize * 2);
    FloatBuffer nBuff = BufferUtils.createFloatBuffer(bSize * 3);
    int iAmount = 6 * (size - 3) * (size - 3);
    IntBuffer iBuff = BufferUtils.createIntBuffer(iAmount);
    for (int pX = 0; pX < size - 2; pX++)
      for (int pZ = 0; pZ < size - 2; pZ++) {
        harray[pX][pZ] = map[x + pX + 1][y + pZ + 1];
        vBuff.put(pX * q);
        vBuff.put(map[x + pX + 1][y + pZ + 1]);
        vBuff.put(pZ * q);
        vBuff.put(1);
        tBuff.put((pX / (float) (size - 3)) * Chunk.TEXTURES);
        tBuff.put((pZ / (float) (size - 3)) * Chunk.TEXTURES);
        float hU = map[x + pX + 1][y + pZ + 2];
        float hD = map[x + pX + 1][y + pZ];
        float hL = map[x + pX][y + pZ + 1];
        float hR = map[x + pX + 2][y + pZ + 1];
        temp.set(hL - hR, 2f, hD - hU);
        temp.normalise(temp);
        nBuff.put(temp.x);
        nBuff.put(temp.y);
        nBuff.put(temp.z);
        if (pX < size - 3 && pZ < size - 3) {
          iBuff.put((pZ + 1) * (size - 2) + pX);
          iBuff.put(pZ * (size - 2) + pX);
          iBuff.put(pZ * (size - 2) + pX + 1);

          iBuff.put((pZ + 1) * (size - 2) + pX + 1);
          iBuff.put((pZ + 1) * (size - 2) + pX);
          iBuff.put(pZ * (size - 2) + pX + 1);
        }
      }
    vBuff.flip();
    tBuff.flip();
    nBuff.flip();
    iBuff.flip();
    dest.load(vBuff, tBuff, nBuff, iBuff, iAmount, q, harray);
  }
Example #21
0
  public void move() {
    if (position.x > direction.x) {
      position.x -= speed * 0.1;

    } else if (position.x < direction.x) {
      position.x += speed * 0.1;
    }

    if (position.z > direction.z) {
      position.z -= speed;
    } else if (position.z < direction.z) {
      position.z += speed;
    }

    model.setPosition(position.x, position.y, position.z);
    model.setRotation(0, 0, 0);
    model.setScaling(scale, scale, scale);
    model.render3D();
  }
Example #22
0
  private Matrix4f getTransform(float mouseX, float mouseY) {
    Preconditions.checkNotNull(dragStart, "Draging not started");
    Vector3f current = calculateSpherePoint(mouseX, mouseY);

    float dot = Vector3f.dot(dragStart, current);
    if (Math.abs(dot - 1) < 0.0001) return lastTransform;

    Vector3f axis = Vector3f.cross(dragStart, current, null);

    try {
      axis.normalise();
    } catch (IllegalStateException e) { // Zero length vector
      return lastTransform;
    }

    float angle = 2 * (float) (Math.acos(dot));

    Matrix4f rotation = new Matrix4f();
    rotation.rotate(angle, axis);
    return Matrix4f.mul(rotation, lastTransform, null);
  }
Example #23
0
  /**
   * Creates rotation matrix accord to current rotation and pushes it into GlStateManager. Don't
   * forget to pop (remove) it once you are done rendering with this rotation.
   */
  public void pushTransformMatrix() {
    GlStateManager.pushMatrix();
    // add operations in reverse order

    // first, rotate forward vector to rotForward
    float angle1 = Vector3f.angle(forward, rotForward);
    MathUtils.cross(forward, rotForward, tmp1);
    tmp1.normalise();

    // rotate up and rotate up
    tmpMatrix.setIdentity();
    tmpMatrix.rotate(angle1, tmp1);
    MathUtils.multiplyVec(tmpMatrix, up, tmp2);

    // L.s("Diff1: " + MathUtils.distanceSquared(up, tmp2));
    // L.s("Diff2: " + MathUtils.distanceSquared(rotUp, tmp3));

    // second, rotate up to rotUp
    float angle2 = Vector3f.angle(tmp2, rotUp);
    // L.s("Angle2: " + angle2);
    if (Math.abs(angle2) < Math.PI) {
      MathUtils.cross(tmp2, rotUp, tmp2);
      tmp2.normalise();
    } else {
      // full 180 degree rotation, use rotForward instead
      tmp2.set(rotForward);
    }
    // L.s("Tmp2: " + tmp2 + ", atan: " + Math.atan2(tmp2.z, tmp2.x) * MathUtils.radToDeg);
    GlStateManager.rotate(angle2 * MathUtils.radToDegF, tmp2.x, tmp2.y, tmp2.z); // */

    GlStateManager.rotate(angle1 * MathUtils.radToDegF, tmp1.x, tmp1.y, tmp1.z); // */

    invertedRotation.setIdentity();
    invertedRotation.rotate(angle2, tmp2);
    invertedRotation.rotate(angle1, tmp1);
    invertedRotation.invert();
  }
 public int doCompare(
     RendererSchematicChunk par1RendererSchematicChunk,
     RendererSchematicChunk par2RendererSchematicChunk) {
   if (par1RendererSchematicChunk.isInFrustrum && !par2RendererSchematicChunk.isInFrustrum) {
     return -1;
   } else if (!par1RendererSchematicChunk.isInFrustrum
       && par2RendererSchematicChunk.isInFrustrum) {
     return 1;
   } else {
     Vector3f position = new Vector3f();
     Vector3f.sub(this.settings.playerPosition, this.settings.offset, position);
     double dist1 = par1RendererSchematicChunk.distanceToPoint(position);
     double dist2 = par2RendererSchematicChunk.distanceToPoint(position);
     return dist1 > dist2 ? 1 : (dist1 < dist2 ? -1 : 0);
   }
 }
Example #25
0
  public void update(float delta, Vector3f emitterPos) {

    lifetime -= delta;
    if (lifetime < 0) {
      return;
    }

    a.set(acceleration);
    a.scale(delta);
    velocity = Vector3f.add(velocity, a, velocity);

    v.set(velocity);
    v.scale(delta);
    position = Vector3f.add(position, v, position);

    verticesBuffer = setupStream(position, emitterPos);
  }
  /*
   * A super messy way to initiate the camera position without gameplay-input (meant to be run exactly once,
   * at the beginning of the loading of a level).
   */
  public void findPlayer() {
    boolean lockNS =
        ResourceManager.MANAGER.playerFocusEntity.cameraLockNS(
            GameMap.MAP, GraphicsManager.MANAGER);
    boolean lockEW =
        ResourceManager.MANAGER.playerFocusEntity.cameraLockEW(
            GameMap.MAP, GraphicsManager.MANAGER);

    int mapHeight =
        GameMap.MAP.mapCanvas.get(ResourceManager.MANAGER.playerFocusEntity.mapLevel).mapHeight
            * GameMap.MAP.tileDimensions;
    int mapWidth =
        GameMap.MAP.mapCanvas.get(ResourceManager.MANAGER.playerFocusEntity.mapLevel).mapWidth
            * GameMap.MAP.tileDimensions;

    int screenHeight = GraphicsManager.MANAGER.getHeight();
    int screenWidth = GraphicsManager.MANAGER.getWidth();

    int top = mapHeight - screenHeight + (GraphicsManager.MANAGER.border * 2); // excess height!
    int right = mapWidth - screenWidth + (GraphicsManager.MANAGER.border * 2);

    setPosition(0, 0, 0);

    if (lockNS) position.y = ResourceManager.MANAGER.playerFocusEntity.position.y;
    else {
      if (ResourceManager.MANAGER.playerFocusEntity.position.y > ((mapHeight / 2) - top / 2))
        position.y = mapHeight / 2 + top / 2;
      else position.y = mapHeight / 2 - top / 2;
    }

    if (lockEW) position.x = ResourceManager.MANAGER.playerFocusEntity.position.x;
    else {
      if (ResourceManager.MANAGER.playerFocusEntity.position.x > ((mapWidth / 2) - right / 2))
        position.x = mapWidth / 2 + right / 2;
      else position.x = mapWidth / 2 - right / 2;
    }
  }
Example #27
0
  public HeightMap(String path, int resolution) {

    heightMap = loadHeightmap(path);

    xScale = 1000f / resolution;
    yScale = 0.08f;
    zScale = 1000f / resolution;

    verticesArray = new Vector3f[width * height];
    vertices = BufferUtils.createFloatBuffer(3 * width * height);
    texCoords = BufferUtils.createFloatBuffer(2 * width * height);
    for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
        final int pos = height * x + y;
        final Vector3f vertex = new Vector3f(xScale * x, yScale * heightMap[x][y], zScale * y);

        verticesArray[pos] = vertex;
        vertex.store(vertices);

        texCoords.put(x / (float) width);
        texCoords.put(y / (float) height);
      }
    }
    vertices.flip();
    texCoords.flip();

    normalsArray = new Vector3f[height * width];
    normals = BufferUtils.createFloatBuffer(3 * width * height);
    final float xzScale = xScale;
    for (int x = 0; x < width; ++x) {
      for (int y = 0; y < height; ++y) {
        final int nextX = x < width - 1 ? x + 1 : x;
        final int prevX = x > 0 ? x - 1 : x;
        float sx = heightMap[nextX][y] - heightMap[prevX][y];
        if (x == 0 || x == width - 1) {
          sx *= 2;
        }

        final int nextY = y < height - 1 ? y + 1 : y;
        final int prevY = y > 0 ? y - 1 : y;
        float sy = heightMap[x][nextY] - heightMap[x][prevY];
        if (y == 0 || y == height - 1) {
          sy *= 2;
        }

        final Vector3f normal =
            new Vector3f(-sx * yScale, 2 * xzScale, sy * yScale).normalise(null);
        normalsArray[height * x + y] = normal;
        normal.store(normals);
      }
    }
    normals.flip();

    indicesArray = new int[7 * (height - 1) * (width - 1)];
    indices = BufferUtils.createIntBuffer(12 * (width - 1) * (height - 1));
    for (int i = 0; i < width - 1; i++) {
      for (int j = 0; j < height - 1; j++) {
        int pos = (height - 1) * i + j;

        indices.put(height * i + j);
        indices.put(height * (i + 1) + j);
        indices.put(height * (i + 1) + (j + 1));

        indices.put(height * i + (j + 1));
        indices.put(height * i + j);
        // indices.put(height * (i + 1) + j);
        indices.put(height * (i + 1) + (j + 1));

        indicesArray[6 * pos] = height * i + j;
        indicesArray[6 * pos + 1] = height * (i + 1) + j;
        indicesArray[6 * pos + 2] = height * (i + 1) + (j + 1);

        // indicesArray[6 * pos + 3] = height * i + (j + 1);

        indices.put(height * i + j);
        indices.put(height * i + (j + 1));
        indices.put(height * (i + 1) + (j + 1));

        indices.put(height * i + (j + 1));
        indices.put(height * i + j);
        // indices.put(height * (i + 1) + j);
        indices.put(height * (i + 1) + (j + 1));

        indicesArray[6 * pos + 4] = height * i + j;
        indicesArray[6 * pos + 5] = height * i + (j + 1);
        indicesArray[6 * pos + 6] = height * (i + 1) + (j + 1);

        // indicesArray[6 * pos + 7] = height * i + (j + 1);

      }
    }
    indices.flip();
  }
Example #28
0
  @Override
  public void update() {
    // constructing means the pellet has triggered something to be built at
    // its sticking location
    if (!constructing) {
      // not constructing means the pellet is still traveling through
      // space

      /*
       * if (Main.timer.getTime() - birthday == 0) { Vector3f back_up =
       * new Vector3f(vel); back_up.scale(-40 * Main.world_scale);
       * Vector3f.add(pos, back_up, pos); }
       */

      // move the pellet
      Vector3f.add(pos, vel, pos);

      // if it's too old, kill it
      if (Main.timer.getTime() - birthday > 2) {
        if (last_good_position == null) {
          alive = false;
        } else {
          constructing = true;
          pos = last_good_position;
          setInPlace();
        }

      } else {
        // if the pellet is not dead yet, see if it intersected anything

        // did it hit a line or plane?
        Vector3f closest_point = queryScaffoldGeometry();

        if (closest_point != null) {
          System.out.println("pellet stuck to some geometry");

          pos.set(closest_point);

          if (is_first_pellet) {
            constructing = true;
            launchSecondPellet();
          } else {
            constructing = true;
          }

        } else if (Main.draw_points) {
          // it didn't hit some existing geometry or pellet
          // so check the point cloud
          int neighbors = queryKdTree(pos.x, pos.y, pos.z, radius);

          // is it near some points?!
          if (neighbors > 0 && is_first_pellet) {
            constructing = true;
            setInPlace();
            launchSecondPellet();
          } else if (neighbors > 0 && !is_first_pellet) {
            last_good_position = new Vector3f(pos);
          }
        }
      }
    } else {
      // the pellet has stuck... here we just give it a nice growing
      // bubble animation
      if (radius < max_radius) {
        radius *= 1.1;
      }
    }
  }
Example #29
0
 public Vertex(int index, Vector3f position) {
   this.index = index;
   this.position = position;
   this.length = position.length();
 }
Example #30
0
 public void reset() {
   rotForward.set(forward);
   rotUp.set(up);
   rotRight.set(right);
 }