Skip to content

Sectors

SolarLune edited this page Jun 5, 2024 · 4 revisions

Sector Checkbox

Sectors are an easy way to graphically partition primarily indoor / enclosed game spaces into individual sections that Tetra3D will automatically handle. As you move the camera through the game scene, Tetra3D will only render relevant sectors to help maintain a smooth framerate. This gives you more control over how heavily your game runs.

To enable sectors, simply check off the "Is a Sector" checkbox in Blender on the Object panel (seen above), and enable sector-based rendering either from a Camera's Tetra3d Camera Properties panel in Blender:

Sector Rendering Checkbox

... or during run-time with Camera.SectorRendering.

Doing this creates a Sector on a Model when it is loaded into a Scene in Tetra3d. Each Sector is comprised of an AABB that should completely surround a Model. This being the case, Sectors currently need to have width, height, and depth in order for it to work (so you can't have, say a flat plain model be an effective sector - it would need triangles to extend the sector AABB upwards as well). Sectors can be connected in one of two different ways - either by sectors sharing vertex positions, or if their AABBs touch each other. This can be altered using the Sector detection type: option in Tetra3D's Render settings panel.

If multiple Sectors overlap and a Camera lies within all of these Sectors, then the Camera will consider the physically smallest Sector to be the Sector that it's in (think "being inside a room (a sector) in a house (a bigger sector)").

Sectors are usually static, though if you need to move one in-game, its list of neighboring Sectors can be updated on command. You can do this by accessing the Sector through the Model (Model.Sector), and then calling Sector.Neighbors.Clear() followed by Sector.UpdateNeighbors(others) with a slice of the other sector models in the scene.

If you parent a Model or a light to a Sector, it will only render / be used for rendering if the Sector is also rendering.

Sector Rendering Depth

Tetra3D will render the current Sector, and any neighbors up to the depth limit - this is customizeable in the camera's Tetra3d properties panel or using Camera.SectorRenderDepth. Each neighbor counts as one "hop", and neighbors that are further away than the depth limit won't render. To illustrate this, if you had a map laid out like this:

A - B - C       H
    |   |       |
    D - E - F - G

... And you were rendering the scene from Sector F with a depth of 2, you would render sectors F, G, H, E, C, and D (so up to 2 away from sector F). Of course, frustum culling still takes effect; this is just the sector models that are considered visible.

Clone this wiki locally