use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.
the class TerrainLodControl method write.
@Override
public void write(JmeExporter ex) throws IOException {
super.write(ex);
OutputCapsule oc = ex.getCapsule(this);
oc.write((Node) terrain, "terrain", null);
oc.write(lodCalculator, "lodCalculator", null);
}
use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.
the class AssetLinkNode method attachLinkedChildren.
/**
* Loads the linked children AssetKeys from the AssetManager and attaches them to the Node<br>
* If they are already attached, they will be reloaded.
* @param manager
*/
public void attachLinkedChildren(AssetManager manager) {
detachLinkedChildren();
for (Iterator<ModelKey> it = assetLoaderKeys.iterator(); it.hasNext(); ) {
ModelKey assetKey = it.next();
Spatial curChild = assetChildren.get(assetKey);
if (curChild != null) {
curChild.removeFromParent();
}
Spatial child = manager.loadAsset(assetKey);
attachChild(child);
assetChildren.put(assetKey, child);
}
}
use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.
the class AssetLinkNode method read.
@Override
public void read(JmeImporter e) throws IOException {
super.read(e);
InputCapsule capsule = e.getCapsule(this);
BinaryImporter importer = BinaryImporter.getInstance();
AssetManager loaderManager = e.getAssetManager();
assetLoaderKeys = (ArrayList<ModelKey>) capsule.readSavableArrayList("assetLoaderKeyList", new ArrayList<ModelKey>());
for (Iterator<ModelKey> it = assetLoaderKeys.iterator(); it.hasNext(); ) {
ModelKey modelKey = it.next();
AssetInfo info = loaderManager.locateAsset(modelKey);
Spatial child = null;
if (info != null) {
child = (Spatial) importer.load(info);
}
if (child != null) {
child.parent = this;
children.add(child);
assetChildren.put(modelKey, child);
} else {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot locate {0} for asset link node {1}", new Object[] { modelKey, key });
}
}
}
use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.
the class Spatial method oldClone.
/**
* The old clone() method that did not use the new Cloner utility.
*/
public Spatial oldClone(boolean cloneMaterial) {
try {
Spatial clone = (Spatial) super.clone();
if (worldBound != null) {
clone.worldBound = worldBound.clone();
}
clone.worldLights = worldLights.clone();
clone.localLights = localLights.clone();
// Set the new owner of the light lists
clone.localLights.setOwner(clone);
clone.worldLights.setOwner(clone);
clone.worldOverrides = new SafeArrayList<>(MatParamOverride.class);
clone.localOverrides = new SafeArrayList<>(MatParamOverride.class);
for (MatParamOverride override : localOverrides) {
clone.localOverrides.add((MatParamOverride) override.clone());
}
// No need to force cloned to update.
// This node already has the refresh flags
// set below so it will have to update anyway.
clone.worldTransform = worldTransform.clone();
clone.localTransform = localTransform.clone();
if (clone instanceof Node) {
Node node = (Node) this;
Node nodeClone = (Node) clone;
nodeClone.children = new SafeArrayList<Spatial>(Spatial.class);
for (Spatial child : node.children) {
Spatial childClone = child.clone(cloneMaterial);
childClone.parent = nodeClone;
nodeClone.children.add(childClone);
}
}
clone.parent = null;
clone.setBoundRefresh();
clone.setTransformRefresh();
clone.setLightListRefresh();
clone.setMatParamOverrideRefresh();
clone.controls = new SafeArrayList<Control>(Control.class);
for (int i = 0; i < controls.size(); i++) {
Control newControl = controls.get(i).cloneForSpatial(clone);
newControl.setSpatial(clone);
clone.controls.add(newControl);
}
if (userData != null) {
clone.userData = (HashMap<String, Savable>) userData.clone();
}
return clone;
} catch (CloneNotSupportedException ex) {
throw new AssertionError();
}
}
use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.
the class BillboardControl method rotateScreenAligned.
/**
* Rotate the billboard so it points directly opposite the direction the
* camera's facing
*
* @param camera
* Camera
*/
private void rotateScreenAligned(Camera camera) {
// coopt diff for our in direction:
look.set(camera.getDirection()).negateLocal();
// coopt loc for our left direction:
left.set(camera.getLeft()).negateLocal();
orient.fromAxes(left, camera.getUp(), look);
Node parent = spatial.getParent();
Quaternion rot = new Quaternion().fromRotationMatrix(orient);
if (parent != null) {
rot = parent.getWorldRotation().inverse().multLocal(rot);
rot.normalizeLocal();
}
spatial.setLocalRotation(rot);
fixRefreshFlags();
}
Aggregations