Planeshift

charapp.h

Go to the documentation of this file.
00001 /*
00002  * charapp.h
00003  *
00004  * Copyright (C) 2002-2009 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 
00020 #ifndef CHAR_APP_HEADER
00021 #define CHAR_APP_HEADER
00022 //=============================================================================
00023 // Crystal Space Includes
00024 //=============================================================================
00025 #include <csutil/csstring.h>
00026 #include <csutil/list.h>
00027 #include <csgeom/vector3.h>
00028 #include <iengine/mesh.h>
00029 #include <imesh/animesh.h>
00030 #include <imesh/spritecal3d.h>
00031 
00032 //=============================================================================
00033 // Project Includes
00034 //=============================================================================
00035 
00036 //=============================================================================
00037 // Local Includes
00038 //=============================================================================
00039 #include "psengine.h"
00040 
00041 struct Trait;
00042 struct iEngine;
00043 struct iLoader;
00044 struct iVFS;
00045 struct iTextureManager;
00046 struct iGraphics3D;
00047 struct iRegion;
00048 struct iDocumentSystem;
00049 struct iStringSet;
00050 
00051 using namespace CS::Mesh;
00052 
00057 struct SkinToneSet
00058 {
00059     csString part;                  
00060     csString material;              
00061 };
00062 
00065 class psCharAppearance : public DelayedLoader
00066 {
00067 public:
00072     psCharAppearance(iObjectRegistry* objectReg);
00073     ~psCharAppearance();
00074 
00079     void SetMesh(iMeshWrapper* mesh);
00080 
00084     void FaceTexture(csString& faceMaterial);
00085 
00089     void HairMesh(csString& submesh);
00090 
00094     void BeardMesh(csString& submesh);
00095 
00099     void HairColor(csVector3 &shader);
00100 
00104     void EyeColor(csVector3 &shader);
00105 
00109     void ShowHair(bool flag=true);
00110 
00116     void ShowMeshes(csString& slot, csString& meshList, bool show=true);
00117     
00122     void UpdateMeshShowStatus(csString& meshName);
00123 
00128     void SetSkinTone(csString& part, csString& material);
00129 
00134     void ApplyTraits(const csString& traits);
00135 
00142     void ApplyEquipment(const csString& equipment);
00143 
00148     void ApplyRider(iMeshWrapper* mesh);
00149 
00158     void Equip(csString& slotname, csString& mesh, csString& part, csString& subMesh, csString& texture, csString& removedMesh);
00159 
00160 
00169     bool Dequip(csString& slotname, csString& mesh, csString& part, csString& subMesh, csString& texture, csString& removedMesh);
00170 
00174     void Clone(psCharAppearance* clone);
00175 
00176 
00178     void ClearEquipment(const char* slot = NULL);
00179 
00180     bool CheckLoadStatus();
00181 
00182     void SetSneak(bool sneaking);
00183 
00192     bool ChangeMaterial(const char* part, const char* materialName);
00193 
00194 private:
00204     csString ParseStrings(const char *part, const char* str) const;
00205 
00212     bool SetTrait(Trait * trait);
00213 
00220     bool ChangeMesh(const char* partPattern, const char* newPart);
00221 
00229     bool Attach(const char* socketName, const char* meshFactName, const char* materialName = NULL);
00230 
00236     bool Detach(const char* socketName);
00237 
00241     void DefaultMaterial(csString& part);
00242 
00249     void DefaultMesh(const char* part, const char *subMesh = NULL);
00250 
00254     void Free();
00255 
00256     void ProcessAttach(iThreadReturn* factory, iThreadReturn* material, const char* meshFactName, const char* socket);
00257     void ProcessAttach(iMeshWrapper* meshWrap, const char* socket);
00258     void ProcessAttach(iThreadReturn* material, const char* materialName, const char* partName);
00259     bool ProcessMaterial(iThreadReturn* material, const char* materialName, const char* partName);
00260 
00261     csRef<iMeshWrapper> baseMesh;                       
00262 
00263     csRef<iSpriteCal3DFactoryState>  stateFactory;      
00264     csRef<iSpriteCal3DState>    state;                  
00265 
00266     csRef<CS::Mesh::iAnimatedMeshFactory> animeshFactory; 
00267     csRef<CS::Mesh::iAnimatedMesh> animeshObject; 
00268 
00269     csRef<iShaderVarStringSet>  stringSet;              
00270     csRef<iStringSet> strings;                          
00271 
00275     csRef<iEngine>              engine;
00276     csRef<iVFS>                 vfs;
00277     csRef<iGraphics3D>          g3d;
00278     csRef<iTextureManager>      txtmgr;
00279     csRef<iDocumentSystem>      xmlparser;
00280     csRef<iShaderManager>       shman;
00282 
00283     csString eyeMesh;                                   
00284     csString hairMesh;                                  
00285     csString beardMesh;                                 
00286 
00287     csVector3 eyeShader;                                
00288     csVector3 hairShader;                               
00289 
00290     bool beardAttached;                                 
00291 
00292     csHash<csString> removedMeshes;                     
00293     csHash<csRef<iThreadReturn>, csString> materials;   
00294     csHash<csRef<iThreadReturn>, csString> factories;   
00295 
00296     bool eyeColorSet;                                   
00297     bool hairColorSet;                                  
00298 
00299     bool sneak;                                         
00300 
00301     csString faceMaterial;                              
00302     csArray<SkinToneSet> skinToneSet;                   
00303 
00304     csArray<csString> usedSlots;                        
00305     csHash<int, csString> effectids;                    
00306     csHash<int, csString> lightids;                     
00307 
00309     struct Attachment
00310     {
00311         bool factory;
00312 
00313         csString socket;
00314         csString partName;
00315 
00316         csString factName;
00317         csRef<iThreadReturn> factoryPtr;
00318         csString materialName;
00319         csRef<iThreadReturn> materialPtr;
00320 
00321         Attachment(bool factory) : factory(factory)
00322         {
00323         }
00324     };
00325 
00326     csList<Attachment> delayedAttach;
00327 };
00328 
00329 #endif