/** * Removes the "set-by-current-material" flag from all uniforms. * When a uniform is modified after this call, the flag shall * become "set-by-current-material". * A call to {@link #resetUniformsNotSetByCurrent() } will reset * all uniforms that do not have the "set-by-current-material" flag * to their default value (usually all zeroes or false). */ public void clearUniformsSetByCurrentFlag() { int size = uniforms.size(); for (int i = 0; i < size; i++) { Uniform u = uniforms.getValue(i); u.clearSetByCurrentMaterial(); } }
@Test public void testListMap() { ListMap<String, String> listMap = new ListMap<String, String>(); listMap.put("bob", "hello"); assert "hello".equals(listMap.get("bob")); assert "hello".equals(listMap.remove("bob")); assert listMap.size() == 0; assert listMap.isEmpty(); listMap.put("abc", "1"); listMap.put("def", "2"); listMap.put("ghi", "3"); listMap.put("jkl", "4"); listMap.put("mno", "5"); assert "3".equals(listMap.get("ghi")); assert listMap.size() == 5; assert !listMap.isEmpty(); // check iteration order, should be consistent for (int i = 0; i < listMap.size(); i++) { String expectedValue = Integer.toString(i + 1); String key = listMap.getKey(i); String value = listMap.getValue(i); Entry<String, String> entry = listMap.getEntry(i); assert key.equals(entry.getKey()); assert value.equals(entry.getValue()); assert expectedValue.equals(value); } } }
/** * Returns a collection of all parameters set on this material. * * @return a collection of all parameters set on this material. * * @see #setParam(java.lang.String, com.jme3.shader.VarType, java.lang.Object) */ public Collection<MatParam> getParams() { return paramValues.values(); }
/** * Clones this material. The result is returned. */ @Override public Material clone() { try { Material mat = (Material) super.clone(); if (additionalState != null) { mat.additionalState = additionalState.clone(); } mat.technique = null; mat.techniques = new HashMap<String, Technique>(); mat.paramValues = new ListMap<String, MatParam>(); for (int i = 0; i < paramValues.size(); i++) { Map.Entry<String, MatParam> entry = paramValues.getEntry(i); mat.paramValues.put(entry.getKey(), entry.getValue().clone()); } mat.sortingId = -1; return mat; } catch (CloneNotSupportedException ex) { throw new AssertionError(ex); } }
@Override public void putAll(Map<? extends K, ? extends V> map) { for (Entry<? extends K, ? extends V> entry : map.entrySet()){ put(entry.getKey(), entry.getValue()); } // if (map instanceof ListMap){ // ListMap<K, V> listMap = (ListMap<K, V>) map; // ArrayList<ListMapEntry<K, V>> otherEntries = listMap.entries; // for (int i = 0; i < otherEntries.size(); i++){ // ListMapEntry<K, V> entry = otherEntries.get(i); // put(entry.key, entry.value); // } // }else{ // for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()){ // put(entry.getKey(), entry.getValue()); // } // } }
/** * Returns the parameter set on this material with the given name, * returns <code>null</code> if the parameter is not set. * * @param name The parameter name to look up. * @return The MatParam if set, or null if not set. */ public MatParam getParam(String name) { return paramValues.get(name); }
private void clearTextureParam(String name) { name = checkSetParam(null, name); MatParamTexture val = getTextureParam(name); if (val == null) { throw new IllegalArgumentException("The given texture for parameter \"" + name + "\" is null."); } int texUnit = val.getUnit(); // paramValues.remove(name); paramValues.put(name, null); nextTexUnit--; for (MatParam param : paramValues.values()) { if (param instanceof MatParamTexture) { MatParamTexture texParam = (MatParamTexture) param; if (texParam.getUnit() > texUnit) { texParam.setUnit(texParam.getUnit() - 1); } } } sortingId = -1; }
@Override public boolean isEmpty() { return size() == 0; }
/** * Removes a buffer block by the name. * * @param name the buffer block's name. */ public void removeBufferBlock(final String name){ bufferBlocks.remove(name); }
/** * Creates a new shader, {@link #initialize() } must be called * after this constructor for the shader to be usable. */ public Shader(){ super(); shaderSourceList = new ArrayList<>(); uniforms = new ListMap<>(); bufferBlocks = new ListMap<>(); attribs = new IntMap<>(); boundUniforms = new ArrayList<>(); }
public void setParam(int paramIndex, VarType type, Object value) { MatParam val = paramValues.getValue(paramIndex); // if (technique != null) { // technique.notifySetParam(name, type, value); // } val.setValue(value); Object value2 = val.multiData != null ? val.multiData : value; if (techniqueArray == null) { setTechniqueArray(); } paramValues.getValue(0); for(Technique tech : techniqueArray) { tech.notifySetParam(paramIndex, type, value2); } } /**
/** * Clones this material. The result is returned. */ @Override public Material clone() { try { Material mat = (Material) super.clone(); if (additionalState != null) { mat.additionalState = additionalState.clone(); } mat.technique = null; mat.techniques = new HashMap<String, Technique>(); mat.techniqueArray = null; mat.paramValues = new ListMap<String, MatParam>(); for (int i = 0; i < paramValues.size(); i++) { Map.Entry<String, MatParam> entry = paramValues.getEntry(i); mat.paramValues.put(entry.getKey(), entry.getValue().clone()); } return mat; } catch (CloneNotSupportedException ex) { throw new AssertionError(); } }