]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/model/cpicomodel.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / plugins / model / cpicomodel.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 _CPICOMODEL_H_\r
23 #define _CPICOMODEL_H_\r
24 \r
25 #include "plugin.h"\r
26 #include "picomodel.h"\r
27 \r
28 #include "gtkr_vector.h"\r
29 \r
30 class CPicoParent\r
31 {\r
32 public:\r
33   virtual void UpdateShaders( void ) = 0;\r
34 };\r
35 \r
36 class CModelManager;  // forward declaration\r
37 \r
38 //typedef std::pair<Str, int> PicoModelKey;\r
39 typedef pair<Str, int> PicoModelKey;\r
40 \r
41 class CPicoModel : public IRender, public ISelect\r
42 {\r
43   friend class CModelManager;\r
44 public:\r
45   CPicoModel(const PicoModelKey& key);\r
46   CPicoModel(const Str& name);\r
47   CPicoModel(const Str& name, const int frame);\r
48         CPicoModel(const char *name, const int frame);\r
49         ~CPicoModel(); \r
50   void CPicoModel::load(const char *name, const int frame);\r
51         \r
52   void IncRef()\r
53   {\r
54     ++m_refcount;\r
55   }\r
56   void DecRef()\r
57   {\r
58     if(--m_refcount == 0)\r
59       delete this;\r
60   }\r
61 \r
62   void AddParent( CPicoParent *parent );\r
63   void RemoveParent( CPicoParent *parent );\r
64 \r
65   void Reload( void );\r
66 \r
67   void Draw(int state, vector<IShader*> shaders, int rflags) const;\r
68   //IRender\r
69   virtual void Draw( int state, int rflags ) const;\r
70   virtual const aabb_t *GetAABB() const { return &m_BBox; }\r
71 \r
72   //ISelect\r
73   virtual bool TestRay( const ray_t *ray, vec_t *dist ) const;\r
74 \r
75   int GetNumSurfaces( void );\r
76   char *GetShaderNameForSurface( const unsigned int surf );\r
77 \r
78 private:\r
79         void AccumulateBBox();\r
80 \r
81   char *m_name;\r
82   int m_frame;\r
83   picoModel_t *m_pModel;\r
84   unsigned int m_refcount;\r
85         aabb_t m_BBox;\r
86   GPtrArray *m_children; // array of CPicoSurface\r
87   GPtrArray *m_parents; // array of CPicoParent\r
88 \r
89   GPtrArray* m_shaders;\r
90 \r
91   bool m_bReloaded; // managed by CModelManager\r
92 };\r
93 \r
94 #endif // _CPICOMODEL_H_\r