Skip to content

Commit

Permalink
rough ofCamera
Browse files Browse the repository at this point in the history
  • Loading branch information
base committed Nov 15, 2011
1 parent dc68d7f commit 041da34
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
56 changes: 56 additions & 0 deletions 3d/ofCamera.markdown
@@ -0,0 +1,56 @@
## ofCamera() ##

ofCamera provides a camera onto a 3D scene. Some of the different properties of the camera are shown in the picture below:

![FOV](/fov.gif)

### void setFov(float f) ###
Here you can set the field of view of the camera.

### void setNearClip(float f) ###
This sets the near clip plane.

### void setFarClip(float f) ###
Sets the far clip plane

### void enableOrtho() ###
Orthographic, or parallel, projections consist of those that involve no perspective correction. There is no adjustment for distance from the camera made in these projections, meaning objects on the screen will appear the same size no matter how close or far away they are. Calling enableOrtho() sets the ofCamera to orthographic mode.

### void disableOrtho() ###
Calling disableOrtho() turns off the orthographic mode.

### bool getOrtho() const ###
Get whether the camera is in orthographic mode.

### float getImagePlaneDistance([ofRectangle](types/ofRectangle.htm) viewport = ofGetCurrentViewport()) const ###
This allows you to get the image plane distance from any viewport passed in. By default this is the current viewport, but it can be whatever you find useful.

### virtual void begin([ofRectangle](types/ofRectangle.htm) viewport = ofGetCurrentViewport()) ###
set the matrices that the camera will use.

### virtual void end() ###
set the matrices

### void cacheMatrices(bool cache=true) ###
This caches the projection matrix for the ofCamera.

### ofMatrix4x4 getProjectionMatrix(ofRectangle viewport = ofGetCurrentViewport()) ###
Access to the projection matrix.

### ofMatrix4x4 getModelViewMatrix() ###
Access to the projection matrix.

### ofMatrix4x4 getModelViewProjectionMatrix(ofRectangle viewport = ofGetCurrentViewport()) ###
Access to the projection ModelViewProjectionMatrix.

### ofVec3f worldToScreen(ofVec3f WorldXYZ, ofRectangle viewport = ofGetCurrentViewport()) ###
When you have a position in world coordinates you can get what it would be in world coordinates, transforming it using the ofCamera.

### ofVec3f screenToWorld(ofVec3f ScreenXYZ, ofRectangle viewport = ofGetCurrentViewport()) ###
When you have a position in screen coordinates you can get what it would be in world coordinates, transforming it using the ofCamera.

### ofVec3f worldToCamera(ofVec3f WorldXYZ, ofRectangle viewport = ofGetCurrentViewport()) ###
When you have a position in world coordinates you can get what it would be in camera coordinates, transforming it using the ofCamera.

### ofVec3f cameraToWorld(ofVec3f CameraXYZ, ofRectangle viewport = ofGetCurrentViewport()) ###
When you have a position in camera coordinates you can get what it would be in world coordinates, transforming it using the ofCamera.
2 changes: 1 addition & 1 deletion gl/ofFbo.markdown
@@ -1,7 +1,7 @@

## ofFbo ##

ofFbo is an essay way to work with Frame Buffer Objects or fobs, which allow you to easily do off-screen rendering, very convenient for doing image filters or post-processing effects.
ofFbo is an easy way to work with Frame Buffer Objects or fobs, which allow you to easily do off-screen rendering, very convenient for doing image filters or post-processing effects.

As an example, with an fbo you can do some drawing to the fbo (instead of to the screen or a texture) and then do some blurring, maybe invert the colors, combine multiple images, all without needing to draw it to the screen until you're ready.

Expand Down
16 changes: 15 additions & 1 deletion gl/ofTexture.markdown
Expand Up @@ -51,6 +51,20 @@ Clears all the data from the texture
### void loadData(float* data, int w, int h, int glFormat) ###
Loads raw data from an array. Make sure to se the pixel type in the glFormat correctly.

Loads into the texture the array of unsigned chars (data), with a given width (w) and height (h). You also pass in the format that the data is stored in (some options: GL_LUMINANCE, GL_RGB, GL_RGBA). For example, to upload a 200*100 pixel RGB array into an already allocated texture:


unsigned char pixels[200*100];

for (int i = 0; i < 200*100; i++){

pixels[i] = (int)(255 * ofRandomuf());

}

myTexture.loadData(pixels, 200, 100, GL_RGB);


### void loadData(unsigned char* data, int w, int h, int glFormat) ###
Loads raw data from an array. Make sure to se the pixel type in the glFormat correctly.

Expand All @@ -67,7 +81,7 @@ Loads raw data from an ofPixels object.
Loads raw data from an ofPixels object.

### void loadScreenData(int x, int y, int w, int h) ###
Load data from the current screen into this texture.
Load data from the current screen into this texture. Grabs a region of the screen and loads it into the texture. Specifiy the position (x,y) you wish to grab from, with the width (w) and height (h) of the region. Make sure that you have allocated your texture (using allocate()) to be large enough to hold the region of the screen you wish to load.

### void setAnchorPercent(float xPct, float yPct) ###

Expand Down

0 comments on commit 041da34

Please sign in to comment.