1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef CL_STREAMABLE_IG
21 #define CL_STREAMABLE_IG
23 #include "streamable_entity.h"
26 #include "nel/3d/u_scene.h"
45 /** A streamable IG hierarchy (hierarchy is used to build clusters hierarchy). It may be loaded synchronously or asynchronously depending on the distance.
47 class CStreamableIG
: public CStreamableEntity
, public CIGNotifier
50 typedef std::map
<std::string
, NL3D::UInstanceGroup
*> TString2IG
;
58 /** Init this streamable ig
59 * \param owningScene the scene in which that ig should be inserted
60 * \param pos center of the testing volume
61 * \param forceLoadRadius the radius at which loading should be forced
62 * \param loadRadius the radius at which asynchronous loading should start
63 * \param unloadRadius the radius at which the ig should be unloaded
66 NL3D::UScene
*owningScene
,
67 const NLMISC::CVector
&pos
,
68 float forceLoadRadius
,
72 NL3D::UScene
*getScene() const { return _Scene
; }
74 /// Optimisation purpose. If you know how many calls to addIG will be done, you can call this
75 void reserve(uint size
);
76 /** Add an ig and the name of its parent ig (for clusters linking), or an empty name it no linking is done
78 void addIG(const std::string
&name
, const std::string
&parentName
, const NLMISC::CVector
&pos
, const NLMISC::CQuat
&rot
);
79 /** Set an additionnal map (ig name -> ig pointer) that will be filled with loaded igs.
80 * Setting that pointer to NULL will remove currently loaded igs from the map and will disable it.
81 * By default, no map is used
83 void setLoadedIGMap(TString2IG
*igMap
);
85 virtual void forceUnload();
86 /** enum all currently instanciated IGs
87 * \return false if the enumeration has been stopped
89 bool enumIGs(IIGEnum
*callback
);
92 bool setIG(uint ig
, const std::string
&name
, const std::string
&parentName
);
94 // Get num of IG in the streamable IG..
97 return (uint
)_IGs
.size();
100 /////////////////////////////////////////////////////////////////////////////////////////////////////////
101 /////////////////////////////////////////////////////////////////////////////////////////////////////////
103 class CCallback
: public NL3D::IAsyncLoadCallback
106 CStreamableIG
*Owner
;
107 virtual void InstanceGroupCreated(NL3D::UInstanceGroup
*newVal
)
109 Owner
->notifyIGLoaded(newVal
);
116 std::string ParentName
;
117 NL3D::UInstanceGroup
*IG
;
123 typedef std::vector
<CIGNode
> TIGArray
;
127 NL3D::UScene
*_Scene
;
129 bool _Linked
; // instance are linked in a tree of cluster
131 EGSPD::CSeason::TSeason _Season
;
139 //\name From CStreamableEntity
141 virtual void loadAsync();
142 virtual void load(NLMISC::IProgressCallback
&progress
);
143 virtual void unload();
145 void linkInstances();
146 void addLoadedIGToMap();
147 void removeLoadedIGFromMap();