/** * This version of clone is a shallow clone, in other words, the * same mesh is referenced as the original geometry. * Exception: if the mesh is marked as being a software * animated mesh, (bind pose is set) then the positions * and normals are deep copied. */ @Override public Geometry clone(boolean cloneMaterial) { return (Geometry)super.clone(cloneMaterial); }
/** * @return A clone of this Spatial, the scene graph in its entirety * is cloned and can be altered independently of the original scene graph. * * Note that meshes of geometries are not cloned explicitly, they * are shared if static, or specially cloned if animated. * * @see Mesh#cloneForAnim() */ @Override public Spatial clone() { return clone(true); }
@Override public Node clone(boolean cloneMaterials){ Node nodeClone = (Node) super.clone(cloneMaterials); // nodeClone.children = new ArrayList<Spatial>(); // for (Spatial child : children){ // Spatial childClone = child.clone(); // childClone.parent = nodeClone; // nodeClone.children.add(childClone); // } // Reset the fields of the clone that should be in a 'new' state. nodeClone.updateList = null; nodeClone.updateListValid = false; // safe because parent is nulled out in super.clone() return nodeClone; }
@Override public Object load(AssetInfo info) throws IOException { AssetKey key=info.getKey(); Spatial output=cache.get(key); if(output==null){ output=(Spatial)super.load(info); cache.put(key,output); } return output.clone(false); } public void reset(){
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; }
return ((Spatial) obj).clone();
@Override public void simpleInitApp() { cam.setLocation(new Vector3f(10f, 3f, 40f)); cam.lookAtDirection(Vector3f.UNIT_Z.negate(), Vector3f.UNIT_Y); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); AnimComposer composer; Spatial originalModel = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); composer = originalModel.getControl(AnimComposer.class); composer.setCurrentAction("Walk"); rootNode.attachChild(originalModel); Spatial clonedModel = originalModel.clone(); clonedModel.move(10, 0, 0); composer = clonedModel.getControl(AnimComposer.class); composer.setCurrentAction("push"); rootNode.attachChild(clonedModel); Spatial exportedModel = BinaryExporter.saveAndLoad(assetManager, originalModel); exportedModel.move(20, 0, 0); composer = exportedModel.getControl(AnimComposer.class); composer.setCurrentAction("pull"); rootNode.attachChild(exportedModel); } }
@Override public void simpleInitApp() { flyCam.setMoveSpeed(10f); flyCam.setDragToRotate(true); setPauseOnLostFocus(false); cam.setLocation(new Vector3f(38.76639f, 14.744472f, 45.097454f)); cam.setRotation(new Quaternion(-0.06086266f, 0.92303723f, -0.1639443f, -0.34266636f)); makeHudText(); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); Spatial models[] = new Spatial[4]; for (int i = 0; i < 4; i++) { models[i] =loadModel(i); } for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { Node model = (Node)models[(i + j) % 4]; Spatial s = model.getChild(0).clone(); model.attachChild(s); float x = (float)(i - SIZE / 2) / 0.1f; float z = (float)(j - SIZE / 2) / 0.1f; s.setLocalTranslation(x, 0, z); } } inputManager.addListener(this, "toggleHWS"); inputManager.addMapping("toggleHWS", new KeyTrigger(KeyInput.KEY_SPACE)); }
@Override public Object createClonedInstance(Object asset){ Spatial model = (Spatial) asset; return model.clone(); }
@Override public Node clone(boolean cloneMaterials){ Node nodeClone = (Node) super.clone(cloneMaterials); // nodeClone.children = new ArrayList<Spatial>(); // for (Spatial child : children){ // Spatial childClone = child.clone(); // childClone.parent = nodeClone; // nodeClone.children.add(childClone); // } return nodeClone; }
/** * This version of clone is a shallow clone, in other words, the * same mesh is referenced as the original geometry. * Exception: if the mesh is marked as being a software * animated mesh, (bind pose is set) then the positions * and normals are deep copied. */ @Override public Geometry clone(boolean cloneMaterial) { return (Geometry)super.clone(cloneMaterial); }
@Override public Node clone(boolean cloneMaterials){ Node nodeClone = (Node) super.clone(cloneMaterials); // nodeClone.children = new ArrayList<Spatial>(); // for (Spatial child : children){ // Spatial childClone = child.clone(); // childClone.parent = nodeClone; // nodeClone.children.add(childClone); // } // Reset the fields of the clone that should be in a 'new' state. nodeClone.updateList = null; nodeClone.updateListValid = false; // safe because parent is nulled out in super.clone() return nodeClone; }
/** * @return A clone of this Spatial, the scene graph in its entirety * is cloned and can be altered independently of the original scene graph. * * Note that meshes of geometries are not cloned explicitly, they * are shared if static, or specially cloned if animated. * * All controls will be cloned using the Control.cloneForSpatial method * on the clone. * * @see Mesh#cloneForAnim() */ @Override public Spatial clone() { return clone(true); }
/** * @return A clone of this Spatial, the scene graph in its entirety * is cloned and can be altered independently of the original scene graph. * * Note that meshes of geometries are not cloned explicitly, they * are shared if static, or specially cloned if animated. * * All controls will be cloned using the Control.cloneForSpatial method * on the clone. * * @see Mesh#cloneForAnim() */ @Override public Spatial clone() { return clone(true); }
@Override public Object load(AssetInfo info) throws IOException { AssetKey key=info.getKey(); Spatial output=cache.get(key); if(output==null){ output=(Spatial)super.load(info); cache.put(key,output); } return output.clone(false); } public void reset(){
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 Spatial deepClone(){ 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; }
public void emitAllParticles() { for (int i = 0; i < effect.getElementsPerTurn(); i++) { Spatial s = spatial.clone(); if (effect.getFlags().contains(Effect.EffectFlag.RANDOM_DISTRIBUTION)) { } else if (effect.getFlags().contains(Effect.EffectFlag.UNIFORM_DISTRIBUTION)) { // TODO add to all s uniform parameters } s.addControl(new EffectElementControl(effectElement) { @Override public void onDie(Vector3f location) { EffectEmitter.this.onDeath(location); } @Override public void onHit(Vector3f location) { EffectEmitter.this.onHit(location); } }); this.attachChild(s); } }
private Spatial createFlame() { Spatial result = ((DesktopAssetManager) assetManager).getFromCache(ASSET_KEY); if (result == null) { try { material = createMaterial(); material.setTexture("DiffuseMap", createTexture()); result = new Geometry("torch flame", createMesh(0.5f, 0.5f)); result.setMaterial(material); result.setQueueBucket(RenderQueue.Bucket.Translucent); result.move(0.14f, 0.2f, 0); } catch (Exception e) { log.log(Level.WARNING, "Can't create torch flame", e); } ((DesktopAssetManager) assetManager).addToCache(ASSET_KEY, result); } if (result != null) { return result.clone(); } return null; }