Jump to content
Spriter Forums

Recommended Posts

Posted

Hi :)

I have been horribly ignoring Spriter since the kickstarter finished so i decided to change that and start on a java implementation this weekend, progress so far can be found below.

https://github.com/Discobeard/spriter

Its obviously rather rough at the moment but i am planning on putting some serious effort in the coming weeks.

The example project i have there is for the lwjgl with Slick2D Texture, but i have been trying to code quite generically it so it can be used in various frameworks with little effort.

Implementation is quite basic at the moment

Spriter spriter = new Spriter(path_to_SCML_folder,drawer,fileloader);
spriter.playAnimation(animation number);

spriter.draw(x coord,y coord);//will draw the current state of the animation using your custom drawer

Would love to get some help, moral support, ideas or comments on how to move forward.

EDIT:

Trixtor is going to take of the main work now, as i am just to lazy at the moment to keep things going at a decent speed. His fork can be found below.

https://github.com/Trixt0r/spriter

Posted

Still very early but should but good enough to draw a simple(no bones) animation out.

Not sure how easy it would be to port at the moment as i haven't thought the whole thing through yet, going to try and get a few test projects for different frameworks together once Ive got the bones working(hopefully in the next few days).

Posted

- adding in slick test project with ImageLoader and ImageDrawer which seems to be rendering the test monster animation fine.

- Did quite a large refactor a few days back after realizing i had completely misunderstood the mainline.

- Bone support is going rather slowly unfortunately.

Posted

Another check in.

-Bones, Alpha and Scaling now supported.

-refactoring around the drawers and loaders.

Next

-refactor around the bone code(rather ugly a the moment)

-add some extra functionality including pausing the animation and lining animations up

-try and get a test project up and running for libGDX.

Posted

Nice work Discobeard!

A nice feature would be to rotate and scale bones while running the animation.

I think it should not be that hard. It is just an extra angle and scale for a bone.

Maybe you could specify in the interface whether the children of the bone inherit only the animation

specific rotation and scale or also the new one.

Two other cool features would be:

Set the bone and object data by interpolating between two or more animations with different weights.

This could be tricky for interpolating between animations with different lengths.

The second one: Create a new animation between two.

So you just take the last keyframe of the first animation and the first keyframe of the second one and save them in the new animation.

Edit: Never mind.

Edit2: The bone animation is quite buggy.

Keep up the good work!

Posted

Hey Discobear!

I have figured out some bugs in the SpriterAnimation class.

So first of all: the interpolation for angles is not the same as for positions, since angles have values between 0 and 359 (or 0 and 2*pi, whatever).

I fixed it with two helper methods:

private float calculateAngleInterpolation(float a, float b, float timeA, float timeB, long currentTime) {
return a + (angleDifference(b, a) * ((currentTime - timeA) / (timeB - timeA)));
}
private float angleDifference(float a, float b){
return ((((a - b) % 360) + 540) % 360) - 180;
}

Of course you have to refactor the rotation-values in createDrawInstructions.

Furthermore I found this:

scale_y = scale_x * tempBones[obj1.getParent()].getScaleY();
//which has to be:
scale_y = scale_y * tempBones[obj1.getParent()].getScaleY();

Then the next bug is, that the drawing order is not in the order of the z_index.

But I think this is a library specific issue. In libGDX you could just fix that with using scene2d actors and assign the z_index value.

Another thing which is not that nice, is that your plugin creates at runtime new DrawInstruction arrays.

I bet this will cause lags, especially if you run that stuff on android, because garbage collection is not that fast on current devices.

A collection of draw instructions would be an easy solution.

See ya!

Posted

Sounds great!

I fixed many things in your implementation. Furthermore I added following features:

- Rotate an animation

- Scale an animation

- Flip an animation

I tested everything with LibGDX and it runs quite well on the Desktop. I have to fix some things for the android execution.

I'm working now on an user frienldy interface. Maybe I could push my stuff on a new branch, if you add me as a collaborator.

Btw: My name is also Trixt0r at github.

See ya!

Posted

Thanks!

I pushed my new stuff on the integration branch. You can check it out now.

I added a new libGDX project with a little bit more animated monster.

You can walk with the arrow keys and jump with 'A'.

Furthermore you can rotate the skeleton by dragging the mouse around the screen. Scaling is also possible.

Just have a look at SpriterPlayer.java.

I bet there can be made some more fixes, cause I didn't test everything out yet.

See ya!

Posted

Hey Trixtor that's awesome! I was actually looking at adding exactly those two pieces of functionality!

I don't suppose you've modified the libgdx loader to be able to pull resources from a textureAtlas instead of from separate files?

If not I'll try and see if I can mangle my way through it.

Posted

Hey Darkkheim!

Yes it would be cool if you could create an asset loader for LibGDX, because now you can not run all the stuff on android.

Maybe Discobeard could add you as a collaborator, too, so that you can push the loader on github.

I added some new features:

- You can now manipulate bones at runtime, means you can rotate and scale them. I would also add this feature for objects, but since objects can not be named in Spriter, this feature makes not much sense. But this could be a feature for the future ;) .

- You can have smooth transitions between two animations. This feature works right now, but there are still some bugs, which I could not figure out yet.

See ya!

Posted

Hey Trixt0r,

Did you mean to commit your fatman SCML file and the references to it's animations to the desktop test?

(in fact the test only works if you change the scml file loaded from data/monster/ to data/fatman/fatman.scml

:-/

Other than that it seems to work pretty swell :) I did have parts of the character just vanish after a while until there's only a floating head mucking about :lol:

Posted

I hope, I fixed now the vanish bug.

No, I mean you could commit your loader to the libGDX Spriter folder if Discobeard has added you as a collaborator.

Please keep testing the SpriterPlayer class. My implementation is still buggy.

Posted

Sorry some real life stuff and all those cheap games on steam last week have made me lazy im going to force myself to get a bit more productive.

I did have a quick attempt at merging in your changes to the master branch last night but my amature git skills failed me, ill try again tonight with hopefully better results.

I might have a look at the textureAtlas stuff myself as well to get me back in the code.

  • 1 month later...
Posted

Good news dudes!

The generic spriter plugin for java has evolved. I added the following features:

* Play animations in forward and backward ("wow" =D).

* Animations are running now on android with libgdx (have a look at GdxSpriter.java, basically you have to use GdxSpriter.getSpriter instead of Spriter.getSpriter).

* You can change the interpolation techniques between two keyframes by inheriting from SpriterPlayer (have a look at the protected methods interpolate and interpolateAngle).

The next things which I want to add are:

* sprite hotswapping.

* quadratic, cubic, etc. interpolation.

See ya!

Posted

Hi Trixt0r,

thx allot for your effort! The desktop version is running like a charm now. But the android version was throwing the ArrayIndexOutOfBoundsException again. Looks like the SCML in the android assets is still the old, broken one in the repository. After copying the newer one from the desktop version, I got the android version running too.

Would be nice, if you could clean up the whole asset thing in general: Its quite confusing, I found the monster asset in 10 different places..

Damn, my notebook is so slow, I only got 5 or 6 fps -_- in the emulator. Can't wait to get back to my heavy machine back home..

And maybe you could make the switching between Spriter.getSpriter() and GdxSpriter.getSpriter() somehow automatic, I found this in the GDX wiki which should work for that:

switch(Gdx.app.getApplicationType()) {
case ApplicationType.Android:
// android specific code
case ApplicationType.Desktop:
// desktop specific code
case ApplicationType.WebGl:
/// HTML5 specific code
}

(It didn't work on my first try, but I don't have the time to get deeper into right now. Hope you be more successful..)

Hope you don't feel like I am complaining, I just try to give some input to make things better. ;)

Thx allot again, hope to see more of that great coding soon..

Posted

Hi grofie,

thanks for the reply. I cleaned up the repo (I think...).

If you use LibGDX you won't need to distinguish which Spriter class you have to use, just use GdxSpriter.java.

GdxSpriter is always using the internal file system. If you don't like it, you can change getSpriter and pass a FileHandle object, which points to the scml file, instead of the file path.

If you are not using LibGDX you can use the Spriter class. But beware! JAXB does run on a desktop system fine, but it may be that it is not supported on an other system like on Android. That's why I had to re-implement the SCML parser for LibGDX. So if you run into parsing problems, you will have to implement your own parser for the specific platform (it's quite easy, you can have a look into the private methods in GdxSpriter.java).

You mentioned the whole animation stuff runs on android emulator very slow, but it runs also on a normal cell phone slow (I tested the monster animation on my Sony Xperia Sola, 1GHz dual core).

Well, if I run just one SpriterPlayer instance, I get 62 fps, that's good. But if you have about 10 players at runtime, the fps drops down to 30-35. So beware, if you want to run this on slow devices, my friends. You have either to reduce the number of objects and bones for an animation or run your game on 30 fps. Maybe I can figure out some performance issues.

On my desktop computer the situation is much better. I get 60 fps while running 217 instances of SpriterPlayer at a 3GHz core. On a 2GHz core the whole thing runs at 60 fps while running about 100 SpriterPlayer instances. I think that is ok, if you don't plan to create games á la Little Fighter 2 with massive gang fights :D. Otherwise your games have to support mutlithreading.

Trixt0r out!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...