Hi all 8) . I came across another problem. Not sure where to post the problem so I posted it here. I made a BillBoard Text that keeps hovering on a model, it only shows the text without any background color. It worked perfectly but when I removed the Display Stat View(setDisplayStatView(false)) the BillBoard Text started to have a black background, not sure why.
Here is my code of the BillBoard Text:
[java]
package Others;
import com.jme3.asset.AssetManager;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial.CullHint;
import com.jme3.scene.control.BillboardControl;
/**
*
-
@author Kamran
*/
public class StatPopUp {
AssetManager assetManager;
BitmapFont font;
BitmapText textHP, textE;public Node textNode;
public StatPopUp(AssetManager assetManager){
this.assetManager = assetManager;
textNode = new Node(“Text Node”);init();
}
public void init(){
font = assetManager.loadFont(“Interface/Fonts/ComicSansMS.fnt”);
textHP = new BitmapText(font, false);
textHP.setText(“Health”);
textHP.setColor(ColorRGBA.Red);
textHP.setSize(0.6f);textE = new BitmapText(font, false); textE.setText("Energy"); textE.setColor(new ColorRGBA(0.4f, 1.0f, 1.0f, 0.5f)); textE.setSize(0.7f);
// textHP.rotate(0, 0, 1.57f);
// textHP.addControl(new BillboardControl());
textNode.attachChild(textHP);
textNode.attachChild(textE);
textNode.addControl(new BillboardControl());
textHP.setLocalTranslation(-1, 3, 0);
textE.setLocalTranslation(-1, 3.7f, 0);
}
public void setupTextAxisY(float y){
textHP.setLocalTranslation(-1, y, 0);
textE.setLocalTranslation(-1, y + 0.7f, 0);
}
public void setVisible(){
textNode.setCullHint(CullHint.Inherit);
}
public void setInvisible(){
textNode.setCullHint(CullHint.Always);
}
public void update(Vector3f position, int hp, int energy){
if(hp <= 0){
setInvisible();
}
textHP.setText(""+hp);
textE.setText(""+energy);
textNode.setLocalTranslation(position);
}
}
[/java]
I am also giving images to show what I mean.
- With FPS and Stat View Display
[java]
@Override
public void simpleInitApp() {
// setDisplayFps(false);
// setDisplayStatView(false);
setupHeadLessClasses();
setupCamAndLight();
loadGUI();
}
[/java]
- Without FPS and Stat View Display
[java]
@Override
public void simpleInitApp() {
setDisplayFps(false);
setDisplayStatView(false);
setupHeadLessClasses();
setupCamAndLight();
loadGUI();
}
[/java]
The problem only arises when I remove the Display Stat.
Thank you.
K Out!