-
-
Save norman784/d08ecb519a0ce0adadb9990e390e5b20 to your computer and use it in GitHub Desktop.
Subnautica Optoctree Batches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_int(stream, size=1): | |
return int.from_bytes(stream.read(size), byteorder='little') | |
class Node: | |
def __init__(self, stream): | |
self.material = read_int(stream) | |
self.distance = read_int(stream) | |
self.child = read_int(stream, 2) | |
def __repr__(self): | |
return f"<Node, m: {self.material} d: {self.distance} c: {self.child}>" | |
class Octree: | |
def __init__(self, stream): | |
self.count = read_int(stream, 2) | |
self.nodes = [] | |
for i in range(self.count): | |
self.nodes.append(Node(stream)) | |
def __repr__(self): | |
if self.count == 1: | |
return f"<Octree, 1 node>" | |
else: | |
return f"<Octree, {self.count} nodes>" | |
class Batch: | |
def __init__(self, path): | |
stream = open(path, mode='rb') | |
self.version = read_int(stream, 4) | |
self.octrees = [] | |
for i in range(125): | |
self.octrees.append(Octree(stream)) | |
b1 = Batch("SNUnmanagedData/Build18/CompiledOctreesCache/compiled-batch-12-18-12.optoctrees") | |
print(f"ver {b1.version}\n{b1.octrees}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment