Search in sources :

Example 16 with BitmapText

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

the class TestMipMapGen method simpleInitApp.

@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);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) BitmapText(com.jme3.font.BitmapText) Material(com.jme3.material.Material) Image(com.jme3.texture.Image) Texture(com.jme3.texture.Texture)

Example 17 with BitmapText

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

the class RenderDeviceJme method renderFont.

@Override
public void renderFont(RenderFont font, String str, int x, int y, Color color, float sizeX, float sizeY) {
    if (str.length() == 0) {
        return;
    }
    RenderFontJme jmeFont = (RenderFontJme) font;
    ColorRGBA colorRgba = convertColor(color, tempColor);
    CachedTextKey key = new CachedTextKey(jmeFont.getFont(), str);
    BitmapText text = textCacheLastFrame.get(key);
    if (text == null) {
        text = jmeFont.createText();
        text.setText(str);
        text.updateLogicalState(0);
    }
    textCacheCurrentFrame.put(key, text);
    //        float width = text.getLineWidth();
    //        float height = text.getLineHeight();
    //+ 0.5f * width * (1f - sizeX);
    float x0 = x;
    // + 0.5f * height * (1f - sizeY);
    float y0 = y;
    tempMat.loadIdentity();
    tempMat.setTranslation(x0, getHeight() - y0, 0);
    tempMat.setScale(sizeX, sizeY, 0);
    rm.setWorldMatrix(tempMat);
    rm.setForcedRenderState(renderState);
    text.setColor(colorRgba);
    text.updateLogicalState(0);
    text.render(rm, colorRgba);
//        System.out.format("renderFont(%s, %s, %d, %d, %s, %f, %f)\n", jmeFont.getFont(), str, x, y, color.toString(), sizeX, sizeY);
}
Also used : ColorRGBA(com.jme3.math.ColorRGBA) BitmapText(com.jme3.font.BitmapText)

Example 18 with BitmapText

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

the class TestHWSkinning method makeHudText.

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);
}
Also used : BitmapText(com.jme3.font.BitmapText)

Example 19 with BitmapText

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

the class TestSkeletonControlRefresh method makeHudText.

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);
}
Also used : BitmapText(com.jme3.font.BitmapText)

Example 20 with BitmapText

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

the class HelloOpenCL method simpleInitApp.

@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);
}
Also used : BitmapText(com.jme3.font.BitmapText) BitmapFont(com.jme3.font.BitmapFont)

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