Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / ig_callback.h
blobf1bce19d2deab6d328314d04a7f046146e66031d
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
8 //
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_IG_CALLBACK
21 #define CL_IG_CALLBACK
23 #include "nel/3d/u_instance_group.h"
24 #include "nel/misc/debug.h"
26 #include "ig_enum.h"
27 #include "timed_fx_manager.h"
29 #include <list>
30 #include <string>
32 namespace NL3D
34 class UInstanceGroup;
37 namespace NLPACS
39 class UMoveContainer;
40 class UMovePrimitive;
41 class UPrimitiveBlock;
45 class CEntitySheet;
47 /** A class to manage callback (collisions, constructions ..) with igs of the landscape.
48 * Its purpose is to create pacs primitive for objects of the landscape that need them.
49 * The matching primitive for an instance is deduced from its shape name.
50 * Pacs primitives must be loaded at startup.
51 * \author Nicolas Vizerie
52 * \author Nevrax France
53 * \date 2002
55 class CIGCallback : public CIGNotifier
57 public:
58 ///\name Object
59 //@{
60 /// default ctor
61 CIGCallback();
62 /// dtor
63 ~CIGCallback();
64 //@}
66 ///\name IG mgt
67 //@{
68 /** Add an ig. Its callbacks primitive will be created when it has been added
69 * to the scene
71 void addIG(NL3D::UInstanceGroup *ig);
72 /** Add an ig with his num ZC. Its callbacks primitive will be created when it has been added
73 * to the scene
75 void addIGWithNumZC(NL3D::UInstanceGroup *ig, sint numZC);
77 /** Add a vector of instance groups
79 void addIGs(const std::vector<NL3D::UInstanceGroup *> &igs);
80 /** Add a vector of instance groups with the num ZC associated.
82 void addIGsWithNumZC(std::vector<std::pair<NL3D::UInstanceGroup *, sint> > &igs);
83 /// Remove all IGs
84 void deleteIGs();
85 /// Force creation of all zones (not to be used in client side..)
86 void forceAddAll();
87 //@}
89 ///\name Collisions
90 //@{
91 /** Set the move container that should be used for collision. This MUST
92 * be called once and only once, unless it is reseted
94 void setMoveContainer(NLPACS::UMoveContainer *mc);
95 // Get the move container associated with that object, or NULL if none.
96 NLPACS::UMoveContainer *getMoveContainer() const { return _MoveContainer; }
98 /** Add a pacs primitive from its file name.
99 * This may raise an exception if loading failed.
101 void addPacsPrim(const std::string &fileName);
102 /** Add all pacs primitives from the given directory.
104 void resetContainer();
105 //@}
107 ///\name Enumeration
108 //@{
109 /** enumerate all currently loaded zone igs
110 * \return false if the enumeration has been stopped
112 bool enumIGs(IIGEnum *callback);
113 //@}
115 ///\name Season change
116 //@{
117 // apply change of season on iug (for now, only change the fxs to match the season)
118 void changeSeason();
119 //@}
122 ///////////////////////////////////////////////////////////////////////////////////////////////////
123 ///////////////////////////////////////////////////////////////////////////////////////////////////
124 private:
125 class CIGInstance;
126 friend class CIGInstance;
127 // instanciated igs
128 typedef std::vector<CIGInstance *> TIGInstanceList;
130 * An instanciated ig and its matching collisions primitives
132 class CIGInstance : public NL3D::IAddRemoveInstance,
133 public NL3D::ITransformName,
134 public NL3D::IIGAddBegin
136 public:
137 /// ctor
138 CIGInstance(NL3D::UInstanceGroup *ig, CIGCallback *owner);
139 /** Dtor
140 * NB:
141 * -This release move primitives from the move container
143 ~CIGInstance();
144 /// force this instance to be added
145 void forceAdd() { instanceGroupAdded(); }
146 void numZC(sint num) {_NumZC = num;}
147 NL3D::UInstanceGroup *getIG() const { return _IG; }
148 void updateManagedFXs();
149 void shutDownFXs();
150 bool hasManagedFXs() const { return _HasManagedFXs; }
151 // force to rebuild the sheet vector
152 void buildSheetVector();
153 // earse the sheet vector
154 void eraseSheetVector();
155 private:
156 typedef std::vector<NLPACS::UMovePrimitive *> TMovePrimitiveVect;
157 typedef std::vector<CEntitySheet *> TEntitySheetVect;
158 private:
159 void releaseMovePrimitives();
160 ///\name from NL3D::IAddRemoveInstance
161 //@{
162 virtual void instanceGroupAdded();
163 virtual void instanceGroupRemoved();
164 //@}
165 ///\name from NL3D::ITransformName
166 //@{
167 virtual std::string transformName (uint index, const std::string &instanceName, const std::string &shapeName);
168 //@}
169 ///\name from NL3D::IIGAddBegin
170 //@{
171 virtual void startAddingIG(uint numInstances);
172 //@}
173 /** Called after all instance have been added, and when their sheets have been retrieved.
174 * This is the place to setup parameters from sheets
176 void updateFromSheets();
178 private:
180 TMovePrimitiveVect _MovePrimitives;
181 TEntitySheetVect _EntitySheets; // matching sheets for each instance (or NULL), they are used only after the instance have been added to the scene
182 CIGCallback *_Owner;
183 NL3D::UInstanceGroup *_IG; // the IG we're looking at
184 sint _NumZC; // >= 0 if valid.
185 bool _HasManagedFXs; // true if there are managed fx in the group, otherwise, _ManagedFXHandle is not used
186 CTimedFXManager::TFXGroupHandle _ManagedFXHandle;
189 private:
190 NLPACS::UMoveContainer *_MoveContainer;
191 TIGInstanceList _IGInstances;
198 /** Debug purpose only: create instances in a scene from the content of a move container.
199 * The created instances are static. Their pointer can be retrieved in a pointer
200 * The following shapes must be available :
201 * unit_box.shape : a box of 1 x 1 x 1 centered at the origin
202 * unit_cylinder.shape : a cylinder of height 1, radius 1
204 void createInstancesFromMoveContainer(NL3D::UScene *scene, NLPACS::UMoveContainer *mc, std::vector<NL3D::UInstance> *instances = NULL);
210 #endif