00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_PROCTEX_H__
00021 #define __CS_PROCTEX_H__
00022
00023 #include <stdarg.h>
00024 #include "csutil/csobject.h"
00025 #include "qint.h"
00026
00027 struct iTextureWrapper;
00028 struct iMaterialWrapper;
00029 struct iEngine;
00030
00031 struct iObjectRegistry;
00032 struct iGraphics2D;
00033 struct iGraphics3D;
00034 struct iTextureManager;
00035 struct iTextureWrapper;
00036 struct iEventHandler;
00037
00042 class csProcTexture : public csObject
00043 {
00044 friend struct ProcCallback;
00045
00046 private:
00047
00048
00049 static iEventHandler* SetupProcEventHandler (iObjectRegistry* object_reg);
00050 csRef<iEventHandler> proceh;
00051
00052 protected:
00053
00054 bool ptReady;
00055
00056
00057 int texFlags;
00058
00059
00060 iTextureWrapper* tex;
00061
00062 int mat_w, mat_h;
00063 csRef<iGraphics3D> g3d;
00064 csRef<iGraphics2D> g2d;
00065 iObjectRegistry* object_reg;
00066 bool anim_prepared;
00067
00068 bool key_color;
00069 int key_red, key_green, key_blue;
00070
00071
00072
00073
00074 bool use_cb;
00075
00076 public:
00077
00078
00079
00080 csTicks last_cur_time;
00081
00082 private:
00083 static void ProcCallback (iTextureWrapper* txt, void* data);
00084
00085 public:
00086 csProcTexture ();
00087 virtual ~csProcTexture ();
00088
00089 iGraphics3D* GetG3D () { return g3d; }
00090 iGraphics2D* GetG2D () { return g2d; }
00091
00099 void DisableAutoUpdate () { use_cb = false; }
00100
00115 virtual bool Initialize (iObjectRegistry* object_reg);
00116
00126 iMaterialWrapper* Initialize (iObjectRegistry* object_reg, iEngine* engine,
00127 iTextureManager* txtmgr, const char* name);
00128
00133 virtual bool PrepareAnim ();
00134
00136 void SetKeyColor (int red, int green, int blue)
00137 {
00138 key_color = true;
00139 key_red = red;
00140 key_green = green;
00141 key_blue = blue;
00142 }
00143
00148 virtual void Animate (csTicks current_time) = 0;
00149
00151 iTextureWrapper* GetTextureWrapper () { return tex; }
00152
00154 virtual void GetDimension (int &w, int &h)
00155 { w = mat_w; h = mat_h; }
00156
00157 static int GetRandom (int max)
00158 {
00159 return int ((float(max)*rand()/(RAND_MAX+1.0)));
00160 }
00161 };
00162
00163
00164 #endif // __CS_PROCTEX_H__
00165