3 buttons, only 2 work

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

[java]public void makeBuilding(){



public void makeTower(){



public void makeCoal(){



this is in the xml file for the HUD

[xml]<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()"/>



<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()"/>



<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()"/>



and this is in the main file

[java]public void newBuilding(){

Box red = new Box(Vector3f.ZERO, 2, 2, 2);

redGeom = new Geometry("Building" + buildNum, red);


redGeom.setLocalTranslation(0, 0, distanceFromCamera);

Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");

mat2.setTexture("ColorMap", assetManager.loadTexture("Textures/building.jpg"));





public void newTower(){

Spatial transTower = assetManager.loadModel("Models/transmissiontower/transmissiontower.j3o");

transTower.setLocalTranslation(0, 0, distanceFromCamera);


//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.setName("Transmission Tower" + 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);


//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.setName("Coal Plant");

gen.add(new Generator(5, 1, 1, coal.getName()));



Any help or suggestions of things to look for etc would be appreciated.

Put a breakpoint or some logging in newCoal() to see if it is even reaching there. Also step through there with the debugger and make sure nothing is null, the spatials have a bounding box and look normal (ie not super, super tiny).

If that doesn’t work, try applying the working transmission tower texture to the coal model; see if it shows up then.

You can also try replacing the coal tower code with the box code from the newBuilding() method, that will tell you if you model isn’t quite loaded right.

Other than that, nothing jumps out at me in your code as to what might be wrong.

I wanna see a nice screenshot when this is working :slight_smile:

I had it in it already with the same code and it was the correct size and had the texture and everything. So i know its not the texture or the model. Ill try what you are suggesting though. And it really isnt all that pretty. Its for a project for school that is basically a power system with buildings and wires and such. But if you really want a screenshot when its working ill put one up. haha

So it seems to not be getting to newCoal(). Is there a way to see if its getting to the makeCoal() function in the controller? Because the system.out.println doesnt seem to work from the controllers.

Also is it possible this is some sort of bug in the alpha 4 code? im in the process of switching over but i have to change some things first that apparently dont exist any longer in beta.

Set a beakpoint in newBuilding() code and when the debugger reaches there, check the path (call stack) that it took to get there. Set a beakpoint above that and see what it does when you click on your coal button.

It is most likely not a bug in the nifty code in Beta. Especially if it works for some of your methods but not one of them.

So i tried something else before trying what you suggested. and no matter what i have in the makeBuilding function (in the controller)…it always makes a building. i dont know if this shows something or not or if im just doing something dumb and not seeing it haha. ill try your idea next.

So i added the breakpoint…and was going to ask how to run the debugger…then it started working. then i took off the breakpoint and it is still working but i didnt change anything besides the breakpoint…so im confused

heres the screenshot you asked for. nothing exciting.

Glad it is working now. That looks pretty cool btw, you have a good start.

Thanks. Its a prototype for a thing my (college) senior project professor is doing.

And now I have a new button and it isnt working…and I tried the breakpoint but it isnt magically working this time. How do you run debug?

I found how to run debug but it says

Not able to submit breakpoint MethodBreakpoint [Empowerment.HUDScreenController].goSolve ‘()Lvoid;’, reason: Method ‘goSolve’ with signature ‘()Lvoid;’ does not exist in class Empowerment.HUDScreenController.

Not able to submit breakpoint LineBreakpoint HUDScreenController.java : 39, reason: No executable location available at line 39 in class Empowerment.HUDScreenController.

it sounds like you need to do a clean and rebuild of the project. The built jars seem to be out of date from what you have in your code.

Thank you so much. You are a life saver. Or at the least a sanity saver. Thank you :slight_smile:

No problem :slight_smile: