Java Code Examples for com.jme3.font.BitmapText#setLocalTranslation()

The following examples show how to use com.jme3.font.BitmapText#setLocalTranslation() . 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 File: TestImageRaster.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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);
}
 
Example 2
Source File: TerrainTestCollision.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void loadHintText() {
    hintText = new BitmapText(guiFont, false);
    hintText.setSize(guiFont.getCharSet().getRenderedSize());
    hintText.setLocalTranslation(0, getCamera().getHeight(), 0);
    hintText.setText("Press T to toggle wireframe");
    guiNode.attachChild(hintText);
}
 
Example 3
Source File: HelloOpenCL.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
    Context clContext = context.getOpenCLContext();
    if (clContext == null) {
        BitmapText txt = new BitmapText(fnt);
        txt.setText("No OpenCL Context created!\nSee output log for details.");
        txt.setLocalTranslation(5, settings.getHeight() - 5, 0);
        guiNode.attachChild(txt);
        return;
    }
    CommandQueue clQueue = clContext.createQueue();
    
    StringBuilder str = new StringBuilder();
    str.append("OpenCL Context created:\n  Platform: ")
            .append(clContext.getDevices().get(0).getPlatform().getName())
            .append("\n  Devices: ").append(clContext.getDevices());
    str.append("\nTests:");
    str.append("\n  Buffers: ").append(testBuffer(clContext, clQueue));
    str.append("\n  Kernel: ").append(testKernel(clContext, clQueue));
    str.append("\n  Images: ").append(testImages(clContext, clQueue));
    
    clQueue.release();
    
    BitmapText txt1 = new BitmapText(fnt);
    txt1.setText(str.toString());
    txt1.setLocalTranslation(5, settings.getHeight() - 5, 0);
    guiNode.attachChild(txt1);
    
    flyCam.setEnabled(false);
    inputManager.setCursorVisible(true);
}
 
Example 4
Source File: TestBatchNodeTower.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void initCrossHairs() {
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText ch = new BitmapText(guiFont, false);
    ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);
    ch.setText("+"); // crosshairs
    ch.setLocalTranslation( // center
            settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2,
            settings.getHeight() / 2 + ch.getLineHeight() / 2, 0);
    guiNode.attachChild(ch);
}
 
Example 5
Source File: TestHWSkinning.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void makeHudText() {
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    hwsText = new BitmapText(guiFont, false);
    hwsText.setSize(guiFont.getCharSet().getRenderedSize());
    hwsText.setText("HWS : "+ hwSkinningEnable);
    hwsText.setLocalTranslation(0, cam.getHeight(), 0);
    guiNode.attachChild(hwsText);
}
 
Example 6
Source File: TestObjGroupsLoading.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void initCrossHairs() {
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText ch = new BitmapText(guiFont, false);
    ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);
    ch.setText("+"); // crosshairs
    ch.setLocalTranslation( // center
        settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2,
        settings.getHeight() / 2 + ch.getLineHeight() / 2, 0);
    guiNode.attachChild(ch);
}
 
Example 7
Source File: HelloPicking.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** A centred plus sign to help the player aim. */
protected void initCrossHairs() {
  setDisplayStatView(false);
  guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
  BitmapText ch = new BitmapText(guiFont, false);
  ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);
  ch.setText("+"); // crosshairs
  ch.setLocalTranslation( // center
    settings.getWidth() / 2 - ch.getLineWidth()/2, settings.getHeight() / 2 + ch.getLineHeight()/2, 0);
  guiNode.attachChild(ch);
}
 
Example 8
Source File: TestJoystick.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void addInfo( String info, int column ) {

    BitmapText t = new BitmapText(guiFont);
    t.setText( info );
    t.setLocalTranslation( column * 200, yInfo, 0 );
    joystickInfo.attachChild(t);
    yInfo -= t.getHeight();
}
 
Example 9
Source File: TestBrickWall.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void initCrossHairs() {
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText ch = new BitmapText(guiFont, false);
    ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);
    ch.setText("+"); // crosshairs
    ch.setLocalTranslation( // center
            settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2,
            settings.getHeight() / 2 + ch.getLineHeight() / 2, 0);
    guiNode.attachChild(ch);
}
 
Example 10
Source File: AndroidApplication.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Attaches FPS statistics to guiNode and displays it on the screen.
 *
 */
public void loadFPSText() {
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    fpsText = new BitmapText(guiFont, false);
    fpsText.setLocalTranslation(0, fpsText.getLineHeight(), 0);
    fpsText.setText("Frames per second");
    guiNode.attachChild(fpsText);
}
 
Example 11
Source File: TestOpenCLLibraries.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
    Context clContext = context.getOpenCLContext();
    if (clContext == null) {
        BitmapText txt = new BitmapText(fnt);
        txt.setText("No OpenCL Context created!\nSee output log for details.");
        txt.setLocalTranslation(5, settings.getHeight() - 5, 0);
        guiNode.attachChild(txt);
        return;
    }
    CommandQueue clQueue = clContext.createQueue(clContext.getDevices().get(0));
    
    StringBuilder str = new StringBuilder();
    str.append("OpenCL Context created:\n  Platform: ")
            .append(clContext.getDevices().get(0).getPlatform().getName())
            .append("\n  Devices: ").append(clContext.getDevices());
    str.append("\nTests:");
    str.append("\n  Random numbers: ").append(testRandom(clContext, clQueue));
    str.append("\n  Matrix3f: ").append(testMatrix3f(clContext, clQueue));
    str.append("\n  Matrix4f: ").append(testMatrix4f(clContext, clQueue));
    
    clQueue.release();
    
    BitmapText txt1 = new BitmapText(fnt);
    txt1.setText(str.toString());
    txt1.setLocalTranslation(5, settings.getHeight() - 5, 0);
    guiNode.attachChild(txt1);
    
    flyCam.setEnabled(false);
    inputManager.setCursorVisible(true);
}
 
Example 12
Source File: TestLightScattering.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void loadFPSText(){
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    fpsText = new BitmapText(guiFont, false);
    fpsText.setSize(guiFont.getCharSet().getRenderedSize());
    fpsText.setLocalTranslation(0, fpsText.getLineHeight(), 0);
    fpsText.setText("Frames per second");
    guiNode.attachChild(fpsText);
}
 
Example 13
Source File: TestBoneRagdoll.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void initCrossHairs() {
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText ch = new BitmapText(guiFont, false);
    ch.setSize(guiFont.getCharSet().getRenderedSize() * 2f);
    ch.setText("+"); // crosshairs
    ch.setLocalTranslation( // center
            settings.getWidth() / 2f - guiFont.getCharSet().getRenderedSize() / 3f * 2f,
            settings.getHeight() / 2f + ch.getLineHeight() / 2f, 0f);
    guiNode.attachChild(ch);
}
 
Example 14
Source File: TerrainTestReadWrite.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void loadHintText() {
    hintText = new BitmapText(guiFont, false);
    hintText.setSize(guiFont.getCharSet().getRenderedSize());
    hintText.setLocalTranslation(0, getCamera().getHeight(), 0);
    hintText.setText("Hit T to save, and Y to load");
    guiNode.attachChild(hintText);
}
 
Example 15
Source File: MyDebugger.java    From OpenRTS with MIT License 4 votes vote down vote up
public MyDebugger(int x, int y, BitmapFont font) {
	bitmap = new BitmapText(font, false);
	bitmap.setLocalTranslation(x, y, 0);
	bitmap.setText("");
}
 
Example 16
Source File: TestMipMapGen.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
    public void simpleInitApp() {
        BitmapText txt = guiFont.createLabel("Left: HW Mips");
        txt.setLocalTranslation(0, settings.getHeight() - txt.getLineHeight() * 4, 0);
        guiNode.attachChild(txt);

        txt = guiFont.createLabel("Right: AWT Mips");
        txt.setLocalTranslation(0, settings.getHeight() - txt.getLineHeight() * 3, 0);
        guiNode.attachChild(txt);

        // create a simple plane/quad
        Quad quadMesh = new Quad(1, 1);
        quadMesh.updateGeometry(1, 1, false);
        quadMesh.updateBound();

        Geometry quad1 = new Geometry("Textured Quad", quadMesh);
        Geometry quad2 = new Geometry("Textured Quad 2", quadMesh);

        Texture tex = assetManager.loadTexture("Interface/Logo/Monkey.png");
        tex.setMinFilter(Texture.MinFilter.Trilinear);

        Texture texCustomMip = tex.clone();
        Image imageCustomMip = texCustomMip.getImage().clone();
        MipMapGenerator.generateMipMaps(imageCustomMip);
        texCustomMip.setImage(imageCustomMip);

        Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat1.setTexture("ColorMap", tex);

        Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat2.setTexture("ColorMap", texCustomMip);

        quad1.setMaterial(mat1);
//        quad1.setLocalTranslation(1, 0, 0);

        quad2.setMaterial(mat2);
        quad2.setLocalTranslation(1, 0, 0);

        rootNode.attachChild(quad1);
        rootNode.attachChild(quad2);
    }
 
Example 17
Source File: TestDirectionalLightShadow.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void initInputs() {

        inputManager.addMapping("ThicknessUp", new KeyTrigger(KeyInput.KEY_Y));
        inputManager.addMapping("ThicknessDown", new KeyTrigger(KeyInput.KEY_H));
        inputManager.addMapping("lambdaUp", new KeyTrigger(KeyInput.KEY_U));
        inputManager.addMapping("lambdaDown", new KeyTrigger(KeyInput.KEY_J));
        inputManager.addMapping("switchGroundMat", new KeyTrigger(KeyInput.KEY_M));
        inputManager.addMapping("debug", new KeyTrigger(KeyInput.KEY_X));
        inputManager.addMapping("stabilize", new KeyTrigger(KeyInput.KEY_B));
        inputManager.addMapping("distance", new KeyTrigger(KeyInput.KEY_N));


        inputManager.addMapping("up", new KeyTrigger(KeyInput.KEY_NUMPAD8));
        inputManager.addMapping("down", new KeyTrigger(KeyInput.KEY_NUMPAD2));
        inputManager.addMapping("right", new KeyTrigger(KeyInput.KEY_NUMPAD6));
        inputManager.addMapping("left", new KeyTrigger(KeyInput.KEY_NUMPAD4));
        inputManager.addMapping("fwd", new KeyTrigger(KeyInput.KEY_PGUP));
        inputManager.addMapping("back", new KeyTrigger(KeyInput.KEY_PGDN));
        inputManager.addMapping("pp", new KeyTrigger(KeyInput.KEY_P));
        inputManager.addMapping("backShadows", new KeyTrigger(KeyInput.KEY_K));


        inputManager.addListener(this, "lambdaUp", "lambdaDown", "ThicknessUp", "ThicknessDown",
                "switchGroundMat", "debug", "up", "down", "right", "left", "fwd", "back", "pp", "stabilize", "distance", "ShadowUp", "ShadowDown", "backShadows");

        ShadowTestUIManager uiMan = new ShadowTestUIManager(assetManager, dlsr, dlsf, guiNode, inputManager, viewPort);

        inputManager.addListener(this, "Size+", "Size-");
        inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W));
        inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S));

        shadowStabilizationText = new BitmapText(guiFont, false);
        shadowStabilizationText.setSize(guiFont.getCharSet().getRenderedSize() * 0.75f);
        shadowStabilizationText.setText("(b:on/off) Shadow stabilization : " + dlsr.isEnabledStabilization());
        shadowStabilizationText.setLocalTranslation(10, viewPort.getCamera().getHeight() - 100, 0);
        guiNode.attachChild(shadowStabilizationText);


        shadowZfarText = new BitmapText(guiFont, false);
        shadowZfarText.setSize(guiFont.getCharSet().getRenderedSize() * 0.75f);
        shadowZfarText.setText("(n:on/off) Shadow extend to 500 and fade to 50 : " + (dlsr.getShadowZExtend() > 0));
        shadowZfarText.setLocalTranslation(10, viewPort.getCamera().getHeight() - 120, 0);
        guiNode.attachChild(shadowZfarText);
    }
 
Example 18
Source File: TestComboMoves.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    fpsText.setCullHint(CullHint.Always);
    statsView.setCullHint(CullHint.Always);

    // Create debug text
    BitmapText helpText = new BitmapText(guiFont);
    helpText.setLocalTranslation(0, settings.getHeight(), 0);
    helpText.setText("Moves:\n" +
                     "Fireball: Down, Down+Right, Right\n"+
                     "Shuriken: Left, Down, Attack1(Z)\n"+
                     "Jab: Attack1(Z)\n"+
                     "Punch: Attack1(Z), Attack1(Z)\n");
    guiNode.attachChild(helpText);

    fireballText = new BitmapText(guiFont);
    fireballText.setColor(ColorRGBA.Orange);
    fireballText.setLocalTranslation(0, fireballText.getLineHeight(), 0);
    guiNode.attachChild(fireballText);

    shurikenText = new BitmapText(guiFont);
    shurikenText.setColor(ColorRGBA.Cyan);
    shurikenText.setLocalTranslation(0, shurikenText.getLineHeight()*2f, 0);
    guiNode.attachChild(shurikenText);

    jabText = new BitmapText(guiFont);
    jabText.setColor(ColorRGBA.Red);
    jabText.setLocalTranslation(0, jabText.getLineHeight()*3f, 0);
    guiNode.attachChild(jabText);

    punchText = new BitmapText(guiFont);
    punchText.setColor(ColorRGBA.Green);
    punchText.setLocalTranslation(0, punchText.getLineHeight()*4f, 0);
    guiNode.attachChild(punchText);

    inputManager.addMapping("Left",    new KeyTrigger(KeyInput.KEY_LEFT));
    inputManager.addMapping("Right",   new KeyTrigger(KeyInput.KEY_RIGHT));
    inputManager.addMapping("Up",      new KeyTrigger(KeyInput.KEY_UP));
    inputManager.addMapping("Down",    new KeyTrigger(KeyInput.KEY_DOWN));
    inputManager.addMapping("Attack1", new KeyTrigger(KeyInput.KEY_Z));
    inputManager.addListener(this, "Left", "Right", "Up", "Down", "Attack1");

    fireball = new ComboMove("Fireball");
    fireball.press("Down").notPress("Right").done();
    fireball.press("Right", "Down").done();
    fireball.press("Right").notPress("Down").done();
    fireball.notPress("Right", "Down").done();
    fireball.setUseFinalState(false); // no waiting on final state

    shuriken = new ComboMove("Shuriken");
    shuriken.press("Left").notPress("Down", "Attack1").done();
    shuriken.press("Down").notPress("Attack1").timeElapsed(0.11f).done();
    shuriken.press("Attack1").notPress("Left").timeElapsed(0.11f).done();
    shuriken.notPress("Left", "Down", "Attack1").done();

    jab = new ComboMove("Jab");
    jab.setPriority(0.5f); // make jab less important than other moves
    jab.press("Attack1").done();

    punch = new ComboMove("Punch");
    punch.press("Attack1").done();
    punch.notPress("Attack1").done();
    punch.press("Attack1").done();

    fireballExec = new ComboMoveExecution(fireball);
    shurikenExec = new ComboMoveExecution(shuriken);
    jabExec = new ComboMoveExecution(jab);
    punchExec = new ComboMoveExecution(punch);
}
 
Example 19
Source File: TestIssue1120.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    cam.setLocation(new Vector3f(-7.285349f, -2.2638104f, 4.954474f));
    cam.setRotation(new Quaternion(0.07345789f, 0.92521834f, -0.2876841f, 0.23624739f));
    getFlyByCamera().setMoveSpeed(5);

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

    //Setup interactive test controls
    inputManager.addMapping("restart", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addMapping("pause", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addMapping("+", new KeyTrigger(KeyInput.KEY_ADD), new KeyTrigger(KeyInput.KEY_EQUALS));
    inputManager.addMapping("-", new KeyTrigger(KeyInput.KEY_SUBTRACT), new KeyTrigger(KeyInput.KEY_MINUS));
    inputManager.addListener((ActionListener) (String name, boolean isPressed, float tpf) -> {
        if (!isPressed) {
            return;
        }
        switch (name) {
            case "restart":
                cleanup();
                initializeNewTest();
                break;
            case "pause":
                bulletAppState.setSpeed(bulletAppState.getSpeed() > 0.1 ? 0 : bulletSpeed);
                break;
            case "+":
                bulletSpeed += 0.1f;
                if (bulletSpeed > 1f) {
                    bulletSpeed = 1f;
                }
                bulletAppState.setSpeed(bulletSpeed);
                break;
            case "-":
                bulletSpeed -= 0.1f;
                if (bulletSpeed < 0.1f) {
                    bulletSpeed = 0.1f;
                }
                bulletAppState.setSpeed(bulletSpeed);
                break;
        }
    }, "pause", "restart", "+", "-");

    guiNode = getGuiNode();
    font = assetManager.loadFont("Interface/Fonts/Default.fnt");
    testInfo[0] = new BitmapText(font);
    testInfo[1] = new BitmapText(font);
    speedText = new BitmapText(font);

    float lineHeight = testInfo[0].getLineHeight();
    testInfo[0].setText("Camera move: W/A/S/D/Q/Z     +/-: Increase/Decrease Speed");
    testInfo[0].setLocalTranslation(5, test.settings.getHeight(), 0);
    guiNode.attachChild(testInfo[0]);
    testInfo[1].setText("Left Click: Toggle pause            Space: Restart test");
    testInfo[1].setLocalTranslation(5, test.settings.getHeight() - lineHeight, 0);
    guiNode.attachChild(testInfo[1]);

    speedText.setLocalTranslation(202, lineHeight * 1, 0);
    guiNode.attachChild(speedText);

    initializeNewTest();
}
 
Example 20
Source File: CubeField.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * Sets up a BitmapText to be displayed
 * @param txt the Bitmap Text
 * @param text the 
 * @param font the font of the text
 * @param x    
 * @param y
 * @param z
 */
private void loadText(BitmapText txt, String text, BitmapFont font, float x, float y, float z) {
    txt.setSize(font.getCharSet().getRenderedSize());
    txt.setLocalTranslation(txt.getLineWidth() * x, txt.getLineHeight() * y, z);
    txt.setText(text);
    guiNode.attachChild(txt);
}