Jump to content

[1.2-1.7] Blender (2.83+) .mu import/export addon


Recommended Posts

I have finally got armature (ie, skinned mesh renderer with bone deformation) support working, for both import (which it wasn't, really, before) and export, including animation of bones.

(post got merged)

@Olympic1: oh, great :/ well, thanks, I'll look into that (I did my testing on the launch clamp and @Angel-125's DSEV centrifuge).

Edited by taniwha
Link to comment
Share on other sites

Yeah, that's pretty messed up. Just a general failure all-round.

I see the problem, though: it's because there are two skins sharing the one armature hierarchy. I was wondering if I would need to support that situation. It looks like the answer is a resounding "yes".

Link to comment
Share on other sites

@Olympic1: another update: the cause of the fcurve problem is that it seems the skeleton/armature is not anywhere near the skins in the hierarchy. I'm not sure how, of even if, I can automate this.

[edit] or at least partially caused by that

[edit 2] Actually, I'm not sure about that at all. Not one skirt bone has a nice rotation, and none of the skirt bones work properly. The switches are all unrotated and do work properly. I did noticed while getting export that blender's bone rotation fcurves are in bone space (location can be forced to be parent space), so I guess I've got to figure out what I'm doing wrong with the rotations.

Edited by taniwha
Link to comment
Share on other sites

@LatiMacciato: Answering here not because it's off topic in EL, but because it's on topic here :) (others with similar questions are more likely to look here).

Dealing with textures for KSP in blender varies in difficulty: most difficult being dds (they're upside down). However...

UVs are are done the same way as any other blender model. The exporter uses the first layer on the list (and only one layer because when I tried supporting two, I found that KSP ignored the second layer).

That's the easy part (hah, from what I've heard from other modders regarding UVs...) done...

Materials are a little fiddly, but not too bad...

Before doing anything (this is generally once-only), ensure the shader presets are installed: in User Preferences -> Add-ons, open the Mu model import panel. You should find a Shaders section with an "Install KSP Shader Presets" button. Click that, it will install a bunch of shader configs that you can use later. (config templates are a little advanced and off topic for this post, but the color palettes might interest you (for texture and image painting in blender). gamedata path is for importing craft files).

With your object selected, go to the materials panel and add a material (make sure it's connected to the mesh rather than the object: dropdown to the right of the new material button/material name). Then scroll down through the panel until you find the Mu Material section. At the top of that, you will find a "Shaders" dropdown: from that select the shader you want to use (requires previous step, so if there's no list, go do that). Selecting a shader will fill in a bunch of values with reasonable defaults. The "Name" field is the name of the material in the .mu file. "Shader" is the name of the shader that will be used and must be one available to KSP when the model is loaded (Unity, KSP, or mod shader should be ok). I'll use "KSP/Diffuse" as an example because it's simple.

Below that is a series of collapsed boxes: Textures, Colors, Vectors, Float2 and Float3 (I never did figure out whether the two float types in a mu material spec can be merged, or what the exact difference is in unity): those hold the various shader properties, and those with fields in them will have a dot to the right of the bar. For KSP/Diffuse, only Textures and Colors have values. In general, you need to edit only Textures, so open that.

In there you'll find a list of shader properties (click on the one you edit, but for KSP/Diffuse, there's only _MainTex), a field with the property name (don't edit unless you know what you're doing), and below that, the name of the texture to use (default is "gray"): set this to the name of your texture (for preview in blender, you need to have an image loaded with the same name in the image editor).

I think that's pretty much it. Other shaders just have more/different properties. Note that not all shaders are supported for viewing in blender (I haven't figured out the node setup), but for those that are, they look pretty cool in Eevee render :).

Link to comment
Share on other sites

@taniwha You're just amazing!

Thank you very much for helping out! Shaders installed and the 2 other options is a very great help.
Seriously .. I was searching for the 3 Buttons for 30 mins .. yes Blender is killing me LOL but the 2.80 interface looks WAAAY better!

EDIT: I'm aware of this addon is not even alpha, tho I ran into this error when attempting to export mu file:

Spoiler

Traceback (most recent call last):
  File "<snip>/blender-2.80rc2-linux-glibc217-x86_64/2.80/scripts/addons/io_object_mu/export_mu/operators.py", line 63, in execute
    return export_mu(self, context, **keywords)
  File "<snip>/blender-2.80rc2-linux-glibc217-x86_64/2.80/scripts/addons/io_object_mu/export_mu/operators.py", line 34, in export_mu
    mu = export.export_object (context.active_object, filepath)
  File "<snip>/blender-2.80rc2-linux-glibc217-x86_64/2.80/scripts/addons/io_object_mu/export_mu/export.py", line 157, in export_object
    mu.obj = make_obj(mu, obj, "")
  File "<snip>blender-2.80rc2-linux-glibc217-x86_64/2.80/scripts/addons/io_object_mu/export_mu/export.py", line 120, in make_obj
    return make_obj_core(mu, obj, path, muobj)
  File "<snip>/blender-2.80rc2-linux-glibc217-x86_64/2.80/scripts/addons/io_object_mu/export_mu/export.py", line 109, in make_obj_core
    child = make_obj(mu, o, path)
  File "<snip>/blender-2.80rc2-linux-glibc217-x86_64/2.80/scripts/addons/io_object_mu/export_mu/export.py", line 120, in make_obj
    return make_obj_core(mu, obj, path, muobj)
  File "<snip>/blender-2.80rc2-linux-glibc217-x86_64/2.80/scripts/addons/io_object_mu/export_mu/export.py", line 89, in make_obj_core
    muobj = type_handlers[type(obj.data)](obj, muobj, mu)
  File "<snip>/blender-2.80rc2-linux-glibc217-x86_64/2.80/scripts/addons/io_object_mu/export_mu/mesh.py", line 237, in handle_mesh
    muobj.renderer = make_renderer(mu, obj.data)
  File "<snip>/blender-2.80rc2-linux-glibc217-x86_64/2.80/scripts/addons/io_object_mu/export_mu/mesh.py", line 182, in make_renderer
    rend.materials = mesh_materials(mu, mesh)
  File "<snip>/blender-2.80rc2-linux-glibc217-x86_64/2.80/scripts/addons/io_object_mu/export_mu/mesh.py", line 173, in mesh_materials
    if mat.mumatprop.shaderName:
AttributeError: 'NoneType' object has no attribute 'mumatprop'

location: <unknown location>:-1

 

EDIT 2: Hierarchy resorting helped! I had the RecycleField object/collider next to the main object, but should have been as part inside of the main mesh.

Edited by LatiMacciato
Link to comment
Share on other sites

  • 2 weeks later...

When importing .mu or .craft, are they supposed to have their textures automatically? If so, I think mine is configured incorrectly

https://www.dropbox.com/s/v90xpqpxqem3j8u/Screenshot 2019-08-02 18.13.45.png

EDIT: Ignore me. I'm a Blender noob and was just missing a critical step. Herp derp

Edited by seanth
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
On 8/2/2019 at 4:15 PM, seanth said:

When importing .mu or .craft, are they supposed to have their textures automatically? If so, I think mine is configured incorrectly

https://www.dropbox.com/s/v90xpqpxqem3j8u/Screenshot 2019-08-02 18.13.45.png

EDIT: Ignore me. I'm a Blender noob and was just missing a critical step. Herp derp

My textures aren't working, and rather than digging through this thread to try and find an answer, could you explain to me what you did to fix your problem?

Link to comment
Share on other sites

  • 2 weeks later...

Ok, so back to my original problem.  Blender 2.80, and the plugin cloned today

I'm importing a tank into Blender.  

I rename the main object

So far, so good.  To export, I select the collection, and then do the export.

But when I load this into KSP, the tank is on it's side

What can I do to fix this?

Thanks in advance

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
On 9/26/2019 at 2:30 PM, ceceriboli said:

Hi @taniwha, I would like to import a whole craft to Blender. Is it possibile using this Plugin? Because I tried but got an error.

You need to set gamedata folder location in Preferences> expand mu importer addon info. However if you have a lot of mods the addon will freak out

Link to comment
Share on other sites

  • 2 weeks later...
Quote

Traceback (most recent call last):
  File "E:\SteamLibrary\steamapps\common\Blender\2.80\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 106, in execute
    return import_craft_op(self, context, **keywords)
  File "E:\SteamLibrary\steamapps\common\Blender\2.80\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 80, in import_craft_op
    obj = import_craft(filepath)
  File "E:\SteamLibrary\steamapps\common\Blender\2.80\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 60, in import_craft
    part = gamedata.parts[pname].get_model()
  File "E:\SteamLibrary\steamapps\common\Blender\2.80\scripts\addons\io_object_mu-master\import_craft\part.py", line 70, in get_model
    Vector((1, 1, 1)) * scale)
  File "E:\SteamLibrary\steamapps\common\Blender\2.80\scripts\addons\io_object_mu-master\import_craft\part.py", line 76, in instantiate
    obj.instance_collection = self.model
ReferenceError: StructRNA of type Collection has been removed

location: <unknown location>:-1

This is the series of error I got when trying to use the craft importer

Link to comment
Share on other sites

Wondering if someone could help with an issue,  my goal is to remove variants from .mu files for a mod that breaks with variants to work. After removing variants the part looks fine in shading window preview, bu in game the shading looks off.

I tried just importing a part, doing 0 changes and then exporting it, and it still breaks.  This is how it looks in the preview:
https://imgur.com/chULkio

 

In game it looks like this :

https://imgur.com/LRCOltv

 

 

And when I import it back into Blender it now looks like this, there is a line that breaks the smoothness of the surface and at that line there is drastic change in shading.
https://imgur.com/ytFwiJ7

 

Edited by Nether
Link to comment
Share on other sites

  • 2 weeks later...

@taniwha I'm assuming MultiMesh and Procedural mods are not (yet) supported?

I have the unfortunate predicament of having every ship made from B9 Proc Wings and MultiMesh parts. Are there any other mods that might not work with the plugin?

Thanks for updating this for 2.8 btw, really excited to see what I can make using this.

 

Edited by Supergamervictor
Link to comment
Share on other sites

  • 5 weeks later...

I tried to import a craft, but it is said that the file ' ' doesn't exist

Can this be fixed?

Quote

Traceback (most recent call last):
  File "C:\Users\aaliu\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 106, in execute
    return import_craft_op(self, context, **keywords)
  File "C:\Users\aaliu\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 80, in import_craft_op
    obj = import_craft(filepath)
  File "C:\Users\aaliu\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 44, in import_craft
    gamedata = GameData(Preferences().GameData)
  File "C:\Users\aaliu\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\io_object_mu-master\import_craft\gamedata.py", line 146, in __init__
    self.create_db()
  File "C:\Users\aaliu\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\io_object_mu-master\import_craft\gamedata.py", line 129, in create_db
    recurse_tree(self.root, self.build_db)
  File "C:\Users\aaliu\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\io_object_mu-master\import_craft\gamedata.py", line 29, in recurse_tree
    files = os.listdir(path)
FileNotFoundError: [WinError 3] The system cannot find the path specified: ''

location: <unknown location>:-1

 

Edited by ZeroC00l
Link to comment
Share on other sites

  • 4 weeks later...
On 9/14/2019 at 4:38 AM, linuxgurugamer said:

Ok, so back to my original problem.  Blender 2.80, and the plugin cloned today

I'm importing a tank into Blender.  

I rename the main object

So far, so good.  To export, I select the collection, and then do the export.

But when I load this into KSP, the tank is on it's side

What can I do to fix this?

Thanks in advance

Put the tank on it's side in blender, so it get's turned the right way in KSP?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...