Esempio n. 1
0
 private static long attemptTimeParse_1( ValueString str ) {
   final byte[] buf = str.get_buf();
   int i=str.get_off();
   final int end = i+str.get_length();
   while( i < end && buf[i] == ' ' ) i++;
   if   ( i < end && buf[i] == '"' ) i++;
   if( (end-i) < 8 ) return Long.MIN_VALUE;
   int yy=0, MM=0, dd=0;
   dd = digit(dd,buf[i++]);
   if( buf[i] != '-' ) dd = digit(dd,buf[i++]);
   if( dd < 1 || dd > 31 ) return Long.MIN_VALUE;
   if( buf[i++] != '-' ) return Long.MIN_VALUE;
   byte[]mm=null;
   OUTER: for( ; MM<MMS.length; MM++ ) {
     byte[][] mms = MMS[MM];
     INNER: for( int k=0; k<mms.length; k++ ) {
       mm = mms[k];
       if( mm == null ) continue;
       for( int j=0; j<mm.length; j++ )
         if( mm[j] != Character.toLowerCase(buf[i+j]) )
           continue INNER;
       break OUTER;
     }
   }
   if( MM == MMS.length ) return Long.MIN_VALUE; // No matching month
   i += mm.length;             // Skip month bytes
   MM++;                       // 1-based month
   if( buf[i++] != '-' ) return Long.MIN_VALUE;
   yy = digit(yy,buf[i++]);
   yy = digit(yy,buf[i++]);
   yy += 2000;                 // Y2K bug
   if( i<end && buf[i] == '"' ) i++;
   if( i<end ) return Long.MIN_VALUE;
   return new GregorianCalendar(yy,MM,dd).getTimeInMillis();
 }
Esempio n. 2
0
    public void checkLineOfAction(
        ArrayList<Cam> cameras, ArrayList<Character> characters, int selectedIdx) {
      if (cameras == null || cameras.isEmpty()) {
        println("No cameras in the scene!");
      }

      if (characters.size() != 2) {
        println("Only two characters supported for now");
        // TODO (sanjeet): Hack! Fix this once more characters are allowed
      }

      Cam selectedCamera = cameras.get(selectedIdx);

      // TODO The characters.get results in a runtime error because there aren't currently any
      // characters allocated in the input file.
      Character ch1 = characters.get(0);
      Character ch2 = characters.get(1);

      // Obtaining (x,y,z) for characters and selected camera
      PVector ch1Location = ch1.getTranslation();
      PVector ch2Location = ch2.getTranslation();

      line(
          ch1Location.x, ch1Location.y, ch1Location.z, ch2Location.x, ch2Location.y, ch2Location.z);

      PVector selectedCameraLocation = selectedCamera.getTranslation();

      // Iterate through other cameras in the scene and check for line of action rule
      for (int i = 0; i < cameras.size(); i++) {
        if (i == selectedIdx) {
          continue;
        }
        PVector currCamLocation = cameras.get(i).getTranslation();
        if (!isInSameHalfPlane(selectedCameraLocation, currCamLocation, ch1Location, ch2Location)) {
          // If the Selected Camera and current camera are not in the same half plane its a
          // violation
          cameras.get(i).setColor(255, 0, 0);
        } else {
          cameras.get(i).setColor(0, 0, 255);
        }
      }
    }
Esempio n. 3
0
 /** Skip any whitespace. @return @throws Exception */
 int skipWs() throws Exception {
   while (Character.isWhitespace(current())) read();
   return current();
 }
Esempio n. 4
0
    public void checkThirtyDegreeRule(
        ArrayList<Cam> cameras, ArrayList<Character> characters, int selectedIdx) {
      if (cameras == null || cameras.isEmpty()) {
        println("No cameras in the scene!");
      }

      if (characters.size() != 2) {
        println("Only two characters supported for now");
        // TODO (sanjeet): Hack! Fix this once more characters are allowed
      }

      Cam selectedCamera = cameras.get(selectedIdx);

      // TODO The characters.get results in a runtime error because there aren't currently any
      // characters allocated in the input file.
      Character ch1 = characters.get(0);
      Character ch2 = characters.get(1);

      // Obtaining (x,y,z) for characters and selected camera
      PVector ch1Location = ch1.getTranslation();
      PVector ch2Location = ch2.getTranslation();
      PVector selectedCameraLocation = selectedCamera.getTranslation();

      PVector cameraPoint = new PVector();
      cameraPoint.add(selectedCameraLocation);
      for (int i = 0; i < 100; i++) {
        cameraPoint.add(selectedCamera.getZAxis());
      }
      PVector intersection =
          getTwoLinesIntersection(
              new PVector(ch1Location.x, ch1Location.z),
              new PVector(ch2Location.x, ch2Location.z),
              new PVector(selectedCameraLocation.x, selectedCameraLocation.z),
              new PVector(cameraPoint.x, cameraPoint.z));

      PVector diff = PVector.sub(selectedCameraLocation, intersection);
      diff.normalize();
      FloatBuffer fb = selectedCamera.modelViewMatrix;
      float[] mat = fb.array();
      float[] fbMatrix = new float[mat.length];
      for (int i = 0; i < fbMatrix.length; i++) {
        fbMatrix[i] = mat[i];
      }
      fbMatrix[0] = -diff.x;
      fbMatrix[1] = diff.y;
      fbMatrix[2] = -diff.z;
      fbMatrix[9] = diff.x;
      fbMatrix[10] = diff.y;
      fbMatrix[11] = diff.z;
      fbMatrix[13] = intersection.x;
      fbMatrix[14] = intersection.y;
      fbMatrix[15] = intersection.z;
      PMatrix3D matrix = new PMatrix3D();
      matrix.set(fbMatrix);
      matrix.transpose();
      pushMatrix();
      applyMatrix(matrix);
      rotateY(radians(30));
      line(0, 0, 0, 0, 0, 1000);
      rotateY(radians(-2 * 30));
      line(0, 0, 0, 0, 0, 1000);
      popMatrix();

      for (int i = 0; i < cameras.size(); i++) {
        if (i == selectedIdx) {
          continue;
        }

        if (!cameras.get(i).isInView(ch1Location) && !cameras.get(i).isInView(ch2Location)) {
          continue;
        }
        PVector currCamLocation = cameras.get(i).getTranslation();
        PVector vect1 = PVector.sub(currCamLocation, intersection);
        PVector vect2 = PVector.sub(selectedCameraLocation, intersection);
        float dotP = vect1.dot(vect2) / (vect1.mag() * vect2.mag());
        if (acos(dotP) <= PI / 6) {
          cameras.get(i).setColor(255, 0, 0);
        } else {
          cameras.get(i).setColor(0, 0, 255);
        }
      }
    }