00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GEOMSPRITE_H
00020 #define GEOMSPRITE_H
00021
00022 #include <pta_float.h>
00023 #include "geom.h"
00024
00025
00026
00027
00028
00029 class EXPCL_PANDA GeomSprite : public Geom {
00030 public:
00031 GeomSprite(Texture *tex = (Texture *) NULL,
00032 bool alpha_disable = false);
00033
00034 virtual Geom *make_copy() const;
00035 virtual void print_draw_immediate() const;
00036 virtual void draw_immediate(GraphicsStateGuardianBase *gsg, GeomContext *gc);
00037
00038 virtual int get_num_vertices_per_prim() const { return 1; }
00039 virtual int get_num_more_vertices_than_components() const { return 0; }
00040 virtual bool uses_components() const { return false; }
00041 virtual int get_length(int) const { return 1; }
00042
00043 virtual Geom *explode() const {
00044 return new GeomSprite(*this); }
00045
00046 static float get_frustum_top() { return 1.0f; }
00047 static float get_frustum_bottom() { return -1.0f; }
00048 static float get_frustum_left() { return -1.0f; }
00049 static float get_frustum_right() { return 1.0f; }
00050
00051 INLINE void set_texture(Texture *tex);
00052 INLINE Texture *get_texture() const;
00053
00054 INLINE void set_ll_uv(const TexCoordf &ll_uv);
00055 INLINE const TexCoordf &get_ll_uv() const;
00056
00057 INLINE void set_ur_uv(const TexCoordf &ur_uv);
00058 INLINE const TexCoordf &get_ur_uv() const;
00059
00060 INLINE void set_alpha_disable(bool a);
00061 INLINE bool get_alpha_disable() const;
00062
00063 INLINE void set_x_texel_ratio(PTA_float x_texel_ratio, GeomBindType x_bind_type);
00064 INLINE void set_y_texel_ratio(PTA_float y_texel_ratio, GeomBindType y_bind_type);
00065 INLINE void set_thetas(PTA_float theta, GeomBindType theta_bind_type);
00066
00067 INLINE GeomBindType get_x_bind_type() const;
00068 INLINE GeomBindType get_y_bind_type() const;
00069 INLINE GeomBindType get_theta_bind_type() const;
00070
00071
00072 PTA_float _x_texel_ratio;
00073 PTA_float _y_texel_ratio;
00074 PTA_float _theta;
00075
00076 protected:
00077 PT(Texture) _texture;
00078 TexCoordf _ll_uv;
00079 TexCoordf _ur_uv;
00080
00081 bool _alpha_disable;
00082
00083 GeomBindType _x_bind_type;
00084 GeomBindType _y_bind_type;
00085 GeomBindType _theta_bind_type;
00086
00087 public:
00088 static void register_with_read_factory();
00089 virtual void write_datagram(BamWriter *manager, Datagram &me);
00090
00091 int complete_pointers(TypedWritable **plist, BamReader *manager);
00092 static TypedWritable *make_GeomSprite(const FactoryParams ¶ms);
00093
00094 protected:
00095 void fillin(DatagramIterator &scan, BamReader *manager);
00096
00097 PUBLISHED:
00098 static TypeHandle get_class_type() {
00099 return _type_handle;
00100 }
00101 public:
00102 static void init_type() {
00103 Geom::init_type();
00104 register_type(_type_handle, "GeomSprite",
00105 Geom::get_class_type());
00106 }
00107 virtual TypeHandle get_type() const {
00108 return get_class_type();
00109 }
00110 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00111
00112 private:
00113 static TypeHandle _type_handle;
00114 };
00115
00116 #include "geomSprite.I"
00117
00118 #endif // GEOMSPRITE_H