taniwha

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

Recommended Posts

Hi, I can import fine, but the export button is visible, yet grayed out (can export to dae etc., but mu is grayed out only)? All I did was import a mu file, delete a coffee cup, and dag some cameras around, so I'm pretty confident I didn't add any unsupported things, etc. since I didn't add anything at all, or change any properties. Why is it not letting me export?

Edited by Crimeo

Share this post


Link to post
Share on other sites

@Crimeo: For the export button to be enabled, the active object must be either an empty or a mesh object. What you need to do is select the root object of the model, which will pretty much always be an empty.

KSP models are a tree of objects in parent-child relationships.

Share this post


Link to post
Share on other sites

At some point in the past GameData\Squad\Spaces\MK3_CrewCab_Int\MK3_CrewCab_Int.mu was changed and ended up with two Camera_Left004 and no Camera_Left003.

[LOG 14:21:51.447] PartLoader: Compiling Internal Space 'Squad/Spaces/MK3_CrewCab_Int/internal_MK3_CrewCab/MK3_CrewCab_Int'
[LOG 14:21:51.449] InternalSeat: Cannot find portraitCamera of name 'Camera_Left003'

While I was able to distinguish the two lights correctly and changing the mu in a hex-editor is working this is not the way I wanna go.

I followed the instructions seen in thread as simple as they are and importing works fine. Renaming the two lights (Camera_Left004 becomes Camera_Left003 and Camera_Left004.001 becomes Camera_Left004) is simple. But it seems I'm missing something when I try to export the mu:

Spoiler

MK3_Crew_Cab_Int.png

A 2.04 MB mu becomes a 592 KB one. Including the expected error in ksp.log. What am I doing wrong in Blender?

Thanks in advance

Share this post


Link to post
Share on other sites

This may or may not be the cause of the errors, but I was able to export the internal (unmodified) just fine: you need to select the root object of the heirarchy. This is the empty named "MK3_CrewCabin_Int", and  is at the root of the tree in the scene view (currently hidden under your error panel). If you select only that empty, it should work.

Share this post


Link to post
Share on other sites

Thanks for reply.

You can see the highlighted (white) "MK3_CrewCabin_Int" root object between the third and fourth line hidden under the error panel. I've also moved the "Select" snippet to show this better.

I've followed your instruction and only selected the root object "MK3_CrewCabin_Int":

Spoiler

MK3_Crew_Cab_Int_2.png

Same result.

Just to make sure there is no other flaw on my side:

  • Extracted https://github.com/taniwha/io_object_mu/releases io_object_mu-1.0.0.zip ... C:\Program Files\Blender Foundation\Blender\2.78\scripts\addons\io_object_mu\*.py
  • Blender 2.78c in Blender mode
  • I've also tried to rename the four *.mbm to *.dds in MK3_CrewCab_Int.mu just in case the missing textures would be the problem - same result.
  • But does Blender support dds? No. So I changed *.mbm to *.png in mu and converted *.dds to *.png - same result.
  • I've tried to import/export unmodified Squad\Spaces\MK3_CrewCab_Int\MK3_CrewCab_Int.mu - same result.
  • I've also tried to import/export unmodified Squad\Parts\Command\mk1Cockpits\CockpitStandard.mu - similar result.
  • Ok, last info: Windows 10 x64. Could it be that the import/export doesn't work with x64? No. Same result with Blender for x32.

You've said it works fine for you. So there has to be something on my side. Any ideas?

As a wise man said:

Quote

There is no can't. -- Duun

It's better to have it and not need it than to need it and not have it. -- taniwha

 

Share this post


Link to post
Share on other sites

Actually, I found the change that fixed the bug you're encountering: Tue May 10 18:06:50 2016 +0900.

Update by cloning from github (rather than downloading any zips). That way, in the future you can update just by doing a "git pull".

 

Share this post


Link to post
Share on other sites

First things first - no error when exporting.

Here are the results:

Spoiler

Both are very similar, both throw no error in ksp.log but now none of the 16 portraitCameras can be found:

Spoiler

[LOG 12:22:31.034] PartLoader: Compiling Internal Space 'Squad/Spaces/MK3_CrewCab_Int/internal_MK3_CrewCab/MK3_CrewCab_Int'
[LOG 12:22:31.036] InternalSeat: Cannot find portraitCamera of name 'Camera_Left001'
[LOG 12:22:31.037] InternalSeat: Cannot find portraitCamera of name 'Camera_Left002'
[LOG 12:22:31.038] InternalSeat: Cannot find portraitCamera of name 'Camera_Left003'
[LOG 12:22:31.039] InternalSeat: Cannot find portraitCamera of name 'Camera_Left004'
[LOG 12:22:31.039] InternalSeat: Cannot find portraitCamera of name 'Camera_Left005'
[LOG 12:22:31.040] InternalSeat: Cannot find portraitCamera of name 'Camera_Left006'
[LOG 12:22:31.041] InternalSeat: Cannot find portraitCamera of name 'Camera_Left007'
[LOG 12:22:31.042] InternalSeat: Cannot find portraitCamera of name 'Camera_Left008'
[LOG 12:22:31.043] InternalSeat: Cannot find portraitCamera of name 'Camera_Right001'
[LOG 12:22:31.044] InternalSeat: Cannot find portraitCamera of name 'Camera_Right002'
[LOG 12:22:31.045] InternalSeat: Cannot find portraitCamera of name 'Camera_Right003'
[LOG 12:22:31.045] InternalSeat: Cannot find portraitCamera of name 'Camera_Right004'
[LOG 12:22:31.046] InternalSeat: Cannot find portraitCamera of name 'Camera_Right005'
[LOG 12:22:31.047] InternalSeat: Cannot find portraitCamera of name 'Camera_Right006'
[LOG 12:22:31.048] InternalSeat: Cannot find portraitCamera of name 'Camera_Right007'
[LOG 12:22:31.049] InternalSeat: Cannot find portraitCamera of name 'Camera_Right008'

The original mu has 2,148,245 bytes. After import/export both end up a bit larger: 2,454,640 bytes. I wasn't expecting the same size but with rearranging the data and no deeper knowledge about the format I would have to start from scratch analysing the files. I hope you can fiddle it out. Or in case you create different, hopefully correct results you can tell me how to avoid making something wrong.

Sorry for not mentioning before, it's a clean KSP install, no mods.

Share this post


Link to post
Share on other sites

That is odd, the cameras are there in my test export. As for analyzing the file, take a look at dump.py in the io_object_mu, it's a tool I created to help me debug various issues.

Share this post


Link to post
Share on other sites

The cameras don't vanish. You can see them in the exported mu's I've uploaded for you. Imported again in Blender the cameras are all there.

In game I've noticed no visual difference. Using "V" in IVA there are four views in Squad (Left003 missing), Hacked (none missing) and Blender-export (all 16 missing). As posted before there are no ERR but LOG entries in ksp.log. Locating the reason why was no problem. Solving it due a hack (changing 0x20c3bd from 0x34 to 0x33, Blender helped in locating the wrong Left004) is easy and the LOG entry vanishes, ksp is happy. After import/rename/export ksp can (now) still read and display mu somewhat correctly. While ksp claims to be unable to find the 16 portraitCameras in ksp.log they are somehow still accessible. Or they are simply not used anymore as there are four seats in Mk3 Cockpit and you can switch through them using any of the three different mu's. Nonetheless the portraitCameras are recognized but the related data can't be found by ksp.

On 27.9.2013 at 2:50 PM, taniwha said:

Try liquidEngine1 (that's what I used for initial testing). It's the LV-T30, and I've just confirmed it's version 1.

Also: what errors are you getting?

So I tried the LV-T30. Import/export, just made sure that "liquidEngine1" was selected. Result on my side is a very different mu file in size and content (http://s000.tinyupload.com/?file_id=65345131473896721265). Also ksp seems to be happy on a first try to fly this new "liquidEngine1" while the mu-file was missing "HeatAnimationEmissive" (at 0xb8) and many more. Neither are there new entries in ksp.log. As this was the test file you've used before I'm sure you can see at a glance what's wrong with the result I've produced. I assume I simply miss some important click you haven't mentioned because it's so obvious to anybody familiar with Blender. But as I've mentioned, I've installed Blender the day before and am anything else but familiar with it.

I would like to use your tool but I have to know at least what to do to produce working mu's. There are many happy kerbals out there writing you've done a tremendous job. Conclusion: I'm missing some simple but essential information.

Edited by khr15714n

Share this post


Link to post
Share on other sites

Quick question: What criteria is used to split edges on import? Are any two faces that meet at an angle automatically split? Or is it something else?

I noticed when importing the mk2 crew cabin internals that the cargo bags became blocky looking due to edges being split. These are smooth in the original, so I had to merge the edges back manually to restore the desired look.

blockycargobag.png

I'm working on something that requires rebuilding the stock parts (with some modification), so knowing what to look out for would be very helpful -- i.e. knowing where to find undesirable split edges so they can be merged back accordingly.

 

Share this post


Link to post
Share on other sites

Problems with things looking blocky on import are because I haven't figured out how to set vertex normals in blender. However, I'm pretty sure I was able to extract vertex normals properly (my exported modes are smooth).

Share this post


Link to post
Share on other sites

Ah, so the edges were split to begin with, but without setting vertex normals they default to the face normal. Same visual outcome. Thanks for clarifying.

I think my workaround -- merging the edges -- should still do the trick?
If I understand the situation correctly, this is pretty much betting on the general case being a smooth edge -- normals averaged from the adjoining faces.
If the original mesh had some other custom vertex normals set, then all bets are off I guess.

Share this post


Link to post
Share on other sites

I am trying to use this on windows and am having trouble importing. I have tried re-downloading and re-installing everything and am only using stock crafts.
I receive the attached report from the command window.
16b5de8295304774bbf6f187fd3daed3.png
Is it because KSP was just updated to 1/3?

Share this post


Link to post
Share on other sites
On 5/29/2017 at 10:22 PM, cakepie said:

If I understand the situation correctly, this is pretty much betting on the general case being a smooth edge -- normals averaged from the adjoining faces.
If the original mesh had some other custom vertex normals set, then all bets are off I guess.

Unfortunately, yes. However, I have yet to see a model that has custom vertex normals, so it's not all bad.


@Dynames: This is something about which I forgot: the location of KSP's GameData is hard-coded in import_craft.py. However, the hard-coding is in only one place and is easy to fix. Near the top (should be line 37), you will find a line saying:

gamedata = "/home/bill/ksp/KSP_linux-ckan/GameData"

Simply change the contents of the quotes to be the path to your KSP's GameData. Note that / works just as well in windows as it does in linux, and that \ needs to be specified as \\ (eg, "c:/KSP/GameData" or "c:\\KSP\\GameData").

Share this post


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

I have yet to see a model that has custom vertex normals

Reassuring to know. Thanks!

Share this post


Link to post
Share on other sites

Thanks Taniwha,

I have changed the path, but now it is still throwing me another error.
I feel like I should be able to figure this out, but I am not a programmer. Just trying to get it to work so my students at school can print off their prototypescd17244c7b374734b3b436410ab3b0d2.png

Share this post


Link to post
Share on other sites

@Dynames: if you grab the latest version, it should be fixed (though you'll need to fix the path again). KSP 1.3's i18n support broke my ConfigNode parser slightly.

Share this post


Link to post
Share on other sites

It's posible that, if you have an .MU file of a model that wasn't maded in Blender, then this Addon don't recognize the format of the file and can't load it?

Share this post


Link to post
Share on other sites

@GonDragon: Just this morning I pushed a commit that makes the addon recognize version 5 .mu files, so I suspect that's your problem.

Also committed changes such that attach nodes are exported as NODE{} allowing access to the other attach node options.

Share this post


Link to post
Share on other sites

Just discovered this.  Easy to install.

I have no idea how to use Blender, but now I can convert the .mu files to .stl.

You've made my printers very happy.  Thank you!

Edited by Geonovast

Share this post


Link to post
Share on other sites

Hi - have been trying to use the mu importer addon (with Blender 2.78 on Mac)

Always get the following error - any ideas?

 Ben
 Nr76vsG.png

 

Share this post


Link to post
Share on other sites

Hmm, the code there looks a little bogus. I need to double check what I had in mind because I'm not sure what the right fix would be. Thanks for the report.

Share this post


Link to post
Share on other sites

Looks like this has no trouble with Stock models, but I get all kinds of errors when trying to import an .mu from the KSO mod.  

4z8Wbbb.png

Is there any other way to get an object list from an .mu file? All I really need is to know what the object inside super25commandkso.mu is called.

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.