Jump to content

SpriterPlusPlus - a C++ Spriter implementation


Recommended Posts

@Revagames

I spoke briefly with Edgar about your issue and his thoughts were as follows:
 it seems like it's a bug in either your code or the SpriterPlusPlus code that's leaving easingCurve set to null or pointing somewhere invalid.  

Unfortunately Edgar will not be able to look into this anytime soon, as Spriter 2 requires his full attention until we hit certain milestones, but he suggests debugging with a breakpoint in that function in order to verify, and going back through the callstack to see when the issue happens would be the first step to looking into it.

Let me know if this is helpful.

 

Link to post
Share on other sites
  • 8 months later...
  • Replies 140
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Cool! Really good job. I will now be able to update it to the Clickteam Fusion 2.5 tool. For what I have seen so far it should be straightforward from my existing implementation.

@lucid OK thanks, nice new wrappers. I updated my fork https://github.com/Breush/SpriterPlusPlus with the PugiXml loaders. You should check example/override/pugixml* and the pugixml at the root di

I've added a pull request for a gcc change and a fix for header files not found. I could build the engine now with: cd spriterengine LANG=C g++ -std=c++14 -shared -fPIC -I. */*.cpp -o spriter

Posted Images

I noticed a problem regarding sounds:
The volume for sounds is not set correctly. It seems to be always set to 1.
Do you have any ideas what the problem could be?

EDIT: If I understand the code correctly, the value for the volume is loaded in SpriterDocumentLoader::getSoundObjectInfoFromSoundlineKey(...) and stored in a SoundObjectInfo, which is then passed to a TimelineKey.
On call of SpriterModel::getNewEntityInstance() a SfmlSoundObjectInfoReference is created, which holds the actual Sound object of SFML.
By debugging i found out that the correct volume is loaded and stored into the SoundObjectInfo.
Also setting the volume from outside by calling setVolume() on the object returned by EntityInstance::getSoundObject() works as expected.
But somehow the volume loaded from the xml, which is stored in this SoundObjectInfo is not passed to the actual sf::Sound that is stored in the SfmlSoundObjectInfoReference. When calling getVolume() on the object returned by EntityInstance::getSoundObject() the returned value always is 1.

 

SECOND EDIT: I managed to fix this by changing the code of the body of the for-loop that iterates over the soundTimelines in Animation::setupAnimationInstance(...) into:

auto newVolume = dynamic_cast<SoundObjectInfo*>(it->getLastKey()->getObjectInfo())->getVolume();
SoundTimelineInstance *newInstance = new SoundTimelineInstance(entityInstanceData, it, it->getObjectId());
newInstance->getResultObject()->setVolume(newVolume);
timelineInstances->push_back(newInstance);

This is probably not the best way to fix this but it works for me right now. If you have a cleaner solution, maybe you could share it :)

Link to post
Share on other sites
  • 1 year later...

Hi

I've implemented the library into my SFML based project.
I've just replaced the "to override".
Basically had to update the file factory and object factory a little.
Remove the XML support and left only the JSON support.

Currently trying to load a 6 MB JSON file that has 12 sprites consist from 6 MB of PNG files,
took more than 2 1/2 minutes to load, raising the memory usage to 2 GB which were dropped significantly after load to around 400 MB.

I output to log texture loading to see if this is a bottleneck and its not, loading the textures (one by one, not from an atlas file) was pretty quick.

Something is wrong, does anyone have  an idea where to look ?

I have yet to try implementing a sprite to the screen, just focusing on loading.

Link to post
Share on other sites
1 hour ago, Dror Rejwan said:

Hi

I've implemented the library into my SFML based project.
I've just replaced the "to override".
Basically had to update the file factory and object factory a little.
Remove the XML support and left only the JSON support.

Currently trying to load a 6 MB JSON file that has 12 sprites consist from 6 MB of PNG files,
took more than 2 1/2 minutes to load, raising the memory usage to 2 GB which were dropped significantly after load to around 400 MB.

I output to log texture loading to see if this is a bottleneck and its not, loading the textures (one by one, not from an atlas file) was pretty quick.

Something is wrong, does anyone have  an idea where to look ?

I have yet to try implementing a sprite to the screen, just focusing on loading.

@Dror Rejwan if you'd like to send me the json file (lucid@brashmonkey.com).  6MB seems really large for the scon file.  It may have become corrupted, and I might be able to fix it.   If you can send it in a zip with the project files it may help me to troubleshoot.

Link to post
Share on other sites
5 hours ago, Dror Rejwan said:

Sent you a PM with a link, thank you for your help

I didn't find anything unusual in the file.
Have you tried yet with the example sfml/json implementation?   It takes about 3 seconds to load the json on my machine.   No spike in memory usage either.

Link to post
Share on other sites

Also, another question on the matter

As you can see from the Spriter project I sent you, there are 12 "monsters" that all look has the same movement animations but using different PNG's (e.g a blue monster, a red monster, a white monster etc..).

Is it possible to use the library to "construct" a monster from various monsters ?
(or in other words, combine different animation elements into a new animation) ?

If so, can you please give pointers to where I should investigate ?

 

Thanks !

Link to post
Share on other sites

I just tested it with the example project.

It took mote then 60 seconds to load and memory raised to 1.2 GB. After it was loaded it dropped down to around 400 MB memory.

I took a video and will send it to you via PM.

Could this have anything to do with SFML being linked statically and in debug mode?
Why does the SCON file takes 6 MB ?

Link to post
Share on other sites
4 hours ago, Dror Rejwan said:

I just tested it with the example project.

It took mote then 60 seconds to load and memory raised to 1.2 GB. After it was loaded it dropped down to around 400 MB memory.

I took a video and will send it to you via PM.

Could this have anything to do with SFML being linked statically and in debug mode?
Why does the SCON file takes 6 MB ?

Debug mode might be causing things to go much slower.  The scon file just has a lot of repeated information in it.  See below:
 

 

13 hours ago, Dror Rejwan said:

Also, another question on the matter

As you can see from the Spriter project I sent you, there are 12 "monsters" that all look has the same movement animations but using different PNG's (e.g a blue monster, a red monster, a white monster etc..).

Is it possible to use the library to "construct" a monster from various monsters ?
(or in other words, combine different animation elements into a new animation) ?

If so, can you please give pointers to where I should investigate ?

 

Thanks !

I hadn't gone through all the animations, so I didn't notice they were all the same.  I see you already have character maps in your project.  You don't need to duplicate the animation for each design.  That's what the character maps are for.  You can use them to try out on your character in Spriter and to playback in the implementation.   After removing the duplicate entries, the file was only 435k.

Link to post
Share on other sites
6 hours ago, lucid said:

Debug mode might be causing things to go much slower.  The scon file just has a lot of repeated information in it.  See below:
 

 

I hadn't gone through all the animations, so I didn't notice they were all the same.  I see you already have character maps in your project.  You don't need to duplicate the animation for each design.  That's what the character maps are for.  You can use them to try out on your character in Spriter and to playback in the implementation.   After removing the duplicate entries, the file was only 435k.

Thank you,

Can you please send me the fixed file so we can take a look and study for future characters ?

I hope this will fix the problem.

Link to post
Share on other sites
3 hours ago, Dror Rejwan said:

Thank you,

Can you please send me the fixed file so we can take a look and study for future characters ?

I hope this will fix the problem.

I sent it to you, but all I did was delete all the entities except the first one.

Link to post
Share on other sites
30 minutes ago, lucid said:

I sent it to you, but all I did was delete all the entities except the first one.

Yes, I can see you did that.

The project loads much faster now, around 10 seconds, I think its still not optimal but I will test to see if non-debug version is faster.

 

Is there a way to dynamically create character maps through the code ?
I may have to dig inside to see how this can be done, but if you have any pointers for me I will appriciate.

Link to post
Share on other sites
Just now, Dror Rejwan said:

Yes, I can see you did that.

The project loads much faster now, around 10 seconds, I think its still not optimal but I will test to see if non-debug version is faster.

 

Is there a way to dynamically create character maps through the code ?
I may have to dig inside to see how this can be done, but if you have any pointers for me I will appriciate.

You can choose how to apply and stack them via code.  If you wanted to just use multiple character maps together, like one for the arms, one for the legs, etc.  You can just do that without needing to create them dynamically.  It is most likely possible to create your own using the charactermap classes (in the character map folders), but this isn't a built-in function.

Link to post
Share on other sites
3 hours ago, lucid said:

I sent it to you, but all I did was delete all the entities except the first one.

O.K, I spent some time with the code and think I found the cause for the slow loading.
It looks like the cause is the nlohmann/json library.

When loading the XML version, it loads up in 1 second where in the json version it takes around 10 (!).

Also it is not clear to me why the XML spriter file is smaller than the JSON, since JSON should be a'lot thinner, but thats another question.

Lucid, I assume that when you checked it yourself, you did that with the SCML version too, right ?

Link to post
Share on other sites
3 hours ago, Dror Rejwan said:

O.K, I spent some time with the code and think I found the cause for the slow loading.
It looks like the cause is the nlohmann/json library.

When loading the XML version, it loads up in 1 second where in the json version it takes around 10 (!).

Also it is not clear to me why the XML spriter file is smaller than the JSON, since JSON should be a'lot thinner, but thats another question.

Lucid, I assume that when you checked it yourself, you did that with the SCML version too, right ?

I tried with the scon version (that was the one that took 3 seconds).  Disabling prettify in custom save options will make the file smaller:
image.png

It is most likely taking up so much more space because pretty printing json arrays involves a lot more newlines and indentations total.
You're still having slow loading issues when not in debug mode, and with the updated file (without the duplicate animations)?

Link to post
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.

  • Recently Browsing   0 members

    No registered users viewing this page.


×
×
  • Create New...