Skip to content

Latest commit

 

History

History
129 lines (102 loc) · 5.54 KB

BLENDER.md

File metadata and controls

129 lines (102 loc) · 5.54 KB

The models in Blender

Run browse with the Models box ticked (or --kinds models on the command line) and every .lex model on the disc becomes a .glb file under browse/models/, in the same folders the game uses:

browse/models/chain0/char/pc/kosmos.glb        KOS-MOS, face included
browse/models/chain0/char/pc/kosmos_face.glb   just her face
browse/models/chain0/char/pc/kosmos_h.glb      her alternate outfit
browse/models/chain0/char/npc/andrew.glb       Cherenkov
browse/models/chain0/enemy/… robo/… weapon/… obj/… map/…

Each file carries its texture inside it, so there are no paths to fix up. Drop one into Blender and it just works.

Importing

  1. File ▸ Import ▸ glTF 2.0 and pick the .glb.
  2. Leave the importer settings alone.
  3. Press Z and choose Material Preview so you see the textures.

Blender 2.8 or newer, no add-ons needed.

What you will see

Objects. One per game mesh, named number/group/bone, for example 01/kosmos_mune/kosmos_body. The group is the artist's name for the part; the bone is what it hangs off. Parts that came from a separate face file are prefixed with that file's name.

Materials. Named after the region of the texture they use, like mat3_u256-320_v128-256. They all share one image. Hair materials end in _rgba and eyelashes in _lash; both blend, everything else uses a cut-out alpha.

Vertex colours in the Col attribute. That is the game's baked-in shading tint. If a model looks too dark, unplug the Color Attribute node from Base Color in the material.

An armature named after the character, built from the .jnt skeleton file: the real joint hierarchy in the game's pose, plus the face file's own small skeleton for eyes and mouth. Every bone sits on the mesh, arms and hair included; the skin weights are the game's own, as vertex groups named j<number> for the rotation joints, with the offset, translate and bone-end nodes in between. You can pose the character straight away.

Bone display. Blender's importer gives every bone an icosphere shape, so a 121-bone character looks covered in spiky balls. Select the armature, Properties ▸ Armature ▸ Viewport Display ▸ Display As: Stick (and tick In Front), or in the importer options set Bone Shape to "Blender" before importing.

Scale. The game works in metres, Y up, same as glTF. KOS-MOS stands 1.73 m tall and lands upright on Blender's floor with no scaling.

Which files to open

Folder under browse/models/chain0/ What is in it
char/pc/ the party: kosmos, shion, jr, momo, chaos, ziggy; *1, *2, *_h are alternate outfits; *_face are the face parts (already merged into the body files)
char/npc/ every NPC; Cherenkov is andrew, Albedo is albelt
enemy/, enemy/boss/ enemies and bosses
robo/ the A.G.W.S. mechs
weapon/pc/ weapons
obj/ props
map/ field and battle maps (MC_BTL* are the battle arenas; large)

A body file already includes its companions: anything in the same folder whose name starts with the body's name and has no texture of its own (kosmos_face.lex, kosmos_h_face.lex). The companions are also written on their own, so kosmos_face.glb is there if you only want the head.

Playing the motion

A model whose skeleton has motion clips on the disc comes with them: one action per clip, named after the pack and slot (motion/kosmos_cf#01). Select the armature, open the Dope Sheet in Action Editor mode (or the Animation workspace), pick an action from the list and press Space. Set the scene to 30 frames a second (Output properties ▸ Frame Rate) before importing: each key then lands on a whole frame. The importer turns the file's times into frames at the scene's rate, so at Blender's default of 24 the clips still play at the right speed, but their keys fall between frames. Changing the rate after importing changes the speed. browse attaches the clips made for each skeleton; for one model with chosen clips:

python cli.py model --dump out/dump --path 'char\pc\kosmos.lex' --out kosmos.glb \
       --motion 'motion\kosmos_cf.fpk#1,3'

The legs are baked: the game solves them toward foot targets every frame and the action holds the result, one key per frame. The targets themselves are not in the action. The hair and cloth bones are baked too: the clip does not store them, so the kit runs the game's hair simulation and keys where it puts them. The face is a set of small bones under the head bone and follows it. Details in MOTION.md.

Known gaps

  • Animation has not been compared with the running game. Hair and cloth are baked from a port of the game's simulation; chains the game treats as skirts keep their rest pose, and there is no wind (MOTION.md, "What is not done").
  • Two map meshes use vertex formats the parser skips, and blend shapes are ignored. Anything skipped is listed in the .glb's extras.

From Python

import arx, lex
from browse import decode_xtx, png_bytes

body_lex = arx.decompress(open("out/dump/chain0/char/pc/kosmos.lex", "rb").read())
face_lex = arx.decompress(open("out/dump/chain0/char/pc/kosmos_face.lex", "rb").read())
body = lex.parse_lex(body_lex)
lex.merge_companion(body, lex.parse_lex(face_lex), "kosmos_face/")

xtx = arx.decompress(open("out/dump/chain0/char/pc/kosmos.xtx", "rb").read())
w, h, rgba, _ = decode_xtx(xtx, [body_lex, face_lex])
open("kosmos.glb", "wb").write(lex.to_glb(body, png_bytes(w, h, rgba), (w, h)))

The file format itself is written up in FORMATS.md under "LEX models".