Jump to content
Spriter Forums

Gamemaker Studio Implementation Issues


hippyman

Recommended Posts

I would love to make a plugin for GM:S but first I need to address some issues.

The biggest problem with using Spriter and GM:S together is the way GM:S works with external images. When you add an image dynamically in GM:S it adds a new texture page to the resources. Which means if you import ten images, you've created ten texture pages. That causes memory to spike. 
Then say you're drawing all ten of those sprites to render your skeleton, that results in ten texture swaps every draw update. This turns into terrible performance with GM:S, especially once your characters start getting more complex.

I thought I was going to get lucky with the parser by using the built-in json_encode/json_decode functions in GM:S but that turned into a good laugh as GM tried to make a 1.5 TB ds map and damn near froze my computer. Not really sure what happened there.... It won't be hard to make a simple XML parser though, so that's not as big of an issue.

The best solution I can think of is only pulling out the skeleton data and then loading the images directly into GM:S. That would unfortunately result in a longer setup time compared to most other implementations but that's just one of the many quirks of working with GM:S ;)

I remember seeing something about TexturePacker in Spriter but I'm not sure what that is all about. Is it possible to get all the images into a sprite sheet and then have the SCML file reference images from that? That would make it MUCH quicker when setting up a project since you could just import the single sprite sheet and then just draw the part that you need in GM:S. It would be one imported sprite, one texture page, one texture swap.
 

If it doesn't go without saying, I'm only in the planning stages right now but I would really like to get something up and running for everybody (me included) as soon as possible.

Right now I'm just trying to get some ideas on how to move forward with this. I've already tried to just dive in coding and sure enough that was a pure mess.

 

 

 

 

Just in case anybody gets confused, when I'm talking about importing images dynamically or just loading them in.

GM:S has several different types of resources. Out of them, there are "Sprites" and "Included Files"
You can create a sprite in the editor and then import existing images that way which is more efficient but slower to setup

OR

You can put the images in the included files which is quick and you can drag folders in there to keep your organization. This is much faster obviously but results in the mass memory usage and multiple textures pages/swaps.

Link to comment
Share on other sites

Hi hippyman,

I'll keep an eye on this thread and will help any way I can.

For texture atlases, it's already possible with Spriter Pro (through its TexturePacker integration support) to create your animations using images from texture sheets as opposed to individual images or to create texture atlases after the fact. 

 

Unless some kind of unforeseen emergency pop's up, I'll make a new tutorial video and an example Spriter project some time this weekend, which you could use to continue testing and development. 

cheers.
-Mike at BrashMonkey

Link to comment
Share on other sites

Here are two example files which are created completely from texture atlas based images instead of individual images. Each using a slightly different texture atlas format..

I'll try and make s video explaining the method I used to create them tomorrow, but I might end up late by a day or so.

cheers.

-Mike at BrashMonkey

AtlasGuyFree.zip

AtlasGuyFull.zip

Link to comment
Share on other sites

Can you please clear your browser cache and try again, or with a new browser, just to see if there's a problem on the forums end or on your end (the links work for me) In the mean-time, here they are via Dropbox:

https://dl.dropboxusercontent.com/u/61721248/AtlasGuyFull.zip

https://dl.dropboxusercontent.com/u/61721248/AtlasGuyFree.zip

Also, an unforeseen delay did come up.  A nasty Flu has my wife out of commission, so I've had no time open to record a video. I'll get to it as soon as I can. Sorry for the delay.

cheers.

-Mike at BrashMonkey

Link to comment
Share on other sites

  • 2 months later...

Sorry for the long break with no reply. I've been taking a break from programming but I'm back to messing with stuff once again. I'm curious about some of the variables in the json file for AtlasGuyFree.

Each frame has the following variables

frame, rotated, trimmed, spriteSourceSize and sourceSize

I'm assuming the frame variable tells you the xy position of the top left corner and the width/height of the sprite inside the texture and the sourceSize looks like it's just the size of the original sprite. The one that confuses me is the spriteSourceSize variable. I see that the width and height are the same as frame but the xy position is different. So I don't really know what it's there for. Any information on this would be greatly appreciated.

 

 

p.s. I hope your wife made it through the flu without too much struggle. I managed to catch it too while it was going around and it definitely was no party.

Link to comment
Share on other sites

@hippyman

It's TexturePacker's json hash format:

"frame"
"x", "y" = location in spritesheet
"w", "h" = trimmed unrotated image size

"rotated" = is the image rotated 90 degrees clockwise
"trimmed" = always "true" in spriter generated spritesheets

"spriteSourceSize"
"x", "y" = trimmed offset - pixels trimmed from the top and left
"w", "h" = same as in "frame"

"sourceSize"
"w", "h" = original image size

Link to comment
Share on other sites

Thank you, that is very helpful. Are you using the MaxRects algorithm for the free AtlasGuy? Should basic and MaxRects be the same pretty much

Never mind I see the difference between full and free now after looking at them. 

 

I think I'd like to try something different. I don't see why it wouldn't be, but it should be possible to just import the bone data into GM:S and then let the programmer assign sprites in code to the bones. I really don't quite understand the SCML files very well so I guess I'm not sure how tied in the sprites are. Do you think this would be doable without breaking the way everything works?

 

@lucid @BrashAdmin I wasn't sure if you saw my edits and I don't know your rules on bumping so hopefully you notice this.

Link to comment
Share on other sites

  • 4 weeks later...

@hippyman I'm not sure if you mean to let the user of the plugin assign sprites to bones, or manage bone animation, but I don't think that would work very well for the user.

This is a bit outdated as far as the latest features and may have some small errors, so I recommend using the reference implementations stickied on this board to get a more detailed look if needed, but this reference can be used to get a basic understanding for how the format works, and if you have specific questions, I can answer them.

Link to comment
Share on other sites

  • 2 months later...

I'm taking yet another stab at this and I'm curious about something in the scon files. What is the gline variable found in animations used for? It's always empty from what I've seen so far.

 

I'm also interested in possibly using the C++ implementation and making a DLL extension for GM. The only downside is it would be Windows only but it would have much better performance since C++ would be handling the most of it and GML would simply retrieve data from it.

I'm also not very experienced with C++ so any help would be appreciated. Is it possible to just compile the engine code as a DLL or is there more to it than that?

Link to comment
Share on other sites

@hippyman ,  There are likely GameMaker specific requirements, so I would check their SDK documentation/ask on their forums.   You may need to modify the code a bit to get it to work in a dll, though depending on how their plugin system works, you may not.   Sometimes, plugin architectures can hide the details from you and you don't need to get to in depth into specifics of how dlls work, but here's some basic info on creating a dll, just in case: http://www.tutorialspoint.com/dll/dll_writing.htm

Link to comment
Share on other sites

I've actually been reading up on it and I'm getting better with DLLs and GM:S. I think using the C++ implementation will be possible. I will have to make some changes but I have some ideas that I'm going to try out. I'll be sure to keep you guys updated if I figure something out.

Link to comment
Share on other sites

  • 2 months later...

Another long break and I'm back again....

I've found a framework that solves the external image texture page issue I spoke of previously and JSON seems to work better in GM:S so I'm messing with this again.

I'm just curious about one thing at the moment.  Is the "interval" tag in animations the "playback speed" of the animation?

 

 

EDIT: Also I noticed I did ask but I never got an answer. What is the "gline" tag used for? It's always empty

Edited by hippyman
Had another question
Link to comment
Share on other sites

7 hours ago, hippyman said:

Is the "interval" tag in animations the "playback speed" of the animation?

Interval is the snapping interval that you set using the '...' button next to the snapping (magnet) button on the timeline window.

It's the size of the interval, in milliseconds that Spriter will snap the keys to if you have snapping enabled.

7 hours ago, hippyman said:

Also I noticed I did ask but I never got an answer. What is the "gline" tag used for? It's always empty

Sorry I must have missed the question earlier.  The gline shouldn't always be there.  It's a bug, and probably only in the scon version.  It should only be there if you are using guidelines in Spriter Pro (You can drag them from the rulers on the top or left side of the main canvas).   Gline is the tag where Spriter saves their locations.   

Link to comment
Share on other sites

2 minutes ago, lucid said:

Interval is the snapping interval that you set using the '...' button next to the snapping (magnet) button on the timeline window.

It's the size of the interval, in milliseconds that Spriter will snap the keys to if you have snapping enabled.

Aaah I see. What does that do? I enabled snapping but didn't really notice a difference other than the keys got all fat in the timeline. The animations didn't really seem to change.

 

5 minutes ago, lucid said:

Sorry I must have missed the question earlier.  The gline shouldn't always be there.  It's probably only in the scon version.  It should only be there if you are using guidelines in Spriter Pro.  You can drag them from the rulers on the top or left side of the main canvas.  Gline is the tag where Spriter saves that information.

That would make sense as that is the file format I'm using to import the data. On a side note, I didn't know you could do that in Spriter. So that's pretty useful! :-D

 

It's taking me forever but I'm not going to give up on it. The people will get their GM:S implementation!

 

 

I do have some more questions though. Since I'm having troubles wrapping my head around the other finished implementations, what should be my next step?

At the moment I have a simple system where you just drag in your entire project folder into GM:S (you must have a .scon file)

Then you create an object and call the script spriter_init and the arguments are the name of the .scon file and the name of the root folder that contains all the images and data files.

All of the images are imported automatically and grouped onto their own texture pages.

Basically I had no problem on the file end of things but I really don't know where to go from there. Any sort of guidance would be extremely helpful and if I'm being vague please let me know and I'll try my best to communicate better.

Link to comment
Share on other sites

11 hours ago, hippyman said:

Aaah I see. What does that do? I enabled snapping but didn't really notice a difference other than the keys got all fat in the timeline. The animations didn't really seem to change.

When they get fat, they also snap to the grid when you drag and drop them.  Also, if you go into the additional snapping options (the '...' next to the magnet), there's a checkbox to lock the playback framerate to the snapping interval, so you can preview what your animation would look like exported to png/gif at a specific framerate.
 

11 hours ago, hippyman said:

Any sort of guidance would be extremely helpful

What language are you programming it in?  The best place to start would be to see if there's already an implementation in that language, and then just extend it to work within gamemaker.     

EDIT: Earlier you mentioned considering using C++.  If that's still a possibility, the c++ implementation might only require you to override a few classes to work.

Link to comment
Share on other sites

8 hours ago, lucid said:

When they get fat, they also snap to the grid when you drag and drop them.  Also, if you go into the additional snapping options (the '...' next to the magnet), there's a checkbox to lock the playback framerate to the snapping interval, so you can preview what your animation would look like exported to png/gif at a specific framerate.

Okay that makes sense. 

 

8 hours ago, lucid said:

What language are you programming it in?  The best place to start would be to see if there's already an implementation in that language, and then just extend it to work within gamemaker.     

EDIT: Earlier you mentioned considering using C++.  If that's still a possibility, the c++ implementation might only require you to override a few classes to work.

Unfortunately there is no current implementation in Gamemaker Language which is what I'm trying to do. I thought I could try making a DLL with the C++ implementation but I couldn't really wrap my head around it and it would also lock it to Windows. I'm trying to make it completely cross-platform with GML. 

I don't really understand what the flow should be if that makes any sense at all. My biggest issue I'm having is understanding how the mainline and timelines all work together? Do I even need the mainline?

 

 

 

EDIT: I think I just noticed something. The .scon files are missing some data in the object references in mainline tags. They don't have any of the transform data.

 

Object refs looks like this in the scon files

object_ref": [
	{
		"id": 0,
		"key": 8,
		"parent": 6,
		"timeline": "2",
		"z_index": "0"
	}

 

While the .scml files look like this

<object_ref id="0" parent="6" name="p_arm_idle_a" folder="2" file="0" abs_x="30" abs_y="114.999967" abs_pivot_x="0.388889" abs_pivot_y="0.487179" abs_angle="290.409883" abs_scale_x="0.999999" abs_scale_y="1" abs_a="1" timeline="2" key="0" z_index="0"/>

 

Is this a bug or did I tick a setting that removes those properties when saving the .scon file?

Edited by hippyman
Found issue with .scon files I think
Link to comment
Share on other sites

I'm flip flopping again. I'm going to use SCML files instead of SCON.

What are the <frame> elements for in between <obj_info> elements?

EDIT: Sorry I should mention that I'm using the free Grey Guy project while working on this framework. Am I just making things more complicated than they need to be? I don't get how everybody else making implementations seems to just get how the SCML files work.

Link to comment
Share on other sites

Hello?? Is anybody there??

 

I created a new project and now the SCML file only has bone objects and no sprites. Is grey guy like a really old project or something?

It would be extremely helpful if you guys made an updated version of the SCML reference that shows every possible element you can find, since it seems like things that don't exist in a project are omitted from the SCML file.

 

EDIT: On a side note... what would be the possibility of adding in support for OGG sound files? It would save me from having to make an external sound system also.

Link to comment
Share on other sites

  • 2 weeks later...

Quick question about timelines. Would there ever be a case where timelines will have more than one bone or object in a key?

For example

<timeline id="18" obj="0" name="bone_groin" object_type="bone">
  <key id="0" spin="0">
    <bone x="7.594937" y="179.746835" angle="270"/>
    <bone x="25" y="150" angle="90"/>
  </key>
</timeline>

Or is it one bone/object per timeline?

 

 

EDIT: Another quick question. When the spin variable is omitted from the key does that mean it should be a value of 1? I get really confused when variables are missing randomly. Is there any way to export without removing these random things?

 

Edited by hippyman
Had another question
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.

  • Recently Browsing   0 members

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