Package org.pollux3d.menu

Source Code of org.pollux3d.menu.TextTest

package org.pollux3d.menu;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.material.RenderState.FaceCullMode;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;

public class TextTest extends SimpleApplication {

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

  @Override
  public void simpleInitApp() {
        cam.setLocation(new Vector3f(3, 3, 3));
        cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);

        //rootNode.attachChild(loadLetter("A"));
       
        rootNode.attachChild(loadWord("HGFEBCA"));

  }
 
  private Node loadWord(String text) {
    Node word = new Node("word");
    int i = 0;
    float size = 0.65f;
    for (char c : text.toCharArray()) {
      Spatial letter = loadLetter(String.valueOf(c));
      letter.setLocalTranslation(size*i, 0, 0);
      word.attachChild(letter);
      i++;
    }
    return word;
  }
 
  private Spatial loadLetter(String letter) {
        Spatial sletter = (Spatial) assetManager.loadModel("Text/"+letter+".mesh.xml");
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    mat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
    sletter.setMaterial(mat);
    return sletter;
  }

}
TOP

Related Classes of org.pollux3d.menu.TextTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.