Java Code Examples for com.jme3.util.SafeArrayList#getArray()

The following examples show how to use com.jme3.util.SafeArrayList#getArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Node.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void read(JmeImporter e) throws IOException {
    // XXX: Load children before loading itself!!
    // This prevents empty children list if controls query
    // it in Control.setSpatial().
    children = new SafeArrayList(Spatial.class,
            e.getCapsule(this).readSavableArrayList("children", null));

    // go through children and set parent to this node
    if (children != null) {
        for (Spatial child : children.getArray()) {
            child.parent = this;
        }
    }
    super.read(e);
}
 
Example 2
Source File: Material.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private int applyOverrides(Renderer renderer, Shader shader, SafeArrayList<MatParamOverride> overrides, int unit) {
    for (MatParamOverride override : overrides.getArray()) {
        VarType type = override.getVarType();

        MatParam paramDef = def.getMaterialParam(override.getName());

        if (paramDef == null || paramDef.getVarType() != type || !override.isEnabled()) {
            continue;
        }

        Uniform uniform = shader.getUniform(override.getPrefixedName());

        if (override.getValue() != null) {
            if (type.isTextureType()) {
                renderer.setTexture(unit, (Texture) override.getValue());
                uniform.setValue(VarType.Int, unit);
                unit++;
            } else {
                uniform.setValue(type, override.getValue());
            }
        } else {
            uniform.clearValue();
        }
    }
    return unit;
}
 
Example 3
Source File: Node.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void read(JmeImporter e) throws IOException {
    // XXX: Load children before loading itself!!
    // This prevents empty children list if controls query
    // it in Control.setSpatial().
    
    children = new SafeArrayList( Spatial.class, 
                                  e.getCapsule(this).readSavableArrayList("children", null) );

    // go through children and set parent to this node
    if (children != null) {
        for (Spatial child : children.getArray()) {
            child.parent = this;
        }
    }
    
    super.read(e);
}
 
Example 4
Source File: Technique.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void applyOverrides(DefineList defineList, SafeArrayList<MatParamOverride> overrides) {
    for (MatParamOverride override : overrides.getArray()) {
        if (!override.isEnabled()) {
            continue;
        }
        Integer defineId = def.getShaderParamDefineId(override.name);
        if (defineId != null) {
            if (def.getDefineIdType(defineId) == override.type) {
                defineList.set(defineId, override.type, override.value);
            }
        }
    }
}
 
Example 5
Source File: TerrainLodControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
private List<Vector3f> cloneVectorList(SafeArrayList<Vector3f> locations) {

        final List<Vector3f> cloned = new ArrayList<>(locations.size());

        for (final Vector3f location : locations.getArray()) {
            cloned.add(location.clone());
        }

        return cloned;
    }