Support Forum G3D Web Page |
Uses a First Person (Quake- or World of Warcraft style) mapping to translate keyboard and mouse input into a flying camera position.
More...
Inherits G3D::Manipulator.
Public Types | |
enum | MouseMode { MOUSE_DIRECT, MOUSE_DIRECT_RIGHT_BUTTON, MOUSE_SCROLL_AT_EDGE, MOUSE_PUSH_AT_EDGE } |
Public Member Functions | |
FirstPersonManipulator (UserInput *ui) | |
virtual | ~FirstPersonManipulator () |
Deactivates the controller. More... | |
float | altSpeedMultipler () const |
virtual Rect2D | bounds () const override |
Inherited from Surface2D. More... | |
virtual float | depth () const override |
Inherited from Surface2D. More... | |
bool | enabled () const override |
virtual void | fireEvent (const GEvent &event) |
Fire an event on the containing window. More... | |
GKey | flyDownKey () const |
Key for translating -Y. More... | |
GKey | flyUpKey () const |
Key for translating +Y. More... | |
virtual CoordinateFrame | frame () const override |
virtual void | getFrame (CoordinateFrame &c) const override |
void | lookAt (const Vector3 &position) |
Vector3 | lookVector () const |
WidgetManager * | manager () const |
MouseMode | mouseMode () const |
virtual void | onAfterEvents () |
Invoked after all onEvent handlers for the current frame and before onUserInput for any other Widget. More... | |
virtual void | onAI () override |
virtual void | onBeforeGraphics () |
Invoked by WidgetManager immediately before GApp::onGraphics runs. More... | |
virtual bool | onEvent (const GEvent &event) override |
Returning true consumes the event and prevents other GModules from seeing it. More... | |
virtual void | onNetwork () override |
virtual void | onPose (Array< shared_ptr< Surface > > &surfaceArray, Array< shared_ptr< Surface2D > > &surface2DArray) |
Appends a posed model for this object to the array, if it has a graphic representation. More... | |
virtual void | onPose (Array< shared_ptr< Surface >> &p3d, Array< shared_ptr< Surface2D >> &p2d) override |
virtual void | onSimulation (RealTime rdt, SimTime sdt, SimTime idt) override |
virtual void | onUserInput (UserInput *ui) override |
float | pitch () const |
virtual float | positionalEventZ (const Point2 &pixel) const |
The camera-space z position that this Widget considers this pixel to be at. More... | |
virtual void | render (RenderDevice *rd) const override |
Inherited from Surface2D. More... | |
void | reset () |
Invoke immediately before entering the main game loop. More... | |
void | setAltSpeedMultipler (float m) |
When the alt key is held down, multiply m_maxMoveRate by this. More... | |
virtual void | setDepth (float d) |
Called by the WidgetManager. More... | |
void | setEnabled (bool a) override |
When enabled, the FirstPersonManipulator responds to events and updates its frame. More... | |
void | setFlyDownKey (GKey k) |
Default is 'c'. More... | |
void | setFlyUpKey (GKey k) |
Default is 'z'. More... | |
virtual void | setFrame (const CoordinateFrame &c) override |
Sets to the closest legal controller orientation to the coordinate frame. More... | |
virtual void | setFrame (const CFrame &c) |
By default, does nothing. More... | |
virtual void | setManager (WidgetManager *m) |
Called by the WidgetManager when this module is added to it. More... | |
void | setMouseMode (MouseMode m) |
void | setMoveRate (double metersPerSecond) |
Initial value is 10. More... | |
void | setPitch (float p) |
void | setPosition (const Vector3 &t) |
void | setShiftSpeedMultipler (float m) |
When the shift key is held down, multiply m_maxMoveRate by this. More... | |
void | setTurnRate (double radiansPerSecond) |
Initial value is PI / 2. More... | |
void | setYaw (float y) |
float | shiftSpeedMultipler () const |
const Vector3 & | translation () const |
virtual OSWindow * | window () const |
Returns the operating system window that is currently rendering this Widget. More... | |
float | yaw () const |
Static Public Member Functions | |
static shared_ptr< FirstPersonManipulator > | create (UserInput *ui=nullptr) |
If the UserInput is not provided here, it is automatically recorded after the first onUserInput method invocation. More... | |
static void | sort (Array< shared_ptr< Surface2D >> &array) |
Sorts from farthest to nearest. More... | |
static void | sortAndRender (RenderDevice *rd, Array< shared_ptr< Surface2D >> &array) |
Calls sort, RenderDevice::push2D, and then render on all elements. More... | |
Protected Member Functions | |
bool | rightDown (UserInput *) const |
Returns true if the right mouse button is down, or on OSX, the user is using the left mouse and ctrl. More... | |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
Protected Attributes | |
float | m_altSpeedMultiplier |
More... | |
float | m_depth |
bool | m_enabled |
GKey | m_flyDownKey |
GKey | m_flyUpKey |
WidgetManager * | m_manager |
The manager, set by setManager(). More... | |
float | m_maxMoveRate |
m/s More... | |
float | m_maxTurnRate |
rad/s More... | |
MouseMode | m_mouseMode |
float | m_pitch |
bool | m_rightDown |
Is the right mouse button currently held down? More... | |
float | m_shiftSpeedMultiplier |
More... | |
Vector3 | m_translation |
class UserInput * | m_userInput |
float | m_yaw |
GKey | m_yawLeftKey |
GKey | m_yawRightKey |
Uses a First Person (Quake- or World of Warcraft style) mapping to translate keyboard and mouse input into a flying camera position.
The result is an Euler-angle camera controller suitable for games and fly-throughs.
To use without G3D::GApp:
G3D::FirstPersonManipulator::FirstPersonManipulator | ( | UserInput * | ui | ) |
|
virtual |
Deactivates the controller.
|
inline |
|
inlineoverridevirtualinherited |
Inherited from Surface2D.
Implements G3D::Surface2D.
Reimplemented in G3D::GuiWindow, G3D::GConsole, and G3D::FullScreenWidget.
|
static |
If the UserInput is not provided here, it is automatically recorded after the first onUserInput method invocation.
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
|
inlineoverridevirtualinherited |
Inherited from Surface2D.
Controls the depth of objects when rendering. Subclasses may override this but it can interfere with the normal handling of rendering and event delivery. depth = 0 is usually the "top" widget and depth = 1 is usually the "bottom" widget.
Implements G3D::Surface2D.
Reimplemented in G3D::GuiWindow, G3D::GConsole, and G3D::FullScreenWidget.
|
overridevirtual |
Reimplemented from G3D::Manipulator.
|
virtualinherited |
Fire an event on the containing window.
Reimplemented in G3D::WidgetManager.
|
inline |
Key for translating -Y.
|
inline |
Key for translating +Y.
|
overridevirtual |
Implements G3D::Manipulator.
Referenced by lookVector().
|
overridevirtual |
Implements G3D::Manipulator.
void G3D::FirstPersonManipulator::lookAt | ( | const Vector3 & | position | ) |
|
inline |
|
inlineinherited |
MouseMode G3D::FirstPersonManipulator::mouseMode | ( | ) | const |
|
inlinevirtualinherited |
Invoked after all onEvent handlers for the current frame and before onUserInput for any other Widget.
Reimplemented in G3D::WidgetManager, and G3D::GameController.
|
overridevirtual |
Reimplemented from G3D::Widget.
|
inlinevirtualinherited |
Invoked by WidgetManager immediately before GApp::onGraphics runs.
Reimplemented in G3D::WidgetManager, G3D::CallbackWidget, and G3D::XRWidget.
|
overridevirtual |
Returning true consumes the event and prevents other GModules from seeing it.
Motion events (GEventType::MOUSEMOTION, GEventType::JOYHATMOTION, JGEventType::OYBALLMOTION, and GEventType::JOYAXISMOTION) cannot be cancelled.
Reimplemented from G3D::Widget.
|
overridevirtual |
Reimplemented from G3D::Widget.
|
inlinevirtualinherited |
Appends a posed model for this object to the array, if it has a graphic representation.
The posed model appended is allowed to reference the agent and is allowed to mutate if the agent is mutated.
Reimplemented in G3D::GuiWindow, G3D::WidgetManager, G3D::Discovery::Client, G3D::SceneEditorWindow, G3D::CallbackWidget, G3D::FullScreenWidget, G3D::UprightSplineManipulator, and G3D::ControlPointEditor.
|
overridevirtual |
|
overridevirtual |
Reimplemented from G3D::Widget.
|
overridevirtual |
Reimplemented from G3D::Widget.
|
inline |
|
inlinevirtualinherited |
The camera-space z position that this Widget considers this pixel to be at.
Used for positional event (e.g., mouse click) delivery. Higher means closer.
Large negative values are far away. 0 is the closest 3D object. Values greater than zero are used for 2D objects. Returning fnan() [the default] requests the WidgetManager to set hte positionalEventZ to the object's normal event zorder.
See the implementation of ControlPointEditor::positionalEventZ for an example of how to use this with a 3D object.
Reimplemented in G3D::ControlPointEditor.
|
inlineoverridevirtualinherited |
Inherited from Surface2D.
Implements G3D::Surface2D.
Reimplemented in G3D::GConsole, G3D::GuiWindow, G3D::GuiMenu, and G3D::DebugTextWidget.
void G3D::FirstPersonManipulator::reset | ( | ) |
Invoke immediately before entering the main game loop.
|
protected |
Returns true if the right mouse button is down, or on OSX, the user is using the left mouse and ctrl.
|
inline |
When the alt key is held down, multiply m_maxMoveRate by this.
Default is 0.1
|
inlinevirtualinherited |
Called by the WidgetManager.
This is the depth that the Widget is expected to use when posed as a Surface2D. Subclasses may override or ignore this but it can interfere with the normal handling of rendering.
|
overridevirtual |
When enabled, the FirstPersonManipulator responds to events and updates its frame.
When deactivated, the mouse cursor is restored and the mouse is located where it was when the camera controller was activated.
In some modes (e.g., MOUSE_DIRECT_RIGHT_BUTTON), the FirstPersonManipulator does not hide the mouse until some other event has occured.
In release mode, the cursor movement is restricted to the window while the controller is active. This does not occur in debug mode because you might hit a breakpoint while the controller is active and it would be annoying to not be able to move the mouse.
Reimplemented from G3D::Manipulator.
|
inline |
Default is 'c'.
|
inline |
Default is 'z'.
|
overridevirtual |
Sets to the closest legal controller orientation to the coordinate frame.
|
inlinevirtualinherited |
By default, does nothing.
|
inlinevirtualinherited |
Called by the WidgetManager when this module is added to it.
The argument may be nullptr
Reimplemented in G3D::SceneEditorWindow, G3D::ControlPointEditor, G3D::CameraControlWindow, G3D::GameController, G3D::DeveloperWindow, G3D::ProfilerWindow, G3D::TextureBrowserWindow, and G3D::SettingsWindow.
void G3D::FirstPersonManipulator::setMouseMode | ( | MouseMode | m | ) |
void G3D::FirstPersonManipulator::setMoveRate | ( | double | metersPerSecond | ) |
Initial value is 10.
|
inline |
|
inline |
|
inline |
When the shift key is held down, multiply m_maxMoveRate by this.
Default is 0.1
void G3D::FirstPersonManipulator::setTurnRate | ( | double | radiansPerSecond | ) |
Initial value is PI / 2.
|
inline |
|
inline |
Sorts from farthest to nearest.
|
staticinherited |
Calls sort, RenderDevice::push2D, and then render on all elements.
|
inline |
|
virtualinherited |
Returns the operating system window that is currently rendering this Widget.
Reimplemented in G3D::WidgetManager.
Referenced by G3D::FullScreenWidget::bounds().
|
inline |
|
protected |
Referenced by altSpeedMultipler(), and setAltSpeedMultipler().
|
protectedinherited |
Referenced by G3D::Widget::depth(), and G3D::Widget::setDepth().
|
protected |
|
protected |
Referenced by flyDownKey(), and setFlyDownKey().
|
protected |
Referenced by flyUpKey(), and setFlyUpKey().
|
protectedinherited |
The manager, set by setManager().
This cannot be a reference counted pointer because that would create a cycle between the Widget and its manager.
Referenced by G3D::Widget::manager(), G3D::GuiWindow::manager(), G3D::Widget::setManager(), and G3D::GuiWindow::setVisible().
|
protected |
m/s
|
protected |
rad/s
|
protected |
|
protected |
Referenced by pitch(), and setPitch().
|
protected |
Is the right mouse button currently held down?
|
protected |
Referenced by setShiftSpeedMultipler(), and shiftSpeedMultipler().
|
protected |
Referenced by setPosition(), and translation().
|
protected |
|
protected |
|
protected |