// Create portals for every door
public void createPortals( SceneManager scene,
Entity room,
SceneNode roomNode,
PCZone zone,
short doorFlags,
bool isEnclosure )
{
string portalName;
Vector3[] corners = new Vector3[ 4 ];
if ( isEnclosure )
{
if ( ( doorFlags & (short)RoomDoors.DOOR_FRONT ) != 0 )
{
// 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.Name + ( "_FrontDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_BACK ) != 0 )
{
// 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.Name + ( "_BackDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_TOP ) != 0 )
{
// 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.Name + ( "_TopDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_BOT ) != 0 )
{
// 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.Name + ( "_BottomDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_LEFT ) != 0 )
{
// 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.Name + ( "_LeftDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_RIGHT ) != 0 )
{
// 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.Name + ( "_RightDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_FRONT ) != 0 )
{
// 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.Name + ( "_FrontDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_BACK ) != 0 )
{
// 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.Name + ( "_BackDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_TOP ) != 0 )
{
// 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.Name + ( "_TopDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_BOT ) != 0 )
{
// 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.Name + ( "_BottomDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_LEFT ) != 0 )
{
// 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.Name + ( "_LeftDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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 & (short)RoomDoors.DOOR_RIGHT ) != 0 )
{
// 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.Name + ( "_RightDoorPortal" );
Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
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();
}
}
}