ofEasyCam
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
addInteraction( ... )
void addInteraction(ofEasyCam::TransformType type, int mouseButton, int key)begin( ... )
void begin(const ofRectangle &viewport)} \name Rendering {
Begin using the camera, e.g.:
void draw() {
myCamera.begin();
ofDrawGrid();
//draw rest of scene
myCamera.end();
}
begin( )
void begin()clearControlArea( )
void clearControlArea()Clears the area bounds for mouse control so that the full viewport is used.
disableInertia( )
void disableInertia()disableMouseInput( )
void disableMouseInput()Disable mouse camera control.
disableMouseMiddleButton( )
void disableMouseMiddleButton()Disable the mouse's middle button for camera control.
enableInertia( )
void enableInertia()enableMouseInput( )
void enableMouseInput()Enable mouse camera control.
enableMouseMiddleButton( )
void enableMouseMiddleButton()Enable the mouse's middle button for camera control.
getControlArea( )
ofRectangle getControlArea()Returns the area bounds used for mouse control.
getDistance( )
float getDistance()Get the distance to the target.
Returns: the distance to the target.
getDrag( )
float getDrag()Get the camera's drag coefficient.
Returns: the camera's drag coefficient.
getInertiaEnabled( )
bool getInertiaEnabled()Determine if intertia is enabled.
getMouseInputEnabled( )
bool getMouseInputEnabled()Determine if mouse camera control is enabled. \todo Rename to isMouseInputEnabled().
Returns: true iff mouse camera control is enabled.
getMouseMiddleButtonEnabled( )
bool getMouseMiddleButtonEnabled()Determine if the middle mouse button is enabled. \todo Rename to isMouseMiddleButtonEnabled().
Returns: true iff the mouse's middle button is enabled.
getRelativeYAxis( )
bool getRelativeYAxis()Determine if the Y axis is set to be relative to the camera orientation
getTarget( )
const ofNode & getTarget()Get the camera's target node reference.
Returns: a reference the the camera's target node.
getTranslationKey( )
char getTranslationKey()Get the current translation key code.
Returns: the current translation key code.
getUpAxis( )
const glm::vec3 & getUpAxis()Get the up axis.
hasInteraction( ... )
bool hasInteraction(int mouseButton, int key)hasInteraction( ... )
bool hasInteraction(ofEasyCam::TransformType type, int mouseButton, int key)mousePressed( ... )
void mousePressed(ofMouseEventArgs &mouse)mouseReleased( ... )
void mouseReleased(ofMouseEventArgs &mouse)mouseScrolled( ... )
void mouseScrolled(ofMouseEventArgs &mouse)ofEasyCam( )
ofEasyCam()Create a default camera.
removeAllInteractions( )
void removeAllInteractions()removeInteraction( ... )
void removeInteraction(ofEasyCam::TransformType type, int mouseButton, int key)reset( )
void reset()Reset the camera position and orientation.
setAutoDistance( ... )
void 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:
bAutoDistance true to enable auto distance.
setControlArea( ... )
void setControlArea(const ofRectangle &controlArea)Set the area bounds for mouse control. Uses the full viewport by default.
setDistance( ... )
void setDistance(float distance)Set the camera's distance to the target.
Parameters:
distance The distance to the target.
setDistance( ... )
void setDistance(float distance, bool save)setDrag( ... )
void 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:
drag The normalized coefficient value between 0 and 1.
setEvents( ... )
void setEvents(ofCoreEvents &events)setRelativeYAxis( ... )
void 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( ... )
void setRotationSensitivity(const glm::vec3 &sensitivity)setRotationSensitivity( ... )
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.
Parameters:
value Scales the xyz axes rotation factor by these values.
setTarget( ... )
void setTarget(const glm::vec3 &target)Set the camera's target.
Parameters:
target The position of the target.
setTarget( ... )
void setTarget(ofNode &target)Set the camera's target.
Parameters:
target The position of the target.
setTranslationKey( ... )
void 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:
key The key code for the translation key. \todo char is not the right data type for this. Should be int.
setTranslationSensitivity( ... )
void setTranslationSensitivity(const glm::vec3 &sensitivity)setTranslationSensitivity( ... )
void setTranslationSensitivity(float x, float y, float z)Set the input sensitivity of the translation.
Parameters:
value Scales the xyz axes translation factor by these values.
setUpAxis( ... )
void setUpAxis(const glm::vec3 &up)Set the camera fixed up axis for interactive manipulation.
up( )
glm::vec3 up()Returns the up axis vector;
update( ... )
void update(ofEventArgs &args)updateMouse( ... )
void updateMouse(const glm::vec2 &mouse)updateRotation( )
void updateRotation()updateTranslation( )
void updateTranslation()