Confused noob question about CEGUI

The amazing Noob

08-11-2008 14:58:58

Hey all,
I've been puttering around with the wiki tutorials trying to figure out how python-ogre works, but when I get to lesson 6 (the first time that the code doesn't use SampleFramework coincidentally ^^) I get a nasty error trying to set up CEGUI and I can't understand why. I'm using version 2.5.2 of python and a prebuilt Ogre SDK for VC++ 2008 express edition.


def setupCEGUI(self):
sM = self.root.getSceneManager("Default SceneManager")
renderWindow = self.root.getAutoCreatedWindow()
self.renderer = CEGUI.OgreCEGUIRenderer(renderWindow,ogre.RENDER_QUEUE_OVERLAY, False, 3000, sM)
self.system = CEGUI.System(self.renderer)


The error I get when I run it is here:
Traceback (most recent call last):
File "basic_6.py", line 106, in <module>
ta.go()
File "basic_6.py", line 25, in go
self.setupCEGUI()
File "basic_6.py", line 80, in setupCEGUI
self.system = CEGUI.System(self.renderer)
RuntimeError: DynamicModule::DynamicModule - Failed to load module 'CEGUITinyXML
Parser': The specified module could not be found.


I went searching around in some of the CEGUI source files trying to find where it references CEGUITinyXMLParser, but the only reference I can find is to an Expat XML parser, and I don't find any files related to CEGUITinyXML.
Any help on this would be appreciated, thanks!

andy

08-11-2008 21:49:16

You need to tell CEGUI what parser to use. Check out CEGUI_framework.py (in the demos/CEGUI directory) which does..
# Another fix for CEGUI to ensure we get a working parser..
if os.name == 'nt':
CEGUI.System.setDefaultXMLParserName("ExpatParser")
else:
CEGUI.System.setDefaultXMLParserName("TinyXMLParser")


Regards
Andy

The amazing Noob

09-11-2008 01:51:41

Well, I found 3 CEGUI_framework.py's (including the one in the cegui folder) and changed all of them to always set "ExpatParser" as the default parser name, but no luck was had UNTIL I found the __init__.py file under C:\Python25\Lib\site-packages\ogre\gui\CEGUI actually had a reference to TinyXMLParser as well! Problem solved.

On an unrelated note, ParticleGS isn't majorly important to Ogre, is it? Seems to not compile when I run anything.

andy

09-11-2008 07:58:50

What version of Python-Ogre are you using -- the fix for CEGUI is in the SVN and is part of the 1.6RC1 release...

And they (the cegui_frameworks) override the __init__ in the gui/cegui module hence this shouldn't have been an issue -- however I've updated the __init__ with the same code as in the framework..

What is the issue with ParticleGS???

Andy

The amazing Noob

09-11-2008 14:41:59

Looks like I'm using 1.6RC1 for python-ogre and 1.6.0RC1 for ogre, which I should probably update to the final ver.

Nothing wrong about ParticleGS, per se, just that it yells at me whenever I run a script.

High-level program Ogre/ParticleGS/GenerateVS encountered an error during loadin
g and is thus not supported.
OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/Part
icleGS/GenerateVS: CG ERROR : The compile returned an error.
(0) : error C6015: Output 'POSITION' not completely written
in CgProgram::loadFromSource at ..\src\OgreCgProgramManagerDll.cpp (line 66)
High-level program Ogre/ParticleGS/DisplayVS encountered an error during loading
and is thus not supported.
OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/Part
icleGS/DisplayVS: CG ERROR : The compile returned an error.
(249) : warning C7050: "output.color" might be used before being initialized
(0) : error C6015: Output 'POSITION' not completely written
in CgProgram::loadFromSource at ..\src\OgreCgProgramManagerDll.cpp (line 66)
expr: (sampler) diffuseTex
High-level program Ogre/ParticleGS/DisplayPS encountered an error during loading
and is thus not supported.
OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/Part
icleGS/DisplayPS: CG ERROR : The compile returned an error.
(323) : fatal error C9999: unexpected cast operation
in CgProgram::loadFromSource at ..\src\OgreCgProgramManagerDll.cpp (line 66)

Nodin

24-12-2008 17:31:55

I'm having the exact same issues, is there any resolution?
I'm running 1.6.0 (Python-Ogre-1.6.0-r789-py252.exe)...

09:11:16: Parsing script ParticleGS.material
09:11:16: OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/ParticleGS/GenerateVS: CG ERROR : The compile returned an error.
(0) : error C6015: Output 'POSITION' not completely written
in CgProgram::loadFromSource at ..\src\OgreCgProgramManagerDll.cpp (line 66)
09:11:16: High-level program Ogre/ParticleGS/GenerateVS encountered an error during loading and is thus not supported.
OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/ParticleGS/GenerateVS: CG ERROR : The compile returned an error.
(0) : error C6015: Output 'POSITION' not completely written
in CgProgram::loadFromSource at ..\src\OgreCgProgramManagerDll.cpp (line 66)
09:11:16: OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/ParticleGS/DisplayVS: CG ERROR : The compile returned an error.
(249) : warning C7050: "output.color" might be used before being initialized
(0) : error C6015: Output 'POSITION' not completely written
in CgProgram::loadFromSource at ..\src\OgreCgProgramManagerDll.cpp (line 66)
09:11:16: High-level program Ogre/ParticleGS/DisplayVS encountered an error during loading and is thus not supported.
OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/ParticleGS/DisplayVS: CG ERROR : The compile returned an error.

Here is my source created from the tutorial;


import ogre.renderer.OGRE as ogre
import ogre.io.OIS as OIS
import ogre.gui.CEGUI as CEGUI

class EventListener(ogre.FrameListener, ogre.WindowEventListener, OIS.MouseListener, OIS.KeyListener, OIS.JoyStickListener):
"""
This class handles all our ogre and OIS events, mouse/keyboard/joystick
depending on how you initialize this class. All events are handled
using callbacks (buffered).
"""

mouse = None
keyboard = None
joy = None

def __init__(self, renderWindow, bufferedMouse, bufferedKeys, bufferedJoy):

# Initialize the various listener classes we are a subclass from
ogre.FrameListener.__init__(self)
ogre.WindowEventListener.__init__(self)
OIS.MouseListener.__init__(self)
OIS.KeyListener.__init__(self)
OIS.JoyStickListener.__init__(self)

self.renderWindow = renderWindow

# Create the inputManager using the supplied renderWindow
windowHnd = self.renderWindow.getCustomAttributeInt("WINDOW")
self.inputManager = OIS.createPythonInputSystem([("WINDOW",str(windowHnd))])

# Attempt to get the mouse/keyboard input objects,
# and use this same class for handling the callback functions.
# These functions are defined later on.

try:
if bufferedMouse:
self.mouse = self.inputManager.createInputObjectMouse(OIS.OISMouse, bufferedMouse)
self.mouse.setEventCallback(self)

if bufferedKeys:
self.keyboard = self.inputManager.createInputObjectKeyboard(OIS.OISKeyboard, bufferedKeys)
self.keyboard.setEventCallback(self)

if bufferedJoy:
self.joy = self.inputManager.createInputObjectJoyStick(OIS.OISJoyStick, bufferedJoy)
self.joy.setEventCallback(self)

except Exception, e: # Unable to obtain mouse/keyboard/joy input
raise e

# Set this to True when we get an event to exit the application
self.quitApplication = False

# Listen for any events directed to the window manager's close button
ogre.WindowEventUtilities.addWindowEventListener(self.renderWindow, self)
def __del__ (self ):
# Clean up OIS
print "QUITING"
self.delInputObjects()

OIS.InputManager.destroyInputSystem(self.inputManager)
self.inputManager = None

ogre.WindowEventUtilities.removeWindowEventListener(self.renderWindow, self)
self.windowClosed(self.renderWindow)

def delInputObjects(self):
# Clean up the initialized input objects
if self.keyboard:
self.inputManager.destroyInputObjectKeyboard(self.keyboard)
if self.mouse:
self.inputManager.destroyInputObjectMouse(self.mouse)
if self.joy:
self.inputManager.destroyInputObjectJoy(self.mouse)

def frameStarted(self, evt):
"""
Called before a frame is displayed, handles events
(also those via callback functions, as you need to call capture()
on the input objects)

Returning False here exits the application (render loop stops)
"""

# Capture any buffered events and call any required callback functions
if self.keyboard:
self.keyboard.capture()
if self.mouse:
self.mouse.capture()
if self.joy:
self.joy.capture()

# Neatly close our FrameListener if our renderWindow has been shut down
if(self.renderWindow.isClosed()):
return False

return not self.quitApplication

### Window Event Listener callbacks ###

def windowResized(self, renderWindow):
pass

def windowClosed(self, renderWindow):
# Only close for window that created OIS
if(renderWindow == self.renderWindow):
del self

### Mouse Listener callbacks ###

def mouseMoved(self, evt):
# Pass the location of the mouse pointer over to CEGUI
CEGUI.System.getSingleton().injectMouseMove(evt.get_state().X.rel, evt.get_state().Y.rel)
return True

def mousePressed(self, evt, id):
# Handle any CEGUI mouseButton events
CEGUI.System.getSingleton().injectMouseButtonDown(self.convertButton(id))
return True

def mouseReleased(self, evt, id):
# Handle any CEGUI mouseButton events
CEGUI.System.getSingleton().injectMouseButtonUp(self.convertButton(id))
return True


def convertButton(self,oisID):
if oisID == OIS.MB_Left:
return CEGUI.LeftButton
elif oisID == OIS.MB_Right:
return CEGUI.RightButton
elif oisID == OIS.MB_Middle:
return CEGUI.MiddleButton
else:
return CEGUI.LeftButton

### Key Listener callbacks ###

def keyPressed(self, evt):
# Quit the application if we hit the escape button
if evt.key == OIS.KC_ESCAPE:
self.quitApplication = True

if evt.key == OIS.KC_1:
print "hello"

return True

def keyReleased(self, evt):
return True

### Joystick Listener callbacks ###

def buttonPressed(self, evt, id):
return True

def buttonReleased(self, evt, id):
return True

def axisMoved(self, evt, id):
return True

class Application(object):

app_title = "MyApplication"

def go(self):
# See Basic Tutorial 6 for details
self.createRoot()
self.defineResources()
self.setupRenderSystem()
self.createRenderWindow()
self.initializeResourceGroups()
self.setupScene()
self.createFrameListener()
self.setupCEGUI()
self.startRenderLoop()
#self.cleanUp()

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

def defineResources(self):
# Read the resources.cfg file and add all resource locations in it
cf = ogre.ConfigFile()
cf.load("resources.cfg")
seci = cf.getSectionIterator()
while seci.hasMoreElements():
secName = seci.peekNextKey()
settings = seci.getNext()

for item in settings:
typeName = item.key
archName = item.value
ogre.ResourceGroupManager.getSingleton().addResourceLocation(archName, typeName, secName)


def setupRenderSystem(self):
# Show the config dialog if we don't yet have an ogre.cfg file
if not self.root.restoreConfig() and not self.root.showConfigDialog():
raise Exception("User canceled config dialog! (setupRenderSystem)")

def createRenderWindow(self):
self.root.initialise(True, self.app_title)

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

def setupScene(self):
self.renderWindow = self.root.getAutoCreatedWindow()
self.sceneManager = self.root.createSceneManager(ogre.ST_GENERIC, "Default SceneManager")
self.camera = self.sceneManager.createCamera("Camera")
viewPort = self.root.getAutoCreatedWindow().addViewport(self.camera)

self.camera.setPosition(ogre.Vector3(0, 100, -400))
self.camera.lookAt(ogre.Vector3(0, 0, 1))


self.sceneManager.setAmbientLight(ogre.ColourValue(0.7,0.7,0.7))
self.sceneManager.setSkyDome(True, 'Examples/CloudySky',4, 8 )
self.sceneManager.setFog( ogre.FOG_EXP, ogre.ColourValue(1,1,1),0.0002)
self.light = self.sceneManager.createLight( 'lightMain')
self.light.setPosition ( ogre.Vector3(20, 80, 50) )

self.rn = self.sceneManager.getRootSceneNode()

self.entityOgre = self.sceneManager.createEntity('Ogre','ogrehead.mesh')
self.nodeOgre = self.rn.createChildSceneNode('nodeOgre')
self.nodeOgre.setPosition(ogre.Vector3(0, 0, 0))
self.nodeOgre.attachObject(self.entityOgre)


def createFrameListener(self):
self.eventListener = EventListener(self.renderWindow, True, True, False)
self.root.addFrameListener(self.eventListener)

def setupCEGUI(self):
sceneManager = self.sceneManager

# CEGUI
self.renderer = CEGUI.OgreCEGUIRenderer(self.renderWindow, ogre.RENDER_QUEUE_OVERLAY, False, 3000, sceneManager)
self.system = CEGUI.System(self.renderer)

CEGUI.SchemeManager.getSingleton().loadScheme("TaharezLookSkin.scheme")
self.system.setDefaultMouseCursor("TaharezLook", "MouseArrow")
self.system.setDefaultFont("BlueHighway-12")

# Uncomment the following to read in a CEGUI sheet (from CELayoutEditor)
#
# self.mainSheet = CEGUI.WindowManager.getSingleton().loadWindowLayout("myapplication.layout")
# self.system.setGUISheet(self.mainSheet)

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

def cleanUp(self):
# Clean up CEGUI
print "CLEANING"
#del self.renderer
del self.system

# Clean up Ogre
#del self.exitListener
del self.root


if __name__ == '__main__':
try:
ta = Application()
ta.go()
except ogre.OgreException, e:
print e