Search in sources :

Example 26 with BitmapText

use of com.jme3.font.BitmapText in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionUtil method getWireTerm.

/**
 * 添加接线头
 * @return 新添加的接线头模型
 */
public static Spatial getWireTerm() {
    AssetManager assetManager = Dispatcher.getIns().getMainApp().getAssetManager();
    Spatial spatial = assetManager.loadModel("Models/JieXianDuanZi.j3o");
    // 创建号码管贴图
    Spatial parent = ((Node) spatial).getChild("Label");
    BitmapFont font = assetManager.loadFont("com/cas/me/fonts/numtext.fnt");
    BitmapText txt1 = getBitmapText(font);
    BitmapText txt2 = getBitmapText(font);
    BitmapText txt3 = getBitmapText(font);
    BitmapText txt4 = getBitmapText(font);
    txt1.setLocalTranslation(new Vector3f(1.3148814f, -1.6f, -1.1656954f));
    txt1.setLocalRotation(new Quaternion(0.8827012f, 0.85739714f, 0.003711f, -0.023661964f));
    txt2.setLocalTranslation(new Vector3f(-1.4674674f, -1.6f, 1.0630512f));
    txt2.setLocalRotation(new Quaternion(-0.0127319945f, -0.0059094937f, -0.8755521f, -0.8649177f));
    txt3.setLocalTranslation(new Vector3f(-1.0670044f, -1.6f, -1.4330314f));
    txt3.setLocalRotation(new Quaternion(-0.60574f, -0.61861926f, 0.6301226f, 0.60679734f));
    txt4.setLocalTranslation(new Vector3f(1.0652375f, -1.6f, 1.4834414f));
    txt4.setLocalRotation(new Quaternion(0.6125322f, 0.62533164f, 0.608011f, 0.6155914f));
    ((Node) parent).attachChild(txt1);
    ((Node) parent).attachChild(txt2);
    ((Node) parent).attachChild(txt3);
    ((Node) parent).attachChild(txt4);
    // spatial.setLocalScale(0.001f);
    return spatial;
}
Also used : AssetManager(com.jme3.asset.AssetManager) BitmapText(com.jme3.font.BitmapText) Spatial(com.jme3.scene.Spatial) Quaternion(com.jme3.math.Quaternion) Node(com.jme3.scene.Node) Vector3f(com.jme3.math.Vector3f) BitmapFont(com.jme3.font.BitmapFont)

Example 27 with BitmapText

use of com.jme3.font.BitmapText in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionUtil method getBitmapText.

private static BitmapText getBitmapText(BitmapFont font) {
    final BitmapText bitmapText = new BitmapText(font);
    bitmapText.setQueueBucket(Bucket.Transparent);
    bitmapText.setLocalScale(0.048106655f);
    bitmapText.setColor(ColorRGBA.Black);
    bitmapText.setName("Text");
    return bitmapText;
}
Also used : BitmapText(com.jme3.font.BitmapText)

Example 28 with BitmapText

use of com.jme3.font.BitmapText in project jmonkeyengine by jMonkeyEngine.

the class StatsAppState method setFont.

/**
     *  Called by SimpleApplication to provide an early font
     *  so that the fpsText can be created before init.  This
     *  is because several applications expect to directly access
     *  fpsText... unfortunately.
     */
public void setFont(BitmapFont guiFont) {
    this.guiFont = guiFont;
    this.fpsText = new BitmapText(guiFont, false);
}
Also used : BitmapText(com.jme3.font.BitmapText)

Example 29 with BitmapText

use of com.jme3.font.BitmapText in project jmonkeyengine by jMonkeyEngine.

the class TestCameraMotionPath method simpleInitApp.

@Override
public void simpleInitApp() {
    createScene();
    cam.setLocation(new Vector3f(8.4399185f, 11.189463f, 14.267577f));
    camNode = new CameraNode("Motion cam", cam);
    camNode.setControlDir(ControlDirection.SpatialToCamera);
    camNode.setEnabled(false);
    path = new MotionPath();
    path.setCycle(true);
    path.addWayPoint(new Vector3f(20, 3, 0));
    path.addWayPoint(new Vector3f(0, 3, 20));
    path.addWayPoint(new Vector3f(-20, 3, 0));
    path.addWayPoint(new Vector3f(0, 3, -20));
    path.setCurveTension(0.83f);
    path.enableDebugShape(assetManager, rootNode);
    cameraMotionControl = new MotionEvent(camNode, path);
    cameraMotionControl.setLoopMode(LoopMode.Loop);
    //cameraMotionControl.setDuration(15f);
    cameraMotionControl.setLookAt(teapot.getWorldTranslation(), Vector3f.UNIT_Y);
    cameraMotionControl.setDirectionType(MotionEvent.Direction.LookAt);
    rootNode.attachChild(camNode);
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    final BitmapText wayPointsText = new BitmapText(guiFont, false);
    wayPointsText.setSize(guiFont.getCharSet().getRenderedSize());
    guiNode.attachChild(wayPointsText);
    path.addListener(new MotionPathListener() {

        public void onWayPointReach(MotionEvent control, int wayPointIndex) {
            if (path.getNbWayPoints() == wayPointIndex + 1) {
                wayPointsText.setText(control.getSpatial().getName() + " Finish!!! ");
            } else {
                wayPointsText.setText(control.getSpatial().getName() + " Reached way point " + wayPointIndex);
            }
            wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);
        }
    });
    flyCam.setEnabled(false);
    chaser = new ChaseCamera(cam, teapot);
    chaser.registerWithInput(inputManager);
    chaser.setSmoothMotion(true);
    chaser.setMaxDistance(50);
    chaser.setDefaultDistance(50);
    initInputs();
}
Also used : MotionPathListener(com.jme3.cinematic.MotionPathListener) BitmapText(com.jme3.font.BitmapText) Vector3f(com.jme3.math.Vector3f) CameraNode(com.jme3.scene.CameraNode) ChaseCamera(com.jme3.input.ChaseCamera) MotionPath(com.jme3.cinematic.MotionPath) MotionEvent(com.jme3.cinematic.events.MotionEvent)

Example 30 with BitmapText

use of com.jme3.font.BitmapText 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)

Aggregations

BitmapText (com.jme3.font.BitmapText)52 Vector3f (com.jme3.math.Vector3f)10 Geometry (com.jme3.scene.Geometry)9 KeyTrigger (com.jme3.input.controls.KeyTrigger)8 Material (com.jme3.material.Material)8 BitmapFont (com.jme3.font.BitmapFont)7 DirectionalLight (com.jme3.light.DirectionalLight)5 ColorRGBA (com.jme3.math.ColorRGBA)5 Spatial (com.jme3.scene.Spatial)5 Rectangle (com.jme3.font.Rectangle)4 ChaseCamera (com.jme3.input.ChaseCamera)4 Quaternion (com.jme3.math.Quaternion)4 Node (com.jme3.scene.Node)4 Box (com.jme3.scene.shape.Box)4 Quad (com.jme3.scene.shape.Quad)4 ActionListener (com.jme3.input.controls.ActionListener)3 Wire (com.cas.circuit.vo.Wire)2 MotionPath (com.jme3.cinematic.MotionPath)2 MotionPathListener (com.jme3.cinematic.MotionPathListener)2 MotionEvent (com.jme3.cinematic.events.MotionEvent)2