00001 // Filename: matrixLens.cxx 00002 // Created by: drose (12Dec01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "matrixLens.h" 00020 #include "indent.h" 00021 00022 TypeHandle MatrixLens::_type_handle; 00023 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: MatrixLens::make_copy 00027 // Access: Public, Virtual 00028 // Description: Allocates a new Lens just like this one. 00029 //////////////////////////////////////////////////////////////////// 00030 PT(Lens) MatrixLens:: 00031 make_copy() const { 00032 return new MatrixLens(*this); 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function: MatrixLens::is_linear 00037 // Access: Published, Virtual 00038 // Description: Returns true if the lens represents a linear 00039 // projection (e.g. PerspectiveLens, MatrixLens), 00040 // and therefore there is a valid matrix returned by 00041 // get_projection_mat(), or false otherwise. 00042 //////////////////////////////////////////////////////////////////// 00043 bool MatrixLens:: 00044 is_linear() const { 00045 return true; 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: MatrixLens::write 00050 // Access: Public, Virtual 00051 // Description: 00052 //////////////////////////////////////////////////////////////////// 00053 void MatrixLens:: 00054 write(ostream &out, int indent_level) const { 00055 indent(out, indent_level) << get_type() << ":\n"; 00056 _projection_mat.write(out, indent_level + 2); 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: MatrixLens::compute_projection_mat 00061 // Access: Protected, Virtual 00062 // Description: Computes the complete transformation matrix from 3-d 00063 // point to 2-d point, if the lens is linear. 00064 //////////////////////////////////////////////////////////////////// 00065 void MatrixLens:: 00066 compute_projection_mat() { 00067 _projection_mat = get_lens_mat_inv() * _user_mat * get_film_mat(); 00068 adjust_comp_flags(CF_projection_mat_inv, 00069 CF_projection_mat); 00070 }