Java Code Examples for com.jme3.scene.Node

The following examples show how to use com.jme3.scene.Node. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Lemur   Source File: GridPanel.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void refreshGrid() {
    if( model == null ) {
        getControl(GuiControl.class).getLayout().clearChildren();
        return;
    }

    for( int r = row; r < row + visibleRows; r++ ) {
        for( int c = column; c < column + visibleColumns; c++ ) {                
            Node existing = layout.getChild(r-row, c-column);
            if( r < 0 || r >= model.getRowCount() || c < 0 || c >= model.getColumnCount() ) {
                // Out of bounds
                layout.addChild(null, r-row, c-column);
            } else {
                Panel child = model.getCell(r, c, (Panel)existing);
                if( child != existing ) {
                    // Make sure new children pick up the alpha of the container
                    if( alpha != null && alpha != 1 ) {
                        child.setAlpha(alpha);
                    }
                    layout.addChild(child, r-row, c-column);
                }                    
            }                
        }    
    }    
}
 
Example 2
public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall2.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess", 0);

    Node floorGeom = (Node) assetManager.loadAsset("Models/WaterTest/WaterTest.mesh.xml");
    Geometry g = ((Geometry) floorGeom.getChild(0));
    g.getMesh().scaleTextureCoordinates(new Vector2f(10, 10));
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(0, 22, 0);
    floorGeom.setLocalScale(100);

    floorGeom.setMaterial(mat);        
    rootNode.attachChild(floorGeom);
}
 
Example 3
Source Project: jmonkeybuilder   Source File: SlopeTerrainToolControl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@JmeThread
protected void onAttached(@NotNull Node node) {
    super.onAttached(node);

    var editedModel = notNull(getPaintedModel());
    var baseMarker = getBaseMarker();
    var targetMarker = getTargetMarker();
    var line = getLine();

    var markersNode = component.getMarkersNode();
    markersNode.attachChild(baseMarker);
    markersNode.attachChild(targetMarker);
    markersNode.attachChild(line);

    baseMarker.setLocalTranslation(editedModel.getWorldTranslation());
    targetMarker.setLocalTranslation(editedModel.getWorldTranslation());
}
 
Example 4
/**
 * Rotate the billboard so it points directly opposite the direction the
 * camera's facing
 *
 * @param camera
 *            Camera
 */
private void rotateScreenAligned(Camera camera) {
    // coopt diff for our in direction:
    look.set(camera.getDirection()).negateLocal();
    // coopt loc for our left direction:
    left.set(camera.getLeft()).negateLocal();
    orient.fromAxes(left, camera.getUp(), look);
    Node parent = spatial.getParent();
    Quaternion rot=new Quaternion().fromRotationMatrix(orient);
    if ( parent != null ) {
        rot =  parent.getWorldRotation().inverse().multLocal(rot);
        rot.normalizeLocal();
    }
    spatial.setLocalRotation(rot);
    fixRefreshFlags();
}
 
Example 5
Source Project: MikuMikuStudio   Source File: Octree.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
private static List<Geometry> getGeometries(Spatial scene){
    if (scene instanceof Geometry){
        List<Geometry> geomList = new ArrayList<Geometry>(1);
        geomList.add((Geometry) scene);
        return geomList;
    }else if (scene instanceof Node){
        Node n = (Node) scene;
        List<Geometry> geoms = new ArrayList<Geometry>();
        for (Spatial child : n.getChildren()){
            geoms.addAll(getGeometries(child));
        }
        return geoms;
    }else{
        throw new UnsupportedOperationException("Unsupported scene element class");
    }
}
 
Example 6
private void createMarkerPoints(float count) {
    Node center = createAxisMarker(10);
    markers.attachChild(center);
    
    float xS = (count-1)*terrain.getTerrainSize() - (terrain.getTerrainSize()/2);
    float zS = (count-1)*terrain.getTerrainSize() - (terrain.getTerrainSize()/2);
    float xSi = xS;
    float zSi = zS;
    for (int x=0; x<count*2; x++) {
        for (int z=0; z<count*2; z++) {
            Node m = createAxisMarker(5);
            m.setLocalTranslation(xSi, 0, zSi);
            markers.attachChild(m);
            zSi += terrain.getTerrainSize();
        }
        zSi = zS;
        xSi += terrain.getTerrainSize();
    }
}
 
Example 7
public void makeToonish(Spatial spatial){
        if (spatial instanceof Node){
            Node n = (Node) spatial;
            for (Spatial child : n.getChildren())
                makeToonish(child);
        }else if (spatial instanceof Geometry){
            Geometry g = (Geometry) spatial;
            Material m = g.getMaterial();
            if (m.getMaterialDef().getName().equals("Phong Lighting")){
                Texture t = assetManager.loadTexture("Textures/ColorRamp/toon.png");
//                t.setMinFilter(Texture.MinFilter.NearestNoMipMaps);
//                t.setMagFilter(Texture.MagFilter.Nearest);
                m.setTexture("ColorRamp", t);
                m.setBoolean("UseMaterialColors", true);
                m.setColor("Specular", ColorRGBA.Black);
                m.setColor("Diffuse", ColorRGBA.White);
                m.setBoolean("VertexLighting", true);
            }
        }
    }
 
Example 8
/**
 * Update this control. Invoked once per frame during the logical-state
 * update, provided the control is enabled and added to a scene. Should be
 * invoked only by a subclass or by AbstractControl.
 *
 * @param tpf the time interval between frames (in seconds, &ge;0)
 */
@Override
protected void controlUpdate(float tpf) {
    CollisionShape newShape = body.getCollisionShape();
    Vector3f newScale = newShape.getScale();
    if (myShape != newShape || !oldScale.equals(newScale)) {
        myShape = newShape;
        oldScale.set(newScale);

        Node node = (Node) spatial;
        node.detachChild(geom);

        geom = DebugShapeFactory.getDebugShape(myShape);
        geom.setName(body.toString());

        node.attachChild(geom);
    }
    geom.setMaterial(debugAppState.DEBUG_YELLOW);

    body.getPhysicsLocation(location);
    body.getPhysicsRotation(rotation);
    applyPhysicsTransform(location, rotation);
}
 
Example 9
public void linkModel(final AssetManager manager, final String assetName, final Vector3f location) {
    if (selectedSpat == null) {
        return;
    }
    final Node selected = selectedSpat.getLookup().lookup(Node.class);
    if (selected != null) {
        setNeedsSave(true);
        SceneApplication.getApplication().enqueue(new Callable<Object>() {
            
            public Object call() throws Exception {
                doLinkModel(manager, assetName, selected, location);
                return null;
            }
        });
    } else {
        displayInfo("Please select a Node to attach to\nin the SceneExplorer.");
    }
}
 
Example 10
private void setupSkyBox() {
    Mesh sphere = new Sphere(32, 32, 10f);
    sphere.setStatic();
    skyBox = new Geometry("SkyBox", sphere);
    skyBox.setQueueBucket(Bucket.Sky);
    skyBox.setShadowMode(ShadowMode.Off);

    Image cube = SceneApplication.getApplication().getAssetManager().loadTexture("Textures/blue-glow-1024.dds").getImage();
    TextureCubeMap cubemap = new TextureCubeMap(cube);

    Material mat = new Material(SceneApplication.getApplication().getAssetManager(), "Common/MatDefs/Misc/Sky.j3md");
    mat.setBoolean("SphereMap", false);
    mat.setTexture("Texture", cubemap);
    mat.setVector3("NormalScale", new Vector3f(1, 1, 1));
    skyBox.setMaterial(mat);

    ((Node) SceneApplication.getApplication().getViewPort().getScenes().get(0)).attachChild(skyBox);
}
 
Example 11
private void initScene() {
    //init cam location
    cam.setLocation(new Vector3f(0, 10, 10));
    cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
    //init scene
    sceneNode = new Node("Scene");
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
    Box b = new Box(1, 1, 1);
    Geometry geom = new Geometry("Box", b);
    geom.setMaterial(mat);
    sceneNode.attachChild(geom);

    // load sky
    sceneNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
    rootNode.attachChild(sceneNode);

    //add lightPos Geometry
    Sphere lite=new Sphere(8, 8, 3.0f);
    lightSphere=new Geometry("lightsphere", lite);
    lightSphere.setMaterial(mat);
    lightSphere.setLocalTranslation(lightPos);
    rootNode.attachChild(lightSphere);
}
 
Example 12
@Override
@FxThread
protected void process() {
    super.process();

    final TreeNode<?> treeNode = getNode();
    final Node node = (Node) treeNode.getElement();

    EXECUTOR_MANAGER.addJmeTask(() -> visitSpatial(node, ParticleEmitter.class, ParticleEmitter::killAllParticles));
    ADDITIONAL_ACTIONS.forEach(node, (factory, toCheck) -> {
        final Runnable action = factory.apply(toCheck);
        if (action != null) {
            EXECUTOR_MANAGER.addJmeTask(action);
        }
    });
}
 
Example 13
/**
 * Removes all physics controls and joints in the given spatial from the physics space
 * (e.g. before saving to disk) - recursive if node
 * @param spatial the rootnode containing the physics objects
 */
public void removeAll(Spatial spatial) {
    if (spatial.getControl(RigidBodyControl.class) != null) {
        RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class);
        //remove joints with physicsNode as BodyA
        List<PhysicsJoint> joints = physicsNode.getJoints();
        for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) {
            PhysicsJoint physicsJoint = it1.next();
            if (physicsNode.equals(physicsJoint.getBodyA())) {
                removeJoint(physicsJoint);
                //remove(physicsJoint.getBodyB());
            }
        }
    }
    
    remove(spatial);
    //recursion
    if (spatial instanceof Node) {
        List<Spatial> children = ((Node) spatial).getChildren();
        for (Iterator<Spatial> it = children.iterator(); it.hasNext();) {
            Spatial spat = it.next();
            removeAll(spat);
        }
    }
}
 
Example 14
Node createTestNode(float mass, Vector3f location) {
    float size = 0.1f;
    Vector3f halfExtents = new Vector3f(size, size, size);
    CollisionShape shape = new BoxCollisionShape(halfExtents);
    RigidBodyControl control = new RigidBodyControl(shape, mass);
    Node node = new Node();
    node.addControl(control);
    rootNode.attachChild(node);
    bulletAppState.getPhysicsSpace().add(node);
    control.setPhysicsLocation(location);

    return node;
}
 
Example 15
@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(50);
    Node scene = new Node("Scene");
    Spatial obj1 = assetManager.loadModel("Models/Ferrari/Car.scene");
    obj1.setLocalTranslation(-4, 0, 0);
    Spatial obj2 = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    obj2.setLocalTranslation(-2, 0, 0);
    Spatial obj3 = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
    obj3.setLocalTranslation(-0, 0, 0);
    Spatial obj4 = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
    obj4.setLocalTranslation(2, 0, 0);
    Spatial obj5 = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
    obj5.setLocalTranslation(4, 0, 0);
    scene.attachChild(obj1);
    scene.attachChild(obj2);
    scene.attachChild(obj3);
    scene.attachChild(obj4);
    scene.attachChild(obj5);

    Geometry geom = TextureAtlas.makeAtlasBatch(scene, assetManager, 2048);

    AmbientLight al = new AmbientLight();
    rootNode.addLight(al);

    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(0.69077975f, -0.6277887f, -0.35875428f).normalizeLocal());
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    rootNode.addLight(sun);

    rootNode.attachChild(geom);

    //quad to display material
    Geometry box = new Geometry("displayquad", new Quad(4, 4));
    box.setMaterial(geom.getMaterial());
    box.setLocalTranslation(0, 1, 3);
    rootNode.attachChild(box);
}
 
Example 16
public void save() throws IOException {
    SceneApplication.getApplication().enqueue(new Callable() {

        public Object call() throws Exception {
            currentFileObject.saveAsset();
            //TerrainSaveCookie sc = currentFileObject.getCookie(TerrainSaveCookie.class);
            //if (sc != null) {
                Node root = rootNode.getLookup().lookup(Node.class);
                doSaveAlphaImages((Terrain)getTerrain(root));
            //}
            return null;
        }
    });
}
 
Example 17
protected Node createAxisMarker(float arrowSize) {

        Material redMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        redMat.getAdditionalRenderState().setWireframe(true);
        redMat.setColor("Color", ColorRGBA.Red);
        
        Material greenMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        greenMat.getAdditionalRenderState().setWireframe(true);
        greenMat.setColor("Color", ColorRGBA.Green);
        
        Material blueMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        blueMat.getAdditionalRenderState().setWireframe(true);
        blueMat.setColor("Color", ColorRGBA.Blue);

        Node axis = new Node();

        // create arrows
        Geometry arrowX = new Geometry("arrowX", new Arrow(new Vector3f(arrowSize, 0, 0)));
        arrowX.setMaterial(redMat);
        Geometry arrowY = new Geometry("arrowY", new Arrow(new Vector3f(0, arrowSize, 0)));
        arrowY.setMaterial(greenMat);
        Geometry arrowZ = new Geometry("arrowZ", new Arrow(new Vector3f(0, 0, arrowSize)));
        arrowZ.setMaterial(blueMat);
        axis.attachChild(arrowX);
        axis.attachChild(arrowY);
        axis.attachChild(arrowZ);

        //axis.setModelBound(new BoundingBox());
        return axis;
    }
 
Example 18
private void addSpatialUndo(final Node undoParent, final Spatial undoSpatial, final AbstractSceneExplorerNode parentNode) {
    //add undo
    if (undoParent != null && undoSpatial != null) {
        Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {

            @Override
            public void sceneUndo() throws CannotUndoException {
                //undo stuff here
                undoSpatial.removeFromParent();
            }

            @Override
            public void sceneRedo() throws CannotRedoException {
                //redo stuff here
                undoParent.attachChild(undoSpatial);
            }

            @Override
            public void awtRedo() {
                if (parentNode != null) {
                    parentNode.refresh(true);
                }
            }

            @Override
            public void awtUndo() {
                if (parentNode != null) {
                    parentNode.refresh(true);
                }
            }
        });
    }
}
 
Example 19
@Override
public Node apply(Node node, BlenderContext blenderContext) {
    if (invalid) {
        LOGGER.log(Level.WARNING, "Particles modifier is invalid! Cannot be applied to: {0}", node.getName());
        return node;
    }

    MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class);
    ParticleEmitter emitter = particleEmitter.clone();

    // veryfying the alpha function for particles' texture
    Integer alphaFunction = MaterialHelper.ALPHA_MASK_HYPERBOLE;
    char nameSuffix = emitter.getName().charAt(emitter.getName().length() - 1);
    if (nameSuffix == 'B' || nameSuffix == 'N') {
        alphaFunction = MaterialHelper.ALPHA_MASK_NONE;
    }
    // removing the type suffix from the name
    emitter.setName(emitter.getName().substring(0, emitter.getName().length() - 1));

    // applying emitter shape
    EmitterShape emitterShape = emitter.getShape();
    List<Mesh> meshes = new ArrayList<Mesh>();
    for (Spatial spatial : node.getChildren()) {
        if (spatial instanceof Geometry) {
            Mesh mesh = ((Geometry) spatial).getMesh();
            if (mesh != null) {
                meshes.add(mesh);
                Material material = materialHelper.getParticlesMaterial(((Geometry) spatial).getMaterial(), alphaFunction, blenderContext);
                emitter.setMaterial(material);// TODO: divide into several pieces
            }
        }
    }
    if (meshes.size() > 0 && emitterShape instanceof EmitterMeshVertexShape) {
        ((EmitterMeshVertexShape) emitterShape).setMeshes(meshes);
    }

    node.attachChild(emitter);
    return node;
}
 
Example 20
public void childrenAdded(NodeMemberEvent ev) {
    boolean isTerrain = false;
    for(org.openide.nodes.Node n : ev.getSnapshot()) {
        Node node = n.getLookup().lookup(Node.class);
        if (node instanceof Terrain) {
            isTerrain = true;
            break;
        }
    }
    if (isTerrain)
        topComponent.reinitTextureTable();
}
 
Example 21
@Override
public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);
    this.inputManager = app.getInputManager();
    target = new Node("ChaseCamTarget");
    camNode.setCamera(app.getCamera());        
    camNode.setControlDir(CameraControl.ControlDirection.SpatialToCamera);
    target.attachChild(camNode);
    camNode.setLocalTranslation(0, 0, distance);
    upVector = app.getCamera().getUp().clone();
    leftVector = app.getCamera().getLeft().clone();
    registerWithInput();
    rotateCamera();
}
 
Example 22
private void resetHeight(Terrain terrain, List<Vector2f> undoLocs, List<Float> undoHeights) {
    List<Float> neg = new ArrayList<Float>();
    for (Float f : undoHeights)
        neg.add( f * -1f );
    
    terrain.adjustHeight(undoLocs, neg);
    ((Node)terrain).updateModelBound();
}
 
Example 23
Source Project: jmonkeybuilder   Source File: SlopeTerrainToolControl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@JmeThread
protected void onDetached(@NotNull Node node) {
    super.onDetached(node);

    var baseMarker = getBaseMarker();
    var targetMarker = getTargetMarker();
    var line = getLine();

    var markersNode = component.getMarkersNode();
    markersNode.detachChild(baseMarker);
    markersNode.detachChild(targetMarker);
    markersNode.detachChild(line);
}
 
Example 24
Source Project: jmonkeybuilder   Source File: LevelTerrainToolControl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@JmeThread
protected void onAttached(@NotNull Node node) {
    super.onAttached(node);

    var editedModel = notNull(getPaintedModel());
    var levelMarker = getLevelMarker();

    component.getMarkersNode()
            .attachChild(levelMarker);

    levelMarker.setLocalTranslation(editedModel.getWorldTranslation());
}
 
Example 25
/**
 * Enumerate all animated meshes in the specified subtree of a scene graph.
 * Note: recursive!
 *
 * @param subtree which subtree (aliases created)
 * @param storeResult (added to if not null)
 * @return an expanded list (either storeResult or a new instance)
 */
static List<Mesh> listAnimatedMeshes(Spatial subtree,
        List<Mesh> storeResult) {
    if (storeResult == null) {
        storeResult = new ArrayList<>(10);
    }

    if (subtree instanceof Geometry) {
        Geometry geometry = (Geometry) subtree;
        Mesh mesh = geometry.getMesh();
        VertexBuffer indices = mesh.getBuffer(VertexBuffer.Type.BoneIndex);
        boolean hasIndices = indices != null;
        VertexBuffer weights = mesh.getBuffer(VertexBuffer.Type.BoneWeight);
        boolean hasWeights = weights != null;
        if (hasIndices && hasWeights && !storeResult.contains(mesh)) {
            storeResult.add(mesh);
        }

    } else if (subtree instanceof Node) {
        Node node = (Node) subtree;
        List<Spatial> children = node.getChildren();
        for (Spatial child : children) {
            listAnimatedMeshes(child, storeResult);
        }
    }

    return storeResult;
}
 
Example 26
@Override
public void simpleInitApp() {
    Spatial ogreModel = assetManager.loadModel("Models/Oto/Oto.mesh.xml");

    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White);
    dl.setDirection(new Vector3f(0,-1,-1).normalizeLocal());
    rootNode.addLight(dl);

    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        BinaryExporter exp = new BinaryExporter();
        exp.save(ogreModel, baos);

        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        BinaryImporter imp = new BinaryImporter();
        imp.setAssetManager(assetManager);
        Node ogreModelReloaded = (Node) imp.load(bais, null, null);

        AnimComposer composer = ogreModelReloaded.getControl(AnimComposer.class);
        composer.setCurrentAction("Walk");

        rootNode.attachChild(ogreModelReloaded);
    } catch (IOException ex){
        ex.printStackTrace();
    }
}
 
Example 27
public AdvancedPbrWithStudioSky3DEditorPart(@NotNull final T fileEditor) {
    super(fileEditor);

    final AssetManager assetManager = EditorUtil.getAssetManager();
    final Geometry sky = (Geometry) SkyFactory.createSky(assetManager, "graphics/textures/sky/studio.hdr",
            SkyFactory.EnvMapType.EquirectMap);

    final Node stateNode = getStateNode();
    stateNode.attachChild(sky);
}
 
Example 28
private Node createLimb(float width, float height, Vector3f location, boolean rotate) {
    int axis = rotate ? PhysicsSpace.AXIS_X : PhysicsSpace.AXIS_Y;
    CapsuleCollisionShape shape = new CapsuleCollisionShape(width, height, axis);
    Node node = new Node("Limb");
    RigidBodyControl rigidBodyControl = new RigidBodyControl(shape, 1);
    node.setLocalTranslation(location);
    node.addControl(rigidBodyControl);
    return node;
}
 
Example 29
@Override
public void simpleInitApp() {
    Spatial ogreModel = assetManager.loadModel("Models/Oto/Oto.mesh.xml");

    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White);
    dl.setDirection(new Vector3f(0,-1,-1).normalizeLocal());
    rootNode.addLight(dl);

    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        BinaryExporter exp = new BinaryExporter();
        exp.save(ogreModel, baos);

        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        BinaryImporter imp = new BinaryImporter();
        imp.setAssetManager(assetManager);
        Node ogreModelReloaded = (Node) imp.load(bais, null, null);
        
        AnimControl control = ogreModelReloaded.getControl(AnimControl.class);
        AnimChannel chan = control.createChannel();
        chan.setAnim("Walk");

        rootNode.attachChild(ogreModelReloaded);
    } catch (IOException ex){
        ex.printStackTrace();
    }
}
 
Example 30
@Override
public void simpleInitApp() {
  // activate physics
  bulletAppState = new BulletAppState();
  stateManager.attach(bulletAppState);

  // init a physical test scene
  PhysicsTestHelper.createPhysicsTestWorldSoccer(rootNode, assetManager, bulletAppState.getPhysicsSpace());
  setupKeys();

  // Add a physics character to the world
  physicsCharacter = new CharacterControl(new CapsuleCollisionShape(0.5f, 1.8f), .1f);
  physicsCharacter.setPhysicsLocation(new Vector3f(0, 1, 0));
  characterNode = new Node("character node");
  Spatial model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
  model.scale(0.25f);
  characterNode.addControl(physicsCharacter);
  getPhysicsSpace().add(physicsCharacter);
  rootNode.attachChild(characterNode);
  characterNode.attachChild(model);

  // set forward camera node that follows the character
  camNode = new CameraNode("CamNode", cam);
  camNode.setControlDir(ControlDirection.SpatialToCamera);
  camNode.setLocalTranslation(new Vector3f(0, 1, -5));
  camNode.lookAt(model.getLocalTranslation(), Vector3f.UNIT_Y);
  characterNode.attachChild(camNode);

  //disable the default 1st-person flyCam (don't forget this!!)
  flyCam.setEnabled(false);

}