My favourite trick!


05-04-2007 09:39:52

Are you tired of not being able to print Vector3s in your application without extracting the x,y,z components? Have no fear!
Just paste this immediately after the "import Ogre" line in you main file:

def v3repr(self):
return str((self.x, self.y, self.z))
Ogre.Vector3.__repr__ = v3repr

This gives the Ogre.Vector3 class a "representation" method that turns the x,y,z triples into a parenthesized string of the components.
"print v" will now yield the expected results.

Don't you love python?


05-04-2007 10:11:11

A simular work around is in the in the Python-Ogre SVN (I don't think it made the 0.9 release)...

And in version 1.0 (nearly there) you get it for free as the Ogre 1.4 library implemented the operator<< function in the Vector3 class..

And I agree -- Python is cool in it's ability to do this..

On another topic, do you have any test code I can use that shows the node->SceneNode/Bone problem -- I've fixed the problem in the SVN code but wasn't able to duplicate the orginal issue for test purposes (if I walk the skeletons in the demos they just work...)




06-04-2007 08:59:51

I hacked around the issue by walking over the submeshes instead, so I dont really have the code that exhibited the issue. I'll hack up a copy.