Beispiel #1
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);
  }
Beispiel #2
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);
  }
Beispiel #3
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);
  }
Beispiel #4
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);
    }
  }