00001 // Filename: matrixLens.I 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 //////////////////////////////////////////////////////////////////// 00020 // Function: MatrixLens::Constructor 00021 // Access: Public 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 INLINE MatrixLens:: 00025 MatrixLens() : 00026 _user_mat(LMatrix4f::ident_mat()) 00027 { 00028 // The default film size for a MatrixLens is 2, which makes the 00029 // default range for both X and Y be [-1, 1]. This also, 00030 // incidentally, makes the film_mat be identity. 00031 set_film_size(2.0f); 00032 } 00033 00034 //////////////////////////////////////////////////////////////////// 00035 // Function: MatrixLens::Copy Constructor 00036 // Access: Public 00037 // Description: 00038 //////////////////////////////////////////////////////////////////// 00039 INLINE MatrixLens:: 00040 MatrixLens(const MatrixLens ©) : 00041 Lens(copy), 00042 _user_mat(copy._user_mat) 00043 { 00044 } 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Function: MatrixLens::Copy Assignment Operator 00048 // Access: Public 00049 // Description: 00050 //////////////////////////////////////////////////////////////////// 00051 INLINE void MatrixLens:: 00052 operator = (const MatrixLens ©) { 00053 Lens::operator = (copy); 00054 _user_mat = copy.get_user_mat(); 00055 } 00056 00057 //////////////////////////////////////////////////////////////////// 00058 // Function: MatrixLens::set_user_mat 00059 // Access: Published 00060 // Description: Explicitly specifies the projection matrix. This 00061 // matrix should convert X and Y to the range 00062 // [-film_size/2, film_size/2], where (-fs/2,-fs/2) is 00063 // the lower left corner of the screen and (fs/2, fs/2) 00064 // is the upper right. Z should go to the range [-1, 00065 // 1], where -1 is the far plane and 1 is the near 00066 // plane. Note that this is a left-handed Y-up 00067 // coordinate system. 00068 // 00069 // The default film_size for a MatrixLens is 2, so the 00070 // default range is [-1, 1] for both X and Y. This is 00071 // consistent with the GL conventions for projection 00072 // matrices. 00073 //////////////////////////////////////////////////////////////////// 00074 INLINE void MatrixLens:: 00075 set_user_mat(const LMatrix4f &user_mat) { 00076 _user_mat = user_mat; 00077 adjust_comp_flags(CF_mat, 0); 00078 } 00079 00080 //////////////////////////////////////////////////////////////////// 00081 // Function: MatrixLens::get_user_mat 00082 // Access: Published 00083 // Description: Returns the explicit projection matrix as set by the 00084 // user. This does not include transforms on the lens 00085 // or film (e.g. a film offset or view hpr). 00086 //////////////////////////////////////////////////////////////////// 00087 INLINE const LMatrix4f &MatrixLens:: 00088 get_user_mat() const { 00089 return _user_mat; 00090 }