51 void OrthographicLens::
52 write(std::ostream &out,
int indent_level)
const {
61 bool OrthographicLens::
62 do_extrude_depth(
const CData *cdata,
63 const LPoint3 &point2d, LPoint3 &point3d)
const {
64 return do_extrude_depth_with_mat(cdata, point2d, point3d);
71 void OrthographicLens::
72 do_compute_projection_mat(Lens::CData *lens_cdata) {
73 CoordinateSystem cs = lens_cdata->_cs;
74 if (cs == CS_default) {
75 cs = get_default_coordinate_system();
78 PN_stdfloat a = 2.0f / (lens_cdata->_far_distance - lens_cdata->_near_distance);
79 PN_stdfloat b = -(lens_cdata->_far_distance + lens_cdata->_near_distance) / (lens_cdata->_far_distance - lens_cdata->_near_distance);
84 canonical.set(1.0f, 0.0f, 0.0f, 0.0f,
86 0.0f, 1.0f, 0.0f, 0.0f,
91 canonical.set(1.0f, 0.0f, 0.0f, 0.0f,
92 0.0f, 1.0f, 0.0f, 0.0f,
98 canonical.set(1.0f, 0.0f, 0.0f, 0.0f,
100 0.0f, 1.0f, 0.0f, 0.0f,
101 0.0f, 0.0f, b, 1.0f);
105 canonical.set(1.0f, 0.0f, 0.0f, 0.0f,
106 0.0f, 1.0f, 0.0f, 0.0f,
108 0.0f, 0.0f, b, 1.0f);
113 <<
"Invalid coordinate system " << (int)cs <<
" in OrthographicLens!\n";
114 canonical = LMatrix4::ident_mat();
117 lens_cdata->_projection_mat = do_get_lens_mat_inv(lens_cdata) * canonical * do_get_film_mat(lens_cdata);
118 lens_cdata->_projection_mat_left = lens_cdata->_projection_mat_right = lens_cdata->_projection_mat;
120 do_adjust_comp_flags(lens_cdata,
121 CF_projection_mat_inv | CF_projection_mat_left_inv | CF_projection_mat_right_inv,
145 lens->fillin(scan, manager);
virtual bool is_linear() const
Returns true if the lens represents a linear projection (e.g.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool is_orthographic() const
Returns true if the lens represents a orthographic projection (i.e.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
get_film_size
Returns the horizontal and vertical film size of the virtual film.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PT(Lens) OrthographicLens
Allocates a new Lens just like this one.
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, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.