Jump to content
  • Advertisement
Sign in to follow this  
mtfr

[java] 2D drawing with Java3D

This topic is 4394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. Is there any possibility to use 2D drawing (text and primitives like line, rectangle) in a Java3D window? Just like the HUD in games. But without using bitmaps in the 3D space oriented towards the user...

Share this post


Link to post
Share on other sites
Advertisement
Indeed there is. What you have to do is create a class that extends Canvas3D and use that instead of the default Canvas3D class. Once you have done that you can override various methods, with the one you want in this case being postRender(). This gets called every frame after everything else in the scene has been rendered.

For example:

      public MyCanvas3D(GraphicsConfiguration gcfg) {
super(gcfg,false);
}

public void postRender() {

if (g2 == null) {
g2 = this.getGraphics2D();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
drawStuff(g2);
g2.flush(true);
}

Share this post


Link to post
Share on other sites
Thanks for the answer. I didn't get to try it yet but I'll post again when I do, about the outcome.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!