1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program 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 Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef CL_CHARACTER_3D_H
23 #define CL_CHARACTER_3D_H
25 // ------------------------------------------------------------------------------------------------
26 #include "game_share/character_summary.h"
27 #include "game_share/slot_types.h"
28 #include "nel/3d/u_skeleton.h"
29 #include "nel/gui/interface_options.h"
30 #include "interface_options_ryzom.h"
31 #include "nel/gui/interface_element.h"
34 // ------------------------------------------------------------------------------------------------
44 // ------------------------------------------------------------------------------------------------
54 Char3DPart_HandRightItem
,
55 Char3DPart_HandLeftItem
,
59 #define NB_CHARACTER3D_PARTS 9
60 #define NB_MORPH_TARGETS 8
62 // ------------------------------------------------------------------------------------------------
63 struct SCharacter3DSetup
65 // A Part of the character body
66 // if the name, color or quality changed the instances are rebuilt. It is not for all fxs.
69 std::string Name
; // name of the .shape
70 std::string AdvFx
; // advantage fx .ps
71 std::vector
<std::string
> StatFxNames
; // all the static fx .ps
72 std::vector
<std::string
> StatFxBones
; // the bones on which to bind the static fx (weird but done like that in CCharacterCL)
73 std::vector
<NLMISC::CVector
> StatFxOffss
; // the offset on the bone
74 sint32 Color
; // a color slot (in the color table of the color slot manager)
75 sint32 Quality
; // quality of the item
77 // Primary information (if changed instances are rebuilt)
78 std::string Skeleton
; // filename (.skel)
79 SCharacterPart Parts
[NB_CHARACTER3D_PARTS
];
87 float CharHeight
; // from -1 (smallest) to 1 (tallest)
88 float ChestWidth
; // Slim -1 Normal 0 Fat 1
93 float MorphTarget
[NB_MORPH_TARGETS
]; // -100.0 - 100.0 (percentage of the mt)
95 // Additionnal information (if changed the instances are not reconstructed)
96 EGSPD::CPeople::TPeople People
;
97 bool Male
; // false == Female
98 bool LeftHandItemIsShield
; // If false this is a weapon if it exists
101 // Constructor (setup a default fyros male)
102 SCharacter3DSetup ();
104 // Initialize the structure with race_stats form
105 void setupDefault (EGSPD::CPeople::TPeople eRace
, bool bMale
);
107 // Initialize the structure from a character summary struct
108 void setupFromCharacterSummary (const CCharacterSummary
&cs
);
110 // Initialize the structure from a DataBase Branch (look in cpp to see the structure)
111 void setupFromDataBase (const std::string
&branchName
);
113 // Initialize the structure from the SERVER:... DataBase Branch (which is messy)
114 void setupFromSERVERDataBase (uint8 entityID
= 0);
118 // Database Converter Tool
119 static void setupDBFromCharacterSummary (const std::string
&branchName
, const CCharacterSummary
&cs
);
120 static void setupCharacterSummaryFromDB (CCharacterSummary
&cs
, const std::string
&branchName
);
121 static void setupCharacterSummaryFromSERVERDB (CCharacterSummary
&cs
, uint8 entityID
= 0);
124 static TChar3DPart
convert_VisualSlot_To_Char3DPart (SLOTTYPE::EVisualSlot vs
);
125 static SLOTTYPE::EVisualSlot
convert_Char3DPart_To_VisualSlot (TChar3DPart cp
);
126 static std::string
convert_VisualSlot_To_String (SLOTTYPE::EVisualSlot vs
);
128 static uint64
getDB (const std::string
&name
);
129 static void setDB (const std::string
&name
, uint64 val
);
132 void setupFromCS_ModelCol (SLOTTYPE::EVisualSlot s
, sint32 model
, sint32 col
);
136 // ------------------------------------------------------------------------------------------------
137 class CCharacter3D
: public CReflectableRefPtrTarget
145 bool init (NL3D::UScene
*pScene
);
146 void setup (const SCharacter3DSetup
&newSetup
);
147 SCharacter3DSetup
getCurrentSetup () { return _CurrentSetup
; }
149 void setPos (float x
, float y
, float z
); // reference point : Feet
150 void setClusterSystem (NL3D::UInstanceGroup
*pIG
);
151 void setRotEuler (float rx
, float ry
, float rz
);
153 void getPos (float &x
, float &y
, float &z
) { x
= _CurPosX
; y
= _CurPosY
; z
= _CurPosZ
; }
154 void getHeadPos (float &x
, float &y
, float &z
);
155 void getRotEuler (float &rx
, float &ry
, float &rz
) { rx
= _CurRotX
; ry
= _CurRotY
; rz
= _CurRotZ
; }
157 void setAnim (uint animID
);
159 void animate (double globalTime
); // Should be called each frame
161 EGSPD::CPeople::TPeople
getPeople() { return _CurrentSetup
.People
; }
162 void setPeople(EGSPD::CPeople::TPeople people
) { _CurrentSetup
.People
= people
; }
164 bool getSex() { return _CurrentSetup
.Male
; }
165 void setSex(bool male
) { _CurrentSetup
.Male
= male
; }
168 NL3D::USkeleton
getSkeleton() { return _Skeleton
; }
170 void copyAnimation(bool copyAnim
) { _CopyAnim
=copyAnim
; }
174 void resetAnimation (NL3D::UAnimationSet
*animSet
);
175 void animblink (double globalTime
);
176 NLMISC::CVector
getBonePos (const std::string
&boneName
);
179 void setSkeleton (const std::string
&filename
);
180 void createInstance (TChar3DPart i
, const SCharacter3DSetup::SCharacterPart
&part
);
181 void bindToSkeleton (TChar3DPart i
);
182 uint32
peopleToSkin (EGSPD::CPeople::TPeople p
) const;
184 void disableFaceMorphAndBlinks();
188 NL3D::UScene
*_Scene
; // reference to the scene containing the character
190 NL3D::UPlayListManager
*_PlayListManager
;
191 NL3D::UAnimationSet
*_AnimationSet
; // reference to the option AnimationSet
193 NL3D::UPlayList
*_PlayList
;
194 NL3D::UPlayList
*_FacePlayList
;
196 std::vector
<COptionsAnimationSet::CAnim
> _AnimMale
;
197 std::vector
<COptionsAnimationSet::CAnim
> _AnimFemale
;
200 NL3D::UInstance _Instances
[NB_CHARACTER3D_PARTS
];
204 NL3D::UInstance AdvantageFx
;
205 std::vector
<NL3D::UInstance
> StaticFx
;
207 SInstanceFx _InstancesFx
[NB_CHARACTER3D_PARTS
];
210 NL3D::USkeleton _Skeleton
;
212 // Root is the parent of skeleton (needed because skeleton receive animation values)
213 NL3D::UTransform _Root
;
215 NL3D::UInstanceGroup
*_ClusterSystem
;
217 float _CurPosX
, _CurPosY
, _CurPosZ
;
218 float _CurRotX
, _CurRotY
, _CurRotZ
;
220 // The animated pelvis pos
221 NLMISC::CVector _PelvisPos
;
222 float _CustomScalePos
;
224 double _NextBlinkTime
;
227 SCharacter3DSetup _CurrentSetup
;
232 #endif // CL_CHARACTER_3D_H