Panda3D

sourceTextureImage.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 sourceTextureImage.h
10 * @author drose
11 * @date 2000-11-28
12 */
13
14 #ifndef SOURCETEXTUREIMAGE_H
15 #define SOURCETEXTUREIMAGE_H
16
17 #include "pandatoolbase.h"
18
19 #include "imageFile.h"
20
21 class TextureImage;
22 class PNMImageHeader;
23
24 /**
25 * This is a texture image reference as it appears in an egg file: the source
26 * image of the texture.
27 */
28 class SourceTextureImage : public ImageFile {
29 private:
30 SourceTextureImage();
31
32 public:
33 SourceTextureImage(TextureImage *texture, const Filename &filename,
34 const Filename &alpha_filename, int alpha_file_channel);
35
36 TextureImage *get_texture() const;
37
38 void increment_egg_count();
39 int get_egg_count() const;
40
41 bool get_size();
42 bool read_header();
43 void set_header(const PNMImageHeader &header);
44
45 private:
46 TextureImage *_texture;
47 int _egg_count;
48 bool _read_header;
49 bool _successfully_read_header;
50
51 // The TypedWritable interface follows.
52 public:
53 static void register_with_read_factory();
54 virtual void write_datagram(BamWriter *writer, Datagram &datagram);
55 virtual int complete_pointers(TypedWritable **p_list,
56 BamReader *manager);
57
58 protected:
59 static TypedWritable *make_SourceTextureImage(const FactoryParams &params);
60 void fillin(DatagramIterator &scan, BamReader *manager);
61
62 public:
63 static TypeHandle get_class_type() {
64 return _type_handle;
65 }
66 static void init_type() {
67 ImageFile::init_type();
68 register_type(_type_handle, "SourceTextureImage",
69 ImageFile::get_class_type());
70 }
71 virtual TypeHandle get_type() const {
72 return get_class_type();
73 }
74
75 private:
76 static TypeHandle _type_handle;
77 };
78
79 INLINE std::ostream &
80 operator << (std::ostream &out, const SourceTextureImage &source) {
81 source.output_filename(out);
82 return out;
83 }
84
85 #endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
Filename
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
ImageFile
This is the base class of both TextureImage and PaletteImage.
Definition: imageFile.h:33
ImageFile::output_filename
void output_filename(std::ostream &out) const
Writes the filename (or pair of filenames) to the indicated output stream.
Definition: imageFile.cxx:424
PNMImageHeader
This is the base class of PNMImage, PNMReader, and PNMWriter.
Definition: pnmImageHeader.h:40
SourceTextureImage
This is a texture image reference as it appears in an egg file: the source image of the texture.
Definition: sourceTextureImage.h:28
SourceTextureImage::get_size
bool get_size()
Determines the size of the SourceTextureImage, if it is not already known.
Definition: sourceTextureImage.cxx:87
SourceTextureImage::write_datagram
virtual void write_datagram(BamWriter *writer, Datagram &datagram)
Fills the indicated datagram up with a binary representation of the current object,...
Definition: sourceTextureImage.cxx:160
SourceTextureImage::register_with_read_factory
static void register_with_read_factory()
Registers the current object as something that can be read from a Bam file.
Definition: sourceTextureImage.cxx:150
SourceTextureImage::read_header
bool read_header()
Reads the actual image header to determine the image properties, like its size.
Definition: sourceTextureImage.cxx:102
SourceTextureImage::increment_egg_count
void increment_egg_count()
Increments by one the number of egg files that are known to reference this SourceTextureImage.
Definition: sourceTextureImage.cxx:67
SourceTextureImage::complete_pointers
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Called after the object is otherwise completely read from a Bam file, this function's job is to store...
Definition: sourceTextureImage.cxx:178
SourceTextureImage::get_texture
TextureImage * get_texture() const
Returns the particular texture that this image is one of the sources for.
Definition: sourceTextureImage.cxx:58
SourceTextureImage::set_header
void set_header(const PNMImageHeader &header)
Sets the header information associated with this image, as if it were loaded from the disk.
Definition: sourceTextureImage.cxx:127
SourceTextureImage::get_egg_count
int get_egg_count() const
Returns the number of egg files that share this SourceTextureImage.
Definition: sourceTextureImage.cxx:75
TextureImage
This represents a single source texture that is referenced by one or more egg files.
Definition: textureImage.h:46
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
imageFile.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22