-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reducing exported mesh size idea #99
Comments
Anson,
Thank you! I’ll put it in the ReadME for the new version (hopefully coming over the holidays).
Cheers
Chris
On Dec 7, 2024, at 18:18, Anson Liu ***@***.***> wrote:
Chris,
I noticed that the exported map models have twice as many vertices as needed due to the full resolution grid on the bottom surface. I made a Blender script to automate decreasing the vertices count by selecting all bottom vertices and applying a 1% decimate modifier.
It's probably more streamlined to avoid making the extra vertices during the TouchTerrain generation but I don't see an easy way to do that at the moment. I added some screenshots on how to run the script below if anyone else needs to decrease the size of their models. Maybe this can be added to the documentation.
image.png (view on web)<https://github.com/user-attachments/assets/0dc62081-1a62-439a-8a73-f44a84836e39>
image.png (view on web)<https://github.com/user-attachments/assets/0708a9d6-674e-4302-ac46-0a8f80e0584c>
The model must be selected (highlighted in yellow) in the 3D view or object list before clicking the Run script button.
image.png (view on web)<https://github.com/user-attachments/assets/1524aca1-3a75-4aae-8f05-0df9d09889dd>
The vertices of the object can be viewed by with Tab key to go to Edit mode when the object is selected.
The script to paste into Blender is below
import bpy, time
variantProcessStartTime = time.monotonic()
originalVertexCount = 0
for obj in bpy.context.scene.objects:
originalVertexCount += len(obj.data.vertices)
print(f'Original vertex count {originalVertexCount}')
# Deselect everything on object
for e in [bpy.context.active_object.data.vertices, bpy.context.active_object.data.polygons, bpy.context.active_object.data.edges]:
e.foreach_set("select", (False,)*len(e))
# Select vertices at or below Z0
for v in bpy.context.active_object.data.vertices:
v.select = v.co.z <= 0
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(type="VERT")
bpy.ops.mesh.select_less()
bpy.ops.object.vertex_group_assign_new()
bpy.context.active_object.vertex_groups[0].name = 'bottom-inner'
bpy.ops.object.modifier_add(type='DECIMATE')
bpy.context.object.modifiers["Decimate"].vertex_group='bottom-inner'
bpy.context.object.modifiers["Decimate"].ratio=0.01
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.modifier_apply(modifier='Decimate')
bpy.ops.object.mode_set(mode='OBJECT')
print(f'select inner bottom and decimate took {time.monotonic()-variantProcessStartTime}s')
—
Reply to this email directly, view it on GitHub<#99>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEYDF5LDNSL4QWN2PRE2XR32EOF5VAVCNFSM6AAAAABTGVMQHGVHI2DSMVQWIX3LMV43ASLTON2WKOZSG4ZDIOBWHEYDCNQ>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Chris,
I noticed that the exported map models have twice as many vertices as needed due to the full resolution grid on the bottom surface. I made a Blender script to automate decreasing the vertices count by selecting all bottom vertices and applying a 1% decimate modifier.
It's probably more streamlined to avoid making the extra vertices during the TouchTerrain generation but I don't see an easy way to do that at the moment. I added some screenshots on how to run the script below if anyone else needs to decrease the size of their models. Maybe this can be added to the documentation.
The model must be selected (highlighted in yellow) in the 3D view or object list before clicking the Run script button.
The vertices of the object can be viewed by with Tab key to go to Edit mode when the object is selected.
The script to paste into Blender is below
The text was updated successfully, but these errors were encountered: