rw-parser-ng 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +88 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +26 -0
- package/lib/renderware/RwFile.d.ts +10 -0
- package/lib/renderware/RwFile.js +33 -0
- package/lib/renderware/RwSections.d.ts +20 -0
- package/lib/renderware/RwSections.js +29 -0
- package/lib/renderware/dff/DffModelType.d.ts +5 -0
- package/lib/renderware/dff/DffModelType.js +9 -0
- package/lib/renderware/dff/DffParser.d.ts +155 -0
- package/lib/renderware/dff/DffParser.js +418 -0
- package/lib/renderware/errors/RwParseError.d.ts +6 -0
- package/lib/renderware/errors/RwParseError.js +34 -0
- package/lib/renderware/txd/TxdParser.d.ts +38 -0
- package/lib/renderware/txd/TxdParser.js +185 -0
- package/lib/renderware/utils/ImageDecoder.d.ts +23 -0
- package/lib/renderware/utils/ImageDecoder.js +512 -0
- package/lib/renderware/utils/ImageFormatEnums.d.ts +25 -0
- package/lib/renderware/utils/ImageFormatEnums.js +32 -0
- package/lib/renderware/utils/RwVersion.d.ts +7 -0
- package/lib/renderware/utils/RwVersion.js +30 -0
- package/lib/scripts/sort_models.d.ts +1 -0
- package/lib/scripts/sort_models.js +185 -0
- package/lib/scripts/sort_worker.d.ts +1 -0
- package/lib/scripts/sort_worker.js +140 -0
- package/lib/src/index.d.ts +8 -0
- package/lib/src/index.js +28 -0
- package/lib/src/renderware/RwFile.d.ts +10 -0
- package/lib/src/renderware/RwFile.js +33 -0
- package/lib/src/renderware/RwSections.d.ts +20 -0
- package/lib/src/renderware/RwSections.js +29 -0
- package/lib/src/renderware/common/types.d.ts +50 -0
- package/lib/src/renderware/common/types.js +2 -0
- package/lib/src/renderware/dff/DffModelType.d.ts +5 -0
- package/lib/src/renderware/dff/DffModelType.js +9 -0
- package/lib/src/renderware/dff/DffParser.d.ts +112 -0
- package/lib/src/renderware/dff/DffParser.js +418 -0
- package/lib/src/renderware/errors/RwParseError.d.ts +6 -0
- package/lib/src/renderware/errors/RwParseError.js +34 -0
- package/lib/src/renderware/ifp/IfpData.d.ts +28 -0
- package/lib/src/renderware/ifp/IfpData.js +9 -0
- package/lib/src/renderware/ifp/IfpParser.d.ts +12 -0
- package/lib/src/renderware/ifp/IfpParser.js +196 -0
- package/lib/src/renderware/txd/TxdParser.d.ts +38 -0
- package/lib/src/renderware/txd/TxdParser.js +185 -0
- package/lib/src/renderware/utils/ImageDecoder.d.ts +23 -0
- package/lib/src/renderware/utils/ImageDecoder.js +512 -0
- package/lib/src/renderware/utils/ImageFormatEnums.d.ts +25 -0
- package/lib/src/renderware/utils/ImageFormatEnums.js +32 -0
- package/lib/src/renderware/utils/RwVersion.d.ts +7 -0
- package/lib/src/renderware/utils/RwVersion.js +30 -0
- package/lib/src/utils/ByteStream.d.ts +17 -0
- package/lib/src/utils/ByteStream.js +65 -0
- package/lib/utils/ByteStream.d.ts +16 -0
- package/lib/utils/ByteStream.js +60 -0
- package/package.json +64 -0
- package/src/index.ts +10 -0
- package/src/renderware/RwFile.ts +22 -0
- package/src/renderware/RwSections.ts +27 -0
- package/src/renderware/common/types.ts +59 -0
- package/src/renderware/dff/DffModelType.ts +5 -0
- package/src/renderware/dff/DffParser.ts +596 -0
- package/src/renderware/errors/RwParseError.ts +11 -0
- package/src/renderware/ifp/IfpData.ts +33 -0
- package/src/renderware/ifp/IfpParser.ts +203 -0
- package/src/renderware/txd/TxdParser.ts +234 -0
- package/src/renderware/utils/ImageDecoder.ts +571 -0
- package/src/renderware/utils/ImageFormatEnums.ts +28 -0
- package/src/renderware/utils/RwVersion.ts +28 -0
- package/src/utils/ByteStream.ts +75 -0
- package/tsconfig.json +68 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ByteStream = void 0;
|
|
4
|
+
var ByteStream = /** @class */ (function () {
|
|
5
|
+
function ByteStream(stream) {
|
|
6
|
+
this._cursor = 0;
|
|
7
|
+
this._stream = stream;
|
|
8
|
+
}
|
|
9
|
+
ByteStream.prototype.readUint8 = function () {
|
|
10
|
+
var uint8 = this._stream.readUInt8(this._cursor);
|
|
11
|
+
this._cursor++;
|
|
12
|
+
return uint8;
|
|
13
|
+
};
|
|
14
|
+
ByteStream.prototype.readUint16 = function () {
|
|
15
|
+
var uint16 = this._stream.readUInt16LE(this._cursor);
|
|
16
|
+
this._cursor += 2;
|
|
17
|
+
return uint16;
|
|
18
|
+
};
|
|
19
|
+
ByteStream.prototype.readUint32 = function () {
|
|
20
|
+
var uint32 = this._stream.readUInt32LE(this._cursor);
|
|
21
|
+
this._cursor += 4;
|
|
22
|
+
return uint32;
|
|
23
|
+
};
|
|
24
|
+
ByteStream.prototype.readInt16 = function () {
|
|
25
|
+
var int16 = this._stream.readInt16LE(this._cursor);
|
|
26
|
+
this._cursor += 2;
|
|
27
|
+
return int16;
|
|
28
|
+
};
|
|
29
|
+
ByteStream.prototype.readInt32 = function () {
|
|
30
|
+
var int32 = this._stream.readInt32LE(this._cursor);
|
|
31
|
+
this._cursor += 4;
|
|
32
|
+
return int32;
|
|
33
|
+
};
|
|
34
|
+
ByteStream.prototype.readFloat = function () {
|
|
35
|
+
var float = this._stream.readFloatLE(this._cursor);
|
|
36
|
+
this._cursor += 4;
|
|
37
|
+
return float;
|
|
38
|
+
};
|
|
39
|
+
ByteStream.prototype.readString = function (size) {
|
|
40
|
+
var string = this._stream.toString('ascii', this._cursor, this._cursor + size);
|
|
41
|
+
this._cursor += size;
|
|
42
|
+
return string.split(/\0/g).shift() || '';
|
|
43
|
+
};
|
|
44
|
+
ByteStream.prototype.read = function (size) {
|
|
45
|
+
var data = new Uint8Array(size);
|
|
46
|
+
for (var i = 0; i < size; i++) {
|
|
47
|
+
data[i] = this.readUint8();
|
|
48
|
+
}
|
|
49
|
+
return data;
|
|
50
|
+
};
|
|
51
|
+
ByteStream.prototype.getSize = function () {
|
|
52
|
+
return this._stream.byteLength;
|
|
53
|
+
};
|
|
54
|
+
ByteStream.prototype.getPosition = function () {
|
|
55
|
+
return this._cursor;
|
|
56
|
+
};
|
|
57
|
+
ByteStream.prototype.setPosition = function (position) {
|
|
58
|
+
this._cursor = position;
|
|
59
|
+
};
|
|
60
|
+
ByteStream.prototype.skip = function (size) {
|
|
61
|
+
this._cursor += size;
|
|
62
|
+
};
|
|
63
|
+
return ByteStream;
|
|
64
|
+
}());
|
|
65
|
+
exports.ByteStream = ByteStream;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class ByteStream {
|
|
2
|
+
private _cursor;
|
|
3
|
+
private _stream;
|
|
4
|
+
constructor(stream: Buffer);
|
|
5
|
+
readUint8(): number;
|
|
6
|
+
readUint16(): number;
|
|
7
|
+
readUint32(): number;
|
|
8
|
+
readInt32(): number;
|
|
9
|
+
readFloat(): number;
|
|
10
|
+
readString(size: number): string;
|
|
11
|
+
read(size: number): Uint8Array<ArrayBuffer>;
|
|
12
|
+
getSize(): number;
|
|
13
|
+
getPosition(): number;
|
|
14
|
+
setPosition(position: number): void;
|
|
15
|
+
skip(size: number): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ByteStream = void 0;
|
|
4
|
+
var ByteStream = /** @class */ (function () {
|
|
5
|
+
function ByteStream(stream) {
|
|
6
|
+
this._cursor = 0;
|
|
7
|
+
this._stream = stream;
|
|
8
|
+
}
|
|
9
|
+
ByteStream.prototype.readUint8 = function () {
|
|
10
|
+
var uint8 = this._stream.readUInt8(this._cursor);
|
|
11
|
+
this._cursor++;
|
|
12
|
+
return uint8;
|
|
13
|
+
};
|
|
14
|
+
ByteStream.prototype.readUint16 = function () {
|
|
15
|
+
var uint16 = this._stream.readUInt16LE(this._cursor);
|
|
16
|
+
this._cursor += 2;
|
|
17
|
+
return uint16;
|
|
18
|
+
};
|
|
19
|
+
ByteStream.prototype.readUint32 = function () {
|
|
20
|
+
var uint32 = this._stream.readUInt32LE(this._cursor);
|
|
21
|
+
this._cursor += 4;
|
|
22
|
+
return uint32;
|
|
23
|
+
};
|
|
24
|
+
ByteStream.prototype.readInt32 = function () {
|
|
25
|
+
var int32 = this._stream.readInt32LE(this._cursor);
|
|
26
|
+
this._cursor += 4;
|
|
27
|
+
return int32;
|
|
28
|
+
};
|
|
29
|
+
ByteStream.prototype.readFloat = function () {
|
|
30
|
+
var float = this._stream.readFloatLE(this._cursor);
|
|
31
|
+
this._cursor += 4;
|
|
32
|
+
return float;
|
|
33
|
+
};
|
|
34
|
+
ByteStream.prototype.readString = function (size) {
|
|
35
|
+
var string = this._stream.toString('ascii', this._cursor, this._cursor + size);
|
|
36
|
+
this._cursor += size;
|
|
37
|
+
return string.split(/\0/g).shift() || '';
|
|
38
|
+
};
|
|
39
|
+
ByteStream.prototype.read = function (size) {
|
|
40
|
+
var data = new Uint8Array(size);
|
|
41
|
+
for (var i = 0; i < size; i++) {
|
|
42
|
+
data[i] = this.readUint8();
|
|
43
|
+
}
|
|
44
|
+
return data;
|
|
45
|
+
};
|
|
46
|
+
ByteStream.prototype.getSize = function () {
|
|
47
|
+
return this._stream.byteLength;
|
|
48
|
+
};
|
|
49
|
+
ByteStream.prototype.getPosition = function () {
|
|
50
|
+
return this._cursor;
|
|
51
|
+
};
|
|
52
|
+
ByteStream.prototype.setPosition = function (position) {
|
|
53
|
+
this._cursor = position;
|
|
54
|
+
};
|
|
55
|
+
ByteStream.prototype.skip = function (size) {
|
|
56
|
+
this._cursor += size;
|
|
57
|
+
};
|
|
58
|
+
return ByteStream;
|
|
59
|
+
}());
|
|
60
|
+
exports.ByteStream = ByteStream;
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rw-parser-ng",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Parses RenderWare DFF, TXD and IFP files into usable format!",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "DepsCian",
|
|
7
|
+
"url": "https://github.com/DepsCian"
|
|
8
|
+
},
|
|
9
|
+
"contributors": [
|
|
10
|
+
{
|
|
11
|
+
"name": "Timic3",
|
|
12
|
+
"url": "https://github.com/Timic3"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "MegadreamsBE",
|
|
16
|
+
"url": "https://github.com/MegadreamsBE"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"license": "GPL-3.0",
|
|
20
|
+
"homepage": "https://github.com/DepsCian/rw-parser-ng#readme",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/DepsCian/rw-parser-ng.git"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"gta",
|
|
27
|
+
"gtasa",
|
|
28
|
+
"gtavc",
|
|
29
|
+
"gtaiii",
|
|
30
|
+
"san andreas",
|
|
31
|
+
"vice city",
|
|
32
|
+
"iii",
|
|
33
|
+
"renderware",
|
|
34
|
+
"parser",
|
|
35
|
+
"rw-parser",
|
|
36
|
+
"dff",
|
|
37
|
+
"txd",
|
|
38
|
+
"ifp"
|
|
39
|
+
],
|
|
40
|
+
"main": "lib/index.js",
|
|
41
|
+
"types": "lib/index.d.ts",
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/jest": "^30.0.0",
|
|
44
|
+
"@types/node": "^24.0.3",
|
|
45
|
+
"jest": "^30.0.0",
|
|
46
|
+
"ts-jest": "^29.4.0",
|
|
47
|
+
"typescript": "^5.8.3"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -p tsconfig.json",
|
|
51
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
52
|
+
"prepare": "npm run build",
|
|
53
|
+
"test": "jest",
|
|
54
|
+
"sort:models": "tsc && node lib/scripts/sort_models.js"
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"lib",
|
|
58
|
+
"src",
|
|
59
|
+
"LICENSE",
|
|
60
|
+
"README.md",
|
|
61
|
+
"package.json",
|
|
62
|
+
"tsconfig.json"
|
|
63
|
+
]
|
|
64
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ByteStream } from './utils/ByteStream';
|
|
2
|
+
export { RwFile } from './renderware/RwFile';
|
|
3
|
+
export { RwSections } from './renderware/RwSections';
|
|
4
|
+
|
|
5
|
+
export * from './renderware/dff/DffParser';
|
|
6
|
+
export * from './renderware/txd/TxdParser';
|
|
7
|
+
export * from './renderware/ifp/IfpParser';
|
|
8
|
+
|
|
9
|
+
export * from './renderware/dff/DffModelType';
|
|
10
|
+
export * from './renderware/ifp/IfpData';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ByteStream } from "../utils/ByteStream";
|
|
2
|
+
|
|
3
|
+
export interface RwSectionHeader {
|
|
4
|
+
sectionType: number,
|
|
5
|
+
sectionSize: number,
|
|
6
|
+
versionNumber: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class RwFile extends ByteStream {
|
|
10
|
+
|
|
11
|
+
constructor(stream: Buffer) {
|
|
12
|
+
super(stream);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public readSectionHeader(): RwSectionHeader {
|
|
16
|
+
const sectionType = this.readUint32();
|
|
17
|
+
const sectionSize = this.readUint32();
|
|
18
|
+
const versionNumber = this.readUint32();
|
|
19
|
+
|
|
20
|
+
return { sectionType, sectionSize, versionNumber };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export enum RwSections {
|
|
2
|
+
// Core
|
|
3
|
+
RwStruct = 0x0001,
|
|
4
|
+
RwString = 0x0002,
|
|
5
|
+
RwExtension = 0x0003,
|
|
6
|
+
RwTexture = 0x0006,
|
|
7
|
+
RwMaterial = 0x0007,
|
|
8
|
+
RwMaterialList = 0x0008,
|
|
9
|
+
RwFrameList = 0x000E,
|
|
10
|
+
RwGeometry = 0x000F,
|
|
11
|
+
RwClump = 0x0010,
|
|
12
|
+
RwAtomic = 0x0014,
|
|
13
|
+
RwTextureNative = 0x0015,
|
|
14
|
+
RwTextureDictionary = 0x0016,
|
|
15
|
+
RwGeometryList = 0x001A,
|
|
16
|
+
RwSkin = 0x116,
|
|
17
|
+
RwAnim = 0x11E,
|
|
18
|
+
|
|
19
|
+
// Toolkit
|
|
20
|
+
RwMaterialEffectsPLG = 0x0120,
|
|
21
|
+
|
|
22
|
+
// R* specific RW plugins
|
|
23
|
+
RwReflectionMaterial = 0x0253F2FC,
|
|
24
|
+
// This was renamed to RwNodeName from RwFrame to prevent confusion.
|
|
25
|
+
// https://gtamods.com/wiki/Node_Name_(RW_Section)
|
|
26
|
+
RwNodeName = 0x0253F2FE,
|
|
27
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export interface RwVector2 {
|
|
2
|
+
x: number,
|
|
3
|
+
y: number,
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface RwVector3 {
|
|
7
|
+
x: number,
|
|
8
|
+
y: number,
|
|
9
|
+
z: number,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface RwVector4 {
|
|
13
|
+
x: number,
|
|
14
|
+
y: number,
|
|
15
|
+
z: number,
|
|
16
|
+
t: number,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface RwQuaternion {
|
|
20
|
+
x: number,
|
|
21
|
+
y: number,
|
|
22
|
+
z: number,
|
|
23
|
+
w: number,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface RwMatrix3 {
|
|
27
|
+
right: RwVector3,
|
|
28
|
+
up: RwVector3,
|
|
29
|
+
at: RwVector3,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RwMatrix4 {
|
|
33
|
+
right: RwVector4,
|
|
34
|
+
up: RwVector4,
|
|
35
|
+
at: RwVector4,
|
|
36
|
+
transform: RwVector4,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface RwColor {
|
|
40
|
+
r: number,
|
|
41
|
+
g: number,
|
|
42
|
+
b: number,
|
|
43
|
+
a: number,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface RwTextureCoordinate {
|
|
47
|
+
u: number,
|
|
48
|
+
v: number,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface RwTriangle {
|
|
52
|
+
vector: RwVector3,
|
|
53
|
+
materialId: number,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface RwSphere {
|
|
57
|
+
vector: RwVector3,
|
|
58
|
+
radius: number,
|
|
59
|
+
}
|