Jump to content

KSPBlender - Blender Addon for importing .craft files (now with complete mod support!)


Dasoccerguy

Recommended Posts

I actually had a much stupider way of figuring out each part name. I can't believe I didn't use the .cfg files.

Does that mean that I ninja'ed you by two weeks ? Wow, slowest ninja ever ! :D

Ok, here it is, I've posted it on Github:https://github.com/Cptmann/ksp_partdic

It surely isn't the most effcient thing ever nor the better piece of code, but it works.

Some notes :

-The name cheaters_probe is because I first intentended to make myself the function which would find the .cfg (and not look everywhere in GameData) but after a number of (half-)failed attempts I discovered that a function was already existing. So, it felt like cheating to me. But rename it to probe (or whatever) if you prefer.

-It creates some quite big dictionnaries : with B9, NFT, Kethane, Interstellar, KAX, KAS, TAC, Atomic age and of course Squad, the part dictionnnary has 737 entries !! So they take quite some time to make

-The cheaters_probe_large function is for the mods which do not have a 'Parts' folder (exeample: AIES), if you use the first function they won't be explored. The downside is that it saves other .cfg which are not for parts.

You will also need to add the 'Vector' thing in the script (where it's indicated), I didn't put it to for tesst not in Blender.

Fun fact : only two parts made by Squad do not have a scale or rescale factor parameter: JetEngine and ladder1

I really hope it works correctly (I have only tested with a few parts for a few mods)

Edited by Cptman
Link to comment
Share on other sites

I've been here in the past to attempt this, but have failed due to my OS (mac). Has there been any major changes that might make this update compatible, without or without tweaking?

Well Python is inherently OS-agnostic so all you'd have to do is change all the paths so that they use a backslash rather than a frontslash.

Link to comment
Share on other sites

I keep getting an error when trying to import.I've done everything according to the instructions in the readme file.Every time I go to file-import-KSP Craft, go to my KSP folder and try to open the stock KSP prebuilt ship it says import error-cannot import name partdic

That was an error I caused and I should not have uploaded that version. I fixed it about a day after I realized what I had done. Try downloading again, or you can just open import-craft.py and delete the line that says "import partdic." I was starting to incorporate CptMan's code and didn't finish.

- - - Updated - - -

I've been here in the past to attempt this, but have failed due to my OS (mac). Has there been any major changes that might make this update compatible, without or without tweaking?

If you go to page... 8 or 9, Sma and I figured it out and fixed the directory problem. The issue was that Windows uses backslashes and everything else uses forward slashes, so there is just a section of the script that chooses the slashes based on what OS it detects. It should work perfectly now, so please let me know if you have issues!

Edited by Dasoccerguy
more info
Link to comment
Share on other sites

I'm working on an animation using not only stock parts but also B9 and BD Armory. Can someone help me tweak the script? I know nothing about programming If you need a copy of my files to get the locations I'll put them up on mediafire along with a page giving my directory leading into those files.

Link to comment
Share on other sites

I'm working on an animation using not only stock parts but also B9 and BD Armory. Can someone help me tweak the script? I know nothing about programming If you need a copy of my files to get the locations I'll put them up on mediafire along with a page giving my directory leading into those files.

This weekend I'm going to incorporate CptMan's script into the addon, which will add support for every mod. I thought I would have to go through manually and add each file location, but CptMan found a way to do it procedurally.

Look for a new version on Sunday!

Link to comment
Share on other sites

Glad to hear that you will incorporate it :)

I modified partdic today to add a function to handle mods with a different name for the part in .cfg and the .craft (for exemple B9). For this there is an exceptions dic at the beginning of the file.

I also changed the name of a few function (probe functions and make_dic -> make_dic_aux) and I added a matser make_dic function to which you only have to give the path.

You will still have to add the Vector in the make_dic_aux function where it is indicated and uncomment the import mathutils.

If you only need the old partdic.py I think it will still be available in the commits tab (I new to Github so I don't really know). Anyway, I have a backup on my computer in case.

If you have any questions/problem/complaints send me a message, I'll try to check the forums a few time during the day.

Link to comment
Share on other sites

If you go to page... 8 or 9, Sma and I figured it out and fixed the directory problem. The issue was that Windows uses backslashes and everything else uses forward slashes, so there is just a section of the script that chooses the slashes based on what OS it detects. It should work perfectly now, so please let me know if you have issues!

Sorry, but I'm a noob (great conversation starter btw). Do I change the all the \\ of every text file (and .py, you know what I mean) in your addon, or just kspdir? If I have to do it with everysingle \\, because there are 1,410 // in part_dir.py

(I swear I used to be good at this sort of stuff)

Link to comment
Share on other sites

Sorry, but I'm a noob (great conversation starter btw). Do I change the all the \\ of every text file (and .py, you know what I mean) in your addon, or just kspdir? If I have to do it with everysingle \\, because there are 1,410 // in part_dir.py

(I swear I used to be good at this sort of stuff)

The fix that he mentioned means you shouldn't have to change the slashes at all. Just add the directories to your specific mods and use \\ and it should be fine. Although he may have an update to the add on soon that if I'm not mistaken means you won't have to add anything to the part directory.

Also, to change them all at once you could just do a find/replace and it should be fine.

Link to comment
Share on other sites

Sorry, but I'm a noob (great conversation starter btw). Do I change the all the \\ of every text file (and .py, you know what I mean) in your addon, or just kspdir? If I have to do it with everysingle \\, because there are 1,410 // in part_dir.py

(I swear I used to be good at this sort of stuff)

Yeah, no need to change code any more. That is all in the past. Tonight I'm going to wrap up this process of including Cptman's code so there will be even less of a reason to edit code (up until now you had to manually add mod support line by line).

Just be sure that you use the correct slashes in kspdir.txt. Don't use double slashes there either... just as it appears in the navigator, like C:\Users\manni01\Kerbal Space Program

Link to comment
Share on other sites

Hey, I wanted to try this out, it looks really cool, but I am always getting this:

zhlONGw.png

I tried to import the Stock Z-Map Satellite launcher. THe importing process is normal, but when it is finished and I want to rotate the camera around the imported craft file it doesn't rotate and the things you can see above happen. :(

Link to comment
Share on other sites

Hey, I wanted to try this out, it looks really cool, but I am always getting this:

:(

I tried to import the Stock Z-Map Satellite launcher. THe importing process is normal, but when it is finished and I want to rotate the camera around the imported craft file it doesn't rotate and the things you can see above happen. :(

It's hard to tell what is happening, but that almost looks like a computer issue with how most of the text is messed up.

Could you try this? Open up Blender again, press A (select all), press Delete (just to get rid of that cube in the middle), press Ok. Now Import the Kerbal2. That has always been my test ship so I know it will work.

If it's still weird, could you send me another screenshot?

Link to comment
Share on other sites

Noticed the Github updated so I gave the new version a shot a few hours ago. Stock craft still import fine but I can't seem to get mod craft to import. B9 just errors out while the Stock-alike station parts wouldn't display an error but didn't import.

Link to comment
Share on other sites

Noticed the Github updated so I gave the new version a shot a few hours ago. Stock craft still import fine but I can't seem to get mod craft to import. B9 just errors out while the Stock-alike station parts wouldn't display an error but didn't import.

Cptman said the naming scheme of things for B9 was a bit funky. Let me try some stuff when I get home.

And as for things not importing but giving no error, that means that it's just a naming issue. That's the mod name? Stock-alike? I'll take a look at those too.

Link to comment
Share on other sites

Cptman said the naming scheme of things for B9 was a bit funky. Let me try some stuff when I get home.

And as for things not importing but giving no error, that means that it's just a naming issue. That's the mod name? Stock-alike? I'll take a look at those too.

Of course I pick the wonky one to test ;) The other random mod I tried was the Stock A like Station Parts here. Should have linked that before, oops. I'll give a few others a go here soon.

- - - Updated - - -

Tried a simple craft with a few KW parts on it to verify imports. Stock Mk1 command pod, KW SB-2 LFT fuel tank, and the Griffon Century engine. Results below. Thanks for your work on this!!!!!

9tXksc2.png
Link to comment
Share on other sites

Of course I pick the wonky one to test ;) The other random mod I tried was the Stock A like Station Parts here. Should have linked that before, oops. I'll give a few others a go here soon.

- - - Updated - - -

Tried a simple craft with a few KW parts on it to verify imports. Stock Mk1 command pod, KW SB-2 LFT fuel tank, and the Griffon Century engine. Results below. Thanks for your work on this!!!!!

Thanks for sharing. I guess I was a bit hasty claiming that all mods would work :(.

I'll try to fix this as soon as I can.

Link to comment
Share on other sites

4. I need your help with the mods, though. There are going to be bugs, so please let me know what goes wrong!

I'll give it a try, as soon as I finish up this one scene I'm trying to complete....getting the uhh....not really smoke....effect just right is a pain, especially because it takes so long to render lol

Link to comment
Share on other sites

I'll give it a try, as soon as I finish up this one scene I'm trying to complete....getting the uhh....not really smoke....effect just right is a pain, especially because it takes so long to render lol

Are you compositing the smoke in or are you using a node setup for Cycles smoke?

Link to comment
Share on other sites

Jay, now it works!

http://i.imgur.com/F9sycYc.png

But it looks a big pixelated, did I something wrong? I just imported the craft, added a camera and a Hemi as light source and rendered it. I have really almost no experience in rendering things... :S

No, that's just how Cycles works. You need to increase the number of samples to 50 to 150 in the Render menu. If you have a GTX, you can set the compute device in Preferences to that GPU and then set your sample count to 1,000.

Link to comment
Share on other sites

Are you compositing the smoke in or are you using a node setup for Cycles smoke?

A little of both I guess? sort of, lol... Originally I was just rendering out the scene, background, foreground+smoke. Then I decided to render just the background, adjusted so clouds wouldn't be where the smoke was, and I could use that over and over for different tests. Then I just rendered the foreground+smoke with the background transparent. I am using a node setup for the cycles smoke, where the various nodes go into the volume socket of the output. Thinking about it now though it might have saved some time if I had also just rendered the foreground and saved it then just rendered the smoke, and composted the background and foreground together. Although, part of the foreground is set as collision for the smoke, so I guess I would have to leave that in, or clone it and set it to not be rendered, maybe that would work. I might try it one more time, but with a different shape for the emitter. If that doesn't work I'll just call it done for now and post what I have over at Show off your KSP Blender Renders Page 18. I've got another KSP project I want to move on to, which is going to take some time to finish lol.

Part of what takes so much time, at least in my experience (which is all of about a week, if that), is the baking process, then rendering to see what the smoke looks like. Then of course any change to the smoke and it has to be baked again. I do save some time by only baking to the frame I want (using a cloth simulation) then stopping it.

[uPDATE]

An edited version of the render I was working on. To check out the original go take a look at the KSP Blender Render thread. :)

9K0xRyA.jpg
Edited by Sma
Link to comment
Share on other sites

I'm having a problem with the setup. I'm on OSX, and I'm wondering how/where to copy the KSP directory. Does anyone have experience with this?

I don't know much about Mac, but from googling I found the KSP directory by default (if you are using steam) can be found at /Library/Application Support/Steam/SteamApps/common/Kerbal Space Program

You will need to find where you installed the addon, where ever your blender is installed, and change what is already in the kspdir.txt file to where ever your KSP is at. In my case, on linux my kspdir.txt file is located at /home/[myusername]/blender-2.74-linux-glibc211-x86_64/2.74/scripts/addons/io_kspblender-master

Here is an example of how mine is setup:

My KSP folder: /home/[myusername]/Desktop/Untitled Folder/Link to Kerbal Space Program (yeah yeah, I know it's a strange folder name/link haa)

My Blender folder: /home/[myusername]/blender-2.74-linux-glibc211-x86_64/

The io_kspblender-master and io_object_mu-master addons get extracted from the zip file to the blender addons folder: /2.74/scripts/addons/

In the /io_kspblender-master/ folder, now in the blender addons folder, I added the path to my KSP folder to the file kspdir.txt

After everything is in the right place, you have to enable the plugins. Open up blender, go to the user preferences in the file menu (or alt+ctrl+U or the mac equivilant, option U or ctrl+option U...whatever it may be lol) click on the addons tab then do a search for ksp. Both the mu importer and ksp craft importer should show up. Click on the box to enable them, then at the bottom left click the save user preferences button, other wise the next time you open blender they won't be enabled.Hope this helps and doesn't confuse you too much. :)

Oh, also on a side note, I noticed there is a bolt factory addon, at least in blender 2.74. Not enabled by default though. It's kind of neat, you can make nuts (including lock nuts/nylock nuts) and bolts, with different types of heads (philips, allen) along with if its a pan head, counter sunk head, round or flat. Thought they might also have square drive, flat head, and torx but didn't see those.

Link to comment
Share on other sites

Just did a test using the craft I made last night for taking reference shots of KSC and this is the result. The one on the right is how it came imported. The one on the left is how it should be. Though as I remember there were some scale/position issues originally. Not sure if that is something that can be easily fixed with out causing issues else where.

Oh, on a positive note, everything wasn't super huge like before, at least not with this import. I haven't tried other parts yet.

FZIRsEz.jpg

Update: I imported the tests I did a while back for SCANsat, Remote Tech, and Kethane. They all imported, for the most part, except for the notes below:

  • Remote Tech: Some stuff wouldn't deploy, the gigadish had no dish, although I did find some part of it when i unhid everything. One of the antenna (the one that extends out on a scissor type truss) only part of it would deploy. The scissor truss was there, but didn't seem to want to deploy. The scale for the most part all seemed to be correct though.
  • ScanSat: Of the two scanners that imported (visible anyway), one of the scanners was bigger than it should be and the other was smaller. The SAR scanner I think is, was missing, it had an empty for it though.
  • Kethane: The two drills imported super huge, but the rest of the parts seemed to come in fine.

Of course, I guess the scaling problems, and well all these problems really, are more to do with the configs of the parts and not really a problem with the importer. The scale issue is easily fixed on my side by selecting the part (and using the K menu to select all of the part) and resizing it as needed. The deploy states not working is a little trickier, but I guess they could be delt with. At least they seemed to import for the most part, and all with out me having to add to the part directory :)

Edited by Sma
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...