[Python-ogre-commit] SF.net SVN: python-ogre:[744] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-09-18 18:11:56
|
Revision: 744 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=744&view=rev Author: andy_miller Date: 2008-09-19 01:11:49 +0000 (Fri, 19 Sep 2008) Log Message: ----------- Updates for QuickGUI source Hikari almost completed Added Hikari media and demo to the SVN Started adding descriptions etc to environment.py Fix to sampleframework due to Ogre 1.6 API changes Extended sampleframework to allow OIS flags to be passed - needed for Hikari as it wants a system mouse pointer Modified Paths: -------------- trunk/python-ogre/ChangeLog.txt trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.h trunk/python-ogre/code_generators/hikari/generate_code.py trunk/python-ogre/code_generators/hikari/hand_made_wrappers.py trunk/python-ogre/code_generators/hikari/python_hikari_sizeof.h trunk/python-ogre/environment.py trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py Added Paths: ----------- trunk/python-ogre/demos/hikari/ trunk/python-ogre/demos/hikari/Demo_Hikari_01.py trunk/python-ogre/demos/hikari/media/ trunk/python-ogre/demos/hikari/media/controls.fla trunk/python-ogre/demos/hikari/media/controls.swf trunk/python-ogre/demos/hikari/media/fps.fla trunk/python-ogre/demos/hikari/media/fps.swf trunk/python-ogre/demos/hikari/resources.cfg Modified: trunk/python-ogre/ChangeLog.txt =================================================================== --- trunk/python-ogre/ChangeLog.txt 2008-09-18 03:03:32 UTC (rev 743) +++ trunk/python-ogre/ChangeLog.txt 2008-09-19 01:11:49 UTC (rev 744) @@ -1,10 +1,20 @@ -August 29 2008 : Release 1.6 RC1 -================================ +xxxx xx 2008 : Release 1.6.0 xxxx +================================== + +Updates to QuickGUI and Caelum C++ library source +Implemented Hikari demo (implemented callbacks in the wrapper generation) +Fixed code generation for QuickGui, bullet and noise to correctly generate PyDoc documentation strings +Implemented description text and description links in environment.py to help automate module summary + + + +August 29 2008 : Release 1.6.0 RC1 +================================== The Python-Ogre version numbering has changed to match the Ogre release versions along with the SVN release numbering 'Python-Ogre-<ogre version>-<SVN Version>-<Python Version>' Built using MSVC 9, DirectX August 2008, Boost 1.36.0, Py++ r1383 -** Modules Included and thier versions ** +** Modules Included and their versions ** OGRE 1.6.0RC1 OIS 1.2 CEGUI 0.6.1 Modified: trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.cpp =================================================================== --- trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.cpp 2008-09-18 03:03:32 UTC (rev 743) +++ trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.cpp 2008-09-19 01:11:49 UTC (rev 744) @@ -3,6 +3,8 @@ namespace QuickGUI { + Character::Character() {}; + Character::Character(Ogre::UTFString::code_point cp, Ogre::FontPtr fp, Ogre::ColourValue cv) : codePoint(cp), fontPtr(fp), Modified: trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.h =================================================================== --- trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.h 2008-09-18 03:03:32 UTC (rev 743) +++ trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.h 2008-09-19 01:11:49 UTC (rev 744) @@ -56,8 +56,8 @@ /// UV coords of glyph, retreived from Font texture generated by Ogre::Font class. UVRect uvCoords; + protected: Character(); - protected: bool mHighlighted; bool mWhiteSpace; Modified: trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.cpp =================================================================== --- trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.cpp 2008-09-18 03:03:32 UTC (rev 743) +++ trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.cpp 2008-09-19 01:11:49 UTC (rev 744) @@ -9,6 +9,9 @@ { new ScriptReader(); } + + ScriptReader::ScriptReader(ScriptReader const&) {}; // copy ctor is hidden + //ScriptReader::ScriptReader& operator=(ScriptReader const&) {}; // assign op is hidden ScriptReader::ScriptReader() : mBegin(false) Modified: trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.h =================================================================== --- trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.h 2008-09-18 03:03:32 UTC (rev 743) +++ trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.h 2008-09-19 01:11:49 UTC (rev 744) @@ -62,9 +62,9 @@ void parseScript(Ogre::DataStreamPtr &stream, const Ogre::String &groupName); // void parseScript(std::ifstream& stream, const Ogre::String& groupName); + protected: ScriptReader(ScriptReader const&); // copy ctor is hidden ScriptReader& operator=(ScriptReader const&); // assign op is hidden - protected: static ScriptReader* mSingletonPtr; Modified: trunk/python-ogre/code_generators/hikari/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/hikari/generate_code.py 2008-09-18 03:03:32 UTC (rev 743) +++ trunk/python-ogre/code_generators/hikari/generate_code.py 2008-09-19 01:11:49 UTC (rev 744) @@ -53,7 +53,9 @@ if MAIN_NAMESPACE: main_ns = global_ns.namespace( MAIN_NAMESPACE ) else: - main_ns = global_ns + main_ns = global_ns + + ## Need to review these as they will be needed... excludes = ['::Hikari::Position::left', '::Hikari::Position::top', '::Hikari::Position::position', @@ -63,6 +65,15 @@ for x in excludes: main_ns.variable(x).exclude() + excludes = ['::Hikari::FlashControl::bind' # implemented in hand_made_wrappers + ,'::Hikari::FlashControl::unbind' + +# ,'::Hikari::FlashControl::callFunction' # uses Args which we don't have a to python converter for +# remove default creator on args... + + ] + for x in excludes: + main_ns.mem_fun(x).exclude() ############################################################ ## ## And there are things that manually need to be INCLUDED @@ -106,7 +117,19 @@ def create_output( size ): return [ ft.output( i ) for i in range( size ) ] - + +# x =global_ns.mem_fun('::Hikari::FlashControl::getExtents') +# x.add_transformation(ft.inout('width'),ft.inout('height')) +# x.documentation = docit ("","width,height", "tuple - width,height") +# +# x =global_ns.mem_fun('::Hikari::FlashControl::getUVScale') +# x.add_transformation(ft.inout('uScale'),ft.inout('vScale')) +# x.documentation = docit ("","uScale,vScale", "tuple - uScale,vScale") + +# # # # x= main_ns.mem_funs('::Caelum::Astronomy::getGregorianDateFromJulianDay') +# # # # x.add_transformation( ft.output('year'), ft.output('month'), ft.output('day'), alias = 'getGregorianDateFromJulianDay' ) +# # # # x.documentation = docit ("","JulianDay", "tuple - year,month,day") + ############################################################################### ## Modified: trunk/python-ogre/code_generators/hikari/hand_made_wrappers.py =================================================================== --- trunk/python-ogre/code_generators/hikari/hand_made_wrappers.py 2008-09-18 03:03:32 UTC (rev 743) +++ trunk/python-ogre/code_generators/hikari/hand_made_wrappers.py 2008-09-19 01:11:49 UTC (rev 744) @@ -1,8 +1,72 @@ import os import environment +WRAPPER_DEFINITION_FlashControl=\ +""" +class PythonDispatcher +{ +public: + PythonDispatcher(PyObject* subscriber, ::Ogre::String const & method) + { + mSubscriber = subscriber; + mMethod = method; + } + ~PythonDispatcher() {} + Hikari::FlashValue callback ( Hikari::FlashControl* me, const Hikari::Arguments& args ) + { + Hikari::FlashValue retval ; + if (mMethod.length() > 0 ) + retval = boost::python::call_method<Hikari::FlashValue>(mSubscriber, mMethod.c_str(), + boost::ref(me), args ); + else + retval = boost::python::call<Hikari::FlashValue>(mSubscriber, + boost::ref(me), args ); + return retval; + } +private: + PyObject* mSubscriber; + std::string mMethod; +}; + +// Bind function takes name of 'flash' command, plus a python object with optional method name if it's a class + +std::map<std::string,PythonDispatcher *> m_mapDispatchers; + +int FlashControl_bind(Hikari::FlashControl & me, std::string const & pFuncName, + PyObject * subscriber, std::string const & method = "") +{ + PythonDispatcher *pDispatch = new PythonDispatcher(subscriber, method); + m_mapDispatchers[pFuncName] = pDispatch; + me.bind(pFuncName, Hikari::FlashDelegate(pDispatch, &PythonDispatcher::callback)); + return 0; +} + +int FlashControl_unbind(Hikari::FlashControl & me, std::string const & funcName) +{ + me.unbind(funcName); + std::map<std::string,PythonDispatcher *>::iterator it = m_mapDispatchers.find(funcName); + if(it != m_mapDispatchers.end()) + { + delete (*it).second; + m_mapDispatchers.erase(it); + } + return 0; +} + + +""" +WRAPPER_REGISTRATION_FlashControl = [ + """def( "bind", &::FlashControl_bind , + "Python-Ogre Helper Function: Binds a python object as the callback for a flash event\\n\\ + Input: Flash Function/Event Name, Python Callback Option, Optional method name\\n\\ + Ouput: 0" );""", + """def( "unbind", &::FlashControl_unbind , + "Python-Ogre Helper Function: Unbinds from a Flash event\\n\\ + Input: Flash Function/Event Name\\n\\ + Ouput: 0" );""" + ] ################################################################################################# ################################################################################################# @@ -11,5 +75,7 @@ class_.add_registration_code ( c ) def apply( mb ): - pass + rt = mb.class_( 'FlashControl' ) + rt.add_declaration_code( WRAPPER_DEFINITION_FlashControl ) + apply_reg (rt, WRAPPER_REGISTRATION_FlashControl ) \ No newline at end of file Modified: trunk/python-ogre/code_generators/hikari/python_hikari_sizeof.h =================================================================== --- trunk/python-ogre/code_generators/hikari/python_hikari_sizeof.h 2008-09-18 03:03:32 UTC (rev 743) +++ trunk/python-ogre/code_generators/hikari/python_hikari_sizeof.h 2008-09-19 01:11:49 UTC (rev 744) @@ -1 +1,4 @@ // sizeof ( variable ); +sizeof ( Hikari::Args ); +sizeof ( Hikari::Arguments ); + Added: trunk/python-ogre/demos/hikari/Demo_Hikari_01.py =================================================================== --- trunk/python-ogre/demos/hikari/Demo_Hikari_01.py (rev 0) +++ trunk/python-ogre/demos/hikari/Demo_Hikari_01.py 2008-09-19 01:11:49 UTC (rev 744) @@ -0,0 +1,133 @@ +# This code is in the Public Domain +# ----------------------------------------------------------------------------- +# This source file is part of Python-Ogre +# For the latest info, see http://python-ogre.org/ +# +# It is likely based on original code from OGRE and/or PyOgre +# For the latest info, see http://www.ogre3d.org/ +# +# You may use this sample code for anything you like, it is not covered by the +# LGPL. +# ----------------------------------------------------------------------------- +import sys +sys.path.insert(0,'..') +import PythonOgreConfig +import ogre.renderer.OGRE as ogre +import SampleFramework as sf +import ogre.gui.hikari as hikari +import ogre.io.OIS as ois +import os + +def TEST(caller, args): + return True + +class HikariApplication(sf.Application): + def _createScene(self): + + sceneManager = self.sceneManager + camera = self.camera + + sceneManager.ambientLight = ogre.ColourValue(0.5, 0.5, 0.5) +# sceneManager.ambientLight = ogre.ColourValue(ogre.ColourValue.White) + print ogre.ColourValue.White + sceneManager.setShadowTechnique(ogre.SHADOWTYPE_TEXTURE_ADDITIVE) + self.setupHikari() + + def setupHikari(self): + self.hikariMgr = hikari.HikariManager(".\\media") + + self.fps = self.hikariMgr.createFlashOverlay("FPS", self.viewport, 130, 91, hikari.Position(hikari.TopLeft)) + self.fps.load("fps.swf") + self.fps.setTransparent(True) + self.fps.setDraggable(False) + + self.controls = self.hikariMgr.createFlashOverlay("Controls", self.viewport, 350, 400, hikari.Position(hikari.Center)) + self.controls.load("controls.swf") + self.controls.setTransparent(True, True) + +# self.controls.bind("opacityChange", TEST,"" ) ## self, "onOpacityChange") + self.controls.bind("opacityChange", self, "onOpacityChange") + self.controls.bind("colorChange", self, "onColorChange") + self.controls.bind("exitClick", self, "onExitClick") + + + def onOpacityChange(self, caller, args): + opacityPercent = args[0].getNumber() + caller.setOpacity(opacityPercent / 100) + return hikari.FlashValue() + + def onColorChange(self, caller, args): + color = args[0].getNumberAsColor() + self.viewport.setBackgroundColour(color) + return hikari.FlashValue() + + def onExitClick(self, caller, args): + self.frameListener.shouldQuit = True + return hikari.FlashValue() + + def _createFrameListener(self): + self.frameListener = HikariListener( self ) + self.root.addFrameListener(self.frameListener) + + +class HikariListener(sf.FrameListener, ois.MouseListener, ois.KeyListener): + def __init__(self, app): + sf.FrameListener.__init__(self, app.renderWindow, app.camera, bufferedKeys = False) + ois.KeyListener.__init__(self) + ois.MouseListener.__init__(self) + self.app = app + self.Mouse.setEventCallback(self) + self.MenuMode = True # stops the mouse moving the background + self.Keyboard.setEventCallback(self) + + def mouseMoved(self,arg): + state= arg.get_state() + return self.app.hikariMgr.injectMouseMove(state.X.abs, state.Y.abs) or self.app.hikariMgr.injectMouseWheel(state.Z.rel) + + def mousePressed(self, arg, id): + return self.app.hikariMgr.injectMouseDown(id) + + def mouseReleased(self, arg, id): + return self.app.hikariMgr.injectMouseUp(id) + + def keyPressed( self, arg): + if self.app.hikariMgr.isAnyFocused(): + return True + return False + + def keyReleased ( self, arg ): + k = arg.key + if k == ois.KC_ESCAPE: + self.shouldQuit = True + elif k == ois.KC_F2: + self.app.sceneManager.getRootSceneNode().flipVisibility(True) + return True + + + def _inputSystemParameters (self ): + """ the demo needs the system mouse + """ + if os.name == 'nt': + print "NT" + return [("w32_mouse","DISCL_FOREGROUND"), ("w32_mouse", "DISCL_NONEXCLUSIVE")] + else: + return [("x11_mouse_grab","false"), ("x11_mouse_hide", "false")] ## untested + + + def frameStarted(self, frameEvent): + self.app.hikariMgr.update() +# root.renderOneFrame() +# Ogre::WindowEventUtilities::messagePump() + + stats = self.renderWindow.getStatistics() + self.app.fps.callFunction("setFPS", hikari.Args(hikari.FlashValue(stats.lastFPS) )) + return sf.FrameListener.frameStarted(self, frameEvent) + + + +if __name__ == '__main__': + try: + application = HikariApplication() + application.go() + except ogre.OgreException, e: + print e Property changes on: trunk/python-ogre/demos/hikari/media/controls.fla ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: trunk/python-ogre/demos/hikari/media/controls.swf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: trunk/python-ogre/demos/hikari/media/fps.fla ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: trunk/python-ogre/demos/hikari/media/fps.swf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/python-ogre/demos/hikari/resources.cfg =================================================================== --- trunk/python-ogre/demos/hikari/resources.cfg (rev 0) +++ trunk/python-ogre/demos/hikari/resources.cfg 2008-09-19 01:11:49 UTC (rev 744) @@ -0,0 +1,24 @@ +[Bootstrap] +Zip=../media/packs/OgreCore.zip + +# Resource locations to be added to the default path +[General] +FileSystem=../media +FileSystem=../media/fonts +FileSystem=../media/sounds +FileSystem=../media/Audio +FileSystem=../media/materials/programs +FileSystem=../media/materials/scripts +FileSystem=../media/materials/textures +FileSystem=../media/models +FileSystem=../media/overlays +FileSystem=../media/particle +FileSystem=../media/gui +Zip=../media/packs/cubemap.zip +Zip=../media/packs/cubemapsJS.zip +Zip=../media/packs/dragon.zip +Zip=../media/packs/fresneldemo.zip +Zip=../media/packs/ogretestmap.zip +Zip=../media/packs/skybox.zip + +FileSystem=./media Modified: trunk/python-ogre/environment.py =================================================================== --- trunk/python-ogre/environment.py 2008-09-18 03:03:32 UTC (rev 743) +++ trunk/python-ogre/environment.py 2008-09-19 01:11:49 UTC (rev 744) @@ -1545,6 +1545,7 @@ CCFLAGS = ' -D_PRECOMP ' ModuleName = 'OgreBulletD' CheckIncludes=['boost/python.hpp', 'Ogre.h'] + descText = "Ogre Bullet Dynamics (physics) implementation" class noise: active = True @@ -1563,6 +1564,7 @@ CheckIncludes=[] libs=[ boost.lib] ModuleName="noise" + descText = "Generate 'noise'" class watermesh: active = True @@ -1581,6 +1583,7 @@ CheckIncludes=[] libs=[ boost.lib, 'OgreMain' ] ModuleName="watermesh" + descText = "C++ code from Ogre Water demo -- use Hydrax instead" class ofusion: active = True @@ -1599,6 +1602,7 @@ CheckIncludes=[] libs=[ boost.lib, 'OgreMain' ] ModuleName="ofusion" + descText = "Import Ogre 'Scenes' from 3dMax using the ofusion exporter" class cadunetree: active = True @@ -1616,7 +1620,8 @@ ] CheckIncludes=[] libs=[ boost.lib, 'OgreMain' ] - ModuleName="cadunetree" + ModuleName="cadunetree" + descText = "Generate realistic trees" class ogrepcz: active = True @@ -1634,7 +1639,8 @@ ] CheckIncludes=[] libs=[ boost.lib, 'Plugin_PCZSceneManager', 'OgreMain' ] - ModuleName="ogrepcz" + ModuleName="ogrepcz" + descText = "Portal SceneManager - seamlessly move from interior to exterior scene management" class opensteer: active = False @@ -1670,7 +1676,8 @@ ] CheckIncludes=[] libs=[ boost.lib, 'OgreMain' ] - ModuleName="hydrax" + ModuleName="hydrax" + descText = "Fantastic water/ocean effects" class hikari: active = True @@ -1690,6 +1697,8 @@ CheckIncludes=[] libs=[ boost.lib, 'OgreMain', 'hikari' ] ModuleName="hikari" + descText = "Use Flash controls within Ogre" + descLink = "http://hikari-library.googlecode.com/" ############################################################################################ Modified: trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py =================================================================== --- trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py 2008-09-18 03:03:32 UTC (rev 743) +++ trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py 2008-09-19 01:11:49 UTC (rev 744) @@ -219,12 +219,16 @@ self.translateVector = ogre.Vector3(0.0,0.0,0.0) self.filtering = ogre.TFO_BILINEAR self.showDebugOverlay(True) + self.rotateSpeed = ogre.Degree(36) self.moveSpeed = 100.0 self.rotationSpeed = 8.0 self.displayCameraDetails = False self.bufferedKeys = bufferedKeys self.bufferedMouse = bufferedMouse + self.rotationX = ogre.Degree(0.0) + self.rotationY = ogre.Degree(0.0) self.bufferedJoy = bufferedJoy + self.shouldQuit = False # set to True to exit.. self.MenuMode = False # lets understand a simple menu function ## we can tell if we are using OgreRefapp based upon the camera class @@ -237,7 +241,12 @@ def __del__ (self ): ogre.WindowEventUtilities.removeWindowEventListener(self.renderWindow, self) self.windowClosed(self.renderWindow) - + + def _inputSystemParameters (self ): + """ ovreride to extend any OIS system parameters + """ + return [] + def _setupInput(self): # ignore buffered input @@ -252,8 +261,10 @@ else: windowHnd = self.renderWindow.getCustomAttributeInt("WINDOW") - self.InputManager = \ - OIS.createPythonInputSystem([("WINDOW",str(windowHnd))]) + t= self._inputSystemParameters() + params = [("WINDOW",str(windowHnd))] + params.extend(t) + self.InputManager = OIS.createPythonInputSystem( params ) #pl = OIS.ParamList() #windowHndStr = str ( windowHnd) @@ -301,22 +312,52 @@ OIS.InputManager.destroyInputSystem(self.InputManager) self.InputManager=None + + ## NOTE the in Ogre 1.6 (1.7) this is changed to frameRenderingQueued !!! def frameRenderingQueued ( self, evt ): - return True - - def frameStarted(self, frameEvent): - if(self.renderWindow.isClosed()): + if(self.renderWindow.isClosed() or self.shouldQuit ): return False - ##Need to capture/update each device - this will also trigger any listeners self.Keyboard.capture() self.Mouse.capture() + buffJ = True if( self.Joy ): self.Joy.capture() + buffJ = self.Joy.buffered() + + ##Check if one of the devices is not buffered + if self.Mouse.buffered() or self.Keyboard.buffered() or not buffJ : + ## one of the input modes is immediate, so setup what is needed for immediate movement + if self.timeUntilNextToggle >= 0: + self.timeUntilNextToggle -= evt.timeSinceLastFrame + + ## Move about 100 units per second + self.moveScale = self.moveSpeed * evt.timeSinceLastFrame + ## Take about 10 seconds for full rotation + self.rotScale = self.rotateSpeed * evt.timeSinceLastFrame + + self.rotationX = ogre.Degree(0.0) + self.rotationY = ogre.Degree(0.0) + self.translateVector = ogre.Vector3.ZERO + + ##Check to see which device is not buffered, and handle it + if not self.Keyboard.buffered(): + if self._processUnbufferedKeyInput(evt) == False: + return False + if not self.Mouse.buffered(): + if self._processUnbufferedMouseInput(evt) == False: + return False + + if not self.Mouse.buffered() or not self.Keyboard.buffered() or not buffJ: + self._moveCamera() + + return True + + + def frameStarted(self, frameEvent): + return True - ##bool buffJ = (mJoy) ? mJoy->buffered() : true; - if self.timeUntilNextToggle >= 0: self.timeUntilNextToggle -= frameEvent.timeSinceLastFrame This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |