Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
G3D::ThirdPersonManipulator Class Reference

By default, the ThirdPersonManipulator moves an object relative to its own axes. More...

Inherits G3D::Manipulator.

Public Member Functions

virtual Rect2D bounds () const override
 Inherited from Surface2D. More...
 
void computeProjection (RenderDevice *rd) const
 Assumes that m_controlFrame is the current object to world matrix. More...
 
virtual float depth () const override
 Inherited from Surface2D. More...
 
Vector3 doubleAxisTranslationDrag (int a0, int a1, const Vector2 &delta)
 
bool enabled () const
 
virtual void fireEvent (const GEvent &event)
 Fire an event on the containing window. More...
 
virtual CoordinateFrame frame () const
 
void getControlFrame (CoordinateFrame &c) const
 
void getFrame (CoordinateFrame &c) const
 Returns the object's new frame. More...
 
WidgetManagermanager () const
 
virtual void onAfterEvents ()
 Invoked after all onEvent handlers for the current frame and before onUserInput for any other Widget. More...
 
virtual void onAI ()
 
virtual void onBeforeGraphics ()
 Invoked by WidgetManager immediately before GApp::onGraphics runs. More...
 
virtual void onDrag (const Vector2 &delta)
 Called when the user has dragged on the control. More...
 
virtual void onDragBegin (const Vector2 &start)
 Called when it has been determined that the user first began a drag on one of our controls. More...
 
virtual void onDragEnd (const Vector2 &stop)
 Invoked after m_dragging is false. More...
 
bool onEvent (const GEvent &event)
 Returning true consumes the event and prevents other GModules from seeing it. More...
 
virtual void onNetwork ()
 
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 > > &posedArray, Array< shared_ptr< Surface2D >> &posed2DArray)
 
void onSimulation (RealTime rdt, SimTime sdt, SimTime idt)
 
void onUserInput (UserInput *ui)
 
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...
 
virtual void render3D (RenderDevice *rd)
 Called by the Surface. More...
 
bool rotationEnabled () const
 
void setControlFrame (const CoordinateFrame &c)
 Keeps the object where it in world space is and moves the control in world space. More...
 
virtual void setDepth (float d)
 Called by the WidgetManager. More...
 
void setEnabled (bool e)
 
void setFrame (const CoordinateFrame &c)
 Moves the object and the control in world space. 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 setRotationEnabled (bool r)
 
void setTranslationEnabled (bool r)
 
Vector3 singleAxisTranslationDrag (int a, const Vector2 &delta)
 Called from onDrag. More...
 
bool translationEnabled () const
 
virtual OSWindowwindow () const
 Returns the operating system window that is currently rendering this Widget. More...
 

Static Public Member Functions

static CoordinateFrame computeOffsetFrame (const CoordinateFrame &controlFrame, const CoordinateFrame &objectFrame)
 Given the desired start frame for the axes and the desired frame for the object, returns the offsetFrame that should be used t. More...
 
static ThirdPersonManipulatorRef create ()
 
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

 ThirdPersonManipulator ()
 

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_depth
 
WidgetManagerm_manager
 The manager, set by setManager(). More...
 

Friends

class TPMSurface
 

Detailed Description

By default, the ThirdPersonManipulator moves an object relative to its own axes.

To move the object relative to the world axes, use setOffsetFrame.

To manipulate an object, set that object's coordinate frame to the frame(), as in:

shared_ptr<Surface> posedModel = model->pose(manipulator->frame());

(see the shader demo for an example)

Examples:

  CoordinateFrame obj = CoordinateFrame(Matrix3::fromAxisAngle(Vector3::unitY(), toRadians(30)), Vector3(2, 0, 0));
  // To move object relative to its own axes
  manipulator.setFrame(obj);
  manipulator.setControlFrame(obj);
  // Move object relative to the world axes
  manipulator.setFrame(obj);
  manipulator.setControlFrame(CoordinateFrame());
  // Move object relative to the world axes using its own translation
  manipulator.setFrame(obj);
  manipulator.setControlFrame(CoordinateFrame(obj.translation));

Constructor & Destructor Documentation

◆ ThirdPersonManipulator()

G3D::ThirdPersonManipulator::ThirdPersonManipulator ( )
protected

Member Function Documentation

◆ bounds()

virtual Rect2D G3D::Widget::bounds ( ) const
inlineoverridevirtualinherited

Inherited from Surface2D.

Implements G3D::Surface2D.

Reimplemented in G3D::GuiWindow, G3D::GConsole, and G3D::FullScreenWidget.

◆ computeOffsetFrame()

static CoordinateFrame G3D::ThirdPersonManipulator::computeOffsetFrame ( const CoordinateFrame controlFrame,
const CoordinateFrame objectFrame 
)
static

Given the desired start frame for the axes and the desired frame for the object, returns the offsetFrame that should be used t.

◆ computeProjection()

void G3D::ThirdPersonManipulator::computeProjection ( RenderDevice rd) const

Assumes that m_controlFrame is the current object to world matrix.

◆ create()

static ThirdPersonManipulatorRef G3D::ThirdPersonManipulator::create ( )
static

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ depth()

virtual float G3D::Widget::depth ( ) const
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.

◆ doubleAxisTranslationDrag()

Vector3 G3D::ThirdPersonManipulator::doubleAxisTranslationDrag ( int  a0,
int  a1,
const Vector2 delta 
)

◆ enabled()

bool G3D::ThirdPersonManipulator::enabled ( ) const
virtual

Reimplemented from G3D::Manipulator.

◆ fireEvent()

virtual void G3D::Widget::fireEvent ( const GEvent event)
virtualinherited

Fire an event on the containing window.

Reimplemented in G3D::WidgetManager.

◆ frame()

virtual CoordinateFrame G3D::ThirdPersonManipulator::frame ( ) const
virtual

Implements G3D::Manipulator.

◆ getControlFrame()

void G3D::ThirdPersonManipulator::getControlFrame ( CoordinateFrame c) const

◆ getFrame()

void G3D::ThirdPersonManipulator::getFrame ( CoordinateFrame c) const
virtual

Returns the object's new frame.

Implements G3D::Manipulator.

◆ manager()

WidgetManager* G3D::Widget::manager ( ) const
inlineinherited

◆ onAfterEvents()

virtual void G3D::Widget::onAfterEvents ( )
inlinevirtualinherited

Invoked after all onEvent handlers for the current frame and before onUserInput for any other Widget.

Reimplemented in G3D::WidgetManager, and G3D::GameController.

◆ onAI()

virtual void G3D::ThirdPersonManipulator::onAI ( )
virtual

Reimplemented from G3D::Widget.

◆ onBeforeGraphics()

virtual void G3D::Widget::onBeforeGraphics ( )
inlinevirtualinherited

Invoked by WidgetManager immediately before GApp::onGraphics runs.

Reimplemented in G3D::WidgetManager, G3D::CallbackWidget, and G3D::XRWidget.

◆ onDrag()

virtual void G3D::ThirdPersonManipulator::onDrag ( const Vector2 delta)
virtual

Called when the user has dragged on the control.

◆ onDragBegin()

virtual void G3D::ThirdPersonManipulator::onDragBegin ( const Vector2 start)
virtual

Called when it has been determined that the user first began a drag on one of our controls.

Invoked before m_dragging is true.

◆ onDragEnd()

virtual void G3D::ThirdPersonManipulator::onDragEnd ( const Vector2 stop)
virtual

Invoked after m_dragging is false.

◆ onEvent()

bool G3D::ThirdPersonManipulator::onEvent ( const GEvent event)
virtual

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.

◆ onNetwork()

virtual void G3D::ThirdPersonManipulator::onNetwork ( )
virtual

Reimplemented from G3D::Widget.

◆ onPose() [1/2]

virtual void G3D::Widget::onPose ( Array< shared_ptr< Surface > > &  surfaceArray,
Array< shared_ptr< Surface2D > > &  surface2DArray 
)
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.

◆ onPose() [2/2]

virtual void G3D::ThirdPersonManipulator::onPose ( Array< shared_ptr< Surface > > &  posedArray,
Array< shared_ptr< Surface2D >> &  posed2DArray 
)
virtual

◆ onSimulation()

void G3D::ThirdPersonManipulator::onSimulation ( RealTime  rdt,
SimTime  sdt,
SimTime  idt 
)
virtual

Reimplemented from G3D::Widget.

◆ onUserInput()

void G3D::ThirdPersonManipulator::onUserInput ( UserInput ui)
virtual

Reimplemented from G3D::Widget.

◆ positionalEventZ()

virtual float G3D::Widget::positionalEventZ ( const Point2 pixel) const
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.

◆ render()

virtual void G3D::Widget::render ( RenderDevice rd) const
inlineoverridevirtualinherited

Inherited from Surface2D.

Implements G3D::Surface2D.

Reimplemented in G3D::GConsole, G3D::GuiWindow, G3D::GuiMenu, and G3D::DebugTextWidget.

◆ render3D()

virtual void G3D::ThirdPersonManipulator::render3D ( RenderDevice rd)
virtual

Called by the Surface.

◆ rotationEnabled()

bool G3D::ThirdPersonManipulator::rotationEnabled ( ) const

◆ setControlFrame()

void G3D::ThirdPersonManipulator::setControlFrame ( const CoordinateFrame c)

Keeps the object where it in world space is and moves the control in world space.

Changes the value of frame() constant.

◆ setDepth()

virtual void G3D::Widget::setDepth ( float  d)
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.

◆ setEnabled()

void G3D::ThirdPersonManipulator::setEnabled ( bool  e)
virtual

Reimplemented from G3D::Manipulator.

◆ setFrame() [1/2]

void G3D::ThirdPersonManipulator::setFrame ( const CoordinateFrame c)

Moves the object and the control in world space.

◆ setFrame() [2/2]

virtual void G3D::Manipulator::setFrame ( const CFrame c)
inlinevirtualinherited

By default, does nothing.

◆ setManager()

virtual void G3D::Widget::setManager ( WidgetManager m)
inlinevirtualinherited

◆ setRotationEnabled()

void G3D::ThirdPersonManipulator::setRotationEnabled ( bool  r)

◆ setTranslationEnabled()

void G3D::ThirdPersonManipulator::setTranslationEnabled ( bool  r)

◆ singleAxisTranslationDrag()

Vector3 G3D::ThirdPersonManipulator::singleAxisTranslationDrag ( int  a,
const Vector2 delta 
)

Called from onDrag.

Parameters
aAxis index.

◆ sort()

static void G3D::Surface2D::sort ( Array< shared_ptr< Surface2D >> &  array)
staticinherited

Sorts from farthest to nearest.

◆ sortAndRender()

static void G3D::Surface2D::sortAndRender ( RenderDevice rd,
Array< shared_ptr< Surface2D >> &  array 
)
staticinherited

Calls sort, RenderDevice::push2D, and then render on all elements.

◆ translationEnabled()

bool G3D::ThirdPersonManipulator::translationEnabled ( ) const

◆ window()

virtual OSWindow* G3D::Widget::window ( ) const
virtualinherited

Returns the operating system window that is currently rendering this Widget.

Reimplemented in G3D::WidgetManager.

Referenced by G3D::FullScreenWidget::bounds().

Friends And Related Function Documentation

◆ TPMSurface

friend class TPMSurface
friend

Member Data Documentation

◆ m_depth

float G3D::Widget::m_depth
protectedinherited

◆ m_manager

WidgetManager* G3D::Widget::m_manager
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().


documentation generated on Wed Nov 24 2021 08:02:01 using doxygen 1.8.15