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