Panda3D
 All Classes Functions Variables Enumerations
pfmFile.I
00001 // Filename: pfmFile.I
00002 // Created by:  drose (23Dec10)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: PfmFile::is_valid
00018 //       Access: Published
00019 //  Description: 
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE bool PfmFile::
00022 is_valid() const {
00023   return _num_channels != 0 && (_x_size * _y_size == (int)_table.size());
00024 }
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: PfmFile::get_x_size
00028 //       Access: Published
00029 //  Description: 
00030 ////////////////////////////////////////////////////////////////////
00031 INLINE int PfmFile::
00032 get_x_size() const {
00033   return _x_size;
00034 }
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //     Function: PfmFile::get_y_size
00038 //       Access: Published
00039 //  Description: 
00040 ////////////////////////////////////////////////////////////////////
00041 INLINE int PfmFile::
00042 get_y_size() const {
00043   return _y_size;
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: PfmFile::get_scale
00048 //       Access: Published
00049 //  Description: The "scale" is reported in the pfm header and is
00050 //               probably meaningless.
00051 ////////////////////////////////////////////////////////////////////
00052 INLINE PN_stdfloat PfmFile::
00053 get_scale() const {
00054   return _scale;
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: PfmFile::get_num_channels
00059 //       Access: Published
00060 //  Description: A pfm file can be either 1-channel
00061 //               (get_num_channels() == 1) or 3-channel
00062 //               (get_num_channels() == 3).  In the case of a
00063 //               1-channel file, the values can be found in the x
00064 //               component of each point, and the y and z components
00065 //               are unused.
00066 ////////////////////////////////////////////////////////////////////
00067 INLINE int PfmFile::
00068 get_num_channels() const {
00069   return _num_channels;
00070 }
00071 
00072 ////////////////////////////////////////////////////////////////////
00073 //     Function: PfmFile::has_point
00074 //       Access: Published
00075 //  Description: Returns true if there is a valid point at x, y.  This
00076 //               always returns true unless the zero_special flag is
00077 //               enabled, in which case it returns false if the point
00078 //               at x, y is zero.
00079 ////////////////////////////////////////////////////////////////////
00080 INLINE bool PfmFile::
00081 has_point(int x, int y) const {
00082   if ((x >= 0 && x < _x_size) && 
00083       (y >= 0 && y < _y_size)) {
00084     return (!_zero_special || _table[y * _x_size + x] != LPoint3::zero());
00085   }
00086   return false;
00087 }
00088 
00089 ////////////////////////////////////////////////////////////////////
00090 //     Function: PfmFile::get_point
00091 //       Access: Published
00092 //  Description: Returns the 3-component point value at the indicated
00093 //               point.  In a 1-channel image, the channel value is in
00094 //               the x component.
00095 ////////////////////////////////////////////////////////////////////
00096 INLINE const LPoint3 &PfmFile::
00097 get_point(int x, int y) const {
00098   nassertr(x >= 0 && x < _x_size, LPoint3::zero());
00099   nassertr(y >= 0 && y < _y_size, LPoint3::zero());
00100   return _table[y * _x_size + x];
00101 }
00102 
00103 ////////////////////////////////////////////////////////////////////
00104 //     Function: PfmFile::set_point
00105 //       Access: Published
00106 //  Description: Replaces the 3-component point value at the indicated
00107 //               point.  In a 1-channel image, the channel value is in
00108 //               the x component.
00109 ////////////////////////////////////////////////////////////////////
00110 INLINE void PfmFile::
00111 set_point(int x, int y, const LVecBase3 &point) {
00112   nassertv(!point.is_nan());
00113   nassertv(x >= 0 && x < _x_size);
00114   nassertv(y >= 0 && y < _y_size);
00115   _table[y * _x_size + x] = point;
00116 }
00117 
00118 ////////////////////////////////////////////////////////////////////
00119 //     Function: PfmFile::modify_point
00120 //       Access: Published
00121 //  Description: Returns a modifiable 3-component point value at the
00122 //               indicated point.
00123 ////////////////////////////////////////////////////////////////////
00124 INLINE LPoint3 &PfmFile::
00125 modify_point(int x, int y) {
00126 #ifndef NDEBUG
00127   static LPoint3 dummy_value = LPoint3::zero();
00128   nassertr(x >= 0 && x < _x_size, dummy_value);
00129   nassertr(y >= 0 && y < _y_size, dummy_value);
00130 #endif
00131 
00132   return _table[y * _x_size + x];
00133 }
00134 
00135 ////////////////////////////////////////////////////////////////////
00136 //     Function: PfmFile::set_zero_special
00137 //       Access: Published
00138 //  Description: Sets the zero_special flag.  When this flag is true,
00139 //               values of (0, 0, 0) in the pfm file are treated as a
00140 //               special case, and are not processed.
00141 ////////////////////////////////////////////////////////////////////
00142 INLINE void PfmFile::
00143 set_zero_special(bool zero_special) {
00144   _zero_special = zero_special;
00145 }
00146 
00147 ////////////////////////////////////////////////////////////////////
00148 //     Function: PfmFile::get_zero_special
00149 //       Access: Published
00150 //  Description: Returns the zero_special flag.  When this flag is true,
00151 //               values of (0, 0, 0) in the pfm file are treated as a
00152 //               special case, and are not processed.
00153 ////////////////////////////////////////////////////////////////////
00154 INLINE bool PfmFile::
00155 get_zero_special() const {
00156   return _zero_special;
00157 }
00158 
00159 ////////////////////////////////////////////////////////////////////
00160 //     Function: PfmFile::set_vis_inverse
00161 //       Access: Published
00162 //  Description: Sets the vis_inverse flag.  When this flag is true,
00163 //               vis meshes and point clouds are generated with the
00164 //               3-d depth value in the texture coordinates, and the
00165 //               2-d index value in the vertex position.  When it is
00166 //               false, meshes are generated normally, with the 3-d
00167 //               depth value in the vertex position and the 2-d index
00168 //               value in the texture coordinates.
00169 ////////////////////////////////////////////////////////////////////
00170 INLINE void PfmFile::
00171 set_vis_inverse(bool vis_inverse) {
00172   _vis_inverse = vis_inverse;
00173 }
00174 
00175 ////////////////////////////////////////////////////////////////////
00176 //     Function: PfmFile::get_vis_inverse
00177 //       Access: Published
00178 //  Description: Returns the vis_inverse flag.  See set_vis_inverse().
00179 ////////////////////////////////////////////////////////////////////
00180 INLINE bool PfmFile::
00181 get_vis_inverse() const {
00182   return _vis_inverse;
00183 }
00184 
00185 ////////////////////////////////////////////////////////////////////
00186 //     Function: PfmFile::set_flat_texcoord_name
00187 //       Access: Published
00188 //  Description: If the flat_texcoord_name is specified, it is the
00189 //               name of an additional vertex column that will be
00190 //               created for the "flat" texture coordinates, i.e. the
00191 //               original 0..1 values that correspond to the 2-D index
00192 //               position of each point in the original pfm file.
00193 //
00194 //               These are the same values that will be assigned to
00195 //               the default texture coordinates if the vis_inverse
00196 //               flag is *not* true.
00197 ////////////////////////////////////////////////////////////////////
00198 INLINE void PfmFile::
00199 set_flat_texcoord_name(InternalName *flat_texcoord_name) {
00200   _flat_texcoord_name = flat_texcoord_name;
00201 }
00202 
00203 ////////////////////////////////////////////////////////////////////
00204 //     Function: PfmFile::clear_flat_texcoord_name
00205 //       Access: Published
00206 //  Description: Resets the flat_texcoord_name to empty, so that
00207 //               additional texture coordinates are not created.
00208 ////////////////////////////////////////////////////////////////////
00209 INLINE void PfmFile::
00210 clear_flat_texcoord_name() {
00211   _flat_texcoord_name = NULL;
00212 }
00213 
00214 ////////////////////////////////////////////////////////////////////
00215 //     Function: PfmFile::get_flat_texcoord_name
00216 //       Access: Published
00217 //  Description: Returns the flat_texcoord_name.  See set_flat_texcoord_name().
00218 ////////////////////////////////////////////////////////////////////
00219 INLINE InternalName *PfmFile::
00220 get_flat_texcoord_name() const {
00221   return _flat_texcoord_name;
00222 }
00223 
00224 ////////////////////////////////////////////////////////////////////
00225 //     Function: PfmFile::set_vis_2d
00226 //       Access: Published
00227 //  Description: Sets the vis_2d flag.  When this flag is true,
00228 //               only the first two (x, y) value of each depth point
00229 //               is considered meaningful; the z component is ignored.
00230 //               This is only relevant for generating visualizations.
00231 ////////////////////////////////////////////////////////////////////
00232 INLINE void PfmFile::
00233 set_vis_2d(bool vis_2d) {
00234   _vis_2d = vis_2d;
00235 }
00236 
00237 ////////////////////////////////////////////////////////////////////
00238 //     Function: PfmFile::get_vis_2d
00239 //       Access: Published
00240 //  Description: Returns the vis_2d flag.  See set_vis_2d().
00241 ////////////////////////////////////////////////////////////////////
00242 INLINE bool PfmFile::
00243 get_vis_2d() const {
00244   return _vis_2d;
00245 }
 All Classes Functions Variables Enumerations