Page 1 of 5

Lugaru Model Import / Export scripts for Blender

Posted: Tue Nov 03, 2009 8:56 pm
by rudel_ic
Hi,

I just finished an importer and an exporter for Blender.

These two scripts are written in Python, and Blender can use them directly. Once they're in the proper directory, you can access them via the File -> Import / File -> Export menus from inside Blender.

You can get the scripts in a ZIP archive right here: viewtopic.php?f=7&t=5620&p=232622#p232622
(Used to be http://www.alice-dsl.net/wolf.mathwig/tools/py/ -- not anymore though)

Make sure you read the instructions on that site carefully. For Blender 2.49, you HAVE to install Python. You HAVE to place the scripts into the proper directory after unzipping the archive, this differs by Blender version. For 2.58, it's Blender's addons folder.

The scripts are self-explanatory, but I'll tell you how you're supposed to use them anyway:

Importer

You select the menu point File -> Import -> Lugaru models (.solid)...
You choose what type of model you want to import: Body, Weapon or Immobile
You choose the file from your disk, press the button "Import Solid"
Done
Blender 2.49: If you want to import more models, do that. Otherwise, click the button "Exit"

Exporter

You select one or more models in Object mode (Blender 2.58: Only one model per export!)
Make sure they've only got triangle faces and that they have some kind of UV map
You select the menu point File -> Export -> Lugaru models (.solid)...
Blender 2.49: You read the text. You understand what it says.
You select what type of model you want to export: Body, Weapon or Immobile
You choose the filename, press the button "Export Solid"
Done
Blender 2.49: If you want to export the selected models again for some reason, do that. Otherwise, click the button "Exit"

Please backup your Lugaru/Data folder BEFORE replacing models.

If there's something weird happening or if you have problems installing / using these scripts, post away. Random nerd posts are also welcome.

Blender 2.49: Note that this is opensource. So if you want to tinker with the source code, go ahead, it's right there. Python scripts aren't compiled in some way, and the language is one of the simplest languages around in terms of syntax.

Blender 2.58: The scripts are now GPL.

Have fun with that stuff.

Doesn't work with Black Shades, by the way. Black Shades has no texture mapping on SOLID models or something along those lines.

Re: Lugaru Model Import / Export scripts for Blender

Posted: Tue Nov 03, 2009 8:58 pm
by rudel_ic
If you need help in all things modeling, then go to the Blender wiki. If you need specific hints regarding modeling for Lugaru, read these:
viewtopic.php?f=7&t=5474
viewtopic.php?f=7&t=5246#p86391

Of course, for these scripts, you should disregard all instructions that are related to Brainfart.

Re: Lugaru Model Import / Export scripts for Blender

Posted: Tue Nov 03, 2009 10:29 pm
by rudel_ic
Image

WATUP DAWG

:lol:

Obviously, you _CAN_ replace Body.solid and it works, at least with this script. I think I simply messed stuff up in Brainfart.

What you want to do is import Body.solid, then just move vertices / faces, rotate them, scale them.

Do not introduce new faces or vertices, do not remove old vertices or faces. The number of faces and vertices has to stay the same.

Don't go too wild though. You want to keep the hands at the same place so that the weapons grab correctly; you want to keep the body shaped in such a way that holstered weapons still connect; you want to keep the feet touching the ground at the same point (don't move the lowest vertices).

For a convenient editing view, press CTRL-NUM7.

When you're done, export the misformed abomination to solid, backup Body.solid, Body2.solid etc.

Overwrite Body.solid - Body6.solid with your new creation. No morphing, nothing. Awesome!

You don't want to replace Body7.solid though. That's the one with the exploded head.

You might also want to adjust the UV mapping and textures.

You can also edit Bodylow.solid in exactly the same way (that's the mesh for low Level of Detail).

Have fun making new dudes.

Edit: Here's the ant guy you can see above.
ant.zip
The body mesh you can see above.
It's just a proof-of-concept, not awesome by any means
(133.06 KiB) Downloaded 935 times
Unzip that to Data/Models. You'll get a new folder called "ant".
Backup Body.solid, Body2.solid, Body3.solid, Body4.solid, Body5.solid, Body6.solid, Body7.solid and Bodylow.solid.
Copy all files in Data/Models/ant/ to Data/Models, overwriting the original files.

Re: Lugaru Model Import / Export scripts for Blender

Posted: Tue Nov 03, 2009 10:55 pm
by Lotus Wolf
Very nice, rudel! They work great! To get an idea of the scale (DimX) of weapons, the original sword has a scale of 0.858. Remember this is the length of your weapon, not width or thickness. Importing a solid then exporting it creates no errors, so feel free to open up any of my models to get an idea of the scale, or for any other reason. (It would be cool if the got used somewhere else, just give me credit :) )

Edit: I still think I'll wait for characters to be fully implemented before I mess with them, but I'd still be on the lookout for a tweak or two.
Morphoid.jpg
Testing the Body export function. A simple change applied to all the separate body*.solids to conserve the interpolation animations. (Simply using the same model for all the body files removes the open/close of mouths and eyes, and the characters ears will never move.)
Morphoid.jpg (170.83 KiB) Viewed 29039 times

Re: Lugaru Model Import / Export scripts for Blender

Posted: Thu Nov 05, 2009 11:05 am
by Precastwig
Hey, i have a mac osx ppc running blender 249.2 and python 2.3, i've put the folders in and the importer works fine. but when i try to run the exporter, just run the script. it says error, and directs me to were it says
finally:
It highlights it, is something wrong?

Re: Lugaru Model Import / Export scripts for Blender

Posted: Thu Nov 05, 2009 1:50 pm
by Lotus Wolf
for blender 2.8 and up you need python 2.5 or 2.6 you can install both if you like, that's what I've done. The scripts probably need 2.5 or 2.6 to run. 2.3 is old.........

Re: Lugaru Model Import / Export scripts for Blender

Posted: Thu Nov 05, 2009 2:13 pm
by rudel_ic
Precastwig wrote:Hey, i have a mac osx ppc running blender 249.2 and python 2.3, i've put the folders in and the importer works fine. but when i try to run the exporter, just run the script. it says error, and directs me to were it says
finally:
It highlights it, is something wrong?
The Blender console should contain a more descriptive error message, please post that.
Edit: Don't bother, I found the issue, read next post :)

Not the issue:
Usually, what's wrong is that you either didn't convert all faces to triangles or that you forgot to generate a UV map.

You convert all faces to triangles by pressing CTRL-T in Edit Mode when all faces are selected.
You can also do this by pressing SPACE in the editing window, then choosing Edit -> Faces -> Convert to Triangles

You generate a UV map by pressing U in Edit Mode when all faces are selected, then you choose some unwrapping method. You can see how the unwrapping ends up by opening a UV/Image View while in Edit mode.


Apart from these hints, Lotus Wolf is certainly right in saying that Python 2.3 is rather outdated.
Maybe exception handling with try: except: finally: doesn't work in your Python version, in which case you (or I) can edit the source to not contain exception handling. If you don't know Python though, I recommend not to do that.
Edit: See the next post to find out how to do it. I may put this into the next release myself.

Ignore this:
It would be really cool if you tried tackling this with following my first suggestion, then updating Python if that's not the issue. I'd love to know how you resolve this so that I can fix stuff for Python 2.3 dudes; although 2.3 is old, I'd happily make the script work for it, obviously.

Edit: Also, thanks for trying to do things with this! I really need PowerPC people to test it out; the reason is that I don't have one myself.

Re: Lugaru Model Import / Export scripts for Blender

Posted: Thu Nov 05, 2009 2:51 pm
by rudel_ic
Alright, I found out why this error occurs. It's not your fault!

http://python.active-venture.com/ref/try.html

So I guess I can't mix try: except: with finally: under Python 2.3.

You can easily fix that issue yourself, by the way.
All you have to do is remove the finally:
Then, copy the self.file.close() into the except: block, over the raise thing.
Then, remove a tab before the old self.file.close()

This should emulate the finally: behavior.

So the source looks like this afterwards:

Code: Select all

		except:
			self.file.close()
			raise
		self.file.close()
You need to overwrite the script. Save it over the original.
Then, you can restart Blender and it should just work.

Hope this helps.

Re: Lugaru Model Import / Export scripts for Blender

Posted: Thu Nov 05, 2009 5:48 pm
by Precastwig
It now has the same error for the 'except:'
heres what i have:
Picture 1.png
What i've put instead of finally:

Re: Lugaru Model Import / Export scripts for Blender

Posted: Thu Nov 05, 2009 6:15 pm
by Lotus Wolf
rudel_ic wrote:Usually, what's wrong is that you either didn't convert all faces to triangles or that you forgot to generate a UV map.
Not triangulating the model doesn't make the script mess up, it show up in game with what looks like the mesh with half of the would-be triangles missing.

Re: Lugaru Model Import / Export scripts for Blender

Posted: Thu Nov 05, 2009 6:23 pm
by rudel_ic
Precastwig wrote:It now has the same error for the 'except:'
heres what i have:
The attachment Picture 1.png is no longer available
Well, this is how I meant it:
meant.png
meant.png (4.17 KiB) Viewed 29003 times
The tabs are important.
Lotus Wolf wrote: Not triangulating the model doesn't make the script mess up, it show up in game with what looks like the mesh with half of the would-be triangles missing.
Ah right, that makes sense.

Re: Lugaru Model Import / Export scripts for Blender

Posted: Fri Nov 06, 2009 4:02 pm
by Precastwig
Thank you,
But anyway. I've done that, its come up with ANOTHER error slightly lower, same error.
Picture 2.png
Here's the highlighted error
Picture 2.png (9.09 KiB) Viewed 28983 times

Re: Lugaru Model Import / Export scripts for Blender

Posted: Fri Nov 06, 2009 5:04 pm
by rudel_ic
Precastwig wrote:Thank you,
But anyway. I've done that, its come up with ANOTHER error slightly lower, same error.
Picture 2.png
That one looks easy at first glance. Seems like we're almost there :)

Here's the quick fix:
Image

Re: Lugaru Model Import / Export scripts for Blender

Posted: Fri Nov 06, 2009 6:15 pm
by Precastwig
OMG it works, it's like christmas a month early...
you my friend, are a genius.

Re: Lugaru Model Import / Export scripts for Blender

Posted: Fri Nov 06, 2009 7:14 pm
by rudel_ic
It's a pleasure mate, I'm happy you can use it!