Jump to content

[PLUGIN] [WIP] Mirror symmetry for asymmetrical parts


lo-fi

Recommended Posts

Ever felt stumped because 'mirroring' in KSP is actually rotational symmetry? It makes asymmetrical or 'handed' parts impossible without making two separate parts. Think wings that curve upwards at the tips (one side will curve down, the other up), wheels with trailing arm suspension (one wheel will have the trailing arm pointing forward, the other will have it correctly backwards) and main landing gear to name a few examples.

So, I have a potential solution: Mirror the part in your favourite 3D editor, do a little extra rigging in Unity, export a single part including both left and right hands and let the plugin enable them as appropriate. Demo below to illustrate:

Rigging in Unity is easy, just put each side in a GameObject called "Left" and "Right" respectively and call the plugin in the part.cfg like so:

JExQXGl.png



MODULE
{
name = ModuleMirror
}

That's it :) Use the GUI buttons to flip between versions of the part. The symmetry counterpart will automatically change too. This is SPH only, will probably do funny things if used in the VAB - I just haven't figured out how to disable it in the VAB yet.

It's very, very early stages at the moment, but initial results are good.

Code and pre-built plugin here:

https://github.com/KerbalFoundries/ModuleMirror

License: https://creativecommons.org/licenses/by-sa/3.0/

Comments and contributions appreciated, please feel free to use and abuse it as you see fit.

EDIT: Apologies, I meant to heavily comment the code before posting and forgot. I will fix that tomorrow.

Edited by lo-fi
Link to comment
Share on other sites

hi !

Few question :

1 - The animator component is required or not ?

2 - For two symmetrical gear respectively in Left and Right gameObject , it's not important if I keep the same name ex: both Wheel or Sus_Deplace

Tested with the Cpt.Kipard main Gear it's work but, to try fast I have just duplicated the par in Unity

and affect a mirror operation by scale :

result : same part !!, symmetry work for placement, but mirror no applied.

- In unity it's possible to duplicate an object and mirror it by ex : Mirror X -> scale -1,1,1, but after export mirror it's not applied

tested with the pluggin give the same part (no mirror)

in unity :

55Hru43.jpg

no I have two symmetrical part, but in KSP the part stay the same

steph

Edited by stephm
Link to comment
Share on other sites

Rig animations as you normally would for both sides.

Yes, keep the same names.

I realised last night that a little extra code is needed to handle wheels, I will update later and provide notes on which direction to rig the left and right models.

I've never tried the mirror function in unity, I would be a little skeptical.

Very work in progress, but thanks for diving in and testing :)

Link to comment
Share on other sites

:wink:

it seem to be work : except the mirror thing in Unity !

YEWkoJF.jpg

but look the torque link on a simple part they are in good position, here they seem blocked !

need to test on runway, if they are active or not !!

edit :

oups forget that, I don't use at all Animator component, just animation component , the reason for my first question !

steph

Link to comment
Share on other sites

GRREEEAAATTT !! You give a fix to one of a annoying issue of KSP editor :)

I'm just in it too for a part and it was boring to do quite twice the job, correct me if I'm wrong but it's not (yet) auto-magic and you have to design the part for the plug-in. It doesn't work on all (stock parts for ex.)

Link to comment
Share on other sites

re :

try some new test :

In fact the Mirror Scale function work very (except on the wheelCollider in KSp again him !!), and it's very interesting

because no need to build a second model!!!

if I keek the two game object oriented same (like you're first picture), with one object mirrored scale -1,1,1

result in unity :

rPwxmXU.jpg

and in the SPH :

FC2tFci.jpg

- symmetry is now fully functional , strut are correctly mirrored !

- but the Wheelcollider seem to be not react normally, I think is affected by unity scale mirror or something else!!

- And it's not working on runway !

..need to see and test with reoriented axe !

-the pluggin look good !!

I want to say something :

- I'm not enough expert to conclude if it work well, because I have not enough experience to valid something !

- and all error I have encounter are the result of my lack of experience, I'm afraid !

The whole gear thing need to be tested and confirmed by beta Testers from squad ! (just my opinion !)

steph

Link to comment
Share on other sites

Ignore the wheel colliders being funny, that's something I need to fix later. The stock modules activate objects my code disables, so I just need to destroy the side that isn't needed in flight to stop this happening. There may be other undesired interactions with stock plugins, but I'll have to work through those.

Nothing we can't handle ourselves ;)

Link to comment
Share on other sites

I'd wait until I've updated this eve to try properly with wheels. I had a go with repulsors last night (which went well), but I've not tested with the stock modules at all. Currently wheelscolliders all get activated whether they are in the disabled side or not, so I need to add in a little destruct routine to get rid of the unused bits when the scene changes to flight. Trivial compared to the rest. Otherwise treat as normal and keep names of GO's the same between sides. I'd appreciate your input! You need to mirror front to back, rather than side to side - I'll make a better demo with one of my wheels when I get a chance later. It'll give me a chance to do some better testing too, I just wanted to get it posted while it was all fresh in my head last night.

You can use for stackable parts to change between versions even if you're not using symmetry, so might work quite well for some of your wheels. Nowhere near as sophisticated as TweakScale yet, but I'm aiming for something similarly useful and flexible.

Made some progress on the crawler code and I know what I need to do to complete it, I just haven't had a chance to write it yet :)

Edited by lo-fi
Link to comment
Share on other sites

hi ! again !

Mad some test with my strange personal gear used the fast option in Unity (mirror scalling)

Well mirroring mesh or symmetry work very fine I'm sure for that, some animations pass the test but not a majority

but I think with simple animation on one parent or children may be it's working work !!!.

With this plugins is now possible to have correct mirroring !! it's great !

For much complex animation they need two reel model I'm afraid, so I'm starting right now

a new scene with the two model of my gear for final test :wink:!

I don't now if it's possible to merge scene in UNITY, so that demand a little time

because I need to rebuild the whole process for on part in unty . (wheelcollider, bounds etc )

if everything work well , I'll do two version, one with two basic left, right gear and one with mirror plug

for people who have difficulty to place my gear :D !

@+

Link to comment
Share on other sites

I don't now if it's possible to merge scene in UNITY, so that demand a little time

because I need to rebuild the whole process for on part in unty . (wheelcollider, bounds etc )

you can export one project as a Unity package; and import the package to a different folder. this is closest thing to merging projects option in Unity. Best to make sure project folder structure is same in both projects, or you might end up with multiple parttools in same project.

Link to comment
Share on other sites

You'l need to wait, Steph. The animation stuff will be getting horribly confused by having two objects named the same in the part. I've not even tested that kind of stuff yet, so let's not get too ahead of ourselves. One step at a time!

Link to comment
Share on other sites

hi ! :blush: may be I have done a not good gear for testing :

So the scene in Unity is now composed by the two part grouped in Left-Right Game Object, respectively

in Left and Right Game Object.

In Unity :

Mp1U6dF.jpg

After compilation on Runwway :

With my bad English, picture is a better way to explain !

OMSbFMM.jpg

According to the order to place the gear on part in sph, something on runway if have the stock smallgearbay buggy, sometime

when gear retracted the aircraft stay in place without falling it's weir ......

But the mirrored Gear is broken don't work With G key and right clik.

u5DWhDc.jpgFull throttle and no movement the aircraft is sticked on ground!

In Sph some feature Work , not the animation, my light animation is broken on mirrored part :

84IgpG5.jpg

But it's certainly because my part is filled with a multiple component , with a simple part + one animation may be it's better !

I'm not enough good to understand you full code, but it's doesn't change the transform ?, no operation by transform, it's just

swapping object between left and right ? just for info !

Edit :

-I'm starting to change the name for the right part ! for all components except wheelcolider of course.

-Arghg it's worts thing to do changing name break my animation outch !!!

- I'm in debug mod I have possibility to change manually the curve name animation file is writen in ASCII

take time but it's possible.

steph

Edited by stephm
Link to comment
Share on other sites

You don't give up, do you! Most of this stuff should be fixed after my update later, though its possible the stock gear modules will never behave well with this plugin. We will see shortly :)

Thanks for the info, its confirmed a lot of my suspicions - I think most of it is fixable.

Link to comment
Share on other sites

hello !

With notepad++ I have modified the animation (.ani) file for testing on some object renamed (Flag and the

skinned mech object)

do nothing and same error ...

I'm in the way to change the entire name object by adding _R for the right gear, a dangerous operation :D!

@+

steph

Link to comment
Share on other sites

I did tell you ;)

Try the new version of the plugin I just committed, but make sure that it's declared above any other modules in the .cfg:


part
{
some stuff
weight
cost
bla bla bla

MODULE
{
name = ModuleMirror
}

MODULE
{
name = ModuleLandingGear
some other stuff
}
}

not:


part
{
some stuff
weight
cost
bla bla bla

MODULE
{
name = ModuleLandingGear
some other stuff
}

MODULE
{
name = ModuleMirror
}


}

Testing shows that this affects which order the modules are activated in. I currently have my repulsors working flawlessly with the mirror plugin :)

Animations may cause more of an issue. I will look at this next.

Link to comment
Share on other sites

hello !

In fact is already on the top off my module party :D in cfg, (almost since I have downloaded it )!!!

But after the conversion of the right part by _R naming there is a big problem ..............

-Wheelcollider must stay same name..

And the worst in my animation, caused by symmetry they are not the same ..

And there is only one cfg file ........

This time I think I'm trapped by the module Landing gear....

but if it's possible to have that it' ok :

name = ModuleLandingGear

animationName = Train_AniG, Train_AniD

but I 'm not sure, I read somewhere it's not possible to have two animation by module

and if it's true it's dead for my gear.

it's the result of the broken mirrored gear in the sph and on the runway !!!!

It's a Mobius loop trap lol !!!!

I try the new version , with my modified file !!

@+

Link to comment
Share on other sites

I'm having trouble following you in that last post I'm afraid? I think I follow!

I'll do some investigation into animations, this might be fixable if I can rename them.... I have no idea if this is possible in the plugin yet!

Link to comment
Share on other sites

re !

:confused:

Xfu34l6.jpg

it's like in Zbrush painting object on surface, and plenty of nulreference object, normal I have double module lol !

The model drop directly on sph floor on the first click in TAB, and you must reclick on the part to retrieve it !

but but , the mesh now is good for left and right , same for the fxconstraint, because it's possible to manage

plenty of them !!!

Concerning the ModuleLandingGear , it's the main problem, I try something else and I'm back !!

steph

Link to comment
Share on other sites

hello again !!

And it's dead by the stock module Landing gear in this case, only one animation !!!

Mirroring mesh work wheel , and for Fxlookat too, but not for the wheelcolider party it's a mess

Module light seem don't like the mirrored part too .....

At this moment firespitter is my friend :D, but I have no idea how he work and the possibility

on my gear (or other) and with you're module, it's an other story I'm afraid !!!.

But it's possible I'm wrong in the way how I manage the whole test , may be it's possible with

someone more specialist than me :wink: !

Well I see you tomorrow !!

Good Night or Good Day :wink:

steph

@+

Link to comment
Share on other sites

Just running some tests myself. I think we're on to a complete fail with stock wheel modules, far too much is hard coded. A shame, but not unexpected. I wouldn't put much more time into it for the moment, Steph, this one is going to take some working through.

Edit: This may be no-go for parts that contain modules that reference named objects from the point of creation in the editor. Modulewheel and modulelandinggear are great examples. Referencing at flight time works fine currently as the unused duplicate objects get destroyed. I have some ideas though, but it's going to require some heavy tinkering. Parts surface attached to those using this plugin will not have their positions changed when sides are swapped currently.

Edited by lo-fi
Link to comment
Share on other sites

hello !

do nothing today because, just achieve some flight with concerned landing Gear !!

(and falling into problem with Far, with the Aeris4 (include in my Gear upload on forum)

- Agree with you for stock module, they do their assigned job only !

It's a coding thing only hardware change in code can change function

Only way make a new module, perhaps with a similar code to Module landing gear with more possibility !

But we have already Firespitter, and it's seem have more function :wink:

steph

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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