public BufferObject(final int binding, final Layout layout, final BufferType bufferType) { this.handleRef = new Object(); this.bufferType = bufferType; this.binding = binding; this.layout = layout; this.fields = new HashMap<>(); this.fieldArray = new SafeArrayList<>(BufferObjectField.class); }
public MultiTerrainLodControl() { terrains = new SafeArrayList<>(TerrainQuad.class); removedTerrains = new ArrayList<>(); addedTerrains = new ArrayList<>(); }
public TerrainLodControl() { hasResetLod = false; forceUpdate = true; previousCameraLocation = new Vector3f(); cameras = new SafeArrayList<>(Camera.class); cameraLocations = new SafeArrayList<>(Vector3f.class); lastCameraLocations = new SafeArrayList<>(Vector3f.class); lodCalcRunning = new AtomicBoolean(false); lodOffCount = 0; lodCalculator = makeLodCalculator(); // a default calculator }
@Override public void cloneFields(final Cloner cloner, final Object original) { super.cloneFields(cloner, original); this.lodCalculator = cloner.clone(lodCalculator); this.cameras = new SafeArrayList<>(Camera.class, cameras); this.cameraLocations = new SafeArrayList<>(Vector3f.class); this.lastCameraLocations = new SafeArrayList<>(Vector3f.class); this.lodCalcRunning = new AtomicBoolean(); this.previousCameraLocation = new Vector3f(); }
public void addMorphTarget(MorphTarget target) { if (morphTargets == null) { morphTargets = new SafeArrayList<>(MorphTarget.class); } morphTargets.add(target); }
/** * This method creates a clone of the current object. * @return a clone of the current object */ @Override public Animation clone() { try { Animation result = (Animation) super.clone(); result.tracks = new SafeArrayList<Track>(Track.class); for (Track track : tracks) { result.tracks.add(track.clone()); } return result; } catch (CloneNotSupportedException e) { throw new AssertionError(); } }
public BaseAction(Tween tween) { this.tween = tween; setLength(tween.getLength()); List<Action> subActions = new SafeArrayList<>(Action.class); gatherActions(tween, subActions); actions = new Action[subActions.size()]; subActions.toArray(actions); }
private SafeArrayList<Spatial> getUpdateList() { if( updateListValid ) { return updateList; } if( updateList == null ) { updateList = new SafeArrayList<Spatial>(Spatial.class); } else { updateList.clear(); } // Build the list addUpdateChildren(updateList); updateListValid = true; return updateList; }
/** * * @param spat * @return */ public Animation cloneForSpatial(Spatial spat) { try { Animation result = (Animation) super.clone(); result.tracks = new SafeArrayList<Track>(Track.class); for (Track track : tracks) { if (track instanceof ClonableTrack) { result.tracks.add(((ClonableTrack) track).cloneForSpatial(spat)); } else { result.tracks.add(track); } } return result; } catch (CloneNotSupportedException e) { throw new AssertionError(); } }
/** * Constructor instantiates a new <code>Spatial</code> object setting the * rotation, translation and scale value to defaults. * * @param name * the name of the scene element. This is required for * identification and comparison purposes. */ protected Spatial(String name) { this.name = name; localTransform = new Transform(); worldTransform = new Transform(); localLights = new LightList(this); worldLights = new LightList(this); localOverrides = new SafeArrayList<>(MatParamOverride.class); worldOverrides = new SafeArrayList<>(MatParamOverride.class); refreshFlags |= RF_BOUND; }
@Override public void write(JmeExporter e) throws IOException { SafeArrayList<Spatial> childs = children; children = new SafeArrayList<>(Spatial.class); super.write(e); OutputCapsule capsule = e.getCapsule(this); capsule.writeSavableArrayList(assetLoaderKeys, "assetLoaderKeyList", null); children = childs; } }
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; }
@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; }
/** * Create a shallow clone of this Mesh. The {@link VertexBuffer vertex * buffers} are shared between this and the clone mesh, the rest * of the data is cloned. * * @return A shallow clone of the mesh */ @Override public Mesh clone() { try { Mesh clone = (Mesh) super.clone(); clone.meshBound = meshBound.clone(); clone.collisionTree = collisionTree != null ? collisionTree : null; clone.buffers = buffers.clone(); clone.buffersList = new SafeArrayList<>(VertexBuffer.class, buffersList); clone.vertexArrayID = -1; if (elementLengths != null) { clone.elementLengths = elementLengths.clone(); } if (modeStart != null) { clone.modeStart = modeStart.clone(); } return clone; } catch (CloneNotSupportedException ex) { throw new AssertionError(); } }
@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); }
@Override public Node clone(boolean cloneMaterials) { BatchNode clone = (BatchNode) super.clone(cloneMaterials); if (batches.size() > 0) { for (Batch b : batches) { for (int i = 0; i < clone.children.size(); i++) { if (clone.children.get(i).getName().equals(b.geometry.getName())) { clone.children.remove(i); break; } } } clone.needsFullRebatch = true; clone.batches = new SafeArrayList<Batch>(Batch.class); clone.batchesByGeom = new HashMap<Geometry, Batch>(); clone.batch(); } return clone; }
@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); } } } }
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); ArrayList<MatParamOverride> localOverridesList = ic.readSavableArrayList("overrides", null); if (localOverridesList == null) { localOverrides = new SafeArrayList<>(MatParamOverride.class); } else { localOverrides = new SafeArrayList(MatParamOverride.class, localOverridesList); } worldOverrides = new SafeArrayList<>(MatParamOverride.class); //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); }
public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); numSamples = ic.readInt("numSamples", 0); filters = new SafeArrayList<Filter>(Filter.class, ic.readSavableArrayList("filters", null)); for (Filter filter : filters.getArray()) { filter.setProcessor(this); setFilterState(filter, filter.isEnabled()); } assetManager = im.getAssetManager(); }
clone.buffersList = new SafeArrayList<>(VertexBuffer.class); for (VertexBuffer vb : buffersList.getArray()){ VertexBuffer bufClone = vb.clone();