HOpCameraWalk

class HOpCameraWalk

The HOpCameraWalk allows the user to walk “inside” of the current scene with optional collision detection.

There are two different control schemes for camera manipulation which are keyboard or mouse based.

Keyboard based WASD Control: This control scheme centers around the keyboard for movement and the mouse for changes in orientation. The “W” and “S” keys move the camera forward and backwards respectively while “A” and “D” allow for left and right strafing/dollying. “Q” and “Z” move the camera up and down. Alternatively the up and down arrow keys can be used for forward/backward, the left/right arrow keys for straffing and PageUp/PageDown for up/down movement. Holding down the left mouse button and dragging the mouse across the screen changes the camera orientation Additionally collision detection can be activated programatically. To override collision detection while walking hold down the “SHIFT” key.

Mouse based Control: By Pressing the left mouse button and dragging the mouse forward or backward the camera moves along the current view vector. Dragging the mouse left and right rotates the camera around its current up-vector. Holding down the middle mouse button allows for up and down movement as well as straffing. The mouse wheel tilts the view around the horizontal camera axis

The “Space” Key recenters the camera along the current ground plane.

Inherits from: HBaseOperator

Methods

HOpCameraWalk::HOpCameraWalk(HBaseView *view, int DoRepeat = 0, int DoCapture = 1)

Constructs an HOpCameraWalk object.

Parameters

view: A pointer to an HBaseView object.

DoRepeat: An integer denoting whether this is a repeatable operator. This parameter has been deprecated.

DoCapture: An integer denoting whether the mouse state should be captured, which means that all mouse events should be received after a mousedown, even if it leaves the window. This parameter has been deprecated.

virtual HOpCameraWalk::~HOpCameraWalk()

virtual

virtual char const *HOpCameraWalk::GetName()

virtual

Returns

A pointer to a character string denoting the name of the operator which is ‘HOpCameraWalk‘.
virtual int HOpCameraWalk::OnLButtonDown(HEventInfo &hevent)

virtual

The left button down handler defines the starting point for walk/rotation.

Parameters

hevent: An HEventInfo object containing information about the current event

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpCameraWalk::OnLButtonDownAndMove(HEventInfo &hevent)

virtual

The left button down and move handler let the user drag the mouse forward and back to move the camera back and forth with a speed based on the distance to the initial mouse position. Moving the mouse horizontally rotates the camera.

Parameters

hevent: An HEventInfo object containing information about the current event

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpCameraWalk::OnLButtonUp(HEventInfo &hevent)

virtual

Left button up handler ends the operation.

Parameters

hevent: An HEventInfo object containing information about the current event

Returns

An HOperatorReturn indicating the status of the event.
void HOpCameraWalk::SetLightFollowsCamera(bool follow)

SetLightFollowsCamera sets the lights to follow the camera or to stay in one place during orbit. This has the effect of either lighting the scene during orbit or allowing the camera to move through shadow. The default is off.

Parameters

follow: Pass true to have the light follow the camera.
bool HOpCameraWalk::GetLightFollowsCamera()

Returns

True if the light follows the camera or false if it doesn’t.
virtual int HOpCameraWalk::OnMouseWheel(HEventInfo &hevent)

virtual

The mouse wheel handler uses event information to tilt the camera around the horizontal axis.

Parameters

hevent: An HEventInfo object containing information about the current event

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpCameraWalk::OnMButtonDown(HEventInfo &hevent)

virtual

The middle button down handler defines the starting point for straffing and up/down movement.

Parameters

hevent: An HEventInfo object containing information about the current event

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpCameraWalk::OnMButtonDownAndMove(HEventInfo &hevent)

virtual

The middle button down and move handler let the user drag the mouse forward and backward to move the camera up/down based on the distance to the initial mouse position. Moving the mouse horizontally strafes the camera left/right.

Parameters

hevent: An HEventInfo object containing information about the current event

Returns

An HOperatorReturn indicating the status of the event.
virtual int HOpCameraWalk::OnMButtonUp(HEventInfo &hevent)

virtual

The middle button up handler uses event information to end the operation.

Parameters

hevent: An HEventInfo object containing information about the current event

Returns

An HOperatorReturn indicating the status of the event.
virtual HBaseOperator *HOpCameraWalk::Clone()

virtual

Creates a new operator which is a copy of the current operator. The user is responsible for deleting the newly created operator.

Returns

A pointer to the newly created HOpCameraWalk object.
void HOpCameraWalk::OnWalk(float requested_time, float actual_time)

This is a mouse centric walking function called from timer callback.

Parameters

requested_time: the time that the event had requested.

actual_time: the actual time

void HOpCameraWalk::OnKeyWalk(float requested_time, float actual_time)

This is the keyboard centric walking function called from timer callback.

Parameters

requested_time: the time that the event had requested.

actual_time: The actual time that this method was called.

void HOpCameraWalk::OnButtonWalk(char const *action, HButtonState buttonstate)
void HOpCameraWalk::ViewDeleted()

Use this method to indicate that the HBaseView object associated to this operator has been deleted.

void HOpCameraWalk::SetKeyboardWalk(bool kw)

Activates/deactivates keyboard centric walking.

Parameters

kw: Pass true to activate walking via keyboard controls.
void HOpCameraWalk::SetCollision(bool c)

Activates/Deactivates collision detection during walk.

Parameters

c: Pass true to turn on collision detection.
void HOpCameraWalk::SetSnapToFloor(bool s)

Activates/Deactivates automatic adjustment of position to geometry “under” the camera.

Parameters

s: Pass true to turn on snapping to the floor.
void HOpCameraWalk::SetAvatarHeight(float ah)

Sets distance from floor to camera position if floor snapping is on.

Parameters

ah: The height of the camera from the floor.
void HOpCameraWalk::SetStepHeightUp(float shu)

Sets maximum “up” step height. While “walking” with collision detection, this value determines what maximum vertical distance increased allowed when moving from one object at a given elevation to another one at a higher elevation.

Parameters

shu: The maximum height increase of the camera when moving from one object to another.
void HOpCameraWalk::SetStepHeightDown(float shd)

Sets maximum “down” step height. While “walking” with collision detection, this value determines the maximum vertical distance decrease when moving from one object at a given elevation to another one at a lower elevation.

Parameters

shd: The maximum height decrease of the camera when moving from one object to another.
float HOpCameraWalk::GetAvatarHeight()

Returns

The eye level height of camera in relation to the floor plane.
void HOpCameraWalk::SetSpeed(float s)

Sets Movement Speed. This value hich is initially set to to a quarter of the diagonal of the world bounding box represents the number of “units” the camera moves forward or strafes sideways per second.

Parameters

s: The speed of the movement forward, back or across the scene.
float HOpCameraWalk::GetSpeed()
int HOpCameraWalk::OnKeyDown(HEventInfo &hevent)

virtual

The derived operator should overload this function to intercept and handle the case where a keyboard key has been pressed down. It will be automatically called from the HOOPS/GUI toolkit when such an event occurs, and should be manually called by platform-specific UI code if HOOPS/GUI is not being used.

Parameters

hevent: An HEventInfo object containing information about the current event

Returns

An HOperatorReturn indicating the status of the event.
void HOpCameraWalk::ShowNavigationWindow(char const *image_dir = 0)

Displays a navigation bar in the Window which users can then use to control the camera movement within the scene.

void HOpCameraWalk::RemoveNavigationWindow()

Remove the navigation bar from the window.

void HOpCameraWalk::FitControlsToCorner()
static bool HOpCameraWalk::WalkTimerClbk(float request_time, float actual_time, void *user_data)

static

This is the walking function called from timer.

Parameters

request_time: the time that the event had requested.

actual_time: The actual time that this method was called.

user_data: Optional user data.

Returns

Success
static float HOpCameraWalk::CalculateExtents(HBaseView *view)

static

static int HOpCameraWalk::ImageAction(HImageRegion *ii, void *data, HButtonState keyup)

static

void HOpCameraWalk::SnapToGround()

protected

void HOpCameraWalk::AdjustCameraCollision(HCamera &oldcamera, bool noextrude = false)

protected

void HOpCameraWalk::AdjustHeight(HCamera &oldcamera)

protected

void HOpCameraWalk::ReadjustPosition()

protected

void HOpCameraWalk::SetupControls(char forward, char backward, char strafe_left, char strafe_right, char up, char down)

protected

static bool HOpCameraWalk::signal_callback(int signal, void *signal_data, void *user_data)

protected static

void HOpCameraWalk::ResetPosition()

private

void HOpCameraWalk::Level()

private

void HOpCameraWalk::Walk(bool b_forward, bool b_backward, bool b_left, bool r_right, bool b_up, bool b_down, double time_diff, HCamera &oldcamera)

private

void HOpCameraWalk::PostWalk(HC_KEY scene_key, bool b_forward, bool b_backward)

private

void HOpCameraWalk::UpdateTilt(HPoint const &p, HPoint const &t, float deg)

private

double HOpCameraWalk::UpdateTime(bool first, HCamera &lastCamera)

private

Variables

HCamera HOpCameraWalk::m_oldcamera

private

bool HOpCameraWalk::m_bOperatorCreated

private

bool
bool HOpCameraWalk::m_LightFollowsCamera

private

bool
HPoint HOpCameraWalk::m_camera

private

HPoint HOpCameraWalk::m_target

private

HPoint HOpCameraWalk::m_up

private

float HOpCameraWalk::m_time

private

float
unsigned HOpCameraWalk::m_timer

private

unsigned
float HOpCameraWalk::m_max_world_extent

private

float
float HOpCameraWalk::m_alpha

private

float
float HOpCameraWalk::m_beta

private

float
float HOpCameraWalk::m_rotate

private

float
float HOpCameraWalk::m_move

private

float
float HOpCameraWalk::m_tilt

private

float
float HOpCameraWalk::m_updown

private

float
float HOpCameraWalk::m_strafe

private

float
bool HOpCameraWalk::m_walkmode

private

bool
int HOpCameraWalk::m_AxisMode

private

int
bool HOpCameraWalk::m_bChange

private

bool
bool HOpCameraWalk::doOnce

private

bool
bool HOpCameraWalk::m_bViewDeleted

private

bool
HTClient *HOpCameraWalk::m_pWalkTimer

private

int HOpCameraWalk::m_cookie

private

int

The key that needs to be passed to HBaseView::UnSetEventNotify()

bool HOpCameraWalk::m_bBlocked

private

bool
bool HOpCameraWalk::m_bBlockedForward

private

bool
bool HOpCameraWalk::m_bBlockedBackward

private

bool
bool HOpCameraWalk::m_bSnappedToGround

private

bool
bool HOpCameraWalk::m_bOldSnappedToGround

private

bool
bool HOpCameraWalk::m_bKeyboardWalk

private

bool
bool HOpCameraWalk::m_bCollision

private

bool
bool HOpCameraWalk::m_bSnapToFloor

private

bool
float HOpCameraWalk::m_MaxUpGap

private

float
float HOpCameraWalk::m_MaxDownGap

private

float
float HOpCameraWalk::m_AvatarDiameter

private

float
float HOpCameraWalk::m_AvatarHeight

private

float
float HOpCameraWalk::m_Speed

private

float
float HOpCameraWalk::m_totalrotate

private

float
float HOpCameraWalk::m_totalrotateold

private

float
char HOpCameraWalk::m_c_forward

private

char
char HOpCameraWalk::m_c_backward

private

char
char HOpCameraWalk::m_c_strafe_left

private

char
char HOpCameraWalk::m_c_strafe_right

private

char
char HOpCameraWalk::m_c_up

private

char
char HOpCameraWalk::m_c_down

private

char
bool HOpCameraWalk::m_bNoKeyMove

private

bool
bool HOpCameraWalk::m_bNavigationWindowActive

private

bool