最近的项目是用python脚本把HDA模型导入UE4并在Houdini Inputs中设置几何输入以及模型:
def configure_inputs(self, in_wrapper):
print('configure_inputs')
in_wrapper.on_post_instantiation_delegate.remove_callable(self.configure_inputs)
geo_input = in_wrapper.create_empty_input(unreal.HoudiniPublicAPIGeoInput)
geo_input.set_input_objects((self.asset, ))
geo_input.set_object_transform_offset(
self.asset,
unreal.Transform(
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
)
)
in_wrapper.set_input_at_index(0, geo_input)
geo_input = None
然后还要设置hda的参数:
def on_post_instantiation(self, in_wrapper):
print('on_post_instantiation')
in_wrapper.on_post_instantiation_delegate.remove_callable(self.on_post_instantiation)
# 设置normal_blend_factor和Blendmode的默认值:
in_wrapper.set_float_parameter_value('normal_blend_factor', 0.7)
in_wrapper.set_int_parameter_value('Blendmode', 2)
最后bake出来(默认bake路径是/Game/HoudiniEngine/Bake):
def on_post_bake(self, in_wrapper, success):
print('on_post_bake')
in_wrapper.on_post_bake_delegate.remove_callable(self.on_post_bake)
print('bake complete ... {}'.format('success' if success else 'failed'))
in_wrapper.delete_instantiated_asset()
global _g_wrapper
_g_wrapper = None