/** * Set the {@link Track}s to be used by this animation. * * @param tracksArray The tracks to set. */ public void setTracks(Track[] tracksArray) { for (Track track : tracksArray) { tracks.add(track); } }
/** * Adds a track to this animation * @param track the track to add */ public void addTrack(Track track) { tracks.add(track); }
public void addChild(Joint child) { children.add(child); child.parent = this; }
/** * Adds a forced material parameter to use when rendering geometries. * <p> * The provided parameter takes precedence over parameters set on the * material or any overrides that exist in the scene graph that have the * same name. * * @param override The override to add * @see MatParamOverride * @see #removeForcedMatParam(com.jme3.material.MatParamOverride) */ public void addForcedMatParam(MatParamOverride override) { forcedOverrides.add(override); }
/** * Adds a {@link SceneProcessor} to this ViewPort. * <p> * SceneProcessors that are added to the ViewPort will be notified * of events as the ViewPort is being rendered by the {@link RenderManager}. * * @param processor The processor to add * * @see SceneProcessor */ public void addProcessor(SceneProcessor processor){ if (processor == null) { throw new IllegalArgumentException( "Processor cannot be null." ); } processors.add(processor); }
public void addMorphTarget(MorphTarget target) { if (morphTargets == null) { morphTargets = new SafeArrayList<>(MorphTarget.class); } morphTargets.add(target); }
public void setCamera(final Camera camera) { this.cameras.clear(); this.cameras.add(camera); }
/** * Adds a local material parameter override. * * @param override The override to add. * @see MatParamOverride */ public void addMatParamOverride(MatParamOverride override) { if (override == null) { throw new IllegalArgumentException("override cannot be null"); } localOverrides.add(override); setMatParamOverrideRefresh(); }
/** * Declares a filed in this BO. * * @param name the field's name. * @param varType the field's type. */ public void declareField(final String name, final VarType varType) { if (fields.containsKey(name)) { throw new IllegalArgumentException("The field " + name + " is already declared."); } final BufferObjectField field = new BufferObjectField(name, varType); fields.put(name, field); fieldArray.add(field); }
/** * Attaches a new scene to render in this ViewPort. * * @param scene The scene to attach * * @see Spatial */ public void attachScene(Spatial scene){ if (scene == null) { throw new IllegalArgumentException( "Scene cannot be null." ); } sceneList.add(scene); if (scene instanceof Geometry) { scene.forceRefresh(true, false, true); } }
@Override public void cloneFields( Cloner cloner, Object original ) { // There is some logic here that I'm copying but I'm not sure if // it's a mistake or not. If a track is not a CloneableTrack then it // isn't cloned at all... even though they all implement clone() methods. -pspeed SafeArrayList<Track> newTracks = new SafeArrayList<>(Track.class); for( Track track : tracks ) { if (track instanceof JmeCloneable) { newTracks.add(cloner.clone(track)); } else { // this is the part that seems fishy newTracks.add(track); } } this.tracks = newTracks; }
/** * More efficient than e.g detaching and attaching as no updates are needed. * * @param index1 The index of the first child to swap * @param index2 The index of the second child to swap */ public void swapChildren(int index1, int index2) { Spatial c2 = children.get(index2); Spatial c1 = children.remove(index1); children.add(index1, c2); children.remove(index2); children.add(index2, c1); }
/** * If specified the geometry has an animated mesh, add its mesh and material * to the lists of animation targets. */ private void findTargets(Geometry geometry) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimated()) { targets.add(geometry); } }
/** * If specified the geometry has an animated mesh, add its mesh and material * to the lists of animation targets. */ private void findTargets(Geometry geometry) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimated()) { targets.add(geometry); } }
public Spatial oldDeepClone(){ Node nodeClone = (Node) super.clone(); nodeClone.children = new SafeArrayList<Spatial>(Spatial.class); for (Spatial child : children){ Spatial childClone = child.deepClone(); childClone.parent = nodeClone; nodeClone.children.add(childClone); } return nodeClone; }
private void addUpdateChildren( SafeArrayList<Spatial> results ) { for( Spatial child : children.getArray() ) { if( child.requiresUpdates() ) { results.add(child); } if( child instanceof Node ) { ((Node)child).addUpdateChildren(results); } } }
/** * Adds a filter to the filters list<br> * @param filter the filter to add */ public void addFilter(Filter filter) { if (filter == null) { throw new IllegalArgumentException("Filter cannot be null."); } filters.add(filter); if (isInitialized()) { initFilter(filter, viewPort); } setFilterState(filter, filter.isEnabled()); }
/** * Add a control to the list of controls. * @param control The control to add. * * @see Spatial#removeControl(java.lang.Class) */ public void addControl(Control control) { boolean before = requiresUpdates(); controls.add(control); control.setSpatial(this); boolean after = requiresUpdates(); // If the requirement to be updated has changed // then we need to let the parent node know so it // can rebuild its update list. if( parent != null && before != after ) { parent.invalidateUpdateList(); } }
@Override public void read(JmeImporter im) throws IOException { InputCapsule in = im.getCapsule(this); name = in.readString("name", null); length = in.readFloat("length", 0f); Savable[] arr = in.readSavableArray("tracks", null); if (arr != null) { // NOTE: Backward compat only .. Some animations have no // tracks set at all even though it makes no sense. // Since there's a null check in setTime(), // its only appropriate that the check is made here as well. tracks = new SafeArrayList<Track>(Track.class); for (Savable savable : arr) { tracks.add((Track) savable); } } } }
/** * Sets the {@link VertexBuffer} on the mesh. * This will update the vertex/triangle counts if needed. * * @param vb The buffer to set * @throws IllegalArgumentException If the buffer type is already set */ public void setBuffer(VertexBuffer vb){ if (buffers.containsKey(vb.getBufferType().ordinal())) { throw new IllegalArgumentException("Buffer type already set: " + vb.getBufferType()); } buffers.put(vb.getBufferType().ordinal(), vb); buffersList.add(vb); updateCounts(); }