NAP
Public Member Functions | List of all members
FirstPersonControllerInstance Class Reference

#include <firstpersoncontroller.h>

Public Member Functions

 FirstPersonControllerInstance (EntityInstance &entity, Component &resource)
 
virtual bool init (utility::ErrorState &errorState) override
 
virtual void update (double deltaTime) override
 
void enable (const glm::vec3 &translate, const glm::quat &rotate)
 
void enable ()
 
void disable ()
 
CameraComponentInstancegetCameraComponent ()
 
float getMovementSpeed () const
 
void setMovementSpeed (float speed)
 
float getRotationSpeed () const
 
void setRotationSpeed (float speed)
 
- Public Member Functions inherited from ComponentInstance
 ComponentInstance (EntityInstance &entity, Component &resource)
 
nap::EntityInstancegetEntityInstance () const
 
nap::ComponentgetComponent () const
 
template<typename T >
T * getComponent () const
 
virtual bool init (utility::ErrorState &errorState)
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Description

Instance part of the first person controller. The controller applies first-person movement to the (camera) entity it is attached to. Hold left mouse to activate. WASD to move, QE to move up and down, mouse to rotate. Requires a nap::KeyInputComponent and nap::TransformComponent to be present on the same entity.

Inheritance diagram for FirstPersonControllerInstance:
[legend]
Collaboration diagram for FirstPersonControllerInstance:
[legend]

Constructor & Destructor Documentation

◆ FirstPersonControllerInstance()

FirstPersonControllerInstance ( EntityInstance entity,
Component resource 
)

Member Function Documentation

◆ disable()

void disable ( )

Disables the component.

◆ enable() [1/2]

void enable ( )

Enable the component, keeping the current transform.

◆ enable() [2/2]

void enable ( const glm::vec3 &  translate,
const glm::quat &  rotate 
)

Enable the component while setting the transform.

Parameters
translateCamera translation to set.
rotateCamera rotation to set.

◆ getCameraComponent()

CameraComponentInstance& getCameraComponent ( )
Returns
The perspective camera component that we're controlling.

◆ getMovementSpeed()

float getMovementSpeed ( ) const
Returns
the camera movement speed

◆ getRotationSpeed()

float getRotationSpeed ( ) const
Returns
current camera rotation speed

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Initialize this ComponentInstance

Reimplemented from ComponentInstance.

◆ setMovementSpeed()

void setMovementSpeed ( float  speed)

Sets the camera movement speed

Parameters
speedthe new movement speed

◆ setRotationSpeed()

void setRotationSpeed ( float  speed)

Sets the current camera rotation speed

Parameters
speedthe new camera rotation speed

◆ update()

virtual void update ( double  deltaTime)
overridevirtual

Update this ComponentInstance

Reimplemented from ComponentInstance.