Material Not Defined Clipping

Hi there,

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!

@BigBob said: Hi there,

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?

1 Like

@t0neg0d

Sure, the weird thing is was that it was working just a few minutes before!

Here you go!

info face=null size=50 bold=0 italic=0 charset=ASCII unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
common lineHeight=62 base=26 scaleW=600 scaleH=600 pages=1 packed=0
page id=0 file=“Impact.png”
chars count=255

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

@BigBob

Replace charset=ASCII with charset=""

Can’t guarantee this will solve the issue, however… it has cause other similar issues before.

The other thing you may want to do, is clean & build the project to make sure it isn’t a caching issue.

1 Like

@t0neg0d

Unfortunately neither worked :frowning:

Can you post the code for the element?

Are you running windows?

Have you restarted your machine? =)

If this started without a change to the code and it’s the same version of the plugin, then this has to be a caching issue.

@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).

Well… I just tested the following with TextElement and can’t repro this:

el.hide();
el.show();
el.hideWithEffect();
el.showWithEffect();

All of these set the clipping on the material.

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.

@t0neg0d

No it is the button I’m trying to hide.

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

@BigBob said: @t0neg0d

No it is the button I’m trying to hide.

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]