48 VL_DEBUG_SET_OBJECT_NAME()
69 glMatrixMode(GL_MODELVIEW);
71 VL_glLoadMatrix( viewm.
ptr() );
72 VL_glMultMatrix( matrix.ptr() );
74 viewm = viewm * matrix;
75 VL_glLoadMatrix( viewm.ptr() );
77 VL_glLoadMatrix( (viewm * model_matrix).ptr() );
84 glMatrixMode( GL_PROJECTION );
96 glMatrixMode(GL_MODELVIEW);
97 VL_glLoadMatrix( viewm.
ptr() );
103 if (!scene_bounding_sphere.
isNull())
114 real epsilon = camera_sphere.
radius() / 1000.0f;
130 Log::bug(
"Camera::computeNearFarOptimizedProjMatrix() called on unsupported projection type.\n");
140 vl::Log::bug(
"Camera::adjustView(): 'bias' must be >= 0.\n");
147 const real R = sphere.
radius();
155 for(
int i=0; i<4; ++i)
159 real dot_n_v =
dot(N,V);
162 real t = - (R +
dot(O,N) -
dot(C,N)) / dot_n_v;
260 out.
x() = out.
x() * 0.5f + 0.5f;
261 out.
y() = out.
y() * 0.5f + 0.5f;
262 out.
z() = out.
z() * 0.5f + 0.5f;
283 v.
x() = v.
x() * 2.0f - 1.0f;
284 v.
y() = v.
y() * 2.0f - 1.0f;
285 v.
z() = v.
z() * 2.0f - 1.0f;
308 for(
unsigned i=0; i<win.size(); ++i)
311 v =
vec4( win[i], 1.0 );
318 v.
x() = v.
x() * 2.0f - 1.0f;
319 v.
y() = v.
y() * 2.0f - 1.0f;
320 v.
z() = v.
z() * 2.0f - 1.0f;
378 frustum.planes().push_back(
Plane( B1.
xyz(), n2 ) );
379 frustum.planes().push_back(
Plane( C1.
xyz(), n3 ) );
380 frustum.planes().push_back(
Plane( D1.
xyz(), n4 ) );
EProjectionMatrixType projectionMatrixType() const
The Camera's projection matrix type.
void setNearPlane(real nearplane)
The near clipping plane.
const T_Scalar & z() const
VLCORE_EXPORT void extractPlanes(Plane *planes, const mat4 &modelviewproj)
Extracts the 6 frustum planes for the given model-view-projection matrix.
const mat4 & viewMatrix() const
Returns the Camera's view matrix (inverse of the modeling matrix).
const T_Scalar & e(int i, int j) const
const T_Scalar & x() const
Vector3< T_Scalar > getZ() const
Projection matrix generated by mat4::getPerspective() or similar.
static Matrix4 getPerspective(float fovy, float aspect_ratio, float znear, float zfar)
The Ray class defines a ray as an origin and direction using real precision.
The Plane class defines a plane using a normal and an origin.
bool isNull() const
Returns true if the AABB is null.
ref< Viewport > mViewport
Ray computeRay(int viewp_x, int viewp_y)
Computes the ray passing through the point <viewp_x,viewp_y>.
A set of planes defining a frustum used for culling purposes (frustum culling).
const T_Scalar & z() const
std::vector< Plane > & planes()
void getViewMatrixAsLookAt(vec3 &eye, vec3 &at, vec3 &up, vec3 &right) const
Returns the look-at parameters of the modelview transform.
void adjustView(const AABB &aabb, const vec3 &dir, const vec3 &up, real bias=1.0f)
Adjusts the camera position so that the given aabb can be properly viewed.
void setProjectionPerspective()
Builds a perspective projection matrix for the Camera based on the Camera's and Viewport's settings...
const vec3 & center() const
Returns the center of the sphere.
Frustum computeRayFrustum(int viewp_x, int viewp_y)
Computes a 1 pixel wide frustum suitable to cull objects during ray intersection detection.
void setFarPlane(real farplane)
The far clipping plane.
Vector3< T_Scalar > xyz() const
const Plane & plane(unsigned i) const
vec3 center() const
Returns the center of the AABB.
static Matrix4 getOrtho(float pleft, float pright, float pbottom, float ptop, float pnear, float pfar)
real left() const
'left' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() ...
real nearPlane() const
The near clipping plane.
fvec3 cross(const fvec3 &v1, const fvec3 &v2)
void applyViewMatrix() const
Loads the GL_MODELVIEW matrix with the Camera's view matrix.
EProjectionMatrixType mProjectionType
Viewport * viewport()
The viewport bound to a camera.
Visualization Library main namespace.
Projection matrix generated by mat4::getFrustum() or similar.
real radius() const
Returns the radius of the sphere.
bool unproject(const vec3 &in_viewp, vec4 &out_world) const
Unprojects a vector from viewport coordinates to world coordinates.
float dot(float a, float b)
const Frustum & frustum() const
The view frustum of the camera used to perform frustum culling.
bool project(const vec4 &in_world, vec4 &out_viewp) const
Projects a vector from world coordinates to viewport coordinates.
void computeFrustumPlanes()
Computes the Camera's frustum planes in world space.
void computeNearFarOptimizedProjMatrix(const Sphere &scene_bounding_sphere)
The near and far clipping planes are adjusted to fit the provided scene_bounding_sphere.
static void bug(const String &message)
Use this function to provide information about programming errors: wrong parameter initialization...
real fov() const
The field of view of the camera.
The AABB class implements an axis-aligned bounding box using vl::real precision.
real top() const
'top' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() ...
Projection matrix generated by mat4::getOrtho() or similar.
float max(float a, float b)
const mat4 & modelingMatrix() const
Returns the Camera's modelingMatrix() (inverse of the view matrix).
const T_Scalar & y() const
Implements the viewport and clearing settings associated to a Camera.
real farPlane() const
The far clipping plane.
real bottom() const
'bottom' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() ...
const T_Scalar & y() const
void setProjectionMatrix(const mat4 &mat, EProjectionMatrixType proj_type)
The Camera's projection matrix.
void setOrigin(const vec3 &orig)
void setViewMatrixLookAt(const vec3 &eye, const vec3 &at, const vec3 &up)
Setup the modelview transform of the camera based on look-at parameters.
void setViewMatrix(const mat4 &mat)
Sets the Camera's view matrix (inverse of the modeling matrix).
The Sphere class defines a sphere using a center and a radius using vl::real precision.
void applyProjMatrix() const
Loads the GL_PROJECTION matrix with the Camera's projection matrix.
void setDirection(const vec3 &dir)
Vector3< T_Scalar > getT() const
static Matrix4 getFrustum(float pleft, float pright, float pbottom, float ptop, float pnear, float pfar)
const vec3 & normal() const
void setProjectionFrustum(real left, real right, real bottom, real top, real znear, real zfar)
Produces a perspective projection matrix.
void applyModelViewMatrix(const mat4 &model_matrix) const
Loads the GL_MODELVIEW matrix with the Camera's view matrix multiplied by the specified model matrix...
void getAsLookAtModeling(Vector3< T_Scalar > &eye, Vector3< T_Scalar > &at, Vector3< T_Scalar > &up, Vector3< T_Scalar > &right) const
void setProjectionOrtho()
Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its...
const mat4 & projectionMatrix() const
The Camera's projection matrix.
const T_Scalar & x() const
real right() const
'right' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() ...
void setFOV(real fov)
The field of view of the camera.
real aspectRatio() const
Returns the aspect ratio computed as viewport()->width()/viewport()->height().
void transformed(Sphere &out, const mat4 &mat) const
Returns a sphere that contains the original sphere transformed by the given matrix.
fvec4 vec4
Defined as: 'typedef fvec4 vec4'. See also VL_PIPELINE_PRECISION.
bool isNull() const
Returns true if the sphere is null, ie, if radius is < 0.
static Matrix4 getLookAt(const Vector3< float > &eye, const Vector3< float > &at, const Vector3< float > &up)
Camera()
Constructs a perspective projecting camera with FOV = 60.0, Near Plane = 0.05, Far Plane = 10000...
const T_Scalar & w() const