Placed entities -> own collection to avoid asset meshes being placed entities. Add shotgun art

main
parent aeeb9bfb0a
commit fc0c9e766d

@ -6,6 +6,8 @@ RPG GPT. Short experience
# Important Building Steps and Contribution Notes # Important Building Steps and Contribution Notes
Every time you checkin/clone the project, you have to unzip art.blend... If this is annoying to you, make a git hook Every time you checkin/clone the project, you have to unzip art.blend... If this is annoying to you, make a git hook
When editing Exporter.py in either the blender editor, or in a text editor in the repo, you have to continually make sure blender's internal version of the script doesn't go out of date with the actual script on disk, by either saving consistently from blender to disk if you're editing from blender, or by reloading from disk in the blend file before each commit.
Be very cautious about committing a change to any large asset files, i.e the art.blend and png files. Every time you do so, even if you change one little thing like moving the player somewhere, you copy the entire file in git lfs, ballooning the storage usage of the git project on the remote. So just try to minimize edits to those big files. Be very cautious about committing a change to any large asset files, i.e the art.blend and png files. Every time you do so, even if you change one little thing like moving the player somewhere, you copy the entire file in git lfs, ballooning the storage usage of the git project on the remote. So just try to minimize edits to those big files.
You must clone with git lfs is, and download git lfs files in this repository. If you don't know what that is, google it You must clone with git lfs is, and download git lfs files in this repository. If you don't know what that is, google it

@ -109,7 +109,7 @@ def ensure_tex_saved_and_get_name(o) -> str:
if img_obj.packed_file: if img_obj.packed_file:
img_obj.save(filepath=bpy.path.abspath(save_to)) img_obj.save(filepath=bpy.path.abspath(save_to))
else: else:
assert img_obj.filepath != "", f"{img_obj.filepath} in mesh {mesh_name} Isn't there but should be, as it has no packed image" assert img_obj.filepath != "", f"filepath '{img_obj.filepath}' in mesh {mesh_name} Isn't there but should be, as it has no packed image"
old_path = bpy.path.abspath(img_obj.filepath) old_path = bpy.path.abspath(img_obj.filepath)
if not is_file_in_project(old_path): if not is_file_in_project(old_path):
print(f"Image {image_filename} has filepath {img_obj.filepath}, outside of the current directory. So we're copying it baby. Hoo-rah!") print(f"Image {image_filename} has filepath {img_obj.filepath}, outside of the current directory. So we're copying it baby. Hoo-rah!")
@ -123,11 +123,12 @@ def ensure_tex_saved_and_get_name(o) -> str:
return image_filename return image_filename
def object_in_level(o):
return o.users_collection[0].name == "Level" or (o.users_collection[0] in D.collections["Level"].children_recursive)
# meshes can either be Meshes, or Armatures. Armatures contain all mesh data to draw it, and any anims it has def object_in_collection(o, collection):
"""Probably only works for root level collections"""
return o.users_collection[0].name == collection or (o.users_collection[0] in D.collections[collection].children_recursive)
# meshes can either be Meshes, or Armatures. Armatures contain all mesh data to draw it, and any anims it has
for o in D.objects: for o in D.objects:
if o.hide_get(): continue if o.hide_get(): continue
if o.type == "MESH": if o.type == "MESH":
@ -135,7 +136,7 @@ for o in D.objects:
mesh_object = o mesh_object = o
o = o.parent o = o.parent
object_transform_info = (mesh_name, mapping @ o.location, o.rotation_euler, o.scale) object_transform_info = (mesh_name, mapping @ o.location, o.rotation_euler, o.scale)
if object_in_level(o): if object_in_collection(o, "Level") or object_in_collection(o, "PlacedEntities"):
assert False, "Cannot put armatures in the level. The level is for static placed meshes. For dynamic entities, you put them outside of the level collection, their entity kind is encoded, and the game code decides how to draw them" assert False, "Cannot put armatures in the level. The level is for static placed meshes. For dynamic entities, you put them outside of the level collection, their entity kind is encoded, and the game code decides how to draw them"
else: else:
pass pass
@ -289,20 +290,20 @@ for o in D.objects:
object_transform_info = (mesh_name, mapping @ o.location, o.rotation_euler, o.scale) object_transform_info = (mesh_name, mapping @ o.location, o.rotation_euler, o.scale)
if object_in_level(o) and mesh_name == "CollisionCube": if object_in_collection(o, "Level") and mesh_name == "CollisionCube":
collision_cubes.append((o.location, o.dimensions)) collision_cubes.append((o.location, o.dimensions))
else: else:
if object_in_level(o): if object_in_collection(o, "Level"):
print(f"Object {o.name} has mesh name {o.to_mesh().name}") print(f"Object {o.name} has mesh name {o.to_mesh().name}")
assert(o.rotation_euler.order == 'XYZ') assert(o.rotation_euler.order == 'XYZ')
level_object_data.append(object_transform_info) level_object_data.append(object_transform_info)
else: elif object_in_collection(o, "PlacedEntities"):
placed_entities.append((o.name,) + object_transform_info) placed_entities.append((o.name,) + object_transform_info)
if mesh_name in saved_meshes: if mesh_name in saved_meshes:
continue continue
saved_meshes.add(mesh_name) saved_meshes.add(mesh_name)
print(f"Mesh name {mesh_name} in level {object_in_level(o)} collections {o.users_collection}") print(f"""Mesh name {mesh_name} in level {object_in_collection(o, "Level")} collections {o.users_collection}""")
image_filename = ensure_tex_saved_and_get_name(o) image_filename = ensure_tex_saved_and_get_name(o)
assert(mesh_name != LEVEL_EXPORT_NAME) assert(mesh_name != LEVEL_EXPORT_NAME)

BIN
art/Shotgun.png (Stored with Git LFS)

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save