The AvatarCanvas class (used within the Entry class) provides a high-level API for constructing and rendering character avatars (paper dolls).
Key capabilities include:
- Loading Assets: Use
LoadZ(), LoadActions(), and LoadEmotions() to prepare the canvas with WZ data. - Adding Parts: Use
AddPart(Wz_Node node) to add specific image nodes (e.g., hair, face, clothing) to the avatar. - Frame Management:
GetActionFrames(string actionName): Retrieves the sequence of frames for a specific animation.GetFaceFrames(string emotionName): Retrieves frames for a specific facial emotion.CreateFrame(ActionFrame frame, Wz_Node faceFrame, Wz_Node weapon): Creates a composite frame structure.DrawFrame(Bone bone): Renders the composite frame into a bitmap.
- Animation Generation: The canvas can be used to generate
Gif objects by iterating through action frames and combining them with facial expressions.
AvatarCanvas canvas = new AvatarCanvas();
canvas.LoadZ();
canvas.LoadActions();
canvas.LoadEmotions();
// Add character parts
canvas.AddPart(PluginManager.FindWz("Character\\00002000.img"));
canvas.AddPart(PluginManager.FindWz("Character\\Face\\00020000.img"));
// Set current state
canvas.ActionName = "stand1";
canvas.EmotionName = "shine";
// Retrieve and render frames
var actionFrames = canvas.GetActionFrames("stand1");
foreach (var frame in actionFrames)
{
var bone = canvas.CreateFrame(frame, null, null);
var bmp = canvas.DrawFrame(bone);
// bmp.Bitmap contains the rendered frame
}