From d8257dcfd3ca497898e8a198aa15816616ca985a Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 7 May 2018 11:45:17 -0700 Subject: [PATCH 1/3] Add 010 fbx template --- tools/010-templates/fbx.bt | 102 +++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tools/010-templates/fbx.bt diff --git a/tools/010-templates/fbx.bt b/tools/010-templates/fbx.bt new file mode 100644 index 0000000000..dcb620066e --- /dev/null +++ b/tools/010-templates/fbx.bt @@ -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]; + while (FTell() < endOffset) { + Node children; + } +}; + +struct File { + Header header; + use64BitAddresses = header.version >= 7500; + local int i = 0; + Node node; + local string name = node.name; + while (name != "") { + Node node; + i++; + name = exists(node[i].name) ? node[i].name : ""; + } + +} file; From b9fb9875a7462f3262237c8ead48feac565324a5 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 7 May 2018 11:48:50 -0700 Subject: [PATCH 2/3] Add 010 ktx template --- tools/010-templates/ktx.bt | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tools/010-templates/ktx.bt diff --git a/tools/010-templates/ktx.bt b/tools/010-templates/ktx.bt new file mode 100644 index 0000000000..9690dbb391 --- /dev/null +++ b/tools/010-templates/ktx.bt @@ -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; + 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] ; + 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 ; + } + char imageData[FileSize() - FTell()]; +} file; From 894cd3ed76b3d870e391a406f3173d9f8f833b3d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 7 May 2018 11:52:29 -0700 Subject: [PATCH 3/3] Add 010-templates/README.md --- tools/010-templates/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 tools/010-templates/README.md diff --git a/tools/010-templates/README.md b/tools/010-templates/README.md new file mode 100644 index 0000000000..df3ce6d0e5 --- /dev/null +++ b/tools/010-templates/README.md @@ -0,0 +1 @@ +This directory contains [010 editor](https://www.sweetscape.com/010editor/) templates for parsing and inspecting different file types.