FORUM_TEST_2-19-14 Posted March 1, 2014 Share Posted March 1, 2014 (edited) ███ Update  4/13/14  There is now a plugin that does this! ███Landing Height: Show distance from bottom of your vessel to ground by DiazoNote: The release of my own Mod/Addon/Plugin is still pending & will be linked here & in my sig when ready.███ Original Plugin Request Below ███I need a mod that will alter the built-in altimeter & change it to display "real altitude"...as in the "when am I gonna land/crash" altitude  or "if I go straight down, what's gonna stop me 1st" altitude. I want something that will display 0 when the BOTTOM (not CoM) of my ship touches ANYTHING (be that water, land or a building).These mods are NOT what I'm looking for...Radar altimeter? Other then mechjebBucky's InstrumentsSteamGauges - Analog Radar Altimeter and More!MechJebKerbal Engineer Redux...OK, now that I've listed every mod in existence. I need a new mod...or pointers on how in the world I could write it.The mod should follow these rules...If I'm actually over water: do nothing. The built-in Altimeter shows the "altitude above sea level", so if I'm really over water, the number displayed is correct!If I'm over land, show the "distance to land". I don't care about "sea level" when I'm not over the friggen sea. Call this "Radar Altitude" if you want, but I don't want any limits on it, for example the IVA altimeter only works below a certain height...I don't want that. Also, if I'm over sea I do not want the "altitude to the bottom of the sea" (which some mods display as "true altitude").If I'm over a building or "crash-into-able object", then I want the "altitude to that object". Scenery rocks CAN be ignored, since you pass thru them & don't crash...but I'm fine with knowing the distance to them too...of course, as soon as the bottom of my ship passes thru the Rock, it needs to recalibrate & tell me the real distance to land....I hope I made it clear why the existing solutions are not acceptable.Things the mod should do...Alter the EXISTING altimeter to show the "correct" altitude (based on the rules above), using the "scrolling numbers font" like it already does.Provide DIGITAL (not Analog) numbers in a nice font (the font should be the same size as the built-in altimeter's numbers, not a small font Gui on top of the existing altimeter) to REPLACE the built-in scrolling numbers.Be clickable to toggle the displayed altitude between "correct", "sea level", "land", etc...clicking should rotate thru all the modes that it can display, it should be obvious which mode you just changed to. Perhaps clicking & holding for 1 or 2 seconds should return to "correct" mode, regardless of what mode it was in before (even if it was already in "correct" mode).As a bonus, I'd also like the mod to...Show the "trajectory altitude". For example, if you are going sideways on the Mun, really low & a mountain is coming up, you don't need to know the "straight down" altitude, you need the "direction I'm traveling into the side of that mountain" altitude. This mode would always show the distance/altitude in the direction your velocity is going, sideways, up, down, etc.So, now, how do we get this created? I'm willing to TRY to write this myself, but I don't think there are ANY Docs on how to do it. 1st of all, "how do I get a "handle" to the built-in altimeter? For example, the "Sliding Nav Ball" mod has this code in it...GameObject ce = GameObject.Find("collapseExpandButton");...where in the bloody heck did he find out that the navball's collapse/expand button, was actually called "collapseExpandButton"??? Is that mentioned anywhere? Should I just assume the built-in altimeter is called "altimeter"? But then, once I find the "handle" or "name", what do I do with it? In this case, the handle is in the ce var...OK, but what attributes/methods are available off that var? In his code he does "ce.GetComponent<ScreenSafeUIButton>();"...how am I supposed to know to do something like that? Are there ANY Docs on this API/stuff? & before you link, NO the stuff on the Wiki talking about "API" does NOT have enough info...sure there's SOME info, if you wanna do any of the stuff it does mention, but what about when you wanna do something that's NOT mentioned in the Wiki's API listing?My current plan is to get a handle to the built-in altimeter, then force it to display my "corrected" value...but I need to know...How can I force the built-in altimeter to display some other number?How can I get the "correct" number in the 1st place?It would probably be much easier to just write the "correct" altitude code, then display is on my own Gui, but again, that's not what I'm looking to do. I wanna display it on the built-in altimeter.So any mod authors wanna take this on? I'm sure this would be a POPULAR mod, since, in almost every video on YouTube the person doing the video mentions "well, that altitude is above sea level, so I might crash sooner". People are always "landing" at 3785 km...so absurd. Why on KERBIN does anyone CARE about sea level when they are trying to land/about to crash??? They don't! Everyone wants an altimeter that would work like I've described. Edited April 13, 2014 by FORUM_TEST_2-19-14 Diazo released Landing Height which satisfies this request Link to comment Share on other sites More sharing options...
vetrox Posted March 1, 2014 Share Posted March 1, 2014 Rasterpropmoniter has alot of what your looking for (i believe) but its an IVA mod Link to comment Share on other sites More sharing options...
NeoMorph Posted March 1, 2014 Share Posted March 1, 2014 (edited) The IVA has a radar altimeter which shows how high you are... but yeah, seems silly when looking from outside.What you CAN do though is use Steam Gauges I think. http://forum.kerbalspaceprogram.com/threads/40730-0-23-SteamGauges-V1-4-2-Analog-Radar-Altimeter-and-More!Bah.. not awake (and the blue writing messed me up lol).There is one thing you could do... get an arduino, a 20x4 LCD display and use Telemachus to extract the data you want to display. It's pretty easy to do (and I will be doing a tutorial on it soon when I get some free time together). Edited March 1, 2014 by NeoMorph Link to comment Share on other sites More sharing options...
FORUM_TEST_2-19-14 Posted March 1, 2014 Author Share Posted March 1, 2014 ...but its an IVA mod ...nope. Doesn't fit the requirements. Non-IVA only. Must alter the built-in altimeter...& that's only in non-IVA.What you CAN do though is use Steam Gauges I think....that was in my list of "NOT what I'm looking for"...Steam Gauges adds an ANALOG altimeter. I want a digital one/one that alters the built-in altimeter. Link to comment Share on other sites More sharing options...
NeoMorph Posted March 1, 2014 Share Posted March 1, 2014 One that alters the main altimeter sounds great... ie when you drop below 3000m and get a radar return it should change from altimeter-true (which is the height above sea level) to altimeter-absolute (which is the height above ground). There is another altitude that pilots use which is pressure altitude but as that can change from when the spacecraft has left the planet it's pretty useless.To be honest there are a few basic booboos with the navigation system. I pointed out that the nav ball is basically a land based navigation ball as space rated ones don't use Pitch, Roll, Heading but instead use Pitch, Roll, Yaw. Rich (the guy who wrote Telemachus) has been great to extract the Yaw data so that my nav ball project can behave like an Apollo/Shuttle nav ball (which means the ball doesn't flip when you pitch over). I think they did Squad used heading as most people understand land based stuff easier as using a notional frame of reference for space craft can be very confusing (and yeah, I get easily confused at times lol). Link to comment Share on other sites More sharing options...
FORUM_TEST_2-19-14 Posted March 1, 2014 Author Share Posted March 1, 2014 ...when you drop below 3000m and get a radar return......it's OK if the mod CAN do that, but I mainly want a mode that will "stay in correct mode" regardless of "radar range" or "height above ground". Yes, real Radar Altimeters have limits, but this is a game & I don't want limits. Basically, I just want my "correct" alt, from orbit, all the way down, without it switching on the way down. It should only switch, if what's below me changes.I should probably look at Telemachus, not as "the mod to do this", but as "how in the world does he get the data I need". Hopefully, in all the "altitudes" that Telemachus might display, at least one of them will be my "correct" value at any particular time...then my mod can simply change which way it's getting the altitude, depending on what's below...but the real key here: I want the altitude from the BOTTOM of my ship, which the normal Game API might not tell you. I don't care when the CENTER (CoM) of my ship will hit the ground, I care when the bottom hits -- or not even "bottom", but the "lowest part of the ship"...if I happen to be landing upside down or sideways, then I wanna know when the top or side will hit, whichever side is closer to the thing I'm gonna hit. Link to comment Share on other sites More sharing options...
Unteknikal Posted March 1, 2014 Share Posted March 1, 2014 You should take a look at this; http://kerbalspaceprogram.com/ceko-labs-rangefinder/, but either mechjeb, engineer, and Void gives you perfect readings of true altitude in their respective surface info panels. Link to comment Share on other sites More sharing options...
Justin Kerbice Posted March 1, 2014 Share Posted March 1, 2014 It's a good idea but:- it may need a lot more calculation for a little enhancement, so does it really worth it ? Of course it's worth to give it a shot, but you'll to test it in many conditions and with many mods to be sure the overhead is not too big,- it may be quite hard, as you have to manage to get the lowest point of collider, roll/yaw/pitch could make you crazy,- the "trajectory altitude" should not be a bonus as when I fly over Kerbin (or anywhere else) landscape, and I want to go to x m steady, I don't really want to see the altimeter constantly changing over mountains, it'll be confusing Even it's absurd to land at 3785 m, and unless you use a (windowless) cockpit view, it doesn't bother me that much IMHO. Link to comment Share on other sites More sharing options...
FORUM_TEST_2-19-14 Posted March 1, 2014 Author Share Posted March 1, 2014 You should take a look at this...thx! That mod, Ceko Labs Rangefinder (forum), had not come up in all my searches. I can't say it's the answer yet, but I'm definitely gonna look at it! Note: I would prefer a mod that doesn't require a part...but in any case, perhaps the source code (if it's available???) will help me too!This image (in the post linked above), kinda sums up what I want, at least the "digital display" part of it. I now need to find Ceko & get that source code! (it could be in the download on Spaceport, I haven't checked yet)but either mechjeb, engineer, and Void gives you perfect readings of true altitude...as I mentioned, their idea of true altitude sometimes means "the bottom of the sea". I know that this reading is probably a limitation of the Game, so I don't fault the mods...but in any case, "bottom of the sea" alt is not what I want...even if it is correct over land....in their respective surface info panels....yes, I never said there aren't mods to give you this info, but I want one that "fixes" the normal altimeter, instead of providing the info in a small font window. Those mods are great, but they don't serve the purpose I'm describing here.- the "trajectory altitude" should not be a bonus as when I fly over Kerbin......the "trajectory altitude" mode is not for when you are "over" the mountain, it's when you'll hit it cuz you are too low to go over it. The normal altitude is in the "straight down" direction (which, in this example, is not the direction you are going, so it doesn't apply in the "trajectory altitude" mode). The "trajectory altitude" mode comes into play when you are going sideways or "not down" (it would ALSO work in the down direction, but ignore that for now, since the normal mode also covers the down direction). If moving sideways means you'll pass OVER the mountain, then the "trajectory altitude" reading would be infinite, since you AREN'T gonna hit anything, in that direction. The "correct" altitude mode is what would be "constantly changing over mountains", since the mountain DOES get closer & farther away as you pass over it....I don't really want to see the altimeter constantly changing over mountains, it'll be confusing ...which is why you click the altimeter to change to the mode you want (other modes would exist so you can get a constant reading over mountains, if you want)...or simply don't install the mod, if you like the default behavior.Even it's absurd to land at 3785 m......it's TOTALLY absurd that everyone is "landing" when it don't say 0. With the current altimeter, you NEVER know when you'll "really land", unless you over water...making the current altimeter almost useless. Link to comment Share on other sites More sharing options...
Unteknikal Posted March 1, 2014 Share Posted March 1, 2014 The only problem of ceko rangefinder is that it only works at 2000 mts over that altitude it does not work.I'm using the 3 mechjeb, Void, and engineer and they work really nice my landings are perfect I never crash and the information is at least for me absurdly accurate, however for taste colors . Link to comment Share on other sites More sharing options...
Starwaster Posted April 8, 2014 Share Posted April 8, 2014 I'm not willing to code everything on your list for you but here is enough to get you or someone else started coding:It will change the existing altimeter GUI (external view) to display distance to terrain or distance to sea level, whichever is higher when below 8000 meters. No configuration file parsing is coded so this requires alteration in the source and recompiling.Will display text notifying that radar altimeter is active when below 8000 meters.Requires no parts.Link to compiled DLL and source: https://www.dropbox.com/s/ncrncunxs25u5pe/RadarAltimeter.zipLicense: This is released into the public domain// Radar Altimeter modifies the altimeter to display altitude above terrain instead of sea level.// This KSP plugin code is released into the Public Domain by its author, Starwaster// Code from Real Chutes, MechJeb and Ferrams Aerospace Research was researched as examples// of gathering world information and altimeter UI modification.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using UnityEngine;namespace RadarAltimeter{ [KSPAddon(KSPAddon.Startup.Flight,false)] public class RadarAltimeterUI : MonoBehaviour { public void awake() { } public void start() { } public void LateUpdate() { updateAltimeter(); } //public void FixedUpdate() //{ // updateAltimeter(); //} private void updateAltimeter() { CelestialBody body = FlightGlobals.getMainBody(); if (body.ocean) { double ASL = FlightGlobals.getAltitudeAtPos(FlightGlobals.ActiveVessel.GetWorldPos3D(), body); if (ASL < 8000) { double realAltitude = ASL - FlightGlobals.ActiveVessel.PQSAltitude(); if (realAltitude < 0.0) realAltitude = 0.0; FlightUIController UI = FlightUIController.fetch; UI.alt.setValue(realAltitude); ScreenMessages.PostScreenMessage("Radar Altimeter Active", Time.fixedDeltaTime, ScreenMessageStyle.UPPER_CENTER); } } } }} Link to comment Share on other sites More sharing options...
CaptainKipard Posted April 8, 2014 Share Posted April 8, 2014 Wow cool. Now all that's needed is a part that allows you to change the offset. Link to comment Share on other sites More sharing options...
Diazo Posted April 8, 2014 Share Posted April 8, 2014 I want something that will display 0 when the BOTTOM (not CoM) of my ship touches ANYTHING (be that water, land or a building).Note that nothing I've seen in the thread address this and it is a limitation of what Squad has given us.Any call for information a plugin can make that I am aware of is always the center of mass, not the bottom of the ship.To get this is actually rather complicated, I took a look at it for my Velocity Control mod when I added in Height Control and gave up because it turned into a horrendously complex mess.However, at the time I was trying to work with distances calculated off the model wireframe size to do so. Since then I've become more comfortable with raycasts and if I looked at it again I would try something like a raycast from pqsDirectlyBelowVessel to each partCentorOfMass on the vessel and take the shortest distance.D. Link to comment Share on other sites More sharing options...
xEvilReeperx Posted April 8, 2014 Share Posted April 8, 2014 1st of all, "how do I get a "handle" to the built-in altimeter? For example, the "Sliding Nav Ball" mod has this code in it...GameObject ce = GameObject.Find("collapseExpandButton");...where in the bloody heck did he find out that the navball's collapse/expand button, was actually called "collapseExpandButton"??? Is that mentioned anywhere? I'm the SlidingNavBall author. The magic secret is: I wrote a function that dumped the names of all GameObjects, listed the ones that looked like they could be right and then tried hiding them one at a time until I struck gold Should I just assume the built-in altimeter is called "altimeter"? But then, once I find the "handle" or "name", what do I do with it? In this case, the handle is in the ce var...OK, but what attributes/methods are available off that var? In his code he does "ce.GetComponent<ScreenSafeUIButton>();"...how am I supposed to know to do something like that? Are there ANY Docs on this API/stuff?There's no magic in that either. Similar process. Oh, this button has component X? That sounds interesting. <Look up component with an object browser> Hmm maybe I could do <insert thing> with this. You just have to try things out Link to comment Share on other sites More sharing options...
hawk_za Posted April 8, 2014 Share Posted April 8, 2014 awesome idea too many moon landings have been brought to ruin as a result to a lack of this feature. Link to comment Share on other sites More sharing options...
Diazo Posted April 9, 2014 Share Posted April 9, 2014 (edited) Wow, this is clunky to say the least.I just tried to build this out using raycasts, it does not work with those.The math itself works, the problem is that the planet colliders shift when the different texture levels are hit.So on Kerbin, the first texture reduction is at 10,000 meters. Once I cross this my raycast to kerbin now hits the "zoomed out" texture at 10,000 meters.So raycasts are no good. I've got an idea on how to do it with vectors and a part's location relative to the craft's CoM, but I've never used Vector3's before so I'll have to read up on them first.D. Edited April 9, 2014 by Diazo Link to comment Share on other sites More sharing options...
FORUM_TEST_2-19-14 Posted April 9, 2014 Author Share Posted April 9, 2014 FlightUIController UI = FlightUIController.fetch; UI.alt.setValue(realAltitude);...those 2 lines, 2 freaking lines!!! I will start searching right now, but where did you find "FlightUIController"?...don't tell me, you used an "object browser"...if I knew about "UI.alt.setValue"...I would've been much farther sooner.Wow cool. Now all that's needed is a part that allows you to change the offset....in my current working code (written before Starwaster's reply)...I do have a way to set the offset...pretty manual tho.As, Diazo said we still need CoM-to-Bottom-of-ship correction code...but with a manual offset, this is very close to being awesome! Link to comment Share on other sites More sharing options...
Diazo Posted April 9, 2014 Share Posted April 9, 2014 Now that I'm not up well past my bedtime, my brain is working again and I've already got ideas for workarounds on the problems I ran into.It will have to wait until I get home from work this evening, but I should have something releasable tonight.D. Link to comment Share on other sites More sharing options...
FORUM_TEST_2-19-14 Posted April 9, 2014 Author Share Posted April 9, 2014 Once I cross this my raycast to kerbin......I've been thinking of trying to raycast from CoM to "edge of ship"...can I collide (a raycast) with my own ship? Link to comment Share on other sites More sharing options...
Monkeh Posted April 9, 2014 Share Posted April 9, 2014 Engineer redux has the readout you want. Not sure why it's on the list in OP. It's in the SUR tab. Actual height and even time until impact. Link to comment Share on other sites More sharing options...
Diazo Posted April 9, 2014 Share Posted April 9, 2014 (edited) It's on the list because KER uses the CoM of the ship for altitude above terrain as far as I know, not the actual bottom of the vessel.I believe it is listed in the OP because of that.I will admit to not checking KER myself, but that is how I understand it to work.D.edit: Not on my KSP computer, but a quick check of KER's source shows it does display the Vessel's CoM, not the actual bottom of the vessel for terrain altitude. Edited April 9, 2014 by Diazo Link to comment Share on other sites More sharing options...
pizzaoverhead Posted April 9, 2014 Share Posted April 9, 2014 As, Diazo said we still need CoM-to-Bottom-of-ship correction code...but with a manual offset, this is very close to being awesome!You can find the lowest part by looping through each part on the vessel and checking its position. To find how low the lowest area of that part is, grab the collider and check the vertices. There's an example of this here. Link to comment Share on other sites More sharing options...
FORUM_TEST_2-19-14 Posted April 9, 2014 Author Share Posted April 9, 2014 I'm the SlidingNavBall author....thank you for replying!The magic secret is: I wrote a function that dumped the names of all GameObjects......since posting this topic & after writing some code, I too found a function to do that. Well, not "all GameObjects"...but a function to dump the passed object...Logging an entire GameObject - AngryAnt<Look up component with an object browser>...this is where I went wrong...I'm not using any IDE, just Notepad2 & csc.exe (command line C# compiler, included with every .NET install)...so I don't have any "object browser" to use. It's like writing code blindfolded...I can't see what's inside any object or what any object does...well, now I can, cuz of the LogGameObject() function, but before I couldn't.Engineer redux has the readout you want....I will check, but if it's altitude-to-CoM of ship, that problem is already solved. I already found a way to get an accurate altitude to the ship's CoM (which is not 100% what I want, but it's what I can get right now).Starwaster just showed me how to force a new value into the built-in altimeter, which is great! So the only problem left, in my mind, is getting a CoM-to-side-of-ship distance (in the Vector3.down direction, specifically), so I can offset my CoM altitude. I can already offset my calculations, but I don't know how much to offset them by.Not sure why it's on the list in OP....keep in mind those mods are not on the list cuz they are "bad mods"...they are great mods & do their job well...the only problem is this topic is for a specific mod to only do Real Altitude. It's not just finding a way to display the info, it's displaying the info on the built-in Altimeter or displaying the info in a large font Gui on top of the built-in Altimeter. My current code does the "large font Gui" method...with Starwaster new code, I can amend my code to fix the built-in Altimeter. I plan on having a user setting for doing 1, the other, or both!Even before these most-recent replies, I already had some pretty good code. Now, with these new developments, it will be even more awesome!...& I can't wait to see what Diazo's cooking up! If he can solve the CoM problem, that'd be great!I wanna take this time to mention another great resource I found since posting this topic...KSP Plugin Framework - Plugin Examples & Structure...I haven't used it quite yet...but it looks awesome...I need to rewrite my addon to use that Framework. I really wish I had found that before I started writing...would've saved me some time.You can find the lowest part by......thanks will look into it now!...every piece of info helps! Link to comment Share on other sites More sharing options...
Starwaster Posted April 9, 2014 Share Posted April 9, 2014 ...this is where I went wrong...I'm not using any IDE, just Notepad2 & csc.exe (command line C# compiler, included with every .NET install)...so I don't have any "object browser" to use. It's like writing code blindfolded...I can't see what's inside any object or what any object does...well, now I can, cuz of the LogGameObject() function, but before I couldn't....I will check, but if it's altitude-to-CoM of ship, that problem is already solved. I already found a way to get an accurate altitude to the ship's CoM (which is not 100% what I want, but it's what I can get right now).Starwaster just showed me how to force a new value into the built-in altimeter, which is great! So the only problem left, in my mind, is getting a CoM-to-side-of-ship distance (in the Vector3.down direction, specifically), so I can offset my CoM altitude. I can already offset my calculations, but I don't know how much to offset them by.Ugh, you really ought to install VisualStudios. Maybe MonoDevelop but I have no experience with that one and don't know if it has the same browsing options.But with Visual Studios, let's say you want to get all of the PartModules that have been written for stock KSP. Most of them have the word module in them so just type module and the autocomplete feature will display a list for you. Then let's say you want to look at the docking port module, which is ModuleDockingNode so you put that in. Right click it and click definition and it will show you all variables and methods defined on it. You can even tell from looking at that which variables can actually be accessed from a part's config file. You can learn a lot that way. Link to comment Share on other sites More sharing options...
Diazo Posted April 10, 2014 Share Posted April 10, 2014 (edited) Okay, I've got the raycast thing working.On both pictures, note the ground cutting off the thrust plume.Note that I think the altimeter cuts off the decimal places and does not round them, so 0.9m shows as 0m, not 1m.The mod also triggers off Surface or Orbit mode as shown just above the navball.If in Orbit, the mod does nothing.If in Surface, the mod engages. However, Raycasts are only reliable within physics range (2500m), so if the Vessel CoM is more the 2400m above terrain, the altitude meter at the top of the screen simply shows the Vessel's CoM altitude.If less then 2400m to terrain, RayCast mode engages. For each part on the vessel with physical significance, the closest point on the collider mesh to ground casts a ray to ground and the part with the shortest distance to ground gets displayed as the vessel altitude. See my second picture with the titled ship, the altitude being displayed is the bottom of the engine almost touching the ground.You can toggle as normal between Orbit and Surface modes by clicking the speed box just above the navball. In Orbit, altitude displayed is from sea level, in Surface, height from terrain.The entire source code is as follows:Code on github here.Released under the GPL3 license.A complied .dll ready to drop into the GameData folder can be downloaded here. The .dll can just be dropped in GameData itself or a subfolder, the exact path does not matter.This is actually almost release ready, the only thing I'd want to add is a part count check so that on a vessel with hundreds of parts, only the 30 parts closest to the ground actually do raycasts. D. Edited April 10, 2014 by Diazo Link to comment Share on other sites More sharing options...
Recommended Posts