Search in sources :

Example 1 with NiftyJmeDisplay

use of com.jme3.niftygui.NiftyJmeDisplay in project jmonkeyengine by jMonkeyEngine.

the class TestAppStates method initialize.

@Override
public void initialize() {
    super.initialize();
    System.out.println("Initialize");
    RootNodeState state = new RootNodeState();
    viewPort.attachScene(state.getRootNode());
    stateManager.attach(state);
    Spatial model = assetManager.loadModel("Models/Teapot/Teapot.obj");
    model.scale(3);
    model.setMaterial(assetManager.loadMaterial("Interface/Logo/Logo.j3m"));
    state.getRootNode().attachChild(model);
    NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
    niftyDisplay.getNifty().fromXml("Interface/Nifty/HelloJme.xml", "start");
    guiViewPort.addProcessor(niftyDisplay);
}
Also used : NiftyJmeDisplay(com.jme3.niftygui.NiftyJmeDisplay) Spatial(com.jme3.scene.Spatial)

Example 2 with NiftyJmeDisplay

use of com.jme3.niftygui.NiftyJmeDisplay in project jmonkeyengine by jMonkeyEngine.

the class TestNiftyExamples method simpleInitApp.

public void simpleInitApp() {
    NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
    nifty = niftyDisplay.getNifty();
    nifty.fromXml("all/intro.xml", "start");
    // attach the nifty display to the gui view port as a processor
    guiViewPort.addProcessor(niftyDisplay);
    // disable the fly cam
    flyCam.setEnabled(false);
}
Also used : NiftyJmeDisplay(com.jme3.niftygui.NiftyJmeDisplay)

Example 3 with NiftyJmeDisplay

use of com.jme3.niftygui.NiftyJmeDisplay in project jmonkeyengine by jMonkeyEngine.

the class TestCinematic method simpleInitApp.

@Override
public void simpleInitApp() {
    //just some text
    NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(getAssetManager(), getInputManager(), getAudioRenderer(), getGuiViewPort());
    Nifty nifty;
    nifty = niftyDisplay.getNifty();
    nifty.fromXmlWithoutStartScreen("Interface/Nifty/CinematicTest.xml");
    getGuiViewPort().addProcessor(niftyDisplay);
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    final BitmapText text = new BitmapText(guiFont, false);
    text.setSize(guiFont.getCharSet().getRenderedSize());
    text.setText("Press enter to play/pause cinematic");
    text.setLocalTranslation((cam.getWidth() - text.getLineWidth()) / 2, cam.getHeight(), 0);
    guiNode.attachChild(text);
    createScene();
    cinematic = new Cinematic(rootNode, 20);
    stateManager.attach(cinematic);
    createCameraMotion();
    //creating spatial animation for the teapot
    AnimationFactory factory = new AnimationFactory(20, "teapotAnim");
    factory.addTimeTranslation(0, new Vector3f(10, 0, 10));
    factory.addTimeTranslation(20, new Vector3f(10, 0, -10));
    factory.addTimeScale(10, new Vector3f(4, 4, 4));
    factory.addTimeScale(20, new Vector3f(1, 1, 1));
    factory.addTimeRotationAngles(20, 0, 4 * FastMath.TWO_PI, 0);
    AnimControl control = new AnimControl();
    control.addAnim(factory.buildAnimation());
    teapot.addControl(control);
    //fade in
    cinematic.addCinematicEvent(0, new FadeEvent(true));
    // cinematic.activateCamera(0, "aroundCam");
    cinematic.addCinematicEvent(0, new AnimationEvent(teapot, "teapotAnim", LoopMode.DontLoop));
    cinematic.addCinematicEvent(0, cameraMotionEvent);
    cinematic.addCinematicEvent(0, new SoundEvent("Sound/Environment/Nature.ogg", LoopMode.Loop));
    cinematic.addCinematicEvent(3f, new SoundEvent("Sound/Effects/kick.wav"));
    cinematic.addCinematicEvent(3, new SubtitleTrack(nifty, "start", 3, "jMonkey engine really kicks A..."));
    cinematic.addCinematicEvent(5.1f, new SoundEvent("Sound/Effects/Beep.ogg", 1));
    cinematic.addCinematicEvent(2, new AnimationEvent(model, "Walk", LoopMode.Loop));
    cinematic.activateCamera(0, "topView");
    //  cinematic.activateCamera(10, "aroundCam");
    //fade out
    cinematic.addCinematicEvent(19, new FadeEvent(false));
    //        cinematic.addCinematicEvent(19, new AbstractCinematicEvent() {
    //
    //            @Override
    //            public void onPlay() {
    //                fade.setDuration(1f / cinematic.getSpeed());
    //                fade.fadeOut();
    //
    //            }
    //
    //            @Override
    //            public void onUpdate(float tpf) {
    //            }
    //
    //            @Override
    //            public void onStop() {
    //            }
    //
    //            @Override
    //            public void onPause() {
    //            }
    //        });
    cinematic.addListener(new CinematicEventListener() {

        public void onPlay(CinematicEvent cinematic) {
            chaseCam.setEnabled(false);
            System.out.println("play");
        }

        public void onPause(CinematicEvent cinematic) {
            System.out.println("pause");
        }

        public void onStop(CinematicEvent cinematic) {
            chaseCam.setEnabled(true);
            fade.setValue(1);
            System.out.println("stop");
        }
    });
    //cinematic.setSpeed(2);
    flyCam.setEnabled(false);
    chaseCam = new ChaseCamera(cam, model, inputManager);
    initInputs();
}
Also used : NiftyJmeDisplay(com.jme3.niftygui.NiftyJmeDisplay) Cinematic(com.jme3.cinematic.Cinematic) ChaseCamera(com.jme3.input.ChaseCamera) Nifty(de.lessvoid.nifty.Nifty) AnimControl(com.jme3.animation.AnimControl) BitmapText(com.jme3.font.BitmapText) AnimationFactory(com.jme3.animation.AnimationFactory) Vector3f(com.jme3.math.Vector3f)

Example 4 with NiftyJmeDisplay

use of com.jme3.niftygui.NiftyJmeDisplay in project jmonkeyengine by jMonkeyEngine.

the class TestContextSwitching method simpleInitApp.

@Override
public void simpleInitApp() {
    clContext = null;
    NiftyJmeDisplay niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
    nifty = niftyDisplay.getNifty();
    nifty.fromXml("jme3test/opencl/ContextSwitchingScreen.xml", "Screen", this);
    guiViewPort.addProcessor(niftyDisplay);
    inputManager.setCursorVisible(true);
    flyCam.setEnabled(false);
}
Also used : NiftyJmeDisplay(com.jme3.niftygui.NiftyJmeDisplay)

Example 5 with NiftyJmeDisplay

use of com.jme3.niftygui.NiftyJmeDisplay in project jmonkeyengine by jMonkeyEngine.

the class TestNiftyGui method simpleInitApp.

@Override
public void simpleInitApp() {
    Box b = new Box(1, 1, 1);
    Geometry geom = new Geometry("Box", b);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
    geom.setMaterial(mat);
    rootNode.attachChild(geom);
    NiftyJmeDisplay niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
    nifty = niftyDisplay.getNifty();
    nifty.fromXml("Interface/Nifty/HelloJme.xml", "start", this);
    // attach the nifty display to the gui view port as a processor
    guiViewPort.addProcessor(niftyDisplay);
    // disable the fly cam
    //        flyCam.setEnabled(false);
    //        flyCam.setDragToRotate(true);
    inputManager.setCursorVisible(true);
}
Also used : Geometry(com.jme3.scene.Geometry) NiftyJmeDisplay(com.jme3.niftygui.NiftyJmeDisplay) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material)

Aggregations

NiftyJmeDisplay (com.jme3.niftygui.NiftyJmeDisplay)6 Material (com.jme3.material.Material)2 Geometry (com.jme3.scene.Geometry)2 Box (com.jme3.scene.shape.Box)2 AnimControl (com.jme3.animation.AnimControl)1 AnimationFactory (com.jme3.animation.AnimationFactory)1 Cinematic (com.jme3.cinematic.Cinematic)1 BitmapText (com.jme3.font.BitmapText)1 ChaseCamera (com.jme3.input.ChaseCamera)1 Vector3f (com.jme3.math.Vector3f)1 Camera (com.jme3.renderer.Camera)1 ViewPort (com.jme3.renderer.ViewPort)1 Spatial (com.jme3.scene.Spatial)1 FrameBuffer (com.jme3.texture.FrameBuffer)1 Texture2D (com.jme3.texture.Texture2D)1 Nifty (de.lessvoid.nifty.Nifty)1