Jump to content
Spriter Forums

Recommended Posts

Posted

Hi guys,

I'm very interested in testing out your project, but implementing it doesn't seem to be very straightforward. Took a little bit of searching, but am I correct in discovering that the source code for the actual importer is within the Spriter folder and every other folder there just contains set ups that are used to test the importer? I went with that assumption and attempted to get a test of this working, but I cannot manage to find the Sprite and Spritebatch classes or even the com.badlogic.gdx package itself. It seems that I am not quite knowledgeable enough to get this working on my own, but here's to hoping someone will be able to help me out as well as anyone else that comes across this and is having trouble.

Good job though guys, it looks to have a lot of functionality as well as flexibility! Glad to hear the Android version is getting along as well! :)

Posted

Hey guys,

sorry for the double post. I worked again a little bit on the spriter plugin and fixed the some transition issues between two animations, and modified the SpriterDrawer class.

Now it is possible to change the sprites for a whole entity. Basically you have to add an extra loader and let the Spriter class load the extra textures and store them in the new loader:

loader = new SpriterLoader();
loader2 = new SpriterLoader();
drawer = new SpriterDrawer(loader,spriteBatch);
Spriter spriter = FatSpriter.getSpriter("data/monster/basic.scml", loader);
Spriter.getSpriter("data/monster_mod/basic.scml", loader2);

And if you want to change the skin, you just have to assign the other loader to your drawer:

drawer.loader = loader2;

This is just a temporary solution. I have to work a little on the structure, so that you have the ability to change just bodyparts and not the whole body.

I hope I can finish this soon.

If you have wishes for other features, let me know, I will try to implement them.

See ya!

  • 2 weeks later...
Posted

T T T Tripple post!!!!!

Hey guys!

I almost finished with the plugin (well from my point of view ^^) and added some new cool features.

I created a wiki, which explains you, how to use the plugin: Wiki.

What's left: Support for inverse kinematics. I will try to implement the CCD algorithm and let users the ability to change the algorithms via an interface or an abstract class.

For performance: I noticed that using an atlas can give you a quite big performance boost (especially in LibGDX). Running animations without drawing textures runs quite well. On my machine I get 60 fps with about 400 to 500 instances of a SpriterPlayer (with 15 bones and 14 objects). So if you run into some performance issues, try to pack the loaded textures into an atlas, because I can not do it for every framework.

See ya!

Edit: Inverse kinematics is supported now. I implemented an ISpriterIKResolver interface, which can be used to implement other algorithms. A SpriterPlayerIK uses this interface, so if you want IK in your game, use this player. I already implemented the CCD algorithm.

Posted

And the 4th post :mrgreen:

Hi guys,

I managed to increase the speed for LibGDX. I modified the SpriterLoader class such that the loader saves the sprites into an atlas. This makes a very big boost. Here is a screenshot:

benchmarkh.png

ImageShack.us

Should be 60 fps at around 930 instances. Without using an atlas, I just get 217 @60fps. I think this is a very big boost. And the core which was executing the application was not on full utilization. So the speed depends on the current graphics card. Anyone who is using LibGDX can get the class here:

/**************************************************************************
* Copyright 2013 by Trixt0r
* (https://github.com/Trixt0r, Heinrich Reich, e-mail: trixter16@web.de)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

package com.spritertest;

import java.util.Set;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Disposable;
import com.brashmonkey.spriter.file.FileLoader;
import com.brashmonkey.spriter.file.Reference;

public class SpriterLoader extends FileLoader implements Disposable{

private PixmapPacker packer;
private boolean pack;

public SpriterLoader(boolean pack){
this.pack = pack;
}

@Override
public void load(Reference ref, String path) {
if(packer == null && this.pack) packer = new PixmapPacker(512, 256, Pixmap.Format.RGBA8888, 2, true);
Pixmap pix = new Pixmap(Gdx.files.internal(path));
if(packer != null) packer.pack(ref.fileName, pix);

files.put(ref, this.createSprite(new Texture(pix)));

pix.dispose();
}

private Sprite createSprite(Texture texture){
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
TextureRegion region = new TextureRegion(texture,0,0,texture.getWidth(),texture.getHeight());
Sprite sprite = new Sprite(region);
sprite.setSize(texture.getWidth(), texture.getHeight());
return sprite;
}

public void generatePackedSprites(){
TextureAtlas atlas = this.packer.generateTextureAtlas(TextureFilter.Linear, TextureFilter.Linear, false);
Set keys = this.files.keySet();
this.disposeNonPackedTextures();
for(Reference ref: keys){
TextureRegion texReg = atlas.findRegion(ref.fileName);
Sprite sprite = new Sprite(atlas.findRegion(ref.fileName));
sprite.setSize(texReg.getRegionWidth(), texReg.getRegionHeight());
files.put(ref, sprite);
}
}

private void disposeNonPackedTextures(){
Set keys = this.files.keySet();
for(Reference ref: keys)
files.get(ref).getTexture().dispose();
}

@Override
public void dispose() {
if(this.pack && this.packer != null) this.packer.dispose();
else this.disposeNonPackedTextures();
}

}

It would be really nice, if Spriter would calculate the maximum size for a texture to save all sprites per file. Then we would need just one page (texture) for all parts.

See ya.

  • 2 weeks later...
Posted

The package is not missing. You have to import the dom project with a maven plugin which fits to your environment. If you are using eclipse, there should be no problem to install the maven plugin via the eclipse market place.

-Trixt0r

Posted

What? How exactly do I do that? How much easier would it have been if the package was included with the other files??? This is beyond ridiculous...

NEVERMIND! I figured out how to do this frickin crap.

FOR ALL THOSE WHO FOUND THIS SITE AND NEED A SOLUTION TO THE SAME D*MN PROBLEM:

Here's the zipped download for the com.discobeard.spriter.dom package: http://uppit.com/k2wky6wh2el3/com.zip

Now here's how to do it from Eclipse, using that Maven bullsh*t:


  1. [*:3me73k43]Download the zipped file of the all spriter projects here:
https://github.com/Trixt0r/spriter
[*:3me73k43]Unzip it to any location
[*:3me73k43]Run > Run Configurations > Maven Build
[*:3me73k43] Double click on Maven Build to create a new configuration
[*:3me73k43]In Base Directory, select Browse File System
[*:3me73k43]Browse to the *Save location*\spriter-master\spriter-master\spriter-dom
[*:3me73k43]Select it
[*:3me73k43]For "Goals:" in Eclipse, write "install"
[*:3me73k43]Then click "Run"

It did a lot of mumbo jumbo hoopla loopa and all that bullsh*t. It gave me some quackity error b.s., but it had downloaded the frickin' files, so that's all I cared about.

Go to *Save location*\spriter-master\spriter-master\spriter-dom and you'll see a new folder called "target".

Go to *Save location*\spriter-master\spriter-master\spriter-dom\target\generated-sources\jaxb and you have the motherslayin files. THE END!

  • 1 month later...
  • 2 months later...
Posted

Hey guys!

I was working today a little bit on the plugin and cleaned up my git repo. The maven project is now replaced with a clean eclipse project. I also added a new LibGDX example.

For people who don't use eclipse and Java:

Here is a runnable version of the LibGDX example (sorry for the size, but the native files are quite big). You can load new SCML files into the program by pressing CTRL+O (if you don't see any opening dialog, move the window to the left or right, it could be behind the main frame).

The plugin is still a work in progress and I have to work on the tweening since the new Spriter betas brought new features into the scml file.

The main problem right now is that the tweening is not working properly for animations with partially keyframed objects and bones. So if you want to work now with the plugin, make sure, that on every keyframe all objects and bones are keyframed otherwise you will get weired effects.

- Trixt0r

Posted

Thanks! I really like the cleaned up code. For some reason, though, I can not use GdxSpriter to import. I have searched for a long time for an answer and have made sure my code followed the example completely. Here is the error I get:


Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NullPointerException
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: java.lang.NullPointerException
at com.brashmonkey.spriter.objects.SpriterObject.setRef(SpriterObject.java:50)
at com.brashmonkey.spriter.player.SpriterAbstractPlayer.generateData(SpriterAbstractPlayer.java:94)
at com.brashmonkey.spriter.player.SpriterPlayer.(SpriterPlayer.java:81)
at com.brashmonkey.spriter.player.SpriterPlayer.(SpriterPlayer.java:103)
at org.jtechdev.larrythelightbulb.LarryHero.(LarryHero.java:87)
at org.jtechdev.larrythelightbulb.LevelLoader.loadMap(LevelLoader.java:90)
at org.jtechdev.larrythelightbulb.Screens.GameScreen.(GameScreen.java:95)
at org.jtechdev.larrythelightbulb.Screens.SplashScreen.render(SplashScreen.java:59)
at com.badlogic.gdx.Game.render(Game.java:46)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:187)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110)

The Spriter import works just fine. I did find though that if I used the monster scml file, then it would work. Tried saving my project as a new scml file and it still would not work. Do you think this is something wrong with Spriter corrupting the files?

Thank you!

Posted

Hmmm... This error can only occur, if there is no reference created. Did you manipulate the SpriterLoader class or are you using a second thread to load the scml file?

Could you please post the scml file with its textures, so I can have a closer look on this issue?

- Trixt0r

Posted

I have attached a file test and its assets. Also, here is the code I use for importing:


m_spriterLoader = new SpriterLoader(true);
m_spriterDrawer = new SpriterDrawer(m_stage.getSpriteBatch());
m_spriter = GdxSpriter.getSpriter("basic.scml", m_spriterLoader);

m_spriterPlayer = new SpriterPlayer(m_spriter, 0, m_spriterLoader);
m_spriterPlayer.setAnimatioIndex(0, 10, 100);

No, I did not edit the SpriterLoader nor am I using a second thread. I did edit the SpriterDrawer, however, but I was just commenting out a debug draw line that threw an error.

shapeRenderer.polyline(vertices);

Spriter-Error-Example.zip

Posted

Trixtor, thanks for all your work on this importer. I'm trying to use Spriter right now, but I need to be able to use it with a TextureAtlas. From what people have told me, I need to get Spriter to find the files in the TextureAtlas at runtime. Do they mean runtime for my game, or runtime for Spriter so that it grabs a file from the packed texture. Any help with this is much appreciated.

Posted

@JeffreyWalraven: There is no problem with the library. Your example runs fine for me. Your fault is, that you didn't put the folder name of the scml file into the path name:

"Spriter-Error-Example/basic.scml"

and the error occurs because the texture files were not found and thus no references were put into the files map (well this was my fault, because the loader does not throw any exceptions, i'll fix that).

@aspiretocode: They mean the runtime of your specific game. The LibGDX loader class packs already all loaded textures into an atlas (which was made for testing purposes and is not perfect yet), which was quite easy to implement. Have a look at the code, maybe it can help you to make your own backend specific atlas.

Anyway. I ported the LibGDX XmlReader. This means now, that the JAXB parsing stuff is no longer needed and parsing scml files should run anywhere (even if you want to port the library to another language ;P).

For people who did use the GdxSpriter class: Now you should just call

Spriter.getSpriter("scml file path", yourLoader);

to get all spriter data and there should not be any problems on Android, HTML5, iOS or any other crazy operating system.

For people who are working with C# and XNA: I managed to create a library for C#, which allows you to use the Java library with any C# game library. Here is an example for XNA. :D

I am still fixing things in the library. Please post bugs in this thread or create issues on github, which can help me fixing them.

- Trixt0r

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...