Latest Blender Export Script [Wed Aug 25, 2010 - v1.4]

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
User avatar
Jabberwocky
OGRE Moderator
OGRE Moderator
Posts: 2819
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada
x 218

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by Jabberwocky »

I'm not aware of any way to export partial animations. I'm pretty sure Ogre does not have the capability to handle anything like that. You need to use BoneBlendMasks.
Image
User avatar
Jason Rogers
Kobold
Posts: 32
Joined: Fri Apr 09, 2010 8:10 am

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by Jason Rogers »

Hi guys/gals, just wondering if anyone has made/started to make a script to work with Blender 2.5x yet? or is it still too early? :D

I would use 2.49 but im so used to the 2.5 that it makes my head hurt just looking at the old interface :oops:

Thanks for any info in advance! im in no rush, i still have a lot of modelling to do - trying to make a demo MMO RPG example on my own, fun fun! :)
<MetalPig> a world without undo-redo is a world I dont want to live in.
<JayRogers> wish reality had an undo function.. the redo function seems to be working fine though, i can screw up as many times as i want.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 116

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by mkultra333 »

I've just started using the exporter.

The way I work is to assign UVs to my mesh and then export with a temp material, I work on the real material later outside of blender. I'm using the "Game Engine Materials" option. I just need the material name and material file to be a basic stub, as long as it has the correct name.

One thing that isn't working as I'd like is the exported material file and the material name inside the xml file. I've entered the name "rocket.material" in the "Export Materials" box, and it does output a file called "rocket.material" However inside that material the name is still the temp texture I've applied (a generic callibartion texture I use for everything.)

So what I get is a file named "rocket.material" but a material within that file called "material SOLID/TEX/_texcal.bmp"
And the material name in the "rocket.mesh.xml" file isn't "rocket.material" but "material SOLID/TEX/_texcal.bmp"

This is inconvienient, since I now either have to constuct a bunch of blender materials I never use, or edit the xml files before converting them to mesh manually instead of allowing the script to run the conversion automatically.

For the time being I've decided I'll create a modified version of OgreXmlConverter that ignores the xml material name and generates the name I want. But in future it'd be really handy if the script could be forced to output the desired material name.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 116

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by mkultra333 »

I was thinking, an easy way to achieve what I need would be to have an extra option next to "Rendering Materials," "Game Engine Materials" and "Custom Materials"

The new option would be "Stub Materials." It would output the material name for each submesh as that submesh's name, perhaps with an option additional material path to prefix it.

For instance, I have a rocket object with two meshes, "body" and "fins". If I select "Stub Materials" then the output material names within the material file and xml file would be "body" and "fins". If I had set the optiona prefix to "martian/transports" then the materials would be "martian/transports/body" and "martian/transports/fins"

I don't think this would be very complicated to add, I'd do it myself but I don't really understand python very well. Anyhow, just a thought, something that would be handy for me and maybe others.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by lf3thn4d »

@ Jason Rogers: No, it's not ready yet. Still too early. Sorry. ;)
@ mkultra333: Sounds pretty sane to me. We could do that. :) I'm currently quite busy myself. I haven't even gotten myself to get the mercurial branch. Sigh.. At any rate, do give it a go if you can. That will definitely push me to get mercurial branch going. :-P
User avatar
Jason Rogers
Kobold
Posts: 32
Joined: Fri Apr 09, 2010 8:10 am

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by Jason Rogers »

Thankyou for the response lf3thn4d :) it will be a few months before i have enough models to use - or at least ones that i am happy with anyway :P hehe
<MetalPig> a world without undo-redo is a world I dont want to live in.
<JayRogers> wish reality had an undo function.. the redo function seems to be working fine though, i can screw up as many times as i want.
User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm
x 13

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by koirat »

Since I'm using this exporter extensively I would like to share some of my new thoughts about improvement that can be made. It's about "Custom Material" templates.

What we got right now is file *.tpl that defines some template for our materials, but it would be very useful to be able to specify multiple material templates inside one *.tpl file. This additional templates would be a fallback templates if conditions where not solved (for example missing texture). I had this real-life :) problem when I was doing my level with lightmap (sometimes I wanted to check how it looks without generated lightmap) or with normal mapping sometimes I was using NM and sometimes I was disabling it. I was forced to edit my material PropertyID every time, i don't have to mention how prone to error such a messing is.

[edit]
Last thing,(less important) that was bothering me were textures generated inside blender. As I know you can't export them with "Copy Textures" until you save them.
[/edit]
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by lf3thn4d »

@Jason Rogers: you're welcome. :-) I will announce when I start working on the blender 2.5 exporter.
@koirat: I share your pain in that problem. However your suggestion is not a simple fix. Template fallback is not a simple task especially since I'm using python's build-in template string replacement module. To allow more complex template as suggested, we would probably need to write our own template replacement system. Personally, my wish is to provide more advance templating with minimal scripting capability to build logic blocks. We probably need to look into some third party python template modules to achieve more complexity.
User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm
x 13

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by koirat »

First of all I highly appreciate all the work (thousands of python code lines) you put into this project. So I feel a little :oops: when writing about new requests.
But since I took some effort to read through your material resolver code and if I understood it correctly I would like to ask for your opinion about following solution to this problem.

1. Split *.tpl file into single material template chunks. (this can be done by regular expressions [the hard way :)] or by introducing additional info to *.tpl file something like "<<<----SPLIT_POINT---->>>" between consecutive material templates)

2. Take first chunk and feed it with your material parser. (just like you do it now)

3. Check parsed chunk, if it contains "%" sign, parsing was not successful, go to next chunk, else write this material.
(I assume "%" is reserved character used only for material template)



I'm kind of obliged to help you with this one after all the pressure I have put on you :P. So if you need additional keyboard :wink: I would gladly help you improve your exporter. My experience with Python is about 60 hours of sweat and swearing when trying to finish HL2 model with animation exporter for blender (I failed because of different handedness), and additional hours of swearing when playing with Regular Expressions.
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by lf3thn4d »

koirat wrote: 1. Split *.tpl file into single material template chunks. (this can be done by regular expressions [the hard way :)] or by introducing additional info to *.tpl file something like "<<<----SPLIT_POINT---->>>" between consecutive material templates)

2. Take first chunk and feed it with your material parser. (just like you do it now)

3. Check parsed chunk, if it contains "%" sign, parsing was not successful, go to next chunk, else write this material.
(I assume "%" is reserved character used only for material template)
Your suggestion is mostly sound. Though I'm a bit weary about hard wiring it this way. This only allows cases when users want to have a simple fallback mechanism. However if we provide a more complex templating solution like I mentioned before, it would render this method redundant. Personally I like it to be as dynamic as possible. Give more power to the user so they can do as they pleased. :-)
koirat wrote: I'm kind of obliged to help you with this one after all the pressure I have put on you :P. So if you need additional keyboard :wink: I would gladly help you improve your exporter. My experience with Python is about 60 hours of sweat and swearing when trying to finish HL2 model with animation exporter for blender (I failed because of different handedness), and additional hours of swearing when playing with Regular Expressions.
Thanks. :-) I'm always open for additional help. Though I think we should nail this part down with a better flexible solution first.

Me thinks we need an idea list and approved todo list in the wiki page so things don't get lost. Especially since I'm rather busy these days, I might forget about something I promised to do. :-P
gareth
Gnoblar
Posts: 2
Joined: Sun May 23, 2010 9:24 pm

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by gareth »

I was wondering if anyone has modified the script to work with args instead of the gui? I want to write a script to automate the process of converting 100's of meshes.

Thanks,
Gareth
bhain7
Gnoblar
Posts: 2
Joined: Fri May 14, 2010 5:42 pm

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by bhain7 »

I don't know if this has been addressed already, but when you copy textures along with exporting your model, and your textures have spaces in them; it corrects the spaces as underscores for the code, but then the actual textures have no underscores.
dekatrion
Gnoblar
Posts: 1
Joined: Mon May 24, 2010 12:50 am

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by dekatrion »

lf3thn4d wrote: Thanks. :-) I'm always open for additional help. Though I think we should nail this part down with a better flexible solution first.
You might want to look at several Python templating systems listed here: http://wiki.python.org/moin/Templating

Personally, I worked with Django's templating system, its aim is to be simple yet flexible. The others (that I know of) I think are too heavy for your problem.

I don't know how Blender scripts are packaged, specially their dependencies, and if you have to pack everything together, probably the copy-and-paste from Django's source is the better option (although this raises another problem: how modular is the template system inside Django? and how easy is to extract it to be usable, with the less effort possible? I don't know the answers to this).

But I may be wrong and there's a lightweight module in that (extensive) list.

Edit: A little research in that list and there's a single-file, around 100 lines, code snippet that can be used pretty much like PHP works: http://code.activestate.com/recipes/576663/
But this will be requiring the designer to know Python. That's why I recommended Django's template, it was built with designers in mind.
User avatar
merlinblack
Goblin
Posts: 224
Joined: Thu Mar 15, 2007 10:05 am
Location: Sydney, Australia
x 7

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by merlinblack »

I've just been playing around with Blender 2.5 - hacking around with the example "raw" mesh export. Didn't make anything useful, but I had fun. :) It wasn't hard to add a few extra settable parameters in the export UI. Don't know how you'd go about plonking the Ogre logo there however. :P I wonder how much of the current exporter code could be scavenged and hooked into the new API? The custom properties you seem to be able to put on anything might be useful for the exporter too. I'm looking forward to it going beta and beyond - the API documentation is understandably sparse right now.

@l3fthn4d - I'm happy to help with testing, coding, or debugging with a 2.5 version of the exporter when you decide to do one. I guess the 2.49 version will need maintaining for some time too! :|

If anyone is wondering - 2.5 happily co-exists with older versions. Well at least on Linux where I tried it. :wink:
"He'd never realized that, deep down inside, what he really wanted to do was make things go splat."
Terry Pratchett, Reaper Man
Image
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by lf3thn4d »

@dekatrion: Thanks for the advice. :-) I'm currently looking at mako templates. It looks simmilar to Django and is also faster. A thing about exporter I want to maintain is the speed of exporting. Once artists start batch exporting multiple meshes, a non optimal exporter will start to bog down their ability to iterate their works. As for the integration and distribution of this extra module, it's rather ugly right now. The way I see it is that users will have to manually install the template module to their python system. What we could do is to make this optional where when not installed, we will simply use the current crappy template system. Other wise, unless someone smart enough to decouple a good template module and force it into the blender exporter, I don't see how we can effortlessly make it simple for the end users. The next best thing I can think of is to provide some sort of installer that will automatically install the template module.

@merlinblack: Thanks for your willingness to give a hand. Really appreciates it. I will announce in this thread when I start working on 2.5 exporter. Most likely I will try to port some code over if possible. Though I suspect the whole mesh data exporting code might need to go out of the window :-( Due to the new 2.5 data access API. Still, I believe it might be a good thing. A fresh start means a better possibility to build a more robust and optimal exporter. :-) Yes, 2.49 will still need to be maintained. However I do not expect to add anymore massive features once the 2.5 exporter begins development. As for custom properties, I'm using blender's ID-Properties system. It allows scripts to bind user properties to any object; material, mesh, light, scene. This is something where I'm very excited about the next exporter. Being the new blender will have better event system, our exporter UI will be able to capture selection change and update realtime. This means that in theory (I haven't checked yet), when a material is selected, the exporter UI can show the selected material's custom properties for users to edit. This will improve usability as compared to the current cumbersome ID-Property Browser system.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 116

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by mkultra333 »

lf3thn4d wrote: @ mkultra333: Sounds pretty sane to me. We could do that. :) I'm currently quite busy myself. I haven't even gotten myself to get the mercurial branch. Sigh.. At any rate, do give it a go if you can. That will definitely push me to get mercurial branch going. :-P
I gave it a shot, but the double difficulty of understanding someone else's code in a language I don't understand was too tricky. I managed to get the button to appear, but that was about it. Ended up opting for a modified OgreXmlConverter, running it from the exporter with an extra command to manually set the material name. Whole mesh has to have the same material, but it's adequate for now.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
Otherearth
Gnoblar
Posts: 20
Joined: Wed Apr 22, 2009 4:40 pm

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by Otherearth »

Hi,
It's me again from the Otherearth Project.
Your script is awesome and I think I'm doing sth wrong I hope you can help me find what it is.

I am trying to export a fountain with a water texture. I applied mirror and normal effects to the texture so it looks like this in Blender Render:
0001.jpg
But when I now export it to Ogre it looks
1) deformed (edges cut away)
2) water looks just like normal texture picture
OEClient 2010-06-13 19-29-52-99.jpg

What is my mistake? Or isn't the script yet capable of the features?
Btw I just realized that the Blender Game Engine output looks exactly the same as in Ogre so I suppose I did sth wrong...

Thanks for the answer :)
You do not have the required permissions to view the files attached to this post.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by jacmoe »

I am not sure, but it looks as if the normals are inverted?
Could you check the mesh in Blender - show normals.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Otherearth
Gnoblar
Posts: 20
Joined: Wed Apr 22, 2009 4:40 pm

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by Otherearth »

Thanks for the quick reply.
I can't see anything bad, maybe you can:
blender.jpg
You do not have the required permissions to view the files attached to this post.
radsun
Gnoblar
Posts: 4
Joined: Fri Jan 11, 2008 9:18 am

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by radsun »

I found small bug. If i have animated mesh with default animation:

Code: Select all

<animation name="stand" length="0.000000">
</animation>
This will crash xmlConvertex.

Exporter should produce something like this:

Code: Select all

<animation name="stand" length="0.000000">
   <tracks/>
</animation>
I don't think it's hard to fix :)
User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm
x 13

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by koirat »

I have already mentioned this bug few months ago.
It looks like it will stay for a while there :wink:
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 116

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by mkultra333 »

I just noticed something that threw me for an day or so. I had a mesh and skeleton, but the scale and position needed to be changed in the game (I wasn't sure if the game was messing up the position/scale or the problem was with the mesh).

I tried changing the scale and position in Blender but it made no difference. Eventually I realized that any transformations you apply in Object mode in blender don't have any effect on the mesh or skeleton. Everything has to be applied in Edit mode.

Don't know if this is already documented somewhere, don't know if this is intended behaviour, but people making models should be aware of this. Don't apply fix up transformations like scale, rotation and position in Object mode, do them in Edit mode.

And in the spirit of not complaining about the stuff that doesn't work the way I want instead of appreciating the stuff that does, I'll also add that its a great format converter, so thanks for the work that went into it.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
merlinblack
Goblin
Posts: 224
Joined: Thu Mar 15, 2007 10:05 am
Location: Sydney, Australia
x 7

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by merlinblack »

mkultra333 wrote:I tried changing the scale and position in Blender but it made no difference. Eventually I realized that any transformations you apply in Object mode in blender don't have any effect on the mesh or skeleton. Everything has to be applied in Edit mode.
This 'got' me too until I figured out what was happening. Perhaps something to consider in the future for the 2.5 version. But you'd want to be able to turn it on or off, and perhaps be told somehow the mesh was being transformed by the object properties. Otherwise you are back to wondering why your mesh is broken. ;-)
"He'd never realized that, deep down inside, what he really wanted to do was make things go splat."
Terry Pratchett, Reaper Man
Image
User avatar
Sergio10
Halfling
Posts: 48
Joined: Tue Mar 23, 2010 8:31 pm

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by Sergio10 »

HI,

I don't know how exactly to install exporter. :?
According to the first topic:
1. Download python and install: http://www.python.org/download/ (Note: Get v2.6.4. Blender is compiled against v2.6. Hence only this version will work.)
2. Copy the the script and all subdirectories either into ".blender/scripts" or the user defined scripts directory.
3. In the "Scripts Window" run "Scripts → Update Menus".
I've installed Blender 2.49 and python 2.7. But didn't find "scripts" directory in blender folder. Correct?
So I created it and put the exporter files.

What is "Scripts Window"? How to install them?

Thanks
reptor
Ogre Magi
Posts: 1120
Joined: Wed Nov 15, 2006 7:41 pm
Location: Finland
x 5

Re: Latest Blender Export Script [Sun Nov 8, 2009 - v1.3]

Post by reptor »

Blender 2.5 (alpha edit: oh it's beta now, as of today) uses Python 3 which can mean that the scripts have to be modified. Has anyone checked the situation on that yet?