Weird behaviour with Manual Object

lodr

17-01-2011 10:40:05

Hello everybody.

First say hello: Hello!

I need some explanation about a weird behaviour I found using Python Ogre for the first time.

I'm working with manual objects and I have extended ManualObject with Environment. So, the process to attach my Environment instance to the SceneManager is as follows:


node = sceneManager.getRootSceneNode().createChildSceneNode("DataNode")
self.env = Environment("my_environment", buffers)
node.attachObject(self.env)


Ok, this works with any problem. But now, I was trying to reduce the number of members of my classes in order to use names of the meshes and nodes instead. I'm not asking if it is a better way, I was just trying. So I replace the former code by this:


node = sceneManager.getRootSceneNode().createChildSceneNode("DataNode")
env = Environment("my_environment", buffers)
node.attachObject(env)


Note how 'env' is a local variable (not a member) now. In this case, my manual object does not reder.

I suposed it could be related with the garbage collector so I disable it at the beginning of the module but it continues to not rendering.

Can someone explain me what happend? It is not urgent, I can continue with my application but I cannot explain myself what happend.

Thanks a lot.

Vi3GameHkr

17-01-2011 17:41:56

My guess would be the obvious guess that since the environment is local, the renderer can't access it. When you call attachObject, you give it a reference to env and then when the function in which you define env returns, env disappears so the renderer doesn't have anything to render.