00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef TEXTUREPEEKER_H
00016 #define TEXTUREPEEKER_H
00017
00018 #include "pandabase.h"
00019
00020 #include "referenceCount.h"
00021 #include "texture.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030 class EXPCL_PANDA_GOBJ TexturePeeker : public ReferenceCount {
00031 private:
00032 TexturePeeker(Texture *tex, Texture::CData *cdata);
00033
00034 public:
00035 INLINE bool is_valid() const;
00036
00037 PUBLISHED:
00038 INLINE int get_x_size() const;
00039 INLINE int get_y_size() const;
00040 INLINE int get_z_size() const;
00041
00042 void lookup(LColor &color, PN_stdfloat u, PN_stdfloat v) const;
00043 void lookup(LColor &color, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) const;
00044 void filter_rect(LColor &color,
00045 PN_stdfloat min_u, PN_stdfloat min_v,
00046 PN_stdfloat max_u, PN_stdfloat max_v) const;
00047 void filter_rect(LColor &color,
00048 PN_stdfloat min_u, PN_stdfloat min_v, PN_stdfloat min_w,
00049 PN_stdfloat max_u, PN_stdfloat max_v, PN_stdfloat max_w) const;
00050
00051 private:
00052 static void init_rect_minmax(int &min_x, int &max_x,
00053 PN_stdfloat &min_u, PN_stdfloat &max_u,
00054 int x_size);
00055
00056 void accum_filter_z(LColor &color, PN_stdfloat &net,
00057 int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u,
00058 int min_y, int max_y, PN_stdfloat min_v, PN_stdfloat max_v,
00059 int min_z, int max_z, PN_stdfloat min_w, PN_stdfloat max_w) const;
00060 void accum_filter_y(LColor &color, PN_stdfloat &net, int zi,
00061 int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u,
00062 int min_y, int max_y, PN_stdfloat min_v, PN_stdfloat max_v,
00063 PN_stdfloat weight) const;
00064 void accum_filter_x(LColor &color, PN_stdfloat &net, int yi, int zi,
00065 int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u,
00066 PN_stdfloat weight) const;
00067 void accum_texel(LColor &color, PN_stdfloat &net, const unsigned char *&p,
00068 PN_stdfloat weight) const;
00069
00070 typedef double GetComponentFunc(const unsigned char *&p);
00071 typedef void GetTexelFunc(LColor &color, const unsigned char *&p,
00072 GetComponentFunc *get_component);
00073
00074 static void get_texel_r(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
00075 static void get_texel_g(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
00076 static void get_texel_b(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
00077 static void get_texel_a(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
00078 static void get_texel_l(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
00079 static void get_texel_la(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
00080 static void get_texel_rgb(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
00081 static void get_texel_rgba(LColor &color, const unsigned char *&p, GetComponentFunc *get_component);
00082
00083 int _x_size;
00084 int _y_size;
00085 int _z_size;
00086 int _component_width;
00087 int _num_components;
00088 int _pixel_width;
00089 Texture::Format _format;
00090 Texture::ComponentType _component_type;
00091 CPTA_uchar _image;
00092
00093 GetComponentFunc *_get_component;
00094 GetTexelFunc *_get_texel;
00095
00096 friend class Texture;
00097 };
00098
00099 #include "texturePeeker.I"
00100
00101 #endif
00102