Blender26 Ogre Exporter

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

Re: Blender26 Ogre Exporter

Postby Pforce » Mon Sep 10, 2012 3:18 pm

Hello everyone

hartsantler the main author and maintainer has very little time nowadays to keep working on the addon. I'm from Adminotech Ltd. and we work on the realXtend Tundra project. Tundra uses Ogre as its rendering engine so we needed a nice plugin from blender to ogre. We have sponsored (paid) for some of the features we need to hartsantler as I guess you could see from the "Sponsors Adminotech Ltd." in the README.txt. Anyways, we want to continue doing work on this plugin.

I have made a new 0.5.8 release that fixes several issue with the addon since the 2.63 update (0.5.7-preview.rar). I've also checked the issue tracker and fixed what I could, mainly things that people attached source code fixes to. Quite many of my fixes target the .txml export in particular as it had the most bugs, and our artists use it most. However there are other nice things like .exe installer that has auto update checks and ships with the OgreXmlConverter (1.8) tool and the script picks it up from there, no need to configure anything (except if you want to use the optional dependencies: OgreMeshy, texture tools etc.). The .exe installer also copies the main .py script into the correct path in Blender if it Blender install location can be detected, this is done via the registry so it should work quite well if you have used the windows installers for Blender, instead of building from sources or using some .zip archive. The addon .py script is also removed from Blender when you install blender2ogre.

I'd be happy if people could help out testing the new plugin. Also if you encounter problems please use the issue tracker to report problems, if it is something related to the 3D manipulations from blender objects to Ogre form please provide source code how to fix the issue :) I'm not an expert on Blender nor Ogre internals, someone just needed to pick up the development, but I'll do my best.

Windows http://code.google.com/p/blender2ogre/downloads/detail?name=blender2ogre-0.5.8.exe
Windows/Linux/Mac http://code.google.com/p/blender2ogre/downloads/detail?name=blender2ogre-0.5.8.zip

Changelog

  • Added silent auto update checks if blender2ogre was installed using the .exe installer. This will keep people up to date when new versions are out.
  • Fix tracker issue 48: Needs to check if outputting to /tmp or ~/.wine/drive_c/tmp on Linux. Thanks to vax456 for providing the patch, added him to contributors. Preview mesh's are now placed under /tmp on Linux systems if the OgreMeshy executable ends with .exe
  • Fix tracker issue 46: add operationtype to <submesh>
  • Implement a modal dialog that reports if material names have invalid characters and cant be saved on disk. This small popup will show until user presses left or right mouse (anywhere).
  • Fix tracker issue 44: XML Attributes not properly escaped in .scene file
  • Implemented reading OgreXmlConverter path from windows registry. The .exe installer will ship with certain tools so we can stop guessing and making the user install tools separately and setting up paths.
  • Fix bug that .mesh files were not generated while doing a .txml export. This was result of the late 2.63 mods that forgot to update object facecount before determining if mesh should be exported.
  • Fix bug that changed settings in the export dialog were forgotten when you re-exported without closing blender. Now settings should persist always from the last export. They are also stored to disk so the same settings are in use when if you restart Blender.
  • Fix bug that once you did a export, the next time the export location was forgotten. Now on sequential exports, the last export path is remembered in the export dialog.
  • Remove all local:// from asset refs and make them relative in .txml export. Having relative refs is the best for local preview and importing the txml to existing scenes.
  • Make .material generate what version of this plugins was used to generate the material file. Will be helpful in production to catch things. Added pretty printing line endings so the raw .material data is easier to read.
  • Improve console logging for the export stages. Run Blender from cmd prompt to see this information.
  • Clean/fix documentation in code for future development
  • Add todo to code for future development
  • Restructure/move code for easier readability
  • Remove extra white spaces and convert tabs to space

Release commit http://code.google.com/p/blender2ogre/source/detail?r=0193c36dbcd38c6f325d3412830a22922a13cf2d

P.S. Unfortunately I cant edit the first post of this thread so there will be some old links, if there are any admins that could help out with that I'd appreciate it :)
Pforce
Kobold
 
Posts: 27
Kudos: 0
Joined: 07 Apr 2010

Re: Blender26 Ogre Exporter

Postby Waruck » Tue Sep 11, 2012 6:01 am

Nice to see some official support from the tundra-team allthough I think most users use the exporter without using tundra.

However in the 0.5.7-preview1 version that I updated to support blender 2.63 there is still a bug with the new 'ignore non-deformable bones' option that has been fixed in a preview2 release: viewtopic.php?f=8&t=61485&start=575#p461607
and also the preview in OgreMeshy doesn't work in this version as jellyzone pointed out 2 posts above.

Since I have the same problem as you, that I can't edit the first post many people missed the updated version but this fix is necessary to make the exporter work with the blender rigify tool, which was the main purpose of that 'ignore non-deformable bones' option.
I think the best solution would be to start a new thread and have the mods make that one sticky instead of this old
User avatar
Waruck
Goblin
 
Posts: 207
Kudos: 33
Joined: 12 Dec 2011
Location: Heidelberg - Germany

Re: Blender26 Ogre Exporter

Postby bstone » Tue Sep 11, 2012 7:31 am

Maybe creating a Wiki page to host the links to the most actual version alongside the latest changes would be easier.
bstone
OGRE Expert User
OGRE Expert User
 
Posts: 1920
Kudos: 200
Joined: 19 Feb 2012
Location: Russia

Re: Blender26 Ogre Exporter

Postby Pforce » Tue Sep 11, 2012 10:37 am

I took the latest code I could find and was actually surprised it was not in the source repo. I pushed that code and continued onwards. I did not have the sense to check out ogre forums for improvements. I'm not here as a "Tundra" guy, I want to help everyone that needs this plugin. I just pointed out that I'm not going to do things like what you have fixed myself as I don't have enough experience to do so. So this really comes down to community effort now that hartsantler is away.

We have two choices here: a) You need to provide me issues to the tracker and attach a patch or if the code change is trivial just point to the changed lines. b) One of you (waruck im looking at you :)) picks up the Ogre side of things and I give you commit rights to the repo, so you can develop the project directly. I know you have made multiple fixes, helped on the ogre side before and you are familiar with the code base so I have no problem giving you commit rights.

If you haven't done this kind of thing earlier there is a little learning curve. This is actually my first real thing where i have to use mercurial. Anyways I hope you are up to it, I would prefer not copy pasting issue patches to the repo when you could apply them too and just commit.

My main point is: We need to me more organized that "posting zip files somewhere after doing fixes". You can't assume people find you preview2 zip here. I certainly did not :( However I'm not blaming anyone of anything, but we need to use the projects website and its issue tracker for stuff like this :)

bstone: Another wiki page to keep up to date seems like another extra thing someone needs to upkeep. Looking at how the project is now, everything is rotting, we need to simplify the development and release to get forward! Or we need more people like said above :)

I would actually suggest any admin that can, remove the direct download links from the first post and replace "See latest release from http://code.google.com/p/blender2ogre/downloads/list" thats it.

TL;DR: Sorry I missed your efforts and code :( I will gladly put them in immediately if you can provide patches on top of the latest HG tip. I can even make a 0.5.8.1 release for them if they are significant for Ogre users!
Pforce
Kobold
 
Posts: 27
Kudos: 0
Joined: 07 Apr 2010

Re: Blender26 Ogre Exporter

Postby Waruck » Wed Sep 12, 2012 9:13 am

Right now I'm a little bit busy because I'll move back to germany next week and have to finish all my businesses here but once that is over it should be no problem for me to take the Ogre side of the project and keep the project up to the needs of the community. I've worked on private projects with mercurial together with friends so it should be no problem for me to commit changes to the repo.

When I find the time I can also make a wiki-page and keep it up to date with new changes, but I still think we should have the first post edited or start a new thread since for most people the forum is the first point to find information (and like my preview2-update nobody finds something that is not presented in the first post ^^)
User avatar
Waruck
Goblin
 
Posts: 207
Kudos: 33
Joined: 12 Dec 2011
Location: Heidelberg - Germany

Re: Blender26 Ogre Exporter

Postby neighborlee » Thu Sep 20, 2012 3:26 pm

I am learning to program , but I have a long way to go ( artist & project lead), so my question is; Can I use the 2.6 blender exporter, to export a multitexture mesh into Ogre, or is it more likely I"d need to write a shader. I tried searching for this, but what I found was too technical to assess them.

By Multitexture, I mean that I've used the texture slots ( with stencil in between them) to texture paint the 3 textures onto my mesh.

Thx anyone for some needed help on this issue.

nl

o there will be some old links, if there are any admins that could help out with that I'd appreciate it :)[/quote]
========================================
all our tomorrows hold to hope we remember the past and make today a bright reminder of our humanity and what we have to look fwd to and become..
neighborlee
Halfling
 
Posts: 47
Kudos: 0
Joined: 08 Dec 2002

Re: Blender26 Ogre Exporter

Postby Pforce » Thu Sep 20, 2012 3:57 pm

In Ogre you can have multiple submeshes in a single mesh, and all of those can have their own material that have a texture. I'm again not an artist so I'm not sure if you can utilize multiple textures (blend) somehow in a single material, probably the Ogre experts here can tell you more on that. But is this essentially what you are asking? How to get many different texture to parts of a single "mesh"?

blender2ogre should create submeshes for you when you assign different materials to vertex groups or is it triangle groups. So you select in edit mode the triangles, go to materials and select what you want and click assign. Hope that helps.
Pforce
Kobold
 
Posts: 27
Kudos: 0
Joined: 07 Apr 2010

Re: Blender26 Ogre Exporter

Postby bstone » Thu Sep 20, 2012 4:44 pm

Yes, you can export multitexture materials but their support was built around a specific workflow. See the related doc pages and videos at google code. If you can bend your mind around that workflow then you're all set. Otherwise it might be simpler for you to just create your .material scripts manually. It's not hard and you don't have to use shaders right away. Ogre materials support fixed function pipeline so you can build simple multitexture materials very quickly by adding texture units and specifying the blending operations between them. See Ogre's manual section on materials.
bstone
OGRE Expert User
OGRE Expert User
 
Posts: 1920
Kudos: 200
Joined: 19 Feb 2012
Location: Russia

Re: Blender26 Ogre Exporter

Postby Pforce » Thu Sep 20, 2012 5:15 pm

If he is working with blender + blender2ogre he doesn't need to do this manually. Afaik you can define all the behaviour in the blender2ogre panels that you mentioned. Not sure about shaders but probably those too, just have to find the place. Bret made the tool to support a wide range of things. Ofc there is always the option of manually editing the .material files after the export, but there is no need strictly to know how to build material files from scratch.
Pforce
Kobold
 
Posts: 27
Kudos: 0
Joined: 07 Apr 2010

Re: Blender26 Ogre Exporter

Postby neighborlee » Fri Sep 21, 2012 1:22 am

.
Last edited by neighborlee on Mon Sep 24, 2012 1:22 am, edited 1 time in total.
========================================
all our tomorrows hold to hope we remember the past and make today a bright reminder of our humanity and what we have to look fwd to and become..
neighborlee
Halfling
 
Posts: 47
Kudos: 0
Joined: 08 Dec 2002

Re: Blender26 Ogre Exporter

Postby duststorm » Sun Sep 23, 2012 7:34 pm

I wonder whether there is a way to export a mesh without shared vertices.
This is a rather non-standard way that is not often used (and I believe not used as it was intended). The result is that some Ogre components don't work, as was already pointed out by a post in this thread.
I'm also hitting an issue because of this: the new instancing component crashes on meshes with shared vertices (dark_sylinc mentions explicitly that he didn't make it work with shared vertices yet).

It's possible to fix meshes manually by editing their XML files, but it's not really convenient.
User avatar
duststorm
Minaton
 
Posts: 906
Kudos: 80
Joined: 31 Jul 2010
Location: Belgium

Re: Blender26 Ogre Exporter

Postby neighborlee » Mon Sep 24, 2012 1:46 am

THe videos are rather hard to follow, as they jump around alot and aren't clear, though I appreciate their existance.
If I understand you correctly, I should be able to ( or I'll have to revert to manually fixing in ogre material code (.material ) after export ) to define the mulitexture setup entirely in blender2ogre and export straight from there.

I"ll try that first , thx.

nl


Pforce wrote:If he is working with blender + blender2ogre he doesn't need to do this manually. Afaik you can define all the behaviour in the blender2ogre panels that you mentioned. Not sure about shaders but probably those too, just have to find the place. Bret made the tool to support a wide range of things. Ofc there is always the option of manually editing the .material files after the export, but there is no need strictly to know how to build material files from scratch.
========================================
all our tomorrows hold to hope we remember the past and make today a bright reminder of our humanity and what we have to look fwd to and become..
neighborlee
Halfling
 
Posts: 47
Kudos: 0
Joined: 08 Dec 2002

Re: Blender26 Ogre Exporter

Postby Shtuka » Mon Sep 24, 2012 3:47 pm

I installed the Blender26 Ogre Exporter 0.5.8, but in Blender -> File/Export, it doesn't show up. What am I doing wrong?
Shtuka
Greenskin
 
Posts: 146
Kudos: 9
Joined: 10 Jan 2011

Re: Blender26 Ogre Exporter

Postby Pforce » Mon Sep 24, 2012 3:54 pm

You need to still go to the preferences and enable the plugin. Ctrl+Alt+U should bring up the ui, go to Addons tab, filter with ogre and check the box. Remember to hit "Save as default" so the plugin gets loaded on your next blender run.

You can also check out the readme for more help how to enable the UI. For the .exe installer the readme is in C:\Program Files (x86)\blender2ogre\README.txt.
Pforce
Kobold
 
Posts: 27
Kudos: 0
Joined: 07 Apr 2010

Re: Blender26 Ogre Exporter

Postby Shtuka » Mon Sep 24, 2012 4:33 pm

Thank you.
Shtuka
Greenskin
 
Posts: 146
Kudos: 9
Joined: 10 Jan 2011

Re: Blender26 Ogre Exporter

Postby Complexity » Wed Oct 10, 2012 10:35 pm

I'm not sure if something is wrong with my Ogre rendering configuration or if it has to do with the exporter. I made a simple cube mesh and it seemingly exports fine but when I try to render it in Ogre, the mesh itself isn't even appearing. I believe the texture and material works as I was able to apply it to the Ogre sample tutorial's ninja mesh. What's strange is that OgreMeshy displays the cube mesh just fine, material and all.

Would anyone mind trying to see if the cube mesh renders on your end (mesh and material attached)? For something so basic, I'm assuming it has to be something wrong with my rendering setup but it would be a big help to confirm it.
Attachments
test.zip
(46.35 KiB) Downloaded 54 times
Complexity
Gnoblar
 
Posts: 8
Kudos: 1
Joined: 25 Sep 2012

Re: Blender26 Ogre Exporter

Postby Waruck » Thu Oct 11, 2012 7:36 am

not sure but maybe there's a problem here because Ogre already has a default cube.mesh with lowercase. Also your Ogre.log could help figuring out the problem. If ogre continues running but the mesh doesn't seem to be loaded that's usually a problem with the texture, since ogre crashes if it fails to load a mesh or material.
User avatar
Waruck
Goblin
 
Posts: 207
Kudos: 33
Joined: 12 Dec 2011
Location: Heidelberg - Germany

Re: Blender26 Ogre Exporter

Postby Complexity » Fri Oct 12, 2012 12:36 am

Figured it out. Epic fail that I did not figure this out sooner. The cube mesh did in fact appear but the scale was so small I couldn't see it. It took opening another model up in blender and seeing the scale differences between that and in Ogre for me to come to the realization. :lol:
Complexity
Gnoblar
 
Posts: 8
Kudos: 1
Joined: 25 Sep 2012

Re: Blender26 Ogre Exporter

Postby kromar » Tue Nov 20, 2012 11:05 am

i get this error when trying to export an animtion with r52344. would be great if you could take a look at this issue.
exporting works fine with the same scene and the release version of blender.

Code: Select all
 
Traceback (most recent call last):
  File "C:\Users\'user'\AppData\Roaming\Blender Foundation\Blender\2.64\scripts\addons\io_export_ogreDotScene.py", line 2175, in execute    umaterials = dot_mesh( context.active_object, path=path, force_name='preview' )
  File "C:\Users\'user'\AppData\Roaming\Blender Foundation\Blender\2.64\scripts\addons\io_export_ogreDotScene.py", line 5337, in dot_mesh    mesh.user_clear()
ReferenceError: StructRNA of type Mesh has been removed
User avatar
kromar
Gnoblar
 
Posts: 13
Kudos: 1
Joined: 23 Aug 2011

Re: Blender26 Ogre Exporter

Postby Lightnet » Sun Nov 25, 2012 6:37 pm

Blender 2.64 there were some changes in their api.
#mesh.user_clear()
#copy.user_clear()

Those do not work just ignore or comment them out.

Code: Select all
      bones = []
      for bone in arm.pose.bones:
         bones.append(bone.name)
      
      if   not   arm.animation_data   or   (arm.animation_data   and   not   arm.animation_data.nla_tracks):   #   assume   animated   via   constraints   and   use   blender   timeline.
         anims   =   doc.createElement('animations');   root.appendChild(   anims   )
         for action in bpy.data.actions:
            count = 0
            for actionbone in action.groups:
               for b in bones:
                  if b == actionbone.name:
                     count += 1
                     #print(b," : ",actionbone.name)
                     break
         
            if len(bones) == len(action.groups) == count:
               print("MACTHES Armature bones with Action groups.")
            else:
               #if action doesn't matches in case if you have another armature it will override the action and will give off sets.
               print("Fail to match armature with action group.","Bones:",len(bones)," Action Group:",len(action.groups))
               continue
                  
            arm.animation_data.action = action
            anim   =   doc.createElement('animation');   anims.appendChild(   anim   )
            tracks   =   doc.createElement('tracks');   anim.appendChild(   tracks   )


This line of code that change was simple. Although it need to make sure the armature bones matches the action group in case the animation get override of another armature. Thought it was just quick coding so it need more checking. This line of code deal with exporting all animations if matches. Just select all the pose bones and assign a key frame.

Here the full code.
http://www.pasteall.org/37511/python
Lightnet
Gnoblar
 
Posts: 11
Kudos: 2
Joined: 18 Oct 2012

Re: Blender26 Ogre Exporter

Postby kromar » Mon Nov 26, 2012 9:18 am

can you tell me at what line you added that code? i can not use the pastall link, its all scrambled up:(

EDIT: i tried to get your changes in, but its a huge mess with tons of indent errors... i would apreciate if you could upload the *.py file somewhere. thanks
User avatar
kromar
Gnoblar
 
Posts: 13
Kudos: 1
Joined: 23 Aug 2011

Re: Blender26 Ogre Exporter

Postby Lightnet » Tue Nov 27, 2012 12:01 am

Here the link with the file:
http://code.google.com/p/unrealtactical ... 121125.zip

Although it was quick added into it.

For this message the author Lightnet has received kudos
Lightnet
Gnoblar
 
Posts: 11
Kudos: 2
Joined: 18 Oct 2012

Re: Blender26 Ogre Exporter

Postby kromar » Tue Nov 27, 2012 9:26 am

thanks a lot
User avatar
kromar
Gnoblar
 
Posts: 13
Kudos: 1
Joined: 23 Aug 2011

Re: Blender26 Ogre Exporter

Postby lunkhound » Thu Dec 13, 2012 10:57 pm

So I updated to Blender 2.65. Tried the latest blender2ogre 0.5.8. Works OK for just a mesh, but if there is animation it errors out on the "mesh.user_clear()" line like kromar posted. I guess the latest blender2ogre hasn't been updated to work with recent versions of Blender yet.
Downloaded the version from Lightnet, but the file is mangled. Every space in the entire file was replaced with a tab character. That makes it really hard to see what the changes were. It was a hassle but I think I managed to get the changes applied, and now animation can be exported without exporter errors. For those thinking of upgrading to the latest Blender, beware.

Here is a diff:
Code: Select all
--- io_export_ogreDotScene-0.5.8.py   2012-09-10 06:38:26.335504600 -0700
+++ io_export_ogreDotScene-fixed.py   2012-12-13 12:29:49.335963700 -0800
@@ -4424,11 +4424,11 @@
         #x,y,z = arm.matrix_local.copy().inverted().to_euler()
         #e = mathutils.Euler( (x,z,y) )
         #self.object_space_transformation = e.to_matrix().to_4x4()
         x,y,z = arm.matrix_local.to_euler()
         if x != 0 or y != 0 or z != 0:
-            Report.warnings.append('ERROR: Armature: %s is rotated - (rotation is ignored)' %arm.name)
+            Report.warnings.append('ERROR: Armature: %s is rotated (%f %f %f) - (rotation is ignored)' % (arm.name, x, y, z))
 
         ## setup bones for Ogre format ##
         for b in self.bones: b.rebuild_tree()
         ## walk bones, convert them ##
         self.roots = []
@@ -4487,67 +4487,89 @@
                 scale.setAttribute('x', str(x))
                 scale.setAttribute('y', str(y))
                 scale.setAttribute('z', str(z))
 
         arm = self.arm
-        if not arm.animation_data or (arm.animation_data and not arm.animation_data.nla_tracks):  # assume animated via constraints and use blender timeline.
+        #this deal with bones check if action group matches
+        bones = []
+        for bone in arm.pose.bones:
+            bones.append(bone.name)
+       
+        if not arm.animation_data or (arm.animation_data and not arm.animation_data.nla_tracks):   # assume animated via constraints and use blender timeline.
             anims = doc.createElement('animations'); root.appendChild( anims )
-            anim = doc.createElement('animation'); anims.appendChild( anim )
-            tracks = doc.createElement('tracks'); anim.appendChild( tracks )
-            anim.setAttribute('name', 'my_animation')
-            start = bpy.context.scene.frame_start; end = bpy.context.scene.frame_end
-            anim.setAttribute('length', str( (end-start)/_fps ) )
-
-            _keyframes = {}
-            _bonenames_ = []
-            for bone in arm.pose.bones:
-                if self.get_bone(bone.name):                     #check if the bone was exported
-                    _bonenames_.append( bone.name )
-                    track = doc.createElement('track')
-                    track.setAttribute('bone', bone.name)
-                    tracks.appendChild( track )
-                    keyframes = doc.createElement('keyframes')
-                    track.appendChild( keyframes )
-                    _keyframes[ bone.name ] = keyframes
-
-            for frame in range( int(start), int(end)+1, bpy.context.scene.frame_step):
-                bpy.context.scene.frame_set(frame)
-                for bone in self.roots: bone.update()
-                print('\t\t Frame:', frame)
-                for bonename in _bonenames_:
-                    if self.get_bone(bonename):                         #check if the bone was exported
-                        bone = self.get_bone( bonename )
-                        _loc = bone.pose_location
-                        _rot = bone.pose_rotation
-                        _scl = bone.pose_scale
-
-                        keyframe = doc.createElement('keyframe')
-                        keyframe.setAttribute('time', str((frame-start)/_fps))
-                        _keyframes[ bonename ].appendChild( keyframe )
-                        trans = doc.createElement('translate')
-                        keyframe.appendChild( trans )
-                        x,y,z = _loc
-                        trans.setAttribute('x', '%6f' %x)
-                        trans.setAttribute('y', '%6f' %y)
-                        trans.setAttribute('z', '%6f' %z)
-
-                        rot =  doc.createElement( 'rotate' )
-                        keyframe.appendChild( rot )
-                        q = _rot
-                        rot.setAttribute('angle', '%6f' %q.angle )
-                        axis = doc.createElement('axis'); rot.appendChild( axis )
-                        x,y,z = q.axis
-                        axis.setAttribute('x', '%6f' %x )
-                        axis.setAttribute('y', '%6f' %y )
-                        axis.setAttribute('z', '%6f' %z )
-
-                        scale = doc.createElement('scale')
-                        keyframe.appendChild( scale )
-                        x,y,z = _scl
-                        scale.setAttribute('x', '%6f' %x)
-                        scale.setAttribute('y', '%6f' %y)
-                        scale.setAttribute('z', '%6f' %z)
+            for action in bpy.data.actions:
+                count = 0
+                for actionbone in action.groups:
+                    for b in bones:
+                        if b == actionbone.name:
+                            count += 1
+                            #print(b," : ",actionbone.name)
+                            break
+           
+                if len(bones) == len(action.groups) == count:
+                    print("MACTHES Armature bones with Action groups.")
+                else:
+                    #if action doesn't matches in case if you have another armature it will override the action and will give off sets.
+                    print("Fail to match armature with action group.","Bones:",len(bones)," Action Group:",len(action.groups))
+                    continue
+                       
+                arm.animation_data.action = action
+                anim = doc.createElement('animation'); anims.appendChild( anim )
+                tracks = doc.createElement('tracks'); anim.appendChild( tracks )
+                anim.setAttribute('name', action.name)
+                start = bpy.context.scene.frame_start; end = bpy.context.scene.frame_end
+                anim.setAttribute('length', str( (end-start)/_fps ) )
+
+                _keyframes = {}
+                _bonenames_ = []
+                for bone in arm.pose.bones:
+                    if self.get_bone(bone.name):   #check if the bone was exported
+                        _bonenames_.append( bone.name )
+                        track = doc.createElement('track')
+                        track.setAttribute('bone', bone.name)
+                        tracks.appendChild( track )
+                        keyframes = doc.createElement('keyframes')
+                        track.appendChild( keyframes )
+                        _keyframes[ bone.name ] = keyframes
+
+                for frame in range( int(start), int(end)+1, bpy.context.scene.frame_step):
+                    bpy.context.scene.frame_set(frame)
+                    for bone in self.roots: bone.update()
+                    print('\t\t Frame:', frame)
+                    for bonename in _bonenames_:
+                        if self.get_bone(bonename):   #check if the bone was exported
+                            bone = self.get_bone( bonename )
+                            _loc = bone.pose_location
+                            _rot = bone.pose_rotation
+                            _scl = bone.pose_scale
+
+                            keyframe = doc.createElement('keyframe')
+                            keyframe.setAttribute('time', str((frame-start)/_fps))
+                            _keyframes[ bonename ].appendChild( keyframe )
+                            trans = doc.createElement('translate')
+                            keyframe.appendChild( trans )
+                            x,y,z = _loc
+                            trans.setAttribute('x', '%6f' %x)
+                            trans.setAttribute('y', '%6f' %y)
+                            trans.setAttribute('z', '%6f' %z)
+
+                            rot = doc.createElement( 'rotate' )
+                            keyframe.appendChild( rot )
+                            q = _rot
+                            rot.setAttribute('angle', '%6f' %q.angle )
+                            axis = doc.createElement('axis'); rot.appendChild( axis )
+                            x,y,z = q.axis
+                            axis.setAttribute('x', '%6f' %x )
+                            axis.setAttribute('y', '%6f' %y )
+                            axis.setAttribute('z', '%6f' %z )
+
+                            scale = doc.createElement('scale')
+                            keyframe.appendChild( scale )
+                            x,y,z = _scl
+                            scale.setAttribute('x', '%6f' %x)
+                            scale.setAttribute('y', '%6f' %y)
+                            scale.setAttribute('z', '%6f' %z)
 
         elif arm.animation_data:
             anims = doc.createElement('animations'); root.appendChild( anims )
             if not len( arm.animation_data.nla_tracks ):
                 Report.warnings.append('you must assign an NLA strip to armature (%s) that defines the start and end frames' %arm.name)
@@ -5332,12 +5354,12 @@
         #bpy.context.scene.meshes.unlink(mesh)
         if cleanup:
             #bpy.context.scene.objects.unlink(copy)
             bpy.data.objects.remove(copy)
             bpy.data.meshes.remove(mesh)
-            mesh.user_clear()
-            copy.user_clear()
+            #mesh.user_clear()
+            #copy.user_clear()
             del copy
             del mesh
         del _remap_verts_
         del uvcache
         doc.close() # reported by Reyn


The first part of the diff is something I added because I was getting a warning that my armature was rotated, even though I entered all zeros into the rotation fields. So it prints the amount of x, y, and z rotation with the warning. In my case, it printed something like:
Code: Select all
ERROR: Armature: skel is rotated (0.000000 -0.000000 0.000000) - (rotation is ignored)

So it's a bogus warning because some numerical error crept into the matrix inversion, and its checking for exactly zero--usually a bad idea with floating point.
The rest of the diff is Lightnet's changes (with all the tabs stripped out by me).

For this message the author lunkhound has received kudos
User avatar
lunkhound
Gremlin
 
Posts: 150
Kudos: 17
Joined: 29 Apr 2012
Location: Santa Monica, California

Re: Blender26 Ogre Exporter

Postby bstone » Fri Dec 14, 2012 7:04 am

Thanks for keeping the exporter actual guys.
bstone
OGRE Expert User
OGRE Expert User
 
Posts: 1920
Kudos: 200
Joined: 19 Feb 2012
Location: Russia

PreviousNext

Return to Artists & Content Creators

Who is online

Users browsing this forum: No registered users and 2 guests