Jump to content

[Early development, 0.24] Kopernicus Planetary System Modifier


Recommended Posts

screenshot17.png

We've decided, at least for the time being, to generate the PQS of the new planets after the system has been spawned by KSP. This was not an easy decision, as it goes against the grain of our technical aspirations with this mod, but after essentially two days of fruitless work on the problem, it's time to be pragmatic and move on. This is not to rule out a return to the question in the future, of course. (Also, note that this is not the same approach that PlanetFactory used.)

Basically, the technical problem seems to be that there is no way to copy (and alter) a prefab without Instantiating it, which seems to trigger diverse and complicated Bad Things. Even after a whole day of hacking on it, I was only able to kill one or the other of the following bugs: (1) it is impossible to launch anything, (2) it is impossible to see the new planet.

So, for the time being, we're moving our application of PQSmods to the new planets from prefab-modification-time (where we do everything else) to after the PSystem has been created from the (replaced) systemPrefab. This will allow us to redirect our development efforts toward getting this project usable rather than struggling with something that Unity has made very difficult (because there's no first-party-developer reason to do it).

Link to comment
Share on other sites

Do you plan on making it possible to create custom Gas Giants? With custom i mean variable size (not only 6000km) and various Atmosphere and so on. I've tried PF CE and that was the thing that annoyed me the most.

Besides: I like the look of the things your doing so far. Keep it on.

Link to comment
Share on other sites

Thanks.

Do you plan on making it possible to create custom Gas Giants?

Yes, it will need that capability, since the goal is to support modeling the real solar system, which has four gas giants, and stock KSP only has one.

Link to comment
Share on other sites

Thanks.

Yes, it will need that capability, since the goal is to support modeling the real solar system, which has four gas giants, and stock KSP only has one.

No worries, it will actually be very easy to implement custom gas giants - there isn't a PQS on it, all you actually have to do is create a new PSystemBody and attach a properly sized scaledVersion to it. And thats about it ... I wonder if it is possible for EVE and Better Atmospheres to add multiple cloud deck levels though - that would be sweet....

Link to comment
Share on other sites

Another milestone complete - custom planets now show up in the Science Archives.

This was achieved by finding a little gem in the AssetBase object - AssetBase.RnDTechTree.GetRDScreenPrefab (). Wrote a function to crawl this prefab in search of the behavior responsible for the tech tree view - RDArchivesController. It has a parameter called systemPrefab, which we overwrote with the custom planetary system we generated. Then it just works flawlessly....

Screenshot.2014.07_30_15.01.32.png

- Nathaniel R. Lewis

Edited by Teknoman117
Link to comment
Share on other sites

So, just wanted to say I love what you guys are doing here! Your dedication to building a real, lasting solution to expanding the Kerbal universe is awesome!

As much as I'd love to ask when I can get my hands on a test build, I know such inquiries are not appropriate. I will instead ask this: Will this have a solution for adding other stars? And/or will it be compatible with StarSystems?

Link to comment
Share on other sites

I just found this thread and I'm very excited about this mod!

Planet Factory CE was probably my favorite mod for KSP and I'm happy to know that a mod is being made to do everything it did and more!

I have a few questions. Hopefully they haven't been mentioned already (I couldn't see them in a quick read through of the thread).

1. Will we be able to modify the PQS & textures of stock planets? Also, rename the planets?

2. Can the order and nesting of the planetary objects in the archives window be modified?

3. Will it be possible to add new contracts that deal with the new planets? (ex. Land on planet Kopernicus)

Keep up the great work!

Edited by VonFrank
Link to comment
Share on other sites

Another milestone complete - custom planets now show up in the Science Archives.

This was achieved by finding a little gem in the AssetBase object - AssetBase.RnDTechTree.GetRDScreenPrefab (). Wrote a function to crawl this prefab in search of the behavior responsible for the tech tree view - RDArchivesController. It has a parameter called systemPrefab, which we overwrote with the custom planetary system we generated. Then it just works flawlessly....

https://dl.dropboxusercontent.com/u/8061287/Kopernicus/Screenshot.2014.07_30_15.01.32.png

- Nathaniel R. Lewis

This is the only thing that was holding me back from getting PlanetFactory! Can't wait until it's released!

Link to comment
Share on other sites

Hi VonFrank,

1. The functionality of modifying stock planets' appearance and other properties is planned. Renaming them may break other mods, though. In particular, renaming Kerbin has been problematic for other mods that have tried to do that.

2. Yes, but only if their order or hierarchical position in the solar system changes. The Science Archive makes its planet menu from the planetary system. I suppose technically one could hack it so that it sees a different version from the rest of the game, theoretically.

3. I haven't looked into contracts yet, but I don't see why not at this point. It's certainly a goal, but I don't know how close we are to achieving it.

Link to comment
Share on other sites

Hi VonFrank,

1. The functionality of modifying stock planets' appearance and other properties is planned. Renaming them may break other mods, though. In particular, renaming Kerbin has been problematic for other mods that have tried to do that.

2. Yes, but only if their order or hierarchical position in the solar system changes. The Science Archive makes its planet menu from the planetary system. I suppose technically one could hack it so that it sees a different version from the rest of the game, theoretically.

3. I haven't looked into contracts yet, but I don't see why not at this point. It's certainly a goal, but I don't know how close we are to achieving it.

Thanks for the reply.

Yeah, I've encountered issues with modifying the name of Kerbin. It tends to make vessels un-recoverable. At least the rest of the planets can be renamed with fewer issues.

Keeping planets in the correct hierarchical position is the reason I asked. The fact that the mod knows to properly arrange celestial objects is great to know!

I realize dealing with contracts is probably one of the last things to deal with, but its good to know that you might consider it eventually.

I wish I was able to help out with this mod in some useful way. My unity programming knowledge is limited but I do have plenty of experience with PF CE. I made a recreation of the Sol system with 52 planets/dwarf planets/moons back in 0.23.5, so when you get to that stage I'd be more than willing to offer whatever suggestions I can.

Regardless, I hope everything goes smoothly for you guys!

Link to comment
Share on other sites

rbray adds a PQS to Jool in EVE Overhaul. You can check the code in the Overhaul branch.

BryceSchroeder: got the mail! Thanks! I'll send you a PM with my email.

Not really... I add a "PQS Fake" that is a partial implementation of the PQS as I was never able to get the "real" pqs object to trigger once in proximity.

Once you have the PQS created, its just a matter of setting its texture and adding PQSMods, both are relatively easy and I think this plugin's first useable beta can be pushed very soon!

I think the shader that is mainly used is: Terrain/PQS/PQS Main - Optimised

with some interesting values; _lowTex, _steepTex, _highTex and some other configurable blending variables...

edit: My personal attempt at PQS to Jool is going OK, I just need to copy Kerbins texture, and that is causing some errors, once done. Ill put the code on github.

Whoa-Whoa-Whoa... How the heck did you get the shader params!? I tried for about a week scrubbing fourms and using my google-fu but couldn't get anywhere. I was desperate enough to try and brute-force it but gave up and begged for textures instead. This changes a lot for me. Thank you for this alone!

Link to comment
Share on other sites

A pretty important bit of technical update. Bryce mentioned before how we were going do modification of the live PQS tree because we couldn't get custom prefabs working due to various issues. In implementing the solution for the science archives, we stumbled across the answer to getting custom prefabs working. When we were modifying the system prefab for the archives controller, it would have gotten deleted by the time the archives would spawn. I thought it rather strange, and then remembered that we had never called DontDestroyOnLoad() on the prefabs. This is empirically set for prefab objects, but when cloning them with instantiate, they get added to the garbage collectors tracking. Doing this solved our problem with the science archives, but it also gave us insight into the PQS problem.

Turns out, if you instantiate the prefab of one of the planets (PSystemBody.pqsVersion) and immediately call DontDestroyOnLoad(), it solved the NullException problem, but was still throwing errors everywhere (Sphere target null). Since PQS modifies global state (why Squad, why?), if you called SetActive(false) on the prefab, it stops it from doing these bad things. The only caveat is that Instantiate() caries the state of the active flag over to the new object, so the PQS on the new planet is turned off. The present solution is to enable them manually in OnPSystemReady() once spawning is complete.

[TL;DR] - We now have planets spawned entirely from the system prefab without any live tree modification.

Link to comment
Share on other sites

A pretty important bit of technical update. Bryce mentioned before how we were going do modification of the live PQS tree because we couldn't get custom prefabs working due to various issues. In implementing the solution for the science archives, we stumbled across the answer to getting custom prefabs working. When we were modifying the system prefab for the archives controller, it would have gotten deleted by the time the archives would spawn. I thought it rather strange, and then remembered that we had never called DontDestroyOnLoad() on the prefabs. This is empirically set for prefab objects, but when cloning them with instantiate, they get added to the garbage collectors tracking. Doing this solved our problem with the science archives, but it also gave us insight into the PQS problem.

Turns out, if you instantiate the prefab of one of the planets (PSystemBody.pqsVersion) and immediately call DontDestroyOnLoad(), it solved the NullException problem, but was still throwing errors everywhere (Sphere target null). Since PQS modifies global state (why Squad, why?), if you called SetActive(false) on the prefab, it stops it from doing these bad things. The only caveat is that Instantiate() caries the state of the active flag over to the new object, so the PQS on the new planet is turned off. The present solution is to enable them manually in OnPSystemReady() once spawning is complete.

[TL;DR] - We now have planets spawned entirely from the system prefab without any live tree modification.

This is the whole reason for using your own PSystem instead of instantiating planets, global states.

I'm so proud of this project and I really wish Squad sees your work!!

I'll do my best to help you with any problem though I cannot always check the forums regularly but, as with the PQS problem, I see you are a couple smart guys ;)

Link to comment
Share on other sites

Hey Bryce & Tek, just wanted to give you guys a quick shout and say I'm totally down for doing any testing you need. I did some testing for Nathan on RSS a while back & with Nova for Alternis also. I tend to have a very good knack fore breaking things good. (Hence my desire to get away from Planet Factory dependence) I'd also love, once you guys are ready for release, to show it off an stream if you'd like. Adding planets (and combining them with the new mod that allows multiple star systems especially) really opens up the true potential for so many other mods (resource & base building stuff) that are great, but not really needed due to the limited size on the Kerbal system stock. I'd love to do anything I can to help push that limit & open up more of KSP's potential.

Let me know if you're interested and I'll drop you guys a PM.

Link to comment
Share on other sites

Will we have custom biomes? like we give the mod a biome map then we can tell what colors are the biomes..

Almost certainly yes, and probably in the first release. I'm looking into it in more detail at the moment (currently, the custom testing planet has a clone of Dres, which is not very interesting in that respect...)

Link to comment
Share on other sites

Omg. This is the most excited iwe been about a ksp plugin since the time planetfactory was first released (i guess i missed all the drama that led up to the release). Sadly it was inherently broken and later broken more and more each ksp update and abandoned by krag. I havent been able to use it since 0.23 came out.

Seems you guys have all the code stuff sorted out and taking no shortcuts:P

I guess my only humble request would be that perhaps the (/one of the) example planet shipped with the first version be a kindof hybrid duna/kerbin/ planet (1200km radius. Some oceans, 25km atmosphere(thin with no oxygen maybe some mountains with their peaks outside the atmosphere). 1.7g gravity. Call it splat etc., because that will be the sound your lander will make when it "lands") perhaps also a really big rocky "superplanet" the size of jool with somewhat thick atmosphere no oceans and some rediculously high gravity. Call it kool etc.:P could have several moons orbiting it maybe some less challenging to land on. Would be nice as a first exoplanet around another star

Thank you guys so much for making this.

Edited by landeTLS
Link to comment
Share on other sites

Ingenious! I never would have thought of DontDestroyOnLoad! I must say I am exited for the first config loader based iteration. I will probably rewrite the planets in my 'testplugin' with the config loader this plugin will provide.

How do you plan on generating the atmosphere mesh? The only way I can think of right now is to copy Jool's and scale it with respect to the planet.

Link to comment
Share on other sites

Ingenious! I never would have thought of DontDestroyOnLoad! I must say I am exited for the first config loader based iteration. I will probably rewrite the planets in my 'testplugin' with the config loader this plugin will provide.

How do you plan on generating the atmosphere mesh? The only way I can think of right now is to copy Jool's and scale it with respect to the planet.

Well, I've been using Unity for awhile, I just never come across a need for prefab modification at runtime, and I generally avoid global state whenever possible. We haven't worked on the atmospheres yet, but as for the scaled version, we just cloned jool. Upon examination of the assets in KSP, Jool just uses the reference scaled model (Geosphere1000m). We cloned this and wrote a wrapper that takes the PQSMod_VertexHeightMap to apply the surface details to the scaled version (so with the mars texture, Olympus Mons is sticking out in the map and the science archives). We'll probably just clone Jool for the atmosphere as well. Should be easy enough considering Jool is pretty much a reference implementation of everything but the PQS.

Omg. This is the most excited iwe been about a ksp plugin since the time planetfactory was first released (i guess i missed all the drama that led up to the release). Sadly it was inherently broken and later broken more and more each ksp update and abandoned by krag. I havent been able to use it since 0.23 came out.

Seems you guys have all the code stuff sorted out and taking no shortcuts:P

I guess my only humble request would be that perhaps the (/one of the) example planet shipped with the first version be a kindof hybrid duna/kerbin/ planet (1200km radius. Some oceans, 25km atmosphere(thin with no oxygen maybe some mountains with their peaks outside the atmosphere). 1.7g gravity. Call it splat etc., because that will be the sound your lander will make when it "lands") perhaps also a really big rocky "superplanet" the size of jool with somewhat thick atmosphere no oceans and some rediculously high gravity. Call it kool etc.:P could have several moons orbiting it maybe some less challenging to land on. Would be nice as a first exoplanet around another star

Thank you guys so much for making this.

It could very well be a configuration issue, but we are currently having issues with the detail on planets much bigger than Kerbin. We have tried setting up our custom world with the settings for Mars from Real Solar System (hence the Mars texture above), so a radius of 3389 km. The largest features of mars like the Valles Marineris and Olympus Mons look flat. It seems there may be a cap somewhere in KSP for the maximum level of allowed subdivision, even though we tried to set the maximum subdivision level to 32 (default is 12 - 14 for the high detail setting). Again, this could easily be a config option we've yet to find. If anyone has previously found a solution to this, i'm all ears.

Technical Update: Bryce has a custom biome and science map working for our test planet. Next steps are to write a configuration system for all the available PQS Mods (going to be modeled off EVE Overhaul edition's EVEManager) and the finish figuring out how to create an entirely custom PQS. We have isolated the issue to something in our initialization of the PQS object ourself. The current code instantiates the PQS prefab from Dres, deletes EVERY PQSMod, and adds our custom ones, which seems to be working great.

Edited by Teknoman117
Link to comment
Share on other sites

Thanks for the encouragement.

Those sound like cool planet ideas! We all have a variety of planet ideas, but of course, the focus with Kopernicus is letting other people (such as you) realize your planet ideas, be they simple or complex. Right now, Kopernicus is... sort of Mars with no atmosphere. Oh well. Some progress with biomes has been made:

screenshot117.png

(Pardon the odd values, still working out what all the science-related numbers do. But at least it shows up in the archive correctly now.)

Link to comment
Share on other sites

Technical Update: Brought a PQS up completely from scratch - No more Instantiate()

I do have to say, as a C++ developer whose only dabbled in .Net, this concept of type reflection is absolutely amazing. Essentially, for those who don't know, it amounts to being able to get information about the structure of an object at runtime. Instead of having to sift through all the data members and copy each one manually, I can do this fun operation



[FONT=Menlo][COLOR=#009695]foreach[/COLOR][COLOR=#444444] ([/COLOR][COLOR=#444444]FieldInfo [/COLOR][COLOR=#444444]field [/COLOR][COLOR=#009695]in [/COLOR][COLOR=#444444]Dres[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]pqsVersion[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]GetType[/COLOR][COLOR=#444444]().[/COLOR][COLOR=#444444]GetFields[/COLOR][COLOR=#444444]())
[/COLOR][COLOR=#444444]{
[/COLOR] // Only copy if the member isn't global
[COLOR=#009695] if[/COLOR][COLOR=#444444] (![/COLOR][COLOR=#444444]field[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]IsStatic[/COLOR][COLOR=#444444])[/COLOR]
[COLOR=#444444] {[/COLOR]
[COLOR=#3363a4] Debug[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]Log[/COLOR][COLOR=#444444] ([/COLOR][COLOR=#f57c00]"[/COLOR][COLOR=#f57c00]Copying: [/COLOR][COLOR=#f57c00]"[/COLOR][COLOR=#444444] + [/COLOR][COLOR=#444444]field[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]Name[/COLOR][COLOR=#444444] + [/COLOR][COLOR=#f57c00]"[/COLOR][COLOR=#f57c00] = [/COLOR][COLOR=#f57c00]"[/COLOR][COLOR=#444444] + [/COLOR][COLOR=#444444]field[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]GetValue[/COLOR][COLOR=#444444] ([/COLOR][COLOR=#444444]Dres[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]pqsVersion[/COLOR][COLOR=#444444]));[/COLOR]
[/FONT][COLOR=#444444][FONT=Menlo] field[/FONT][/COLOR][COLOR=#444444][FONT=Menlo].[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]SetValue[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]([/FONT][/COLOR][COLOR=#444444][FONT=Menlo]body[/FONT][/COLOR][COLOR=#444444][FONT=Menlo].[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]pqsVersion[/FONT][/COLOR][COLOR=#444444][FONT=Menlo], [/FONT][/COLOR][COLOR=#444444][FONT=Menlo]field[/FONT][/COLOR][COLOR=#444444][FONT=Menlo].[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]GetValue[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]([/FONT][/COLOR][COLOR=#444444][FONT=Menlo]Dres[/FONT][/COLOR][COLOR=#444444][FONT=Menlo].[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]pqsVersion[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]));[/FONT][/COLOR][FONT=Menlo]
[COLOR=#444444] }[/COLOR]
[COLOR=#444444]}

[/COLOR][/FONT]

Link to comment
Share on other sites

Technical Update: Brought a PQS up completely from scratch - No more Instantiate()

I do have to say, as a C++ developer whose only dabbled in .Net, this concept of type reflection is absolutely amazing. Essentially, for those who don't know, it amounts to being able to get information about the structure of an object at runtime. Instead of having to sift through all the data members and copy each one manually, I can do this fun operation



[FONT=Menlo][COLOR=#009695]foreach[/COLOR][COLOR=#444444] ([/COLOR][COLOR=#444444]FieldInfo [/COLOR][COLOR=#444444]field [/COLOR][COLOR=#009695]in [/COLOR][COLOR=#444444]Dres[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]pqsVersion[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]GetType[/COLOR][COLOR=#444444]().[/COLOR][COLOR=#444444]GetFields[/COLOR][COLOR=#444444]())
[/COLOR][COLOR=#444444]{
[/COLOR] // Only copy if the member isn't global
[COLOR=#009695] if[/COLOR][COLOR=#444444] (![/COLOR][COLOR=#444444]field[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]IsStatic[/COLOR][COLOR=#444444])[/COLOR]
[COLOR=#444444] {[/COLOR]
[COLOR=#3363a4] Debug[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]Log[/COLOR][COLOR=#444444] ([/COLOR][COLOR=#f57c00]"[/COLOR][COLOR=#f57c00]Copying: [/COLOR][COLOR=#f57c00]"[/COLOR][COLOR=#444444] + [/COLOR][COLOR=#444444]field[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]Name[/COLOR][COLOR=#444444] + [/COLOR][COLOR=#f57c00]"[/COLOR][COLOR=#f57c00] = [/COLOR][COLOR=#f57c00]"[/COLOR][COLOR=#444444] + [/COLOR][COLOR=#444444]field[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]GetValue[/COLOR][COLOR=#444444] ([/COLOR][COLOR=#444444]Dres[/COLOR][COLOR=#444444].[/COLOR][COLOR=#444444]pqsVersion[/COLOR][COLOR=#444444]));[/COLOR]
[/FONT][COLOR=#444444][FONT=Menlo] field[/FONT][/COLOR][COLOR=#444444][FONT=Menlo].[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]SetValue[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]([/FONT][/COLOR][COLOR=#444444][FONT=Menlo]body[/FONT][/COLOR][COLOR=#444444][FONT=Menlo].[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]pqsVersion[/FONT][/COLOR][COLOR=#444444][FONT=Menlo], [/FONT][/COLOR][COLOR=#444444][FONT=Menlo]field[/FONT][/COLOR][COLOR=#444444][FONT=Menlo].[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]GetValue[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]([/FONT][/COLOR][COLOR=#444444][FONT=Menlo]Dres[/FONT][/COLOR][COLOR=#444444][FONT=Menlo].[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]pqsVersion[/FONT][/COLOR][COLOR=#444444][FONT=Menlo]));[/FONT][/COLOR][FONT=Menlo]
[COLOR=#444444] }[/COLOR]
[COLOR=#444444]}

[/COLOR][/FONT]

Isn't it!? It is how I am doing the GUI for EVE now. All the persistent fields are read and the gui is generated dynamically for me.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...