当前位置: 首页>>代码示例>>Java>>正文


Java Spatial.depthFirstTraversal方法代码示例

本文整理汇总了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;
						}
					}
				}
			}
		}
	});
}
 
开发者ID:riccardobl,项目名称:JMELink-SP,代码行数:24,代码来源:SubstanceLinkAppState.java

示例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);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:22,代码来源:LayerNodeTree.java

示例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);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:LayerNodeTree.java

示例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;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:20,代码来源:SceneLayerTreeNode.java

示例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
				}
			}
		}
	});
}
 
开发者ID:riccardobl,项目名称:JMELink-SP,代码行数:32,代码来源:SubstanceLinkAppState.java

示例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);
            }
        }
    });
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:20,代码来源:ModelEditorBulletState.java


注:本文中的com.jme3.scene.Spatial.depthFirstTraversal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。