HConstantFrameRate

class HConstantFrameRate

The HConstantFrameRate class provides support for maintaining a constant framerate when rendering.

HConstantFrameRate stores and manages ‘simplification-level’ objects which are used as fallbacks during rendering, in order to maintain a constant framerate. It also includes logic to determine the current framerate and if fallback is necessary and how much.

Methods

HConstantFrameRate::HConstantFrameRate(HBaseView *view)

Constructs a new HConstantFrameRatge Object.

Parameters

view: Pointer to HBaseView object
virtual HConstantFrameRate::~HConstantFrameRate()

virtual

HBaseView *HConstantFrameRate::GetView()

Returns

A pointer to the HBaseView object.
void HConstantFrameRate::UpdateLevel(int SimpLevel, int SimpListPos)

This method calls update on the simplication type associated with SimpListPos with the given SimpLevel.

Parameters

SimpLevel: Simplification Level

SimpListPos: Position in current Simplification Level

bool HConstantFrameRate::GetMode(HConstFRSimpType ***sd = 0L, float *target_framerate = 0L, int *length = 0L)

deprecated

This method lets you retrieve the simplification type list, its length and the target frame rate.  Please
do NOT use the pointers to the objects returned to change the their values.  If you want to modify
the target frame rate, use the SetTargetFrameRate() method.  If you want to update the simplification type list,
please use the Init() method.

\param sd If sd is not 0, the method returns a pointer to the simplification type list.
This is a read- only array. If you want to update the list, use the Init() method.
\param target_framerate If target_framerate is not 0, the method returns the desired update rate for the scene, in frames

per second.

Warning

use GetList() GetTargetFramerate() or GetLength() instead

Parameters

length: If length is not 0, the method returns the length of the simplification array.

Returns

True if there is a simplification type list and false if none has been set up.
HConstFRSimpType const *const *HConstantFrameRate::GetList() const

const

This method lets you retrieve the simplification type list. This is a read- only array. If you want to update the list, use the Init() method.

Returns

a pointer to the simplification type list.
float HConstantFrameRate::GetTargetFramerate() const

const

The method returns the desired update rate for the scene, in frames per second.

Returns

the desired update rate for the scene
int HConstantFrameRate::GetLength() const

const

The method returns the length of the simplification array.

Returns

the length of the simplification array.
void HConstantFrameRate::Init(float target_framerate = 20.0, HConstFRSimpType *sd[] = 0, int length = 0, float deadzone = 3.0)

Initializes constant frame rate mode, sets the target framerate, and supplies a list of geometry simplification levels. The levels are used by the internal framereate logic to degrade the visual quality of the geometry in the scene in order to maintain the target framerate. If no list of simplification levels is provided, a default list is used.

Parameters

target_framerate: The desired update rate for the scene, in frames per second.

sd: A pointer to an array of simplification types. Passed by reference.

length: The length of the simplification list.

deadzone: Allowed variance from target framerate

void HConstantFrameRate::Shutdown()

This method clears the simplification types list.

bool HConstantFrameRate::GetActive() const

const

Returns

True if constant framerate watch is activated and false if otherwise.
void HConstantFrameRate::Watch()

This method checks the update time for every frame and calls AdjustDetail() with a frames per second value. This method updates the scene if the view position has changed since the last update OR different activity that is relevant for the framerate has occured.

void HConstantFrameRate::Start()

If the simplification type list is set along with the deadzone and target framerate, this method activates the constant framerate functionality. It starts the timer. The watch function will also begin making adjustments to the scene according to the state variables that have been set. This function is normally called when an operator is started (e.g. mouse down event on rotate).

void HConstantFrameRate::Stop()

Deactivates the constant frame rate functionality. This function is normally called if an operator is stopped (e.g. mouse up event on rotate).

void HConstantFrameRate::IncreaseDetailTemp()

Temporarily bumps up the detail level if e.g. no mouse movement has occured Also adjust the base detail level based on the draw time of the frames This function is usually called from a timer event in the main application.

bool HConstantFrameRate::ViewpointHasChanged(bool update = true)

Determines if the viewpoint has changed for the associated scene.

Parameters

update: Pass true if you want the new viewpoint to be recorded if it has changed. Default is true.

Returns

True if the viewpoint has changed and false if otherwise.
void HConstantFrameRate::SetDetailIncMode(DetailChangeMode mode)

This method sets the state of detail increase mode which tells the framerate logic whether to try a lower simplification level when the actual framerate exceeds the target frame rate.

Parameters

mode: New Detail change mode
void HConstantFrameRate::SetDetailIncOnIdleMode(DetailChangeMode mode)
DetailChangeMode HConstantFrameRate::GetDetailIncMode()

Returns

The current state of detail increase mode which determines if the framerate logic should be allowed to try a lower simplification level if the actual framerate exceeds the target framerate.
void HConstantFrameRate::SetDetailDecMode(DetailChangeMode mode)

Sets the state of the detail decrease mode which determines if the framerate logic should be allowed to try increase the simplification level if the actual framerate is less than the target framerate.

Parameters

mode: New Detail decrease mode
DetailChangeMode HConstantFrameRate::GetDetailDecMode()

Returns

The state of detail decrease mode which determines if the framerate logic should be allowed to try increase the simplification level if the actual framerate is less than the target framerate.
void HConstantFrameRate::ResetListPointers()

Resets the simplification list and level pionters.

float HConstantFrameRate::GetTargetFrameRate()

Returns

Target framerate which we want the scene to maintain.
void HConstantFrameRate::SetTargetFrameRate(float framerate)

Sets the new target framerate which we want the scene to maintain during rendering.

Parameters

framerate: New target framerate
void HConstantFrameRate::SetDeadZone(float deadzone)

Sets the new dead zone around the target framerate. Framerate changes in that area will not result in detail level changes

Parameters

deadzone: new dead zone
void HConstantFrameRate::SetEmergencyDetailDecrease(bool detaildecrease)

Sets the emergency decrease feature which allows sharp drops in detail level if the framerate is very low.

Parameters

detaildecrease: Turn detaildecrease on/off
void HConstantFrameRate::SetActivityType(HActivityType at)

This method sets the status of the activity flag. The information is used by this class to determine how to maintain the framerate. This method supersedes SetNoActivity().

Parameters

at: Pass the current activity type which can be NoActivity, MovementActivity, CuttingPlaneActivity or GeneralActivity.
HActivityType HConstantFrameRate::GetActivityType()

Returns

The state of the activity flag which can be NoActivity, MovementActivity, CuttingPlaneActivity or GeneralActivity. This flag affects the constant framerate logic.
int HConstantFrameRate::GetSimpLevel()

Returns

Current simplification level.
void HConstantFrameRate::AdjustLodOptions()

This method adjusts the LOD rendering settings. If there is a ConstFRLodClampType in the simplification list, this method sets the LOD clamp value to the simple level maximum. If there is a ConstFRLodThresholdType in the simplification list, then this method performs a calculation based on the simple level maximum to set the LOD threshold.

Returns

State of detail increase flag.
bool HConstantFrameRate::GetDetailIncreaseState()
void HConstantFrameRate::SetDetailLevel(int listpos, int simplevel)

Sets the default detail level before the framerate logic is started.

Parameters

listpos: simplification type

simplevel: simplification level for given type

HConstFRSimpType *HConstantFrameRate::GetSimpType(ConstFRType stype)

This method returns a pointer to the object in the simplification list that correctsponds to given ConstFRType.

Parameters

stype: The ConstFRType type you are looking for in the simplification list.

Returns

The HConstFRSimpType object in the simplification list whose type is the given stype.
void HConstantFrameRate::SetSimpLevel(int simplevel)

Sets the current simplification level.

Parameters

simplevel: simplification level for the scene
void HConstantFrameRate::AdjustDefaultDetailLevelToModel()

This method adjusts the default detail level by calculating the complexity of the model of the associated view.

void HConstantFrameRate::SetDisableIncreaseTemp(bool it)
void HConstantFrameRate::InitiateDelay()
int HConstantFrameRate::GetDetailLevelNum()
int HConstantFrameRate::GetTotalDetailLevelNum()
void HConstantFrameRate::SetWatchActivity(bool wa)
void HConstantFrameRate::MajorDetailDecrease()
void HConstantFrameRate::MajorDetailIncrease()
void HConstantFrameRate::SetHoopsSimplificationOptions(int SimpLevel, int SimpListPos)

protected

Sets HOOPS rendering and driver options for the given simplification type and level.

Parameters

SimpLevel: Simplification level inside the current simplification type

SimpListPos: Current position in the Simplification list - determines current simplification type.

void HConstantFrameRate::AdjustListPointers(int &SimpLevel, int &SimpListPos)

protected

This method adjusts simplification level and simplification list pointers to valid values inside the simplification ranges.

Parameters

SimpLevel: Pass by reference. This method returns with the simplification level adjusted to be within simplification range.

SimpListPos: Pass by reference. This method returns with the simplification list position adjusted to be within simplification range.

void HConstantFrameRate::AdjustDetail(float FrameRate)

protected

This method increases or lowers the simplification level as necessary in order to achieve the target framerate.

Parameters

FrameRate: The rendering time for the last frame in frames per second.
void HConstantFrameRate::StartTimer()

protected

This method creates a new detail increase timer and starts it so that the Tick() method will be called periodically.

void HConstantFrameRate::StopTimer()

protected

This method stops the detail increase timer. The Tick() method will no longer be called by the timer.

bool HConstantFrameRate::IsLowestDetail()

protected

void HConstantFrameRate::ChangeDetail(int change, int *SimpLevel = 0, int *SimpListPos = 0)

protected

static bool HConstantFrameRate::Tick(float request_time, float actual_time, void *user_data)

static

Tick function called from timer manager.

Parameters

request_time: Timer Parameter

actual_time: Timer Parameter

user_data: User Data

Returns

True if the event was processed.

Variables

HBaseView *HConstantFrameRate::m_pHView

protected

A pointer to the the associated view object.

bool HConstantFrameRate::m_bConstFRActive

protected

bool

This value indicates whether the constant frame rate mode is currently active.

float HConstantFrameRate::m_TargetFrameRate

protected

float

Target frame rate in frames per second. The system will try to achieve this frame rate if the constant frame rate mode has been activated.

HConstFRSimpType **HConstantFrameRate::m_pSimpList

protected

List of object simplification types used by the constant frame rate logic to simplify the scene and increase rendering speed. The list should be in order of increasing simplification.

bool HConstantFrameRate::m_pOwnsList

protected

bool
int HConstantFrameRate::m_SimpLevel

protected

int

Current object simplification level used by the constant frame rate logic.

int HConstantFrameRate::m_SimpListPos

protected

int

Current object simplification type used by the constant frame rate logic.

int HConstantFrameRate::m_SimpListLength

protected

int

Length of the object simplification list used by the constant frame rate logic.

DetailChangeMode HConstantFrameRate::m_SimplificationDecrease

protected

State variable that reflects if a detail decrease is still allowed.

DetailChangeMode HConstantFrameRate::m_SimplificationIncrease

protected

State variable that reflects if a detail increase is still allowed.

DetailChangeMode HConstantFrameRate::m_SimplificationIncreaseOnIdle

protected

State variable that reflects if a detail increase is still allowed.

int HConstantFrameRate::m_FrameRateCounter

protected

int

Counter for number of frames passed before framerate is calculated.

DetailChangeMode HConstantFrameRate::m_DetailIncMode

protected

Determines if a detail increase is allowed after the constant framerate logic has been activated.

DetailChangeMode HConstantFrameRate::m_DetailIncOnIdleMode

protected

DetailChangeMode HConstantFrameRate::m_DetailDecMode

protected

Determines if a detail decrease is allowed after the constant framerate logic has been activated.

float HConstantFrameRate::m_DeadZone

protected

float

Tolerance around target framerate.

int HConstantFrameRate::m_lastupdown

protected

int
bool HConstantFrameRate::m_bEmergencyDecrease

protected

bool

Flag that indicates if detail level should be significantly reduced if framerate has fallen below a critical threshold.

HActivityType HConstantFrameRate::m_ActivityType

protected

Flag that indicates whether an event like a user interaction has occurred that would effect the framerate. If it false, then no event occurred.

bool HConstantFrameRate::m_bFullDetailTemp

private

bool
bool HConstantFrameRate::m_bWatchActivity

private

bool
bool HConstantFrameRate::m_bIncreaseDetailTemp

private

bool
float HConstantFrameRate::m_oldPos[11]

private

float
HTClient *HConstantFrameRate::m_pUpdateTimerClient

private

bool HConstantFrameRate::m_bDisableIncreaseTemp

private

bool
bool HConstantFrameRate::m_bOneDelay

private

bool
float HConstantFrameRate::m_OneDelayStart

private

float
bool HConstantFrameRate::m_bAdjustNextTime

private

bool
float HConstantFrameRate::m_AdjustTime

private

float
bool HConstantFrameRate::m_bIncrease

private

bool
int HConstantFrameRate::m_CounterThreshold

private

int
int HConstantFrameRate::m_TempDetailIncrement

private

int
bool HConstantFrameRate::m_bFirstIncrease

private

bool