taniwha

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

Recommended Posts

Posted (edited)

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

Share this post


Link to post
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".

Share this post


Link to post
Share on other sites

@Olympic1: the problem was exactly what I thought it was: two skins sharing the skeleton. That is fixed, but it turns out I've got the fcurve transformation wrong so that still needs fixing.

Share this post


Link to post
Share on other sites
Posted (edited)

@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

Share this post


Link to post
Share on other sites

@taniwha Thx for trying to fix this, I really appreciate your work for this addon

Share this post


Link to post
Share on other sites

I got the rotations sorted out. There's still a problem with either bind pose setup or location/scale animation, but it works much better now.

Share this post


Link to post
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 :).

Share this post


Link to post
Share on other sites
Posted (edited)

@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

Share this post


Link to post
Share on other sites

Hello !

I have just one question : how to use the mesh collider ?

When i want to add one, blender send me an error message. 

So thank you for your help ! :)

Share this post


Link to post
Share on other sites

@Lgg159: sorry, I need more details. I just tried all the mesh collider options (in blender 2.80) and they all worked.

Share this post


Link to post
Share on other sites

@taniwha Ok the problem come from an older version of your addon. I've downloaded the last one and the problem is gone.

But thank you anyway ! :D

 

 

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

@taniwha

Never mind, my shortcut was going to the wrong Blender

Edited by linuxgurugamer

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.