[Python-ogre-commit] SF.net SVN: python-ogre:[680] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-07-30 04:14:08
|
Revision: 680 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=680&view=rev Author: andy_miller Date: 2008-07-30 04:14:17 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Expose 'points' and 'triangles' void * variables in PhysX Modified Paths: -------------- trunk/python-ogre/code_generators/physx/generate_code.py trunk/python-ogre/demos/ogrepcz/Demo_PCZ01.py Modified: trunk/python-ogre/code_generators/physx/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/physx/generate_code.py 2008-07-29 13:49:17 UTC (rev 679) +++ trunk/python-ogre/code_generators/physx/generate_code.py 2008-07-30 04:14:17 UTC (rev 680) @@ -135,7 +135,15 @@ def ManualFixes ( mb ): global_ns = mb.global_ns - + known = ['points', 'triangles'] + for c in global_ns.classes(): + if c.name.startswith ('Nx'): + print "Checking", c + for v in c.variables(allow_empty = True ): + if v.name in known: + v.expose_address = True + print "Exposing Address: ", v.name, " of class: ", c.name + sys.exit() ############################################################ ## Modified: trunk/python-ogre/demos/ogrepcz/Demo_PCZ01.py =================================================================== --- trunk/python-ogre/demos/ogrepcz/Demo_PCZ01.py 2008-07-29 13:49:17 UTC (rev 679) +++ trunk/python-ogre/demos/ogrepcz/Demo_PCZ01.py 2008-07-30 04:14:17 UTC (rev 680) @@ -35,80 +35,84 @@ Global_targetMO = None #ogre.MovableObject() -# # class PCZTestFrameListener ( sf.ExampleFrameListener) -# # -# # public: -# # PCZTestFrameListener(RenderWindow* win, Camera* cam) : ExampleFrameListener( win, cam ) -# # -# # self.MoveSpeed = 15.0 -# # self.updateRay=ogre.Ray() -# # -# # -# # void moveCamera() -# # -# # # Make all the spatial changes to the camera's scene node -# # # Note that YAW direction is around a fixed axis (freelook style) rather than a natural YAW -# # #(e.g. airplane) -# # self.camera.getParentSceneNode().translate(self.translateVector, Node.TS_LOCAL) -# # self.camera.getParentSceneNode().pitch(mRotY) -# # self.camera.getParentSceneNode().yaw(mRotX, Node.TS_WORLD) -# # Global_buildingNode.translate(Global_buildingTranslate, Node.TS_LOCAL) -# # -# # -# # bool frameRenderingQueued( const FrameEvent& evt ) -# # -# # if( ExampleFrameListener.frameRenderingQueued( evt ) == False ) -# # return False -# # -# # Global_buildingTranslate = ogre.Vector3(0,0,0) -# # if( self.keyboard.isKeyDown( ois.KC_LBRACKET ) ) -# # -# # Global_buildingTranslate = ogre.Vector3(0,-10,0) -# # -# # if( self.keyboard.isKeyDown( ois.KC_RBRACKET ) ) -# # -# # Global_buildingTranslate = ogre.Vector3(0,10,0) -# # -# # -# # if( self.keyboard.isKeyDown( ois.KC_LSHIFT ) || -# # self.keyboard.isKeyDown( ois.KC_RSHIFT )) -# # -# # self.MoveSpeed = 150 -# # -# # else -# # -# # self.MoveSpeed = 15 -# # -# # -# # # test the ray scene query by showing bounding box of whatever the camera is pointing directly at -# # # (takes furthest hit) -# # self.updateRay.setOrigin(self.camera.getParentSceneNode().getPosition()) -# # self.updateRay.setDirection(self.camera.getParentSceneNode().getOrientation()*ogre.Vector3.NEGATIVE_UNIT_Z) -# # Global_raySceneQuery.setRay(updateRay) -# # zone = ((PCZSceneNode*)(self.camera.getParentSceneNode())).getHomeZone() -# # ((PCZRaySceneQuery*)Global_raySceneQuery).setStartZone(zone) -# # ((PCZRaySceneQuery*)Global_raySceneQuery).setExcludeNode(self.camera.getParentSceneNode()) -# # RaySceneQueryResult& qryResult = Global_raySceneQuery.execute() -# # RaySceneQueryResult.iterator i = qryResult.begin() -# # if (i != qryResult.end()) -# # -# # RaySceneQueryResult.reverse_iterator ri = qryResult.rbegin() -# # MovableObject * mo = ri.movable -# # if (Global_targetMO != mo) -# # -# # if (Global_targetMO != 0) -# # -# # Global_targetMO.getParentSceneNode().showBoundingBox(False) -# # -# # Global_targetMO = mo -# # Global_targetMO.getParentSceneNode().showBoundingBox(True) -# # -# # -# # -# # return True +class PCZTestFrameListener ( sf.ExampleFrameListener): + def __init__(self, renderWindow, camera ): + sf.FrameListener.__init__(self, renderWindow, camera) + self.moveSpeed = 15.0 + self.raySceneQueue = sceneManager.createRayQuery(ogre.Ray(camera.getPosition(), + ogre.Vector3.NEGATIVE_UNIT_Y)) + self.camera = camera + self.updateRay=ogre.Ray() + self.pczCameraParentNode = pcz.castAsPCZSceneNode(self.camera.getParentSceneNode()) + + def moveCamera( self ): + # Make all the spatial changes to the camera's scene node + # Note that YAW direction is around a fixed axis (freelook style) rather than a natural YAW + #(e.g. airplane) + self.camera.getParentSceneNode().translate(self.translateVector, ogre.Node.TS_LOCAL) + self.camera.getParentSceneNode().pitch(self.rotationY) + self.camera.getParentSceneNode().yaw(self.rotationX, ogre.Node.TS_WORLD) + + Global_buildingNode.translate(Global_buildingTranslate, ogre.Node.TS_LOCAL) + def frameRenderingQueued( self, evt ): + if sf.FrameListener.frameRenderingQueued( evt ) == False: + return False + Global_buildingTranslate = ogre.Vector3(0,0,0) + if self.keyboard.isKeyDown( ois.KC_LBRACKET ): + Global_buildingTranslate = ogre.Vector3(0,-10,0) + if self.keyboard.isKeyDown( ois.KC_RBRACKET ): + Global_buildingTranslate = ogre.Vector3(0,10,0) + if self.keyboard.isKeyDown( ois.KC_LSHIFT ) or self.keyboard.isKeyDown( ois.KC_RSHIFT ): + self.moveSpeed = 150 + else + self.moveSpeed = 15 + # test the ray scene query by showing bounding box of whatever the camera is pointing directly at + # (takes furthest hit) + self.updateRay.setOrigin(self.camera.getParentSceneNode().getPosition()) + self.updateRay.setDirection(self.camera.getParentSceneNode().getOrientation()*ogre.Vector3.NEGATIVE_UNIT_Z) + Global_raySceneQuery.setRay(updateRay) + zone = self.pczCameraParentNode.getHomeZone() + pcz.castAsPCZRaySceneQuery(Global_raySceneQuery).setStartZone(zone) + pcz.castAsPCZRaySceneQuery(Global_raySceneQuery).setExcludeNode(self.camera.getParentSceneNode()) + for queryResult in Global_raySceneQuery.execute(): + ri = qryResult.rbegin() + mo = ri.movable + if Global_targetMO != mo: + if Global_targetMO != 0: + Global_targetMO.getParentSceneNode().showBoundingBox(False) + Global_targetMO = mo + Global_targetMO.getParentSceneNode().showBoundingBox(True) + return True + +class TerrainListener(sf.FrameListener): + def __init__(self, renderWindow, camera, sceneManager): + sf.FrameListener.__init__(self, renderWindow, camera) + self.sceneManager = sceneManager + self.moveSpeed = 50.0 + + self.raySceneQuery = sceneManager.createRayQuery(ogre.Ray(camera.getPosition(), + ogre.Vector3.NEGATIVE_UNIT_Y)) + self.camera = camera + #self.camera.setPosition (self.camera.getPosition() + ogre.Vector3(0.0, 10.0, 0.0)) + + def frameStarted(self, frameEvent): + # clamp to terrain + updateRay = ogre.Ray() + updateRay.setOrigin (self.camera.getPosition() + ogre.Vector3(0.0, 10.0, 0.0)) + updateRay.setDirection (ogre.Vector3.NEGATIVE_UNIT_Y) + self.raySceneQuery.Ray = updateRay + for queryResult in self.raySceneQuery.execute(): + if queryResult.worldFragment is not None: + pos = self.camera.getPosition() + self.camera.setPosition (pos.x, pos.y - queryResult.distance + 15.0, pos.z) + break + + return sf.FrameListener.frameStarted(self, frameEvent) + + class PCZTestApplication (sf.Application): def __del__(self): del Global_raySceneQuery This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |