SMF - 3D skeletal animation - Now with a custom Blender exporter!

TheSnidr

Heavy metal viking dentist
GMC Elder
right. seems to work fine now. I'll still want to look into it later if I can use the format I made for myself and pipeline it into this so I can use the already skinned version.... attaching the bones is a different question. I'll look into that myself too. other than that, yay it works! I'll fiddle with it more tomorrow.

Edit.: I realized something while fiddling today.
-Would be nice to have control or something to select multiple points without deselecting previous points on the model for weighting. (and deselecting too)

-You can't delete the first frame. which by default fine, so be it, but for instance what if I want the 2nd frame to become the very first frame? a copy frame or delete frame -> 2nd becomes 1st would be a good idea to implement maybe.

-an in between keyframe would also be useful. Most animators do the "end" positions of some animation and refine the in between frames in 2D it's usually like adding a frame between two frames and get the in between frame by drawing between the lines. in 3D it can be nicely used to fix issues like the legs and such after you have the middle positions.
1: You can already do that! Hold shift while selecting to add to selection, or hold control to remove from selection. This also works when using the selection box!
2: I've removed the message and made it so that when you delete the first frame, the second frame gets moved into the first frame's position. If only one frame remains, it's just cleared instead of deleted.
3: Excellent idea! I've added the option to create frames inbetween other frames :D
I've also added a separate tab for model editing so that it doesn't have to update the model every time you do something. Now the model only updates when you leave model edit mode, and a nice, blue message is displayed on screen while it's working.
The possibility to modify bones ingame is also coming along nicely. I've made it possible to change the local orientation around the parent bone, still trying to get world rotation working.

Download latest version of rigging tool
 
Last edited:

GMWolf

aka fel666
The possibility to modify bones ingame is also coming along nicely. I've made it possible to change the local orientation around the parent bone, still trying to get world rotation working.
Does that mean possible IK? (Or just, simple head look, for example)
 

TheSnidr

Heavy metal viking dentist
GMC Elder
That could mean IK! I've previously made a two-joint IK system, importing it into the editor shouldn't be too much of a hassle. It's on my to-do list! Once I get it to work in the editor, it should also work ingame.
 
M

Multimagyar

Guest
I was hacking around a bit in the source now edited a few things checking how others worked etc. and a few question came up in my mind.
Having the grid as sprite is a convenience or because the lack of consistent line draw function on the GPU?
Having only one root is a convenience thing or something specific? (would be useful for gun animations for instance where the gun usually made out of individual sliding pieces)
Does dual quaternion only allow 2 bones / vertex or can be extended to a more regular 4x4 format? (4 bones 4 weights)
 

TheSnidr

Heavy metal viking dentist
GMC Elder
- Pretty much everything is out of convenience! Having the grid as a sprite works well enough for its purpose.
- I could add the possibility for multiple roots, shouldn't be too difficult.
- Dual quaternions can have as many influences as you'd like, but I set the limit of two influences to be able to use the same format as I use for everything else! What I could do, however, is add another color attribute to the format. I'll do this for the next version.

This is what I'm working on now:

It's still a bit volatile and has the potential to ruin the frame so that you have to reset it completely. Working on ironing out this.
 
M

Multimagyar

Guest
- Pretty much everything is out of convenience! Having the grid as a sprite works well enough for its purpose.
- I could add the possibility for multiple roots, shouldn't be too difficult.
- Dual quaternions can have as many influences as you'd like, but I set the limit of two influences to be able to use the same format as I use for everything else! What I could do, however, is add another color attribute to the format. I'll do this for the next version.

This is what I'm working on now:
-snip-
It's still a bit volatile and has the potential to ruin the frame so that you have to reset it completely. Working on ironing out this.
Right. Thank you for the info,
That new feature looks pretty useful... and kind of screams for an undo button which usually pretty annoying to implement mostly with some more complex operation.... sounds fun I might look into it just for the heck of it.
 

TheSnidr

Heavy metal viking dentist
GMC Elder
Okay, here's a new version. It has the rudimentary inverse kinematics, although it's still very volatile! Use with care :p I've also added the possibility to detach bones from their parents so that they can be moved individually:


Download

EDIT:
Oh, and the format is changed btw. Anything you've made with a previous version won't be able to load into this.

EDIT2:
Oops, just realized there's no way to rotate the detached bone in rigging mode. Oh well, I'll fix it for the next version
 
Last edited:

hippyman

Member
Hopefully you're planning on it, but if not, you should definitely put this on itch.io. I appreciate the free download at the moment but I'll gladly give you my money for the editor to support the development of this. GM needs more 3D tools.
 
M

Misty

Guest
Is there a way I can get this to load into GMS1.4? I don't have a 64 bit computer, nor much money, and thus I cannot run GMS2.
 

TheSnidr

Heavy metal viking dentist
GMC Elder
OH COD WHAT HAVE I DONE

I've made it so that the detached bones have a length of 0, since their orientation and length doesn't make any sense anymore anyway. This also makes it easier to attach other bones to them. What I did in this .gif was to detach Link's hips and collar bones, and move them to the side.

hippyman: I want this to be freee! The people who will be able to use it have already spent a lot of money just to get GM studio. I've love to see more proper 3D games made with GM studio. I'm only doing this for fun :D Plus, if I charge people for it, I'll have to support it. The nice thing about making free stuff is that I can simply put it on the shelf when I'm tired of it.

Misty: The SMF format scripts aren't difficult to port back to GMS 1.4, I'll provide a link when the rigging tool is done. I don't plan to release the source of the editor.
 
M

Multimagyar

Guest
my apologies but I could not stop laughing for good 4 minutes of that image. it's just so funny to me. it's so good.

Donations always an option over payed versions if so whatever.

But it seems things coming along nicely.
 

dadio

Potato Overlord
GMC Elder
Crazily impressive as always TheSnidr. I'm sure once this is a bit further along, alotta people will use this for their 3D GM games. (I too would like to see more 3D games in GM - pity there wasn't a bit more support/simplification of some elements of 3D built into GMS/GMS2).
 

hippyman

Member
hippyman: I want this to be freee! The people who will be able to use it have already spent a lot of money just to get GM studio. I've love to see more proper 3D games made with GM studio. I'm only doing this for fun :D Plus, if I charge people for it, I'll have to support it. The nice thing about making free stuff is that I can simply put it on the shelf when I'm tired of it.
I can understand and appreciate that. That's super cool and I look forward to actually messing with this. I bought Ark the other day so not a lot of dev has been going on in my world... This will be one of the next things I mess with.
 

TheSnidr

Heavy metal viking dentist
GMC Elder
What I might do is provide the rigging tool .exe and model format scripts for free, and put the source of the rigging tool up for sale. That way, everyone will be able to use it, but people who want more control will be able to buy it and edit it themselves!

Here's a new version - this might actually be a release candidate, as I'm running out of ideas for reasonable tools to add!
Download rigging tool
Download skinned Wolf Link model and walking animation (This can be loaded into the rigging tool)

Changes:
- More model tools, models can be moved, scaled and rotated before creating a rig
- Inverse kinematics is now much more stable! I haven't been able to ruin a frame with the latest version, but I can't promise anything... Worst case scenario you'll have to reset the frame.
- Bugfixes overall
 
Last edited:
M

Multimagyar

Guest
What I might do is provide the rigging tool .exe and model format scripts for free, and put the source of the rigging tool up for sale. That way, everyone will be able to use it, but people who want more control will be able to buy it and edit it themselves!
Certainly would throw money in your face for it. Probably. What I seen from the source it's easy to handle or modify for my needs, well only from the one I've seen last time that is.
 
N

Never Mind

Guest
~1400-1600 FPS
64-bit Windows 10
Intel Core i5-6500 CPU @ 3.20GHZ
8 GB RAM

Also
Not sure what I did here. This is your latest download link from post #66. I'll try to reproduce it.
I realize how stupid the screenshot must look (using a single bone), but I was just messing around.
Are you supposed to have at least two bones?
Bug1.png
Super cool that your doing this by the way!
Here's a little walk cycle for a crappy dude I made:
 
Last edited by a moderator:

TheSnidr

Heavy metal viking dentist
GMC Elder
Nice catch, the error appeared because you had a frame at time 0 and a frame at time 1, which the system interprets as the same time. Two frames at the same time lead to a division by 0! I've fixed this now :D
Love your little character! :D
 
N

Never Mind

Guest
Ah sweet. And thank you!
I've always been in love with low-poly 3D art. All my favorite games are from N64 times.

I just barely started messing with your tool, but a couple of thoughts I wanted to share:
  • I support something I read Multimagyar post earlier about using colors to represent bone weight / influence, as well as a possible "weight painting" mode in the future.
  • Consider using TAB to quickly cycle / switch between tools (move, rotate, scale, etc.), instead of letter keys.. which leads me to this suggestion:
Suggestions.png
They aren't necessary to have, but they are apart of my preferred work-flow. I must admit these both come from Blender.
Basically you can hold down "B" to start a box selection, and "R" to start a rotation. With the rotations, the mouse can be anywhere in the view-pane. This gives you a lot of control since your using a big lever.
I found it a little difficult to precisely control bone rotations with your current setup (maybe I'm doing it wrong). Of course, there are a number of different ways you could change it.

Another thing that I use a lot in Blender, is manually adjusting the angles (Euler or course!) via changing their numbers in a text / input field.
Lastly, a useful tool that speeds up my work-flow in Blender:
You can start a rotation by pressing "R", then you can press the letter key for the axis you want to rotate on: "X", "Y", or "Z".
You can then use the mouse to rotate (Similar to explanation above but it's different since you've locked onto a certain axis), or you can override the mouse input by starting to type in a number.
I find typing in the value to be extremely useful! You can type in a negative number as well.

Another thing to note is that when you press the same letter key for the axis your already rotating on, it switches between local and absolute rotation.
The tool is great as it is, so I don't mean to pressure you into adding silly things if you don't already plan on pouring more time into it.
I was especially impressed by the inverse kinematics tool :D

Keep up the great work! And, as always.. thank you for sharing your knowledge and work so freely with us!

-EDIT- I'm currently trying to break down your 3D collisions example to see if I can figure out how to use it with my own map and player. It's a really well organized project file, and the comments are on point.
 
Last edited by a moderator:

TheSnidr

Heavy metal viking dentist
GMC Elder
Thanks for your feedback Never Mind! I've added some of it, I especially liked the bone rotation idea where it actually rotates towards the mouse. Now, local bone rotation is kinda like the inverse kinematics, but only for one joint at a time. Box selection is already possible if you right click in skinning mode! I won't add the possibility to write values manually, as the values of a dual quaternion makes no sense to a human anyway. Converting to euler angles and back introduces precision errors, and to be honest, I'm not a fan of euler angles at all for general 3D orientations!

Unless there are any bugs, the model tool itself is pretty much finished:
Download model tool
And here are the import scripts, along with a simple demo on how to use them:
Download import demo


The model tool is no longer exclusively a rigging tool, but can also be used to generate collision buffers for the SMF collision system. Here I've generated a collision buffer from the Wolf Link model:



The model tool can export the following formats:
  • .smf are models compatible with the SMF system. They can be loaded into GM by importing them as buffers and converting them to vertex buffers (or by just using smf_model_load)
  • .col are collision buffers for use with the SMF system. These have been split into octrees.
  • .ani is the animation format. These can be applied to the .smf models.
It also exports two intermediary formats that can't be used in a game, but lets you save your progress:
  • .rig saves the positions and orientations of the bones, but does not save the animation
  • .frm saves the animation frames, but does not save the rig
My plan now is to create a proper manual and instruction video, and then upload it to the marketplace.
 
Last edited:
N

Never Mind

Guest
Wow the new "SMF import scripts" demo is sweet. Great work!
upload_2017-4-19_10-53-57.png
Once again the organization, and commenting is on point!

This should allow people to prototype their 3D games really quickly.
 
Last edited by a moderator:
This is absolutely excellent; something truly amazing to see in GM. I'd love to see some functions for importing third party formats into this.

Because I don't have GMS2 right now, I can't actually get my own benchmark, so I'd like to ask how fast the IO for loading the models is? Say I've got a 3000 polygon model for example, will it take a minute or a second heh.

- TSB
 

DukeSoft

Member
Holy 💩💩💩💩, did you just make an IK rigging system for GM?
Now all we need to build is a proper 3D physics engine... and boom! 3D ragdolls! Then add a material system and we're getting close to high-end 3d engines.

I've been working on a 3D collision engine in the past - Generic GML endpoints which use a C++ engine, a JS engine or a pure GML engine based on the target platform. Might be interesting to combine this with your work here... Man, keep up the good work! Maybe nice to start working on the VR as well again? I've bound forces with Indecom4000 before on a Oculus setup, and i've worked on a Razer Hydra module for GM. Maybe interesting to make GM work the the Oculus CV1 and HTC Vive? Imagine the possibilities :D
 

DukeSoft

Member
Hmm. Can this work for GMS 1.4 games yet?
I think thats going to be really hard, given the fact the entire draw pipeline has been changed as well as DX9 support being switched to DX11 for GM:S2. There's a lot of native DX11 functions in GM:S2 that are not in GM:S1.4, and I'm guessing TheSnidr is utilizing a lot of those. So, I'm guessing - no.
 
M

Multimagyar

Guest
first off as far as I'm concerned the shader script is in opengl ES so the shader should be fine for just including it GMS1.4 the only real work you have to do is like stitching back the scripts from it in GMS1.4 and make sure the scripts don't contain post GMS1.4 code pieces. It's a bit of under taking but that GMS2 supports DirectX11 instead if 9... does not matter if they using the same commands pretty much. So your guessing is wrong sorry to say. Some of those GMS2 codes can be re-written from scratch so that also should not be a problem like building an identity matrix or build a look-at matrix.
Most important thing is D3D functions removed which is not a problem as far as I know he used vertex buffers for it so walls and etc should not matter.
And some has been replaced with gpu functions instead of d3d like "d3d_set_culling" to "gpu_set_culling" so not really much.
Again it's just a bit of work probably to port it over and keep it up-to-date in case he changes a thing.
Good luck.
 

Juju

Member
So, I'm guessing
There're a few in-line macros. The core engine will probably port as a straight copy-paste job.

There's a lot of native DX11 functions in GM:S2 that are not in GM:S1.4
There's a small number of extra ancillary functions in GMS2 to deal niche functionality (z testing, alpha testing, alpha-based blend modes etc). The biggest change are the function names and some minor behaviour differences that are unimportant in this case. The matrix functions used for transforms are available in GMS1.

Good work @TheSnidr. I don't think we'll see a rush towards 3D just yet... but we're getting there.
 
I

icuurd12b42

Guest
Hey man, great job on this!

Do you have model features sort of like gmmodelfix has/had. I'm looking for a better model tweaker than my old tool which is showing it's age... since I lost the project and with all the resolution bump since then... it's almost unworkable and unfixable.... your tool seems to have the fundamentals for it.
 

lolslayer

Member
Hey man, great job on this!

Do you have model features sort of like gmmodelfix has/had. I'm looking for a better model tweaker than my old tool which is showing it's age... since I lost the project and with all the resolution bump since then... it's almost unworkable and unfixable.... your tool seems to have the fundamentals for it.
Don't worry man, I occasionally still use your engine :')
 

trg601

Member
Whoa! This looks incredible! I definitely want to get working with GMS2 and 3D now XD!
Anyways, I was trying out the editor, and I was wondering if it is possible to change the window size of the model tool? It is a tad too large for my monitor.

Thank you!
(The 3d elements and GUI elements also don't really line up, and I can't seem to click anything in the 3d view)
 

TheSnidr

Heavy metal viking dentist
GMC Elder
Hmm. Can this work for GMS 1.4 games yet?
Porting it is pretty straight forward, most of the scripts will work right off the bat, while some have to be modified slightly (specifically the ones containing in-line macros, like Juju mentioned). I started the porting process, but GMS 1.4 froze halfway, I guess the engine was too awesome for it to handle. Maybe somebody else will be nice enough to port it, but I don't know if I care to keep two versions of it updated at all times. God I've gotten lazy...

Good work @TheSnidr. I don't think we'll see a rush towards 3D just yet... but we're getting there.
Thanks Juju :D

Hey man, great job on this!

Do you have model features sort of like gmmodelfix has/had. I'm looking for a better model tweaker than my old tool which is showing it's age... since I lost the project and with all the resolution bump since then... it's almost unworkable and unfixable.... your tool seems to have the fundamentals for it.
Howdy old fella, thanks! Your tool is legendary. What features would you like me to add? It can import .obj models, so the models can be properly tweaked in a modelling program before importing.

Whoa! This looks incredible! I definitely want to get working with GMS2 and 3D now XD!
Anyways, I was trying out the editor, and I was wondering if it is possible to change the window size of the model tool? It is a tad too large for my monitor.

Thank you!
(The 3d elements and GUI elements also don't really line up, and I can't seem to click anything in the 3d view)
Thank you! :D The window size is currently locked to 1600x900, but enabling the user to resize it shouldn't be too challenging. I'll add this to the next update :)
 
M

Misty

Guest
Porting it is pretty straight forward, most of the scripts will work right off the bat, while some have to be modified slightly (specifically the ones containing in-line macros, like Juju mentioned). I started the porting process, but GMS 1.4 froze halfway, I guess the engine was too awesome for it to handle. Maybe somebody else will be nice enough to port it, but I don't know if I care to keep two versions of it updated at all times. God I've gotten lazy...
Same here. I was actually too lazy to download this yet. But I want to download this soon because next thing you know a year goes by and the link is dead by then.
 
I

icuurd12b42

Guest
>Howdy old fella, thanks! Your tool is legendary. What features would you like me to add? It can import .obj models, so the models can be properly tweaked in a modelling program before importing.

Yep, scaling, turning the model inside out, rotation, aligning the bottom of the model on an axis... more precisely setting the model origins, saving as a gm model which is now a buffer containing vertex buffer data and lighting are mainly the main features that I use all the time. The ability to load a d3d models and save it back as obj are also useful... but d3d models are dead in gms2 so I don't see the point of going from a buffer file to obj...

A side feature of my obj loader was also the (automatic) ability to triangulate facets because at the time, less likely now, many models did not come with triangulated facets.

>The window size is currently locked to 1600x900, but enabling the user to resize it shouldn't be too challenging. I'll add this to the next update
You definitely want that!
 
Last edited by a moderator:

TheSnidr

Heavy metal viking dentist
GMC Elder
Yep, scaling, turning the model inside out, rotation, aligning the bottom of the model on an axis... more precisely setting the model origins, saving as a gm model which is now a buffer containing vertex buffer data and lighting are mainly the main features that I use all the time. The ability to load a d3d models and save it back as obj are also useful... but d3d models are dead in gms2 so I don't see the point of going from a buffer file to obj...

A side feature of my obj loader was also the (automatic) ability to triangulate facets because at the time, less likely now, many models did not come with triangulated facets.
With the exception of d3d format support and aligning a model to an axis, all those are already in the model tool! :)
 
G

GproKaru

Guest
You are a legend. Your 3D animation extension has convinced me to finally buy GMS2 while I was actively avoiding GMS2 after having a horrible time with the beta.
I can't wait to see what I can whip up now in GMS2 since I was able to do stuff like this in GMS1:

https://steamuserimages-a.akamaihd....307/697041814E46B8B872F6063819F21741CE6A686C/

https://steamuserimages-a.akamaihd....926/74EBEF27052F76D418B88742193A4CC3E2785BBE/

http://cloud-3.steamusercontent.com/ugc/401180373444644692/458F27B211A9928F5A862E064E6A1DA76774CF44/

 
M

Misty

Guest
You are a legend. Your 3D animation extension has convinced me to finally buy GMS2 while I was actively avoiding GMS2 after having a horrible time with the beta.
Hmm. How do I play your Steam games?
 
G

GproKaru

Guest
I have a suggestion. I was wondering if there will eventually be a feature to allow bones to be extended or contracted when making animations? So far there only seems options to bend bones or move them all bones at once.

[edit] One more suggestion. Would it be possible to copy/paste keyframes and insert frames from other previous animations into new ones?

Hmm. How do I play your Steam games?
I currently don't have any of my projects on steam as none of them have been completed yet.
 
Last edited by a moderator:

TheSnidr

Heavy metal viking dentist
GMC Elder
I have a suggestion. I was wondering if there will eventually be a feature to allow bones to be extended or contracted when making animations? So far there only seems options to bend bones or move them all bones at once.

[edit] One more suggestion. Would it be possible to copy/paste keyframes and insert frames from other previous animations into new ones?
I use dual quaternions for bone orientations, which is excellent for rigid transformations - but they do not allow for stretching or scaling. So that's impossible, unless you convert the engine to use matrices instead. You can do a limited stretching by detaching a bone and moving it, like I did in this .gif: https://dl.dropboxusercontent.com/u/41252865/Images/Animation/FatLink.gif

I like your copy/paste suggestion! It would be limited to animations on the same rig, but it's definitely something I'm gonna add.

Your game looks amazing, I look forward to seeing what you'll be able to make in GMS 2!
 

lolslayer

Member
You are a legend. Your 3D animation extension has convinced me to finally buy GMS2 while I was actively avoiding GMS2 after having a horrible time with the beta.
I can't wait to see what I can whip up now in GMS2 since I was able to do stuff like this in GMS1:
To be honest, it isn't because of GMS2 that this is possible, TheSnidr just didn't port it over to GMS1 (which I'm planning to do with a friend of mine)

Nice looking game though :)
 
G

GproKaru

Guest
I like your copy/paste suggestion! It would be limited to animations on the same rig, but it's definitely something I'm gonna add.

Your game looks amazing, I look forward to seeing what you'll be able to make in GMS 2!
Another question, is it possible to manually get/set the position and rotation of a bone within game maker? Things like held props would require rigging for each model type without being able to get bone pos/rot data, and things like head tracking aren't possible without being able to adjust the mesh's head bone.

One other idea that came to mind earlier today while making some animations was a mirror on x/y/z axis feature. Just a button for each axis that mirros the entire animation along the chosen global axis.

Also, thanks for the compliment on my project. But I still gotta thank you for this great tool and I can't wait to see it grow into something even greater as time goes on!
 

TheSnidr

Heavy metal viking dentist
GMC Elder
Another question, is it possible to manually get/set the position and rotation of a bone within game maker? Things like held props would require rigging for each model type without being able to get bone pos/rot data, and things like head tracking aren't possible without being able to adjust the mesh's head bone.
I've been planning to add the posibility to get a bone's orientation, but I didn't get around to adding it before getting sick of looking at my own code xD
It's pretty easy once you've created a sample. Multiply the sample dual quaternion with the bind pose dual quaternion, and use the result to transform the prop. I don't expect people to learn how to work with dual quaternions just to use this engine though, so I'll add some wrapper scripts for this process.

Setting a bone's orientation is trickier. If you edit the sample directly, you'll only move that single bone without affecting the rest of the hierarchy. The change has to happen somewhere before creating the sample. I'll look into a solution to this.
One other idea that came to mind earlier today while making some animations was a mirror on x/y/z axis feature. Just a button for each axis that mirros the entire animation along the chosen global axis.
I've thought about that too, but it'll require soo much work from my part! I just don't think it's worth it :p

EDIT:
Here's the script that lets you get a bone's current orientation:
Code:
/// @description smf_sample_get_bone_orientation(animationIndex, sample, boneIndex)
/// @param animationIndex
/// @param sample
/// @param boneIndex
/*
Returns the dual quaternion of the given bone
*/
var bindPose, bone, sample, R, S, Q, j;
bindPose = SMF_bindList[| argument0];
sample = argument1;
bone = argument2;
S = bindPose[| bone];
R[7] = 0;
for (j = 0; j < 8; j ++){
    R[j] = sample[bone * 8 + j];}
Q[0] = R[3] * S[0] + R[0] * S[3] + R[1] * S[2] - R[2] * S[1];
Q[1] = R[3] * S[1] + R[1] * S[3] + R[2] * S[0] - R[0] * S[2];
Q[2] = R[3] * S[2] + R[2] * S[3] + R[0] * S[1] - R[1] * S[0];
Q[3] = R[3] * S[3] - R[0] * S[0] - R[1] * S[1] - R[2] * S[2];
Q[4] = R[3] * S[4] + R[0] * S[7] + R[1] * S[6] - R[2] * S[5] + R[7] * S[0] + R[4] * S[3] + R[5] * S[2] - R[6] * S[1];
Q[5] = R[3] * S[5] + R[1] * S[7] + R[2] * S[4] - R[0] * S[6] + R[7] * S[1] + R[5] * S[3] + R[6] * S[0] - R[4] * S[2];
Q[6] = R[3] * S[6] + R[2] * S[7] + R[0] * S[5] - R[1] * S[4] + R[7] * S[2] + R[6] * S[3] + R[4] * S[1] - R[5] * S[0];
Q[7] = R[3] * S[7] - R[0] * S[4] - R[1] * S[5] - R[2] * S[6] + R[7] * S[3] - R[4] * S[0] - R[5] * S[1] - R[6] * S[2];
return Q;
You can use smf_matrix_create_from_dualquat on the result to get a transformation matrix that can be used to transform your prop. Notice that you need to supply the bone index. You can find the bone index in the editor by pressing "Toggle bone indices" in the upper left corner.
I will include a demonstration on how to use this properly in the next release of the engine.
 
Last edited:
G

GproKaru

Guest
Setting a bone's orientation is trickier. If you edit the sample directly, you'll only move that single bone without affecting the rest of the hierarchy. The change has to happen somewhere before creating the sample. I'll look into a solution to this.

I've thought about that too, but it'll require soo much work from my part! I just don't think it's worth it :p
That's all good, I kind of figured it might be a bit difficult to set up.

You can use smf_matrix_create_from_dualquat on the result to get a transformation matrix that can be used to transform your prop. Notice that you need to supply the bone index. You can find the bone index in the editor by pressing "Toggle bone indices" in the upper left corner.
I will include a demonstration on how to use this properly in the next release of the engine.
With your code and some trial and error, I figured it out. I made a new script called "scr_GetBonePos", placed your code inside it and at the end, replaced "return Q;" with "return smf_matrix_create_from_dualquat(Q);".
I assigned the result to a variable "Prop_Matrix" and then using matrix_multiply(Prop_Matrix, Character_Matrix); to combine my character's matrix with the bones matrix creates a 1:1 origin point. Thanks! :D

I also added another matrix_multiply just so I also can further manipulate the prop on that point. Currently just to scale it down.
Code:
Pos = scr_GetBonePos(anim,anim_final,5);
var scale_multi = 0.2;
var origin = matrix_multiply(Pos, main_matr);
var matr = matrix_multiply(matrix_build(0, 0, 0, 0, 0, 0, scale_multi, scale_multi, scale_multi), origin);

shader_set(sh_smf_passthrough);
matrix_set(matrix_world, matr);
smf_model_draw(RightHand_Prop, sprite_get_texture(RightHand_Prop_Texture, 0));
shader_reset();
matrix_set(matrix_world, matrix_build_identity());
This is the results (excuse my terrible placeholder models). Basically getting the cube to follow the character's hand as if they are carrying it. Works like a charm! :D
https://www.dropbox.com/s/lij20l8zbqmrkh0/handcube.gif?dl=0

[edit]
One other thing I'm noticing is that sometimes my project will have inconsistent performance issues. sometimes my project will average a fairly low fps around the 160-250fps range. I'm trying to track down what the issue could possibly be but it seems to be connected to smf_sample_create. When I comment out that function it seem to take me back to 1700+fps. I'll keep looking into it to see what I can find.

[edit 2]
Now this has me baffled. I've noticed that increasing the games overall FPS setting seems to at least increase performance, but I find it bizarre that there is less impact from the script when doing so. I get 60-250fps at 120fps setting, yet I get around 1000-1700+ fps at the 9999fps setting.

Not sure what's happening there but you would think increasing the game speed wouldn't actually increase performance. Just seems like the script is working around or within the set game fps range.
 
Last edited by a moderator:

TheSnidr

Heavy metal viking dentist
GMC Elder
That looks absolutely incredible! Smooth animations and amazing landing transition. Looks like you managed the prop holding perfectly. Good job!
I honestly have no idea why the speed of the script depends on the gamespeed o.o That's kinda nice though, wish it was always like that! "Does your game run slowly? Simply increase the game speed!"

EDIT:
What you can do if the sample generation script is bothering you, is to precompute the animation as frames. The sample is just an array, it can be stored in another array like so:
Code:
for (var i = 0; i < num; i ++)
{
    walkSample[i] = smf_create_sample(aniWalk, SMF_loop_quadratic, i / num);
}
EDIT2:
The performance issues aren't related to just this project it seems:
https://forum.yoyogames.com/index.php?threads/losing-fps-on-larger-projects.27287/
 
Last edited:
G

GproKaru

Guest
I figured out that I might as well just work around 10 times the normal game speed I'm used to. I'm defaulting to 1200 fps instead of 120 so it'll be fairly easy to work within the same bounds I'm used to.
I just bring any time based math code down by one decimal (instead of: x += 10, I use: x += 0.1) and it acts just like it used to but still grants me a flawless framerate.

My only concern is that I knew of a previous issue (which I don't know if it exists in GMS2) that if you set your game's speed/fps too high, it could accidentally skip some coding at times. So far that issue hasn't been present but I shouldn't let my guard down about it either.

[edit]
Another question, is it possible to stop an animation from looping? I noticed that you had incorporated some features in there that seem like they should work when applied to smf_sample_create ( SMF_play_linear and SMF_play_quadratic ) but the animation still seems to loop no matter which setting I apply.

[edit 2]
I made a work around. Everytime the animation changes, I just set the animation frame counter back to 0 and for animations I want to stop looping, I use an if backet to stop it.:
Code:
if (anim != prev_anim && switchAnimationProgress == 0)
{
   //If we've recently changed animation index, interpolate smoothly between them
   switchAnimationProgress = 1;
   prev_anim_final = anim_final;
   anim_frame = 0;
}

if(anim == animLanding) { if(anim_frame < 19) { anim_frame += 0.04; }}
else { anim_frame += 0.0345; }

anim_final = smf_sample_create(anim, SMF_loop_quadratic, frac(anim_frame / 20));
I would of thought that 0 - 1 was the full length for animations, but it's actually 0 - 19. Regardless, it got the job done! :D
 
Last edited by a moderator:
Top