TrueType Font Support

cool, and correct…blending = srcColsrcFunction + dstColdstFunction … so doing sb_src_alpha and db_one with your source color black rgba=(0,0,0,1) and some background color rgba=(0.5,0.2,0.7,1.0) would sum up to…tadaaaa! rgba=(0.5,0.2,0.7,1.0) the destination color! :slight_smile: (looking more transparent the darker the color)

I have been experimenting with the TextTT class… thanks for providing it! I am not having success using this class to render to the ORTHO render queue, and can't seem to figure why. Is this possible? I've tried just changing the render queue in the test class provided in this thread but the text does not render to screen. I've also set it to CULL_NEVER to make sure it's not being culled. Any ideas?

what translation are you giving the text?  I've had things disappear in ortho mode if z != 0 or if my x or y coordinate is off screen.

I'm using the text class provided, only modifying the render queue, setting CULL_NEVER, and setting the translation to (200,200,0) which should be on screen. Are you able to make it work? I'm just using the TextTT class directly as written in the initial posting on this thread.



Thanks!


package datascape.util;

import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import java.io.InputStream;

import org.lwjgl.Sys;

import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;

/**
 * <code>TestTruetypeFont</code>
 * @author Jeremy Adams
 *
 */
public class TestTruetypeFont extends SimpleGame {

   public static void main(String[] args) {
      TestTruetypeFont app = new TestTruetypeFont();
      app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
      app.start();
   }

   protected void simpleInitGame() {
      display.setTitle("A Truetype Font Test");

      Font font = new Font("Serif", Font.PLAIN, 32);

      long tstarttime = System.currentTimeMillis();
      FontTT text = new FontTT(font.deriveFont(Font.PLAIN),64,0);
      long tendtime = System.currentTimeMillis() - tstarttime;
      System.out.println("Finished loading fonts in " + tendtime);
      Node playertext = text.createText("Look at me!", 2, new ColorRGBA(1,1,0.1f,1f),true);
      playertext.setLocalTranslation(new Vector3f(200,200,0));
      playertext.setCullMode(Node.CULL_NEVER);
      playertext.setRenderQueueMode(Renderer.QUEUE_ORTHO);
      playertext.setModelBound(new BoundingBox());
      playertext.updateModelBound();
      playertext.updateWorldBound();



      rootNode.attachChild(playertext);
   }
}

Try adding a rootNode.setCullMode(Node.CULL_NEVER); in your code.  Your bounding box may be propogated up to the rootnode resulting in a bounding that doesn't work the way you think it does.

Hmmm… yes this had an effect but still not quite there. Prior to adding the "rootNode.setCullMode(Node.CULL_NEVER);", the statistics output (after FPS) showed: "Counts: nothing displaying". If I add the CULL_NEVER to rootNode then I get "Counts: Mesh(11) Tri(22) Vert(44)" so it appears that that helped with the culling, but I still have nothing displaying on screen. Do you get the same results?


package datascape.util;

import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import java.io.InputStream;

import org.lwjgl.Sys;

import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;

/**
 * <code>TestTruetypeFont</code>
 * @author Jeremy Adams
 *
 */
public class TestTruetypeFont extends SimpleGame {

   public static void main(String[] args) {
      TestTruetypeFont app = new TestTruetypeFont();
      app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
      app.start();
   }

   protected void simpleInitGame() {
      display.setTitle("A Truetype Font Test");

      Font font = new Font("Serif", Font.PLAIN, 32);

      long tstarttime = System.currentTimeMillis();
      FontTT text = new FontTT(font.deriveFont(Font.PLAIN),64,0);
      long tendtime = System.currentTimeMillis() - tstarttime;
      System.out.println("Finished loading fonts in " + tendtime);
      Node playertext = text.createText("Look at me!", 2, new ColorRGBA(1,1,0.1f,1f),true);
      playertext.setLocalTranslation(new Vector3f(200,200,0));
      rootNode.setCullMode(Node.CULL_NEVER);
      playertext.setRenderQueueMode(Renderer.QUEUE_ORTHO);
      playertext.setModelBound(new BoundingBox());
      playertext.updateModelBound();
      playertext.updateWorldBound();



      rootNode.attachChild(playertext);
   }
}

The problem is scale.  The quads are a few units high, which is fine in 3d space, but teeny in ortho.  Adding a line like this will blow it up big enough to see:


playertext.getLocalScale().set(16,16,1);

d'oh! good call…



thanks for the help, renanse!

happy to help

What kind of license is this code snippet under (the topic starter true type text node generator class)? I want to use it in jcrpg (http://jcrpg.blogspot.com) an opensource game. Is it GPL/BSD or Totally Free?