Esempio n. 1
0
  @Override
  public Vector3 localGetSupportingVertexWithoutMargin(Vector3 vec0, Vector3 out) {
    Stack stack = Stack.enter();
    Vector3 supVec = out;
    supVec.set(0f, 0f, 0f);

    float maxDot = -1e30f;

    Vector3 vec = stack.alloc(vec0);
    float lenSqr = vec.len2();
    if (lenSqr < 0.0001f) {
      vec.set(1f, 0f, 0f);
    } else {
      float rlen = 1f / (float) Math.sqrt(lenSqr);
      vec.scl(rlen);
    }

    Vector3 vtx = stack.allocVector3();
    float newDot;

    float radius = getRadius();

    Vector3 tmp1 = stack.allocVector3();
    Vector3 tmp2 = stack.allocVector3();
    Vector3 pos = stack.allocVector3();

    {
      pos.set(0f, 0f, 0f);
      VectorUtil.setCoord(pos, getUpAxis(), getHalfHeight());

      VectorUtil.mul(tmp1, vec, localScaling);
      tmp1.scl(radius);
      tmp2.set(vec).scl(getMargin());
      vtx.set(pos).add(tmp1);
      vtx.sub(tmp2);
      newDot = vec.dot(vtx);
      if (newDot > maxDot) {
        maxDot = newDot;
        supVec.set(vtx);
      }
    }
    {
      pos.set(0f, 0f, 0f);
      VectorUtil.setCoord(pos, getUpAxis(), -getHalfHeight());

      VectorUtil.mul(tmp1, vec, localScaling);
      tmp1.scl(radius);
      tmp2.set(vec).scl(getMargin());
      vtx.set(pos).add(tmp1);
      vtx.sub(tmp2);
      newDot = vec.dot(vtx);
      if (newDot > maxDot) {
        maxDot = newDot;
        supVec.set(vtx);
      }
    }
    stack.leave();
    return out;
  }
Esempio n. 2
0
 private static Vector3 calcNor(Vector3 v1, Vector3 v2, Vector3 v3) {
   _A = v2.cpy();
   _A.sub(v1);
   _B = v3.cpy();
   _B.sub(v2);
   _n = _A.crs(_B).nor();
   return _n;
 }
  /**
   * 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;
  }
Esempio n. 4
0
 @Override
 public boolean touchDragged(int screenX, int screenY, int pointer) {
   mCurrentPos.set(screenX, screenY, 0);
   camera.unproject(mCurrentPos);
   camera.position.sub(mCurrentPos.sub(mCamPos));
   camera.update();
   return true;
 }
Esempio n. 5
0
 private void updateCamZoom(float newZoom) {
   OrthographicCamera c = cam.camera;
   c.unproject(zTmp1.set(cs.xy.x, cs.xy.y, 0));
   c.zoom = newZoom;
   c.update();
   c.unproject(zTmp2.set(cs.xy.x, cs.xy.y, 0));
   c.translate(zTmp1.sub(zTmp2));
   c.update();
 }
 @Override
 public boolean touchDragged(int x, int y, int pointer) {
   camera.unproject(curr.set(x, y, 0));
   if (!(last.x == -1 && last.y == -1 && last.z == -1)) {
     camera.unproject(delta.set(last.x, last.y, 0));
     delta.sub(curr);
     camera.position.add(delta.x, delta.y, 0);
   }
   last.set(x, y, 0);
   return false;
 }
  @Override
  public boolean touchDragged(int x, int y, int pointer) {
    Ray ray = camera.getPickRay(x, y);
    Intersector.intersectRayPlane(ray, plane, curr);

    if (!(last.x == -1 && last.y == -1 && last.z == -1)) {
      ray = camera.getPickRay(last.x, last.y);
      Intersector.intersectRayPlane(ray, plane, delta);
      delta.sub(curr);
      camera.position.add(delta.x, delta.y, delta.z);
    }
    last.set(x, y, 0);
    return false;
  }
Esempio n. 8
0
 @Override
 public void activate(T target, long curTime) {
   /*
    * Flush cached values via volatile
    */
   targetScale.set(initScale);
   //		System.out.print("Activated NodeScaleProcessor target: " + targetScale + ", scaleTime: " +
   // initTime);
   scaleTime = initTime;
   this.nodeOperator.getNodeData(/*this.nodeOperatorName*/ ).flushScale(scaleSpeed);
   //		System.out.print(", current scale: " + scaleSpeed);
   scaleSpeed.sub(targetScale);
   scaleSpeed.scl(-1f / scaleTime);
   //		System.out.println(", Scale speed: " + scaleSpeed);
   super.activate(target, curTime);
 }