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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations