[Python-ogre-commit] SF.net SVN: python-ogre: [405] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
|
From: <and...@us...> - 2007-10-03 03:55:27
|
Revision: 405
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=405&view=rev
Author: andy_miller
Date: 2007-10-02 20:55:30 -0700 (Tue, 02 Oct 2007)
Log Message:
-----------
Added Forests (new landscape scene manager)
Cleaned up video demos (fixed Theora)
Minor demo fixes
Modified Paths:
--------------
trunk/python-ogre/ChangeLog.txt
trunk/python-ogre/PythonOgreConfig_nt.py
trunk/python-ogre/PythonOgreConfig_posix.py
trunk/python-ogre/SConstruct
trunk/python-ogre/code_generators/theora/generate_code.py
trunk/python-ogre/code_generators/theora/hand_made_wrappers.py
trunk/python-ogre/demos/dshow/Demo_Video.py
trunk/python-ogre/demos/ffmpeg/Demo_Video.py
trunk/python-ogre/demos/ogre/Demo_Fresnel.py
trunk/python-ogre/demos/ogre/Demo_Terrain.py
trunk/python-ogre/demos/theora/demo_video.py
trunk/python-ogre/environment.py
trunk/python-ogre/scripts/MakeRelease.bat
trunk/python-ogre/scripts/UpdateDLLs.bat
trunk/python-ogre/scripts/epydoc_config
trunk/python-ogre/setup.py
Added Paths:
-----------
trunk/python-ogre/code_generators/ogreforests/
trunk/python-ogre/code_generators/ogreforests/customization_data.py
trunk/python-ogre/code_generators/ogreforests/generate_code.py
trunk/python-ogre/code_generators/ogreforests/hand_made_wrappers.py
trunk/python-ogre/code_generators/ogreforests/python_forests.h
trunk/python-ogre/code_generators/ogreforests/python_forests_aliases.h
trunk/python-ogre/code_generators/ogreforests/python_forests_sizeof.h
trunk/python-ogre/demos/ogre/Demo_NetworkClient.py
trunk/python-ogre/demos/ogre/Demo_NetworkServer.py
trunk/python-ogre/demos/ogre/Demo_OgreCollision02.py
trunk/python-ogre/demos/ogreforests/
trunk/python-ogre/demos/ogreforests/Application.cpp
trunk/python-ogre/demos/ogreforests/Application.h
trunk/python-ogre/demos/ogreforests/Demo_Forest.py
trunk/python-ogre/demos/ogreforests/Impostor.General.tree2.mesh.png
trunk/python-ogre/demos/ogreforests/SampleFramework.py
trunk/python-ogre/demos/ogreforests/media/
trunk/python-ogre/demos/ogreforests/media/grass/
trunk/python-ogre/demos/ogreforests/media/grass/grass.material
trunk/python-ogre/demos/ogreforests/media/grass/grass.png
trunk/python-ogre/demos/ogreforests/media/grass/grass2.png
trunk/python-ogre/demos/ogreforests/media/terrains/
trunk/python-ogre/demos/ogreforests/media/terrains/densitymap.png
trunk/python-ogre/demos/ogreforests/media/terrains/terrain.cfg
trunk/python-ogre/demos/ogreforests/media/terrains/terrain.png
trunk/python-ogre/demos/ogreforests/media/terrains/terrain_detail.jpg
trunk/python-ogre/demos/ogreforests/media/terrains/terrain_texture.jpg
trunk/python-ogre/demos/ogreforests/media/trees/
trunk/python-ogre/demos/ogreforests/media/trees/Leaves.png
trunk/python-ogre/demos/ogreforests/media/trees/Pine1.mesh
trunk/python-ogre/demos/ogreforests/media/trees/PineLeaves.png
trunk/python-ogre/demos/ogreforests/media/trees/tree.material
trunk/python-ogre/demos/ogreforests/media/trees/tree.mesh
trunk/python-ogre/demos/ogreforests/media/trees/tree2.mesh
trunk/python-ogre/demos/ogreforests/media/trees/wood7.jpg
trunk/python-ogre/demos/ogreforests/ogre.cfg
trunk/python-ogre/demos/ogreforests/plugins.cfg
trunk/python-ogre/demos/ogreforests/resources.cfg
trunk/python-ogre/demos/ogreode/Demo_GranTurism.py
trunk/python-ogre/demos/plib/
trunk/python-ogre/demos/plib/Demo_Client.py
trunk/python-ogre/demos/plib/Demo_Server.py
trunk/python-ogre/demos/plib/Demo_Sound.py
trunk/python-ogre/demos/plib/Demo_httpget.py
trunk/python-ogre/demos/plib/NETrecv1.py
trunk/python-ogre/demos/plib/NETsend1.py
trunk/python-ogre/demos/qgui/ogre.cfg
Removed Paths:
-------------
trunk/python-ogre/demos/ogreode/media/OgreMeshUpgrade.log
Modified: trunk/python-ogre/ChangeLog.txt
===================================================================
--- trunk/python-ogre/ChangeLog.txt 2007-10-01 15:10:25 UTC (rev 404)
+++ trunk/python-ogre/ChangeLog.txt 2007-10-03 03:55:30 UTC (rev 405)
@@ -1,3 +1,24 @@
+xxx 2007: Version 1.1 Release
+===============================
+* Built with Ogre 1.4.4+
+* Added Theora module for video playback
+* Code generated with updated Py++ that fixes 'already exposed' issues with multiple modules
+* Updated QuickGui - SVN
+* Updated NxOgre using version 0.9-38
+* Added initial Plib support - Sound and Networking + subset of ssg
+* Bug fix to OgreAL to fix ogg playback and general stability
+* Ogre code generation improvements - Ctype support for 'void const *' (changed to unsigned int)
+ previous version only modified 'void *' (missed the const variables)
+ Fixed cases where multiple void *'s in argument list - only first one was being fixed
+ Moved common functions into common_utils so single place to fix -- need to implement for other modules
+* added helper function for PixelBox ("getData") to give access to the data variable
+* updated the vcredist files to the current version
+* updated NxOgre config and framework (bug fixes)
+* Added "navi" gui support - Now this REALLY needs Python built with VC8 and so IS BUGGY
+ all current python binaries for Windows are built with VC7 with an older MSVC runtime library that conflicts
+ with the javascript interpreter thats part of the Mozilla libraries
+* demos/media is now the standard OgreSDK media directory
+ where necessary each demo directory has a ./media directory for additional 'demo' media
August 10 2007: Version 1.0 - Release
============================================
Modified: trunk/python-ogre/PythonOgreConfig_nt.py
===================================================================
--- trunk/python-ogre/PythonOgreConfig_nt.py 2007-10-01 15:10:25 UTC (rev 404)
+++ trunk/python-ogre/PythonOgreConfig_nt.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -33,6 +33,7 @@
PATH_ALUT= os.path.join(BASE_DIR, 'freealut')
PATH_OgreOde= os.path.join(BASE_DIR, PATH_OgreAddons,'ogreode')
PATH_OgreBullet= os.path.join(PATH_OgreAddons,'ogrebullet')
+PATH_ogreforests= os.path.join(PATH_OgreAddons,'forests')
PATH_OGREAL= os.path.join(PATH_THIRDPARTY,'ogreal')
PATH_OPCODE= os.path.join(PATH_THIRDPARTY,'opcode')
@@ -127,6 +128,7 @@
PATH_INCLUDE_ogredshow = PATH_ogredshow
PATH_INCLUDE_plib = PATH_plib
PATH_INCLUDE_navi = os.path.join (PATH_navi,'include')
+PATH_INCLUDE_ogreforests = os.path.join (PATH_ogreforests,'include')
PATH_INCLUDE_OggVorbisTheora = [ os.path.join(BASE_DIR,'ogg','include')
,os.path.join(BASE_DIR, 'vorbis', 'include')
Modified: trunk/python-ogre/PythonOgreConfig_posix.py
===================================================================
--- trunk/python-ogre/PythonOgreConfig_posix.py 2007-10-01 15:10:25 UTC (rev 404)
+++ trunk/python-ogre/PythonOgreConfig_posix.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -40,6 +40,7 @@
PATH_ALUT= os.path.join(BASE_DIR, 'freealut-1.1.0')
PATH_OgreOde= os.path.join(PATH_OgreAddons,'ogreode')
PATH_OgreBullet= os.path.join(PATH_OgreAddons,'ogrebullet')
+PATH_ogreforests= os.path.join(PATH_OgreAddons,'forests')
PATH_OGREAL= os.path.join(PATH_THIRDPARTY,'ogreal')
PATH_OPCODE= os.path.join(PATH_THIRDPARTY,'opcode')
@@ -117,6 +118,7 @@
PATH_INCLUDE_navi = os.path.join (PATH_navi,'include')
PATH_INCLUDE_plib = PATH_plib
PATH_INCLUDE_ogredshow = PATH_ogredshow
+PATH_INCLUDE_ogreforests = os.path.join (PATH_ogreforests,'include')
PATH_INCLUDE_Theora = os.path.join (PATH_Theora,'include')
PATH_INCLUDE_ogrevideoffmpeg = PATH_ogrevideoffmpeg
Modified: trunk/python-ogre/SConstruct
===================================================================
--- trunk/python-ogre/SConstruct 2007-10-01 15:10:25 UTC (rev 404)
+++ trunk/python-ogre/SConstruct 2007-10-03 03:55:30 UTC (rev 405)
@@ -60,7 +60,7 @@
if os.sys.platform <> 'darwin':
CCFLAGS = ' `pkg-config --cflags OGRE` '
CCFLAGS += ' -I'
- CCFLAGS += ' -O3 -I./ '##### -fvisibility=hidden -finline-limit=20 '
+ CCFLAGS += ' -O3 -I./ -fvisibility=hidden -finline-limit=20 '
CCFLAGS += ' -DOGRE_GCC_VISIBILITY ' # -fvisibility-inlines-hidden
else:
CCFLAGS = ' -I -pipe -Os -I./'
@@ -90,10 +90,12 @@
# Let us select the projects to build
possible_projects = ['ogre' , 'ois', 'ogrerefapp', 'ogrenewt', 'cegui', 'ode',\
'ogreode', 'ogreal', 'quickgui', 'opcode', 'nxogre', 'bullet', 'physx', 'betagui','theora',\
- 'ogrevideoffmpeg', 'ogredshow', 'plib', 'navi', 'ogrebulletc', 'ogrebulletd' ] # , 'raknet'
+ 'ogrevideoffmpeg', 'ogredshow', 'plib', 'ogrebulletc', 'ogrebulletd',
+ 'ogreforests' ] # , 'raknet', 'navi',
default_projects = ['ogre' , 'ois', 'ogrerefapp', 'ogrenewt', 'cegui', 'ode',\
'ogreode', 'ogreal', 'quickgui', 'opcode', 'nxogre', 'bullet', 'physx', 'betagui','theora',\
- 'ogrevideoffmpeg', 'ogredshow', 'plib', 'navi', 'ogrebulletc', 'ogrebulletd' ]
+ 'ogrevideoffmpeg', 'ogredshow', 'plib', 'ogrebulletc', 'ogrebulletd',
+ 'ogreforests' ] # 'navi',
# This lets you call scons like: 'scons PROJECTS=ogre,cegui'
opts = Options('custom.py')
@@ -155,13 +157,10 @@
## ugly hack - scons returns a list of targets from SharedLibrary - we have to choose the one we want
index = 0 # this is the index into a list of targets - '0' should be the platform default
- if os.name=="nt":
- ## and lets have it install the output into the 'package_dir_name/ModuleName' dir and rename to the PydName
- _env.AddPostAction(package,\
- 'mt.exe -nologo -manifest %(name)s.manifest -outputresource:%(name)s;2' % { 'name':package[index] } )
- else:
- _env.AddPostAction(package,\
- 'strip -g -S -d --strip-debug -s %(name)s' % { 'name':package[index] } )
+
+ ## and lets have it install the output into the 'package_dir_name/ModuleName' dir and rename to the PydName
+ _env.AddPostAction(package,\
+ 'mt.exe -nologo -manifest %(name)s.manifest -outputresource:%(name)s;2' % { 'name':package[index] } )
_env.InstallAs(os.path.join(environment.package_dir_name, cls.parent,
cls.ModuleName, cls.PydName),
Added: trunk/python-ogre/code_generators/ogreforests/customization_data.py
===================================================================
--- trunk/python-ogre/code_generators/ogreforests/customization_data.py (rev 0)
+++ trunk/python-ogre/code_generators/ogreforests/customization_data.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -0,0 +1,12 @@
+
+def header_files( version ):
+ return [ "GrassLoader.h"
+ ,"TreeLoader3D.h"
+ ,"TreeLoader2D.h"
+ ,"BatchPage.h"
+ ,"ImpostorPage.h"
+ ]
+
+def huge_classes( version ):
+ return []
+
\ No newline at end of file
Added: trunk/python-ogre/code_generators/ogreforests/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/ogreforests/generate_code.py (rev 0)
+++ trunk/python-ogre/code_generators/ogreforests/generate_code.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -0,0 +1,349 @@
+#!/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 ogreforests with lowercase ogreforests 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 = ''
+
+############################################################
+##
+## 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
+
+ Exclude= ['::TreeRef::getScale'
+ ]
+ for c in Exclude:
+ print "Excluding:",c
+ main_ns.member_functions( c ).exclude()
+
+############################################################
+##
+## 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
+
+ Include=["::BatchedGeometry"
+# ,"::SubBatch"
+ ,"::BatchPage"
+ ,"::GrassLayer"
+ ,"::GrassLoader"
+ ,"::GrassPage"
+# ,"::ImpostorBatch"
+# ,"::ImpostorTexture"
+# ,"::ImpostorPage"
+ ,"::GeometryPageManager"
+ ,"::PageLoader"
+ ,"::PagedGeometry"
+ ,"::GeometryPage"
+# ,"::StaticBillboard"
+# ,"::StaticBillboardSet"
+# ,"::SBMaterialRef"
+ ,"::TreeIterator3D"
+ ,"::TreeIterator2D"
+ ,"::TreeLoader2D"
+ ,"::TreeRef"
+ ,"::TreeIterator2D"
+ ,"::TreeLoader3D"
+ ]
+ for c in Include:
+ print "Including:",c
+ main_ns.class_( c ).include()
+
+ Include=["::GrassTechnique"
+ ,"::FadeTechnique"
+ ,"::MapChannel"
+ ,"::MapFilter"
+# ,"::ImpostorBlendMode"
+# ,"::BillboardMethod"
+ ]
+ for c in Include:
+ print "Including:",c
+ main_ns.enums( c ).include()
+
+ Include=[
+ ]
+ for c in Include:
+ main_ns.typedefs( c ).include()
+
+# for t in main_ns.typedefs():
+# print "td", t
+
+############################################################
+##
+## 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 ) ]
+
+
+###############################################################################
+##
+## 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.ogreforests.root_dir, "python_forests.h" )
+ , environment.ogreforests.cache_file )
+
+ defined_symbols = ['OGRE_NONCLIENT_BUILD', 'WIN32', "GCCXML_BUG" ]
+ defined_symbols.append( 'VERSION_' + environment.ogreforests.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.ogreforests.include_dirs
+ , define_symbols=defined_symbols
+ , indexing_suite_version=2
+ , cflags=environment.ogreforests.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.register_module_dependency ( environment.ogre.generated_dir )
+
+ 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()
+ if MAIN_NAMESPACE:
+ main_ns = global_ns.namespace( MAIN_NAMESPACE )
+ else:
+ main_ns = global_ns
+
+ main_ns.exclude() ## no namespace so start with everything excluded
+
+ common_utils.AutoExclude ( mb, MAIN_NAMESPACE )
+ common_utils.AutoInclude ( mb, MAIN_NAMESPACE )
+ ManualInclude ( mb )
+ ManualExclude ( 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 ( main_ns )
+
+ #
+ # 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, { 'ogreforests_version' : '"%s"' % environment.ogreforests.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__' : '"ogreforests 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='_ogreforests_' , doc_extractor= extractor )
+
+ for inc in environment.ogreforests.include_dirs:
+ mb.code_creator.user_defined_directories.append(inc )
+ mb.code_creator.user_defined_directories.append( environment.ogreforests.generated_dir )
+ mb.code_creator.replace_included_headers( customization_data.header_files( environment.ogreforests.version ) )
+
+ huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogreforests.version ) )
+
+ mb.split_module(environment.ogreforests.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=[environment.Config.PATH_INCLUDE_ogreforests,
+ os.path.join (environment.Config.PATH_ogreforests, 'source') ]
+ 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.ogreforests.generated_dir, f )
+ if not common_utils.samefile( sourcefile ,destfile ):
+ shutil.copy( sourcefile, environment.ogreforests.generated_dir )
+ print "Updated ", f, "as it was missing or out of date"
+
+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/ogreforests/hand_made_wrappers.py
===================================================================
--- trunk/python-ogre/code_generators/ogreforests/hand_made_wrappers.py (rev 0)
+++ trunk/python-ogre/code_generators/ogreforests/hand_made_wrappers.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -0,0 +1,96 @@
+import os
+import environment
+
+WRAPPER_DEFINITION_TreeLoader2D = \
+"""
+static PyObject* mSubscriber_tree;
+static std::string mName_tree;
+Ogre::Real HelperHeightFunction_Tree2D ( Ogre::Real x, Ogre::Real z) {
+ Ogre::Real y;
+ if (mName_tree.length() == 0 )
+ y = boost::python::call<Ogre::Real>(mSubscriber_tree, x, z);
+ else
+ y = boost::python::call_method<Ogre::Real>(mSubscriber_tree, mName_tree.c_str(), x, z);
+ return y;
+ }
+
+void TreeLoader2D_setHeightFunction( TreeLoader2D & me, PyObject* function, std::string name="" ) {
+ mSubscriber_tree = function;
+ mName_tree = name;
+ me.setHeightFunction ( &HelperHeightFunction_Tree2D );
+ }
+"""
+
+WRAPPER_DEFINITION_GrassLoader = \
+"""
+static PyObject* mSubscriber_grass;
+static std::string mName_grass;
+Ogre::Real HelperHeightFunction_Grass ( Ogre::Real x, Ogre::Real z) {
+ Ogre::Real y;
+ if (mName_grass.length() == 0 )
+ y = boost::python::call<Ogre::Real>(mSubscriber_grass, x, z);
+ else
+ y = boost::python::call_method<Ogre::Real>(mSubscriber_grass, mName_grass.c_str(), x, z);
+ return y;
+ }
+
+void GrassLoader_setHeightFunction( GrassLoader & me, PyObject* function, std::string name="" ) {
+ mSubscriber_grass = function;
+ mName_grass = name;
+ me.setHeightFunction ( &HelperHeightFunction_Grass );
+ }
+"""
+
+WRAPPER_REGISTRATION_TreeLoader2D =[
+ 'def ("setHeightFunction", &::TreeLoader2D_setHeightFunction );'
+ ]
+
+WRAPPER_REGISTRATION_GrassLoader =[
+ 'def ("setHeightFunction", &::GrassLoader_setHeightFunction );'
+ ]
+
+
+
+WRAPPER_DEFINITION_PagedGeometry = \
+"""
+void PagedGeometry_addDetailLevel_ImpostorPage( PagedGeometry & me, Ogre::Real maxRange, Ogre::Real transitionLength = 0) {
+ me.addDetailLevel<ImpostorPage>(maxRange, transitionLength);
+ }
+void PagedGeometry_addDetailLevel_BatchPage( PagedGeometry & me, Ogre::Real maxRange, Ogre::Real transitionLength = 0) {
+ me.addDetailLevel<BatchPage>(maxRange, transitionLength);
+ }
+void PagedGeometry_addDetailLevel_GrassPage( PagedGeometry & me, Ogre::Real maxRange, Ogre::Real transitionLength = 0) {
+ me.addDetailLevel<GrassPage>(maxRange, transitionLength);
+ }
+"""
+WRAPPER_REGISTRATION_PagedGeometry =[
+ 'def ("addDetailLevelBatchPage", &::PagedGeometry_addDetailLevel_BatchPage,\
+ (bp::arg("maxRange"), bp::arg("transitionLength")=0.0 ));'
+ ,'def ("addDetailLevelImpostorPage", &::PagedGeometry_addDetailLevel_ImpostorPage,\
+ (bp::arg("maxRange"), bp::arg("transitionLength")=0.0 ));'
+ ,'def ("addDetailLevelGrassPage", &::PagedGeometry_addDetailLevel_GrassPage,\
+ (bp::arg("maxRange"), bp::arg("transitionLength")=0.0 ));'
+ ]
+
+
+#################################################################################################
+#################################################################################################
+
+def apply_reg ( class_, code ):
+ for c in code:
+ class_.add_registration_code ( c )
+
+def apply( mb ):
+ rt = mb.class_( 'GrassLoader' )
+ rt.add_declaration_code( WRAPPER_DEFINITION_GrassLoader )
+ apply_reg (rt, WRAPPER_REGISTRATION_GrassLoader )
+
+ rt = mb.class_( 'TreeLoader2D' )
+ rt.add_declaration_code( WRAPPER_DEFINITION_TreeLoader2D )
+ apply_reg (rt, WRAPPER_REGISTRATION_TreeLoader2D )
+
+ rt = mb.class_( 'PagedGeometry' )
+ rt.add_declaration_code( WRAPPER_DEFINITION_PagedGeometry )
+ apply_reg (rt, WRAPPER_REGISTRATION_PagedGeometry )
+
+
\ No newline at end of file
Added: trunk/python-ogre/code_generators/ogreforests/python_forests.h
===================================================================
--- trunk/python-ogre/code_generators/ogreforests/python_forests.h (rev 0)
+++ trunk/python-ogre/code_generators/ogreforests/python_forests.h 2007-10-03 03:55:30 UTC (rev 405)
@@ -0,0 +1,26 @@
+#include <string>
+#include "PagedGeometry.h"
+#include "GrassLoader.h"
+
+#include "TreeLoader3D.h"
+#include "TreeLoader2D.h"
+#include "BatchPage.h"
+#include "ImpostorPage.h"
+
+
+// First we create a magic namespace to hold all our aliases
+namespace pyplusplus { namespace aliases {
+
+ #include "python_forests_aliases.h"
+} }
+
+// then we exposed everything needed (and more) to ensure GCCXML makes them visible to Py++
+//
+namespace python_forests{ namespace details{
+inline void instantiate(){
+ //using namespace OGRE;
+ #include "python_forests_sizeof.h"
+
+} } }
+
+
Added: trunk/python-ogre/code_generators/ogreforests/python_forests_aliases.h
===================================================================
--- trunk/python-ogre/code_generators/ogreforests/python_forests_aliases.h (rev 0)
+++ trunk/python-ogre/code_generators/ogreforests/python_forests_aliases.h 2007-10-03 03:55:30 UTC (rev 405)
@@ -0,0 +1,16 @@
+// typedef name nicename;
+typedef std::list<GrassLayer*, std::allocator<GrassLayer*> > listGrassLayer;
+typedef std::map<Ogre::String, Ogre::MaterialPtr> FadedMaterialMap;
+typedef Ogre::TRect<float> TBounds;
+typedef std::list<GeometryPage*> TPGeometryPages;
+typedef std::map<Ogre::Material*, SBMaterialRef*> SBMaterialRefList;
+typedef std::map<Ogre::String, Ogre::MaterialPtr> FadedMaterialMap;
+typedef std::list<GeometryPageManager*, std::allocator<GeometryPageManager*> > listGeometryPageManager;
+// typedef std::map<Ogre::Entity*, std::vector<TreeDef>*>::iterator PageGridListIterator;
+// typedef std::pair<Ogre::Entity*, std::vector<TreeDef>*> PageGridListValue;
+// typedef std::map<Ogre::Entity*, std::vector<TreeDef>*>::iterator PageGridListIterator;
+// typedef std::pair<Ogre::Entity*, std::vector<TreeDef>*> PageGridListValue;
+// typedef std::vector<QueuedMesh>::iterator MeshQueueIterator;
+// typedef std::vector<QueuedMesh> MeshQueue;
+// typedef std::map<Ogre::String, SubBatch*> SubBatchMap; //Stores a list of GeomBatch'es, using a format string (generated with getGeometryFormatString()) as the key value
+// typedef Ogre::MapIterator<SubBatchMap> SubBatchIterator;
Added: trunk/python-ogre/code_generators/ogreforests/python_forests_sizeof.h
===================================================================
--- trunk/python-ogre/code_generators/ogreforests/python_forests_sizeof.h (rev 0)
+++ trunk/python-ogre/code_generators/ogreforests/python_forests_sizeof.h 2007-10-03 03:55:30 UTC (rev 405)
@@ -0,0 +1,10 @@
+// sizeof ( variable );
+sizeof (std::list<GrassLayer*, std::allocator<GrassLayer*> > );
+sizeof (std::map<Ogre::String, Ogre::MaterialPtr> );
+sizeof (Ogre::TRect<float> );
+sizeof (std::list<GeometryPage*> );
+sizeof (std::map<Ogre::Material*, SBMaterialRef*> );
+sizeof (std::map<Ogre::String, Ogre::MaterialPtr> );
+sizeof (std::list<GeometryPageManager*, std::allocator<GeometryPageManager*> > );
+
+
Modified: trunk/python-ogre/code_generators/theora/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/theora/generate_code.py 2007-10-01 15:10:25 UTC (rev 404)
+++ trunk/python-ogre/code_generators/theora/generate_code.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -129,15 +129,15 @@
if cls.name.startswith('Cmd'):
cls.exclude()
- c = main_ns.class_('::Ogre::TheoraVideoController')
- print dir ( c )
- print c.bases
- for i in c.bases:
- print "Base: ", i
- print dir (i)
+# # c = main_ns.class_('::Ogre::TheoraVideoController')
+# # print dir ( c )
+# # print c.bases
+# # for i in c.bases:
+# # print "Base: ", i
+# # print dir (i)
- main_ns.enum('::Ogre::eTexturePlayMode').include(already_exposed=True)
- main_ns.enum('::Ogre::eAudioSampleFormat').include(already_exposed=True)
+ main_ns.enum('::Ogre::eTexturePlayMode').include()
+ main_ns.enum('::Ogre::eAudioSampleFormat').include()
main_ns.class_('::Ogre::RingBuffer').include(already_exposed=True)
main_ns.class_('::Ogre::TexturePtr').include(already_exposed=True)
@@ -506,7 +506,8 @@
# We need to tell boost how to handle calling (and returning from) certain functions
#
Set_Call_Policies ( mb.global_ns.namespace (MAIN_NAMESPACE) )
-
+ c = main_ns.class_('::Ogre::ExternalTextureSource' ).include(already_exposed=True)
+
#
# the manual stuff all done here !!!
#
Modified: trunk/python-ogre/code_generators/theora/hand_made_wrappers.py
===================================================================
--- trunk/python-ogre/code_generators/theora/hand_made_wrappers.py 2007-10-01 15:10:25 UTC (rev 404)
+++ trunk/python-ogre/code_generators/theora/hand_made_wrappers.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -6,7 +6,14 @@
Ogre::TheoraVideoController * General_castAsVideoController( Ogre::ExternalTextureSource* e ){
return (Ogre::TheoraVideoController*) e;
}
-
+
+Ogre::TheoraVideoController * Get_Controller( void ) {
+ Ogre::TheoraVideoController * mVideoControl = static_cast<Ogre::TheoraVideoController*>
+ (Ogre::ExternalTextureSourceManager::getSingleton().
+ getExternalTextureSource("ogg_video"));
+ return mVideoControl;
+ }
+
Ogre::TheoraVideoController * General_Init( void ) {
Ogre::TheoraVideoController * mVideoControl = static_cast<Ogre::TheoraVideoController*>
(Ogre::ExternalTextureSourceManager::getSingleton().
@@ -54,6 +61,11 @@
Input: None\\n\\
Ouput: ",\
bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >());"""
+ """bp::def( "getVideoController", &Get_Controller,
+ "Python-Ogre Helper Function: Get a Video Controller .\\n\\
+ Input: None\\n\\
+ Ouput: ",\
+ bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >());"""
]
#################################################################################################
@@ -64,7 +76,8 @@
class_.add_registration_code ( c )
def apply( mb ):
- mb.add_declaration_code( WRAPPER_DEFINITION_General )
- apply_reg (mb, WRAPPER_REGISTRATION_General )
+ return
+# # mb.add_declaration_code( WRAPPER_DEFINITION_General )
+# # apply_reg (mb, WRAPPER_REGISTRATION_General )
\ No newline at end of file
Modified: trunk/python-ogre/demos/dshow/Demo_Video.py
===================================================================
--- trunk/python-ogre/demos/dshow/Demo_Video.py 2007-10-01 15:10:25 UTC (rev 404)
+++ trunk/python-ogre/demos/dshow/Demo_Video.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -23,18 +23,12 @@
light = sceneManager.createLight('MainLight')
light.setPosition (20, 80, 150)
- self.dshowMovieTextureSystem = OgreDshow.DirectShowMovieTexture(321,321)
- movieName = "/downloads/vf2.avi"
- movieName = "c:/temp/apple.wmv"
+ self.dshowMovieTextureSystem = OgreDshow.DirectShowMovieTexture(160,120) ## get this right for scaling
+ movieName = "../media_extra/fish.avi"
self.dshowMovieTextureSystem.loadMovie(movieName)
self.dshowMovieTextureSystem.playMovie()
-
-# self._createScalingPlane()
-# self._createScrollingKnot()
- #self._createWateryPlane()
-# self._createVideoPlane()
skyMaterial = ogre.MaterialManager.getSingleton() #get the material manager pointer
skyMaterial = skyMaterial.create('SkyMat', ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME )
skyMaterial.lightingEnabled = False
@@ -43,7 +37,7 @@
textureUnitState.setScrollAnimation(0.15, 0)
sceneManager.setSkyDome(True, 'SkyMat', -5.0, 2.0)
-#
+
c = sceneManager.createEntity("cubo", "cube.mesh")
n = sceneManager.getRootSceneNode().createChildSceneNode()
n.attachObject(c)
@@ -56,41 +50,10 @@
tex=mat.getTechnique(0).getPass(0).getTextureUnitState(0)
tex.setTextureName(
self.dshowMovieTextureSystem.getMovieTexture().getName())
-
- def _createScalingPlane(self):
- entity = self.sceneManager.createEntity('Plane', ogre.SceneManager.PT_PLANE)
- entity.setMaterialName('Examples/TextureEffect1')
- node = self.sceneManager.getRootSceneNode().createChildSceneNode(ogre.Vector3(-250, -40, -100))
- node.attachObject(entity)
-
- def _createScrollingKnot(self):
- entity = self.sceneManager.createEntity('Knot', 'knot.mesh')
- entity.setMaterialName('Examples/TextureEffect2')
- node = self.sceneManager.getRootSceneNode().createChildSceneNode(ogre.Vector3(200, 50, 150))
- node.attachObject(entity)
-
- def _createWateryPlane(self):
- entity = self.sceneManager.createEntity('WaterPlane', ogre.SceneManager.PT_PLANE)
- entity.setMaterialName('Examples/TextureEffect3')
- node = self.sceneManager.getRootSceneNode().attachObject(entity)
-
- def _createVideoPlane(self):
- entity = self.sceneManager.createEntity('WaterPlane', ogre.SceneManager.PT_PLANE)
- entity.setMaterialName('Examples/Rockwall')
- node = self.sceneManager.getRootSceneNode().attachObject(entity)
-
- mat=ogre.MaterialManager.getSingleton().getByName('Examples/Rockwall')
- tex=mat.getTechnique(0).getPass(0).getTextureUnitState(0)
- tex.setTextureName(
- self.dshowMovieTextureSystem.getMovieTexture().getName())
-
-
-
def _createFrameListener(self):
self.frameListener = VideoListener(self.renderWindow, self.camera, self.dshowMovieTextureSystem)
self.root.addFrameListener(self.frameListener)
-
def __del__(self):
self.dshowMovieTextureSystem.stopMovie()
@@ -103,11 +66,13 @@
sf.FrameListener.__init__(self, renderWindow, camera)
def frameStarted(self, frameEvent):
- self.video.updateMovieTexture()
+ if not self.video.isPlayingMovie():
+ self.video.rewindMovie()
+ self.video.playMovie()
+ else:
+ self.video.updateMovieTexture()
return sf.FrameListener.frameStarted(self, frameEvent)
-
-
if __name__ == '__main__':
try:
application = VideoApplication()
Modified: trunk/python-ogre/demos/ffmpeg/Demo_Video.py
===================================================================
--- trunk/python-ogre/demos/ffmpeg/Demo_Video.py 2007-10-01 15:10:25 UTC (rev 404)
+++ trunk/python-ogre/demos/ffmpeg/Demo_Video.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -51,7 +51,7 @@
n.setPosition(ogre.Vector3(i*250, 0, 0))
#self.cubeEntities.append(c)
- v = VIDEO.cVideoPlayer("videoMaterial" + str(i), "apple.wmv")
+ v = VIDEO.cVideoPlayer("videoMaterial" + str(i), "fish.avi")
#v = VIDEO.cVideoPlayer("videoMaterial" + str(i), "test.divx")
v.setLoop(True)
self.videoPlayer.append(v)
Modified: trunk/python-ogre/demos/ogre/Demo_Fresnel.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_Fresnel.py 2007-10-01 15:10:25 UTC (rev 404)
+++ trunk/python-ogre/demos/ogre/Demo_Fresnel.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -38,15 +38,15 @@
def preRenderTargetUpdate(self,evt):
#Hide plane and objects above the water
- self.planeEnt.visible = False
+ self.planeEnt.setVisible ( False )
for e in self.aboveWaterEnts:
- e.visible = False
+ e.setVisible ( False )
def postRenderTargetUpdate(self,evt):
#Show plane and objects above the water
- self.planeEnt.visible = True
+ self.planeEnt.setVisible ( True )
for e in self.aboveWaterEnts:
- e.visible = True
+ e.setVisible ( True )
# Reflection Render Target Listener
class ReflectionTextureListener(ogre.RenderTargetListener):
@@ -60,16 +60,16 @@
def preRenderTargetUpdate(self,evt):
#Hide plane and objects above the water
- self.planeEnt.visible = False
+ self.planeEnt.setVisible ( False )
for e in self.belowWaterEnts:
- e.setVisible ( False ) ##.visible to setVisible
+ e.setVisible ( False )
self.cam.enableReflection(self.reflectionPlane)
def postRenderTargetUpdate(self,evt):
#Show plane and objects above the water
- self.planeEnt.visible = True
+ self.planeEnt.setVisible ( True )
for e in self.belowWaterEnts:
- e.setVisible ( True ) # .visible to setVisible
+ e.setVisible ( True )
self.cam.disableReflection()
class FresnelFrameListener(sf.FrameListener):
@@ -165,15 +165,15 @@
# check graphics card capabilities
capabilities = ogre.Root.getSingleton().getRenderSystem().getCapabilities()
- if not capabilities.hasCapability(ogre.RSC_VERTEX_PROGRAM) or not capabilities.hasCapability(ogre.RSC_FRAGMENT_PROGRAM):
- raise ogre.Exception(1, 'Your card does not support vertex and fragment programs, so cannot run this demo. Sorry!', 'fresneldemo.py')
-
- else:
- if (ogre.GpuProgramManager.getSingleton().isSyntaxSupported("arbfp1") and
- ogre.GpuProgramManager.getSingleton().isSyntaxSupported("ps_2_0") and
- ogre.GpuProgramManager.getSingleton().isSyntaxSupported("ps_1_4")):
-
- raise ogre.Exception(1, 'Your card does not support advanced fragment programs, so cannot run this demo. Sorry!', 'fresneldemo.py')
+# if not capabilities.hasCapability(ogre.RSC_VERTEX_PROGRAM) or not capabilities.hasCapability(ogre.RSC_FRAGMENT_PROGRAM):
+# raise ogre.Exception(1, 'Your card does not support vertex and fragment programs, so cannot run this demo. Sorry!', 'fresneldemo.py')
+#
+# else:
+# if (ogre.GpuProgramManager.getSingleton().isSyntaxSupported("arbfp1") and
+# ogre.GpuProgramManager.getSingleton().isSyntaxSupported("ps_2_0") and
+# ogre.GpuProgramManager.getSingleton().isSyntaxSupported("ps_1_4")):
+#
+# raise ogre.Exception(1, 'Your card does not support advanced fragment programs, so cannot run this demo. Sorry!', 'fresneldemo.py')
theCam = self.camera
self.camera.setPosition (-50,125,760)
@@ -233,6 +233,7 @@
(0, 0, 1))
self.planeEnt = sceneManager.createEntity( "plane", "ReflectPlane" )
+ print "\n\n", self.planeEnt, "\n",dir(self.planeEnt )
self.planeEnt.setMaterialName("Examples/FresnelReflectionRefraction")
Added: trunk/python-ogre/demos/ogre/Demo_NetworkClient.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_NetworkClient.py (rev 0)
+++ trunk/python-ogre/demos/ogre/Demo_NetworkClient.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -0,0 +1,26 @@
+"""
+VERY simple and crude client code.
+Assumes there is a server that will echo the sent data and when it's time to close
+the server will send "Done"
+
+"""
+
+import socket as s
+
+if __name__ == "__main__":
+ # we need to send (and recieve) data on the local machine using port 4444
+ (family, socktype, proto, canonname, sockaddr) = s.getaddrinfo ( "127.0.0.1",4444)[0] #s.gethostname(), 4444 )[0]
+
+ socket = s.socket( s.AF_INET, s.SOCK_DGRAM ) # create the client socket, note I'm testing with UDP traffic
+ socket.connect ( sockaddr )
+ loop = True
+ count = 0
+ while loop:
+ socket.send ( str(count) + " hello out there")
+ incomming = socket.recv ( 256 )
+ print "Received:", incomming
+ if incomming == "Done": ## special -- it's up to the server to decided when we are done...
+ loop = False
+ count += 1
+ socket.close()
+
\ No newline at end of file
Added: trunk/python-ogre/demos/ogre/Demo_NetworkServer.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_NetworkServer.py (rev 0)
+++ trunk/python-ogre/demos/ogre/Demo_NetworkServer.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -0,0 +1,41 @@
+"""
+VERY simple and crude Python server
+
+Receives data in a none state ful fashion -- loops as an echo server for a while
+and after 10 loops sends a 'Done' to the client and tells the server to stop
+
+"""
+
+import socket as s
+import SocketServer as ss
+
+class Handler ( ss.BaseRequestHandler ):
+ def handle ( self ):
+ datain = self.request[0] # get the input string
+ s=datain.split() ## Assume input data is <count><space><rest of info>
+ count = int ( s[0] )
+
+ sock = self.request[1] ## this is the incomming socket
+
+ ## because this is a UDP demo we need to connect to send info back
+ ## I suspect this isn't needed if we use TCP server
+ sock.connect ( self.client_address )
+
+ if count > 10: # we are only looping 10 times
+ sock.send ("Done")
+ self.server.closenow = True # tell the server we are done..
+ else:
+ sock.send ( "Back at you: " + datain) ## send data back
+
+
+class Server(ss.ThreadingMixIn, ss.UDPServer): pass
+
+if __name__ == "__main__":
+ # we create a server on the local machine listening to port 4444..
+ # could also use "localhost" instead of gethostname()
+ (family, socktype, proto, canonname, sockaddr) = s.getaddrinfo ( "127.0.0.1", 4444 )[0]
+ myServer = Server ( sockaddr, Handler )
+ myServer.closenow = False
+
+ while not myServer.closenow:
+ myServer.handle_request()
Added: trunk/python-ogre/demos/ogre/Demo_OgreCollision02.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_OgreCollision02.py (rev 0)
+++ trunk/python-ogre/demos/ogre/Demo_OgreCollision02.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -0,0 +1,223 @@
+##
+## This is a very ugly hack in progress to test collisions (without Physics)
+##
+## It uses the Ogre Intersection Query functions with the intention of extending it
+## to use Opcode to see if there is a performance difference
+##
+
+import ogre.renderer.OGRE as ogre
+import ogre.physics.ODE as ode
+
+import SampleFramework as sf
+import random, sys
+from math import *
+
+NUMBOXES=300
+TypeOgre=0
+TypeODE=1
+
+AppType = TypeODE
+
+class OgreCollideApplication(sf.Application):
+ #
+ # first lets create a nice scene with a floor plane (that also get's collided
+ #
+ def _createScene(self):
+ sceneManager = self.sceneManager
+ ## Set ambient light
+ sceneManager.setAmbientLight ( (0.6, 0.6, 0.6) )
+
+ ## Create a skydome
+ sceneManager.setSkyDome (True, "Examples/CloudySky",5,8)
+ light = sceneManager.createLight('MainLight')
+ light.setPosition (20, 80, 50)
+
+ # create the floor
+ plane = ogre.Plane()
+ plane.normal = ogre.Vector3.UNIT_Y
+ plane.d = 200
+ mm = ogre.MeshManager.getSingleton()
+ mm.createPlane('FloorPlane', 'General', plane, 200000.0, 200000.0,
+ 20, 20, True, 1, 50, 50, ogre.Vector3.UNIT_Z)
+ entity = sceneManager.createEntity('floor', 'FloorPlane')
+ entity.setMaterialName('Examples/RustySteel')
+ sceneManager.getRootSceneNode().createChildSceneNode().attachObject(entity)
+
+ # create the camera node & attach camera
+ cameraNode = sceneManager.getRootSceneNode().createChildSceneNode()
+ cameraNode.attachObject(self.camera)
+
+ # how many barrels and pallets do we want
+ self.numBoxes = NUMBOXES
+
+ # we need a framelistener to make life easy
+ def _createFrameListener(self):
+ self.frameListener = OgreCollideListener(self.renderWindow, self.camera, self.sceneManager, self.numBoxes)
+ self.root.addFrameListener(self.frameListener)
+
+
+
+class OgreCollideQueryListener(ogre.IntersectionSceneQueryListener):
+ """ the listener that gets called for each pair of intersecting objects """
+ def __init__ ( self ):
+ ogre.IntersectionSceneQueryListener.__init__ ( self )
+
+ def queryResult ( self, first, second ):
+ """ the actual function that gets called - for the demo I simply change the material type
+ so we see the collisions - except I don't change the floor material"""
+ if first.name != "floor":
+ first.setMaterialName('Examples/Chrome')
+ if second.name != "floor":
+ second.setMaterialName('Examples/TextureEffect2')
+ return True
+
+class OgreCollideListener(sf.FrameListener):
+ """ the frame listener we are using"""
+
+ def __init__(self, renderWindow, camera, sm, num):
+ sf.FrameListener.__init__(self, renderWindow, camera)
+ # Create an intersection query
+ self.intersectSceneQuery = sm.createIntersectionQuery()
+ # and a listener to receive the results
+ self.querylistener = OgreCollideQueryListener()
+
+ # I then create a range of crates and barrels to test with
+ self.numBoxes = num
+ self.sceneManager = sm
+ self.CreateBoxes ( num )
+ self.frametime = 0
+
+ if AppType == TypeODE:
+ self.SetupODE()
+
+ def SetupODE(self):
+ # Create a world object
+ self.world = ode.dWorld()
+ self.world.setGravity( 0,-9.81,0 )
+ self.world.setERP(0.8)
+ self.world.setCFM(1E-5)
+
+ # Create a space object
+ self.space = ode.CreateSimpleSpace()
+
+ # Create a plane geom which prevent the objects from falling forever
+ self.floor = ode.dPlane(space.id(), 0.0, 1.0, 0.0, 0.0)
+
+ # A list with ODE bodies
+ self.odebodies = []
+
+ # A joint group for the contact joints that are generated whenever
+ # two bodies collide
+ self.contactgroup = ode.dJointGroup()
+
+ def frameStarted(self, frameEvent):
+ """ called each frame (at the start), check if it's time to do collision checking and
+ if so do it, otherwise pass through"""
+ self.frametime += frameEvent.timeSinceLastFrame
+
+ if AppType == TypeOgre:
+ # for performance reasons lets check for collisions about 5 times a second
+ if self.frametime > 0.2:
+ self.ResetBoxes()
+ self.intersectSceneQuery.execute( self.querylistener )
+ self.frametime = 0
+ elif AppType == TypeODE:
+ # Detect collisions and create contact joints
+ self.space.collide((self.world,self.contactgroup), self, "ODE_callback")
+
+ # Simulation step
+ self.world.step(self.frametime)
+
+ # Remove all contact joints
+ contactgroup.empty()
+ return sf.FrameListener.frameStarted(self, frameEvent)
+
+ # Collision callback
+ def ODE_callback(self,args, geom1, geom2):
+ """Callback function for the collide() method.
+
+ This function checks if the given geoms do collide and
+ creates contact joints if they do.
+ """
+ # Check if the objects do collide
+ contacts = ode.dCollide(geom1, geom2)
+ # Create contact joints
+ world,contactgroup = args
+ for c in contacts:
+ c.setBounce(0.2)
+ c.setMu(5000)
+ j = ode.ContactJoint(world, contactgroup, c)
+ j.attach(geom1.getBody(), geom2.getBody())
+
+ def frameEnded ( self, ev ):
+ """and at the end of the frame we update the objects positions in preparation for the
+ next frame"""
+ self.UpdateBoxes(ev.timeSinceLastFrame)
+ return sf.FrameListener.frameEnded(self, ev)
+
+ def CreateBoxes (self, num):
+ self.numBoxes=num
+ self._bodies=[]
+ names = ['WoodPallet','Barrel']
+ self.mBoxTime = [] #new float[mNbBoxes]
+ self.nodes = []
+ self.mSpeed = .000001
+ self.mAmplitude = .5
+ for i in range ( self.numBoxes ):
+ ## Create the visual representation (the Ogre entity and scene node)
+ name = "object" + str(i)
+ entity = self.sceneManager.createEntity(name, names[i % len(names)] + ".mesh")
+ node = self.sceneManager.getRootSceneNode().createChildSceneNode(name)
+ node.attachObject(entity)
+ entity.setNormaliseNormals(True)
+ entity.setCastShadows(True)
+ ## Pick a size
+ scale= 100
+ size = ogre.Vector3((random.random() * 0.5 + 0.1) * scale,
+ (random.random() * 0.5 + 0.1) * scale,
+ (random.random() * 0.5 + 0.1) * scale)
+ position = ogre.Vector3((random.random() -0.5 ) * 800.0,
+ (random.random() - 0.5 ) * 500.0,
+ (random.random() - 0.5 ) * 800.0)
+
+ node.setScale (size.x * 0.1,size.y * 0.1,size.z * 0.1)
+ node.setPosition (position)
+
+ # we need access to the entity and nodes to reset the material
+ self._bodies.append ( entity)
+ self.nodes.append( node)
+ self.mBoxTime.append ( 10.0*random.random() )
+
+ def ResetBoxes(self):
+ """ set the objects back to their original materials
+ """
+ for i in range ( self.numBoxes):
+ if i % 2 :
+ self._bodies[i].setMaterialName('RustyBarrel')
+ else:
+ self._bodies[i].setMaterialName('WoodPallet')
+
+ def UpdateBoxes(self, timesincelastframe):
+ """ move the objects in an interesting way :) """
+ for i in range ( self.numBoxes):
+ self.mBoxTime[i] += timesincelastframe * 0.001 # self.mSpeed
+ Center = ogre.Vector3()
+ n = self.nodes[i]
+ Center.x = cos(self.mBoxTime[i]*2.17)*self.mAmplitude + sin(self.mBoxTime[i])*self.mAmplitude*0.5
+ Center.y = cos(self.mBoxTime[i]*1.38)*self.mAmplitude + sin(self.mBoxTime[i]*self.mAmplitude)
+ Center.z = sin(self.mBoxTime[i]*0.777)*self.mAmplitude
+ pos = n.Position
+ pos.x += Center.x
+ pos.y += Center.y
+ pos.z += Center.y
+ n.Position = pos
+
+
+if __name__ == '__main__':
+ try:
+ application = OgreCollideApplication()
+ application.go()
+ except ogre.OgreException, e:
+ print e
+
+
Modified: trunk/python-ogre/demos/ogre/Demo_Terrain.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_Terrain.py 2007-10-01 15:10:25 UTC (rev 404)
+++ trunk/python-ogre/demos/ogre/Demo_Terrain.py 2007-10-03 03:55:30 UTC (rev 405)
@@ -18,24 +18,7 @@
self.sceneManager = self.root.createSceneManager(ogre.ST_GENERIC)
self.sceneManager = self.root.createSceneManager(ogre.ST_EXTERIOR_CLOSE)
- def _createCamera(self):
- self.camera = self.sceneManager.createCamera('PlayerCam')
- self.camera.setPosition (ogre.Vector3(128, 25, 128))
- self.camera.setPosition (128, 25, 128)
- self.camera.position = ogre.Vector3(128, 25, 128)
- self.camera.position = (128, 25, 128)
- self.camera.position = [128, 25, 128]
- self.camera.position = 128, 25, 128
-
- self.camera.lookAt(0, 0, -300)
- self.camera.NearClipDistance = 1
- # infinte far clip plane?
- #if self.root.renderSystem.capabilities.hasCapability(ogre.RSC_INFINITE_FAR_PLANE):
- #self.camera.farClipDistance = 0
- #else:
- self.camera.FarClipDistance = 1000
-
def _createScene(self):
sceneManager = self.sceneManager
camera = self.camera
Added: trunk/python-ogre/demos/ogreforests/Application.cpp
===================================================================
--- trunk/python-ogre/demos/ogreforests/Application.cpp (rev 0)
+++ trunk/python-ogre/demos/ogreforests/Application.cpp 2007-10-03 03:55:30 UTC (rev 405)
@@ -0,0 +1,359 @@
+/*-----------------------------------------------------------------------------
+WARNING!!! main.cpp, Appliation.h, and Appliation.cpp are TEMPORARY source files
+that demonstrate PagedGeometry. They are extremely messy, unstructured, and they
+should NOT be taken as an example. This is the beta version of PagedGeometry 1.0
+and does not include the examples and tutorials that the final version will have.
+-----------------------------------------------------------------------------*/
+
+//Application.cpp
+//-------------------------------------------------------------------------------------
+
+#include "Application.h"
+#include "ExampleFrameListener.h"
+
+#include "OgreRoot.h"
+#include "OgreFrameListener.h"
+#include "OgreCamera.h"
+#include "OgreRenderWindow.h"
+#include "OgreSceneManager.h"
+#include "OgreSceneQuery.h"
+#include "OgreRay.h"
+using namespace Ogre;
+
+#include "PagedGeometry.h"
+#include "ImpostorPage.h"
+#include "BatchPage.h"
+
+#include "TreeLoader2D.h"
+#include "TreeLoader3D.h"
+#include "GrassLoader.h"
+
+
+//Global pointer to the Application object
+Application *app;
+std::string mResourcePath;
+
+bool GrassFrameListener::frameStarted(const FrameEvent& evt)
+{
+ app->trees->update();
+ app->grass->update();
+ grassloader->updateAnimation();
+ return true;
+}
+
+//Standard constructor
+Application::Application()
+{
+ frameListener = 0;
+ root = 0;
+
+ //set resource path depending on platform
+ mResourcePath = getResourcePath();
+}
+
+//Standard destructor
+Application::~Application()
+{
+ if (frameListener)
+ delete frameListener;
+ if (root)
+ delete root;
+}
+
+//Starts application. Called automatically from main()
+void Application::go()
+{
+ //Initialize
+ if (!setup())
+ return;
+
+ //Load world
+ createScene();
+
+ //Start render loop
+ root->startRendering();
+
+ //Unload world
+ destroyScene();
+}
+
+//Initializes OGRE scene manager, resources, cameras, viewports, etc.
+bool Application::setup()
+{
+ //Create Ogre::Root
+ root = new Root();
+
+ // OSX does not have a working config dialog at the moment
+ #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+ root->loadPlugin("RenderSystem_GL");
+ root->loadPlugin("Plugin_CgProgramManager");
+ root->loadPlugin("Plugin_BSPSceneManager");
+ root->loadPlugin("Plugin_OctreeSceneManager");
+ root->setRenderSystem(root->getAvailableRenderers()->front());
+ root->getRenderSystem()->setConfigOption("RTT Preferred Mode", "RTT");
+ root->getRenderSystem()->setConfigOption("Full Screen", "No");
+ root->getRenderSystem()->setConfigOption("Video Mode", "800 x 600");
+ window = root->initialise(true);
+ #else
+...
[truncated message content] |