Panda3D
 All Classes Functions Variables Enumerations
fltTexture.h
1 // Filename: fltTexture.h
2 // Created by: drose (25Aug00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef FLTTEXTURE_H
16 #define FLTTEXTURE_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "fltRecord.h"
21 
22 #include "filename.h"
23 #include "luse.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : FltTexture
27 // Description : Represents a single texture in the texture palette.
28 ////////////////////////////////////////////////////////////////////
29 class FltTexture : public FltRecord {
30 public:
31  FltTexture(FltHeader *header);
32 
33  virtual void apply_converted_filenames();
34 
35  string _orig_filename;
36  Filename _converted_filename;
37  int _pattern_index;
38  int _x_location;
39  int _y_location;
40 
42  void set_texture_filename(const Filename &filename);
44  FltError read_attr_data();
45  FltError write_attr_data() const;
46  FltError write_attr_data(Filename attr_filename) const;
47 
48  // The remaining fields are from the attr file.
49  enum FileFormat {
50  FF_none = -1,
51  FF_att_8_pattern = 0,
52  FF_att_8_template = 1,
53  FF_sgi_i = 2,
54  FF_sgi_ia = 3,
55  FF_sgi_rgb = 4,
56  FF_sgi_rgba = 5
57  };
58 
59  enum Minification {
60  MN_point = 0,
61  MN_bilinear = 1,
62  MN_OB_mipmap = 2, // obsolete
63  MN_mipmap_point = 3,
64  MN_mipmap_linear = 4,
65  MN_mipmap_bilinear = 5,
66  MN_mipmap_trilinear = 6,
67  MN_bicubic = 8,
68  MN_bilinear_gequal = 9,
69  MN_bilinear_lequal = 10,
70  MN_bicubic_gequal = 11,
71  MN_bicubic_lequal = 12
72  };
73 
74  enum Magnification {
75  MG_point = 0,
76  MG_bilinear = 1,
77  MG_bicubic = 3,
78  MG_sharpen = 4,
79  MG_add_detail = 5,
80  MG_modulate_detail = 6,
81  MG_bilinear_gequal = 7,
82  MG_bilinear_lequal = 8,
83  MG_bicubic_gequal = 9,
84  MG_bicubic_lequal = 10
85  };
86 
87  enum RepeatType {
88  RT_repeat = 0,
89  RT_clamp = 1
90  };
91 
92  enum EnvironmentType {
93  ET_modulate = 0,
94  ET_blend = 1,
95  ET_decal = 2,
96  ET_color = 3
97  };
98 
99  enum InternalFormat {
100  IF_default = 0,
101  IF_i_12a_4 = 1,
102  IF_ia_8 = 2,
103  IF_rgb_5 = 3,
104  IF_rgba_4 = 4,
105  IF_ia_12 = 5,
106  IF_rgba_8 = 6,
107  IF_rgba_12 = 7,
108  IF_i_16 = 8, // shadow mode only
109  IF_rgb_12 = 9
110  };
111 
112  enum ExternalFormat {
113  EF_default = 0,
114  EF_pack_8 = 1,
115  EF_pack_16 = 2
116  };
117 
118  enum ProjectionType {
119  PT_flat_earth = 0,
120  PT_lambert = 3,
121  PT_utm = 4,
122  PT_undefined = 7
123  };
124 
125  enum EarthModel {
126  EM_wgs84 = 0,
127  EM_wgs72 = 1,
128  EM_bessel = 2,
129  EM_clarke_1866 = 3,
130  EM_nad27 = 4
131  };
132 
133  enum ImageOrigin {
134  IO_lower_left = 0,
135  IO_upper_left = 1
136  };
137 
138  enum PointsUnits {
139  PU_degrees = 0,
140  PU_meters = 1,
141  PU_pixels = 2
142  };
143 
144  enum Hemisphere {
145  H_southern = 0,
146  H_northern = 1,
147  };
148 
149  struct LODScale {
150  PN_stdfloat _lod;
151  PN_stdfloat _scale;
152  };
153 
155  LPoint2d _uv;
156  LPoint2d _real_earth;
157  };
158 
160 
161  struct SubtextureDef {
162  string _name;
163  int _left;
164  int _bottom;
165  int _right;
166  int _top;
167  };
169 
170  int _num_texels_u;
171  int _num_texels_v;
172  int _real_world_size_u;
173  int _real_world_size_v;
174  int _up_vector_x;
175  int _up_vector_y;
176  FileFormat _file_format;
177  Minification _min_filter;
178  Magnification _mag_filter;
179  RepeatType _repeat;
180  RepeatType _repeat_u;
181  RepeatType _repeat_v;
182  int _modify_flag;
183  int _x_pivot_point;
184  int _y_pivot_point;
185  EnvironmentType _env_type;
186  bool _intensity_is_alpha; // if true, a one-channel image is actually
187  // an alpha image, not an intensity image.
188  double _float_real_world_size_u;
189  double _float_real_world_size_v;
190  int _imported_origin_code;
191  int _kernel_version;
192  InternalFormat _internal_format;
193  ExternalFormat _external_format;
194  bool _use_mipmap_kernel;
195  PN_stdfloat _mipmap_kernel[8];
196  bool _use_lod_scale;
197  LODScale _lod_scale[8];
198  PN_stdfloat _clamp;
199  Magnification _mag_filter_alpha;
200  Magnification _mag_filter_color;
201  double _lambert_conic_central_meridian;
202  double _lambert_conic_upper_latitude;
203  double _lambert_conic_lower_latitude;
204  bool _use_detail;
205  int _detail_j;
206  int _detail_k;
207  int _detail_m;
208  int _detail_n;
209  int _detail_scramble;
210  bool _use_tile;
211  PN_stdfloat _tile_lower_left_u;
212  PN_stdfloat _tile_lower_left_v;
213  PN_stdfloat _tile_upper_right_u;
214  PN_stdfloat _tile_upper_right_v;
215  ProjectionType _projection;
216  EarthModel _earth_model;
217  int _utm_zone;
218  ImageOrigin _image_origin;
219  PointsUnits _geospecific_points_units;
220  Hemisphere _geospecific_hemisphere;
221  string _comment;
222  int _file_version;
223  GeospecificControlPoints _geospecific_control_points;
224  SubtextureDefs _subtexture_defs;
225 
226 protected:
227  virtual bool extract_record(FltRecordReader &reader);
228  virtual bool build_record(FltRecordWriter &writer) const;
229 
230 private:
231  FltError unpack_attr(const Datagram &datagram);
232  FltError pack_attr(Datagram &datagram) const;
233 
234 public:
235  virtual TypeHandle get_type() const {
236  return get_class_type();
237  }
238  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
239  static TypeHandle get_class_type() {
240  return _type_handle;
241  }
242  static void init_type() {
243  FltRecord::init_type();
244  register_type(_type_handle, "FltTexture",
245  FltRecord::get_class_type());
246  }
247 
248 private:
249  static TypeHandle _type_handle;
250 
251  friend class FltHeader;
252 };
253 
254 #endif
255 
256 
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly...
This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extr...
void set_texture_filename(const Filename &filename)
Changes the name of the texture image file.
Definition: fltTexture.cxx:119
This is a two-component point in space.
Definition: lpoint2.h:411
Filename get_texture_filename() const
Returns the name of the texture image file.
Definition: fltTexture.cxx:109
This is the first bead in the file, the top of the bead hierarchy, and the primary interface to readi...
Definition: fltHeader.h:48
Filename get_attr_filename() const
Returns the name of the texture's associated .attr file.
Definition: fltTexture.cxx:140
virtual void apply_converted_filenames()
Walks the hierarchy at this record and below and copies the _converted_filename record into the _orig...
Definition: fltTexture.cxx:98
Represents a single texture in the texture palette.
Definition: fltTexture.h:29
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
The base class for all kinds of records in a MultiGen OpenFlight file.
Definition: fltRecord.h:40
FltError read_attr_data()
Opens up the texture's .attr file and reads its data into the extra FltTexture fields.
Definition: fltTexture.cxx:154
FltError write_attr_data() const
Writes the texture's .attr file.
Definition: fltTexture.cxx:192
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43