Jump to content

FSmeshswitch objects


Recommended Posts

Hello. I am trying to set up FSmeshswitch on my mod to change between two shapes on the one part but I need some clarification on how. The FSmodules guide says to put the objects of the one mu in the cfg. Eg the part.mu has both (2) meshes in it. How do you add more that one mesh/shape in one mu? I am using blender to export the basic .dae then using unity to add the collision mesh and convert to .mu. Do I just add both .dae's to the gameObject in unity? 

Thanks to anyone who answers this (and all my other threads. I'm just starting to make parts and these forums are so helpful),

Benji13. 

Link to comment
Share on other sites

You just need multiple objects in blender. I wasn't sure if .dae can have multiple objects because I prefere to use the .blend file (internal .fbx). So I made a quick test and it works:

GI2wygM.png

The part has 4 objects: Collider, Model.Base, Model.Cube and Model.Sphere. Collider and Model.Base (blue) will always be loaded, Model.Cube (yellow) and Model.Sphere (red) will be switchable. Export everything to .dae, copy it over to unity and import it:

b2EDOjd.png

Note that the object names have changed in unity; dots are replaced with underscore (Model.Cube is now Model_Cube). After setting up the material and collider, the GameObject can be exported to .mu.
Now you need to configure the module:

    MODULE
    {
        name:NEEDS[Firespitter] = FSmeshSwitch
        name:NEEDS[InterstellarFuelSwitch&!Firespitter] = InterstellarMeshSwitch
        moduleID = 0
        buttonName:NEEDS[Firespitter] = Next setup
        previousButtonName:NEEDS[Firespitter] = Prev setup
        objectDisplayNames = Sphere;Cube
        objects = Model_Sphere;Model_Cube
        useFuelSwitchModule = false
        affectColliders = false
    }

This config requires ModuleManager! The benefit is that it doesn't matter if Firespitter of InterstellarFuelSwitch is installed, both will work (If both are installed at the same time, Firespitter will be used).
The config is based on NecroBones Fuel Tanks Plus Mod:

In general this mod is a true goldmine for mesh/tank-switch configs, examples and very useful tricks.

Edit: Had to correct the config. Also a picture how it looks ingame:

RGgX4M4.jpg

Edited by Eleusis La Arwall
Corrected config ( " ; " instead of " , " ). Added picture.
Link to comment
Share on other sites

Collider is the same for both. In order to switch colliders you need multiple colliders. Place the collider for each mesh as a child of the object you want to switch. I've marked three colliders in the image, the first (Collider) will be used in all setups. So the Cube-setup will use Collider and Collider_Cube, the Sphere-setup Collider and Collider_Sphere.

GMIx9S7.png

Also you need to set

affectColliders = true

in the config.

Link to comment
Share on other sites

@Eleusis La Arwall ok. I did this and all I'm getting are errors. I went through the same process as I usually do for single shape models but with this one (cylinder,sphere and triangle (cylinder)) I get this error in the log:

[LOG 17:22:53.407] Load(Model): StructuralDisks/Assets/structuralShapes
[ERR 17:22:53.427] File error:
Failed to read past end of stream.
  at System.IO.BinaryReader.FillBuffer (Int32 numBytes) [0x00000] in <filename unknown>:0 
  at System.IO.BinaryReader.ReadInt32 () [0x00000] in <filename unknown>:0 
  at PartReader.ReadMesh (System.IO.BinaryReader br) [0x00000] in <filename unknown>:0 
  at PartReader.ReadChild (System.IO.BinaryReader br, UnityEngine.Transform parent) [0x00000] in <filename unknown>:0 
  at PartReader.ReadChild (System.IO.BinaryReader br, UnityEngine.Transform parent) [0x00000] in <filename unknown>:0 
  at PartReader.ReadChild (System.IO.BinaryReader br, UnityEngine.Transform parent) [0x00000] in <filename unknown>:0 
  at PartReader.Read (.UrlFile file) [0x00000] in <filename unknown>:0 

[WRN 17:22:53.438] Model load error in 'C:\Users\Benji\Documents\KSP 1.2.1 - Dev\GameData\StructuralDisks\Assets\structuralShapes.mu'

The parts do not show up in the editor and later on in the log it says that the parts weren't loaded as 'the model does not exist'. Any idea why? Here is the Unity hierarchy:

BSWQL5f.png

I added the .dae straight to the hierarchy the made an empty child for each shape. I added the mesh colliders to each child. The shader/texture component went on the main shape part. Here is what the 'structuralshapes' bit looks like:

VzqH9y1.png

So yea, I'm not really sure what's going on here. Any ideas?

 

Link to comment
Share on other sites

IDK what the exact problem is but it seems there is something wrong with the .mu file. To me the hierarchy looks strange.
I'll write down step by step how I do it in detail (maybe a bit image-overkill but pictures say more than 1000 words and the Devil lies in the detail :wink: ) :

1. Set up the hierarchy in blender:
2Nx79RV.png

2. Export .dae or use the .blend file and copy it over to the assets folder (if you use the same directory skip this step):
rf8U6fa.png

3. Bring up Unity and create a new scene (File / New Scene). Delete the two objects "Main Camera" and "DirectionalLight" in the hierarchy tab. Locate your files in the Project tab:
Wi1cTdP.png

4. Create an Empty:
vNKZE9i.png

5. Select GameObject and go to the inspector. In the Transform section set position to 0 0 0. Add the PartTool component and set Model Name, File URL and Texture format to your likings (no .dds textures!). At this point I'd advice to save the scene as template. I always open this scene for every new part.
yTXEkJD.png

6. Select the .dae or .blend in the Project tab and click on "Rig" in the Inspector tab. Set "Animation Type" to None and apply:
ksckwdB.png

7. Drag'n drop the .dae/.blend onto the GameObject. Should look like this:
6hoWJva.png

8. Select all Colliders and remove the "Mesh Renderer":
W8bMtId.png

9. Add Mesh Collider component:
8gzliXC.png

10. Make sure the colliders are all set to convex! Should look like this:
Lc5GPPL.png

11. Set up the Shader of the other objects:
YdLZ6az.png

12. When everything is set up click on GameObject in the hierarchy tab and export the .mu file:
5hN6hsL.png

The full config of the part:
 

// FSMStest

PART
{
    // General parameters
    name = FSMStest
    module = Part
    author = NoOne

    // Asset parameters
    mesh = model.mu
    scale = 1
    rescaleFactor = 1

    // Node definitions - Position X, Position Y, Position Z, Up X, Up Y, Up Z
    node_stack_top = 0.0, 2.0, 0.0, 0.0, 1.0, 0.0, 2
    node_stack_bottom = 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 2
//    CoMOffset = 0.0, 0.0, 0.0

    // Editor parameters
    TechRequired = none
    entryCost = 200
    cost = 200
    category = Utility
    subcategory = 0
    title = FSMStest
    manufacturer = None
    description = None

    // attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision
    attachRules = 1,0,1,1,0

    // Standard part parameters
    mass = 1
    fuelCrossFeed = True

    // Drag
    dragModelType = default
    maximum_drag = 0.2
    minimum_drag = 0.2
    angularDrag = 2

    // Damage and Temperature
    crashTolerance = 8
    maxTemp = 2200

    MODULE
    {
        name = FSmeshSwitch
        moduleID = 0
        buttonName = Next setup
        previousButtonName = Prev setup
        objectDisplayNames = Sphere;Cube
        objects = Model_Sphere;Model_Cube
        useFuelSwitchModule = false
        affectColliders = true
    }
}

Hope this helps to put a finger on your issue :)

Edited by Eleusis La Arwall
Grammar
Link to comment
Share on other sites

You're welcome!

If you click on the yellow triangle of an object (child) you can drag'n drop it onto another object (parent).
For multiple objects you can use Ctrl + P. Select all objects you want to have as child and select the object you want to parent them to last. Move the mouse-cursor to the 3D view area and press Ctrl + P (Blender is very sensitive where you put your mouse-cursor; The objects must be visible too).
3RNWGRW.png

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