// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild (function (root, factory) { if (typeof define === 'function' && define.amd) { define(['kaitai-struct/KaitaiStream'], factory); } else if (typeof module === 'object' && module.exports) { module.exports = factory(require('kaitai-struct/KaitaiStream')); } else { root.RFLResource = factory(root.KaitaiStream); } }(typeof self !== 'undefined' ? self : this, function (KaitaiStream) { var RFLResource = (function() { RFLResource.GXPrimitive = Object.freeze({ QUADS: 128, TRIANGLES: 144, TRIANGLESTRIP: 152, TRIANGLEFAN: 160, LINES: 168, LINESTRIP: 176, POINTS: 184, 128: "QUADS", 144: "TRIANGLES", 152: "TRIANGLESTRIP", 160: "TRIANGLEFAN", 168: "LINES", 176: "LINESTRIP", 184: "POINTS", }); RFLResource.RflIArcId = Object.freeze({ BEARD: 0, EYE: 1, EYEBROW: 2, FACELINE: 3, FACE_TEX: 4, FORE_HEAD: 5, GLASS: 6, GLASS_TEX: 7, HAIR: 8, MASK: 9, MOLE: 10, MOUTH: 11, MUSTACHE: 12, NOSE: 13, NLINE: 14, NLINE_TEX: 15, CAP: 16, CAP_TEX: 17, MAX: 18, 0: "BEARD", 1: "EYE", 2: "EYEBROW", 3: "FACELINE", 4: "FACE_TEX", 5: "FORE_HEAD", 6: "GLASS", 7: "GLASS_TEX", 8: "HAIR", 9: "MASK", 10: "MOLE", 11: "MOUTH", 12: "MUSTACHE", 13: "NOSE", 14: "NLINE", 15: "NLINE_TEX", 16: "CAP", 17: "CAP_TEX", 18: "MAX", }); function RFLResource(_io, _parent, _root) { this._io = _io; this._parent = _parent; this._root = _root || this; this._read(); } RFLResource.prototype._read = function() { this.totalArchiveCount = this._io.readU2be(); this.version = this._io.readU2be(); this.offsets = []; for (var i = 0; i < this.totalArchiveCount; i++) { this.offsets.push(this._io.readU4be()); } } var RFLiTexture = RFLResource.RFLiTexture = (function() { function RFLiTexture(_io, _parent, _root) { this._io = _io; this._parent = _parent; this._root = _root || this; this._read(); } RFLiTexture.prototype._read = function() { this.format = this._io.readU1(); this.alpha = this._io.readU1(); this.width = this._io.readU2be(); this.height = this._io.readU2be(); this.wrapS = this._io.readU1(); this.wrapT = this._io.readU1(); this.indexTexture = this._io.readU1(); this.colorFormat = this._io.readU1(); this.numColors = this._io.readU2be(); this.paletteOfs = this._io.readU4be(); this.enableLod = this._io.readU1(); this.enableEdgeLod = this._io.readU1(); this.enableBiasClamp = this._io.readU1(); this.enableMaxAniso = this._io.readU1(); this.minFilt = this._io.readU1(); this.magFilt = this._io.readU1(); this.minLod = this._io.readS1(); this.maxLod = this._io.readS1(); this.mipmapLevel = this._io.readU1(); this.reserved = this._io.readS1(); this.lodBias = this._io.readS2be(); this.imageOfs = this._io.readU4be(); } return RFLiTexture; })(); var Vertex = RFLResource.Vertex = (function() { function Vertex(_io, _parent, _root) { this._io = _io; this._parent = _parent; this._root = _root || this; this._read(); } Vertex.prototype._read = function() { this.posIdx = this._io.readU1(); this.nrmIdx = this._io.readU1(); if (!(this._parent._parent.skipTxc)) { this.texIdx = this._io.readU1(); } } return Vertex; })(); /** * NOTE: Untyped. Custom type. * Real data is loaded from "res" in RFLiInitShapeRes */ var RFLiShape = RFLResource.RFLiShape = (function() { function RFLiShape(_io, _parent, _root) { this._io = _io; this._parent = _parent; this._root = _root || this; this._read(); } RFLiShape.prototype._read = function() { this.identifier = KaitaiStream.bytesToStr(this._io.readBytes(4), "ascii"); if (this.isFaceline) { this.noseTrans = []; for (var i = 0; i < 3; i++) { this.noseTrans.push(this._io.readF4be()); } } if (this.isFaceline) { this.beardTrans = []; for (var i = 0; i < 3; i++) { this.beardTrans.push(this._io.readF4be()); } } if (this.isFaceline) { this.hairTrans = []; for (var i = 0; i < 3; i++) { this.hairTrans.push(this._io.readF4be()); } } this.numVtxPos = this._io.readU2be(); this.vtxPos = []; for (var i = 0; i < (this.numVtxPos * 3); i++) { this.vtxPos.push(this._io.readU2be()); } this.numVtxNrm = this._io.readU2be(); this.vtxNrm = []; for (var i = 0; i < (this.numVtxNrm * 3); i++) { this.vtxNrm.push(this._io.readU2be()); } if (!(this.skipTxc)) { this.numVtxTxc = this._io.readU2be(); } if (!(this.skipTxc)) { this.vtxTxc = []; for (var i = 0; i < (this.numVtxTxc * 2); i++) { this.vtxTxc.push(this._io.readU2be()); } } this.primCount = this._io.readU1(); this.primitives = []; for (var i = 0; i < this.primCount; i++) { this.primitives.push(new Primitive(this._io, this, this._root)); } } Object.defineProperty(RFLiShape.prototype, 'skipTxc', { get: function() { if (this._m_skipTxc !== undefined) return this._m_skipTxc; this._m_skipTxc = ((this.identifier == "frhd") || (this.identifier == "hair") || (this.identifier == "berd") || (this.identifier == "nose")) ; return this._m_skipTxc; } }); Object.defineProperty(RFLiShape.prototype, 'isFaceline', { get: function() { if (this._m_isFaceline !== undefined) return this._m_isFaceline; this._m_isFaceline = this.identifier == "face"; return this._m_isFaceline; } }); /** * 4-byte identifier, unused by RFL. * 'nose', 'frhd', 'face', 'hair', 'cap_', 'berd', 'nsln', 'mask', 'glas' * https://github.com/SMGCommunity/Petari/blob/6b6a7635d3ab985a5866be9ae4db09d52d678f6c/src/RVLFaceLib/RFL_Model.c#L835 */ return RFLiShape; })(); var RFLiArchive = RFLResource.RFLiArchive = (function() { function RFLiArchive(_io, _parent, _root) { this._io = _io; this._parent = _parent; this._root = _root || this; this._read(); } RFLiArchive.prototype._read = function() { this.num = this._io.readU2be(); this.maxsize = this._io.readU2be(); this.offset = []; for (var i = 0; i < (this.num + 1); i++) { this.offset.push(this._io.readU4be()); } } /** * Number of files in the archive. */ /** * Size of the biggest entry in the archive. */ /** * Offsets of each part in the archive. */ return RFLiArchive; })(); /** * Image width and height are calculated by * getting the next power of two. In JS: * const nextPow2 = x => x <= 1 ? 1 : 1 << (32 - Math.clz32(x - 1)); */ var CFLiTexHeader = RFLResource.CFLiTexHeader = (function() { function CFLiTexHeader(_io, _parent, _root) { this._io = _io; this._parent = _parent; this._root = _root || this; this._read(); } CFLiTexHeader.prototype._read = function() { this.imageW = this._io.readU2be(); this.imageH = this._io.readU2be(); this.mMipmapSize = this._io.readU1(); this.mFormat = this._io.readU1(); this.mWrapS = this._io.readU1(); this.mWrapT = this._io.readU1(); } return CFLiTexHeader; })(); var Primitive = RFLResource.Primitive = (function() { function Primitive(_io, _parent, _root) { this._io = _io; this._parent = _parent; this._root = _root || this; this._read(); } Primitive.prototype._read = function() { this.vtxCount = this._io.readU1(); this.primType = this._io.readU1(); this.vertices = []; for (var i = 0; i < this.vtxCount; i++) { this.vertices.push(new Vertex(this._io, this, this._root)); } } return Primitive; })(); Object.defineProperty(RFLResource.prototype, 'archive4', { get: function() { if (this._m_archive4 !== undefined) return this._m_archive4; var _pos = this._io.pos; this._io.seek(this.offsets[4]); this._m_archive4 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive4; } }); Object.defineProperty(RFLResource.prototype, 'archive18', { get: function() { if (this._m_archive18 !== undefined) return this._m_archive18; var _pos = this._io.pos; this._io.seek(this.offsets[18]); this._m_archive18 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive18; } }); Object.defineProperty(RFLResource.prototype, 'archive9', { get: function() { if (this._m_archive9 !== undefined) return this._m_archive9; var _pos = this._io.pos; this._io.seek(this.offsets[9]); this._m_archive9 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive9; } }); Object.defineProperty(RFLResource.prototype, 'archive16', { get: function() { if (this._m_archive16 !== undefined) return this._m_archive16; var _pos = this._io.pos; this._io.seek(this.offsets[16]); this._m_archive16 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive16; } }); Object.defineProperty(RFLResource.prototype, 'archive3shape1', { get: function() { if (this._m_archive3shape1 !== undefined) return this._m_archive3shape1; var _pos = this._io.pos; this._io.seek((((8 + this.offsets[3]) + (this.archive3.num * 4)) + 1619)); this._m_archive3shape1 = new RFLiShape(this._io, this, this._root); this._io.seek(_pos); return this._m_archive3shape1; } }); Object.defineProperty(RFLResource.prototype, 'archive8shape33', { get: function() { if (this._m_archive8shape33 !== undefined) return this._m_archive8shape33; var _pos = this._io.pos; this._io.seek((((8 + this.offsets[8]) + (this.archive8.num * 4)) + 73511)); this._m_archive8shape33 = new RFLiShape(this._io, this, this._root); this._io.seek(_pos); return this._m_archive8shape33; } }); Object.defineProperty(RFLResource.prototype, 'archive1shape1', { get: function() { if (this._m_archive1shape1 !== undefined) return this._m_archive1shape1; var _pos = this._io.pos; this._io.seek((((8 + this.offsets[0]) + (this.archive0.num * 4)) + 9)); this._m_archive1shape1 = new RFLiShape(this._io, this, this._root); this._io.seek(_pos); return this._m_archive1shape1; } }); Object.defineProperty(RFLResource.prototype, 'archive1', { get: function() { if (this._m_archive1 !== undefined) return this._m_archive1; var _pos = this._io.pos; this._io.seek(this.offsets[1]); this._m_archive1 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive1; } }); Object.defineProperty(RFLResource.prototype, 'archive6', { get: function() { if (this._m_archive6 !== undefined) return this._m_archive6; var _pos = this._io.pos; this._io.seek(this.offsets[6]); this._m_archive6 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive6; } }); Object.defineProperty(RFLResource.prototype, 'archive12', { get: function() { if (this._m_archive12 !== undefined) return this._m_archive12; var _pos = this._io.pos; this._io.seek(this.offsets[12]); this._m_archive12 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive12; } }); Object.defineProperty(RFLResource.prototype, 'archive0', { get: function() { if (this._m_archive0 !== undefined) return this._m_archive0; var _pos = this._io.pos; this._io.seek(this.offsets[0]); this._m_archive0 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive0; } }); Object.defineProperty(RFLResource.prototype, 'archive13', { get: function() { if (this._m_archive13 !== undefined) return this._m_archive13; var _pos = this._io.pos; this._io.seek(this.offsets[13]); this._m_archive13 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive13; } }); Object.defineProperty(RFLResource.prototype, 'archive10', { get: function() { if (this._m_archive10 !== undefined) return this._m_archive10; var _pos = this._io.pos; this._io.seek(this.offsets[10]); this._m_archive10 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive10; } }); Object.defineProperty(RFLResource.prototype, 'archive11', { get: function() { if (this._m_archive11 !== undefined) return this._m_archive11; var _pos = this._io.pos; this._io.seek(this.offsets[11]); this._m_archive11 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive11; } }); Object.defineProperty(RFLResource.prototype, 'archive8', { get: function() { if (this._m_archive8 !== undefined) return this._m_archive8; var _pos = this._io.pos; this._io.seek(this.offsets[8]); this._m_archive8 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive8; } }); Object.defineProperty(RFLResource.prototype, 'archive1texture0', { get: function() { if (this._m_archive1texture0 !== undefined) return this._m_archive1texture0; var _pos = this._io.pos; this._io.seek(((8 + this.offsets[1]) + (this.archive1.num * 4))); this._m_archive1texture0 = new CFLiTexHeader(this._io, this, this._root); this._io.seek(_pos); return this._m_archive1texture0; } }); Object.defineProperty(RFLResource.prototype, 'archive7', { get: function() { if (this._m_archive7 !== undefined) return this._m_archive7; var _pos = this._io.pos; this._io.seek(this.offsets[7]); this._m_archive7 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive7; } }); Object.defineProperty(RFLResource.prototype, 'archive19', { get: function() { if (this._m_archive19 !== undefined) return this._m_archive19; var _pos = this._io.pos; this._io.seek(this.offsets[19]); this._m_archive19 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive19; } }); Object.defineProperty(RFLResource.prototype, 'archive3', { get: function() { if (this._m_archive3 !== undefined) return this._m_archive3; var _pos = this._io.pos; this._io.seek(this.offsets[3]); this._m_archive3 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive3; } }); Object.defineProperty(RFLResource.prototype, 'archive17', { get: function() { if (this._m_archive17 !== undefined) return this._m_archive17; var _pos = this._io.pos; this._io.seek(this.offsets[17]); this._m_archive17 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive17; } }); Object.defineProperty(RFLResource.prototype, 'archive15', { get: function() { if (this._m_archive15 !== undefined) return this._m_archive15; var _pos = this._io.pos; this._io.seek(this.offsets[15]); this._m_archive15 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive15; } }); Object.defineProperty(RFLResource.prototype, 'archives', { get: function() { if (this._m_archives !== undefined) return this._m_archives; var _pos = this._io.pos; this._io.seek(this.offsets[i]); this._m_archives = []; for (var i = 0; i < this.totalArchiveCount; i++) { this._m_archives.push(new RFLiArchive(this._io, this, this._root)); } this._io.seek(_pos); return this._m_archives; } }); Object.defineProperty(RFLResource.prototype, 'archive5', { get: function() { if (this._m_archive5 !== undefined) return this._m_archive5; var _pos = this._io.pos; this._io.seek(this.offsets[5]); this._m_archive5 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive5; } }); Object.defineProperty(RFLResource.prototype, 'archive14', { get: function() { if (this._m_archive14 !== undefined) return this._m_archive14; var _pos = this._io.pos; this._io.seek(this.offsets[14]); this._m_archive14 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive14; } }); Object.defineProperty(RFLResource.prototype, 'archive2', { get: function() { if (this._m_archive2 !== undefined) return this._m_archive2; var _pos = this._io.pos; this._io.seek(this.offsets[2]); this._m_archive2 = new RFLiArchive(this._io, this, this._root); this._io.seek(_pos); return this._m_archive2; } }); /** * Amount of total archives within the file. * RFL = 18 (RFLiArcID_Max), NFL = 20 (?), CFL = 20 (CFLi_PARTS_ID_COUNT) */ /** * Resource version. Set in RFL and CFL, only seen used in CFL debug mode. * CFL bootloadDB2Res_: nn::dbg::detail::Printf("CFL: Cached Resource Version = 0x%04x\n"); * / Debug assert; "cfl_resource.cpp",0x19d,"%s", "loader->mVersion >= 0x509" */ /** * Offsets for each part type. */ return RFLResource; })(); return RFLResource; }));