Log inGet started
Package

bodyRegions.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

bodyRegions

The colour regions of a character body made of one skinned mesh, found from the mesh itself. A body whose meshes are its regions (a hair mesh, a jacket mesh) colours each mesh by name through the avatar's regions; a body that is one mesh with one material (most generated and imported characters) holds every colour in one texture, and bodyRegions finds them there.

Each triangle's colour is what it shows: the base colour texture its material binds, sampled across the triangle, times its vertex colours and the material's base colour. Each triangle's part of the body is the part of the skeleton that moves it, by the humanoid role of its joints: head, torso, arms, hands, legs, feet. The colours are sorted into a few, close ones joined; each run of one colour takes the region of the part of the body it covers, and small runs join the region around them.

RegionCovers
hairwhat covers the head that is not skin: hair, a hood, a hat
eyesa small patch of the face in a colour of its own
topthe chest, the back and the arms: a jacket, a shirt, a cloak
gloveswhat covers the hands that is not skin
trousersthe hips and the legs
shoesthe feet
bodythe skin, and every triangle no other region takes

A second region of one kind is named by its colour (top_brown, hair_grey). A body showing one colour has no region but body.

  • find(body) answers the regions, each with its average colour, its share of the body's surface and its share on each part of the body. It writes nothing.
  • split(body, { dest }) writes a bundle at dest whose one mesh is cut into one mesh per region, each named after its region, skinned to the same skeleton with the same material, and answers the avatar regions naming them.
  • splittable(body) says whether a body is one skinned mesh with a rig.
  • aliases maps the everyday names a person gives a region to the region: jacket and shirt to top, boots to shoes, skin to body; avatar.colour colours every region of that kind with it.

avatar.create cuts a body of one mesh into its regions when it makes an avatar wearing it, writing the cut body inside the avatar, and avatar.colour cuts the body of an avatar made before then.

local bodyRegions = require("@builtin::modules.bodyRegions")
for _, r in bodyRegions.find("/source/chars/hero.bundle").regions do
    print(r.name, r.colour, r.share)
end
local cut = bodyRegions.split("/source/chars/hero.bundle", { dest = "/source/hero.avatar/body.bundle" })
print(cut.bundle.guid, cut.regions.top[1])