How to change the car body to another model in TestFancyCar?

in TestFancyCar, a portion of the code to create the car vehicle is as follows:



//Load model and get chassis Geometry

carNode = (Node)assetManager.loadModel(“Models/Ferrari/Car.scene”);

carNode.setShadowMode(ShadowMode.Cast);

Geometry chasis = findGeom(carNode, “Car”);

BoundingBox box = (BoundingBox) chasis.getModelBound();



//Create a hull collision shape for the chassis

CollisionShape carHull = CollisionShapeFactory.createDynamicMeshShape(chasis);



however i can’t just change the model loaded to another one that i have!

i’m guessing it’s because my own model doesn’t have a findGeom()?

so what do i have to do to be able to load another car model?



please help!!

You can’t just load any car model you find on the net.

In order for the physics engine to recognize your model, you have to split the car chasis from its wheels, and then load each wheel separately.

what if my vehicle model already has no wheels? it’s a model created in blender specially for this purpose but i’ve no idea how to load the model correctly to make it work

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_asset

i’m able to load models in other programs, but in this case with the car, i can’t. it generates an error whenever i change the reference name for the model.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies

what i did was:



//Load model and get chassis Geometry

(1) carNode = (Node)assetManager.loadModel(“Models/Bus/Scene.scene”); //replaced this with an existing bus model i created

(2) carNode.setShadowMode(ShadowMode.Cast);

(3) Geometry chasis = findGeom(carNode, “Car”);

(4) BoundingBox box = (BoundingBox) chasis.getModelBound();



but it’ll generate a nullpointer exception to the line (4).

kindly advise…

You dont need to find a sub geometry. Just use the model as you loaded it.

Its probably not going to work. You need to understand the hierarchy of your model, so you need to open it in jMP, and see what the structure is in the scene graph view. Then you can see which nodes are where, and you can find them so you can use them for the physics. The wheels probably won’t work either since you need to know where to put them as well (once again, know your model).

As a last resort, I recommend you use the jMP vehicle editor