2d polygonal animation library / editor: PolyAnim

Greetings, this is my first post here! :slight_smile:

I’m making a 2d vector / polygon animation library (+ an animation editor later) in Java, called PolyAnim. It is intended for game sprites, mainly, but I guess there’s nothing stopping you making “movie” clips with it… :wink: It comes with Java 2D and LWJGL renderers built-in. There’s also several render modifiers that can be used to create some neat effects on the animations, such as HSL transforms.

I’m posting here to see if there’s any interest in this kind of library (it’s not Flash killer by any means, but still… :persecutioncomplex: ), and to ask for comments & suggestions. As PolyAnim is still in rather early stages of development, this is the perfect opportunity to suggest new features, API changes, etc. I’m going to use this in my next game for game sprites, and I hope that Java developers find it useful in their own projects as well, at least when I have the editor done (won’t happen soon, unfortunately).

Actually, the biggest downside at the moment is the lack of the animation editor. I’m developing it using Qt Jambi, but I’ve hit a bad bug that prevents me working further until the next Qt Jambi patch release is out… I managed to hack a tool that allows creating the animations in Inkscape, though.

Here’s a screenshot of the test program, displaying several copies of the very first proper animation created using this thing:

http://polyanim.googlecode.com/svn/trunk/polyanim/images/screenshot.jpg

The biggest dude is the original, scaled 2x. Others are rendered using different modifiers.

If you’re interested in polygon based game sprites, do take a look at the PolyAnim website at http://polyanim.googlecode.com. There are Web Start demos available at http://code.google.com/p/polyanim/wiki/WebStartDemos, please drop me a note if they do not work on your system! They’re my first Web Starts, after all… :slight_smile:

Any kind of feedback is much appreciated! Thank you. 8)

[quote]I’m posting here to see if there’s any interest in this kind of library…
[/quote]
Heh, and I thought that at least a few people would be interested in this kind of stuff here, this forum being meant for Java game development… :persecutioncomplex: Anyway, the lack of interest raises a couple of questions: why it is not interesting enough to warrant a comment? And in turn, how can I make it more interesting? :slight_smile: Perhaps the fact that it’s in fairly early phase of development has to do with this. Is it too early to talk about this? ??? Please, don’t take these questions as bad blood, for I’m truly trying to develop a library that would be useful to Java game developers, myself included. :slight_smile:

What would you like to have in a vector animation library, so that you’d consider using it in your own projects? I’ll present the feature list (+ a road map) for PolyAnim below, is there important stuff missing? What there is not that useful? Please comment, anything helps me to define this project better. :wink:

Animation features:

  • Animations:
    [list][li]Building animations using key frames, polygon groups, polygons and vertices. b[/b]
  • Interpolating smoothly between key frames b[/b]
    [list][li]Polygon groups have flexible transformations: scale, rotate (around pivot point) and offset (= translate) b[/b]
  • Groups are sorted (and thus drawn) by their depth-level b[/b]
  • Group polygons can itself be animated by moving their vertices b[/b]
  • Polygon color interpolation b[/b]
  • Blending settings per polygon: alpha, additive, none
  • Performs transformations on the renderer side (e.g. glRotatef() in OpenGL) but can optionally compute transformation matrices for renderers that don’t have transformations built-in. b[/b][/li]
  • Looping:
    [li]Variable start and end points b[/b]
  • Bidirectional and ping-pong playback b[/b][/li]
  • Anchor point system
    [li]Allows implanting anchor points with specific offset, direction to the animation frames. The anchors will be animated along with the rest.
  • Game code can query for example an anchor in players hand, and render a gun sprite there. [/li]
  • Animation I/O:
    [li]XML read and write b[/b]
  • Custom binary format
  • Experimental (+ unsupported) Inkscape SVG --> PolyAnim XML animation converter b[/b] Tutorial here!
  • Animation collections (store several animations in one file; for example player run, walk and jump animations)
    [/li][/list]
    [/li]
    [/list]

Rendering features:

  • Different renderers:
    [list][li]OpenGL (LWJGL) renderer b[/b] (recommended for games, but doesn’t support concave polygons)
  • Java 2D renderer b[/b] (supports concave polygons)
  • Easy to implement new renderers, as long as drawing polygons is supported by the platform![/li]
  • Render modifiers:
    [li]Can be used to modify the animation rendering. Useful for game sprites!
  • Flip (mirror) vertically and horizontally b[/b]
  • Scale, rotate b[/b]
  • HSL (Hue-Saturation-Lightness) modifier (effects such as desaturation and hue rotation) b[/b]
  • Color modifier: blending to color, additive blending to color, conversion to grey scale b[/b]
  • Alpha modifier: multiply the polygon alpha with a specified alpha factor b[/b]
  • …more? (ideas are welcome!)
    [/li][/list]-

PolyAnim Editor:

  • Allows creation of the animations
  • Uses Qt Jambi
  • Has its own renderer using Qt (supports concave polygons)

(phew, typing the list structure tags took a while! :P)

Items marked with b[/b] are already in the code base. Currently PolyAnim is at (quite arbitary) version 0.6.

Btw, has anyone tried the Web Start demos? I’m interested if they work in Macs, since it’s something I cannot test myself, having only Windows and Linux here.

Is there some sort of bone support (apologies if I missed it in the list above, I did try to check :)).

Can a polygon be replaced with a fixed image which moves with the orientation/translation that poly would do?

Kev

Thanks for your comment, Kevin! And btw, thanks for all your work in Java gaming, Coke And Code, etc. Your tutorials have been helpful for me. :slight_smile:

Nope, and probably not going to happen either, at least not for 1.0. Unless a massive amount of people request it and/or somebody contributes… :wink: While it would make character animation easier, I’m aiming for a more general approach (== means more work for certain cases, such as, character animation… :P).

[quote]Can a polygon be replaced with a fixed image which moves with the orientation/translation that poly would do?
[/quote]
Not directly, but the anchor points would make this quite easy. The idea is that you’d query the anchor orientation from PolyAnim and then render something there (anchors itself are not rendered except in the editor). Having a ImageAnchor built-in might be good, though, thanks for the suggestion. :slight_smile:

It looks pretty cool. I can see it making pretty nice intro for a game. The webstarts work fine on my windows computer

So it uses QT Jambi? I did some quick searching and it says qt jambi doesn’t use java2D, but on your website it says it uses java2d and lwjgl? Can QT Jambi integrate with existing games using java2d or lwjgl?

Nice work :slight_smile:

Thanks. :slight_smile:

A cool thing this could be used for would be in game characters in 2D games being rigged like 3D models - give a feeling of Another world but with real time physics - hence the bone question.

It’s a definitely a cool tool tho, how tricky is it to create a renderer - I’d quite like to render it using Slick (thought the LWJGL renderer would do just fine for that in the short term :)).

Kev

That would be cool, definately. I guess I’ll have to think about bone support at some point, then. :wink: But not quite soon, I’d like to get 1.0 (and the darn editor) out before that, as the bones would require quite a lot of changes… Btw, Another World is an inspiration for me, it’s just the kind of look I’m aiming for. 8)

[quote]It’s a definitely a cool tool tho, how tricky is it to create a renderer - I’d quite like to render it using Slick (thought the LWJGL renderer would do just fine for that in the short term :)).
[/quote]
Not hard at all, assuming Slick can render (convex) polygons. And if it supports transformations (scale, rotation and translation) directly, like OpenGL and Java 2D, all the better. A transformation matrix that has everything in it can be also computed by PolyAnim. Take a look at http://code.google.com/p/polyanim/source/browse/trunk/polyanim/src/nr/co/mhgames/polyanim/renderer/?r=66. Render modifiers are optional if you don’t want to use them, but implementing them shouldn’t be too hard either. :slight_smile:

Today I remaked Kevins avatar for PolyAnim. It’s now included in the Web Start demos, with Kevins permission. (thanks again!) :slight_smile: See it in action!

http://koti.mbnet.fi/lsoft/images/polyanimdude.png

Why that character? Well, I wanted to try making a character animation, but didn’t want to waste time on developing a walk cycle… That one character sprung to my mind, so here we are. 8) I must say, creating this took me lot of time, over 5 hours I think. :stuck_out_tongue: I made a stupid mistake by using the wrong origin in Inkscape, and due to limitations of the converter I couldn’t use rotate/scale on group basis, but only with individual polygons… Had I started it correctly, it would have taken less time, I’m sure. Anyway, I didn’t recreate all the details, nor the outlines, but the end result is still rather cool, in my opinion.

What do you think? :slight_smile:

Looks good! 8)

Thanks! :slight_smile:

I committed PolyAnim v0.65 to SVN. Finally added backwards playing and ping-pong playback support. 8) I’ve updated the demo, as well. Btw, I found out that Web Start doesn’t close the JVM with the application, unless I explicitly call System.exit(). :stuck_out_tongue: Now I’ve added the exit-calls, and the JVM closes properly.

Status update:
While waiting for the next Qt bugfix release, I haven’t been coding PolyAnim, but instead working on the game engine for my next game. But today, I implemented two features which come handy when PolyAnim is used in game context. Lazy updates, which mean that the animations will keep their playing state etc. up to date, but skip interpolating the current key frame (the most costly step). In game, you’d enable lazy updates when an animation instance (say, an enemy sprite) goes out of view / far away from the player, and disable them when the animation comes back to sight. :slight_smile:

To save memory, I added sharedCopy() method that creates a new copy of an Animation, with its own state but sharing the key frames with the original. Key frames take the most of the memory, so it’s useful they can be shared now. For example, if you had several enemies using the same animation, you can share the key frames between all the Animation instances.