Search in sources :

Example 21 with BitmapText

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

the class DetailedProfilerState method initialize.

@Override
protected void initialize(Application app) {
    Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f));
    mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
    Geometry darkenStats = new Geometry("StatsDarken", new Quad(PANEL_WIDTH, app.getCamera().getHeight()));
    darkenStats.setMaterial(mat);
    darkenStats.setLocalTranslation(0, -app.getCamera().getHeight(), -1);
    ui.attachChild(darkenStats);
    ui.setLocalTranslation(app.getCamera().getWidth() - PANEL_WIDTH, app.getCamera().getHeight(), 0);
    font = app.getAssetManager().loadFont("Interface/Fonts/Console.fnt");
    bigFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt");
    prof.setRenderer(app.getRenderer());
    rootLine = new StatLineView("Frame");
    rootLine.attachTo(ui);
    BitmapText frameLabel = new BitmapText(bigFont);
    frameLabel.setText("Total Frame Time: ");
    ui.attachChild(frameLabel);
    frameLabel.setLocalTranslation(new Vector3f(PANEL_WIDTH / 2 - bigFont.getLineWidth(frameLabel.getText()), -PADDING, 0));
    BitmapText cpuLabel = new BitmapText(bigFont);
    cpuLabel.setText("CPU");
    ui.attachChild(cpuLabel);
    cpuLabel.setLocalTranslation(PANEL_WIDTH / 4 - bigFont.getLineWidth(cpuLabel.getText()) / 2, -PADDING - 30, 0);
    BitmapText gpuLabel = new BitmapText(bigFont);
    gpuLabel.setText("GPU");
    ui.attachChild(gpuLabel);
    gpuLabel.setLocalTranslation(3 * PANEL_WIDTH / 4 - bigFont.getLineWidth(gpuLabel.getText()) / 2, -PADDING - 30, 0);
    frameTimeValue = new BitmapText(bigFont);
    frameCpuTimeValue = new BitmapText(bigFont);
    frameGpuTimeValue = new BitmapText(bigFont);
    selectedField = new BitmapText(font);
    selectedField.setText("Selected: ");
    selectedField.setLocalTranslation(PANEL_WIDTH / 2, -PADDING - 75, 0);
    selectedField.setColor(ColorRGBA.Yellow);
    ui.attachChild(frameTimeValue);
    ui.attachChild(frameCpuTimeValue);
    ui.attachChild(frameGpuTimeValue);
    ui.attachChild(selectedField);
    hideInsignificantField = new BitmapText(font);
    hideInsignificantField.setText("O " + INSIGNIFICANT);
    hideInsignificantField.setLocalTranslation(PADDING, -PADDING - 75, 0);
    ui.attachChild(hideInsignificantField);
    final InputManager inputManager = app.getInputManager();
    if (inputManager != null) {
        inputManager.addMapping(TOGGLE_KEY, new KeyTrigger(KeyInput.KEY_F6));
        inputManager.addMapping(CLICK_KEY, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
        inputManager.addListener(new ActionListener() {

            @Override
            public void onAction(String name, boolean isPressed, float tpf) {
                if (name.equals(TOGGLE_KEY) && isPressed) {
                    setEnabled(!isEnabled());
                }
                if (isEnabled() && name.equals(CLICK_KEY) && isPressed) {
                    handleClick(inputManager.getCursorPosition());
                }
            }
        }, TOGGLE_KEY, CLICK_KEY);
    }
}
Also used : Quad(com.jme3.scene.shape.Quad) Material(com.jme3.material.Material) BitmapText(com.jme3.font.BitmapText)

Example 22 with BitmapText

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

the class StatsAppState method loadFpsText.

/**
     * Attaches FPS statistics to guiNode and displays it on the screen.
     *
     */
public void loadFpsText() {
    if (fpsText == null) {
        fpsText = new BitmapText(guiFont, false);
    }
    fpsText.setLocalTranslation(0, fpsText.getLineHeight(), 0);
    fpsText.setText("Frames per second");
    fpsText.setCullHint(showFps ? CullHint.Never : CullHint.Always);
    guiNode.attachChild(fpsText);
}
Also used : BitmapText(com.jme3.font.BitmapText)

Example 23 with BitmapText

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

the class TestBrickWall method initCrossHairs.

protected void initCrossHairs() {
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText ch = new BitmapText(guiFont, false);
    ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);
    // crosshairs
    ch.setText("+");
    // center
    ch.setLocalTranslation(settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2, settings.getHeight() / 2 + ch.getLineHeight() / 2, 0);
    guiNode.attachChild(ch);
}
Also used : BitmapText(com.jme3.font.BitmapText)

Example 24 with BitmapText

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

the class TestBoneRagdoll method initCrossHairs.

protected void initCrossHairs() {
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText ch = new BitmapText(guiFont, false);
    ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);
    // crosshairs
    ch.setText("+");
    // center
    ch.setLocalTranslation(settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2, settings.getHeight() / 2 + ch.getLineHeight() / 2, 0);
    guiNode.attachChild(ch);
}
Also used : BitmapText(com.jme3.font.BitmapText)

Example 25 with BitmapText

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

the class WireNumberControl method controlUpdate.

@Override
protected void controlUpdate(float tpf) {
    for (Entry<BitmapText, Vector3f> num : nums.entrySet()) {
        Vector3f middle = num.getValue();
        Vector3f loc = camera.getScreenCoordinates(middle);
        moveMarker(num.getKey(), loc);
    }
}
Also used : BitmapText(com.jme3.font.BitmapText) 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