This repository has been archived by the owner on Oct 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
F3bExporterOperator.py
68 lines (50 loc) · 1.85 KB
/
F3bExporterOperator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import bpy,os
from bpy.props import ( BoolProperty )
from bpy_extras.io_utils import ExportHelper
from .F3bContext import *
from . import F3bExporter
def menu_func_export_f3b(self, context):
self.layout.operator(F3bExporterOperator.bl_idname, text="f3b (.f3b)")
def register():
bpy.utils.register_class(F3bExporterOperator)
bpy.types.TOPBAR_MT_file_export.append(menu_func_export_f3b)
def unregister():
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export_f3b)
bpy.utils.unregister_class(F3bExporterOperator)
class F3bExporterOperator(bpy.types.Operator, ExportHelper):
bl_idname = "export_scene.f3b"
bl_label = "Export f3b"
filename_ext = ".f3b"
#Properties
optionExportSelection: BoolProperty(
name = "Export Selection",
description = "Export only selected objects",
default = True
)
optionExportTangents: BoolProperty(
name = "Export Tangents",
description = "",
default = True
)
optionToDDS: BoolProperty(
name = "Convert textures to dds",
description = "",
default = True
)
def execute(self, context):
print("Export f3b")
if self.filepath.endswith(".f3h"):
self.filepath[:len(self.filepath)-len("f3h")]+"f3b"
scene: bpy.types.Scene=context.scene
topath=os.path.dirname(self.filepath)
f3bctx=F3bContext(self,self.filepath,topath)
data,collectionsData=F3bExporter.startExport(f3bctx,scene)
file = open(self.filepath, "wb")
file.write(data.SerializeToString())
file.close()
headerFile=self.filepath[:len(self.filepath)-len("f3b")]+"f3h"
print("Write header in"+headerFile)
file = open(headerFile, "wb")
file.write(collectionsData.SerializeToString())
file.close()
return {'FINISHED'}