Revision: 558
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=558&view=rev
Author: andy_miller
Date: 2008-01-29 16:12:44 -0800 (Tue, 29 Jan 2008)
Log Message:
-----------
Fix to addPoly function in OgreNewt, changes to Forests underlying api
Modified Paths:
--------------
trunk/python-ogre/code_generators/ogreforests/hand_made_wrappers.py
trunk/python-ogre/code_generators/ogrenewt/generate_code.py
trunk/python-ogre/code_generators/ogrenewt/hand_made_wrappers.py
Modified: trunk/python-ogre/code_generators/ogreforests/hand_made_wrappers.py
===================================================================
--- trunk/python-ogre/code_generators/ogreforests/hand_made_wrappers.py 2008-01-22 09:17:13 UTC (rev 557)
+++ trunk/python-ogre/code_generators/ogreforests/hand_made_wrappers.py 2008-01-30 00:12:44 UTC (rev 558)
@@ -5,12 +5,12 @@
"""
static PyObject* mSubscriber_tree;
static std::string mName_tree;
-Ogre::Real HelperHeightFunction_Tree2D ( Ogre::Real x, Ogre::Real z) {
+Ogre::Real HelperHeightFunction_Tree2D ( Ogre::Real x, Ogre::Real z, void *userData) {
Ogre::Real y;
if (mName_tree.length() == 0 )
- y = boost::python::call<Ogre::Real>(mSubscriber_tree, x, z);
+ y = boost::python::call<Ogre::Real>(mSubscriber_tree, x, z, userData);
else
- y = boost::python::call_method<Ogre::Real>(mSubscriber_tree, mName_tree.c_str(), x, z);
+ y = boost::python::call_method<Ogre::Real>(mSubscriber_tree, mName_tree.c_str(), x, z, userData);
return y;
}
@@ -25,12 +25,12 @@
"""
static PyObject* mSubscriber_grass;
static std::string mName_grass;
-Ogre::Real HelperHeightFunction_Grass ( Ogre::Real x, Ogre::Real z) {
+Ogre::Real HelperHeightFunction_Grass ( Ogre::Real x, Ogre::Real z, void * userData) {
Ogre::Real y;
if (mName_grass.length() == 0 )
- y = boost::python::call<Ogre::Real>(mSubscriber_grass, x, z);
+ y = boost::python::call<Ogre::Real>(mSubscriber_grass, x, z, userData );
else
- y = boost::python::call_method<Ogre::Real>(mSubscriber_grass, mName_grass.c_str(), x, z);
+ y = boost::python::call_method<Ogre::Real>(mSubscriber_grass, mName_grass.c_str(), x, z, userData);
return y;
}
Modified: trunk/python-ogre/code_generators/ogrenewt/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/ogrenewt/generate_code.py 2008-01-22 09:17:13 UTC (rev 557)
+++ trunk/python-ogre/code_generators/ogrenewt/generate_code.py 2008-01-30 00:12:44 UTC (rev 558)
@@ -58,6 +58,7 @@
## these need to be excluded due to callback functions - Have been wrapped
ogrenewt_ns.class_( "World" ).member_functions("setLeaveWorldCallback").exclude()
+
ogrenewt_ns.class_( "Body" ).member_functions("addBouyancyForce").exclude()
ogrenewt_ns.class_( "Body" ).member_functions("setAutoactiveCallback").exclude()
@@ -75,6 +76,10 @@
ogrenewt_ns.class_( "Joint" ).member_functions("setUserData").exclude()
ogrenewt_ns.class_( "Body" ).member_functions("getUserData").exclude()
ogrenewt_ns.class_( "Joint" ).member_functions("getUserData").exclude()
+
+ ## This one needs a list of vertices given to it
+ ogrenewt_ns.class_( "TreeCollision" ).member_functions("addPoly").exclude()
+
# ConvexHull has an overloaded constructor that takes 5 args, one is a pointer to a list of vectors which we can't
# handle, so we created a helper function caller createConvexHull that takes a python list instead.
Modified: trunk/python-ogre/code_generators/ogrenewt/hand_made_wrappers.py
===================================================================
--- trunk/python-ogre/code_generators/ogrenewt/hand_made_wrappers.py 2008-01-22 09:17:13 UTC (rev 557)
+++ trunk/python-ogre/code_generators/ogrenewt/hand_made_wrappers.py 2008-01-30 00:12:44 UTC (rev 558)
@@ -398,6 +398,37 @@
'def ("setAutoactiveCallback", &::Body_setAutoactiveCallback);',
'def ("setCustomTransformCallback", &::Body_setCustomTransformCallback);'
]
+
+
+
+WRAPPER_DEFINITION_TreeCollision=\
+"""
+void
+TreeCollision_addPoly( ::OgreNewt::CollisionPrimitives::TreeCollision & me, boost::python::list polys, unsigned int ID )
+ {
+
+ Ogre::Vector3* newverts = new Ogre::Vector3[ 3 ];
+ Ogre::Vector3* startpos = newverts;
+ int index;
+ if (len(polys) < 3 ) {
+ throw std::runtime_error ( std::string ("addPoly called with a list with less than 3 verticies") );
+ return;
+ }
+ for (index=0;index<3;index++ ) {
+ *newverts++ = boost::python::extract<Ogre::Vector3> (polys[index]);
+ }
+ me.addPoly( startpos, ID );
+ return;
+ }
+ """
+WRAPPER_REGISTRATION_TreeCollision= [
+ """def ("addPoly", &::TreeCollision_addPoly,\
+ "Python-Ogre Helper Function: Adds a list of 3 Ogre:Vector3's to the collision system.\\n\\
+ Input: List of 3 Ogre::Vector3's, ID\\n\\
+ Output: Nothing" );"""
+ ]
+
+
########################################################################################
WRAPPER_DEFINITION_General=\
"""
@@ -458,6 +489,10 @@
cs.add_declaration_code( WRAPPER_DEFINITION_BodyIterator )
apply_reg (cs, WRAPPER_REGISTRATION_BodyIterator )
+ cs = mb.class_( 'TreeCollision' )
+ cs.add_declaration_code( WRAPPER_DEFINITION_TreeCollision )
+ apply_reg (cs, WRAPPER_REGISTRATION_TreeCollision )
+
mb.add_declaration_code( WRAPPER_DEFINITION_General )
apply_reg (mb, WRAPPER_REGISTRATION_General )
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|