2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
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.
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.
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
22 #if !defined( INCLUDED_MODELSKIN_H )
23 #define INCLUDED_MODELSKIN_H
25 #include "generic/constant.h"
26 #include "generic/callbackfwd.h"
33 SkinRemap( const char* from, const char* to ) : m_from( from ), m_to( to ){
37 typedef Callback1<SkinRemap> SkinRemapCallback;
43 STRING_CONSTANT( Name, "ModelSkin" );
44 virtual ~ModelSkin(){}
45 /// \brief Attach an \p observer whose realise() and unrealise() methods will be called when the skin is loaded or unloaded.
46 virtual void attach( ModuleObserver& observer ) = 0;
47 /// \brief Detach an \p observer previously-attached by calling \c attach.
48 virtual void detach( ModuleObserver& observer ) = 0;
49 /// \brief Returns true if this skin is currently loaded.
50 virtual bool realised() const = 0;
51 /// \brief Returns the shader identifier that \p name remaps to, or "" if not found or not realised.
52 virtual const char* getRemap( const char* name ) const = 0;
53 /// \brief Calls \p callback for each remap pair. Has no effect if not realised.
54 virtual void forEachRemap( const SkinRemapCallback& callback ) const = 0;
60 STRING_CONSTANT( Name, "SkinnedModel" );
61 virtual ~SkinnedModel(){}
62 /// \brief Instructs the skinned model to update its skin.
63 virtual void skinChanged() = 0;
69 INTEGER_CONSTANT( Version, 1 );
70 STRING_CONSTANT( Name, "modelskin" );
71 virtual ~ModelSkinCache(){}
72 /// \brief Increments the reference count of and returns a reference to the skin uniquely identified by 'name'.
73 virtual ModelSkin& capture( const char* name ) = 0;
74 /// \brief Decrements the reference-count of the skin uniquely identified by 'name'.
75 virtual void release( const char* name ) = 0;
79 #include "modulesystem.h"
81 template<typename Type>
83 typedef GlobalModule<ModelSkinCache> GlobalModelSkinCacheModule;
85 template<typename Type>
86 class GlobalModuleRef;
87 typedef GlobalModuleRef<ModelSkinCache> GlobalModelSkinCacheModuleRef;
89 inline ModelSkinCache& GlobalModelSkinCache(){
90 return GlobalModelSkinCacheModule::getTable();