python / PyOgre dotscene xml loader [ Fixed ]

bharling

30-06-2006 13:19:08

Hi, greetz to all in the forum :P

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.

http://www.zerofilter.com/pyogre/pyOgreDotSceneLoader.zip

if you want to use this script, you'll need the pyXML module from:

http://pyxml.sourceforge.net/

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
return _ogre.SceneNode_createChildSceneNode(*args)
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.

bharling

30-06-2006 14:39:07

Aha, just saw the 'No Matching function' thread, I will link this thread from there, although are any devs actually watching that thread now?

dermont

30-06-2006 16:14:49

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).

Istari

30-06-2006 16:23:17

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.

bharling

30-06-2006 17:24:26

Aha, thanks muchly!, try it out now :D

bharling

30-06-2006 17:42:09

:P :P :lol: :lol:

worked, thankyou !
have updated the link above with the working loader if anyone wants it

http://www.zerofilter.com/pyogre/pyOgreDotSceneLoader.zip

konsumer

12-01-2007 06:06:54

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.

bharling

13-01-2007 18:37:32

Dang, sorry, the file must have got deleted :cry:

i took a quick look at the script and its similar to mine, but definitely looks a bit more complete :) nice!

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:

http://www.cgf-ai.com/docs/gdc2001_paper.pdf

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 :cry:
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 :wink:

konsumer

06-05-2007 05:42:15

I made some updates to the script to work with new versions of python-ogre, and added a better explanation (in a blender file)

Here.