Jump to content

Spriter Generic C++ API


grimfang4
 Share

Recommended Posts

Hey everyone,

I'm working on a generic API for C++ that is not tied to a specific rendering engine. If you have feature requests specific to such an interface, leave a message here, email me, or create a new issue on the Google Code page. You can find my info at http://www.dinomage.com.

EDIT: It's ready to use! Get the code at http://code.google.com/p/scml-pp/

Included is a sample implementation targeting the SDL_gpu rendering API.

I'm still interested in feedback and interface suggestions!

Currently implemented renderers:

SDL_gpu

SPriG (no GPU)

SFML 2.0

Link to comment
Share on other sites

  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Thanks, Mike!

I just fixed the "drawing mostly right" issue (you can see it in the previous image where some joints don't seem to line up - notably the forward knee). Tweening of the basic positioning parameters is implemented now too, so the animation is nice and smooth.

So, except for comprehensive use cases, it's ready to be put into a game. I'm just awaiting an example that uses bones so I can finish that part. Then there are all the details left, like atlases, character maps, metadata and such. Here's to Spriter!

Link to comment
Share on other sites

  • 2 weeks later...

Thanks to Edgar and Spriter A4! SCMLpp now draws entities that have bone hierarchies.

A sample is included in the source repository. The sample and code might also be helpful to developers who are implementing bone animation in other plugins (more so when it gets cleaned up). I'll put together some extra documentation for such an implementation.

post-7563-14159834057976_thumb.png

Link to comment
Share on other sites

You're welcome. It'll be very useful personally, once my projects are ready for it.

The knight sprite is indeed crayon. My daughter drew it (and others) for my little game, Button Battle (http://www.dinomage.com/?s=button+battle). I didn't use Spriter for Button Battle, so it has very simple movements. To retain the authentic messy crayon style, I used the GIMP to cut a white layer to the shape of the sprite and the Color to Alpha tool (in the Colors menu) to overlay the drawing on top of the cutout.

Link to comment
Share on other sites

For those who might want to create a new renderer for SCMLpp, I've just factored out all of the SCML complexity so the renderer implementation is incredibly simple. Take a look at SCML_SDL_gpu.h and SCML_SDL_gpu.cpp. The overall interface is still evolving, but the renderer-specific interface is settling down.

If you want to contribute a renderer to the project and source repository, let me know!

Link to comment
Share on other sites

Hi,

Thanks for working on the CPP implementation.

I like that you split the code to a rendered. I'm currently trying to use your implementation to get it working on Cocos2d-x.

It seems like the bones aren't working well, the anchor points are wrong. Maybe you should send them in the rendered draw call?

Also, I've tried running "Hero.SCML" example, and it crashes.

Thanks & keep with the great work :!:

Link to comment
Share on other sites

Thanks Obg1. It'll be great to have Cocos2d-x support. If you write the renderer code, you can email it to me or if I have your Google account email address, I can add you to the repository project members.

The renderer interface draw_internal() is meant to rotate about and draw at the center of the image. This is the simplest renderer-agnostic choice. All the hard work is done elsewhere so that this function can be just a dumb drawing wrapper.

I've fixed up the tweening so it doesn't crash on Hero.SCML (now included in the repo). However, it looks like there's a spin direction issue still...

Link to comment
Share on other sites

Hi,

I've just emailed you regarding this.

Also, if you need an example file to test bones let me know and I'll send you one.

I think it will be best if all of the efforts will be made on your port due to its generic nature.

If someone from the Spriter team can also help on improving your port, it will help a lot. Especially the bone mechanism.

Link to comment
Share on other sites

Yep, I figured out what the problem was. I was assuming that the mainline object ids could be used to refer to the same object in different keys, but Spriter actually follows the timeline for each object to do tweening. I fixed SCMLpp to use the timeline for that purpose. Problem solved.

The Cocos2d-x renderer technically works, but I'll make it official as soon as it works as well as the others. There are still some kinks to smooth out.

Link to comment
Share on other sites

  • 3 weeks later...

There is now an interface to get current bone and object transforms. This can be used both for drawing bones and for in-game effect placement. Let me know if you have any feedback or suggestions on this:

int SCML::Entity::getNumBones() const;

int SCML::Entity::getNumObjects() const;

bool SCML::Entity::getBoneTransform(SCML::Transform& result, int boneID);

bool SCML::Entity::getObjectTransform(SCML::Transform& result, int objectID);

Link to comment
Share on other sites

  • 1 month later...
I was able to run your api on Mac using the SFML renderer after a little tweaking.

Thanks!

Awesome. :)

Please send me the tweaks if you think they apply to others, too.

Basically, the tweak is just to change the way we load resources, as the Mac apps have this sandboxing system where all the assests are within that sandbox.

I guess everyone who uses SFML on mac knows about it.

We just need to modify two methods:


//main.cpp
int main(int argc, char* argv[])
{
if(!init(800, 600))
return 1;

vector data_files;
data_files.push_back(resourcePath() + "Example.SCML");
data_files.push_back(resourcePath() + "knight.scml");
data_files.push_back(resourcePath() + "Hero.SCML");
data_files.push_back(resourcePath() + "fish.scml");

main_loop(data_files);

quit();
return 0;
}

//SCML_SFML.cpp
bool FileSystem::loadImageFile(int folderID, int fileID, const std::string& filename)
{
sf::Texture* img = new sf::Texture;
img->loadFromFile(resourcePath() + filename);
if(img == NULL)
return false;

if(!SCML_MAP_INSERT(images, SCML_MAKE_PAIR(folderID, fileID), img))
{
printf("SCML_SFML::FileSystem failed to load image: Loading %s duplicates a folder/file id (%d/%d)\n", SCML_TO_CSTRING(filename), folderID, fileID);
delete img;
return false;
}
return true;
}

Here resourcePath() is available from the ResourcePath.hpp, that comes with SFML, and is also available on github

And when adding the images and the .scml files to the project, keeping them with the .SCML file at the root level with other images added with 'Folder Type' reference. Such that the images are available at path:


YourApp.app/Contents/Resources/mon_arms/hand_0_2.png

For example, this is how my Xcode's Project Navigator looks like

v0dSD.png

I hope this helps all the SFML Mac devs. If not, let me know, I'd be glad to help :)

Link to comment
Share on other sites

  • 3 months later...
Hey everyone,

I'm working on a generic API for C++ that is not tied to a specific rendering engine. If you have feature requests specific to such an interface, leave a message here, email me, or create a new issue on the Google Code page. You can find my info at http://www.dinomage.com.

EDIT: It's ready to use! Get the code at http://code.google.com/p/scml-pp/

Included is a sample implementation targeting the SDL_gpu rendering API.

I'm still interested in feedback and interface suggestions!

Currently implemented renderers:

SDL_gpu

SPriG (no GPU)

SFML 2.0

Please Support App Game Kit C++ Tier 2 Rendering... I've been waiting on an interface to AGK from The Game Creators for a while now, and I think this is the perfect opportunity, especially since I would rather work in C++ than the basic like language of Tier 1..

I'm more than happy to help test it out, as I am a registered spriter pro pre-purchase owner, and AGK Beta tester, currently on version 1.08 beta 9.. I have plenty of C++ experience, so would love to get this working, and welcome your implementation for AGK 1.08 Tier 2 C++ Rendering..

Thank you for this soooo Much!

Ken Cornett aka StOrM3

storm3@twlakes.net

Link to comment
Share on other sites

  • 2 weeks later...

Hey I will give it a go, if you can zip up the entire repository, and either send it to my email or post it some where I can snag it.. I am not using GIT nor do I have any subversion client setup right now.. Sorry for the lack of my reply, but I have been battling a problem with my current game, I have a physics game, done with GM:Studio and the prismatic joint and motor is not working as it should, to allow my spike objects to go up and down, to kill the player etc.. I had to make 2 prismatic joints with motors and create and delete them based on collision of spikes with sensor boxes, and this is needless to say less than Ideal setup, so I posted a bug report that setting / changing the motor speed to a -negative number does not make it move back up as it should.. But, I still do want to make this work with App Game Kit, especially since I will be doing alot more work in AGK at least until GM:Studio can fix these bugs or add these features, also I requested Ashley add a prismatic joint and motors to Construct 2 Physics behaviors and properties also.. We'll see, but until then, I will be trying to work exclusively in AGK, once PEP is done for level editing and sprite placement and physics shapes and properties can be setup.. If I have the complete package, it should be nothing to change the member functions we need to get it rendering inside AGK Tier 2 or C++ inside Eclipse.. Thank you for all your help as many others have stated already, this is a great thing to have... Just let me know where I can snag it from, or if you want to email it to me, you can send it to my gmail account at: storm36969@gmail.com

Thanks again,

StOrM3 aka Ken

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