Ok, so this is simple:
1 2 3 4 5 6 7 8 9 10
| private void load3DAssets(){ forestTemplateBG = new BranchGroup(); String filename = "props\\forest.obj"; ObjectFile f = new ObjectFile(ObjectFile.RESIZE); forestMesh = null; try { forestMesh = f.load(filename); } catch errors... } |
But then, i'm not sure how to cloneTree it ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| private void addTree(float posx, float posy, float posz){ TransformGroup tg = new TransformGroup(); tg.addChild(forestTemplateBG.cloneTree()); <-------???? tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D tr = new Transform3D(); tr.rotX( Math.PI / 2.0);
Vector3f translation = new Vector3f(posx, posy, posz + 0.1f); tr.setTranslation(translation); Vector3d scale = new Vector3d(0.5d, 0.5d, 0.5d); tr.setScale(scale); tg.setTransform(tr); forestBG.addChild(tg); forestBG.setPickable(false); forest.add( forestBG ); } |
"forest" at the end is an ArrayList of BranchGroup that i use to add to the scene with:
sceneBG.addChild( forest.get( forest.size()-1 ) );
each time i'm adding a forest to the game. (Working on the level editor right now.)
It might be clumsy but, but i'm still learning
