Rectangle2D missing inherited methods?


07-07-2006 02:29:48

According to the Ogre manual,, Rectangle2D has (among others) "setMaterial" and "setRenderGroup" methods. These attributes appears to be missing in the current CVS bindings (both trunk and dev1.2.0).

>>> dir(ogre.Rectangle2D)
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__swig_destroy__', '__weakref__', 'boundingRadius', 'getSquaredViewDepth', 'setCorners', 'thisown', 'usesIdentityProjection', 'usesIdentityView']

Actually, Rectangle2D is supposed to inherit from SimpleRenderable which has a very extensive set of methods (but which is also missing the setRenderGroup" method):

>>> dir(ogre.SimpleRenderable)
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__swig_destroy__', '__weakref__', '_getManager', '_notifyCreator', '_notifyManager', 'addQueryFlags', 'addVisibilityFlags', 'attached', 'boundingBox', 'boundingRadius', 'castShadows', 'castsShadows', 'createAnimableValue', 'getAnimableValueNames', 'getCustomParameter', 'getDefaultQueryFlags', 'getDefaultVisibilityFlags', 'getRenderingDistance', 'getSquaredViewDepth', 'getTypeFlags', 'getUserAny', 'getVisibilityFlags', 'inScene', 'material', 'movableType', 'name', 'normaliseNormals', 'numWorldTransforms', 'parentNode', 'parentSceneNode', 'polygonModeOverrideable', 'queryFlags', 'removeQueryFlags', 'removeVisibilityFlags', 'renderQueueGroup', 'setCustomParameter', 'setDefaultQueryFlags', 'setDefaultVisibilityFlags', 'setMaterial', 'setRenderOperation', 'setRenderingDistance', 'setUserAny', 'setVisibilityFlags', 'setWorldTransform', 'technique', 'thisown', 'useIdentityProjection', 'useIdentityView', 'visible', 'worldBoundingBox', 'worldBoundingSphere', 'worldOrientation', 'worldPosition']

So it seems like there are a number of holes in pyOgre at present. Is there a detailed list of what still needs to be done?


07-07-2006 06:52:40

Follow-up to my original post, I just discovered that Rectangle2D is listed as NEW in the pyOgreTODO file for the dev1.2.0 SVN branch ...


07-07-2006 11:29:22

Yep the Rectangle2D was listed as NEW in the pyOgreTODO meaning that I added a new interface file for Rectangle2D. The pyOgreTODO was meant to be a quick summary, for passing on to the new maintainer, of the changes I made from version1.0.6 to 1.2.0 and the things that I were aware at that time that needed addressing.

Yes there are a number of holes in pyOgre at present, some have always been there, and not all are included in the Todo list.

Regarding the Rectangle2D/SimpleRenderable inheritance, I've double checked and ran through my original test case on:

  1. 1. dev1.2.0 bindings
    2. Istari's build(1.2.0)
    3. My own build (1.2.1)
    and the Rectangle2D / SimpleRenderable inheritance appears to be working properly.

    The trunk bindings are for Ogre1.0.6, the dev1.2.0 bindings for Ogre1.2.0 and the apis you pointed to (I think) are for Ogre1.2.1.
    Are you sure your using the 'branches/dev-1.2.0/' branch or Istari's build above. Here's my test case code (based on DWord's wiki example) if it's
    any use (you'll still have some work to do on deletion of rect):

    # This code is in the Public Domain
    from pyogre import ogre
    import SampleFramework as sf

    class SmokeApplication(sf.Application):

    def __init__(self):
    self.rect = None

    def __del__(self):
    "Clear variables, this should not actually be needed."
    print 1
    del self.rect
    print 2

    del self.sceneManager
    del self.frameListener
    del self.root
    del self.renderWindow

    def _printInfo(self,rect2D):

    print "------------- Rectangle2D ---------------------"
    print dir(ogre.Rectangle2D)

    print "------------- Class Rectangle2D ---------------------"
    print dir(rect2D)

    print "------------- Type Rectangle2D ---------------------"
    print type(rect2D)

    def _createScene(self):
    sceneManager = self.sceneManager
    camera =

    sceneManager.ambientLight = (0.5, 0.5, 0.5)
    #sceneManager.setSkyDome(True, 'Examples/CloudySky', 5.0, 8.0)

    self.fountainNode = sceneManager.rootSceneNode.createChildSceneNode()

    psm = ogre.ParticleSystemManager.getSingleton()
    particleSystem2 = sceneManager.createParticleSystem('fountain1', 'Examples/Smoke')
    node = self.fountainNode.createChildSceneNode()

    #Create background material
    material = ogre.MaterialPointer(ogre.MaterialManager.getSingleton().create("Background", "General"))

    material.getTechnique(0).getPass(0).depthCheckEnabled = False
    material.getTechnique(0).getPass(0).depthWriteEnabled = False

    #Disable lighting on the background (it will show as fully lit)
    material.getTechnique(0).getPass(0).lightingEnabled = False

    rect = ogre.Rectangle2D(True)
    rect.setCorners(-1.0, 1.0, 1.0,-1.0)
    v = ogre.Vector3.UNIT_SCALE
    #print v
    min = ogre.Vector3(v.x*-100000.0,v.y*-100000.0,v.z*-100000.0)
    max = ogre.Vector3(v.x*100000.0,v.y*100000.0,v.z*100000.0)
    #print min,max

    rect.boundingBox = ogre.AxisAlignedBox(min,max)
    rect.boundingBox.setExtents(-1.0, 1.0, 0, 1.0, -1.0, 0)

    self.rect = rect

    self.node = sceneManager.rootSceneNode.createChildSceneNode("Background")

    material.getTechnique(0).getPass(0).getTextureUnitState(0).setScrollAnimation(-0.25, 0.0)


    if __name__ == '__main__':
    application = SmokeApplication()
    except ogre.OgreException, e:
    print e


07-07-2006 21:26:22

Hi Dermont,

I rebuilt the dev1.2.0 bindings (as per this morning and it appears to be working. I don't know where my problem lay ... but it's gone now ;-)

On a related note, two problems have cropped up in my medviz demo when using the dev1.2.0 bindings:

1) ogre.Camera seems to be missing the setPolygonMode method.

2) ogre.Quaternion constructor

>>> from pyogre import ogre
>>> ogre.Quaternion(ogre.Radian(ogre.Degree(-17)), ogre.Vector3(0,0,1))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "c:\cygwin\home\darran\trunk\DemoSystem\lib\pyogre\", line 2819, in __init__
TypeError: in method 'new_Quaternion', argument 1 of type 'Ogre::Real'

Can you offer any advice about these issues? Should I be using your 1.2.1 build? If so, is the source available?

$ svn list


07-07-2006 22:48:45

1) The get/setPolygonMode have been wrapped as polygonMode, take a look at, e.g. = ogre.PM_SOLID

2) The ogre.Quaternion constructor I believe is due to the new typemap implementation of Ogre::Radian where a float is now implicitly converted to Ogre::Radian:

So your code will probably be something like:

ogre.Quaternion(ogre.Degree(-17).valueRadians(), ogre.Vector3(0,0,1))

You may encounter similar problems/crashes with Abs,Cos,Sin,Sign,Sqrt and Tan. For me it was all pretty confusing and I felt more more comfortable with the original implementation so I just reverted back to the old typemap.

3) Regarding the 1.2.1 build, as far as I remember pyOgre compiled as is.
There's probably quite a few updates still required for Ogre 1.2.1 but given the APIs are for 1.2.1, the number of bug fixes from 1.2.0 and the current status of 1.2.0 it would make sense to move the development branch to 1.2.1.


09-07-2006 07:44:19

For anyone trying to get Rectangle2D working with pyOgre, there is the slim chance that the following might be of help ... ;-)

I just spent several hours trying to understand why my background image wasn't appearing. It turned out that making the Rectangle2D instance persistent via the line

self.rect = rect

is critically important. Without it, I don't get an error - just a black background as if the rectangle is being culled (which is what I thought was happening).