HUD : Clipping and Componentization

Actually widgets extends TransformGroup, which is a bad thing, because a widget isn’t a sort of TransformGroup. Instead it uses a TransformGroup to be displayed.

So instead of :

WidgetBase extends TransformGroup

we should have :

WidgetBase {
TransformGroup tg

public void addChild(Node node) {
//...

Which would permit us to add an invisible yet rendered plane (TransparencyAttributes, alpha test function = NEVER) used only for stencil test (stencil function = ALWAYS) and when adding child to a component, setting the stencil function of all children to EQUALS.
I’m afraid I am not clear at all but I think it would permit to clip widgets so they display only in their allocated zone.

(See the StencilTest to see what I’m talking about).

If there’s no objection I’m gonna implement that. But I didn’t used Stencil Buffer before and maybe some of you can point out possible issues with this technique, or simpler methods to do clipping.

[quote="<MagicSpark.org [ BlueSky ]>,post:1,topic:27903"]
Actually widgets extends TransformGroup, which is a bad thing, because a widget isn’t a sort of TransformGroup. Instead it uses a TransformGroup to be displayed.

So instead of :

WidgetBase extends TransformGroup

we should have :

WidgetBase {
TransformGroup tg

public void addChild(Node node) {
//...

[/quote]
Wouldn’t this stand for doing things like group.addChild(hud.getGroup()). Which is a bad thing one will have to fight with like in the SceneBase class. So I don’t see the advantage. WidgetBase should at least extend Group or BranchGroup.

[quote="<MagicSpark.org [ BlueSky ]>,post:1,topic:27903"]
Which would permit us to add an invisible yet rendered plane (TransparencyAttributes, alpha test function = NEVER) used only for stencil test (stencil function = ALWAYS) and when adding child to a component, setting the stencil function of all children to EQUALS.
I’m afraid I am not clear at all but I think it would permit to clip widgets so they display only in their allocated zone.

(See the StencilTest to see what I’m talking about).

If there’s no objection I’m gonna implement that. But I didn’t used Stencil Buffer before and maybe some of you can point out possible issues with this technique, or simpler methods to do clipping.
[/quote]
Yes, I have already thought of this. That’s why I introduced the WidgetContainer interface. But I didn’t know a way to do clipping. But when I saw the StencilTest during my code cleaning/-streamlining of the test package the last days I thought of doing this, too. So great idea, Amos. Feel free to implement it.

But we should talk about this TransformGroup extension thing. You are right, that a Widget is not a TransformGroup, but it is a Group or BranchGroup.

When I saw the PolygonOffsetTest I realized that this technique is the right one to implement the zindex thing. So far I move a Widget with a greater zindex a minimal step to the camera, which is bad.

But I didn’t fully check it. So I cannot say, if it will work properly.

Yes, I have already thought of this. That’s why I introduced the WidgetContainer interface. But I didn’t know a way to do clipping. But when I saw the StencilTest during my code cleaning/-streamlining of the test package the last days I thought of doing this, too. So great idea, Amos. Feel free to implement it.
[/quote]
I am not sure… but I think the combination “alpha test function = NEVER & stencil function = ALWAYS” wouldn’t work. Alpha test is done before the stencil so reference stencil value will never end up in stencil buffer… so those pixels of HUD-components which are to be comparised by stencil value simply will have nothing to be comparised to… and clipping will not be performed they will be drawen as they are… Again - I’m not too sure… but I had problems with that some time and I had to just set alpha = 1.0 for stencil reference plane, disable alpha sorting (you may need it if your HUD components are to be transparent), and switch off depth test on it (as for coinsiding/coplanar geoms… same “z”…) that way it works… but again switching off depth buffer - is not always the best thing… anyhow what I wanted to say - it might be not that easy… just be aware of these possible problems.

Bohdan.

[quote="<MagicSpark.org [ BlueSky ]>,post:1,topic:27903"]
Actually widgets extends TransformGroup, which is a bad thing, because a widget isn’t a sort of TransformGroup. Instead it uses a TransformGroup to be displayed.

So instead of :

WidgetBase extends TransformGroup

we should have :

WidgetBase {
TransformGroup tg

public void addChild(Node node) {
//...

[/quote]
Hah, you were right. :slight_smile:
I rechecked this thing and removed the TransformGroup extension from WidgetBase.