本文整理汇总了Java中com.jme3.scene.Spatial.depthFirstTraversal方法的典型用法代码示例。如果您正苦于以下问题:Java Spatial.depthFirstTraversal方法的具体用法?Java Spatial.depthFirstTraversal怎么用?Java Spatial.depthFirstTraversal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.scene.Spatial
的用法示例。
在下文中一共展示了Spatial.depthFirstTraversal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeSpatial
import com.jme3.scene.Spatial; //导入方法依赖的package包/类
public void removeSpatial(Spatial s) {
s.depthFirstTraversal(new SceneGraphVisitor(){
@Override
public void visit(Spatial sx) {
if(sx instanceof Geometry){
Geometry geo=(Geometry)sx;
Material mat=geo.getMaterial();
String mat_name=mat==null?null:mat.getName();
if(mat_name==null){
System.err.println("Invalid material or missing name");
}else{
Iterator<Entry> e_i=ENTRIES.iterator();
while(e_i.hasNext()){
if(e_i.next().geo==geo){
e_i.remove();
break;
}
}
}
}
}
});
}
示例2: notifyAdded
import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
* Notify about added a spatial.
*
* @param spatial the spatial.
*/
public void notifyAdded(@NotNull final Spatial spatial) {
spatial.depthFirstTraversal(child -> {
final SceneLayer layer = SceneLayer.getLayer(child);
if (layer == SceneLayer.NO_LAYER) return;
final TreeItem<TreeNode<?>> newLayerItem = findItemForValue(getTreeView(), layer);
final TreeItem<TreeNode<?>> treeItem = findItemForValue(getTreeView(), child);
if (newLayerItem != null && treeItem == null) {
final TreeNode<?> objectNode = FACTORY_REGISTRY.createFor(child);
newLayerItem.getChildren().add(new TreeItem<>(objectNode));
}
}, Spatial.DFSMode.POST_ORDER);
}
示例3: notifyRemoved
import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
* Notify about removed a spatial.
*
* @param spatial the spatial.
*/
public void notifyRemoved(@NotNull final Spatial spatial) {
spatial.depthFirstTraversal(child -> {
final SceneLayer layer = SceneLayer.getLayer(child);
if (layer == SceneLayer.NO_LAYER) return;
final TreeItem<TreeNode<?>> newLayerItem = findItemForValue(getTreeView(), layer);
final TreeItem<TreeNode<?>> treeItem = findItemForValue(getTreeView(), child);
if (newLayerItem != null && treeItem != null) {
newLayerItem.getChildren().remove(treeItem);
}
}, Spatial.DFSMode.POST_ORDER);
}
示例4: getChildren
import com.jme3.scene.Spatial; //导入方法依赖的package包/类
@Override
@FXThread
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {
final SceneLayer element = getElement();
final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class);
final ModelChangeConsumer changeConsumer = (ModelChangeConsumer) notNull(nodeTree.getChangeConsumer());
final Spatial currentModel = changeConsumer.getCurrentModel();
currentModel.depthFirstTraversal(spatial -> {
final SceneLayer layer = SceneLayer.getLayer(spatial);
if(layer == element) {
result.add(FACTORY_REGISTRY.createFor(spatial));
}
});
return result;
}
示例5: addSpatial
import com.jme3.scene.Spatial; //导入方法依赖的package包/类
public void addSpatial(Spatial s) {
NEED_SUBSTANCES_UPDATE=true;
s.depthFirstTraversal(new SceneGraphVisitor(){
@Override
public void visit(Spatial sx) {
if(sx instanceof Geometry){
Geometry geo=(Geometry)sx;
Material mat=geo.getMaterial();
String mat_name=mat==null?null:mat.getName();
if(mat_name==null){
System.err.println("Invalid material or missing name");
}else{
boolean exists=false;
Iterator<Entry> e_i=ENTRIES.iterator();
while(e_i.hasNext()){
if(e_i.next().geo==geo){
exists=true;
break;
}
}
if(!exists){
Entry e=new Entry();
e.geo=geo;
ENTRIES.add(e);
}
// Apply substance
}
}
}
});
}
示例6: updateNode
import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
* Update a spatial.
*
* @param spatial the spatial.
* @param physicsSpace the new physical space or null.
*/
private void updateNode(@NotNull final Spatial spatial, @Nullable final PhysicsSpace physicsSpace) {
spatial.depthFirstTraversal(spatial1 -> {
final int numControls = spatial1.getNumControls();
for (int i = 0; i < numControls; i++) {
final Control control = spatial1.getControl(i);
if (control instanceof PhysicsControl) {
((PhysicsControl) control).setPhysicsSpace(physicsSpace);
}
}
});
}