Jump to content

Asteroid Spawn API?


Recommended Posts

You can edit the potatoroid part.cfg file to change the rescale factor and mass right? I think I've seen people do this before and get bigger asteroids.

Can you make a second potatoroid part, just copy the first and change the name, and direct the spawning code to that part instead, or alternate between spawning with both parts.

Link to comment
Share on other sites

  • 1 year later...
On 5/25/2014 at 7:48 PM, NathanKell said:

If it's not in GameData, it's in one of the assets files in KSP_Data. You can use a Unity assets browser to open them.

*Sigh* I'm going to feel like an idiot once I learn the answer, but...

Exactly how does one read a .assets file? I have Unity 5.2.4 with PartTools, but it doesn't seem to recognize the file type.

(Yes, I'm finally ready to tackle asteroid textures. Or try to, anyway...)

Link to comment
Share on other sites

I'm not sure that you can unpack the .asset files with Unity.

You can try Unity Assets Explorer, but I've had difficulty using it with Unity 5, it never seems to be able to open the larger asset files.

If you want to access the texture in-game you can try grabbing the texture by name and doing whatever you want with it. Try printing out every texture's name if you don't know which one you want, they usually have names that make sense. You can draw the texture on-screen if you want to make sure.

This is what CapCom does to access the Mission Control texture atlas, just don't do this more than once per KSP session...

	Texture original = null;

	foreach (Texture2D t in Resources.FindObjectsOfTypeAll<Texture2D>())
	{
		if (t.name == "SpriteAtlasTexture-MissionControl (Group 0)-1024x1024-fmt5")
		{
			original = t;
			break;
		}
	}

If you want to edit that texture you'll need to make it writable:

	Texture2D missionControlTexture = new Texture2D(original.width, original.height);

	var rt = RenderTexture.GetTemporary(original.width, original.height, , RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB, 1);

	Graphics.Blit(original, rt);

	RenderTexture.active = rt;

	missionControlTexture.ReadPixels(new Rect(, , original.width, original.height), , );

	RenderTexture.active = null;
	RenderTexture.ReleaseTemporary(rt);

	rt = null;
	original = null;

	missionControlTexture.Apply();

 

Edited by DMagic
Link to comment
Share on other sites

Unfortunately, none of the Texture2Ds appear to be "the" asteroid texture (though rock00 almost looks like part of a PotatoRoid). The asteroid may use a mix of textures for different parts of the surface.

Also, to clarify, I'd prefer not to have to edit the asteroid every time it loads in physics range -- the stability of the modern Custom Asteroids is a welcome change from how it worked in the prerelease days. So my ideal solution would be to create a KSP asset bundle, then set moduleAsteroid.prefabBaseURL to point to the bundle instead of the stock assets. No on-the-fly hacks required, but I'd need to imitate the structure and format of the stock assets for it to work -- and all I know right now is that there's a folder for every size class.

Link to comment
Share on other sites

On 26.5.2016 at 9:26 AM, Starstrider42 said:

Unfortunately, none of the Texture2Ds appear to be "the" asteroid texture (though rock00 almost looks like part of a PotatoRoid). The asteroid may use a mix of textures for different parts of the surface.

Also, to clarify, I'd prefer not to have to edit the asteroid every time it loads in physics range -- the stability of the modern Custom Asteroids is a welcome change from how it worked in the prerelease days. So my ideal solution would be to create a KSP asset bundle, then set moduleAsteroid.prefabBaseURL to point to the bundle instead of the stock assets. No on-the-fly hacks required, but I'd need to imitate the structure and format of the stock assets for it to work -- and all I know right now is that there's a folder for every size class.

Asteroids are generated by PQSMods, and therefore their mesh and the texture are procedural. I tried to interface with this system, but it ended up being horrible in-game :D
My solution to the whole "customize your asteroid" stuff was, that I added a node to my asteroid config, that represents an overload for the finally generated Vessel. This allows the user to make his own part and load it into the asteroid (You can even build an asteroid in the VAB, from fuel tanks and command pods (#debrisfields) with that).

We (especially Sigma88 and GregroxMun) did some funny stuff with that in #Kopernicus.

Link to comment
Share on other sites

On 5/28/2016 at 10:14 AM, Thomas P. said:

Asteroids are generated by PQSMods, and therefore their mesh and the texture are procedural. I tried to interface with this system, but it ended up being horrible in-game :D

Could you elaborate? You've clearly had no problem with planetary PQSMods; what makes the asteroid ones different?

Link to comment
Share on other sites

27 minutes ago, Starstrider42 said:

Could you elaborate? You've clearly had no problem with planetary PQSMods; what makes the asteroid ones different?

The problem is that Asteroids store their values in the assets files, and you cannot access them, even with changing the used path (that will still look inside the game assets and not in your asset bundles iirc). You would have to intercept the mesh generation, replace the values, and redo the generation.
Also, the asteroids use min / max wrappers for the mods, and copying all the PQSLoaders to that and check if the mod supports Asteroids (only numeric types) was a bit too much for me.

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