Exemple #1
0
 @Override
 public void read(JmeImporter im) throws IOException {
   InputCapsule ic = im.getCapsule(this);
   charSet = (BitmapCharacterSet) ic.readSavable("charSet", null);
   Savable[] pagesSavable = ic.readSavableArray("pages", null);
   pages = new Material[pagesSavable.length];
   System.arraycopy(pagesSavable, 0, pages, 0, pages.length);
 }
Exemple #2
0
  public void read(JmeImporter e) throws IOException {
    InputCapsule capsule = e.getCapsule(this);

    rot = (Quaternion) capsule.readSavable("rot", new Quaternion());
    translation = (Vector3f) capsule.readSavable("translation", null);
    if (translation == null) {
      translation = new Vector3f();
    }
    scale = (Vector3f) capsule.readSavable("scale", Vector3f.UNIT_XYZ);
  }
 public void read(JmeImporter im) throws IOException {
   InputCapsule ic = im.getCapsule(this);
   numSamples = ic.readInt("numSamples", 0);
   filters = ic.readSavableArrayList("filters", null);
   for (Filter filter : filters) {
     filter.setProcessor(this);
     setFilterState(filter, filter.isEnabled());
   }
   assetManager = im.getAssetManager();
 }
 @Override
 public void read(JmeImporter im) throws IOException {
   super.read(im);
   InputCapsule in = im.getCapsule(this);
   Savable[] sav = in.readSavableArray("targets", null);
   if (sav != null) {
     targets = new Mesh[sav.length];
     System.arraycopy(sav, 0, targets, 0, sav.length);
   }
   skeleton = (Skeleton) in.readSavable("skeleton", null);
 }
Exemple #5
0
 public void read(JmeImporter im) throws IOException {
   InputCapsule ic = im.getCapsule(this);
   leftIndex = ic.readInt("left_index", 0);
   rightIndex = ic.readInt("right_index", 0);
   leftPlane = ic.readFloat("left_plane", 0);
   rightPlane = ic.readFloat("right_plane", 0);
   axis = ic.readInt("axis", 0);
   left = (BIHNode) ic.readSavable("left_node", null);
   right = (BIHNode) ic.readSavable("right_node", null);
 }
Exemple #6
0
 public void read(JmeImporter e) throws IOException {
   InputCapsule capsule = e.getCapsule(this);
   normal = (Vector3d) capsule.readSavable("normal", Vector3d.ZERO.clone());
   constant = capsule.readDouble("constant", 0);
 }
 public void read(JmeImporter im) throws IOException {
   InputCapsule capsule = im.getCapsule(this);
   this.scale = (Vector3f) capsule.readSavable("scale", new Vector3f(1, 1, 1));
   this.margin = capsule.readFloat("margin", 0.0f);
 }
 @Override
 public void read(JmeImporter im) throws IOException {
   InputCapsule in = im.getCapsule(this);
   array = in.readFloatArray("array", null);
   index = in.readIntArray("index", null);
 }
  public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);

    name = ic.readString("name", null);
    worldBound = (BoundingVolume) ic.readSavable("world_bound", null);
    cullHint = ic.readEnum("cull_mode", CullHint.class, CullHint.Inherit);
    batchHint = ic.readEnum("batch_hint", BatchHint.class, BatchHint.Inherit);
    queueBucket = ic.readEnum("queue", RenderQueue.Bucket.class, RenderQueue.Bucket.Inherit);
    shadowMode = ic.readEnum("shadow_mode", ShadowMode.class, ShadowMode.Inherit);

    localTransform = (Transform) ic.readSavable("transform", Transform.IDENTITY);

    localLights = (LightList) ic.readSavable("lights", null);
    localLights.setOwner(this);

    // changed for backward compatibility with j3o files generated before the
    // AnimControl/SkeletonControl split
    // the AnimControl creates the SkeletonControl for old files and add it to the spatial.
    // The SkeletonControl must be the last in the stack so we add the list of all other control
    // before it.
    // When backward compatibility won't be needed anymore this can be replaced by :
    // controls = ic.readSavableArrayList("controlsList", null));
    controls.addAll(0, ic.readSavableArrayList("controlsList", null));

    userData = (HashMap<String, Savable>) ic.readStringSavableMap("user_data", null);
  }
Exemple #10
0
  public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);

    additionalState = (RenderState) ic.readSavable("render_state", null);
    transparent = ic.readBoolean("is_transparent", false);

    // Load the material def
    String defName = ic.readString("material_def", null);
    HashMap<String, MatParam> params =
        (HashMap<String, MatParam>) ic.readStringSavableMap("parameters", null);

    boolean enableVcolor = false;
    boolean separateTexCoord = false;
    boolean applyDefaultValues = false;
    boolean guessRenderStateApply = false;

    int ver = ic.getSavableVersion(Material.class);
    if (ver < 1) {
      applyDefaultValues = true;
    }
    if (ver < 2) {
      guessRenderStateApply = true;
    }
    if (im.getFormatVersion() == 0) {
      // Enable compatibility with old models
      if (defName.equalsIgnoreCase("Common/MatDefs/Misc/VertexColor.j3md")) {
        // Using VertexColor, switch to Unshaded and set VertexColor=true
        enableVcolor = true;
        defName = "Common/MatDefs/Misc/Unshaded.j3md";
      } else if (defName.equalsIgnoreCase("Common/MatDefs/Misc/SimpleTextured.j3md")
          || defName.equalsIgnoreCase("Common/MatDefs/Misc/SolidColor.j3md")) {
        // Using SimpleTextured/SolidColor, just switch to Unshaded
        defName = "Common/MatDefs/Misc/Unshaded.j3md";
      } else if (defName.equalsIgnoreCase("Common/MatDefs/Misc/WireColor.j3md")) {
        // Using WireColor, set wireframe renderstate = true and use Unshaded
        getAdditionalRenderState().setWireframe(true);
        defName = "Common/MatDefs/Misc/Unshaded.j3md";
      } else if (defName.equalsIgnoreCase("Common/MatDefs/Misc/Unshaded.j3md")) {
        // Uses unshaded, ensure that the proper param is set
        MatParam value = params.get("SeperateTexCoord");
        if (value != null && ((Boolean) value.getValue()) == true) {
          params.remove("SeperateTexCoord");
          separateTexCoord = true;
        }
      }
      assert applyDefaultValues && guessRenderStateApply;
    }

    def = (MaterialDef) im.getAssetManager().loadAsset(new AssetKey(defName));
    paramValues = new ListMap<String, MatParam>();

    // load the textures and update nextTexUnit
    for (Map.Entry<String, MatParam> entry : params.entrySet()) {
      MatParam param = entry.getValue();
      if (param instanceof MatParamTexture) {
        MatParamTexture texVal = (MatParamTexture) param;

        if (nextTexUnit < texVal.getUnit() + 1) {
          nextTexUnit = texVal.getUnit() + 1;
        }

        // the texture failed to load for this param
        // do not add to param values
        if (texVal.getTextureValue() == null || texVal.getTextureValue().getImage() == null) {
          continue;
        }
      }

      if (im.getFormatVersion() == 0 && param.getName().startsWith("m_")) {
        // Ancient version of jME3 ...
        param.setName(param.getName().substring(2));
      }

      checkSetParam(param.getVarType(), param.getName());
      paramValues.put(param.getName(), param);
    }

    if (applyDefaultValues) {
      // compatability with old versions where default vars were
      // not available
      for (MatParam param : def.getMaterialParams()) {
        if (param.getValue() != null && paramValues.get(param.getName()) == null) {
          setParam(param.getName(), param.getVarType(), param.getValue());
        }
      }
    }
    if (guessRenderStateApply && additionalState != null) {
      // Try to guess values of "apply" render state based on defaults
      // if value != default then set apply to true
      additionalState.applyPolyOffset = additionalState.offsetEnabled;
      additionalState.applyAlphaFallOff = additionalState.alphaTest;
      additionalState.applyAlphaTest = additionalState.alphaTest;
      additionalState.applyBlendMode = additionalState.blendMode != BlendMode.Off;
      additionalState.applyColorWrite = !additionalState.colorWrite;
      additionalState.applyCullMode = additionalState.cullMode != FaceCullMode.Back;
      additionalState.applyDepthTest = !additionalState.depthTest;
      additionalState.applyDepthWrite = !additionalState.depthWrite;
      additionalState.applyPointSprite = additionalState.pointSprite;
      additionalState.applyStencilTest = additionalState.stencilTest;
      additionalState.applyWireFrame = additionalState.wireframe;
    }
    if (enableVcolor) {
      setBoolean("VertexColor", true);
    }
    if (separateTexCoord) {
      setBoolean("SeparateTexCoord", true);
    }
  }