From d8257dcfd3ca497898e8a198aa15816616ca985a Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 7 May 2018 11:45:17 -0700 Subject: [PATCH] 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;