Search in sources :

Example 6 with BitmapText

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

the class TerrainTestTile method loadHintText.

public void loadHintText() {
    hintText = new BitmapText(guiFont, false);
    hintText.setLocalTranslation(0, getCamera().getHeight(), 0);
    hintText.setText("Hit 'T' to toggle wireframe");
    guiNode.attachChild(hintText);
}
Also used : BitmapText(com.jme3.font.BitmapText)

Example 7 with BitmapText

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

the class TestImageRaster method convertAndPutImage.

private void convertAndPutImage(Image image, float posX, float posY) {
    Texture tex = new Texture2D(image);
    tex.setMagFilter(MagFilter.Nearest);
    tex.setMinFilter(MinFilter.NearestNoMipMaps);
    tex.setAnisotropicFilter(16);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setTexture("ColorMap", tex);
    Quad q = new Quad(5, 5);
    Geometry g = new Geometry("quad", q);
    g.setLocalTranslation(posX, posY - 5, -0.0001f);
    g.setMaterial(mat);
    rootNode.attachChild(g);
    BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText txt = new BitmapText(fnt);
    txt.setBox(new Rectangle(0, 0, 5, 5));
    txt.setQueueBucket(RenderQueue.Bucket.Transparent);
    txt.setSize(0.5f);
    txt.setText(image.getFormat().name());
    txt.setLocalTranslation(posX, posY, 0);
    rootNode.attachChild(txt);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Texture2D(com.jme3.texture.Texture2D) BitmapText(com.jme3.font.BitmapText) Rectangle(com.jme3.font.Rectangle) Material(com.jme3.material.Material) BitmapFont(com.jme3.font.BitmapFont) Texture(com.jme3.texture.Texture)

Example 8 with BitmapText

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

the class TestMotionPath method simpleInitApp.

@Override
public void simpleInitApp() {
    createScene();
    cam.setLocation(new Vector3f(8.4399185f, 11.189463f, 14.267577f));
    path = new MotionPath();
    path.addWayPoint(new Vector3f(10, 3, 0));
    path.addWayPoint(new Vector3f(10, 3, 10));
    path.addWayPoint(new Vector3f(-40, 3, 10));
    path.addWayPoint(new Vector3f(-40, 3, 0));
    path.addWayPoint(new Vector3f(-40, 8, 0));
    path.addWayPoint(new Vector3f(10, 8, 0));
    path.addWayPoint(new Vector3f(10, 8, 10));
    path.addWayPoint(new Vector3f(15, 8, 10));
    path.enableDebugShape(assetManager, rootNode);
    motionControl = new MotionEvent(teapot, path);
    motionControl.setDirectionType(MotionEvent.Direction.PathAndRotation);
    motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y));
    motionControl.setInitialDuration(10f);
    motionControl.setSpeed(2f);
    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() + "Finished!!! ");
            } else {
                wayPointsText.setText(control.getSpatial().getName() + " Reached way point " + wayPointIndex);
            }
            wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);
        }
    });
    flyCam.setEnabled(false);
    ChaseCamera chaser = new ChaseCamera(cam, teapot);
    //        motionControl.setSpeed(-3f);
    //        motionControl.setLoopMode(LoopMode.Loop);
    //        path.setCycle(true);
    // chaser.setEnabled(false);
    chaser.registerWithInput(inputManager);
    initInputs();
}
Also used : MotionPathListener(com.jme3.cinematic.MotionPathListener) BitmapText(com.jme3.font.BitmapText) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) ChaseCamera(com.jme3.input.ChaseCamera) MotionPath(com.jme3.cinematic.MotionPath) MotionEvent(com.jme3.cinematic.events.MotionEvent)

Example 9 with BitmapText

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

the class TestChangeAppIcon method simpleInitApp.

@Override
public void simpleInitApp() {
    // Write text on the screen (HUD)
    setDisplayStatView(false);
    BitmapText helloText = new BitmapText(guiFont);
    helloText.setText("The icon of the app should be a smart monkey!");
    helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);
    guiNode.attachChild(helloText);
}
Also used : BitmapText(com.jme3.font.BitmapText)

Example 10 with BitmapText

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

the class TestAndroidTouch method simpleInitApp.

@Override
public void simpleInitApp() {
    getViewPort().setBackgroundColor(ColorRGBA.White);
    analogFormat.setMaximumFractionDigits(3);
    analogFormat.setMinimumFractionDigits(3);
    locationFormat.setMaximumFractionDigits(0);
    locationFormat.setMinimumFractionDigits(0);
    // Setup list of triggers based on different keyboard key codes. For Android, the soft keyboard key events
    // are translated into jme key events.
    int[] keyCodes = new int[] { KeyInput.KEY_0, KeyInput.KEY_1, KeyInput.KEY_2, KeyInput.KEY_3, KeyInput.KEY_4, KeyInput.KEY_5, KeyInput.KEY_6, KeyInput.KEY_7, KeyInput.KEY_8, KeyInput.KEY_9, KeyInput.KEY_DECIMAL, KeyInput.KEY_PERIOD, KeyInput.KEY_A, KeyInput.KEY_B, KeyInput.KEY_C, KeyInput.KEY_D, KeyInput.KEY_E, KeyInput.KEY_F, KeyInput.KEY_G, KeyInput.KEY_H, KeyInput.KEY_I, KeyInput.KEY_J, KeyInput.KEY_K, KeyInput.KEY_L, KeyInput.KEY_M, KeyInput.KEY_N, KeyInput.KEY_O, KeyInput.KEY_P, KeyInput.KEY_Q, KeyInput.KEY_R, KeyInput.KEY_S, KeyInput.KEY_T, KeyInput.KEY_U, KeyInput.KEY_V, KeyInput.KEY_W, KeyInput.KEY_X, KeyInput.KEY_Y, KeyInput.KEY_Z, KeyInput.KEY_CAPITAL, KeyInput.KEY_LSHIFT, KeyInput.KEY_RSHIFT, KeyInput.KEY_UP, KeyInput.KEY_DOWN, KeyInput.KEY_LEFT, KeyInput.KEY_RIGHT };
    for (int idx = 0; idx < keyCodes.length; idx++) {
        String keyMapping = mappingKeyPrefix + KeyNames.getName(keyCodes[idx]);
        inputManager.addMapping(keyMapping, new KeyTrigger(keyCodes[idx]));
        inputManager.addListener(actionListener, keyMapping);
        logger.log(Level.INFO, "Adding key mapping: {0}", keyMapping);
    }
    // setup InputManager to trigger our listeners when the various triggers are received.
    // Touch inputs are all sent to the TouchTrigger.  To have one mapping for all touch events, use TouchInput.ALL.
    inputManager.addMapping(touchMapping, new TouchTrigger(TouchInput.ALL));
    inputManager.addListener(touchListener, touchMapping);
    // If inputManager.isSimulateMouse = true, touch events will be translated into Mouse Button and Axis events.
    // To enable this, call inputManager.setSimulateMouse(true).
    inputManager.addMapping(mappingMouseLeft, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, mappingMouseLeft);
    inputManager.addMapping(mappingMouseXNeg, new MouseAxisTrigger(MouseInput.AXIS_X, true));
    inputManager.addMapping(mappingMouseXPos, new MouseAxisTrigger(MouseInput.AXIS_X, false));
    inputManager.addMapping(mappingMouseYNeg, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
    inputManager.addMapping(mappingMouseYPos, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
    inputManager.addListener(analogListener, mappingMouseXNeg, mappingMouseXPos, mappingMouseYNeg, mappingMouseYPos);
    // add raw input listener to inputManager
    inputManager.addRawInputListener(rawInputListener);
    float mouseSize = (settings.getWidth() >= settings.getHeight()) ? settings.getHeight() / 2f : settings.getWidth() / 2f;
    picMouseBackground = new Picture("Mouse Background");
    picMouseBackground.setImage(assetManager, "mouse_none.png", true);
    picMouseBackground.setWidth(mouseSize);
    picMouseBackground.setHeight(mouseSize);
    picMouseBackground.setLocalTranslation(settings.getWidth() - mouseSize, 0f, 0f);
    picMouseLeftButton = new Picture("Mouse Button Left");
    picMouseLeftButton.setImage(assetManager, "mouse_left.png", true);
    picMouseLeftButton.setWidth(mouseSize);
    picMouseLeftButton.setHeight(mouseSize);
    picMouseLeftButton.setLocalTranslation(settings.getWidth() - mouseSize, 0f, 1f);
    picMouseDisabled = new Picture("Mouse Disabled");
    picMouseDisabled.setImage(assetManager, "mouse_disabled.png", true);
    picMouseDisabled.setWidth(mouseSize);
    picMouseDisabled.setHeight(mouseSize);
    picMouseDisabled.setLocalTranslation(settings.getWidth() - mouseSize, 0f, 1f);
    float phoneSize = (settings.getWidth() >= settings.getHeight()) ? settings.getHeight() / 2f : settings.getWidth() / 2f;
    // preload images to send data to gpu to avoid hesitations during run time the first time the image is displayed
    renderManager.preloadScene(picMouseBackground);
    renderManager.preloadScene(picMouseLeftButton);
    renderManager.preloadScene(picMouseDisabled);
    guiNode.attachChild(picMouseBackground);
    if (inputManager.isSimulateMouse()) {
        picMouseDisabled.removeFromParent();
    } else {
        guiNode.attachChild(picMouseDisabled);
    }
    textMouseLabel = new BitmapText(guiFont, false);
    textMouseLabel.setSize(mouseSize / 10f);
    textMouseLabel.setColor(ColorRGBA.Blue);
    textMouseLabel.setBox(new Rectangle(0f, 0f, mouseSize, mouseSize / 5f));
    textMouseLabel.setAlignment(BitmapFont.Align.Center);
    textMouseLabel.setVerticalAlignment(BitmapFont.VAlign.Bottom);
    textMouseLabel.setText("Mouse Analog\nand Position");
    textMouseLabel.setLocalTranslation(settings.getWidth() - mouseSize, mouseSize * 1.25f, 1f);
    guiNode.attachChild(textMouseLabel);
    textMouseAnalog = new BitmapText(guiFont, false);
    textMouseAnalog.setSize(mouseSize / 10f);
    textMouseAnalog.setColor(ColorRGBA.Blue);
    textMouseAnalog.setBox(new Rectangle(0f, 0f, mouseSize, mouseSize / 10f));
    textMouseAnalog.setAlignment(BitmapFont.Align.Center);
    textMouseAnalog.setVerticalAlignment(BitmapFont.VAlign.Center);
    textMouseAnalog.setText("0.000, 0.000");
    textMouseAnalog.setLocalTranslation(settings.getWidth() - mouseSize, mouseSize / 2f, 2f);
    guiNode.attachChild(textMouseAnalog);
    textMouseLocation = new BitmapText(guiFont, false);
    textMouseLocation.setSize(mouseSize / 10f);
    textMouseLocation.setColor(ColorRGBA.Blue);
    textMouseLocation.setBox(new Rectangle(0f, 0f, mouseSize, mouseSize / 10f));
    textMouseLocation.setAlignment(BitmapFont.Align.Center);
    textMouseLocation.setVerticalAlignment(BitmapFont.VAlign.Center);
    textMouseLocation.setText("0, 0");
    textMouseLocation.setLocalTranslation(settings.getWidth() - mouseSize, mouseSize / 2f - mouseSize / 10f, 2f);
    guiNode.attachChild(textMouseLocation);
    textCursorLocation = new BitmapText(guiFont, false);
    textCursorLocation.setSize(mouseSize / 10f);
    textCursorLocation.setColor(ColorRGBA.Blue);
    textCursorLocation.setBox(new Rectangle(0f, 0f, mouseSize, mouseSize / 10f));
    textCursorLocation.setAlignment(BitmapFont.Align.Center);
    textCursorLocation.setVerticalAlignment(BitmapFont.VAlign.Center);
    textCursorLocation.setText("0, 0");
    textCursorLocation.setLocalTranslation(settings.getWidth() - mouseSize, mouseSize / 2f - mouseSize / 10f * 2f, 2f);
    guiNode.attachChild(textCursorLocation);
    textKeyPressed = new BitmapText(guiFont, false);
    textKeyPressed.setSize(mouseSize / 10f);
    textKeyPressed.setColor(ColorRGBA.Blue);
    textKeyPressed.setBox(new Rectangle(0f, 0f, settings.getWidth(), mouseSize / 10f));
    textKeyPressed.setAlignment(BitmapFont.Align.Center);
    textKeyPressed.setVerticalAlignment(BitmapFont.VAlign.Top);
    textKeyPressed.setText("Last Key Pressed: None");
    textKeyPressed.setLocalTranslation(0f, settings.getHeight() - mouseSize / 10f, 2f);
    guiNode.attachChild(textKeyPressed);
    picPhone = new Picture("Phone");
    picPhone.setImage(assetManager, "phone_landscape.png", true);
    picPhone.setWidth(phoneSize);
    picPhone.setHeight(phoneSize);
    picPhone.setLocalTranslation(picMouseBackground.getLocalTranslation().x - phoneSize, 0f, 1f);
    guiNode.attachChild(picPhone);
    textPhoneLocation = new BitmapText(guiFont, false);
    textPhoneLocation.setSize(phoneSize / 10f);
    textPhoneLocation.setColor(ColorRGBA.White);
    textPhoneLocation.setBox(new Rectangle(0f, 0f, phoneSize, phoneSize / 10f));
    textPhoneLocation.setAlignment(BitmapFont.Align.Center);
    textPhoneLocation.setVerticalAlignment(BitmapFont.VAlign.Center);
    textPhoneLocation.setText("0, 0");
    textPhoneLocation.setLocalTranslation(picMouseBackground.getLocalTranslation().x - phoneSize, phoneSize * 0.5f, 2f);
    guiNode.attachChild(textPhoneLocation);
    textPhoneLabel = new BitmapText(guiFont, false);
    textPhoneLabel.setSize(phoneSize / 10f);
    textPhoneLabel.setColor(ColorRGBA.Blue);
    textPhoneLabel.setBox(new Rectangle(0f, 0f, phoneSize, phoneSize / 10f));
    textPhoneLabel.setAlignment(BitmapFont.Align.Center);
    textPhoneLabel.setVerticalAlignment(BitmapFont.VAlign.Bottom);
    textPhoneLabel.setText("Touch Location");
    textPhoneLabel.setLocalTranslation(picMouseBackground.getLocalTranslation().x - phoneSize, picPhone.getLocalTranslation().y + phoneSize * 0.75f, 1f);
    guiNode.attachChild(textPhoneLabel);
    renderManager.preloadScene(picPhone);
}
Also used : BitmapText(com.jme3.font.BitmapText) Picture(com.jme3.ui.Picture) Rectangle(com.jme3.font.Rectangle)

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