Jump to content

[WIP][1.12.x] James Webb for Kerbal


bcink

Recommended Posts

2 hours ago, CobaltWolf said:

The solar sail is really small?

Yep, yep, I'm on it. Just trying to figure out all this stuff while shifting into this Unity black hole. Scale adjusted:

Now I have my asset bundle and I'm trying to figure out how to get it loaded with the help of the plugin. Using @Shadowmage's code, not even sure what to do with it =/ Will continue researching. Question - analyzing the code provided and setup of the smf files in SSTU, will I be able to use two materials on the object? It looks like the code loads based off a naming scheme referring to the different texture types, one type of each per smf file. That's also a lot of texture types - are those all required? I've been working with an image fine and a normal map only.

iuiLpHF.gif

Edited by bcink
Link to comment
Share on other sites

12 hours ago, bcink said:

That's also a lot of texture types - are those all required? I've been working with an image fine and a normal map only.

It only loads what was being used on the original model.  So if using KSP/Bumped -- you only need a DIFF and NRM, and that is all it will load/look for.  If I remember correctly it expects the textures to be located in the same folder as the asset-bundle'd model file, though it may or may not have a fallback to do a global search by name....

Yeah, the SSTU code is a bit...obtuse... the model loading feature that you are looking at is just the lowest level of an entire system of model/texture/shader handling.  Likely none of which you actually need for your current use (you just need to load the model and restore its textures).

I think all that you should need to do is to place the model file somewhere within GameData (e.g. GameData/JamesWebb/telescope.smf), and then reference that model within your part (e.g. inside of MODEL node, model = JamesWebb/telescope ).  (and need to have the SSTU plugin somewhere in the GameData folder as well).

Edit:  Should add that if you can't get it figured out and don't mind sharing the model file with me, I could possibly take a few minutes this weekend to help sort it out and get it loading.  If asked very nicely I might even be willing to slap together a stand-alone asset-bundle-model-loading plugin (so that you don't need to use the SSTU one; though you are welcome to if you want).

Edited by Shadowmage
Link to comment
Share on other sites

4 hours ago, Shadowmage said:

It only loads what was being used on the original model.  So if using KSP/Bumped -- you only need a DIFF and NRM, and that is all it will load/look for.  If I remember correctly it expects the textures to be located in the same folder as the asset-bundle'd model file, though it may or may not have a fallback to do a global search by name....

Yeah, the SSTU code is a bit...obtuse... the model loading feature that you are looking at is just the lowest level of an entire system of model/texture/shader handling.  Likely none of which you actually need for your current use (you just need to load the model and restore its textures).

I think all that you should need to do is to place the model file somewhere within GameData (e.g. GameData/JamesWebb/telescope.smf), and then reference that model within your part (e.g. inside of MODEL node, model = JamesWebb/telescope ).  (and need to have the SSTU plugin somewhere in the GameData folder as well).

Edit:  Should add that if you can't get it figured out and don't mind sharing the model file with me, I could possibly take a few minutes this weekend to help sort it out and get it loading.  If asked very nicely I might even be willing to slap together a stand-alone asset-bundle-model-loading plugin (so that you don't need to use the SSTU one; though you are welcome to if you want).

Thanks so much. I think it's fair to say that you may be my saving grace here. I'll give it hell some more tonight and see what I can't figure out. Sounds like I shouldn't need to re-create the AO bake pictures into a single image as the plugin would load whatever was being used in the original (in this case 2x ao's and 2x normals) as long as they are in the same location as the bundle. Would this mean that the file names should remain exactly as they were? I was just drooling over how perfectly setup your files were, same naming scheme all the way through for the different files.

And if it comes down to it I certainly wouldn't mind sharing the file. 

Will mess around some more and report back. Thanks a million!

Link to comment
Share on other sites

17 minutes ago, bcink said:

Would this mean that the file names should remain exactly as they were?

Yes, your texture files should be named exactly as they were in Unity when you setup the materials for the model.

The SSTU-asset-bundle-model-loading code shouldn't have any problems with different meshes using different materials textures, as long as there is only one material per mesh (KSP does not like sub-material assignments).

However, KSP shaders do not support using stand-alone AO/occlusion maps -- you'll need to bake those into your diffuse texture.  The notes you see about _AOMap in the loading code are because I use some custom shaders in SSTU that support additional features (colored specular texture input, separate AO texture input, etc...).  The loading code should work fine with the standard KSP shaders, but you'll be limited to their feature set (the same texture slots you see for those shaders in the Unity Editor).

Link to comment
Share on other sites

2 hours ago, Shadowmage said:

Yes, your texture files should be named exactly as they were in Unity when you setup the materials for the model.

The SSTU-asset-bundle-model-loading code shouldn't have any problems with different meshes using different materials textures, as long as there is only one material per mesh (KSP does not like sub-material assignments).

However, KSP shaders do not support using stand-alone AO/occlusion maps -- you'll need to bake those into your diffuse texture.  The notes you see about _AOMap in the loading code are because I use some custom shaders in SSTU that support additional features (colored specular texture input, separate AO texture input, etc...).  The loading code should work fine with the standard KSP shaders, but you'll be limited to their feature set (the same texture slots you see for those shaders in the Unity Editor).

Sweet! It almost sounds magically easier at this point. Looking forward to trying this tonight. 

Link to comment
Share on other sites

@Shadowmage Trying to mimic your setup here as exactly as I can with no luck yet though. At least KSP is stuck when trying to load the part so I know it's getting there... a few questions?

1. Does the name of the asset bundle affect anything, like the name of the folder the .smf is placed in?

2. Do the texture files also need to be marked as belonging to the same asset bundle as the prefab? (I've tried both methods not knowing which is proper)

3. Do the texture files need to be in .dds or .png only? 

In just trying to get it to load simply, I marked the prefab as belonging to a new one, "jwst-base." I have placed "jwst-base.smf" inside the SSTU>>Assets folder along with the texture files. I added jwst-base.cfg to the parts folder and set model = SSTU/Assets/jwst-base.

Log returns the following:

[LOG 20:13:49.350] Load(Model): SSTU/Assets/jwst-base
[EXC 20:13:49.468] NullReferenceException: Object reference not set to an instance of an object
 SSTUTools.SMFBundleDefinitionReader.setupModelTextures (.UrlDir dir, UnityEngine.GameObject model)
 SSTUTools.SMFBundleDefinitionReader+<Load>d__0.MoveNext ()
 UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress)

 

:o

Link to comment
Share on other sites

10 hours ago, bcink said:

@Shadowmage Trying to mimic your setup here as exactly as I can with no luck yet though. At least KSP is stuck when trying to load the part so I know it's getting there... a few questions?

1. Does the name of the asset bundle affect anything, like the name of the folder the .smf is placed in?

2. Do the texture files also need to be marked as belonging to the same asset bundle as the prefab? (I've tried both methods not knowing which is proper)

3. Do the texture files need to be in .dds or .png only? 

In just trying to get it to load simply, I marked the prefab as belonging to a new one, "jwst-base." I have placed "jwst-base.smf" inside the SSTU>>Assets folder along with the texture files. I added jwst-base.cfg to the parts folder and set model = SSTU/Assets/jwst-base.

Log returns the following:

[LOG 20:13:49.350] Load(Model): SSTU/Assets/jwst-base
[EXC 20:13:49.468] NullReferenceException: Object reference not set to an instance of an object
 SSTUTools.SMFBundleDefinitionReader.setupModelTextures (.UrlDir dir, UnityEngine.GameObject model)
 SSTUTools.SMFBundleDefinitionReader+<Load>d__0.MoveNext ()
 UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress)

 

:o

From the log excerpt it is properly detecting the model file and attempting to load it, but failing out during texture loading.  This could be caused by either the model itself being null (nothing found inside the AssetBundle), or by... well.. that looks to be about it from the code -- there is only one potential cause of null-ref in that method, and it would happen if the game-object passed in was null.

So the likely cause is that the bundle was not constructed properly and did not contain a valid model.  Can you look at the asset-bundle meta file that should have been created and check to make sure it actually has a prefab in it?

This is the point where I am going to need to ask for the model files so that I can do a bit of debugging.  I would need at least the .smf file, textures, and part.cfg file; that should let me diagnose what is causing the model itself to fail loading.

 

1.) Nope, shouldn't matter (looks like you have it setup properly)
2.) Nope, shouldn't need to be (otherwise they'll be included in the bundle as well... but there is no easy way to extract/restore them... at least not yet)
3.) Shouldn't matter; any texture that KSP can load should work.

 

Link to comment
Share on other sites

1 hour ago, Shadowmage said:

From the log excerpt it is properly detecting the model file and attempting to load it, but failing out during texture loading.  This could be caused by either the model itself being null (nothing found inside the AssetBundle), or by... well.. that looks to be about it from the code -- there is only one potential cause of null-ref in that method, and it would happen if the game-object passed in was null.

So the likely cause is that the bundle was not constructed properly and did not contain a valid model.  Can you look at the asset-bundle meta file that should have been created and check to make sure it actually has a prefab in it?

This is the point where I am going to need to ask for the model files so that I can do a bit of debugging.  I would need at least the .smf file, textures, and part.cfg file; that should let me diagnose what is causing the model itself to fail loading.

 

1.) Nope, shouldn't matter (looks like you have it setup properly)
2.) Nope, shouldn't need to be (otherwise they'll be included in the bundle as well... but there is no easy way to extract/restore them... at least not yet)
3.) Shouldn't matter; any texture that KSP can load should work.

 

Will check on that ASAP. I suppose it's possible I'm not building the asset properly... I downloaded and imported the "Unity Asset Bundle Manager" package and just use that to rick click the prefab, click build asset bundle. Is that the correct tool even or is there some other process? Can send things off tonight once I"m back home if necessary :}

Link to comment
Share on other sites

21 minutes ago, bcink said:

Will check on that ASAP. I suppose it's possible I'm not building the asset properly... I downloaded and imported the "Unity Asset Bundle Manager" package and just use that to rick click the prefab, click build asset bundle. Is that the correct tool even or is there some other process? Can send things off tonight once I"m back home if necessary :}

I'm not sure what tool that is, have never used it.  I originally used the KSP PartTools AssetBundle building setup (that was intended for KSPedia creation; but it works for generic bundles); it should spit out a file named such as xxxxx.assetbundle.  You mark the prefab file as belonging to an asset-bundle, go into the KSP asset-bundle menu and do some setup in there, and then export from the KSP asset bundle tools.

 

Alternatively, I have also written and used the following custom scripts to export the asset-bundle based model files: https://github.com/shadowmage45/SSTULabs/tree/master/Plugin/SSTUTools/SSTUPartTools/EditorTools

It creates a system similar to the .mu based PartTools, mimicking much of the setup and workflow.  If you wanted to try those out, download the three .cs files and place them somewhere in your Unity Editor Assets folder; it should add a new option to the menu bar (SSTU-part-tools setup or similar); setup your output folders in there.  Add the SSTUPartExporter component to the root game-object, enter the model name, and hit the export button.  (you may or may not need to create an Assets/Build folder first... or the script might fail from a missing folder... been awhile since I've played with it)

 

(Oh, what fun it is to get these BlendShape models working in-game...but it is awesome once they are actually working)

Link to comment
Share on other sites

3 hours ago, Shadowmage said:

I'm not sure what tool that is, have never used it.  I originally used the KSP PartTools AssetBundle building setup (that was intended for KSPedia creation; but it works for generic bundles); it should spit out a file named such as xxxxx.assetbundle.  You mark the prefab file as belonging to an asset-bundle, go into the KSP asset-bundle menu and do some setup in there, and then export from the KSP asset bundle tools.

 

Alternatively, I have also written and used the following custom scripts to export the asset-bundle based model files: https://github.com/shadowmage45/SSTULabs/tree/master/Plugin/SSTUTools/SSTUPartTools/EditorTools

It creates a system similar to the .mu based PartTools, mimicking much of the setup and workflow.  If you wanted to try those out, download the three .cs files and place them somewhere in your Unity Editor Assets folder; it should add a new option to the menu bar (SSTU-part-tools setup or similar); setup your output folders in there.  Add the SSTUPartExporter component to the root game-object, enter the model name, and hit the export button.  (you may or may not need to create an Assets/Build folder first... or the script might fail from a missing folder... been awhile since I've played with it)

 

(Oh, what fun it is to get these BlendShape models working in-game...but it is awesome once they are actually working)

Curious! So I ran home at lunch and looked around, found the KSPAssetBuilder and see that it can make a bundle in a .ksp file format I guess? It pulls up a list of everything associated with the prefab and gives you the option to check mark them? and then build the bundle? Wasn't exactly sure which route to take with selecting everything, including fbs files? or just the texture files? Yikes. Could try using your tool there, but at first glance sounds a bit complicated, where if I'm just not bundling this thing right could save time getting that right anyways lol.

Link to comment
Share on other sites

5 minutes ago, bcink said:

Curious! So I ran home at lunch and looked around, found the KSPAssetBuilder and see that it can make a bundle in a .ksp file format I guess? It pulls up a list of everything associated with the prefab and gives you the option to check mark them? and then build the bundle? Wasn't exactly sure which route to take with selecting everything, including fbs files? or just the texture files? Yikes. Could try using your tool there, but at first glance sounds a bit complicated, where if I'm just not bundling this thing right could save time getting that right anyways lol.

If I remember, I'll try to cap some screenshots tonight of the proper process for exporting the model asset bundles.  Seems like the clearest way to explain things :)  (and also will be a good refresher for me, as I haven't touched them much in ~6mo or so).

Link to comment
Share on other sites

6 hours ago, Shadowmage said:

If I remember, I'll try to cap some screenshots tonight of the proper process for exporting the model asset bundles.  Seems like the clearest way to explain things :)  (and also will be a good refresher for me, as I haven't touched them much in ~6mo or so).

So, here's the good news:

BL3ExnR.gif

Now it looks like I need to square away my collision mesh and remake the bundle. Scale needs adjusted as well. This will probably be done sometime over the weekend, but it's a busy weekend for me. I had textures assigned to materials and materials assigned to the objects. I think this was causing my issue earlier. I ended up remaking the asset bundle and indeed only the prefab file shows up in the bundle instead of a bunch of other stuff, and that file renamed to smf etc. loaded without a hitch. Just getting some mesh issues as I didn't do that yet, I was just going with Unity's generic. If that all goes well, I should have the option to play the animation and then we all have the ticket for a JWST :D 

Also, you are awesome.

Edited by bcink
Link to comment
Share on other sites

5 minutes ago, bcink said:

So, here's the good news:

Now it looks like I need to square away my collision mesh and remake the bundle. Scale needs adjusted as well. This will probably be done sometime over the weekend, but it's a busy weekend for me. I had textures assigned to materials and materials assigned to the objects. I think this was causing my issue earlier. I ended up remaking the asset bundle and indeed only the prefab file shows up in the bundle instead of a bunch of other stuff, and that file renamed to smf etc. loaded without a hitch. Just getting some mesh issues as I didn't do that yet, I was just going with Unity's generic. If that all goes well, I should have the option to play the animation and then we all have the ticket for a JWST :D 

Amazing work! almost there

Link to comment
Share on other sites

6 hours ago, Drakenex said:

I'm soooo recreating this soon!

 

I cannot wait either! Trying to do as much as I can with my busy schedule :)  Finished the collision mesh for the base structure and created a more refined part configuration file for it and verified it's all working nicely. Then, being stuck not at my house with my laptop only tonight, I produced some imagery (all about the hype right? :D)

TsEMFQY.gif

Link to comment
Share on other sites

2 hours ago, Drakenex said:

looks like a dipole antenna, but I can't really find any info about it :confused:

 

Edit: @bcink can't find it anywhere, where is it located on your model?

You can see it's location in this gif, basically just opposite side of the main antenna. This specifically, as with the rest of this was modelled after NASA's downloadable JWST Maya model.

g8FfqNG.gif

Link to comment
Share on other sites

On 11/4/2017 at 6:40 AM, bcink said:

Apparently waking up at 4am because of your dogs yields a chance of this happening:

DvoY3Vf.gif

Glad to hear you got it all working :)

I'm currently working on spinning off some of the SSTU model/shader related code into a separate plugin, and will consider adding in the 'asset-bundle-based-model-loader' code in there as well.  So hopefully you'll have a stand-alone method to get the models and textures loaded soon.

Link to comment
Share on other sites

1 hour ago, bcink said:

You can see it's location in this gif, basically just opposite side of the main antenna. This specifically, as with the rest of this was modelled after NASA's downloadable JWST Maya model.

 

yes, that's strange, cant find it in any other model, also is not mentioned here.

 

But well, it doesn't matter. Awesome and detailed model you've got there

Edited by Drakenex
Link to comment
Share on other sites

1 hour ago, Shadowmage said:

Glad to hear you got it all working :)

I'm currently working on spinning off some of the SSTU model/shader related code into a separate plugin, and will consider adding in the 'asset-bundle-based-model-loader' code in there as well.  So hopefully you'll have a stand-alone method to get the models and textures loaded soon.

Thanks! And that's very exciting!

13 minutes ago, Drakenex said:

yes, that's strange, cant find it in any other model, also is not mentioned here.

 

But well, it doesn't matter. Awesome and detailed model you've got there

Thanks!!! At this point it's just something to have a little extra fun with :)

Link to comment
Share on other sites

16 hours ago, bcink said:

I cannot wait either! Trying to do as much as I can with my busy schedule :)  Finished the collision mesh for the base structure and created a more refined part configuration file for it and verified it's all working nicely. Then, being stuck not at my house with my laptop only tonight, I produced some imagery (all about the hype right? :D)

 

I hate to be *that guy* -- but are you sure the RCS Thrusters provide "the unnecessary boost needed to align the observatory".  Wouldn't that be "the neccessary boost"?  If it's unnecessary, why would I want to use them? :)

 

Link to comment
Share on other sites

10 minutes ago, MOARdV said:

I hate to be *that guy* -- but are you sure the RCS Thrusters provide "the unnecessary boost needed to align the observatory".  Wouldn't that be "the neccessary boost"?  If it's unnecessary, why would I want to use them? :)

 

You're fine - It definitely falls under the category of unnecessary for the purposes of the Kerbal universe, other than to add a small amount of self-propulsion (which will pretty much only be able to handle small orbital adjustments. I presume they would be desired simply because they are on the actual JWST and that's all :D   In RL, it's a fancy set of 8x redundant dual monopropellant thrusters that run on hydrazine only and no oxidizer. When combined they provide pitch, roll and yaw control. Fun fact: Due to the awkward shape of the JWST, any adjustments to the pitch, roll, or yaw must be calculated into it's maneuver nodes ahead of time as they also affect the vehicle's DeltaV.

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