[Python-ogre-commit] SF.net SVN: python-ogre: [414] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2007-10-10 02:21:28
|
Revision: 414 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=414&view=rev Author: andy_miller Date: 2007-10-09 19:21:29 -0700 (Tue, 09 Oct 2007) Log Message: ----------- Much better wrapping of Bullet and OgreBullet (was missing some base classes) Ogre handles SceneManager set and getOption functionality Modified Paths: -------------- trunk/python-ogre/code_generators/bullet/generate_code.py trunk/python-ogre/code_generators/bullet/hand_made_wrappers.py trunk/python-ogre/code_generators/ogre/generate_code.py trunk/python-ogre/code_generators/ogre/hand_made_wrappers.py trunk/python-ogre/code_generators/ogrebulletc/generate_code.py Added Paths: ----------- trunk/python-ogre/demos/ogre/tests/Test_SceneManagerOptions.py Modified: trunk/python-ogre/code_generators/bullet/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/bullet/generate_code.py 2007-10-07 00:40:05 UTC (rev 413) +++ trunk/python-ogre/code_generators/bullet/generate_code.py 2007-10-10 02:21:29 UTC (rev 414) @@ -5,7 +5,12 @@ # # ----------------------------------------------------------------------------- +## STARTER TEMPLATE.. +## replace bullet with lowercase project name +## set MAIN_NAMESPACE +## rename and configure .h files + import os, sys, time, shutil #add environment to the path @@ -18,7 +23,6 @@ import common_utils import customization_data import hand_made_wrappers -##import register_exceptions from pygccxml import parser from pygccxml import declarations @@ -33,16 +37,10 @@ import common_utils.extract_documentation as exdoc import common_utils.var_checker as varchecker import common_utils.ogre_properties as ogre_properties +from common_utils import docit -MAIN_NAMESPACE = 'bullet' +MAIN_NAMESPACE = '' -## small helper function -def docit ( general, i, o ): - docs = "Python-Ogre (Bullet) Modified Function Call\\n" + general +"\\n" - docs = docs + "Input: " + i + "\\n" - docs = docs + "Output: " + o + "\\n\\\n" - return docs - ############################################################ ## ## Here is where we manually exclude stuff @@ -51,7 +49,10 @@ def ManualExclude ( mb ): global_ns = mb.global_ns - + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns # remove functions that fail during compile excludes=['remove', 'findBinarySearch','findLinearSearch'] for c in global_ns.classes(): @@ -60,9 +61,6 @@ if m.name in excludes: m.exclude() excludes=['::btAlignedObjectArray<int>::expand' -# ,'::btAxisSweep3::createProxy' -# ,'::btBU_Simplex1to4::getName' -# ,'getName' ,'::btCollisionDispatcher::getNewManifold' ,'::btCollisionDispatcher::defaultNearCallback' ,'::btCollisionDispatcher::getInternalManifoldPointer' @@ -85,7 +83,6 @@ ,'::btBU_Simplex1to4::getName' ,'::btBoxShape::getName' ,'::btBvhTriangleMeshShape::getName' - ##,'::btConcaveShape::getName' ,'::btDispatcher::getInternalManifoldPointer' ,'::btAxisSweep3Internal<unsigned>::processAllOverlappingPairs' ,'::btAxisSweep3Internal<unsigned short>::processAllOverlappingPairs' @@ -102,16 +99,10 @@ excludes = ['btAlignedAllocator<btCollisionObject*, 16>' # ,'btAlignedAllocator<btCollisionShape*, 16>' + ,'btAlignedAllocator<int, 16>' ,'btAlignedAllocator<btPersistentManifold*, 16>' ,'btAlignedAllocator<btTypedConstraint*, 16>' ,'btAlignedAllocator<btRaycastVehicle*, 16>' - # these are being excluded becasue they keep including functions from their parent class - # instead of specifing 'bases' - ,'btCapsuleShape' ## fix later - ,'btConcaveShape' - ,'btConvexInternalShape' - ,'btConvexShape' - ,'btPolyhedralConvexShape' ] for e in excludes: print "excluding class", e @@ -128,6 +119,8 @@ o.exclude() global_ns.class_('btQuaternion').operators("operator-", arg_types=[]).exclude() + + ############################################################ ## ## And there are things that manually need to be INCLUDED @@ -136,18 +129,24 @@ def ManualInclude ( mb ): global_ns = mb.global_ns + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns global_ns.enumerations('PHY_ScalarType').include() - - + ############################################################ ## ## And things that need manual fixes, but not necessarly hand wrapped ## ############################################################ def ManualFixes ( mb ): - global_ns = mb.global_ns - + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns + ## issue where the defaults are &0.0 instead of 0.0 fixes=['btTransform', 'btRigidBody'] for e in fixes: @@ -155,8 +154,7 @@ for a in c.arguments: if a.default_value and "&0.0" in a.default_value: a.default_value = "::btVector3( (0.0), (0.0), (0.0) )" - - + ############################################################ ## ## And things that need to have their argument and call values fixed. @@ -168,105 +166,79 @@ def ManualTransformations ( mb ): global_ns = mb.global_ns - main_ns = global_ns# .namespace( MAIN_NAMESPACE ) - + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns + def create_output( size ): return [ ft.output( i ) for i in range( size ) ] - -############################################################################### -## -## Now for the AUTOMATIC stuff that should just work -## -############################################################################### - - -def AutoExclude( mb ): - """ Automaticaly exclude a range of things that don't convert well from C++ to Python - """ + +def AutoInclude( mb, dumy ): global_ns = mb.global_ns - main_ns = global_ns # No namespaces in bullet - - # vars that are static consts but have their values set in the header file are bad - Remove_Static_Consts ( main_ns ) - - ## Exclude protected and private that are not pure virtual - query = declarations.access_type_matcher_t( 'private' ) \ - & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL ) - try: - non_public_non_pure_virtual = main_ns.calldefs( query ) - non_public_non_pure_virtual.exclude() - except: - pass - - #Virtual functions that return reference could not be overriden from Python - query = declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.VIRTUAL ) \ - & declarations.custom_matcher_t( lambda decl: declarations.is_reference( decl.return_type ) ) - try: - main_ns.calldefs( query ).virtuality = declarations.VIRTUALITY_TYPES.NOT_VIRTUAL - except: - pass - -def AutoInclude( mb ): - global_ns = mb.global_ns global_ns.exclude() main_ns = global_ns ## Bullet doesn't have it's own namespace.. for cls in main_ns.classes(): -# print "checking", cls.name -# print cls.decl_string try: if cls.decl_string[2:4]=='bt' and cls.decl_string[4].isupper(): -# print "Including Class:", cls.name cls.include() except: pass ## and we'll need the free functions as well for funcs in main_ns.free_functions (): -# print "checking free", cls.name if funcs.name[0:2]=='bt' and funcs.name[2].isupper(): funcs.include() for var in main_ns.variables (): -# print "checking var ", var.name if len(var.name) > 2: if var.name[0:2]=='bt' and var.name[2].isupper(): var.include() for var in main_ns.typedefs (): -# print "checking typedef ", var.name if len(var.name) > 2: if var.name[0:2]=='bt' and var.name[2].isupper(): var.include() -# print "Member Func:", funcs.name -# if funcs.name[0]=='d': -# print "Including Member Function", funcs.name -# funcs.include() + + + +############################################################################### +## +## Now for the AUTOMATIC stuff that should just work +## +############################################################################### -def AutoFixes ( mb ): +def AutoFixes ( mb, MAIN_NAMESPACE ): """ now we fix a range of things automatically - typically by going through the entire name space trying to guess stuff and fix it:) - """ + """ global_ns = mb.global_ns - - main_ns = global_ns # .namespace( ns ) - - # arguments passed as refs but not const are not liked by boost -# Fix_Ref_Not_Const ( main_ns ) - + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns + # Functions that have void pointers in their argument list need to change to unsigned int's - Fix_Void_Ptr_Args ( main_ns ) - + pointee_types=[] + ignore_names=[] + common_utils.Fix_Void_Ptr_Args ( main_ns ) # , pointee_types, ignore_names ) + # and change functions that return a variety of pointers to instead return unsigned int's - Fix_Pointer_Returns ( main_ns ) + pointee_types=[] + ignore_names=[] # these are function names we know it's cool to exclude + common_utils.Fix_Pointer_Returns ( main_ns ) # , pointee_types, ignore_names ) # functions that need to have implicit conversions turned off - Fix_Implicit_Conversions ( main_ns) - + ImplicitClasses=[] + common_utils.Fix_Implicit_Conversions ( main_ns, ImplicitClasses ) + if os.name =='nt': Fix_NT( mb ) elif os.name =='posix': Fix_Posix( mb ) + common_utils.Auto_Document( mb, MAIN_NAMESPACE ) + ############################################################################### ## @@ -287,157 +259,13 @@ """ fixup for NT systems """ - -def Fix_Implicit_Conversions ( mb ): - """By default we disable explicit conversion, however sometimes it makes sense - """ - ImplicitClasses=[] - for className in ImplicitClasses: - mb.class_(className).constructors().allow_implicit_conversion = True - -def Add_Auto_Conversions( mb ): - pass - - -def Set_Call_Policies( mb ): - """ set the return call policies on classes that this hasn't already been done for. - Set the default policy to deal with pointer/reference return types to reference_existing object - """ - mem_funs = mb.calldefs () - mem_funs.create_with_signature = True #Generated code will not compile on - #MSVC 7.1 if function has throw modifier. - for mem_fun in mem_funs: - if mem_fun.call_policies: - continue - if not mem_fun.call_policies and \ - (declarations.is_reference (mem_fun.return_type) or declarations.is_pointer (mem_fun.return_type) ): - mem_fun.call_policies = call_policies.return_value_policy( - call_policies.reference_existing_object ) - -def Set_Exception(mb): - pass - #~ """We don't exclude Exception, because it contains functionality, that could - #~ be useful to user. But, we will provide automatic exception translator - #~ """ - #~ Exception = mb.namespace( 'Ogre' ).class_( 'Exception' ) - #~ Exception.include() - #~ Exception.mem_fun('what').exclude() # declared with empty throw - #~ Exception.mem_fun('getNumber').exclude() # declared with empty throw - #~ Exception.translate_exception_to_string( 'PyExc_RuntimeError', 'exc.getFullDescription().c_str()' ) - - -def _ReturnUnsignedInt( type_ ): - """helper to return an UnsignedInt call for tranformation functions - """ - return declarations.cpptypes.unsigned_int_t() - -def Fix_Void_Ptr_Args ( mb ): - """ we modify functions that take void *'s in their argument list to instead take - unsigned ints, which allows us to use CTypes buffers - """ - for fun in mb.member_functions(): - arg_position = 0 - for arg in fun.arguments: - if arg.type.decl_string == 'void const *' or arg.type.decl_string == 'void *': - fun.add_transformation( ft.modify_type(arg_position,_ReturnUnsignedInt ), alias=fun.name ) - fun.documentation = docit ("Modified Input Argument to work with CTypes", - "Argument "+arg.name+ "(pos:" + str(arg_position)\ - +") takes a CTypes.adddressof(xx)", "...") - #print "Fixed Void Ptr", fun, arg_position - break - arg_position +=1 - - ## lets go and look for stuff that might be a problem - pointee_types=['unsigned int',' int ', ' char', ' float ', ' Real ', 'uchar', 'uint8', - 'unsigned char'] - - function_names=[] - for fun in mb.member_functions(): - if fun.documentation or fun.ignore: continue ## means it's been tweaked somewhere else - for n in function_names: - if n in fun.name: - print "CHECK :", fun - break - arg_position = 0 - for arg in fun.arguments: - if declarations.is_pointer(arg.type): ## and "const" not in arg.type.decl_string: - for i in pointee_types: - if i in arg.type.decl_string: - print '"',arg.type.decl_string, '"' - print "CHECK ", fun, str(arg_position) - fun.documentation=docit("SUSPECT - MAYBE BROKEN", "....", "...") - break - arg_position +=1 - -## NEED To do the same for constructors - for fun in mb.constructors(): - arg_position = 0 - for arg in fun.arguments: - if declarations.is_pointer(arg.type): ## and "const" not in arg.type.decl_string: - for i in pointee_types: - if i in arg.type.decl_string: - print '"',arg.type.decl_string, '"' - print "Excluding: ", fun - fun.exclude() - break - arg_position +=1 - - - -def Fix_Pointer_Returns ( mb ): - """ Change out functions that return a variety of pointers to base types and instead - have them return the address the pointer is pointing to (the pointer value) - This allow us to use CTypes to handle in memory buffers from Python - - Also - if documentation has been set then ignore the class/function as it means it's been tweaked else where - """ - pointee_types=['unsigned int','int','float', 'char', 'unsigned char']# , 'char' ,'int'] - known_names=[] # these are function names we know it's cool to exclude - for fun in mb.member_functions(): - - if declarations.is_pointer (fun.return_type): ## and not fun.documentation: - for i in pointee_types: - if fun.return_type.decl_string.startswith ( i ) and not fun.documentation: - if not fun.name in known_names: - print "Excluding (function):", fun, "as it returns (pointer)", i - fun.exclude() - try: - for fun in mb.member_operators(): - if declarations.is_pointer (fun.return_type) and not fun.documentation: - for i in pointee_types: - if fun.return_type.decl_string.startswith ( i ) and not fun.documentation: - print "Excluding (operator):", fun - fun.exclude() - except: - pass - - - -def query_containers_with_ptrs(decl): - if not isinstance( decl, declarations.class_types ): - return False - if not decl.indexing_suite: - return False - return declarations.is_pointer( decl.indexing_suite.element_type ) - - -def Remove_Static_Consts ( mb ): - """ linux users have compile problems with vars that are static consts AND have values set in the .h files - we can simply leave these out """ - checker = varchecker.var_checker() - for var in mb.vars(): - if type(var.type) == declarations.cpptypes.const_t: - if checker( var ): - print "Excluding static const ", var - var.exclude() - # # the 'main'function # def generate_code(): messages.disable( -# # # Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X +# Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X messages.W1020 , messages.W1021 , messages.W1022 @@ -450,15 +278,15 @@ , messages.W1029 , messages.W1030 , messages.W1031 -# # , messages.W1035 -# # , messages.W1040 -# # , messages.W1038 -# , messages.W1041 + , messages.W1035 + , messages.W1040 + , messages.W1038 + , messages.W1041 , messages.W1036 # pointer to Python immutable member -# # , messages.W1033 # unnamed variables -# # , messages.W1018 # expose unnamed classes + , messages.W1033 # unnamed variables + , messages.W1018 # expose unnamed classes , messages.W1049 # returns reference to local variable -# , messages.W1014 # unsupported '=' operator + , messages.W1014 # unsupported '=' operator ) # # Use GCCXML to create the controlling XML file. @@ -469,7 +297,7 @@ os.path.join( environment.bullet.root_dir, "python_bullet.h" ) , environment.bullet.cache_file ) - defined_symbols = ['BULLET_EXPORTS'] # + defined_symbols = [ 'BULLET_EXPORTS' ] defined_symbols.append( 'VERSION_' + environment.bullet.version ) # @@ -483,34 +311,41 @@ , indexing_suite_version=2 , cflags=environment.bullet.cflags ) - # NOTE THE CHANGE HERE + + # if this module depends on another set it here + ## mb.register_module_dependency ( environment.ogre.generated_dir ) + + # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off mb.constructors().allow_implicit_conversion = False mb.BOOST_PYTHON_MAX_ARITY = 25 mb.classes().always_expose_using_scope = True - - + # # We filter (both include and exclude) specific classes and functions that we want to wrap # global_ns = mb.global_ns global_ns.exclude() - AutoInclude ( mb ) - - AutoExclude ( mb ) - ManualExclude ( mb ) + if MAIN_NAMESPACE == "" : + main_ns = global_ns + main_ns.include() + else: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + main_ns.exclude () + + AutoInclude ( mb, MAIN_NAMESPACE ) ## note we use our own version, not common_utils + common_utils.AutoExclude ( mb, MAIN_NAMESPACE ) ManualInclude ( mb ) # here we fixup functions that expect to modifiy their 'passed' variables ManualTransformations ( mb ) - - AutoFixes ( mb ) + AutoFixes ( mb, MAIN_NAMESPACE ) ManualFixes ( mb ) - + ManualExclude ( mb ) # # We need to tell boost how to handle calling (and returning from) certain functions # - Set_Call_Policies ( mb.global_ns ) + common_utils.Set_DefaultCall_Policies ( main_ns ) # # the manual stuff all done here !!! @@ -518,10 +353,9 @@ hand_made_wrappers.apply( mb ) NoPropClasses = [""] - main_ns = global_ns -# for cls in main_ns.classes(): -# if cls.name not in NoPropClasses: -# cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() ) + for cls in main_ns.classes(): + if cls.name not in NoPropClasses: + cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() ) common_utils.add_constants( mb, { 'bullet_version' : '"%s"' % environment.bullet.version.replace("\n", "\\\n") , 'python_version' : '"%s"' % sys.version.replace("\n", "\\\n" ) } ) @@ -535,7 +369,7 @@ # Creating the code. After this step you should not modify/customize declarations. # ########################################################################################## - extractor = exdoc.doc_extractor("") # I'm excluding the UTFstring docs as lots about nothing + extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing mb.build_code_creator (module_name='_bullet_' , doc_extractor= extractor ) for inc in environment.bullet.include_dirs: @@ -547,7 +381,18 @@ mb.split_module(environment.bullet.generated_dir, huge_classes, use_files_sum_repository=False) - + ## now we need to ensure a series of headers and additional source files are + ## copied to the generated directory.. + additional_dirs=[] + for d in additional_dirs: + for f in os.listdir(d): + if f.endswith('cpp') or f.endswith('.h'): + sourcefile = os.path.join(d, f) + destfile = os.path.join(environment.bullet.generated_dir, f ) + if not common_utils.samefile( sourcefile ,destfile ): + shutil.copy( sourcefile, environment.bullet.generated_dir ) + print "Updated ", f, "as it was missing or out of date" + if __name__ == '__main__': start_time = time.clock() generate_code() Modified: trunk/python-ogre/code_generators/bullet/hand_made_wrappers.py =================================================================== --- trunk/python-ogre/code_generators/bullet/hand_made_wrappers.py 2007-10-07 00:40:05 UTC (rev 413) +++ trunk/python-ogre/code_generators/bullet/hand_made_wrappers.py 2007-10-10 02:21:29 UTC (rev 414) @@ -16,6 +16,105 @@ } """ +WRAPPER_DEFINITION_btPersistentManifold=\ +""" +btCollisionObject* getBodyAsObject0 ( btPersistentManifold & me ){ + return static_cast<btCollisionObject*>(me.getBody0()); + } +btCollisionObject* getBodyAsObject1 ( btPersistentManifold & me ){ + return static_cast<btCollisionObject*>(me.getBody1()); + } +bp::list getBodies ( btPersistentManifold & me ) { + bp::list listout; + listout.append( static_cast<btCollisionObject*>(me.getBody0()) ); + listout.append( static_cast<btCollisionObject*>(me.getBody1()) ); + return listout; + } +""" + +WRAPPER_REGISTRATION_btPersistentManifold = [ + """def( "getBodyAsObject0", &::getBodyAsObject0, + "Python-Ogre Helper Function: Get the first body (0) in a collision\\n\\ + Input: None\\n\\ + Output: btCollisionObject\\n", + bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >() );""", + """def( "getBodyAsObject1", &::getBodyAsObject1, + "Python-Ogre Helper Function: Get the second body (1) in a collision\\n\\ + Input: None\\n\\ + Output: btCollisionObject\\n", + bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >() );""", + """def( "getBodies", &::getBodies, + "Python-Ogre Helper Function: Get a list containing both bodies in a collision\\n\\ + Input: None\\n\\ + Output: list of 2 btCollisionObject objects\\n" );""" + ] + +WRAPPER_DEFINITION_btCollisionWorld=\ +""" +bp::list getCollidingObjects ( btCollisionWorld & me ) { + bp::list listout; + // do the collisiondetection + me.performDiscreteCollisionDetection(); + + const unsigned int numManifolds = me.getDispatcher()->getNumManifolds(); + for (unsigned int i=0;i < numManifolds; i++) + { + btPersistentManifold* contactManifold = me.getDispatcher()->getManifoldByIndexInternal(i); + + btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0()); + btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1()); + + contactManifold->refreshContactPoints(obA->getWorldTransform(),obB->getWorldTransform()); + + const unsigned int numContacts = contactManifold->getNumContacts(); + if (numContacts > 0) { + listout.append(bp::make_tuple(obA, obB, numContacts) ); + } + } + return listout; +} + +bp::list getCollidingObjectsAndPoints ( btCollisionWorld & me ) { + bp::list listout; + bp::list * sublist; + + // do the collisiondetection + me.performDiscreteCollisionDetection(); + + const unsigned int numManifolds = me.getDispatcher()->getNumManifolds(); + for (unsigned int i=0;i < numManifolds; i++) { + btPersistentManifold* contactManifold = me.getDispatcher()->getManifoldByIndexInternal(i); + + btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0()); + btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1()); + + contactManifold->refreshContactPoints(obA->getWorldTransform(),obB->getWorldTransform()); + + const unsigned int numContacts = contactManifold->getNumContacts(); + if (numContacts > 0) { + sublist = new bp::list(); + for (unsigned int j = 0;j < numContacts; j++) { + btManifoldPoint& pt = contactManifold->getContactPoint(j); + sublist->append ( pt ); + } + listout.append(bp::make_tuple(obA, obB, sublist) ); + } + } + return listout; +} +""" +WRAPPER_REGISTRATION_btCollisionWorld = [ + """def( "getCollidingObjects", &::getCollidingObjects, + "Python-Ogre Helper Function: Get a list of all colliding bodies in the world\\n\\ + Input: None\\n\\ + Output: lists of tuples, each tuple contains body0, body1 and num contact points\\n" );""", + """def( "getCollidingObjectsAndPoints", &::getCollidingObjectsAndPoints, + "Python-Ogre Helper Function: Get a list of all colliding bodies along with contact points\\n\\ + Input: None\\n\\ + Output: list of tuples, each tuples contains body0, body1 and a list of contact points\\n" );""", + ] + + ################################################################################################# ################################################################################################# @@ -27,8 +126,15 @@ rt = mb.class_( 'btCollisionShape' ) rt.add_wrapper_code ( WRAPPER_WRAPPER_getName ) - rt = mb.class_( 'btConcaveShape' ) - rt.add_wrapper_code ( WRAPPER_WRAPPER_getName ) + rt = mb.class_( 'btDispatcher' ) rt.add_wrapper_code ( WRAPPER_WRAPPER_getInternalManifoldPointer ) -# \ No newline at end of file + + rt = mb.class_( 'btCollisionWorld' ) + rt.add_declaration_code( WRAPPER_DEFINITION_btCollisionWorld ) + apply_reg (rt, WRAPPER_REGISTRATION_btCollisionWorld ) + + rt = mb.class_( 'btPersistentManifold' ) + rt.add_declaration_code( WRAPPER_DEFINITION_btPersistentManifold ) + apply_reg (rt, WRAPPER_REGISTRATION_btPersistentManifold ) + \ No newline at end of file Modified: trunk/python-ogre/code_generators/ogre/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/ogre/generate_code.py 2007-10-07 00:40:05 UTC (rev 413) +++ trunk/python-ogre/code_generators/ogre/generate_code.py 2007-10-10 02:21:29 UTC (rev 414) @@ -175,7 +175,9 @@ ## these are hand wrapper -- # global_ns.class_('::Ogre::RenderQueueListener').mem_fun('renderQueueStarted').exclude() # global_ns.class_('::Ogre::RenderQueueListener').mem_fun('renderQueueEnded').exclude() - + global_ns.class_('::Ogre::SceneManager').mem_fun('setOption').exclude() + global_ns.class_('::Ogre::SceneManager').mem_fun('getOption').exclude() + ## as we now include all protected functions tere are a couple of problem areas that popped up main_ns.constructor("IndexData",arg_types=['::Ogre::IndexData const &']).exclude() global_ns.class_('::Ogre::OverlayManager').\ @@ -935,7 +937,14 @@ ManualAlias ( mb ) AutoFixes ( mb, MAIN_NAMESPACE ) ManualFixes ( mb ) - + for cls in main_ns.classes(): + if not cls.ignore: + try: + for c in cls.constructors(): + if c.access_type != 'public': + print "NPC:", c.access_type, c + except: + print "Class without constructors", cls #Py++ can not expose static pointer member variables main_ns.vars( 'ms_Singleton' ).disable_warnings( messages.W1035 ) Modified: trunk/python-ogre/code_generators/ogre/hand_made_wrappers.py =================================================================== --- trunk/python-ogre/code_generators/ogre/hand_made_wrappers.py 2007-10-07 00:40:05 UTC (rev 413) +++ trunk/python-ogre/code_generators/ogre/hand_made_wrappers.py 2007-10-10 02:21:29 UTC (rev 414) @@ -620,7 +620,115 @@ """def( "createVertexData", &::SubMesh_createandsetVertexData );""" ] + +################################################################################################# +WRAPPER_DEFINITION_SceneManager =\ +""" +bool SceneManager_setOption( Ogre::SceneManager & me, const Ogre::String& strKey, bp::object pValue ) { + bp::extract<Ogre::AxisAlignedBox> p( pValue ); + if( p.check() ){ + Ogre::AxisAlignedBox var = p(); + return me.setOption ( strKey, reinterpret_cast< void * >( &var ) ); + } + bp::extract<Ogre::Vector3> p3( pValue ); + if( p3.check() ){ + Ogre::Vector3 var = p3(); + return me.setOption ( strKey, reinterpret_cast< void * >( &var ) ); + } + bp::extract<Ogre::Matrix3> p4( pValue ); + if( p4.check() ){ + Ogre::Matrix3 var = p4(); + return me.setOption ( strKey, reinterpret_cast< void * >( &var ) ); + } + bp::extract<Ogre::Matrix4> p5( pValue ); + if( p5.check() ){ + Ogre::Matrix4 var = p5(); + return me.setOption ( strKey, reinterpret_cast< void * >( &var ) ); + } + bp::extract<Ogre::Quaternion> p6( pValue ); + if( p6.check() ){ + Ogre::Quaternion var = p6(); + return me.setOption ( strKey, reinterpret_cast< void * >( &var ) ); + } + bp::extract<int> p2( pValue ); + if( p2.check() ){ + int var = p2(); + return me.setOption ( strKey, reinterpret_cast< void * >( &var ) ); + } + bp::extract<bool> p1( pValue ); + if( p1.check() ){ + bool var = p1(); + return me.setOption ( strKey, reinterpret_cast< void * >( &var ) ); + } + return false; +} + + +bp::tuple SceneManager_getOption( Ogre::SceneManager & me, const Ogre::String& strKey, bp::object returnType) { + + bp::extract<Ogre::AxisAlignedBox> p( returnType ); + if( p.check() ){ + Ogre::AxisAlignedBox var = p(); + bool ret = me.getOption ( strKey, reinterpret_cast< void * >( &var ) ); + return bp::make_tuple ( ret, var ); + } + bp::extract<Ogre::Vector3> p3( returnType ); + if( p3.check() ){ + Ogre::Vector3 var = p3(); + bool ret = me.getOption ( strKey, reinterpret_cast< void * >( &var ) ); + return bp::make_tuple ( ret, var ); + } + bp::extract<Ogre::Matrix3> p4( returnType ); + if( p4.check() ){ + Ogre::Matrix3 var = p4(); + bool ret = me.getOption ( strKey, reinterpret_cast< void * >( &var ) ); + return bp::make_tuple ( ret, var ); + } + bp::extract<Ogre::Matrix4> p5( returnType ); + if( p5.check() ){ + Ogre::Matrix4 var = p5(); + bool ret = me.getOption ( strKey, reinterpret_cast< void * >( &var ) ); + return bp::make_tuple ( ret, var ); + } + bp::extract<Ogre::Quaternion> p6( returnType ); + if( p6.check() ){ + Ogre::Quaternion var = p6(); + bool ret = me.getOption ( strKey, reinterpret_cast< void * >( &var ) ); + return bp::make_tuple ( ret, var ); + } + bp::extract<int> p2( returnType ); + if( p2.check() ){ + int var = p2(); + bool ret = me.getOption ( strKey, reinterpret_cast< void * >( &var ) ); + return bp::make_tuple ( ret, var ); + } + bp::extract<bool> p1( returnType ); + if( p1.check() ){ + bool var = p1(); + bool ret = me.getOption ( strKey, reinterpret_cast< void * >( &var ) ); + return bp::make_tuple ( ret, var ); + } + return bp::make_tuple ( false, false ); +} + +""" + +WRAPPER_REGISTRATION_SceneManager = [ + """def( "setOption", &::SceneManager_setOption , + "Python-Ogre Helper Function: sets an option in the SceneManager\\n\\ + Input: Option Name, Option Value\\n\\ + Ouput: True/False" );""", + """def( "getOption", &::SceneManager_getOption , + "Python-Ogre Helper Function: returns an option from the SceneManager\\n\\ + Input: Option Name\\n\\ + Ouput: Tuple containing bool (True/False -- success of call) and value" );""" + ] + + + +################################################################################################# + def iter_as_generator_vector( cls ): print "ITER:", cls @@ -695,6 +803,11 @@ rt.add_declaration_code( WRAPPER_DEFINITION_SubMesh ) apply_reg (rt, WRAPPER_REGISTRATION_SubMesh ) + rt = mb.class_( 'SceneManager' ) + rt.add_declaration_code( WRAPPER_DEFINITION_SceneManager ) + apply_reg (rt, WRAPPER_REGISTRATION_SceneManager ) + + mb.add_declaration_code( WRAPPER_DEFINITION_General ) apply_reg (mb, WRAPPER_REGISTRATION_General ) Modified: trunk/python-ogre/code_generators/ogrebulletc/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/ogrebulletc/generate_code.py 2007-10-07 00:40:05 UTC (rev 413) +++ trunk/python-ogre/code_generators/ogrebulletc/generate_code.py 2007-10-10 02:21:29 UTC (rev 414) @@ -67,6 +67,11 @@ else: main_ns = global_ns + global_ns.namespace( 'Ogre' ).class_('MovableObject').include(already_exposed=True) + global_ns.namespace( 'Ogre' ).class_('UserDefinedObject').include(already_exposed=True) + global_ns.namespace( 'Ogre' ).class_('SimpleRenderable').include(already_exposed=True) + + ############################################################ ## ## And things that need manual fixes, but not necessarly hand wrapped Added: trunk/python-ogre/demos/ogre/tests/Test_SceneManagerOptions.py =================================================================== --- trunk/python-ogre/demos/ogre/tests/Test_SceneManagerOptions.py (rev 0) +++ trunk/python-ogre/demos/ogre/tests/Test_SceneManagerOptions.py 2007-10-10 02:21:29 UTC (rev 414) @@ -0,0 +1,50 @@ +import ogre.renderer.OGRE as ogre +import SampleFramework as sf +import ctypes + + +class EnvMapApplication(sf.Application): + def _createScene( self ): + sceneManager = self.sceneManager + camera = self.camera + + sceneManager.ambientLight = ogre.ColourValue (0.5, 0.5, 0.5) + + light = sceneManager.createLight('MainLight') + light.setPosition (20, 80, 50) + + entity = sceneManager.createEntity('head', 'ogrehead.mesh') + entity.setMaterialName("Examples/EnvMappedRustySteel") + sceneManager.getRootSceneNode().createChildSceneNode().attachObject(entity) + print "\n\nCHECKING OPTIONS" + svO = ogre.StringVector() + options = sceneManager.getOptionKeys(svO) + for o in svO: + print "Option: ", o + svV = ogre.StringVector() + values = sceneManager.getOptionValues(o, svV) + for v in svV: + print "Possible Value: ", v + + ## octscenemanager (default) has the following options + ## Size -- AxisAligneBox + ## Depth -- Int + ## ShowOctree -- bool + ret,size = sceneManager.getOption ( 'Size', ogre.AxisAlignedBox() ) + print "Size: ", size + ret,depth = sceneManager.getOption ( 'Depth', int(1) ) + print "Depth: ", depth + ret,value = sceneManager.getOption ( 'ShowOctree', bool(0) ) + print "ShowOctree: ", value + + sceneManager.setOption( 'ShowOctree', True) + sceneManager.setOption( 'Depth',depth) + print dir(size) + + size.setMaximum((100,100,100)) + size.setMinimum((0,0,0)) + sceneManager.setOption( 'Size', size) +if __name__ == '__main__': + + application = EnvMapApplication() + application.go() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |