Tag Archives: Python

Some tips on building fuse-python on Mac OS X

I can’t document everything from scratch since I don’t have a machine that’s “virgin” enough for me to document that. This machine has been touched by Fink, MacPorts, Rudix, and several hand-build packages; I’m not sure if MacFUSE installs the necessary stuff for pkg-config.

But, let’s presume you:
a) installed macfuse,
b) fetched pkg-config source code from freedesktop.org (I took 0.25)
c) built it and installed it (./configure, make, sudo make install)
d) switched to pristine Python 2.6 that Apple ships with Snow Leopard.

I’m also obviously using Snow Leopard, so no guarantees about other OS X versions.

Ok, and now come the tips…
Continue reading

Assigning UTF8 display strings in PythonOgre with CEGUI 0.6.2b

If you just do:

line=f.readline()
cegui.wm[“destination”][“Text”]=line
# Of course: cegui.wm=cegui.WindowManager.getSingleton()

then, despite “line” being UTF8, some piece of code will attempt to convert it into something “appropriate.” We don’t want that. We want our UTF8 string to be displayed with correct encoding, without guesses about what to convert it into — because the guess is incorrect! (It looks like it converts it into ascii or some Western European codepage).

So let’s force the wrapper to do the right thing:

line=f.readline()
line_cg=cegui.String(); line_cg.assign(line)
cegui.wm[“destination”][“Text”]=line_cg

Or you may prefer a utility function which does that:

def getDisplayString(txt):
  cg_string=cegui.String()
  cg_string.assign(line)
  return cg_string


line=f.readline()
cegui.wm[“destination”][“Text”]=getDisplayString(line)

This was necessary on PythonOgre SVN revision 996, wrapping Ogre 1.6.1 and CEGUI 0.6.2b for Python 2.5, on Mac. 
Image courtesy of Bart Simpson Chalkboard Generator from addletters.com

Axis aligned boxes on particle systems in Ogre3d and PythonOgre


/Users/ivucica/Developer/ogre/Mac/Ogre/../../OgreMain/include/OgreAxisAlignedBox.h:246: failed assertion `(min.x <= max.x && min.y <= max.y && min.z <= max.z) && "The minimum corner of the box must be less than or equal to maximum corner"'

In Cateia, we were getting this bug on one particular place in the game, related to a particle system in Ogre3D.
We use PythonOgre and we normally quite liberally throw around try..except blocks to catch issues. Most exceptions are caught properly on the Python level because PythonOgre wraps most Ogre3D exceptions. However, this is not an exception, this is an assertion.
Basically, particle systems in Ogre are interesting in that they automatically update their own AAB (axis aligned boundary [box]) for initial 10 seconds (after which they are presumed to reach their maximum size). You can change the length during which update will happen, if at all.
We have a particle system of water which falls to the ground. This means that at one point AAB becomes very, very small (or perhaps even inverses itself?) Since our game is a 2.5D adventure (2D backgrounds, 3D characters), we really don’t need AABs that much because only objects that are on scene are relevant.
So the solution is:
   aabInf=ogre.AxisAlignedBox()
   aabInf.setInfinite()
   self.ps.setBounds(aabInf)
   self.ps.setBoundsAutoUpdated(False, 0)
We expand to infinite boundary box, and tell the particle system not to update itself. C++ code is the same.