SceneEditor issues

I am using scene editor on the jMonkeyEngine SDK to load in 3dmodels. However, I am running into a couple of issues.

  1. It takes super long to render in the 3d models, which didn’t happen before. Here is the scene editor formatting:
    image

  2. I don’t know how to set collision detection to the model in the scene (the scene is a .j3o file). The objects just fall into the terrain like this:
    image

This is what the model looks like (for reference)

image

I am trying to drive a plane as a vehicle, the plane somehow rotates and falls, which I didn’t set. I am new to the physics library. Can somebody help me with my issues?

Here is the code for rendering in the model:

 bulletAppState = new BulletAppState();
        bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
        stateManager.attach(bulletAppState);
        terrain.setSupportMultipleCollisions(true); 
        terrain.addControl(new RigidBodyControl(0));
        bulletAppState.getPhysicsSpace().addAll(terrain);
        spaceShipShape = new CompoundCollisionShape();
        spaceship.addControl(new RigidBodyControl(0));
        bulletAppState.getPhysicsSpace().add(spaceship);
        playerCapsule = new CapsuleCollisionShape(1.5f, 15f, 1);
        character = new CharacterControl(playerCapsule, 0.2f);
        character.setJumpSpeed(20);
        character.setFallSpeed(50);
        character.setGravity(new Vector3f(0,-40f,0));
        character.setLinearVelocity(new Vector3f(400, 0, 400));
        character.setPhysicsLocation(new Vector3f(-30f, 100f, -101f)); 
        bulletAppState.getPhysicsSpace().add(character);
        float stiffness = 120.0f;//200=f1 car
        float compValue = 0.2f; //(lower than damp!)
        float dampValue = 0.3f;
        final float mass = 400;

        Node planeNode = (Node)assetManager.loadModel("Scenes/Plane2.j3o");
        planeNode.addControl(new RigidBodyControl(0));
        Geometry chasis = findGeom(planeNode, "Jet_Body") ;
        BoundingBox box = (BoundingBox) chasis.getModelBound();
        
        //Create a hull collision shape for the chassis
        CollisionShape carHull = CollisionShapeFactory.createDynamicMeshShape(chasis);

        //Create a vehicle control
        plane = new VehicleControl(carHull, mass);
        
        planeNode.addControl(plane);

        //Setting default values for wheels
        plane.setSuspensionCompression(compValue * 2.0f * FastMath.sqrt(stiffness));
        plane.setSuspensionDamping(dampValue * 2.0f * FastMath.sqrt(stiffness));
        plane.setSuspensionStiffness(stiffness);
        plane.setMaxSuspensionForce(10000);

        //Create four wheels and add them at their locations
        //note that our fancy car actually goes backwards..
        Vector3f wheelDirection = new Vector3f(0, -1, 0);
        Vector3f wheelAxle = new Vector3f(-1, 0, 0);

        Geometry wheel_fr = findGeom(planeNode, "WheelFrontRight");
        wheel_fr.center();
        box = (BoundingBox) wheel_fr.getModelBound();
        float wheelRadius = box.getYExtent();
        float back_wheel_h = (wheelRadius * 1.7f) - 1f;
        float front_wheel_h = (wheelRadius * 1.9f) - 1f;
        plane.addWheel(wheel_fr.getParent(), box.getCenter().add(0, -front_wheel_h, 0),
                wheelDirection, wheelAxle, 0.2f, wheelRadius, true);

       Geometry wheel_fl = findGeom(planeNode, "WheelFrontLeft");
        wheel_fl.center();
        box = (BoundingBox) wheel_fl.getModelBound();
        plane.addWheel(wheel_fl.getParent(), box.getCenter().add(0, -front_wheel_h, 0),
                wheelDirection, wheelAxle, 0.2f, wheelRadius, false);

        Geometry wheel_br = findGeom(planeNode, "WheelBackRight");
        wheel_br.center();
        box = (BoundingBox) wheel_br.getModelBound();
        plane.addWheel(wheel_br.getParent(), box.getCenter().add(0, -back_wheel_h, 0),
                wheelDirection, wheelAxle, 0.2f, wheelRadius, false);

        Geometry wheel_bl = findGeom(planeNode, "WheelBackLeft");
        wheel_bl.center();
        box = (BoundingBox) wheel_bl.getModelBound();
        plane.addWheel(wheel_bl.getParent(), box.getCenter().add(0, -back_wheel_h, 0),
                wheelDirection, wheelAxle, 0.2f, wheelRadius, false);

        plane.getWheel(2).setFrictionSlip(4);
        plane.getWheel(3).setFrictionSlip(4);
        

Thank you.

To see your physics object(s), enable debug:

bulletAppState.setDebugEnabled(true);

Ok – I loaded my .j3o into the game and am editing it using scene editor:
image
spaceship is a spatial → has the mesh called “Body”. I load this in. I want to get wheels on the plane using the same process as shown in the TestFancyCar.java.

Here is my wheel:
image
Would I need to do planeNode.attachChild(wheelNode1) to get the wheel attached like in TestFancyCar.java? This is as the wheels are not attached to the planeNode yet.

To add a wheel to the vehicle control use :

vehicleControl.addWheel(node1, new Vector3f(-xOff, yOff, zOff),
                    wheelDirection, wheelAxle, restLength, radius, true);

Where, node1 is the wheel node…

No

The code however is attaching a geometry
image
I am already attaching the geometry but not showing up/working

My model should have 3 wheels underneath:

image

But it has nothing at the bottom:
image

Here is what the scene looks like:
image

Here is my code:


        Node planeNode = (Node)spaceship;
        spaceship.scale(0.1f);
        planeNode.addControl(new RigidBodyControl(0));
        Geometry chasis = findGeom(planeNode, "Body") ;
        BoundingBox box = (BoundingBox) chasis.getModelBound();
        
       
        CollisionShape carHull = CollisionShapeFactory.createDynamicMeshShape(chasis);

        //Create a vehicle control
        plane = new VehicleControl(carHull, mass);
        
        planeNode.addControl(plane);

        //Setting default values for wheels
        plane.setSuspensionCompression(compValue * 2.0f * FastMath.sqrt(stiffness));
        plane.setSuspensionDamping(dampValue * 2.0f * FastMath.sqrt(stiffness));
        plane.setSuspensionStiffness(stiffness);
        plane.setMaxSuspensionForce(10000);

        //Create four wheels and add them at their locations
        //note that our fancy car actually goes backwards..
        Vector3f wheelDirection = new Vector3f(0, -1, 0);
        Vector3f wheelAxle = new Vector3f(-1, 0, 0);
        
       
        Geometry wheel_f = findGeom(planeNode, "WheelFront");
        wheel_f.center();
        
        box = (BoundingBox) wheel_f.getModelBound();
        float wheelRadius = box.getYExtent();
        float back_wheel_h = (wheelRadius * 1.7f) - 1f;
        float front_wheel_h = (wheelRadius * 1.9f) - 1f;
       
        plane.addWheel(wheel_f, new Vector3f(-159.85843f, -87.32049f, 497.02417f),
                wheelDirection, wheelAxle, 0.2f, wheelRadius, true);
       
       


my model keeps spinning out of control… somebody please help

I have sent you another example code on another thread, please have a look at

NB : in adding wheels you can use anything extending Spatial & Node extends Spatial & Geometry extends Spatial as well

So,

Node = Spatial + Some custom code

And,

Geometry = Spatial + More custom Code

But,

Spatial ≠ Node

Spatial ≠ Geometry

Node ≠ Geometry

Geometry ≠ Node

So, its Spatial Based Hierarchy…