Jump to content

[WIP] ActiveStruts Dev Thread [updated 10.10.2014]


marce

What type of joints do you prefer?  

7 members have voted

  1. 1. What type of joints do you prefer?

    • all should be AttachJoints
      18
    • all should be ConfigJoints
      5
    • keep it as it is now (user's choice)
      66


Recommended Posts

Update 10.10.2014: Release 1.0 is out!

Simply put, this plugin allows for re-attachable struts. There are two parts:

  • Grappler: has only one struts “storedâ€Â. Can connect to another Grappler (1:1), a Grapple (1:n) or attach to any part of the vessel (which has a tiny module added by a MM patch)
  • Grapple: can accept an infinite number of struts from Grapplers

Struts can be created and removed in the editor and in flight. Based on the type of link different connection strength can be applied.

So what’s that all about? It basically started with a request from ZodiusInfuser to overhaul the original DockingStruts mod by JDP (with which I started; with permission; thanks to him) to help with wobbling of parts extended in flight with IR. On the way we thought about some additional features and the plugin grew. Therefore, we decided that I will provide it as a separate mod and not as part of IR (or ZI’s model rework to be exact). However, since I know less than nothing about modelling this comes with no parts of its own. You can use ZI’s parts of course (which I recommend since I had to tailor the plugin to those during development and I think they are very neat) and I also hope to get part creation guidelines out soon if you want to create your own.

Disclaimer: There is a slight overlapping with KAS, so I have to state that this is not KAS or wants to compete in any form. Actually everything that works while on EVA started to work by accident while I was working on something else and I simply did not remove it. And docking is just dangerous.

Here you have some pictures:

Javascript is disabled. View full album

Lots of things can be changed through the config file (default one created every time none is present as on first start):

[TABLE=width: 608]

[TR]

[TD]Property[/TD]

[TD]Function[/TD]

[TD]Default value[/TD]

[/TR]

[TR]

[TD]MaxDistance[/TD]

[TD]Max length of a strut[/TD]

[TD]15[/TD]

[/TR]

[TR]

[TD]MaxAngle[/TD]

[TD]Max angle between strut origin (plane) and target[/TD]

[TD]95[/TD]

[/TR]

[TR]

[TD]WeakJointStrength[/TD]

[TD]Break force of the joint when “free attached†to any part of the vessel[/TD]

[TD]1[/TD]

[/TR]

[TR]

[TD]NormalJointStrength[/TD]

[TD]Break force of the joint when attached to a Grapple[/TD]

[TD]5[/TD]

[/TR]

[TR]

[TD]MaximalJointStrength[/TD]

[TD]Break force of the joint when attached to a Grappler (inactive by default)[/TD]

[TD]50[/TD]

[/TR]

[TR]

[TD]ConnectorDimension[/TD]

[TD]Thickness of the “guidance†beam[/TD]

[TD]0.5[/TD]

[/TR]

[TR]

[TD]ColorTransparency[/TD]

[TD]Transparency of the “guidance†beam[/TD]

[TD]0.3[/TD]

[/TR]

[TR]

[TD]FreeAttachDistanceTolerance[/TD]

[TD]Currently not in use, just leave it alone[/TD]

[TD]0.1[/TD]

[/TR]

[TR]

[TD]FreeAttachStrutExtension[/TD]

[TD]Currently not in use, just leave it alone[/TD]

[TD]0.05[/TD]

[/TR]

[TR]

[TD]StartDelay[/TD]

[TD]Frames to wait after a scene load before performing any relevant operation (like automatic reattachment)[/TD]

[TD]60[/TD]

[/TR]

[TR]

[TD]StrutRealignInterval[/TD]

[TD]Every X frame the visual strut representation is realigned to fit with a possibly new position of the target[/TD]

[TD]5[/TD]

[/TR]

[TR]

[TD]SoundAttachFile[/TD]

[TD]The sound you hear when you attach a strut[/TD]

[TD]ActiveStruts/Sounds/AS_Attach[/TD]

[/TR]

[TR]

[TD]SoundDetachFile[/TD]

[TD]The sound you hear when you unlink[/TD]

[TD]ActiveStruts/Sounds/AS_Detach[/TD]

[/TR]

[TR]

[TD]SoundBreakFile[/TD]

[TD]The sound you hear when a joint breaks[/TD]

[TD]ActiveStruts/Sounds/AS_Break[/TD]

[/TR]

[TR]

[TD]GlobalJointEnforcement[/TD]

[TD]If set to true AttachJoints will be used for everything instead for Grappler-Grappler links only[/TD]

[TD]False[/TD]

[/TR]

[TR]

[TD]GlobalJointWeakness[/TD]

[TD]If set to true ConfigurableJoints will be used for everything including Grappler-Grappler links[/TD]

[TD]False[/TD]

[/TR]

[TR]

[TD]StrutRealignDistanceTolerance[/TD]

[TD]The position offset of the target position since the last check (see StrutRealignInterval). If lower than this value strut will not be realigned.[/TD]

[TD]0.02[/TD]

[/TR]

[TR]

[TD]EnableDocking[/TD]

[TD]If set to true Grapplers which are linked to another vessel will get the option to perform a docking operation. It kind of works but is considered a cheaty emergency measure. Undocking is possible too.

Attention: there are no safeguards, if you dock multiple vehicles or do something else except the simplest prepare for pure chaos.[/TD]

[TD]False[/TD]

[/TR]

[TR]

[TD]ShowHelpTexts[/TD]

[TD]If set to false the how-to-use-hints when using "Link" or "FreeAttach" are not shown.[/TD]

[TD]True[/TD]

[/TR]

[TR]

[TD]ShowStraightOutHint[/TD]

[TD]Shows a beam where the strut would hit when using "Straight Out" action[/TD]

[TD]True[/TD]

[/TR]

[TR]

[TD]StraightOutHintDuration[/TD]

[TD]The duration (in seconds) the beam is shown if active[/TD]

[TD]2[/TD]

[/TR]

[TR]

[TD]TargetHighlightDuration[/TD]

[TD]The duration the target of a Grappler is highlighted (in seconds)[/TD]

[TD]3[/TD]

[/TR]

[TR]

[TD]KerbalTetherSpringForce[/TD]

[TD]Spring force of the Kerbal tether[/TD]

[TD]5000[/TD]

[/TR]

[TR]

[TD]KerbalTetherDamper[/TD]

[TD]Spring dampening force for the Kerbal tether[/TD]

[TD]500[/TD]

[/TR]

[/TABLE]

What is the difference between enforced and non-enforced connections?

Well, I had quite a hard time to decide which type of Joint to use. There are as far as I know two types:

  1. ConfigurableJoints: Work as expected, break when too much force is applied. But they wobble and I wasn’t able to prevent that.
  2. AttachJoints: Super stable. Those are used by the stock strut module as well. Problem: those ignore whatever breakforce I set resulting in having the whole universe break before these joints do. A lot less wobble, but one tester reported that he got a kraken visit when linking two vessels and having them rotate fast. And it renders the different types (strengths) of links useless.

And ZI mentioned that there might very well be an audience for both versions. So here is what I did (default config):

  • Weak Link (Grappler -> “free attached†to any part): uses ConfigJoint, breaks and wobbles. Can be enforced temporarily to use an AttachJoint.
  • Normal Link (Grappler -> Grapple): uses stronger ConfigJoint, breaks and wobbles. Can be enforced temporarily to use an AttachJoint.
  • Maximal Link (Grappler -> Grappler): uses AttachJoint, less wobble, won’t hardly every break. I’m using the super strong joint here to reward that two of the expensive Grapplers are used for this connection. Can be weakened temporarily to use a ConfigJoint.
  • Temporarily means exactly that, it will be gone after a reload (since it’s a bit cheaty I think).
  • Be careful that a change of the enforcement requires a reconnection at the moment => don’t use while parts are moving
  • As seen above this behavior can be changed through the config file to the user’s liking.

I'd like you to participate in the poll telling me what you'd prefer.

What is this “Straight out attach†action?

It kind of reflects the functionality of QuantumStruts “firing†a strut straight out of the Grappler connecting to anything in reach. However, especially by default that’s not exactly true since QS uses Infinity strength connections while I use weak links (see above) which break easily. Additionally it can only connect to a part which has the aforementioned small module added via MM. Some of those problems can be “fixed†through the config file, but not all of them. You can use this function with an ActionGroup.

I talked to K3|Chris who told me that he’s not planning to actively maintain QS and that I could take over if I want to which I don’t, but I suppose what I did here is ok for everyone under this circumstances.

Note regarding the “guidance†beam: if you don’t see it try to zoom in or rotate your view, usually it appears then. I haven’t found the source of this problem yet.

As suggested by DavidHunter here's the difference to KAS in a nutshell:

KAS is all about EVA, while this mod simulates "automated/robotic connectors" (it started as part of the IR model rework after all). So you do not have to be on EVA or even have a Kerbal on board to create struts. And you can create links in the editor as well.

It's not fully realistic but the massive wobble we are fighting isn't as well.

Edited by marce
release v1.0
Link to comment
Share on other sites

Creating parts for this plugin

Here are some guidelines for creating parts that work with this plugin. First of all, I don’t know anything about modeling, so I’ll try to tell you what I’m doing in the code which will hopefully help you to understand what the plugin needs. Second, as mentioned before I tailored it heavily towards ZodiusInfuser parts because those were not only the ones I had available but this project also started as a part of the IR model rework.

If you don’t want to use something (like hooks or lights) I have to ask you to still provide a tiny non-collider, invisible bit with the right name otherwise you’ll get a bunch of NullRefExceptions and nothing will work.

Very important: everything has to be aligned with the front in what seems to be the –x axis in Blender (the red axis but with the front in the opposite direction of the arrow). I don’t know if it matters how it’s imported into Unity, I’m already struggling to open a mu file in Blender and understand anything I see – sorry. Anyway, the correct orientation is vital for proper display in the part list AND proper handling through the plugin.

It’s very hard to describe (at least for me), please look at ZI’s parts (in game I suppose, don’t know what’s allowed to do with models IP-wise) to get a basic understand what I’m talking about.

The module you need to add to your parts is called “ModuleActiveStrutâ€Â.

Alright, let’s start with the Grappler. There are basically 6 parts in the model:

  1. The base. Main body of your part, it’s attached to another part.
  2. The strut. You also have to supply a “StrutScaleFactor†in the part module config which states the factor I need to multiply to reach a length of 1m. Example: strut is modelled with a length of 25cm, then you have to supply a scale factor of 4.0. You have to state the name of this transform as “StrutName†in the part module config.
  3. The grappler. That’s the part which is at the top of the strut. Beside the “GrapplerName†you also have to supply a “GrapplerOffset†telling the plugin how to offset the grappler when two Grappler parts (sorry for the same naming) are linked.
  4. The Hooks. Only used when a strut is free attached anywhere. You have to specify the name as “HooksName†in the part module config.
  5. The Dull Lights. Those are used whenever a link is established. On ZI’s Grappler part it’s the “thicker†part of the strut at the origin. You have to supply a “LightsDullName†in the part module config. Those work in conjunction with the Bright Lights, see below.
  6. The Bright Lights. Those are used when two vessels are docked using ActiveStruts. The reason is that it’s a pain to go through all Grappler trying to find the one which performed the docking operation (since only this one can undock again – remember that docking is a not well supported feature) if there isn’t some visual aid. Therefore once a Grappler performs docking it removes the DullLights and shows the BrightLights. You have to supply a “LightsBrightName†and a “LightsOffset†value in the part module config. The offset determines how far the bright lights are hidden inside the base part. When the lights are “switched on†the plugin moves the bright lights out and the dull lights in according to the supplied offset. They are also scaled down to 0, so maybe this requirement can be removed in the future, I haven’t tried it yet.

Additionally you have to set “IsTargetOnly†to false in the part module config.

The second part is the Grapple (or Fixture or whatever you want to call it). It is much simpler and contains only of two parts:

  1. The base. Same as above applies.
  2. The grappler. It’s the small “knob†extended once a strut is linked. The reason for having a grappler on the fixture and not using the one of the Grappler is that an unlimited number of connections can be established with one fixture. Therefore there would be heavy overlapping. Hence the Grappler's grappler (uff :confused:) is not used but only the one of the fixture. Again you have to supply a “GrapplerName†and a “GrapplerOffset†which defines the movement between extended and retracted.

The “IsTargetOnly†value has to be set to true this time.

That’s it. I’m fully aware that this is fairly complicated and that my description is poor. Sorry again, I’m really out of my comfort zone here.

I suppose you would benefit a lot by looking at ZI’s parts and maybe playing around with the values in the config file to see what happens. Maybe Zodius would even allow you to open the models in Blender or can give you some hints, but please don’t flood him with requests since this mod is not his responsibility.

What I can do is trying to pinpoint issues if you send me your parts and tell me what’s wrong. However, I really don’t have much time at the moment so expect at least a few days until I can even attempt to look at it.

Also if you know a bit about KSP/Unity programming please feel free to look at the code and search for the bits where I’m transforming and rotating.

Zodius gracefully posted some actually useful instructions! Here

Edited by marce
Link to comment
Share on other sites

Great news it's ready for others to try out. Would you mind if I provide a link to this thread on the IR page for those who want more stability with robotic parts?

Thanks!

Not at all, the more people try things I never thought about the more problems I might be able to get rid of in time. Actually I feel honored :)

Link to comment
Share on other sites

  • Be careful that a change of the enforcement requires a reconnection at the moment => don’t use while parts are moving

Interesting mod, I'm using Quantum Struts for some of my Crafts with IR, using the toggle on/off. This is a nice addition to the QS.

And I have a suggestion. Is it possible to make struts that allow movement, a type of dynamic struts? So that they change their length/angle while the IR parts move, but also maintain a strong connection. This could reduce the wobble with larger builds while moving.

Link to comment
Share on other sites

I have to ask if would be possible to implement a new feature (at least, I could not find it already covered, though I may have lost something from the OP). To start, I am using both IR and the Model Rework, the feature I am about is to be used together with both those excellent addons.

Struts in KSP have a length defined by the distance of the two points they are attached to. Once the two points are given, the distance is fixed and the strut keeps it (stock struts, KAS, IR Model Rework all do the same). However, I would like to use "extensible" struts, that could allow the distance to change. Not actively (other parts with IR and the Model Rework provide the needed movements) but rather keeping connected the two points af attachment while these points have a relative movement because of other parts moving. The user should be able to select if the strut is "blocked" (as by default, keeping a fixed distance) or "flexible" (allows distance to increase or decrease, within some limits that may become tweakables). Parts that actually can change a distance actively (like pistons or extendatrons) are not allowing the distance to change while other parts move, what these "extensible struts" should do.

There are structures in real life that actually have similar characteristics. Extensible bars, cables with tightening systems (of course cables only keep a maximum distance, not a minimum between the attach points).

Unlike (for what I can see) what this mod already provides, these "struts" would neither be removed nor created, the attach points remain the ones defined at build time. But the flexibility they provide could be perfect to complement other moving parts.

Link to comment
Share on other sites

This is for @Space Scumbag and @diomeda since I think you want to see the same functionality: it all comes down to a Unity joint which binds two gameobjects together at a certain distance and angle.

There is a possible allowance for movement but that only increases wobble and would still have the joint trying to return to the original “centerâ€Â.

So I think what you want to see could be accomplished by rapidly destroying and recreating the joint which would take the new position into account. First of all, to get this behavior automatically it would need integration with IR to register that there is movement which has to be "ignored" and that the current module is affected by this movement. That's a no from my side. What might be possible is to manually turn this feature on and off via the action menu. I could add that but I don't expect a satisfying result. Try for yourself by assigning “toggle†to an ActionGroup and rapidly pressing its button while the parts move then you get an impression what is possible.

EDIT: I should elaborate on my "no" a bit. It would require work from my and sirkut's side and at least I won't have time for a large feature for at long time now. And it should be fully optional since this is not IR only any more. But again, if someone is ready to do that I have no problem to include the change :wink:

EDIT2: Majiir might have a better idea since the KAS winch has flexible connections. Well, I really don't know much about Unity.

Edited by marce
Link to comment
Share on other sites

Thanks for your answer. Yes, seems two of us had the same idea at the same time (I took longer to write about it... :blush:).

Indeed KAS does something similar, and wasn't because those cables are attached to winches (that I don't always see as required) and the fact I can't set cables already attached in VAB, I could just use those. Still think such struts would be a great addition with IR, but probably also as a general part usable with other mods :).

Link to comment
Share on other sites

Fuel pipes can move with things they're attached to. Could they be modified into movable struts?

From my understanding of what marce explained to me, I don't think you can have a strut that helps make a connection stronger whilst also allowing for movement. Seems like a "have your cake and eat it" sort of thing (which as a phrase never really made much sense :P ). One possible alternative, since this seems mainly focused on IR parts, is to actually have then unable to move if a strut is connected to them in any way, like engaging the lock button on them. This would avoid issues with hinges etc fighting with struts, and be useful for both this and stock struts. No idea how this could be implemented though.

Link to comment
Share on other sites

Seems like a "have your cake and eat it" sort of thing (which as a phrase never really made much sense :P ).

If you eat your cake, you won't have it any more.

I am thinking about how to make a telescopic damping strut. It would accomplish much of what a strut does, but could be arranged with a hinge at each end, and still be flexible enough to allow for movement.

Kind of like a Macpherson strut suspension in a car.

Link to comment
Share on other sites

If you eat your cake, you won't have it any more.

I am thinking about how to make a telescopic damping strut. It would accomplish much of what a strut does, but could be arranged with a hinge at each end, and still be flexible enough to allow for movement.

Kind of like a Macpherson strut suspension in a car.

You mean some kind of universal damper? Yeah, I'd like to see that :)

Link to comment
Share on other sites

I installed this mod but couldn't find any of the parts. Where are they hiding?

At the beginning of the structural tab if you installed Zodius' parts. If you didn't you have none as stated in the OP :wink:

Link to comment
Share on other sites

Thanks! (Don't mind me, I'm just missing the obvious as usual...)

Never mind, it was my fault hiding it in a wall of text. I colored the part red to make it more obvious.

And thanks for testing!

Link to comment
Share on other sites

This is looking absolutely fantastic, marce.

For my FusTek Station Parts pack, I've been wanting to make some faux-procedural truss segments (along with standard fixed-length segments) to allow folks to construct closed-loop truss structures. The MaxAngle parameter would be perfect to ensure that folks don't build trusses out at weird angles.

Looking forward to the documentation on model-making!

Link to comment
Share on other sites

This is looking absolutely fantastic, marce.

For my FusTek Station Parts pack, I've been wanting to make some faux-procedural truss segments (along with standard fixed-length segments) to allow folks to construct closed-loop truss structures. The MaxAngle parameter would be perfect to ensure that folks don't build trusses out at weird angles.

Looking forward to the documentation on model-making!

Thank you!

I wrote down some stuff that should help you getting started (second post in the thread). I know it's a bit confusing and probably incomplete, but I simply don't really understand this modelling witchcraft :huh:

Anyway, I hope you can find a use for this plugin somehow.

Link to comment
Share on other sites

I'll try to clarify things from the model point of view :)

Here is what the Unity scene for the two parts looks like:

_486d6a969a194f668470d6b49f646084

As marce noted, the part is oriented along the -x, which makes it match the orientation of stock struts.

The first part shown (Grappler) consists of the main GameObject and several meshes:

  • Anchor - The base of the part and is the only one with a mesh collider
  • Grappler - The end point of a strut connection, used when performing free attach or connecting with another active strut
  • Hooks - A child of the grappler, that are only shown when a free connection is made
  • Lights Bright - A cylinder around the strut with a green emissive to indicate docked state. This is offset in unity so it appears hidden on the part icon
  • Lights Dull - A cylinder around the strut for when a normal connection is made. This is not offset in unity
  • Strut - The strut cylinder, which in this case is 0.25m long so the part icon isn't too small

The second part shown (Fixture) consists of the main GameObject and two meshes:

  • Anchor - The base of the part and is the only one with a mesh collider
  • Grappler - The "fake" end point of a strut connection to avoid clipping when several struts connect. Is offset in unity so it appears hidden on the part icon

I am sure there is a better way to do the Lights Dull/Bright transition but my knowledge on this matter was limited, and we were already using the scaling solution for the hooks and other parts so it made sense to apply the same technique.

Hope that helps in some way :)

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