[Python-ogre-commit] SF.net SVN: python-ogre: [648] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
|
From: <and...@us...> - 2008-07-15 18:48:59
|
Revision: 648
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=648&view=rev
Author: andy_miller
Date: 2008-07-15 11:49:08 -0700 (Tue, 15 Jul 2008)
Log Message:
-----------
Fix for Windows build in environment
Various demo updates and code generation improvements
Modified Paths:
--------------
trunk/python-ogre/PythonOgreConfig_nt.py
trunk/python-ogre/code_generators/ogreal/generate_code.py
trunk/python-ogre/code_generators/ogreode/generate_code.py
trunk/python-ogre/demos/cegui/Demo_CEGUI_Gui.py
trunk/python-ogre/demos/ogreal/Demo_AL_01.py
trunk/python-ogre/demos/ogreode/Demo_GranTurism.py
trunk/python-ogre/demos/ogreode/SimpleScenes.py
trunk/python-ogre/demos/ogreode/SimpleScenes_BoxStack.py
trunk/python-ogre/demos/ogreode/resources.cfg
trunk/python-ogre/demos/plib/Demo_Sound.py
trunk/python-ogre/demos/theora/demo_video.py
trunk/python-ogre/environment.py
Modified: trunk/python-ogre/PythonOgreConfig_nt.py
===================================================================
--- trunk/python-ogre/PythonOgreConfig_nt.py 2008-07-15 13:28:33 UTC (rev 647)
+++ trunk/python-ogre/PythonOgreConfig_nt.py 2008-07-15 18:49:08 UTC (rev 648)
@@ -20,9 +20,9 @@
## Path to your boost_pythonxxxx lib file
# PATH_LIB_Boost = os.path.join(BASE_DIR, PATH_Boost,'bin.v2/libs/python/build/msvc-8.0/release/threading-multi')
# # # # # # # PATH_LIB_Boost = os.path.join(PATH_Boost, 'bin.v2/libs/python/build/msvc/release/threading-multi')
-PATH_LIB_Boost = os.path.join(PATH_Boost, 'bin.v2/libs/python/build/msvc-9.0express/release/threading-multi')
+PATH_LIB_Boost = os.path.join(PATH_Boost, 'bin.v2/libs/python/build/msvc-9.0/release/threading-multi')
## and the name of the boost python library
-LIB_Boost = r'boost_python-vc90-mt-1_35'
+LIB_Boost = r'boost_python-vc90-mt-1_36'
# # LIB_Boost = r'boost_python-vc80-mt-1_34_1'
# LIB_Boost = r'boost_python-vc-mt-1_35'
@@ -55,6 +55,9 @@
PATH_OgreBullet= os.path.join(PATH_THIRDPARTY,'ogrebullet')
PATH_ogreforests= os.path.join(PATH_THIRDPARTY,'forests')
PATH_OGREAL= os.path.join(PATH_THIRDPARTY,'ogreal')
+
+PATH_OGREAL= os.path.join(BASE_DIR,'ogreal')
+
PATH_OPCODE= os.path.join(PATH_THIRDPARTY,'opcode')
PATH_quickgui= os.path.join(PATH_THIRDPARTY,'quickgui')
PATH_betagui= os.path.join(PATH_THIRDPARTY,'betagui')
@@ -103,7 +106,8 @@
# # PATH_LIB_OgreBullet = os.path.join( PATH_OgreBullet, 'lib/Release')
PATH_LIB_OgreOdePrefab = os.path.join( PATH_OgreOde, 'prefab/lib/Release' )
PATH_LIB_OgreOdeLoader = os.path.join( PATH_OgreOde, 'loader/lib/Release' )
-PATH_LIB_OgreAL = os.path.join( PATH_OGREAL)#, 'lib/Release' )
+
+PATH_LIB_OgreAL = os.path.join( PATH_OGREAL, 'lib/Release' )
PATH_LIB_betagui = PATH_betagui
PATH_LIB_quickgui = PATH_quickgui
PATH_LIB_NxOgre= os.path.join(PATH_NxOgre, 'lib')
@@ -135,7 +139,8 @@
PATH_INCLUDE_ODE = os.path.join( PATH_ODE, 'include')
PATH_INCLUDE_OPCODE = PATH_OPCODE
PATH_INCLUDE_ODESOURCE = os.path.join( PATH_ODE, 'ode/src')
-PATH_INCLUDE_OgreAL = os.path.join( PATH_OGREAL)#, 'include' )
+
+PATH_INCLUDE_OgreAL = os.path.join( PATH_OGREAL, 'include' )
PATH_INCLUDE_OPENAL = os.path.join( PATH_OPENAL, 'include')
PATH_INCLUDE_OGG= os.path.join( PATH_OGG, 'include' )
PATH_INCLUDE_VORBIS= os.path.join( PATH_VORBIS, 'include' )
Modified: trunk/python-ogre/code_generators/ogreal/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/ogreal/generate_code.py 2008-07-15 13:28:33 UTC (rev 647)
+++ trunk/python-ogre/code_generators/ogreal/generate_code.py 2008-07-15 18:49:08 UTC (rev 648)
@@ -1,6 +1,16 @@
#!/usr/bin/env python
+# -----------------------------------------------------------------------------
+# This source file is part of Python-Ogre and is covered by the LGPL
+# For the latest info, see http://python-ogre.org/
+#
+# -----------------------------------------------------------------------------
+## STARTER TEMPLATE..
+## replace ogreal with lowercase project name
+## set MAIN_NAMESPACE
+## rename and configure .h files
+
import os, sys, time, shutil
#add environment to the path
@@ -14,6 +24,7 @@
import customization_data
import hand_made_wrappers
+
from pygccxml import parser
from pygccxml import declarations
from pyplusplus import messages
@@ -22,139 +33,180 @@
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 = 'OgreAL'
-def filter_declarations( mb ):
+############################################################
+##
+## Here is where we manually exclude stuff
+##
+############################################################
+def ManualExclude ( mb ):
global_ns = mb.global_ns
- global_ns.exclude()
+ if MAIN_NAMESPACE:
+ main_ns = global_ns.namespace( MAIN_NAMESPACE )
+ else:
+ main_ns = global_ns
+ excludes=['::OgreAL::SoundManager::errorToString']
+ for e in excludes:
+ main_ns.mem_fun(e).exclude()
+
+ # a couple of defined functions without source
+ main_ns.class_('Sound').mem_fun('setGainValues').exclude()
+ main_ns.class_('Sound').mem_fun('setDistanceValues').exclude()
- ogreal_ns = global_ns.namespace( 'OgreAL' )
- ogreal_ns.include()
- ##ogreal_ns.mem_funs( return_type='::OgreAL::Real const *', allow_empty=True).exclude()
+ main_ns.class_('SoundManager').variable('WAV').exclude()
+ main_ns.class_('SoundManager').variable('OGG').exclude()
+ main_ns.class_('SoundManager').variable('FILE_TYPE').exclude()
+ main_ns.class_('SoundManager').variable('AUDIO_FORMAT').exclude()
-# #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 ) )
-# ogreal_ns.calldefs( query ).virtuality = declarations.VIRTUALITY_TYPES.NOT_VIRTUAL
-
- ## Exclude protected and private that are not pure virtual
- query = ~declarations.access_type_matcher_t( 'public' ) \
- & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
- non_public_non_pure_virtual = ogreal_ns.calldefs( query )
- non_public_non_pure_virtual.exclude()
-
-
- # a couple of defined functions without source
- ogreal_ns.class_('Sound').mem_fun('setGainValues').exclude()
- ogreal_ns.class_('Sound').mem_fun('setDistanceValues').exclude()
+ excludes= ['::OgreAL::alcCreateContext',
+ '::OgreAL::alcCaptureOpenDevice',
+ '::OgreAL::alcCreateContext',
+ '::OgreAL::alcGetContextsDevice',
+ '::OgreAL::alcGetCurrentContext',
+ '::OgreAL::alcOpenDevice'
+ ]
+ for e in excludes:
+ main_ns.free_function(e).exclude()
+############################################################
+##
+## And there are things that manually need to be INCLUDED
+##
+############################################################
- # need to force these to be included so they get exposed..
- global_ns.namespace( 'Ogre' ).class_('Singleton<OgreAL::Listener>').include()
- global_ns.namespace( 'Ogre' ).class_('Singleton<OgreAL::SoundManager>').include()
+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
+
+############################################################
+##
+## 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 ) ]
+
- # and classes the we need to be exposed but don't want code generated as they already exist in
- # other modules ('Ogre' in this case) that will be "imported" before the OgreAL module
- global_ns.namespace( 'Ogre' ).class_('AxisAlignedBox').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('MovableObject').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('MovableObjectFactory').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Vector3').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Node').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('RenderQueue').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('FrameEvent').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('FrameListener').include(already_exposed=True)
-# global_ns.namespace( 'Ogre' ).class_('Quaternion').include(already_exposed=True)
-# global_ns.namespace( 'Ogre' ).class_('SceneManager').include(already_exposed=True)
-# global_ns.namespace( 'Ogre' ).class_('SceneNode').include(already_exposed=True)
-# global_ns.namespace( 'Ogre' ).class_('NameValuePairList').include(already_exposed=True)
-# global_ns.namespace( 'Ogre' ).class_('String').include(already_exposed=True)
-# global_ns.namespace( 'Ogre' ).class_('ResourceGroupManager').include(already_exposed=True)
-#
-# global_ns.namespace( 'Ogre' ).class_('MapIterator<OgreAL::FormatMap>').include(already_exposed=True)
-
- ogreal_ns.class_('SoundManager').variable('WAV').exclude()
- ogreal_ns.class_('SoundManager').variable('OGG').exclude()
- ogreal_ns.class_('SoundManager').variable('FILE_TYPE').exclude()
- ogreal_ns.class_('SoundManager').variable('AUDIO_FORMAT').exclude()
+###############################################################################
+##
+## 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 )
-
-def set_call_policies( mb ):
-#
- # Set the default policy to deal with pointer/reference return types to reference_existing object
- # as this is the Ogre Default.
- 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 declarations.is_pointer (mem_fun.return_type) or declarations.is_reference (mem_fun.return_type):
- mem_fun.call_policies = call_policies.return_value_policy(
- call_policies.reference_existing_object )
+ # 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 )
-
-def set_smart_pointers( mb ):
- 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
-
-def configure_exception(mb):
- #We don't exclude Exception, because it contains functionality, that could
- #be useful to user. But, we will provide automatic exception translator
- return
- Exception = mb.namespace( 'OgreAL' ).class_( 'Exception' )
- Exception.include()
- Exception.translate_exception_to_string( 'PyExc_RuntimeError', 'exc.getFullDescription().c_str()' )
+ # 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 add_transformations ( mb ):
- ns = mb.global_ns.namespace ('Ogre')
-
- def create_output( size ):
- return [ ft.output( i ) for i in range( size ) ]
-
+
+def Fix_NT ( mb ):
+ """ fixup for NT systems
+ """
-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 )
-
#
# 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.W1040
-# # Inaccessible property warning
-# , messages.W1041 )
-
+ 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
@@ -164,10 +216,8 @@
os.path.join( environment.ogreal.root_dir, "python_ogreal.h" )
, environment.ogreal.cache_file )
- defined_symbols = [ 'OGREAL_NONCLIENT_BUILD', 'OGRE_NONCLIENT_BUILD' ]
- if os.name=='nt':
- defined_symbols= defined_symbols + [ 'WIN32', '_LIB', '_MBCS', 'NDEBUG' ]
- defined_symbols.append( 'OGREAL_VERSION_' + environment.ogreal.version )
+ defined_symbols = [ 'OGRE_NONCLIENT_BUILD' ]
+ defined_symbols.append( 'VERSION_' + environment.ogreal.version )
#
# build the core Py++ system from the GCCXML created source
@@ -178,58 +228,63 @@
, include_paths=environment.ogreal.include_dirs
, define_symbols=defined_symbols
, indexing_suite_version=2
+ , cflags=environment.ogreal.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
+
#
- mb.register_module_dependency ( environment.ogre.generated_dir )
-
# We filter (both include and exclude) specific classes and functions that we want to wrap
#
- filter_declarations (mb)
-
+ global_ns = mb.global_ns
+ global_ns.exclude()
+ main_ns = global_ns.namespace( MAIN_NAMESPACE )
+ main_ns.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 )
#
- # fix shared Ptr's that are defined as references but NOT const...
+ # We need to tell boost how to handle calling (and returning from) certain functions
#
-# find_nonconst ( mb.namespace( 'OgreAL' ) )
-
-
- mb.BOOST_PYTHON_MAX_ARITY = 25
- mb.classes().always_expose_using_scope = True
-
- ogreal_ns = mb.namespace( 'OgreAL' )
+ common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( MAIN_NAMESPACE ) )
- configure_exception( mb )
-
#
# the manual stuff all done here !!!
#
hand_made_wrappers.apply( mb )
-
- #
- # We need to tell boost how to handle calling (and returning from) certain functions
- #
- set_call_policies ( mb.global_ns.namespace ('OgreAL') )
- set_call_policies ( mb.global_ns.namespace ('Ogre') ) # need this to set singletons to return_existing_object
-
- # now we fix up the smart pointers ...
-# set_smart_pointers ( mb.global_ns.namespace ('OgreAL') )
-
- # here we fixup functions that expect to modifiy their 'passed' variables
- add_transformations ( mb )
-
- for cls in ogreal_ns.classes():
- cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
-
+ 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, { 'ogreal_version' : '"%s"' % environment.ogreal.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__' : '"ogreal DESCRIPTION"' } )
+
+
##########################################################################################
#
# Creating the code. After this step you should not modify/customize declarations.
#
##########################################################################################
- extractor = exdoc.doc_extractor("")
- mb.build_code_creator (module_name='_ogreal_' , doc_extractor= extractor)
+ extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing
+ mb.build_code_creator (module_name='_ogreal_' , doc_extractor= extractor )
for inc in environment.ogreal.include_dirs:
mb.code_creator.user_defined_directories.append(inc )
@@ -238,30 +293,16 @@
huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogreal.version ) )
- mb.split_module(environment.ogreal.generated_dir, huge_classes)
+ mb.split_module(environment.ogreal.generated_dir, huge_classes, use_files_sum_repository=False)
-# if not os.path.exists( os.path.join(environment.ogreal.generated_dir, 'py_shared_ptr.h' ) ):
-# shutil.copy( os.path.join( environment.shared_ptr_dir, 'py_shared_ptr.h' )
-# , environment.ogreal.generated_dir )
## now we need to ensure a series of headers and additional source files are
- ## copied to the generated directory.. Also cope with sub directories
- additional_dirs=[
- [environment.Config.PATH_OGREAL,''],
-# [os.path.join(environment.Config.root_dir, 'ThirdParty', 'ogreal', 'extra'),''],
-# [os.path.join(environment.Config.root_dir, 'ThirdParty', 'ogreal', 'extra','ogg'),'ogg'],
-# # [os.path.join(environment.Config.root_dir, 'ThirdParty', 'ogreal', 'extra','vorbis'),'vorbis'],
- ]
- for d,d1 in additional_dirs:
- for f in os.listdir(d):
- if f.endswith('cpp') or f.endswith('.h') or f.endswith('.c'):
- sourcefile = os.path.join(d, f)
- destfile = os.path.join(environment.ogreal.generated_dir, d1, f )
- if not os.path.exists ( os.path.join(environment.ogreal.generated_dir, d1 ) ):
- os.mkdir ( os.path.join(environment.ogreal.generated_dir, d1 ) )
- if not common_utils.samefile( sourcefile ,destfile ):
- shutil.copy( sourcefile, environment.ogreal.generated_dir )
- print "Updated ", f, "as it was missing or out of date"
+ ## copied to the generated directory..
+
+# common_utils.copyTree ( sourcePath = environment.Config.PATH_Config.PATH_OGREAL,
+# destPath = environment.ogreal.generated_dir,
+# recursive=False )
+
if __name__ == '__main__':
start_time = time.clock()
generate_code()
- print 'Python-OgreAL source code was updated( %f minutes ).' % ( ( time.clock() - start_time )/60 )
+ print 'Source code was updated( %f minutes ).' % ( ( time.clock() - start_time )/60 )
Modified: trunk/python-ogre/code_generators/ogreode/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/ogreode/generate_code.py 2008-07-15 13:28:33 UTC (rev 647)
+++ trunk/python-ogre/code_generators/ogreode/generate_code.py 2008-07-15 18:49:08 UTC (rev 648)
@@ -1,13 +1,18 @@
#!/usr/bin/env python
+# -----------------------------------------------------------------------------
+# This source file is part of Python-Ogre and is covered by the LGPL
+# For the latest info, see http://python-ogre.org/
+#
+# -----------------------------------------------------------------------------
-#-------------------------------------------------------------------------------
-# TODO:
-# 1. void* as a function argument - they are currently wrapped (and compile/load etc) due to latest CVS of boost.
-# However probably don't actually work
-# 2. Properties.py and calling 'properties.create' - commented out at the moment, not sure if it is really needed?
+## STARTER TEMPLATE..
+## replace ogreode with lowercase project name
+## set MAIN_NAMESPACE
+## rename and configure .h files
-import os, sys, time
+import os, sys, time, shutil
+
#add environment to the path
sys.path.append( os.path.join( '..', '..' ) )
#add common utils to the pass
@@ -19,6 +24,7 @@
import customization_data
import hand_made_wrappers
+
from pygccxml import parser
from pygccxml import declarations
from pyplusplus import messages
@@ -30,242 +36,258 @@
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
-import common_utils.process_warnings as process_warnings
+from common_utils import docit
+MAIN_NAMESPACE = ['OgreOde','OgreOde_Prefab', 'OgreOde_Loader']
-def filter_declarations( mb ):
+############################################################
+##
+## Here is where we manually exclude stuff
+##
+############################################################
+
+def ManualExclude ( mb ):
global_ns = mb.global_ns
- global_ns.exclude()
+# if MAIN_NAMESPACE:
+# main_ns = global_ns.namespace( MAIN_NAMESPACE )
+# else:
+# main_ns = global_ns
-# # global_ns.namespace("std").class_('list<Ogre::Plane, std::allocator<Ogre::Plane> >').exclude()
+############################################################
+##
+## And there are things that manually need to be INCLUDED
+##
+############################################################
- if not environment.ogre.version.startswith("1.2") and os.name =='nt':
- mb.global_ns.class_( 'vector<Ogre::Vector4, std::allocator<Ogre::Vector4> >' ).exclude( )
+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
+ ## here we adjust for functions that return poiners to ODE "ID's", which are really C structs
+ ## I may have been over agressive in identifing these functions but hopefully not...
+ for func in mb.namespace( 'OgreOde' ).member_functions():
+ if func.return_type.decl_string.endswith('ID'):
+ print "Setting ", func.name, "to Opaque"
+ func.opaque = True
+ func.call_policies = call_policies.return_value_policy(
+ call_policies.return_opaque_pointer )
+
+############################################################
+##
+## 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 ) ]
+
- ogreode_ns = global_ns.namespace( 'OgreOde' )
- ogreode_ns.include()
- ogreode_ns.class_("Body").variable("MovableType").exclude() ## this "static const Ogre::String" causes msvc7.1 to die!!
- ogreode_ns.class_("Utility").variable("Infinity").exclude() ## this "static const Ogre::String" causes msvc7.1 to die!!
-
- ogreode_ns.class_("EntityInformer").mem_fun("getIndices").exclude() ## unsigned int const *
+###############################################################################
+##
+## Now for the AUTOMATIC stuff that should just work
+##
+###############################################################################
- # Unfortunately the classes here being used with Maintainedlist don't implement ALL of
- # maintaintlist's functions - hence Py++ has tried to expose them all and it fails at
- # compile time. Probably need to patch the source to implement null functions.
- ogreode_ns.class_("MaintainedList<OgreOde::Body>").exclude()
- ogreode_ns.class_("MaintainedList<OgreOde::Geometry>").exclude()
- ogreode_ns.class_("MaintainedList<OgreOde::Joint>").exclude()
- ogreode_ns.class_("MaintainedList<OgreOde::JointGroup>").exclude()
- ogreode_ns.class_("MaintainedList<OgreOde::Space>").exclude()
-# ogreode_ns.class_("MaintainedListIterator<OgreOde::Body>").exclude()
-# ogreode_ns.class_("MaintainedListIterator<OgreOde::Geometry>").exclude()
-# ogreode_ns.class_("MaintainedListIterator<OgreOde::Joint>").exclude()
-# ogreode_ns.class_("MaintainedListIterator<OgreOde::JointGroup>").exclude()
-# ogreode_ns.class_("MaintainedListIterator<OgreOde::Space>").exclude()
-
- # this one has link errors
- ogreode_ns.class_("CircularBuffer<OgreOde::BodyState*>").exclude()
- ogreode_ns.class_("PlaneBoundedRegionGeometry").member_functions("_planeCallback").exclude()
- ogreode_ns.class_("TerrainGeometry").member_functions("_heightCallback").exclude()
-
- ## couple of functions that are hand wrapped
- ogreode_ns.class_("Geometry").mem_fun("setUserObject").exclude()
- ogreode_ns.class_("Geometry").mem_fun("getUserObject").exclude()
+def AutoFixes ( mb, ns ):
+ """ 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 = mb.global_ns.namespace(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 )
- ogreodeP_ns = global_ns.namespace( 'OgreOde_Prefab' )
- ogreodeP_ns.include()
- ogreodeP_ns.class_("Vehicle").mem_fun("load").exclude()
-
- ogreodeL_ns = global_ns.namespace( 'OgreOde_Loader' )
- ogreodeL_ns.include()
- ogreodeL_ns.class_('DotLoader').mem_fun('loadFile').exclude() # it returns a pointer to a tinyxml object - could make it opaque?
- ##ogreodeL_ns.class_('DotLoader').mem_fun('loadObject').exclude() # hand wrapped
+ # 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 )
-
- ## Exclude private that are not pure virtual
- query = declarations.access_type_matcher_t( 'private' ) \
- & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
- ogreode_ns.calldefs( query,allow_empty=True ).exclude()
- ogreodeP_ns.calldefs( query,allow_empty=True ).exclude()
- ogreodeL_ns.calldefs( query,allow_empty=True ).exclude()
-
- ## now expose but don't create class that exist in other modules
- global_ns.namespace( 'Ogre' ).class_('Bone').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Quaternion').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('SimpleRenderable').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('FrameEvent').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Plane').include(already_exposed=True)
-# global_ns.namespace( 'Ogre' ).class_('SceneQuery').struct('WorldFragment').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('MovableObjectFactory').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('MovableObject').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('RaySceneQueryListener').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Root').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Matrix3').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Vector3').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('UserDefinedObject').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('AxisAlignedBox').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Camera').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('FrameListener').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Node').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('SceneNode').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('RenderQueue').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Entity').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('SceneManager').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Matrix4').include(already_exposed=True)
- global_ns.namespace( 'Ogre' ).class_('Plugin').include(already_exposed=True)
-# print "\nCLASSES::: Std"
-# for c in global_ns.namespace('std').classes():
-# print c.name, c
- global_ns.namespace("std").class_('list<Ogre::Plane, std::allocator<Ogre::Plane> >').include(already_exposed=True)
-# global_ns.class_('::std::list<Ogre::Plane, std::allocator<Ogre::Plane> >').include(already_exposed=True)
-# print "\nCLASSES::: std"
-# for c in global_ns.namespace('std').classes():
-# print c.name, c
-# sys.exit()
-# # print "\nCLASSES::: Prefab"
-# for c in global_ns.namespace('OgreOde_Prefab').classes():
-# print c.name, c
-# print "\nCLASSES::: Loader"
-# for c in global_ns.namespace('OgreOde_Loader').classes():
-# print c.name, c
-# print "\n\nfunction"
-# c= global_ns.namespace('OgreOde_Prefab').class_('Vehicle')
-# print dir(c)
-# mem_funs = c.calldefs()
-# for f in mem_funs:
-# print f
-# sys.exit()
-# global_ns.namespace( 'std' ).class_('vector<Ogre::Vector4, std::allocator<Ogre::Vector4> >').include(already_exposed=True)
-# global_ns.namespace( 'std' ).class_('StringVector').include(already_exposed=True)
-
- #global_ns.namespace( 'Ogre' ).class_('Root').class_('PluginInstanceList').exclude()
-
-def set_call_policies( mb ):
-#
- # Set the default policy to deal with pointer/reference return types to reference_existing object
- # as this is the Ogre Default.
- 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 declarations.is_pointer (mem_fun.return_type) or declarations.is_reference (mem_fun.return_type):
- mem_fun.call_policies = call_policies.return_value_policy(
- call_policies.reference_existing_object )
-
+ if os.name =='nt':
+ Fix_NT( mb )
+ elif os.name =='posix':
+ Fix_Posix( mb )
+
+ common_utils.Auto_Document( mb, ns )
+
+
+###############################################################################
+##
+## 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 add_transformations ( mb ):
- global_ns = mb.global_ns
-# global_ns.member_functions('::OgreOde_Prefab::Ragdoll::pick').exclude()
-# global_ns.mem_fun('::OgreOde_Prefab::Ragdoll::pick', arg_types=[None,None,None]).include()
-# # f = global_ns.mem_fun('::OgreOde_Prefab::Ragdoll::pick', arg_types=[None,None,None])
-# # f.add_transformation(ft.output('body'), ft.output('position') , alias='pick')
-
+def Fix_NT ( mb ):
+ """ fixup for NT systems
+ """
+
-
-
-def configure_exception(mb):
- #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( 'OgreOde' ).class_( 'Exception' )
- Exception.translate_exception_to_string( 'PyExc_RuntimeError', 'exc.getFullDescription().c_str()' )
-
-def generate_ogreode():
+#
+# 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.ogreode.root_dir, "python_ogreode.h" )
, environment.ogreode.cache_file )
- defined_symbols = [ 'OGRE_NONCLIENT_BUILD', 'ODE_LIB' ]
+
+ defined_symbols = ['OGRE_NONCLIENT_BUILD', 'ODE_LIB' ]
defined_symbols.append( 'OGREODE_VERSION_' + environment.ogreode.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.ogreode.include_dirs
- , define_symbols= defined_symbols
- , indexing_suite_version=2 )
-
- ## This module depends on Ogre
+ , define_symbols=defined_symbols
+ , indexing_suite_version=2
+ , cflags=environment.ogreode.cflags
+ )
+
+ # if this module depends on another set it here
mb.register_module_dependency ( environment.ogre.generated_dir )
- filter_declarations (mb)
-
- ## we need to handle "ode" return values etc
- query = lambda decl: isinstance( decl, ( declarations.class_t, declarations.class_declaration_t ) ) \
- and decl.name.startswith( 'dx' )
- mb.global_ns.decls( query ).opaque = True
- ## here we adjust for functions that return poiners to ODE "ID's", which are really C structs
- ## I may have been over agressive in identifing these functions but hopefully not...
- for func in mb.namespace( 'OgreOde' ).member_functions():
- if func.return_type.decl_string.endswith('ID'):
- print "Setting ", func.name, "to Opaque"
- func.opaque = True
- func.call_policies = call_policies.return_value_policy(
- call_policies.return_opaque_pointer )
-
-
- #
+ # 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
-
- ogreode_ns = mb.namespace( 'OgreOde' )
- try:
- common_utils.fix_unnamed_classes( ogreode_ns.classes( name='' ), 'OgreOde' )
- except:
- pass # there weren't any unnamed classes
-
- common_utils.configure_shared_ptr(mb)
-# configure_exception( mb )
-
+
#
+ # We filter (both include and exclude) specific classes and functions that we want to wrap
+ #
+ global_ns = mb.global_ns
+ global_ns.exclude()
+ for ns in MAIN_NAMESPACE:
+ main_ns = global_ns.namespace( ns )
+ main_ns.include()
+
+ common_utils.AutoExclude ( mb, ns )
+ ManualExclude ( mb )
+ common_utils.AutoInclude ( mb, ns )
+ ManualInclude ( mb )
+ # here we fixup functions that expect to modifiy their 'passed' variables
+ ManualTransformations ( mb )
+ AutoFixes ( mb, ns )
+ 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 ( ns ) )
+
+ #
# the manual stuff all done here !!!
#
hand_made_wrappers.apply( mb )
-
- #
- # We need to tell boost how to handle calling (and returning from) certain functions
- #
- set_call_policies ( mb.global_ns.namespace ('OgreOde') )
- set_call_policies ( mb.global_ns.namespace ('OgreOde_Prefab') )
- set_call_policies ( mb.global_ns.namespace ('OgreOde_Loader') )
-
- # here we fixup functions that expect to modifiy their 'passed' variables
- add_transformations ( mb )
- #
- # add properties to the 3 namespaces, in a conservative fashion
- #
- namespaces = ['OgreOde', 'OgreOde_Prefab', 'OgreOde_Loader']
- for ns in namespaces:
- for cls in mb.global_ns.namespace(ns).classes():
+ 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, { 'ogreode_version' : '"%s"' % environment.ogreode.version.replace("\n", "\\\n")
, 'python_version' : '"%s"' % sys.version.replace("\n", "\\\n" ) } )
- for ns in namespaces:
- for cls in mb.global_ns.namespace(ns).classes():
- process_warnings.go ( cls )
+
+ ## need to create a welcome doc string for this...
+ common_utils.add_constants( mb, { '__doc__' : '"ogreode DESCRIPTION"' } )
+
+
+ ##########################################################################################
#
- # now do the work
+ # Creating the code. After this step you should not modify/customize declarations.
#
- #Creating ogreode creator. After this step you should not modify/customize declarations.
- #
- extractor = exdoc.doc_extractor("")
- mb.build_code_creator (module_name='_ogreode_' , doc_extractor= extractor)
-
+ ##########################################################################################
+ extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing
+ mb.build_code_creator (module_name='_ogreode_' , doc_extractor= extractor )
+
for inc in environment.ogreode.include_dirs:
mb.code_creator.user_defined_directories.append(inc )
-
mb.code_creator.user_defined_directories.append( environment.ogreode.generated_dir )
- mb.code_creator.replace_included_headers( customization_data.header_files(environment.ogreode.version) )
+ mb.code_creator.replace_included_headers( customization_data.header_files( environment.ogreode.version ) )
- huge_classes = map( mb.class_, customization_data.huge_classes(environment.ogreode.version) )
- print "ABOUT TO SPLIT"
- mb.split_module(environment.ogreode.generated_dir, huge_classes, use_files_sum_repository=False )
+ huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogreode.version ) )
+ mb.split_module(environment.ogreode.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_ogreode,
+# destPath = environment.ogreode.generated_dir,
+# recursive=False )
+
if __name__ == '__main__':
start_time = time.clock()
- generate_ogreode()
- print 'Python-ogreode source ogreode was updated( %f minutes ).' % ( ( time.clock() - start_time )/60 )
+ generate_code()
+ print 'Source code was updated( %f minutes ).' % ( ( time.clock() - start_time )/60 )
Modified: trunk/python-ogre/demos/cegui/Demo_CEGUI_Gui.py
===================================================================
--- trunk/python-ogre/demos/cegui/Demo_CEGUI_Gui.py 2008-07-15 13:28:33 UTC (rev 647)
+++ trunk/python-ogre/demos/cegui/Demo_CEGUI_Gui.py 2008-07-15 18:49:08 UTC (rev 648)
@@ -138,7 +138,7 @@
self.GUIsystem.setDefaultMouseCursor("TaharezLook", "MouseArrow")
self.GUIsystem.setDefaultFont( "BlueHighway-12")
- sheet = CEGUI.WindowManager.getSingleton().loadWindowLayout("ogregui.layout", False)
+ sheet = CEGUI.WindowManager.getSingleton().loadWindowLayout("ogregui.layout" ) ##, False)
self.GUIsystem.setGUISheet(sheet)
#
Modified: trunk/python-ogre/demos/ogreal/Demo_AL_01.py
===================================================================
--- trunk/python-ogre/demos/ogreal/Demo_AL_01.py 2008-07-15 13:28:33 UTC (rev 647)
+++ trunk/python-ogre/demos/ogreal/Demo_AL_01.py 2008-07-15 18:49:08 UTC (rev 648)
@@ -65,6 +65,9 @@
def _createScene(self):
"Override sf create scene"
+ self.soundManager = OgreAL.SoundManager() ## "Generic Software")
+
+
sceneManager = self.sceneManager
camera = self.camera
@@ -119,29 +122,30 @@
#
#
#
- self.soundManager = OgreAL.SoundManager() ## "Generic Software")
dl = self.soundManager.getDeviceList()
# for dev in dl:
# print "Device available:", dev
+
node = rootNode.createChildSceneNode( "Head" )
node.attachObject( ogreHead )
sound = self.soundManager.createSound("Roar", "roar.wav", True) ## "6chan.ogg", True) ## "roar.wav", True)
node.attachObject(sound)
sound.play()
-
- bgSound = self.soundManager.createSound("stereo", "6chan.ogg", True, True)
- bgSound.setGain(0.5)
- bgSound.setRelativeToListener(True)
- bgSound.play()
+ OgreAL.SoundManager.getSingleton().getSound("Roar").play()
+
+ bgSound = self.soundManager.createSound("ZeroFactor", "Zero Factor - Untitled.ogg", True, True)
+
+
node = sceneManager.getRootSceneNode().createChildSceneNode("CameraNode")
node.setPosition(0, 100, 100)
+
node = node.createChildSceneNode("PitchNode")
-# node.attachObject(self.camera)
+# node.attachObject(self.camera)
node.attachObject(self.soundManager.getListener())
node.pitch(ogre.Degree(-30))
- self.pitchnode = node
+ self.pitchnode = node
OgreAL.SoundManager.getSingleton().getSound("Roar").play()
Modified: trunk/python-ogre/demos/ogreode/Demo_GranTurism.py
===================================================================
--- trunk/python-ogre/demos/ogreode/Demo_GranTurism.py 2008-07-15 13:28:33 UTC (rev 647)
+++ trunk/python-ogre/demos/ogreode/Demo_GranTurism.py 2008-07-15 18:49:08 UTC (rev 648)
@@ -10,14 +10,14 @@
#------------------------------------------------------------------------------------------------
carNames = [
+ "Subaru",
"Jeep",
- "JeepSway",
- "Subaru"
+ "JeepSway"
]
carFileNames= [
+ "subaru.ogreode",
"jeep.ogreode",
- "jeep.ogreode",
- "subaru.ogreode"
+ "jeep.ogreode"
]
sSelectedCar = 1
maxNumCar = 3
@@ -25,6 +25,7 @@
#------------------------------------------------------------------------------------------------
class GranTurismOgreFrameListener ( sf.FrameListener ):
def __init__(self, win, cam,time_step,root,world) :
+ print "frame init"
sf.FrameListener.__init__(self, win,cam)
self.camera = cam
self.vehicle = None
@@ -85,6 +86,7 @@
ogre.OverlayManager.getSingleton().getOverlayElement("OgreOdeDemos/Keys").setCaption("Keys: " + "I/K - Accelerate/Brake, J/L - Turn, X - Change drive mode, N - Change Car")
ogre.OverlayManager.getSingleton().getOverlayElement("OgreOdeDemos/OtherKeys").setCaption("Extra: " + "E - Debug Object")
pOver.show()
+ print "Done"
#------------------------------------------------------------------------------------------------
def __del__(self ):
@@ -92,6 +94,7 @@
#------------------------------------------------------------------------------------------------
def changeCar( self ):
+ print "ChangeCar"
self.sSelectedCar = (self.sSelectedCar + 1) % self.maxNumCar
del self.vehicle
@@ -106,8 +109,10 @@
self.vehicle.setPosition(v_pos)
self.updateInfo()
+ print "Done Change Car"
#------------------------------------------------------------------------------------------------
def updateInfo( self ):
+ print "** Updating Info"
pOver = ogre.OverlayManager.getSingleton().getByName("OgreOdeDemos/Overlay")
newInfo = "Info: " + carNames[self.sSelectedCar]
if self.drive =='R':
@@ -120,9 +125,11 @@
elif self.drive == '4':
newInfo = newInfo + " & Rear wheel drive"
ogre.OverlayManager.getSingleton().getOverlayElement("OgreOdeDemos/Info").setCaption(newInfo)
+ print "** Done"
#------------------------------------------------------------------------------------------------
def frameStarted( self, evt):
+ print "*** frameStarted"
time = evt.timeSinceLastFrame
ret = sf.FrameListener.frameStarted(self,evt)
@@ -179,11 +186,12 @@
self.TimeUntilNextToggle = 0.5
if( not self._stepper.isPaused()):
- self.vehicle.setInputs(self.Keyboard.isKeyDown(OIS.KC_J),
- self.Keyboard.isKeyDown(OIS.KC_L),
- self.Keyboard.isKeyDown(OIS.KC_I),
- self.Keyboard.isKeyDown(OIS.KC_K))
- self.vehicle.update(time)
+ print "**** Stepping"
+# self.vehicle.setInputs(self.Keyboard.isKeyDown(OIS.KC_J),
+# self.Keyboard.isKeyDown(OIS.KC_L),
+# self.Keyboard.isKeyDown(OIS.KC_I),
+# self.Keyboard.isKeyDown(OIS.KC_K))
+# self.vehicle.update(time)
# Thanks to Ahmed!
followFactor = 0.2
@@ -200,6 +208,7 @@
self.camera.move( (toCam - self.camera.getPosition()) * followFactor )
self.camera.lookAt(self.vehicle.getSceneNode().getPosition() + ((self.vehicle.getSceneNode().getOrientation() * ogre.Vector3.UNIT_Z) * camLookAhead))
+ print "*** FrameStarted End" , ret
return ret
#------------------------------------------------------------------------------------------------
@@ -242,6 +251,7 @@
#------------------------------------------------------------------------------------------------
# Just override the mandatory create scene method
def _createScene(self):
+ print "** _CreateScene"
# Set ambient light
self.sceneManager.setAmbientLight(ogre.ColourValue(0.5, 0.5, 0.5))
self.sceneManager.setSkyBox(True,"GranTurismOgre/Skybox")
@@ -273,9 +283,11 @@
track_node.attachObject(track_mesh)
ei = OgreOde.EntityInformer(track_mesh)
+ print "** Done 1"
print ei
print self._world.getDefaultSpace()
self._track = ei.createStaticTriangleMesh(self._world, self._world.getDefaultSpace())
+ print "****"
#------------------------------------------------------------------------------------------------
# Create new frame listener
@@ -284,6 +296,7 @@
self.root.addFrameListener(self.FrameListener)
#------------------------------------------------------------------------------------------------
def collision(self, contact):
+ print "** Collision "
if not OgreOde.Vehicle.handleTyreCollision(contact):
contact.setBouncyness(0.0)
contact.setCoulombFriction(18.0)
Modified: trunk/python-ogre/demos/ogreode/SimpleScenes.py
===================================================================
--- trunk/python-ogre/demos/ogreode/SimpleScenes.py 2008-07-15 13:28:33 UTC (rev 647)
+++ trunk/python-ogre/demos/ogreode/SimpleScenes.py 2008-07-15 18:49:08 UTC (rev 648)
@@ -13,9 +13,11 @@
STEP_RATE = 0.01
def __init__ ( self, world ):
global KEY_DELAY
+ print "** SimpleScenes Init"
OgreOde.CollisionListener.__init__(self)
+ print "1"
OgreOde.StepListener.__init__(self)
-
+ print "Ode Created"
self._world = world
self._mgr = self._world.getSceneManager()
self._world.setCollisionListener(self)
@@ -23,15 +25,29 @@
self._key_delay = 1.0 # KEY_DELAY
self._last_node = 0
self.RagdollList=[]
-
+ print "3"
self.dotOgreOdeLoader = OgreOde.DotLoader( world )
+ print "3.1"
self._bodies=[] # an array to keep objects around in (like c++ "new" )
self._geoms=[]
self._joints=[]
+ print "3.2"
self._ragdollFactory = OgreOde.RagdollFactory()
+ print dir (OgreOde)
+ print dir ( self._ragdollFactory)
+# print self._ragdollFactory.Type
+
+ print "Type is:", self._ragdollFactory.getType()
+ print "Flags:", self._ragdollFactory.requestTypeFlags()
+ print "3.3"
+ print self._ragdollFactory
+ print ogre.Root.getSingletonPtr()
+
ogre.Root.getSingletonPtr().addMovableObjectFactory(self._ragdollFactory)
+
+ print "3.4"
self.setInfoText("")
-
+ print "4"
self.xmlNames = [
"zombie",
"zombie",
@@ -66,13 +82,14 @@
]
self.sSelectedMesh = 0
self._ragdoll_count = 0
-
+ print "SimpleScenes Init Done"
#
# Called by OgreOde whenever a collision occurs, so
# that we can modify the contact parameters
#
def collision( self, contact) :
+# print "Simple Scenes Collision"
## Check for collisions between things that are connected and ignore them
g1 = contact.getFirstGeometry()
g2 = contact.getSecondGeometry()
@@ -95,25 +112,31 @@
# Handle key presses
#
def frameEnded(self, time, keyinput, mouse):
+# print "SimpleScenes frameEnded"
self._key_delay += time
for d in self.RagdollList:
d.update() # ??
+# print "Done"
#
# Utility method to set the information string in the UI
#
def setInfoText(self, text):
+# print "Setinfotext"
ogre.OverlayManager.getSingleton().getOverlayElement("OgreOdeDemos/Info").setCaption(ogre.UTFString("Info: " + text))
def getLastNode(self):
+# print "getlastnode"
return self._last_node
## If we register this with a stepper it'll get told every time the world's about to be stepped
def preStep(self, time):
+# print "preStep"
self.addForcesAndTorques()
return True
def addForcesAndTorques(self):
+# print "Addforces"
pass
# /*
# Create a ragdoll
@@ -187,23 +210,28 @@
typeName = "gun"
else:
typeName = "unknown"
-
+ print "2", typeName
## Create the visual representation (the Ogre entity and scene node)
name = typeName + str(len(self._bodies))
entity = self._mgr.createEntity(name, typeName + ".mesh")
node = self._mgr.getRootSceneNode().createChildSceneNode(name)
node.attachObject(entity)
- entity.setNormaliseNormals(True)
+# entity.setNormaliseNormals(True)
entity.setCastShadows(True)
-
+ print "3"
## Pick a size
size = ogre.Vector3((OgreOde.Utility.randomReal() * 0.5 + 0.1) * 2.0,
(OgreOde.Utility.randomReal() * 0.5 + 0.1) * 2.0,
(OgreOde.Utility.randomReal() * 0.5 + 0.1) * 2.0)
-
+ print size
## Create a body associated with the node we created
body = OgreOde.Body(self._world) ##AJM
+ print body
+ print "About to attach"
+ print node
node.attachObject(body)
+ print "node:", node
+
## Set the mass and geometry to match the visual representation
if objectClass == OgreOde.Geometry.Class_Box:
@@ -217,12 +245,15 @@
body.setMass(mass)
elif objectClass == OgreOde.Geometry.Class_Sphere:
+ print "setting spehere"
mass= OgreOde.SphereMass(1.0,size.x)
mass.setDensity(5.0,size.x)
-
+ print mass
geom = OgreOde.SphereGeometry(size.x,self._world,self._space)
+ print gemo
node.setScale(size.x * 0.2,size.x * 0.2,size.x * 0.2)
body.setMass(mass)
+ print body
elif objectClass == OgreOde.Geometry.Class_Cylinder:
size.x *= 0.5
@@ -245,6 +276,7 @@
body.setMass(mass)
## Tie the collision geometry to the physical body
+ print "5"
geom.setBody(body)
## Keep track of the body
@@ -252,7 +284,7 @@
self._geoms.append(geom)
self._key_delay = 0.0
-
+ print "body is: ", body
## If we created something position and orient it randomly
if (body) :
body.setOrientation(ogre.Quaterni...
[truncated message content] |