Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (494)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  2D vector graphics style  (Read 6555 times)
0 Members and 1 Guest are viewing this topic.
Online CommanderKeith
« Posted 2008-09-23 14:54:41 »

Hi,

I'm trying to make an RPG, and since I'm not good at 3D graphics and there's not much nice-looking 2D image/sprite resources around, I started trying out a simple 2D vector graphics style from a top-down perspective.

It just uses ellipses, polygons and some radial gradient fills. Here are some prototypes that I made using the vector graphics program Inkscape (www.inkscape.org):





Here's the inkscape svg file where the above screnshots come from:
http://www.fileden.com/files/2008/9/22/2110084/playerAndTrees.svg

After prototyping it in Inkscape, I then re-make the graphic in java 2D code using Ellipse2D's etc in the java.awt.geom package. I've re-created the first graphic in my RPG game, and also animated it so that the tree's leaves blow around, moving according to a sine wave. The man also swaggers (rotates back and forth) as he walks according to a sine wave, where the y-axis of the wave is his rotation angle and the x-axis is time.

I'm getting ok-ish performance, averaging nearly 60FPS on a 750x750 pixel window, but ranging from 25 - 130FPS. I'm using the pre-release Java 6 update 10 (or update N). Thankfully java 6 update 10's D3D pipeline does a good job accelerating everything. Still, when I profile the game, most time is spent rendering (using -Xprof, 40% time is spent in the method sun.dc.pr.PathFiller.writeAlpha8 and 20% in sun.java2d.d3d.D3DRenderQueue.flushBuffer alone).

I wanted to put this up to see what you thought and to get ideas. I also wanted to see if anyone was interested in using such an art style in their own game - it would be great to share ideas for graphics. I can post up a webstart and source if anyone is interested.

Thanks!
Keith

Offline kevglass

JGO Kernel


Medals: 163
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2008-09-23 15:24:14 »

It's a really nice style - I've always liked the idea but never managed to pull it off. There was a useful tool posted here a while ago:

http://code.google.com/p/polyanim/

That might help with this sort of thing.

Kev

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #2 - Posted 2008-09-23 15:54:27 »

The vector-y style is definitely in right now, and as you've found it can be quite easy (or rather, easier) to make something that looks good.

However I don't think java2d is the right tool to be using here. It's not particularly hot with vector shapes, and I suspect you'd get much better results by converting the inkscape files into triangles and drawing them via LWJGL.

Personally I use Flash and <a href="http://www.ambientdesign.com/">ArtRage</a> for my graphics, but export the flash drawings to regular sprite images to use in game. I find that works well because I like to mix vector art with pixel art, and I don't really need to scale things (which is where a pure vector approach would really shine).

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ShannonSmith
« Reply #3 - Posted 2008-09-23 17:28:09 »

I think using SVG based graphics can look very nice and has many advantages, especially if you are programmer and doing your own artwork. However using Java2D to render it is going to have substantial performance problems. What you want to do is pre-render on load, or deploy pre-rendered files. Figuring out which pixels need to be filled with which colour for a transformed anti-aliased radial gradient ellipse is not trivial and using them for leaves on trees is going to kill performance.

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #4 - Posted 2008-09-24 01:50:41 »

Definitely don't use Java2D for this. It's incredibly pathetic at rendering when compared to the other options. If you're making a simple puzzle game or something, it doesn't matter, but otherwise Java2D is going to be your bottleneck.

See my work:
OTC Software
Online CommanderKeith
« Reply #5 - Posted 2008-09-24 02:58:37 »

Thanks everyone for the advice and links. It's really great how all of you have lent your help.  Cool

About Java2D, it's meant to be as fast as JOGL/LWJGL when these two are in immediate mode. I read in this thread (http://www.java-gaming.org/topics/opengl-2d-performance/19203/view.html) that immediate mode is slow, and that VBO's are the way to go. I know very little about how to use them unfortunately. I'm thinking of studying up on it. How much do you think the performance gain will be? In your experience, how much is gained when going from immediate mode to VBO's? Because if i move to JOGL or LWJGL I'm sacrificing the trouble-free nature of Java2D, which always works, always runs on any computer, and can easily be made into an applet.

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2008-09-24 05:51:45 »

LWJGL is pretty trouble free once you get the hang of it. I can send you over some drawing functions I made to emulate the built-in stuff for Java2D, if you want (glFillRect, glDrawRect, glDrawOval, etc.). Also, in literally every game I've ever switched over to LWJGL (I believe that amounts to 4, off the top of my head), I have seen a speed increase of, at the minimum, 600%. Sometimes the increase goes as high as 2000%, depending upon what and how much is being drawn. I'm referring to frame rate and time between loop updates, by the way. i.e. I've seen a frame rate of 10 go up to 200. Java2D seems to do okay in some situations, but literally any game I've made that is relatively complicated has needed to make the leap to LWJGL.

So I can give you some code to make the conversion painless, if you'd like, and there are also plenty of tutorials around you can check out.

See my work:
OTC Software
Offline kevglass

JGO Kernel


Medals: 163
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #7 - Posted 2008-09-24 06:23:36 »

The new Java 2D pipeline does optimize stuff past the level of OpenGL immediate mode, performance can be perfectly good enough for action games. However, Java 2D provides a lot of extra functionality above and beyond what games normally need - this is generally where their bottlenecks hit (example: arbitary gradient fills).

I'm pretty sure CK has tried the other options and it's absolutely true that using pure Java 2D gives you way better compatibility.

Like OpenGL you need to know how to use the tools to get best performance. Java 2D written carefully can run really well. Obviously this can be a bit time consuming but then thats the price of the extra compatibility.

Kev

PS. If you do end up wanting to go OpenGL, someone wrote a more complete SVG renderer for Slick (http://slick.javaunlimited.net/viewtopic.php?t=1268).


Online CommanderKeith
« Reply #8 - Posted 2008-09-24 07:36:41 »


LWJGL is pretty trouble free once you get the hang of it. I can send you over some drawing functions I made to emulate the built-in stuff for Java2D, if you want (glFillRect, glDrawRect, glDrawOval, etc.).

That would be great Demonpants, thanks a lot. I would love to see how you do all of that kind of think in openGL, and such a speed boost would be spectacular. My email 's keithphw at hotmail.com. I use swing menus so if I end up using ogl it'll be JOGL rather than LWJGL, but I hear that it's a piece of cake to to convert between the two.

I'm pretty sure CK has tried the other options and it's absolutely true that using pure Java 2D gives you way better compatibility.

It's a bit embarrasing but I've never made anything with openGL. I only tried it out properly 2 weeks ago. I tested JOGL to see how quickly it could paint a plain colour on the window. Turned out it was the same as Java2D - 300 FPS. Maybe I was doing something wrong since this was on a computer with an nVidia GS 8400M video card. Windows vista and dual core.

PS. If you do end up wanting to go OpenGL, someone wrote a more complete SVG renderer for Slick (http://slick.javaunlimited.net/viewtopic.php?t=1268).

I checked the link, thanks Kev. It looks very handy. The link to the poster's source is broken though, I'll register in the forum and let him know.

Thanks for all the help  Cool


Offline thijs

Junior Member




Lava games rock!


« Reply #9 - Posted 2008-09-24 07:44:06 »

My rant on Java2D:
I think its a bit bloathed and it frustrates me that the pipeline has the tendancy to change quite often, making good practices not as good as they were before (I've seen quite some questions about sudden changes in performance after a new JRE release). Also you have no way of hooking into / overriding the way it works under the hood. For example I recall Java2D doing some strange things while rendering shapes (not primitives) on opengl/directx... using rasterized spans or something instead of triangulizing the shape, which sounds far less efficient.

On the other hand you're sure your game will run everywhere; It offers a D3D an OGL and a software backend. Bruno and I have been working on a small 2d library (2dzzd) which also features an opengl and software rendering backend (for both vector and bitmap graphics), which will be more game oriented. Hope to post a demo next month or so...

<a href="http://www.dzzd.net">3DzzD!</a>
<a href="http://www.arcazoid.com">Arcazoid!</a>
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #10 - Posted 2008-09-24 09:01:28 »

I use swing menus so if I end up using ogl it'll be JOGL rather than LWJGL, but I hear that it's a piece of cake to to convert between the two.

LWJGL has an AwtCanvas which you can use to embed a LWJGL display inside an AWT or Swing gui. I'd go with that as it tends to be more reliable than Jogl.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Online CommanderKeith
« Reply #11 - Posted 2008-09-24 14:02:50 »

LWJGL has an AwtCanvas which you can use to embed a LWJGL display inside an AWT or Swing gui. I'd go with that as it tends to be more reliable than Jogl.

Thanks for the tip. I'm also using AWT's MouseEvent and KeyEvents for input. If LWJGL supports them as well then that'll be the way to go.

My rant on Java2D:
I think its a bit bloathed and it frustrates me that the pipeline has the tendancy to change quite often, making good practices not as good as they were before

Agreed, like BufferedImages used to be accelerated as good as VolatileImages but now not so. Also now it seems that BufferStrategy is better than VolatileImage because you can't page-flip a VolatileImage.

Bruno and I have been working on a small 2d library (2dzzd) which also features an opengl and software rendering backend (for both vector and bitmap graphics), which will be more game oriented. Hope to post a demo next month or so...

Sounds interesting. Have you thought about how GUI's will be done in this? Will it integrate with Swing or do you just have to build your own components, buttons,etc?

 Cool

Offline princec

JGO Kernel


Medals: 378
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #12 - Posted 2008-09-24 14:11:45 »

No need to use AWTGLCanvas any more - you can just call Display.setParent(someComponent) to make any AWT component GL capable!

Cas Smiley

Offline thijs

Junior Member




Lava games rock!


« Reply #13 - Posted 2008-09-24 21:36:44 »

Sounds interesting. Have you thought about how GUI's will be done in this? Will it integrate with Swing or do you just have to build your own components, buttons,etc?

My thoughts about Swing are basically the same as on Java2D: bloathed Wink (for gamedevelopment that is)
I have written a very small GUI around 2dzzd, which offers the most basic building blocks like components and containers which you can extend to make your own gui controls. It also contains some premade components like labels, textfields, buttons and dialogs. Logic for handling the events from these components must be provided by a callback interface.

<a href="http://www.dzzd.net">3DzzD!</a>
<a href="http://www.arcazoid.com">Arcazoid!</a>
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.

Dwinin (19 views)
2014-09-12 09:08:26

Norakomi (54 views)
2014-09-10 13:57:51

TehJavaDev (63 views)
2014-09-10 06:39:09

Tekkerue (31 views)
2014-09-09 02:24:56

mitcheeb (53 views)
2014-09-08 06:06:29

BurntPizza (37 views)
2014-09-07 01:13:42

Longarmx (23 views)
2014-09-07 01:12:14

Longarmx (27 views)
2014-09-07 01:11:22

Longarmx (26 views)
2014-09-07 01:10:19

mitcheeb (34 views)
2014-09-04 23:08:59
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!