Plane Clipping / ClipState

Maybee someone can help me with this:

I have made a HUD, and are trying to clip a child node of a hud.

The clipping kind of works, but not in the coordinate system of my child node…



The clipping planes are in the coordinarte system of the root HUD node. This is possible to get around, by getting the right coordinates for my subnode… BUT… When I change the sign of the x-value in the equation:


…nothing is clipped at all… I would expect "the other side" to be clipped…

What am I missing?? Any ideas??

if you want the plane to be at the same position you would have to change the offset value too…like this:


Thanks Mr. Coder!! It works…

This makes the HUD gymnastics code much more clean! Here is a helper class I made, that clips a HUD spatial with a rectangle:

import com.jme.scene.Spatial;
import com.jme.scene.state.ClipState;
import com.jme.system.DisplaySystem;

 * @author TOMMYS
public class ClipRectangleHUD {
    private Spatial spat;
    private ClipState cs;
    private float width = 0;
    private float height = 0;
    public ClipRectangleHUD(Spatial spat, float width, float height) {
        this.spat = spat;
        cs = DisplaySystem.getDisplaySystem().getRenderer().createClipState();
        updateEquations(width, height);
        for (int i = 0; i < 4; i++) {
            cs.setEnableClipPlane(i, true);

    public void updateEquations(float wi, float he) {
        float x0 = spat.getWorldTranslation().x - wi / 2;
        float x1 = spat.getWorldTranslation().x + wi / 2;
        float y0 = spat.getWorldTranslation().y - he / 2;
        float y1 = spat.getWorldTranslation().y + he / 2;