com.jme3.scene.Spatial.clone()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中com.jme3.scene.Spatial.clone()方法的一些代码示例,展示了Spatial.clone()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spatial.clone()方法的具体详情如下:
包路径:com.jme3.scene.Spatial
类名称:Spatial
方法名:clone

Spatial.clone介绍

暂无

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * 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);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * @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);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@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;
  }

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@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(){

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

return ((Spatial) obj).clone();

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@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);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@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));
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

TangentBinormalGenerator.generate(obj[0]);
Spatial t = obj[0].clone(false);
t.setLocalScale(10f);
t.setMaterial(mat[1]);
  t = obj[FastMath.nextRandomInt(0, obj.length - 1)].clone(false);
  t.setLocalScale(FastMath.nextRandomFloat() * 10f);
  t.setMaterial(mat[FastMath.nextRandomInt(0, mat.length - 1)]);

代码示例来源:origin: info.projectkyoto/mms-engine

@Override
public Object createClonedInstance(Object asset){
  Spatial model = (Spatial) asset;
  return model.clone();
}

代码示例来源:origin: info.projectkyoto/mms-engine

@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;
  }

代码示例来源:origin: org.jmonkeyengine/jme3-core

/**
 * 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);
}

代码示例来源:origin: org.jmonkeyengine/jme3-core

@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;
  }

代码示例来源:origin: org.jmonkeyengine/jme3-core

/**
 * @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);
}

代码示例来源:origin: info.projectkyoto/mms-engine

/**
 * @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);
}

代码示例来源:origin: org.jmonkeyengine/jme3-plugins

@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(){

代码示例来源:origin: org.jmonkeyengine/jme3-core

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;
}

代码示例来源:origin: info.projectkyoto/mms-engine

@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;
}

代码示例来源:origin: tonihele/OpenKeeper

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);
  }
}

代码示例来源:origin: tonihele/OpenKeeper

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;
}

相关文章

Spatial类方法