Skip to content

Commit

Permalink
added file version and reserved data
Browse files Browse the repository at this point in the history
  • Loading branch information
maccesch committed Feb 22, 2023
1 parent 8c71028 commit dc7a9ec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@ Download the file [io_export_panim.py](https://raw.githubusercontent.com/Synphon

The file format is a binary format that is designed to be as compact as possible. The following
shows the format of the file. It's given as `field_name - type`. All data is stored in little endian byte order.
At the moment only f32 frame values are supported.

```
frames_per_second - f32
version : u32
frames_per_second : f32
<repeat for all objects and custom properties>
object_name - utf8 string, 0-terminated
property_name - utf8 string, 0-terminated
frame_start - u32
frame_end - u32
value_type - u8, character "i" / "f" for i32 / f32
object_name : utf8 string, 0-terminated
property_name : utf8 string, 0-terminated
frame_start : u32
frame_end : u32
value_type : u8, not used currently. always 0.
reserved : 32 bytes of unused per prop data reserved for future use
<repeat for every frame between frame_start until frame_end (including)>
value - i32 / f32 depending on value_type
frame_value : f32
</repeat>
</repeat>
```
19 changes: 10 additions & 9 deletions io_export_panim.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bl_info = {
"name": "Export custom props anim (.panim)",
"author": "Marc-Stefan Cassola (maccesch)",
"version": (1, 0, 0),
"version": (0, 2, 0),
"blender": (3, 4, 0),
"location": "File > Export > Custom Props Anim (.panim)",
"description": "Export all animations of custom properties as a binary .panim file",
Expand All @@ -13,7 +13,6 @@
import re
import struct


def i32(i):
return struct.pack("<i", i)

Expand All @@ -25,11 +24,14 @@ def u32(i):
def f32(f):
return struct.pack("<f", f)


def write_anim_data(context, filepath):
print("Exporting custom props anim data...")
f = open(filepath, 'wb')

major, minor, patch = bl_info["version"]
file_version = ((major * 1024) + minor) * 1024 + patch
f.write(u32(file_version))

f.write(f32(bpy.data.scenes["Scene"].render.fps))

pattern = re.compile(r'\["([^"]+)"\]')
Expand All @@ -52,16 +54,15 @@ def write_anim_data(context, filepath):
f.write(u32(frame_start))
f.write(u32(frame_end))

typ = b'i' if type(obj[name]) is int else b'f'
typ = b'\0' # TODO : support other types like vector values and so on
f.write(typ)

reserved_per_prop_data = b'\0' * 32
f.write(reserved_per_prop_data)

for frame in range(frame_start, frame_end + 1):
bpy.context.scene.frame_set(frame)

if typ == b'i':
f.write(i32(obj[name]))
else:
f.write(f32(obj[name]))
f.write(f32(obj[name]))

f.close()

Expand Down

0 comments on commit dc7a9ec

Please sign in to comment.