Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  HUD : Clipping and Componentization  (Read 1007 times)
0 Members and 1 Guest are viewing this topic.
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Posted 2006-07-13 13:26:32 »

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 :
1  
WidgetBase extends TransformGroup

we should have :
1  
2  
3  
4  
5  
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.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #1 - Posted 2006-07-13 15:11:49 »

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 :
1  
WidgetBase extends TransformGroup

we should have :
1  
2  
3  
4  
5  
WidgetBase {
TransformGroup tg

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


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.

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.

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.
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #2 - Posted 2006-07-13 15:15:27 »

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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline bohdan

Junior Member




Java-positive...


« Reply #3 - Posted 2006-07-14 01:11:21 »


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.

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.

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.
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #4 - Posted 2006-07-16 23:41:20 »

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 :
1  
WidgetBase extends TransformGroup

we should have :
1  
2  
3  
4  
5  
WidgetBase {
TransformGroup tg

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


Hah, you were right. Smiley
I rechecked this thing and removed the TransformGroup extension from WidgetBase.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (64 views)
2014-04-15 18:08:23

BurntPizza (62 views)
2014-04-15 03:46:01

UprightPath (75 views)
2014-04-14 17:39:50

UprightPath (58 views)
2014-04-14 17:35:47

Porlus (76 views)
2014-04-14 15:48:38

tom_mai78101 (101 views)
2014-04-10 04:04:31

BurntPizza (161 views)
2014-04-08 23:06:04

tom_mai78101 (256 views)
2014-04-05 13:34:39

trollwarrior1 (209 views)
2014-04-04 12:06:45

CJLetsGame (216 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!