[Python-ogre-commit] SF.net SVN: python-ogre:[757] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-10-14 14:12:11
|
Revision: 757 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=757&view=rev Author: andy_miller Date: 2008-10-14 14:11:52 +0000 (Tue, 14 Oct 2008) Log Message: ----------- Changes to fix smart pointers in Ogre generation Improvements to Quickgui to remove static const string variables that didn't have default values Helper functions to make Triangle and Complex mesh objects in OgreODE Bug fix to sample framework (recently introduced) that has lead to an API change in Ogre See the Changelog.txt for details Modified Paths: -------------- trunk/python-ogre/ChangeLog.txt trunk/python-ogre/code_generators/common_utils/__init__.py trunk/python-ogre/code_generators/common_utils/shared_ptr.py trunk/python-ogre/code_generators/ogre/generate_code.py trunk/python-ogre/code_generators/ogre/python_ogre.h trunk/python-ogre/code_generators/ogre/python_ogre_aliases.h trunk/python-ogre/code_generators/ogreode/generate_code.py trunk/python-ogre/code_generators/ogreode/hand_made_wrappers.py trunk/python-ogre/code_generators/quickgui/generate_code.py trunk/python-ogre/demos/ogre/CompositorDemo_FrameListener.py trunk/python-ogre/demos/ogre/Demo_Compositor.py trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py Modified: trunk/python-ogre/ChangeLog.txt =================================================================== --- trunk/python-ogre/ChangeLog.txt 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/ChangeLog.txt 2008-10-14 14:11:52 UTC (rev 757) @@ -1,11 +1,17 @@ xxxx xx 2008 : Release 1.6.0 xxxx ================================== +Fixed QuickGui with static consts not having default value and causing a boost load error +Removed constant 'vars' and replaced them with properties that return a copy of the object. Specifically ZERO, UNIT_X, + UNIT_Y, UNIT_Z, Black, White, Red, Green, Blue in Classes ColourValue, MatrixX, Quaternion and VectorX. + this is due to the fact they were actually passing a pointer to a non constant (mutable) variable which + caused very annoying bugs. So now Ogre.Vector3.ZERO has to be replaced with Ogre.Vector3().ZERO etc... + Changed all code generation modules to use the common_code Auto_Functional_Transformation function Fix auto transform funtion to not wrap reference arguments that are const (bug) Fix auto transform funtion to handle extern free functions Removed 'asClassType' functions as they didn't actually do anything (and are not needed) Added PSSM camera functionality - it was missing from the sizeof.h file -Added helper functions to OgreODE as constructors needed hand wrapping +Added helper functions to OgreODE as constructors needed hand wrapping (makeTriangleMeshGeometry, makeConvexGeometry) Fix to Py++ to handle bool/int references correctly (renderQueueListener functions) Simplified Ogre patch file requirements due to fix in Py++ for bool refs Fixed a couple of incorrect versions in environment.py Modified: trunk/python-ogre/code_generators/common_utils/__init__.py =================================================================== --- trunk/python-ogre/code_generators/common_utils/__init__.py 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/code_generators/common_utils/__init__.py 2008-10-14 14:11:52 UTC (rev 757) @@ -67,6 +67,7 @@ po = ".".join( (env.PythonOgreMajorVersion,env.PythonOgreMinorVersion, env.PythonOgrePatchVersion) ) t = datetime.datetime.now().isoformat(' ').strip() + t = datetime.date.today().isoformat() # making this less granular so it doesn't change 'every' time I do a regenerate v = envClass.version s = getSVNVersion( env ) detail = "_".join( (po,s,envClass.name, v, t) ) @@ -162,7 +163,7 @@ continue except: print "**** Error in unnamed_classes", mvar - + print "Fixing Unnamed Class:", unnamed_cls, mvar, names_parent.name named_parent.add_code( template % dict( ns=namespace, mvar=mvar.name, parent=named_parent.name ) ) def set_declaration_aliases(global_ns, aliases): @@ -553,7 +554,7 @@ GetterReg = \ """ add_property( // special :) - "%(variable_name)s_Copy" + "%(variable_name)s" // _Copy , fget_Special_%(variable_name)s ( &%(getter_name)s ) , "special get property, built to access const variable" ) """ @@ -579,7 +580,8 @@ known = True if not known: ## OK so it must be mutable so lets fix it.. -# # # # v.exclude() ## remove it as a variable + v.exclude() ## remove it as a variable + print "Excluding Problem Const", cls.name, v return_type, ignore = v.type.decl_string.split(' ',1) # remove cont etc from decl return_type = return_type[2:] # remove leading :: variable_name = v.name Modified: trunk/python-ogre/code_generators/common_utils/shared_ptr.py =================================================================== --- trunk/python-ogre/code_generators/common_utils/shared_ptr.py 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/code_generators/common_utils/shared_ptr.py 2008-10-14 14:11:52 UTC (rev 757) @@ -65,6 +65,8 @@ def expose_single( self, sp_instantiation ): sp_instantiation.exclude() # we don't want to export SharedPtr< X > + print "SharedPointer Excluded", sp_instantiation, sp_instantiation.decl_string +# print dir (sp_instantiation) sp_instantiation.disable_warnings( messages.W1040 ) pointee = self.get_pointee( sp_instantiation ) @@ -74,6 +76,7 @@ assert 1 == len( sp_instantiation.derived ) sp_derived = sp_instantiation.derived[0].related_class sp_derived.exclude() + print "SharedPointer Excluded Derived", sp_derived, pointee sp_derived.disable_warnings( messages.W1040 ) if Version1: Modified: trunk/python-ogre/code_generators/ogre/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/ogre/generate_code.py 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/code_generators/ogre/generate_code.py 2008-10-14 14:11:52 UTC (rev 757) @@ -33,6 +33,7 @@ import hand_made_wrappers import register_exceptions +import pygccxml from pygccxml import parser from pygccxml import declarations from pyplusplus import messages @@ -49,6 +50,46 @@ import common_utils.ogre_properties as ogre_properties from common_utils import docit + + + +predefined_is_smart_ptr = declarations.smart_pointer_traits +class my_smart_ptr: + @staticmethod + def is_smart_pointer( v ): + t = v + if predefined_is_smart_ptr.is_smart_pointer( v ): + return True + v=t + v = declarations.type_traits.remove_alias( v ) + v = declarations.type_traits.remove_cv( v ) + v = declarations.type_traits.remove_declarated( v ) + if not isinstance( v, ( declarations.class_declaration_t , declarations.class_t ) ): + return False + if not declarations.is_class( v ): + return False + + cls = declarations.class_traits.get_declaration( v ) + if len(cls.bases) > 0: + for b in cls.bases: + r = b.related_class + if r.decl_string.startswith ( '::Ogre::SharedPtr<' ) : +# print "ANDY Smart Class:", v, cls, r.decl_string + return True + else: + if cls.name.startswith ( 'SharedPtr<' ) or cls.name.endswith( 'SharedPtr' ): +# print "Andy Smart 2", v, cls, cls.name + return True + return False + + @staticmethod + def value_type( type ): +# print "ANDY VALUE_TYPE", type + if my_smart_ptr.is_smart_pointer( type ): + return predefined_is_smart_ptr.value_type( type, False ) +pygccxml.declarations.smart_pointer_traits = my_smart_ptr + + HACK = True MAIN_NAMESPACE = 'Ogre' @@ -229,7 +270,7 @@ ## Remove private classes , and those that are internal to Ogre... private_decls = common_utils.private_decls_t(environment.ogre.include_dirs) for cls in main_ns.classes(): - print "MC:", cls +# print "MC:", cls if private_decls.is_private( cls ): cls.exclude() print '{*} class "%s" is marked as private' % cls.decl_string @@ -322,6 +363,7 @@ if type_or_decl.ignore == False and Expose: print "OPERATOR<<:", oper oper.include() + main_ns.class_('MaterialPtr').include() ############################################################ @@ -381,14 +423,8 @@ f=main_ns.class_('MeshManager').mem_fun('createBezierPatch') f.arguments[6]._set_default_value ( '::Ogre::PatchSurface::AUTO_LEVEL') f.arguments[7]._set_default_value ( '::Ogre::PatchSurface::AUTO_LEVEL') - print f - print f.arguments - print f.arguments[6] - print f.arguments[6].default_value - print dir(f.arguments[6]) + - - ## Functions that return objects we need to manage FunctionsToMemoryManage=[\ '::Ogre::VertexData::clone', @@ -873,25 +909,34 @@ def Set_Smart_Pointers( mb ): """ we need to identify 'smart pointers' which are any of the SharedPtr classes """ + knownSmartClasses= ['MaterialPtr', + 'CompositorPtr', + 'FontPtr', + 'GpuProgramPtr', + 'HardwareIndexBufferSharedPtr', + 'HardwarePixelBufferSharedPtr', + 'HardwareVertexBufferSharedPtr', + 'HighLevelGpuProgramPtr', + 'MeshPtr', + 'PatchMeshPtr', + 'SkeletonPtr', + 'TexturePtr', + ] for v in mb.variables(): if not declarations.is_class( v.type ): continue cls = declarations.class_traits.get_declaration( v.type ) + if cls.name.startswith( 'SharedPtr<' ): v.apply_smart_ptr_wa = True print "Applying Smart Pointer: ", v.name, " of class: ", cls.name elif cls.name.endswith( 'SharedPtr' ): v.apply_smart_ptr_wa = True print "Applying Smart Pointer: ", v.name, " of class: ", cls.name - - # now I want to get some specials, the are not classes so haven't been found so far - # this is potentially too broad brushed in it's approach but seems OK so far -- however if - # need bewe could check for specific classes - the current list being: - # - # InstancedGeometry,SubMeshLodGeometryLink,OptimisedSubMeshGeometry,SubMesh - # StaticGeometry,SubMeshLodGeometryLink,OptimisedSubMeshGeometry, - # RenderOperation,IndexData,EdgeListBuilder,Geometry,EdgeData,EdgeGroup - + elif cls.name in knownSmartClasses: + v.apply_smart_ptr_wa = True + print "Applying Smart Pointer: ", v.name, " of class: ", cls.name + # now for some specials by variable name.. known = ['indexBuffer', 'vertexData', 'indexData'] for c in mb.classes(): for v in c.variables(allow_empty = True ): @@ -899,7 +944,7 @@ v.apply_smart_ptr_wa = True print "Applying Smart Pointer (know): ", v.name, " of class: ", c.name - + #~ def Set_Exception(mb): #~ """We don't exclude Exception, because it contains functionality, that could #~ be useful to user. But, we will provide automatic exception translator @@ -1074,7 +1119,6 @@ FindProtectedVars ( mb ) - for cls in main_ns.classes(): if not cls.ignore: @@ -1104,7 +1148,7 @@ # hand_made_wrappers.apply( mb ) - + NoPropClasses = ["UTFString"] for cls in main_ns.classes(): @@ -1140,7 +1184,8 @@ common_utils.Find_Problem_Transformations ( main_ns ) - + + ########################################################################################## # # Creating the code. After this step you should not modify/customize declarations. Modified: trunk/python-ogre/code_generators/ogre/python_ogre.h =================================================================== --- trunk/python-ogre/code_generators/ogre/python_ogre.h 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/code_generators/ogre/python_ogre.h 2008-10-14 14:11:52 UTC (rev 757) @@ -30,6 +30,7 @@ } } } + // This code is VERY UNTESTED and PROBABLY BROKEN // Uee the CVS version of Ogre !!!! // #ifndef OGRE_VERSION_1.4 // these are needed for the 1.2.x SDK Modified: trunk/python-ogre/code_generators/ogre/python_ogre_aliases.h =================================================================== --- trunk/python-ogre/code_generators/ogre/python_ogre_aliases.h 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/code_generators/ogre/python_ogre_aliases.h 2008-10-14 14:11:52 UTC (rev 757) @@ -10,6 +10,7 @@ // typedef std::multimap<Ogre::HardwareVertexBuffer*, Ogre::VertexBufferBinding::HardwareVertexBufferSharedPtr> FreeTemporaryVertexBufferMap; //typedef std::map<unsigned short, Ogre::VertexBufferBinding::HardwareVertexBufferSharedPtr> VertexBufferBindingMap; typedef Ogre::SharedPtr<Ogre::Resource> ResourcePtr; +typedef Ogre::SharedPtr<Ogre::Material> MaterialPtr; typedef Ogre::SharedPtr<Ogre::ShadowCameraSetup> ShadowCameraSetupPtr; typedef Ogre::SharedPtr<Ogre::DefaultShadowCameraSetup> DefaultShadowCameraSetupPtr; Modified: trunk/python-ogre/code_generators/ogreode/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/ogreode/generate_code.py 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/code_generators/ogreode/generate_code.py 2008-10-14 14:11:52 UTC (rev 757) @@ -68,7 +68,8 @@ '::OgreOde::TerrainGeometry::_heightCallback', '::OgreOde::EntityInformer::getIndices', ## unsigned int const * # '::OgreOde::RagdollFactory::requestTypeFlags', # causes issues with moveableobjectfactory - '::OgreOde::EntityInformer::getBoneVertices' # hand wrapped + '::OgreOde::EntityInformer::getBoneVertices', # hand wrapped + '::OgreOde::TriangleMeshData::getIndices' ## needs to be hand wrapped ] @@ -112,10 +113,9 @@ excludes =['::OgreOde::TriangleMeshGeometry' ,'::OgreOde::ComplexGeometry' ] - for c in excludes: - print dir ( global_ns.class_( c ) ) - sys.exit() - +# for c in excludes: +# print dir ( global_ns.class_( c ) ) +# Modified: trunk/python-ogre/code_generators/ogreode/hand_made_wrappers.py =================================================================== --- trunk/python-ogre/code_generators/ogreode/hand_made_wrappers.py 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/code_generators/ogreode/hand_made_wrappers.py 2008-10-14 14:11:52 UTC (rev 757) @@ -71,38 +71,82 @@ boost::python::list indices, unsigned int index_count, OgreOde::World *world, OgreOde::Space* space = 0) { - Ogre::Vector3 * Vectors, vStart; - OgreOde::TriangleIndex * Triangles, tStart; - int index; + Ogre::Vector3 * Vectors; + OgreOde::TriangleIndex * Triangles; + unsigned int index; + OgreOde::TriangleMeshGeometry * ret; + // first lets make sure the counts aren't 'too' big - if ( len (vertices) < vertex_count ) vertex_count = len(vertices); + if ( (unsigned int) bp::len (vertices) < vertex_count ) vertex_count = (unsigned int)bp::len(vertices); // allocate memory - Vectors = new Ogre::Vector3 [ len( vertex_count ) ]; + Vectors = new Ogre::Vector3 [ vertex_count ]; // do the copy - vStart = Vector; - for (index =0 ; index <len(vertex_count); index ++) { - *Vectors++ = boost::python::extract<Ogre::Vector3> (vertices[index]); + for (index =0 ; index < vertex_count ; index ++) { + Vectors[index] = bp::extract<Ogre::Vector3> (vertices[index]); } // now the same for the indices - if ( len (indices) < index_count ) index_count = len(indices); - Triangles = new OgreOde::TriangleIndex [ len ( index_count ) ]; - tStart = Triangles; - for (index =0 ; index <len(index_count); index ++) { - *Triangles++ = boost::python::extract<OgreOde::TriangleIndex> (indices[index]); + if ( (unsigned int)bp::len (indices) < index_count ) index_count = (unsigned int)bp::len(indices); + Triangles = new OgreOde::TriangleIndex [ index_count ]; + for (index =0 ; index < index_count; index ++) { + Triangles[index] = bp::extract<OgreOde::TriangleIndex> (indices[index]); } - return ( OgreOde::TriangleMeshGeometry ( vStart, vertex_count, tStart, index_count, world, space ) ); - } + ret = &OgreOde::TriangleMeshGeometry ( Vectors, vertex_count, Triangles, index_count, world, space ); + delete [] Vectors; + delete [] Triangles; + return ret; + + } + +OgreOde::ConvexGeometry * +OgreOdeGeometry_makeConvexGeometry (boost::python::list vertices, unsigned int vertex_count, + boost::python::list indices, unsigned int index_count, + OgreOde::World *world, OgreOde::Space* space = 0) { + + Ogre::Vector3 * Vectors; + unsigned int* Triangles; + unsigned int index; + OgreOde::ConvexGeometry * ret; + + + // first lets make sure the counts aren't 'too' big + if ( (unsigned int)bp::len (vertices) < vertex_count ) vertex_count = (unsigned int)bp::len(vertices); + // allocate memory + Vectors = new Ogre::Vector3 [ vertex_count ]; + // do the copy + for (index =0 ; index < vertex_count; index ++) { + Vectors[index] = boost::python::extract<Ogre::Vector3> (vertices[index]); + } + + // now the same for the indices + if ( (unsigned int)bp::len (indices) < index_count ) index_count = (unsigned int)bp::len(indices); + Triangles = new unsigned int [ index_count ]; + for (index =0 ; index < index_count; index ++) { + Triangles[index] = boost::python::extract<unsigned int> (indices[index]); + } + + ret = &OgreOde::ConvexGeometry ( Vectors, vertex_count, Triangles, index_count, world, space ); + delete [] Vectors; + delete [] Triangles; + return ret; + } + """ WRAPPER_REGISTRATION_Helper = [ """def( "makeTriangleMeshGeometry", &::OgreOdeGeometry_makeTriangleMeshGeometry, ( bp::arg("vertices"), bp::arg("vertex_count"), bp::arg("indices"), bp::arg("index_count"), - bp::arg("world", bp::arg("space")=0 ), + bp::arg("world"), bp::arg("space")=0 ), "Python-Ogre Hand Wrapped\\nReturns a TriangleMeshGeometry object", + bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >());""", + """def( "makeConvexGeometry", &::OgreOdeGeometry_makeConvexGeometry, + ( bp::arg("vertices"), bp::arg("vertex_count"), bp::arg("indices"), bp::arg("index_count"), + bp::arg("world"), bp::arg("space")=0 ), + "Python-Ogre Hand Wrapped\\nReturns a ConvexGeometry object", bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >());""" + ] @@ -117,7 +161,7 @@ if ( ! me.getBoneVertices(bone,vertex_count,vertices ) ) return outlist; - while ( count-- > 0 ) { + while ( vertex_count-- > 0 ) { outlist.append ( *vertices++ ); } delete[] vertices; @@ -142,4 +186,6 @@ rt = mb.class_( 'EntityInformer' ) rt.add_declaration_code( WRAPPER_DEFINITION_EntityInformer ) apply_reg (rt, WRAPPER_REGISTRATION_EntityInformer ) + mb.add_declaration_code( WRAPPER_DEFINITION_Helper ) + apply_reg (mb, WRAPPER_REGISTRATION_Helper ) \ No newline at end of file Modified: trunk/python-ogre/code_generators/quickgui/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/quickgui/generate_code.py 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/code_generators/quickgui/generate_code.py 2008-10-14 14:11:52 UTC (rev 757) @@ -8,13 +8,13 @@ # TO EXCLUDE # Menu: # bool evtHndlr_listItemCreated(const EventArgs& e); -# bool evtHndlr_listItemMouseEnters(const EventArgs& e); -# bool evtHndlr_listItemMouseLeaves(const EventArgs& e); +# bool evtHndlr_listItemMouseEnters(const EventArgs& e); +# bool evtHndlr_listItemMouseLeaves(const EventArgs& e); # Widget: # Ogre::Vector2 convertPixelToRelativePoint(const Ogre::Vector2& point); -# -# - +# +# + import os, sys, time, shutil try: import psyco @@ -86,8 +86,16 @@ # if c.name in excludeName: # print "Excluding:",c # c.exclude() - - + + # static consts that don't have a value set -- causes a boost cant set variable error + excludes=['::QuickGUI::Menu::DEFAULT', + '::QuickGUI::Menu::DOWN', + '::QuickGUI::Menu::OVER' + ] + for e in excludes: + global_ns.variable(e).exclude() + print "Excluding variable", e + NonExistant = [] for cls in NonExistant: try: @@ -119,9 +127,10 @@ try: global_ns.member_functions(e).exclude() except: - print "FAILED to exclude", e + pass + #print "FAILED to exclude", e -# +# ############################################################ ## @@ -161,7 +170,11 @@ global_ns = mb.global_ns main_ns = global_ns.namespace( MAIN_NAMESPACE ) - + for v in main_ns.variables(): + if '::Ogre::String const' in v.type.decl_string: + v.exclude() + print "Excluding Const String var:",v, v.decl_string + ############################################################ ## Modified: trunk/python-ogre/demos/ogre/CompositorDemo_FrameListener.py =================================================================== --- trunk/python-ogre/demos/ogre/CompositorDemo_FrameListener.py 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/demos/ogre/CompositorDemo_FrameListener.py 2008-10-14 14:11:52 UTC (rev 757) @@ -106,6 +106,7 @@ self.mVpHeight = height ##--------------------------------------------------------------------------- def notifyCompositor(self, instance): + print "NOTIFYCOMPOSITOR" ## Get some RTT dimensions for later calculations defIter = instance.getTechnique().getTextureDefinitionIterator() while (defIter.hasMoreElements()) : @@ -147,9 +148,11 @@ self.mBloomTexOffsetsHorz[i*self.x+1] = 0.0 self.mBloomTexOffsetsVert[i*self.x+0] = 0.0 self.mBloomTexOffsetsVert[i*self.x+1] = -self.mBloomTexOffsetsVert[(i - 7)*self.x+1] + print "OK" ##--------------------------------------------------------------------------- def notifyMaterialSetup(self, pass_id, mat): + print "NOTIFYMATERIALSETUP", mat ## Prepare the fragment params offsets # switch(pass_id) # ##case 994: ## rt_lum4 @@ -175,8 +178,10 @@ progName = mat.getBestTechnique().getPass(0).getFragmentProgramName() fparams.setNamedConstantFloat("sampleOffsets",ctypes.addressof(self.mBloomTexOffsetsVert), self.x) fparams.setNamedConstantFloat("sampleWeights",ctypes.addressof(self.mBloomTexWeights), self.x) + print "OK" ##--------------------------------------------------------------------------- def notifyMaterialRender(self, pass_id, mat): + print "NOTIFYMATERIALRENDER", mat pass ##--------------------------------------------------------------------------- @@ -349,7 +354,7 @@ OIS.MouseListener.__init__(self) ItemSelectorInterface.__init__(self) self.mMain = main - self.mTranslateVector = Ogre.Vector3.ZERO + self.mTranslateVector = Ogre.Vector3().ZERO self.mStatsOn = True self.mNumScreenShots = 0 self.mWriteToFile = False @@ -488,7 +493,7 @@ self.mUpdateMovement = False self.mRotX = 0 self.mRotY = 0 - self.mTranslateVector = Ogre.Vector3.ZERO + self.mTranslateVector = Ogre.Vector3().ZERO if(self.mWriteToFile): self.mNumScreenShots +=1 @@ -679,14 +684,17 @@ def itemStateChanged( self, index, state): ## get the item text and tell compositor manager to set enable state compositor = str(self.mCompositorSelectorViewManager.getItemSelectorText(index)) + print "Compositor", compositor Ogre.CompositorManager.getSingleton().\ setCompositorEnabled(self.mMain.getRenderWindow().getViewport(0),compositor, state) + print "CHANGED" self.updateDebugRTTWindow() ##----------------------------------------------------------------------------------- def registerCompositors(self): vp = self.mMain.getRenderWindow().getViewport(0) self.hvListener = HeatVisionListener() self.hdrListener = HDRListener() + print "HDR OK !!!!" self.gaussianListener = gaussianListener() self.mCompositorSelectorViewManager = ItemSelectorViewManager("CompositorSelectorWin") @@ -714,9 +722,11 @@ if instance and (compositorName == "Heat Vision"): instance.addListener(self.hvListener) elif instance and (compositorName == "HDR"): + print "ADDING LISTENER" instance.addListener(self.hdrListener) self.hdrListener.notifyViewportSize(vp.getActualWidth(), vp.getActualHeight()) self.hdrListener.notifyCompositor(instance) + print "DONE" elif instance and (compositorName == "Gaussian Blur"): instance.addListener(self.gaussianListener) Modified: trunk/python-ogre/demos/ogre/Demo_Compositor.py =================================================================== --- trunk/python-ogre/demos/ogre/Demo_Compositor.py 2008-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/demos/ogre/Demo_Compositor.py 2008-10-14 14:11:52 UTC (rev 757) @@ -9,7 +9,7 @@ # You may use this sample code for anything you like, it is not covered by the # LGPL. # ----------------------------------------------------------------------------- -import sys +import sys, os sys.path.insert(0,'..') import PythonOgreConfig @@ -18,6 +18,31 @@ from CompositorDemo_FrameListener import * from ogre.renderer.OGRE import PixelFormat +if os.name == 'nt': + CEGUI.System.setDefaultXMLParserName("ExpatParser") +else: + CEGUI.System.setDefaultXMLParserName("TinyXMLParser") + +def getPluginPath(): + """Return the absolute path to a valid plugins.cfg file.""" + import sys + import os + import os.path + + paths = [os.path.join(os.getcwd(), 'plugins.cfg'), + os.path.join(os.getcwd(), '..','plugins.cfg'), + '/etc/OGRE/plugins.cfg', + os.path.join(os.path.dirname(os.path.abspath(__file__)), + 'plugins.cfg')] + for path in paths: + if os.path.exists(path): + return path + + sys.stderr.write("\n" + "** Warning: Unable to locate a suitable plugins.cfg file.\n" + "** Warning: Please check your ogre installation and copy a\n" + "** Warning: working plugins.cfg file to the current directory.\n\n") + raise ogre.Exception(0, "can't locate the 'plugins.cfg' file", "") # # /************************************************************************* # CompositorDemo Methods # # *************************************************************************/ @@ -33,11 +58,12 @@ def go(self): if (not self.setup()): return False + print "SETUP DONE" self.mRoot.startRendering() ##-------------------------------------------------------------------------- def setup(self): - self.mRoot = Ogre.Root() + self.mRoot = Ogre.Root( getPluginPath() ) self.setupResources() carryOn = self.configure() @@ -107,7 +133,10 @@ ## Load resource paths from config file config = Ogre.ConfigFile() - config.load('resources.cfg' ) + try: + config.load('../resources.cfg' ) + except: + config.load('resources.cfg' ) seci = config.getSectionIterator() while seci.hasMoreElements(): SectionName = seci.peekNextKey() @@ -131,6 +160,7 @@ self.mSceneMgr.setShadowFarDistance(1000) ## setup GUI system print "**6" + self.mGUIRenderer = CEGUI.OgreCEGUIRenderer(self.mWindow, Ogre.RENDER_QUEUE_OVERLAY, False, 3000, self.mSceneMgr) ## load scheme and set up defaults print "***7" @@ -170,11 +200,11 @@ plane=Ogre.Plane() - plane.normal = Ogre.Vector3.UNIT_Y + plane.normal = Ogre.Vector3().UNIT_Y plane.d = 100 Ogre.MeshManager.getSingleton().createPlane("Myplane", Ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, - 1500, 1500, 10, 10, True, 1, 5, 5, Ogre.Vector3.UNIT_Z) + 1500, 1500, 10, 10, True, 1, 5, 5, Ogre.Vector3().UNIT_Z) pPlaneEnt = self.mSceneMgr.createEntity( "plane", "Myplane" ) pPlaneEnt.setMaterialName("Examples/Rockwall") pPlaneEnt.setCastShadows(False) @@ -266,6 +296,8 @@ comp3 = Ogre.CompositorManager.getSingleton().create( "Motion Blur", Ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME ) + print comp3 + print dir(comp3) t = comp3.createTechnique() def_ = t.createTextureDefinition("scene") def_.width = 0 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-10-07 13:43:51 UTC (rev 756) +++ trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py 2008-10-14 14:11:52 UTC (rev 757) @@ -341,7 +341,7 @@ self.rotationX = ogre.Degree(0.0) self.rotationY = ogre.Degree(0.0) - self.translateVector = ogre.Vector3(0,0,0) + self.translateVector = ogre.Vector3().ZERO ##Check to see which device is not buffered, and handle it if not self.Keyboard.buffered(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |