The HOpCameraWalk allows the user to walk "inside" of the current scene with optional collision detection. More...
#include <HOpCameraWalk.h>
Public Member Functions | |
virtual HBaseOperator * | Clone () |
void | FitControlsToCorner () |
float | GetAvatarHeight () |
bool | GetLightFollowsCamera () |
virtual const char * | GetName () |
float | GetSpeed () |
HOpCameraWalk (HBaseView *view, int DoRepeat=0, int DoCapture=1) | |
void | OnButtonWalk (char const *action, HButtonState buttonstate) |
int | OnKeyDown (HEventInfo &hevent) |
void | OnKeyWalk (float requested_time, float actual_time) |
virtual int | OnLButtonDown (HEventInfo &hevent) |
virtual int | OnLButtonDownAndMove (HEventInfo &hevent) |
virtual int | OnLButtonUp (HEventInfo &hevent) |
virtual int | OnMButtonDown (HEventInfo &hevent) |
virtual int | OnMButtonDownAndMove (HEventInfo &hevent) |
virtual int | OnMButtonUp (HEventInfo &hevent) |
virtual int | OnMouseWheel (HEventInfo &hevent) |
void | OnWalk (float requested_time, float actual_time) |
void | RemoveNavigationWindow () |
void | SetAvatarHeight (float ah) |
void | SetCollision (bool c) |
void | SetKeyboardWalk (bool kw) |
void | SetLightFollowsCamera (bool follow) |
void | SetSnapToFloor (bool s) |
void | SetSpeed (float s) |
void | SetStepHeightDown (float shd) |
void | SetStepHeightUp (float shu) |
void | ShowNavigationWindow (const char *image_dir=0) |
void | ViewDeleted () |
Static Public Member Functions | |
static float | CalculateExtents (HBaseView *view) |
static int | ImageAction (HImageRegion *ii, void *data, HButtonState keyup) |
static bool | WalkTimerClbk (float request_time, float actual_time, void *user_data) |
Protected Member Functions | |
void | AdjustCameraCollision (HCamera &oldcamera, bool noextrude=false) |
void | AdjustHeight (HCamera &oldcamera) |
void | ReadjustPosition () |
void | SetupControls (char forward, char backward, char strafe_left, char strafe_right, char up, char down) |
void | SnapToGround () |
Static Protected Member Functions | |
static bool | signal_callback (int signal, void *signal_data, void *user_data) |
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.
HOpCameraWalk::HOpCameraWalk | ( | HBaseView * | view, |
int | DoRepeat = 0 , |
||
int | DoCapture = 1 |
||
) |
Constructs an HOpCameraWalk object.
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 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.
Reimplemented from HBaseOperator.
float HOpCameraWalk::GetAvatarHeight | ( | ) | [inline] |
bool HOpCameraWalk::GetLightFollowsCamera | ( | ) | [inline] |
virtual const char* HOpCameraWalk::GetName | ( | ) | [virtual] |
Reimplemented from HBaseOperator.
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.
hevent | An HEventInfo object containing information about the current event |
Reimplemented from HBaseOperator.
void HOpCameraWalk::OnKeyWalk | ( | float | requested_time, |
float | actual_time | ||
) |
This is the keyboard centric walking function called from timer callback.
requested_time | the time that the event had requested. |
actual_time | The actual time that this method was called. |
virtual int HOpCameraWalk::OnLButtonDown | ( | HEventInfo & | hevent | ) | [virtual] |
The left button down handler defines the starting point for walk/rotation.
hevent | An HEventInfo object containing information about the current event |
Reimplemented from HBaseOperator.
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.
hevent | An HEventInfo object containing information about the current event |
Reimplemented from HBaseOperator.
virtual int HOpCameraWalk::OnLButtonUp | ( | HEventInfo & | hevent | ) | [virtual] |
Left button up handler ends the operation.
hevent | An HEventInfo object containing information about the current event |
Reimplemented from HBaseOperator.
virtual int HOpCameraWalk::OnMButtonDown | ( | HEventInfo & | hevent | ) | [virtual] |
The middle button down handler defines the starting point for straffing and up/down movement.
hevent | An HEventInfo object containing information about the current event |
Reimplemented from HBaseOperator.
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.
hevent | An HEventInfo object containing information about the current event |
Reimplemented from HBaseOperator.
virtual int HOpCameraWalk::OnMButtonUp | ( | HEventInfo & | hevent | ) | [virtual] |
The middle button up handler uses event information to end the operation.
hevent | An HEventInfo object containing information about the current event |
Reimplemented from HBaseOperator.
virtual int HOpCameraWalk::OnMouseWheel | ( | HEventInfo & | hevent | ) | [virtual] |
The mouse wheel handler uses event information to tilt the camera around the horizontal axis.
hevent | An HEventInfo object containing information about the current event |
Reimplemented from HBaseOperator.
void HOpCameraWalk::OnWalk | ( | float | requested_time, |
float | actual_time | ||
) |
This is a mouse centric walking function called from timer callback.
requested_time | the time that the event had requested. |
actual_time | the actual time |
void HOpCameraWalk::RemoveNavigationWindow | ( | ) |
Remove the navigation bar from the window.
void HOpCameraWalk::SetAvatarHeight | ( | float | ah | ) | [inline] |
Sets distance from floor to camera position if floor snapping is on.
ah | The height of the camera from the floor. |
void HOpCameraWalk::SetCollision | ( | bool | c | ) | [inline] |
Activates/Deactivates collision detection during walk.
c | Pass true to turn on collision detection. |
void HOpCameraWalk::SetKeyboardWalk | ( | bool | kw | ) | [inline] |
Activates/deactivates keyboard centric walking.
kw | Pass true to activate walking via keyboard controls. |
void HOpCameraWalk::SetLightFollowsCamera | ( | bool | follow | ) | [inline] |
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.
follow | Pass true to have the light follow the camera. |
void HOpCameraWalk::SetSnapToFloor | ( | bool | s | ) | [inline] |
Activates/Deactivates automatic adjustment of position to geometry "under" the camera.
s | Pass true to turn on snapping to the floor. |
void HOpCameraWalk::SetSpeed | ( | float | s | ) | [inline] |
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.
s | The speed of the movement forward, back or across the scene. |
void HOpCameraWalk::SetStepHeightDown | ( | float | shd | ) | [inline] |
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.
shd | The maximum height decrease of the camera when moving from one object to another. |
void HOpCameraWalk::SetStepHeightUp | ( | float | shu | ) | [inline] |
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.
shu | The maximum height increase of the camera when moving from one object to another. |
void HOpCameraWalk::ShowNavigationWindow | ( | const char * | 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::ViewDeleted | ( | ) | [inline] |
Use this method to indicate that the HBaseView object associated to this operator has been deleted.
static bool HOpCameraWalk::WalkTimerClbk | ( | float | request_time, |
float | actual_time, | ||
void * | user_data | ||
) | [static] |
This is the walking function called from timer.
request_time | the time that the event had requested. |
actual_time | The actual time that this method was called. |
user_data | Optional user data. |