Jump to content

How do I use MODEL to load a texture for a part?


JoePatrick1

Recommended Posts

I am trying to use MODEL{} as I need several parts to use the same texture so I just want one copy but the texture isn't loading

This is what I have, the model loads fine but the texture doesn't. The CFG and .mu model are in the same folder but the texture is in a separate location

MODEL
	{
		model = KerBalloons/Parts/0625Balloons/model
		texture =  KerBalloons/Parts/Textures/KBTexKerbin
	}

 

Link to comment
Share on other sites

If the actual texture is not in the same folder as the .mu file, then you will need a dummy texture in the folder in it's place. This can be a 1x1 pixel image, but something must be there for the MODEL node to recognize and swap with the intended texture. The dummy texture in the folder with the .mu must be named the same as the texture applied to the model in unity. The replacement texture can be named anything. 

Your node should be as follows:

MODEL
{
          model = KerBalloons/Parts/0625Balloons/model
          texture = KBTexKerbin, KerBalloons/Parts/Textures/KBTexKerbin
          scale = 1,1,1
}

So, in the "texture =" line:

texture = KBTexKerbin - This portion is the name of the models texture you want to replace. There must be an image file in the same folder as the model with this name.

, KerBallons/Parts/Textures/KBTexKerbin - This portion is the filepath and name of the texture you want to switch with the original. The name of this texture does not have to match the original. ", KerBallons/Parts/Textures/Gobbledegook001" would work just fine.

 

Edit:

And you can replace as many textures as you want by adding more texture = lines.

Edited by Randazzo
Link to comment
Share on other sites

26 minutes ago, Randazzo said:

If the actual texture is not in the same folder as the .mu file, then you will need a dummy texture in the folder in it's place. This can be a 1x1 pixel image, but something must be there for the MODEL node to recognize and swap with the intended texture. The dummy texture in the folder with the .mu must be named the same as the texture applied to the model in unity. The replacement texture can be named anything. 

Your node should be as follows:


MODEL
{
          model = KerBalloons/Parts/0625Balloons/model
          texture = KBTexKerbin, KerBalloons/Parts/Textures/KBTexKerbin
          scale = 1,1,1
}

So, in the "texture =" line:

texture = KBTexKerbin - This portion is the name of the models texture you want to replace. There must be an image file in the same folder as the model with this name.

, KerBallons/Parts/Textures/KBTexKerbin - This portion is the filepath and name of the texture you want to switch with the original. The name of this texture does not have to match the original. ", KerBallons/Parts/Textures/Gobbledegook001" would work just fine.

 

Edit:

And you can replace as many textures as you want by adding more texture = lines.

Done all this and now the game doesn't load. It gets stuck on my part on the loading screen.  

I have tried same file names/different. png/mbm/dds, changine folder names. Nothing works.  

When I use dds (converted my png to dds with onlineconvert) the game loads but in the log it says texture loading error and the texture is not loaded  

any ideas?  

edit: here are some screenshots

 

Edited by JoePatrick1
Link to comment
Share on other sites

19 minutes ago, JoePatrick1 said:

Done all this and now the game doesn't load. It gets stuck on my part on the loading screen.  

I have tried same file names/different. png/mbm/dds, changine folder names. Nothing works.  

When I use dds (converted my png to dds with onlineconvert) the game loads but in the log it says texture loading error and the texture is not loaded  

any ideas?  

edit: here are some screenshots

 

Try adding the scale line to your model node.

scale = 1,1,1

If that doesn't work, the output_log and .cfg file for the part may help with the troubleshooting.

Edit: It also looks like you might have an extra space between "=" and "KBTexKerbin". Not sure if that will matter.

Edited by Randazzo
Link to comment
Share on other sites

4 minutes ago, Randazzo said:

Try adding the scale line to your model node.

scale = 1,1,1

If that doesn't work, the output_log and .cfg file for the part may help with the troubleshooting.

Nope, that didn't work  

Here is what the log says

[LOG 15:32:47.262] PartLoader: Compiling Part 'KerBalloons/Parts/0625Balloons/standard/625BalloonS'
[EXC 15:32:47.273] NullReferenceException: Object reference not set to an instance of an object
	PartLoader.ReplaceTextures (UnityEngine.GameObject model, System.Collections.Generic.List`1 textureNames, System.Collections.Generic.List`1 newTextures)
	PartLoader.CompileModel (.UrlConfig cfg, .ConfigNode partCfg, Single scaleFactor, .AvailablePart partInfo)
	PartLoader.ParsePart (.UrlConfig urlConfig, .ConfigNode node)
	PartLoader+<CompileParts>c__Iterator4A.MoveNext ()
[ERR 15:32:55.426] [KSPSteamController]: Action set handle for MenuControls has &0. That's probably not right.

[ERR 15:32:55.445] [KSPSteamController]: Action set handle for FlightControls has &0. That's probably not right.

[ERR 15:32:55.475] [KSPSteamController]: Action set handle for DockingControls has &0. That's probably not right.

[ERR 15:32:55.523] [KSPSteamController]: Action set handle for EditorControls has &0. That's probably not right.

[ERR 15:32:55.524] [KSPSteamController]: Action set handle for MapControls has &0. That's probably not right.

[EXC 15:32:55.639] InvalidOperationException: Steamworks is not initialized.
	Steamworks.InteropHelp.TestIfAvailableClient ()
	Steamworks.SteamController.Shutdown ()
	SteamController.KSPSteamController.OnDestroy ()

 

Edited by JoePatrick1
Link to comment
Share on other sites

45 minutes ago, Randazzo said:

 

texture = KBTexKerbin - This portion is the name of the models texture you want to replace. There must be an image file in the same folder as the model with this name.

, KerBallons/Parts/Textures/KBTexKerbin - This portion is the filepath and name of the texture you want to switch with the original. The name of this texture does not have to match the original. ", KerBallons/Parts/Textures/Gobbledegook001" would work just fine.

Ahhh... Thank You... I've been wondering why the def needed the two "parts", and why you would need to specify the texture name first, then basically repeat with the folder path... Seems every example I've seen of the texture def, has always had the replacement texture named the same as the original...

Link to comment
Share on other sites

2 minutes ago, JoePatrick1 said:

Nope, that didn't work  

Here is what the log says


[LOG 15:32:47.262] PartLoader: Compiling Part 'KerBalloons/Parts/0625Balloons/standard/625BalloonS'
[EXC 15:32:47.273] NullReferenceException: Object reference not set to an instance of an object
	PartLoader.ReplaceTextures (UnityEngine.GameObject model, System.Collections.Generic.List`1 textureNames, System.Collections.Generic.List`1 newTextures)
	PartLoader.CompileModel (.UrlConfig cfg, .ConfigNode partCfg, Single scaleFactor, .AvailablePart partInfo)
	PartLoader.ParsePart (.UrlConfig urlConfig, .ConfigNode node)
	PartLoader+<CompileParts>c__Iterator4A.MoveNext ()
[ERR 15:32:55.426] [KSPSteamController]: Action set handle for MenuControls has &0. That's probably not right.

[ERR 15:32:55.445] [KSPSteamController]: Action set handle for FlightControls has &0. That's probably not right.

[ERR 15:32:55.475] [KSPSteamController]: Action set handle for DockingControls has &0. That's probably not right.

[ERR 15:32:55.523] [KSPSteamController]: Action set handle for EditorControls has &0. That's probably not right.

[ERR 15:32:55.524] [KSPSteamController]: Action set handle for MapControls has &0. That's probably not right.

[EXC 15:32:55.639] InvalidOperationException: Steamworks is not initialized.
	Steamworks.InteropHelp.TestIfAvailableClient ()
	Steamworks.SteamController.Shutdown ()
	SteamController.KSPSteamController.OnDestroy ()

 

Hmm. Config file?

Link to comment
Share on other sites

2 minutes ago, Randazzo said:

Hmm. Config file?

PART
{
	name = 625BalloonS
	module = Part
	author = JoePatrick1
	
	MODEL
	{
		model = KerBalloons/Parts/0625Balloons/model
		texture =  KBTexKerbin, KerBalloons/Textures/KBTexKerbin
		scale = 1,1,1
	}

	scale = 1
	rescaleFactor = 1
	node_stack_bottom = 0.0, 0, 0.0, 0.0, -1.0, 0.0, 0
	TechRequired = start
	entryCost = 6000
	cost = 250
	category = none
	subcategory = 0
	title = KerBalloon (Kerbin) - 0.625m, Standard
	manufacturer = KerBalloons
	description = When KerBalloons came to us to pitch their product our first thought was - "Why the heck would we want balloons when we could have rockets". Lets just we changed our mind when we heard about the potential science and cost savings. KerBalloons also have a small flight computer onboard.
	attachRules = 1,0,1,1,0
	mass = 0.005
	dragModelType = default
	maximum_drag = 0.1
	minimum_drag = 0.1
	angularDrag = 0.5
	crashTolerance = 8
	maxTemp = 2000 // = 3000
	bulkheadProfiles = size0
	
	RESOURCE
	{
		name = ElectricCharge
		amount = 10
		maxAmount = 10
	}
	
	MODULE
	{
		name = ModuleKerBalloon
		recommendedBody = Kerbin
		minAtmoPressure = 5
		maxAtmoPressure = 102
		minScale = 1
		maxScale = 5
		minLift = 10
		maxLift = 13

		targetTWR = 1
		liftLimit = 1
		speedLimiter = true
		maxSpeed = 5
		maxSpeedTolerence = 0.05
		speedAdjustStep = 0.01
		speedAdjustMin = 0.9
		speedAdjustMax = 1.1

		CFGballoonObject = Balloon
		CFGropeObject = Rope
		CFGcapObject = Cap
		CFGliftPointObject = liftPoint
		CFGballoonPointObject = balloonPoint
	}

	MODULE
	{
		name = FlagDecal
		textureQuadName = flagDecal
	}

	EFFECTS
	{
		inflate
		{
			AUDIO
			{
				clip = KerBalloons/Sounds/inflate
				volume = 1
			}
		}
		deflate
		{
			AUDIO
			{
				clip = KerBalloons/Sounds/deflate
				volume = 1
			}
		}
		burst
		{
			AUDIO
			{
				clip = KerBalloons/Sounds/burst
				volume = 1
			}
		}
	}
}

(the path is now slightly different as I moved things around but is still correct)

Link to comment
Share on other sites

Just now, Stone Blue said:

@JoePatrick1 do you compile your materials in Unity, before writing the new model?

I apply the textures to the models in Unity, then hit write which creates the .mbm - I then move this texture to my separate folder and put a dummy texture in its place

Link to comment
Share on other sites

Assuming the pathing is correct, that looks mostly fine. You still have a double space in your texture line, I don't know for certain if it makes a difference, but since the compiler is having trouble with the texture, best to make sure everything is in order.

texture =  KBTexKerbin, KerBalloons/Textures/KBTexKerbin versus
texture = KBTexKerbin, KerBalloons/Textures/KBTexKerbin

Remove that scale = 1 line from below the Model node. Beyond that, assuming the pathing is correct, that looks like it should load fine.

Does this part load properly if you put the texture in the folder with it and load it via mesh? If it still throws errors without the model node, there may be a problem with the part itself.

 


 

Link to comment
Share on other sites

1 minute ago, JoePatrick1 said:

I apply the textures to the models in Unity, then hit write which creates the .mbm - I then move this texture to my separate folder and put a dummy texture in its place

Yes, but do you check the "Show Materials" box, and click the "Compile Materials" button in the Part Tools component, before writing the .mbm?

I've had issues where I've changed materials/textures in Unity, and NOT recompiled before writing the model, and had similar issues with loading in-game...

I'm not sure if it only does it when you do the actual change in Unity, then write without compiling, or if Unity will automagically recompiile everything if you Save Scene/Project, and or close/re-open Unity...

Link to comment
Share on other sites

Hi by any chance are all your models mapped to the same texture and contained in the same folder?

I ask because I've recently started doing a similar thing, and have found that if you have 1 copy of the texture, the models cfg's and model mu's all in the same folder there is actually no need to define the texture if the texture is the same name as that which is present in the .mu

Link to comment
Share on other sites

34 minutes ago, Randazzo said:

Assuming the pathing is correct, that looks mostly fine. You still have a double space in your texture line, I don't know for certain if it makes a difference, but since the compiler is having trouble with the texture, best to make sure everything is in order.

texture =  KBTexKerbin, KerBalloons/Textures/KBTexKerbin versus
texture = KBTexKerbin, KerBalloons/Textures/KBTexKerbin

Remove that scale = 1 line from below the Model node. Beyond that, assuming the pathing is correct, that looks like it should load fine.

Does this part load properly if you put the texture in the folder with it and load it via mesh? If it still throws errors without the model node, there may be a problem with the part itself.

Tried all of this, still no luck.  If I remove the 'proper' texture from the separate folder everyone loads fine (but obviously the part doesn't have the texture)  

17 minutes ago, SpannerMonkey(smce) said:

Hi by any chance are all your models mapped to the same texture and contained in the same folder?

I ask because I've recently started doing a similar thing, and have found that if you have 1 copy of the texture, the models cfg's and model mu's all in the same folder there is actually no need to define the texture if the texture is the same name as that which is present in the .mu

I do but I then also have other parts in separate folders that use the texture so I then have a copy of the texture with those as well where as I want to just have 1 texture for all parts in all folders

33 minutes ago, Stone Blue said:

Yes, but do you check the "Show Materials" box, and click the "Compile Materials" button in the Part Tools component, before writing the .mbm?

I've had issues where I've changed materials/textures in Unity, and NOT recompiled before writing the model, and had similar issues with loading in-game...

I'm not sure if it only does it when you do the actual change in Unity, then write without compiling, or if Unity will automagically recompiile everything if you Save Scene/Project, and or close/re-open Unity...

I didn't even know that button was there, I will try checking that and then let you know

edit: seems to have had no effect

Edited by JoePatrick1
Link to comment
Share on other sites

13 minutes ago, JoePatrick1 said:

Tried all of this, still no luck.  If I remove the 'proper' texture from the separate folder everyone loads fine (but obviously the part doesn't have the texture'  

Well then I'm at a loss. I don't know why the actual texture being present would break the thing. I've never used mbm's or different image file types, but I don't think that should matter.

Were I in your shoes I would now be in the "Try stuff" stage. Is it only that texture that breaks it? Try a different one. Try .pngs. I would still be curious to know if it loads properly when using mesh = model.mu with the texture in the folder.

That's the best advice I've got at the moment, sorry.

Edit: I'm going to ping @NecroBones, I know he uses textures between parts. Perhaps he's encountered this before.

Edited by Randazzo
Link to comment
Share on other sites

7 minutes ago, Randazzo said:

Well then I'm at a loss. I don't know why the actual texture being present would break the thing. I've never used mbm's or different image file types, but I don't think that should matter.

Were I in your shoes I would now be in the "Try stuff" stage. Is it only that texture that breaks it? Try a different one. Try .pngs. I would still be curious to know if it loads properly when using mesh = model.mu with the texture in the folder.

That's the best advice I've got at the moment, sorry.

I tried .png - same issue
.dds loads the game but doesn't replace the texture and I get this error the debug log  
kpjc1PF.png

I converted my .png to .dds with onlineconvert.com, is there a specific way I'm supposed to do it?

I have had this part working fully for months but I wanted to try and remove duplicate textures which is why I am doing this and it is only now that I am having this problem. before I was just using mesh = model with the texture in the folder, not using MODEL{}

Edited by JoePatrick1
Link to comment
Share on other sites

Just now, JoePatrick1 said:

I tried .png - same issue
.dds loads the game but it still doesn't work because I get this error the debug log  
kpjc1PF.png

I converted my .png to .dds with onlineconvert.com, is there a specific way I'm supposed to do it?

I have had this part working fully for months but I wanted to try and remove duplicate textures which is why I am doing this and it is only now that I am having this problem

Well that is telling you the file path is not correct.

The screenshot you posted does have a different structure, but you said you had moved things.

 

Link to comment
Share on other sites

2 minutes ago, Randazzo said:

Well that is telling you the file path is not correct.

The screenshot you posted does have a different structure, but you said you had moved things.

 

Maybe I'm missing something but from what I can tell the path is correct.
Here are some screenshots
 

Link to comment
Share on other sites

5 minutes ago, JoePatrick1 said:

Maybe I'm missing something but from what I can tell the path is correct.
Here are some screenshots
 

I'm not seeing it either. :(

To answer your earlier question about converting to DDS, I use DDS4KSP (http://forum.kerbalspaceprogram.com/index.php?/topic/88972-win-ksp-to-dds-texture-converter) but I recall I had to do some other things (install a .net framework or something) to get it working properly.

 

Link to comment
Share on other sites

3 minutes ago, Randazzo said:

I'm not seeing it either. :(

To answer your earlier question about converting to DDS, I use DDS4KSP (http://forum.kerbalspaceprogram.com/index.php?/topic/88972-win-ksp-to-dds-texture-converter) but I recall I had to do some other things (install a .net framework or something) to get it working properly.

 

Just tried that and using that .dds file gave me the same issue as .mbm and .png (not loading) so I guess the other .dds I was using had something wrong with it as it loaded the game like when no file is there. Have absolutely no idea why the game doesn't load though.

Link to comment
Share on other sites

Hi again, thought i should mention that for some reason on my system i can only  share textures within a folder, every attempt using every method and trick and all the advice on the forum to share textures across folders has failed for no apparent reason.   i  posted here about my problem a while back and despite everything being correct, right down to having dummy textures, it refused to work, in my case i was trying to ref a squad texture for a custom model but the rules are the same.

Sadly it sounds like you have exactly the same problem, although you may be able to compromise and combine some of those texture sharing models into one folder and just have a couple of duplicates instead of many.

Link to comment
Share on other sites

2 minutes ago, SpannerMonkey(smce) said:

Hi again, thought i should mention that for some reason on my system i can only  share textures within a folder, every attempt using every method and trick and all the advice on the forum to share textures across folders has failed for no apparent reason.   i  posted here about my problem a while back and despite everything being correct, right down to having dummy textures, it refused to work, in my case i was trying to ref a squad texture for a custom model but the rules are the same.

Sadly it sounds like you have exactly the same problem, although you may be able to compromise and combine some of those texture sharing models into one folder and just have a couple of duplicates instead of many.

ok, that's a shame.
There is no reason why I can't just put all the parts in the same folder - I just like to have things organised

Link to comment
Share on other sites

3 hours ago, Randazzo said:

Edit: I'm going to ping @NecroBones, I know he uses textures between parts. Perhaps he's encountered this before.

 

Gosh, it looks like you've all done a lot to troubleshoot this already. I'm not seeing it either. but I also second the vote for DDS4KSP. I use it, and it works wonderfully.

 

Here are some stupid/annoying things I've run into before though:

 

* Sometimes you can end up with a corrupted DDS. I'm not sure what exactly is going on, but I had one occasion where my textures were coming out as much larger files than normal, so I think it was screwing up the mipmaps or something, and I had similar problems. Try getting the reassignment to work with an MBM texture as the target, instead of DDS, and see if that works first. If it does, redo your DDS conversion.

 

* Never use PNGs for this. Really. Just don't. KSP is horribly inconsistent about allowing reassignment of textures when they're in that format, for some reason. If it's your model (not one from another person's mod), then you have control of this, and should export the model with the associated texture as MBM format only. I used to use PNGs for placeholders, which worked for a while (I was lucky), but ran into enough problems that were hard to diagnose, that I now just avoid them.

 

* Don't use Active Texture Management when doing this. ATM was useful a long time ago, but not anymore, with KSP 64-bit, and DDS support included. ATM interferes with cross-folder reassignments. I'm not sure if anyone still uses this at all, but I figured I'd mention it.

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