So I have a nifty gui with 3 buttons. one creates a building, the second a transmission tower, and the third a coal factory. The first two work and the third doesnt. And i cant figure out why so I thought I would ask and see if anyone else can see something I dont, or think of something I cannot.
This is in the HUDScreenController
public void makeBuilding(){
app.newBuilding();
}
public void makeTower(){
app.newTower();
}
public void makeCoal(){
app.newCoal();
}
this is in the xml file for the HUD
<panel id="panel_right" width="20%" height="100%" childLayout="vertical"
backgroundColor="#00f8" >
<panel id="panel_right1" width="100%" height ="5%" childLayout="center">
<control name="button" label="Building" id="BuildingButton" align="center" valign="center" visibleToMouse="true">
<interact onClick="makeBuilding()"/>
</control>
</panel>
<panel id="panel_right2" width="100%" height ="5%" childLayout="center">
<control name="button" label="Tower" id="TowerButton" align="center" valign="center" visibleToMouse="true">
<interact onClick="makeTower()"/>
</control>
</panel>
<panel id="panel_right3" width="100%" height ="5%" childLayout="center">
<control name="button" label="Coal" id="CoalButton" align="center" valign="center" visibleToMouse="true">
<interact onClick="makeCoal()"/>
</control>
</panel>
and this is in the main file
public void newBuilding(){
Box red = new Box(Vector3f.ZERO, 2, 2, 2);
redGeom = new Geometry("Building" + buildNum, red);
buildNum++;
redGeom.setLocalTranslation(0, 0, distanceFromCamera);
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat2.setTexture("ColorMap", assetManager.loadTexture("Textures/building.jpg"));
redGeom.setMaterial(mat2);
rootNode.attachChild(redGeom);
newGenerator(redGeom.getName());
}
public void newTower(){
Spatial transTower = assetManager.loadModel("Models/transmissiontower/transmissiontower.j3o");
transTower.setLocalTranslation(0, 0, distanceFromCamera);
transTower.scale(0.2f);
//in radians 90 degrees is 1.57079633 radians, also turned it a little with the 3rd field
transTower.getLocalRotation().fromAngles(1.57079633f, 0, 1);
Material matb = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
//matb.setColor("Color", ColorRGBA.Magenta);
matb.setTexture("ColorMap", assetManager.loadTexture("Textures/transmissiontower.png"));
transTower.setMaterial(matb);
rootNode.attachChild(transTower);
transTower.setName("Transmission Tower" + transNum);
transNum++;
con.add(new Consumer(10, 0, transTower.getName()));
}
public void newCoal(){
Spatial coal = assetManager.loadModel("Models/coalplant/coalplant.j3o");
coal.setLocalTranslation(0, 0, distanceFromCamera);
coal.scale(0.5f);
//in radians 90 degrees is 1.57079633 radians
coal.getLocalRotation().fromAngles(1.57079633f, 0, 0);
Material mata = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
//mata.setColor("Color", ColorRGBA.Orange);
mata.setTexture("ColorMap", assetManager.loadTexture("Textures/coalplant.png"));
coal.setMaterial(mata);
rootNode.attachChild(coal);
coal.setName("Coal Plant");
gen.add(new Generator(5, 1, 1, coal.getName()));
genNum++;
}
Any help or suggestions of things to look for etc would be appreciated.