Hi, greetz to all in the forum
Been looking for a way to use the ogre scene XML files with pyOgre, couldn't find a way to do it, so I sat down and wrote a parser in python. Now, I'm no python expert, but it does seem to be doing things right, however, it seems to have a problem instantiating the ogre sceneManager. Could someone with more pyogre skill than me have a look and see what I'm doing wrong?
Fixed now, and updated, the module below will allow you to open scene.xml files created by blender, albeit not rotated correctly.
if you want to use this script, you'll need the pyXML module from:
the error i GOT was (at the bottom of a long traceback):
File "C:\Documents and Settings\.....\Desktop\myPyOgreProject\SceneLoader.py", line 143, in createOgreNode
node = self.sceneManager.rootSceneNode.createChildSceneNode(name)
File "C:\Python24\Lib\site-packages\pyogre\ogre.py", line 15213, in createChildSceneNode
NotImplementedError: No matching function for overloaded 'SceneNode_createChildSceneNode'
Solution kindly pointed out to me was that the xml parser was feeding unicode into the rest of the script, judicious use of str() float() sorts that out.
Aha, just saw the 'No Matching function' thread, I will link this thread from there, although are any devs actually watching that thread now?
Don't think it's a problem with createChildSceneNode. I seem to recall having similar problems when creating a DotScene/Octree parser. I think it was either an null name or I resolved it by moving the createChildSceneNode(name) into startElement/endElement. The code to create the ChildSceneNode works for me and is similar to yours:
sn = self.sceneManager.rootSceneNode.createChildSceneNode(self.node.getName())
I'd post the full code here but it's probably too large (i.e. convoluted).
Here is what made it work for me. Instead of
self.currNode = self.sceneManager.rootSceneNode.createChildSceneNode(name) Try:
self.currNode = self.sceneManager.rootSceneNode.createChildSceneNode(str(name))
And instead of
self.currNode.position = ogre.Vector3(x, y, z) Try:
self.currNode.position = ogre.Vector3(float(x), float(y), float(z))
It seems to me that the xml parser is returning all values as unicode.
Aha, thanks muchly!, try it out now
The link was dead, so I wrote my own
I thought I would put it here for others who are in search of this.
It doesn't have any of the other attributes like skyDome, etc, but it will render a blender scene, quickly with the export plugin, and give you an idea of how to start on your own dotScene parser.
Dang, sorry, the file must have got deleted
i took a quick look at the script and its similar to mine, but definitely looks a bit more complete
on a similar tip ..
im trying to implement terrain reasoning at the moment and will release the source here if i ever get it complete:
basically a way to export waypoints from blender in a prepackaged and easy to use format for your in-game AI. I've got 80% of it complete, but the pre-calculations being done on the map in blender take forever
however, it will work out the walkable space on your map, and rate all the points for sniping suitability.
i'm saving a graph of waypoints via pickle, which contains methods to do lookups for AI 'point-finding' (sadly not path-finding yet) with an octree. Not really sure if that is best but hey
it means you can load it and get going quite fast with writing your AI actions, without having to make them aware of the level space
anyway i will do a post in the near future when i get it to work (much) better in Blender
I made some updates to the script to work with new versions of python-ogre, and added a better explanation (in a blender file)