#include <ckviewpoint.h>
Public Types | |
enum | { nClip = 4 } |
Public Member Functions | |
CkViewpoint (const CkVector3d &E_, const CkVector3d &R_, CkVector3d Y_=CkVector3d(0, 1, 1.0e-8)) | |
Build a camera at eye point E pointing toward R, with up vector Y. | |
CkViewpoint (const CkVector3d &E_, const CkVector3d &R_, const CkVector3d &X_, const CkVector3d &Y_, int w, int h) | |
Build a camera at eye point E for view plane with origin R and X and Y as pixel sizes. | |
CkViewpoint (const CkVector3d &R_, const CkVector3d &X_, const CkVector3d &Y_, const CkVector3d &Z_, int w, int h, bool yesThisIsPerspective) | |
Build an orthogonal camera for a view plane with origin R and X and Y as pixel sizes, and the given Z axis. | |
void | disablePerspective (void) |
Make this perspective camera orthogonal-- turn off perspective. | |
void | discretize (int w, int h, double hFOV) |
Make this camera, fresh-built with the above constructor, have this X and Y resolution and horizontal full field-of-view (degrees). | |
void | discretizeFlip (int w, int h, double hFOV) |
Like discretize, but flips the Y axis (for typical raster viewing). | |
void | flip (void) |
Flip the image's Y axis (for typical raster viewing). | |
void | window (int w, int h, int x, int y) |
Extract a window with this width and height, with origin at this pixel. | |
CkViewpoint () | |
For use by pup:. | |
const CkVector3d & | getEye (void) const |
Return the center of projection (eye point). | |
bool | isOrthographic (void) const |
Return true if this is an orthographic (perspective-free) camera. | |
const CkVector3d & | getOrigin (void) const |
Return the projection plane origin (View Reference Point). | |
const CkVector3d & | getX (void) const |
Return the projection plane pixel-length X axis. | |
const CkVector3d & | getY (void) const |
Return the projection plane pixel-length Y axis (View Up Vector). | |
const CkVector3d & | getZ (void) const |
Return the z-unit-length Z axis (from reference towards camera). | |
int | getXsize (void) const |
Return the number of pixels in the X direction. | |
int | getWidth (void) const |
int | getYsize (void) const |
Return the number of pixels in the Y direction. | |
int | getHeight (void) const |
const CkMatrix3d & | getMatrix (void) const |
Return the 4x4 projection matrix. | |
CkVector3d | project (const CkVector3d &in) const |
Project this point into the camera volume. | |
CkHalfspace3d | getClip (int i) const |
Get our i'th clipping plane. | |
bool | allOffscreen (int n, const CkVector3d *p) const |
Return true if any convex combination of these points is still offscreen. | |
CkVector2d | project_noz (const CkVector3d &in) const |
Project this point onto the screen, returning zero for the z axis. | |
void | project_noz (const float *in, int *x, int *y) const |
CkVector3d | viewplane (const CkVector2d &v) const |
Backproject this view plane point into world coordinates. | |
CkVector3d | projectViewplane (const CkVector3d &u) const |
Project, the back-project this universe point:. | |
CkRay | getRay (const CkVector3d &univ) const |
CkRay | getPixelRay (const CkVector2d &screen) const |
CkVector3d | toCamera (const CkVector3d &pt) const |
Get a universe-coords vector pointing to the camera from this point. | |
bool | isInbounds (const CkVector2d &screen) const |
void | clip (CkVector2d &screen) const |
void | makeOpenGL (double *dest, double z_near, double z_far) const |
void | pup (PUP::er &p) |
Private Member Functions | |
void | buildM (void) |
Fill our projection matrix m with values from E, R, X, Y, Z. | |
Private Attributes | |
float | projX [4] |
float | projY [4] |
float | projZ [4] |
float | projW [4] |
CkVector3d | E |
CkVector3d | R |
CkVector3d | X |
CkVector3d | Y |
CkVector3d | Z |
CkMatrix3d | m |
int | wid |
int | ht |
bool | isPerspective |
Definition at line 110 of file ckviewpoint.h.
anonymous enum |
CkViewpoint::CkViewpoint | ( | const CkVector3d & | E_, | |
const CkVector3d & | R_, | |||
CkVector3d | Y_ = CkVector3d(0, 1, 1.0e-8) | |||
) |
Build a camera at eye point E pointing toward R, with up vector Y.
The up vector is not allowed to be parallel to E-R. This is an easy-to-use, but restricted (no off-axis) routine. It is normally followed by discretize or discretizeFlip.
CkViewpoint::CkViewpoint | ( | const CkVector3d & | E_, | |
const CkVector3d & | R_, | |||
const CkVector3d & | X_, | |||
const CkVector3d & | Y_, | |||
int | w, | |||
int | h | |||
) |
Build a camera at eye point E for view plane with origin R and X and Y as pixel sizes.
CkViewpoint::CkViewpoint | ( | const CkVector3d & | R_, | |
const CkVector3d & | X_, | |||
const CkVector3d & | Y_, | |||
const CkVector3d & | Z_, | |||
int | w, | |||
int | h, | |||
bool | yesThisIsPerspective | |||
) |
Build an orthogonal camera for a view plane with origin R and X and Y as pixel sizes, and the given Z axis.
For a parallel-projection camera (yesThisIsPerspective==false) and project(R_+x*X_+y*Y_+z*Z_) = (x,y,z)
CkViewpoint::CkViewpoint | ( | ) | [inline] |
void CkViewpoint::buildM | ( | void | ) | [private] |
Fill our projection matrix m with values from E, R, X, Y, Z.
void CkViewpoint::disablePerspective | ( | void | ) |
Make this perspective camera orthogonal-- turn off perspective.
Make this camera, fresh-built with the above constructor, have this X and Y resolution and horizontal full field-of-view (degrees).
This routine rescales X and Y to have the appropriate length for the field of view, and shifts the projection origin by (-w/2,-h/2).
Like discretize, but flips the Y axis (for typical raster viewing).
void CkViewpoint::flip | ( | void | ) |
Flip the image's Y axis (for typical raster viewing).
Extract a window with this width and height, with origin at this pixel.
const CkVector3d& CkViewpoint::getEye | ( | void | ) | const [inline] |
Return the center of projection (eye point).
Definition at line 169 of file ckviewpoint.h.
References E.
Referenced by getPixelRay(), getRay(), and toCamera().
bool CkViewpoint::isOrthographic | ( | void | ) | const [inline] |
Return true if this is an orthographic (perspective-free) camera.
Definition at line 171 of file ckviewpoint.h.
References isPerspective.
const CkVector3d& CkViewpoint::getOrigin | ( | void | ) | const [inline] |
Return the projection plane origin (View Reference Point).
Definition at line 174 of file ckviewpoint.h.
References R.
const CkVector3d& CkViewpoint::getX | ( | void | ) | const [inline] |
Return the projection plane pixel-length X axis.
Definition at line 176 of file ckviewpoint.h.
References X.
const CkVector3d& CkViewpoint::getY | ( | void | ) | const [inline] |
Return the projection plane pixel-length Y axis (View Up Vector).
Definition at line 178 of file ckviewpoint.h.
References Y.
const CkVector3d& CkViewpoint::getZ | ( | void | ) | const [inline] |
Return the z-unit-length Z axis (from reference towards camera).
Definition at line 180 of file ckviewpoint.h.
References Z.
int CkViewpoint::getXsize | ( | void | ) | const [inline] |
Return the number of pixels in the X direction.
Definition at line 183 of file ckviewpoint.h.
References wid.
int CkViewpoint::getWidth | ( | void | ) | const [inline] |
int CkViewpoint::getYsize | ( | void | ) | const [inline] |
Return the number of pixels in the Y direction.
Definition at line 186 of file ckviewpoint.h.
References ht.
int CkViewpoint::getHeight | ( | void | ) | const [inline] |
const CkMatrix3d& CkViewpoint::getMatrix | ( | void | ) | const [inline] |
Return the 4x4 projection matrix.
This is a column-wise matrix, meaning the translation portion is the rightmost column.
Definition at line 191 of file ckviewpoint.h.
References m.
CkVector3d CkViewpoint::project | ( | const CkVector3d & | in | ) | const [inline] |
Project this point into the camera volume.
The projected screen point is (return.x,return.y);
return.z is 1.0/depth: +inf at the eye to 1 at the projection plane. This is the "perspective scale value"; the screen size multiplier needed because of perspective.
Definition at line 199 of file ckviewpoint.h.
References float, m, PUP::w, CkVector3dT< real >::x, CkVector3dT< real >::y, and CkVector3dT< real >::z.
Referenced by impl_LV3D_Array::LV3D_FlatRender().
CkHalfspace3d CkViewpoint::getClip | ( | int | i | ) | const |
Get our i'th clipping plane.
0 and 1 are the left and right horizontal clip planes. 2 and 3 are the top and bottom vertical clip planes.
Referenced by allOffscreen().
bool CkViewpoint::allOffscreen | ( | int | n, | |
const CkVector3d * | p | |||
) | const [inline] |
Return true if any convex combination of these points is still offscreen.
Definition at line 218 of file ckviewpoint.h.
References c, getClip(), h, nClip, and CkHalfspace3d::side().
CkVector2d CkViewpoint::project_noz | ( | const CkVector3d & | in | ) | const [inline] |
Project this point onto the screen, returning zero for the z axis.
Definition at line 232 of file ckviewpoint.h.
References float, m, PUP::w, CkVector3dT< real >::x, CkVector3dT< real >::y, and CkVector3dT< real >::z.
Referenced by projectViewplane(), and PUPmarshall().
Definition at line 243 of file ckviewpoint.h.
References _ck_SSE_dot(), projW, projX, projY, and PUP::w.
CkVector3d CkViewpoint::viewplane | ( | const CkVector2d & | v | ) | const [inline] |
Backproject this view plane point into world coordinates.
Definition at line 269 of file ckviewpoint.h.
References R, X, CkVector3dT< real >::x, Y, and CkVector3dT< real >::y.
Referenced by getPixelRay(), and projectViewplane().
CkVector3d CkViewpoint::projectViewplane | ( | const CkVector3d & | u | ) | const [inline] |
Project, the back-project this universe point:.
Definition at line 273 of file ckviewpoint.h.
References project_noz(), and viewplane().
CkRay CkViewpoint::getRay | ( | const CkVector3d & | univ | ) | const [inline] |
Definition at line 278 of file ckviewpoint.h.
References getEye().
CkRay CkViewpoint::getPixelRay | ( | const CkVector2d & | screen | ) | const [inline] |
Definition at line 282 of file ckviewpoint.h.
References getEye(), isPerspective, viewplane(), and Z.
CkVector3d CkViewpoint::toCamera | ( | const CkVector3d & | pt | ) | const [inline] |
Get a universe-coords vector pointing to the camera from this point.
Definition at line 289 of file ckviewpoint.h.
References getEye(), isPerspective, and Z.
bool CkViewpoint::isInbounds | ( | const CkVector2d & | screen | ) | const [inline] |
Definition at line 297 of file ckviewpoint.h.
References ht, wid, CkVector3dT< real >::x, and CkVector3dT< real >::y.
void CkViewpoint::clip | ( | CkVector2d & | screen | ) | const [inline] |
Definition at line 302 of file ckviewpoint.h.
References ht, wid, CkVector3dT< real >::x, and CkVector3dT< real >::y.
void CkViewpoint::makeOpenGL | ( | double * | dest, | |
double | z_near, | |||
double | z_far | |||
) | const |
void CkViewpoint::pup | ( | PUP::er & | p | ) |
float CkViewpoint::projX[4] [private] |
float CkViewpoint::projY[4] [private] |
float CkViewpoint::projZ[4] [private] |
Definition at line 112 of file ckviewpoint.h.
float CkViewpoint::projW[4] [private] |
CkVector3d CkViewpoint::E [private] |
CkVector3d CkViewpoint::R [private] |
CkVector3d CkViewpoint::X [private] |
CkVector3d CkViewpoint::Y [private] |
CkVector3d CkViewpoint::Z [private] |
CkMatrix3d CkViewpoint::m [private] |
Definition at line 118 of file ckviewpoint.h.
Referenced by getMatrix(), project(), and project_noz().
int CkViewpoint::wid [private] |
Definition at line 119 of file ckviewpoint.h.
Referenced by CkViewpoint(), clip(), getWidth(), getXsize(), and isInbounds().
int CkViewpoint::ht [private] |
Definition at line 119 of file ckviewpoint.h.
Referenced by CkViewpoint(), clip(), getHeight(), getYsize(), and isInbounds().
bool CkViewpoint::isPerspective [private] |
Definition at line 121 of file ckviewpoint.h.
Referenced by getPixelRay(), isOrthographic(), and toCamera().