Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (555)
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 on top of Canvas3D  (Read 2125 times)
0 Members and 1 Guest are viewing this topic.
Offline under_R_run

Innocent Bystander





« Posted 2005-06-06 11:16:23 »

Hi,

I'm trying to create a Heads up display for a game on top of the Canvas3D. What I have done so far is create a class that extends Canvas3D and overrides the postRender() method. In postRender() I grab the Graphics object usng this.getGraphics() and draw on it, but it flickers. I think that is because it draws it on the current screen, then it swaps the buffer and calls paint over the HUD.  Is there a way in postRender() to grab the buffer and draw to it?  What I can do is override paint() and have it draw to an offescreen buffer, draw to the buffer then paint it on, but then it becomes over-buffered. IS there an easier way?
Offline kevglass

JGO Kernel


Medals: 159
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2005-06-06 13:26:24 »

This thread might help:

http://192.18.37.44/forums/index.php?topic=7320.0

Kev

Offline Jeff

JGO Coder




Got any cats?


« Reply #2 - Posted 2005-06-10 05:33:52 »

Every really sucessful try at this i knwo of uses textured ploygons in the 3D space aligned parallel to the screen.

I believe the Magicosmn guys made a libnrary they wrote to make thsi easier generally available.,  Its something you might look into.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #3 - Posted 2005-06-10 12:52:36 »

We tried that free early xith/magicosm GUI stuff, but as soon as the GUI reached a reasonable size, performance broke down. Those days we managed to create a radar screen 64x64 in size. 65x65 (which in fact is the same as 128x128) already cut performance significantly...

j3d.org has something similar IIRC.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Breakfast

Senior Member




for great justice!


« Reply #4 - Posted 2005-06-10 14:09:55 »

The only problem I've had with this approach is that things getting close to the camera can collide with the UI panes. I've not really investigated this in depth yet, though- does anyone have a good workaround for it?

Herkules- did you try splitting up your panes into several different small squares rather than using a single big one?
Offline Jeff

JGO Coder




Got any cats?


« Reply #5 - Posted 2005-06-12 08:18:49 »

On the collision, what if yo uset your near clkip plane to the same depth as your HUD?


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline kevglass

JGO Kernel


Medals: 159
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #6 - Posted 2005-06-12 08:25:27 »

Endolf's newdawn HUD stuff attempts to do the breaking down of the surfaces for you I believe. It also uses some forumla provided by StarFire Research to calculate where the HUD plane should exist to prevent the collision issue (at least as far as I recall).

http://www.newdawnsoftware.com/resources/earlyaccess.html

Kev

Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #7 - Posted 2005-06-16 07:07:14 »

Herkules- did you try splitting up your panes into several different small squares rather than using a single big one?

The xith lib did that. Nevertheless ... as soon as it grew bigger than 64x64, there was a performance breakdown.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline mokopa

Senior Newbie





« Reply #8 - Posted 2005-07-12 06:52:58 »

I have had much success with the extension of Canvas3D, overriding postRender(). I have also solved the flickering issue:

class DrawOnCanvas3D extends Canvas3D
{
    private GraphicsContext3D gc3d;
    private J3DGraphics2D j3dg2d;
    private int width = 512, height = width;
    private BufferedImage bufim;
    private Graphics2D g2d;

    public DrawOnCanvas3D(GraphicsConfiguration gc)
    {
        super(gc);
        bufim = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
        g2d = bufim.createGraphics();
        j3dg2d = this.getGraphics2D();
        gc3d = this.getGraphicsContext3D();
    }

    public void postRender()
    {

        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
        g2d.setColor(Color.BLACK);
        g2d.fillRect(0,0,width,height);
        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
        g2d.setColor(Color.WHITE);

  /*---->
  g2d.drawingStuffHappensHere(...)
  <----*/

        j3dg2d.drawAndFlushImage(bufim, 0, 0, this);
    }
}
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.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (38 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (24 views)
2014-08-16 06:20:21

Tekkerue (34 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (48 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!