Blender export script

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Guest

Blender export script

Post by Guest »

For those who prefer eye candy and ease of use, I uploaded a blender script version ogreexport-0.8.py which has a graphical user interface. Please report any problems.

Regards,
Michael

[ 815849 ] Blender export script updated
https://sourceforge.net/tracker/index.p ... tid=302997

Known issue: In the current blender release (2.31a) the Draw.Scrollbar button from blenders python interface is broken. You therefore may have to resize the export window to fit the dictionary for animation renaming.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Thanks mate!

Blender users, please get testing. I can't make head nor tail of the product myself ;)
User avatar
iovsal
Kobold
Posts: 33
Joined: Sun Mar 30, 2003 3:20 pm
Location: Finland

Post by iovsal »

That's a great job, from the beginning. Honestly the GUI is nice and ok, but it was hard to make it simpler than it was! :-)

There's something probably wrong, or I'm missing something, don't know: some faces aren't translated in the exporting process. In the log i get some "ignored face with 2 edges" messages, but there are few of them, while the faces not being created at all are quite more. This is something I noticed in the previous version too. If you find it necessary I'll provide you some screenshots.

_jones
reimpell

missing faces

Post by reimpell »

iovsal wrote:some faces aren't translated in the exporting process. In the log i get some "ignored face with 2 edges" messages, but there are few of them, while the faces not being created at all are quite more.
AFAIK the ogre format only allows for faces with 3 or 4 vertices, so does the exporter.

Workaround:

Faces with only 2 edges aren't really faces, so try to remove them with the "Remove Doubles" option with an appropriate limit setting.

Triangulize your mesh if you also got a warning about faces with more than 4 edges: In "edit mode" select all vertices and choose
Edit->Faces->Convert to Triangles (Ctrl+T).

You may need to assign a dummy material to all faces even if it has a texture assigned to it, but I'm not sure about that.

Only textures assigned in the "UV-Face Select" mode are exported.

Hope that helps,
Michael
reimpell

Blender export script

Post by reimpell »

Blender 2.32 menu integration is supported by ogreexport-0.9.py.

Regards,
Michael

[ 815849 ] Blender export script updated
https://sourceforge.net/tracker/index.p ... tid=302997
User avatar
iovsal
Kobold
Posts: 33
Joined: Sun Mar 30, 2003 3:20 pm
Location: Finland

Post by iovsal »

Great job, i will check better for that problem.
I'd suggest you two changes:

1) According to recent OGRE modification, i'd line 414 from:

Code: Select all

self.v = v
to:

Code: Select all

self.v = -v
2) Since all the .material files are supposed to be in the same directory (usualle the Media/ dir of one's project) i'd remove the full path of the material leaving only the material name, which OGRE can find thank to resources.cfg. My personal solution has been to change line 1214 from:

Code: Select all

f.write(tab(2)+"texture %s\n" % material.texture)
to:

Code: Select all

f.write(tab(2)+"texture %s\n" % string.replace(material.texture, "/path/to/your/textures/", ""))
Obviously this assumes that all your textures are in the same dir when you loaded them into your blender file. And you could of course replace the string "/path/to/your/textures/" with a variable to which an user could assign the proper value via a GUI element.
I find this much better than having to edit the .material file at the end.

Greetings, _jones
reimpell

missing faces

Post by reimpell »

Well, of course "Remove Doubles" does only work if the 2 edges of the "face" are nearby. Otherwise you must remove them by hand. To find unusual normals and needless edges/faces it often helps to use the SubSurf Mesh option: You get strange artefacts if something is wrong.
iovsal wrote: 1) According to recent OGRE modification, i'd line 414 from:

Code: Select all

self.v = v
to:

Code: Select all

self.v = -v
Another possible reason why there are vanishing faces is, that the normals of these faces point in the wrong direction. Maybe a simple Mesh->Normals->Recalculate outside (Ctrl+N) does help. Does it also correct the UV mapping?
iovsal wrote: 2) Since all the .material files are supposed to be in the same directory (usualle the Media/ dir of one's project) i'd remove the full path of the material leaving only the material name, which OGRE can find thank to resources.cfg.
I totally agree with that one.

Regards,
Michael
reimpell

UV mapping

Post by reimpell »

iovsal wrote: 1) According to recent OGRE modification, i'd line 414 from:

Code: Select all

self.v = v
to:

Code: Select all

self.v = -v
I just saw the "Change in 'v' texture coordinate origin in 0.13" announcement. Well, what about

Code: Select all

self.v = (1 - v)
as sinbad's post suggest?

Regards,
Michael
User avatar
iovsal
Kobold
Posts: 33
Joined: Sun Mar 30, 2003 3:20 pm
Location: Finland

Post by iovsal »

About my point number 1, it didn't concern my problem with faces, but a recent Ogre modification which flipped the V coordinate, so to fix it one should apply that change. Otherwise all the textures will be upside down.
User avatar
iovsal
Kobold
Posts: 33
Joined: Sun Mar 30, 2003 3:20 pm
Location: Finland

Post by iovsal »

Sorry, you just posted a minute before me :-)

Anyways, i think that

Code: Select all

self.v = (1-v)
could work as well.

Code: Select all

self.v = -v
works for me, so it's supposed to be ok.

_jones
reimpell

UV mapping

Post by reimpell »

iovsal wrote:

Code: Select all

self.v = -v
works for me, so it's supposed to be ok.
Well, looking at line 920pp:

Code: Select all

    if submesh.material.texture:
      uv = [face.uv[i][0], face.uv[i][1]]

      if not vertex.uvmaps:
        vertex.uvmaps.append(UVMap(*uv))
      elif (vertex.uvmaps[0].u != uv[0]) or (vertex.uvmaps[0].v != uv[1]):
        # the vertex in blender has different uv maps for each face
        # we need to clone the vertex for each uv coordinate
you may get some unnecessary vertex clones this way. We should change

Code: Select all

    uv = [face.uv[i][0], face.uv[i][1]]
to

Code: Select all

    uv = [face.uv[i][0],(1 -  face.uv[i][1])]
instead.

Regards,
Michael
User avatar
iovsal
Kobold
Posts: 33
Joined: Sun Mar 30, 2003 3:20 pm
Location: Finland

Post by iovsal »

Actually that doesnt work, meaning that it voids the effects of the first change. It flips back the textures along y axis, driving them upside down again.
reimpell

UV mapping

Post by reimpell »

iovsal wrote:it voids the effects of the first change.
It was supposed to replace the first change, since changing the UVMap constructor may lead to unwanted vertex clones. Also v -> 1 - v and v -> -v has the same effect as long as the texture is treated with periodic boundary conditions. Since I am not willing to read specifications of Ogre, OpenGL and DirectX to ensure this behaviour, I just take sinbad's words for granted. ;)

By the way, last night I wrote a replacement class for blenders broken scrollbar. It will be in the next version. Having a scrollbar I will also display the export log in the message window that appears at the end of the export process. The texture path dictionary you proposed probably won't make it into the next version since I am not quite sure about implementation details: At the moment, it is no problem to change your selection while the gui is shown. Of course, the used textures highly depend on your selection, but checking for selction changes in every update cycle may lead to poor performance.

Regards,
Michael
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

v = (1-v) is the correct version, because v = -v will not work correctly if your mesh is designed to use clamped texture coordinates (-v means that all values get clamped to 0, which means solid-colour land). 1-v works correctly in all cases.
reimpell

ogreexport-0.10.py

Post by reimpell »

ogreexport-0.10.py is now available!

The blender python interface is a somewhat moving target but I try to catch up. This release has all features I thought of in the first place.

Some additional notes:

ogrenew/Docs/Readme/Readme_Features.html should change:
<Blender3D (meshes)
>Blender (meshes and animation)

Should I write a 4.1 Exporters subsection for the manual? I though of a short explanation of the interface, maybe with one or two nice screenshots.

Regards,
Michael

[ 815849 ] Blender export script updated
https://sourceforge.net/tracker/index.p ... tid=302997
reimpell

ogreexport-0.11.py

Post by reimpell »

ogreexport-0.11.py is now available!

It supports the new material script schema. I noticed that the "Prebuilt exporters" version 0.13.0a still have the old blender export script. Due to some changes in the blender python interface, the old script version 0.7 will not work with blender version 2.32. Therefore it would be nice if someone could just check in the new version and commit the following changes to the manual.

ogrenew/Docs/Readme/Readme_Features.html:
<Blender3D (meshes)
>Blender (meshes and animation)

Thanks,
Michael
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Thanks, I've committed this (and the doc update).
reimpell

Plans for ogreexport-0.12.py

Post by reimpell »

sinbad wrote:I've committed this (and the doc update).
Thank you!

In ogreexport-0.12 the way multiple animations are treated will be enhanced. It will be possible to export keyframe ranges to different animations in the same way blender's action actuators work. Therefore you can easily export baked actions (actions with constraints). Of course the old way of exporting multiple animations will still work, too.
After that, I will write the exporter documentation with a blender modelling and animation guide.

Regards,
Michael
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Sounds great mate, maybe I should have another crack at learning how to use Blender ;)
User avatar
cTh
Halfling
Posts: 81
Joined: Wed Dec 11, 2002 10:47 am
Location: Moscow/Russia

Post by cTh »

sinbad wrote:Sounds great mate, maybe I should have another crack at learning how to use Blender ;)
Just what I thought of when reading this up ;)

Blender is sure a good tool, but the only think keeping me away from it is it's, to me, strange and non intuitive user interface, and I must admit that I would like to use it.
reimpell

ogreexport-0.12.py

Post by reimpell »

ogreexport-0.12.py is now available!

Don't be confused by its version number: It is intended for the latest ogre version. As indicated in my previous post, you can now export animations based on frame ranges. Also new: You can toggle the material color (ambient, diffuse, specular and emissive) with the material TexFace mode button on and off. This way you can combine uv textures with the material modes Shadeless, ZInvert, Env and No Mist and mix pure textures and materials within the same mesh.

Sinbad, since this update enhances the flexibility of the exporter it would be nice if you could do just another check-in.

Thanks,
Michael

[ 815849 ] Blender export script updated
https://sourceforge.net/tracker/index.p ... tid=302997
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Thanks, I've committed this.
MMind
Gnoblar
Posts: 10
Joined: Tue Jan 20, 2004 6:05 pm
Location: Dresden / Saxony / Germany

Post by MMind »

cTh wrote:Blender is sure a good tool, but the only think keeping me away from it is it's, to me, strange and non intuitive user interface, and I must admit that I would like to use it.
I don't think Blender is non intuitive, just different :-)
Blender has it's own ways and quirks.
Myself I have just started the 3D-thingie ... so I'm new to any modeler and if you haven't touched any modeler before, you won't notice any difference :-)
A few days ago, I got to take a look on 3DS and it seems much more complicated to me, simply because it uses a different approach to the user interface :-)
Blender has a wonderful beginners tutorial where you model and texture a cake man ... I just started with that as it introduced many functions (including their keys) of Blender-every-day-use.
Last night I began modelling a bus for my game project, after some mistakes on my side, I have now an outline of the side view and can now extrude it and complete it.
Short: I think Blender is a wonderful program with lots of potential, if one can get himself to adapt to Blenders interface
User avatar
cTh
Halfling
Posts: 81
Joined: Wed Dec 11, 2002 10:47 am
Location: Moscow/Russia

Post by cTh »

Well, I'm pretty used to MAX, that's my prob., I use it back from the old DOS version, was 3DStudio then ;)
reimpell

BlenderExport-0.12.1.tar.gz

Post by reimpell »

For those who always wanted to know what these funny buttons of the exporter are all about, you can read it in the documentation. The documentation will also give you a clue, which of Blender's material and face settings take effect in Ogre. Check out BlenderExport-0.12.1.tar.gz. In the next version you will be able to save and load your exporter settings.

Regards,
Michael

[ 815849 ] Blender export script updated
https://sourceforge.net/tracker/index.p ... tid=302997