public void computeBoundaries() {
    min.set(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
    max.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);

    for (CubeVertex vert : verts) {

      // x coord
      if (vert.getPosition()[0] < min.x) {
        min.x = vert.getPosition()[0];
      } else if (vert.getPosition()[0] > max.x) {
        max.x = vert.getPosition()[0];
      }

      // y coord
      if (vert.getPosition()[1] < min.y) {
        min.y = vert.getPosition()[1];
      } else if (vert.getPosition()[1] > max.y) {
        max.y = vert.getPosition()[1];
      }

      // z coord
      if (vert.getPosition()[2] < min.z) {
        min.z = vert.getPosition()[2];
      } else if (vert.getPosition()[2] > max.z) {
        max.z = vert.getPosition()[2];
      }
    }

    mean.set((max.x + min.x) / 2f, (max.y + min.y) / 2f, (max.z + min.z) / 2f);
    center.set(min.x + mean.x, min.y + mean.y, min.z + mean.z);
  }
  @Override
  public void getAabb(Transform t, Vector3 aabbMin, Vector3 aabbMax) {
    Stack stack = Stack.enter();
    Vector3 tmp = stack.allocVector3();

    Vector3 halfExtents = stack.allocVector3();
    halfExtents.set(getRadius(), getRadius(), getRadius());
    VectorUtil.setCoord(halfExtents, upAxis, getRadius() + getHalfHeight());

    halfExtents.x += getMargin();
    halfExtents.y += getMargin();
    halfExtents.z += getMargin();

    Matrix3 abs_b = stack.allocMatrix3();
    abs_b.set(t.basis);
    MatrixUtil.absolute(abs_b);

    Vector3 center = t.origin;
    Vector3 extent = stack.allocVector3();

    MatrixUtil.getRow(abs_b, 0, tmp);
    extent.x = tmp.dot(halfExtents);
    MatrixUtil.getRow(abs_b, 1, tmp);
    extent.y = tmp.dot(halfExtents);
    MatrixUtil.getRow(abs_b, 2, tmp);
    extent.z = tmp.dot(halfExtents);

    aabbMin.set(center).sub(extent);
    aabbMax.set(center).add(extent);
    stack.leave();
  }
 @Override
 public void read(Json json, JsonValue jsonData) {
   position.x = jsonData.getFloat(JsonKey.X);
   position.y = jsonData.getFloat(JsonKey.Y);
   position.z = jsonData.getFloat(JsonKey.Z);
   eulerAngles.x = jsonData.getFloat(JsonKey.YAW);
   eulerAngles.y = jsonData.getFloat(JsonKey.PITCH);
   eulerAngles.z = jsonData.getFloat(JsonKey.ROLL);
 }
  @Override
  public void calculateLocalInertia(float mass, Vector3 inertia) {
    // as an approximation, take the inertia of the box that bounds the spheres

    Stack stack = Stack.enter();
    Transform ident = stack.allocTransform();
    ident.setIdentity();

    float radius = getRadius();

    Vector3 halfExtents = stack.allocVector3();
    halfExtents.set(radius, radius, radius);
    VectorUtil.setCoord(halfExtents, getUpAxis(), radius + getHalfHeight());

    float margin = BulletGlobals.CONVEX_DISTANCE_MARGIN;

    float lx = 2f * (halfExtents.x + margin);
    float ly = 2f * (halfExtents.y + margin);
    float lz = 2f * (halfExtents.z + margin);
    float x2 = lx * lx;
    float y2 = ly * ly;
    float z2 = lz * lz;
    float scaledmass = mass * 0.08333333f;

    inertia.x = scaledmass * (y2 + z2);
    inertia.y = scaledmass * (x2 + z2);
    inertia.z = scaledmass * (x2 + y2);
    stack.leave();
  }
Exemple #5
0
  private void cameraUpdate(float delta) {
    Vector3 position = camera.position;
    position.x = player.getPosition().x * PPM;
    position.y = player.getPosition().y * PPM;
    camera.position.set(position);

    camera.update();
  }
  /**
   * Returns triangle normal
   *
   * @param v1 point of triangle
   * @param v2 point of triangle
   * @param v3 point of triangle
   * @return normal to triangle
   */
  protected Vector3 Triangle3DCalculateSurfaceNormal(Vector3 v1, Vector3 v2, Vector3 v3) {
    Vector3 u = v2.sub(v1);
    Vector3 v = v3.sub(v1);

    Vector3 ret = new Vector3();
    ret.x = (u.y * v.z) - (u.z * v.y);
    ret.y = (u.z * v.x) - (u.x * v.z);
    ret.z = (u.x * v.y) - (u.y * v.x);
    return ret;
  }
 private void checkFinish() {
   this.nodeOperator.getNodeData(/*this.nodeOperatorName*/ ).flushScale(helpV);
   if (checkSingleOrth(helpV.x, targetScale.x, scaleSpeed.x)
       || checkSingleOrth(helpV.y, targetScale.y, scaleSpeed.y)
       || checkSingleOrth(helpV.z, targetScale.z, scaleSpeed.z)) {
     helpV.x = targetScale.x / helpV.x;
     helpV.y = targetScale.y / helpV.y;
     helpV.z = targetScale.z / helpV.z;
     this.nodeOperator.scale(helpV);
     finish = true;
   }
 }
  public void render() {

    logger.log();

    final float delta = Gdx.graphics.getDeltaTime();
    camController.update(delta);

    timer += delta;
    for (int i = 0; i < lightManager.pointLights.size; i++) {
      final Vector3 v = lightManager.pointLights.get(i).position;
      v.x += MathUtils.sin(timer) * 0.01f;
      v.z += MathUtils.cos(timer) * 0.01f;
      lightManager.pointLights.get(i).color.b = MathUtils.sin(timer) * 0.25f + 0.25f;
    }

    animInstance.time += delta;
    if (Gdx.input.justTouched()) {
      currAnimIdx++;
      if (currAnimIdx == model3.getAnimations().length) currAnimIdx = 0;
      animInstance.animation = model3.getAnimations()[currAnimIdx].name;
      animInstance.time = 0;
    }
    if (animInstance.time > model3.getAnimations()[currAnimIdx].totalDuration) {
      animInstance.time = 0;
    }

    Gdx.gl.glEnable(GL10.GL_CULL_FACE);
    Gdx.gl.glFrontFace(GL10.GL_CCW);
    Gdx.gl.glCullFace(GL10.GL_FRONT);

    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);
    Gdx.gl.glDepthMask(true);

    Gdx.gl.glClearColor(0, 0.1f, 0.2f, 0);
    Gdx.gl.glClear(
        GL10.GL_COLOR_BUFFER_BIT
            | GL10.GL_DEPTH_BUFFER_BIT
            | (Gdx.graphics.getBufferFormat().coverageSampling
                ? GL20.GL_COVERAGE_BUFFER_BIT_NV
                : 0));

    protoRenderer.begin();

    protoRenderer.draw(model3, animInstance);

    protoRenderer.end();
    Gdx.gl.glCullFace(GL10.GL_BACK);
    protoRenderer.begin();
    protoRenderer.draw(model, instance);
    protoRenderer.draw(model, instance2);
    protoRenderer.draw(model2, instance2);
    protoRenderer.end();
  }
 public void act(float delta) {
   super.act(delta);
   offset.x -= (delta / transition.getTime()) * 1600;
   if (nextScene != null) {
     nextScene.setY(0);
     nextScene.setX(0);
     remainingTime -= game.getSkippedMilliseconds();
     if (remainingTime <= 0) {
       nextScene.setVisible(true);
       super.finish();
     }
   }
 }
 @Override
 public void doJob(T target, long processTime) {
   long diffTime = processTime - this.lastCheckTime;
   if (diffTime > 20) {
     this.nodeOperator.getNodeData(/*this.nodeOperatorName*/ ).flushScale(helpV);
     helpV.x = 1f + (scaleSpeed.x * diffTime) / helpV.x;
     helpV.y = 1f + (scaleSpeed.y * diffTime) / helpV.y;
     helpV.z = 1f + (scaleSpeed.z * diffTime) / helpV.z;
     this.nodeOperator.scale(helpV);
     this.lastCheckTime += diffTime;
     checkFinish();
     this.nodeOperator.updatePrint();
     this.subject.adjustCurrentPrint();
   }
 }
Exemple #11
0
  /**
   * Updates the clipping plane's based on the given inverse combined projection and view matrix,
   * e.g. from an {@link OrthographicCamera} or {@link PerspectiveCamera}.
   *
   * @param inverseProjectionView the combined projection and view matrices.
   */
  public void update(Matrix4 inverseProjectionView) {
    System.arraycopy(
        clipSpacePlanePointsArray, 0, planePointsArray, 0, clipSpacePlanePointsArray.length);
    Matrix4.prj(inverseProjectionView.val, planePointsArray, 0, 8, 3);
    for (int i = 0, j = 0; i < 8; i++) {
      Vector3 v = planePoints[i];
      v.x = planePointsArray[j++];
      v.y = planePointsArray[j++];
      v.z = planePointsArray[j++];
    }

    planes[0].set(planePoints[1], planePoints[0], planePoints[2]);
    planes[1].set(planePoints[4], planePoints[5], planePoints[7]);
    planes[2].set(planePoints[0], planePoints[4], planePoints[3]);
    planes[3].set(planePoints[5], planePoints[1], planePoints[6]);
    planes[4].set(planePoints[2], planePoints[3], planePoints[6]);
    planes[5].set(planePoints[4], planePoints[0], planePoints[1]);
  }
Exemple #12
0
 public static void ToObjectVector(Vector3 v, float[] tmp) {
   v.x = tmp[0];
   v.y = tmp[1];
   v.z = tmp[2];
 }