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] 2
  ignore  |  Print  
  Xith3D HUD support?  (Read 3431 times)
0 Members and 1 Guest are viewing this topic.
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Posted 2004-09-11 07:21:05 »

Has anyone had luck implementing a good clean HUD in Xith3D?

I've looked at the Billboard options and I'm not convinced there isn't a better way.  I don't want to use the UI package for this as Swing adds a lot of overhead just for displaying a few images.

I would like a Node which keeps the geometry always infront of the view automatically (and importantly that honours alpha transparancy and blending).

Would I be correct in implementing this in the Foreground node?  It doesn't seem to do much at the moment.

I would probably use a similar technique to the background node to keep the camera locked to the objects, but unlike with the background  node where the camera would rotate depending on the view, with the Foreground it would not.

These are just my initial thoughts - any comments?  I will hopefuly be implementing this soon.

Cheers,

Will.

Offline hawkwind

Junior Member




Java games rock!


« Reply #1 - Posted 2004-09-11 20:03:10 »

Why not use a varient of the XithGui test example Huh

 I have several dialog windows, button etc painted to fixed positions of the window independent of view rotation
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #2 - Posted 2004-09-12 00:34:07 »

The XithGui test (what I dubbed "UI package") a.k.a. com.xith3d.userinterface is a great package, don't get me wrong but there are some issues in using it for HUD's.

Advantages:

  • It uses Swing, so adding widgets is now very easy.  Clickable buttons for example are simple, as are text boxes, scrollable windows, tabbed panes etc.


Disadvantages:

  • It uses Swing so you add a dependancy and some operating overhead.  If you use Swing stuff then this isn't a problem - you are saving a lot of development time, but if you just want an image on the screen this is a lot of needless overhead.
  • It's 2D.  While you can pre-render the HUD images to give a 3D looking HUD, it's not true 3D.  Eg. what if I want a cool movable 3D switch or steering wheel?


This is my reasoning.

I'm going to go code in this support as I think it will be useful for HUD's and other uses.

Will.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Bombadil

Senior Member





« Reply #3 - Posted 2004-09-12 05:27:13 »

Yes, we need a clean and very simple to use HUD system in Xith3d.
The UI one is another topic, like Will said. Way too complex for some simple 2d textures.
However I've no idea which would be the best way to implement.

From a user's point of view, there could be a switch to say "HUD mode on" (in other API's you switch the renderer) and then you directly let plot your textures to screen coordinates.
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #4 - Posted 2004-09-12 05:57:36 »

Ok, I have beefed up the Forground node functionality considerably.

I had to keep the "normal" view support as it turns out the com.xith3d.scenegraph package was using it (and now I think about it there may be some other use-cases which need it).  By "normal", I mean the geometry is rendered like it normally is as if it wasn't a Foreground node at all, the only difference being that it is rendered last.

I added in "fixed" view support where the view is set to the origin to render the geometry (thus the geometry will always be in the same place) - this is commonly used for HUDs and this is what I needed.  I decided to add in "fixed-position" support as well.  This is exactly like how the background works, but as a foreground.  I figured someone may need this for special application where the user could look around their HUD.

For completness, I added in "fixed" and "normal" view support to background node as well.

If you want to see how it's done, look at the "display" and "setGLViewMatrix" methods of CanvasPeerImpl.

However, I had to make some alterations so that different nodes would be rendered in the correct view (it is possible to have FIXED and FIXED_POSITION foreground geometry).  There were a few different ways of doing this, but to keep the overhead down I decided to simply create a special foreground renderBin just for the FIXED geometry and a second one for the FIXED_POSITION.  This way, the view is set, the atoms are rendered and then the view is returned to normal.  If an application doesn't have any such atoms, then it should be absolutealy no different than before (except for maybe an extra boolean comparison).


Example of a very primitive HUD - just a single textured cube.  As transparency adds some overhead in Xith3d it is probably better not to have one big quad with a transparent window like this.

To use is quite simple:
just call:
1  
Foreground f = new Foreground(quad, View.VIEW_FIXED);


Where "quad" is your BranchGroup geometry and is added to your scene.  Unless you are using transparency, it's probably a good idea to disable the depth buffer so the foreground is always drawn on top.

Support in the LWJGL renderer was also added.

Enjoy,

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #5 - Posted 2004-09-12 06:11:03 »

Quote
Yes, we need a clean and very simple to use HUD system in Xith3d.
The UI one is another topic, like Will said. Way too complex for some simple 2d textures.
However I've no idea which would be the best way to implement.

From a user's point of view, there could be a switch to say "HUD mode on" (in other API's you switch the renderer) and then you directly let plot your textures to screen coordinates.


The re-implementation of Foreground should be able to do exactly that Grin

It's still geometry, so you're not painting directly to the screen, but that geometry (if you use View.VIEW_FIXED) will always be rendered in exactly the same spot (with no jitter).  A bit like making a Billboard that follows the View around - but MUCH more efficient CPU wise (basically two calls to OpenGL to get the VIEW_FIXED affect rather than lots of matrix multiplications to move the Billboard into position and keep it rotated correctly).  I'm not saying Billboards are bad, there are just better ways of doing a HUD.

Basically what you do is create a single Shape3d quad which you position just infront of the origin (e.g. at a depth of -2.5f).  Then plonk your texture on that quad and your done.  When it renders - the camera will briefly move back to the origin to render your HUD (this is where those two OpenGL calls come in) then move back to where it actually is in the scene).

The nice thing about this is you don't have to have a single quad - you can have a 3D animated HUD if you wish.  You can also have a funky radar/map using little quads or tiny models to represent the targets.

Will.

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #6 - Posted 2004-09-12 09:24:43 »

Quote
The XithGui test (what I dubbed "UI package") a.k.a. com.xith3d.userinterface is a great package, don't get me wrong but there are some issues in using it for HUD's.


The UI package single-handedly reduced survivor's frame rate by a large factor. It also randomly chops off the edges of swing components (looks like the clipping is broken non-deterministically).

Kev's the expert on these problems, but I looked through the code and it's so simple it's hard to see how you could describe the UI systme as anything other than "broken for any real usage". It's fine for toy examples - like a single FPS counter - but just can't cut it for even moderatly complex HUD's Sad.

malloc will be first against the wall when the revolution comes...
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #7 - Posted 2004-09-12 13:06:48 »

Ironic that displaying the frame rate reduce it substantially :-/

I think it's a great concept and I was very impressed with the magicosm screen shot of it in use.  I have not used it much myself beyond some testing.

It would be great to have the issues you and Kev found documented (prefrably in IssueZilla) if they arn't already.

Will.

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #8 - Posted 2004-09-12 13:13:58 »

AFAICS, the UI stuff is probably going to be rewritten almost from scratch at some point, seeing as no-one currently understands it, and it appears to have strange bugs.

It should be a very valuable feature, but until it's perfect it's almost useless in practice - I'd rather slave over creating a node-based 3D HUD from scrath that works than quickly whip up a swing GUI that doesn't. I think that in general people prefer to learn a new skill than spend the same amount of time trying to work around someone else's bugs to make the stuff created with their existing skill work the way it should.

So...all power to the 3D HUD! We'd already ended up deciding to go with a 3D HUD of some kind for survivor-2, but this will just make that considerably easier, I think Smiley.

malloc will be first against the wall when the revolution comes...
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #9 - Posted 2004-09-12 14:34:20 »

I've added a simple demo and made a new snapshot.

Run the Xith3DBackgroundGeomTest demo - it now has a Foreground (VIEW_FIXED mode) as well.  Press the 'q' and 'a' buttons to move the view.  It's a very basic demo, but hopefully shows how it works.  The foreground geometry is just a quad - but it can be anything.

Will.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cascade

Junior Member




Java games rock!


« Reply #10 - Posted 2004-09-14 10:15:24 »

Thanks a lot for your effort dennis  Cheesy

perhaps the people in need for a hud can cooperate to get some general basic hud components up and running that can be (perhaps easily) incorporated into games.

components like crosshairs, radar (2d/3d), some simple video screen (like the com window in wing commander), a very simple console for text output, gauges.

It will take me still a couple of months to get to the point where I need a hud but I will be happy to share components.
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #11 - Posted 2004-09-14 23:38:45 »

I have an application that requires switching between multiple Background nodes.  After switching to the 9-13-04 Xith3D build, I am noticing that Background geometries do not seem to disappear when I detach the Background node or call setGeometry with a new geometry.   Any ideas?  Smiley
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #12 - Posted 2004-09-15 13:14:26 »

Quote
I have an application that requires switching between multiple Background nodes.  After switching to the 9-13-04 Xith3D build, I am noticing that Background geometries do not seem to disappear when I detach the Background node or call setGeometry with a new geometry.   Any ideas?  Smiley


That was a bug - I noticed it too.

Try the latest CVS, I have fixed this problem.  Else, I can release a new community snapshot for you in 12 hours.

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #13 - Posted 2004-09-15 13:20:26 »

Quote
Thanks a lot for your effort dennis  Cheesy

perhaps the people in need for a hud can cooperate to get some general basic hud components up and running that can be (perhaps easily) incorporated into games.

components like crosshairs, radar (2d/3d), some simple video screen (like the com window in wing commander), a very simple console for text output, gauges.

It will take me still a couple of months to get to the point where I need a hud but I will be happy to share components.


Thank you, I appreciate the comments Smiley  It's nice to hear that my efforts are helping other people.

I agree a library of HUD components would be great.  Alas, I don't have a full time artist for my game, so I probably won't contribute my HUD scribbles Wink

One important note:  The foreground node does not sort transparent nodes currently (unlike with "standard" transparent nodes that Xith sorts before rendering).  This means you must add them to the BranchGroup in the order you would like them rendered (an undocumented feature of BranchGroup, it will draw them in the order added - perhaps it is better to use an OrderedGroup so it's guaranteed??).  An easy bug to work around, I just thought I would mention it.

Will.

Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #14 - Posted 2004-09-15 20:12:38 »

Background switching seems to be working now.  Thanks!
Offline hawkwind

Junior Member




Java games rock!


« Reply #15 - Posted 2004-09-16 00:20:10 »

Ok first is the performance penalty real or speculation??  I see from previous posts that it has affected people...but by how much 10% or 8 frames/sec? Is it the actual UI or calculating/writing the data in an FPS window.  Does anyone have a feel for  this, is it something like??

    No UI at all          = 50 fps
    UI no data           = 40 FPS
    UI with FPS calcs = 10 FPS

I ask because in my case at least one culprit was displaying the # triangle displayed.  The call to determine this seemed to account for most of the time penalties.

What would you suggest for a dialog component for example.  Currently I am writing text as my game progresses to a dialog based on the xith UI stuff. Is there a better way using a foreground node??
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #16 - Posted 2004-09-16 00:27:43 »

That data is made up right?  Just so nobody confuses it with a real benchmark, could you make that more clear?

I'm going to look into Text2D soon.  Someone contributed some code a while back, I am going to see how that works with a foreground node.

Personally I am going to avoid UI for the realtime stuff.  Also because I want my game to work with Xith3D/LWJGL and the UI stuff uses Swing.

I have added several alpha-transparency foreground nodes to my game for the HUD and the performance loss is negligable (just an observation, no real benchmarks - they will come).  Foreground stuff is generally 3D and can be done on the grpahics card.  The UI stuff involves 2D drawing which uses the CPU, and then has to be drawn by the graphics card as well.

Will.

Offline hawkwind

Junior Member




Java games rock!


« Reply #17 - Posted 2004-09-16 02:15:08 »

the data is not real.  I was trying to identify how much of a penalty I would pay using the UI.

I assume what you are doing will have some textual display...how will you implement this??  Grabbing the image out of a texture and writing to it is not particulary efficient either...I guess that is essentially what updates to a Text2D would be.
Offline SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Reply #18 - Posted 2004-09-16 05:44:57 »

I am watching this thread and anticipating some good examples of this new setup! Thanks for doing this! I've been waiting for a replacement for the UIWindow method for some time now because of all the bugs with it, and noone understands it to fix it.

This sounds great. I assume we'll be able to use this functionality for buttons and text input and such as well?

Sacramento Volleyball
"Whitty phrase goes here."
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #19 - Posted 2004-09-16 05:53:01 »

Quote
I am watching this thread and anticipating some good examples of this new setup! Thanks for doing this! I've been waiting for a replacement for the UIWindow method for some time now because of all the bugs with it, and noone understands it to fix it.

This sounds great. I assume we'll be able to use this functionality for buttons and text input and such as well?


Potentially.  Personally I have not decided on how to handle this for my game.  I don't have any buttons in-game, it's just the menus and setup that I am worried about.  Some opengl based widgits would be nice and would work with Foreground.

Will.

Offline SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Reply #20 - Posted 2004-09-16 08:11:58 »

Hrm, I will have to mess around with it, any help would be appreciated Smiley

I've been trying to show off my game for quite some time and I've been waiting since early in this year for fixes to the UIWindow system.

I was going to release my game for feedback, but I had some friends test it on macos and linux and the UIWindow stuff seems completely messed up.

I hope I can pull something off with what you have done here...

Sacramento Volleyball
"Whitty phrase goes here."
Offline aNt

Senior Member




AFK


« Reply #21 - Posted 2004-09-21 16:30:52 »

yer it still seems a mess Sad
Offline SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Reply #22 - Posted 2004-09-21 18:29:06 »

Yeah Smiley I just want to get rid of the Swing from UIWindow, etc so I can have cross platform support. The current UIWindow implementation I have works pretty well on Windows with some modifications, but fails to display properly on MacOS and Linux.

Sacramento Volleyball
"Whitty phrase goes here."
Offline aNt

Senior Member




AFK


« Reply #23 - Posted 2004-09-22 19:07:55 »

something that working cross the puters would be sweet Smiley
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #24 - Posted 2004-11-06 16:04:43 »

Hi,

Guys, seems that we have regression bug in Parallel Projection - try Xith3DProjectionPolicyTest (hit Space to change to Parallel projection) and you'll see the rotating cube disappears.

I will try to figure out the reason and fix it.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #25 - Posted 2004-11-06 16:18:44 »

OK, fixed now.

The reason was no default value for screenScale, so if app does not set it explicitly, View sets ortho projection with width/height of zero, which is wrong of course.

Default value changed to 1f.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline cascade

Junior Member




Java games rock!


« Reply #26 - Posted 2005-01-27 07:13:21 »

Hi,

I am just trying to implement a hud using the foreground node. This works fine. The only problem I have now is that if I want to zoom using view.setFieldOfView the elements in the foreground get zoomed too which is not desired.

Any ideas on how to address this problem ? Different way of zooming or perhaps just some magic parameter to make the forground nodes static ?

One remark: in some occasions it will perhaps be usefull to have hud elements affected by the fieldOfView: for example a "lock on" bounding box for some visible object on screen (like in air/space combat sims)


Thanks,
Ca$
Offline Amos Wenger

Senior Member




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


« Reply #27 - Posted 2005-01-27 08:05:59 »

I would be pleased to help the community creating new widgets.
I would just look at the source-code of this part of Xith before.

"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 SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Reply #28 - Posted 2005-01-27 17:04:09 »

If someone could make a UI structure and not dissapear, I think the entire Xith community would thank you, at least!

Sacramento Volleyball
"Whitty phrase goes here."
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #29 - Posted 2005-01-27 21:43:28 »

second!
Pages: [1] 2
  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 (54 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (211 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!