zone.cpp

Engine/source/T3D/zone.cpp

More...

Public Functions

ConsoleDocClass(Zone , "@brief An object that represents an interior <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n\n</a>" "A zone is an invisible volume that encloses an interior space. All objects that have " "their world space axis-aligned bounding boxes (AABBs) intersect the zone's volume are " "assigned <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the zone. This assignment happens automatically as objects are placed " "and transformed. Also, assignment is not exclusive meaning that an object can be assigned " "<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> many zones at the same time <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it intersects all of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">them.\n\n</a>" "In itself, the volume of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> zone is fully sealed off from the outside. This means that <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a> " "viewing the scene from inside the volume, only objects assigned <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the zone are rendered <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a> " "when viewing the scene from outside the volume, objects< em >exclusively</em > only assigned the " "zone are not <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rendered.\n\n</a>" " Usually, you will want <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> connect zones <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> each other by means of portals. A portal overlapping " "with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> zone \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//Example declaration of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Zone. This creates <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> box-shaped <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">zone.\n</a>" "<a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classzone/">Zone</a>(TestZone)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " position=\"3.61793 -1.01945 14.7442\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   rotation = \"1 0 0 0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   scale = \"10 10 10\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@section Zone_zoneGroups <a href="/coding/class/classzone/">Zone</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Groups\n\n</a>" " Normally, Zones will not connect <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> each other when they overlap. This means that <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> viewing " "the scene from one zone, the contents of the other zone will not be visible except when there " "is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> portal connecting the zones. However, sometimes it is convenient <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> represent <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> single interior " "space through <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> combination of Zones so that when any of these zones is visible, all other zones " "that are part of the same interior space are visible. This is possible by employing \"zone groups\".\n\n" "@see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Portal\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">enviroMisc\n</a>" )
DefineEngineMethod(Zone , dumpZoneState , void , (bool updateFirst) , (true) , "Dump <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> list of all objects assigned <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the zone <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the console as well as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> list " "of all connected zone <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">spaces.\n\n</a>" "@param updateFirst Whether <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> update the contents of the zone before dumping. Since zoning states of " "objects are updated on demand, the zone contents can be outdated." )
DefineEngineMethod(Zone , getZoneId , S32 , () , "Get the unique numeric ID of the zone in its <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">scene.\n\n</a>" "@return The ID of the zone." )
DefineEngineMethod(Zone , selectWithin , void , () , "select <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> list of all objects assigned <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the zone" )

Detailed Description

Public Functions

ConsoleDocClass(Zone , "@brief An object that represents an interior <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n\n</a>" "A zone is an invisible volume that encloses an interior space. All objects that have " "their world space axis-aligned bounding boxes (AABBs) intersect the zone's volume are " "assigned <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the zone. This assignment happens automatically as objects are placed " "and transformed. Also, assignment is not exclusive meaning that an object can be assigned " "<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> many zones at the same time <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it intersects all of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">them.\n\n</a>" "In itself, the volume of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> zone is fully sealed off from the outside. This means that <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a> " "viewing the scene from inside the volume, only objects assigned <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the zone are rendered <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a> " "when viewing the scene from outside the volume, objects< em >exclusively</em > only assigned the " "zone are not <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rendered.\n\n</a>" " Usually, you will want <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> connect zones <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> each other by means of portals. A portal overlapping " "with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> zone \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//Example declaration of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Zone. This creates <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> box-shaped <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">zone.\n</a>" "<a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classzone/">Zone</a>(TestZone)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " position=\"3.61793 -1.01945 14.7442\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   rotation = \"1 0 0 0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   scale = \"10 10 10\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@section Zone_zoneGroups <a href="/coding/class/classzone/">Zone</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Groups\n\n</a>" " Normally, Zones will not connect <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> each other when they overlap. This means that <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> viewing " "the scene from one zone, the contents of the other zone will not be visible except when there " "is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> portal connecting the zones. However, sometimes it is convenient <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> represent <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> single interior " "space through <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> combination of Zones so that when any of these zones is visible, all other zones " "that are part of the same interior space are visible. This is possible by employing \"zone groups\".\n\n" "@see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Portal\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">enviroMisc\n</a>" )

DefineEngineMethod(Zone , dumpZoneState , void , (bool updateFirst) , (true) , "Dump <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> list of all objects assigned <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the zone <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the console as well as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> list " "of all connected zone <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">spaces.\n\n</a>" "@param updateFirst Whether <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> update the contents of the zone before dumping. Since zoning states of " "objects are updated on demand, the zone contents can be outdated." )

DefineEngineMethod(Zone , getZoneId , S32 , () , "Get the unique numeric ID of the zone in its <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">scene.\n\n</a>" "@return The ID of the zone." )

DefineEngineMethod(Zone , selectWithin , void , () , "select <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> list of all objects assigned <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the zone" )

IMPLEMENT_CO_NETOBJECT_V1(Zone )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#include "platform/platform.h"
 25#include "T3D/zone.h"
 26
 27#include "console/consoleTypes.h"
 28#include "console/engineAPI.h"
 29#include "scene/mixin/sceneAmbientSoundObject.impl.h"
 30#include "scene/mixin/scenePolyhedralObject.impl.h"
 31
 32#include "scene/sceneManager.h"
 33#include "gui/worldEditor/worldEditor.h"
 34
 35IMPLEMENT_CO_NETOBJECT_V1( Zone );
 36
 37ConsoleDocClass( Zone,
 38   "@brief An object that represents an interior space.\n\n"
 39
 40   "A zone is an invisible volume that encloses an interior space.  All objects that have "
 41   "their world space axis-aligned bounding boxes (AABBs) intersect the zone's volume are "
 42   "assigned to the zone.  This assignment happens automatically as objects are placed "
 43   "and transformed.  Also, assignment is not exclusive meaning that an object can be assigned "
 44   "to many zones at the same time if it intersects all of them.\n\n"
 45
 46   "In itself, the volume of a zone is fully sealed off from the outside.  This means that while "
 47   "viewing the scene from inside the volume, only objects assigned to the zone are rendered while "
 48   "when viewing the scene from outside the volume, objects <em>exclusively</em> only assigned the "
 49   "zone are not rendered.\n\n"
 50
 51   "Usually, you will want to connect zones to each other by means of portals.  A portal overlapping "
 52   "with a zone \n\n"
 53
 54   "@tsexample\n"
 55   "// Example declaration of a Zone.  This creates a box-shaped zone.\n"
 56   "new Zone( TestZone )\n"
 57   "{\n"
 58   "   position = \"3.61793 -1.01945 14.7442\";\n"
 59   "   rotation = \"1 0 0 0\";\n"
 60   "   scale = \"10 10 10\";\n"
 61   "};\n"
 62   "@endtsexample\n\n"
 63
 64   "@section Zone_zoneGroups Zone Groups\n\n"
 65
 66   "Normally, Zones will not connect to each other when they overlap.  This means that if viewing "
 67   "the scene from one zone, the contents of the other zone will not be visible except when there "
 68   "is a portal connecting the zones.  However, sometimes it is convenient to represent a single interior "
 69   "space through a combination of Zones so that when any of these zones is visible, all other zones "
 70   "that are part of the same interior space are visible.  This is possible by employing \"zone groups\".\n\n"
 71
 72   "@see Portal\n"
 73
 74   "@ingroup enviroMisc\n"
 75);
 76
 77
 78//-----------------------------------------------------------------------------
 79
 80void Zone::consoleInit()
 81{
 82   // Disable rendering of zones by default.
 83   getStaticClassRep()->mIsRenderEnabled = false;
 84}
 85
 86void Zone::initPersistFields()
 87{
 88   addProtectedField("selectAll", TypeBool, Offset(mSelecting, Zone),
 89      &_doSelect, &defaultProtectedGetFn, "Select all in this zone", AbstractClassRep::FieldFlags::FIELD_ComponentInspectors);
 90
 91   Parent::initPersistFields();
 92}
 93
 94
 95bool Zone::_doSelect(void* object, const char* index, const char* data)
 96{
 97   Zone* zone = reinterpret_cast<Zone*>(object);
 98
 99   zone->selectWithin();
100
101   return false;
102}
103
104void Zone::selectWithin()
105{
106   SimpleQueryList sql;
107   Zone* zoneClient = (Zone*)getClientObject();
108   if (zoneClient)
109   {
110      SceneZoneSpaceManager* zoneManager = zoneClient->getSceneManager()->getZoneManager();
111      if (zoneManager)
112      {
113         for (U32 zoneId = zoneClient->mZoneRangeStart; zoneId < zoneClient->mZoneRangeStart + zoneClient->mNumZones; ++zoneId)
114            for (SceneZoneSpaceManager::ZoneContentIterator iter(zoneManager, zoneId, false); iter.isValid(); ++iter)
115            {
116               SceneObject* obj = (SceneObject*)iter->getServerObject();
117               bool fullyEnclosed = true;
118
119            for (SceneObject::ObjectZonesIterator zoneIter(obj); zoneIter.isValid(); ++zoneIter)
120            {
121               if (*zoneIter != zoneId)
122                  fullyEnclosed = false;
123               }
124               if (fullyEnclosed)
125                  sql.insertObject(obj);
126            }
127      }
128   }
129
130
131   WorldEditor* wedit;
132   if (Sim::findObject("EWorldEditor", wedit))
133   {
134      wedit->clearSelection();
135      wedit->selectObject(this);
136      for (SceneObject** i = sql.mList.begin(); i != sql.mList.end(); i++)
137      {
138         wedit->selectObject(*i);
139      }
140   }
141}
142//=============================================================================
143//    Console API.
144//=============================================================================
145// MARK: ---- Console API ----
146
147//-----------------------------------------------------------------------------
148
149DefineEngineMethod( Zone, getZoneId, S32, (),,
150   "Get the unique numeric ID of the zone in its scene.\n\n"
151   "@return The ID of the zone." )
152{
153   return object->getZoneRangeStart();
154}
155
156//-----------------------------------------------------------------------------
157
158DefineEngineMethod( Zone, dumpZoneState, void, ( bool updateFirst ), ( true ),
159   "Dump a list of all objects assigned to the zone to the console as well as a list "
160   "of all connected zone spaces.\n\n"
161   "@param updateFirst Whether to update the contents of the zone before dumping.  Since zoning states of "
162      "objects are updated on demand, the zone contents can be outdated." )
163{
164   object->dumpZoneState( updateFirst );
165}
166
167DefineEngineMethod(Zone, selectWithin, void, () ,,
168   "select a list of all objects assigned to the zone")
169{
170   object->selectWithin();
171}
172