Ogre don't show sutdown messages

IchUndNichtDu

28-10-2012 10:56:03

If i shutdown my programm it don't show me messages like "plugin succesfully uninstalled" or other. Is this normal? What does it mean? What can i do?
The programm is shuted down by an False returned in frameStarted()
I'm using Python-ogre 1.7.2
i'm using windows 7
i'm using python 2.7.3

dermont

03-11-2012 06:27:11

If i shutdown my programm it don't show me messages like "plugin succesfully uninstalled" or other. Is this normal? What does it mean? What can i do?
The programm is shuted down by an False returned in frameStarted()
I'm using Python-ogre 1.7.2
i'm using windows 7
i'm using python 2.7.3


First check your log/console output for any errors on shutdown.

Otherwise it looks like the you are not cleaning up properly on shutdown. This normally happens when you hold a reference to something that may only be deleted on garbage collection, i.e. the order of deletion may not be as you expect.

It would be easier if you could upload a simple example illustrating the problem.

IchUndNichtDu

03-11-2012 12:05:47

Maybe i forgot to Cleanup something
Here my (for this post changed) Code
import ogre.renderer.OGRE as ogre
import ogre.io.OIS as OIS

class Player(object):
name = "player"
mesh = "Kubus.mesh"
x = 0
y = 0
z = 0
speed = 0.01

class World(object):
def __init__(self):
self.objects = [Player()]

world = World()

class Application(object):
def __init__(self, player):
assert player in world.objects
self.player = player

def go(self):
self.create_root()
self.define_ressources()
self.choose_rendersystem()
self.create_window()
self.initialise_ressources()
self.scene()
self.start_packages()
self.create_framelistener()
self.start()
self.end()

def create_root(self):
self.root = ogre.Root()

def define_ressources(self):
config = ogre.ConfigFile()
config.load("resources.cfg")
seci = config.getSectionIterator()
while seci.hasMoreElements():
name = seci.peekNextKey()
settings = seci.getNext()
for value in settings:
typ = value.key
path = value.value
ogre.ResourceGroupManager.getSingleton().addResourceLocation(path, typ, name)

def choose_rendersystem(self):
if not self.root.restoreConfig() and not self.root.showConfigDialog():
exit()

def create_window(self):
self.root.initialise(True, "MMORPG")

def initialise_ressources(self):
ogre.TextureManager.getSingleton().setDefaultNumMipmaps(5)
ogre.ResourceGroupManager.getSingleton().initialiseAllResourceGroups()

def scene(self):
self.sceneManager = self.root.createSceneManager(ogre.ST_GENERIC, "Default sceneManager")
i = 0
for thing in world.objects:
name = thing.name + " #%s" % i
entity = self.sceneManager.createEntity(name, thing.mesh)
node = self.sceneManager.getRootSceneNode().createChildSceneNode(name + "-node", (thing.x, thing.y, thing.z))
node.attachObject(entity)
thing.node = node
light = self.sceneManager.createLight("light")
light.type = ogre.Light.LT_POINT
light.position = 0, 400, 400
light.diffuseColour = 1, 1, 1
light.specularColour = 1, 1, 1
self.sceneManager.ambientLight = 1, 1, 1
self.camera = self.sceneManager.createCamera("camera")
self.camera.nearClipDistance = 1
self.camera.farClipDistance= 100000
self.camera.lookAt((0, 0, 0))
self.player.node.attachObject(self.camera)
self.camera.position = 0, 0, 10
viewPort = self.root.getAutoCreatedWindow().addViewport(self.camera)
viewPort.backgroundColour = 0, 0, 0

def start_packages(self):
window = self.root.getAutoCreatedWindow()
windowhandle = window.getCustomAttributeInt("WINDOW")
parameter = [("WINDOW", str(windowhandle))]
self.inputManager = OIS.createPythonInputSystem(parameter)

self.keyboard = self.inputManager.createInputObjectKeyboard(OIS.OISKeyboard, False)
self.mouse = self.inputManager.createInputObjectMouse(OIS.OISMouse, False)
try:
self.joystick = self.inputManager.createInputObjectJoyStick(OIS.OISJoyStick, False)
except:
self.joystick = None


def create_framelistener(self):
self.control = Control(self, self.keyboard, self.mouse, self.joystick)
self.root.addFrameListener(self.control)

def start(self):
self.root.startRendering()

def end(self):
self.inputManager.destroyInputObjectKeyboard(self.keyboard)
self.inputManager.destroyInputObjectMouse(self.mouse)
if self.joystick:
self.inputManager.destroyInputObjectJoyStick(self.joystick)
OIS.InputManager.destroyInputSystem(self.inputManager)
self.inputManager = None

class Control(ogre.FrameListener, OIS.KeyListener, OIS.MouseListener, OIS.JoyStickListener):
def __init__(self, application, keyboard, mouse, joystick = 0):
ogre.FrameListener.__init__(self)
OIS.KeyListener.__init__(self)
OIS.MouseListener.__init__(self)
OIS.JoyStickListener.__init__(self)
keyboard.setEventCallback(self)
self.keyboard = keyboard
mouse.setEventCallback(self)
self.mouse = mouse
if joystick:
joystick.setEventCallback(self)
self.joystick = joystick
else:
self.joystick = False
self.application = application
self.rotation = 0.1

self.tab = False

def frameStarted(self, frameEvent):
self.keyboard.capture()
self.mouse.capture()

if self.joystick:
self.joystick.capture()

if not self.keyPressed(frameEvent):
return False

self.mouseMoved(frameEvent)

return True


def keyPressed(self, frameEvent):
if self.keyboard.isKeyDown(OIS.KC_ESCAPE):
return False

if self.keyboard.isKeyDown(OIS.KC_W):
self.application.player.node.translate(0, 0, -self.application.player.speed, self.application.player.node.TS_LOCAL)

if self.keyboard.isKeyDown(OIS.KC_S):
self.application.player.node.translate(0, 0, self.application.player.speed, self.application.player.node.TS_LOCAL)

if self.keyboard.isKeyDown(OIS.KC_A):
self.application.player.node.translate(-self.application.player.speed, 0, 0, self.application.player.node.TS_LOCAL)

if self.keyboard.isKeyDown(OIS.KC_D):
self.application.player.node.translate(self.application.player.speed, 0, 0, self.application.player.node.TS_LOCAL)

if self.keyboard.isKeyDown(OIS.KC_TAB):
if not self.tab:
if self.application.camera.position == (0, 0, 0):
self.application.camera.position = 0, 0, 10
else:
self.application.camera.position = 0, 0, 0
self.tab = True
else:
self.tab = False

return True

def mouseMoved(self, frameEvent):
move = self.mouse.getMouseState()
self.application.player.node.yaw(ogre.Degree(move.X.rel).valueRadians() * -self.rotation)
self.application.player.node.pitch(ogre.Degree(move.Y.rel).valueRadians() * -self.rotation)

def __del__(self):
del self.steuerung
del self.root

Application(world.objects[0]).go()

dermont

03-11-2012 13:48:12

Try adding some debug statements to your __del__ methods. You will probably find with your code it that the ogre root is not being deleted.


def __del__(self):
print "DELETE XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
del self.root


Try updating your code with something like:


# def __del__(self):
# #del self.steuerung
# del self.root


def end(self):
self.inputManager.destroyInputObjectKeyboard(self.keyboard)
self.inputManager.destroyInputObjectMouse(self.mouse)
if self.joystick:
self.inputManager.destroyInputObjectJoyStick(self.joystick)
OIS.InputManager.destroyInputSystem(self.inputManager)
self.inputManager = None
-> self.root.removeFrameListener(self.control)
-> del self.control
-> del self.root

IchUndNichtDu

03-11-2012 21:20:22

Thanks it works after i moved the deletes from the __del__ to the end function.