Skip to content

Commit

Permalink
jMonkeyEngine#2279 Add a test for BitmapText3D
Browse files Browse the repository at this point in the history
  • Loading branch information
richardTingle committed Jun 7, 2024
1 parent f9894c1 commit e87071c
Showing 1 changed file with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.jmonkeyengine.screenshottests.gui;

import com.jme3.anim.AnimComposer;
import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.app.state.BaseAppState;
import com.jme3.asset.AssetManager;
import com.jme3.export.binary.BinaryExporter;
import com.jme3.export.binary.BinaryImporter;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.font.Rectangle;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Quad;
import org.jmonkeyengine.screenshottests.testframework.ExtentReportExtension;
import org.jmonkeyengine.screenshottests.testframework.ScreenshotTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

@ExtendWith(ExtentReportExtension.class)
public class TestBitmapText3D{


/**
* This tests both that bitmap text is rendered correctly and that it is
* wrapped correctly.
*/
@Test
public void testBitmapText3D(){

new ScreenshotTest(
new BaseAppState(){
@Override
protected void initialize(Application app){
String txtB = "ABCDEFGHIKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()-=_+[]\\;',./{}|:<>?";

AssetManager assetManager = app.getAssetManager();
Node rootNode = ((SimpleApplication)app).getRootNode();

Quad q = new Quad(6, 3);
Geometry g = new Geometry("quad", q);
g.setLocalTranslation(-1.5f, -3, -0.0001f);
g.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
rootNode.attachChild(g);

BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
BitmapText txt = new BitmapText(fnt);
txt.setBox(new Rectangle(0, 0, 6, 3));
txt.setQueueBucket(RenderQueue.Bucket.Transparent);
txt.setSize( 0.5f );
txt.setText(txtB);
txt.setLocalTranslation(-1.5f,0,0);
rootNode.attachChild(txt);
}

@Override
protected void cleanup(Application app){}

@Override
protected void onEnable(){}

@Override
protected void onDisable(){}
}
).run();


}
}

0 comments on commit e87071c

Please sign in to comment.