Jump to content

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


Dasoccerguy

Recommended Posts

Well, I tried mucking about with the directory and it seems to be working- partially though. It refuses to import .craft files, and gives me various error messages when I try. I was able to import the Skipper .mu file straight from Squad's Gamedata, although it appeared only partially and way off center. Can someone tell me what I'm doing wrong?

An album of my failure: http://imgur.com/a/PHtyD#0

Link to comment
Share on other sites

It seems that the nozzles of engines are painted white for me... though I haven't grabbed an update in a while. Was this fixed?

I haven't noticed that, though I haven't imported much lately. The poodle engine i think it was in my muncan1-5 video was fine.

Link to comment
Share on other sites

This badly needs a Mac tutorial starting from the beginning. I'm having a lot of trouble, and would sell my soul for a step-by-step guide for OSX. File placement especially- where do I find and paste the directory?

Link to comment
Share on other sites

This badly needs a Mac tutorial starting from the beginning. I'm having a lot of trouble, and would sell my soul for a step-by-step guide for OSX. File placement especially- where do I find and paste the directory?

Is ksp.app the executable or a folder? I don't know the different paths you tried for kspdir.txt, but maybe try this one:

/users/gdoehne/Desktop/KSP 0.90/

Looks like you have the addons in the right place though. Also try using a stock craft first and see if that works.

Link to comment
Share on other sites

Is ksp.app the executable or a folder? I don't know the different paths you tried for kspdir.txt, but maybe try this one:

Code:

/users/gdoehne/Desktop/KSP 0.90/

Looks like you have the addons in the right place though. Also try using a stock craft first and see if that works.

KSP.app is the executable (I assume you mean the actual game) and it's within KSP 0.90, which is a folder. So would it be \\users\\gdoehne\\Desktop\\KSP. 0.90\\KSP.app? It wasn't clear whether to use the two backwards slashes or not, or whether the folder hierarchy was backwards.

Link to comment
Share on other sites

KSP.app is the executable (I assume you mean the actual game) and it's within KSP 0.90, which is a folder. So would it be \\users\\gdoehne\\Desktop\\KSP. 0.90\\KSP.app? It wasn't clear whether to use the two backwards slashes or not, or whether the folder hierarchy was backwards.

That should do it, although you shouldn't need the \\ just a single \ should work, you also shouldn't need ksp.app, as all it needs is the path, because it uses that as the base of where to automatically find the parts.

Originally Dasoccerguy had it setup only for windows which uses \ (i think it had to be doubled because \ is used in the code to designate certain things, and having it double effectively turned it into the normal single \ However on linux and Mac (because it is unix/linux based) they use / which doesn't need the double / or \, just the single / Long story short because I brought this to his attention he was able to write the code so that it would detect whether it was linux/mac or windows.

Long story short again.... try using /users/gdoehne/Desktop/KSP. 0.90 or /users/gdoehne/Desktop/KSP. 0.90/ Not sure if it needs that last one or not.

Once you get it working, you may find that some parts import really big, or really small, or offset. So you might have to manually adjust those. The addon has a menu you can bring up by pushing the K key (think it works the same on all OS). So, like say you want to move/resize landing gear, you can click on part of it, hit the K key, and in the menu that comes up there should be an option to "select all of part" i think, that way you can resize the whole thing. Also another good menu item in that menu is the "toggle deploy" button, which may or may not work on all parts lol.

Good luck :)

Link to comment
Share on other sites

I tried both versions, nothing. The way I'm trying to import the craft is Blender Program -> File -> Import -> KSP Craft (.craft) -> Desktop -> KSP 0.90 -> saves -> KSP Forum- Replicas and Designs (this is the save file) -> Ships -> VAB -> [REPLICA] Soyuz.craft. No matter what .craft I select, it throws up an error message like this one:

9IZd0rN.png

Apologies, Imgur is up to weird stuff the past few days. I'm wondering if a( I need to place the .craft file somewhere else, b( There's a different way to import the craft, c( The directory in kspdir.txt needs some kind of prefix.

Link to comment
Share on other sites

I tried both versions, nothing. The way I'm trying to import the craft is Blender Program -> File -> Import -> KSP Craft (.craft) -> Desktop -> KSP 0.90 -> saves -> KSP Forum- Replicas and Designs (this is the save file) -> Ships -> VAB -> [REPLICA] Soyuz.craft. No matter what .craft I select, it throws up an error message like this one:

http://i.imgur.com/9IZd0rN.png

Apologies, Imgur is up to weird stuff the past few days. I'm wondering if a( I need to place the .craft file somewhere else, b( There's a different way to import the craft, c( The directory in kspdir.txt needs some kind of prefix.

Huh, don't think I've seen an error like that before. From what the error is showing

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1828: ordinal not in range(128)

it seems to me that all your paths are correct. The only thing I can think of is that MAYBE your text file is being saved in a different format/character encoding that the script isn't handling. I don't what text editor you are using but if there is a way to check when you save the file (or in settings) and make sure it is being saved in UTF-8 format (thats what mine uses) and then try it again with one of the folder paths I listed in my previous post.

Update: I tried saving my kspdir.txt with a different format (UTF-2 in this case) and it said it had an error, not the same error as you though. In my case it was a "TypeError: embedded NUL character" Also, another thought I had is, depending on your locale settings for your keyboard, it's might be possible keyboard layout is using a character encoding that some how encodes the slashes differently. So when the script tries to read the kspdir.txt it has that error. Though I think it's still more likely it's the encoding of the file it's self. If you are still having trouble with it, I can try saving a kspdir.txt and upload it somewhere for you to try. Though if you don't trust me to do that I wouldn't blame you lol

Edited by Sma
Link to comment
Share on other sites

No, I trust you! That would be fine. The kspdir.txt is being edited with Textedit. One thing: does the directory in kspdir.txt need some kind of prefix before?

Sent you a PM with a link to the file. Hopefully this does the trick for you. I don't think it needs a prefix, as you can see in your screenshots the path to blender just starts with the /

Link to comment
Share on other sites

That didn't quite do the trick. The kspdir.txt is being saved in the right format. I've also moved both folders from the desktop to the Applications folder. Neither importing a craft file from the Blender add ons folder or from my KSP saves folder has worked. This is the new error message, which I've gotten trying to make things work several times before.

oqzzO1L.png

If it doesn't work soon, I'll sit tight and wait for an updated version or something, you and Dasoccerguy have better things to do than be IT for one guy. Thanks for all the help though!

Link to comment
Share on other sites

That didn't quite do the trick. The kspdir.txt is being saved in the right format. I've also moved both folders from the desktop to the Applications folder. Neither importing a craft file from the Blender add ons folder or from my KSP saves folder has worked. This is the new error message, which I've gotten trying to make things work several times before.

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

If it doesn't work soon, I'll sit tight and wait for an updated version or something, you and Dasoccerguy have better things to do than be IT for one guy. Thanks for all the help though!

Huh, sorry about that. Hopefully someone who knows mac better than me will be able to help you. I did some googling on the file structure in mac and didn't really find much (the /blender.app/ thing keeps throwing me off lol). I mean, it seems as if you have all the paths right to me though, as it is running the python scripts. Maybe it's just some glitch in the addon I guess, or we have the wrong folder some how in the partdir.txt file... lol and it's just not finding the gamedata folder.

Link to comment
Share on other sites

Sorry, I don't have any idea on how to correct problems for Mac users but I have some updates for the add-on:

-If you want to use, the script with B9 crafts you have to comment the lines 'exceptions = make_exceptions()' and 'exceptions_manager(p,rl,exceptions)' at the beginning of part_dict.py in the make_dict function.

The problem was that my piece of code tried to correct the name of B9 part from 'B9_part123' in the .cfg (part file) to 'B9.part123' for the .craft (craft file) (in part_dict.py) and Dasoccerguy tried to correct the name from 'B9.part456' in the .craft to 'B9_part456' for the .cfg (in import_craft.py). So, in the end the script had diffulties matching the name: from a 'B9_part' vs 'B9.part' problem we went to a 'B9.part' vs 'B9_part' problem. :confused:

Here is a quick render of a B9 craft in Blender : http://www.pasteall.org/pic/show.php?id=86598

As you can see, the imported craft needs a bit of clean up since a lot of useless meshes (manually moved to side in the picture) are created during the import process. Use the fix at your own risk. However, we have a hint for you: a lot of these objects have 'proxy' in their name and even better, Dasoccerguy pointed out that these objects don't seem to have a texture or a material.

-I've also been able to correct the part where the make_dict function creates the right_scale dict (not in the current release of the add-on but it was in previous on).

For people who want to test things or know how it works (otherwise you can skip the text between '***'):

***

The problem was that I wasn't paying enough attention to the wiki and right_scale.py from Dasoccerguy. So, I guess RTFM to me.

Here, is how it works now: it still looks for 'rescaleFactor' and 'scale' in the .cfg (but only the one with 'scale = 2,5,9' and not 'scale = 1.3566' the second one is just for the nodes (and it was where I made a mistake)):

rescale_factor __scale

false __________ false -> scale =1.25 (I was also one of my mistakes)

false __________ true -> scale (not sure about that one, should it be scale*1.25 ?)

true __________ false -> rescale_factor

true __________ true -> rescale_fatcor * scale

If you want to try it (not recommended if you are afraid of potential bugs) you can go to https://github.com/Cptmann/ksp_partdic and dowload partdic.py . You then have to copy-paste it in the right folder and rename it to part_dict.py (after making a save of the old one) and change the name of 'make_dict_with_rs' to 'make_dict', remove the other make_dict function and change at the beginning of import_craft.py after the rocket drawing (which is very nice by the way :) ) '[partdir,right_location] = part_dict.make_dict(ksp); rightscale = right_scale.make()' to '[partdir,rightscale,right_location] = part_dict.make_dict(ksp)'.

***

-Finally, you might have some problems with parts that are actually two parts stuck together (two models are indicated the .cfg)

Sorry for the long post.

Edited by Cptman
Link to comment
Share on other sites

I have no clue how to install this. If you could link me to a tutorial that would be great!

I'm very slowly working on a video series for the addon. I have quite a few projects going at the moment, but I'm going to make a push this week before 1.0 rolls out.

For now, the Readme on Github will have to do. Feel free to ask any questions!

Link to comment
Share on other sites

  • 2 weeks later...

I'm having problems too and it seems that it comes from the images.

But it seems (to me) that the problem comes from the .mu importer.

I've quickly checked and the problem might come from the fact that the textures are not in a .mbm file anymore but are .dds now (You can check the full changelog from KSP 1.0).

I've tried modifying a little the io_object_mu addon and it seems to be ok now. Try adding ".dds" in the list wherever ".png" is mentionned in import_mu.py (I think that the addon is checking for a .png or a .tga file (used by modders) when there is no .mbm file (used by Squad), so adding the ".dds" should tell the script to look for the new texture files from Squad )

Also, if you were previously able to import craft from mods they shouldn't be affected by the problem since a lot of them use .png files.

I hope this works.

Edited by Cptman
Link to comment
Share on other sites

Seems the 1.0 update caused all sorts of havoc with the mod. Anyone else experiencing problems? I can't import craft anymore :(

It's working for me on stock craft but the UV (texture) mapping is messed up. Weird offsets like the bottom of fuel tanks showing up on the sides. Probably an easy fix but I'm not familiar enough with Python to suggest how.

- - - Updated - - -

Okay I figured out the issue. All the texture UV's are rotated 180 degrees. Most obvious on things like the Kerbal X craft.

Link to comment
Share on other sites

Hello , Dasoccerguy ! I'm using your great addon for my papercraft project right now , but it seems that the textures are messed up unfortunately ;.; Can you please help me with this problem ?

It seems that the new parts don't work too :(

Edited by arc5555
Link to comment
Share on other sites

For the parts which are not importing you can try the manipulation I described above (only if the addon was working with 0.90 otherwise that's a whole different problem (a problem in the addon itself)). Just make sure to make a copy of the io_import_mu addon before.

The problem with the messed up texture is that they are not rotated correctly like gardocki pointed out. So, you can go select the part and and open a UV editor window and then try to rotate the uv map (a 180° rotation plus sometime a -1 scale on the y axis should do it).

Or you can try something like this:

import bpy

from math import radians

last_area = bpy.context.area.type

bpy.ops.object.editmode_toggle()

bpy.context.area.type = 'IMAGE_EDITOR'

bpy.ops.uv.select_all(action='SELECT')

bpy.ops.transform.rotate(value=radians(180))

bpy.ops.transform.mirror(constraint_axis=(True,False,False))

bpy.ops.object.editmode_toggle()

bpy.context.area.type = last_area

Paste it in the text editor, select the part (the mesh not the green empty made of circles) you want to modify and it 'Run Script'.

The only problem is that it doesn't work with every part (example: the landing gear of the Aeris 3A) and might not be exact.

I hope this work

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