reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

A super simple camera for interacting with objects in 3D space. More...

#include <ofEasyCam.h>

Inheritance diagram for ofEasyCam:
ofCamera ofNode

Public Types

enum  TransformType {
  TRANSFORM_NONE , TRANSFORM_ROTATE , TRANSFORM_TRANSLATE_XY , TRANSFORM_TRANSLATE_Z ,
  TRANSFORM_SCALE
}
 Transformation types available for mouse interaction. More...
 

Public Member Functions

void setRelativeYAxis (bool relative=true)
 
bool getRelativeYAxis () const
 
void setUpAxis (const glm::vec3 &up)
 
const glm::vec3 & getUpAxis () const
 Get the up axis.
 
void enableInertia ()
 
void disableInertia ()
 
bool getInertiaEnabled () const
 Determine if intertia is enabled.
 
void setControlArea (const ofRectangle &controlArea)
 
void clearControlArea ()
 
ofRectangle getControlArea () const
 Returns the area bounds used for mouse control.
 
void addInteraction (TransformType type, int mouseButton, int key=-1)
 
void removeInteraction (TransformType type, int mouseButton, int key=-1)
 
bool hasInteraction (TransformType type, int mouseButton, int key=-1)
 
bool hasInteraction (int mouseButton, int key)
 
void removeAllInteractions ()
 
Constructor and Destructor
 ofEasyCam ()
 Create a default camera.
 
Rendering
virtual void begin (const ofRectangle &viewport)
 
virtual void begin ()
 Begins rendering with the camera.
 
void reset ()
 Reset the camera position and orientation.
 
Camera Target
void setTarget (const glm::vec3 &target)
 Set the camera's target.
 
void setTarget (ofNode &target)
 Set the camera's target.
 
const ofNodegetTarget () const
 Get the camera's target node reference.
 
Getters and Setters
void setDistance (float distance)
 Set the camera's distance to the target.
 
float getDistance () const
 Get the distance to the target.
 
void setDrag (float drag)
 Set the camera's drag coefficient.
 
float getDrag () const
 Get the camera's drag coefficient.
 
void setAutoDistance (bool bAutoDistance)
 Enable or disable camera autodistance.
 
void setEvents (ofCoreEvents &events)
 
void setRotationSensitivity (float x, float y, float z)
 Set the input sensitivity of the rotation. X and Y axes - when the value is 1.0, moving the mouse from one side to the other of the arcball (min(viewport.width, viewport.height)) will rotate 180 degrees. When the value is 0.5, the rotation will be 90 degrees.
 
void setRotationSensitivity (const glm::vec3 &sensitivity)
 
void setTranslationSensitivity (float x, float y, float z)
 Set the input sensitivity of the translation.
 
void setTranslationSensitivity (const glm::vec3 &sensitivity)
 
void setTranslationKey (char key)
 Set the key used to switch between camera rotation and translation.
 
char getTranslationKey () const
 Get the current translation key code.
 
Mouse Input
void enableMouseInput ()
 Enable mouse camera control.
 
void disableMouseInput ()
 Disable mouse camera control.
 
bool getMouseInputEnabled () const
 Determine if mouse camera control is enabled.
 
void enableMouseMiddleButton ()
 Enable the mouse's middle button for camera control.
 
void disableMouseMiddleButton ()
 Disable the mouse's middle button for camera control.
 
bool getMouseMiddleButtonEnabled () const
 Determine if the middle mouse button is enabled.
 
- Public Member Functions inherited from ofCamera
void drawFrustum (const ofRectangle &viewport) const
 Draw a visual representation of the camera's frustum.
 
void drawFrustum () const
 
 ofCamera ()
 Construct a default camera.
 
virtual ~ofCamera ()
 Destroy the camera.
 
void setFov (float f)
 Set the field of view for a perspective camera.
 
void setNearClip (float f)
 
void setFarClip (float f)
 
void setLensOffset (const glm::vec2 &lensOffset)
 Set the "lens offset" applied to this camera.
 
void setAspectRatio (float aspectRatio)
 Set the recommended aspect ratio for a perspective camera.
 
void setForceAspectRatio (bool forceAspectRatio)
 Set whether or not the aspect ratio of this camera is forced to a non-default setting.
 
float getFov () const
 Get the camera's field of view, in degrees.
 
float getNearClip () const
 
float getFarClip () const
 
glm::vec2 getLensOffset () const
 Get the "lens offset" applied to this camera, encoded as an glm::vec2.
 
bool getForceAspectRatio () const
 Get the boolean state which indicates whether the aspect ratio of this camera is forced to a non-default setting.
 
float getAspectRatio () const
 Get the aspect ratio of this camera's viewport.
 
void setupPerspective (bool vFlip=true, float fov=60, float nearDist=0, float farDist=0, const glm::vec2 &lensOffset=glm::vec2(0.0f, 0.0f))
 
void setupOffAxisViewPortal (const glm::vec3 &topLeft, const glm::vec3 &bottomLeft, const glm::vec3 &bottomRight)
 
void setVFlip (bool vflip)
 
bool isVFlipped () const
 
void enableOrtho ()
 
void disableOrtho ()
 
bool getOrtho () const
 
float getImagePlaneDistance (const ofRectangle &viewport=ofRectangle()) const
 
virtual void end ()
 Ends rendering with the camera.
 
glm::mat4 getProjectionMatrix () const
 Access the projection matrix.
 
glm::mat4 getProjectionMatrix (const ofRectangle &viewport) const
 
glm::mat4 getModelViewMatrix () const
 Access the model view matrix.
 
glm::mat4 getModelViewProjectionMatrix (const ofRectangle &viewport) const
 
glm::mat4 getModelViewProjectionMatrix () const
 
glm::vec3 worldToScreen (glm::vec3 WorldXYZ, const ofRectangle &viewport) const
 Obtain the screen coordinates of a point in the 3D world.
 
glm::vec3 worldToScreen (glm::vec3 WorldXYZ) const
 
glm::vec3 screenToWorld (glm::vec3 ScreenXYZ, const ofRectangle &viewport) const
 Obtain the coordinates, in the 3D world, of a 2D point presumed to be on your screen.
 
glm::vec3 screenToWorld (glm::vec3 ScreenXYZ) const
 
glm::vec3 worldToCamera (glm::vec3 WorldXYZ, const ofRectangle &viewport) const
 
glm::vec3 worldToCamera (glm::vec3 WorldXYZ) const
 
glm::vec3 cameraToWorld (glm::vec3 CameraXYZ, const ofRectangle &viewport) const
 
glm::vec3 cameraToWorld (glm::vec3 CameraXYZ) const
 
void setRenderer (std::shared_ptr< ofBaseRenderer > renderer)
 
- Public Member Functions inherited from ofNode
void setParent (ofNode &parent, bool bMaintainGlobalTransform=false)
 Set parent for the node. The node will inherit transformations from parent.
 
void clearParent (bool bMaintainGlobalTransform=false)
 Remove parent node linking.
 
ofNodegetParent () const
 Get the parent node of this node.
 
glm::vec3 getPosition () const
 Get node's local position as a 3D vector.
 
float getX () const
 Get node's local x position.
 
float getY () const
 Get node's local y position.
 
float getZ () const
 Get node's local z position.
 
glm::vec3 getXAxis () const
 Get the node's local x axis as 3d vector.
 
glm::vec3 getYAxis () const
 Get the node's local y axis as 3d vector.
 
glm::vec3 getZAxis () const
 Get the node's local z axis as 3d vector.
 
glm::vec3 getSideDir () const
 Get direction of node's side aka local x axis, as 3d vector.
 
glm::vec3 getLookAtDir () const
 Get direction the node looks at aka local -z axis, as 3d vector.
 
glm::vec3 getUpDir () const
 Get direction of node's top aka local y axis, as 3d vector.
 
 OF_DEPRECATED_MSG ("Use Deg/Rad versions.", float getPitch() const)
 
 OF_DEPRECATED_MSG ("Use Deg/Rad versions.", float getHeading() const)
 
 OF_DEPRECATED_MSG ("Use Deg/Rad versions.", float getRoll() const)
 
float getPitchDeg () const
 Get pitch of node, aka the rotation along local x axis.
 
float getHeadingDeg () const
 Get heading of node, aka the rotation along local y axis.
 
float getRollDeg () const
 Get roll of node, aka the rotation along local z axis.
 
float getPitchRad () const
 Get pitch of node, aka the rotation along local x axis.
 
float getHeadingRad () const
 Get heading of node, aka the rotation along local y axis.
 
float getRollRad () const
 Get roll of node, aka the rotation along local z axis.
 
glm::quat getOrientationQuat () const
 Get the local orientation of the node as a quaternion.
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", glm::vec3 getOrientationEuler() const)
 
glm::vec3 getOrientationEulerDeg () const
 Get local orientation of node in degrees around x, y, and z axes.
 
glm::vec3 getOrientationEulerRad () const
 Get local orientation of node in degrees around x, y, and z axes.
 
glm::vec3 getScale () const
 Get local scale of node in xyz axes where 1 is default.
 
const glm::mat4 & getLocalTransformMatrix () const
 Get node's local transformations (position, orientation, scale).
 
glm::mat4 getGlobalTransformMatrix () const
 Get node's global transformations (position, orientation, scale).
 
glm::vec3 getGlobalPosition () const
 Get node's global position as a 3D vector.
 
glm::quat getGlobalOrientation () const
 Get the global orientation of the node as a quaternion.
 
glm::vec3 getGlobalScale () const
 Get global scale of node in xyz axes where 1 is default.
 
void setPosition (float px, float py, float pz)
 Set the local position of the node using xyz coordinates.
 
void setPosition (const glm::vec3 &p)
 Set the local position of the node using a 3D vector of coordinates.
 
void setGlobalPosition (float px, float py, float pz)
 Set the global position of the node using xyz coordinates.
 
void setGlobalPosition (const glm::vec3 &p)
 Set the global position of the node using a 3D vector of coordinates.
 
void setOrientation (const glm::quat &q)
 Set local orientation with a quaternion.
 
void setOrientation (const glm::vec3 &eulerAngles)
 Set local orientation with xyz euler angles.
 
void setGlobalOrientation (const glm::quat &q)
 Set global orientation with a quaternion.
 
void setScale (float s)
 Set local uniform scale (x, y, and z are equally scaled).
 
void setScale (float sx, float sy, float sz)
 Set local scale for xyz axes individually.
 
void setScale (const glm::vec3 &s)
 Set local scale for xyz axes individually with a 3D vector.
 
void move (float x, float y, float z)
 Move node by relative amount with xyz coordinates.
 
void move (const glm::vec3 &offset)
 Move node by relative amount with xyz as ref to 3D vector.
 
void truck (float amount)
 Move node left+right relative to current position (in local x axis).
 
void boom (float amount)
 Move node up+down relative to current position (in local y axis).
 
void dolly (float amount)
 Move node backward+forward relative to current position (in local z axis).
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void tilt(float degrees))
 
void tiltDeg (float degrees)
 Tilt up+down relative to current orientation (around local x axis).
 
void tiltRad (float radians)
 Tilt up+down relative to current orientation (around local x axis).
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void pan(float degrees))
 
void panDeg (float degrees)
 Rotate left+right relative to current orientation (around local y axis).
 
void panRad (float radians)
 Rotate left+right relative to current orientation (around local y axis).
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void roll(float degrees))
 
void rollDeg (float degrees)
 Roll left+right relative to current orientation (around local z axis).
 
void rollRad (float radians)
 Roll left+right relative to current orientation (around local z axis).
 
void rotate (const glm::quat &q)
 Rotate relative to current orientation by quaternion.
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void rotate(float degrees, const glm::vec3 &v))
 
void rotateDeg (float degrees, const glm::vec3 &v)
 Rotate relative to current orientation around arbitrary axis.
 
void rotateRad (float radians, const glm::vec3 &v)
 Rotate relative to current orientation around arbitrary axis.
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void rotate(float degrees, float vx, float vy, float vz))
 
void rotateDeg (float degrees, float vx, float vy, float vz)
 Rotate relative to current orientation around arbitrary axis.
 
void rotateRad (float radians, float vx, float vy, float vz)
 Rotate relative to current orientation around arbitrary axis.
 
void rotateAround (const glm::quat &q, const glm::vec3 &point)
 Rotate relative to current orientation by quaternion around point.
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void rotateAround(float degrees, const glm::vec3 &axis, const glm::vec3 &point))
 
void rotateAroundDeg (float degrees, const glm::vec3 &axis, const glm::vec3 &point)
 Rotate relative to current orientation around arbitrary axis around point.
 
void rotateAroundRad (float radians, const glm::vec3 &axis, const glm::vec3 &point)
 Rotate relative to current orientation around arbitrary axis around point.
 
void lookAt (const glm::vec3 &lookAtPosition)
 Orient node to look at point (-z axis pointing to global position).
 
void lookAt (const glm::vec3 &lookAtPosition, glm::vec3 upVector)
 Orient node to look at point (-z axis pointing to global position).
 
void lookAt (const ofNode &lookAtNode)
 Orient node to look at another node (-z axis pointing at other node).
 
void lookAt (const ofNode &lookAtNode, const glm::vec3 &upVector)
 Orient node to look at another node (-z axis pointing at other node).
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void orbit(float longitude, float latitude, float radius, const glm::vec3 &centerPoint=glm::vec3(0, 0, 0)))
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void orbit(float longitude, float latitude, float radius, ofNode &centerNode))
 
void orbitDeg (float longitude, float latitude, float radius, const glm::vec3 &centerPoint=glm::vec3(0, 0, 0))
 Orbit node around a global position at a specific radius.
 
void orbitDeg (float longitude, float latitude, float radius, ofNode &centerNode)
 Orbit node around another node at a specific radius.
 
void orbitRad (float longitude, float latitude, float radius, const glm::vec3 &centerPoint=glm::vec3(0, 0, 0))
 Orbit node around a global position at a specific radius.
 
void orbitRad (float longitude, float latitude, float radius, ofNode &centerNode)
 Orbit node around another node at a specific radius.
 
void transformGL (ofBaseRenderer *renderer=nullptr) const
 Set opengl renderer's modelview matrix to this nodes transform.
 
void restoreTransformGL (ofBaseRenderer *renderer=nullptr) const
 Restore opengl renderer's previous modelview transform matrix.
 
void resetTransform ()
 Reset this node's transformations, position, rotation and scale.
 
virtual void customDraw (const ofBaseRenderer *renderer) const
 If you extend ofNode and wish to change the way it draws, extend this.
 
virtual void customDraw ()
 If you extend ofNode and wish to change the way it draws, extend this.
 
virtual void draw () const
 Draw the node as a white cube with xyz axes.
 

Protected Member Functions

virtual void onPositionChanged ()
 Classes extending ofNode can override this method to get notified when the position changed.
 
- Protected Member Functions inherited from ofCamera
ofRectangle getViewport () const
 
std::shared_ptr< ofBaseRenderergetRenderer () const
 
void calcClipPlanes (const ofRectangle &viewport)
 
- Protected Member Functions inherited from ofNode
void createMatrix ()
 
void updateAxis ()
 
virtual void onOrientationChanged ()
 Classes extending ofNode can override this methods to get notified when the orientation changed.
 
virtual void onScaleChanged ()
 Classes extending ofNode can override this methods to get notified when the scale changed.
 

Additional Inherited Members

- Protected Attributes inherited from ofNode
ofNodeparent = nullptr
 

Detailed Description

A super simple camera for interacting with objects in 3D space.

Member Enumeration Documentation

◆ TransformType

Transformation types available for mouse interaction.

Enumerator
TRANSFORM_NONE 
TRANSFORM_ROTATE 
TRANSFORM_TRANSLATE_XY 
TRANSFORM_TRANSLATE_Z 
TRANSFORM_SCALE 

Constructor & Destructor Documentation

◆ ofEasyCam()

ofEasyCam::ofEasyCam ( )

Create a default camera.

Member Function Documentation

◆ addInteraction()

void ofEasyCam::addInteraction ( TransformType  type,
int  mouseButton,
int  key = -1 
)

◆ begin() [1/2]

virtual void ofEasyCam::begin ( )
inlinevirtual

Begins rendering with the camera.

void draw() {
// Begin rendering from the camera's perspective.
camera.begin();
// Additional rendering ...
// End rendering form the camera's perspective.
camera.end();
}
virtual void draw() const
Draw the node as a white cube with xyz axes.
Definition ofNode.cpp:637
int ofGetWidth()
Definition ofAppRunner.cpp:405
int ofGetHeight()
Definition ofAppRunner.cpp:409
void ofLine(const glm::vec3 &p1, const glm::vec3 &p2)
Definition ofGraphics.cpp:925
Parameters
viewportThe camera's rendering viewport.

Reimplemented from ofCamera.

◆ begin() [2/2]

void ofEasyCam::begin ( const ofRectangle viewport)
virtual

Reimplemented from ofCamera.

◆ clearControlArea()

void ofEasyCam::clearControlArea ( )

Clears the area bounds for mouse control so that the full viewport is used.

◆ disableInertia()

void ofEasyCam::disableInertia ( )

◆ disableMouseInput()

void ofEasyCam::disableMouseInput ( )

Disable mouse camera control.

◆ disableMouseMiddleButton()

void ofEasyCam::disableMouseMiddleButton ( )

Disable the mouse's middle button for camera control.

◆ enableInertia()

void ofEasyCam::enableInertia ( )

◆ enableMouseInput()

void ofEasyCam::enableMouseInput ( )

Enable mouse camera control.

◆ enableMouseMiddleButton()

void ofEasyCam::enableMouseMiddleButton ( )

Enable the mouse's middle button for camera control.

◆ getControlArea()

ofRectangle ofEasyCam::getControlArea ( ) const

Returns the area bounds used for mouse control.

◆ getDistance()

float ofEasyCam::getDistance ( ) const

Get the distance to the target.

Returns
the distance to the target.

◆ getDrag()

float ofEasyCam::getDrag ( ) const

Get the camera's drag coefficient.

Returns
the camera's drag coefficient.

◆ getInertiaEnabled()

bool ofEasyCam::getInertiaEnabled ( ) const

Determine if intertia is enabled.

◆ getMouseInputEnabled()

bool ofEasyCam::getMouseInputEnabled ( ) const

Determine if mouse camera control is enabled.

Todo:
Rename to isMouseInputEnabled().
Returns
true iff mouse camera control is enabled.

◆ getMouseMiddleButtonEnabled()

bool ofEasyCam::getMouseMiddleButtonEnabled ( ) const

Determine if the middle mouse button is enabled.

Todo:
Rename to isMouseMiddleButtonEnabled().
Returns
true iff the mouse's middle button is enabled.

◆ getRelativeYAxis()

bool ofEasyCam::getRelativeYAxis ( ) const

Determine if the Y axis is set to be relative to the camera orientation

◆ getTarget()

const ofNode & ofEasyCam::getTarget ( ) const

Get the camera's target node reference.

Returns
a reference the the camera's target node.

◆ getTranslationKey()

char ofEasyCam::getTranslationKey ( ) const

Get the current translation key code.

Returns
the current translation key code.

◆ getUpAxis()

const glm::vec3 & ofEasyCam::getUpAxis ( ) const

Get the up axis.

◆ hasInteraction() [1/2]

bool ofEasyCam::hasInteraction ( int  mouseButton,
int  key 
)

◆ hasInteraction() [2/2]

bool ofEasyCam::hasInteraction ( TransformType  type,
int  mouseButton,
int  key = -1 
)

◆ onPositionChanged()

void ofEasyCam::onPositionChanged ( )
protectedvirtual

Classes extending ofNode can override this method to get notified when the position changed.

Reimplemented from ofNode.

◆ removeAllInteractions()

void ofEasyCam::removeAllInteractions ( )

◆ removeInteraction()

void ofEasyCam::removeInteraction ( TransformType  type,
int  mouseButton,
int  key = -1 
)

◆ reset()

void ofEasyCam::reset ( )

Reset the camera position and orientation.

◆ setAutoDistance()

void ofEasyCam::setAutoDistance ( bool  bAutoDistance)

Enable or disable camera autodistance.

Allow the camera to attempt to set the distance based on the camera's current viewpoirt.

Parameters
bAutoDistancetrue to enable auto distance.

◆ setControlArea()

void ofEasyCam::setControlArea ( const ofRectangle controlArea)

Set the area bounds for mouse control. Uses the full viewport by default.

◆ setDistance()

void ofEasyCam::setDistance ( float  distance)

Set the camera's distance to the target.

Parameters
distanceThe distance to the target.

◆ setDrag()

void ofEasyCam::setDrag ( float  drag)

Set the camera's drag coefficient.

Drag is affects how quickly the camera starts up and slows down when a user interacts with its position using a pointer.

Parameters
dragThe normalized coefficient value between 0 and 1.

◆ setEvents()

void ofEasyCam::setEvents ( ofCoreEvents events)

◆ setRelativeYAxis()

void ofEasyCam::setRelativeYAxis ( bool  relative = true)

Uses Y axis relative to the camera orientation

By default the Y axis used for interactive rotation is vec3(0,1,0) or whatever is set as up axis using setUpAxis

◆ setRotationSensitivity() [1/2]

void ofEasyCam::setRotationSensitivity ( const glm::vec3 &  sensitivity)

◆ setRotationSensitivity() [2/2]

void ofEasyCam::setRotationSensitivity ( float  x,
float  y,
float  z 
)

Set the input sensitivity of the rotation. X and Y axes - when the value is 1.0, moving the mouse from one side to the other of the arcball (min(viewport.width, viewport.height)) will rotate 180 degrees. When the value is 0.5, the rotation will be 90 degrees.

Parameters
valueScales the xyz axes rotation factor by these values.

◆ setTarget() [1/2]

void ofEasyCam::setTarget ( const glm::vec3 &  target)

Set the camera's target.

Parameters
targetThe position of the target.

◆ setTarget() [2/2]

void ofEasyCam::setTarget ( ofNode target)

Set the camera's target.

Parameters
targetThe position of the target.

◆ setTranslationKey()

void ofEasyCam::setTranslationKey ( char  key)

Set the key used to switch between camera rotation and translation.

Translation will only happen when the translation key is pressed.

Parameters
keyThe key code for the translation key.
Todo:
char is not the right data type for this. Should be int.

◆ setTranslationSensitivity() [1/2]

void ofEasyCam::setTranslationSensitivity ( const glm::vec3 &  sensitivity)

◆ setTranslationSensitivity() [2/2]

void ofEasyCam::setTranslationSensitivity ( float  x,
float  y,
float  z 
)

Set the input sensitivity of the translation.

Parameters
valueScales the xyz axes translation factor by these values.

◆ setUpAxis()

void ofEasyCam::setUpAxis ( const glm::vec3 &  up)

Set the camera fixed up axis for interactive manipulation.


The documentation for this class was generated from the following files:
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/3d/ofEasyCam.h
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/3d/ofEasyCam.cpp