Jump to content

mesh -> model


Recommended Posts

so I have a habit of updating part.cfg's.

 

nasty habit of mine.

and in some parts I like to adjust scale, rotation, textures.

many still use the < mesh = model.mu > syntax.

I want to update to the

	MODEL
	{
		model = MoarKerbals/Assets/GenericModule
		texture = Decal00 , MoarKerbals/Assets/Decal18
		texture = Decal00_GLOW , MoarKerbals/Assets/Decal18_GLOW
		rotation = 1.0, 1.0, 1.0
		scale = 1.0, 1.0, 1.0
	}

 

however, just converting over rarely seemingly works.

Is there a trick to doing this without going into blender (which my super-grand-potato refuses to run) or Unity?

Link to comment
Share on other sites

16 hours ago, zer0Kerbal said:

Is there a trick to doing this without going into blender

It has to be addressed on a part-by-part basis.  Due to the completely random assortment of scales and scaling factors used in the stock models (mostly the older ones; newer ones are better), each part must be recalculated based on the scaling values listed in the config file.

You need to know:

  • The default scale/units the model was created in.  This is where it is faster to import the model into blender, but with some math you can calculate backwards from the config-specified values and measurements from within KSP.
  • What sort of scaling is being used in the current config.  This is both 'scale=' and 'rescaleFactor=', which get applied in different methods (one of them also scales attach nodes I think?), but both impact the model scaling.
  • How to fix legacy particle effects if/when they are in use, as they also interacted with the scaling, and will be incorrect when the model is scaled through the MODEL node setup.

If you had a specific example of where the direct/simple conversion is failing, I could possibly walk you through the calculation process to determine what 'scale = X,X,X' to put into the MODEL node, and how to fix the attach-nodes.

 

 

Link to comment
Share on other sites

 

@zer0Kerbal When you say it fails, does that mean it doesn't load, part is distorted, parts are all one color?

Spoiler

An example for your part. 

mesh=GenericModule.mu

File Structure.

GameData/MoarKerbals/GenericModule.mu

GameData/MoarKerbals/Decal00.dds

GameData/MoarKerbals/Decal00_GLOW.dds

Should work.

 

 

Now to convert it without moving any assets

    MODEL
    {
        model = MoarKerbals/GenericModule.mu
    }

File Structure

GameData/MoarKerbals/GenericModule.mu

GameData/MoarKerbals/Decal00.dds

GameData/MoarKerbals/Decal00_GLOW.dds

You will need to keep your texture files located with the .mu file to work. This should work.

 

 

Now to move the texture files but leaving the .mu file in the same location

   MODEL
    {
        model = MoarKerbals/GenericModule.mu
        texture = Decal00, MoarKerbals/Assets/Decal18
        texture = Decal00_GLOW, MoarKerbals/Assets/Decal18_GLOW
    }

You will need to still keep texture files labelled Decal00.dds, Decal00_GLOW.dds in the same folder as the .mu file or you cant swap textures. You will sometimes find texture files that are 1kb blank files. This is so the game will load the part to texture swap. If it does not find the destination texture, the part should show as white or maybe as what the blank texture is.

File Structure.

GameData/MoarKerbals/GenericModule.mu

GameData/MoarKerbals/Decal00.dds

GameData/MoarKerbals/Decal00_GLOW.dds

GameData/MoarKerbals/Assets/Decal18.dds

GameData/MoarKerbals/Assets/Decal18_GLOW.dds

 

 

Your Example given does this.

   MODEL
    {
        model = MoarKerbals/Assets/GenericModule.mu
        texture = Decal00, MoarKerbals/Assets/Decal18
        texture = Decal00_GLOW, MoarKerbals/Assets/Decal18_GLOW
    }

So your file structure should be as follows to work.

GameData/MoarKerbals/Assets/GenericModule.mu

GameData/MoarKerbals/Assets/Decal00.dds

GameData/MoarKerbals/Assets/Decal00_GLOW.dds

GameData/MoarKerbals/Assets/Decal18.dds

GameData/MoarKerbals/Assets/Decal18_GLOW.dds

 

Shadowmage is smart on all the other stuff.

I hope this helps and correct me if I am wrong on any of it.

 

Link to comment
Share on other sites

@Barar thank you.

I have been updating part mods; part of that is moving textures and models into an Assets folder. I can't remember which one has been giving me trouble, but once I find it - (it has to be one of the many mods I have in my adoption pipeline) I will come back here.

Currently trying to do a texture swap using stock variant system. I can do it with B9, just want to do it via stock not only to learn how to do it, but so it is done with stock. :D

Link to comment
Share on other sites

@zer0Kerbal

I have played around with the variant system. Usually just followed the examples from some parts like the expansion fuel tanks. The mk2LanderCan_v2 can show some advanced options if you want to go beyond texture swapping. It can disable the gameobject meshes, colliders and even animations. You can also adjust nodes, costs and mass.

You can find some more information here if you have not seen this thread.

 

Link to comment
Share on other sites

thank you @Shadowmage and  @Barar !

+1 :rep:

things are behaving better.

still flumoxed about partvarient - just swapping the color

here are the parts

https://github.com/zer0Kerbal/DaMichel/tree/master/GameData/DaMichel/SphericalTanks

trying to swap out 'orange-tank-r140-color.dds' for a host of other color textures in /Assets/

here is the code I am using:

Spoiler

PART
{
	// --- general parameters ---
	name = DM-SphericalTank-125-55
	module = Part
	author = DaMichel
	// refactor by Color Curves Company

	// --- asset parameters ---
	MODEL
	{
		model = DaMichel/SphericalTanks/Assets/sphericalTank-c125-r55
		scale = 1.0, 1.0, 1.0
	}
...

 

...

Spoiler

...
	RESOURCE
	{
		name = Oxidizer
		amount = 67.375 // = 67
		maxAmount = 67.375 // = 67
	}

	MODULE
	{
		name = ModulePartVariants
		primaryColor = #ffffff
		secondaryColor = #ffdd00
		baseDisplayName = #autoLOC_8003114
		baseThemeName = YellowAndWhite
		orange-tank-r140-color
		VARIANT
		{
			name = Gold
			displayName = Gold // #autoLOC_8007116 	//#autoLOC_8007116 = White
			themeName = Gold
			primaryColor = #ffd700
			secondaryColor = #ffd700
			TEXTURE
			{
				materialName = orange-tank-r140-color // orange-tank-r55-color
				// mainTextureURL = DaMichel/SphericalTanks/Assets/gold
				_Color = DaMichel/SphericalTanks/Assets/gold
			}
		}
		VARIANT
		{
			name = Silver
			displayName = #autoLOC_8007116 	//#autoLOC_8007116 = White
			themeName = Silver
			primaryColor = #c0c0c0
			secondaryColor = #c0c0c0
			TEXTURE
			{
				materialName = orange-tank-r140-color // orange-tank-r55-color
				// mainTextureURL = DaMichel/SphericalTanks/Assets/gold
				_BumpMap = DaMichel/SphericalTanks/Assets/silver
			}
		}
		VARIANT
		{
			name = Copper
			displayName = #autoLOC_8007116 	//#autoLOC_8007116 = White
			themeName = Copper
			primaryColor = #ffffff
			secondaryColor = #ffffff
			TEXTURE
			{
				// mainTextureURL = DaMichel/SphericalTanks/Assets/gold
				_BumpMap = DaMichel/SphericalTanks/Assets/copper
			}
		}
		VARIANT
		{
			name = Bronze
			displayName = #autoLOC_8007116 	//#autoLOC_8007116 = White
			themeName = Bronze
			primaryColor = #ffffff
			secondaryColor = #ffffff
			TEXTURE
			{
				// mainTextureURL = DaMichel/SphericalTanks/Assets/gold
				_BumpMap = DaMichel/SphericalTanks/Assets/bronze
			}
		}
		VARIANT
		{
			name = Aluminum
			displayName = #autoLOC_8007116 	//#autoLOC_8007116 = White
			themeName = Aluminum
			primaryColor = #ffffff
			secondaryColor = #ffffff
			TEXTURE
			{
				// mainTextureURL = DaMichel/SphericalTanks/Assets/gold
				_BumpMap = DaMichel/SphericalTanks/Assets/aluminum
			}
		}
		VARIANT
		{
			name = NettedCarbonFiber
			displayName = #autoLOC_8007116 	//#autoLOC_8007116 = White
			themeName = NettedCarbonFiber
			primaryColor = #ffffff
			secondaryColor = #ffffff
			TEXTURE
			{
				// mainTextureURL = DaMichel/SphericalTanks/Assets/gold
				_BumpMap = DaMichel/SphericalTanks/Assets/NettedCarbonFiber
			}
		}
	}
		// texture = c125-colormap ,DaMichel/SphericalTanks/Parts/c125-colormap
		// texture = c125-normalmap_NRM ,DaMichel/SphericalTanks/Parts/c125-normalmap_NRM
}

 

I can get it swap out lots of things - just not the one I want.

I want to swap out 'orange-tank-r140-color ' for 'gold.dds' or 'silver.dds' or 'red.dds'

thank you in advance!

                materialName = orange-tank-r140-color // orange-tank-r55-color
                // mainTextureURL = DaMichel/SphericalTanks/Assets/gold
                _Color = DaMichel/SphericalTanks/Assets/gold

Link to comment
Share on other sites

Unfortunately for PartVariants, I cannot offer any support.  I've stayed as far away from that stock kludge as possible.  Although, I can tell you that the '_Color' parameter is not how to specify a texture, that needs to go under something like _MainTex or similar (_Color is a shader parameter that expects a color input and not a texture; you need to find the name of the shader parameter for the main texture, often _MainTex, and also however the stock PartVariant system references that texture).

If you have problems with any parts which simply use the MODEL node setup, I can likely assist with those if needed (that is just doing calculations on model scales and node positions).

Link to comment
Share on other sites

Looking at the parts, I can see where you want to go.

This is setup to swap out the texture.

Spoiler

    MODULE
    {
        name = ModulePartVariants
        primaryColor = #ffffff
        secondaryColor = #ffdd00
        baseDisplayName = #autoLOC_8003114
        baseThemeName = YellowAndWhite
//        orange-tank-r140-color
        VARIANT
        {
            name = Gold
            displayName = Gold // #autoLOC_8007116     //#autoLOC_8007116 = White
            themeName = Gold
            primaryColor = #ffd700
            secondaryColor = #ffd700
            TEXTURE
            {
//                materialName = orange-tank-r140-color // orange-tank-r55-color
                mainTextureURL = DaMichel/SphericalTanks/Assets/gold
//                _Color = DaMichel/SphericalTanks/Assets/gold
            }
        }
        VARIANT
        {
            name = Silver
            displayName = #autoLOC_8007116     //#autoLOC_8007116 = White
            themeName = Silver
            primaryColor = #c0c0c0
            secondaryColor = #c0c0c0
            TEXTURE
            {
//                materialName = orange-tank-r140-color // orange-tank-r55-color
                mainTextureURL = DaMichel/SphericalTanks/Assets/silver
//                _BumpMap = DaMichel/SphericalTanks/Assets/silver
            }
        }
        VARIANT
        {
            name = Copper
            displayName = #autoLOC_8007116     //#autoLOC_8007116 = White
            themeName = Copper
            primaryColor = #ffffff
            secondaryColor = #ffffff
            TEXTURE
            {
                mainTextureURL = DaMichel/SphericalTanks/Assets/copper
//                _BumpMap = DaMichel/SphericalTanks/Assets/copper
            }
        }
        VARIANT
        {
            name = Bronze
            displayName = #autoLOC_8007116     //#autoLOC_8007116 = White
            themeName = Bronze
            primaryColor = #ffffff
            secondaryColor = #ffffff
            TEXTURE
            {
                mainTextureURL = DaMichel/SphericalTanks/Assets/bronze
//                _BumpMap = DaMichel/SphericalTanks/Assets/bronze
            }
        }
        VARIANT
        {
            name = Aluminum
            displayName = #autoLOC_8007116     //#autoLOC_8007116 = White
            themeName = Aluminum
            primaryColor = #ffffff
            secondaryColor = #ffffff
            TEXTURE
            {
                mainTextureURL = DaMichel/SphericalTanks/Assets/aluminum
//                _BumpMap = DaMichel/SphericalTanks/Assets/aluminum
            }
        }
        VARIANT
        {
            name = NettedCarbonFiber
            displayName = #autoLOC_8007116     //#autoLOC_8007116 = White
            themeName = NettedCarbonFiber
            primaryColor = #ffffff
            secondaryColor = #ffffff
            TEXTURE
            {
                mainTextureURL = DaMichel/SphericalTanks/Assets/NettedCarbonFiber
//                _BumpMap = DaMichel/SphericalTanks/Assets/NettedCarbonFiber
            }
        }
    }

The next issue will be that it swaps out all the textures for the one replacing it. This is from what I can tell is that the variant module can only handle one texture swap to the part, at a time. The only way I can see around it using the Variant system would be to create a texture file that would be a combination of c125-colormap.dds/Copper.dds in one texture file. With every variant being a combination of c125-colormap.dds/aluminum.dds, c125-colormap.dds/gold.dds, c125-colormap.dds/silver.dds and so on. Combined into one file, also making sure the UV maps line up, so would need the same texture layout.

The other way would be to skip swapping out the texture. You would rebuild the model, naming the gameobject unique names, and then flag them true or false. The GAMEOBJECTS in this case being the tanks that have a texture applied to it, but just made invisible till you make it visible. I'll mess with the sphere tanks and try to send you a model. 

 

 

 

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