Planeshift
charapp.h
Go to the documentation of this file.
1 /*
2  * charapp.h
3  *
4  * Copyright (C) 2002-2009 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef CHAR_APP_HEADER
21 #define CHAR_APP_HEADER
22 //=============================================================================
23 // Crystal Space Includes
24 //=============================================================================
25 #include <csutil/csstring.h>
26 #include <csutil/list.h>
27 #include <csgeom/vector3.h>
28 #include <iengine/mesh.h>
29 #include <imesh/animesh.h>
30 #include <imesh/spritecal3d.h>
31 
32 //=============================================================================
33 // Project Includes
34 //=============================================================================
35 
36 //=============================================================================
37 // Local Includes
38 //=============================================================================
39 #include "psengine.h"
40 
41 struct Trait;
42 struct iEngine;
43 struct iLoader;
44 struct iVFS;
45 struct iTextureManager;
46 struct iGraphics3D;
47 struct iRegion;
48 struct iDocumentSystem;
49 struct iStringSet;
50 
51 using namespace CS::Mesh;
52 
58 {
59  csString part;
60  csString material;
61 };
62 
66 {
67 public:
72  psCharAppearance(iObjectRegistry* objectReg);
74 
79  void SetMesh(iMeshWrapper* mesh);
80 
84  void FaceTexture(csString& faceMaterial);
85 
89  void HairMesh(csString& submesh);
90 
94  void BeardMesh(csString& submesh);
95 
99  void HairColor(csVector3 &shader);
100 
104  void EyeColor(csVector3 &shader);
105 
109  void ShowHair(bool flag=true);
110 
116  void ShowMeshes(csString& slot, csString& meshList, bool show=true);
117 
122  void UpdateMeshShowStatus(csString& meshName);
123 
128  void SetSkinTone(csString& part, csString& material);
129 
134  void ApplyTraits(const csString& traits);
135 
142  void ApplyEquipment(const csString& equipment);
143 
148  void ApplyRider(iMeshWrapper* mesh);
149 
158  void Equip(csString& slotname, csString& mesh, csString& part, csString& subMesh, csString& texture, csString& removedMesh);
159 
160 
169  bool Dequip(csString& slotname, csString& mesh, csString& part, csString& subMesh, csString& texture, csString& removedMesh);
170 
174  void Clone(psCharAppearance* clone);
175 
176 
178  void ClearEquipment(const char* slot = NULL);
179 
180  bool CheckLoadStatus();
181 
182  void SetSneak(bool sneaking);
183 
192  bool ChangeMaterial(const char* part, const char* materialName);
193 
194 private:
204  csString ParseStrings(const char *part, const char* str) const;
205 
212  bool SetTrait(Trait * trait);
213 
220  bool ChangeMesh(const char* partPattern, const char* newPart);
221 
229  bool Attach(const char* socketName, const char* meshFactName, const char* materialName = NULL);
230 
236  bool Detach(const char* socketName);
237 
241  void DefaultMaterial(csString& part);
242 
249  void DefaultMesh(const char* part, const char *subMesh = NULL);
250 
254  void Free();
255 
256  void ProcessAttach(iThreadReturn* factory, iThreadReturn* material, const char* meshFactName, const char* socket);
257  void ProcessAttach(iMeshWrapper* meshWrap, const char* socket);
258  void ProcessAttach(iThreadReturn* material, const char* materialName, const char* partName);
259  bool ProcessMaterial(iThreadReturn* material, const char* materialName, const char* partName);
260 
261  csRef<iMeshWrapper> baseMesh;
262 
263  csRef<iSpriteCal3DFactoryState> stateFactory;
264  csRef<iSpriteCal3DState> state;
265 
266  csRef<CS::Mesh::iAnimatedMeshFactory> animeshFactory;
267  csRef<CS::Mesh::iAnimatedMesh> animeshObject;
268 
269  csRef<iShaderVarStringSet> stringSet;
270  csRef<iStringSet> strings;
271 
275  csRef<iEngine> engine;
276  csRef<iVFS> vfs;
277  csRef<iGraphics3D> g3d;
278  csRef<iTextureManager> txtmgr;
279  csRef<iDocumentSystem> xmlparser;
280  csRef<iShaderManager> shman;
282 
283  csString eyeMesh;
284  csString hairMesh;
285  csString beardMesh;
286 
287  csVector3 eyeShader;
288  csVector3 hairShader;
289 
290  bool beardAttached;
291 
292  csHash<csString> removedMeshes;
293  csHash<csRef<iThreadReturn>, csString> materials;
294  csHash<csRef<iThreadReturn>, csString> factories;
295 
296  bool eyeColorSet;
297  bool hairColorSet;
298 
299  bool sneak;
300 
301  csString faceMaterial;
302  csArray<SkinToneSet> skinToneSet;
303 
304  csArray<csString> usedSlots;
305  csHash<int, csString> effectids;
306  csHash<int, csString> lightids;
307 
309  struct Attachment
310  {
311  bool factory;
312 
313  csString socket;
314  csString partName;
315 
316  csString factName;
317  csRef<iThreadReturn> factoryPtr;
318  csString materialName;
319  csRef<iThreadReturn> materialPtr;
320 
321  Attachment(bool factory) : factory(factory)
322  {
323  }
324  };
325 
326  csList<Attachment> delayedAttach;
327 };
328 
329 #endif
Defines a character trait.
Definition: psclientchar.h:58
A manager class that handles all the details of a characters appearance.
Definition: charapp.h:65
csString material
The material to place on that part.
Definition: charapp.h:60
Holds a set of skin tone.
Definition: charapp.h:57
csString part
The part of the model to adjust.
Definition: charapp.h:59