getting the exporter to work with non-deformable parent bones should not be that hard hymerman. Give it a shot, i'm sure there are many here who would like Rigify rigs to be compatible. Just read the code in the Skeleton and Bone classes.hymerman wrote:Has anyone managed to export a mesh with a rig generated by rigify and the human meta-rig? I saw the 'export deformable bones only' option and got all excited but I've just tried to export a mesh with a rigify rig and it's throwing an exception (AttributeError: NoneType has no attribute children) here:
I saw the warning in the tooltip about using this option when deformable bones have non-deformable parents, so I guess this is what is happening - the deformable bones are all over the hierarchy of a rigify rig.Code: Select all
def rebuild_tree( self ): # called first on all bones if self.parent: self.parent = self.skeleton.get_bone( self.parent.name ) self.parent.children.append( self ) # <--- here, line 3741, in version 0.5.7 preview1
Any idea about how to fix this? Would it be possible to get the option to work with non-deformable parent bones? Or is there some way to alter the rig so that it still works the way it does normally, but with all deform bones in the same part of the hierarchy?
I don't mind doing some coding if somebody will point me in the right direction, but I have no idea where to look in this beastly 6691-line file
Blender26 Ogre Exporter
-
- Greenskin
- Posts: 107
- Joined: Tue Nov 16, 2010 7:33 am
- x 15
Re: Blender26 Ogre Exporter
-
- Gnoblar
- Posts: 13
- Joined: Fri Apr 20, 2012 4:37 am
- Location: Hangzhou, China
Re: Blender26 Ogre Exporter
Hi everyone,
I'm having some problems setting up the ogre material scripts using the exporter for Blender 2.6. I'm new to this (and Ogre in general), and I have a feeling I'm just not getting something that's in front of my face.
I have a simple grass/plant model that has a diffuse (with alpha), a specular, a normal, and an emissive map. At this point, I'd just be happy to get the diffuse map to look right in Ogre, but I'll eventually have to get the other's working too, so any help in that regard would be great. I have all the maps as textures in one Blender material. Is that how it's supposed to be done? Or, should I have each map as it's own material in Blender? I think from looking at other files, if I only used the simple diffuse map, then I would only need a .material file, but if I use these other maps, I'll need to shader script file?
I can get the plant to look correct in Blender's renderer, but when I export and look at it with OgreMeshy, the alpha is not being used. I've been trying to understand how to use the exporters material script generator. I've looked at the video listed on the google code site in relation to alpha textures... however the audio seems to be screwed up, and doing similar steps in the video didn't change my results. I've also tried to read through some documents on shaders, but for the most part, they're for creating shaders from scratch. I've also looked at a number of Ogre example files (and their material files), but from what I could tell, most of them were simple with just one texture file and no alpha (like Sinbad). So, I'm kind of at a loss.
Are there any good tutorials/walkthroughs on a proper set up for models with multiple types of maps for Blender->Ogre?
I'm having some problems setting up the ogre material scripts using the exporter for Blender 2.6. I'm new to this (and Ogre in general), and I have a feeling I'm just not getting something that's in front of my face.
I have a simple grass/plant model that has a diffuse (with alpha), a specular, a normal, and an emissive map. At this point, I'd just be happy to get the diffuse map to look right in Ogre, but I'll eventually have to get the other's working too, so any help in that regard would be great. I have all the maps as textures in one Blender material. Is that how it's supposed to be done? Or, should I have each map as it's own material in Blender? I think from looking at other files, if I only used the simple diffuse map, then I would only need a .material file, but if I use these other maps, I'll need to shader script file?
I can get the plant to look correct in Blender's renderer, but when I export and look at it with OgreMeshy, the alpha is not being used. I've been trying to understand how to use the exporters material script generator. I've looked at the video listed on the google code site in relation to alpha textures... however the audio seems to be screwed up, and doing similar steps in the video didn't change my results. I've also tried to read through some documents on shaders, but for the most part, they're for creating shaders from scratch. I've also looked at a number of Ogre example files (and their material files), but from what I could tell, most of them were simple with just one texture file and no alpha (like Sinbad). So, I'm kind of at a loss.
Are there any good tutorials/walkthroughs on a proper set up for models with multiple types of maps for Blender->Ogre?
-
- OGRE Expert User
- Posts: 1920
- Joined: Sun Feb 19, 2012 9:24 pm
- Location: Russia
- x 201
Re: Blender26 Ogre Exporter
There's no such thing as direct exporting of Blender materials to Ogre as it's just infeasible (due to major differences between their concepts and implementation). This exporter has a rather clever way to deal with that I should say but it's obviously been developed with a very specific process in mind. It's usable when you know all the details. I think I figured out how it should be used looking at some of the videos provided by the author but I found it not suitable for my own process.
I really recommend you this: model a prop in Blender, assign some materials (mainly needed for their names at this point but you can apply your textures there as well to make sure everything looks good together); now export just the geometry and create a .material file where you define all the materials used by the model. This might sound like some extra hand work but you will know exactly what's there and the flexibility is all yours.
I really recommend you this: model a prop in Blender, assign some materials (mainly needed for their names at this point but you can apply your textures there as well to make sure everything looks good together); now export just the geometry and create a .material file where you define all the materials used by the model. This might sound like some extra hand work but you will know exactly what's there and the flexibility is all yours.
-
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
Re: Blender26 Ogre Exporter
I basically drop the material files exported with the exporter and roll my own. The only thing I need from the exporter is that the mesh has the right submeshes so I can assign materials to it. Which means I just create stub materials in blender that will be replaced manually afterwards.
You could use a specific Ogra material editor if you want.
You could use a specific Ogra material editor if you want.
Developer @ MakeHuman.org
-
- Gnoblar
- Posts: 13
- Joined: Fri Apr 20, 2012 4:37 am
- Location: Hangzhou, China
Re: Blender26 Ogre Exporter
Thanks for the info duststorm and bstone. I've got Yaose as my material script editor right now. I'll try and get just the diffuse maps to work, and then tackle the rest of it when I have more time in the summer (coming up on finals right now).
I guess another question I've had is, concerning models with various kinds of maps, when exactly do I need to make a shader (cg/glsl/hlsl) file? When I want to use the specular map, normal map, ambient occlusion, emissive, etc.?
As for the submesh stuff, after looking at Sinbad, I understand that a bit better.
I guess another question I've had is, concerning models with various kinds of maps, when exactly do I need to make a shader (cg/glsl/hlsl) file? When I want to use the specular map, normal map, ambient occlusion, emissive, etc.?
As for the submesh stuff, after looking at Sinbad, I understand that a bit better.
-
- OGRE Expert User
- Posts: 1920
- Joined: Sun Feb 19, 2012 9:24 pm
- Location: Russia
- x 201
Re: Blender26 Ogre Exporter
Exactly. Though applying modulative ambient occlusion and emmisive maps can be done using passes and the fixed function pipeline the more you can do in a single pass the better performance you will get. And since per-pixel specular lighting and relief mapping require shaders anyway it's the way to go.golembuilder wrote:I guess another question I've had is, concerning models with various kinds of maps, when exactly do I need to make a shader (cg/glsl/hlsl) file? When I want to use the specular map, normal map, ambient occlusion, emissive, etc.?
-
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
Re: Blender26 Ogre Exporter
For anything different than the shading of the fixed rendering function you need shaders.
Fixed function is plain old boring gouraud shading. The moment you want per-pixel lighting (phong), which is probably the first step up from the default, you need shaders.
That's why new render systems like DX11 just dropped FF entirely and need you to work with shaders exclusively.
So actually, unless you want 90's shading, you will have to use shaders.
Have a look at the RTShader system. It can generate a lot of standard shader techniques for you. Unfortunately it has not been documented very well (for example in the manual).
Fixed function is plain old boring gouraud shading. The moment you want per-pixel lighting (phong), which is probably the first step up from the default, you need shaders.
That's why new render systems like DX11 just dropped FF entirely and need you to work with shaders exclusively.
So actually, unless you want 90's shading, you will have to use shaders.
Have a look at the RTShader system. It can generate a lot of standard shader techniques for you. Unfortunately it has not been documented very well (for example in the manual).
Developer @ MakeHuman.org
-
- Gnoblar
- Posts: 13
- Joined: Fri Apr 20, 2012 4:37 am
- Location: Hangzhou, China
Re: Blender26 Ogre Exporter
Thanks both of you
I stumbled across the materials section of the wiki (again) and noticed that had a few pieces of material code that helped fix my plant alpha texture problem. I ended up spending a few hours getting really confused when the changes in the script file wouldn't result in any changes to the Ogremeshy view. I eventually realized it was loading up a completely different material script of the same name (from the blender exporter). But, it's working now.
I stumbled across the materials section of the wiki (again) and noticed that had a few pieces of material code that helped fix my plant alpha texture problem. I ended up spending a few hours getting really confused when the changes in the script file wouldn't result in any changes to the Ogremeshy view. I eventually realized it was loading up a completely different material script of the same name (from the blender exporter). But, it's working now.
-
- Greenskin
- Posts: 115
- Joined: Wed Dec 07, 2011 9:05 pm
- x 4
Re: Blender26 Ogre Exporter
I'm having weird scaling issues with this script.
First, I have a simple level, which is based on a plane scaled up to 30 (default) Blender units. When exported, it's about the same size as the Blender default cube. Here is a screenshot of this mesh displayed in Meshy, notice the size compared to the grid:
Then, I have a piece of fence, about the size of the default Blender cube. When exported, it's so big that it's not even visible in my app at my current far clip distance. Here is it compared to the Meshy grid:
What did I do wrong?
First, I have a simple level, which is based on a plane scaled up to 30 (default) Blender units. When exported, it's about the same size as the Blender default cube. Here is a screenshot of this mesh displayed in Meshy, notice the size compared to the grid:
Then, I have a piece of fence, about the size of the default Blender cube. When exported, it's so big that it's not even visible in my app at my current far clip distance. Here is it compared to the Meshy grid:
What did I do wrong?
-
- Goblin
- Posts: 260
- Joined: Tue Oct 25, 2011 1:07 am
- x 36
Re: Blender26 Ogre Exporter
hi,
i have a small question:
how do you rotate an existing rigged model?
when i rotate parent rig and apply rotation, exporter shows 'root rotation' offset error. exported mesh's bones are not rotated.
does it only accept 0 roll?
how do i get past this?
thank you.
i have a small question:
how do you rotate an existing rigged model?
when i rotate parent rig and apply rotation, exporter shows 'root rotation' offset error. exported mesh's bones are not rotated.
does it only accept 0 roll?
how do i get past this?
thank you.
-
- OGRE Expert User
- Posts: 1920
- Joined: Sun Feb 19, 2012 9:24 pm
- Location: Russia
- x 201
Re: Blender26 Ogre Exporter
Sounds like you've forgotten to apply the scale to your meshes before exporting them.N_K wrote:I'm having weird scaling issues with this script.
-
- Greenskin
- Posts: 115
- Joined: Wed Dec 07, 2011 9:05 pm
- x 4
Re: Blender26 Ogre Exporter
Yeah, that was the problem, thank you. I wasn't even aware of this feautre...
-
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
Re: Blender26 Ogre Exporter
I think you might want to do "set smooth" on the geometry of that fence to make the bars look round.
Developer @ MakeHuman.org
-
- Gnoblar
- Posts: 2
- Joined: Thu Jun 21, 2012 5:14 am
Re: Blender26 Ogre Exporter
Hi,
I would like to ask if there is a way to load the exported .xml or .mesh file back into blender2.6 ?
Thanks.
I would like to ask if there is a way to load the exported .xml or .mesh file back into blender2.6 ?
Thanks.
-
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
Re: Blender26 Ogre Exporter
There is an old ogre mesh importer for the old Blender 2.4. It will probably not support all features of new .mesh.xml files either.devilvkws wrote:I would like to ask if there is a way to load the exported .xml or .mesh file back into blender2.6?
Maybe OgreAssimp can do it?
But in fact, parsing the ogre mesh XML should be pretty straightforward. Someone with a little time and some knowledge of the Blender API could probably make a new importer in not too much time.
Developer @ MakeHuman.org
-
- Goblin
- Posts: 210
- Joined: Mon Dec 12, 2011 12:52 pm
- Location: Germany
- x 34
Re: Blender26 Ogre Exporter
I've been quite busy this month and hadn't really had time to look into the forum so I'm sorry to awnswer a little late...hymerman wrote:Has anyone managed to export a mesh with a rig generated by rigify and the human meta-rig? I saw the 'export deformable bones only' option and got all excited but I've just tried to export a mesh with a rigify rig and it's throwing an exception (AttributeError: NoneType has no attribute children) here:
I saw the warning in the tooltip about using this option when deformable bones have non-deformable parents, so I guess this is what is happening - the deformable bones are all over the hierarchy of a rigify rig.Code: Select all
def rebuild_tree( self ): # called first on all bones if self.parent: self.parent = self.skeleton.get_bone( self.parent.name ) self.parent.children.append( self ) # <--- here, line 3741, in version 0.5.7 preview1
Any idea about how to fix this? Would it be possible to get the option to work with non-deformable parent bones? Or is there some way to alter the rig so that it still works the way it does normally, but with all deform bones in the same part of the hierarchy?
I don't mind doing some coding if somebody will point me in the right direction, but I have no idea where to look in this beastly 6691-line file
The reason the script crashes is because when it exports a bone that has a parent it seaches the parent in the allready exported bones and adds itself as a child. If the parent wasn't exported it won't find it and so causes an error when trying to add itself as a child.
There is one problem when exporting non-deformable bones only if they have deformable children:
The mesh is exported completly before the skeleton. This means the bone-weights of the vertices are exported before the skeleton is built and for this the id of the bones needs to be known. I think the easiest way to do this will be to write a recursive function that checks if the bone has any deformable offsprings.
This function is called when the mesh is exported to get the index of the bones for the vertizes' bone-weights: (line 817)
Code: Select all
def find_bone_index( ob, arm, groupidx): # sometimes the groups are out of order, this finds the right index.
if groupidx < len(ob.vertex_groups): # reported by Slacker
vg = ob.vertex_groups[ groupidx ]
j = 0
for i,bone in enumerate(arm.pose.bones):
if not bone.bone.use_deform and CONFIG['ONLY_DEFORMABLE_BONES']: j+=1 #if we skip bones we need to adjust the id
if bone.name == vg.name: return i-j
else:
print('WARNING: object vertex groups not in sync with armature', ob, arm, groupidx)
Code: Select all
for pbone in arm.pose.bones:
if pbone.bone.use_deform or not CONFIG['ONLY_DEFORMABLE_BONES']:
mybone = Bone( arm.data.bones[pbone.name] ,pbone, self )
self.bones.append( mybone )
If you have problems with python or the blender api I can also write this for you, shouldn't really take that long (propably less than this post ^^)
-
- Halfling
- Posts: 66
- Joined: Wed Dec 20, 2006 10:15 pm
- x 1
Re: Blender26 Ogre Exporter
Thanks for the reply!
If I understand you correctly, you mean to export bones that don't deform the mesh if they have children that do, right? The trouble with that is, if I remember the rig generated by rigify from the human meta-rig (I'll just call it "rigify rig") correctly, that'll take it over the 64 bone maximum limit Ogre has on skeletons. There are less than 64 deform bones in rigify rig (I think it's about 56 including twist bones and all the fingers), but the organisation bones that are parented to some of them will likely take it over that.
I guess the only way to resolve that is to... sort of reparent the bones with non-deformable parents so that their parent is the root? Though perhaps that will cause problems later when blending animations, since that could move the arms away from the shoulders! In that case, perhaps the best way would be to reorganise the rigify rig so it has a proper hierarchy for the deform bones again?
If I understand you correctly, you mean to export bones that don't deform the mesh if they have children that do, right? The trouble with that is, if I remember the rig generated by rigify from the human meta-rig (I'll just call it "rigify rig") correctly, that'll take it over the 64 bone maximum limit Ogre has on skeletons. There are less than 64 deform bones in rigify rig (I think it's about 56 including twist bones and all the fingers), but the organisation bones that are parented to some of them will likely take it over that.
I guess the only way to resolve that is to... sort of reparent the bones with non-deformable parents so that their parent is the root? Though perhaps that will cause problems later when blending animations, since that could move the arms away from the shoulders! In that case, perhaps the best way would be to reorganise the rigify rig so it has a proper hierarchy for the deform bones again?
-
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
Re: Blender26 Ogre Exporter
I agree with this. The reason to remove the non-deformables in the first place is to make it compatible with ogre (and optimize the skeleton for performance).hymerman wrote:If I understand you correctly, you mean to export bones that don't deform the mesh if they have children that do, right? The trouble with that is, if I remember the rig generated by rigify from the human meta-rig (I'll just call it "rigify rig") correctly, that'll take it over the 64 bone maximum limit Ogre has on skeletons.
The only bones that matter are those that deform the mesh, is it not possible to remove all the rest? Constraints and IK are not used in ogre, so they serve no purpose. The only thing I can imagine is that bones can be positioned relative to their parent, but it's possible to fix their offsets in those cases. Or is there some problem I am not seeing?
I believe this is what the unity script does (that has been mentioned a few pages back in this thread).
Developer @ MakeHuman.org
-
- Halfling
- Posts: 66
- Joined: Wed Dec 20, 2006 10:15 pm
- x 1
Re: Blender26 Ogre Exporter
The trouble is, bone transforms will be specified relative to their parents, and at runtime their final transforms will be calculated by evaluating the transforms of the whole hierarchy. So the problem is that to export the animation from Blender correctly whilst removing bones from the hierarchy, there will have to be some fixup done to the now parentless bones, and that fixup can't be as simple as treating them as being parented to the root, since I imagine things like animation blending may go weird. Really I think we need to rearrange the rigify rig to avoid having to fiddle with the skeleton on export at all.duststorm wrote:... The only thing I can imagine is that bones can be positioned relative to their parent, but it's possible to fix their offsets in those cases. Or is there some problem I am not seeing?
Tell me if I'm wrong though; perhaps it's ok to remove some parts of the hierarchy and I've gotten totally the wrong end of the stick!
-
- Goblin
- Posts: 210
- Joined: Mon Dec 12, 2011 12:52 pm
- Location: Germany
- x 34
Re: Blender26 Ogre Exporter
Non-Deformable bones can be useful for adding equipment to your character but of course all the ik-bones in blender are wasted in ogre and the 64 bone-limit of ogre is a problem if the rigify-rig exceeds this.
I think there are two ways to deal with this without altering the rigify-rig:
1) export the non-deformable bones if they have any deformable bones in the hirarchy under them and accept that they are useless in ogre (only viable if this doesn't exceed the limit of 64).
2) skip the non-deformable bones even if they have deformable children and have the exporter calculate the new hirarchy and the bone's relativ positions in it. This can be a little bit tricky though, especially when exporting animations.
For exporting non-deformable bones that are not used for ik-constraints but meant as a tag-point for equipment one can introduce a custom property to force export.
I've never worked with rigify and the human meta-rig but I'll have a look at it now and try to make it work with the exporter. I'll try to go with the 2nd solution since it's more efficient in ogre
edit:
turned out to be easier than expected. The script already recalculates the location and rotation of each bone relativ to its (exported) parent so the only task left was to rebuild the tree correctly. Now the script searches recursivly through the parents until it finds a parent that is exported.
I also added the possibility to force exportation of non-deformable bones that are meant as tag-points for equipment. To do this you simply have to give the bone a custom property named "Force_Export" (the value doesn't matter). But you have to give this property to the bone with which you are dealing in object- or edit-mode. While in pose-mode you're dealing with pose-bones that are a different python-struct.
I've only tested the changes with my own armature and not the rigify-rig so please give feedback whether or not this works correctly now.
I think there are two ways to deal with this without altering the rigify-rig:
1) export the non-deformable bones if they have any deformable bones in the hirarchy under them and accept that they are useless in ogre (only viable if this doesn't exceed the limit of 64).
2) skip the non-deformable bones even if they have deformable children and have the exporter calculate the new hirarchy and the bone's relativ positions in it. This can be a little bit tricky though, especially when exporting animations.
For exporting non-deformable bones that are not used for ik-constraints but meant as a tag-point for equipment one can introduce a custom property to force export.
I've never worked with rigify and the human meta-rig but I'll have a look at it now and try to make it work with the exporter. I'll try to go with the 2nd solution since it's more efficient in ogre
edit:
turned out to be easier than expected. The script already recalculates the location and rotation of each bone relativ to its (exported) parent so the only task left was to rebuild the tree correctly. Now the script searches recursivly through the parents until it finds a parent that is exported.
I also added the possibility to force exportation of non-deformable bones that are meant as tag-points for equipment. To do this you simply have to give the bone a custom property named "Force_Export" (the value doesn't matter). But you have to give this property to the bone with which you are dealing in object- or edit-mode. While in pose-mode you're dealing with pose-bones that are a different python-struct.
I've only tested the changes with my own armature and not the rigify-rig so please give feedback whether or not this works correctly now.
You do not have the required permissions to view the files attached to this post.
-
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
Re: Blender26 Ogre Exporter
Flick the pirate girl is a good model to test this out with. It's got a pretty complex rigify setup with IK bones.Waruck wrote:I've only tested the changes with my own armature and not the rigify-rig so please give feedback whether or not this works correctly now.
If the script works properly with this model the script will probably work fine
When testing that model, be aware that some bones are hidden on different bone layers.
Developer @ MakeHuman.org
-
- Goblin
- Posts: 210
- Joined: Mon Dec 12, 2011 12:52 pm
- Location: Germany
- x 34
Re: Blender26 Ogre Exporter
Seems to work for me, though something stranges happens....
while in blender the upper part of the body as well as the arms and the head doesn't seem to follow the bones and remains in place. however after exporting a little test animation everything worked fine... really don't know why it doesn't work in blender... ^^
Also I noticed there are 160 bones exported even when ignoring all ik bones, far more than 64. Does ogre really have a limit here, because everything looked fine in OgreMeshy (though I only moved the arms/legs and upper body a bit and didn't look in every detail of the face)
while in blender the upper part of the body as well as the arms and the head doesn't seem to follow the bones and remains in place. however after exporting a little test animation everything worked fine... really don't know why it doesn't work in blender... ^^
Also I noticed there are 160 bones exported even when ignoring all ik bones, far more than 64. Does ogre really have a limit here, because everything looked fine in OgreMeshy (though I only moved the arms/legs and upper body a bit and didn't look in every detail of the face)
-
- Greenskin
- Posts: 132
- Joined: Mon Oct 13, 2008 3:01 pm
Re: Blender26 Ogre Exporter
hi,
i have a little problem with this exporter
i am trying to export the default blender cube but i get an error :
please see the attached image
according to the error it's in line 1969 of the exporter
any help is welcome
thanks and good day/naight
i have a little problem with this exporter
i am trying to export the default blender cube but i get an error :
please see the attached image
according to the error it's in line 1969 of the exporter
really don't know what it is talking aboutumaterials = dot_mesh( context.active_object, path=path, force_name='preview' )
any help is welcome
thanks and good day/naight
-
- OGRE Expert User
- Posts: 1920
- Joined: Sun Feb 19, 2012 9:24 pm
- Location: Russia
- x 201
Re: Blender26 Ogre Exporter
You have a version of the exporter that works in Blender 2.62 and below. Look through the recent pages of this topic - there's an updated version that works with Blender 2.63.
-
- Greenskin
- Posts: 132
- Joined: Mon Oct 13, 2008 3:01 pm
Re: Blender26 Ogre Exporter
i have just grabbed the latest version from here
https://code.google.com/p/blender2ogre/
and tested it in 2.61, 2.62, 2.63 versions with the same issue
any other places i can can get a working copy
i need just a mesh exporter not animations at the moment
https://code.google.com/p/blender2ogre/
and tested it in 2.61, 2.62, 2.63 versions with the same issue
any other places i can can get a working copy
i need just a mesh exporter not animations at the moment