[Python-ogre-commit] SF.net SVN: python-ogre:[678] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-07-29 12:56:11
|
Revision: 678 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=678&view=rev Author: andy_miller Date: 2008-07-29 12:56:20 +0000 (Tue, 29 Jul 2008) Log Message: ----------- further Portal work (not finished with the demo) Modified Paths: -------------- trunk/python-ogre/code_generators/ogrepcz/generate_code.py trunk/python-ogre/code_generators/ogrepcz/hand_made_wrappers.py trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py Added Paths: ----------- trunk/python-ogre/demos/ogrepcz/ trunk/python-ogre/demos/ogrepcz/Demo_PCZ01.py trunk/python-ogre/demos/ogrepcz/RoomObject.py trunk/python-ogre/demos/plugins.cfg trunk/python-ogre/demos/resources.cfg Removed Paths: ------------- trunk/python-ogre/demos/ogre/resources.cfg trunk/python-ogre/packages_2.6/ Modified: trunk/python-ogre/code_generators/ogrepcz/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/ogrepcz/generate_code.py 2008-07-29 10:25:07 UTC (rev 677) +++ trunk/python-ogre/code_generators/ogrepcz/generate_code.py 2008-07-29 12:56:20 UTC (rev 678) @@ -86,7 +86,14 @@ if MAIN_NAMESPACE: main_ns = global_ns.namespace( MAIN_NAMESPACE ) else: - main_ns = global_ns + main_ns = global_ns + + includes = ['::Ogre::Portal::PORTAL_TYPE', + '::Ogre::Portal::PortalIntersectResult', +# '::Ogre::PCZone::NODE_LIST_TYPE' + ] + for i in includes: + main_ns.enum(i).include() ############################################################ ## @@ -277,9 +284,17 @@ main_ns = global_ns.namespace( MAIN_NAMESPACE ) # main_ns.include() for c in main_ns.classes(): - if c.name.startswith ('PCZ'): + if c.name.startswith ('PCZ') or c.name.startswith ('PCPlane') or c.name.startswith ('Portal'): + c.include() print "Including ", c - c.include() + + for c in ['Portal','PCPlane']: + main_ns.class_(c).include() + print "Including ", c +# for e in c.enums(allow_empty=True): +# e.include() +# for v in c.variables(allow_empty=True): +# v.include() common_utils.AutoExclude ( mb, MAIN_NAMESPACE ) ManualExclude ( mb ) Modified: trunk/python-ogre/code_generators/ogrepcz/hand_made_wrappers.py =================================================================== --- trunk/python-ogre/code_generators/ogrepcz/hand_made_wrappers.py 2008-07-29 10:25:07 UTC (rev 677) +++ trunk/python-ogre/code_generators/ogrepcz/hand_made_wrappers.py 2008-07-29 12:56:20 UTC (rev 678) @@ -1,7 +1,47 @@ import os import environment +WRAPPER_DEFINITION_General = \ +""" +// The following helper functions are a start and possibly need to be extended to include +// additional scene queries.. +Ogre::PCZSceneNode * General_castAsPCZSceneNode( Ogre::SceneNode * in ){ + return (Ogre::PCZSceneNode*) in; + } +Ogre::PCZSceneManager * General_castAsPCZSceneManager( Ogre::SceneManager * in ){ + return (Ogre::PCZSceneManager*) in; + } +Ogre::PCZRaySceneQuery * General_castAsPCZRaySceneQuery( Ogre::RaySceneQuery * in ){ + return (Ogre::PCZRaySceneQuery*) in; + } + +/// TO HANDLE ?? +/* PCZAxisAlignedBoxSceneQuery : public DefaultAxisAlignedBoxSceneQuery +PCZRaySceneQuery : public DefaultRaySceneQuery +PCZSphereSceneQuery : public DefaultSphereSceneQuery +PCZPlaneBoundedVolumeListSceneQuery : public DefaultPlaneBoundedVolumeListSceneQuery +*/ + + +""" +WRAPPER_REGISTRATION_General = [ + """bp::def( "castAsPCZSceneNode", &General_castAsPCZSceneNode, + "Python-Ogre Helper Function: Casts a SceneNode as a PCZSceneNode.\\n\\ + Input: SceneNode\\n\\ + Ouput: PCZSceneNode",\ + bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >());""", + """bp::def( "castAsPCZSceneManager", &General_castAsPCZSceneManager, + "Python-Ogre Helper Function: Casts a SceneManager as a PCZSceneManager.\\n\\ + Input: SceneManager\\n\\ + Ouput: PCZSceneManager",\ + bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >());""", + """bp::def( "castAsPCZRaySceneQuery", &General_castAsPCZRaySceneQuery, + "Python-Ogre Helper Function: Casts a RaySceneQuery as a PCZRaySceneQuery.\\n\\ + Input: RaySceneQuery\\n\\ + Ouput: PCZRaySceneQuery",\ + bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >());""", +] ################################################################################################# ################################################################################################# @@ -11,5 +51,6 @@ class_.add_registration_code ( c ) def apply( mb ): - pass + mb.add_declaration_code( WRAPPER_DEFINITION_General ) + apply_reg (mb, WRAPPER_REGISTRATION_General ) \ No newline at end of file Deleted: trunk/python-ogre/demos/ogre/resources.cfg =================================================================== --- trunk/python-ogre/demos/ogre/resources.cfg 2008-07-29 10:25:07 UTC (rev 677) +++ trunk/python-ogre/demos/ogre/resources.cfg 2008-07-29 12:56:20 UTC (rev 678) @@ -1,24 +0,0 @@ -[Bootstrap] -Zip=../media/packs/OgreCore.zip - -# Resource locations to be added to the default path -[General] -FileSystem=../media -FileSystem=../media/fonts -FileSystem=../media/sounds -FileSystem=../media/Audio -FileSystem=../media/materials/programs -FileSystem=../media/materials/scripts -FileSystem=../media/materials/textures -FileSystem=../media/models -FileSystem=../media/overlays -FileSystem=../media/particle -FileSystem=../media/gui -Zip=../media/packs/cubemap.zip -Zip=../media/packs/cubemapsJS.zip -Zip=../media/packs/dragon.zip -Zip=../media/packs/fresneldemo.zip -Zip=../media/packs/ogretestmap.zip -Zip=../media/packs/skybox.zip -#Zip=../media/packs/chiropteraDM.pk3 - Added: trunk/python-ogre/demos/ogrepcz/Demo_PCZ01.py =================================================================== --- trunk/python-ogre/demos/ogrepcz/Demo_PCZ01.py (rev 0) +++ trunk/python-ogre/demos/ogrepcz/Demo_PCZ01.py 2008-07-29 12:56:20 UTC (rev 678) @@ -0,0 +1,327 @@ +# This code is in the Public Domain +# ----------------------------------------------------------------------------- +# This source file is part of Python-Ogre +# For the latest info, see http://python-ogre.org/ +# +# It is likely based on original code from OGRE and/or PyOgre +# For the latest info, see http://www.ogre3d.org/ +# +# Specialisation of OGRE's framework application to test/demo the +# Portal Connected Zone (PCZ) Scene Manager Plugin. +# +# You may use this sample code for anything you like, it is not covered by the +# LGPL. +# ----------------------------------------------------------------------------- +import sys +import os +sys.path.insert(0,'..') +import PythonOgreConfig + +## this here becase the Plug_PCZSceneManager.dll needs to be accessed by both the python module and the ogre plugins +if sys.platform == 'win32': + newpath = os.path.join ( os.path.abspath(os.path.dirname(__file__)), '../../plugins') + os.environ['PATH'] = newpath +';' + os.environ['PATH'] + +import ogre.renderer.OGRE as ogre +import SampleFramework as sf +import ogre.io.OIS as ois +import ogre.renderer.ogrepcz as pcz + +# import RoomObject + +Global_buildingNode = None #pcz.PCZSceneNode() +Global_buildingTranslate = None # ogre.Vector3() +Global_raySceneQuery = None # ogre.RaySceneQuery() +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 PCZTestApplication (sf.Application): + def __del__(self): + del Global_raySceneQuery + + + def _chooseSceneManager ( self ): + + # Create the SceneManager, in this case a generic one + self.sceneManager = self.root.createSceneManager("PCZSceneManager", "PCZSceneManager") + # initialize the scene manager using terrain as default zone + zoneTypeName = "ZoneType_Default" + self.pczSM = pcz.castAsPCZSceneManager( self.sceneManager ) # store this for future reference + self.pczSM.init(zoneTypeName) + #self.sceneManager.showBoundingBoxes(True) + +# def _createFrameListener( self ): +# self.frameListener= PCZTestFrameListener(self.renderWindow, self.camera) +# self.root.addFrameListener(self.frameListener) + + def _createCamera(self): + # Create the camera + self.camera = self.sceneManager.createCamera("PlayerCam") + + # NEW: create a node for the camera and control that instead of camera directly. + # We do this because PCZSceneManager requires camera to have a node + self.cameraNode = self.sceneManager.getRootSceneNode().createChildSceneNode("PlayerCamNode") + # attach the camera to the node + self.cameraNode.attachObject(self.camera) + # fix the yaw axis of the camera + self.cameraNode.setFixedYawAxis(True) + + self.camera.setNearClipDistance(2) + self.camera.setFarClipDistance( 1000 ) + # set camera zone +# ((PCZSceneNode*)(self.cameraNode)).setHomeZone(((PCZSceneManager*)(self.sceneManager)).getDefaultZone()) + + + # utility function to create terrain zones easily + def createTerrainZone(self, zoneName, terrain_cfg): + # load terrain into the terrain zone + terrainZone = self.pczSM.createZone("ZoneType_Terrain", zoneName) + terrainZone.notifyCameraCreated(self.camera) + self.pczSM.setZoneGeometry( zoneName, pcz.castAsPCZSceneNode(self.sceneManager.getRootSceneNode()), terrain_cfg ) + + # create aab portal(s) around the terrain + corners =[] + aabb = ogre.AxisAlignedBox() + + # make portal from terrain to default + terrainZone.getAABB(aabb) + portalName = "PortalFrom"+zoneName+"ToDefault_Zone" + p = self.pczSM.createPortal(portalName, pcz.Portal.PORTAL_TYPE_AABB) + corners[0] = aabb.getMinimum() + corners[1] = aabb.getMaximum() + p.setCorner(0, corners[0]) + p.setCorner(1, corners[1]) + p.setDirection(ogre.Vector3.NEGATIVE_UNIT_Z) # this indicates an "inward" pointing normal + # associate the portal with the terrain's main node + p.setNode(terrainZone.getEnclosureNode()) + # IMPORTANT: Update the derived values of the portal + p.updateDerivedValues() + # add the portal to the zone + terrainZone._addPortal(p) + + # make portal from default to terrain + portalName = "PortalFromDefault_ZoneTo"+zoneName + p2 = self.pczSM.createPortal(portalName, pcz.Portal.PORTAL_TYPE_AABB) + corners[0] = aabb.getMinimum() + corners[1] = aabb.getMaximum() + p2.setCorner(0, corners[0]) + p2.setCorner(1, corners[1]) + p2.setDirection(ogre.Vector3.UNIT_Z) # this indicates an "outward" pointing normal + # associate the portal with the terrain's main node + p2.setNode(terrainZone.getEnclosureNode()) + # IMPORTANT: Update the derived values of the portal + p2.updateDerivedValues() + # add the portal to the zone + self.pczSM.getDefaultZone()._addPortal(p2) + + # connect the portals manually + p.setTargetPortal(p2) + p2.setTargetPortal(p) + p.setTargetZone(self.pczSM.getDefaultZone()) + p2.setTargetZone(terrainZone) + + return terrainZone + + + # Just override the mandatory create scene method + def _createScene( self ): + + # Set ambient light + self.sceneManager.setAmbientLight(ogre.ColourValue(0.25, 0.25, 0.25)) + + # Create a skybox + self.sceneManager.setSkyBox(True, "Examples/CloudyNoonSkyBox", 500 ) + # put the skybox node in the default zone +# self.pczSM.setSkyZone(None) + + # Create a light + l = self.sceneManager.createLight("MainLight") + l.setPosition(0,0,0) + l.setAttenuation(500, 0.5, 1.0, 0.0) + # Accept default settings: point light, white diffuse, just set position + # attach light to a scene node so the PCZSM can handle it properly (zone-wise) + # IMPORTANT: Lights (just like cameras) MUST be connected to a scene node! + lightNode = self.cameraNode.createChildSceneNode("light_Node") + lightNode.attachObject(l) + + # Fog + # NB it's VERY important to set this before calling setWorldGeometry + # because the vertex program picked will be different + fadeColour= ogre.ColourValue(0.101, 0.125, 0.1836) + self.sceneManager.setFog( ogre.FOG_LINEAR, fadeColour, .001, 500, 1000) + self.renderWindow.getViewport(0).setBackgroundColour(fadeColour) + + # create a terrain zone + terrain_cfg = "terrain.cfg" + zoneName ="Terrain1_Zone" + terrainZone = self.createTerrainZone(zoneName, terrain_cfg) + +# # /* # Create another terrain zone +# # terrain_cfg = "terrain.cfg" +# # zoneName = "Terrain2_Zone" +# # terrainZone = createTerrainZone(zoneName, terrain_cfg) +# # # move second terrain next to first terrain +# # terrainZone.getEnclosureNode().setPosition(1500, 0, 0) +# # +# # # Create another terrain zone +# # terrain_cfg = "terrain.cfg" +# # zoneName = "Terrain3_Zone" +# # terrainZone = createTerrainZone(zoneName, terrain_cfg) +# # # move terrain next to first terrain +# # terrainZone.getEnclosureNode().setPosition(0, 0, 1500) +# # +# # # Create another terrain zone +# # terrain_cfg = "terrain.cfg" +# # zoneName = "Terrain4_Zone" +# # terrainZone = createTerrainZone(zoneName, terrain_cfg) +# # # move terrain next to first terrain +# # terrainZone.getEnclosureNode().setPosition(-1500, 0, 0) +# # +# # # Create another terrain zone +# # terrain_cfg = "terrain.cfg" +# # zoneName = "Terrain5_Zone" +# # terrainZone = createTerrainZone(zoneName, terrain_cfg) +# # # move terrain next to first terrain +# # terrainZone.getEnclosureNode().setPosition(0, 0, -1500) +# # +# # # Create another terrain zone +# # terrain_cfg = "terrain.cfg" +# # zoneName = "Terrain6_Zone" +# # terrainZone = createTerrainZone(zoneName, terrain_cfg) +# # # move terrain next to first terrain +# # terrainZone.getEnclosureNode().setPosition(1500, 0, 1500) +# # +# # # Create another terrain zone +# # terrain_cfg = "terrain.cfg" +# # zoneName = "Terrain7_Zone" +# # terrainZone = createTerrainZone(zoneName, terrain_cfg) +# # # move terrain next to first terrain +# # terrainZone.getEnclosureNode().setPosition(-1500, 0, -1500) +# # +# # # Create another terrain zone +# # terrain_cfg = "terrain.cfg" +# # zoneName = "Terrain8_Zone" +# # terrainZone = createTerrainZone(zoneName, terrain_cfg) +# # # move terrain next to first terrain +# # terrainZone.getEnclosureNode().setPosition(-1500, 0, 1500) +# # +# # # Create another terrain zone +# # terrain_cfg = "terrain.cfg" +# # zoneName = "Terrain9_Zone" +# # terrainZone = createTerrainZone(zoneName, terrain_cfg) +# # # move terrain next to first terrain +# # terrainZone.getEnclosureNode().setPosition(1500, 0, -1500) +# # */ + # set far clip plane to one terrain zone width (we have a LOT of terrain here, so we need to do far clipping!) + self.camera.setFarClipDistance(1500) + +# # create test buildinig +# RoomObject roomObj +# Global_buildingNode = roomObj.createTestBuilding(self.sceneManager, String("1")) +# Global_buildingNode.setPosition(500, 165, 570) +# #ogre.Radian r = Radian(3.1416/7.0) +# #Global_buildingNode.rotate(ogre.Vector3.UNIT_Y, r) +# +# # create another test buildinig +# RoomObject roomObj2 +# Global_buildingNode = roomObj2.createTestBuilding(self.sceneManager, String("2")) +# Global_buildingNode.setPosition(400, 165, 570) +# #ogre.Radian r = Radian(3.1416/7.0) +# #Global_buildingNode.rotate(ogre.Vector3.UNIT_Y, r) +# +# # Position camera in the center of the building +# self.cameraNode.setPosition(Global_buildingNode.getPosition()) +# # Look back along -Z +# self.camera.lookAt(self.cameraNode._getDerivedPosition() + ogre.Vector3(0,0,-300)) +# # Update bounds for camera +# self.cameraNode._updateBounds() +# +# # create the ray scene query +# Global_raySceneQuery = self.sceneManager.createRayQuery( +# Ray(self.camera.getParentNode().getPosition(), ogre.Vector3.NEGATIVE_UNIT_Z)) +# Global_raySceneQuery.setSortByDistance(True, 5) + + + +if __name__ == '__main__': + import exceptions,sys + try: + application = PCZTestApplication() + application.go() + except ogre.OgreException, e: + print e + Added: trunk/python-ogre/demos/ogrepcz/RoomObject.py =================================================================== --- trunk/python-ogre/demos/ogrepcz/RoomObject.py (rev 0) +++ trunk/python-ogre/demos/ogrepcz/RoomObject.py 2008-07-29 12:56:20 UTC (rev 678) @@ -0,0 +1,1009 @@ +## +## +## +## Filename : RoomObject.cpp + +# # +# # +# # class RoomObject +# # +# # private: +# # Ogre::Vector3 points[32]; +# # int mPortalCount; +# # public: + +DOOR_NONE = 0x00 +DOOR_TOP = 0x01 +DOOR_BOT = 0x02 +DOOR_FRONT = 0x04 +DOOR_BACK = 0x08 +DOOR_LEFT = 0x10 +DOOR_RIGHT = 0x20 +DOOR_ALL = 0xFF + +# # +# # +#include "Ogre.h" +#include "OgreMaterial.h" +#include "RoomObject.h" +#include "OgrePortal.h" + +using namespace Ogre +static int count = 0 + +PCZSceneNode * RoomObject.createTestBuilding(Ogre::SceneManager *scene, String & name) + + count++ + mPortalCount = 0 + Ogre.PCZSceneManager * pczSM = (Ogre::PCZSceneManager*)scene + + ## set points to building exterior size + createPoints(Vector3(60.0, 40.0, 60.0), Vector3(4.0, 10.0, 4.0)) + + ## create the building exterior + Entity *exterior = pczSM->createEntity( name + "_building_exterior", "building_exterior.mesh" ) + + ## make the enclosure a child node of the root scene node + PCZSceneNode * exteriorNode + exteriorNode = (PCZSceneNode*)scene->getRootSceneNode()->createChildSceneNode(name +"_building_exterior_node", Vector3( 0.0, 0.0f, 0.0f ) ) + exteriorNode->attachObject(exterior) + pczSM->addPCZSceneNode(exteriorNode, pczSM->getDefaultZone()) + + ## create portals for the building exterior + createPortals(scene, + exterior, + exteriorNode, + pczSM->getDefaultZone(), + DOOR_FRONT|DOOR_BACK|DOOR_LEFT|DOOR_RIGHT, + True) + + ## reset points to room size + createPoints(Vector3(20.0, 10.0, 20.0), Vector3(4.0, 10.0, 4.0)) + + ## create an interior room + Entity *room = pczSM->createEntity( name +"_room1", "room_nzpz.mesh" ) + + ## add the room as a child node to the enclosure node + PCZSceneNode * roomNode + roomNode = (PCZSceneNode*)exteriorNode->createChildSceneNode( name +"_room1_node", Vector3( 0.0, 0.0f, 20.0f ) ) + roomNode->attachObject(room) + + ## room needs it's own zone + Ogre.String zoneType = "ZoneType_Default" + Ogre.String zoneName = name +"_room1_zone" + PCZone * newZone = pczSM->createZone(zoneType, zoneName) + newZone->setEnclosureNode(roomNode) + pczSM->addPCZSceneNode(roomNode, newZone) + + ## create portals for the room + createPortals(scene, + room, + roomNode, + newZone, + DOOR_FRONT|DOOR_BACK, + False) + + ## create another interior room + room = pczSM->createEntity( name +"_room2", "room_nxpxnypynzpz.mesh" ) + + ## add the room as a child node to the enclosure node + roomNode = (PCZSceneNode*)exteriorNode->createChildSceneNode( name +"_room2_node", Vector3( 0.0, 0.0f, 0.0f ) ) + roomNode->attachObject(room) + + ## room needs it's own zone + zoneName = name +"_room2_zone" + newZone = pczSM->createZone(zoneType, zoneName) + newZone->setEnclosureNode(roomNode) + pczSM->addPCZSceneNode(roomNode, newZone) + + ## create portals for the room + createPortals(scene, + room, + roomNode, + newZone, + DOOR_FRONT|DOOR_BACK|DOOR_LEFT|DOOR_RIGHT|DOOR_TOP|DOOR_BOT, + False) + + ## create another interior room + room = pczSM->createEntity( name +"_room3", "room_nzpz.mesh" ) + + ## add the room as a child node to the enclosure node + roomNode = (PCZSceneNode*)exteriorNode->createChildSceneNode( name +"_room3_node", Vector3( 0.0, 0.0f, -20.0f ) ) + roomNode->attachObject(room) + + ## room needs it's own zone + zoneName = name +"_room3_zone" + newZone = pczSM->createZone(zoneType, zoneName) + newZone->setEnclosureNode(roomNode) + pczSM->addPCZSceneNode(roomNode, newZone) + + ## create portals for the room + createPortals(scene, + room, + roomNode, + newZone, + DOOR_FRONT|DOOR_BACK, + False) + + ## create another interior room + room = pczSM->createEntity( name +"_room4", "room_nxpx.mesh" ) + + ## add the room as a child node to the enclosure node + roomNode = (PCZSceneNode*)exteriorNode->createChildSceneNode( name +"_room4_node", Vector3( -20.0, 0.0f, 0.0f ) ) + roomNode->attachObject(room) + + ## room needs it's own zone + zoneName = name +"_room4_zone" + newZone = pczSM->createZone(zoneType, zoneName) + newZone->setEnclosureNode(roomNode) + pczSM->addPCZSceneNode(roomNode, newZone) + + ## create portals for the room + createPortals(scene, + room, + roomNode, + newZone, + DOOR_LEFT|DOOR_RIGHT, + False) + + ## create another interior room + room = pczSM->createEntity( name +"_room5", "room_nxpx.mesh" ) + + ## add the room as a child node to the enclosure node + roomNode = (PCZSceneNode*)exteriorNode->createChildSceneNode( name +"_room5_node", Vector3( 20.0, 0.0f, 0.0f ) ) + roomNode->attachObject(room) + + ## room needs it's own zone + zoneName = name +"_room5_zone" + newZone = pczSM->createZone(zoneType, zoneName) + newZone->setEnclosureNode(roomNode) + pczSM->addPCZSceneNode(roomNode, newZone) + + ## create portals for the room + createPortals(scene, + room, + roomNode, + newZone, + DOOR_LEFT|DOOR_RIGHT, + False) + + ## create another interior room + room = pczSM->createEntity( name +"_room6", "room_ny.mesh" ) + + ## add the room as a child node to the enclosure node + roomNode = (PCZSceneNode*)exteriorNode->createChildSceneNode( name +"_room6_node", Vector3( 0.0, 10.0f, 0.0f ) ) + roomNode->attachObject(room) + + ## room needs it's own zone + zoneName = name +"_room6_zone" + newZone = pczSM->createZone(zoneType, zoneName) + newZone->setEnclosureNode(roomNode) + pczSM->addPCZSceneNode(roomNode, newZone) + + ## create portals for the room + createPortals(scene, + room, + roomNode, + newZone, + DOOR_BOT, + False) + + ## create another interior room + room = pczSM->createEntity( name +"_room7", "room_py.mesh" ) + + ## add the room as a child node to the enclosure node + roomNode = (PCZSceneNode*)exteriorNode->createChildSceneNode( name +"_room7_node", Vector3( 0.0, -50.0f, 0.0f ) ) + roomNode->attachObject(room) + + ## room needs it's own zone + zoneName = name +"_room7_zone" + newZone = pczSM->createZone(zoneType, zoneName) + newZone->setEnclosureNode(roomNode) + pczSM->addPCZSceneNode(roomNode, newZone) + + ## create portals for the room + createPortals(scene, + room, + roomNode, + newZone, + DOOR_TOP, + False) + + ## reset points to tall room size + createPoints(Vector3(20.0, 40.0, 20.0), Vector3(4.0, 10.0, 4.0)) + + ## create another interior room + room = pczSM->createEntity( name +"_room8", "room_nypy_4y.mesh" ) + + ## add the room as a child node to the enclosure node + roomNode = (PCZSceneNode*)exteriorNode->createChildSceneNode( name +"_room8_node", Vector3( 0.0, -25.0f, 0.0f ) ) + roomNode->attachObject(room) + + ## room needs it's own zone + zoneName = name +"_room8_zone" + newZone = pczSM->createZone(zoneType, zoneName) + newZone->setEnclosureNode(roomNode) + pczSM->addPCZSceneNode(roomNode, newZone) + + ## create portals for the room + createPortals(scene, + room, + roomNode, + newZone, + DOOR_BOT|DOOR_TOP, + False) + + + ## resolve portal zone pointers + pczSM->connectPortalsToTargetZonesByLocation() + + return exteriorNode + + + +Ogre.ManualObject* RoomObject::createRoom(Ogre::SceneManager *scene, + Ogre.String &name, + short doorFlags, + bool isEnclosure, + Ogre.Vector3 dimensions, + Ogre.Vector3 doorDimensions) + + addMaterial(name, Ogre.ColourValue(1,1,1,.75), Ogre::SBT_TRANSPARENT_ALPHA) + + Ogre.ManualObject* room = scene->createManualObject(name) + + room->begin(name, Ogre.RenderOperation::OT_TRIANGLE_LIST) + + ## create points + createPoints(dimensions, doorDimensions) + + Ogre.Real fade=.5 + Ogre.Real solid=.8 + Ogre.ColourValue color = ColourValue(0, 0, solid, solid) + + ## copy to room + for (int i=0 i<32;i++) + + room->position(points[i]) + room->colour(color) + + + createWalls(room, doorFlags, isEnclosure) + + room->end() + + return room + + +void RoomObject.addMaterial( Ogre::String &mat, + Ogre.ColourValue &clr, + Ogre.SceneBlendType sbt) + + static int init=False + if(init): + return + else: + init=True + + Ogre.MaterialPtr matptr = Ogre::MaterialManager::getSingleton().create(mat, "General") + matptr->setReceiveShadows(False) + matptr->getTechnique(0)->setLightingEnabled(True) + matptr->getTechnique(0)->getPass(0)->setDiffuse(clr) + matptr->getTechnique(0)->getPass(0)->setAmbient(clr) + matptr->getTechnique(0)->getPass(0)->setSelfIllumination(clr) + matptr->getTechnique(0)->getPass(0)->setSceneBlending(sbt) + matptr->getTechnique(0)->getPass(0)->setLightingEnabled(False) + matptr->getTechnique(0)->getPass(0)->setVertexColourTracking(Ogre.TVC_DIFFUSE) + + +void RoomObject.createPoints(Ogre::Vector3 dimensions, + Ogre.Vector3 doorDimensions) + + Ogre.Real l = dimensions.x/2 + Ogre.Real h = dimensions.y/2 + Ogre.Real w = dimensions.z/2 + +## 4 7 +## *-------* +## /| /| +## / | / | y +## / 5| 3/ 6| | +## 0*---*---*---* *-- x +## | / | / / +## | / | / z +## |/ |/ +## 1*-------*2 + + points[0] = Ogre.Vector3(-l, h, w) ##0 + points[1] = Ogre.Vector3(-l, -h, w) ##1 + points[2] = Ogre.Vector3(l, -h, w) ##2 + points[3] = Ogre.Vector3(l, h, w) ##3 + + points[4] = Ogre.Vector3(-l, h, -w) ##4 + points[5] = Ogre.Vector3(-l, -h, -w) ##5 + points[6] = Ogre.Vector3(l, -h, -w) ##6 + points[7] = Ogre.Vector3(l, h, -w) ##7 + + ## doors + Ogre.Real l2 = doorDimensions.x/2 + Ogre.Real h2 = doorDimensions.y/2 + Ogre.Real w2 = doorDimensions.z/2 + + ## front door + points[8] = Ogre.Vector3(-l2, h2, w) ##8 + points[9] = Ogre.Vector3(-l2, -h2, w) ##9 + points[10] = Ogre.Vector3(l2, -h2, w) ##10 + points[11] = Ogre.Vector3(l2, h2, w) ##11 + + ## back door + points[12] = Ogre.Vector3(-l2, h2, -w) ##12 + points[13] = Ogre.Vector3(-l2, -h2, -w) ##13 + points[14] = Ogre.Vector3(l2, -h2, -w) ##14 + points[15] = Ogre.Vector3(l2, h2, -w) ##15 + + ## top door + points[16] = Ogre.Vector3(-l2, h, -w2) ##16 + points[17] = Ogre.Vector3(-l2, h, w2) ##17 + points[18] = Ogre.Vector3(l2, h, w2) ##18 + points[19] = Ogre.Vector3(l2, h, -w2) ##19 + + ## bottom door + points[20] = Ogre.Vector3(-l2, -h, -w2) ##20 + points[21] = Ogre.Vector3(-l2, -h, w2) ##21 + points[22] = Ogre.Vector3(l2, -h, w2) ##22 + points[23] = Ogre.Vector3(l2, -h, -w2) ##23 + + ## left door + points[24] = Ogre.Vector3(-l, h2, w2) ##24 + points[25] = Ogre.Vector3(-l, -h2, w2) ##25 + points[26] = Ogre.Vector3(-l, -h2, -w2) ##26 + points[27] = Ogre.Vector3(-l, h2, -w2) ##27 + + ## right door + points[28] = Ogre.Vector3(l, h2, w2) ##28 + points[29] = Ogre.Vector3(l, -h2, w2) ##29 + points[30] = Ogre.Vector3(l, -h2, -w2) ##30 + points[31] = Ogre.Vector3(l, h2, -w2) ##31 + + +void RoomObject.createWalls(Ogre::ManualObject* room, + short doorFlags, + bool isEnclosure) + + + if (isEnclosure): + + if(doorFlags & DOOR_FRONT): + + ## make front wall outward facing with door + room->quad(0, 8, 11, 3) + room->quad(1, 9, 8, 0) + room->quad(2, 10, 9, 1) + room->quad(3, 11, 10, 2) + + else: + + ## make front wall outward facing without door + room->quad(0, 1, 2, 3) + + if(doorFlags & DOOR_BACK): + + ## make back wall outward facing with door + room->quad(7, 15, 12, 4) + room->quad(6, 14, 15, 7) + room->quad(5, 13, 14, 6) + room->quad(4, 12, 13, 5) + + else: + + ## make back wall outward facing without door + room->quad(7, 6, 5, 4) + + if(doorFlags & DOOR_TOP): + + ## make top wall outward facing with door + room->quad(0, 17, 16, 4) + room->quad(4, 16, 19, 7) + room->quad(7, 19, 18, 3) + room->quad(3, 18, 17, 0) + + else: + + ## make top wall outward facing without door + room->quad(0, 3, 7, 4) + + if(doorFlags & DOOR_BOT): + + ## make bottom wall outward facing with door + room->quad(5, 20, 21, 1) + room->quad(6, 23, 20, 5) + room->quad(2, 22, 23, 6) + room->quad(1, 21, 22, 2) + + else: + + ## make bottom wall outward facing without door + room->quad(2, 1, 5, 6) + + if(doorFlags & DOOR_LEFT): + + ## make left wall outward facing with door + room->quad(0, 24, 25, 1) + room->quad(4, 27, 24, 0) + room->quad(5, 26, 27, 4) + room->quad(1, 25, 26, 5) + + else: + + ## make left side wall outward facing without door + room->quad(1, 0, 4, 5) + + if(doorFlags & DOOR_RIGHT): + + ## make right wall outward facing with door + room->quad(2, 29, 28, 3) + room->quad(6, 30, 29, 2) + room->quad(7, 31, 30, 6) + room->quad(3, 28, 31, 7) + + else: + + ## make right side wall outward facing without door + room->quad(3, 2, 6, 7) + + + else: + + ## front back + if(doorFlags & DOOR_FRONT): + + ## make front wall inward facing with door + room->quad(3, 11, 8, 0) + room->quad(0, 8, 9, 1) + room->quad(1, 9, 10, 2) + room->quad(2, 10, 11, 3) + + else: + + ## make front wall inward facing without door + room->quad(3, 2, 1, 0) + + if(doorFlags & DOOR_BACK): + + ## make back wall inward facing with door + room->quad(4, 12, 15, 7) + room->quad(7, 15, 14, 6) + room->quad(6, 14, 13, 5) + room->quad(5, 13, 12, 4) + + else: + + ## make back wall inward facing without door + room->quad(4, 5, 6, 7) + + ## top bottom + if(doorFlags & DOOR_TOP): + + ## make top wall inward facing with door + room->quad(4, 16, 17, 0) + room->quad(7, 19, 16, 4) + room->quad(3, 18, 19, 7) + room->quad(0, 17, 18, 3) + + else: + + ## make top wall inward facing without door + room->quad(4, 7, 3, 0) + + if(doorFlags & DOOR_BOT): + + ## make bottom wall inward facing with door + room->quad(1, 21, 20, 5) + room->quad(5, 20, 23, 6) + room->quad(6, 23, 22, 2) + room->quad(2, 22, 21, 1) + + else: + + ## make bottom wall inward facing without door + room->quad(6, 5, 1, 2) + + ## end caps + if(doorFlags & DOOR_LEFT): + + ## make left wall inward facing with door + room->quad(1, 25, 24, 0) + room->quad(0, 24, 27, 4) + room->quad(4, 27, 26, 5) + room->quad(5, 26, 25, 1) + + else: + + ## make left side wall inward facing without door + room->quad(5, 4, 0, 1) + + if(doorFlags & DOOR_RIGHT): + + ## make right wall inward facing with door + room->quad(3, 28, 29, 2) + room->quad(2, 29, 30, 6) + room->quad(6, 30, 31, 7) + room->quad(7, 31, 28, 3) + + else: + + ## make right side wall inward facing without door + room->quad(7, 6, 2, 3) + + + + +## Create portals for every door +void RoomObject.createPortals(Ogre::SceneManager *scene, + Ogre.ManualObject* room, + Ogre.SceneNode * roomNode, + Ogre.PCZone * zone, + short doorFlags, + bool isEnclosure) + + Ogre.String portalName + Vector3 corners[4] + + if (isEnclosure): + + if(doorFlags & DOOR_FRONT): + + ## set the corners to the front door corners + corners[0] = points[8] + corners[1] = points[9] + corners[2] = points[10] + corners[3] = points[11] + ## create the portal + portalName = room->getName() + Ogre.String("_FrontDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_BACK): + + ## set the corners to the front door corners + corners[0] = points[15] + corners[1] = points[14] + corners[2] = points[13] + corners[3] = points[12] + ## create the portal + portalName = room->getName() + Ogre.String("_BackDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_TOP): + + ## set the corners to the front door corners + corners[0] = points[16] + corners[1] = points[17] + corners[2] = points[18] + corners[3] = points[19] + ## create the portal + portalName = room->getName() + Ogre.String("_TopDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_BOT): + + ## set the corners to the front door corners + corners[0] = points[23] + corners[1] = points[22] + corners[2] = points[21] + corners[3] = points[20] + ## create the portal + portalName = room->getName() + Ogre.String("_BottomDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_LEFT): + + ## set the corners to the front door corners + corners[0] = points[27] + corners[1] = points[26] + corners[2] = points[25] + corners[3] = points[24] + ## create the portal + portalName = room->getName() + Ogre.String("_LeftDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_RIGHT): + + ## set the corners to the front door corners + corners[0] = points[28] + corners[1] = points[29] + corners[2] = points[30] + corners[3] = points[31] + ## create the portal + portalName = room->getName() + Ogre.String("_RightDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + + else: + + if(doorFlags & DOOR_FRONT): + + ## set the corners to the front door corners + corners[0] = points[11] + corners[1] = points[10] + corners[2] = points[9] + corners[3] = points[8] + ## create the portal + portalName = room->getName() + Ogre.String("_FrontDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_BACK): + + ## set the corners to the front door corners + corners[0] = points[12] + corners[1] = points[13] + corners[2] = points[14] + corners[3] = points[15] + ## create the portal + portalName = room->getName() + Ogre.String("_BackDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_TOP): + + ## set the corners to the front door corners + corners[0] = points[19] + corners[1] = points[18] + corners[2] = points[17] + corners[3] = points[16] + ## create the portal + portalName = room->getName() + Ogre.String("_TopDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_BOT): + + ## set the corners to the front door corners + corners[0] = points[20] + corners[1] = points[21] + corners[2] = points[22] + corners[3] = points[23] + ## create the portal + portalName = room->getName() + Ogre.String("_BottomDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_LEFT): + + ## set the corners to the front door corners + corners[0] = points[24] + corners[1] = points[25] + corners[2] = points[26] + corners[3] = points[27] + ## create the portal + portalName = room->getName() + Ogre.String("_LeftDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_RIGHT): + + ## set the corners to the front door corners + corners[0] = points[31] + corners[1] = points[30] + corners[2] = points[29] + corners[3] = points[28] + ## create the portal + portalName = room->getName() + Ogre.String("_RightDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + + + +## Create portals for every door +void RoomObject.createPortals(Ogre::SceneManager *scene, + Ogre.Entity* room, + Ogre.SceneNode * roomNode, + Ogre.PCZone * zone, + short doorFlags, + bool isEnclosure) + + Ogre.String portalName + Vector3 corners[4] + + if (isEnclosure): + + if(doorFlags & DOOR_FRONT): + + ## set the corners to the front door corners + corners[0] = points[8] + corners[1] = points[9] + corners[2] = points[10] + corners[3] = points[11] + ## create the portal + portalName = room->getName() + Ogre.String("_FrontDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_BACK): + + ## set the corners to the front door corners + corners[0] = points[15] + corners[1] = points[14] + corners[2] = points[13] + corners[3] = points[12] + ## create the portal + portalName = room->getName() + Ogre.String("_BackDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_TOP): + + ## set the corners to the front door corners + corners[0] = points[16] + corners[1] = points[17] + corners[2] = points[18] + corners[3] = points[19] + ## create the portal + portalName = room->getName() + Ogre.String("_TopDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_BOT): + + ## set the corners to the front door corners + corners[0] = points[23] + corners[1] = points[22] + corners[2] = points[21] + corners[3] = points[20] + ## create the portal + portalName = room->getName() + Ogre.String("_BottomDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_LEFT): + + ## set the corners to the front door corners + corners[0] = points[27] + corners[1] = points[26] + corners[2] = points[25] + corners[3] = points[24] + ## create the portal + portalName = room->getName() + Ogre.String("_LeftDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_RIGHT): + + ## set the corners to the front door corners + corners[0] = points[28] + corners[1] = points[29] + corners[2] = points[30] + corners[3] = points[31] + ## create the portal + portalName = room->getName() + Ogre.String("_RightDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + + else: + + if(doorFlags & DOOR_FRONT): + + ## set the corners to the front door corners + corners[0] = points[11] + corners[1] = points[10] + corners[2] = points[9] + corners[3] = points[8] + ## create the portal + portalName = room->getName() + Ogre.String("_FrontDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_BACK): + + ## set the corners to the front door corners + corners[0] = points[12] + corners[1] = points[13] + corners[2] = points[14] + corners[3] = points[15] + ## create the portal + portalName = room->getName() + Ogre.String("_BackDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_TOP): + + ## set the corners to the front door corners + corners[0] = points[19] + corners[1] = points[18] + corners[2] = points[17] + corners[3] = points[16] + ## create the portal + portalName = room->getName() + Ogre.String("_TopDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_BOT): + + ## set the corners to the front door corners + corners[0] = points[20] + corners[1] = points[21] + corners[2] = points[22] + corners[3] = points[23] + ## create the portal + portalName = room->getName() + Ogre.String("_BottomDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_LEFT): + + ## set the corners to the front door corners + corners[0] = points[24] + corners[1] = points[25] + corners[2] = points[26] + corners[3] = points[27] + ## create the portal + portalName = room->getName() + Ogre.String("_LeftDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + if(doorFlags & DOOR_RIGHT): + + ## set the corners to the front door corners + corners[0] = points[31] + corners[1] = points[30] + corners[2] = points[29] + corners[3] = points[28] + ## create the portal + portalName = room->getName() + Ogre.String("_RightDoorPortal") + Portal * p = ((PCZSceneManager*)scene)->createPortal(portalName) + p->setCorners(corners) + ## associate the portal with the roomnode + p->setNode(roomNode) + ## add the portal to the zone + zone->_addPortal(p) + ## update derived values for the portal + p->updateDerivedValues() + + + Added: trunk/python-ogre/demos/plugins.cfg =================================================================== --- trunk/python-ogre/demos/plugins.cfg (rev 0) +++ trunk/python-ogre/demos/plugins.cfg 2008-07-29 12:56:20 UTC (rev 678) @@ -0,0 +1,21 @@ +# Defines plugins to load + +## Use this for Windows +# Define plugin folder +PluginFolder=../../plugins +#home/andy/development/root/usr/lib/OGRE +Plugin=RenderSystem_GL.dll +Plugin=RenderSystem_Direct3D9.dll +Plugin=Plugin_ParticleFX.dll +Plugin=Plugin_BSPSceneManager.dll +Plugin=Plugin_OctreeSceneManager.dll +Plugin=Plugin_CgProgramManager.dll +Plugin=Plugin_PCZSceneManager.dll + +## +## NOTE use this for MacOS or Linux +# Plugin=RenderSystem_GL +# Plugin=Plugin_ParticleFX +# Plugin=Plugin_BSPSceneManager +# Plugin=Plugin_OctreeSceneManager +# Plugin=Plugin_CgProgramManager Added: trunk/python-ogre/demos/resources.cfg =================================================================== --- trunk/python-ogre/demos/resources.cfg (rev 0) +++ trunk/python-ogre/demos/resources.cfg 2008-07-29 12:56:20 UTC (rev 678) @@ -0,0 +1,24 @@ +[Bootstrap] +Zip=../media/packs/OgreCore.zip + +# Resource locations to be added to the default path +[General] +FileSystem=../media +FileSystem=../media/fonts +FileSystem=../media/sounds +FileSystem=../media/Audio +FileSystem=../media/materials/programs +FileSystem=../media/materials/scripts +FileSystem=../media/materials/textures +FileSystem=../media/models +FileSystem=../media/overlays +FileSystem=../media/particle +FileSystem=../media/gui +Zip=../media/packs/cubemap.zip +Zip=../media/packs/cubemapsJS.zip +Zip=../media/packs/dragon.zip +Zip=../media/packs/fresneldemo.zip +Zip=../media/packs/ogretestmap.zip +Zip=../media/packs/skybox.zip +#Zip=../media/packs/chiropteraDM.pk3 + Modified: trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py =================================================================== --- trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py 2008-07-29 10:25:07 UTC (rev 677) +++ trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py 2008-07-29 12:56:20 UTC (rev 678) @@ -9,6 +9,11 @@ # You may use this sample code for anything you like, it is not covered by the # LGPL. # ----------------------------------------------------------------------------- + +# +# 29 July 2008: Ensured that resources.cfg and plugins.cfg can exist in the parent directory +# + import ogre.renderer.OGRE as ogre import ogre.io.OIS as OIS ###import OgreRefApp @@ -20,7 +25,7 @@ import os.path paths = [os.path.join(os.getcwd(), 'plugins.cfg'), - os.path.join(os.getcwd(), '../plugins.cfg'), + os.path.join(os.getcwd(), '..','plugins.cfg'), '/etc/OGRE/plugins.cfg', os.path.join(os.path.dirname(os.path.abspath(__file__)), 'plugins.cfg')] @@ -107,7 +112,16 @@ """This sets up Ogre's resources, which are required to be in resources.cfg.""" config = ogre.ConfigFile() - config.load('resources.cfg' ) + try: + config.load('resources.cfg') + except ogre.OgreFileNotFoundException: + try: + config.load('../resources.cfg') + except: + raise + except: + raise + seci = config.getSectionIterator() while seci.hasMoreElements(): SectionName = seci.peekNextKey() @@ -276,7 +290,9 @@ self.InputManager.destroyInputObjectJoyStick( self.Joy ) OIS.InputManager.destroyInputSystem(self.InputManager) self.InputManager=None - + + ## NOTE the in Ogre 1.6 (1.7) this is changed to frameRenderingQueued !!! + def frameStarted(self, frameEvent): if(self.renderWindow.isClosed()): return False This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |