Untitled
unknown
python
a year ago
3.1 kB
8
Indexable
# ----------------------------------------------------------------------------
# Requirements
# ----------------------------------------------------------------------------
# Plugins:
# Scripting -
# Python
# Editor Scripting Utilities
# Python Foundation Packages
# Geometry -
# Geometry
# Geometry Processing
# Geometry Script
# ----------------------------------------------------------------------------
# Import from /includes
# ----------------------------------------------------------------------------
import unreal
# ----------------------------------------------------------------------------
# Unreal Library Classes
# ----------------------------------------------------------------------------
ur = unreal
ur_edit_asset_lib = unreal.EditorAssetLibrary()
ur_asset_helper = unreal.AssetToolsHelpers.get_asset_tools()
ur_subsystem: unreal.SubobjectDataSubsystem = unreal.get_engine_subsystem(unreal.SubobjectDataSubsystem)
physics_actor: unreal.Name = unreal.Name("PhysicsActor")
block_all: unreal.Name = unreal.Name("BlockAll")
# ----------------------------------------------------------------------------
# Import from /includes
# ----------------------------------------------------------------------------
#===========================================================================
# * set_pivot_center_bottom()
# *
# * Purpose:
#===========================================================================
def set_pivot_center_bottom(input_sm:unreal.StaticMesh,outline_actor:unreal.Actor):
if outline_actor==None:
return
print('set_pivot_center_bottom() -- Start')
asset_options = unreal.GeometryScriptCopyMeshFromAssetOptions()
requested_lod = unreal.GeometryScriptMeshReadLOD()
dm = unreal.DynamicMesh()
print(f'{unreal.GeometryScript_AssetUtils.copy_mesh_from_static_mesh(input_sm,dm,asset_options,requested_lod)}')
mesh_bounds = input_sm.get_bounds()
center = mesh_bounds.origin # we need to keep this somewhere as we lose world positions when pivot is bottom center.
extent = mesh_bounds.box_extent
bottom_center = unreal.Vector(center.x, center.y, center.z )#- extent.z)
print(f'DynamicMesh = {dm}','[SPCB]')
print(f'Location = {center}','[SPCB]')
print(f'Extent = {extent}','[SPCB]')
print(f'Bottom Center = {bottom_center}','[SPCB]')
dm.translate_pivot_to_location(bottom_center)
#outline_actor.set_actor_location(center,False,False)
options = unreal.GeometryScriptCopyMeshToAssetOptions()
target_lod = unreal.GeometryScriptMeshWriteLOD()
unreal.GeometryScript_AssetUtils.copy_mesh_to_static_mesh(dm,input_sm,options,target_lod)
#unreal.EditorAssetLibrary.save_asset(input_sm)
print('set_pivot_center_bottom() -- End')
print('Pivot Fixer by T.J.Roughton')
mesh_h = ur_edit_asset_lib.load_asset('/Game/Mesh/Cube')
set_pivot_center_bottom(mesh_h,'/Game/Mesh/Cube_Fix')
Editor is loading...
Leave a Comment