use of com.jme3.util.clone.Cloner in project jmonkeyengine by jMonkeyEngine.
the class ChaseCamera method cloneFields.
@Override
public void cloneFields(Cloner cloner, Object original) {
this.target = cloner.clone(target);
computePosition();
prevPos = new Vector3f(target.getWorldTranslation());
cam.setLocation(pos);
}
use of com.jme3.util.clone.Cloner in project jmonkeyengine by jMonkeyEngine.
the class Spatial method clone.
/**
* @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()
*/
public Spatial clone(boolean cloneMaterial) {
// Setup the cloner for the type of cloning we want to do.
Cloner cloner = new Cloner();
// First, we definitely do not want to clone our own parent
cloner.setClonedValue(parent, null);
// aren't cloned also
if (!cloneMaterial) {
cloner.setCloneFunction(Material.class, new IdentityCloneFunction<Material>());
}
// By default the meshes are not cloned. The geometry
// may choose to selectively force them to be cloned but
// normally they will be shared
cloner.setCloneFunction(Mesh.class, new IdentityCloneFunction<Mesh>());
// Clone it!
Spatial clone = cloner.clone(this);
// Because we've nulled the parent out we need to make sure
// the transforms and stuff get refreshed.
clone.setTransformRefresh();
clone.setLightListRefresh();
clone.setMatParamOverrideRefresh();
return clone;
}
use of com.jme3.util.clone.Cloner in project jmonkeyengine by jMonkeyEngine.
the class Spatial method deepClone.
/**
* @return Similar to Spatial.clone() except will create a deep clone of all
* geometries' meshes. Normally this method shouldn't be used. Instead, use
* Spatial.clone()
*
* @see Spatial#clone()
*/
public Spatial deepClone() {
// Setup the cloner for the type of cloning we want to do.
Cloner cloner = new Cloner();
// First, we definitely do not want to clone our own parent
cloner.setClonedValue(parent, null);
Spatial clone = cloner.clone(this);
// Because we've nulled the parent out we need to make sure
// the transforms and stuff get refreshed.
clone.setTransformRefresh();
clone.setLightListRefresh();
clone.setMatParamOverrideRefresh();
return clone;
}
use of com.jme3.util.clone.Cloner in project jmonkeyengine by jMonkeyEngine.
the class TerrainPatch method cloneFields.
/**
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
*/
@Override
public void cloneFields(Cloner cloner, Object original) {
super.cloneFields(cloner, original);
this.stepScale = cloner.clone(stepScale);
this.offset = cloner.clone(offset);
this.leftNeighbour = null;
this.topNeighbour = null;
this.rightNeighbour = null;
this.bottomNeighbour = null;
// Don't feel like making geomap cloneable tonight
// so I'll copy the old logic.
this.geomap = new LODGeomap(size, geomap.getHeightArray());
Mesh m = geomap.createMesh(stepScale, Vector2f.UNIT_XY, offset, offsetAmount, totalSize, false);
this.setMesh(m);
// In this case, we always clone material even if the cloner is setup
// not to clone it. Terrain uses mutable textures and stuff so it's important
// to clone it. (At least that's my understanding and is evidenced by the old
// clone code specifically cloning material.) -pspeed
this.material = material.clone();
}
Aggregations