if (vis != null && charSelection != null && charSelection.name != null) {
if(label != null)
detachChild(label);
BitmapFont fnt = Singleton.get().getAssetManager().getJmeAssetMan().loadFont("Interface/Fonts/Default.fnt");
BitmapText txt = new BitmapText(fnt, false);
txt.setSize( 0.4f );
txt.setText(charSelection.name);
float w = txt.getLineWidth()+20f;
float off = w*0.5f;
txt.setBox(new Rectangle(-off, 0f, w, txt.getHeight()));
txt.setAlignment(Align.Center);
txt.setQueueBucket(Bucket.Transparent);
txt.addControl(new BillboardControl());
label = new Node("label");
if(vis.getWorldBound() instanceof BoundingBox){
BoundingBox bbox = (BoundingBox)vis.getWorldBound();
label.setLocalTranslation(0f, bbox.getYExtent()+bbox.getYExtent()+0.5f, 0f);
logger.finest("Label by BBox "+txt.getText()+" @ "+label.getLocalTranslation());
}
else if(vis.getWorldBound() instanceof BoundingSphere){
BoundingSphere bound = (BoundingSphere)vis.getWorldBound();
label.setLocalTranslation(0f, bound.getRadius()+bound.getRadius()+0.5f, 0f);
logger.finest("Label by BSphere "+txt.getText()+" @ "+label.getLocalTranslation());
}
else {
label.setLocalTranslation(0f, 2.5f, 0f);
logger.finest("Label by Code "+txt.getText()+" @ "+label.getLocalTranslation());
}
label.attachChild(txt);
attachChild(label);
}
}