I’m trying model the growth of a tree like structure.Growing branches do not have a rigid body control due to the lack of scaling for cylinder collision shapes.
When a branch finishes growing I attempt to then replace that branch with a new brach/cylinder which has a rigid body control and collision shape.
The question is why is the collision shape incorrectly placed?. I checked that the debugger was not just drawing the collision shape incorrectly which was not the case.
// g = growing branches geometry
// c = growing branches cylinder shape
Vector3f localTransform = g.getLocalTranslation();
g.removeFromParent();
Cylinder solidCylinder = new Cylinder(10,10,c.getRadius(),gHeight,true);
Geometry solidGeom = new Geometry(g.getName()+"solid",solidCylinder);
solidGeom.setMaterial(mat);
cylinderCol = new CylinderCollisionShape(new Vector3f(c.getRadius(),gHeight/2,c.getRadius()),1);
cylinderPhys = new RigidBodyControl(cylinderCol,1f);
solidGeom.addControl(cylinderPhys);
bulletAppState.getPhysicsSpace().add(cylinderPhys);
rootNode.attachChild(solidGeom);
cylinderPhys.setPhysicsLocation(localTransform);
cylinderPhys.setPhysicsRotation(gRotate);// growing branches current rotation
Help is greatly appreciated