Jump to content

Lilleman

Members
  • Posts

    242
  • Joined

  • Last visited

Everything posted by Lilleman

  1. Hi everyone! While I was looking for something totally different, I came across this website. It's a plugin allowing the creation of virtual textures in Unity, using the Carmack's MegaTexture idea. According to the author, it can be used to create textures up to 64 Terapixels and stream them at runtime. I'm wondering if a plugin like this can be used with KSP, to load better textures for planets, and eventualy load textures dynamically, to reduce RAM consumption. This plugin is not free, but it comes with a trial version (didn't try it yet). I need confirmation (or at least some hints) from someone who knows Unity (and KSP's code) better than I do: According to the website, all you have to do is to create your texture, load it from an asset, and apply a script to the scene's camera. If it's even possible to apply this, can it be done at runtime?
  2. I wasn't aware of those. DSSP's work is impressive, and his custom animator could be very useful. I didn't had much time last week to make progress on this, but I'll get back to it ASAP. I've found how to create a Unity Ragdoll from models, and rigidbodies, but I didn't tried those in-game yet. I'm tired of horribly deformed Kerbals, I need to be more methodic with my code. Having a GUI like DSSP's one to load models and assign animations could be a good start, I'll look into this.
  3. Well, now I've managed to load animated objects, I can't figure the best way to switch the model at runtime: -instantiate the model, make the Kerbal's model invisible, then change the position and the status of the imported model every update (probably the dirtiest but easiest solution) -create a new part from the imported model, then add the "kerbalEVA" module to it (didnt' tried that yet). -keep as much informations as possible from the original kerbalEVA, then mess with SkinnedMeshRenderers and animation... And probably other tricks I didn't think of. A challenge indeed, and I don't think I could come up with the best solution. But eventually I can make a quick tutorial on how to convert an animated mdl file to mu and load it, if it can help someone to make some tests. Could it help?
  4. Thanks. I think I better not spawn too much EVAs, it might be a problem... I'm trying to get at least models from the ground crew, but I don't think they'll handle physics if I just instantiate some(edit: plus, I don't know how to instantiate them outside the VAB/SPH scenes). Ground crew could be fun, but it will be funnier if you can mess with him. I finally found how to import animations. I think I will go this way: -The ground crew will be made from custom objects, so it will not mess with any of my savegame informations and be destroyed every time a scene change. I'll have to find a way to make those objects as light as possible. -the selectable kerbonauts will be spawned from an invisible vessel near a door of the Crew Facility. If the CrewRoster is empty, no Kerbal is spawned. I'll have to add a custom behaviour to those EVAs. You should take a look at EVAFollowers sources for the animations.
  5. The plan for my plugin is to spawn some NPCs around the KSC; tourists, crew, technicians, scientists, and eventually make this compatible with KerbTown. Since I already know how to change the skin of a Kerbal in EVA, and control it, I thought the easiest way to do so was to spawn some around... As for the AI, it will be more like a Finite State Machine, I don't plan it to be too complex: Tourists will watch your ship take off (the distance will vary depending on their courage), and technicians will recover debris in their range. Scientists may eventually provide sciences points from watching the launch (not sure about this one: gaining science is easy enough) and crew will be Kerbals from the CrewRoster, ready to get aboard a ship. For the number of spawned Kerbs, it will depend on the framerate (Kerbals are Polygons-heavy). Ideally, there will be between 50 and 100 Kerbals around the center. Changing the models for a low-poly one could have been nice in this case... So, yeah, this will be a useless plugin, only meant to get some life around the KSC (in fact "Get Some Life" should be the name). For your animation problem, i don't really get it, I thought you had it working when setting the animation manually? Something like this: _eva.animation.CrossFade("wkC_forward"); //_eva is a KerbalEVA should do the trick, the problem being you'll have to check every update if the animation changed. To get back to the original subject: no progress made. I tried several way to convert mdl files, but I can't get the Animation module to load in Unity, so my newly imported meshes won't move a bit...
  6. Long story short: I tried creating vessels from thin air, create some from Protovessels, loading some from confignodes... The only working thing was to clone a kerbal already in EVA. I didn't tought of spawning kerbals from a vessel... I guess I could make a Spawn Point using an invisible pod, with no collider, then spawn Kerbals from there... For your magboots, if you can't change the status to landed, maybe there's a way to consider the ship as the reference body? I don't know if it's possible to create a celestialBody from a vessel...
  7. I didn't tried to set the animation without scripts yet. But maybe you can try to force the EVA's vessel to consider itself landed: vessel.situation = Vessel.Situations.LANDED; By the way, since we're off-topic, how did you managed to spawn vessels with your plugin? Kerbals in EVA are single-part vessels, so I could use something like this. For now everytime I spawn Kerbals, it summon the Kraken.
  8. Sorry, double post again, but with some news., I finally found a way to import SkinnedMeshRenderers and Bones. The process was actually the same as before, with the internal meshes, but I needed some correct models to load. I found a trick, since I still don't know how to model : convert a Half-Life mdl file to fbx, then convert this fbx to MU using PartTools. There is a known problem with Unity and the way it load materials from fbx, so they have to be reset manually, like in TextureReplacer, or fixed during the conversion. The problem I have now is the animation, not working. I also have to learn how to convert an animated part properly. Some screenshots. Edit: a small snippet of code: GameObject goModel = GameDatabase.Instance.GetModel("GSL/TestHumanoid");//My file is named "TestHumanoid.mu" goModel.transform.position = MMKerb.transform.position + new Vector3(-0.5f, 1, 0);//Spawn the model close to the Main menu Kerbal goModel.transform.rotation = MMKerb.transform.rotation; goModel.SetActive(true); Once the model is loaded, it contains a SkinnedMeshRenderer, some bones, and an Animation module if possible.
  9. I don't really want to start a thread in the plugin section yet, since I have no working code to share: I still didn't managed to create a skinnedMeshRenderer, or to import one. But I really want to make my plugin, even if it will be completely useless. So I guess I will create a thread in the plugin development section just to ask for help... Lately I was only trying to spawn new Kerbals. So my actual plugin can clone some, then it summons the Kraken as soon as the scene change a bit. Not exactly the plugin I want to release... Saddest part being that those two points (spawning Kerbals and changing their meshes) will be a very small part of my plugin, the biggest parts will probably be the spawning logic, the pathfinding and the AI. Still, maybe with the help of someone who knows how to import a skinned mesh, the most interesting part can be done. I need to make some new snippets of code, some screenshots, and I will make this thread.
  10. I'm messing with modding those days, and I saw something in the initialized game objects : Anyone knows what the "Tomb of the Lost Kerbal" is supposed to be?
  11. Have you tried to use the "tag" field of a part? Let's say you put a different tag on each command pod that must be part of a separate ship, they may be keeped even after a docking/undocking. I've solved my problem. To get a new Guid, I needed to call... Wait for it... Guid.newGuid();... Yep, that was that simple, I really overthought this one... Sorry for my previous posts, they were kind of useless...
  12. Speaking of ProtoParts and ProtoCrewMembers, can they be used to spawn Kerbals? For now, I'm looking for a Kerbal in EVA to clone at game start. It's working, but it's a very dirty way to do this. I saw in the API documentation that a Kerbal was a vessel with a single part, so I tried saving the protovessel of one of them in a confignode, to modify and load him later. But it doesn't work, I must be missing something. I don't need my clones to appear in the Tracking station or to be controllable, just spawn some around the KSC for now. What I tried: //Saving the confignode ConfigNode cfgn = new ConfigNode("NewKerb"); vessel.protoVessel.Save(cfgn);[I]//vessel is my original kerbal in EVA. This function return "Input is null" in the log[/I] cfgn.Save("GameData/GSL/Prot.txt"); ***a bunch of stuff here because I had to reset the Orbit parameters manually*** //Load the confignode ProtoVessel pv = new ProtoVessel(cfgn, FlightDriver.FlightStateCache); pv.position = vessel.transform.position + new Vector3(1,1,1);//spawn the little guy close enough pv.Load(FlightDriver.FlightStateCache.flightState); It seems like a lot of parameters are missing from my confignode file (I can post it here if it can help). Also, it's a bad idea to spawn a dozen Kerbals without a vessel, apparently Edit: My bad, I found the solution. I was kinda close actually: ConfigNode cfgn = new ConfigNode(); vessel.BackupVessel().Save(cfgn); cfgn.Save("GameData/GSL/Prot.txt"); ProtoVessel pv = new ProtoVessel(cfgn,HighLogic.CurrentGame); pv.position = vessel.transform.position + new Vector3(1,1,1); pv.Load(HighLogic.CurrentGame.flightState); I just needed to use BackupVessel instead of protoVessel, I don't really know if replacing the FlightDriver by the HighLogic made a difference... Anyway, now I'm dealing with an easier question: How are vessel IDs generated?
  13. @Malah, I think you can change the status of a ship in the tracking station with vessel.DiscoveryInfo.SetLevel(DiscoveryLevels.xxx); I don't think it will disable the "Recover" button in flight, though.
  14. For the inclination, you can take a look here, it's a script from Mission Toolkit. For the eccentricity however, I don't have any useful link, sorry.
  15. I don't like to "up" my posts, but this thread only had 10 views since I edited my last one. Also, I thought I'd found a way to load objects from assets. I was wrong: I can clone objects from the main scene and the main menu at almost anytime, but I can't access objects from VAB/SPH. They are loaded from a different asset, and are destroyed once the game is loaded. As I said earlier, I can make a clone of these objects once an editor is open, and use those clones later in-game. But didn't found anything to instantiate them otherwise. There are lots of props that could be useful here: pencils, drillers, hammer, wrench, etc... Also some Kerbals employees (that's the thing I really want to mess with).
  16. Thanks, I will make some tests with the astronaut, and I also found a Minion from Despicable Me, that could be fun. I also found this page, wich let me think it's possible to copy an armature and keyframes from an existing animation, or at least create new ones in-game for a static mesh. Well, that's enough things to test tonight (who need sleep anyway?). The sad part is, changing the EVA models is only one of the things I want my mod to do, and it's been days since I made actual progress on the remaining code... Coding is one hell of a drug... Edit: Okay, It's driving me crazy. I tried everything I thought of starting with a static mesh, with no success. Whatever I try, all I get is "SkinnedMeshRenderer requires a mesh with skinning or blendshape information." all over my log file. I have a lot of things to learn about animation (I'm starting from scratch), obviously. I will continue my mod and get back to it later. For info, I want to make a small mod to spawn NPCs around the KSC. I can already spawn a bunch of Kerbals and make them move, but it will be nice to actually change their models, and not only their textures. Next thing I have to try is to load an already animated model. That means I have to create one...
  17. Eventually, what I'm working on will become a mod, but it will take some time. I can still share some snippets, since I need help from people who actually know how animated meshes works in Unity. Here is a basic (and naive) example that modify the Kerbal from the main menu. The source code from Toolbar (and his easter egg) has been very useful, and the main difference is this time I actually changed some meshes in the scene. using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; //For this example, we will modify the Main Menu Kerbal, but this is possible in any other scene in the game. namespace KSPMMModifyDemo { //This will be loaded at the main menu [KSPAddon(KSPAddon.Startup.MainMenu,true)] public class MessWithMMKerb : MonoBehaviour { //The kerbal from the Main Menu GameObject MMKerb = null; //Will be called at start public void Awake() { MMKerb = getGOByName("kbEVA@idle"); MessWithKerb(MMKerb); } //return a GameObject from the scene by his name private GameObject getGOByName(string sName) { //A naive (but working) way is to go trough all our loaded GameObjects, and find the one we want foreach (GameObject go in Resources.FindObjectsOfTypeAll(typeof(GameObject))) { if (go.name == sName) { return go; } } return null; } //actually modify the skinnedMeshRenderers private void MessWithKerb(GameObject kb) { //this will be a very simple example, let's just replace the Kerbal's helmet mesh by the one from the visor SkinnedMeshRenderer smrHelmet = null; SkinnedMeshRenderer smrVisor = null; foreach (SkinnedMeshRenderer smr in kb.GetComponentsInChildren(typeof(SkinnedMeshRenderer))) { if (smr.name == "helmet") { smrHelmet = smr; } if (smr.name == "visor") { smrVisor = smr; } } if ((smrHelmet != null) && (smrVisor != null)) { smrHelmet.sharedMesh = smrVisor.sharedMesh;//Replace the mesh smrHelmet.sharedMaterial = smrVisor.sharedMaterial;//Replace the material smrVisor.enabled = false;//disable the visor } } } } That will show something like this: Still, I can't find some animated models to test this in-game. This is so frustrating: Anyone knows of a tutorial for a beginner in modelling that would allow me to create a basic animated stick figure? Also, I found how to spawn objects from assets now.
  18. I'm actually doing something like this at the moment, and I may have found a way to change the models at runtime. For now it's very basic, and I don't think this could be used to load a human model yet. Still, one can mess around with the SkinnedMeshRenderer of a GameObject, and change the SharedMesh and SharedMaterial. I'm actually having a lot of problems with those: The thing is, I don't know how to access a model from an asset, so, when I want to use a particular in-game model, I have to load the scene where the model come from (for instance the VAB), make a copy of what I need, then use this copy elsewhere. I can't just use props (drillers, screwdrivers, etc...) without this shenanigan. And, when I try to load a model from a file (a .dae or a .mu), I get a GameObject containing only MeshRenderers. Those meshes can't be used to change a SharedMesh property, so I wonder if anyone knows how to load (or how to model a correct mesh) for this purpose. Edit: (kind of proof of concept, click it to view the others)
  19. You can try this if you want a more precise value (correct me if this is wrong): set d_ISP to 0. set d_FTot to 0. set d_FISPTot to 0. list engines in l_eList. for eng in l_eList { if eng:isp > 0 { set d_FTot to (d_FTot + eng:maxthrust). set d_FISPTot to (d_FISPTot + (eng:maxthrust / eng:isp)). }. }. if d_FISPTot > 0 { set d_ISP to (d_FTot / d_FISPTot). } else { set d_ISP to 0. }.
  20. I'm getting started with modding, but I'm struggling to find some good ideas for a mod...
  21. I updated MSD's work for 0.24.2. I did make a small change in the code, because of an optional argument problem, but nothing important. Didn't really test this anywhere but the launchpad, I don't know yet if this work on moons or other planets. Sources are included in the zip file.
  22. Still any interest in this mod? Because it work on 0.24 using the source in first page. I can take a look at it if the author does not maintain it anymore.
  23. I guess this is what "Jebediah's Junkyard" must look like:
  24. Some new challenges would be great, but I don't see myself maintaining a thread about them without having completed at least one before... So let's find some ideas! A spaceplanes challenge would be nice, I've not yet seen an autopilot capable of landing on the runway. What about an automated crane for recovering debris, using Infernal Robotics and KAS? This could be fun too, and this could be a good way to test the new feature of the upcoming release.
  25. Well, this is embarrassing, sorry... Anyway, thanks to dzikakulka, I now have a workaround to test if there is a next node, confirmed to work: set iETA to 2147483646.//0x7FFFFFFE set nNode to node(iETA,0,0,0). add nNode. if nextnode:eta < iETA { print "Nextnode exist!". } else { print "Nextnode does not exist!". }. remove nNode. 2147483646 is 0X7FFFFFFE in hexadecimal, and it seems like the maximal value for a date in KSP is 0X7FFFFFFF. This create a node just a second before the end of times, then it check if there is a node before that.
×
×
  • Create New...