Java Code Examples for com.jme3.font.BitmapText#setSize()
The following examples show how to use
com.jme3.font.BitmapText#setSize() .
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 |
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: HelloPhysics.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** A plus sign used as crosshairs to help the player with aiming.*/ 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("+"); // fake crosshairs :) ch.setLocalTranslation( // center settings.getWidth() / 2, settings.getHeight() / 2, 0); guiNode.attachChild(ch); }
Example 3
Source File: TestBrickWall.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 4
Source File: TerrainTestCollision.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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: TestBrickTower.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 6
Source File: TerrainTest.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void loadHintText() { hintText = new BitmapText(guiFont, false); hintText.setSize(guiFont.getCharSet().getRenderedSize()); hintText.setLocalTranslation(0, getCamera().getHeight(), 0); hintText.setText("Hit T to switch to wireframe, P to switch to tri-planar texturing"); guiNode.attachChild(hintText); }
Example 7
Source File: TestBatchedTower.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 8
Source File: HelloPicking.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** A centred plus sign to help the player aim. */ protected void initCrossHairs() { guiNode.detachAllChildren(); 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 9
Source File: HelloAssets.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { /** Load a teapot model (OBJ file from test-data) */ Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj"); Material mat_default = new Material( assetManager, "Common/MatDefs/Misc/ShowNormals.j3md"); teapot.setMaterial(mat_default); rootNode.attachChild(teapot); /** Create a wall (Box with material and texture from test-data) */ Box box = new Box(2.5f, 2.5f, 1.0f); Spatial wall = new Geometry("Box", box ); Material mat_brick = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat_brick.setTexture("ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg")); wall.setMaterial(mat_brick); wall.setLocalTranslation(2.0f,-2.5f,0.0f); rootNode.attachChild(wall); /** Display a line of text (default font from test-data) */ setDisplayStatView(false); guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText helloText = new BitmapText(guiFont, false); helloText.setSize(guiFont.getCharSet().getRenderedSize()); helloText.setText("Hello World"); helloText.setLocalTranslation(300, helloText.getLineHeight(), 0); guiNode.attachChild(helloText); /** Load a Ninja model (OgreXML + material + texture from test_data) */ Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml"); ninja.scale(0.05f, 0.05f, 0.05f); ninja.rotate(0.0f, -3.0f, 0.0f); ninja.setLocalTranslation(0.0f, -5.0f, -2.0f); rootNode.attachChild(ninja); /** You must add a light to make the model visible */ DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal()); rootNode.addLight(sun); }
Example 10
Source File: HelloAssets.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void simpleInitApp() { /** Load a teapot model (OBJ file from test-data) */ Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj"); Material mat_default = new Material( assetManager, "Common/MatDefs/Misc/ShowNormals.j3md"); teapot.setMaterial(mat_default); rootNode.attachChild(teapot); /** Create a wall (Box with material and texture from test-data) */ Box box = new Box(Vector3f.ZERO, 2.5f,2.5f,1.0f); Spatial wall = new Geometry("Box", box ); Material mat_brick = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat_brick.setTexture("ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg")); wall.setMaterial(mat_brick); wall.setLocalTranslation(2.0f,-2.5f,0.0f); rootNode.attachChild(wall); /** Display a line of text (default font from test-data) */ guiNode.detachAllChildren(); guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText helloText = new BitmapText(guiFont, false); helloText.setSize(guiFont.getCharSet().getRenderedSize()); helloText.setText("Hello World"); helloText.setLocalTranslation(300, helloText.getLineHeight(), 0); guiNode.attachChild(helloText); /** Load a Ninja model (OgreXML + material + texture from test_data) */ Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml"); ninja.scale(0.05f, 0.05f, 0.05f); ninja.rotate(0.0f, -3.0f, 0.0f); ninja.setLocalTranslation(0.0f, -5.0f, -2.0f); rootNode.attachChild(ninja); /** You must add a light to make the model visible */ DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal()); rootNode.addLight(sun); }
Example 11
Source File: TestBrickTower.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 12
Source File: TestBrickWall.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 13
Source File: TestBatchNodeTower.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 14
Source File: TestLightScattering.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 15
Source File: TerrainTestCollision.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 16
Source File: TerrainTestReadWrite.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 17
Source File: TestBatchNodeTower.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 18
Source File: TestDirectionalLightShadow.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
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 19
Source File: ShadowTestUIManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
private BitmapText createText(BitmapFont guiFont) { BitmapText t = new BitmapText(guiFont, false); t.setSize(guiFont.getCharSet().getRenderedSize() * 0.75f); return t; }
Example 20
Source File: TestMotionPath.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@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() { @Override 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(); }