Jump to content

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


Recommended Posts

@Briso: you need a more recent blender. I know 2.83 works. I didn't realize VertexColors was new.

@Sparrowhawk: They're tucked away. Go to the outliner, set it to "Scenes" mode, click on the "mu_utils" scene (this will switch you to that scene, so clicking on "Scene" will take you back to the default scene), then switch the outliner back to "View Layer" mode (alternatively, you can have two outlines open: one in scenes mode, the other in outline). You will probably need to turn on the extra vis/selection options: do so by clicking the funnel icon in the upper right and enabling "select" "disable in viewports" and "disable in render". You'll then be able to make the collection you want selectible and visible (and renderable if you so choose). To edit the part models, you will want the "loaded_models" collection. the model you want will be in there. Note that editing these objects will edit all instances of them.

As additional information: loaded_parts holds the "compile parts" much like the parts list in KSP (some parts are made up of multiple models). "craft_collection" holds the assembled craft (much like the VAB or SPH (or even out in flight).

Link to comment
Share on other sites

Hi, having errors trying to import craft in. Which is strange, since I was previously able to successfully import a craft once, then the importer just seemed to break once I tried importing other things. Could be related to the other things having some mod parts that wouldn't load correctly?

Here's the log that shows up after trying to import a craft the previously successfully imported:

J7rAdtu.png

 

 

 

EDIT: ok, I guess I just tried something dumb right after I posted this; I opened up a brand new file and tried the importer again and it functions now again. Will see if I can get it to break again.

 

Here's a different problem, and I have a gist of what might be wrong, but I'm not entirely sure.

 

fBShZPF.png

 

This seems more of a problem with the part config itself than the importer, but I'm not sure what to modify in the part config such that the importer can recognize the part model associated with the config.

Edited by Box of Stardust
Link to comment
Share on other sites

For the top one, something went wrong in computing the path to the model file.

For the second one, it looks like you have no "f5jet" part in your GameData. Missing mod, perhaps?

Link to comment
Share on other sites

10 hours ago, taniwha said:

For the top one, something went wrong in computing the path to the model file.

For the second one, it looks like you have no "f5jet" part in your GameData. Missing mod, perhaps?

For the first one, it seems like the importer breaks when I try and import a craft with parts that don't load, and then from that point on, it seems that that Blender file is corrupted in terms of being able to use the importer? Just trying to report back some observations I think I've noticed.

The part is there; it's AirplanePlus's engine. How exactly does the importer locate the model for a part? Do they have to be linked as some specific name just filename-wise, or is there some internal name in the model file/.mu that gets read? If it's internal to the .mu file, I guess I'll have to do some odd editing somewhere to get it to locate the model.

Link to comment
Share on other sites

Ah, if it was a follow-on error, that might explain in.

Anyway, the way it works is it scans GameData for part config files (actually, if ModuleManager.ConfigCache is there, it reads that instead) building a part database very similar to what KSP makes. This is why craft loading is so slow the first time.

From the part config, the loader extracts the the model name(s) if MODEL nodes are used, otherwise it takes the first .mu file by ascii sort (this is exactly what KSP does, and I wasted a day figuring out why my attempts to have multiple parts in one directory would not work: don't use mesh= in your part.cfg).

Anyway, one thing I can think of for the loader not finding the parts: you have MM but you have not run KSP after  you installed a parts pack.

Link to comment
Share on other sites

Hi. I have problem with importing and then exporting some parts from Station Parts Expantion Redux mod. Such as HUB modules. B9 complains about COLLIDER* transforms not found by name. Seems like in some cases colliders get changed during import->export. Can you look into it?

Link to comment
Share on other sites

Things do get changed going through blender. Sometimes export (particularly PartTools) errors get fix, other times some optimizations, almost always certain triangle vertex indices. The process is not idempotent. However, for colliders, it's entirely possible the collider was on a separate game object in the original import but got merged into the parent game object on export. This is actually a feature (optimization), but can be overridden: find the collider object in blender, go to object properties, Mu Collider panel -> Separate. If you enable that, it will force the collider to be exported on its own game object. This is normally automatic if the parent object has more than one collider child object, but when there's only one collider child object, it will be merged into the parent unless Separate is enabled.

I thought I Made it so separate was set when importing if the collider was on its own object. If that is not the case, please submit an issue as I have a gazillion things on my plate and I'm likely to lose track of something here.

Link to comment
Share on other sites

2 hours ago, taniwha said:

Things do get changed going through blender. Sometimes export (particularly PartTools) errors get fix, other times some optimizations, almost always certain triangle vertex indices. The process is not idempotent. However, for colliders, it's entirely possible the collider was on a separate game object in the original import but got merged into the parent game object on export. This is actually a feature (optimization), but can be overridden: find the collider object in blender, go to object properties, Mu Collider panel -> Separate. If you enable that, it will force the collider to be exported on its own game object. This is normally automatic if the parent object has more than one collider child object, but when there's only one collider child object, it will be merged into the parent unless Separate is enabled.

I thought I Made it so separate was set when importing if the collider was on its own object. If that is not the case, please submit an issue as I have a gazillion things on my plate and I'm likely to lose track of something here.

Odd thing. Tried marking separate and still get error. BUT removing ".collider" from collider transform names resolved issue. Do those ".collider" addition to names needed?

Link to comment
Share on other sites

10 hours ago, taniwha said:

oh, still adding those? hmm, well they're not needed if the collider was originally on its own transform. That might be worth submitting an issue.

Thanks! Submitted. Good to know that I can just delete that addition.

 

Another question. I tried to import Centrifuges from Station part extension redux but they do not import correctly or when exported become messed up in game. Do complex animation or whatever do not supported yet?

Link to comment
Share on other sites

Oh, and I noticed that exported file always about 1.5-2 times larger than original before import.

Also!))) Importing and then exporting extendible solar panels breaks their animations. They just extends as block through closed door and do not unfold.

Link to comment
Share on other sites

10 hours ago, Battou said:

Oh, and I noticed that exported file always about 1.5-2 times larger than original before import.

That's odd. Quite often they're smaller due to useless meshes being omitted. Only things I can think of that would inflate the size are additional animation keys and additional vertex data (normals, tangents, colors)

10 hours ago, Battou said:

Also!))) Importing and then exporting extendible solar panels breaks their animations. They just extends as block through closed door and do not unfold.

This is even odder. Have you confirmed that the solar panels are animated correctly in blender?

Anyway, for both of the above, you will find a mucfg.py script in the addon director. You can use that to examine the contents of the .mu files.

python mucfg.py model.mu

There are some other useful debugging tools there: hierarchy.py and animprop.py

Link to comment
Share on other sites

44 minutes ago, taniwha said:

That's odd. Quite often they're smaller due to useless meshes being omitted. Only things I can think of that would inflate the size are additional animation keys and additional vertex data (normals, tangents, colors)

Dont know. Any .mu file that I import and then export, even if I havent done anything, is always bigger.

 

45 minutes ago, taniwha said:

This is even odder. Have you confirmed that the solar panels are animated correctly in blender?

No, they are not. Upon import animations are wrong in blender, they do not unfold. Its like some animations do not import. try for yourself, take 1x6 solar panel from ReStock mod and try to import.

 

 

Link to comment
Share on other sites

Oh, that's because they're animated via Euler angles which I didn't know was even supported (thought Unity animated via only quaternions).

This will make things... interesting :/

Link to comment
Share on other sites

2 hours ago, taniwha said:

Oh, that's because they're animated via Euler angles which I didn't know was even supported (thought Unity animated via only quaternions).

This will make things... interesting :/

Glad that I pointed you into this.)))) Hope you can figure out how to handle it.)

Link to comment
Share on other sites

On 5/25/2020 at 2:03 PM, taniwha said:

I already have it working for import. Export will be a little more interesting (more in what to when the rotation mode is neither quaternion nor YXZ).

Ive noticed update to repo. Tried to import Solar panels and it worked. But when I tried to export I got this:

 

Traceback (most recent call last):
  File "D:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\addons\io_object_mu\export_mu\operators.py", line 63, in execute
    return export_mu(self, context, **keywords)
  File "D:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\addons\io_object_mu\export_mu\operators.py", line 34, in export_mu
    mu = export.export_object (context.active_object, filepath)
  File "D:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\addons\io_object_mu\export_mu\export.py", line 163, in export_object
    anim_root_obj.animation = make_animations(mu, animations, anim_root)
  File "D:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\addons\io_object_mu\export_mu\animation.py", line 296, in make_animations
    clip.curves.append(make_curve(mu, muobj, curve, path, typ))
  File "D:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\addons\io_object_mu\export_mu\animation.py", line 172, in make_curve
    property, mult, ctyp = property_map[curve.data_path][curve.array_index]
KeyError: 'rotation_euler'

location: <unknown location>:-1

Link to comment
Share on other sites

  • 2 weeks later...
9 hours ago, YoshiIsOrbital said:

I actually /DID/ set it up properly, but fixed the issue. Turns out you have to run blender as an admin, somehow that very simple thing slipped past me. all good now!

Ah, no, you should not run blender as an admin. Rather, do not install blender in Program Files.

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...