Search in sources :

Example 6 with Cloner

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);
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 7 with Cloner

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;
}
Also used : Material(com.jme3.material.Material) Cloner(com.jme3.util.clone.Cloner)

Example 8 with Cloner

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;
}
Also used : Cloner(com.jme3.util.clone.Cloner)

Example 9 with Cloner

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();
}
Also used : Mesh(com.jme3.scene.Mesh)

Aggregations

Cloner (com.jme3.util.clone.Cloner)3 Material (com.jme3.material.Material)2 Mesh (com.jme3.scene.Mesh)2 VehicleWheel (com.jme3.bullet.objects.VehicleWheel)1 MatParam (com.jme3.material.MatParam)1 MatParamOverride (com.jme3.material.MatParamOverride)1 StaticPassLightingLogic (com.jme3.material.logic.StaticPassLightingLogic)1 Vector3f (com.jme3.math.Vector3f)1 Spatial (com.jme3.scene.Spatial)1 Control (com.jme3.scene.control.Control)1 Statement (com.jme3.util.blockparser.Statement)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1