[Python-ogre-commit] SF.net SVN: python-ogre:[676] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-07-29 09:34:21
|
Revision: 676 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=676&view=rev Author: andy_miller Date: 2008-07-29 09:34:29 +0000 (Tue, 29 Jul 2008) Log Message: ----------- Initial Implementation for the PCZ Portal Scene Manager Modified Paths: -------------- trunk/python-ogre/PythonOgreConfig_nt.py trunk/python-ogre/demos/theora/demo_video.py trunk/python-ogre/environment.py Added Paths: ----------- trunk/python-ogre/code_generators/ogrepcz/ trunk/python-ogre/code_generators/ogrepcz/customization_data.py trunk/python-ogre/code_generators/ogrepcz/generate_code.py trunk/python-ogre/code_generators/ogrepcz/hand_made_wrappers.py trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz.h trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz_aliases.h trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz_sizeof.h Modified: trunk/python-ogre/PythonOgreConfig_nt.py =================================================================== --- trunk/python-ogre/PythonOgreConfig_nt.py 2008-07-28 06:56:57 UTC (rev 675) +++ trunk/python-ogre/PythonOgreConfig_nt.py 2008-07-29 09:34:29 UTC (rev 676) @@ -81,6 +81,7 @@ PATH_navi = os.path.join(BASE_DIR, 'navi', 'navi') PATH_particleuniverse = os.path.join(PATH_Ogre, 'PlugIns', 'ParticleUniverse' ) +PATH_ogrepcz = os.path.join(PATH_Ogre, 'PlugIns', 'PCZSceneManager' ) # it's time for the SDK version if SDK: @@ -174,6 +175,7 @@ ##PATH_INCLUDE_ogreforests = os.path.join (PATH_ogreforests,'include') PATH_INCLUDE_ogreforests = PATH_ogreforests PATH_INCLUDE_particleuniverse = os.path.join(PATH_particleuniverse, 'include' ) +PATH_INCLUDE_ogrepcz = os.path.join(PATH_ogrepcz,'include') PATH_INCLUDE_OggVorbisTheora = [ os.path.join(BASE_DIR,'ogg','include') ,os.path.join(BASE_DIR, 'vorbis', 'include') Added: trunk/python-ogre/code_generators/ogrepcz/customization_data.py =================================================================== --- trunk/python-ogre/code_generators/ogrepcz/customization_data.py (rev 0) +++ trunk/python-ogre/code_generators/ogrepcz/customization_data.py 2008-07-29 09:34:29 UTC (rev 676) @@ -0,0 +1,17 @@ + +def header_files( version ): + return ["Ogre.h", + "OgrePortal.h", + "OgrePCZSceneNode.h", + "OgrePCZone.h", + "OgrePCZSceneManager.h", + "OgrePCZSceneQuery.h", + "OgrePCZLight.h", + "OgrePCPlane.h", + "OgrePCZFrustum.h" + + ] + +def huge_classes( version ): + return [] + \ No newline at end of file Added: trunk/python-ogre/code_generators/ogrepcz/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/ogrepcz/generate_code.py (rev 0) +++ trunk/python-ogre/code_generators/ogrepcz/generate_code.py 2008-07-29 09:34:29 UTC (rev 676) @@ -0,0 +1,341 @@ +#!/usr/bin/env python +# ----------------------------------------------------------------------------- +# This source file is part of Python-MAIN_NAMESPACE and is covered by the LGPL +# For the latest info, see http://python-ogre.org/ +# +# ----------------------------------------------------------------------------- + +## STARTER TEMPLATE.. +## replace ogrepcz with lowercase project name +## set MAIN_NAMESPACE +## rename and configure .h files + + +import os, sys, time, shutil + +#add environment to the path +sys.path.append( os.path.join( '..', '..' ) ) +#add common utils to the pass +sys.path.append( '..' ) +sys.path.append( '.' ) + +import environment +import common_utils +import customization_data +import hand_made_wrappers + + +from pygccxml import parser +from pygccxml import declarations +from pyplusplus import messages +from pyplusplus import module_builder +from pyplusplus import decl_wrappers + +from pyplusplus import function_transformers as ft +from pyplusplus.module_builder import call_policies +from pyplusplus.module_creator import sort_algorithms + +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 = 'Ogre' + +############################################################ +## +## Here is where we manually exclude stuff +## +############################################################ + +def ManualExclude ( mb ): + global_ns = mb.global_ns + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns + excludes=['::Ogre::PCZCamera', + '::Ogre::PCZSceneManagerFactory' + ] + for e in excludes: + main_ns.class_(e).exclude() + print "Excluded Class:", e + + excludes=['::Ogre::PCZSceneManagerFactory::initMetaData', + '::Ogre::PCZSceneManagerFactory::createInstance', + '::Ogre::PCZSceneManagerFactory::destroyInstance' + ] + for e in excludes: + main_ns.member_functions(e).exclude() + print "Excluded Member Function:", e + + excludes=['::Ogre::PCZSceneManagerFactory::FACTORY_TYPE_NAME' + ] + for e in excludes: + main_ns.variable(e).exclude() + print "Excluded Variable:", e + +############################################################ +## +## And there are things that manually need to be INCLUDED +## +############################################################ + +def ManualInclude ( mb ): + global_ns = mb.global_ns + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns + +############################################################ +## +## 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 + for c in global_ns.classes(): + if c.decl_string.startswith("::std::vector<Ogre::PlaneBoundedVolume, std::allocator<Ogre::PlaneBoundedVolume> >"): + print "Excluding:", c + c.include(already_exposed=True) + try: + global_ns.namespace("std").class_('vector<Ogre::PlaneBoundedVolume>, std::allocator<Ogre::BoundedVolume> >').exclude() + print "OK1" + except: + print "FAIL1" + try: + main_ns.class_("std::vector<Ogre::PlaneBoundedVolume, std::allocator<Ogre::PlaneBoundedVolume> >").exclude() + print "OK2" + except: + print "FAIL2" + try: + main_ns.class_("::std::vector<Ogre::PlaneBoundedVolume, std::allocator<Ogre::PlaneBoundedVolume> >").exclude() + print "OK3" + except: + print "FAIL3" + +############################################################ +## +## And things that need to have their argument and call values fixed. +## ie functions that pass pointers in the argument list and of course we need +## to read the updated values - so instead we pass them back +## as new values in a tuple (ETC ETC) +## +############################################################ + +def ManualTransformations ( mb ): + global_ns = mb.global_ns + 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 ) ] + +# # # this is from the Ogre generate wrapper and is needed to remove vertexData from the camera +# # known = ['indexBuffer', 'vertexData', 'indexData'] +# # for c in mb.classes(): +# # for v in c.variables(allow_empty = True ): +# # if v.name in known: +# # v.apply_smart_ptr_wa = True +# # print "Applying Smart Pointer (know): ", v.name, " of class: ", c.name + + +############################################################################### +## +## Now for the AUTOMATIC stuff that should just work +## +############################################################################### + +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 + 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 + 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 + 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 + 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 ) + + +############################################################################### +## +## here are the helper functions that do much of the work +## +############################################################################### +def Fix_Posix ( mb ): + """ fixup for posix specific stuff -- note only expect to be called on a posix machine + """ + ## we could do more here if need be... + if sys.platform == 'darwin': + pass + elif sys.platform.startswith ('linux'): + pass + + +def Fix_NT ( mb ): + """ fixup for NT systems + """ + + +# +# the 'main'function +# +def generate_code(): + messages.disable( +# Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X + messages.W1020 + , messages.W1021 + , messages.W1022 + , messages.W1023 + , messages.W1024 + , messages.W1025 + , messages.W1026 + , messages.W1027 + , messages.W1028 + , messages.W1029 + , messages.W1030 + , messages.W1031 + , 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.W1049 # returns reference to local variable + , messages.W1014 # unsupported '=' operator + ) + # + # Use GCCXML to create the controlling XML file. + # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded + # NOTE: If you update the source library code you need to manually delete the cache .XML file + # + xml_cached_fc = parser.create_cached_source_fc( + os.path.join( environment.ogrepcz.root_dir, "python_ogrepcz.h" ) + , environment.ogrepcz.cache_file ) + + defined_symbols = [ 'OGRE_NONCLIENT_BUILD', 'OGRE_GCC_VISIBILITY'] + defined_symbols.append( 'VERSION_' + environment.ogrepcz.version ) + + # + # build the core Py++ system from the GCCXML created source + # + mb = module_builder.module_builder_t( [ xml_cached_fc ] + , gccxml_path=environment.gccxml_bin + , working_directory=environment.root_dir + , include_paths=environment.ogrepcz.include_dirs + , define_symbols=defined_symbols + , indexing_suite_version=2 + , cflags=environment.ogrepcz.cflags + ) + + # 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() + + # We don't include all of MAIN_NAMESPACE otherwise we get the same full wrapper + # so instead we include classes with names that start with PCZ + main_ns = global_ns.namespace( MAIN_NAMESPACE ) +# main_ns.include() + for c in main_ns.classes(): + if c.name.startswith ('PCZ'): + print "Including ", c + c.include() + + common_utils.AutoExclude ( mb, MAIN_NAMESPACE ) + ManualExclude ( mb ) + common_utils.AutoInclude ( mb, MAIN_NAMESPACE ) + ManualInclude ( mb ) + # here we fixup functions that expect to modifiy their 'passed' variables + ManualTransformations ( mb ) + AutoFixes ( mb, MAIN_NAMESPACE ) + ManualFixes ( mb ) + # + # We need to tell boost how to handle calling (and returning from) certain functions + # + common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( MAIN_NAMESPACE ) ) + + # + # the manual stuff all done here !!! + # + hand_made_wrappers.apply( mb ) + + NoPropClasses = [""] + 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, { 'ogrepcz_version' : '"%s"' % environment.ogrepcz.version.replace("\n", "\\\n") + , 'python_version' : '"%s"' % sys.version.replace("\n", "\\\n" ) } ) + + ## need to create a welcome doc string for this... + common_utils.add_constants( mb, { '__doc__' : '"ogrepcz DESCRIPTION"' } ) + + + ########################################################################################## + # + # 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 + mb.build_code_creator (module_name='_ogrepcz_' , doc_extractor= extractor ) + + for inc in environment.ogrepcz.include_dirs: + mb.code_creator.user_defined_directories.append(inc ) + mb.code_creator.user_defined_directories.append( environment.ogrepcz.generated_dir ) + mb.code_creator.replace_included_headers( customization_data.header_files( environment.ogrepcz.version ) ) + + huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogrepcz.version ) ) + + mb.split_module(environment.ogrepcz.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.. + +# common_utils.copyTree ( sourcePath = environment.Config.PATH_INCLUDE_ogrepcz, +# destPath = environment.ogrepcz.generated_dir, +# recursive=False ) + +if __name__ == '__main__': + start_time = time.clock() + generate_code() + print 'Source code was updated( %f minutes ).' % ( ( time.clock() - start_time )/60 ) Added: trunk/python-ogre/code_generators/ogrepcz/hand_made_wrappers.py =================================================================== --- trunk/python-ogre/code_generators/ogrepcz/hand_made_wrappers.py (rev 0) +++ trunk/python-ogre/code_generators/ogrepcz/hand_made_wrappers.py 2008-07-29 09:34:29 UTC (rev 676) @@ -0,0 +1,15 @@ +import os +import environment + + + +################################################################################################# +################################################################################################# + +def apply_reg ( class_, code ): + for c in code: + class_.add_registration_code ( c ) + +def apply( mb ): + pass + \ No newline at end of file Added: trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz.h =================================================================== --- trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz.h (rev 0) +++ trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz.h 2008-07-29 09:34:29 UTC (rev 676) @@ -0,0 +1,27 @@ +#include "Ogre.h" +#include "OgrePortal.h" +#include "OgrePCZSceneNode.h" +#include "OgrePCZone.h" +#include "OgrePCZSceneManager.h" +#include "OgrePCZSceneQuery.h" +#include "OgrePCZLight.h" +#include "OgrePCPlane.h" +#include "OgrePCZFrustum.h" + + +// First we create a magic namespace to hold all our aliases +namespace pyplusplus { namespace aliases { + + #include "python_ogrepcz_aliases.h" +} } + +// then we exposed everything needed (and more) to ensure GCCXML makes them visible to Py++ +// +namespace python_ogrepcz{ namespace details{ +inline void instantiate(){ + using namespace Ogre; + #include "python_ogrepcz_sizeof.h" + +} } } + + Added: trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz_aliases.h =================================================================== --- trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz_aliases.h (rev 0) +++ trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz_aliases.h 2008-07-29 09:34:29 UTC (rev 676) @@ -0,0 +1 @@ +// typedef name nicename; Added: trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz_sizeof.h =================================================================== --- trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz_sizeof.h (rev 0) +++ trunk/python-ogre/code_generators/ogrepcz/python_ogrepcz_sizeof.h 2008-07-29 09:34:29 UTC (rev 676) @@ -0,0 +1 @@ +// sizeof ( variable ); Modified: trunk/python-ogre/demos/theora/demo_video.py =================================================================== --- trunk/python-ogre/demos/theora/demo_video.py 2008-07-28 06:56:57 UTC (rev 675) +++ trunk/python-ogre/demos/theora/demo_video.py 2008-07-29 09:34:29 UTC (rev 676) @@ -42,12 +42,12 @@ if not self.Control: print "\n\nClip not found\n" sys.exit() - self.Control.setInputName( '../media_extra/fish.ogg' ) + self.Control.setInputName( '../media_extra/konqi_ad1_nl.avi.ogg') ##fish.ogg' ) self.Control.setPlayMode(theora.TextureEffectPause ) self.Control.setTextureTecPassStateLevel( 0, 0, 0 ) self.Control.setSeekEnabled( False ) -# self.Control.setAutoAudioUpdate ( True ) + self.Control.setAutoAudioUpdate ( True ) mat = ogre.MaterialManager.getSingleton().getByName("Example/TheoraVideoPlayer/Play") #Create the material the first time through this method @@ -97,7 +97,6 @@ ret = sf.FrameListener.frameStarted(self, frameEvent) if self.video and ret: self.video.blitFrameCheck() - self.video.getAudioDriver().autoUpdate() return ret Modified: trunk/python-ogre/environment.py =================================================================== --- trunk/python-ogre/environment.py 2008-07-28 06:56:57 UTC (rev 675) +++ trunk/python-ogre/environment.py 2008-07-29 09:34:29 UTC (rev 676) @@ -1569,6 +1569,24 @@ libs=[ boost.lib, 'OgreMain' ] ModuleName="cadunetree" +class ogrepcz: + active = False + pythonModule = True + version="1.0" + name='ogrepcz' + parent="ogre/renderer" + cflags = "" + include_dirs = [ Config.PATH_Boost, + Config.PATH_INCLUDE_Ogre, + Config.PATH_INCLUDE_ogrepcz + ] + lib_dirs = [Config.PATH_LIB_Boost, + Config.PATH_LIB_Ogre_OgreMain + ] + CheckIncludes=[] + libs=[ boost.lib, 'Plugin_PCZSceneManager', 'OgreMain' ] + ModuleName="ogrepcz" + class opensteer: active = False pythonModule = True @@ -1647,6 +1665,7 @@ , 'particleuniverse' : particleuniverse , 'cadunetree' : cadunetree ,'opensteer' : opensteer + ,'ogrepcz' : ogrepcz } # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |