I’ve trying to make helicopter, based on fancyCar eample.
I’m creating CompoundCollisionShape with only body of vehicle, and move it down. (if a adding whole model it starts to roll, for my purpose shape of CompoundCollisionShape is not really important)
Spatial mi17Node = assetManager.loadModel(MI17_SCENE_LOCATION); Geometry body = findGeom(mi17Node, "body"); CollisionShape carHull = CollisionShapeFactory.createDynamicMeshShape(body); CompoundCollisionShape compoundCollisionShape=new CompoundCollisionShape(); carHull.setScale(new Vector3f(0.5f,0.5f,0.5f)); compoundCollisionShape.addChildShape(carHull, new Vector3f(0,-1,0)); vehicleControl = new VehicleControl(carHull, 400);
But when i adding whhels they connected to "strange "point. My hypothesis - this point is center of whole objects from .scene file
When i move compoundShape this “point” stays at same place
code for adding wheels:
private void addOneWheel(Spatial node, String nameOfPart, Vector3f addToCenter, Boolean isFrontWheel){
Geometry wheel = findGeom(node, nameOfPart);
wheel.setLocalRotation(new Quaternion().fromAngleAxis((float)Math.toRadians(180), new Vector3f(0, 1, 0)));
wheel.center();
BoundingBox box = (BoundingBox) wheel.getModelBound();
radius = box.getYExtent();
vehicleControl.addWheel(wheel.getParent(),box.getCenter().add(addToCenter), wheelDirection, wheelAxle, 0.2f, radius, isFrontWheel);
}
my question is: how can i move this point? maybe i misunderstood something in process of vehicle creation?
thank you