Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package playground;
- import com.jme3.app.SimpleApplication;
- import com.jme3.scene.Node;
- import com.jme3.scene.Spatial;
- public class TraversalTest extends SimpleApplication {
- @Override
- public void simpleInitApp() {
- Node n_1 = new Node("N-1");
- rootNode.attachChild(n_1);
- Node n_1_1 = new Node("N-1-1");
- n_1.attachChild(n_1_1);
- Node n_1_1_1 = new Node("N-1-1-1");
- n_1_1.attachChild(n_1_1_1);
- Node n_2 = new Node("N-2");
- rootNode.attachChild(n_2);
- Node n_2_1 = new Node("N-2-1");
- n_2.attachChild(n_2_1);
- Node n_2_1_1 = new Node("N-2-1-1");
- n_2_1.attachChild(n_2_1_1);
- /* Graph:
- Root Node
- N-1
- N-1-1
- N-1-1-1
- N-2
- N-2-1
- N-2-1-1
- */
- /* Expected Order (PRE):
- Root Node
- N-1
- N-1-1
- N-1-1-1
- N-2
- N-2-1
- N-2-1-1
- */
- /* Output currently (PRE_ORDER only applied to first call on rootNode):
- Root Node
- N-1-1-1
- N-1-1
- N-1
- N-2-1-1
- N-2-1
- N-2
- */
- /* Output after fix (passing mode to recursive calls in Node.depthFirstTraversal):
- Root Node
- N-1
- N-1-1
- N-1-1-1
- N-2
- N-2-1
- N-2-1-1
- */
- rootNode.depthFirstTraversal((Spatial spatial) -> {
- System.out.println(spatial.getName());
- }, Spatial.DFSMode.PRE_ORDER);
- }
- public static void main(String[] args) {
- TraversalTest app = new TraversalTest();
- app.setShowSettings(false);
- app.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement