]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/entity/entity_entitymodel.h
some updates to the Linux build system - obtained a core binary and all required...
[xonotic/netradiant.git] / plugins / entity / entity_entitymodel.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \r
7 GtkRadiant is free software; you can redistribute it and/or modify\r
8 it under the terms of the GNU General Public License as published by\r
9 the Free Software Foundation; either version 2 of the License, or\r
10 (at your option) any later version.\r
11 \r
12 GtkRadiant is distributed in the hope that it will be useful,\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 GNU General Public License for more details.\r
16 \r
17 You should have received a copy of the GNU General Public License\r
18 along with GtkRadiant; if not, write to the Free Software\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
20 */\r
21 \r
22 #ifndef _ENTITYMODEL_H_\r
23 #define _ENTITYMODEL_H_\r
24 \r
25 #include "plugin.h"\r
26 \r
27 /*! simulates misc_model entity behaviours for rendering/selection/editing */\r
28 class CEntityMiscModel : public IRender, public ISelect, public IEdit\r
29 {\r
30 public:\r
31   CEntityMiscModel (entity_t *e);\r
32   virtual ~CEntityMiscModel ();\r
33 \r
34   void IncRef() { refCount++; }\r
35   void DecRef() { if(--refCount == 0) delete this; }\r
36 \r
37   // IRender\r
38   void Draw(int state, int rflags) const;\r
39   const aabb_t *GetAABB() const { return &m_BBox; }\r
40 \r
41   // ISelect\r
42   bool TestRay(const ray_t *ray, vec_t *dist) const;\r
43   //bool TestBox(const aabb_t aabb) const;\r
44 \r
45   // ITransform\r
46   void Translate(const vec3_t translation);\r
47   void Rotate(const vec3_t pivot, const vec3_t rotation);\r
48   const vec_t *GetTranslation() const { return m_translate; }\r
49   const vec_t *GetRotation() const { return m_euler; }\r
50   void OnKeyValueChanged(entity_t *e, const char *key, const char* value);\r
51 \r
52   void SetName(const char *name);\r
53 private:\r
54   void BuildCacheRequestString(const char *name);\r
55   /*! updates the AABB and transformation matrix */\r
56   void UpdateCachedData();\r
57   entity_interfaces_t *m_model;\r
58 \r
59   entity_t *m_entity;\r
60 \r
61   int refCount;\r
62   string_t m_version;\r
63 \r
64   Str m_cachereq;\r
65 \r
66    /*! AABB in local space */\r
67   aabb_t m_BBox;\r
68 \r
69   /*! worldspace-to-localspace translation */\r
70   vec3_t m_translate;\r
71 \r
72   /*! worldspace-to-localspace euler rotation angles */\r
73   vec3_t m_euler;\r
74 \r
75   /*! worldspace-to-localspace scale */\r
76   vec3_t m_scale;\r
77 \r
78   /*! localspace origin, effectively rotation & scale pivot point */\r
79   vec3_t m_pivot;\r
80 \r
81   /*! worldspace-to-localspace transform, generated from translate/euler/scale/pivot */\r
82   m4x4_t m_transform;\r
83 \r
84   /*! localspace-to-worldspace transform */\r
85   m4x4_t m_inverse_transform;\r
86 };\r
87 \r
88 /*! simulates eclass-model entity behaviours for rendering/selection/editing */\r
89 class CEntityEclassModel : public IRender, public ISelect, public IEdit\r
90 {\r
91 public:\r
92   CEntityEclassModel ();\r
93   virtual ~CEntityEclassModel ();\r
94 \r
95   void IncRef() { refCount++; }\r
96   void DecRef() { if(--refCount == 0) delete this; }\r
97 \r
98   // IRender\r
99   void Draw(int state, int rflags) const;\r
100   const aabb_t *GetAABB() const { return &m_BBox; }\r
101 \r
102   // ISelect\r
103   bool TestRay(const ray_t *ray, vec_t *dist) const;\r
104   //bool TestBox(const aabb_t aabb) const;\r
105 \r
106   // ITransform\r
107   void Translate(const vec3_t translation);\r
108   void Rotate(const vec3_t pivot, const vec3_t rotation);\r
109   const vec_t *GetTranslation() const { return m_translate; }\r
110   const vec_t *GetRotation() const { return m_euler; }\r
111   void OnKeyValueChanged(entity_t *e, const char *key, const char* value);\r
112 \r
113   void SetName(const char *name);\r
114   void SetEclass(const eclass_t* eclass);\r
115 private:\r
116   /*! updates the AABB and transformation matrix */\r
117   void UpdateCachedData();\r
118   entity_interfaces_t *m_model;\r
119 \r
120   int refCount;\r
121   string_t m_name;\r
122   string_t m_version;\r
123   const eclass_t *m_eclass;\r
124 \r
125   /*! AABB in local space */\r
126   aabb_t m_BBox;\r
127 \r
128   /*! worldspace-to-localspace translation */\r
129   vec3_t m_translate;\r
130 \r
131   /*! worldspace-to-localspace euler rotation angles */\r
132   vec3_t m_euler;\r
133 \r
134   /*! worldspace-to-localspace scale */\r
135   vec3_t m_scale;\r
136 \r
137   /*! localspace origin, effectively rotation & scale pivot point */\r
138   vec3_t m_pivot;\r
139 \r
140   /*! worldspace-to-localspace transform, generated from translate/euler/scale/pivot */\r
141   m4x4_t m_transform;\r
142 \r
143   /*! localspace-to-worldspace transform */\r
144   m4x4_t m_inverse_transform;\r
145 };\r
146 \r
147 void pivot_draw(const vec3_t pivot);\r
148 void Entity_UpdateClass(entity_t *e, const char* value);\r
149 \r
150 #endif /* _ENTITYMODEL_H_ */\r