コード例 #1
0
  // $ANTLR start "color"
  // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:112:1: color :
  // TYPE_COLOR ;
  public final RayTracerParser.color_return color() throws RecognitionException {
    RayTracerParser.color_return retval = new RayTracerParser.color_return();
    retval.start = input.LT(1);

    Token TYPE_COLOR5 = null;

    try {
      // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:112:7: (
      // TYPE_COLOR )
      // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:112:9: TYPE_COLOR
      {
        TYPE_COLOR5 = (Token) match(input, TYPE_COLOR, FOLLOW_TYPE_COLOR_in_color265);
        color += (TYPE_COLOR5 != null ? TYPE_COLOR5.getText() : null);
        double[] color1 = new double[3];
        if (color.equals("Yellow")) {
          color1[0] = 1.0;
          color1[1] = 1.0;
          color1[2] = 0.0;
        } else if (color.equals("Blue")) {
          color1[0] = 0.0;
          color1[1] = 0.0;
          color1[2] = 1.0;
        } else if (color.equals("Red")) {
          color1[0] = 1.0;
          color1[1] = 0.0;
          color1[2] = 0.0;
        } else if (color.equals("Green")) {
          color1[0] = 0.0;
          color1[1] = 1.0;
          color1[2] = 0.0;
        } else if (color.equals("White")) {
          color1[0] = 1.0;
          color1[1] = 1.0;
          color1[2] = 1.0;
        }
        color = "";
        switch (typeObject) {
          case 4:
            ligths.add(color1);
            break;
          case 5:
            for (int i = 0; i < 3; i++) {
              ambientLight[i] = color1[i];
            }
            break;
          default:
            break;
        }
      }

      retval.stop = input.LT(-1);

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
    } finally {
    }
    return retval;
  }
コード例 #2
0
  // $ANTLR start "constantLights"
  // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:136:1: constantLights
  // : 'finish' OPEN_BRACKET 'ambient' num0= number 'diffuse' num1= number 'phong' num2= number
  // 'phong_size' num3= number CLOSE_BRACKET ;
  public final void constantLights() throws RecognitionException {
    RayTracerParser.number_return num0 = null;

    RayTracerParser.number_return num1 = null;

    RayTracerParser.number_return num2 = null;

    RayTracerParser.number_return num3 = null;

    try {
      // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:137:2: ( 'finish'
      // OPEN_BRACKET 'ambient' num0= number 'diffuse' num1= number 'phong' num2= number
      // 'phong_size' num3= number CLOSE_BRACKET )
      // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:137:3: 'finish'
      // OPEN_BRACKET 'ambient' num0= number 'diffuse' num1= number 'phong' num2= number
      // 'phong_size' num3= number CLOSE_BRACKET
      {
        flag = true;
        match(input, 25, FOLLOW_25_in_constantLights314);
        match(input, OPEN_BRACKET, FOLLOW_OPEN_BRACKET_in_constantLights316);
        match(input, 26, FOLLOW_26_in_constantLights318);
        pushFollow(FOLLOW_number_in_constantLights322);
        num0 = number();

        state._fsp--;

        match(input, 27, FOLLOW_27_in_constantLights324);
        pushFollow(FOLLOW_number_in_constantLights328);
        num1 = number();

        state._fsp--;

        match(input, 28, FOLLOW_28_in_constantLights330);
        pushFollow(FOLLOW_number_in_constantLights334);
        num2 = number();

        state._fsp--;

        match(input, 29, FOLLOW_29_in_constantLights336);
        pushFollow(FOLLOW_number_in_constantLights340);
        num3 = number();

        state._fsp--;

        match(input, CLOSE_BRACKET, FOLLOW_CLOSE_BRACKET_in_constantLights342);

        double[] temp = new double[4];
        temp[0] =
            Double.valueOf((num0 != null ? input.toString(num0.start, num0.stop) : null))
                .doubleValue();
        temp[1] =
            Double.valueOf((num1 != null ? input.toString(num1.start, num1.stop) : null))
                .doubleValue();
        temp[2] =
            Double.valueOf((num2 != null ? input.toString(num2.start, num2.stop) : null))
                .doubleValue();
        temp[3] =
            Double.valueOf((num3 != null ? input.toString(num3.start, num3.stop) : null))
                .doubleValue();
        switch (typeObject) {
          case 1:
            break;
          case 2:
            spheres.add(temp);
            break;
          case 3:
            break;
          case 4:
            break;
          case 5:
            break;
        }
      }

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
    } finally {
    }
    return;
  }
コード例 #3
0
  // $ANTLR start "pigment"
  // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:62:1: pigment :
  // PIGMENT OPEN_BRACKET COLOR color CLOSE_BRACKET ;
  public final void pigment() throws RecognitionException {
    RayTracerParser.color_return color4 = null;

    try {
      // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:62:9: ( PIGMENT
      // OPEN_BRACKET COLOR color CLOSE_BRACKET )
      // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:62:11: PIGMENT
      // OPEN_BRACKET COLOR color CLOSE_BRACKET
      {
        match(input, PIGMENT, FOLLOW_PIGMENT_in_pigment196);
        match(input, OPEN_BRACKET, FOLLOW_OPEN_BRACKET_in_pigment198);
        match(input, COLOR, FOLLOW_COLOR_in_pigment200);
        pushFollow(FOLLOW_color_in_pigment202);
        color4 = color();

        state._fsp--;

        match(input, CLOSE_BRACKET, FOLLOW_CLOSE_BRACKET_in_pigment204);
        color += (color4 != null ? input.toString(color4.start, color4.stop) : null);
        double[] color1 = new double[3];

        // Para determinar el color
        if (color.equals("Yellow")) {
          color1[0] = 1.0;
          color1[1] = 1.0;
          color1[2] = 0.0;
        } else if (color.equals("Blue")) {
          color1[0] = 0.0;
          color1[1] = 0.0;
          color1[2] = 1.0;
        } else if (color.equals("Red")) {
          color1[0] = 1.0;
          color1[1] = 0.0;
          color1[2] = 0.0;
        } else if (color.equals("Green")) {
          color1[0] = 0.0;
          color1[1] = 1.0;
          color1[2] = 0.0;
        } else if (color.equals("White")) {
          color1[0] = 1.0;
          color1[1] = 1.0;
          color1[2] = 1.0;
        }
        color = "";

        // Para saber a que vector se agrega
        switch (typeObject) {
          case 1:
            break;
          case 2:
            spheres.add(color1);
          case 3:
            break;
          case 4:
            ligths.add(color1);
            break;
        }
      }

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
    } finally {
    }
    return;
  }
コード例 #4
0
  // $ANTLR start "coordenate3D"
  // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:91:1: coordenate3D :
  // LESS_THAN num1= number COMMA num2= number COMMA num3= number GREATER_THAN ;
  public final RayTracerParser.coordenate3D_return coordenate3D() throws RecognitionException {
    RayTracerParser.coordenate3D_return retval = new RayTracerParser.coordenate3D_return();
    retval.start = input.LT(1);

    RayTracerParser.number_return num1 = null;

    RayTracerParser.number_return num2 = null;

    RayTracerParser.number_return num3 = null;

    try {
      // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:92:2: ( LESS_THAN
      // num1= number COMMA num2= number COMMA num3= number GREATER_THAN )
      // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:92:4: LESS_THAN
      // num1= number COMMA num2= number COMMA num3= number GREATER_THAN
      {
        match(input, LESS_THAN, FOLLOW_LESS_THAN_in_coordenate3D216);
        pushFollow(FOLLOW_number_in_coordenate3D220);
        num1 = number();

        state._fsp--;

        match(input, COMMA, FOLLOW_COMMA_in_coordenate3D222);
        pushFollow(FOLLOW_number_in_coordenate3D226);
        num2 = number();

        state._fsp--;

        match(input, COMMA, FOLLOW_COMMA_in_coordenate3D228);
        pushFollow(FOLLOW_number_in_coordenate3D232);
        num3 = number();

        state._fsp--;

        match(input, GREATER_THAN, FOLLOW_GREATER_THAN_in_coordenate3D234);
        double[] temp = new double[3];
        temp[0] =
            Double.valueOf((num1 != null ? input.toString(num1.start, num1.stop) : null))
                .doubleValue();
        temp[1] =
            Double.valueOf((num2 != null ? input.toString(num2.start, num2.stop) : null))
                .doubleValue();
        temp[2] =
            Double.valueOf((num3 != null ? input.toString(num3.start, num3.stop) : null))
                .doubleValue();
        switch (typeObject) {
          case 1:
            break;
          case 2:
            spheres.add(temp);
            break;
          case 3:
            break;
          case 4:
            ligths.add(temp);
            break;
          case 5:
            break;
        }
      }

      retval.stop = input.LT(-1);

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
    } finally {
    }
    return retval;
  }
コード例 #5
0
  // $ANTLR start "sphere"
  // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:34:1: sphere : SPHERE
  // OPEN_BRACKET coordenate3D COMMA number pigment ( constantLights )? CLOSE_BRACKET ;
  public final void sphere() throws RecognitionException {
    RayTracerParser.number_return number1 = null;

    try {
      // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:34:8: ( SPHERE
      // OPEN_BRACKET coordenate3D COMMA number pigment ( constantLights )? CLOSE_BRACKET )
      // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:34:10: SPHERE
      // OPEN_BRACKET coordenate3D COMMA number pigment ( constantLights )? CLOSE_BRACKET
      {
        typeObject = typeSphere;
        flag = false;
        match(input, SPHERE, FOLLOW_SPHERE_in_sphere111);
        match(input, OPEN_BRACKET, FOLLOW_OPEN_BRACKET_in_sphere113);
        pushFollow(FOLLOW_coordenate3D_in_sphere115);
        coordenate3D();

        state._fsp--;

        match(input, COMMA, FOLLOW_COMMA_in_sphere123);
        pushFollow(FOLLOW_number_in_sphere125);
        number1 = number();

        state._fsp--;

        double[] tempRadio = new double[1];
        tempRadio[0] =
            Double.valueOf((number1 != null ? input.toString(number1.start, number1.stop) : null))
                .doubleValue();
        spheres.add(tempRadio);
        /*sphere+= (number1!=null?input.toString(number1.start,number1.stop):null) + ", ";*/
        pushFollow(FOLLOW_pigment_in_sphere133);
        pigment();

        state._fsp--;

        // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:44:11: (
        // constantLights )?
        int alt4 = 2;
        int LA4_0 = input.LA(1);

        if ((LA4_0 == 25)) {
          alt4 = 1;
        }
        switch (alt4) {
          case 1:
            // D:\\Pamela\\Quinto semestre\\Computación  Gráfica\\RayTracer\\RayTracer.g:44:12:
            // constantLights
            {
              pushFollow(FOLLOW_constantLights_in_sphere136);
              constantLights();

              state._fsp--;
            }
            break;
        }

        match(input, CLOSE_BRACKET, FOLLOW_CLOSE_BRACKET_in_sphere140);
        if (!flag) {
          double[] temp = new double[4];
          temp[0] = 0.1;
          temp[1] = 0.7;
          temp[2] = 0.7;
          temp[3] = 20.0;
          spheres.add(temp);
        }
      }

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
    } finally {
    }
    return;
  }