Isle
Loading...
Searching...
No Matches
ViewManager Class Reference

[AI] Manages all ViewROI objects that are rendered in a given scene, handles frustum culling, LOD management, and visibility determination for 3D ROI objects. More...

#include <viewmanager.h>

Public Types

enum  Flags { c_bit1 = 0x01 , c_bit2 = 0x02 , c_bit3 = 0x04 , c_bit4 = 0x08 }
 [AI] Bit flags used internally by ViewManager to track various states or trigger needed calculations (such as view or frustum updates). More...
 

Public Member Functions

 ViewManager (Tgl::Renderer *pRenderer, Tgl::Group *scene, const OrientableROI *point_of_view)
 [AI] Constructs the ViewManager with the renderer, scene group, and initial point-of-view. More...
 
virtual ~ViewManager ()
 [AI] Destroys the ViewManager including detaching the current POV source and releasing Direct3DRM objects. More...
 
void Remove (ViewROI *p_roi)
 [AI] Removes a single ViewROI from the managed ROI list, also detaching any associated LOD data from the scene and handling recursively any compound child ROIs. More...
 
void RemoveAll (ViewROI *p_roi)
 [AI] Recursively removes all ViewROI objects. More...
 
unsigned int IsBoundingBoxInFrustum (const BoundingBox &p_bounding_box)
 [AI] Determines if a bounding box is (partially) inside the camera's view frustum using frustum-plane testing. More...
 
void UpdateROIDetailBasedOnLOD (ViewROI *p_roi, int p_und)
 [AI] Based on computed LOD, updates the scene to show the correct mesh for a given ROI, removing or replacing representations as required. More...
 
void RemoveROIDetailFromScene (ViewROI *p_roi)
 [AI] Removes the currently active LOD detail from the rendering scene for the given ROI and detaches it from the top-level scene group. More...
 
void SetPOVSource (const OrientableROI *point_of_view)
 [AI] Sets the OrientableROI to use as the camera's point-of-view; updates the transformation matrix accordingly. More...
 
float ProjectedSize (const BoundingSphere &p_bounding_sphere)
 [AI] Computes the projected area of a bounding sphere onto the camera's viewing plane (used for LOD calculation). More...
 
ViewROIPick (Tgl::View *p_view, unsigned long x, unsigned long y)
 [AI] Using a screen coordinate and viewport, finds the ViewROI (if any) under the given coordinates by querying Direct3DRM's pick pipeline. More...
 
void SetResolution (int width, int height)
 [AI] Sets the viewport resolution and marks the frustum as needing recalculation. More...
 
void SetFrustrum (float fov, float front, float back)
 [AI] Sets the projection frustum parameters and marks the frustum as needing recalculation. More...
 
void ManageVisibilityAndDetailRecursively (ViewROI *p_roi, int p_und)
 [AI] Recursively traverses and updates the visibility and LOD detail of a ROI and its children, based on projected size and thresholds. More...
 
void Update (float p_previousRenderTime, float)
 [AI] Performs the per-frame update: applies frustum/view updates if needed and recurses the ROI graph for visibility/LOD/detail management. More...
 
int CalculateFrustumTransformations ()
 [AI] Computes frustum planes and transformed corner positions for the current camera/view, updating internal matrices. More...
 
void UpdateViewTransformations ()
 [AI] Updates the transformation matrices using the current POV and frustum edges, recalculating plane normals and D terms for culling. More...
 
const CompoundObjectGetROIs ()
 [AI] Returns the internal CompoundObject list of all managed ViewROI objects for iteration or queries. More...
 
void Add (ViewROI *p_roi)
 [AI] Adds a ViewROI object to the list of managed ROI objects. More...
 

Static Public Member Functions

static int CalculateLODLevel (float p_und1, float p_und2, ViewROI *p_roi)
 [AI] Determines the LOD level index for a ROI based on projected size and user-defined/scene parameters. More...
 
static int IsROIVisibleAtLOD (ViewROI *p_roi)
 [AI] Checks whether the given ROI should be considered visible at any LOD, including compound sub-ROIs. More...
 

Detailed Description

[AI] Manages all ViewROI objects that are rendered in a given scene, handles frustum culling, LOD management, and visibility determination for 3D ROI objects.

Coordinates detail level based on view parameters and maintains view transformation matrices for efficient rendering.

[AI] ViewManager is responsible for controlling the rendering of all 3D real-time object instances (ROIs) in the current scene. It maintains a collection of ViewROI objects, calculates visibility based on the camera's frustum, manages geometric detail levels according to projected object size and LOD thresholds, and applies transformations for the scene's camera (point-of-view) parameters. It provides utility for picking ROI objects using screen coordinates and is tightly bound to the Direct3DRM retained mode pipeline.

Definition at line 16 of file viewmanager.h.

Member Enumeration Documentation

◆ Flags

[AI] Bit flags used internally by ViewManager to track various states or trigger needed calculations (such as view or frustum updates).

Enumerator
c_bit1 

[AI] Used to signals a pending operation (exact purpose is contextually flagged during update routines).

c_bit2 

[AI] Indicates the need to update view transformation matrices.

c_bit3 

[AI] Indicates the need to recalculate frustum parameters (e.g., due to a resolution or frustum change).

c_bit4 

[AI] Signals that the frustum parameters/planes are valid and up to date.

Definition at line 21 of file viewmanager.h.

Constructor & Destructor Documentation

◆ ViewManager()

ViewManager::ViewManager ( Tgl::Renderer pRenderer,
Tgl::Group scene,
const OrientableROI point_of_view 
)

[AI] Constructs the ViewManager with the renderer, scene group, and initial point-of-view.

Initializes transformation matrices and internal state.

Parameters
pRenderer[AI] Pointer to the renderer (Direct3DRM abstraction) to use for view operations.
scene[AI] The top-level scene group for geometry association and manipulation.
point_of_view[AI] The initial camera reference used for setting up the view transformation.

Definition at line 38 of file viewmanager.cpp.

◆ ~ViewManager()

ViewManager::~ViewManager ( )
virtual

[AI] Destroys the ViewManager including detaching the current POV source and releasing Direct3DRM objects.

Definition at line 57 of file viewmanager.cpp.

Member Function Documentation

◆ Add()

void ViewManager::Add ( ViewROI p_roi)
inline

[AI] Adds a ViewROI object to the list of managed ROI objects.

Parameters
p_roi[AI] The ROI to add.

Definition at line 161 of file viewmanager.h.

◆ CalculateFrustumTransformations()

int ViewManager::CalculateFrustumTransformations ( )
inline

[AI] Computes frustum planes and transformed corner positions for the current camera/view, updating internal matrices.

Returns
[AI] 0 if successful, -1 if height/front parameters are invalid.

Definition at line 300 of file viewmanager.cpp.

◆ CalculateLODLevel()

int ViewManager::CalculateLODLevel ( float  p_und1,
float  p_und2,
ViewROI p_roi 
)
inlinestatic

[AI] Determines the LOD level index for a ROI based on projected size and user-defined/scene parameters.

Parameters
p_und1[AI] Projected size value.
p_und2[AI] LOD threshold.
p_roi[AI] Target ROI.
Returns
[AI] The determined LOD index.

Definition at line 353 of file viewmanager.cpp.

◆ GetROIs()

const CompoundObject & ViewManager::GetROIs ( )
inline

[AI] Returns the internal CompoundObject list of all managed ViewROI objects for iteration or queries.

Returns
[AI] Reference to the internal ROI container.

Definition at line 155 of file viewmanager.h.

◆ IsBoundingBoxInFrustum()

unsigned int ViewManager::IsBoundingBoxInFrustum ( const BoundingBox p_bounding_box)

[AI] Determines if a bounding box is (partially) inside the camera's view frustum using frustum-plane testing.

Parameters
p_bounding_box[AI] Axis-aligned bounding box to test.
Returns
[AI] TRUE if any part of the bounding box is within the current frustum, otherwise FALSE.

Definition at line 64 of file viewmanager.cpp.

◆ IsROIVisibleAtLOD()

int ViewManager::IsROIVisibleAtLOD ( ViewROI p_roi)
inlinestatic

[AI] Checks whether the given ROI should be considered visible at any LOD, including compound sub-ROIs.

Parameters
p_roi[AI] The object to check.
Returns
[AI] 1 if visible, 0 otherwise.

Definition at line 376 of file viewmanager.cpp.

◆ ManageVisibilityAndDetailRecursively()

void ViewManager::ManageVisibilityAndDetailRecursively ( ViewROI p_roi,
int  p_und 
)
inline

[AI] Recursively traverses and updates the visibility and LOD detail of a ROI and its children, based on projected size and thresholds.

Parameters
p_roi[AI] The starting ROI for recursive update.
p_und[AI] LOD index, or -1 to auto-calculate, or -2 to hide.

Definition at line 223 of file viewmanager.cpp.

◆ Pick()

ViewROI * ViewManager::Pick ( Tgl::View p_view,
unsigned long  x,
unsigned long  y 
)

[AI] Using a screen coordinate and viewport, finds the ViewROI (if any) under the given coordinates by querying Direct3DRM's pick pipeline.

Parameters
p_view[AI] Pointer to the Tgl view (Direct3DRM viewport abstraction).
x[AI] Screen-space X coordinate.
y[AI] Screen-space Y coordinate.
Returns
[AI] The ROI at the specified location, or NULL if none found.

Definition at line 489 of file viewmanager.cpp.

◆ ProjectedSize()

float ViewManager::ProjectedSize ( const BoundingSphere p_bounding_sphere)

[AI] Computes the projected area of a bounding sphere onto the camera's viewing plane (used for LOD calculation).

Parameters
p_bounding_sphere[AI] The bounding sphere to project.
Returns
[AI] The ratio of the sphere's projected area to the view area at unit distance.

Definition at line 475 of file viewmanager.cpp.

◆ Remove()

void ViewManager::Remove ( ViewROI p_roi)

[AI] Removes a single ViewROI from the managed ROI list, also detaching any associated LOD data from the scene and handling recursively any compound child ROIs.

Parameters
p_roi[AI] The ViewROI instance to remove.

Definition at line 95 of file viewmanager.cpp.

◆ RemoveAll()

void ViewManager::RemoveAll ( ViewROI p_roi)

[AI] Recursively removes all ViewROI objects.

If called with NULL, purges all managed ROI objects in the scene.

Parameters
p_roi[AI] If NULL, removes all; otherwise recursively removes the given ROI and children.

Definition at line 121 of file viewmanager.cpp.

◆ RemoveROIDetailFromScene()

void ViewManager::RemoveROIDetailFromScene ( ViewROI p_roi)

[AI] Removes the currently active LOD detail from the rendering scene for the given ROI and detaches it from the top-level scene group.

Parameters
p_roi[AI] The target ROI.

Definition at line 202 of file viewmanager.cpp.

◆ SetFrustrum()

void ViewManager::SetFrustrum ( float  fov,
float  front,
float  back 
)

[AI] Sets the projection frustum parameters and marks the frustum as needing recalculation.

Parameters
fov[AI] Field of view in degrees.
front[AI] Near plane Z position.
back[AI] Far plane Z position.

Definition at line 456 of file viewmanager.cpp.

◆ SetPOVSource()

void ViewManager::SetPOVSource ( const OrientableROI point_of_view)

[AI] Sets the OrientableROI to use as the camera's point-of-view; updates the transformation matrix accordingly.

Parameters
point_of_view[AI] The OrientableROI representing the camera.

Definition at line 465 of file viewmanager.cpp.

◆ SetResolution()

void ViewManager::SetResolution ( int  width,
int  height 
)

[AI] Sets the viewport resolution and marks the frustum as needing recalculation.

Parameters
width[AI] The width of the view area in pixels.
height[AI] The height of the view area in pixels.

Definition at line 448 of file viewmanager.cpp.

◆ Update()

void ViewManager::Update ( float  p_previousRenderTime,
float   
)

[AI] Performs the per-frame update: applies frustum/view updates if needed and recurses the ROI graph for visibility/LOD/detail management.

Parameters
p_previousRenderTime[AI] Time mark of the previous render.
[unused][AI] Unused parameter.

Definition at line 277 of file viewmanager.cpp.

◆ UpdateROIDetailBasedOnLOD()

void ViewManager::UpdateROIDetailBasedOnLOD ( ViewROI p_roi,
int  p_und 
)

[AI] Based on computed LOD, updates the scene to show the correct mesh for a given ROI, removing or replacing representations as required.

Parameters
p_roi[AI] The ROI for which to update level-of-detail.
p_und[AI] Target LOD index.

Definition at line 149 of file viewmanager.cpp.

◆ UpdateViewTransformations()

void ViewManager::UpdateViewTransformations ( )

[AI] Updates the transformation matrices using the current POV and frustum edges, recalculating plane normals and D terms for culling.

Definition at line 408 of file viewmanager.cpp.


The documentation for this class was generated from the following files: