當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。