Exemplo n.º 1
0
  public void new_scene(String content) {
    int pos, begin_pos;
    String vrml_camera;

    vrml_camera = null;

    begin_pos = content.indexOf("DEF World");
    if (begin_pos > 0) // ViewPoint message present
    {
      pos = content.indexOf('}');
      vrml_camera = content.substring(begin_pos, pos + 1);
      // content = content.substring(pos+1);
    }
    replace_scene(content);
    if (vrml_camera != null) plug_in.set_viewpoint(vrml_camera);
    plug_in.bind_view();
  }
Exemplo n.º 2
0
  public void set_viewpoint(String view) {
    String position;
    String[] position_el;
    String orientation;
    String[] orientation_el;
    String fieldOfView;
    int begin_pos, pos, i;
    Float tmp_f;
    float[] pos_val = null;
    float[] or_val = null;
    float fv_val = -1;

    // user_interface.addInfo(view);
    begin_pos = view.indexOf("position");
    if (begin_pos > 0) {
      position_el = new String[4];
      pos_val = new float[3];
      position = view.substring(begin_pos);
      begin_pos = 0;
      // user_interface.addInfo("\n position_el: ");
      pos = position.indexOf('\t', begin_pos);
      // position_el[0] = position.substring(begin_pos,pos);
      // user_interface.addInfo(position_el[0]);
      // user_interface.addInfo("|");
      begin_pos = pos + 1;
      for (i = 0; i < 3; i++) {
        pos = position.indexOf(" ", begin_pos);
        position_el[i] = position.substring(begin_pos, pos);
        tmp_f = Float.valueOf(position_el[i]);
        pos_val[i] = tmp_f.floatValue();
        // user_interface.addInfo(pos_val[i]);
        // user_interface.addInfo("|");
        begin_pos = pos + 1;
      }
    }
    begin_pos = view.indexOf("orientation");
    if (begin_pos > 0) {
      orientation_el = new String[5];
      or_val = new float[4];
      orientation = view.substring(begin_pos);
      begin_pos = 0;
      // user_interface.addInfo("\n orientation_el: ");
      pos = orientation.indexOf('\t', begin_pos);
      // orientation_el[0] = orientation.substring(begin_pos,pos);
      // user_interface.addInfo(orientation_el[0]);
      // user_interface.addInfo("|");
      begin_pos = pos + 1;
      for (i = 0; i < 3; i++) {
        pos = orientation.indexOf(" ", begin_pos);
        orientation_el[i] = orientation.substring(begin_pos, pos);
        tmp_f = Float.valueOf(orientation_el[i]);
        or_val[i] = tmp_f.floatValue();
        // user_interface.addInfo(or_val[i]);
        // user_interface.addInfo("|");
        begin_pos = pos + 1;
      }
      pos = orientation.indexOf(" ", begin_pos + 1);
      orientation_el[3] = orientation.substring(begin_pos, pos);
      tmp_f = Float.valueOf(orientation_el[3]);
      or_val[3] = tmp_f.floatValue();
      // user_interface.addInfo(or_val[3]);
      // user_interface.addInfo("|");
      begin_pos = pos + 1;
    }
    begin_pos = view.indexOf("fieldOf");
    if (begin_pos > 0) {
      fieldOfView = view.substring(begin_pos);
      begin_pos = fieldOfView.indexOf(" ");
      pos = fieldOfView.indexOf(" ", begin_pos + 1);
      tmp_f = Float.valueOf(fieldOfView.substring(begin_pos, pos));
      fv_val = tmp_f.floatValue();
      // user_interface.addInfo("\nfieldOfView = ");
      // user_interface.addInfo(fv_val);
      // user_interface.addInfo("|\n");
    }
    // user_interface.addInfo("\n======================\n");
    plug_in.set_viewpoint(pos_val, or_val, fv_val);
  }