Addon needs to be able to export to HKT. This will require using Harag's adjusted FBX Importer most likely, but might be worth to test without first. Also pull XML Harag uses to pass to havok from his github and use as a base.
Relevant info:
StollieToday at 7:00 AM
if you want the workflow its fairly straightforward, export out an FBX with the collision model, so in this case just the collection that contains the physics shapes, pass that to the fbx importer for conversion (you wont be able to make collisions without this conversion, its a file format thing), pass the converted FBX and the HKO scene settings file to the Havok tool to create the HKT.
this is an example HKO file (havok settings) - you'll find Harag has one in
which is basically just his way of storing the XML file
How to go about this
- Determine how I can run an extenal exe
- Determine how to run the adjusted FBX exporter specifically (reference Balmung's github) (set that up as a separate function)
- Determine how to best store the HKO settings, export those via a separate function
- Separate function to then call havok content tools? How does that work with export itself taking time? Is there a risk that it would run too early, before export is finished?
- Operator calls those functions.
StollieToday at 7:03 AM
@enenra this method calls the importer
def fbx_to_hkt(settings: ExportSettings, srcfile, dstfile):
settings.callTool(
[settings.fbximporter, srcfile, dstfile],
logfile=dstfile + '.convert.log'
)
which calls this method
def callTool(self, cmdline, logfile=None, cwd=None, successfulExitCodes=[0], loglines=[], logtextInspector=None):
try:
out = subprocess.check_output(cmdline, cwd=cwd, stderr=subprocess.STDOUT)
if self.isLogToolOutput and logfile:
write_to_log(logfile, out, cmdline=cmdline, cwd=cwd, loglines=loglines)
if not logtextInspector is None:
logtextInspector(out)
except subprocess.CalledProcessError as e:
if self.isLogToolOutput and logfile:
write_to_log(logfile, e.output, cmdline=cmdline, cwd=cwd, loglines=loglines)
if not e.returncode in successfulExitCodes:
raise
basically its passing the callTool method the FBXImporter.exe that is selected in the blender config
then has a couple of logs and looks for return codes (exit codes from the program) which are used by a python library to check the success of the programs execution
the whole process of exportation begins in file export.py at line 116 in
it's complex but fairly sequential if you read through it, it goes Settings > FBXImporter > Havok > MWMBuilder
there are also more settings as part of the custom node tree in nodes.py such as
class MwmExportProperties(bpy.types.PropertyGroup):
if bpy.app.version <= (2, 78, 0):
rescale_factor = bpy.props.FloatProperty(name="Rescale Factor", min=0.001, max=1000, soft_min=0.01, soft_max=10,
default=1.0,
description="Instructs MwmBuilder to rescale everything by the given factor. Exporting a character seems to require a value 0.01. The armature must have the same scale.")
rotation_y = bpy.props.FloatProperty(name="Rotation Y", min=-1000, max=1000, soft_min=-360, soft_max=360,
default=0,
description="Instructs MwmBuilder to rotate everything around the Y-axis. Exporting a character seems to require a value of 180°")
else:
rescale_factor = bpy.props.FloatProperty(name="Rescale Factor", min=0.001, max=1000, soft_min=0.01, soft_max=10,
default=0.01,
description="Instructs MwmBuilder to rescale everything by the given factor. Exporting a character seems to require a value 0.01. The armature must have the same scale.")
rotation_y = bpy.props.FloatProperty(name="Rotation Y", min=-1000, max=1000, soft_min=-360, soft_max=360,
default=0,
description="Instructs MwmBuilder to rotate everything around the Y-axis. Exporting a character seems to require a value of 180°")
honesty its kinda scattered all over the damn place lol
I think for your initial step of just getting to the fbximporter though you need whats in these three only
def fbx_to_hkt(settings: ExportSettings, srcfile, dstfile):
def callTool(self, cmdline, logfile=None, cwd=None, successfulExitCodes=[0], loglines=[], logtextInspector=None):
def export_fbx(settings: ExportSettings, filepath, objects, fbx_settings=None):
StollieToday at 6:39 PM
essentially its
1.) Create "ExportSettings" class which contains a bunch of variables (most of which you probably wont need)
2.) Create "export_fbx" method to add the defaults for an FBX export (that may not be needed) with some other scaling which might not be applicable
3.) Create a 1:1 copy of the fbx.py file which hooks into Blenders exporter and extends it with custom properties and saves the FBX file and investigate whats linked to it and if its still needed.
4.) Create some method tied to a button that calls "export_fbx" to fire it all off.
THEN you should have a properly formatted FBX file to easily pass to the FBXImporter
also check the button Harag used to call "export_fbx" it shows how he names the files and sequenced the methods all the way up to MWMBuilder