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