本文整理了Java中com.ardor3d.scenegraph.Node.getChild()
方法的一些代码示例,展示了Node.getChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getChild()
方法的具体详情如下:
包路径:com.ardor3d.scenegraph.Node
类名称:Node
方法名:getChild
[英]getChild
returns a child at a given index.
[中]getChild
返回给定索引处的子级。
代码示例来源:origin: Renanse/Ardor3D
public Object getChild(final Object parent, final int index) {
if (parent instanceof UIFrame) {
return index == 0 ? ((UIFrame) parent).getContentPanel() : null;
}
if (parent instanceof Node) {
final Node parentNode = (Node) parent;
return parentNode.getChild(index);
}
return null;
}
代码示例来源:origin: com.ardor3d/ardor3d-animation
private Spatial findChild(final Spatial root, final String key) {
if (_spatialCache.containsKey(key)) {
return _spatialCache.get(key);
}
if (key.equals(root.getName())) {
_spatialCache.put(key, root);
return root;
} else if (root instanceof Node) {
final Spatial spat = ((Node) root).getChild(key);
if (spat != null) {
_spatialCache.put(key, spat);
return spat;
}
}
return null;
}
代码示例来源:origin: Renanse/Ardor3D
private Spatial findChild(final Spatial root, final String key) {
if (_spatialCache.containsKey(key)) {
return _spatialCache.get(key);
}
if (key.equals(root.getName())) {
_spatialCache.put(key, root);
return root;
} else if (root instanceof Node) {
final Spatial spat = ((Node) root).getChild(key);
if (spat != null) {
_spatialCache.put(key, spat);
return spat;
}
}
return null;
}
代码示例来源:origin: Renanse/Ardor3D
@Override
public void sortLights() {
for (int i = getNumberOfChildren() - 1; i >= 0; i--) {
final Spatial pkChild = getChild(i);
if (pkChild != null) {
pkChild.sortLights();
}
}
}
代码示例来源:origin: com.ardor3d/ardor3d-core
@Override
protected void updateChildren(final double time) {
for (int i = getNumberOfChildren() - 1; i >= 0; i--) {
final Spatial pkChild = getChild(i);
if (pkChild != null) {
pkChild.updateGeometricState(time, false);
}
}
}
代码示例来源:origin: com.ardor3d/ardor3d-core
@Override
public void sortLights() {
for (int i = getNumberOfChildren() - 1; i >= 0; i--) {
final Spatial pkChild = getChild(i);
if (pkChild != null) {
pkChild.sortLights();
}
}
}
代码示例来源:origin: Renanse/Ardor3D
@Override
protected void updateChildren(final double time) {
for (int i = getNumberOfChildren() - 1; i >= 0; i--) {
final Spatial pkChild = getChild(i);
if (pkChild != null) {
pkChild.updateGeometricState(time, false);
}
}
}
代码示例来源:origin: com.ardor3d/ardor3d-core
/**
* <code>getChild</code> returns the first child found with exactly the given name (case sensitive.) If our children
* are Nodes, we will search their children as well.
*
* @param name
* the name of the child to retrieve. If null, we'll return null.
* @return the child if found, or null.
*/
public Spatial getChild(final String name) {
if (name == null) {
return null;
}
for (int i = getNumberOfChildren() - 1; i >= 0; i--) {
final Spatial child = _children.get(i);
if (name.equals(child.getName())) {
return child;
} else if (child instanceof Node) {
final Spatial out = ((Node) child).getChild(name);
if (out != null) {
return out;
}
}
}
return null;
}
代码示例来源:origin: Renanse/Ardor3D
/**
* <code>getChild</code> returns the first child found with exactly the given name (case sensitive.) If our children
* are Nodes, we will search their children as well.
*
* @param name
* the name of the child to retrieve. If null, we'll return null.
* @return the child if found, or null.
*/
public Spatial getChild(final String name) {
if (name == null) {
return null;
}
for (int i = getNumberOfChildren() - 1; i >= 0; i--) {
final Spatial child = _children.get(i);
if (name.equals(child.getName())) {
return child;
} else if (child instanceof Node) {
final Spatial out = ((Node) child).getChild(name);
if (out != null) {
return out;
}
}
}
return null;
}
代码示例来源:origin: com.ardor3d/ardor3d-core
/**
* removes all collision trees associated with a Spatial object.
*
* @param object
* the spatial to remove all collision trees from.
*/
public void removeCollisionTree(final Spatial object) {
if (object instanceof Node) {
final Node n = (Node) object;
for (int i = n.getNumberOfChildren() - 1; i >= 0; i--) {
removeCollisionTree(n.getChild(i));
}
} else if (object instanceof Mesh) {
removeCollisionTree((Mesh) object);
}
}
代码示例来源:origin: Renanse/Ardor3D
/**
* removes all collision trees associated with a Spatial object.
*
* @param object
* the spatial to remove all collision trees from.
*/
public void removeCollisionTree(final Spatial object) {
if (object instanceof Node) {
final Node n = (Node) object;
for (int i = n.getNumberOfChildren() - 1; i >= 0; i--) {
removeCollisionTree(n.getChild(i));
}
} else if (object instanceof Mesh) {
removeCollisionTree((Mesh) object);
}
}
代码示例来源:origin: Renanse/Ardor3D
/**
* updates the existing tree(s) for a supplied spatial. If this tree does not exist, the tree is not updated. If the
* tree is not in the cache, no further operations are handled.
*
* @param object
* the object on which to update the tree.
*/
public void updateCollisionTree(final Spatial object) {
if (object instanceof Node) {
final Node n = (Node) object;
for (int i = n.getNumberOfChildren() - 1; i >= 0; i--) {
updateCollisionTree(n.getChild(i));
}
} else if (object instanceof Mesh) {
updateCollisionTree((Mesh) object);
}
}
代码示例来源:origin: com.ardor3d/ardor3d-core
/**
* updates the existing tree(s) for a supplied spatial. If this tree does not exist, the tree is not updated. If the
* tree is not in the cache, no further operations are handled.
*
* @param object
* the object on which to update the tree.
*/
public void updateCollisionTree(final Spatial object) {
if (object instanceof Node) {
final Node n = (Node) object;
for (int i = n.getNumberOfChildren() - 1; i >= 0; i--) {
updateCollisionTree(n.getChild(i));
}
} else if (object instanceof Mesh) {
updateCollisionTree((Mesh) object);
}
}
代码示例来源:origin: Renanse/Ardor3D
public static void trimEmptyBranches(final Spatial spatial) {
if (spatial instanceof Node) {
final Node node = (Node) spatial;
for (int i = node.getNumberOfChildren(); --i >= 0;) {
trimEmptyBranches(node.getChild(i));
}
if (node.getNumberOfChildren() <= 0) {
spatial.removeFromParent();
}
}
}
代码示例来源:origin: com.ardor3d/ardor3d-core
public static void trimEmptyBranches(final Spatial spatial) {
if (spatial instanceof Node) {
final Node node = (Node) spatial;
for (int i = node.getNumberOfChildren(); --i >= 0;) {
trimEmptyBranches(node.getChild(i));
}
if (node.getNumberOfChildren() <= 0) {
spatial.removeFromParent();
}
}
}
}
代码示例来源:origin: Renanse/Ardor3D
/**
* Recreate this Collision Tree for the given Node and child index.
*
* @param childIndex
* the index of the child to generate the tree for.
* @param parent
* The Node that this tree should represent.
* @param doSort
* true to sort primitives during creation, false otherwise
*/
public void construct(final int childIndex, final int section, final Node parent, final boolean doSort) {
final Spatial spat = parent.getChild(childIndex);
if (spat instanceof Mesh) {
_mesh = makeRef((Mesh) spat);
_primitiveIndices = new int[((Mesh) spat).getMeshData().getPrimitiveCount(section)];
for (int i = 0; i < _primitiveIndices.length; i++) {
_primitiveIndices[i] = i;
}
createTree(section, 0, _primitiveIndices.length, doSort);
}
}
代码示例来源:origin: com.ardor3d/ardor3d-core
/**
* Recreate this Collision Tree for the given Node and child index.
*
* @param childIndex
* the index of the child to generate the tree for.
* @param parent
* The Node that this tree should represent.
* @param doSort
* true to sort primitives during creation, false otherwise
*/
public void construct(final int childIndex, final int section, final Node parent, final boolean doSort) {
final Spatial spat = parent.getChild(childIndex);
if (spat instanceof Mesh) {
_mesh = makeRef((Mesh) spat);
_primitiveIndices = new int[((Mesh) spat).getMeshData().getPrimitiveCount(section)];
for (int i = 0; i < _primitiveIndices.length; i++) {
_primitiveIndices[i] = i;
}
createTree(section, 0, _primitiveIndices.length, doSort);
}
}
代码示例来源:origin: Renanse/Ardor3D
public static void findCollisions(final Spatial spatial, final Spatial scene, final CollisionResults results) {
if (spatial == scene || spatial.getWorldBound() == null
|| !spatial.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)
|| !scene.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) {
return;
}
if (spatial instanceof Node) {
final Node node = (Node) spatial;
if (node.getWorldBound().intersects(scene.getWorldBound())) {
// further checking needed.
for (int i = 0; i < node.getNumberOfChildren(); i++) {
PickingUtil.findCollisions(node.getChild(i), scene, results);
}
}
} else if (spatial instanceof Mesh) {
final Mesh mesh = (Mesh) spatial;
if (mesh.getWorldBound().intersects(scene.getWorldBound())) {
if (scene instanceof Node) {
final Node parent = (Node) scene;
for (int i = 0; i < parent.getNumberOfChildren(); i++) {
PickingUtil.findCollisions(mesh, parent.getChild(i), results);
}
} else {
results.addCollision(mesh, (Mesh) scene);
}
}
}
}
代码示例来源:origin: com.ardor3d/ardor3d-core
/**
* Finds a pick using the given ray starting at the scenegraph given as spatial. Results are stored in the given
* results value.
*
* @param spatial
* @param ray
* @param results
* @param ignoreCulled
* if true, Spatials with CullHint ALWAYS will be skipped.
*/
public static void findPick(final Spatial spatial, final Ray3 ray, final PickResults results,
final boolean ignoreCulled) {
if (spatial == null || !spatial.getSceneHints().isPickingHintEnabled(PickingHint.Pickable)
|| (ignoreCulled && spatial.getSceneHints().getCullHint() == CullHint.Always)
|| spatial.getWorldBound() == null || !spatial.getWorldBound().intersects(ray)) {
return;
}
if (spatial instanceof Pickable) {
results.addPick(ray, (Pickable) spatial);
} else if (spatial instanceof Node) {
final Node node = (Node) spatial;
for (int i = node.getNumberOfChildren() - 1; i >= 0; i--) {
findPick(node.getChild(i), ray, results, ignoreCulled);
}
}
}
代码示例来源:origin: Renanse/Ardor3D
/**
* Finds a pick using the given ray starting at the scenegraph given as spatial. Results are stored in the given
* results value.
*
* @param spatial
* @param ray
* @param results
* @param ignoreCulled
* if true, Spatials with CullHint ALWAYS will be skipped.
*/
public static void findPick(final Spatial spatial, final Ray3 ray, final PickResults results,
final boolean ignoreCulled) {
if (spatial == null || !spatial.getSceneHints().isPickingHintEnabled(PickingHint.Pickable)
|| (ignoreCulled && spatial.getSceneHints().getCullHint() == CullHint.Always)
|| spatial.getWorldBound() == null || !spatial.getWorldBound().intersects(ray)) {
return;
}
if (spatial instanceof Pickable) {
results.addPick(ray, (Pickable) spatial);
} else if (spatial instanceof Node) {
final Node node = (Node) spatial;
for (int i = node.getNumberOfChildren() - 1; i >= 0; i--) {
findPick(node.getChild(i), ray, results, ignoreCulled);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!