Jump to content

Generic Java Importer


Discobeard
 Share

Recommended Posts

There should be no problem with linking the assets folder.

When setting the assets folder as source folder, eclipse will put it into the bin folder during build time, so the assets should be present.

Can you send me your projects (Android and Desktop)? I will test it on my machine.

- Trixt0r

Hi Trixt0r.

Ok here it is https://mega.co.nz/#!3V41RDLZ!hCSGmMDWNeMjjtXguSGN1UPhXR1TYv9YgaEKgGn4Rb8.

Its libGDX gradle project. In core project is your exact libGDX source code from your spriter test project.

When you load project than its show you some error in "Test Spriter-core" so you need to add to "Test Spriter-core" jar file in java build path from the same folder "Test Spriter-core/libs/spriterLoader/spriterLoader.jar" its your SpriterLoader package project.

Really thank you for your help :| .

Link to comment
Share on other sites

I can not test it because MEGA is telling me all the time, that there is a problem with this file.

Please attach a .zip file to your post. This way is much simpler.

Anyway, this line

loader.load(handle.file());

has to be

loader.load("coin");

because the libgdx loader will try to load all assets from the given root folder, i.e. the parent folder of your SCML file.

If you pass a File object as an argument, it will use the parent folder of the given file as root, which does not work on Android, for some strange reason.

You should avoid using File objects, when working with non-desktop platforms. That's the reason why I you can pass a root folder name instead of a File object.

-Trixt0r

Link to comment
Share on other sites

I can not test it because MEGA is telling me all the time, that there is a problem with this file.

Please attach a .zip file to your post. This way is much simpler.

Anyway, this line

loader.load(handle.file());

has to be

loader.load("coin");

because the libgdx loader will try to load all assets from the given root folder, i.e. the parent folder of your SCML file.

If you pass a File object as an argument, it will use the parent folder of the given file as root, which does not work on Android, for some strange reason.

You should avoid using File objects, when working with non-desktop platforms. That's the reason why I you can pass a root folder name instead of a File object.

-Trixt0r

Hi. I cant send file via post because is bigger than is allowed. So I attach it here http://leteckaposta.cz/219430933

-tomiit123

Link to comment
Share on other sites

First problem: you are using an outdated version of the library. Pull the newest version from github, and you will not get the NullPointerException.

Second problem: As JustinC said, you have to remove the "assets/" in the path.

-Trixt0r

Link to comment
Share on other sites

First problem: you are using an outdated version of the library. Pull the newest version from github, and you will not get the NullPointerException.

Second problem: As JustinC said, you have to remove the "assets/" in the path.

-Trixt0r

OMG :D Trixt0r and JustinC you are amazing :D ! I'd never realized that the library is outdate and it can be a problem because I downloaded it recently. Thank you again very much for your help and Trixt0r and Discobeard for amazing Spriter library :).

Cheers guyz :)

-tomiit123

Link to comment
Share on other sites

Hi Trixt0r.

I have little question. Why those .scml files takes so much of Android RAM? Project I sent you few days ago about that coin spriter animation is taking circa 22 MB of RAM and its just simple .scml file. Default project of libGDX with simple picture takes only circa 5 MB.

So that simple .scml file takes about 17 MB of android RAM. Its too much for simple coin animation. Pictures of coin has about 300 Kb together.

Is it normal with those .scml files or I have to do some optimalization?

Thanks.

Link to comment
Share on other sites

Greetings again ,

here is my status report after testing the new Library , plz refer to the picture below to see the results of the test on samsung galaxsy s3:

report.png

The test was done with the project with the following details :

SCML Folder: 20images for the entity , each is 1x1 pixel with 3kb each , total 54.5KB

.SCML file: size 1,154KB, number of entities : 1 , number of animations = 17

Current Issue: Java Grow Heap (Frag case) is called Multiple times

possible issue: com.brashmonkey.spriter.Entity/Animation (sees fit/May) allocate extra heap size growing up to 200~250% of the needed space for the file, is occupies 12.99% percent of total allocated size which remain not used at all by ram and does it everytime a new instance is called, resulting in Java Frag Heap each time eventually leading to RAM being overload and the app exit. (please see first box and 2nd box in the picture)

proven : the png images we use in our scml file are NOT(at least not directly) the reason for the "Grow heap frag case" since we used 1x1 pixel image and we still got the same EXACT Grow heap when use normal images up to even 512x512 pixel size.

-refer for box 1 and box 2 for exact info

result:

The Grow (frag case) call is the first and MAIN issue we are facing which causes grabage collector to kick in and remove the huge unnessory data in RAM, we have 47MB of Ram allocated for 54.5kb worth of images ^^; (mind blown) (107MB active ram with 5 diffrent sml files, they occupie 80MB of RAM i total)

thoughts : is there somewhere in code you think that you r allocate unnessery huge space in ram? like char[1024] and use only one of them etc,(not obvious like this lol but u get the idea)

hope someone would come here and gives you more resultes that may prove useful regarding the issue

always appreciate your work Trixt0r ,

boind

Link to comment
Share on other sites

Ok i found the little devil that causes Grow Heap to be invoked .

in the following method in XmlReader , in the while loop:

public Element parse(Reader reader) throws IOException {

char[] newData = new char[this.data.length * 2]

}

i tested that line in 5 SCML files , and it is always the reason for invoking the Growth heap Issue, it allocates tons of space that are being used ONCE , and when this line invoke many times in the while loop it keep invoking the Growth of Heap. (the line invoked growth of heap 3 times in a single file, each call +15mb which causes the 47MB in Ram that i mentioned before)

only this method must be re-written , i'm gonna see what else i can do about it and hopefully we will reach an answer

Link to comment
Share on other sites

More results :

these are the sizes of the arrays being created

:

05-28 20:35:12.819: I/System.out(23870): 2048

05-28 20:35:12.819: I/System.out(23870): 4096

05-28 20:35:12.819: I/System.out(23870): 8192

05-28 20:35:12.819: I/System.out(23870): 16384

05-28 20:35:12.819: I/System.out(23870): 32768

05-28 20:35:12.819: I/System.out(23870): 65536

05-28 20:35:12.819: I/System.out(23870): 131072

05-28 20:35:12.824: I/System.out(23870): 262144

the sizes that invokes Growth of Heap:

05-28 20:35:12.869: I/System.out(23870): 524288 (size 1)
05-28 20:35:12.889: D/dalvikvm(23870): GC_FOR_ALLOC freed 258K, 36% free 11984K/18620K, paused 22ms, total 22ms
05-28 20:35:12.894: I/dalvikvm-heap(23870): Grow heap (frag case) to 13.846MB for 1048592-byte allocation
05-28 20:35:12.919: D/dalvikvm(23870): GC_FOR_ALLOC freed 512K, 33% free 12496K/18620K, paused 25ms, total 25ms
05-28 20:35:12.919: I/System.out(23870): 1048576 (size 2)
05-28 20:35:12.939: D/dalvikvm(23870): GC_FOR_ALLOC freed <1K, 33% free 12496K/18620K, paused 20ms, total 20ms
05-28 20:35:12.939: I/dalvikvm-heap(23870): Grow heap (frag case) to 15.346MB for 2097168-byte allocation
05-28 20:35:12.964: D/dalvikvm(23870): GC_FOR_ALLOC freed 1024K, 35% free 13520K/20672K, paused 24ms, total 24ms
05-28 20:35:12.974: I/System.out(23870): 2097152 (size 3)
05-28 20:35:12.994: D/dalvikvm(23870): GC_FOR_ALLOC freed <1K, 35% free 13520K/20672K, paused 19ms, total 19ms
05-28 20:35:12.994: I/dalvikvm-heap(23870): Grow heap (frag case) to 18.346MB for 4194320-byte allocation

an array of size 2097152, Tons of RAM w XD yup this method must be re-written sadly , each time we are in the while loop it Creates a char array that twice the size of the previous one , realize we start with char array of 1024 , even if we start with char [1] for debug case the size always keep growing twice previous size which will lead us to 1024 ,2038 etc again

in another word , if this line was invoke a hundred times , we will need an array of size : 1.2676506e+30 ahm ahm

Link to comment
Share on other sites

Hey Trixt0r,

I'm still Trying some stuff here and there to see if i can create an alternative method to the current one, in mean time i submitted a Bug Issue to the libgdx community regarding their class XMLReader since it is the one being used in the library therefore they might be interested in fixing that method in the future for the smart phone devices , the link is here for that topic :

http://www.badlogicgames.com/forum/view ... 11&t=14583

feel free to pump it up there so we can show them there are developers like me struggling with this issue XD

In the mean time i'm doing more tests , i'll submit a solution in both this forum and theirs if i find a solution or correct way to parse the file properly.

Link to comment
Share on other sites

update :

well i owe you guys an apology , i thought Grow heap line of Code is typed out exactly like System.out.println() just like the log here

:

05-28 20:35:12.869: I/System.out(23870): 524288 (size 1)
05-28 20:35:12.889: D/dalvikvm(23870): GC_FOR_ALLOC freed 258K, 36% free 11984K/18620K, paused 22ms, total 22ms
05-28 20:35:12.894: I/dalvikvm-heap(23870): Grow heap (frag case) to 13.846MB for 1048592-byte allocation
05-28 20:35:12.919: D/dalvikvm(23870): GC_FOR_ALLOC freed 512K, 33% free 12496K/18620K, paused 25ms, total 25ms
05-28 20:35:12.919: I/System.out(23870): 1048576 (size 2)
05-28 20:35:12.939: D/dalvikvm(23870): GC_FOR_ALLOC freed <1K, 33% free 12496K/18620K, paused 20ms, total 20ms
05-28 20:35:12.939: I/dalvikvm-heap(23870): Grow heap (frag case) to 15.346MB for 2097168-byte allocation
05-28 20:35:12.964: D/dalvikvm(23870): GC_FOR_ALLOC freed 1024K, 35% free 13520K/20672K, paused 24ms, total 24ms
05-28 20:35:12.974: I/System.out(23870): 2097152 (size 3)
05-28 20:35:12.994: D/dalvikvm(23870): GC_FOR_ALLOC freed <1K, 35% free 13520K/20672K, paused 19ms, total 19ms
05-28 20:35:12.994: I/dalvikvm-heap(23870): Grow heap (frag case) to 18.346MB for 4194320-byte allocation

but apperntly the Grow heap is called before char[] newData = new char[this.data.length * 2], which leaves us back to search for the real cause of this issue >.> i tried to toString.Trim() the xmlReader reader but could not get it to work , gonna try tomorrow again , been working on this for the last 6 hours

Link to comment
Share on other sites

I tried using the current xmlReader in libgdx 1.1.0 , only the parsing method using the following code :

	try {
Element root = new XmlReader().parse(Gdx.files.internal("Offical/Spriter/Edge/CurrentProj.scml"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

for some reason i get allocations of 30MB rather than 47MB for the same file that i always use ,in another file 15MB allocations became 11.04MB, and in one more no allocations were called.

in the no allocations called file it had 9 images , 1 entity and 2 animations

still lil bit of improvemt but it is always the same method that calls Grow heap, perhaps if there is a way to call toString.trim() method during the parsing we might get better results

Link to comment
Share on other sites

Hello, I've been recently trying to implement the system.

When I try to load up the scml-file I'll get an error thrown out by the SpriterException class.

It says the following:

Exception in thread "main" com.brashmonkey.spriter.SpriterException: Error parsing XML on line 1 near: res/GameRes/Player/Spriter/player.scml
at com.brashmonkey.spriter.XmlReader.parse(XmlReader.java:286)
at com.brashmonkey.spriter.XmlReader.parse(XmlReader.java:25)
at com.brashmonkey.spriter.SCMLReader.load(SCMLReader.java:46)
at com.brashmonkey.spriter.SCMLReader.(SCMLReader.java:36)
at js2122.mygame.Entity.SpriterTestEntity.(SpriterTestEntity.java:29)
at js2122.mygame.Game.init(Game.java:40)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
at js2122.mygame.Application.main(Application.java:42)

I already checked wether the path is the correct one and it is. I can't figure out the problem with my code

Data data = new SCMLReader("res/GameRes/Player/Spriter/player.scml").getData();

I hope someone can help me out with that. :?

Link to comment
Share on other sites

Didn't have a chance to play with Trixt0r's latest update, unfortunately. Will try to get to it this weekend, if possible.

Boind, do you have a project you can share demonstrating your memory issue? In my case I was only seeing small bits of mem being collected constantly and I was able to resolve them. A standard/typical test case would be handy because I am doing things radically (horrifically) different from the start :)

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

first of all I'd like to say thank you very much for the importer.

Up to now I've been using a single Player, but I've now switched to a PlayerTweener.

The PlayerTweener is instantiated like so:


_playerTweener = new PlayerTweener(data.getEntity("Robot"));
_playerTweener.getFirstPlayer().setAnimation("Idle");
_playerTweener.getSecondPlayer().setAnimation("Walking");
_playerTweener.setWeight(0);
_playerTweener.setScale(0.0045f); // I'm using Box2d, which uses meters as base units, so the animation has to be scaled down a lot.

The weight between the two animations is set based on the horizontal velocity.

Both animations play fine in simple player instances, but in the tweener some of the sprites of the "Idle" animation are not scaled, i.e. they appear absolutely huge.

As soon as the "Walking" animation gets full weight, there is no problem.

Any hints? Which further information should I provide?

Thanks in advance

Andreas

Link to comment
Share on other sites

Hi Andreas

Thanks for discovering the bug.

Does this problem happen to sprites only or also to bones (just debug draw the player with a ShapeRenderer in case you didn't discover how to do it yet)? Maybe you could send me an SCML file with the two animations and a placeholder sprite. Didn't test the tweener with different scale options… But if the problem only occurs for sprites I may already know hiw to fix it.

Btw, it is easier for me to react to bugs if you create an issue on github for it. Even if it is not a bug and you do not know how to make a workaround for your problem, I could add an example for your needs and commit the issue as "fixed".

- Trixt0r

Link to comment
Share on other sites

  • 1 month later...

I am very sorry that I am repsonding that late, ArrogaX.

Combining those two examples would be definitely possible.

But right now I am busy at work, and it is very hard for me to find some time.

If no one can do it, I will try to do it, if I get some free time.

You could also implement it on your own and I may give you some tipps, if you get in trouble.

Just PM me via e-mail, ICQ or Facebook (fb.com/Trixt0r , the other two addresses are already posted in this thread somewhere).

- Trixt0r

Link to comment
Share on other sites

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.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...