I’ve got a strange error when trying ti hide an element on the screen.
I can’t imagine what I did, as this was working just fine before.
When using the hide method on my start button it crashes with the following trace
May 24, 2014 6:40:26 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalArgumentException: Material parameter is not defined: Clipping
at com.jme3.material.Material.checkSetParam(Material.java:446)
at com.jme3.material.Material.setParam(Material.java:462)
at com.jme3.material.Material.setVector4(Material.java:653)
at tonegod.gui.core.Element.setFontPages(Element.java:2488)
at tonegod.gui.core.Element.updateLocalClipping(Element.java:2469)
at tonegod.gui.core.Element.updateClipping(Element.java:2438)
at tonegod.gui.core.Element.hide(Element.java:2277)
at mygame.GuiManager$1.onButtonMouseLeftUp(GuiManager.java:63)
at tonegod.gui.controls.buttons.Button.onMouseLeftReleased(Button.java:508)
at tonegod.gui.core.Screen.onMouseButtonEvent(Screen.java:893)
at com.jme3.input.InputManager.processQueue(InputManager.java:807)
at com.jme3.input.InputManager.update(InputManager.java:883)
at com.jme3.app.Application.update(Application.java:604)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:231)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)
I’ve got a strange error when trying ti hide an element on the screen.
I can’t imagine what I did, as this was working just fine before.
When using the hide method on my start button it crashes with the following trace
May 24, 2014 6:40:26 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalArgumentException: Material parameter is not defined: Clipping
at com.jme3.material.Material.checkSetParam(Material.java:446)
at com.jme3.material.Material.setParam(Material.java:462)
at com.jme3.material.Material.setVector4(Material.java:653)
at tonegod.gui.core.Element.setFontPages(Element.java:2488)
at tonegod.gui.core.Element.updateLocalClipping(Element.java:2469)
at tonegod.gui.core.Element.updateClipping(Element.java:2438)
at tonegod.gui.core.Element.hide(Element.java:2277)
at mygame.GuiManager$1.onButtonMouseLeftUp(GuiManager.java:63)
at tonegod.gui.controls.buttons.Button.onMouseLeftReleased(Button.java:508)
at tonegod.gui.core.Screen.onMouseButtonEvent(Screen.java:893)
at com.jme3.input.InputManager.processQueue(InputManager.java:807)
at com.jme3.input.InputManager.update(InputManager.java:883)
at com.jme3.app.Application.update(Application.java:604)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:231)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)
Thanks for reading!
Is this a custom font?
If so, can you open the .fnt file and copy & paste the first couple lines into a post here?
@BigBob said:
The only thing I did differently was added a TextElement to the screen, and this started happening.
Might be relevant that it uses the same font
I missed this…!
Ok… when was the last time this ran correctly?
Is it the TextElement you are trying to hide?
I may have broken this with the last update, but need to test your code here (just need to know the specifics of how you set up the text element and how you are showing/hiding it).
I think I need to see your code specifically to figure this out. TextElement is semi-experimental and can be finicky… but I’ve never seen this one before.
Hiding the text elements work just fine and it’s simply the font on the start button that is causing the issue
Here is the culprit class
As you can see line 80 is the culprit
If it’s commented it will run just fine with the default font on the button.
When trying to hide it at line 81 will throw the error with the impact font.
EDIT: Got it working by duplicating my fonts file, and calling it fonts1 and just changing the path. Works just fine now
There has always been an issue with fonts in the gui… one of the reasons I started looking at TextElement as an alternative. Lately, I have taken to not setting button text and creating a method to create a TextElement and add it i to the Button as a child. It solves large font alignment issues as well as dynamically changing the font being used… not to mention a slue of other issues I hit with BitmapText. And you can add effects to the text on mouse over, etc
Here is an example of how I do it:
[java]
// First a method to create a new button label…
private TextElement getButtonLabel(String UID, String text, Vector2f dim) {
TextElement el = new TextElement(screen, UID, Vector2f.ZERO, new Vector2f(dim), null) { @Override
public void onUpdate(float tpf) { } @Override
public void onEffectStart() { } @Override
public void onEffectStop() { }
};
el.setIgnoreMouse(true);
el.setIsResizable(false);
el.setIsMovable(false);
el.setTextWrap(LineWrapMode.NoWrap);
el.setTextVAlign(VAlign.Center);
el.setTextAlign(Align.Center);
el.setFontSize(18);
el.setText(text);
return el;
}
// Then create a button and call the method above to use TextElement as the button label
ButtonAdapter ba = new ButtonAdapter(
screen,
pos, // some position vec2f
dim // whatever dimensions
) {
// your event handlers
};
uid = UIDUtil.getUID();
bLabel = getButtonLabel(uid, “The button label text”, ba.getDimensions()); // set the dimensions of the TextElement to the dimensions of the button
ba.addChild(bLabel);
[/java]