Making forest and cutting trees

hi, im new here.

i wana make some trees that can be cut down and be replaced with stomps. and lets say different trees need different amount of actions.

now i have class extending node with params and geometries.

when i coliding i only get geometry, is there a way to get the node, not the geometry?

lol find out that getParent actualy works. it was so stupid (ashame)

Otherwise you can setUserObject in the control to quickly get the node you want.

Is there a reason you are not using Bullet Physics like Ghost Objects?

It sounds to me like you want to use a Control.

i have lots of nodes, every three is a node. so i do on colision ((Tree)closest.getGeometry().getParent()).cut();

also its easy to get nodes by name.

still learning and do haven’t heard about setUserData, yet :slight_smile:

ok whats ghost object? havent heard about it eather :smiley:

im learning bit bi bit, trying to get familiar with jme stuff

now i have made that i can place trees on map and then cut wen clicking mouse. and trees need different amount of clicks

lots of objects isn’t really ideal. check the manual on “best practices”.

one more question. o have this tree class it basically creates stuff and places them.

i invoke it on ray hit terrain: root.shootables.attachChild(new Tree(this.root, closest.getContactPoint()));

everything works when i use GhostControl(i see trunk and collision shape).

But when i switch to RigidBodyControl i get trunk and collision stuff is misplaced somehow :frowning:

What might be wrong?

[java]public class Tree extends Node {

static int tree_id = 0;

private boolean cuttable = true;

private Game root;

private int id;

private int cuts = 5;

public Tree(Game root, Vector3f pos) {


this.root = root;

id = tree_id;





public void cut() {

if (!cuttable) return;


System.out.println("cutting tree id="+id+" cuts left:"+cuts);

if (cuts==0) this.removeFromParent();


private Geometry createTrunk() {

Cylinder c = new Cylinder(6, 30, 1f, 18f);

Geometry trunk = new Geometry("trunk-"+id, c);

Material mat1 = new Material(root.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");

mat1.setColor("Color", ColorRGBA.Brown);


trunk.rotate(90*FastMath.DEG_TO_RAD, 0, 0);

CylinderCollisionShape cs = new CylinderCollisionShape(new Vector3f(1f,0,9f), 2);

// GhostControl ph = new GhostControl(cs);

RigidBodyControl ph = new RigidBodyControl(cs, 0f);



return trunk;


private Geometry createLeaves() {

Sphere s = new Sphere(30, 30, 5.2f);

Geometry leaves = new Geometry("leaves", s);

Material mat = new Material(root.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");

mat.setColor("Color", ColorRGBA.Green);


leaves.move(0, 13, 0);

return leaves;