Getting/Setting of member variables?

Pod

29-07-2009 17:59:35

Hello, I'm trying to do tutorial 1 and I've noticed an 'inconsistency' in python-Ogre that I'd like to understand.

sceneManager.ambientLight = (0.3, 0.8, 1)
this works fine.

However:
entity.visible = False

does not work. I have to use entity.SetVisible(False).

Is there a rule on when I can and can't set protected/private member variables? If so, what is it? :)

Cheers.

andy

30-07-2009 00:10:54

What you are seeing is one of the challenges when trying to take a C++ library and make a Python wrapper -- by default the C++ library doesn't have 'properties' as such, instead it implements setters and getters.. In the case of getAmbientLight. we have:
//property "AmbientLight"[fget=::Ogre::SceneManager::getAmbientLight, fset=::Ogre::SceneManager::setAmbientLight]
So you are not actually accessing a C++ variable directly, instead we are using C++ functions and hiding these in a Python 'property'.

In the code generation we try and add properties for every getter/setter that we can find (it's automated as manually tracking this would be impossible) AND at times we have to miss one, either because the property name we create would hide a function of the same name, OR (as with entity) it isn't clear what functions to use. Looks like entity defines getVisible and isVisible both getters) so we don't know which one to use and hence take the safe approach and don't implement the property..

How that helps..

Andy

Nosferax

30-07-2009 14:49:12

So it is all generated automatically? Nice !