taniwha

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

Recommended Posts

oi taniwha,does exporting work yet?i have a serious urge to make a small mod but i just cant seem to find out how to export models to .mu and this addon seems like just the right thing

Share this post


Link to post
Share on other sites

@DrexW: exporting of what, in particular? AFAIK, the only thing not working currently is skinned meshes and bones.

Share this post


Link to post
Share on other sites

exporting of a blender model.textures are not required,nor do they work,since each time i attempt to export the model blender gives me an error

Share this post


Link to post
Share on other sites

@DrexW: I'm sorry, but I need specifics. What is the error? What steps did you perform to get the error? Also, have you grabbed the latest updates (3 days ago as of this post)? [note, you need to use git].

At a guess, the error you are getting is about missing UV maps. This was fixed three weeks ago.

Share this post


Link to post
Share on other sites

I have removed the version from the thread title as it is quite incorrect and I have not done an actual release since 1.0.0, nor do I plan to do an actual release any time soon. However, I very much do plan on continuing development.

Share this post


Link to post
Share on other sites

actually,nevermind,it was textures messing it up,after doing a quick uv re-map it was fine

Share this post


Link to post
Share on other sites

@LatiMacciato: just a heads-up to let you know this exists. Thought it better than derailing the KPBS thread too much.

Edited by taniwha

Share this post


Link to post
Share on other sites
20 hours ago, taniwha said:

@LatiMacciato: just a heads-up to let you know this exists. Thought it better than derailing the KPBS thread too much.

I've yet get to get used with Blender (I'm used to C4D tho, unsure how to make meshes that fillfill the requirements for KSP).
I might get behind it eventually, in a far far future LOL.

Share this post


Link to post
Share on other sites

Ive found this useful for locating specific meshes to exclude for TU shaders. This is going to help me a lot with my future project ;). Thanks a bunch!

Share this post


Link to post
Share on other sites

How practical would it be to take the .mu reading code and teach it to dump the part properties to the command line instead?

I'm looking for a way to see the CoG, CoP etc baked into the part, and it's amazingly opaque in KSP.

edit: https://github.com/taniwha/io_object_mu

python dump.py /path/to/KSP_linux/GameData/Squad/Parts/Command/Mk1-3Pod/Mk1-3.mu

shows me the model metadata, but I don't see the CoG there. Hint? Is it part of

M1-3 Pod
  lp (-1.4010000228881836, 0.0, 0.0)
  lr (1.0, -0.0, -0.0, -0.0)
  ls (1.0, 1.0, 1.0)

Edit, from the code

    print("%s  lp %s" % ("    " * level, str(trans.localPosition)))
    print("%s  lr %s" % ("    " * level, str(trans.localRotation)))
    print("%s  ls %s" % ("    " * level, str(trans.localScale)))

so "localPosition", "localRotation" and "localScale" respectively.

I'm assuming that localPosition is the default CoM, but some insight would be a huge help.

Also, do your vectors have the same component-order as the ModuleManager vectors? Because lp would make way more sense if it were (0.0, -1.4, 0.0) for the CM...

(Fascinatingly, this shows me that the mk1-3 pod does have RCS ports in its model, but they're unnamed. Wonder if that means I can't enable them from ModuleManager - I've wanted to make RCS stock on all pods).

Also, Kia-Ora from an Aoterora expat in the big flat red place.

Edited by ringerc

Share this post


Link to post
Share on other sites

this tool is great.however,i cant import .craft files.

Quote

Traceback (most recent call last):
  File "D:\new\blender\2.79\scripts\addons\io_object_mu-master\import_craft.py", line 93, in execute
    return import_craft_op(self, context, **keywords)
  File "D:\new\blender\2.79\scripts\addons\io_object_mu-master\import_craft.py", line 74, in import_craft_op
    obj = import_craft(filepath)
  File "D:\new\blender\2.79\scripts\addons\io_object_mu-master\import_craft.py", line 41, in import_craft
    gamedata = GameData(Preferences().GameData)
  File "D:\new\blender\2.79\scripts\addons\io_object_mu-master\__init__.py", line 146, in Preferences
    return addons["io_object_mu"].preferences
KeyError: 'bpy_prop_collection[key]: key "io_object_mu" not found'

location: <unknown location>:-1

that's the error code,how can i solve this problem?

(thanks for your tool!)

(please forgive me for my poor English)

Share this post


Link to post
Share on other sites

@DAWN: rename your io_object_mu-master directory to io_object_mu.

@ringerc: The default COM for a part is the root object. When you import a .mu into blender, press alt-g to ensure the model is at blender's origin. Blender's origin is then the part's COM unless the COM has been offset in the .cfg file. If the cfg does set the COM offset, move the whole model in the opposite direction: blender's origin will then be the part's COM.

I doubt it's much more useful to your purposes, but you might find mucfg.py more interesting that dump.py: it dumps the model data as a KSP cfg file (nothing reads it yet, though).

Edited by taniwha

Share this post


Link to post
Share on other sites

@taniwha I can't express how happy I am to read about the revival of the .mu importer. Even more so that you took on the task to fix it. I always loved making renders out of this thing until it became outdated... and to see it come back again just opens up memories to this great blender addon. I've tried working around the code for this one but I got stumped by it. I guess my time away from KSP and the blender importer really came in effect. The game version was 1.4.3 and even a single part fuel tank craft would load up the axis but not the physical model. 

(and keep up the good work! It's exciting to see this addon resurface on this forum :cool:)

If the album doesn't work because I forgot how to work the forums too, here is the link.

Album GsdbU1w will appear when post is submitted
I give up on albums:
Spoiler

p1STcgj.png

J7bu8s6.png

 

 

 

Edited by ghostbuzzer7
Forum changes too much.

Share this post


Link to post
Share on other sites

Using Blender 2.79 and git version 49e9ab0 , Trying to import a .craft file gave me this error:

Traceback (most recent call last):
  File "D:\Blender Foundation\Blender\2.79\scripts\addons\io_object_mu\import_craft.py", line 95, in execute
    return import_craft_op(self, context, **keywords)
  File "D:\Blender Foundation\Blender\2.79\scripts\addons\io_object_mu\import_craft.py", line 70, in import_craft_op
    obj = import_craft(filepath)
  File "D:\Blender Foundation\Blender\2.79\scripts\addons\io_object_mu\import_craft.py", line 56, in import_craft
    part = gamedata.parts[pname].get_model()
  File "D:\Blender Foundation\Blender\2.79\scripts\addons\io_object_mu\part.py", line 68, in get_model
    self.cfg, loaded_parts_scene())
  File "D:\Blender Foundation\Blender\2.79\scripts\addons\io_object_mu\model.py", line 57, in compile_model
    scale = parse_vector(n.GetValue("scale"))
NameError: name 'parse_vector' is not defined

It doesn't seem to happen for every craft, though. The one I pasted this from was RO RN Sputnik 1 (though it did happen with some others as well.)

 

Also, the "Install KSP Shader Presets" button gave this error:

Traceback (most recent call last):
  File "D:\Blender Foundation\Blender\2.79\scripts\addons\io_object_mu\preferences.py", line 55, in execute
    install_presets("shaders")
  File "D:\Blender Foundation\Blender\2.79\scripts\addons\io_object_mu\preferences.py", line 30, in install_presets
    dst=presets[-1] + "/" + shader.IO_OBJECT_MU_MT_shader_presets.preset_subdir
NameError: name 'shader' is not defined

 

Edited by Maeyanie

Share this post


Link to post
Share on other sites

^
I get the same error when trying to install the shaders, also on 2.79 (Steam) 

The creating of color palettes is also giving an error. 
unknown.png

Edited by VentZer0

Share this post


Link to post
Share on other sites

I am currently working on support for blender 2.8 (available on the blender2.8 branch). While there are still some warts, the very basics are mostly working: importing .mu files works except for the blender material setup, exporting .mu files works but due to a missing feature in blender 2.8, the volume calculations are broken (I imagine most people didn't know about that feature anyway :P )

Share this post


Link to post
Share on other sites

Is there any chance you could offload the byte format stuff for .mu files into a compiled .dll so as to allow .mu files to be read? Namely, I am looking to read a .mu and get a list of mesh names, material names, and texture paths from those materials. I am working on a WPF app to create/edit parts via GUI, and the mesh and material names are needed to pre-fill drop-downs for some values in PartModule config sections. It also has a sub-feature for scanning the mod folder for orphaned files, such as unused textures.

Share this post


Link to post
Share on other sites
3 hours ago, Electrocutor said:

Is there any chance you could offload the byte format stuff for .mu files into a compiled .dll so as to allow .mu files to be read? Namely, I am looking to read a .mu and get a list of mesh names, material names, and texture paths from those materials. I am working on a WPF app to create/edit parts via GUI, and the mesh and material names are needed to pre-fill drop-downs for some values in PartModule config sections. It also has a sub-feature for scanning the mod folder for orphaned files, such as unused textures.

Have you tried https://github.com/sarbian/DebugStuff

Share this post


Link to post
Share on other sites

@Electrocutor: the file handling code is already in a separate file, mu.py, and there are already several tools ini the io_object_mu directory that use it to do various things, just as jumping the .mu file to .cfg node, edit wheel collider parameters (not so useful since KSP 1.1), and convert all mesh colliders to convex hulls, amongst others. Some of those tools came before the importer, even.

Share this post


Link to post
Share on other sites
20 minutes ago, taniwha said:

@Electrocutor: the file handling code is already in a separate file, mu.py, and there are already several tools ini the io_object_mu directory that use it to do various things, just as jumping the .mu file to .cfg node, edit wheel collider parameters (not so useful since KSP 1.1), and convert all mesh colliders to convex hulls, amongst others. Some of those tools came before the importer, even.

Alright, thanks. I'll see if I can find a decent python to c# converter.

Share this post


Link to post
Share on other sites

@taniwha

I import a .mu, change the material properties (there is only one), and then export it, but the new render seems to have only rendered 1/4, while the rest are now black. Any ideas?

suI7Ttv.jpg

Share this post


Link to post
Share on other sites

As Blender 2.80 has finally gone beta, I have merged my blender2.8 branch into master and created a blender2.79 branch to continue support for 2.79.

This update brings a lot to the table:

  • Much faster import of dds images, especially dds normal maps (shader hacks to do the conversions instead of in python).
  • Much better blender material creation from KSP shaders (not all shaders supported yet). Looks great with Eevee :).
  • Initial skinned mesh/armature support (animations broken still).
  • Support for CoMOffset, CoPOffset and CoLOffset when generating cfg files from cfg.in (just add an empty with the right name to your hierarchy).
  • Full support for collection instancing (including nested collections) on export.
  • Better collider workflow (don't need to add a zillion empties for complex collider setups).
  • Duplicated primitive colliders (sphere/box/capsule/wheel) do copy-on-write when a duplicate is tweaked.
  • Models are now always imported at the cursor.
  • Directory hierarchy cleaned up: much easier to find the command line utilities.
  • Mu Tools buttons moved to blender's new tool properties panel.
  • Clear parent inverse tool added: recursively clears the parent inverse transform of objects. This is necessary for correct transform handling in Unity, and makes for cleaner animations in blender anyway (yeah, what is "parent inverse transform"? Hard to explain but the important thing is that blender's default parenting behavior will mess up your hierarchy if the parent object is transformed).
  • Attach node transforms import correctly (ie, correct orientation)

There are bugs still (and likely will be some due to recent blender API changes), but I have been using blender 2.80 for "production" for a while now.

Share this post


Link to post
Share on other sites

I have just pushed (to both master and the blender2.79 branch) a fix for incorrectly exported tangent vectors.

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.