20tab / UnrealEnginePython

Embed Python in Unreal Engine 4
MIT License
2.73k stars 743 forks source link

Generate LODs on Skeletal Mesh #826

Open ASirrelle opened 4 years ago

ASirrelle commented 4 years ago

I am trying to setup an automated pipeline for importing assets, auto generating LODs, and applying specific settings. I've followed a few of the tutorials for creating LODs, but there doesn't seem to be any information on simplifying the vertex mesh. I only seem to be creating duplicates of LOD 0.

This is the code I have so far:

import unreal_engine as ue
from unreal_engine.classes import SkeletalMesh

original_mesh = ue.get_selected_assets()[0]

if not original_mesh.is_a(SkeletalMesh):
    raise DialogException('the script only works with Skeletal Meshes')

# get original vertex data
vertices = original_mesh.skeletal_mesh_get_lod()

# inform UE4 that this SkeletalMesh has vertex colors
original_mesh.bHasVertexColors = True
original_mesh.bHasBeenSimplified = True

# LOD 1
original_mesh.skeletal_mesh_build_lod(vertices, 1)

# LOD 2
original_mesh.skeletal_mesh_build_lod(vertices, 2)

# LOD 3
original_mesh.skeletal_mesh_build_lod(vertices, 3)

# LOD 4
original_mesh.skeletal_mesh_build_lod(vertices, 4)

original_mesh.save_package()

#ue.open_editor_for_asset(original_mesh)

I'm sure that there is some sort of settings function that i need to fill in and apply to this mesh, but I'm at a bit of a loss. Any help would be appreciated, thanks!

ASirrelle commented 4 years ago

This is pretty much the functionality I'm looking for. I have found ways to set some of the data, but I am still unable to simplify the skeletal mesh when lodding. Has this simply not been added to the API yet?

LodFunctionality