]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/entity/entity_entitymodel.h
error check and bail if permission denied during gamepack install
[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() {
36         if ( --refCount == 0 ) {
37                 delete this;
38         }
39 }
40
41 // IRender
42 void Draw( int state, int rflags ) const;
43 const aabb_t *GetAABB() const { return &m_BBox; }
44
45 // ISelect
46 bool TestRay( const ray_t *ray, vec_t *dist ) const;
47 //bool TestBox(const aabb_t aabb) const;
48
49 // ITransform
50 void Translate( const vec3_t translation );
51 void Rotate( const vec3_t pivot, const vec3_t rotation );
52 const vec_t *GetTranslation() const { return m_translate; }
53 const vec_t *GetRotation() const { return m_euler; }
54 void OnKeyValueChanged( entity_t *e, const char *key, const char* value );
55
56 void SetName( const char *name );
57 private:
58 void BuildCacheRequestString( const char *name );
59 /*! updates the AABB and transformation matrix */
60 void UpdateCachedData();
61 entity_interfaces_t *m_model;
62
63 entity_t *m_entity;
64
65 int refCount;
66 string_t m_version;
67
68 Str m_cachereq;
69
70 /*! AABB in local space */
71 aabb_t m_BBox;
72
73 /*! worldspace-to-localspace translation */
74 vec3_t m_translate;
75
76 /*! worldspace-to-localspace euler rotation angles */
77 vec3_t m_euler;
78
79 /*! worldspace-to-localspace scale */
80 vec3_t m_scale;
81
82 /*! localspace origin, effectively rotation & scale pivot point */
83 vec3_t m_pivot;
84
85 /*! worldspace-to-localspace transform, generated from translate/euler/scale/pivot */
86 m4x4_t m_transform;
87
88 /*! localspace-to-worldspace transform */
89 m4x4_t m_inverse_transform;
90 };
91
92 /*! simulates eclass-model entity behaviours for rendering/selection/editing */
93 class CEntityEclassModel : public IRender, public ISelect, public IEdit
94 {
95 public:
96 CEntityEclassModel ();
97 virtual ~CEntityEclassModel ();
98
99 void IncRef() { refCount++; }
100 void DecRef() {
101         if ( --refCount == 0 ) {
102                 delete this;
103         }
104 }
105
106 // IRender
107 void Draw( int state, int rflags ) const;
108 const aabb_t *GetAABB() const { return &m_BBox; }
109
110 // ISelect
111 bool TestRay( const ray_t *ray, vec_t *dist ) const;
112 //bool TestBox(const aabb_t aabb) const;
113
114 // ITransform
115 void Translate( const vec3_t translation );
116 void Rotate( const vec3_t pivot, const vec3_t rotation );
117 const vec_t *GetTranslation() const { return m_translate; }
118 const vec_t *GetRotation() const { return m_euler; }
119 void OnKeyValueChanged( entity_t *e, const char *key, const char* value );
120
121 void SetName( const char *name );
122 void SetEclass( const eclass_t* eclass );
123 private:
124 /*! updates the AABB and transformation matrix */
125 void UpdateCachedData();
126 entity_interfaces_t *m_model;
127
128 int refCount;
129 string_t m_name;
130 string_t m_version;
131 const eclass_t *m_eclass;
132
133 /*! AABB in local space */
134 aabb_t m_BBox;
135
136 /*! worldspace-to-localspace translation */
137 vec3_t m_translate;
138
139 /*! worldspace-to-localspace euler rotation angles */
140 vec3_t m_euler;
141
142 /*! worldspace-to-localspace scale */
143 vec3_t m_scale;
144
145 /*! localspace origin, effectively rotation & scale pivot point */
146 vec3_t m_pivot;
147
148 /*! worldspace-to-localspace transform, generated from translate/euler/scale/pivot */
149 m4x4_t m_transform;
150
151 /*! localspace-to-worldspace transform */
152 m4x4_t m_inverse_transform;
153 };
154
155 void pivot_draw( const vec3_t pivot );
156 void Entity_UpdateClass( entity_t *e, const char* value );
157
158 #endif /* _ENTITYMODEL_H_ */