Page 1 of 8 123 ... LastLast
Results 1 to 10 of 79

Thread: 0.20 - PartTools, GameDatabase and new features

  1. #1

    Lightbulb 0.20 - PartTools, GameDatabase and new features

    PartTools 0.20

    Firstly, here is the new PartTools package for 0.20. Please read the included ReadMe.txt!


    GameDatabase & PartLoader


    The system that KSP uses to load game resources has changed, its called GameDatabase (GDb).
    GDb iterates through the various game data directories creating a list of files. Each file is assigned a url and then the assets are loaded in a specific order; Assemblies (dlls), audio, textures, models and then configs.

    Once GDb has finished loading files it hands control over to PartLoader which compiles all of the game's configs into parts, internal props and internal spaces.


    GameDatabase URL system

    GDb assigns a unique url to every asset and config in its directory structure. No file extensions are stored in the url, this allows you to reference models, textures and audio without needing to know what the file type is. The legacy directories (parts, internals, etc) are all prefixed with the directory name however the new data directory, GameData, is not. Lets look at some examples...

    File: KSP\GameData\Squad\Parts\Command\landerCabinSmall\ model.mu
    URL: Squad\Parts\Command\landerCabinSmall\model

    File: KSP\Parts\cupola\model000.mbm
    URL: Parts\cupola\model000


    GameDatabase 'Get' Methods

    All of the assets held in the GDb are retrieved via the Get methods. They are seperated into asset type.

    GetAudioClip - Gets audio clip from url
    GetTexture - Gets texture from url
    GetTextureIn - Gets a texture in the specified directory
    GetModel - Gets model by url
    GetModelIn - Gets model in specified directory
    GetConfigNode - Gets a config node by url
    GetConfigNodes - Gets all config nodes by type

    For detailed information load the dll into VisualStudio or MonoDevleop.


    KSPAddon & AddonLoader

    AddonLoader is a simple system which allows modders to instantiate Unity MonoBehaviours without need to messily overload Part, PartModule or UnitTests. To do this you tag a component in your assembly with the KSPAddon attribute. This attribute allows you to set which scene the component is instantiated in and also if it should be repeatedly instantiated upon transition into that scene. If you want the component to not be destroyed then you should set 'once' to true and manually call DontDestroyOnLoad.


    ATTACH Nodes

    Previously, part configs had to define attach nodes with messy position values in the base config. Now you can define an attach node as being linked to a transform on the model. To do this you define an ATTACH config node like this..

    Code:
    NODE
    {
       name = top
       transformName = myTopTransform
    }
    NODE
    {
       name = srfAttach
       transformName = mySrfAttachmentTransform
    }
    There are two key names of attach nodes;
    There is the 'top' node, this defines the traditional part heirarchy structure. If you only have one attach node then it should be called top.
    There is also the 'srfAttach' node, this defines the surface attachment point. The name 'attach' is also valid for this node, you can only have one surface attachment node.

    You can define two other values; size and method.
    'size' allows you to change the node's sphere size in the editor and has no effect on gameplay.
    'method' allows you to change the physic joint type. Its values can be; FIXED_JOINT, HINGE_JOINT, LOCKED_JOINT, MERGED_PHYSICS or NO_PHYSICS. Not sure what madness you can do with this value, will leave it to you all to play.

    NOTE: Attach nodes defined in this way are not animated with respect to physics and should remain static on the model.


    MODEL Nodes

    In the old system, models were loaded directly from a part config's directory. This is still the case however can be overridden using MODEL config nodes.
    MODEL nodes can be used to compile parts containing scaled, translated or rotated models. You can define multiple MODEL nodes to compile multiple models into one part. It also allows you to overload textures on the model.
    Parts, Props and InternalSpaces can all use MODEL nodes instead of the traditional same-driectory loading system.

    Here is a sample MODEL node showing all valid values

    Code:
    MODEL
    {
       model = Squad/Parts/Command/cupola/model
       position = 0.25, 0.5, 1.0
       scale = 2.0, 2.0, 4.0
       rotation = 0, 90, 0
       parent = anotherModelTransform
       texture = model000 , Squad/Parts/Command/landerCabinSmall/model000
       texture = oldTextureName , newTextureURL
    }
    NOTES:
    The 'parent' value is only valid in the second or subsequent MODEL nodes as they refer to a transform which must already exist in the part model heirarchy.

    Texture overloading value is delimited by comma or semicolon just in case you have spaces in your new texture's URL. All materials using the old texture are swapped to the new texture.
    Last edited by DYJ; 12th June 2014 at 12:48. Reason: Changed "ATTACH" to "NODE"
    Si non confectus, non reficiat.

  2. #2
    Quote Originally Posted by Mu View Post
    'size' allows you to change the node's sphere size in the editor and has no effect on gameplay.
    I believe this used to affect snap distance, has that been removed/moved?

    Also, what units are they in now? Is it unity distance measurements so that size 1 is a green sphere the diameter/radius of a fuel tank, rather than the previous fixed sizes?

    Quote Originally Posted by Mu View Post
    'method' allows you to change the physic joint type. Its values can be; FIXED_JOINT, HINGE_JOINT, LOCKED_JOINT, MERGED_PHYSICS or NO_PHYSICS. Not sure what madness you can do with this value, will leave it to you all to play.
    Squee!

    I'm guessing LOCKED_JOINT is a configurableJoint with no movement allowed and FIXED_JOINT is the current default fixedJoint.

    Hinge joint is an interesting one. Are the settings configurable in the config and if not then what are the default ones? Ball bearing type free movement with the axis through the connection? Does the rotation get saved in the persistence file?

    Also, what's the distinction between MERGED_PHYSICS and NO_PHYSICS? Is the difference that the former moves the CoM while the later doesn't? Are they combining both parts under the same rigidbody? If so is there anything to dynamically separate them in a collision or are they stuck together forever once attached?

    This applies to the part that's being attached, and has no influence from the value defined on the node it's attaching to. Is that correct?

    Quote Originally Posted by Mu View Post
    MODEL nodes can be used to compile parts containing scaled, translated or rotated models.
    Just a note generally: In the unity engine uneven scaling may result in funkyness of animations/gameObject rotation. I don't know if anything has changed for the KSP implementation, but if anyone is thinking of using it then bear that in mind.

    Also, a neat trick in unity is that you can provide negative scaling values to mirror something. If you want left and right wing parts, for example, then you can now set the scale to something like 1,1,-1 and have a mirrored model without having to re-export. Although this does count as uneven scaling so the caveat above applies.

  3. #3
    Could you please elaborate on the physics joint types? Or just answer this; if I set NO_PHYSICS there should be no part wobble at all?

    Edit: Reading it over again, can I take this bit
    "NOTE: Attach nodes defined in this way are not animated with respect to physics and should remain static on the model."
    to mean that if you use any of the physics joint types described above, there's no animation with regard to physics (= wobble)?
    Last edited by Borklund; 4th June 2013 at 10:57.

  4. #4
    Quote Originally Posted by Borklund View Post
    can I take this bit to mean that if you use any of the physics joint types described above, there's no animation with regard to physics (= wobble)?
    I believe it means they're attached at the default location of the specified transform rather than to the transform itself, so moving the transform will destroy the illusion as the node won't move with it.

  5. #5
    CEO of Average Industries
    Join Date
    Apr 2013
    Location
    Worcester, UK
    Posts
    197
    I thought I had got used to the old part tools, and then this comes along Is the URL something that has to be assigned in the script in unity, or does it not matter? What happens if I change a folder name, do I need to re do the script?

  6. #6
    Global Moderator Supernovy's Avatar
    Join Date
    Jun 2012
    Location
    Jun 2012
    Posts
    1,164
    How do model nodes interact with other things based on models, like thrust transforms for engines, or jettison modules for fairings?

  7. #7
    Mutants Worship Me Nuke's Avatar
    Join Date
    Nov 2011
    Location
    Alaska
    Posts
    1,508
    heh, cool. any new info about how to use audio clips? thats something i dont think anyone has figured out without a plugin (and the legacy way doesnt work).
    this space intentionally left blank

  8. #8
    When I import it and I try to add Part Tools as a component it says 'Script not found'?
    I've tried installing it multiple times now


    Fixed!
    Last edited by -Lysdal-; 6th June 2013 at 05:44.

  9. #9
    Quote Originally Posted by Mu View Post
    NOTE: Attach nodes defined in this way are not animated with respect to physics and should remain static on the model.

    You got me all excited there for a minute. I was hoping that I'd be able to child a transform to a mesh that gets animated and have the attachment node move. Are there any plans to add this sort of functionality, or is it just not possible due to Unity limitations?

  10. #10
    Is that possible to add a type value to a node defined the old way, entirely in the config? If so, could you provide an example of how it'd look like? I'd like to try out the new node types on the CSS, but I don't have access to source models, only to .mu files.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •