Skip to content

Commit

Permalink
Merge pull request #3 from RealIndrit/submeshes
Browse files Browse the repository at this point in the history
Add support to split model up to submeshes to a collection
  • Loading branch information
RealIndrit authored Dec 7, 2024
2 parents 345e402 + b64ba5a commit 8dbda8b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ in no way endorse using this outside strictly personal and educational use. Any
- Release tags here on [GitHub](https://github.com/RealIndrit/blender-rsi-browser/releases/tag/1.0.0)
- Install like any other blender plugin
- Search for ship and click import
- To import Submeshes in a model go to Preferences > Addon > Separate Submeshes (Slower Import!)

Dev notes
---------
Expand Down
35 changes: 28 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,15 @@ class RSIBrowserPreferences(bpy.types.AddonPreferences):
default=False,
update=_init) # type: ignore

seperate_submeshes: bpy.props.BoolProperty(name="Separate Submeshes",
description="Splits complete loops in the mesh to their on objects for easier individual component manipulation. (SLOW IMPORT)",
default=False,
update=_init) # type: ignore

def draw(self, context):
layout = self.layout
layout.prop(self, "debug")
layout.prop(self, "seperate_submeshes")

layout.operator(RSIClearCacheOperator.bl_idname, icon="CONSOLE")

Expand Down Expand Up @@ -109,13 +115,28 @@ def execute(self, context) -> t.Set[str]:
"Blender is missing the OpenCTM import add-on, please enable it in Preferences")
return {"CANCELLED"}

for obj in bpy.context.selected_objects:
assert isinstance(obj, bpy.types.Object)
obj["rsiId"] = self.sid
obj.name = si["name"]
obj.dimensions = (si['beam'], si['length'], si['height'])
if not obj.parent:
obj.location = bpy.context.scene.cursor.location
oject_collection = bpy.data.collections.new(name=si["name"])
bpy.context.scene.collection.children.link(oject_collection)

obj = bpy.context.selected_objects[0]
assert isinstance(obj, bpy.types.Object)
obj["rsiId"] = self.sid
obj.name = si["name"]
obj.dimensions = (si['beam'], si['length'], si['height'])

if prefs.seperate_submeshes:
if obj.type == 'MESH':
bpy.context.view_layer.objects.active = obj
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.separate(type='LOOSE')
bpy.ops.object.mode_set(mode='OBJECT')

for sub_obj in bpy.context.selected_objects:
oject_collection.objects.link(sub_obj)
bpy.context.scene.collection.objects.unlink(sub_obj)

bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.layer_collection.children[
oject_collection.name]

self.report({"INFO"}, f"Imported Model successfully")
else:
Expand Down
2 changes: 1 addition & 1 deletion blender_manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
schema_version = "1.0.0"
id = "starcitizen_browser"
version = "1.1.0"
version = "1.2.0"
name = "RSI Browser"
tagline = "Search and import models from robertsspaceindustries.com"
maintainer = "RealIndrit <[email protected]>"
Expand Down

0 comments on commit 8dbda8b

Please sign in to comment.