Tiny openFrameworks camera used in first person video games like in FPS genre.
Forks
Forks pushed to more recently than 010pe/ofxFirstPersonCamera itself, plus any admin-confirmed fork with commits of its own — worth checking if you're hitting issues with the original.
README
ofxFirstPersonCamera
Lightweight ofCamera class that replicates camera controls of first person video games. It uses mouse to look around, hides cursor on activation and has reassignable keys which by default set to
WASD for moving the camera, E and C to move camera up and down, Q and R to roll left and right and F to reset camera's up vector.Tested on Linux and Windows, should work on Mac as well.
Dependencies
1. OF 0.9.0 and C++11
Compiling
For openFrameworks:
See wiki
For CMake-based openFrameworks:
Add this repo as a git submodule to your ofApp folder and use
ofxaddon command in CMakeLists.txt.How to use
Include header file in
ofApp.h, add an instance of ofxFirstPersonCamera:#pragma once
include "ofMain.h"
include "ofxFirstPersonCamera.h"
class ofApp : public ofBaseApp
{
public:
void mousePressed(ofMouseEventArgs &mouse);
void draw();
ofxFirstPersonCamera cam;
};Enable first person camera control in
setup call and set computed matrix to any ofCamera:#include "ofApp.h"
void ofApp::mousePressed(ofMouseEventArgs &mouse)
{
cam.toggleControl();
}
void ofApp::draw()
{
cam.begin();
ofDrawGrid(10.0f, 10, true);
cam.end();
}
ofxAddons