72class EXPCL_PANDA_GOBJ
Texture :
public TypedWritableReferenceCount,
public Namable {
74 typedef PT(
Texture) MakeTextureFunc();
129 F_luminance_alphamask,
177 enum DeprecatedFilterType {
178 FT_nearest = SamplerState::FT_nearest,
179 FT_linear = SamplerState::FT_linear,
180 FT_nearest_mipmap_nearest = SamplerState::FT_nearest_mipmap_nearest,
181 FT_linear_mipmap_nearest = SamplerState::FT_linear_mipmap_nearest,
182 FT_nearest_mipmap_linear = SamplerState::FT_nearest_mipmap_linear,
183 FT_linear_mipmap_linear = SamplerState::FT_linear_mipmap_linear,
184 FT_shadow = SamplerState::FT_shadow,
185 FT_default = SamplerState::FT_default,
186 FT_invalid = SamplerState::FT_invalid
188 typedef SamplerState::FilterType FilterType;
191 enum DeprecatedWrapMode {
192 WM_clamp = SamplerState::WM_clamp,
193 WM_repeat = SamplerState::WM_repeat,
194 WM_mirror = SamplerState::WM_mirror,
195 WM_mirror_once = SamplerState::WM_mirror_once,
196 WM_border_color = SamplerState::WM_border_color,
197 WM_invalid = SamplerState::WM_invalid
199 typedef SamplerState::WrapMode WrapMode;
201 enum CompressionMode {
234 explicit Texture(
const std::string &name = std::string());
238 void operator = (
const Texture ©);
243 INLINE PT(
Texture) make_copy()
const;
247 int x_size,
int y_size,
int z_size,
248 ComponentType component_type, Format format);
251 ComponentType component_type, Format format);
254 ComponentType component_type, Format format);
257 ComponentType component_type, Format format);
260 ComponentType component_type, Format format);
263 ComponentType component_type, Format format);
266 ComponentType component_type, Format format);
268 Format format, GeomEnums::UsageHint usage);
283 int primary_file_num_channels,
int alpha_file_channel,
285 BLOCKING
bool read(
const Filename &fullpath,
int z,
int n,
286 bool read_pages,
bool read_mipmaps,
289 int primary_file_num_channels,
int alpha_file_channel,
290 int z,
int n,
bool read_pages,
bool read_mipmaps,
295 BLOCKING INLINE
bool write(
const Filename &fullpath,
int z,
int n,
296 bool write_pages,
bool write_mipmaps);
298 BLOCKING
bool read_txo(std::istream &in,
const std::string &filename =
"");
299 BLOCKING
static PT(
Texture) make_from_txo(std::istream &in,
const std::string &filename =
"");
300 BLOCKING
bool write_txo(std::ostream &out,
const std::string &filename =
"")
const;
301 BLOCKING
bool read_dds(std::istream &in,
const std::string &filename =
"",
bool header_only =
false);
302 BLOCKING
bool read_ktx(std::istream &in,
const std::string &filename =
"",
bool header_only =
false);
310 BLOCKING INLINE
bool store(
PNMImage &pnmimage,
int z,
int n)
const;
312 BLOCKING INLINE
bool store(
PfmFile &pfm,
int z,
int n)
const;
314 BLOCKING INLINE
bool reload();
377 INLINE SamplerState::WrapMode
get_wrap_u()
const;
381 INLINE SamplerState::WrapMode
get_wrap_v()
const;
385 INLINE SamplerState::WrapMode
get_wrap_w()
const;
459 INLINE
void set_ram_image(CPTA_uchar image, CompressionMode compression = CM_off,
460 size_t page_size = 0);
461 void set_ram_image_as(CPTA_uchar image,
const std::string &provided_format);
463 EXTEND
void set_ram_image(PyObject *image, CompressionMode compression = CM_off,
464 size_t page_size = 0);
465 EXTEND
void set_ram_image_as(PyObject *image,
const std::string &provided_format);
476 EXTENSION(PT(
Texture) __deepcopy__(PyObject *memo)
const);
479 QualityLevel quality_level = QL_default,
522 PT(TexturePeeker) peek();
537 PT(
AsyncFuture) prepare(PreparedGraphicsObjects *prepared_objects);
538 bool is_prepared(PreparedGraphicsObjects *prepared_objects)
const;
541 bool get_active(PreparedGraphicsObjects *prepared_objects)
const;
542 bool get_resident(PreparedGraphicsObjects *prepared_objects)
const;
544 bool release(PreparedGraphicsObjects *prepared_objects);
547 void write(std::ostream &out,
int indent_level)
const;
600 PreparedGraphicsObjects *prepared_objects,
607 static void consider_rescale(
PNMImage &pnmimage,
const std::string &name, AutoTextureScale auto_texture_scale = ATS_unspecified);
631 static PT(
Texture) make_texture();
635 static bool is_specific(CompressionMode compression);
638 static bool is_srgb(Format format);
641 static bool adjust_size(
int &x_size,
int &y_size,
const std::string &name,
642 bool for_padding, AutoTextureScale auto_texture_scale = ATS_unspecified);
643 INLINE
bool adjust_this_size(
int &x_size,
int &y_size,
const std::string &name,
644 bool for_padding)
const;
652 virtual void reconsider_dirty();
661 virtual bool do_adjust_this_size(
const CData *cdata,
662 int &x_size,
int &y_size,
const std::string &name,
663 bool for_padding)
const;
665 virtual bool do_read(CData *cdata,
667 int primary_file_num_channels,
int alpha_file_channel,
668 int z,
int n,
bool read_pages,
bool read_mipmaps,
670 virtual bool do_read_one(CData *cdata,
672 int z,
int n,
int primary_file_num_channels,
int alpha_file_channel,
675 virtual bool do_load_one(CData *cdata,
676 const PNMImage &pnmimage,
const std::string &name,
678 virtual bool do_load_one(CData *cdata,
679 const PfmFile &pfm,
const std::string &name,
681 virtual bool do_load_sub_image(CData *cdata,
const PNMImage &image,
682 int x,
int y,
int z,
int n);
683 bool do_read_txo_file(CData *cdata,
const Filename &fullpath);
684 bool do_read_txo(CData *cdata, std::istream &in,
const std::string &filename);
685 bool do_read_dds_file(CData *cdata,
const Filename &fullpath,
bool header_only);
686 bool do_read_dds(CData *cdata, std::istream &in,
const std::string &filename,
bool header_only);
687 bool do_read_ktx_file(CData *cdata,
const Filename &fullpath,
bool header_only);
688 bool do_read_ktx(CData *cdata, std::istream &in,
const std::string &filename,
bool header_only);
690 bool do_write(CData *cdata,
const Filename &fullpath,
int z,
int n,
691 bool write_pages,
bool write_mipmaps);
692 bool do_write_one(CData *cdata,
const Filename &fullpath,
int z,
int n);
693 bool do_store_one(CData *cdata,
PNMImage &pnmimage,
int z,
int n);
694 bool do_store_one(CData *cdata,
PfmFile &pfm,
int z,
int n);
695 bool do_write_txo_file(
const CData *cdata,
const Filename &fullpath)
const;
696 bool do_write_txo(
const CData *cdata, std::ostream &out,
const std::string &filename)
const;
698 virtual CData *unlocked_ensure_ram_image(
bool allow_compression);
699 virtual void do_reload_ram_image(CData *cdata,
bool allow_compression);
701 PTA_uchar do_modify_ram_image(CData *cdata);
702 PTA_uchar do_make_ram_image(CData *cdata);
703 void do_set_ram_image(CData *cdata, CPTA_uchar image,
704 CompressionMode compression = CM_off,
size_t page_size = 0);
705 PTA_uchar do_modify_ram_mipmap_image(CData *cdata,
int n);
706 PTA_uchar do_make_ram_mipmap_image(CData *cdata,
int n);
707 void do_set_ram_mipmap_image(CData *cdata,
int n, CPTA_uchar image,
size_t page_size);
708 size_t do_get_clear_data(
const CData *cdata,
unsigned char *into)
const;
710 bool consider_auto_process_ram_image(
bool generate_mipmaps,
bool allow_compression);
711 bool do_consider_auto_process_ram_image(CData *cdata,
bool generate_mipmaps,
712 bool allow_compression);
713 bool do_compress_ram_image(CData *cdata, CompressionMode compression,
714 QualityLevel quality_level,
716 bool do_uncompress_ram_image(CData *cdata);
718 static void do_compress_ram_image_bc4(
const RamImage &src, RamImage &dest,
719 int x_size,
int y_size,
int z_size);
720 static void do_compress_ram_image_bc5(
const RamImage &src, RamImage &dest,
721 int x_size,
int y_size,
int z_size);
722 static void do_uncompress_ram_image_bc4(
const RamImage &src, RamImage &dest,
723 int x_size,
int y_size,
int z_size);
724 static void do_uncompress_ram_image_bc5(
const RamImage &src, RamImage &dest,
725 int x_size,
int y_size,
int z_size);
726 bool do_has_all_ram_mipmap_images(
const CData *cdata)
const;
728 bool do_reconsider_z_size(CData *cdata,
int z,
const LoaderOptions &options);
729 virtual void do_allocate_pages(CData *cdata);
730 bool do_reconsider_image_properties(CData *cdata,
731 int x_size,
int y_size,
int num_components,
732 ComponentType component_type,
int z,
734 bool do_rescale_texture(CData *cdata);
736 virtual PT(
Texture) make_copy_impl()
const;
737 PT(
Texture) do_make_copy(
const CData *cdata)
const;
738 void do_assign(CData *cdata,
const Texture *copy,
const CData *cdata_copy);
739 virtual void do_clear(CData *cdata);
740 void do_setup_texture(CData *cdata,
741 TextureType texture_type,
int x_size,
int y_size,
742 int z_size, ComponentType component_type,
744 void do_set_num_views(CData *cdata,
int num_views);
745 void do_set_format(CData *cdata, Format format);
746 void do_set_component_type(CData *cdata, ComponentType component_type);
747 void do_set_x_size(CData *cdata,
int x_size);
748 void do_set_y_size(CData *cdata,
int y_size);
749 void do_set_z_size(CData *cdata,
int z_size);
751 void do_set_wrap_u(CData *cdata, WrapMode wrap);
752 void do_set_wrap_v(CData *cdata, WrapMode wrap);
753 void do_set_wrap_w(CData *cdata, WrapMode wrap);
754 void do_set_minfilter(CData *cdata, FilterType filter);
755 void do_set_magfilter(CData *cdata, FilterType filter);
756 void do_set_anisotropic_degree(CData *cdata,
int anisotropic_degree);
757 void do_set_border_color(CData *cdata,
const LColor &color);
758 void do_set_compression(CData *cdata, CompressionMode compression);
759 void do_set_quality_level(CData *cdata, QualityLevel quality_level);
761 bool do_has_compression(
const CData *cdata)
const;
762 virtual bool do_has_ram_image(
const CData *cdata)
const;
763 virtual bool do_has_uncompressed_ram_image(
const CData *cdata)
const;
764 CPTA_uchar do_get_ram_image(CData *cdata);
765 CPTA_uchar do_get_uncompressed_ram_image(CData *cdata);
766 void do_set_simple_ram_image(CData *cdata, CPTA_uchar image,
int x_size,
int y_size);
767 INLINE
size_t do_get_ram_image_size(
const CData *cdata)
const;
768 INLINE
bool do_has_ram_mipmap_image(
const CData *cdata,
int n)
const;
769 int do_get_expected_num_mipmap_levels(
const CData *cdata)
const;
770 INLINE
size_t do_get_expected_ram_image_size(
const CData *cdata)
const;
771 INLINE
size_t do_get_expected_ram_view_size(
const CData *cdata)
const;
772 INLINE
size_t do_get_expected_ram_page_size(
const CData *cdata)
const;
773 size_t do_get_ram_mipmap_page_size(
const CData *cdata,
int n)
const;
774 INLINE
size_t do_get_expected_ram_mipmap_image_size(
const CData *cdata,
int n)
const;
775 INLINE
size_t do_get_expected_ram_mipmap_view_size(
const CData *cdata,
int n)
const;
776 INLINE
size_t do_get_expected_ram_mipmap_page_size(
const CData *cdata,
int n)
const;
777 int do_get_expected_mipmap_x_size(
const CData *cdata,
int n)
const;
778 int do_get_expected_mipmap_y_size(
const CData *cdata,
int n)
const;
779 int do_get_expected_mipmap_z_size(
const CData *cdata,
int n)
const;
780 INLINE
int do_get_expected_mipmap_num_pages(
const CData *cdata,
int n)
const;
781 INLINE
void do_clear_ram_image(CData *cdata);
782 void do_clear_simple_ram_image(CData *cdata);
783 void do_clear_ram_mipmap_images(CData *cdata);
784 void do_generate_ram_mipmap_images(CData *cdata,
bool allow_recompress);
785 void do_set_pad_size(CData *cdata,
int x,
int y,
int z);
786 virtual bool do_can_reload(
const CData *cdata)
const;
787 bool do_reload(CData *cdata);
789 INLINE AutoTextureScale do_get_auto_texture_scale(
const CData *cdata)
const;
791 virtual bool do_has_bam_rawdata(
const CData *cdata)
const;
792 virtual void do_get_bam_rawdata(CData *cdata);
804 void *_pointer_image;
808 static void convert_from_pnmimage(PTA_uchar &image,
size_t page_size,
809 int row_stride,
int x,
int y,
int z,
811 int num_components,
int component_width);
812 static void convert_from_pfm(PTA_uchar &image,
size_t page_size,
814 int num_components,
int component_width);
815 static bool convert_to_pnmimage(
PNMImage &pnmimage,
int x_size,
int y_size,
817 ComponentType component_type,
bool is_srgb,
818 CPTA_uchar image,
size_t page_size,
820 static bool convert_to_pfm(
PfmFile &pfm,
int x_size,
int y_size,
821 int num_components,
int component_width,
822 CPTA_uchar image,
size_t page_size,
824 static PTA_uchar read_dds_level_bgr8(
Texture *tex, CData *cdata,
const DDSHeader &header,
825 int n, std::istream &in);
826 static PTA_uchar read_dds_level_rgb8(
Texture *tex, CData *cdata,
const DDSHeader &header,
827 int n, std::istream &in);
828 static PTA_uchar read_dds_level_abgr8(
Texture *tex, CData *cdata,
const DDSHeader &header,
829 int n, std::istream &in);
830 static PTA_uchar read_dds_level_rgba8(
Texture *tex, CData *cdata,
const DDSHeader &header,
831 int n, std::istream &in);
832 static PTA_uchar read_dds_level_abgr16(
Texture *tex, CData *cdata,
const DDSHeader &header,
833 int n, std::istream &in);
834 static PTA_uchar read_dds_level_abgr32(
Texture *tex, CData *cdata,
const DDSHeader &header,
835 int n, std::istream &in);
836 static PTA_uchar read_dds_level_raw(
Texture *tex, CData *cdata,
const DDSHeader &header,
837 int n, std::istream &in);
838 static PTA_uchar read_dds_level_generic_uncompressed(
Texture *tex, CData *cdata,
839 const DDSHeader &header,
840 int n, std::istream &in);
841 static PTA_uchar read_dds_level_luminance_uncompressed(
Texture *tex, CData *cdata,
842 const DDSHeader &header,
843 int n, std::istream &in);
844 static PTA_uchar read_dds_level_bc1(
Texture *tex, CData *cdata,
845 const DDSHeader &header,
846 int n, std::istream &in);
847 static PTA_uchar read_dds_level_bc2(
Texture *tex, CData *cdata,
848 const DDSHeader &header,
849 int n, std::istream &in);
850 static PTA_uchar read_dds_level_bc3(
Texture *tex, CData *cdata,
851 const DDSHeader &header,
852 int n, std::istream &in);
853 static PTA_uchar read_dds_level_bc4(
Texture *tex, CData *cdata,
854 const DDSHeader &header,
855 int n, std::istream &in);
856 static PTA_uchar read_dds_level_bc5(
Texture *tex, CData *cdata,
857 const DDSHeader &header,
858 int n, std::istream &in);
862 static void consider_downgrade(
PNMImage &pnmimage,
int num_channels,
const std::string &name);
866 INLINE
static void store_unscaled_byte(
unsigned char *&p,
int value);
867 INLINE
static void store_unscaled_short(
unsigned char *&p,
int value);
868 INLINE
static void store_scaled_byte(
unsigned char *&p,
int value,
double scale);
869 INLINE
static void store_scaled_short(
unsigned char *&p,
int value,
double scale);
870 INLINE
static double get_unsigned_byte(
const unsigned char *&p);
871 INLINE
static double get_unsigned_short(
const unsigned char *&p);
872 INLINE
static double get_unsigned_int(
const unsigned char *&p);
873 INLINE
static double get_unsigned_int_24(
const unsigned char *&p);
874 INLINE
static double get_float(
const unsigned char *&p);
875 INLINE
static double get_half_float(
const unsigned char *&p);
877 INLINE
static bool is_txo_filename(
const Filename &fullpath);
878 INLINE
static bool is_dds_filename(
const Filename &fullpath);
879 INLINE
static bool is_ktx_filename(
const Filename &fullpath);
881 void do_filter_2d_mipmap_pages(
const CData *cdata,
882 RamImage &to,
const RamImage &from,
883 int x_size,
int y_size)
const;
885 void do_filter_3d_mipmap_level(
const CData *cdata,
886 RamImage &to,
const RamImage &from,
887 int x_size,
int y_size,
int z_size)
const;
889 typedef void Filter2DComponent(
unsigned char *&p,
890 const unsigned char *&q,
891 size_t pixel_size,
size_t row_size);
893 typedef void Filter3DComponent(
unsigned char *&p,
894 const unsigned char *&q,
895 size_t pixel_size,
size_t row_size,
898 static void filter_2d_unsigned_byte(
unsigned char *&p,
899 const unsigned char *&q,
900 size_t pixel_size,
size_t row_size);
901 static void filter_2d_unsigned_byte_srgb(
unsigned char *&p,
902 const unsigned char *&q,
903 size_t pixel_size,
size_t row_size);
904 static void filter_2d_unsigned_byte_srgb_sse2(
unsigned char *&p,
905 const unsigned char *&q,
906 size_t pixel_size,
size_t row_size);
907 static void filter_2d_unsigned_short(
unsigned char *&p,
908 const unsigned char *&q,
909 size_t pixel_size,
size_t row_size);
910 static void filter_2d_float(
unsigned char *&p,
const unsigned char *&q,
911 size_t pixel_size,
size_t row_size);
913 static void filter_3d_unsigned_byte(
unsigned char *&p,
914 const unsigned char *&q,
915 size_t pixel_size,
size_t row_size,
917 static void filter_3d_unsigned_byte_srgb(
unsigned char *&p,
918 const unsigned char *&q,
919 size_t pixel_size,
size_t row_size,
921 static void filter_3d_unsigned_byte_srgb_sse2(
unsigned char *&p,
922 const unsigned char *&q,
923 size_t pixel_size,
size_t row_size,
925 static void filter_3d_unsigned_short(
unsigned char *&p,
926 const unsigned char *&q,
927 size_t pixel_size,
size_t row_size,
929 static void filter_3d_float(
unsigned char *&p,
const unsigned char *&q,
930 size_t pixel_size,
size_t row_size,
size_t page_size);
932 bool do_squish(CData *cdata, CompressionMode compression,
int squish_flags);
933 bool do_unsquish(CData *cdata,
int squish_flags);
936 typedef pvector<RamImage> RamImages;
939 class EXPCL_PANDA_GOBJ CData :
public CycleData {
942 CData(
const CData ©);
943 ALLOC_DELETED_CHAIN(CData);
949 return Texture::get_class_type();
952 void do_assign(
const CData *copy);
953 INLINE
void inc_properties_modified();
954 INLINE
void inc_image_modified();
955 INLINE
void inc_simple_image_modified();
958 Filename _alpha_filename;
960 Filename _alpha_fullpath;
963 int _primary_file_num_channels;
968 int _alpha_file_channel;
975 int _component_width;
976 TextureType _texture_type;
978 ComponentType _component_type;
979 GeomEnums::UsageHint _usage_hint;
981 bool _loaded_from_image;
982 bool _loaded_from_txo;
983 bool _has_read_pages;
984 bool _has_read_mipmaps;
985 int _num_mipmap_levels_read;
987 SamplerState _default_sampler;
988 bool _keep_ram_image;
989 LColor _border_color;
990 CompressionMode _compression;
991 bool _render_to_texture;
992 bool _match_framebuffer_format;
993 bool _post_load_store_cache;
994 QualityLevel _quality_level;
1000 int _orig_file_x_size;
1001 int _orig_file_y_size;
1003 AutoTextureScale _auto_texture_scale;
1004 CompressionMode _ram_image_compression;
1009 RamImages _ram_images;
1013 RamImage _simple_ram_image;
1016 int32_t _simple_image_date_generated;
1019 bool _has_clear_color;
1020 LColor _clear_color;
1022 UpdateSeq _properties_modified;
1023 UpdateSeq _image_modified;
1024 UpdateSeq _simple_image_modified;
1027 static TypeHandle get_class_type() {
1028 return _type_handle;
1030 static void init_type() {
1035 static TypeHandle _type_handle;
1038 PipelineCycler<CData> _cycler;
1039 typedef CycleDataLockedReader<CData> CDLockedReader;
1040 typedef CycleDataReader<CData> CDReader;
1041 typedef CycleDataWriter<CData> CDWriter;
1042 typedef CycleDataStageReader<CData> CDStageReader;
1043 typedef CycleDataStageWriter<CData> CDStageWriter;
1049 ConditionVarFull _cvar;
1057 typedef pmap<int, TextureContext *> Contexts;
1058 typedef pmap<PreparedGraphicsObjects *, Contexts> PreparedViews;
1059 PreparedViews _prepared_views;
1066 typedef pmap<CPT(InternalName), PT(Texture)> RelatedTextures;
1067 RelatedTextures _related_textures;
1070 Filename _texture_pool_key;
1074 typedef pmap<std::string, PT(TypedReferenceCount) > AuxData;
1077 static AutoTextureScale _textures_power_2;
1078 static PStatCollector _texture_read_pcollector;
1082 static void register_with_read_factory();
1085 virtual void finalize(BamReader *manager);
1088 void do_write_datagram_header(CData *cdata, BamWriter *manager, Datagram &me,
bool &has_rawdata);
1089 virtual void do_write_datagram_body(CData *cdata, BamWriter *manager, Datagram &me);
1090 virtual void do_write_datagram_rawdata(CData *cdata, BamWriter *manager, Datagram &me);
1091 static TypedWritable *make_from_bam(
const FactoryParams ¶ms);
1092 virtual TypedWritable *make_this_from_bam(
const FactoryParams ¶ms);
1093 virtual void do_fillin_body(CData *cdata, DatagramIterator &scan, BamReader *manager);
1094 virtual void do_fillin_rawdata(CData *cdata, DatagramIterator &scan, BamReader *manager);
1095 virtual void do_fillin_from(CData *cdata,
const Texture *dummy);
1098 static TypeHandle get_class_type() {
1099 return _type_handle;
1101 static void init_type() {
1102 TypedWritableReferenceCount::init_type();
1104 TypedWritableReferenceCount::get_class_type());
1107 virtual TypeHandle get_type()
const {
1108 return get_class_type();
1110 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
1114 static TypeHandle _type_handle;
1116 friend class Extension<Texture>;
1117 friend class TextureContext;
1118 friend class PreparedGraphicsObjects;
1119 friend class TexturePool;
1120 friend class TexturePeeker;
1125EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::TextureType tt);
1126EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::ComponentType ct);
1127EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::Format f);
1129EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::CompressionMode cm);
1130EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::QualityLevel tql);
1131EXPCL_PANDA_GOBJ std::istream &operator >> (std::istream &in, Texture::QualityLevel &tql);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This class specializes ConfigVariable as an enumerated type.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
A single page of data maintained by a PipelineCycler.
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
The name of a file, such as a texture file or an Egg file.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
Encodes a string name in a hash table, mapping it to a pointer.
Specifies parameters that may be passed to the loader.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component,...
A table of objects that are saved within the graphics context for reference by handle later.
Represents a set of settings that indicate how a texture is sampled.
This is a special class object that holds all the information returned by a particular GSG to indicat...
An instance of this object is returned by Texture::peek().
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
size_t get_ram_mipmap_image_size(int n) const
Returns the number of bytes used by the in-memory image for mipmap level n, or 0 if there is no in-me...
void setup_2d_texture()
Sets the texture as an empty 2-d texture with no dimensions.
CPTA_uchar get_ram_image_as(const std::string &requested_format)
Returns the uncompressed system-RAM image data associated with the texture.
static TextureType string_texture_type(const std::string &str)
Returns the TextureType corresponding to the indicated string word.
virtual void ensure_loader_type(const Filename &filename)
May be called prior to calling read_txo() or any bam-related Texture- creating callback,...
get_post_load_store_cache
Returns the setting of the post_load_store_cache flag.
set_compression
Requests that this particular Texture be compressed when it is loaded into texture memory.
set_alpha_fullpath
Sets the full pathname to the file that contains the image's alpha channel contents,...
static PT(Texture) make_from_txo(std bool write_txo(std::ostream &out, const std::string &filename="") const
Writes the texture to a Panda texture object.
CPTA_uchar get_uncompressed_ram_image()
Returns the system-RAM image associated with the texture, in an uncompressed form if at all possible.
get_format
Returns the format of the texture, which represents both the semantic meaning of the texels and,...
get_minfilter
Returns the filter mode of the texture for minification.
get_ram_image_size
Returns the total number of bytes used by the in-memory image, across all pages and views,...
size_t get_expected_ram_mipmap_view_size(int n) const
Returns the number of bytes that *ought* to be used by each view of the in- memory image for mipmap l...
has_filename
Returns true if the filename has been set and is available.
void generate_ram_mipmap_images()
Automatically fills in the n mipmap levels of the Texture, based on the texture's source image.
void clear_ram_mipmap_images()
Discards the current system-RAM image for all mipmap levels, except level 0 (the base image).
set_match_framebuffer_format
Sets the special flag that, if true, indicates to the GSG that the Texture's format should be chosen ...
void clear_image()
Clears the texture data without changing its format or resolution.
PTA_uchar modify_ram_image()
Returns a modifiable pointer to the system-RAM image.
TextureContext * prepare_now(int view, PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
Creates a context for the texture on the particular GSG, if it does not already exist.
void setup_cube_map_array(int num_cube_maps)
Sets the texture as cube map array with N cube maps.
static std::string format_component_type(ComponentType ct)
Returns the indicated ComponentType converted to a string word.
size_t get_expected_ram_mipmap_image_size(int n) const
Returns the number of bytes that *ought* to be used by the in-memory image for mipmap level n,...
get_alpha_fullpath
Returns the alpha_fullpath that has been set.
Texture(const std::string &name=std::string())
Constructs an empty texture.
bool has_auto_texture_scale() const
Returns true if set_auto_texture_scale() has been set to something other than ATS_unspecified for thi...
set_wrap_u
This setting determines what happens when the texture is sampled with a U value outside the range 0....
bool get_resident(PreparedGraphicsObjects *prepared_objects) const
Returns true if this Texture is reported to be resident within graphics memory for the indicated GSG.
void setup_2d_texture_array(int z_size=1)
Sets the texture as an empty 2-d texture array with no dimensions (though if you know the depth ahead...
Texture * load_related(const InternalName *suffix) const
Loads a texture whose filename is derived by concatenating a suffix to the filename of this texture.
static CompressionMode string_compression_mode(const std::string &str)
Returns the CompressionMode value associated with the given string representation.
set_z_size
Changes the z size indicated for the texture.
set_num_views
Sets the number of "views" within a texture.
get_ram_page_size
Returns the number of bytes used by the in-memory image per page, or 0 if there is no in-memory image...
get_render_to_texture
Returns a flag on the texture that indicates whether the texture is intended to be used as a direct-r...
PTA_uchar new_simple_ram_image(int x_size, int y_size)
Creates an empty array for the simple ram image of the indicated size, and returns a modifiable point...
static bool is_specific(CompressionMode compression)
Returns true if the indicated compression mode is one of the specific compression types,...
int get_expected_mipmap_num_pages(int n) const
Returns the total number of pages that the nth mipmap level should have, based on the texture's size.
get_num_views
Returns the number of "views" in the texture.
get_compression
Returns the compression mode requested for this particular texture, or CM_off if the texture is not t...
get_wrap_w
Returns the wrap mode of the texture in the W direction.
bool has_ram_image() const
Returns true if the Texture has its image contents available in main RAM, false if it exists only in ...
static std::string format_quality_level(QualityLevel tql)
Returns the indicated QualityLevel converted to a string word.
size_t estimate_texture_memory() const
Estimates the amount of texture memory that will be consumed by loading this texture.
bool read(const Filename &fullpath, const LoaderOptions &options=LoaderOptions())
Reads the named filename into the texture.
void consider_rescale(PNMImage &pnmimage)
Asks the PNMImage to change its scale when it reads the image, according to the whims of the Config....
get_texture_type
Returns the overall interpretation of the texture.
bool write(const Filename &fullpath)
Writes the texture to the named filename.
static bool has_binary_alpha(Format format)
Returns true if the indicated format includes a binary alpha only, false otherwise.
get_filename
Returns the filename that has been set.
get_default_sampler
This returns the default sampler state for this texture, containing the wrap and filter properties sp...
int get_pad_y_size() const
Returns size of the pad region.
void * get_ram_mipmap_pointer(int n) const
Similiar to get_ram_mipmap_image(), however, in this case the void pointer for the given ram image is...
CPTA_uchar get_ram_image()
Returns the system-RAM image data associated with the texture.
static std::string format_compression_mode(CompressionMode cm)
Returns the indicated CompressionMode converted to a string word.
get_simple_ram_image
Returns the image data associated with the "simple" texture image.
get_aux_data
Returns a record previously recorded via set_aux_data().
has_fullpath
Returns true if the fullpath has been set and is available.
static bool is_srgb(Format format)
Returns true if the indicated format is in the sRGB color space, false otherwise.
get_ram_image_compression
Returns the compression mode in which the ram image is already stored pre- compressed.
get_effective_anisotropic_degree
Returns the degree of anisotropic filtering that should be applied to the texture.
set_format
Changes the format value for the texture components.
get_orig_file_z_size
Returns the Z size of the original disk image that this Texture was loaded from (if it came from a di...
get_component_width
Returns the number of bytes stored for each color component of a texel.
void set_orig_file_size(int x, int y, int z=1)
Specifies the size of the texture as it exists in its original disk file, before any Panda scaling.
void setup_texture(TextureType texture_type, int x_size, int y_size, int z_size, ComponentType component_type, Format format)
Sets the texture to the indicated type and dimensions, presumably in preparation for calling read() o...
get_alpha_filename
Returns the alpha_filename that has been set.
int get_expected_mipmap_z_size(int n) const
Returns the z_size that the nth mipmap level should have, based on the texture's size.
bool get_active(PreparedGraphicsObjects *prepared_objects) const
Returns true if this Texture was rendered in the most recent frame within the indicated GSG.
bool load(const PNMImage &pnmimage, const LoaderOptions &options=LoaderOptions())
Replaces the texture with the indicated image.
clear_fullpath
Removes the fullpath, if it was previously set.
bool reload()
Re-reads the Texture from its disk file.
vector_uchar get_clear_data() const
Returns the raw image data for a single pixel if it were set to the clear color.
void clear_simple_ram_image()
Discards the current "simple" image.
get_effective_minfilter
Returns the filter mode of the texture for minification, with special treatment for FT_default.
bool rescale_texture()
This method is similar to consider_rescale(), but instead of scaling a separate PNMImage,...
get_keep_ram_image
Returns the flag that indicates whether this Texture is eligible to have its main RAM copy of the tex...
bool read_dds(std::istream &in, const std::string &filename="", bool header_only=false)
Reads the texture from a DDS file object.
set_anisotropic_degree
Specifies the level of anisotropic filtering to apply to the texture.
set_render_to_texture
Sets a flag on the texture that indicates whether the texture is intended to be used as a direct-rend...
set_loaded_from_image
Sets the flag that indicates the texture has been loaded from a disk file or PNMImage.
set_quality_level
Sets a hint to the renderer about the desired performance / quality tradeoff for this particular text...
set_clear_color
Sets the color that will be used to fill the texture image in absence of any image data.
get_expected_num_mipmap_levels
Returns the number of mipmap levels that should be defined for this texture, given the texture's size...
void generate_normalization_cube_map(int size)
Generates a special cube map image in the texture that can be used to apply bump mapping effects: for...
clear_alpha_fullpath
Removes the alpha fullpath, if it was previously set.
void setup_cube_map()
Sets the texture as an empty cube map texture with no dimensions.
get_anisotropic_degree
Returns the degree of anisotropic filtering that should be applied to the texture.
has_alpha_fullpath
Returns true if the alpha_fullpath has been set and is available.
get_match_framebuffer_format
Returns true if the special flag was set that indicates to the GSG that the Texture's format should b...
PTA_uchar modify_ram_mipmap_image(int n)
Returns a modifiable pointer to the system-RAM image for the nth mipmap level.
get_properties_modified
Returns a sequence number which is guaranteed to change at least every time the texture properties (u...
clear_alpha_filename
Removes the alpha filename, if it was previously set.
bool has_compression() const
Returns true if the texture indicates it wants to be compressed, either with CM_on or higher,...
static QualityLevel string_quality_level(const std::string &str)
Returns the QualityLevel value associated with the given string representation.
get_y_size
Returns the height of the texture image in texels.
void generate_alpha_scale_map()
Generates a special 256x1 1-d texture that can be used to apply an arbitrary alpha scale to objects b...
bool compress_ram_image(CompressionMode compression=CM_on, QualityLevel quality_level=QL_default, GraphicsStateGuardianBase *gsg=nullptr)
Attempts to compress the texture's RAM image internally, to a format supported by the indicated GSG.
bool load_sub_image(const PNMImage &pnmimage, int x, int y, int z=0, int n=0)
Stores the indicated image in a region of the texture.
size_t get_ram_mipmap_view_size(int n) const
Returns the number of bytes used by the in-memory image per view for mipmap level n,...
get_magfilter
Returns the filter mode of the texture for magnification.
LVecBase2 get_tex_scale() const
Returns a scale pair that is suitable for applying to geometry via NodePath::set_tex_scale(),...
get_z_size
Returns the depth of the texture image in texels.
bool read_txo(std::istream &in, const std::string &filename="")
Reads the texture from a Panda texture object.
int get_pad_x_size() const
Returns size of the pad region.
get_image_modified
Returns a sequence number which is guaranteed to change at least every time the texture image data (i...
set_x_size
Changes the x size indicated for the texture.
get_quality_level
Returns the current quality_level hint.
get_simple_image_modified
Returns a sequence number which is guaranteed to change at least every time the texture's "simple" im...
void set_ram_mipmap_image(int n, CPTA_uchar image, size_t page_size=0)
Replaces the current system-RAM image for the indicated mipmap level with the new data.
size_t get_expected_ram_mipmap_page_size(int n) const
Returns the number of bytes that should be used per each Z page of the 3-d texture,...
void setup_1d_texture()
Sets the texture as an empty 1-d texture with no dimensions.
static ComponentType string_component_type(const std::string &str)
Returns the ComponentType corresponding to the indicated string word.
set_minfilter
Sets the filtering method that should be used when viewing the texture from a distance.
get_effective_magfilter
Returns the filter mode of the texture for magnification, with special treatment for FT_default.
static bool adjust_size(int &x_size, int &y_size, const std::string &name, bool for_padding, AutoTextureScale auto_texture_scale=ATS_unspecified)
Computes the proper size of the texture, based on the original size, the filename,...
has_alpha_filename
Returns true if the alpha_filename has been set and is available.
static int up_to_power_2(int value)
Returns the smallest power of 2 greater than or equal to value.
set_magfilter
Sets the filtering method that should be used when viewing the texture up close.
bool might_have_ram_image() const
Returns true if the texture's image contents are currently available in main RAM, or there is reason ...
PTA_uchar make_ram_mipmap_image(int n)
Discards the current system-RAM image for the nth mipmap level, if any, and allocates a new buffer of...
static AutoTextureScale get_textures_power_2()
This flag returns ATS_none, ATS_up, or ATS_down and controls the scaling of textures in general.
int get_pad_z_size() const
Returns size of the pad region.
bool has_ram_mipmap_image(int n) const
Returns true if the Texture has the nth mipmap level available in system memory, false otherwise.
get_loaded_from_image
Returns the flag that indicates the texture has been loaded from a disk file or PNMImage.
get_auto_texture_scale
Returns the power-of-2 texture-scaling mode that will be applied to this particular texture when it i...
void set_ram_mipmap_pointer_from_int(long long pointer, int n, int page_size)
Accepts a raw pointer cast as an int, which is then passed to set_ram_mipmap_pointer(); see the docum...
void setup_buffer_texture(int size, ComponentType component_type, Format format, GeomEnums::UsageHint usage)
Sets the texture as an empty buffer texture with the specified size and properties.
void set_pad_size(int x=0, int y=0, int z=0)
Sets the size of the pad region.
static int down_to_power_2(int value)
Returns the largest power of 2 less than or equal to value.
bool release(PreparedGraphicsObjects *prepared_objects)
Frees the texture context only on the indicated object, if it exists there.
int get_expected_mipmap_x_size(int n) const
Returns the x_size that the nth mipmap level should have, based on the texture's size.
virtual bool has_cull_callback() const
Should be overridden by derived classes to return true if cull_callback() has been defined.
void set_simple_ram_image(CPTA_uchar image, int x_size, int y_size)
Replaces the internal "simple" texture image.
get_num_components
Returns the number of color components for each texel of the texture image.
get_effective_quality_level
Returns the current quality_level hint, or the global default quality_level if this texture doesn't s...
void clear_ram_image()
Discards the current system-RAM image.
bool uses_mipmaps() const
Returns true if the minfilter settings on this texture indicate the use of mipmapping,...
static std::string format_texture_type(TextureType tt)
Returns the indicated TextureType converted to a string word.
get_fullpath
Returns the fullpath that has been set.
set_default_sampler
This sets the default sampler state for this texture, containing the wrap and filter properties speci...
has_clear_color
Returns true if a color was previously set using set_clear_color.
get_wrap_u
Returns the wrap mode of the texture in the U direction.
set_loaded_from_txo
Sets the flag that indicates the texture has been loaded from a txo file.
get_num_pages
Returns the total number of pages in the texture.
has_simple_ram_image
Returns true if the Texture has a "simple" image available in main RAM.
set_auto_texture_scale
Specifies the power-of-2 texture-scaling mode that will be applied to this particular texture when it...
static bool is_integer(Format format)
Returns true if the indicated format is an integer format, false otherwise.
PTA_uchar modify_simple_ram_image()
Returns a modifiable pointer to the internal "simple" texture image.
static void set_textures_power_2(AutoTextureScale scale)
Set this flag to ATS_none, ATS_up, ATS_down, or ATS_pad to control the scaling of textures in general...
size_t get_simple_ram_image_size() const
Returns the number of bytes used by the "simple" image, or 0 if there is no simple image.
get_orig_file_x_size
Returns the X size of the original disk image that this Texture was loaded from (if it came from a di...
size_t get_ram_mipmap_page_size(int n) const
Returns the number of bytes used by the in-memory image per page for mipmap level n,...
void clear_ram_mipmap_image(int n)
Discards the current system-RAM image for the nth mipmap level.
bool was_image_modified(PreparedGraphicsObjects *prepared_objects) const
Returns true if the texture needs to be re-loaded onto the indicated GSG, either because its image da...
bool read_ktx(std::istream &in, const std::string &filename="", bool header_only=false)
Reads the texture from a KTX file object.
get_x_size
Returns the width of the texture image in texels.
bool has_uncompressed_ram_image() const
Returns true if the Texture has its image contents available in main RAM and is uncompressed,...
bool has_all_ram_mipmap_images() const
Returns true if all expected mipmap levels have been defined and exist in the system RAM,...
clear_clear_color
The opposite of set_clear_color.
size_t get_data_size_bytes(PreparedGraphicsObjects *prepared_objects) const
Returns the number of bytes which the texture is reported to consume within graphics memory,...
get_simple_y_size
Returns the height of the "simple" image in texels.
get_expected_ram_page_size
Returns the number of bytes that should be used per each Z page of the 3-d texture.
set_fullpath
Sets the full pathname to the file that contains the image's contents, as found along the search path...
virtual bool cull_callback(CullTraverser *trav, const CullTraverserData &data) const
If has_cull_callback() returns true, this function will be called during the cull traversal to perfor...
int get_expected_mipmap_y_size(int n) const
Returns the y_size that the nth mipmap level should have, based on the texture's size.
bool uncompress_ram_image()
Attempts to uncompress the texture's RAM image internally.
set_y_size
Changes the y size indicated for the texture.
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the texture has already been prepared or enqueued for preparation on the indicated GS...
get_expected_ram_image_size
Returns the number of bytes that *ought* to be used by the in-memory image, based on the texture para...
set_post_load_store_cache
Sets the post_load_store_cache flag.
void set_ram_image_as(CPTA_uchar image, const std::string &provided_format)
Replaces the current system-RAM image with the new data, converting it first if necessary from the in...
void set_ram_mipmap_pointer(int n, void *image, size_t page_size=0)
Sets an explicit void pointer as the texture's mipmap image for the indicated level.
set_aux_data
Records an arbitrary object in the Texture, associated with a specified key.
set_wrap_w
The W wrap direction is only used for 3-d textures.
void texture_uploaded()
This method is called by the GraphicsEngine at the beginning of the frame *after* a texture has been ...
void set_size_padded(int x=1, int y=1, int z=1)
Changes the size of the texture, padding if necessary, and setting the pad region as well.
PTA_uchar make_ram_image()
Discards the current system-RAM image for the texture, if any, and allocates a new buffer of the appr...
static bool has_alpha(Format format)
Returns true if the indicated format includes alpha, false otherwise.
get_component_type
Returns the numeric interpretation of each component of the texture.
void set_ram_image(CPTA_uchar image, CompressionMode compression=CM_off, size_t page_size=0)
Replaces the current system-RAM image with the new data.
bool adjust_this_size(int &x_size, int &y_size, const std::string &name, bool for_padding) const
Works like adjust_size, but also considers the texture class.
get_simple_x_size
Returns the width of the "simple" image in texels.
get_loaded_from_txo
Returns the flag that indicates the texture has been loaded from a txo file.
get_num_loadable_ram_mipmap_images
Returns the number of contiguous mipmap levels that exist in RAM, up until the first gap in the seque...
get_wrap_v
Returns the wrap mode of the texture in the V direction.
void generate_simple_ram_image()
Computes the "simple" ram image by loading the main RAM image, if it is not already available,...
static Format string_format(const std::string &str)
Returns the Format corresponding to the indicated string word.
get_border_color
Returns the solid color of the texture's border.
clear_aux_data
Removes a record previously recorded via set_aux_data().
int release_all()
Frees the context allocated on all objects for which the texture has been declared.
CPTA_uchar get_ram_mipmap_image(int n) const
Returns the system-RAM image data associated with the nth mipmap level, if present.
get_clear_color
Returns the color that was previously set using set_clear_color.
set_keep_ram_image
Sets the flag that indicates whether this Texture is eligible to have its main RAM copy of the textur...
clear_filename
Removes the filename, if it was previously set.
set_border_color
Specifies the solid color of the texture's border.
static std::string format_format(Format f)
Returns the indicated Format converted to a string word.
is_cacheable
Returns true if there is enough information in this Texture object to write it to the bam cache succe...
get_ram_view_size
Returns the number of bytes used by the in-memory image per view, or 0 if there is no in-memory image...
set_alpha_filename
Sets the name of the file that contains the image's alpha channel contents.
set_wrap_v
This setting determines what happens when the texture is sampled with a V value outside the range 0....
set_filename
Sets the name of the file that contains the image's contents.
bool store(PNMImage &pnmimage) const
Saves the texture to the indicated PNMImage, but does not write it to disk.
static bool has_textures_power_2()
If true, then get_textures_power_2 has been set using set_textures_power_2.
set_component_type
Changes the data value for the texture components.
get_orig_file_y_size
Returns the Y size of the original disk image that this Texture was loaded from (if it came from a di...
get_num_ram_mipmap_images
Returns the maximum number of mipmap level images available in system memory.
void setup_3d_texture(int z_size=1)
Sets the texture as an empty 3-d texture with no dimensions (though if you know the depth ahead of ti...
static bool is_unsigned(ComponentType ctype)
Returns true if the indicated component type is unsigned, false otherwise.
get_usage_hint
Returns the usage hint specified for buffer textures, or UH_unspecified for all other texture types.
TypeHandle is the identifier used to differentiate C++ class types.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
Base class for objects that can be written to and read from Bam files.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is a sequence number that increments monotonically.
This is our own Panda specialization on the default STL list.
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.
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.
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.
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.
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(),...
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.