MinieExamples/src/main/java/jme3utilities/minie/test/TestDac.java
/**
     * Add a falling ball to the scene.
     */
Add a falling ball to the scene.
Add a falling ball to the scene .
private void addBall() {
        String name = nameGenerator.unique("ball");
        Geometry geometry = new Geometry(name, ballMesh);
        rootNode.attachChild(geometry);
        Material material = findMaterial("ball");
        geometry.setMaterial(material);
        geometry.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
        ShapeGenerator random = getGenerator();
        Vector3f location = random.nextVector3f();
        location.multLocal(2.5f, 5f, 2.5f);
        location.y += 20f;
        geometry.move(location);
        Vector3f worldScale = geometry.getWorldScale();
        CollisionShape shape = findShape("ball");
        shape.setScale(worldScale);
        float mass = 12f;
        RigidBodyControl rbc = new RigidBodyControl(shape, mass);
        rbc.setApplyScale(true);
        rbc.setLinearVelocity(new Vector3f(0f, -5f, 0f));
        rbc.setKinematic(false);
        rbc.setFriction(10f);
        addCollisionObject(rbc);
        rbc.setGravity(new Vector3f(0f, -1.5f, 0f));
        geometry.addControl(rbc);
    }
private void addBall ( ) { String name = nameGenerator . unique ( "ball" ) ; Geometry geometry = new Geometry ( name , ballMesh ) ; rootNode . attachChild ( geometry ) ; Material material = findMaterial ( "ball" ) ; geometry . setMaterial ( material ) ; geometry . setShadowMode ( RenderQueue . ShadowMode . CastAndReceive ) ; ShapeGenerator random = getGenerator ( ) ; Vector3f location = random . nextVector3f ( ) ; location . multLocal ( 2.5f , 5f , 2.5f ) ; location . y += 20f ; geometry . move ( location ) ; Vector3f worldScale = geometry . getWorldScale ( ) ; CollisionShape shape = findShape ( "ball" ) ; shape . setScale ( worldScale ) ; float mass = 12f ; RigidBodyControl rbc = new RigidBodyControl ( shape , mass ) ; rbc . setApplyScale ( true ) ; rbc . setLinearVelocity ( new Vector3f ( 0f , - 5f , 0f ) ) ; rbc . setKinematic ( false ) ; rbc . setFriction ( 10f ) ; addCollisionObject ( rbc ) ; rbc . setGravity ( new Vector3f ( 0f , - 1.5f , 0f ) ) ; geometry . addControl ( rbc ) ; }
Add a falling ball to the scene.
Add a falling ball to the scene .