@2003scape/rsc-models 中文文档教程

发布于 3年前 浏览 22 项目主页 更新于 3年前

rsc-models

(反)序列化 runescape 经典 3D 模型档案来回 波前 .obj 和 .mtl 文件。 支持自动 UV 展开。 适用于搅拌机导入和导出。 使用 rsc-sprites 转储和打包 纹理。

three.js 模型查看器

模型转储并加载到搅拌机中:

祭坛模型 范围模型 火模型 chest model

从 blender 导出并加载到游戏中的模型:

n64 桌模型 yoshi and gnome trees

install

$ npm install @2003scape/rsc-models # -g for CLI program

cli usage

rsc-models <command>

Commands:
  rsc-models dump-obj <config> <archive>    dump model OBJs from models jag
                                            archive
  rsc-models pack-obj <config> <archive>    pack model OBJ(s) into models jag
  <files..>                                 archive

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
$ rsc-models dump-obj config85.jag models36.jag -o models36-obj/
$ rsc-models pack-obj config85.jag models37.jag yoshi.obj n64.obj

example

const fs = require('fs');
const { Config } = require('@2003scape/rsc-config');
const { Models } = require('@2003scape/rsc-models');

const config = new Config();
config.loadArchive(fs.readFileSync('./config85.jag'));

const models = new Models(config);
models.loadArchive(fs.readFileSync('./models36.jag'));

// dumping wavefront
const tree = models.getModelByName('tree');

fs.writeFileSync('./tree.obj', tree.getObj());
fs.writeFileSync('./tree.mtl', tree.getMtl());

// loading external wavefront
const yoshi = models.fromWavefront(
    fs.readFileSync('./yoshi.obj', 'utf8'),
    fs.readFileSync('./yoshi.mtl', 'utf8')
);

models.setModel('tree', yoshi);

fs.writeFileSync('./models37.jag', models.toArchive());

api

models = new Models({ objects, textures }, extraNames = ANIMATED_MODELS)

创建一个新的模型(反)序列化器实例。 extraNames 是一个模型数组 未存储在配置存档的对象缓存中的名称。

models.loadArchive(buffer)

加载模型 jag 存档缓冲区。

model.modelNames

有效模型名称数组。

models.getModels()

返回所有 Model 实例的数组。

models.getModelByName(name)

按名称返回一个 Model 实例(定义在 rsc-config)。

models.getModelById(id)

根据模型名称的索引返回一个 Model 实例。

models.fromWavefront(objFile, mtlFile)

从 wavefront .obj 和 .mtl 文件字符串返回一个 Model 实例。

models.toArchive()

返回模型 jag 存档缓冲区。

model = new Model({ textureNames }, { name, vertices, faces }?)

创建一个新模型,可以是空的,也可以使用现有属性。

model.name

要在存档中使用的 ob3 文件的名称(不带扩展名)。

model.vertices

{ x, y, z } 整数数组。

model.faces

[
    {
        // front face material
        fillFront: {
            i: 1, // illumination, 0 or 1
            r, g, b, // (0-248) each channel, or
            texture: textureIndex // from rsc-config
        } // or null,
        fillBack: null, // same format as fillFront, or null
        vertices: [] // array of vertex indexes (defined above)
    }
]

model.updateFillIDs()

遍历 model.faces 并更新材料以生成 .mtl 文件。

model.getObj()

以 wavefront .obj 格式返回模型几何字符串。

model.getMtl()

以 wavefront .mtl 格式返回模型材料字符串。

model.toJSON()

返回公共可序列化属性。

ANIMATED_MODELS

不在配置存档中的硬编码模型名称数组。

model bugs

以下模型的面少于三个顶点:

  • logbridgelow
  • logbridgehigh
  • logbridgecurvedhigh
  • logbridgecurvedlow
  • treeplatformlow2
  • treeplatformhigh2
  • stonestand
  • grand tree-lev 0
  • tribalstature
  • grand tree-lev 1
  • grand tree-lev 2
  • fourwayplatform-lev 0
  • fourwayplatform-lev 1
  • grand tree-lev 3
  • blurberrybar
  • cave snaptrap
  • cave snaptrapa
  • rocksteps

还有 25 个从未加载到游戏中的秘密模型(散列):

  • 1037362809
  • -1060436729
  • -1115958269
  • -1220733691
  • 1227393374
  • -1263331649
  • 1347842162
  • -1430585029
  • 1512310831
  • 1526156672
  • 1540002513
  • 1657318544
  • 1721021053
  • 2142891767
  • -380606436
  • 515450526
  • 529296367
  • 538300861
  • 550294861
  • 564140702
  • 587507422
  • -669716258
  • -741690938
  • 763644315
  • 846098451

license

版权所有 2022 2003Scape Team

该程序是免费软件:您可以重新分发它和/或修改它 GNU Affero 通用公共许可证的条款由 自由软件基金会,许可证的第 3 版,或(由您选择) 任何更高版本。

分发该程序是希望它有用,但没有任何 保修单; 甚至没有适销性或适用性的默示保证 特殊用途。 有关详细信息,请参阅 GNU Affero 通用公共许可证。

您应该已经收到 GNU Affero 通用公共许可证的副本 有了这个程序。 如果没有,请参阅 http://www.gnu.org/licenses/。

rsc-models

(de)serialize runescape classic 3D model archives to and from wavefront .obj and .mtl files. supports automatic UV unwrapping. works with blender import and export. use rsc-sprites to dump and pack textures.

three.js model viewer

models dumped and loaded into blender:

altar model range model fire model chest model

models exported from blender and loaded into the game:

n64 table model yoshi and gnome trees

install

$ npm install @2003scape/rsc-models # -g for CLI program

cli usage

rsc-models <command>

Commands:
  rsc-models dump-obj <config> <archive>    dump model OBJs from models jag
                                            archive
  rsc-models pack-obj <config> <archive>    pack model OBJ(s) into models jag
  <files..>                                 archive

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
$ rsc-models dump-obj config85.jag models36.jag -o models36-obj/
$ rsc-models pack-obj config85.jag models37.jag yoshi.obj n64.obj

example

const fs = require('fs');
const { Config } = require('@2003scape/rsc-config');
const { Models } = require('@2003scape/rsc-models');

const config = new Config();
config.loadArchive(fs.readFileSync('./config85.jag'));

const models = new Models(config);
models.loadArchive(fs.readFileSync('./models36.jag'));

// dumping wavefront
const tree = models.getModelByName('tree');

fs.writeFileSync('./tree.obj', tree.getObj());
fs.writeFileSync('./tree.mtl', tree.getMtl());

// loading external wavefront
const yoshi = models.fromWavefront(
    fs.readFileSync('./yoshi.obj', 'utf8'),
    fs.readFileSync('./yoshi.mtl', 'utf8')
);

models.setModel('tree', yoshi);

fs.writeFileSync('./models37.jag', models.toArchive());

api

models = new Models({ objects, textures }, extraNames = ANIMATED_MODELS)

create a new models (de)serializer instance. extraNames are an array of model names that aren't stored in the config archive's objects cache.

models.loadArchive(buffer)

loads a models jag archive buffer.

model.modelNames

array of valid model names.

models.getModels()

return an array of all Model instances.

models.getModelByName(name)

return a Model instance by name (defined in rsc-config).

models.getModelById(id)

return a Model instance based on index of model name.

models.fromWavefront(objFile, mtlFile)

return a Model instance from wavefront .obj and .mtl file strings.

models.toArchive()

return a models jag archive buffer.

model = new Model({ textureNames }, { name, vertices, faces }?)

create a new model, either empty or using existing properies.

model.name

name of ob3 file to use in archive (without extension).

model.vertices

array of { x, y, z } integers.

model.faces

[
    {
        // front face material
        fillFront: {
            i: 1, // illumination, 0 or 1
            r, g, b, // (0-248) each channel, or
            texture: textureIndex // from rsc-config
        } // or null,
        fillBack: null, // same format as fillFront, or null
        vertices: [] // array of vertex indexes (defined above)
    }
]

model.updateFillIDs()

iterate through model.faces and update materials for .mtl file generation.

model.getObj()

return model geometry string in wavefront .obj format.

model.getMtl()

return model materials string in wavefront .mtl format.

model.toJSON()

return public serializable properties.

ANIMATED_MODELS

array of hard-coded model names that aren't in config archive.

model bugs

the following models have faces with less than three vertices:

  • logbridgelow
  • logbridgehigh
  • logbridgecurvedhigh
  • logbridgecurvedlow
  • treeplatformlow2
  • treeplatformhigh2
  • stonestand
  • grand tree-lev 0
  • tribalstature
  • grand tree-lev 1
  • grand tree-lev 2
  • fourwayplatform-lev 0
  • fourwayplatform-lev 1
  • grand tree-lev 3
  • blurberrybar
  • cave snaptrap
  • cave snaptrapa
  • rocksteps

there are also 25 secret models that are never loaded in the game (hashed):

  • 1037362809
  • -1060436729
  • -1115958269
  • -1220733691
  • 1227393374
  • -1263331649
  • 1347842162
  • -1430585029
  • 1512310831
  • 1526156672
  • 1540002513
  • 1657318544
  • 1721021053
  • 2142891767
  • -380606436
  • 515450526
  • 529296367
  • 538300861
  • 550294861
  • 564140702
  • 587507422
  • -669716258
  • -741690938
  • 763644315
  • 846098451

license

Copyright 2022 2003Scape Team

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文