Panda3D
Public Member Functions | Static Public Member Functions | List of all members
CylindricalLens Class Reference

A cylindrical lens. This is the kind of lens generally used for extremely wide panoramic shots. It behaves like a normal perspective lens in the vertical direction, but it is non-linear in the horizontal dimension: a point on the film corresponds to a point in space in linear proportion to its angle to the camera, not to its straight-line distance from the center. More...

Inheritance diagram for CylindricalLens:
Lens TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

Public Member Functions

 __init__ ()
 
- Public Member Functions inherited from Lens
 clear ()
 Resets all lens parameters to their initial default settings. More...
 
 clearCustomFilmMat ()
 Disables the lens custom_film_mat correction. More...
 
 clearKeystone ()
 Disables the lens keystone correction. More...
 
 clearViewMat ()
 Resets the lens transform to identity. More...
 
bool extrude (const LPoint2 point2d, LPoint3 near_point, LPoint3 far_point)
 Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the corresponding vector in space that maps to this point, if such a vector can be determined. The vector is returned by indicating the points on the near plane and far plane that both map to the indicated 2-d point. More...
 
bool extrude (const LPoint3 point2d, LPoint3 near_point, LPoint3 far_point)
 Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the corresponding vector in space that maps to this point, if such a vector can be determined. The vector is returned by indicating the points on the near plane and far plane that both map to the indicated 2-d point. More...
 
bool extrudeDepth (const LPoint3 point2d, LPoint3 point3d)
 Uses the depth component of the 3-d result from project() to compute the original point in 3-d space corresponding to a particular point on the lens. This exactly reverses project(), assuming the point does fall legitimately within the lens. More...
 
bool extrudeVec (const LPoint2 point2d, LVector3 vec3d)
 Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the vector that corresponds to the view direction. This will be parallel to the normal on the surface (the far plane) corresponding to the lens shape at this point. More...
 
bool extrudeVec (const LPoint3 point2d, LVector3 vec3d)
 Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the vector that corresponds to the view direction. This will be parallel to the normal on the surface (the far plane) corresponding to the lens shape at this point. More...
 
float getAspectRatio ()
 Returns the aspect ratio of the Lens. This is determined based on the indicated film size; see set_film_size(). More...
 
str getChangeEvent ()
 Returns the name of the event that will be generated whenever any properties of this particular Lens have changed. More...
 
float getConvergenceDistance ()
 See set_convergence_distance(). More...
 
CoordinateSystem getCoordinateSystem ()
 Returns the coordinate system that all 3-d computations are performed within for this Lens. Normally, this is CS_default. More...
 
const LMatrix4 getCustomFilmMat ()
 Returns the custom_film_mat specified for the lens. More...
 
float getFar ()
 Returns the position of the far plane (or cylinder, sphere, whatever). More...
 
const LMatrix4 getFilmMat ()
 Returns the matrix that transforms from a point behind the lens to a point on the film. More...
 
const LMatrix4 getFilmMatInv ()
 Returns the matrix that transforms from a point on the film to a point behind the lens. More...
 
const LVector2 getFilmOffset ()
 Returns the horizontal and vertical offset amounts of this Lens. See set_film_offset(). More...
 
const LVecBase2 getFilmSize ()
 Returns the horizontal and vertical film size of the virtual film. See set_film_size(). More...
 
float getFocalLength ()
 Returns the focal length of the lens. This may have been set explicitly by a previous call to set_focal_length(), or it may be computed based on the lens' fov and film_size. For certain kinds of lenses, the focal length has no meaning. More...
 
const LVecBase2 getFov ()
 Returns the horizontal and vertical film size of the virtual film. See set_fov(). More...
 
float getHfov ()
 Returns the horizontal component of fov only. See get_fov(). More...
 
float getInterocularDistance ()
 See set_interocular_distance(). More...
 
const LVecBase2 getKeystone ()
 Returns the keystone correction specified for the lens. More...
 
UpdateSeq getLastChange ()
 Returns the UpdateSeq that is incremented whenever the lens properties are changed. As long as this number remains the same, you may assume the lens properties are unchanged. More...
 
const LMatrix4 getLensMat ()
 Returns the matrix that transforms from a point in front of the lens to a point in space. More...
 
const LMatrix4 getLensMatInv ()
 Returns the matrix that transforms from a point in space to a point in front of the lens. More...
 
float getMinFov ()
 Returns the field of view of the narrowest dimension of the window. See set_min_fov(). More...
 
float getNear ()
 Returns the position of the near plane (or cylinder, sphere, whatever). More...
 
LPoint3 getNodalPoint ()
 Returns the center point of the lens: the point from which the lens is viewing. More...
 
const LMatrix4 getProjectionMat (Lens::StereoChannel channel)
 Returns the complete transformation matrix from a 3-d point in space to a point on the film, if such a matrix exists, or the identity matrix if the lens is nonlinear. More...
 
const LMatrix4 getProjectionMatInv (Lens::StereoChannel channel)
 Returns the matrix that transforms from a 2-d point on the film to a 3-d vector in space, if such a matrix exists. More...
 
const LVector3 getUpVector ()
 Returns the axis perpendicular to the camera's view vector that indicates the "up" direction. More...
 
float getVfov ()
 Returns the vertical component of fov only. See get_fov(). More...
 
const LVecBase3 getViewHpr ()
 Returns the direction in which the lens is facing. More...
 
const LMatrix4 getViewMat ()
 Returns the direction in which the lens is facing. More...
 
const LVector3 getViewVector ()
 Returns the axis along which the lens is facing. More...
 
bool isLinear ()
 Returns true if the lens represents a linear projection (e.g. PerspectiveLens, OrthographicLens), and therefore there is a valid matrix returned by get_projection_mat(), or false otherwise. More...
 
bool isOrthographic ()
 Returns true if the lens represents a orthographic projection (i.e. it is a OrthographicLens), false otherwise. More...
 
bool isPerspective ()
 Returns true if the lens represents a perspective projection (i.e. it is a PerspectiveLens), false otherwise. More...
 
BoundingVolume makeBounds ()
 Allocates and returns a new BoundingVolume that encloses the frustum used for this kind of lens, if possible. If a suitable bounding volume cannot be created, returns NULL. More...
 
Lens makeCopy ()
 
Geom makeGeometry ()
 Allocates and returns a new Geom that can be rendered to show a visible representation of the frustum used for this kind of lens, if it makes sense to do so. If a visible representation cannot be created, returns NULL. More...
 
 output (Ostream out)
 
bool project (const LPoint3 point3d, LPoint2 point2d)
 Given a 3-d point in space, determine the 2-d point this maps to, in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner. More...
 
bool project (const LPoint3 point3d, LPoint3 point2d)
 Given a 3-d point in space, determine the 2-d point this maps to, in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner. More...
 
 recomputeAll ()
 Forces all internal parameters of the Lens to be recomputed. Normally, this should never need to be called; it is provided only to assist in debugging. More...
 
 setAspectRatio (float aspect_ratio)
 Sets the aspect ratio of the lens. This is the ratio of the height to the width of the generated image. Setting this overrides the two-parameter fov or film size setting. More...
 
 setChangeEvent (str event)
 Sets the name of the event that will be generated whenever any properties of the Lens have changed. If this is not set for a particular lens, no event will be generated. More...
 
 setConvergenceDistance (float convergence_distance)
 Sets the distance between between the camera plane and the point in the distance that the left and right eyes are both looking at. This distance is used to apply a stereo effect when the lens is rendered on a stereo display region. It only has an effect on a PerspectiveLens. More...
 
 setCoordinateSystem (CoordinateSystem cs)
 Specifies the coordinate system that all 3-d computations are performed within for this Lens. Normally, this is CS_default. More...
 
 setCustomFilmMat (const LMatrix4 custom_film_mat)
 Specifies a custom matrix to transform the points on the film after they have been converted into nominal film space (-1 .. 1 in U and V). This can be used to introduce arbitrary scales, rotations, or other linear transforms to the media plane. This is normally a 2-d matrix, but a full 4x4 matrix may be specified. This is applied on top of any film size, lens shift, and/or keystone correction. More...
 
 setFar (float far_distance)
 Defines the position of the far plane (or cylinder, sphere, whatever). Points farther from the lens than this may not be rendered. More...
 
 setFilmOffset (const LVecBase2 film_offset)
 Sets the horizontal and vertical offset amounts of this Lens. These are both in the same units specified in set_film_size(). More...
 
 setFilmOffset (float x, float y)
 Sets the horizontal and vertical offset amounts of this Lens. These are both in the same units specified in set_film_size(). More...
 
 setFilmSize (const LVecBase2 film_size)
 Sets the size and shape of the "film" within the lens. This both establishes the units used by calls like set_focal_length(), and establishes the aspect ratio of the frame. More...
 
 setFilmSize (float width)
 Sets the horizontal size of the film without changing its shape. The aspect ratio remains unchanged; this computes the vertical size of the film to automatically maintain the aspect ratio. More...
 
 setFilmSize (float width, float height)
 Sets the size and shape of the "film" within the lens. This both establishes the units used by calls like set_focal_length(), and establishes the aspect ratio of the frame. More...
 
 setFocalLength (float focal_length)
 Sets the focal length of the lens. This may adjust the field-of-view correspondingly, and is an alternate way to specify field of view. More...
 
 setFov (const LVecBase2 fov)
 Sets the field of view of the lens in both dimensions. This establishes both the field of view and the aspect ratio of the lens. This is one way to specify the field of view of a lens; set_focal_length() is another way. More...
 
 setFov (float fov)
 Sets the horizontal field of view of the lens without changing the aspect ratio. The vertical field of view is adjusted to maintain the same aspect ratio. More...
 
 setFov (float hfov, float vfov)
 Sets the field of view of the lens in both dimensions. This establishes both the field of view and the aspect ratio of the lens. This is one way to specify the field of view of a lens; set_focal_length() is another way. More...
 
 setFrustumFromCorners (const LVecBase3 ul, const LVecBase3 ur, const LVecBase3 ll, const LVecBase3 lr, int flags)
 Sets up the lens to use the frustum defined by the four indicated points. This is most useful for a PerspectiveLens, but it may be called for other kinds of lenses as well. More...
 
 setInterocularDistance (float interocular_distance)
 Sets the distance between the left and right eyes of a stereo camera. This distance is used to apply a stereo effect when the lens is rendered on a stereo display region. It only has an effect on a PerspectiveLens. More...
 
 setKeystone (const LVecBase2 keystone)
 Indicates the ratio of keystone correction to perform on the lens, in each of three axes. This will build a special non-affine scale factor into the projection matrix that will compensate for keystoning of a projected image; this can be used to compensate for a projector that for physical reasons cannot be aimed directly at its screen. More...
 
 setMinFov (float min_fov)
 Sets the field of view of the smallest dimension of the window. If the window is wider than it is tall, this specifies the vertical field of view; if it is taller than it is wide, this specifies the horizontal field of view. More...
 
 setNear (float near_distance)
 Defines the position of the near plane (or cylinder, sphere, whatever). Points closer to the lens than this may not be rendered. More...
 
 setNearFar (float near_distance, float far_distance)
 Simultaneously changes the near and far planes. More...
 
 setViewHpr (const LVecBase3 view_hpr)
 Sets the direction in which the lens is facing. Normally, this is down the forward axis (usually the Y axis), but it may be rotated. This is only one way of specifying the rotation; you may also specify an explicit vector in which to look, or you may give a complete transformation matrix. More...
 
 setViewHpr (float h, float p, float r)
 Sets the direction in which the lens is facing. Normally, this is down the forward axis (usually the Y axis), but it may be rotated. This is only one way of specifying the rotation; you may also specify an explicit vector in which to look, or you may give a complete transformation matrix. More...
 
 setViewMat (const LMatrix4 view_mat)
 Sets an arbitrary transformation on the lens. This replaces the individual transformation components like set_view_hpr(). More...
 
 setViewVector (const LVector3 view_vector, const LVector3 up_vector)
 Specifies the direction in which the lens is facing by giving an axis to look along, and a perpendicular (or at least non-parallel) up axis. More...
 
 setViewVector (float x, float y, float z, float i, float j, float k)
 Specifies the direction in which the lens is facing by giving an axis to look along, and a perpendicular (or at least non-parallel) up axis. More...
 
 write (Ostream out, int indent_level)
 
- Public Member Functions inherited from TypedWritable
object __reduce__ ()
 
object __reduce_persist__ (object pickler)
 
str encodeToBamStream ()
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string. Returns empty string on failure. More...
 
bool encodeToBamStream (String data, BamWriter writer)
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. Returns true on success, false on failure. More...
 
UpdateSeq getBamModified ()
 Returns the current bam_modified counter. This counter is normally incremented automatically whenever the object is modified. More...
 
 markBamModified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. This should normally not need to be called by user code; it should be called internally when the object has been changed in a way that legitimately requires its retransmission to any connected clients. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 Derived classes should override this function to return get_class_type(). More...
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. This is equivalent to get_type().get_index(). More...
 
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly. More...
 
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type. More...
 
- Public Member Functions inherited from ReferenceCount
int getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. Returns true if ok, false otherwise. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. Returns true if ok, false otherwise. More...
 
bool unref ()
 Explicitly decrements the reference count. Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete(). More...
 

Static Public Member Functions

static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from Lens
static TypeHandle getClassType ()
 
static float getDefaultFar ()
 Returns the default far plane distance that will be assigned to each newly-created lens. This is read from the Configrc file. More...
 
static float getDefaultNear ()
 Returns the default near plane distance that will be assigned to each newly-created lens. This is read from the Configrc file. More...
 
- Static Public Member Functions inherited from TypedWritableReferenceCount
static TypedWritableReferenceCount decodeFromBamStream (str data, BamReader reader)
 Reads the string created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on that string. Returns NULL on error. More...
 
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedWritable
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 

Additional Inherited Members

- Public Types inherited from Lens
enum  FromCorners {
  FC_roll = 1, FC_camera_plane = 2, FC_off_axis = 4, FC_aspect_ratio = 8,
  FC_shear = 16, FC_keystone = 32
}
 These flags are passed in as the last parameter to control the behavior of set_frustum_from_corners(). See the documentation for that method for an explanation of each flag. More...
 
enum  StereoChannel { SC_mono = 0, SC_left = 1, SC_right = 2, SC_stereo = 3 }
 

Detailed Description

A cylindrical lens. This is the kind of lens generally used for extremely wide panoramic shots. It behaves like a normal perspective lens in the vertical direction, but it is non-linear in the horizontal dimension: a point on the film corresponds to a point in space in linear proportion to its angle to the camera, not to its straight-line distance from the center.

This allows up to 360 degree lenses in the horizontal dimension, with relatively little distortion. The distortion is not very apparent between two relatively nearby points on the film, but it becomes increasingly evident as you compare points widely spaced on the film.

Member Function Documentation

◆ __init__()

__init__ ( )

◆ getClassType()

static TypeHandle getClassType ( )
static