My final goal is to do realization for clipping geometry using portals.
Seamless transition for indoor/outdoor scenes.
Torque 3D Portals is children from the Zone objects (c ++)
Description of the Portal under the spoiler:
[spoiler]An object that provides a “window” into a zone, allowing a viewer to see what’s rendered in the zone.
A portal is an object that connects zones such that the content of one zone becomes visible in the other when looking through the portal.
Each portal is a full zone which is divided into two sides by the portal plane that intersects it. This intersection polygon is shown in red in the editor. Either of the sides of a portal can be connected to one or more zones.
A connection from a specific portal side to a zone is made in either of two ways:
By moving a Zone object to intersect with the portal at the respective side. While usually it makes sense for this overlap to be small, the connection is established correctly as long as the center of the Zone object that should connect is on the correct side of the portal plane.
By the respective side of the portal free of Zone objects that would connect to it. In this case, given that the other side is connected to one or more Zones, the portal will automatically connect itself to the outdoor “zone” which implicitly is present in any level.
From this, it follows that there are two types of portals:
Exterior Portals
An exterior portal is one that is connected to one or more Zone objects on one side and to the outdoor zone at the other side. This kind of portal is most useful for covering transitions from outdoor spaces to indoor spaces.
Interior Portals
An interior portal is one that is connected to one or more Zone objects on both sides. This kind of portal is most useful for covering transitions between indoor spaces./dd>
Strictly speaking, there is a third type of portal called an “invalid portal”. This is a portal that is not connected to a Zone object on either side in which case the portal serves no use.
Portals in Torque are bidirectional meaning that they connect zones both ways and you can look through the portal’s front side as well as through its back-side.
Like Zones, Portals can either be box-shaped or use custom convex polyhedral shapes.
Portals will usually be created in the editor but can, of course, also be created in script code as such:
Script:
// Example declaration of a Portal. This will create a box-shaped portal.
new Portal( PortalToTestZone )
{
position = "12.8467 -4.02246 14.8017";
rotation = "0 0 -1 97.5085";
scale = "1 0.25 1";
canSave = "1";
canSaveDynamicFields = "1";
};
Note:
Keep in mind that zones and portals are more or less strictly a scene optimization mechanism meant to improve render times.[/spoiler]
Description of the Zone under the spoiler:
[spoiler]An object that represents an interior space.
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 to the zone. This assignment happens automatically as objects are placed and transformed. Also, assignment is not exclusive meaning that an object can be assigned to many zones at the same time if it intersects all of them.
In itself, the volume of a zone is fully sealed off from the outside. This means that while viewing the scene from inside the volume, only objects assigned to the zone are rendered while when viewing the scene from outside the volume, objects exclusively only assigned the zone are not rendered.
Usually, you will want to connect zones to each other by means of portals. A portal overlapping with a zone
Script:
// Example declaration of a Zone. This creates a box-shaped zone.
new Zone( TestZone )
{
position = "3.61793 -1.01945 14.7442";
rotation = "1 0 0 0";
scale = "10 10 10";
};
Zone Groups
Normally, Zones will not connect to each other when they overlap. This means that if viewing the scene from one zone, the contents of the other zone will not be visible except when there is a portal connecting the zones. However, sometimes it is convenient to represent a single interior space through 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”.[/spoiler]