model.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. enum { ANIM_IDLE = 0, ANIM_RUN, ANIM_ATTACK, ANIM_PAIN, ANIM_JUMP, ANIM_LAND, ANIM_FLIPOFF, ANIM_SALUTE, ANIM_TAUNT, ANIM_WAVE, ANIM_POINT, ANIM_CROUCH_IDLE, ANIM_CROUCH_WALK, ANIM_CROUCH_ATTACK, ANIM_CROUCH_PAIN, ANIM_CROUCH_DEATH, ANIM_DEATH, ANIM_LYING_DEAD, ANIM_FLAG, ANIM_GUN_IDLE, ANIM_GUN_SHOOT, ANIM_GUN_RELOAD, ANIM_GUN_THROW, ANIM_MAPMODEL, ANIM_TRIGGER, ANIM_DECAY, ANIM_ALL, NUMANIMS };
  2. #define ANIM_INDEX 0xFF
  3. #define ANIM_LOOP (1<<8)
  4. #define ANIM_START (1<<9)
  5. #define ANIM_END (1<<10)
  6. #define ANIM_REVERSE (1<<11)
  7. #define ANIM_NOINTERP (1<<12)
  8. #define ANIM_MIRROR (1<<13)
  9. #define ANIM_NOSKIN (1<<14)
  10. #define ANIM_TRANSLUCENT (1<<15)
  11. #define ANIM_PARTICLE (1<<16)
  12. #define ANIM_DYNALLOC (1<<17)
  13. struct animstate // used for animation blending of animated characters
  14. {
  15. int anim, frame, range, basetime;
  16. float speed;
  17. animstate() { reset(); }
  18. void reset() { anim = frame = range = basetime = 0; speed = 100.0f; };
  19. bool operator==(const animstate &o) const { return frame==o.frame && range==o.range && basetime==o.basetime && speed==o.speed; }
  20. bool operator!=(const animstate &o) const { return frame!=o.frame || range!=o.range || basetime!=o.basetime || speed!=o.speed; }
  21. };
  22. enum { MDL_MD2 = 1, MDL_MD3 };
  23. struct model;
  24. struct modelattach
  25. {
  26. const char *tag, *name;
  27. vec *pos;
  28. model *m;
  29. modelattach() : tag(NULL), name(NULL), pos(NULL), m(NULL) {}
  30. modelattach(const char *tag, const char *name) : tag(tag), name(name), pos(NULL), m(NULL) {}
  31. modelattach(const char *tag, vec *pos) : tag(tag), name(NULL), pos(pos), m(NULL) {}
  32. };
  33. class dynent;
  34. struct model
  35. {
  36. bool cullface, vertexlight, alphablend; //ALX Alpha channel models
  37. float alphatest, translucency, scale, radius, zradius, shadowdist;
  38. vec translate;
  39. int cachelimit, batch;
  40. //model() : cullface(true), vertexlight(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {}
  41. model() : cullface(true), vertexlight(false), alphablend(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), zradius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {}
  42. virtual ~model() {}
  43. virtual bool load() = 0;
  44. virtual char *name() = 0;
  45. virtual int type() = 0;
  46. virtual void cleanup() = 0;
  47. virtual void render(int anim, int varseed, float speed, int basetime, const vec &o, float roll, float yaw, float pitch, dynent *d, modelattach *a = NULL, float scale = 1.0f) = 0;
  48. virtual void setskin(int tex = 0) = 0;
  49. virtual void genshadows(float height, float rad) {}
  50. virtual void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, modelattach *a = NULL) {}
  51. virtual bool hasshadows() { return false; }
  52. virtual void startrender() {}
  53. virtual void endrender() {}
  54. };
  55. struct mapmodelinfo { int rad, h, zoff; float scale; string name; model *m; int flags; };
  56. enum { MMA_KEYWORDS = 0, MMA_DESC, MMA_DEFAULTPARAMS, MMA_USAGE, MMA_AUTHOR, MMA_LICENSE, MMA_DISTRIBUTION, MMA_VERSION, MMA_REQUIRES, MMA_NUM };
  57. enum { MMF_REQUIRED = 1<<0, MMF_TEMP_USED = 1<<30, MMF_CONFIGMASK = 0xff };
  58. struct mapmodelattributes
  59. {
  60. string name;
  61. const char *n[MMA_NUM];
  62. int tmp;
  63. mapmodelattributes() { memset(this, 0, sizeof(*this)); }
  64. };