UTFString error

skorpio

23-09-2007 23:53:14

Hello,

when I tried to update one of the fields I get a
RuntimeError: unidentifiable C++ exception

Here is what I was doing

name= node2.getAttribute("name")
print name
self._setGuiCaption('Core/DebugText', name)

where node2 is an XML node that contains the data I would like to apprear on the overlay

I tried different ways to do it but all generated the same error. The error is coming from here

element.setCaption(ogre.UTFString(text))

Is there a way to force the variable name to be compatible with UFTString?

Thanks for your help
-Best regards

andy

25-09-2007 10:32:06

Have you tried simply doing a setCaption(text) ??

If this doesn't work can you let us know what version of Python-Ogre you are using along with a small test program

Thanks
Andy

skorpio

26-09-2007 06:06:14

Thanks, for the tip
I tried it but it did not work.

Here is the sample code you requested


import ogre.renderer.OGRE as ogre
import ogre.io.OIS as OIS
import SampleFramework as sf
import string

import xml.dom.minidom
from xml.dom.minidom import Node
doc = xml.dom.minidom.parse("name.xml")


class TutorialFrameListener(sf.FrameListener):
def __init__(self, renderWindow, camera, sceneManager,AnimStateList,AnimEntNodes):
sf.FrameListener.__init__(self, renderWindow, camera)

self.mAnimStateList = AnimStateList
self.mAnimEntNodeList = AnimEntNodes
self.sceneManager = sceneManager


def frameStarted(self, evt):

if self._isToggleKeyDown(OIS.KC_1,0.25):
title2 = "Hello"
self._setGuiCaption('Core/DebugText', title2)


if self._isToggleKeyDown(OIS.KC_2,0.25):
name=""
for node in doc.getElementsByTagName("section"):
node_section = node.getElementsByTagName("SectionName")
for node2 in node_section:
name = node2.getAttribute("name")
print name
self._setGuiCaption('Core/DebugText', name)


return sf.FrameListener.frameStarted(self, evt)


class TutorialApplication(sf.Application):

def __init__(self):
self.animationStates = []
self.sceneEntNodes=[]
sf.Application.__init__(self)

def _createScene(self):
# first edit
sceneManager = self.sceneManager
sceneManager.ambientLight = ogre.ColourValue(1.0, 1.0, 1.0)
sceneManager.shadowTechnique = ogre.SHADOWTYPE_STENCIL_ADDITIVE


plane = ogre.Plane(ogre.Vector3(0, 1, 0), 0)
mm = ogre.MeshManager.getSingleton()
mm.createPlane('ground', 'general', plane, 700,700, 20, 20,
True, 1, 5, 5, ogre.Vector3(0, 0, 1),
ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY,
ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY,
True,True )
ent = sceneManager.createEntity("GroundEntity", "ground")
node = sceneManager.rootSceneNode.createChildSceneNode("GroundNode",ogre.Vector3(0, 0, 0))
node.attachObject(ent)
ent.setMaterialName("Examples/Rockwall")


# Accept default settings: point light, white diffuse, just set position
light = sceneManager.createLight( 'MainLight' )
self.rotationNode = sceneManager.getRootSceneNode().createChildSceneNode()
self.rotationNode.createChildSceneNode( ogre.Vector3(0,5,0) ).attachObject( light )

entity = sceneManager.createEntity("Ninja", "ninja.mesh")
entNode = sceneManager.rootSceneNode.createChildSceneNode("NinjaNode", ogre.Vector3(0, 0, 0))
entity.castShadows = True
entNode.attachObject(entity)


# create the first camera node/pitch node
node = sceneManager.rootSceneNode.createChildSceneNode("CamNode1", ogre.Vector3(0, 100, -300))
node = node.createChildSceneNode("PitchNode1")
node.attachObject(self.camera)


def _createFrameListener(self):
self.frameListener = TutorialFrameListener(self.renderWindow,
self.camera,
self.sceneManager,
self.animationStates,self.sceneEntNodes
)
self.root.addFrameListener(self.frameListener)
self.frameListener.showDebugOverlay(True)


if __name__ == '__main__':
ta = TutorialApplication()
ta.go()



The name.xml is short

<?xml version="1.0" encoding="ISO-8859-1"?>

<section revision="0">
<SectionName name="Name From Here"/>
</section>




In this example if I press "1" then I get a Hello
but if I press "2" I get an unidentifible C++ exception.

In the debug window I can see the print but it crashes right after.

I'm using Python1RC

Thanks for all your help.

andy

26-09-2007 07:45:18

Could you please download Python-Ogre 1.0 and test it as the bug you are having is already fixed..

I've run your test program without any problems -- of course you don't actually see your debugtext as it's overwritten by the sample framework in _updateStatistics -- however I commented out the offending line in sf_OIS.py (in \python25\lib\site-packages\ogre\renderer\OGRE )
## self._setGuiCaption('Core/DebugText', Application.debugText)
And your test worked great

Cheers
Andy

skorpio

29-09-2007 08:20:53

Yes,

Updating to 1.0 fix the problem.

Thanks