I’m having trouble testing out the 3D rendering of nodes with geometry children since it appears to make materials transparent/semi-transparent in some places or just doesn’t render some child geometries. Looks like there isn’t a Z buffer or something maybe?
Marked some of the see through glitches with red arrows and the cyan arrows show that the turbine blades (which are linked to a bone) get displaced/vanish completely.
How it should look like for reference (nifty + separate viewport):
Lemur init:
GuiGlobals.initialize(CPU.game);
BaseStyles.loadGlassStyle();
GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");
Styles styles = GuiGlobals.getInstance().getStyles();
Attributes attrs;
attrs = styles.getSelector("glass");
attrs.set("fontSize", 14);
QuadBackgroundComponent bg = new QuadBackgroundComponent(new ColorRGBA(0, 0, 0, 0.5f));
attrs = styles.getSelector("button", "glass");
attrs.set("color", new ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f));
attrs.set("background", bg);
BitmapFont font = CPU.game.getAssetManager().loadFont("assets/font/neuropolitical.fnt");
attrs = styles.getSelector("slider", "button", "glass");
attrs.set("fontSize", 14);
attrs.set("font", font);
Code:
//import 60 lines of imports
@SuppressWarnings({"rawtypes" })
public class TradeScreen extends Container{
private Terminal t;
private int i;
private ArrayList<Class> moduletypes = new ArrayList<Class>();
private Mod spin;
private float angle = 0;
private Quaternion startrotat;
private Label name, desc;
@SuppressWarnings("unchecked")
public TradeScreen(Terminal t) {
super();
setLocalScale(GUI.hei/1080);
moduletypes.add(Block.class);
moduletypes.add(Block.class);
moduletypes.add(Block.class);
moduletypes.add(Block2.class);
moduletypes.add(Block2.class);
moduletypes.add(Block2.class);
moduletypes.add(Block4.class);
moduletypes.add(Block4.class);
moduletypes.add(Block4.class);
moduletypes.add(Block_Slope.class);
moduletypes.add(Block_Slope.class);
moduletypes.add(Block_Slope.class);
moduletypes.add(Pylon.class);
moduletypes.add(LongCommand.class);
moduletypes.add(LongCommand.class);
moduletypes.add(LongCommand.class);
moduletypes.add(BasicEngine.class);
moduletypes.add(BasicEngine.class);
moduletypes.add(BasicEngine.class);
moduletypes.add(Minigun.class);
moduletypes.add(SimpleCannon.class);
moduletypes.add(SimpleLaser.class);
moduletypes.add(SimplePlasma.class);
moduletypes.add(Reactor.class);
moduletypes.add(ReactorLong.class);
moduletypes.add(ReactorOld.class);
moduletypes.add(Scanner.class);
moduletypes.add(ScannerFlat.class);
moduletypes.add(ShieldEmitter.class);
moduletypes.add(TractorBeam.class);
moduletypes.add(Cargo.class);
moduletypes.add(CollectorVent.class);
moduletypes.add(BussardCollector.class);
moduletypes.add(CollectorJet.class);
moduletypes.add(MicroTank.class);
moduletypes.add(MediumTank.class);
moduletypes.add(FuelTankMk1.class);
moduletypes.add(IndustrialTank.class);
// Add some elements
Label title = new Label("Trade Terminal");
title.setFontSize(25);
title.setColor(ColorRGBA.White);
title.setFont(CPU.game.getAssetManager().loadFont("assets/font/neuropolitical.fnt"));
addChild(title);
Container subcont = new Container();
subcont.setLayout(new SpringGridLayout(Axis.X, Axis.Y));
addChild(subcont);
name = new Label("name");
name.setColor(ColorRGBA.White);
name.setFont(CPU.game.getAssetManager().loadFont("assets/font/neuropolitical.fnt"));
name.setFontSize(18);
addChild(name);
desc = new Label("desc");
desc.setColor(ColorRGBA.White);
desc.setFont(CPU.game.getAssetManager().loadFont("assets/font/neuropolitical.fnt"));
desc.setFontSize(15);
addChild(desc);
startrotat = new Quaternion().fromAngleAxis(30*FastMath.DEG_TO_RAD, Vector3f.UNIT_Y);
startrotat.multLocal(new Quaternion().fromAngleAxis(30*FastMath.DEG_TO_RAD, Vector3f.UNIT_X));
for (int j = 0; j < moduletypes.size(); j++) {
Class c = moduletypes.get(j);
Class[] cArg = new Class[4];
cArg[0] = float.class;
cArg[1] = float.class;
cArg[2] = float.class;
cArg[3] = Faction.class;
Mod b = null;
try {
b = (Mod)c.getDeclaredConstructor(cArg).newInstance(50,-50,10,nextFac());
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
b.setLocalRotation(startrotat);//Const.ZX45.mult(new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Z))
b.setLocalScale(20);
Button button = subcont.addChild(new Button(""),j%8,(int)j/8);
button.setUserData("mod", b);
button.setPreferredSize(new Vector3f(100,100,0));
button.setColor(ColorRGBA.White);
button.setFont(CPU.game.getAssetManager().loadFont("assets/font/neuropolitical.fnt"));
button.setFontSize(20);
button.attachChild(b);
final long price = b.getPrice();
final Faction fac = b.getFaction();
button.addClickCommands(new Command<Button>() {
@Override
public void execute( Button source ) {
t.buyModule(c, price, fac);
}
});
MouseEventControl.addListenersToSpatial(button, new DefaultMouseListener() {
@Override
public void mouseEntered( MouseMotionEvent event, Spatial target, Spatial capture ) {
spin = (Mod)target.getUserData("mod");
name.setText(spin.Name());
desc.setText(spin.Description());
angle = 0;
}
@Override
public void mouseExited( MouseMotionEvent event, Spatial target, Spatial capture ) {
if(spin == (Mod)target.getUserData("mod")){
name.setText("");
desc.setText("");
spin = null;
}
((Mod)target.getUserData("mod")).setLocalRotation(startrotat);
}
});
}
AmbientLight a = new AmbientLight();
a.setColor(ColorRGBA.White.mult(1f));
addLight(a);
BoundingBox b = (BoundingBox) getWorldBound();
setLocalTranslation(GUI.wid/2f-350, GUI.hei/2f+(moduletypes.size()-1)/8*50, 0);
}
private Faction nextFac(){
i = (i+1)%3;
switch(i-1)
{
case 0: return Faction.Agency;
case 1: return Faction.Industrial;
default: return Faction.Regular;
}
}
public void cycle(float tpf)
{
if(spin != null){
spin.setLocalRotation(startrotat.mult(spin.getLocalRotation().fromAngleAxis(angle, Vector3f.UNIT_Y)));
angle+=tpf*1.5f;
System.out.println(angle);
}
}
}
P.S. How is the label wrap mode on labels coming along? Longer descriptions kind of stretch the whole container by default. This looks kind of grim…