Editing .sim_pc files.

I've been messing around with sim files for the last couple of days and thought i'd share my findings.

I wrote a script for Blender that imports and exports data from a sim file. In order to use it, open it, copy it's contents into Blender's text editor and run it. File selection window should pop up, select the sim file you want to import. What you will get will look something like this:
test.png
Cylindrical objects represent colliders, but they're only imported for visualization sake, the export function will not replace them. All the editable information is stored on the armature object.
From what i understand, physics simulation works in a following way: nodes are attached to dynamic bones of the rig, nodes are joined by links, and linked nodes make up ropes. Game engine runs simulation on those ropes, and then rig bones inherit the result of those simulations.
Each rope is represented by a series of connected bones. Consider each bone a link, and their heads and tails are nodes. Make sure not to disconnect them, cause sim files hold information about the lengths of all links and ropes, and the lengths of links should add up to the length of the rope they make up, else the simulation becomes very wonky.

If you import a model with a rig that uses this sim file, you'll notice that the positions of links match the positions of dynamic bone heads. So if you done some edits on the mesh that required you to adjust the locations of dynamic bones in the rig, make sure to move the links accordingly.

The general simulation parameters can be found in custom properties of the armature object, each individual link-bone has it's own parameters too, found in bone's custom properties. The most important parameters seem to be gravity_multiplier, and spring\damp parameters of each individual link. If you remember high school physics or something, perhaps it will be obvious to you how to achieve the behavior you want. Me, i had to do a lot of trial and error, and i still can't say that i really got the hang of it. These videos have some helpful information on the matter.
What i gathered is that damp parameter, which is probably supposed to vary between 0.0 and 1.0, apparently works backwards, as in higher values seem to result in *less* damping. Spring and damp values can be set to -1.0, which makes the simulation behave in a way i wasn't able to replicate with other settings, making a rope more... rope-y, for lack of a better word.
I tried messing around with other parameters too, and while they do make a difference, i can't say that they necessarily work in a way i would have expected them to, or that i can tell what exactly has changed, so i'm not sure what to tell about them.

Once you're done tweaking stuff, select the armature object and run the script again. This time, check the export box and select the same file you initially imported. That will create a new sim file with the same name + .out extension. And that's it.

Just in case, adding new nodes\links is not supported, and i haven't even implemented an option to change the indices of bones which nodes attach to, so you still have to use the original rig.
 

Attachments

  • simImportExport.zip
    3.3 KB · Views: 89
Back
Top