mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-09 19:12:15 +02:00
Merge pull request #13118 from huffman/feat/010-templates
Add fbx + ktx templates
This commit is contained in:
commit
0fd0a64e7f
3 changed files with 155 additions and 0 deletions
1
tools/010-templates/README.md
Normal file
1
tools/010-templates/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
This directory contains [010 editor](https://www.sweetscape.com/010editor/) templates for parsing and inspecting different file types.
|
102
tools/010-templates/fbx.bt
Normal file
102
tools/010-templates/fbx.bt
Normal file
|
@ -0,0 +1,102 @@
|
|||
//
|
||||
// fbx.bt
|
||||
// tools/010-templates
|
||||
//
|
||||
// Created by Ryan Huffman
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// FBX file template
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
local char use64BitAddresses = 1;
|
||||
|
||||
struct Header {
|
||||
char prefix[23];
|
||||
int32 version;
|
||||
};
|
||||
|
||||
struct Property {
|
||||
char type;
|
||||
if (type == 'Y') {
|
||||
int16 value;
|
||||
} else if (type == 'C') {
|
||||
char value;
|
||||
} else if (type == 'I') {
|
||||
int32 value;
|
||||
} else if (type == 'F') {
|
||||
float value;
|
||||
} else if (type == 'D') {
|
||||
double value;
|
||||
} else if (type == 'L') {
|
||||
int64 value;
|
||||
} else if (type == 'S' || type == 'R') {
|
||||
uint32 size;
|
||||
char value[size];
|
||||
} else {
|
||||
uint32 length;
|
||||
uint32 encoding;
|
||||
uint32 compressedLength;
|
||||
if (encoding == 1) {
|
||||
char compressedData[compressedLength];
|
||||
} else if (type == 'f') {
|
||||
float values[this.length];
|
||||
} else if (type == 'd') {
|
||||
double values[this.length];
|
||||
} else if (type == 'l') {
|
||||
int64 values[this.length];
|
||||
} else if (type == 'i') {
|
||||
int32 values[this.length];
|
||||
} else if (type == 'b') {
|
||||
char values[this.length];
|
||||
} else {
|
||||
Printf("%c", type);
|
||||
Assert(false, "Error, unknown property type");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct Node;
|
||||
|
||||
string nodeName(Node& node) {
|
||||
if (!exists(node.name)) {
|
||||
return "Node ----- ";
|
||||
}
|
||||
local string s;
|
||||
SPrintf(s, "Node (%s) ", node.name);
|
||||
return s;
|
||||
}
|
||||
|
||||
struct Node {
|
||||
if (use64BitAddresses) {
|
||||
int64 endOffset;
|
||||
uint64 propertyCount;
|
||||
uint64 propertyListLength;
|
||||
} else {
|
||||
int32 endOffset;
|
||||
uint32 propertyCount;
|
||||
uint32 propertyListLength;
|
||||
}
|
||||
uchar nameLength;
|
||||
char name[this.nameLength];
|
||||
Property properties[this.propertyCount]<optimize=false>;
|
||||
while (FTell() < endOffset) {
|
||||
Node children<optimize=false, name=nodeName>;
|
||||
}
|
||||
};
|
||||
|
||||
struct File {
|
||||
Header header;
|
||||
use64BitAddresses = header.version >= 7500;
|
||||
local int i = 0;
|
||||
Node node<name=nodeName>;
|
||||
local string name = node.name;
|
||||
while (name != "") {
|
||||
Node node<name=nodeName>;
|
||||
i++;
|
||||
name = exists(node[i].name) ? node[i].name : "";
|
||||
}
|
||||
|
||||
} file;
|
52
tools/010-templates/ktx.bt
Normal file
52
tools/010-templates/ktx.bt
Normal file
|
@ -0,0 +1,52 @@
|
|||
//
|
||||
// ktx.bt
|
||||
// tools/010-templates
|
||||
//
|
||||
// Created by Ryan Huffman
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// KTX file template
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
struct Header {
|
||||
char identifier[12];
|
||||
uint32 endianness<format=hex>;
|
||||
uint32 glType;
|
||||
uint32 glTypeSize;
|
||||
uint32 glFormat;
|
||||
uint32 glInternalFormat;
|
||||
uint32 glBaseInternalFormat;
|
||||
uint32 pixelWidth;
|
||||
uint32 pixelHeight;
|
||||
uint32 pixelDepth;
|
||||
uint32 numberOfArrayElements;
|
||||
uint32 numberOfFaces;
|
||||
uint32 numberOfMipmapLevels;
|
||||
uint32 bytesOfKeyValueData;
|
||||
};
|
||||
|
||||
struct KV {
|
||||
uint32 byteSize;
|
||||
local uint32 keyLength = ReadStringLength(FTell());
|
||||
char key[keyLength];
|
||||
char value[byteSize - keyLength] <format=hex>;
|
||||
char padding[3 - ((byteSize + 3) % 4)];
|
||||
};
|
||||
|
||||
string kvName(KV& kv) {
|
||||
local string s;
|
||||
SPrintf(s, "KeyValue (%s) ", kv.key);
|
||||
return s;
|
||||
}
|
||||
|
||||
struct File {
|
||||
Header header;
|
||||
local uint32 endOfKV = FTell() + header.bytesOfKeyValueData;
|
||||
while (FTell() < endOfKV) {
|
||||
KV keyValue <optimize=false, name=kvName>;
|
||||
}
|
||||
char imageData[FileSize() - FTell()];
|
||||
} file;
|
Loading…
Reference in a new issue