Make a sprite sheet of a Zpup scene
render_spritesDraws a 3D scene from every direction into one transparent PNG sprite sheet for games, adding poses for walk cycles and an optional JSON frame list for engines.
Instructions
Draws one scene from every side, turned in equal steps about its vertical axis, and lays the pictures out as one transparent PNG sprite sheet for a game: the same object in 4, 8 or 16 directions, all from one scene, so they agree with each other. With poses it draws every direction in every pose, for a walk cycle: one row per direction, one column per pose. With save_to it also writes the frame list next to the PNG as JSON, in the form TexturePacker writes (JSON hash) and Phaser, PixiJS and other engines read. Returns the sheet to look at. Every cell has the scene's own frame, so check that nothing is cut off as the object turns, or pass fit to have the frame set for you. Keep the scene's own view angle for the tilt: rotate x around -30 for a view from above. A scene is plain JSON: { width, height, rotate?, children: [...] } with shapes such as dot, path, ellipse, rect, polygon, box, pyramid, cylinder, cone and hemisphere placed with translate and rotate (degrees). x is right, y is down, z is toward the viewer. Call get_reference once before writing a first scene. The server remembers the last valid scene: a later call can leave scene out to draw it again, or pass changes to edit it.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "render_sprites"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fit | No | Set to true to have the frame set for you: every cell shows the same part of the scene, enlarged so that the drawing fills the cell in the direction and pose where it reaches furthest. Nothing is cut off and no space is wasted, and the scene is not changed. Default false, which uses the scene's own frame. | |
| poses | No | Poses of the scene, for a walk or any other motion: each pose is a list of changes, in the form of changes, applied to the scene on its own, and an empty list is the scene as it is. The sheet then has one row per direction and one column per pose. Give each part that moves an id and put it in a group at its joint, so that a pose only sets rotate: [[], [{ "op": "set", "path": "#leg-front.rotate", "value": { "x": 25 } }, { "op": "set", "path": "#leg-back.rotate", "value": { "x": -25 } }], [], [{ "op": "set", "path": "#leg-front.rotate", "value": { "x": -25 } }, { "op": "set", "path": "#leg-back.rotate", "value": { "x": 25 } }]]. Poses do not build on each other and are not remembered. At most 16, and at most 128 cells in all. | |
| scene | No | The scene: an object with width, height and children (JSON text of the same is accepted). Call get_reference for the full format. Leave it out to use the scene from the last valid call. | |
| changes | No | Edits to the remembered scene (or to scene, when both are passed), applied in order, so that a small fix does not need the whole scene again. Example: [{ "op": "set", "path": "children[2].translate.y", "value": -30 }, { "op": "append", "path": "children", "value": { "type": "dot", "stroke": 8, "color": "#333" } }, { "op": "copy", "path": "#tree", "value": { "id": "tree2", "translate": { "x": 60 }, "scale": 0.7 } }]. After a remove or insert, later items in that list have a different index, so give shapes an id and use "#id" paths. If the result is not valid, nothing is changed. | |
| columns | No | Cells per row. Default: all directions in one row, up to 8. Not used with poses, where a row is one direction. | |
| save_to | No | Absolute path ending in .png to write the sheet to. The frame list is written next to it with the same name ending in .json. | |
| cell_size | No | Longer side of each cell in pixels. Default 128. | |
| directions | No | How many directions to draw, at even steps of a full turn. Default 8. | |
| preview_direction | No | A direction, counted from 0, to send back on its own as a second, larger picture: its poses in a row, to judge the motion from one pose to the next. 2 is the side view when there are 8 directions. |