public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    BasicShapeAttributes that = (BasicShapeAttributes) o;

    if (drawOutline != that.drawOutline) return false;
    if (drawInterior != that.drawInterior) return false;
    if (enableAntialiasing != that.enableAntialiasing) return false;
    if (Double.compare(that.outlineOpacity, outlineOpacity) != 0) return false;
    if (Double.compare(that.interiorOpacity, interiorOpacity) != 0) return false;
    if (Double.compare(that.outlineWidth, outlineWidth) != 0) return false;
    if (that.outlineStippleFactor != outlineStippleFactor) return false;
    if (that.outlineStipplePattern != outlineStipplePattern) return false;
    if (interiorMaterial != null
        ? !interiorMaterial.equals(that.interiorMaterial)
        : that.interiorMaterial != null) return false;
    if (outlineMaterial != null
        ? !outlineMaterial.equals(that.outlineMaterial)
        : that.outlineMaterial != null) return false;
    if (interiorImageSource != null
        ? !interiorImageSource.equals(that.interiorImageSource)
        : that.interiorImageSource != null) return false;
    //noinspection RedundantIfStatement
    if (Double.compare(that.interiorImageScale, interiorImageScale) != 0) return false;

    return true;
  }
Beispiel #2
0
  public static void newSpec() {
    List<Material> materials = Material.findAll();
    String username = session.get("username");
    if (username != null) {

      User user = User.getByUserName(username);
      if (user.role.name.equalsIgnoreCase("operator")) {
        materials = user.materials;
      }
    }
    render(materials);
  }
Beispiel #3
0
  public static void editSpec(Long id) {
    Specification spec = null;
    if (id != null) spec = Specification.findById(id);
    List<Material> materials = Material.findAll();
    String username = session.get("username");
    if (username != null) {

      User user = User.getByUserName(username);
      if (user.role.name.equalsIgnoreCase("operator")) {
        materials = user.materials;
      }
    }
    render(spec, materials);
  }
 public int hashCode() {
   int result;
   long temp;
   result = (drawInterior ? 1 : 0);
   result = 31 * result + (drawOutline ? 1 : 0);
   result = 31 * result + (enableAntialiasing ? 1 : 0);
   result = 31 * result + (interiorMaterial != null ? interiorMaterial.hashCode() : 0);
   result = 31 * result + (outlineMaterial != null ? outlineMaterial.hashCode() : 0);
   temp = interiorOpacity != +0.0d ? Double.doubleToLongBits(interiorOpacity) : 0L;
   result = 31 * result + (int) (temp ^ (temp >>> 32));
   temp = outlineOpacity != +0.0d ? Double.doubleToLongBits(outlineOpacity) : 0L;
   result = 31 * result + (int) (temp ^ (temp >>> 32));
   temp = outlineWidth != +0.0d ? Double.doubleToLongBits(outlineWidth) : 0L;
   result = 31 * result + (int) (temp ^ (temp >>> 32));
   temp = outlineStippleFactor;
   result = 31 * result + (int) (temp ^ (temp >>> 32));
   temp = outlineStipplePattern;
   result = 31 * result + (int) (temp ^ (temp >>> 32));
   result = 31 * result + (interiorImageSource != null ? interiorImageSource.hashCode() : 0);
   temp = Double.doubleToLongBits(interiorImageScale);
   result = 31 * result + (int) (temp ^ (temp >>> 32));
   return result;
 }
 @Override
 public ItemStack getItemStack(final String path) {
   final ItemStack stack =
       new ItemStack(
           Material.valueOf(getString(path + ".type", "AIR")),
           getInt(path + ".amount", 1),
           (short) getInt(path + ".damage", 0));
   final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
   if (enchants != null) {
     for (String enchant : enchants.getKeys(false)) {
       final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
       if (enchantment == null) {
         continue;
       }
       final int level = getInt(path + ".enchant." + enchant, enchantment.getStartLevel());
       stack.addUnsafeEnchantment(enchantment, level);
     }
   }
   return stack;
   /*
    * ,
    * (byte)getInt(path + ".data", 0)
    */
 }
  public VehiclesConfiguration(Configuration cfg, File dataFolder) {
    this.dataFolder = dataFolder;

    matBoostMax = Material.getMaterial(cfg.getInt("max-boost-block", 41));
    matBoost25x = Material.getMaterial(cfg.getInt("25x-boost-block", 14));
    matSlow50x = Material.getMaterial(cfg.getInt("50x-slow-block", 88));
    matSlow20x = Material.getMaterial(cfg.getInt("20x-slow-block", 13));
    matReverse = Material.getMaterial(cfg.getInt("reverse-block", 35));
    matStation = Material.getMaterial(cfg.getInt("station-block", 49));
    matSorter = Material.getMaterial(cfg.getInt("sort-block", 87));
    matEjector = Material.getMaterial(cfg.getInt("eject-block", 42));
    matDeposit = Material.getMaterial(cfg.getInt("deposit-block", 15));
    matTeleport = Material.getMaterial(cfg.getInt("teleport-block", 89));
    matDispenser =
        Material.getMaterial(54); // this can't be configurable because we need it to be a chest!

    minecartSlowWhenEmpty = cfg.getBoolean("minecart-slow-when-empty", true);
    minecartMaxSpeedModifier = cfg.getDouble("minecart-max-speed-modifier", 1);
  }
Beispiel #7
0
  public static void register() {

    List<Material> materialList = Material.findAll();
    render(materialList);
  }
Beispiel #8
0
  public static void imp(File file) {
    String result = "";
    String profiles = "";
    int imported = 0;
    int missed = 0;

    if (file != null) {

      Config config = Config.find("1=1").first();

      FileInputStream fileInputStream = null;
      HSSFWorkbook workbook = null;
      try {
        fileInputStream = new FileInputStream(file);
        workbook = new HSSFWorkbook(fileInputStream);
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }

      Profile profile = null;
      User user = null;
      String value = "";
      Material material = null;

      SendMessage m = new SendMessage();
      for (int x = 0; x < workbook.getNumberOfSheets(); x++) {

        HSSFSheet worksheet = workbook.getSheetAt(x);
        HSSFRow row = null;
        HSSFCell cell = null;
        DecimalFormat df = new DecimalFormat("#");
        df.setMaximumFractionDigits(0);

        for (int i = 1; i < worksheet.getLastRowNum(); i++) {
          String unit = "万元";
          String business = "0";
          try {
            row = worksheet.getRow(i);
            if (row.getLastCellNum() < 22) {
              continue;
            }
            cell = row.getCell(0);
            value = cell.getStringCellValue();
            user = User.find("username=?", value).first();
            if (user == null) {
              user = new User(value, getRandomPwd(), ApplicationRole.getByName("user"));
              user.save();
            }

            profile = Profile.find("user.id=?", user.id).first();
            if (profile == null) {
              profile = new Profile();
              profile.user = user;
            }

            profile.is_audit = 1;
            cell = row.getCell(1);
            value = cell.getStringCellValue();
            profile.name = value;

            cell = row.getCell(2);
            value = cell.getStringCellValue();
            material = Material.find("name=?", value).first();
            if (material == null) {
              material = new Material();
              material.name = value;
              material.save();
            }
            if (!profile.materials.contains(material)) profile.materials.add(material);

            cell = row.getCell(3);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }

            cell = row.getCell(4);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }

            cell = row.getCell(5);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.registration_number = value;

            cell = row.getCell(6);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              df.setMaximumFractionDigits(2);
              value = String.valueOf(df.format(cell.getNumericCellValue()));
            } else {
              value = cell.getStringCellValue();
            }
            if (value.contains("美元")) {
              value = value.replace("(美元)", "").trim();
              unit = "万美元";
            }
            profile.registration_assets = value;
            profile.registration_assets_unit = unit;

            df.setMaximumFractionDigits(0);
            cell = row.getCell(7);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.registration_address = value;

            cell = row.getCell(8);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.bank_name = value;

            cell = row.getCell(9);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.account_name = value;

            cell = row.getCell(10);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.tfn = value;

            cell = row.getCell(11);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.factory_name = value;

            cell = row.getCell(12);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.factory_address = value;

            cell = row.getCell(13);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(df.format(cell.getNumericCellValue()));
            } else {
              value = cell.getStringCellValue();
            }
            profile.first_supply = value.replaceAll("年", "");

            cell = row.getCell(14);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.legal_person = value;

            cell = row.getCell(15);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.contact_name = value;

            cell = row.getCell(16);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.contact_job = value;

            cell = row.getCell(17);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(df.format(cell.getNumericCellValue()));
            } else {
              value = cell.getStringCellValue();
            }
            profile.contact_phone = value;

            cell = row.getCell(18);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.sales_name = value;

            cell = row.getCell(19);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            profile.sales_job = value;

            cell = row.getCell(20);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(df.format(cell.getNumericCellValue()));
            } else {
              value = cell.getStringCellValue();
            }
            profile.sales_phone = value;

            cell = row.getCell(21);
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            if (value.equals("自营")) {
              business = "1";
            } else if (value.equals("经销")) {
              business = "2";
            } else if (value.equals("挂靠")) {
              business = "3";
            } else {
              business = "0";
            }
            profile.business_model = business;
            profile.save();
            imported += 1;

            if (profile.contact_phone != null) {
              String message =
                  "您的信息已导入,用户名:" + user.username + ",密码:" + user.password + ",请登录比价平台上传资质文件";
              if (config.msg_import != null && !"".equals(config.msg_import)) {
                message =
                    config
                        .msg_import
                        .replace("{username}", user.username)
                        .replace("{passowrd}", user.password);
              }
              m.sendSms(profile.contact_phone, message, "0000001");
              if (profile.contact_email != null && !"".equals(profile.contact_phone)) {
                m.sendMail(
                    profile.contact_email,
                    "[" + Messages.get("application.name") + "]信息导入",
                    message);
              }
            }
          } catch (Exception e) {
            missed += 1;
            if (!"".equals(profiles)) {
              profiles += "," + profile.name;
            } else {
              profiles += profile.name;
            }
            e.printStackTrace();
          }
        }
      }

      result = "成功导入" + imported + "条记录,丢失" + missed + "条记录。";
      if (!"".equals(profiles)) {
        result += "丢失导入的供应商为:" + profiles;
      }
    }
    redirect("/admin/profiles?result=" + URLEncoder.encode(result));
  }
Beispiel #9
0
  public static void impSpec(File file) {
    if (file != null) {
      List<Specification> specifications = new ArrayList<Specification>();
      Specification spec = null;
      Material material = null;
      try {
        FileInputStream fileInputStream = new FileInputStream(file);
        HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);
        HSSFSheet worksheet = workbook.getSheetAt(0);
        HSSFRow row = null;
        HSSFCell cell = null;
        Map<Integer, String> headerMap = new HashMap<Integer, String>();
        Prop prop = null;
        if (worksheet.getLastRowNum() > 0) {
          row = worksheet.getRow(0);
          for (int i = 0; i < row.getLastCellNum(); i++) {
            headerMap.put(Integer.valueOf(i), row.getCell(i).getStringCellValue());
          }
        }
        for (int i = 1; i < worksheet.getLastRowNum(); i++) {
          row = worksheet.getRow(i);
          cell = row.getCell(0);
          String materialName = cell.getStringCellValue();

          cell = row.getCell(1);
          String specification = cell.getStringCellValue();

          cell = row.getCell(2);
          Double number = cell.getNumericCellValue();

          cell = row.getCell(3);
          String unit = cell.getStringCellValue();

          cell = row.getCell(4);
          String company = cell.getStringCellValue();

          cell = row.getCell(5);
          Date date = cell.getDateCellValue();

          cell = row.getCell(6);
          String description = cell.getStringCellValue();

          spec = new Specification();

          for (int x = 7; x < row.getLastCellNum(); x++) {
            cell = row.getCell(x);
            String value = "";
            if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
              value = String.valueOf(cell.getNumericCellValue());
            } else {
              value = cell.getStringCellValue();
            }
            prop = new Prop();
            prop.name = headerMap.get(x);
            prop.value = value;
            prop.save();
            spec.properties.add(prop);
          }

          spec.name = specification;
          spec.specification = specification;
          if (number != null && !"".equals(number)) spec.amount = number;
          spec.unit = unit;
          spec.company = company;
          if (materialName != null && !"".equals(materialName)) {
            material = Material.find("name=?", materialName.trim()).first();
            spec.material = material;
          }
          spec.arrival_time = date;
          spec.description = description;
          spec.save();
          specifications.add(spec);
        }

        renderJSON(specifications);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Beispiel #10
0
  public static void save() throws Throwable {
    String username = params.get("username");
    String name = params.get("name");
    String password = params.get("password");
    String[] materials = params.getAll("material");
    String registration_number = params.get("registration_number");
    String registration_assets = params.get("registration_assets");
    String registration_assets_unit = params.get("registration_assets_unit");
    String registration_address = params.get("registration_address");
    String bank_name = params.get("bank_name");
    String account_name = params.get("account_name");
    String tfn = params.get("tfn");
    String legal_person = params.get("legal_person");
    String factory_name = params.get("factory_name");
    String factory_address = params.get("factory_address");
    String first_supply = params.get("first_supply");
    String business_model = params.get("business_model");
    String contact_name = params.get("contact_name");
    String contact_job = params.get("contact_job");
    String contact_phone = params.get("contact_phone");
    String contact_email = params.get("contact_email");
    String sales_name = params.get("sales_name");
    String sales_job = params.get("sales_job");
    String sales_phone = params.get("sales_phone");
    String[] files = params.getAll("files");

    User user = null;
    Material m = null;
    Files file = null;
    if (username != null && password != null && !"".equals(username) && !"".equals(password)) {
      user = User.find("username=?", username).first();
      if (user == null) {
        user = new User(username, password, ApplicationRole.getByName("user"));
        user.save();
      }

      Profile profile = Profile.find("user.id=?", user.id).first();
      if (profile == null) {
        profile = new Profile();
        profile.user = user;
      }

      if (materials != null) {
        for (String material_id : materials) {
          m = Material.find("id=?", Long.valueOf(material_id.trim())).first();
          if (m != null) profile.materials.add(m);
        }
      }
      profile.name = name;
      profile.registration_number = registration_number;
      profile.registration_assets = registration_assets;
      profile.registration_address = registration_address;
      profile.registration_assets_unit = registration_assets_unit;
      profile.bank_name = bank_name;
      profile.account_name = account_name;
      profile.tfn = tfn;
      profile.legal_person = legal_person;
      profile.factory_name = factory_name;
      profile.factory_address = factory_address;
      profile.first_supply = first_supply;
      profile.business_model = business_model;
      profile.contact_name = contact_name;
      profile.contact_job = contact_job;
      profile.contact_phone = contact_phone;
      profile.contact_email = contact_email;
      profile.sales_name = sales_name;
      profile.sales_job = sales_job;
      profile.sales_phone = sales_phone;

      if (files != null) {
        for (String f : files) {
          file = Files.find("id=?", Long.valueOf(f)).first();
          if (file != null) {
            profile.files.add(file);
          }
        }
      }

      profile.save();
    }

    session.put("username", username);

    Secure.redirectToOriginalURL();
  }
Beispiel #11
0
  private int decodeChunk(int prof) {

    int offset = 6;
    int id = getUShort();
    int longueur = getInt();
    if (longueur < 0) return 0;

    this.pushChunk(id);

    /*
    	for(int x=0;x<prof;x++)
    		System.out.print(" ");
    	Log.log(prof + " - ID=" + Integer.toHexString(id) + " LONGUEUR=" + longueur );

    */
    switch (id) {
      case FILE_VERSION:
        {
          long ver = getUInt();
          this.fileVersion = (int) ver;
          // System.out.println("FILE VERSION="+this.fileVersion);
          offset += 4;
        }
        break;

      case KEYFRAME_VERSION:
        {
          long ver = getUInt();
          this.keyFrameVersion = (int) ver;
          offset += 4;
          // System.out.println("KEYFRAME VERSION="+this.keyFrameVersion);
        }
        break;

      case MESH_VERSION:
        {
          long ver = getUInt();
          this.meshVersion = (int) ver;
          offset += 4;
          // System.out.println("MESH VERSION="+this.meshVersion);

        }
        break;
        /*
        case 0x0100:
        {
        	double scl=(double) getFloat();
        	offset+=4;
        	System.out.println("MASTER SCALE="+scl);
        }
        break;
        */

      case UNIT: // MASTER_SCALE 1.0 <=> 1==1inch
        this.unit = getFloat();
        offset += 4;
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case BGCOLOR:
        do {
          int colorBId = getUShort();
          int lBColor = getInt();
          offset += 6;
          switch (colorBId) {
            case RGBF:
            case RGBFG:
              this.backgroundColor = readFloatColor();
              offset += 12;
              break;
            case RGBB:
            case RGBBG:
              this.backgroundColor = readByteColor();
              offset += 3;
              break;
          }
        } while (offset < longueur);
        break;

      case OBJECT:
        lastObjectName = getString();
        offset += lastObjectName.length() + 1;

        while (offset < longueur) offset += decodeChunk(prof + 1);

        // TODO: 3DS LOADING MAY BE IT IS NOT NEEDED
        if (cObjet instanceof Mesh3D) {

          //	((Mesh3D)cObjet).buildVertexId();
          //	((Mesh3D)cObjet).buildFaceId();
          //	((Mesh3D)cObjet).removeDuplicateVertices();

          //	((Mesh3D)cObjet).buildFacesNormals();
          //	((Mesh3D)cObjet).buildSphereBoxAndCenter();
          // Auto octree
          //	((Mesh3D)cObjet).buildMesh3DOctree();
        }

        //	if(cObjet!=null)
        // cObjet.build();
        break;

      case OBJECT_HIDDEN:
        ((Mesh3D) cObjet).setVisible(false);
        break;

      case OBJECT_DONT_CAST_SHADOW:
        if (cObjet instanceof Mesh3D) ((Mesh3D) cObjet).setCastShadow(false);
        break;
      case OBJECT_DONT_RECV_SHADOW:
        if (cObjet instanceof Mesh3D) ((Mesh3D) cObjet).setRecvShadow(false);
        break;

      case CAMERA_ATMOS_RANGE:
        float nearAtmosRange = getFloat();
        float farAtmosRange = getFloat();
        offset += 8;
        break;

      case CAMERA:
        {
          cObjet = new Camera3D();
          cObjet.id = -1;
          cObjet.nom = lastObjectName;
          cAxe = new Axis3D();
          cObjet.axes = cAxe;
          tObjets3D[nbObjet] = cObjet;
          nbObjet++;

          float x = getFloat();
          float y = getFloat();
          float z = getFloat();
          float tx = getFloat();
          float ty = getFloat();
          float tz = getFloat();
          float rz = getFloat();
          float focus = getFloat();
          // System.out.println("focal lenght="+focus);
          double FOV = 180.0 * 2.0 * Math.atan(44.1828 / (focus * 2)) / Math.PI;
          // System.out.println("FOV CALC="+FOV);

          cObjet.position.set(x, z, y);
          // cObjet.axes.add(x,z,y);
          // Log.log(cObjet.position.toString());

          cObjet.axes.origine.set(x, z, y);
          cObjet.axes.axeZ.set(tx - x, tz - z, ty - y);
          cObjet.axes.axeX.set(ty - y, 0, -(tx - x));

          cObjet.axes.axeY.copy(cObjet.axes.axeZ).cross(cObjet.axes.axeX);

          cObjet.axes.axeX.normalize();
          cObjet.axes.axeY.normalize();
          cObjet.axes.axeZ.normalize();

          cObjet.rotation.z = rz;
          cObjet.pivot.set(0, 0, 0);

          if (this.meshVersion == 0) focus = (float) ((Camera3D) cObjet).width;
          ((Camera3D) cObjet).focus = focus; // rotation.rz=rz;
          offset += 32;

          // tObjets3D[nbObjet]=new Scene3DObject();
          // nbObjet++;

          while (offset < longueur) offset += decodeChunk(prof + 1);
        }
        break;

      case LIGHT:
        {
          float x = getFloat();
          float y = getFloat();
          float z = getFloat();
          offset += 12;

          while (offset < longueur) offset += decodeChunk(prof + 1);
        }
        break;

      case TRIMESH:
        cObjet = new Mesh3D();
        cObjet.nom = lastObjectName;
        cObjet.id = -1;
        tObjets3D[nbObjet] = cObjet;
        nbObjet++;
        cAxe = new Axis3D();
        while (offset < longueur) offset += decodeChunk(prof + 1);
        cObjet.axes = cAxe;
        break;

      case VERTEXL:
        int nbV = getUShort();
        offset += 2;
        cPoints3D = new Vertex3D[nbV];
        mappingU = new float[nbV];
        mappingV = new float[nbV];

        for (int nV = 0; nV < nbV; nV++) {
          float x = getFloat();
          float y = getFloat();
          float z = getFloat();
          cPoints3D[nV] = new Vertex3D(x, z, y);
          offset += 12;
        }
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case FACEL:
        int nbP = getUShort();
        offset += 2;
        cPolygones3D = new Face3D[nbP];
        for (int nP = 0; nP < nbP; nP++) {
          int p1 = getUShort();
          int p2 = getUShort();
          int p3 = getUShort();
          int info = getUShort();
          Vertex3D p3D[] = new Vertex3D[3];
          p3D[0] = cPoints3D[p3];
          p3D[1] = cPoints3D[p2];
          p3D[2] = cPoints3D[p1];
          cPolygones3D[nP] = new Face3D(p3D[0], p3D[1], p3D[2]);
          cPolygones3D[nP].u0 = mappingU[p3];
          cPolygones3D[nP].v0 = mappingV[p3];
          cPolygones3D[nP].u1 = mappingU[p2];
          cPolygones3D[nP].v1 = mappingV[p2];
          cPolygones3D[nP].u2 = mappingU[p1];
          cPolygones3D[nP].v2 = mappingV[p1];
          offset += 8;
        }

        ((Mesh3D) cObjet).vertices3D = cPoints3D;
        ((Mesh3D) cObjet).faces3D = cPolygones3D;

        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case SMOOTHL:
        int nbpoly = cPolygones3D.length;
        for (int nP = 0; nP < nbpoly; nP++) {
          int nbSmooth = getInt();
          cPolygones3D[nP].smoothGroupMask = nbSmooth;
          offset += 4;
        }
        break;

      case FACEM:
        String nom = getString();
        offset += nom.length() + 1;
        cMateriau = getTempMateriauByName(nom);
        int nbF = getUShort();
        offset += 2;
        for (int nF = 0; nF < nbF; nF++) {
          int numF = getUShort();
          cPolygones3D[numF].material = cMateriau;
          offset += 2;
        }
        while (offset < longueur) offset += decodeChunk(prof + 1);

        break;

      case MAPPINGVL:
        int nbMV = getUShort();
        offset += 2;
        for (int nV = 0; nV < nbMV; nV++) {
          float u = getFloat();
          float v = getFloat();
          mappingU[nV] = u;
          mappingV[nV] = -v;
          offset += 8;
        }
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case OBJAXES:
        double x = getFloat();
        double y = getFloat();
        double z = getFloat();
        cAxe.axeX.set(x, z, y);

        x = getFloat();
        y = getFloat();
        z = getFloat();
        cAxe.axeZ.set(x, z, y);

        x = getFloat();
        y = getFloat();
        z = getFloat();
        cAxe.axeY.set(x, z, y);

        x = getFloat();
        y = getFloat();
        z = getFloat();
        cAxe.origine.set(x, z, y);

        offset += 48;
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MATERIAL:
        cMateriau = new Material();
        tMateriaux3D[nbMaterial] = cMateriau;
        nbMaterial++;
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MATERIALNAME:
        cMateriau.nom = getString();
        offset += cMateriau.nom.length() + 1;
        while (offset < longueur) offset += decodeChunk(prof + 1);

        break;

      case MATERIALAMBIENTCOLOR:
        do {
          int colorAId = getUShort();
          int lAColor = getInt();
          offset += 6;
          switch (colorAId) {
            case RGBF:
            case RGBFG:
              cMateriau.ambientColor = readFloatColor();
              offset += 12;
              break;
            case RGBB:
            case RGBBG:
              cMateriau.ambientColor = readByteColor();
              offset += 3;
              break;
          }
        } while (offset < longueur);
        break;

      case MATERIALDIFFUSECOLOR:
        do {
          int colorDId = getUShort();
          int lDColor = getInt();
          offset += 6;
          switch (colorDId) {
            case RGBF:
            case RGBFG:
              cMateriau.diffuseColor = readFloatColor();
              offset += 12;
              break;
            case RGBB:
            case RGBBG:
              cMateriau.diffuseColor = readByteColor();
              offset += 3;
              break;
          }
        } while (offset < longueur);
        break;

      case MATERIALSPECULARCOLOR:
        do {

          int colorSId = getUShort();
          int lSColor = getInt();
          offset += 6;
          switch (colorSId) {
            case RGBF:
            case RGBFG:
              cMateriau.specularColor = readFloatColor();
              offset += 12;
              break;
            case RGBB:
            case RGBBG:
              cMateriau.specularColor = readByteColor();
              offset += 3;
              break;
          }
        } while (offset < longueur);
        break;

      case MATERIALSHINEPERCENT:
        int shineId = getUShort();
        int lShine = getInt();
        offset += 6;
        switch (shineId) {
          case PERCENTF:
            cMateriau.specularPower = readFloatPercent();
            offset += 4;
            break;
          case PERCENTI:
            cMateriau.specularPower = readIntPercent();
            offset += 2;
            break;
        }
        break;

      case MATERIALILLUMPERCENT:
        int illumId = getUShort();
        int lIllum = getInt();
        offset += 6;
        switch (illumId) {
          case PERCENTF:
            cMateriau.selfIlluminationLevel = readFloatPercent();
            offset += 4;
            break;
          case PERCENTI:
            cMateriau.selfIlluminationLevel = readIntPercent();
            offset += 2;
            break;
        }
        // Log.log(cMateriau.nom+" emi="+emi);
        break;

      case MATERIALSHINEFPERCENT:
        int shineFId = getUShort();
        int lShineF = getInt();
        offset += 6;
        switch (shineFId) {
          case PERCENTF:
            cMateriau.specularLevel = readFloatPercent() * 255 / 100;
            offset += 4;
            break;
          case PERCENTI:
            cMateriau.specularLevel = (readIntPercent() * 255) / 100;
            offset += 2;
            break;
        }
        break;

      case MATERIALTRANSPERCENT:
        int transId = getUShort();
        int lTrans = getInt();
        offset += 6;
        switch (transId) {
          case PERCENTF:
            cMateriau.alphaLevel = readFloatPercent() * 255 / 100;
            offset += 4;
            break;
          case PERCENTI:
            cMateriau.alphaLevel = (readIntPercent() * 255) / 100;
            offset += 2;
            break;
        }
        break;

      case MATERIALTRANSFPERCENT:
        int transFId = getUShort();
        int lTransF = getInt();
        offset += 6;
        switch (transFId) {
          case PERCENTF:
            cMateriau.alphaFalloff = readFloatPercent() * 255 / 100;
            offset += 4;
            break;
          case PERCENTI:
            cMateriau.alphaFalloff = (readIntPercent() * 255) / 100;
            offset += 2;
            break;
        }
        break;

      case MATERIALTEXTUREDIFF:
        cMapping = new MappingUV();
        cMateriau.mapping = cMapping;
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MATERIALTEXTUREBUMP:
        cMapping = new MappingUV();
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MATERIALTEXTUREENV:
        cMapping = new MappingUV();
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MATERIALTEXTUREOPAC:
        cMapping = new MappingUV();
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MATERIALTEXTURESPEC:
        cMapping = new MappingUV();
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MATERIALTEXTURESHIN:
        cMapping = new MappingUV();
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MATERIALTEXTUREILLUM:
        cMapping = new MappingUV();
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MAPPINGFILE:
        String fileName = getString();
        // System.out.println("MAPPINGFILE="+fileName);
        offset += fileName.length() + 1;

        String textureCacheKey = this.ressourcePath + fileName;
        URLTexture nTexture = (URLTexture) textureCache.get(textureCacheKey);
        if (nTexture == null) {
          nTexture = new URLTexture();
          nTexture.nom = fileName;
          nTexture.sourceFile = fileName;
          nTexture.baseURL = this.ressourcePath;
          textureCache.put(textureCacheKey, nTexture);
          this.textures[this.nbTexture++] = nTexture;
        }

        // There cache will cause trouble if same texture used for different kind of map
        if (this.getLastParentChunk() == MATERIALTEXTUREDIFF) {
          nTexture.type = DzzD.TT_RGB;
          cMateriau.diffuseTexture = nTexture;
        }
        if (this.getLastParentChunk() == MATERIALTEXTUREBUMP) {
          nTexture.type = DzzD.TT_HNORMAL;
          cMateriau.bumpNormalTexture = nTexture;
        }
        if (this.getLastParentChunk() == MATERIALTEXTUREENV) {
          nTexture.type = DzzD.TT_ENV;
          cMateriau.envTexture = nTexture;
        }
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MAPPINGOFFSETU:
        float offseMappingU = getFloat();
        offset += 4;
        cMapping.ofsU = offseMappingU;
        break;

      case MAPPINGOFFSETV:
        float offseMappingV = getFloat();
        offset += 4;
        cMapping.ofsV = offseMappingV;
        break;

        /*
         * KEYFRAME BEGIN
         */
      case KEYFHIER:
        // System.out.println("KEYFHIER");
        lastObjectName = getString(); // Name in mesh section
        // System.out.println("Mesh section name="+lastObjectName);
        offset += lastObjectName.length() + 1;

        int info1 = getUShort();
        int info2 = getUShort();
        int idObjetParent = getShort();

        // System.out.println("------- info1: "+info1);
        // System.out.println("------- info2: "+info2);
        // System.out.println("------- idObjetParent parent:("+idObjetParent+")");

        offset += 6;

        if ((this.meshVersion >= 3)
            && ((info1 & 0x4000) == 0)
            && (!lastObjectName.equals("$$$DUMMY"))) {
          // Log.log("------------ Instance From Object" + lastObjectName);
          cObjet = (Scene3DObject) getTempObjetByName(lastObjectName).getClone(false);
          cObjet.nom = "Instance" + nbObjet; // lastObjectName;
          cObjet.id = this.cObjetId;
          tObjets3D[nbObjet] = cObjet;
          nbObjet++;
        } else {
          if (lastObjectName.equals("$$$DUMMY")) {
            // System.out.println("New object");
            cObjet = new Mesh3D();
            cObjet.nom = "$$$DUMMY";
            cObjet.id = this.cObjetId;
            tObjets3D[nbObjet] = cObjet;
            nbObjet++;
          } else {

            this.cObjet = getTempObjetByName(lastObjectName);
            if (this.cObjet instanceof Camera3D) {
              if (getLastParentChunk() == KEYFCAMTARGETFRAME) {
                // System.out.println("TARGET FOR "+lastObjectName);
                // this.cObjet.setTarget(DzzD.newPoint3D());
              }
            }
          }
        }

        // System.out.println("ID objet==" + cObjetId);

        this.cObjet.id = this.cObjetId;
        if (idObjetParent != 65535) {

          Scene3DObject parent = getTempObjetById(idObjetParent);
          if (parent != null) this.cObjet.parent = parent;
          // System.out.println(cObjet.getName()+" is child of "+cObjet.getParent().getName());
        }
        /*
        if(this.cObjet.parent!=null && !lastObjectName.equals("$$$DUMMY"))
        	System.out.println("-" + lastObjectName+"("+ this.cObjet.id +"):parent:("+idObjetParent+")"+this.cObjet.parent.nom);
        */
        while (offset < longueur) offset += decodeChunk(prof + 1);

        break;

      case KEYFNAME: // - Instance objects name.
        String instanceName = getString();
        // Log.log("instanceName="+instanceName);
        cObjet.nom = instanceName;
        offset += instanceName.length() + 1;
        break;

      case KEYFID:
        int idObjet = getUShort();

        offset += 2;
        this.cObjetId = idObjet;
        // System.out.println("ID OBJ="+cObjetId);
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case KEYFTRANS:

        // Read Track Header
        int info = getShort();
        offset += 2;
        for (int niu = 0; niu < 8; niu++) {
          // Read Unknow TrackHeader info 8 byte
          byte infoUnknow = (byte) getByte();
          offset += 1;
        }

        // Read number ok keys
        int nbKey = (int) getUInt();
        offset += 4;

        Point3D cPosition = new Point3D();
        Point3D lastPosition = new Point3D();
        if (this.animators[cObjetId] == null)
          this.animators[cObjetId] = new Scene3DObjectAnimator();

        // Read all track
        for (int xKey = 0; xKey < nbKey; xKey++) {
          // Read the frame number for this key
          int nKey = (int) getUInt();
          offset += 4;

          // Read Spline flag
          int splinef = getShort();
          offset += 2;

          // Read Spline info depending on spline flag
          if ((splinef & 1) != 0) {
            // Read tension
            getFloat();
            offset += 4;
          }
          if ((splinef & 2) != 0) {
            // Read continuity
            getFloat();
            offset += 4;
          }
          if ((splinef & 4) != 0) {
            // Read bias
            getFloat();
            offset += 4;
          }
          if ((splinef & 8) != 0) {
            // Read ease to
            getFloat();
            offset += 4;
          }
          if ((splinef & 16) != 0) {
            // Read ease from
            getFloat();
            offset += 4;
          }

          // Read this key pos (global coordinate
          x = getFloat();
          y = getFloat();
          z = getFloat();
          if (xKey == 0) this.key3DTrans[cObjetId] = new Point3D(x, z, y);

          cPosition.set(x, z, y);
          Point3D position = new Point3D();
          position.copy(cPosition);
          /*
          if(cObjetId!=-1)
          {

          	System.out.println(tObjets3D[cObjetId].getName());
          	System.out.println("pos="+position.toString());
          }
          */

          this.animators[cObjetId].addKeyPosition(nKey * 30, position);
          lastPosition.copy(cPosition);

          offset += 12;
        }
        break;

      case KEYFROT:
        int infor = getShort();
        offset += 2;
        for (int niu = 0; niu < 8; niu++) {
          byte infoUnknow = (byte) getByte();
          offset += 1;
        }
        int nbKeyr = (int) getUInt();
        offset += 4;

        Axis3D cAxis = new Axis3D();
        cAxis.init();
        Point3D cRotation = new Point3D();
        Point3D lastRotation = new Point3D();

        if (this.animators[cObjetId] == null)
          this.animators[cObjetId] = new Scene3DObjectAnimator();

        for (int xKey = 0; xKey < nbKeyr; xKey++) {
          int nKey = (int) getUInt();

          offset += 4;
          int infoAcceleration = getShort();
          offset += 2;
          double a = getFloat();
          offset += 4;
          x = getFloat();
          y = getFloat();
          z = getFloat();

          if (a > Math.PI && xKey != 0) a = 2.0 * Math.PI - a;

          if (xKey == 0) {
            this.key3DRotAng[cObjetId] = a;
            this.key3DRotAxe[cObjetId] = new Point3D(x, z, y);
          }

          cAxis.rotate(a, -x, -z, -y);
          cAxis.getRotationXZY(cRotation);

          Point3D rotation = new Point3D();
          rotation.copy(cRotation);

          this.animators[cObjetId].addKeyRotation(nKey * 30, rotation, new Point3D(-x, -z, -y), a);

          offset += 12;
        }

        break;

      case KEYFZOOM:
        int infoz = getShort();
        offset += 2;
        for (int niu = 0; niu < 8; niu++) {
          byte infoUnknow = (byte) getByte();
          offset += 1;
        }
        int nbKeyz = (int) getUInt();
        offset += 4;
        for (int xKey = 0; xKey < nbKeyz; xKey++) {
          int nKey = (int) getUInt();
          offset += 4;
          int infoAcceleration = getShort();
          offset += 2;
          x = getFloat();
          y = getFloat();
          z = getFloat();
          if (xKey == 0) this.key3DZoom[cObjetId] = new Point3D(x, z, y);
          offset += 12;
        }
        break;

      case KEYFCAMFOVFRAME:
        int infof = getShort();
        offset += 2;
        for (int niu = 0; niu < 8; niu++) {
          byte infoUnknow = (byte) getByte();
          offset += 1;
        }
        int nbKeyf = (int) getUInt();
        offset += 4;
        for (int xKey = 0; xKey < nbKeyf; xKey++) {
          int nKey = (int) getUInt();
          offset += 4;
          int infoAcceleration = getShort();
          offset += 2;
          float fov = getFloat();
          if (this.cObjet instanceof Camera3D) {
            ((Camera3D) this.cObjet).setFOV(fov);
          }

          offset += 4;
        }
        break;

      case KEYFPIVOT:
        x = getFloat();
        y = getFloat();
        z = getFloat();
        offset += 12;
        this.cObjet.pivot.set(x, z, y);
        break;

      case KEYFBOX:
        double x1 = getFloat();
        double y1 = getFloat();
        double z1 = getFloat();
        offset += 12;
        double x2 = getFloat();
        double y2 = getFloat();
        double z2 = getFloat();
        offset += 12;
        this.cObjet.center.set((x1 + x2) * 0.5, (z1 + z2) * 0.5, (y1 + y2) * 0.5);
        break;

      case KEYF3DS:
        this.isKeyFrame = true;
        // System.out.println("KEYF3DS");
        this.cObjetId = 0;
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case KEYFHEADERACTIVE:
        long startf = getUInt();
        long endf = getUInt();
        // System.out.println("KEYFRAME START FRAME="+ startf);
        // System.out.println("KEYFRAME END FRAME="+ endf);
        offset += 8;
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case KEYFHEADERCURRENT:
        long currentf = getUInt();
        // System.out.println("KEYFRAME CURRENT FRAME="+currentf);
        offset += 4;
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case KEYFHEADERGLOBAL:
        this.keyFrameRevision = getShort();
        this.keyFrameFileName = getString();
        this.KeyFrameNbFrame = getUInt();
        offset += 2;
        offset += this.keyFrameFileName.length() + 1;
        offset += 4;
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case MAIN3DS:
        this.cObjetId = 0;
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case EDIT3DS:
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case KEYFOBJFRAME:
        this.cObjetId++;
        while (offset < longueur) offset += decodeChunk(prof + 1);
        break;

      case KEYFCAMFRAME:
        this.cObjetId++;
        // System.out.println("-----CAMERA-------");
        // System.out.println("ID1="+cObjetId);
        while (offset < longueur) offset += decodeChunk(prof + 1);
        // System.out.println("-----END CAMERA-------");
        break;

      case KEYFCAMTARGETFRAME:
        this.cObjetId++;
        // System.out.println("-----CAMERA TARGET-------");
        // System.out.println("ID1="+cObjetId);
        // MUST DO SPECIAL DECODE OF CHILD TO NOT OVERWRITE CAMERA TRACK POS/ROT

        // while(offset<longueur)
        //	offset+=decodeChunk(prof+1);
        // System.out.println("-----END CAMERA TARGET-------");
        break;

      default:
        break;
    }
    this.setProgress(50 + (50 * this.nbBytesDecoded) / this.data.length);
    skip(id, offset, longueur - offset);
    this.popChunk();
    return longueur;
  }