Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 94 lines (76 sloc) 2.875 kB
0991a5c @tbradshaw The GtkRadiant sources as originally released under the GPL license.
tbradshaw authored
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
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 #if !defined(INCLUDED_MODELSKIN_H)
23 #define INCLUDED_MODELSKIN_H
24
25 #include "generic/constant.h"
26
27 class SkinRemap
28 {
29 public:
30 const char* m_from;
31 const char* m_to;
32 SkinRemap(const char* from, const char* to) : m_from(from), m_to(to)
33 {
34 }
35 };
36
37 template<typename FirstArgument>
38 class Callback1;
39 typedef Callback1<SkinRemap> SkinRemapCallback;
40 class ModuleObserver;
41
42 class ModelSkin
43 {
44 public:
45 STRING_CONSTANT(Name, "ModelSkin");
46 /// \brief Attach an \p observer whose realise() and unrealise() methods will be called when the skin is loaded or unloaded.
47 virtual void attach(ModuleObserver& observer) = 0;
48 /// \brief Detach an \p observer previously-attached by calling \c attach.
49 virtual void detach(ModuleObserver& observer) = 0;
50 /// \brief Returns true if this skin is currently loaded.
51 virtual bool realised() const = 0;
52 /// \brief Returns the shader identifier that \p name remaps to, or "" if not found or not realised.
53 virtual const char* getRemap(const char* name) const = 0;
54 /// \brief Calls \p callback for each remap pair. Has no effect if not realised.
55 virtual void forEachRemap(const SkinRemapCallback& callback) const = 0;
56 };
57
58 class SkinnedModel
59 {
60 public:
61 STRING_CONSTANT(Name, "SkinnedModel");
62 /// \brief Instructs the skinned model to update its skin.
63 virtual void skinChanged() = 0;
64 };
65
66 class ModelSkinCache
67 {
68 public:
69 INTEGER_CONSTANT(Version, 1);
70 STRING_CONSTANT(Name, "modelskin");
71 /// \brief Increments the reference count of and returns a reference to the skin uniquely identified by 'name'.
72 virtual ModelSkin& capture(const char* name) = 0;
73 /// \brief Decrements the reference-count of the skin uniquely identified by 'name'.
74 virtual void release(const char* name) = 0;
75 };
76
77
78 #include "modulesystem.h"
79
80 template<typename Type>
81 class GlobalModule;
82 typedef GlobalModule<ModelSkinCache> GlobalModelSkinCacheModule;
83
84 template<typename Type>
85 class GlobalModuleRef;
86 typedef GlobalModuleRef<ModelSkinCache> GlobalModelSkinCacheModuleRef;
87
88 inline ModelSkinCache& GlobalModelSkinCache()
89 {
90 return GlobalModelSkinCacheModule::getTable();
91 }
92
93 #endif
Something went wrong with that request. Please try again.