34 _real_world_size_u = 0;
35 _real_world_size_v = 0;
38 _file_format = FF_none;
39 _min_filter = MN_point;
40 _mag_filter = MG_point;
42 _repeat_u = RT_repeat;
43 _repeat_v = RT_repeat;
47 _env_type = ET_modulate;
48 _intensity_is_alpha =
false;
49 _float_real_world_size_u = 0.0;
50 _float_real_world_size_v = 0.0;
51 _imported_origin_code = 0;
52 _kernel_version = 1520;
53 _internal_format = IF_default;
54 _external_format = EF_default;
55 _use_mipmap_kernel =
false;
56 memset(_mipmap_kernel, 0,
sizeof(_mipmap_kernel));
57 _use_lod_scale =
false;
58 memset(_lod_scale, 0,
sizeof(_lod_scale));
60 _mag_filter_alpha = MG_point;
61 _mag_filter_color = MG_point;
62 _lambert_conic_central_meridian = 0.0;
63 _lambert_conic_upper_latitude = 0.0;
64 _lambert_conic_lower_latitude = 0.0;
72 _tile_lower_left_u = 0.0;
73 _tile_lower_left_v = 0.0;
74 _tile_upper_right_u = 0.0;
75 _tile_upper_right_v = 0.0;
76 _projection = PT_flat_earth;
77 _earth_model = EM_wgs84;
79 _image_origin = IO_lower_left;
80 _geospecific_points_units = PU_degrees;
81 _geospecific_hemisphere = H_southern;
102 return _converted_filename;
110 _converted_filename = filename;
127 return Filename::binary_filename(texture_filename +
".attr");
141 return FE_could_not_open;
145 attr.seekg(0, std::ios::end);
147 return FE_read_error;
149 std::streampos length = attr.tellg();
151 char *buffer =
new char[length];
153 attr.seekg(0, std::ios::beg);
154 attr.read(buffer, length);
156 return FE_read_error;
162 return unpack_attr(datagram);
181 FltError result = pack_attr(datagram);
182 if (result != FE_ok) {
189 return FE_could_not_open;
194 return FE_write_error;
206 if (!FltRecord::extract_record(reader)) {
210 nassertr(reader.
get_opcode() == FO_texture,
false);
213 if (_header->get_flt_version() < 1420) {
218 _converted_filename = _header->convert_path(Filename::from_os_specific(_orig_filename), get_model_path());
238 if (!FltRecord::build_record(writer)) {
250 if (_header->get_auto_attr_update() == FltHeader::AU_always ||
251 (_header->get_auto_attr_update() == FltHeader::AU_if_missing &&
265unpack_attr(
const Datagram &datagram) {
291 _internal_format = (InternalFormat)iterator.
get_be_int32();
292 _external_format = (ExternalFormat)iterator.
get_be_int32();
295 for (i = 0; i < 8; i++) {
299 for (i = 0; i < 8; i++) {
304 _mag_filter_alpha = (Magnification)iterator.
get_be_int32();
305 _mag_filter_color = (Magnification)iterator.
get_be_int32();
327 _geospecific_points_units = (PointsUnits)iterator.
get_be_int32();
328 _geospecific_hemisphere = (Hemisphere)iterator.
get_be_int32();
339 _geospecific_control_points.clear();
341 if (num_points > 0) {
344 while (num_points > 0) {
345 GeospecificControlPoint gcp;
355 while (num_defs > 0) {
374pack_attr(
Datagram &datagram)
const {
402 for (i = 0; i < 8; i++) {
406 for (i = 0; i < 8; i++) {
444 datagram.
add_be_int32(_geospecific_control_points.size());
445 if (!_geospecific_control_points.empty()) {
447 GeospecificControlPoints::const_iterator pi;
448 for (pi = _geospecific_control_points.begin();
449 pi != _geospecific_control_points.end();
451 const GeospecificControlPoint &gcp = (*pi);
461 SubtextureDefs::const_iterator di;
462 for (di = _subtexture_defs.begin();
463 di != _subtexture_defs.end();
465 const SubtextureDef &def = (*di);
A class to retrieve the individual data elements previously stored in a Datagram.
void skip_bytes(size_t size)
Skips over the indicated number of bytes in the datagram.
int32_t get_be_int32()
Extracts a signed 32-bit big-endian integer.
PN_float32 get_be_float32()
Extracts a 32-bit big-endian single-precision floating-point number.
std::string get_fixed_string(size_t size)
Extracts a fixed-length string.
PN_float64 get_be_float64()
Extracts a 64-bit big-endian floating-point number.
size_t get_remaining_size() const
Return the bytes left in the datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
size_t get_length() const
Returns the number of bytes in the datagram.
void add_be_int32(int32_t value)
Adds a signed 32-bit big-endian integer to the datagram.
void add_be_float32(PN_float32 value)
Adds a 32-bit single-precision big-endian floating-point number to the datagram.
void add_fixed_string(const std::string &str, size_t size)
Adds a fixed-length string to the datagram.
void add_be_float64(PN_float64 value)
Adds a 64-bit big-endian floating-point number to the datagram.
void pad_bytes(size_t size)
Adds the indicated number of zero bytes to the datagram.
const void * get_data() const
Returns a pointer to the beginning of the datagram's data.
void add_int8(int8_t value)
Adds a signed 8-bit integer to the datagram.
The name of a file, such as a texture file or an Egg file.
bool open_read(std::ifstream &stream) const
Opens the indicated ifstream for reading the file, if possible.
void set_binary()
Indicates that the filename represents a binary file.
std::string to_os_generic() const
This is similar to to_os_specific(), but it is designed to generate a filename that can be understood...
bool open_write(std::ofstream &stream, bool truncate=true) const
Opens the indicated ifstream for writing the file, if possible.
This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extr...
FltOpcode get_opcode() const
Returns the opcode associated with the current record.
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly.
void set_opcode(FltOpcode opcode)
Sets the opcode associated with the current record.
Datagram & update_datagram()
Returns a modifiable reference to the datagram associated with the current record.
The base class for all kinds of records in a MultiGen OpenFlight file.
void check_remaining_size(const DatagramIterator &di, const std::string &name=std::string()) const
Checks that the iterator has no bytes left, as it should at the end of a successfully read record.
virtual void apply_converted_filenames()
Walks the hierarchy at this record and below and copies the _converted_filename record into the _orig...
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.