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
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'm afraid he is not quite right.

He was talking about unwrapping with.
"Project from view"
"Project from view (bounds)"
As I assume.

And this is not exactly what I want. But almost this.
First one can do it but you can't get good precision easy with such a way. :? Also two models are not exactly seamless. (And you have to do a lot of work manually when unwrapping)

Second method is resizing uv to bounds so you do not get this feature - that texture size will have the same size in world space.

Anyway after longer thinking it can't be made even by exporter.

My problem is that I have got level that is made of smaller bricks those bricks are all linked to each other so change in one of them makes changes in others. So it's not going to work anyway without a shader.

It's probably a reason they did not make it as a unwrapping feature. But process it when doing rendering.
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
Shockeye
Gremlin
Posts: 154
Joined: Mon Nov 24, 2008 10:34 am
Location: 'Straya
x 1

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

Post by Shockeye »

koirat:
This is very helpful when modeling a level, you are just preparing textures that will represent 1x1 unit exactly.
In my case it will be 1x1 meter and texture 512x512 so you do not have to play with unwrapping since uv cords are taken from coordinates.
This is perfect for making levels with seamless textures/walls.
Try "Cube Projection". That always works for me with level geometry with seamless textures.
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 »

Cube projection is useful.
But somehow it's always making uv different in size than textured face.
Only when face is of length 2 units, its is doing what i want. One to one mapping with a texture.
Make a cube of size 1x1x1 with blender and try to texture it with some square image. And you will see what i'm talking about.
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
Shockeye
Gremlin
Posts: 154
Joined: Mon Nov 24, 2008 10:34 am
Location: 'Straya
x 1

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

Post by Shockeye »

Yeah, you're right. I've only used it with rooms 1unit = 1metre, so because no-one builds houses with 1m high walls, I didn't notice. And changing texture size doesn't help either.
"Project from View(Bounds)" seems to work, but but you have to be in the right view direction, if you're rotated or viewing from camera it doesn't work.
And that's with a cube, not a complex shape, so there's no telling what it would do with anything interesting. You'd have to unwrap one face at a time, I think.

One thing I've just discovered is the "UV Calculation" panel, which I've never noticed before. In Blender 2.49b it is in the edit panel, hiding behind the "Multires" panel. I haven't had a chance to fiddle with it yet, but it seems to allow you to adjust the properties of Cube projection etc.
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 »

lf3thn4d wrote:
sparkprime wrote:
lf3thn4d wrote:@koirat: That's an interesting feature. We could probably add that as a special export feature. However, basing on material option is not a good idea since this is a mesh UV export. What could be done is to have a reserved special naming for the given UV channel that wants this. So when exporter detects the given name, it will export the global position in the UV. Though in practice, if you're already using shaders, you should be just grabbing the vertex coord and feed them as tex coord to the pixel shader. ;)
Can't blender's unwrap already do this? Just aim top down on the meshes in orthographic and map from there?
Yes you are quite right. Though I thought he was meaning 3D UV coordinate with UVW; something blender's UV map doesn't support.
Did you mean, to save this texture UV in multiple texture coordinates on one mesh ? So if i have for example 10 objects on the scene with the same mesh. This imported mesh will have 10 additional texture coordinates. And you will have to chose which one to use in your application ?

@shockey:
Great find.
If you set your cube size to 2.0 than it's working just like I want it to. What's logical given how cube projection is working.
This is a block of text that can be added to posts you make. There is a 255 character limit.
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 »

Today I decided to give it a try with Custom Material templates *.tpl in Blender Exporter.

It is great thing, and I regret not doing it sooner.

As there are always some buts:
The first thing that shocked me was a lack of getting texture file out of index of this texture in a material.
What we got instead is [textureName].texture that is almost useless, if i have to set it manually for all my materials, I can do well without this template.

Adding support for texture index was very easy:
(also I'm not a python beast :) so no comments about coding please :P)

here is modified part of an exporter code

Code: Select all

		textureIndex=0;  <---------------------------------------------------- current texture index
		for mtex in self.material.getTextures():
			if mtex:
				if (mtex.tex.type == Blender.Texture.Types['IMAGE']):
					textureName = mtex.tex.getName()
					name, ext = Blender.sys.splitext(textureName)
					if ext.lstrip('.').isdigit() : textureName = name
					if mtex.tex.getImage():
						textureFilename = self.manager.registerTextureFile(mtex.tex.getImage().getFilename())
						templateDict[textureName + '._texture'] = textureFilename
					if mtex.tex.extend & Blender.Texture.ExtendModes['REPEAT']:
						templateDict[textureName + '._tex_address_mode'] = 'wrap'
					else:
						templateDict[textureName + '._tex_address_mode'] = 'clamp'
					if (mtex.tex.imageFlags & Blender.Texture.ImageFlags['INTERPOL']):
						if (mtex.tex.imageFlags & Blender.Texture.ImageFlags['MIPMAP']):
							templateDict[textureName + '._filtering'] = 'trilinear'
						else:
							templateDict[textureName + '._filtering'] = 'linear linear none'
					else:
						if (mtex.tex.imageFlags & Blender.Texture.ImageFlags['MIPMAP']):
							templateDict[textureName + '._filtering'] = 'bilinear'
						else:
							templateDict[textureName + '._filtering'] = 'none'
					if ((mtex.tex.imageFlags & Blender.Texture.ImageFlags['USEALPHA'])
						and not(mtex.mapto & Blender.Texture.MapTo['ALPHA'])):
						templateDict[textureName + '._colour_op'] = 'alpha_blend'
					else:
						templateDict[textureName + '._colour_op'] = 'modulate'
					templateDict[textureName + '._sizeX'] = "%.6g" % mtex.size[0]
					templateDict[textureName + '._sizeY'] = "%.6g" % mtex.size[1]
					templateDict[textureName + '._sizeZ'] = "%.6g" % mtex.size[2]
					templateDict[textureName + '._offsetX'] = "%.6g" % mtex.ofs[0]
					templateDict[textureName + '._offsetY'] = "%.6g" % mtex.ofs[1]
					templateDict[textureName + '._offsetZ'] = "%.6g" % mtex.ofs[2]

					templateDict['_textureIndex'+str(textureIndex) + '._texture'] = textureFilename <---------------- dictionary stuff
					textureIndex=textureIndex+1 <---------------------- increment textureindex
notice that it only supports _texture


and here is example material template (not exactly valid one):

Code: Select all

#import phong from "phong.material"

material %_materialName : phong
{
		texture %_textureIndex0._texture
		texture %_textureIndex1._texture
}
this can be especially useful when you do stuff with additional textures like normal or specular maps.

What can be done also is adding textures based on regular expression.

for example

Code: Select all

texture %textureNameRegex('here regular expression')._texture 
as i know python got built in regular expressions so it should not be a problem.

But this is less important than something like textureindex - from my perspective this is a must have.

Also reconsider something like default material for material templates. If template not specified.
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 »

Ah.. finally I have someone else who give me feedback on that system. :) I will look into what you are suggesting. I need to go out for a meeting first. Will get back to this later. ;)

[edit]
Ok, I see your point. Good suggestion on the texture index reference. I'll add support for that. As for regular expression, it's possible but I don't really see the point of it.

Anyways, this seems easy enough fix. So I'll try to get this done soon. I'll also make it auto fallback to the default material generator when template is not specified. Thanks for the suggestions! :)
[/edit]
gau_veldt
Gnoblar
Posts: 1
Joined: Thu Mar 04, 2010 7:42 pm

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

Post by gau_veldt »

2.6.2 is no longer available on Python site. Only 2.6.4
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 »

Aiks, that's unfortunate. Can someone try out if python 2.6.4 would work with Blender 2.49b?
hAhni
Gnoblar
Posts: 12
Joined: Fri Apr 01, 2005 10:48 pm

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

Post by hAhni »

lf3thn4d wrote:Aiks, that's unfortunate. Can someone try out if python 2.6.4 would work with Blender 2.49b?
I'm using blender 2.49b with python 2.6.4, seems to work.
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 »

Thanks. :) That's good to know. I'll update the info.
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 »

lf3thn4d wrote: As for regular expression, it's possible but I don't really see the point of it.
We can do fine without it. As I have said before it's not one of the hottest feature.
But it's not useless as you might think it is. It's just a generic way of getting texture by name.
It's very often that graphical files/materials are named with some additional info about it's uses.

for example:
postfix "_nm" or "_nor" for normal mapping.
or "_spc" for specular mapping.

Also some materials in blender might be more complex than this one exported.

Let just say that in blender I have materials A and B
A - diffuse/normal/specular textures
B - diffuse/specular textures

What I need is template for diffuse/specular combination. I'm exporting for lower graphics profile.
I can't use the same template for them if I'm getting textures by index.


About fallback to material generator. It would be nice if we got a possibility to specify default material template.


[edit]
Ok it just came to my mind. This one is a killer :P:
In blender material Textures section we got "Map To"
Where we can specify behavior of a texture "Col" "Nor" "Spec" (and more) thanks to this we know the purpouse of a texture.
In material template we can do
%NorTexture.Texture
%ColTexture.Texture
%SpecTexture.Texture
Let just say that the first texture with specified trait will be chosen.

Or an extensions with indexes example for normal mapping texture:
%NorTexture0.Texture == %NorTexture.Texture
%NorTexture1.Texture
.
.
.
%NorTextureN.Texture
[/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 »

Hmm.. I see how regex can be use. Though it seems to me it becomes a little over generic in a way. It might actually complicate matters. So I'll not look into this first.

Your "Map To" thing is interesting. We could probably do it this way:

Code: Select all

_texMapTo[Col|Nor|Csp|Cmir|Ref|Spec|Amb|Hard|RayMir|Alpha|Emit|TransLu|Disp][#]
where # is the index of textures matching the combination modes.

So one could write:

Code: Select all

_texMapTo[Col][0]._texture
_texMapTo[Col][1]._texture
for a case where we have multi texturing.

Or, in some weird cases:

Code: Select all

_texMapTo[Nor|Hard][0]._texture
if they are addressing normal map with specular power in the alpha channel.

With this method, one can pick any of the Map To mode options and even combination.
Obviously this complicates things a little where I have to make sure it doesn't matter which order the MapTo flags are given.

We could probably make the index part optional so without it simply accesses the first matching texMapTo in the list.

as for your texture index idea, I would suggest the naming convention to fix to:

Code: Select all

_tex[#]
This way we can be more certain that it will not conflict with custom user params. We basically reserve _ prefix for internal use. :)
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 »

Some of this options also support positive and negative. But i do not know if you want to implement it for now.

Code: Select all

_texMapTo[ {+Nor|-Nor|Nor}][0]._texture
for example part of the blender documentation
Ref (+/-/off)
Influences the amount of diffuse reflection.
Spec (+/-/off)
Influences the amount of specular reflection.
Amb (+/-/off)
Influences the amount of Ambient light the material receives
Hard (+/-/off)
Influences the specular hardness amount. A DVar of 1 is equivalent to a Hardness of 130, a DVar of 0.5 is equivalent to a Hardness of 65.
RayMir (+/-/off)
Influences the strength of raytraced mirror reflection
Alpha (+/-/off)
Influences the Opacity of the material. See Use Alpha for Object Transparency. Also use ZTransp for light and if combining multiple channels.
Emit (+/-/off)
Influences the amount of light Emitted by the material
Translu (+/-/off)
Influences the Translucency amount
Disp (+/-/off)
Influences the Displacement of vertices, for using Displacement Maps.
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
teofil20
Gnoblar
Posts: 14
Joined: Sun Sep 06, 2009 3:26 pm

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

Post by teofil20 »

Hi im having problems exporting a mesh into ogre it was impoerted frrom makehuman using MHX. The symptoms are the teeth texture gets put to the back of the neck and partially on to the lips and the thumbs get streched to the meshes center.(No errors in the exporter except lots of warnings saying "vetex with more than 4 bone assignments")
here is a picture Image

thanks
f00bar
Halfling
Posts: 57
Joined: Sun Feb 15, 2009 4:00 am
x 1

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

Post by f00bar »

maybe those vertices are not assigned to a bone or to a wrong bone. use "weight painting". does it look ok in blender if you move all bones in pose mode?
User avatar
teofil20
Gnoblar
Posts: 14
Joined: Sun Sep 06, 2009 3:26 pm

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

Post by teofil20 »

Thanks f00bar now it works
lustigerclown
Gnoblar
Posts: 14
Joined: Thu Mar 18, 2010 11:45 am

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

Post by lustigerclown »

Hi guys, I have already posted in a different Thread, but maybe someone of you can help
I can't export a animation with the Exporter...
http://www.ogre3d.org/forums/viewtopic.php?f=8&t=56367
Retrofasciata

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

Post by Retrofasciata »

I am wondering if the Blender 2.5 (alpha 2) release has any influence?
Is it the same exporter? Any other action(s) required to get it to work?
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 »

Nothing happens here until Blender 2.5 goes *stable* - there's no point in a major effort before then.
The API is still in flux.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
BTolputt
Greenskin
Posts: 121
Joined: Thu Feb 18, 2010 8:05 am
x 2

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

Post by BTolputt »

I'm a big fan of Blender 2.5 as well, but jacmoe has a very good point. Blender 2.5 is undergoing some major changes... it is not even known at the moment what the final internal representation of the mesh is going to be (the current EditMesh structure or the new BMesh structure), let alone how they are going to expose these details to the outside world.

I'm going to be making a start in an exporter in the next fortnight because I kind of need it for my own purposes, but there is no point relying on me or anyone else releasing something that may be invalidated with the next SVN commit by the Blender core developers.
Tuftux
Gnoblar
Posts: 20
Joined: Mon Aug 04, 2008 9:19 pm

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

Post by Tuftux »

Hey everyone !

I've got a problem with one of my animated mesh which only appears with two animations : when I try to export the mesh it start calculating the animation (you know, when you see the mesh moving in the 3D window) and then the script crashes even without starting converting the mesh with OgreXMLConverter. It says "Check in the console", and the console returns :

Code: Select all

self.inverseLastKeyFrameTotalTransformation.invert()
ValueError: matrix does not have an inverse
I absolutely don't know where it comes from, and when I try to export other animations there's no problem. Could anoyne help me ? :)
Thanks !
pedro_fp_simoes
Gnoblar
Posts: 2
Joined: Sun Apr 18, 2010 8:04 pm

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

Post by pedro_fp_simoes »

Hi I'm a newbie on Ogre3D and I need to implement an 3D simulation of a island with people and animals.

For that I'm thinking on using Blender for the design and Ogre3D for the engine :), but I'm stuck with the animations :(

I have an simple animated cube in a .blend file (attach)

I can't get animated exported to mesh :(

Please hellllllllllllllllllllllllppppppppppppppppppp :(
You do not have the required permissions to view the files attached to this post.
User avatar
Thorworks
Gnoblar
Posts: 6
Joined: Wed Oct 28, 2009 4:39 pm
Location: The Netherlands

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

Post by Thorworks »

Hey

I got a problem regarding the blender exporter.

When exported, my mesh (Shows up good in Blender and other 3d tools) looses faces and screws up the model.
It looks good in different tools, but as .mesh file it screws up.

I also tried converting the frankie model (from the open source Yo Frankie, or Big Buck Bunny) that exports rather well, but with some weird vertexes, animation and skeleton problems.

My other models exported just right so i have no idea what changed.

Also i would like to request a blender 2.5 exporter.
There actually is a request from the blender developers to start write exporters for 2.5. since the exporter framework is just done!
I use 2.5 alpha 2 on a daily base and really works a lot better imho then 2.49.

Thanks
http://www.thorworks.org - Massive Engine - Gronos
Conferences: Blender Conference 2009
Ultime Alex
Gnoblar
Posts: 13
Joined: Sun Apr 25, 2010 4:02 pm

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

Post by Ultime Alex »

Hi !

Is there a way to export partial animations (not all bones affected) with the exporter to use ANIMBLEND_CUMULATIVE without mask ?
In my skeleton.xml, i see that animations with few bones associated are writed in the file with all bones.

Thx.