Live Chat

Lugaru Model Import / Export scripts for Blender

The place to discuss all things Lugaru.

Lugaru Model Import / Export scripts for Blender

Postby rudel_ic » Tue Nov 03, 2009 8:56 pm

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.
Last edited by rudel_ic on Thu Jan 08, 2015 8:14 am, edited 4 times in total.
User avatar
rudel_ic
official Wolfire heckler
 
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City

Re: Lugaru Model Import / Export scripts for Blender

Postby rudel_ic » Tue Nov 03, 2009 8:58 pm

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.
User avatar
rudel_ic
official Wolfire heckler
 
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City

Re: Lugaru Model Import / Export scripts for Blender

Postby rudel_ic » Tue Nov 03, 2009 10:29 pm

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 697 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.
User avatar
rudel_ic
official Wolfire heckler
 
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City

Re: Lugaru Model Import / Export scripts for Blender

Postby Lotus Wolf » Tue Nov 03, 2009 10:55 pm

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 20151 times
Attachments
Morphoid.zip
Here he is if you want to play with him.
(126.91 KiB) Downloaded 623 times
User avatar
Lotus Wolf
 
Posts: 2218
Joined: Sun Aug 31, 2008 6:03 pm

Re: Lugaru Model Import / Export scripts for Blender

Postby Precastwig » Thu Nov 05, 2009 11:05 am

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?
Precastwig
 
Posts: 157
Joined: Sat Oct 31, 2009 6:27 pm

Re: Lugaru Model Import / Export scripts for Blender

Postby Lotus Wolf » Thu Nov 05, 2009 1:50 pm

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.........
User avatar
Lotus Wolf
 
Posts: 2218
Joined: Sun Aug 31, 2008 6:03 pm

Re: Lugaru Model Import / Export scripts for Blender

Postby rudel_ic » Thu Nov 05, 2009 2:13 pm

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.
Last edited by rudel_ic on Thu Nov 05, 2009 3:00 pm, edited 1 time in total.
User avatar
rudel_ic
official Wolfire heckler
 
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City

Re: Lugaru Model Import / Export scripts for Blender

Postby rudel_ic » Thu Nov 05, 2009 2:51 pm

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.
User avatar
rudel_ic
official Wolfire heckler
 
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City

Re: Lugaru Model Import / Export scripts for Blender

Postby Precastwig » Thu Nov 05, 2009 5:48 pm

It now has the same error for the 'except:'
heres what i have:
Picture 1.png
What i've put instead of finally:
Precastwig
 
Posts: 157
Joined: Sat Oct 31, 2009 6:27 pm

Re: Lugaru Model Import / Export scripts for Blender

Postby Lotus Wolf » Thu Nov 05, 2009 6:15 pm

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.
User avatar
Lotus Wolf
 
Posts: 2218
Joined: Sun Aug 31, 2008 6:03 pm

Re: Lugaru Model Import / Export scripts for Blender

Postby rudel_ic » Thu Nov 05, 2009 6:23 pm

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 20115 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.
User avatar
rudel_ic
official Wolfire heckler
 
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City

Re: Lugaru Model Import / Export scripts for Blender

Postby Precastwig » Fri Nov 06, 2009 4:02 pm

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 20095 times
Precastwig
 
Posts: 157
Joined: Sat Oct 31, 2009 6:27 pm

Re: Lugaru Model Import / Export scripts for Blender

Postby rudel_ic » Fri Nov 06, 2009 5:04 pm

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
User avatar
rudel_ic
official Wolfire heckler
 
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City

Re: Lugaru Model Import / Export scripts for Blender

Postby Precastwig » Fri Nov 06, 2009 6:15 pm

OMG it works, it's like christmas a month early...
you my friend, are a genius.
Precastwig
 
Posts: 157
Joined: Sat Oct 31, 2009 6:27 pm

Re: Lugaru Model Import / Export scripts for Blender

Postby rudel_ic » Fri Nov 06, 2009 7:14 pm

It's a pleasure mate, I'm happy you can use it!
User avatar
rudel_ic
official Wolfire heckler
 
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City

Next

Return to Lugaru

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group cron