Jump to content

Using the .mu plugin in Blender to make parts.


Recommended Posts

A new thread to attempt to de-clutter for easier archiving and answering.

Though the title says Blender, I use the fork of Blender called BforArtists. It is much easier to work with and so it is possible I may reference something that is available in BforArtists that may not be the same in Blender. But I can't be sure. I will assume that 99% of everything is doable in Blender.

I do highly recommend that people use BforArtists rather than Blender to make things easier for both themselves and my ability to help with questions.

 

Edited by ColdJ
Link to comment
Share on other sites

First Links.

Get the .mu plugin latest here. https://github.com/taniwha/io_object_mu

You click on the green "Code" button and then download the Zip file in drop down.

(for those who understand coding and would like to see how the plugin is being upgraded over time, use this link the logs. )

 

Get the latest Blender here. https://download.blender.org/release/

 

Get the latest BforArtists here. https://www.bforartists.de/download/

 

Best to create their own download folders for each to unzip in. Install to the main hardrive of a Windows computer so that their permissions don't get blocked.

Once your 3D editor of choice is installed.

Copy the "io_object_mu-master"you got from the .mu site into BforArtists or Blender \your version\it's number\scripts\addons_contrib\

 

Now start BforArtists and under the "Edit" drop down tab, at the bottom you will see "Preferences", click on it and when it's window comes up, go half way down it and click on Add-ons, then at the top middle click "Testing" once it is clicked scroll down the list till you see "Import-Export MU models KSP" and click the check box. Once it has a tick in it, make sure you go in to it using the expansion triangle that is next to the tick box, then go down and click on the following, "Install KSP Shader Presets", "Install KSP Config Templates" and "Create Community Color Palettes". Also in this section, set your path to the GameData folder so you can import craft files.

Once you have done this go to the bottom left of the window and click on the small blue box with 3 parallel lines in it and then click on "Save Preferences" This way what you have just done will be loaded every time you open BforArtists and you won't have to keep doing it. Close the "Preferences" window and you are ready to go.

38QUryk.jpeg

 

 

 

Edited by ColdJ
Link to comment
Share on other sites

Basics

Hopefully, you will have looked up ways of using Blender. Though there are more video tutorials for Blender, BforArtists has different key layout templates including Blenders. You can also custom assign hot keys by right clicking on menu links and then choosing a key to assign. I have done this and it makes many tasks faster to do.

If you do have things you can't work out I will try to assist you if I have discovered how to myself.

Under the "File" drop down you will find an "Import" option. Within that you should see the option to import "KSP mu" at the bottom. Click on this and you will get folder pathway menu. It tends to default to the Documents folder, so you will need to browse your way into the GameData folder of your KSP and then into your mod part folder of choice. Start by importing a simple .mu part. This can be a Squad part but sometimes they are set up in an old fashion way, so maybe a newer mods part might be better. Importing something for the first time will not only set up that folder as easier to get to the next time, but also allow you to look at the way the model is set up, in order to get you used to the way parts should be set up. Any .mu can be opened to look at. As long as you don't export it with the exact same name to the exact same spot you found it, you can't mess it up. And as long as you are just looking at how parts are set up and don't try to steal someone's meshes to use as your own, then all parts in all mods are available to peruse.

 

If you have imported a model and looked at menu on the right of the workspace, you will have seen how a models heirachy is similar to the way files in folders, that can be in other folders are displayed. Infact most mod folders are set up in a similar fashion. Anything that has something else inside it can be expanded to see what it's child objects are. The very top of a heirarchy is a "Parent" and just like in life it can be a Grandparent, Greatgrandparent etc. A child object of a parent can also be the parent of a different child object etc.

In certain parts, e.g retractable landing gear, it is very important as to where certain things are within a heirarchy for the game to be able to make them work correctly.

 

Heirarchy

When creating models for KSP it is always best to start with an empty axis as the top of your heirachy. Best practice is to have 2, 1 within the other and then your meshes within that second one, this allows for manipulating positions and sizes of the parts of your model and having them stay as you left them. When a save file is loaded it likes the top of a heirachy to be exactly oriented as it was when first created, having your meshes under the heirachy will mean they are loaded in the orientation you left them in. The second empty allows you to manipulate the entire model as 1 thing so that everything under it can be moved and resized as one piece.

To add an empty axis you need to, go to the lower header near the top of the work space and click on "Add", then roughly half way down hover over "Empty" then on it's drop down click on "Plain Axes". This will add a plain axis in to the heirachy on the right hand side of the workspace. Go over and double click to make it editable and then rename it to suit your project name. If you already have meshes you can simply hold down shift, left click and hold on to  their name in the heirachy menu to drag them over the axis and then release the click to have them now inside your new axis heirachy. It is also best to have any animations you do be within a double empty as to buffer it from being changed on loading a save. Holding Alt after Shift before releasing the mouse over the part you want to reparent in will keep it in the same visual orientation. Just make sure you use the "Clear Inverse" option, found inside the "MuHeirarchy" button, on the top of the Heirarchy before exporting, otherwise you are likely to find things are not where you left them.

 

Vertices

Vertices are the most fundamental building block of all models. You literally can't build a 3D model without them. They are the anchor points for edges and contain spacial and orientation data. In Blender they can contain a fair bit more, but in Unity there need to be several more in the same spots to allow Unity to get the information it needs, as such any model that has been exported as .mu model will have far more vertices than is visually apparent. If you import a model that you have previously exported or a model from another mod that you want to borrow shapes from then you will need to merge these vertices just after import, before you try to manipulate any meshes. If you don't do this then you will get some very weird results if you go to move vertices in anything other than wire frame mode. In the Heirarchy menu, you will want to expand all the heirarchies and the wile holding CTRL mouse click all parts that are meshes. Once they are all highlighted change to the "Edit Mode" workspace, click on the "Mesh" drop down menu, then the "Merge" option. In this you will find the "Merge by distance" option. As long as you haven't changed this from it's default, it will merge all the extra vertices into their spacial locations. The .mu plugin will automatically split them out again on export.

Though it is good to save as a Blend file for most of your build, (save often and make new saves with consecutive numbers at key points), there will come a time where you need to export and try your model in KSP, as things can look quite different in game, and then import it back in to make changes. So it is important to remember to do this every import.

Now there is a limit as to how many vertices Unity can render per mesh section, it is roughly 65,500 vertices. (I can never remember the exact amount) and as the export can multiply each vertice 5 to 6 times, it is good practice to limit the amount of vertices to 10,500 per section. This does not mean the entire model has to be less than this, just that it be cut into pieces with each being less than this. On export you will get a yellow warning dialogue pop up if a section exceeds the limit.

 

Face orientation.

The blender enviroment does not make it obvious which way around your faces are orientated unless you turn on "Face Orientation." There are 2 versions it provides but I prefer the one that shows blue on the side that will be seen in KSP and red on the side that will be see through. It will not show in wireframe mode but will in "Solid" and "Material View" modes. Here is where to find the toggle.

Spoiler

hfvPruy.jpg

Can also be useful for finding places where meshes have gaps in them.

 

Normals.

These relate directly to Face orientation. Here is the technical explanation.

"Normals in Blender represent lines that are created perpendicular to the geometry. The direction of the geometry determines the direction of the normal. Normals are used to determine the inward and outward sides of a face, edge, or vertex and can influence how geometry is rendered.

So a normal is created every time geometry is created and is used to determine which side of the geometry is the outward facing side. Let’s take a look at normals in more detail and find out why it is so important to understand normals."

Answer for people like me.

In relation to building models for KSP, Normals can be thought of as being the way of determining which way out the face that can't be seen through in KSP, is pointing. So when you use Face Orientation and see if what should be the outside of your mesh is correct = Blue, or incorrect = Red, you can flip the faces so they will be the other way around.

In editing, select the vertices of the face you want to flip. If you have got them all correctly then the face you are choosing will become a deeper shade of red or blue (assuming you have Face Orientation on). Remember if you are selecting many faces at once that if the vertices you have chosen are also all the vertices of a blue face, that it will get flipped to red. So try to pick groups of faces that don't highlight all the vertices of a blue face at the same time.

Then Click on The "Mesh" dropdown menu. Go down till you see "Normals", click on this and then go to the "Flip" option and click on it. All the red faces you have highlighted should now be blue. Repeat until you get all the incorrect faces.

Normals quite often get generated in reverse to what you expect, so it is good practice whenever you create new faces to check with Face Orientation to make sure they generated how you wanted.

 

Material Setup. Very important for exported .mu

Any model you create in the blender environment must have a Material set up applied before you  export as an .mu or else the meshes without them will be considered not to exist.

There is an option on the import list pop up called "Force Invisible Meshes" ,

It can be found to the right of the list and is there to try to force meshes to show up that haven't been given a Material setup.

Generally though meshes exported without a Material set up won't show up when imported.

There are 2 ways to go about giving meshes a material set up,

1: you can import a model that already has the sort of KSP Shader setup you want and set your mesh to use it, then go down and edit the textures that it looks for to your own, as in this example.

Here is a pic showing the Mk1-3 pod imported in, you will notice on the right hand side I have clicked on the materials icon to bring up that section (in mine that is a brown, yellow and white pie chart.) The materials name it was given by it's author is "Mk1-3 Pod". That material name is the collection of all the shader settings used for the main pod. It also has a material setup called "no name" which is used for the flag mesh that is used in game so that you can change flags. In the second pic I have also imported another model into the same work area. It has the material name "octo". Now in the second pic you will see that there are 3 materials available because each model imported into the same work session, makes it's material setup available for use. I could click on the The material setup in the drop down for the Mk1-3 pod while having the Octo model highlighted and that would change that model to use the Mk1-3 Pod's material set up. Now of course it will be pointed to the texture files that the Mk1-3 pod uses, but you can go further down and change the name that the material looks for for it's texture pics, you can even edit the material name in that area shown in the pic and it will still retain all the colour, shininess etc settings from that material setup.

So if you are able to use blender with the .mu plugin. You can use this method to give your model the materials set up from the pod. My thread in this same section has all the links needed to set it up.

 

Spoiler

tPdSjgK.jpgglOWomm.jpg

 

2: You can create from scratch.

As long as you followed the instructions when you first installed the plugin, then under the Material section, represented by a small pie chart symbol in the symbols menu on the right of the workspace.

You will find that with that clicked (you must have a mesh highlighted first for it to be an option), that if you scroll down inside it's opened up menu you will reach a section

(as this is from scratch nothing will show unless you clicked "New" at the top, it defaults to the name "Material" but you can click on and edit this to a name you want.)

that is labeled "Mu Shader". Within this is a blue drop down named "Shaders", clicking on this will bring up a list of all the possible KSP shaders.(Except for "Depth Mask")

When you choose one it will appear in a box 2 below called "Shader:" inbetween is a box called "Name:" You will want to put your choice of name in here or it won't save on export.

Then below those 2 boxes is a drop down named "Textures". Depending on what you chose as your shader, there will be 1 or more name types e.g "_MainTex" "_BumpMap" "_Emissive" that when clicked on will show a box below it called  "Name:" with that name in it, just below that is a box that usually is defaulted to say "gray". You want to change it from gray to the the name of the texture pic you plan to use for that aspect. You will need to do this for each of the textures used by that shader. I usually pick a name and add a Capital B to the end for my Bump map and Capital E for my Emissive etc.

Once that is all done your mesh now has a Material setup. You can set other parts of your mesh to use the same Material as in the above example or you can give them a different Material setup depending on what they are for. A good example is for the new Lights in KSP.

This is one where I use the Material setup from the stock lights for light up windows as the Material has an animation in it .

That material set up and the unique name of the mesh you have using it are one way to have the new light animation work in your model.

 

Spoiler

dqTILgV.png

gsWYl91.png

 

Setting up a texture pic.

If you are not mapping your model to someone elses texture pic, then you are going to need to set up your own beforehand. A simple colour pallet made of different coloured squares within a texture pic is a good way to start. If you wish to map to more complicated pics, it is best left till you have had experience doing complicated mapping of sections of meshes first.

Place your pic in the same folder you plan to save your .mu model to so that when you import the program can find it straight away.

.DDS vs .PNG used for your texture files.

KSP can actually work with a wide range of texture type files and even used to use an obscure one called .mbm

These days KSP has the easiest time when using .dds format. Only problem is that .dds are flipped vertically when compared to most other formats. Even though blender will flip it in Material View, it won't in the UV MAP workspace, so if you are working off a .dds, where you place your UV maps will not correspond in Material View as seen on your model. The answer to this is use a .png to start when you are mapping, once you have finished all your mapping and have your model textured as you want it. Open your .png in something like Paint.net and flip it vertically then save it as a .dds Make sure you flip it, not rotate it.

It is important that you save it as a"BC3 (Linear, DXT5)" type .dds for it to be used properly by KSP. The option shows up on the "Save Configuration" window when "Saving As" in Paint.net

 

UV mapping.

If  you have created a material set up for your meshes, then you can map your meshes to  the pics you have chosen to paint their faces.

In the main workspace go over and click a mesh in your heirarchy to highlight it. Then at the top of the workspace click on "UV Editing" to bring up the UV mapping workspace.

Here we have a split screen with a 3D editing workspace on the  left and a 2D mapping workspace on the right. If you have exported and then imported your project after you set up your Material properties, then a pic that you assigned to the material properties of your mesh will be showing in the 2D space, for you to map to. If the shader you are using uses more than one pic then you may need to go up near the top of the 2D space and click on the blue dropdown arrow that is next to the pics name, to choose the pic you want for the mesh you are mapping.

Once you have the pic you want, then select the vertices that make up the face or faces you want to map in the left, edit workspace. Though you can use more complicated "Unwrap" methods, they will require that you tailor your pic to the UV mapping they generate. A simpler method is to use "Project from View" and then manipulate the wireframe you create over the section of your pic that you want to use for it.

With your face selected, click on the "UV" menu above the 3D workspace and choose from the list, "Project from View" this will create an orthagonal wireframe based on the angle and zoom level of what you are seeing selected in the 3D space, and overlay it on your texture pic.

Manipulate the wireframe over the section of the pic you want. You will be able to see what is being "painted" in the 3D view if you have turned on "Viewport Shading, Material View" by clicking on he red and white ball up near the top of the 3d workspace. You can set base colour by choosing the whole mesh and putting the wireframe over the texture you want, then choosing small sections at a time and moving them to other textures on your pic that you want. Once you have everything where you want, then it will be saved that way when you next save your project as a .blend or export it as a .mu

XweB8oY.jpeg

BKIBiMi.jpeg

 

If you have mesh colliders set up then they will block the view of your faces. Highlight them and pull them off to one side so you can see your faces. When you have finished, just set their location to 0 in all 3 directions to have them back where they were.

Getting the Warning: "Ngons in the mesh, Tangents will not be saved."

Ngons are faces that have not been divided up into sections. Unity likes all faces to be divided up into triangular sections, thankfully the .mu exporting program will automatically triangulate all faces on export so even though you will get this warning it will be fixed in the exported .mu file.

Apply Scale

Before you add your colliders and export as a .mu it is best to use the function provided by the plugin to "Apply Scale", this makes sure that no matter what size your pieces ended up as, they can be set to be considered 1 in all dimensions. The reason to do this before adding colliders is because if the colliders are already there when you do this they will be reset and you will have to redo them to get them back to how you had them.

Towards the top right are 4 boxes in blue, one says "Mu Heirachy" Click on it and then click on "Apply Scale", when you have a mesh piece highlighted, to set it to being considered 1 in all dimensions.

(I believe the collider problem may have been fixed in the latest version, but you should still always apply scale before your final model is exported.)

Clear Inverse

Orientations are not always as they look in your work space. Best practice is to use "Clear Inverse" just before export to make sure your model parts are actually the way around they look.

Towards the top right are 4 boxes in blue, one says "Mu Heirachy" Click on it and then click on "Clear Inverse", when you have the top of your heirarchy higlighted, to make sure things get exported as they appear to you.

Coliiders

For any model to be interacted with you need at least 1 standard collider (also known as a collision mesh) to be wrapped around one of your meshes. Normal meshes are what you see in the game while collision meshes are invisible but are what you click on, have bump in to other meshes, the ground, Kerbals, etc. Without a collider you can load a part from the parts list out in to the SPH or VAB editor, but once out you will not be able to interact with it. Sometimes, if you have made a mistake, you might have included a collider, but it is not where you thought you put it. You may get lucky by moving the mouse cursor everywhere and if you go over it then the part will highlight and you can interact with it. Standard colliders don't require a change of layer or tagging. There are simple shape colliders if you are not fussed about if a Kerbal needs to walk over something in a realistic manner, and there are mesh colliders that will try to shape themselves to your model mesh. Simpler shapes are easier, More complex can be done, but might take a few minutes to be calculated, the first time you apply in a currently open project. The program is fine with the outward curves but does not do depressions. So you can make a conforming collider for the outside of sphere but you can't for the inside of a sphere. On any complex shapes the program will shortcut across any depressions. You can compensate by cutting your mesh up in to several pieces, so that the program doesn't need to go over depressions. Once you have highlighted a mesh, there are 3 buttons in the right upper corner of the workspace. When first you start working on something it will default to having the "Item" menu open. This shows your co-ordinates and scale boxes. The next button says "Tool". Click on this and you will have a menu that includes a dropdown menu called "Make Mu collider" Then you can choose a simple collider shape under "Single" They will try to size themselves to as close to your mesh dimensions as possible. Or you can choose "Make Mesh Collider" under "Multiple Colliders" to get one that tries to hug your mesh shape.

5vqjf5V.jpeg

Here you can see how if I pull the collider to one side it is the same shape.

wRkhRXb.jpeg

Exporting your Work

Around the top right corner of your work space are 4 blue buttons.  If you tap the "Export Mu" button, you will find an option to export your work as an .mu.

(Important: Make sure that only the top empty of the entire heirarchy is highlighted before hitting export, otherwise when you import back in you may find you are missing pieces.)

 

More Advanced Stuff

Layers in KSP

Layers determine how the game treats meshes in the game. 0 layer labeled meshes are for most external parts. Layers 16 and 20 are used for IVA overlay meshes, while others like 21, 26 and 27 relate to special colliders for things like ladders and wheel colliders.

There are 32 layers available. This is a hard limit in Unity. Layers 0 to 7 are reserved by Unity.

  • 0: Default (Unity built-in): All external visible parts that interact.
  • 1: TransparentFX (Unity built-in)
  • 2: Ignore Raycast (Unity built-in)
  • 3:
  • 4: Water (Unity built-in)
  • 5: UI (Unity built-in)
  • 6:
  • 7: (  @Ger_space said : found Layer 7: its the editor Gizmo handles in the SPH and VAB. )
  • 8: PartsList_Icons
  • 9: Atmosphere
  • 10: Scaled Scenery
  • 11: UIDialog
  • 12: UIVectors
  • 13: UI_Mask
  • 14: Screens
  • 15: Local Scenery
  • 16: kerbals/ Internals and their props. Everything in the heirachy must be set to layer 16, compared to external models the scene is rotated 180 degrees around the blender Z axis then 90 around the X axis.
  • 17: EVA
  • 18: SkySphere
  • 19: PhysicalObjects
  • 20: Internal Space: Used to prevent IVA camera views being blocked by props or hull parts also used when creating internal props)
  • 21: Part Triggers: Airlocks and Ladders etc, Must be tagged as to their function and have the boxes for trigger and separate ticked.
  • 22: KerbalInstructors
  • 23: AeroFXIgnore: Prevents parts from showing aero effects
  • 24: MapFX
  • 25: UIAdditional
  • 26: WheelCollidersIgnore: Layer for the wheel collision enhancer.
  • 27: WheelColliders: Used for the flat wheel collider, this tells the game where the wheel interaction is to be. It is the radius in the config that sets height of visible wheel to ground. If the radius is too large you will bounce high on spawn, too low , wheel will spin but not move.
  • 28: TerrainColliders
  • 29: DragRender
  • 30: SurfaceFX
  • 31: Vectors

TAGS

Used in conjunction with layer 21 for airlocks and ladders.

Also for other functions

Ladder ( used for ladders )

Airlock ( used for hatches/doors )

Icon_Hidden ( used to hide item from editor view, engine shrouds use this )

Icon_Only    ( is useful if you want objects to only appear inside of the thumbnail, like decorative protective intake covers and remove-before-flight tags. Also handy for indicating different sized but similar looking parts ( thanks Ven ) )

NoAttach (prevents surface attach to the collision mesh in Editor. so you can have a part with areas that are not surface attachable while other areas are. set in same way as previous tags)

Drag_Hidden  (Prevents things like turbo fan blades being included or added to drag calculations)

Objects are visible in game when on layers 0 (Default), 15 (Local Scenery) and 19 (Disconnected Parts), and can also be visible on the camera plane on layers 12 (UI_Main) and 13 (UI_Mask). Only layer 0 displays mach and re-entry effects, so placing an object on layer 15 will disable these effects for that object.

 

Lights

Under the light section there is a MU properties section. Within are two wide boxes filled with smaller boxes. Nothing obvious about which box is which but if you hover over a box and look at the end of the fine print you can see a number, knowing about layers now I can see that starting at layer zero at the top left and going all the way across both large boxes, that the top layer is 0 to 15. The next layer down is 16 to 31. If the box is highlighted then that layer gets lit. If not then not.

The modern Stock lights have 0, 15, 17 and 23 highlighted. My old lights have everything highlighted which meant illuminating the entire planet from space. That explains that. You simply tap on a small box to change it's status.

Quaternions

This is a rotational method used by KSP. It used for animations and for orienting Props in Internal models for IVA.

When you start a fresh project in BforArtists/Blender it usually is defaulted to Euler in the Item Transform in the main workspace. (where you see info on location, rotation and scale). Before creating an animation you will want to be sure all your Heirachy parts/meshes are set to Quaterions or else the animation won't work in KSP.

As said it is also used for orientation for stock props. Trouble is it is not consistent and some props are set up differently. For things like Atmosphere depth and Speed readout it is "first is second and negative in BFA2(X), last is first (W)"

e.g

    PROP
    {
        name = ledPanelSpeed
        position = 0.0,0.07,-1.9813
        rotation = 0.707,0,0,0.707
        scale = 1,1,1
    }

In this example the first number 0.707 is in blender in the X rotation box and a negative number. The last number 0.707 is found in the W rotation box and the same positive.

Took a lot of experimenting to get that worked out. Unfortunately The Throttle and the Nav Ball are different.

Making lights requires you have the renderer set to Eevee. It affects what parameters are present on light objects and on Cycles the exported MU won't cast light.

 

Need to do a write up on empties  and colliders used by the game for things like thrust and docking ports, where orientation is important.

thrustTransform

I have mentioned before that the standard Squad empty used to designate where and in what direction thrust comes from, alway turns 90 degrees on export. I had always thought this was some quirk of them being built in Unity, rather than Blender. As such I use my own and they are named differently. But recently I tried to use one I put in myself, renamed to match their name "thrustTransform" and upon export it turned 90 degrees. It had not occured to me that the name of the empty could affect how it is exported. I have to assume this is some quirk in the .mu plugin, though why it would happen is a mystery to me. So simply, don't name your thrust empty "thrustTransform" and remember to adjust your config so that it uses what ever name you did choose, and you will be right.

 

Depth mask

Rather lazily on my part, I had previously not bothered to look at the Depth Mask model that the Squad internals use to stop the entire internal from showing through, as such my internals could always be seen from all angles. I finally tried it and it makes for a much more realistic view from the outside. You simply take a section of the outside of your cab or cockpit that covers the areas you want blocked. Make sure it is set to layer 16, just like your internal and then import a Squad Depth Mask model. The Mk1 inline one for example. Then simply change the material property of your model to the "depthmask" material set up used by their mask. I do this because I can't see this material set up in the Shaders menu that comes with the .mu plugin. No need for any texture pics. This is because it just blocks the internal from being seen. Export to the folder you have your internal config in and add the model path to the config as a second MODEL. If unsure just look at a Squad cockpit internal config to see how they have done it. Load the game and if you remembered to adjust your Cockpit config to use your new internal config, you should get a good internal when you look out on the runway.

Need to put in an example config.

Animation

I just recently worked out how to animate colour and light sources myself, rather than rely of material properties or light sources from other models.
So here are the 3 types of animation I am aware how to do.

First: Physical animation, being able to make a mesh change location, change rotation or change scale. Go to the Animation work space.
First highlight the mesh in the heirachy that you wish to animate. Then go to the setting shown in the pic below to choose what type of animation you want to do, you will see that you can choose a single or combination of types.
Once chosen and showing in it's box you can insert your first Keyframe, using the small white key you can see in the pic. This usually defaults to frame 1. Though you can start at other frames it is best to start all animations at frame 1 and then if you don't wish them to do anything till another frame, move the frame positioner to the frame of your choice (Frame positioner is the green line in the pics and can be dragged by the mouse.) and then add a keyframe without changing anything. Then drag to the next frame you wish and use the tools in the workspace to change what you want, repeat till you have what you want and make sure you have put a keyframe at the end of your animation. You can actually animate several meshes at once, making sure to change and keyframe each one at each point you choose in the animation, this allows you to see how one mesh affects another as you go, especially as any mesh parented inside another will be changed by the parent as you change it. For my example I am just changing one scale dimension.

Don't worry about the right side in the pics, I forgot to highlight the cube before taking the screenshots.

 

NwGHq4H.jpegDMZxHqM.jpeg

Second: Animate a meshes colour, generally used to make engine heat effects. the animation can be used by the "Throttle Animation Module" (Look in Squads Ion Engine to see an example.) Highlight a mesh you have made and give it a new Material Property, go down to the KSP shaders section of material properties and from the list choose "KSP/unlit". Go to the texture section and the "_MainTex" "Name:" to the name of the texture pic you are using. (Remember you are not changing "_MainTex" to something else but rather the reference name found in the box under where it says "Name:" (Usually it is defaulted to say "White" or "Grey")(best to choose a white or very light colour texture on your pic for the mesh) Then go down slightly further and open the drop down that says "Colors" and open it up. It should be defaulted to have a black rectangle box under the "Name:" section. Left click on the black box and you will see a pop up with a circle, choices and a slider.

RI744Su.jpeg

As this example is for a heat effect, leave this as is and then right click the same box and a small menu will come up. At the top of the menu it has the option of "Insert keyframe" . Left click it and then open the Animate workspace. If you have left the frames at frame one from the last exercise then you will see the dots that show you have inserted a keyframe at frame one, if not then remove the keyframe and reset to frame one before redoing. Then move to the frame you want to end on and go left click on the color box to open the popup. Drag the slider on the right all the way up and you will see the circle is a colour palette. Drag the selection dot around till you get the colour you want, then go back out, right click on the color box and choose add keyframe. ( obviously for an effect where it goes through multiple colours you could add more keyframes to your animation, changing the colour each time.) And there you have your animated colour.

 

sSFH5oo.jpeg

You can add lights from the Add menu, remember to reparent them into your heirachy. (note the 4 blue boxes in the "Culling Mask" section. These are the ones needed to cause models and ground to be affected by a light source without lighting things you don't want lit.)

 

8DnaXBC.jpeg

Adding an effect where the light source goes from dark to light is very similar to changing the colour but now we are using the Light properties. Same idea, in the box that has a number and a W for Watts, change the number to zero, then right click and then click "Add Keyframe", go to the Animate workspace and move to your end frame, go change the number to Watt value that you want the light to brighten to, then insert a keyframe as before. Remember you can set the colour of your light using the box above the number. This could also be used in conjunction with the colour animation to make lights that you want to come on gradually.

e1GJMur.jpeg

Now to finish any animation you need to name it. This is the name the animation module will reference in your config file. In the Animation workspace to the left just above the frames section are 4 small boxes, we have been working with the far left to add frames, now we use the far right to name them.(Looks like little rectangles stacked) Open up the dropdown you see linked to your mesh, material or light name, double left click on the "NLA Tracks" you see and type the name you want, hit enter. You have named that particular animation. Repeat for each. So far it seems that if you name the physical animation the same as the others it doesn't export correctly, so best to name it differently.

 

yTa7gPG.jpeg

So far I know of no way to see the light and colour animations on the mesh in blender, but if you look at the properties set to the first frame, then look at them set to the last frame, then you should see the change if it has worked.

Edited by ColdJ
Link to comment
Share on other sites

Tutorials

This is a work in progress, will slowly be fleshed out.

 

Basic Model to get familiar.

First lets create a simple to model to get an idea of what you need to do to have something usable in KSP.

If you have already followed the instructions to have the .mu plugin installed and the preferences required to make it work set, then open up the program and you will be in a fresh work space. The default workspace  is always "Object Mode" which you can see in the top left corner.

First let's add 2 new empties. As this is a fresh project they will be added at world centre, as this is the default starting point of the 3D cursor. If you move the 3D cursor and then add something, that thing will be spawned wherever the 3D cursor has been moved to. There is a menu that allows you to snap the 3D cursor back to world origin, I set this menu to a keyboard key I am comfortable with, make sure no other shortcut is mapped to the same key. The menu will be something you will call up alot to move the cursor to selections or selections to the cursor.

So in the main workspace, go up and click on the "Add" dropdown menu and go down to "Empty", hover and the click on the "Plain Axes" choice. Though you can change empties to the other choices while working on a project, the empty will always be saved as a plain axes when exported as an .mu file. So if you need to see orientation, which you will for things like thrust and airlocks, then you will have to change an empties type each time you import an .mu in.

J0X0UDc.jpegMQD8mto.jpeg

I added 2 new empties, renamed 1 and then held down  SHIFT+left click and held the named empty in the heirarchy menu, dragged the empty over the other and then released the click to reparent it inside the first. Now you have an empty inside another empty, and so the top of your new heirachy. This is what you should do at the beginning of any new project.

Next we will add a simple 3d mesh to work on.

Go up to the "Add" menu and click on it, the top of the list will say "Mesh". Hover over and go down the list and click on "Cone".  A cone will be spawned, centred on the 3D cursor, which currently is at world centre. Always add a new shape with this method, rather than the line of shapes above the menus, because this method brings up a small menu near the bottom left of the workspace, that lets you adjust aspects of the mesh before you finalise the shape and size you want. As I want a very simple shape with only 4 faces, I can change the vertices count from 32, which gives you a circle base, to 3, which gives me a triangle base and so creates a triangular, 4 sided pyramid. I left it as Ngon so I didn't get an extra vertice in the middle of the base, and as they are all triangular faces, nothing needs to be adjusted on export. Changing the choice from Ngon to Triangle Fan is best used for a cone or cylinder, where you will need a triangle section for every 2 vertices on the edge of the circle, connected to a vertice in the centre. You can have a different form of triangulation of the circular faces, but this is the most efficent and allows for the simple removing of sections if you don't want a full cone or cylinder. Also if you want to pull the face in, like with engine bells.

 

BBLoWgs.jpegk9ZsRVu.jpeg

Now, you might have noticed that the mesh was spawned outside of the heirarchy we are creating. So just like the 2nd empty we will SHIFT+click and drag it over the second empty to reparent it.

oQ3CZFl.jpeg

Now that we have done that I will show you how to check the face orientation. This shape should be right from the start, but things like Extrusion can make face orientation really mixed up.

I will go in and flip one face first so you can see what it looks like to have a face the wrong way around.

The following pic shows you where to turn on face orientation.

axQtOsw.jpeg

The red face that you see would be seethrough from the outside when loaded in KSP. If you were looking from inside then the others would be seethrough and it would not.

To fix this we need to  change to the "Edit Mode" workspace. Click on the "Object Mode" button on the top left and then choose "Edit Mode"

Here, vertices become thick dots and those that are lit up will be moved when you choose a tool option to move, rotate, rescale etc.

As this is a very simple shape we can choose the 3 vertices that make up the face quite simply, while remaining in the "viewport shading mode" that allows you to see faces. (Notice the 4 spheres in a row above the dropped down menu in the previous pic, the grey looking one has a blue box around it to show it is the active choice. The ball to the left with the lines is for wire frame mode and the one to the right with red and white chequer is so you can see what you have mapped to your faces. The final one has something to do with unlit (I think).

When selecting vertices in more complicated meshes you will most likely have to go to the wire fame view. Selecting multiple vertices in different areas can be achieved as long as you remember to hold down SHIFT when you are selecting using the Lasso or circle selector. (I mostly only use circle when trying to highlight a hub to separate it from a wheel or similar.)

Holding down CTRL while selecting will allow you to de-select vertices. Very handy for tricky meshes. The box with blue in it near the top left in the "Tools" menu has the selector choices. Left click and hold, then drag the mouse over the choices that pop up and release over the one you want.

 

Now to flip that face, change to the "Lasso" selection tool, then encircle the 3 vertices that make up that face and once done, click on the "Mesh" menu, go down to the "Normals" selection, then in it's menu click on "Flip". The red face should become blue.

6x5HzZH.jpeg

Under the "Item menu" in the right side of the main workspace, be  sure to change the "Mode" from XYZ Euler to Quarternion, for both empties and your mesh. Any thing created in "Edit Mode from your mesh and separated out, will automatically be set to the same mode.

Ok, we have a basic mesh, so now we need to map faces, but first we need for it to have a materials set up in order to do that.

 

First, you will want to minimise BforArtists, then you will want to create a folder somewhere. The easiest would be within the GameData folder of KSP, because soon your mesh will be used as a part in KSP, so this will save time. I will call my folder Tutorial as that is what it is being used as. In this folder either create a .png with patches of colour in it, or grab one from somewhere and then name it Tutorial.png

Bring back up BforArtists, go back to the main workspace "Object Mode" and then making sure your mesh is highlighted click on the little Pie Chart symbol, that is on the right of the workspace, below the heirarchy section, this will open the Material setup menu.

YqqCRse.jpeg

Click on the box that says "new" and now you should have a selection that says material above the box and the box will say material. Click on the material word in the box and rename it to Tutorial.

Then scroll the menu section down till you see a section that says "Mu Shader". Within that you will see a dark blue menu you can click on, doing so brings up a list of loaded shaders for KSP.  Choose KSP/Diffuse. This is a common shader used in KSP and only requires 1 texture pic to work.

JTTPLOd.jpeg

Directly below the blue Shaders button is a box to put a name in. Type in Tutorial. This is only required the first time you create a new material and won't have anything in it the next time you import. Then below that, expand the "Textures" box and then in the box below Name: [_MainTex] where it is defaulted to say "gray", change the gray to say Tutorial. The material set up will now look for a picture file named Tutorial in the folder that you saved your .mu model to.

At this point you could export your mesh as an .mu file to the folder you created or wait till you have mapped your mesh. Either way it will need to exported and then imported back in for the program to establish the new material, so that you will be able to see it on your mesh. On models that already have established materials, this is already done and will show up when imported.

Always remember when importing a .mu file to select all meshes and "Merge by Distance" in "Edit Mode"  before you try to change anything.

Now that our material is set up it is time to map our faces. I am using 4 colours, 1 per face to make this simple.

From the main workspace you wil see along the top some task choice boxes "Main" that we are currently in, "Assets", "Uv Editing", "Shading","Animation", "Nodes", "Scripting"

Shading is rarely used now in the latest version as it now will show established materials without having to go in to Shading and detaching the Vertex color. KSP shaders can't be edited in Blender for their linked modules, but there are values that can be tweaked for some shaders to go from a metalic sheen to a mirror finish, but that is for more advanced modeling when you have had experience of the basics down.

For now we want"Uv Editing".

This will bring up a split screen. Left side, just like "Edit Mode" but with some more options. Right side, a 2D workspace where your texture pic is shown. If you already exported and then imported, then your pic should already be loaded. If not you will need to use the browse function to find it. It looks like a "folder" option. The workspaces can be resized to give you more of 1, less of the other, so it might not be visible at first. But if you hover over any choices line of symbols/menus across the top and then turn your mouse wheel, the options will scroll sideways. Find the right direction to scroll and the option will appear at some point.

XweB8oY.jpeg

Now select the vertices of a face like you would in "Edit Mode". However the default mapping was set up, the vertices and edges of the selected faces will show up on the right panel. If you rotate the view of the mesh on the left workspace so the face is flat to you. You can then use the "UV" drop down and choose "Project from View" to make it easier. How far you are zoomed in will determine how large the wire frame is over your pic when created. Zoom out for smaller frames to be created. Once done you can also move, rotate and resize in the 2D view. Drag the shape you have created in the 2D view over a colour panel and adjust as needed. Then repeat till each face has it's own colour. If you previously exported/imported, then you will be able to see this by choosing the red and white chequered ball. If not then you will need to export and import now to see the result.

tce4G0A.jpegBKIBiMi.jpeg

Notice that after export/import that the things in your heirarchy will now have a little chevron, pointing up, next to them. This is what the latest plugin does when material properties are functioning.

 

Next I want to be able to config an attachment node to go in the centre of the base. For that I will need to know where compared to world centre, the centre of the base is. Now for such a simple model it is easy to work out, but in the future things will be much more complicated. So here is what we can do.

 

Go to the "Edit Mode" workspace. Select the 3 vertices that make up the base. Open the "Mesh" menu and go to the "Snap" choice. Within it choose "Cursor to Selection". The cursor will be placed exactly in the centre of the 3 vertices. (This method is great for if you have to move origin points, for things like flaps and landing gear and more.) A meshes origin point is usually the world centre if spawned in the Main workspace, but if you are moving things or spawning in the "Edit Mode" workspace, then they could be anywhere.

Now that we have moved the 3D cursor, go back to the main workspace and add an empty. This empty will spawn where you left the 3D cursor. It will be outside your heirarchy, but that is fine as we are not keeping it. Give it a name and make sure it is highlighted. (The next part used to have to be done manually but some new tricks have been added.)

PW0fJSW.jpeg

With it highlighted go up and click on the blue "Export Mu" button and you will see the option "Show MODEL{}Transform" When you click this a little green box that says "Scale= 1,1,1"

will briefly show up at the bottom of the workspace. Click it before it disappears and a window with the data of what is highlighted, will pop up. The last part of the data is the important bit as it will state, location , rotation(You want the Quarternion) and scale. This info can be copied from here to your configuration file.

lKNhLSc.jpeg

 

Now finally we want to be able to interact with our model in KSP. For that we are going to need a collider.

So with our mesh highlighted we open the "Tool" menu that is in the main workspace on the right, go down to "Multiple Colliders" and choose "Make Mesh Collider". This will create a fitted collider mesh.

5vqjf5V.jpeg

Here you can see when I drag it off that it is the same shape.

wRkhRXb.jpeg

So now we highlight the top of the heirachy so that we get everything and export the .mu file using the Blue button, give it a name (For me "Tutorial.mu" for ease of project) and save to the folder we created.

 

You may have noticed that the bottom of screen, right side has info that wasn't there in the early shots. That is because I remembered to turn on Scene Statics. The info can be very helpful when you are creating and editing, to be sure a mesh piece does not have too many vertices.

Simply right click your mouse on that area and a little selection menu will pop up. Then just tick Scene Statics.

 

Now considering the type of shape we created, the simplist part to configure it as would be a probe core. The beauty of the KSP configuration system is that it uses simple text document files with a different suffix. You can literally just open a new Text file document and then rename it to have a .cfg rather than .txt suffix.  As it uses what are called "Modules" to tell the game how to configure parts, alot of configing can be done by copy and paste from previous config files that have the modules you need. You just edit parameters as needed to suit your part.

For this project to make it easy, we will go and copy Squad's "Rovemate" config to use as a basis to work from.

You can find it in the Command folder inside the Parts folder inside the Squad folder etc.
 

Spoiler

PART
{
    name = roverBody_v2
    module = Part
    author = AlexanderM
    MODEL {
        model = Squad/Parts/Command/probeRoverBody_v2/probeRoverBody_v2
        texture = QBE_New_diffuse, Squad/Parts/Command/probeCoreCube/QBE_New_diffuse
        texture = QBE_New_NRM, Squad/Parts/Command/probeCoreCube/QBE_New_NRM
    }
    rescaleFactor = 1
    node_stack_right = 0.510226, 0, 0, 1, 0, 0, 0
    node_stack_left = -0.510226, 0, 0, -1, 0, 0, 0
    node_stack_back = 0, 0, 0.22407, 0, 0, 1, 1
    node_stack_front = 0, 0, -0.22407, 0, 0, -1, 1
    node_stack_bottom = 0.0, -0.746285, 0.0, 0.0, -1.0, 0.0, 0
    node_stack_top = 0.0, 0.746285, 0.0, 0.0, 1.0, 0.0, 0
    TechRequired = fieldScience
    entryCost = 6200
    cost = 800
    category = Pods
    subcategory = 0
    title = #autoLOC_500349 //#autoLOC_500349 = Probodobodyne RoveMate
    manufacturer = #autoLOC_501633 //#autoLOC_501633 = Probodobodyne Inc
    description = #autoLOC_500350 //#autoLOC_500350 = A sturdy housing for a robust probe and battery system - no assembly required! Thought intended as the body for surface rovers, we've been told by our most day-dreaming of engineers that the possibilities are endless! While it has a Stability Assistance System, the RoveMate lacks reaction wheels so bring some along if you want to hold that attitude.
    attachRules = 1,0,1,1,0
    mass = 0.15
    dragModelType = default
    maximum_drag = 0.2
    minimum_drag = 0.15
    angularDrag = 1.5
    crashTolerance = 12
    maxTemp = 1200 // = 1200
    explosionPotential = 0
    vesselType = Probe
    bulkheadProfiles = size1
    tags = #autoLOC_500351 //#autoLOC_500351 = command control (core kerbnet probe rover sas space steer
    MODULE
    {
        name = ModuleCommand
        minimumCrew = 0
        RESOURCE
        {
            name = ElectricCharge
            rate = 0.04
        }
        hasHibernation = True
        hibernationMultiplier = 0.25
        defaultControlPointDisplayName = #autoLOC_6011001 //#autoLOC_6011001 = Forward
        CONTROLPOINT
        {
            name = up
            displayName = #autoLOC_6011000 //#autoLOC_6011000 = Up
            orientation = -90,0,0
        }
        CONTROLPOINT
        {
            name = reverse
            displayName = #autoLOC_6011004 //#autoLOC_6011004 = Reversed
            orientation = 0,0,180
        }
    }
    RESOURCE
    {
        name = ElectricCharge
        amount = 120
        maxAmount = 120
    }
    MODULE
    {
        name = ModuleSAS
    }
    MODULE
    {
        name = ModuleKerbNetAccess
        EnhancedSituationMask = 7
        EnhancedMinimumFoV = 160
        EnhancedMaximumFoV = 179.5
        MinimumFoV = 5
        MaximumFoV = 10
        AnomalyDetection = 1
        DISPLAY_MODES
        {
            Mode = Biome,#autoLOC_438890 //#autoLOC_438890 = Biome
            Mode = Terrain,#autoLOC_438839 //#autoLOC_438839 = Terrain
        }
    }

    MODULE
    {
        name = ModuleDataTransmitter
        antennaType = INTERNAL
        packetInterval = 1.0
        packetSize = 2
        packetResourceCost = 12.0
        requiredResource = ElectricCharge
        antennaPower = 5000
        optimumRange = 2500
        packetFloor = .1
        packetCeiling = 5
    }    
    
    MODULE
    {
        name = FlagDecal
        textureQuadName = Flag
    }

    MODULE
    {
        name = ModulePartVariants
        baseVariant = White
        VARIANT
        {
            name = White
            displayName = #autoLOC_8007116
            themeName = White
            primaryColor = #ffffff
            GAMEOBJECTS
            {
                bodyWhite = true
                bodyFoil = false
            }
        }
        VARIANT
        {
            name = Silver
            displayName = #autoLOC_6005005
            themeName = Silver
            primaryColor = #cecece
            TEXTURE
            {
                shader=KSP/Bumped Specular (Mapped)
                mainTextureURL = Squad/Parts/Command/probeRoverBody_v2/probeRoverBody_v2_silver_diffuse
                color = #ffffff
                _BumpMap= Squad/Parts/Command/probeRoverBody_v2/probeRoverBody_v2_silver_NRM
                _SpecMap= Squad/Parts/Command/probeRoverBody_v2/probeRoverBody_v2_silver_specular
                _Shininess= 0.82
                _Opacity= 1.0
                _RimFalloff= 2.0
                _AmbientMultiplier= 0.3
            }
            GAMEOBJECTS
            {
                bodyWhite = false
                bodyFoil = true
            }
        }
        VARIANT
        {
            name = Gold
            displayName = #autoLOC_8007118
            themeName = Gold
            primaryColor = #fccb0a
            TEXTURE
            {
                shader=KSP/Bumped Specular (Mapped)
                mainTextureURL = Squad/Parts/Command/probeRoverBody_v2/probeRoverBody_v2_gold_diffuse
                color = #efe38b
                _BumpMap= Squad/Parts/Command/probeRoverBody_v2/probeRoverBody_v2_gold_NRM
                _SpecMap= Squad/Parts/Command/probeRoverBody_v2/probeRoverBody_v2_gold_specular
                _Shininess= 0.82
                _Opacity= 1.0
                _RimFalloff= 2.0
                _AmbientMultiplier= 0.8
            }
            GAMEOBJECTS
            {
                bodyWhite = false
                bodyFoil = true
            }
        }
        
    }

    MODULE
    {
        name = ModuleCargoPart
        packedVolume = 750
    }
}

Syntax and bracket placement are very important. There must be the starting Bracket just under PART and an ending bracket at the very end. Within theses brackets, every module and sub module must have their own brackets to separate them within the larger layout, so the game can recognise them. On the computer the brackets within brackets are 1 TAB space across to make it clear they are within and sub to modules. The copy and paste into the forum just removes the spacing.

Once you have perused the config for that part, have a look at the next where I have edited to suit our new part.
 

Spoiler

PART
{
    name = TutorialpartCJ
    module = Part
    author = ColdJ
    MODEL
    {
        model = Tutorial/Tutorial

    }
    rescaleFactor = 1
    // spacial x, y, z then rotation x, y z then node size
    node_stack_bottom = 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0

    TechRequired = fieldScience
    entryCost = 6200
    cost = 800
    category = Pods
    subcategory = 0
    title = Pyramid Pod
    manufacturer = CJ Aeronautics
    description = A sharp little probe to spear on.
    attachRules = 1,0,1,1,0
    mass = 0.15
    dragModelType = default
    maximum_drag = 0.2
    minimum_drag = 0.15
    angularDrag = 1.5
    crashTolerance = 12
    maxTemp = 1200 // = 1200
    explosionPotential = 0
    vesselType = Probe
    bulkheadProfiles = size1
    tags = probe pyramid
    MODULE
    {
        name = ModuleCommand
        minimumCrew = 0
        RESOURCE
        {
            name = ElectricCharge
            rate = 0.04
        }
        hasHibernation = True
        hibernationMultiplier = 0.25
        defaultControlPointDisplayName = #autoLOC_6011001 //#autoLOC_6011001 = Forward
        CONTROLPOINT
        {
            name = up
            displayName = #autoLOC_6011000 //#autoLOC_6011000 = Up
            orientation = -90,0,0
        }
        CONTROLPOINT
        {
            name = reverse
            displayName = #autoLOC_6011004 //#autoLOC_6011004 = Reversed
            orientation = 0,0,180
        }
    }
    RESOURCE
    {
        name = ElectricCharge
        amount = 120
        maxAmount = 120
    }
    MODULE
    {
        name = ModuleSAS
    }
    MODULE
    {
        name = ModuleKerbNetAccess
        EnhancedSituationMask = 7
        EnhancedMinimumFoV = 160
        EnhancedMaximumFoV = 179.5
        MinimumFoV = 5
        MaximumFoV = 10
        AnomalyDetection = 1
        DISPLAY_MODES
        {
            Mode = Biome,#autoLOC_438890 //#autoLOC_438890 = Biome
            Mode = Terrain,#autoLOC_438839 //#autoLOC_438839 = Terrain
        }
    }

    MODULE
    {
        name = ModuleDataTransmitter
        antennaType = INTERNAL
        packetInterval = 1.0
        packetSize = 2
        packetResourceCost = 12.0
        requiredResource = ElectricCharge
        antennaPower = 5000
        optimumRange = 2500
        packetFloor = .1
        packetCeiling = 5
    }    
    

 

    MODULE
    {
        name = ModuleCargoPart
        packedVolume = 750
    }
}

I have edited what is needed to make it a new and distinct part. All parts must have a unique "Name" or else the game will only load the first model with that name that it comes to.

I have edited the author to myself as it is the mesh that is significant here. Configs are open to everybody, but the meshes created by people are theirs and should always be respected, even if they have given you permission to make derivitive works, you should make sure to only add your name to the author section, not remove it if it is their mesh you are working off.

I have kept what is needed for the part to work and removed what was only required by the original part that the config was written for.

I have edited the node placement based on the info we generated in the 3D program. First 3 are spacial co-ordinates from world centre, the next 3 are the rotation direction of the node. The last 1 is the size of the node.

    MODEL
    {
        model = Tutorial/Tutorial

    }

Is telling the program to look in the folder inside GameData that is called Tutorial, and to then use the .mu file called Tutorial. Texture info is not required as long as the texture pic that is used by the model's material setup, is in the same folder as the .mu file.

So now we have a config, a model for it to use and it's texture pic. All in a folder that is inside the GameData folder.

So let's load it up.

And here we can see the part in the list, The title it was given, it's UI, the node we created for attachment and it's ability to be used in game.

There are things called "Drag Cubes" that the game calculates on load, based on the mesh shapes, (not the colliders, even if you had a big box collider around the whole model it wouldn't affect this calculation.) that it uses to determine how parts are affected when going through the air and the water. The Drag Cubes it creates can be overridden if you put your own inside your config file.

And so you will see aero and heating effects that match the shape of your mesh model.

7jsMeHJ.png2DmtBx5.png

83Rx3oF.png

 

Tutorial 2

For my second tutorial I am going to cover how to create colliders for a model you want a Kerbal to

be able to go inside of, how to separate sections of a mesh into their own meshes and using a

KSPDiffuse/Emissive shader to create the effect of a section lighting up.

 

Start a new project and add your 2 empties heirarchy. Then go to the "Add" menu and in the "Mesh"

menu choose a cylinder to spawn in. Open up the small menu that appears down the bottom left and

choose "Nothing". This will leave the ends open. Reparent the cylinder into the 2nd empty and then

make sure all 3 parts of the heirarchy are set to Quarternion, using the blue button next to the word

"Mode" in the "Item" menu on the right of the worksace. This will make sure that everything we create

in "Edit Mode" from our original cylinder will be set to Quarternions, and you won't have to change

them one at a time.

afQ5gI4.jpeg

I turn on "Face Orientation" here to show you that the out side faces are all blue and so can be seen

in game, and the inside are red and so won't be visible.

 

Now we are going to make this a walled tube, using the "Solidify faces" option. With all vertices

selected in "Edit Mode" go up and click on the "Face Menu" and then choose the option "Solidify

Faces". You will see that the cylinder now has edges and inside facing walls. But as the cylinder is

1 metre across and 2 metres long, the thickness of the walls is a bit thin. So open the small menu

that appeared down the bottom left and change the thickness to 0.1m , Now your edge will be 10cm

thick.

JJlsb6f.jpegoCyCAPq.jpeg

This the time to give your mesh a material property. As I also want to demonstrate creating a light

strip on the tube, we will create a new one using the KSPdiffuse/Emissive shader. So like the the

last model go through the steps to assign this to your mesh. You now have to have 2 texture pics so

the effect can work. Rename each texture and then go out and create the 2 pics in the folder you plan

to export to.

sE4hnWR.jpeg

To demonstrate how there is a default mapping before you map for yourself, I am going

to add a grey area to my pic from the last project, along the bottom half and "Save As" a different name.

I will then heavily darken the grey area before creating a strip through it's middle that is heavily

lightened. Once done I will "Save As" again and Rename it with an E on the end. These 2 pics are

named to the choices of name that I did in material properties.

 

Now I will export my heirarchy to the folder I have the pics in. As I am doing this as a tutorial, it

will be in the same folder as the first model.

Start a new session and import back in the .mu you just created. It will now have it's material setup

saved. Highlight the mesh and go into "Edit Mode". Choose to "Merge by Distance" while all your

vertices are selected to remove the extras created by the export.

Now when we start separating out new meshes they will already be set up to the mode and material

setup of the first mesh.

0fxIdMb.jpeg

But first we want to map our cylinder before we do this. So go into "Uv Editing" and you should see 1

of your pics in the 2D workspace. Strangely it tends to show the Emissive pic by default. The

emissive won't show on your mesh but we can still use it to setup our light strip. You will see that

if you use the red and white ball to change to material view, that because the default mapping covers

the entire pic, that the white and colour section is showing on he mesh.

RmBs4yi.jpeg

While your mouse is hovering

over the 3D workspace, hit 1 on the number keypad to switch to a side on orthagonal view. While all

the vertices are selected use the "Project from View" option to map a new wireframe on the pic.
Because I chose a light strip that goes from left to right, I need to rotate the wireframe 90 degrees

to line up and then resize to make sure that the faces I want to be lit up are matched to the strip.
You might have notived that due to export and import that all your faces are now triangulated.

NVHSwyR.jpeg

CA2MqV6.jpegWAKJM25.jpeg
With the tube now mapped we can go back to the "Edit Mode" workspace.
(I have chosen a dull grey texture for now so I can use this mesh to show you a metalic sheen on a

future tutorial.)

Now back in the "Edit Mode" workspace, use 7 on the number pad to give you an orthagonal view of the

end of the tube so that you are looking through it. Switch to wireframe view using the ball with

lines and select a segment made of 4 vertices. Because we are in wireframe and looking from an end,

we are actually selecting 8 vertices that make up a wall wedge. With them selected go up and click

"Mesh" then go down and hover over "Separate", the choose "Selected". That selection will have been

separated into a new mesh of it's own that you can see in the heirarchy, with the same name but with

a number added. Only the edges will seem to go dark on the first selection because the wedges either

side need vertices in the same spots to maintain themselves.

kvJF7Pf.jpeg

Repeat this action a wedge at a time,

going all the way around till there is only 1 wedge left.

C2illaP.jpeg

You will now have 0 to 31 wedges named

cylinder, go out to the main "Object Mode" workspace. Choose the first piece in the heirarchy menu

and then go give it a mesh collider. Repeat until all mesh pieces have their own collider. You now

have a tube with colliders that will allow a Kerbal to walk through it.

J1Hn4eW.jpeg

Export your model and now it is time to make a config.

Copy the config file for the Mk1 structural tube to your folder, edit the name, and then go in and

edit the details as in the one below. It also contains the module for the emissive effect, copied

from the Mk1 pod. Copying from other configs is the fastest way to create new ones and once you have

created enough you will be able to just copy from your own.

Spoiler

PART
{
    name = TubesCJ
    module = Part
    author = ColdJ
    rescaleFactor = 1

    // definition format is Position X, Position Y, Position Z, Up X, Up Y, Up Z, [node size], [crossfeed, def=1 i.e. true], [rigid attach, def=0 i.e. false]
    node_stack_top = 0.0, 1.0, 0.0, 0.0, 1.0, 0.0
    node_stack_bottom = 0.0, -1.0, 0.0, 0.0, -1.0, 0.0
    node_attach = 0.0, 0.0, -0.5, 0.0, 0.0, 1.0, 1
    TechRequired = generalConstruction
    entryCost = 2500
    cost = 380
    category = Structural
    subcategory = 0
    title = Tubes
    manufacturer = CJ Aerospace Division
    description = A tube

    // attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision
    attachRules = 1,1,1,1,0 // note the extra numbers set o 1. The first model could be the first picked and could be attached to, this one can also attach to other parts by contact.
    mass = 0.1
    dragModelType = default
    maximum_drag = 0.2
    minimum_drag = 0.3
    angularDrag = 2
    crashTolerance = 10
    breakingForce = 50
    breakingTorque = 50
    maxTemp = 2000 // = 3000
    fuelCrossFeed = True
    bulkheadProfiles = size1, srf
    tags = tube

    MODEL
    {
        model = Tutorial/Tubes
    }
    MODULE
    {
        name = ModuleCargoPart        
        packedVolume = -1
    }
    MODULE
    {
        name = ModuleColorChanger
        shaderProperty = _EmissiveColor
        animRate = 0.8
        animState = false
        useRate = true
        toggleInEditor = true
        toggleInFlight = true
        toggleInFlight = true
        unfocusedRange = 5
        toggleName = #autoLOC_502011 //#autoLOC_502011 = Toggle Lights
        eventOnName = #autoLOC_502012 //#autoLOC_502012 = Lights On
        eventOffName = #autoLOC_502013 //#autoLOC_502013 = Lights Off
        toggleAction = True
        defaultActionGroup = Light
        redCurve
        {
            key = 0 0 0 3
            key = 1 1 0 0
        }
        greenCurve
        {
            key = 0 0 0 1
            key = 1 1 1 0
        }
        blueCurve
        {
            key = 0 0 0 0
            key = 1 0.7 1.5 0
        }
        alphaCurve
        {
            key = 0 1
        }
    }
}

 


The nodes are easy to work out as we know the tube is 2m long and so 1m positive for the front and 1m

negative for the back. As this piece is allowed to stick to others we also attach at a side, half a

metre from centre.

Once done you can load the game and test your creation.

 

Edited by ColdJ
Link to comment
Share on other sites

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