15 #include "orthographicLens.h"
17 #include "bamReader.h"
62 void OrthographicLens::
63 write(ostream &out,
int indent_level)
const {
64 indent(out, indent_level) << get_type() <<
" film size = " <<
get_film_size() <<
"\n";
74 bool OrthographicLens::
75 do_extrude_depth(
const CData *cdata,
77 return do_extrude_depth_with_mat(cdata, point2d, point3d);
86 void OrthographicLens::
87 do_compute_projection_mat(Lens::CData *lens_cdata) {
88 CoordinateSystem cs = lens_cdata->_cs;
89 if (cs == CS_default) {
90 cs = get_default_coordinate_system();
93 PN_stdfloat a = 2.0f / (lens_cdata->_far_distance - lens_cdata->_near_distance);
94 PN_stdfloat b = -(lens_cdata->_far_distance + lens_cdata->_near_distance) / (lens_cdata->_far_distance - lens_cdata->_near_distance);
99 canonical.set(1.0f, 0.0f, 0.0f, 0.0f,
101 0.0f, 1.0f, 0.0f, 0.0f,
102 0.0f, 0.0f, b, 1.0f);
106 canonical.set(1.0f, 0.0f, 0.0f, 0.0f,
107 0.0f, 1.0f, 0.0f, 0.0f,
108 0.0f, 0.0f, -a, 0.0f,
109 0.0f, 0.0f, b, 1.0f);
113 canonical.set(1.0f, 0.0f, 0.0f, 0.0f,
114 0.0f, 0.0f, -a, 0.0f,
115 0.0f, 1.0f, 0.0f, 0.0f,
116 0.0f, 0.0f, b, 1.0f);
120 canonical.set(1.0f, 0.0f, 0.0f, 0.0f,
121 0.0f, 1.0f, 0.0f, 0.0f,
123 0.0f, 0.0f, b, 1.0f);
128 <<
"Invalid coordinate system " << (int)cs <<
" in OrthographicLens!\n";
132 lens_cdata->_projection_mat = do_get_lens_mat_inv(lens_cdata) * canonical * do_get_film_mat(lens_cdata);
133 lens_cdata->_projection_mat_left = lens_cdata->_projection_mat_right = lens_cdata->_projection_mat;
135 do_adjust_comp_flags(lens_cdata,
136 CF_projection_mat_inv | CF_projection_mat_left_inv | CF_projection_mat_right_inv,
165 parse_params(params, scan, manager);
166 lens->fillin(scan, manager);
static const LMatrix4f & ident_mat()
Returns an identity matrix.
static void register_with_read_factory()
Tells the BamReader how to create objects of type Lens.
A base class for any number of different kinds of lenses, linear and otherwise.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Base class for objects that can be written to and read from Bam files.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
virtual bool is_linear() const
Returns true if the lens represents a linear projection (e.g.
This is a 4-by-4 transform matrix.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
const LVecBase2 & get_film_size() const
Returns the horizontal and vertical film size of the virtual film.
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
virtual bool is_orthographic() const
Returns true if the lens represents a orthographic projection (i.e.