Jump to content

Recommended Posts

MODULE
    {
        name = CModuleLinkedMesh
        lineObjName = obj_line
        targetAnchorName = obj_targetAnchor
        anchorCapName = obj_anchorCap
        targetCapName = obj_targetCap
    }

The above was taken from fuelLine.cfg.

I'm trying to make a structural compound part sort of like a strut. I've done some tests in unity creating different cube meshes and assigning the different variables names. The part loads but the orientation of the cubes is really wierd, the caps work as expected, however the obj_line object rotates infinitely towards the editor camera. Also the line obj is rotated 90 degrees to the caps. I'm hoping there's someone on the forum who's made a compound part before, I can't find any information on this so far, other than what the wiki has to say. Specifically, I'd like to know how to set the part up in unity and a break down of the module's properties/how they relate to each other. 

Any help with this would be greatly appreciated!

EDIT: So, it finally dawned on me, I could just import the .mu file through blender with the .mu import addon. I made an FBX file and imported that into Modo. Here's what I got.

Uf42JDB.png?1

I'll report back after I do some experiments. Maybe we can add this to the addon compilation thread when I'm finished.

Edited by Bonus Eventus
Link to comment
Share on other sites

I tried rotating the setup in unity from the imported FBX. The results were not as expected:

3F2gaAG.png?1

HgLe8eh.jpg?1

 

The strange scaling of the line object on the world z axis is weird. It would happen no matter the orientations I tried. I have to put this aside for today, however in the meantime, if anyone has any insight into what I'm doing wrong, please chime in. I'm looking at you @NecroBones :D

 

If I had to guess, I'd blame the mu blender importer or blender itself, considering blender has up set to z.

Edited by Bonus Eventus
Link to comment
Share on other sites

 

Gosh, I never got it to work. I tried making my own strut, and while I got maybe 90% of the way there, the strut itself would either never reach to the second attachment point, or it would fall short.

 

For RSB I cheated by simply retexturing the stock strut, and giving it a rescaleFactor=2.5.

 

Link to comment
Share on other sites

You need a skinned mesh on the line object in Unity... in Max it's Skin modifier; Rigid/Smooth Skin Bind in Maya; not sure what it is in Blender or Modo. Tick the "Update When Offscreen" box so the line doesn't disappear when the root is out of view.

o5jKUkY.jpg

Edited by nli2work
Link to comment
Share on other sites

36 minutes ago, nli2work said:

You need a skinned mesh on the line object in Unity... in Max it's Skin modifier; Rigid/Smooth Skin Bind in Maya; not sure what it is in Blender or Modo. Tick the "Update When Offscreen" box so the line doesn't disappear when the root is out of view.

o5jKUkY.jpg

Brilliant! Let me try this out. I'll report back soon with the results ;)

Link to comment
Share on other sites

After a couple hours of testing I still couldn't get this to work (although I got much closer than I had before). the line keeps being drawn in the negative z instead of positive z, and I have no idea why. Just wanted to say thanks to both @nli2work and @NecroBones for their input. Clearly it's something on my end (most likely Modo). Again, I'll post back here when I get this working. 

@nli2work when you have the time, would it be possible for you send me your strutTest fbx? It would be a big help. Modo has it's own way of doing skinned animation, and sometimes it's been known to do strange things on unity import (like add a bunch of weird transforms or not properly freeze positions). 

Link to comment
Share on other sites

Here's the unity package with FBX and export setup. 
https://www.dropbox.com/s/m61m8tptjaq35bt/strutTest.unitypackage?dl=0

I don't see any settings that stands out in Modo's FBX export settings. Sure way to check the export was correct is that you see a Skinned Mesh component in Unity. If not, make sure the import's Rig is set to something other than "None"

 

Link to comment
Share on other sites

44 minutes ago, nli2work said:

Here's the unity package with FBX and export setup. 
https://www.dropbox.com/s/m61m8tptjaq35bt/strutTest.unitypackage?dl=0

I don't see any settings that stands out in Modo's FBX export settings. Sure way to check the export was correct is that you see a Skinned Mesh component in Unity. If not, make sure the import's Rig is set to something other than "None"

 

Dude, seriously you're my hero :D Thank you so much!

EDIT: so, I think I found the problem. @nli2work had the line mesh (line obj) bound to the root mesh (anchor) and anchor mesh (target anchor) as bones. In other words the line object is a skinned mesh while the starting cap and ending cap meshes act as the bones for the skin. In my earlier experiments I had created two separate bones and bound them to the line mesh, but still referenced the anchor and target meshes separately. I got confused because the blender .mu importer doesn't import animations. So when I saw all these nested transforms I assumed that the CModuleLinkedMesh required those transforms have that layout. Wow, I'm glad it was a simple thing I was missing. Anyways, thanks to @nli2work I cut down the evil factor by a multiple of 2 or 3! When I'm done with my custom part I'll post a full break down.

Edited by Bonus Eventus
Link to comment
Share on other sites

I don't know how strict Modo is regarding skinned mesh, in Max you can skin any mesh to just about anything else, mesh, transforms, bones, splines, etc. I just went the route that took least # of objects. Everything should work just fine if the bones were children of the anchor and root mesh objects in Unity.

Link to comment
Share on other sites

48 minutes ago, nli2work said:

I don't know how strict Modo is regarding skinned mesh, in Max you can skin any mesh to just about anything else, mesh, transforms, bones, splines, etc. I just went the route that took least # of objects. Everything should work just fine if the bones were children of the anchor and root mesh objects in Unity.

fVV9iwu.jpg

Yes, you're absolutely correct. The important bit I was getting hung up on, was connecting the hierarchy. I actually had not placed either bone as the child of the anchor or target objects. On a separate note, I noticed that the target anchor becomes rotated on the z (or possibly scaled on the x) such that the line object is twisted in a strange way. Not sure what's causing that. I also discovered that if you add a collider to the target anchor, it causes a weird bug where the target scales infinitely (don't do that). 

Link to comment
Share on other sites

 

What was really confusing when I worked on my strut, was that the mesh orientation I had to create was 180 degrees opposite to what I saw when I imported the stock strut's mesh into blender. But by just reversing the direction, I got almost all the way there. Here is the thread where I was posting about it.

 

KSP%202015-08-07%2009-32-06-06.jpg

 

This screenie shows the hierarchy I used. It's also in the last experimental condition I left it, which was to try to stretch the strut past the end-point to see what it would do in game. As I recall, at that point it connected in-game, but overshot slightly.

 

KSP%202016-03-06%2008-15-01-55-0.jpg

 

Link to comment
Share on other sites

7 hours ago, NecroBones said:

 

What was really confusing when I worked on my strut, was that the mesh orientation I had to create was 180 degrees opposite to what I saw when I imported the stock strut's mesh into blender. But by just reversing the direction, I got almost all the way there. Here is the thread where I was posting about it.

 

KSP%202015-08-07%2009-32-06-06.jpg

 

This screenie shows the hierarchy I used. It's also in the last experimental condition I left it, which was to try to stretch the strut past the end-point to see what it would do in game. As I recall, at that point it connected in-game, but overshot slightly.

 

KSP%202016-03-06%2008-15-01-55-0.jpg

 

Did another test this morning:

ZVkw4Lg.png?1

LTe3KBJ.png?1

SuOMfKw.jpg

 

From the top, modo setup, unity hierarchy, in-game part.

 

Discovered today that CModuleLinkedMesh deforms the line mesh exactly as it would if you moved the bones in the Unity scene.

The collider to define the selectable/clickable volume for the sturt part in-game. This way you can detach the strut an place it somewhere else (a little obvious, just adding this for the sake of thoroughness).

The distance, position, rotation of the bones is arbitrary. What matters is the position, rotation, distance of the bones when they're bound to the line mesh. 

A good strategy for making sure the line mesh stretches accurately between both the anchor and target bones, is to set their respective centers/pivots to the local center/pivot of their anchor meshes, making sure the center/pivot of the line mesh is in the same local position as the anchor center/pivot. (in other words find the center of the anchor and target anchor, position the line center to that of the anchor center, draw your mesh to fill the total distance between the anchor and target anchor—making sure that both end faces of the line object meet the center of the anchors).

Must have defined two bones. One for the anchor and one for the target anchor. They should each have their own weight maps and each bone should be child of the same parent object and not be parented to one another. (in my case they were parented to the strutTest3 gameObject)

CModuleLinkedMesh does not scale the line mesh at all. it's just deforming the mesh by placing the anchor bone of the line mesh and the target anchor bone (using raycast hit). How they deform is all based on how one binds the line mesh (the position, scale, and rotation of the mesh item when bound as well as the bone weights/influence over what verts)

Like @nli2work pointed out, ticking the "Update When Offscreen" check box is important because otherwise the line mesh will disappear if the cursor is off screen. This is visible on the "Skinned Mesh Renderer" component. CModuleLinkedMesh absolutely will not work as expected if the line object doesn't have a "Skinned Mesh Renderer" component.

I believe the reason why the Squad setup for the strut and fuelLine line meshes on a diagonal, was to minimize weird deformations. 

@NecroBones I see you have a similar setup in unity as the fuelLine part. I'm not sure about how the extra options in CModuleLinkedMesh change the orientation or behavior of the line mesh when "anchorCapName = obj_anchorCap" and "targetCapName = obj_targetCap" are added to the cfg. I plan to do some experiments with both properties to see if I can get closer to a piston strut like these on the ISS:

A9SlHCu.jpg?1

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