Jump to content

Trying to find maximum elivation of a planet.


Recommended Posts

I think the title is pretty self explanatory. I'm trying to find the maximum terrain elevation on (airless) planets and moons, in-game. I know I could just check the object's name and compare against the altitudes off the wiki, but I was hoping to avoid hard-coding the information. Any insights? Thanks.

Link to comment
Share on other sites

The only way I can think of to get that value would be to load up the detailed mesh of the attached transform, iterate through all vertices and find the one with the largest magnitude, then apply whatever scale applies to the mesh (if you're lucky, the transform scale will do).

Suffice to say, this would be very much overkill.

Link to comment
Share on other sites

As it's not something that should change outside of KSP updates, you should be able to do it once for every planet and perhaps graphics level, terrain detail is known to move the coast by a kilometer in some places, then store the results for use.

Link to comment
Share on other sites

A middle ground between hardcoding and detection is to use a config file. That way, users can at least update config files without rebuilding the whole DLL.

You can use PQS to find the terrain height at a given point. There are also some max altitude properties, but I'm not sure they're trustworthy. Experimentation is the name of the game.

Link to comment
Share on other sites

Side thought, given the hopefully quickly oncoming future of custom planets, you may want to do a first-boot scan, and save the determined values to a cfg file, it'll be slow once, but it promotes compatibility.

Link to comment
Share on other sites

If the values are not present in the file (eg a new planet, fresh install etc) perhaps then you should do the expensive "scan" and save that into the file.

I'd also recommend seeing if you can figure out of the planet has changed on you - perhaps there's a way to hash the planet's object or something and store that with the elevation figure? Then, when you load, you:

1. See if there are values. If yes, continue, if no, branch off to the code to figure the values out and store them.

2. See if the 'hash' matches. If yes, continue, if no, drop the values and loop back to #1.

3. Use the values for great success.

(maybe you can serialize the planet's definition, then hash that. or something along those lines.)

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