Guide · 手引き

Guide to the Ayatsuri2D C ABI

Embedding Ayatsuri2D through its C ABI, step by step: each page covers one part, in the order you meet them. Start with the quick start; the function reference has every call.

Start here

  • Quick startThat is the whole loop: set, update, draw. Everything else in this guide is detail around those three calls.
  • How it worksA model is a rig: parameters you drive, deformers that bend regions, meshes that follow. You set parameters, call update, and read where every vertex ended up.
  • Loading a modelThere are two kinds of file. ay2d_load tells them apart by their first bytes.
  • Each frameSet puts values into the model's inbox. Nothing is evaluated yet, and setting the same parameter twice before an update keeps the newest value.

In depth

  • ThreadsEngines tend to touch a model from three places at once. The ABI is built for that.
  • DrawingAfter an update, ay2d_drawables lists the visible meshes back to front. Draw them in that order.
  • Motions and expressionsMotions are the file's scenes and compositions, plus any you add with ay2d_add_motion3. One motion plays in front at a time: ay2d_motion_play starts a motion.
  • PhysicsThe rig is a set of pendulum chains. Some parameters push them (head angle, body angle) and the swing writes other parameters (hair, accessories).
  • ErrorsEvery call returns a status, a count or a pointer. A failed call changes nothing. ay2d_last_error() says why the last call on your thread failed.
  • Memory and lifetimesThe model owns everything it hands you. You never free anything the ABI returns; ay2d_free releases it all.

Shipping it

  • PerformanceA frame is three calls however big the model is. Never look up ids per frame; do it once at load.
  • From other languagesThe ABI uses only fixed-size integers, float, size_t, char *, a few plain structs and one opaque pointer. No callbacks, no variadic functions, no C++.
  • Building and linkingBuild the library with one command, link it shared or static, and keep only the ay2d_ calls you use in your binary.
  • VersionsAY2D_ABI_VERSION (in the header) and ay2d_abi_version() (in the library) must match. Check once at startup.