Blender26 Ogre Exporter

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
mifth
Gnoblar
Posts: 6
Joined: Mon Sep 27, 2010 11:46 am

Re: Blender25 Ogre Exporter + extended .scene format

Post by mifth »

Oh, it loads into addons. I changed this:

Code: Select all

bl_info = { 
......

}

Also I think we need to change line 24 in such a way:
"location": "File > Export",

Well, exporter does not work yet with blender svn... My log is:
Ogre Exporter v31
Traceback (most recent call last):
File "/home/mifth/Документы/blender/2.56/scripts/modules/addon_utils.py", line 212, in enable
mod.register()
File "/home/mifth/Документы/blender/2.56/scripts/addons/io_ogredotscene.py", line 5708, in register
bpy.types.unregister( bpy.types.INFO_HT_header )
AttributeError: 'RNA_Types' object has no attribute 'unregister'
SRombauts
Kobold
Posts: 39
Joined: Mon Feb 28, 2011 6:58 pm
Location: Paris, France
x 2
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by SRombauts »

Hi, thanks for you reports ! Perhaps can you post an issue report as well on the Google Project http://code.google.com/p/blender2ogre/issues/list ?

I'll give a look at it soon, though I need to get Blender SVN first.

Cheers,
SRombauts

edit: @mifth I've taken into account your suggestions (http://code.google.com/p/blender2ogre/source/browse/) and reproduced your problems, but it looks more difficult then anticipated, there are compatibility issues...
Last edited by SRombauts on Sun Mar 20, 2011 10:45 pm, edited 1 time in total.
http://www.srombauts.fr, comments from an Android developer
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by jacmoe »

You guy are going to love it when Blender 2.5 finally goes stable. :wink:
Thumbs up for trying to follow that moving target - but now that it's in Beta (at last!) you should have a much easier ride.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
mifth
Gnoblar
Posts: 6
Joined: Mon Sep 27, 2010 11:46 am

Re: Blender25 Ogre Exporter + extended .scene format

Post by mifth »

Latest blender svn: www.graphicall.org
hartsantler
Greenskin
Posts: 107
Joined: Tue Nov 16, 2010 7:33 am
x 15

Re: Blender25 Ogre Exporter + extended .scene format

Post by hartsantler »

LiMuBei wrote:I'm in the same boat as supermael28. I thought I understood how it's done, but it seems exporting more than one animation is not possible. What I did:
- create an action for each animation
- create an NLA track for each action and import the action therein, thus automatically setting in and out frames
Then I export.

What happens is, that I get an animation for every track with the given lengths (which is what I expect). But every animation then contains the animation data of the top most action in the NLA, cut to the lengths of the respective action. So how is it supposed to work?

Hi LiMuBei,
sorry i am replying so late to your question, seems like you found a solution to your problem. I just want to clarify for others how to export multiple tracks, since this is a bit confusing the way i designed it to hijack the NLA interface. You do not need to bake any animations or convert any actions to NLA strips. I recommend you have a second armature that only contains bones used as constraint targets from armature1. If your using the NLA on armature1 this is going to mess things up; note that you can safely have multitrack NLA on armature2.

Step1 is: on armature1 create a single NLA track, and then add one or more strips to it.
Step2: name your NLA strips, position them in time on NLA track1.
Step3: assign an action to each NLA strip where the root bone has a single keyframe on it - this simply tells the exporter to export all bones below the keyed bone. (the reason i coded it this way is because then you can have control over which bones will be exported per-strip, i assume that you would always want to export all children of the key'ed bone - this way you can segment your animation tracks into upper body and lower body for example)

I think what is confusing people is that the NLA strips should NOT contain animation data. The NLA strip is there only for the purpose of defining a start and end frame, name, and which bone is keyed to mark it as the 'root'.

-hart
SRombauts
Kobold
Posts: 39
Joined: Mon Feb 28, 2011 6:58 pm
Location: Paris, France
x 2
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by SRombauts »

Hi,

I've dig into all your compatibility issues, which turn in fact all around the issue6: "Ongoing Blender SVN mathutils.Matrix changes ?" (http://code.google.com/p/blender2ogre/i ... etail?id=6).

So I've created a BlenderSVN branch on the repository (http://code.google.com/p/blender2ogre/s ... BlenderSVN) with a patched source code for current Blender SVN (r35672).

=> I uploaded a new ZIP specifically for this current Blender SVN (incompatible with 2.56 beta release !) : addon_ogreDotScene-0.3.1-BlenderSVN.zip on http://code.google.com/p/blender2ogre/downloads/list

Please, let us know of any other compatibility issue you encounter.
SRombauts
http://www.srombauts.fr, comments from an Android developer
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by sparkprime »

still doesn't work for me (linux) -- no error message or change of any kind

it is correct to simply copy the .py file to the addons dir?

~/blender_dev/build/bin/2.56/scripts/addons/addon_ogreDotScene.py
mifth
Gnoblar
Posts: 6
Joined: Mon Sep 27, 2010 11:46 am

Re: Blender25 Ogre Exporter + extended .scene format

Post by mifth »

Change that method:

Code: Select all

bl_info = { 
......

}
instead of bl_addon_info.

And

Code: Select all

"location": "File > Export",
instead of "location": "INFO Menu",
SRombauts
Kobold
Posts: 39
Joined: Mon Feb 28, 2011 6:58 pm
Location: Paris, France
x 2
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by SRombauts »

mifth wrote:Change that method:

Code: Select all

bl_info = { 
......

}
instead of bl_addon_info.

And

Code: Select all

"location": "File > Export",
instead of "location": "INFO Menu",
@mifth Thanks, that's what I did, and it is available in the new BlenderSVN 0.3.1 ZIP

@sparkprime Sorry, I did not try yet the Blender SVN under Linux : did you build it by yourself ? And do you know its exact version (SVN révision) ?
http://www.srombauts.fr, comments from an Android developer
Pforce
Kobold
Posts: 27
Joined: Wed Apr 07, 2010 12:45 am

Re: Blender25 Ogre Exporter + extended .scene format

Post by Pforce »

Hello all,

I have implemented some of the features I was requesting for the realXtend scene format:
  • Fix .rex file extension to .txml as it should be, this is the extension of the format it is generating.
  • Split big Scene.material file to individual material files. This means "material MyTestMaterial { ...}" will get MyTestMaterial.material file.
  • Fix rex scene document material references to point to these individual files depending on what materials the object is using. Multiple materials are supported also with the proper ; separated list that Tundra understands. I left note there though as the submesh indexes might not align with the obj.data.materials list indexes. But like this its already much better than precious "Scene.material" for each. Even if submesh indexes end they have the data in the scene and can switch between materials in the Tundra viewer.
  • Dont insert anyting to material ref value if object does not have values, this will only produce ugly warning/error prints when you import the .txml file into Tundra.
  • Fixed file:// to local:// as this is the proper schema for local files in Tundras AssetAPI.
Now my problem is to get this code in :) I have been added as a contributor but I don't have rights to commit. So SRombauts or bret please apply the changes to the repo.

Here is the patch file hopefully it is easy to apply. This has been done agains the "Default" branch, not the "BlendeSVN". Im sure the patch will apply to the other branch with no problems too. I'm unsure how hg uses patch files, tried to google em but didn't find much, the gui tool let me at least generate one.

http://dl.dropbox.com/u/3589544/code/tu ... ents.patch Let me know when its applied, I have people ready to test it! Thanks!

Once more in text format so people can read it:

Code: Select all

@@ -4137,10 +4137,17 @@
 		M = MISSING_MATERIAL + '\n'
 		for mat in mats:
 			Report.materials.append( mat.name )
-			M += self.gen_dot_material( mat, path, convert_textures=True )
+			data = self.gen_dot_material( mat, path, convert_textures=True )
+			M += data
+			self.dot_material_write_separate( mat, data, path )
 		url = os.path.join(path, '%s.material' %bpy.context.scene.name)
 		f = open( url, 'wb' ); f.write( bytes(M,'utf-8') ); f.close()
 		print('saved', url)
+        
+	def dot_material_write_separate( self, mat, data, path = '/tmp' ):
+		url = os.path.join(path, '%s.material' % mat.name)
+		f = open(url, 'wb'); f.write( bytes(data,'utf-8') ); f.close()
+		print('saved', url)
 
 	## python note: classmethods prefer attributes defined at the classlevel, kinda makes sense, (even if called by an instance)
 	@classmethod
@@ -4214,16 +4221,33 @@
 
 		a = doc.createElement('attribute'); c.appendChild(a)
 		a.setAttribute('name', "Mesh ref" )
-		a.setAttribute('value', "file://%s.mesh"%ob.data.name )
+		a.setAttribute('value', "local://%s.mesh"%ob.data.name )
 
 		a = doc.createElement('attribute'); c.appendChild(a)
 		a.setAttribute('name', "Mesh materials" )
-		a.setAttribute('value', "file://%s.material"%bpy.context.scene.name )
+        
+		# Query object its materials and make a proper material ref string of it.
+		# note: We assume blindly here that the 'submesh' indexes are correct in the material list.
+		#       the most common usecase is to have one material per object for rex artists.
+		#       They can now assign multiple and they will at least go to the .txml data but I cant
+		#       guarantee that they are in correct submesh index slots! At least they have the refs and 
+		#       can manually shift them around in the viewer.
+		mymaterials = ob.data.materials
+		if mymaterials != None and len(mymaterials) > 0:
+			mymatstring = ''
+			# generate ; separated material list and remove last ;
+			for mymat in mymaterials: 
+				mymatstring += 'local://' + mymat.name + '.material;'
+			mymatstring = mymatstring[0:-1]
+			a.setAttribute('value', mymatstring )
+		else:
+			# defaul to nothing to avoid error prints in .txml import
+			a.setAttribute('value', "" ) 
 
 		if ob.find_armature():
 			a = doc.createElement('attribute'); c.appendChild(a)
 			a.setAttribute('name', "Skeleton ref" )
-			a.setAttribute('value', "file://%s.skeleton"%ob.data.name )
+			a.setAttribute('value', "local://%s.skeleton"%ob.data.name )
 
 		a = doc.createElement('attribute'); c.appendChild(a)
 		a.setAttribute('name', "Draw distance" )
@@ -4415,7 +4439,7 @@
 
 		if self.EX_SCENE:
 			data = rex.toprettyxml()
-			f = open( url+'.rex', 'wb' ); f.write( bytes(data,'utf-8') ); f.close()
+			f = open( url+'.txml', 'wb' ); f.write( bytes(data,'utf-8') ); f.close()
 			print('realxtend scene dumped', url)
 
 			data = doc.toprettyxml()
Ps. I was very suprised that the whole file used TABs instead of 4 spaces :I Well that I can get over with. But SRombauts was right that the one big >4000 lines python file is not good, I spent 10x more time looking at the spots I need to poke than to write the actual implementation. "class MaterialManager" in a separate file would have helped immensely :)
antont
Gnoblar
Posts: 22
Joined: Fri Mar 11, 2005 8:12 am
Location: Oulu, Finland
x 1
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by antont »

A couple short comments about Pforce's work, keeping brief to not hijack this thread with realXtend specific things too much. Just to clarify some info to not get misunderstandings about the designs:

reX does support the file: URL standard too, local: is just a special addition that queries subdirs as well. The actual prob was that we haven't yet implemented relative refs, so that you can't just say "my.mesh" in a scene file and it'd work no matter if you are using file: or http: or whatever to load the scene from the same place. So Pforce basically suggests using local: as a workaround in .rex/.txml files for now for relative refs. Hopefully we get this fixed soon enough (like in 1-2 months, before get more urgent stuff done first).

Similarily for materials: it is probably a good idea to put many materials in a single file, for example with http that results in much less requests for tiny text snippets. It is just not implemented yet in Naali/Tundra material assets, where currently the material refs in mesh material slots / submeshes are to material files which are assumed to contain a single material only. Should be easy to add support for pointing to e.g. http://myserver/materialbunde.material#materialname when this splitting wouldn't be needed anymore.

So the changes in the patch are useful workarounds now, and possibly useful as options later, but I think once we get the things fixed on reX side may be better to return to not splitting the materials.
~Toni
SRombauts
Kobold
Posts: 39
Joined: Mon Feb 28, 2011 6:58 pm
Location: Paris, France
x 2
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by SRombauts »

sparkprime wrote:still doesn't work for me (linux) -- no error message or change of any kind

it is correct to simply copy the .py file to the addons dir?
Please, what exact Blender version are you using?

You have to copy the file to scripts/addons then enable it in Blender user preferences menu (CTRL+ALT+U)
http://www.srombauts.fr, comments from an Android developer
SRombauts
Kobold
Posts: 39
Joined: Mon Feb 28, 2011 6:58 pm
Location: Paris, France
x 2
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by SRombauts »

Hi Pforce, thanks for helping!

Could you add to your patch a configuration flag to make it optional?
For now a simple variable with some if/else to be able to keep the old behavior if wanted?
http://www.srombauts.fr, comments from an Android developer
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by sparkprime »

SRombauts wrote: @sparkprime Sorry, I did not try yet the Blender SVN under Linux : did you build it by yourself ? And do you know its exact version (SVN révision) ?
Yes, i compiled it myself, 35621
Pforce
Kobold
Posts: 27
Joined: Wed Apr 07, 2010 12:45 am

Re: Blender25 Ogre Exporter + extended .scene format

Post by Pforce »

SRombauts wrote:Hi Pforce, thanks for helping!

Could you add to your patch a configuration flag to make it optional?
For now a simple variable with some if/else to be able to keep the old behavior if wanted?
No this is not needed. As said the old behavior was broken and did nothing, thats why i fixed it. Imporatent to note: this only modifies the realXtend scene export and splitting the materials. Not the ogre export in any way. If you want me to add a UI checkbox to split the materials, I think this is not needed as nothing works without it. If you want to skip the material file splitting when rex export is not on, that I can understand.

I think the UI does not have button to disable rex export that I could then also skip splitting the material files :P Can you just add this, I mean there is already a checkbox to disable material export, then the splitting is not done ofc.
SRombauts
Kobold
Posts: 39
Joined: Mon Feb 28, 2011 6:58 pm
Location: Paris, France
x 2
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by SRombauts »

Pforce wrote:If you want to skip the material file splitting when rex export is not on, that I can understand.

... I mean if there is already a checkbox to disable material export, then the splitting is not done ofc.
Yes, that's the point : please add a configuration variable like "bSplitMaterials", then it would be easy to link it to an UI button when possible :)
http://www.srombauts.fr, comments from an Android developer
hartsantler
Greenskin
Posts: 107
Joined: Tue Nov 16, 2010 7:33 am
x 15

Re: Blender25 Ogre Exporter + extended .scene format

Post by hartsantler »

Hi Pforce, Antont, and other Rex'ers,
Note that .txml (formerly .rex) output is something i just hacked in quickly, i am not sure if it complete or how compatible it is; the exporter is meant to really just support ogre-dot-scene. However if it remains useful, its only a few function calls, is only a slight overhead on speed, so we might as well keep it. One issue might be hierarchies, ogre-dot-scene says each child will be nested under the parents xml element and the transform is an offset from the parent - but with .txml output the hierarchy the child's transform is not an offset of the parent, is that correct for realxtend? objects are in worldspace?
-hart
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by sparkprime »

The problem is with the documentation -- it doesn't mention that you have to enable the addon in the user preferences panel, and before you do this there is no indication that it is correctly installed and it does not try and read the .py file.

Now, I have problems with OgreXMLConverter incorrectly being called OgreXmlConverter but I can hack this in the script

It's also assuming it ends in .exe and the whole approach of using wine to run these commands on linux is braindead -- there are native binaries that will work much better.
SRombauts
Kobold
Posts: 39
Joined: Mon Feb 28, 2011 6:58 pm
Location: Paris, France
x 2
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by SRombauts »

sparkprime wrote:The problem is with the documentation -- it doesn't mention that you have to enable the addon in the user preferences panel, and before you do this there is no indication that it is correctly installed and it does not try and read the .py file.
Thanks to mention that, I corrected it in the Wiki (http://code.google.com/p/blender2ogre/wiki/Installation) and in the script itself !
sparkprime wrote:Now, I have problems with OgreXMLConverter incorrectly being called OgreXmlConverter but I can hack this in the script

It's also assuming it ends in .exe and the whole approach of using wine to run these commands on linux is braindead -- there are native binaries that will work much better.
1) I've double checked (http://www.ogre3d.org/download/tools) "OgreXmlConverter.exe" is the right name under Windows (not case sensitive by the way)
2) OgreXmlConverter is not official provided under Linux (oops, see edit bellow) : do you have a link to the wiki or a forum thread to download it for Linux ?
3) All this turn around one issue : I have to add a config file and UI !!! (issue7: http://code.google.com/p/blender2ogre/i ... etail?id=7)

Thanks again for your remarks, and any help is welcome !
SRombauts

edit: Oh oh, it seems that there is a Debian package called "ogre-tools", with a "/usr/bin/OgreXMLConverter", sorry !
http://www.srombauts.fr, comments from an Android developer
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by sparkprime »

you should run OgreXMLConverter from the path -- don't hardcode /usr/bin as many people are not using ogre from apt

or at least allow the dir to be chosen in some configuration
f00bar
Halfling
Posts: 57
Joined: Sun Feb 15, 2009 4:00 am
x 1

Re: Blender25 Ogre Exporter + extended .scene format

Post by f00bar »

I was too lazy to install the dependencies to the right place, so I added a config file named blender2ogre.cfg: auto generated if not existing, backward compatible (default values determined exacly as in old code). The file is generated in the blender folder if not found there, maybe a problem for users without write permission.

example blender2ogre.cfg:

Code: Select all

[paths]
image_magick = C:\Program Files\ImageMagick-6.6.8-Q16
myshaders = C:\myshaders
ogretools = C:\Users\fb\dev\ogre-1.8-hg\SDK\bin\release
nvidiatools = C:\Program Files\NVIDIA Corporation\DDS Utilities
ogre_meshy = C:\Users\fb\bin\OgreMeshy.1.01.Win32__Ogre_1.8.0\Ogre Meshy.exe
[edit] of course feel free to merge, if the code is not too ugly for you [/edit]
Attachments
blender2ogre_rev6.patch
tortoisehg patch against Rev5
(4.15 KiB) Downloaded 303 times
Pforce
Kobold
Posts: 27
Joined: Wed Apr 07, 2010 12:45 am

Re: Blender25 Ogre Exporter + extended .scene format

Post by Pforce »

Yey for configs. I'd like to see this + my patch in the repo asap.

Btw. I am not going to make another patch that has some random var that tries to prepare for a situation when we one day have ui button for material splitting. That is just, well, I don't see the point. Please apply my stuff or do I have to make a fork to github :)

Edit. Aha apparently brett gave me commit rights now ;) I guess ill put it in myself then. Yey for brett!
SRombauts
Kobold
Posts: 39
Joined: Mon Feb 28, 2011 6:58 pm
Location: Paris, France
x 2
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by SRombauts »

f00bar wrote:... so I added a config file named blender2ogre.cfg: auto generated if not existing, backward compatible (default values determined exactly as in old code).
... of course feel free to merge, if the code is not too ugly for you
Thanks a lot, I will try to merge it quickly so that Pforce could merge its own patch properly :)
http://www.srombauts.fr, comments from an Android developer
SRombauts
Kobold
Posts: 39
Joined: Mon Feb 28, 2011 6:58 pm
Location: Paris, France
x 2
Contact:

Re: Blender25 Ogre Exporter + extended .scene format

Post by SRombauts »

Ok, I've merged the config patch and made some improvement to it (but more are still needed, like the place where to put the config file!).
It works perfectly under Windows.

I've also converted all tabulation into 4 spaces each :)

That was issue7 and issue10.

Now I definitely need to try and improve all this for Linux, hopefully later during the weekend.
http://www.srombauts.fr, comments from an Android developer
f00bar
Halfling
Posts: 57
Joined: Sun Feb 15, 2009 4:00 am
x 1

Re: Blender25 Ogre Exporter + extended .scene format

Post by f00bar »

Ok, I've merged the config patch and made some improvement to it
Thanks a lot for all your work.

PS: For me, the skeleton has a different orientation than the mesh at the moment (official blender 2.56a). But maybe I do something wrong.
Post Reply