Jump to content

michaelhester07

Members
  • Posts

    548
  • Joined

  • Last visited

Posts posted by michaelhester07

  1. Everything except gravity assists as I don't know how to do those. I have yet to do one as I don't have mechjeb either.

    Land at a specific location: depends on where...

    Kerbin: no

    Duna: yes within 5 meters... I had to land a power supply for a lander that fell over so it could get the base it was supposed to build operational.

    Eve: no

    Mun: yes within 1 meter (landed on top of a probe I used for a landing marker)

    Minmus: yes

    Gilly: yes... but it took forever

    Ike: yes.. Ike tends to get lots of bases on it in my career modes.

    I haven't had legit missions to other planets yet.

  2. The hatch placement on the science lab moved to the top because when you used it on a torus station you couldn't get into it. Getting out had a strong chance of clipping into the station and blowing everything up.

    sorry bout the ground base. I hope you brought KAS for ladder parts (they do let you place ladders right?)

  3. You would want to use extraplanetary launchpads to build the torus. I can't imagine KSC surviving the launch. It's possible though as the torus total weight should be no more than 15 kilotons. By that respect it is lighter than it might be in real life. The hull intersects the VAB when it gets placed on the pad. IRL a Stanford torus would certainly not be launched but built in orbit. There are a number of ways that this could happen from launching the raw materials from the moon to a lagrange point or capturing an asteroid and shattering it into an inflated fabric ring so that the asteroid forms the outer ring. The torus should also be a lot bigger, on the order of 60km diameter or larger (that's how big the station in Elysium was).

    The pipeline cancellation point: I was doing that 4 months ago (november vs today) and I may integrate that into the ISRU kerbal recruitment thing. Pipelines would be easy enough so long as i can update the resource gathering parts on each ship included in the pipe.

  4. Long time no revisit. The edit won't bump the update. I've looked into the whole editing process for a stanford torus and figured out a way to shrink the torus and every part in the editor on demand. I do want to do the ISRU kerbal recruitment system and civilian population thing. I had forgotten about it as I went to play other games. The other games' fun is drying up and here i am.

    The ISKR system and civilian population thing will be a different mod from the stanford torus thing.

  5. When Squad did the upgrade-able facilities they changed the way that facility bounds and models are setup. This breaks the old hangar extender I needed to use to edit a stanford torus and thus I'm at an impass for that mod.

    How might I go about resizing the hangar or vab in .90 or later?

    Update: the reason I needed to do this is gone now (I'm shrinking my torus instead of expanding the VAB) but I'd still like to know for educational purposes.

  6. It's a simplistic approximation of recoil:


    double f = powerLevel * acceleratorForce/100;
    var spent = part.RequestResource(resourceName, dt * resourceAmount * f);
    if (spent == 0)
    f = 0;
    double m = vLaunchTarget.RevealMass();
    float a = (float)(f / m);
    dt = Math.Min(dt, accelerationDuration); //for slow computers... don't apply more than the duration of acceleration
    vLaunchTarget.ChangeWorldVelocity(accelerateVector * (a * (float)dt));
    //for every action there is an equal and opposite reaction
    m = this.vessel.RevealMass();
    a = (float)(f / m);
    vLaunchTarget.ChangeWorldVelocity(accelerateVector * (-a * (float)dt));

    There's the code that calculates the force. It uses that equation force=mass*acceleration and solves for acceleration. Then for the duration of launch power it applies the acceleration to the payload in the "up direction" according to the accelerator, and on the launcher in the "down" direction according to the accelerator. If I recall "up" is the side with the black ring on it (i haven't used the accelerator in a while).

    The recoil will be there, just if your launcher is significantly heavy it might not be visible. It's also possible that if your launcher is heavy enough and the framerate fast enough that the floating point error drops the launcher's acceleration.

  7. The source code for the mass driver was included with the science mods in my mod. It compiles with Visual Studio 2013 express and links to the DLLs found in the KSP folder.

    The DLLs linked against the 32 bit KSP so this doesn't work in 64 bit. The DLLs also linked against the .25 version of KSP but I didn't see any issues using it in .9 last friday.

    @ Gaalidas:

    The idea of the world moving and you standing still is one that I like because it allows faster than light travel to exist. My source for this thought

    Let c be the speed of light.

    Generally accelerating anything with mass to the speed of light requires infinite energy. I would assume to follow that it is possible to get to .51c or .6c with finite energy. How much that energy is we don't know as we don't have an engine capable of that yet. Let's say we did though.

    Take 2 objects then and have them fly away from each other at .6c. If the frame of reference is one of those objects then the other object is going faster than light.

    Here's an extension too. It should be possible to find out what velocity is 0 speed with reference to the universe itself if the speed of light cannot be broken. If there is a universal frame of reference for speed then it stands to reason in the scenario where we put 2 objects going away from each other at .6c that one object would require more energy to do so than the other. This effect should be detectable at smaller fractions of c. If there is no difference in the energy required for each object to get to .6c then there is no frame of reference and faster than light travel is actually possible with standard propulsion.

    That's my thought experiment on that matter.

  8. While a catch all can have some use I would recommend to stay away from it as much as you can. It leads to some really bad coding habit where you just hide the exception and never resolve the real problem. (My code is not immune from that bad habit...)

    Catch specific exception ( DivideByZeroException, FileNotFoundException, ...) and make sure the catch is not commonly called in normal use because it's S L O W.

    Wut ?!?

    Is exactly the the same as

    for a class or a reference.

    Or I just moved into some strange parallel universe.

    (Just don't be pedantic and talk about the Unity null check please)

    A note about this:

    Vessel myVessel;

    vs

    Vessel myVessel=null;

    If you're compiling this in visual studio it will give you an error when you use variable from the first version and never assigned it. The first version is a declared but uninitialized variable. Used to be that compilers allowed this (c and c++ did) but that's a HORRRRRRIBLE practice because the variable would pickup whatever was in the memory space that the computer gave it when you ran the program. If you declared

    int myVariable;

    there's no telling what was in the memory that the computer assigns for that variable and that could lead to unpredictable behavior out of your program. This especially goes for if that variable is supposed to be a pointer.

    C# the compiler correctly identifies this as an error if you try to use the uninitialized variable. Even to test if it's null.

    If you create the variable and then assign a new object to it

    Vessel myvessel = new Vessel() then you don't have to initialize. Otherwise you should initialize the variable when you create it.

    Edit: a PS or slashie if you will

    /Uninitialized variables are the cause of probably i'd say 50% of crashes in computer programs (I don't know the exact percent but it's up there). The other half is caused by improperly handled multi-threading... something you hopefully don't have to handle while modding KSP.

  9. Let's have a crash course (it's what kerbals do) in inheritance and then a crash course into your "crash"... heh. (i think i'll mod ksp tonight anyway:) I've been sitting on new torus model for 3 months)

    All Classes in c# are objects. This is the core of objected oriented programming. Objects are Referenced with pointers. Every variable in c# is also treated as a pointer. There are some crazy things you can do with this knowledge but for now we'll keep to the object definition. Think of your class as a physical object like a flashlight. It has variables (the state of the light, the battery power ,etc) and it has methods (turn on the light, turn off the light, open the battery compartment, etc). When you have a manufactured copy of that flashlight you can point to it with your finger. That flashlight's object is referenced with a pointer. It is one instance of the designed object.

    Your mod class uses a base object, defined like so

    class MyShipModule: Module ...

    That little colon is telling the compiler that your class extends or inherits the methods and variables from the base class. In this case the module you inherited has a variable called "vessel" which is an object of type Vessel. That's what the "this.Vessel" is. this is a "pointer" that points to your class's object. Basically you took someone else's flashlight and added features to it, like a laser pointer. You can add methods to the new class (turn on the laser, turn off the laser) but you can also still reference the original class's variables (battery power, state of the light, etc). You can access them through use of the "this" pointer, which refers to the object that the method is being run on. The this pointer is not actually necessary. just saying Vessel in that if statement is the same.

    Now for the Null Reference Exception.

    It is possible to have a pointer that does not actually have an object on the other end of it. You're potentially referencing a new flashlight but it hasn't arrived yet. This pointer carries a special value of "null", meaning there is nothing at the other end of it. Your code is trying to use a feature on the flashlight that doesn't exist (turning on the flashlight). When this happens the computer "throws an exception". This is the computer saying "hey there is no object on the other end of this pointer, what should I do?". The exception mechanism allows you to then "catch" an exception and tell the computer what to do when that happens. Your code is in error because you didn't tell the computer what to do when the object pointed to doesn't exist.

    In this case you're trying to reference the container Vessels out of FlightGlobals, which is a null pointer. The computer can't find the object on the other end and throws an exception. There are several ways you can solve this problem.

    1. Prevent it. If you know that there is nothing on the other end of the variable (the game state is the main menu) and the code you're running won't apply in the current situation you can check for that and exit your code as there is nothing to do.

    2. Check for the null. You check for Null before you access the variable. If you use the variable a lot this can get tedious. You also have to figure out what to do when the variable is null.

    3. Catch the exception. Wrap it all in a try...catch block. The try block says that there might be an exception occurring in the second of code inside. If one occurs then you'll catch it with the catch block.

    try and catch lets you catch any exception, even ones you didn't think about. What if you go out of bounds on the flight globals vessel list? What if you try to reference something that's supposed to be there on a vessel?

    When choosing how to handle when the variable is null there are slight performance issues to keep in mind.

    If you chose the prevent it route then you'll only check the single state (main menu) and you'll exit out of your code. Any time you don't execute part of a code you'll gain some performance. In games this performance means higher framerates. If you do the check for null route then you'll have a higher performance cost but not too great. This is for if you want to execute your code still but want to handle missing objects on a case-by-case situation. The exception catching path is the slowest as there is "overhead" in throwing and catching an exception. Exception catching should only be used when the objects you're using communicate with exceptions. Most of .NET functions are notorious for this. Chances are the code you write for a KSP mod won't be too complex so simply checking for null before you use an object is the best route.

    That's our kerbal crashing course in c#.

  10. How I fight it:

    1. Flat landing spot. Less than 8 degrees slope, with Kerbal Engineer reading the slope out.

    2. Barring 1: Wide base with girders to spread the legs out. My landers have special constraints for base construction (that is they have launch pads on the bottom end of girders with extraplanetary launchpads) so the legs get spread out anyway. I had to rescue a Duna lander in my latest career after a sudden unplanned orientation change upon landing. The wider the base the easier to land. 3x1 girders can maximize the area.

    3. Lots of torque. If my lander has to be narrow, then lots of torque. This especially goes for probes and mk2 lander can landers. Stack 2-3 SAS modules on top of it and I can stay upright on a 40 degree slope with a narrow leg profile. Probes can even fix themselves after an unplanned orientation shift.

    4. I don't fix it. The duna lander above was a base deployment vehicle that was tall enough to turn over. I had to launch 2 ships, one with drills, the other with garages, to get the base operational. Needless to say I learned how to do a precision landing on Duna, both recovery ships landed within KAS pipe range of the downed lander.

  11. You can use the mesh collider in unity without checking the Convex box for a non-convex mesh (like your cargo bay). The only rule is that it must be a sealed object. This is that there are no holes in your mesh. I got caught by this when I did my stanford torus because I was trying to cut out polygons that would normally be invisible. Turns out this is worse for KSP than if I didn't remove the polygons, even though it should make sense from a stand point of model efficiency. KSP calculates the mesh tensor when you don't use the convex hull mode on the collider and if it finds holes it can't calculate the tensor. This can lead to models loading physics poorly and in some cases the ship blowing up because the physics glitched.

    For your model:

    - Split the end caps of your cargo bay into separate model components. You can apply a convex hull to each of the components separately in Unity. This will let your model impact terrain correctly in KSP. Yes. You need convex hulls to hit terrain without going through it.

    - The rest of the cargo bay hull uses the mesh collider without the convex hull. This will satisfy your cargo bay interior requirement. You can separate the doors and animate the physics for them.

  12. With the mk2 hull done I'm not going to release just yet for next version. I want to make having a Stanford Torus an actual useful thing. To do this... I'm going to go back to my roots with the biodomes mod and expand that, bringing it into the torus mod. With the biodomes mod will come a way to truly colonize space: civilian population and in-situ kerbal recruitment.

    You've probably seen the farm biodome if you have my stanford torus mod.

    Y3djAxt.png

    That is one of several biodomes i'm going to make (or make useful ) this weekend.

    Here's how the in-situ kerbal and civilian population will work.

    The farm will produce food. Probably labeled "snacks". This food will be one of 3 parts required to generate a civilian population on your base or space station. An apartment complex biodome will house a civilian population and some working population (you already see the working population in game :) ). Finally entertainment and recreation biodomes (theater and park) will attract civilians to your base/station. The civilian population, food, and recreation will be resources you can monitor. Finally an admin module will be available where you can hire new kerbals on site. Hiring a kerbal on site will cost money and come from your civilian population.

    In addition to this system I plan to integrate one of the life support mods, probably MKS, as well (seeing as i've already seen the torus MKS integration). Stay tuned.

×
×
  • Create New...