Jump to content

Adding / removing MeshFilter nodes in the VAB?


Recommended Posts

I'm experimenting with a "procedural parts" plugin, but instead of deforming a mesh to resize the part, I'd like to add or remove meshes (defined with MODEL { } nodes, maybe?) from the part in the VAB. I've found I can iterate over the list of MeshFilter parts with part.FindModelComponents<MeshFilter>(). Is there a way to add and remove objects from this list? The fallback option would be to include all of the possible MODEL { } nodes in the part, and then rescale hidden elements of the list (or is there a way to say "skip drawing this mesh"?). It's a new area of KSP modding code for me, so feedback would be welcome.

Link to comment
Share on other sites

Nodes in files get converted to actual objects/components/etc once the PART{} is compiled into a Part. Yes, you can definitely add and remove MeshFilter components; I forget the exact code, but Unity docs should tell you how.

Just how procedural do you want to get? Proc Fairings and Proc Parts actually generate the meshes, so you don't need to add and remove MeshFilters, just change their vertices and face lists.

Link to comment
Share on other sites

I've got a model that's broken up in "top", "bottom", and "middle" pieces that are more complex than bezier curves can easily represent. Instead of having a continuous range of sizes, I want discrete steps. Ideally, for each step, I add/remove one of the middle meshes from the list in the part and reposition the other meshes & attach nodes. It might be that I can add/remove vertices from an existing mesh. That might be cheaper, since I can bake the vertex translations into the vertex positions when I add them, and Unity doesn't have to traverse additional transform matrices every draw call.

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