예제 #1
0
 private void testDistanceLock1Look2() {
   Vec3 vecLength = Vec3.vec3MinusVec3(look1, look2);
   if (Vec3.lengthVec3(vecLength) < lengthVec3Look) {
     indexLook++;
     if (!isEndVector()) nextVec3Look();
   }
   look1 = Vec3.vec3SummVec3(vecNormalLook, look1);
 }
예제 #2
0
  private void testDistancePos1Pos2() {
    Vec3 vecLength = Vec3.vec3MinusVec3(pos1, pos2);
    if (Vec3.lengthVec3(vecLength) < lengthVec3Pos) {
      indexPos++;
      if (!isEndVector()) nextVec3Pos();
    }

    pos1 = Vec3.vec3SummVec3(vecNormalPos, pos1);
  }
예제 #3
0
 public void moveDown() {
   if (moveType == MoveType.MANUALCONTROL) {
     pos1.y -= speedPos.y;
     if ((pos1.y <= limitYdown) && blimitYdown) {
       pos1.y += speedPos.y;
       return;
     }
     look1.y -= speedPos.y;
   }
 }
예제 #4
0
  public void moveUp() {
    if (moveType == MoveType.MANUALCONTROL) {

      pos1.y += speedPos.y;
      if ((pos1.y >= limitYup) && blimitYup) {
        pos1.y = limitYup;
        return;
      }
      look1.y += speedPos.y;
    }
  }
예제 #5
0
  private void nextVec3Look() {

    if (indexLook + 1 >= vectorLook.size()) return;
    look1 = vectorLook.get(indexLook);
    look2 = vectorLook.get(indexLook + 1);
    Vec3 normalLook2 = Vec3.vec3MinusVec3(look1, look2);
    normalLook2 = Vec3.vec3Normal(normalLook2);
    normalLook2 = Vec3.Vec3MulVec3(normalLook2, speedLook);
    vecNormalLook = new Vec3(normalLook2);
    lengthVec3Look = Vec3.lengthVec3(vecNormalLook);
  }
예제 #6
0
  private void nextVec3Pos() {
    if (indexPos + 1 >= vectorPos.size()) return;
    pos1 = vectorPos.get(indexPos);
    pos2 = vectorPos.get(indexPos + 1);

    Vec3 normalPos2 = Vec3.vec3MinusVec3(pos1, pos2);
    normalPos2 = Vec3.vec3Normal(normalPos2);
    normalPos2 = Vec3.Vec3MulVec3(normalPos2, speedPos);
    vecNormalPos = new Vec3(normalPos2);
    lengthVec3Pos = Vec3.lengthVec3(vecNormalPos);
  }
예제 #7
0
  // Глобальный метод для следующего шага движения
  public void next() {
    switch (moveType) {
      case TRAJECTORY:
        if (isEndVector()) return;
        if (start) {
          nextVec3Look();
          nextVec3Pos();
          start = false;
        }
        testDistancePos1Pos2();
        testDistanceLock1Look2();
        break;

      case CIRCLE_XZ:
        initAngle();
        pos1.x = point.x + radius * (float) Math.cos(angleStart);
        pos1.y = point.y;
        pos1.z = point.z + radius * (float) Math.sin(angleStart);
        ;
        angleStart += angleInc;
        break;

      case CIRCLE_XY:
        initAngle();
        pos1.x = point.x + radius * (float) Math.cos(angleStart);
        pos1.y = point.y + radius * (float) Math.sin(angleStart);
        pos1.z = point.z;
        angleStart += angleInc;
        break;

      case CIRCLE_YZ:
        initAngle();
        pos1.x = point.x;
        pos1.y = point.y + radius * (float) Math.sin(angleStart);
        pos1.z = point.z + radius * (float) Math.cos(angleStart);
        angleStart += angleInc;
        break;

      case MANUALCONTROL:
        break;

      default:
        break;
    }
  }
예제 #8
0
  // Поворот камеры
  private void setAngleLookUp(double angle, boolean right, boolean up) {
    // Получаю вектор куда смотрит камера
    Vec3 localLookCoord = Vec3.vec3MinusVec3(pos1, look1);

    // Определители точки куда смотрит камера в сферической системе координат
    float r, y, o, rXZ;
    // Перевожу из декартовой системы координат в сферическую
    r =
        (float)
            Math.sqrt(
                localLookCoord.x * localLookCoord.x
                    + localLookCoord.y * localLookCoord.y
                    + localLookCoord.z * localLookCoord.z);
    rXZ =
        (float)
            Math.sqrt(localLookCoord.x * localLookCoord.x + localLookCoord.z * localLookCoord.z);
    y = (float) Math.acos(localLookCoord.x / rXZ);
    o = (float) Math.asin(localLookCoord.y / r);

    if (localLookCoord.z > 0) y = 2 * (float) Math.PI - y;

    // Изменяем углы
    if (up) {
      o += angle;
      if (o < 0.1 - Math.PI / 2) o = 0.1f - (float) Math.PI / 2;
      if (o > Math.PI / 2 - 0.1) o = (float) Math.PI / 2 - 0.1f;
    }
    if (right) y += angle;

    // Перевожу из сферической системы координат в декартовою
    localLookCoord.x = (float) (r * Math.cos(o) * Math.cos(y));
    localLookCoord.y = (float) (r * Math.sin(o));
    localLookCoord.z = (float) -(r * Math.cos(o) * Math.sin(y));

    localLookCoord = Vec3.vec3Normal(localLookCoord);

    // Устанавливаю координаты направления взгляда камеры
    look1 = Vec3.vec3SummVec3(pos1, localLookCoord);
  }
예제 #9
0
  // Перемещение камеры в право и в лево
  private void setRightLeftPos(boolean right) {
    Vec3 lengthPosLook = Vec3.vec3MinusVec3(pos1, look1);
    Vec3 newLook = new Vec3(lengthPosLook);
    double angle;
    if (right) angle = -Math.PI / 2;
    else angle = Math.PI / 2;
    float x = newLook.x * (float) Math.cos(angle) - newLook.z * (float) Math.sin(angle);
    newLook.y = 0;
    float z = newLook.x * (float) Math.sin(angle) + newLook.z * (float) Math.cos(angle);
    newLook.x = x;
    newLook.z = z;
    Vec3 normalSpeed = Vec3.vec3Normal(newLook);
    normalSpeed = Vec3.Vec3MulVec3(normalSpeed, speedPos);

    Vec3 vec = Vec3.vec3SummVec3(pos1, normalSpeed);
    if ((vec.y >= limitYup) && blimitYup) normalSpeed.y = 0;
    if ((vec.y <= limitYdown) && blimitYdown) {
      normalSpeed.y = 0;
      float posY = limitYdown - pos1.y;
      pos1.y += posY;
      look1.y += posY;
    }

    pos1 = Vec3.vec3SummVec3(pos1, normalSpeed);
    look1 = Vec3.vec3SummVec3(look1, normalSpeed);
  }
예제 #10
0
  // Перемещение камеры вперед и назад
  private void goForwardBack(boolean forward) {
    Vec3 lengthPosLook = Vec3.vec3MinusVec3(pos1, look1);
    Vec3 normalSpeed = Vec3.vec3Normal(lengthPosLook);
    normalSpeed = Vec3.Vec3MulVec3(normalSpeed, speedPos);
    Vec3 vec = null;

    if (forward) vec = Vec3.vec3SummVec3(pos1, normalSpeed);
    else vec = Vec3.vec3MinusVec3(normalSpeed, pos1);

    if ((vec.y >= limitYup) && blimitYup) normalSpeed.y = 0;
    if ((vec.y <= limitYdown) && blimitYdown) {
      normalSpeed.y = 0;
      float posY = limitYdown - pos1.y;
      pos1.y += posY;
      look1.y += posY;
    }
    if (forward) {
      pos1 = Vec3.vec3SummVec3(pos1, normalSpeed);
      look1 = Vec3.vec3SummVec3(look1, normalSpeed);
    } else {
      pos1 = Vec3.vec3MinusVec3(normalSpeed, pos1);
      look1 = Vec3.vec3MinusVec3(normalSpeed, look1);
    }
  }
예제 #11
0
 public void setYpos2(float y) {
   pos2.y = y;
 }
예제 #12
0
 public void setZ(float z) {
   pos1.z = z;
 }
예제 #13
0
 public void setY(float y) {
   pos1.y = y;
 }
예제 #14
0
 public void setX(float x) {
   pos1.x = x;
 }