Skip to content

Latest commit

 

History

History
3141 lines (1634 loc) · 38.3 KB

ofEasyCam.markdown

File metadata and controls

3141 lines (1634 loc) · 38.3 KB

#class ofEasyCam

##InlineDescription

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

##Description

ofCamera objects useful for viewing 3D scenes. ofEasyCam gives you a very simple to use interactive camera to view your scene. It's based more or less on PeasyCam from Processing.

It has a few default controls built into it:

  • Left click drag = orbit the target
  • Right click drag = dolly in and out
  • Double click = reset camera position

##Methods

###void addInteraction(type, mouseButton, key)

_inlined_description: _

_description: _

###void begin(&viewport)

_inlined_description: _

} \name Rendering {

_description: _

Begin using the camera, e.g.:

void draw() {

    myCamera.begin();

    ofDrawGrid();
    //draw rest of scene

    myCamera.end();
}

###void begin()

_inlined_description: _

_description: _

###void clearControlArea()

_inlined_description: _

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

_description: _

###void disableInertia()

_inlined_description: _

_description: _

###void disableMouseInput()

_inlined_description: _

Disable mouse camera control.

_description: _

###void disableMouseMiddleButton()

_inlined_description: _

Disable the mouse's middle button for camera control.

_description: _

###void enableInertia()

_inlined_description: _

_description: _

###void enableMouseInput()

_inlined_description: _

Enable mouse camera control.

_description: _

###void enableMouseMiddleButton()

_inlined_description: _

Enable the mouse's middle button for camera control.

_description: _

###ofRectangle getControlArea()

_inlined_description: _

Returns the area bounds used for mouse control.

_description: _

###float getDistance()

_inlined_description: _

Get the distance to the target.

Returns: the distance to the target.

_description: _

###float getDrag()

_inlined_description: _

Get the camera's drag coefficient.

Returns: the camera's drag coefficient.

_description: _

###bool getInertiaEnabled()

_inlined_description: _

Determine if intertia is enabled.

_description: _

###bool getMouseInputEnabled()

_inlined_description: _

Determine if mouse camera control is enabled. \todo Rename to isMouseInputEnabled().

Returns: true iff mouse camera control is enabled.

_description: _

###bool getMouseMiddleButtonEnabled()

_inlined_description: _

Determine if the middle mouse button is enabled. \todo Rename to isMouseMiddleButtonEnabled().

Returns: true iff the mouse's middle button is enabled.

_description: _

###bool getRelativeYAxis()

_inlined_description: _

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

_description: _

###const ofNode & getTarget()

_inlined_description: _

Get the camera's target node reference.

Returns: a reference the the camera's target node.

_description: _

###char getTranslationKey()

_inlined_description: _

Get the current translation key code.

Returns: the current translation key code.

_description: _

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

_inlined_description: _

Get the up axis.

_description: _

###bool hasInteraction(mouseButton, key)

_inlined_description: _

_description: _

###bool hasInteraction(type, mouseButton, key)

_inlined_description: _

_description: _

###void mousePressed(&mouse)

_inlined_description: _

_description: _

###void mouseReleased(&mouse)

_inlined_description: _

_description: _

###void mouseScrolled(&mouse)

_inlined_description: _

_description: _

ofEasyCam()

_inlined_description: _

Create a default camera.

_description: _

###void removeAllInteractions()

_inlined_description: _

_description: _

###void removeInteraction(type, mouseButton, key)

_inlined_description: _

_description: _

###void reset()

_inlined_description: _

Reset the camera position and orientation.

_description: _

###void setAutoDistance(bAutoDistance)

_inlined_description: _

Enable or disable camera autodistance.

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

Parameters:

bAutoDistance true to enable auto distance.

_description: _

###void setControlArea(&controlArea)

_inlined_description: _

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

_description: _

###void setDistance(distance)

_inlined_description: _

Set the camera's distance to the target.

Parameters:

distance The distance to the target.

_description: _

###void setDistance(distance, save)

_inlined_description: _

_description: _

###void setDrag(drag)

_inlined_description: _

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:

drag The normalized coefficient value between 0 and 1.

_description: _

###void setEvents(&events)

_inlined_description: _

_description: _

###void setRelativeYAxis(relative = true)

_inlined_description: _

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

_description: _

###void setRotationSensitivity(&sensitivity)

_inlined_description: _

_description: _

###void setRotationSensitivity(x, y, z)

_inlined_description: _

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:

value Scales the xyz axes rotation factor by these values.

_description: _

###void setTarget(&target)

_inlined_description: _

Set the camera's target.

Parameters:

target The position of the target.

_description: _

###void setTarget(&target)

_inlined_description: _

Set the camera's target.

Parameters:

target The position of the target.

_description: _

###void setTranslationKey(key)

_inlined_description: _

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

Translation will only happen when the translation key is pressed.

Parameters:

key The key code for the translation key. \todo char is not the right data type for this. Should be int.

_description: _

###void setTranslationSensitivity(&sensitivity)

_inlined_description: _

_description: _

###void setTranslationSensitivity(x, y, z)

_inlined_description: _

Set the input sensitivity of the translation.

Parameters:

value Scales the xyz axes translation factor by these values.

_description: _

###void setUpAxis(&up)

_inlined_description: _

Set the camera fixed up axis for interactive manipulation.

_description: _

###glm::vec3 up()

_inlined_description: _

Returns the up axis vector;

_description: _

###void update(&args)

_inlined_description: _

_description: _

###void updateMouse(&mouse)

_inlined_description: _

_description: _

###void updateRotation()

_inlined_description: _

_description: _

###void updateTranslation()

_inlined_description: _

_description: _

##Variables

###bool bApplyInertia

_inlined_description: _

_description: _

###bool bAutoDistance

_inlined_description: _

_description: _

###bool bDistanceSet

_inlined_description: _

_description: _

###bool bEnableMouseMiddleButton

_inlined_description: _

_description: _

###bool bEventsSet

_inlined_description: _

_description: _

###bool bInsideArcball

_inlined_description: _

_description: _

###bool bIsScrolling

_inlined_description: _

_description: _

###bool bMouseInputEnabled

_inlined_description: _

_description: _

###bool bRelativeYAxis

_inlined_description: _

_description: _

###ofRectangle controlArea

_inlined_description: _

If set, the area mouse control is bound to.

_description: _

###ofQuaternion curRot

_inlined_description: _

The current rotation quaternion.

_description: _

###ofEasyCam::TransformType currentTransformType

_inlined_description: _

_description: _

###bool doInertia

_inlined_description: _

_description: _

###char doTranslationKey

_inlined_description: _

The key used to differentiate between translation and rotation.

_description: _

###float drag

_inlined_description: _

_description: _

###ofCoreEvents * events

_inlined_description: _

_description: _

###int interactions

_inlined_description: _

_description: _

###float lastDistance

_inlined_description: _

_description: _

###int lastPressAxisX

_inlined_description: _

\name On Press cache { camera properties when the mouse is pressed.

_description: _

###int lastPressAxisY

_inlined_description: _

_description: _

###int lastPressAxisZ

_inlined_description: _

_description: _

###int lastPressMouse

_inlined_description: _

_description: _

###int lastPressOrientation

_inlined_description: _

_description: _

###int lastPressPosition

_inlined_description: _

_description: _

###unsigned long lastTap

_inlined_description: _

The time of the last pointer down event.

_description: _

###ofEventListeners listeners

_inlined_description: _

_description: _

###int mouseAtScroll

_inlined_description: _

_description: _

###ofVec2f mouseVel

_inlined_description: _

The mouse velocity (mouse position delta).

_description: _

###float prevFarClip

_inlined_description: _

previous far and near clip.

_description: _

###ofVec2f prevMouse

_inlined_description: _

The previous mouse position.

_description: _

###float prevNearClip

_inlined_description: _

previous far and near clip.

_description: _

###int rot

_inlined_description: _

rot and translated are used as a temporary values shared between the mouse callbacks and the update method. How much the camera needs to be rotated.

_description: _

###float sensitivityRot

_inlined_description: _

_description: _

###float sensitivityScroll

_inlined_description: _

_description: _

###int sensitivityTranslate

_inlined_description: _

Sensitivity These varibles determine how sensitive is the interaction. High values mean faster and bigger movements/rotations. Low Values mean more presicion.

_description: _

###ofNode target

_inlined_description: _

_description: _

###int translate

_inlined_description: _

How much the camera needs to be translated.

_description: _

###int upAxis

_inlined_description: _

_description: _

###ofRectangle viewport

_inlined_description: _

the current viewport.

_description: _