Parsing Animation

Hello,

I’ve been working with OpenCV and doing some facial capture experiments, which have resulted in some animation data that I would like to transfer over to Playcanvas.

What would be the proper way of converting a JSON file in my assets into an animation.json.

I tried using an existing animation, dropping in my assets, letting playcanvas convert, then downloaded the JSON and replicated the format… but after uploading back to the editor, it will only see it as a .JSON file, not as an animation.

The request would be one of two options:

  • A way to convert that json into a proper animation file
  • A way to upload the raw data in a txt file and run the parser to generate an animation file.

Any other suggestions?

Thanks!

Also, it would be of help to understand how a blendshape coeficient goes from a single value as seen in 3DS Max or blender, to a its final structure in the JSON file.

Thanks guys!

We don’t currently let you upload json formats for models and animation (because we’d be required to validate the formats to ensure bad uploads didn’t break anything).

You should be able to manually load the data as a json asset and then run it through the engine to create animation assets. If you checkout the animation resource handler on github you should be able to do something like:

var asset = this.app.assets.find("jsonAssetName", "json");
var handler = this.app.loader.getHandler("animation");
var animation = handler.open(asset.getFileUrl(), asset.resource);


// fudge an animation asset
var animAsset = new pc.Asset("My Animation Asset", "animation", {
    file: asset.file
});
animAsset.resource = animation;
animAsset.loaded = true;

It’s a bit of a hack around, and you may not even need to create the actual animation asset if you just need the animation object itself.

1 Like