1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2018 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 RZ_INTERFACE_SCENE_3D_H
23 #define RZ_INTERFACE_SCENE_3D_H
25 #include "nel/gui/interface_group.h"
26 #include "nel/3d/u_point_light.h"
27 #include "nel/3d/u_particle_system_instance.h"
28 #include "nel/3d/u_skeleton.h"
32 class CInterface3DCharacter
;
33 class CInterface3DShape
;
35 class CInterface3DCamera
;
36 class CInterface3DLight
;
41 class UParticleSystemInstance
;
47 * class managing all 3d elements
48 * \author Matthieu 'TrapII' Besson
49 * \author Nevrax France
52 class CInterface3DScene
: public CInterfaceGroup
57 CInterface3DScene(const TCtorParam
¶m
);
58 virtual ~CInterface3DScene();
60 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
62 virtual void checkCoords();
64 virtual void updateCoords ();
68 virtual bool handleEvent (const NLGUI::CEventDescriptor
&eventDesc
);
70 virtual CInterfaceElement
* getElement (const std::string
&id
);
72 NL3D::UScene
*getScene() { return _Scene
; }
74 std::string
getCurrentCamera() const;
75 void setCurrentCamera(const std::string
&sCameraName
);
77 std::string
getCurrentClusterSystem () const;
78 void setCurrentClusterSystem(const std::string
&sCameraName
);
80 float getRotFactor() const { return _RotZFactor
; }
81 void setRotFactor(float f
) { _RotZFactor
= f
; }
83 void setFlareContext(uint context
) { _Scene
->setFlareContext(context
); }
85 float getDistLimitMin() const { return _DistLimitMin
;}
86 void setDistLimitMin(float limitMin
) { _DistLimitMin
= limitMin
;}
88 float getDistLimitMax() const { return _DistLimitMax
;}
89 void setDistLimitMax(float limitMax
) { _DistLimitMax
= limitMax
;}
91 int luaGetElement(CLuaState
&ls
);
93 REFLECT_EXPORT_START(CInterface3DScene
, CInterfaceGroup
)
94 REFLECT_LUA_METHOD ("getElement", luaGetElement
);
95 REFLECT_STRING ("curcam", getCurrentCamera
, setCurrentCamera
);
96 REFLECT_STRING ("curcs", getCurrentClusterSystem
, setCurrentClusterSystem
);
97 REFLECT_FLOAT ("rotzfactor", getRotFactor
, setRotFactor
);
98 REFLECT_FLOAT ("distlimitmin", getDistLimitMin
, setDistLimitMin
);
99 REFLECT_FLOAT ("distlimitmax", getDistLimitMax
, setDistLimitMax
);
102 void remove(NL3D::UInstanceGroup
*pIG
);
104 uint
getCharacter3DCount() const { return (uint
)_Characters
.size(); }
105 CInterface3DCharacter
*getCharacter3D(uint index
);
107 CInterface3DCamera
*getCamera(uint index
);
111 // If this value is not NULL the current scene is just a view onto another one
112 CInterface3DScene
*_Ref3DScene
;
115 NL3D::UScene
*_Scene
; // The scene containing all the 3D elements
117 uint _CurrentCS
; // Current Cluster System
118 // The AutoAnimSet (if some auto_anim)
119 NL3D::UAnimationSet
*_AutoAnimSet
;
121 std::vector
<CInterface3DCharacter
*> _Characters
;
122 std::vector
<CInterface3DShape
*> _Shapes
;
123 std::vector
<CInterface3DIG
*> _IGs
;
124 std::vector
<CInterface3DCamera
*> _Cameras
;
125 std::vector
<CInterface3DLight
*> _Lights
;
126 std::vector
<CInterface3DFX
*> _FXs
;
128 // Mouse event handling
129 bool _UserInteraction
;
130 float _RotZLimitMin
, _RotZLimitMax
;
132 float _RotYLimitMin
, _RotYLimitMax
;
135 float _DistLimitMin
, _DistLimitMax
;
138 bool _MouseLDown
, _MouseRDown
;
139 sint32 _MouseLDownX
, _MouseRDownX
;
140 sint32 _MouseLDownY
, _MouseRDownY
;
142 void mouseLMove (sint32 dx
, sint32 dy
);
143 void mouseRMove (sint32 dx
, sint32 dy
);
148 * class managing character 3d elements
149 * \author Matthieu 'TrapII' Besson
150 * \author Nevrax France
153 class CInterface3DCharacter
: public CInterfaceElement
156 CInterface3DCharacter();
157 virtual ~CInterface3DCharacter();
159 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
161 virtual void checkCoords();
163 void setClusterSystem (NL3D::UInstanceGroup
*pIG
);
165 float getRotX () const;
166 float getRotY () const;
167 float getRotZ () const;
169 void setRotX (float f
);
170 void setRotY (float f
);
171 void setRotZ (float f
);
173 float getPosX () const;
174 float getPosY () const;
175 float getPosZ () const;
177 void setPosX (float f
);
178 void setPosY (float f
);
179 void setPosZ (float f
);
181 float getHeadX () const;
182 float getHeadY () const;
183 float getHeadZ () const;
185 void setHeadX (float /* f */) {}
186 void setHeadY (float /* f */) {}
187 void setHeadZ (float /* f */) {}
189 sint32
getAnim () const {return 0;}
190 void setAnim (sint32 anim
);
192 CCharacter3D
* getCharacter3D() { return _Char3D
; }
194 void setPeople(const std::string
& people
);
195 std::string
getPeople() const;
197 void setSex(bool male
);
200 void setupCharacter3D(sint32 slot
);
201 int luaSetupCharacter3D(CLuaState
&ls
);
203 // active/inactive LOD of skeleton
204 int luaEnableLOD(CLuaState
&ls
);
207 REFLECT_EXPORT_START(CInterface3DCharacter
, CInterfaceElement
)
208 REFLECT_LUA_METHOD("setupCharacter3D", luaSetupCharacter3D
);
209 REFLECT_LUA_METHOD("enableLOD", luaEnableLOD
);
210 REFLECT_FLOAT ("headx", getHeadX
, setHeadX
);
211 REFLECT_FLOAT ("heady", getHeadY
, setHeadY
);
212 REFLECT_FLOAT ("headz", getHeadZ
, setHeadZ
);
213 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
214 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
215 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
216 REFLECT_FLOAT ("rotx", getRotX
, setRotX
);
217 REFLECT_FLOAT ("roty", getRotY
, setRotY
);
218 REFLECT_FLOAT ("rotz", getRotZ
, setRotZ
);
219 REFLECT_SINT32 ("anim", getAnim
, setAnim
);
220 REFLECT_STRING ("people", getPeople
, setPeople
);
221 REFLECT_BOOL ("sex", getSex
, setSex
);
225 CCharacter3D
*_Char3D
;
230 * class managing shape instance 3d elements
231 * \author Matthieu 'TrapII' Besson
232 * \author Nevrax France
235 class CInterface3DShape
: public CInterfaceElement
241 _PlayListManager
= NULL
;
242 _AnimationSet
= NULL
;
244 _Pos
= NLMISC::CVector(0,0,0);
245 _Rot
= NLMISC::CVector(0,0,0);
248 virtual ~CInterface3DShape();
250 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
251 virtual void checkCoords();
253 NL3D::UInstance
getShape() { return _Instance
; }
255 float getPosX () const;
256 float getPosY () const;
257 float getPosZ () const;
259 void setPosX (float f
);
260 void setPosY (float f
);
261 void setPosZ (float f
);
263 float getRotX () const;
264 float getRotY () const;
265 float getRotZ () const;
267 void setRotX (float f
);
268 void setRotY (float f
);
269 void setRotZ (float f
);
271 std::string
getName() const;
272 void setName (const std::string
&ht
);
274 std::string
getTextures() const;
275 void setTextures (const std::string
&textures
);
277 std::string
getSkeleton() const;
278 void setSkeleton (const std::string
&skeleton
);
280 std::string
getAnim() const;
281 void setAnim (const std::string
&anim
);
283 float getBBoxSizeX () const;
284 float getBBoxSizeY () const;
285 float getBBoxSizeZ () const;
289 REFLECT_EXPORT_START(CInterface3DShape
, CInterfaceElement
)
290 REFLECT_FLOAT("getBBoxSizeX", getBBoxSizeX
, setPosX
);
291 REFLECT_FLOAT("getBBoxSizeY", getBBoxSizeY
, setPosX
);
292 REFLECT_FLOAT("getBBoxSizeZ", getBBoxSizeZ
, setPosX
);
293 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
294 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
295 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
296 REFLECT_FLOAT ("rotx", getRotX
, setRotX
);
297 REFLECT_FLOAT ("roty", getRotY
, setRotY
);
298 REFLECT_FLOAT ("rotz", getRotZ
, setRotZ
);
299 REFLECT_STRING ("name", getName
, setName
);
300 REFLECT_STRING("textures", getTextures
, setTextures
);
301 REFLECT_STRING("skeleton", getSkeleton
, setSkeleton
);
302 REFLECT_STRING("anim", getAnim
, setAnim
);
307 NL3D::UInstance _Instance
;
308 NLMISC::CVector _Pos
;
309 NLMISC::CVector _Rot
;
311 std::string _Textures
;
312 std::string _SkeletonName
;
314 NL3D::USkeleton _Skeleton
;
315 NL3D::UPlayListManager
*_PlayListManager
;
316 NL3D::UAnimationSet
*_AnimationSet
;
317 NL3D::UPlayList
*_PlayList
;
321 * class managing instance group 3d elements
322 * \author Matthieu 'TrapII' Besson
323 * \author Nevrax France
326 class CInterface3DIG
: public CInterfaceElement
332 _Pos
= NLMISC::CVector(0,0,0);
333 _Rot
= NLMISC::CVector(0,0,0);
336 virtual ~CInterface3DIG();
338 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
340 NL3D::UInstanceGroup
*getIG() { return _IG
; }
342 float getPosX () const;
343 float getPosY () const;
344 float getPosZ () const;
346 void setPosX (float f
);
347 void setPosY (float f
);
348 void setPosZ (float f
);
350 float getRotX () const;
351 float getRotY () const;
352 float getRotZ () const;
354 void setRotX (float f
);
355 void setRotY (float f
);
356 void setRotZ (float f
);
358 std::string
getName() const;
359 void setName (const std::string
&ht
);
361 REFLECT_EXPORT_START(CInterface3DIG
, CInterfaceElement
)
362 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
363 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
364 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
365 REFLECT_FLOAT ("rotx", getRotX
, setRotX
);
366 REFLECT_FLOAT ("roty", getRotY
, setRotY
);
367 REFLECT_FLOAT ("rotz", getRotZ
, setRotZ
);
368 REFLECT_STRING ("name", getName
, setName
);
373 NL3D::UInstanceGroup
*_IG
;
374 NLMISC::CVector _Pos
;
375 NLMISC::CVector _Rot
;
380 * class managing camera 3d elements
381 * \author Matthieu 'TrapII' Besson
382 * \author Nevrax France
385 class CInterface3DCamera
: public CInterfaceElement
392 _Rot
= NLMISC::CVector(0,0,0);
393 _Pos
= NLMISC::CVector(0,0,0);
394 _Target
= NLMISC::CVector(0,0,1);
400 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
401 float getFOV() { return _FOV
; }
402 NLMISC::CVector
getPos() { return _Pos
; }
403 NLMISC::CVector
getTarget() { return _Target
; }
405 void setRoll(float f
) { _Roll
= f
; }
406 float getRoll() const { return _Roll
; }
407 void setFOV(float f
) { _FOV
= f
; }
408 float getFOV() const { return _FOV
; }
410 void setPosX(float f
) { _Pos
.x
= f
; _Dist
= (_Pos
-_Target
).norm(); }
411 void setPosY(float f
) { _Pos
.y
= f
; _Dist
= (_Pos
-_Target
).norm(); }
412 void setPosZ(float f
) { _Pos
.z
= f
; _Dist
= (_Pos
-_Target
).norm(); }
414 float getPosX() const { return _Pos
.x
; }
415 float getPosY() const { return _Pos
.y
; }
416 float getPosZ() const { return _Pos
.z
; }
418 void setTgtX(float f
) { _Target
.x
= f
; _Dist
= (_Pos
-_Target
).norm(); }
419 void setTgtY(float f
) { _Target
.y
= f
; _Dist
= (_Pos
-_Target
).norm(); }
420 void setTgtZ(float f
) { _Target
.z
= f
; _Dist
= (_Pos
-_Target
).norm(); }
422 float getTgtX() const { return _Target
.x
; }
423 float getTgtY() const { return _Target
.y
; }
424 float getTgtZ() const { return _Target
.z
; }
426 float getRotZ() const { return _Rot
.z
; }
427 void setRotZ(float f
) { _Rot
.z
= f
; }
429 float getRotY() const { return _Rot
.y
; }
430 void setRotY(float f
) { _Rot
.y
= f
; }
432 float getDist() const { return _Dist
; }
433 void setDist(float f
) { _Dist
= f
; }
435 REFLECT_EXPORT_START(CInterface3DCamera
, CInterfaceElement
)
436 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
437 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
438 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
439 REFLECT_FLOAT ("tgtx", getTgtX
, setTgtX
);
440 REFLECT_FLOAT ("tgty", getTgtY
, setTgtY
);
441 REFLECT_FLOAT ("tgtz", getTgtZ
, setTgtZ
);
442 REFLECT_FLOAT ("rotz", getRotZ
, setRotZ
);
443 REFLECT_FLOAT ("roty", getRotY
, setRotY
);
444 REFLECT_FLOAT ("dist", getDist
, setDist
);
445 REFLECT_FLOAT ("fov", getFOV
, setFOV
);
446 REFLECT_FLOAT ("roll", getRoll
, setRoll
);
449 void reset(); // Reset user interaction
453 NLMISC::CVector _Rot
;
456 NLMISC::CVector _Pos
;
457 NLMISC::CVector _Target
;
463 * class managing light 3d elements
464 * \author Matthieu 'TrapII' Besson
465 * \author Nevrax France
468 class CInterface3DLight
: public CInterfaceElement
473 _Pos
= NLMISC::CVector(0,0,0);
476 _Color
= NLMISC::CRGBA(255,255,255);
480 virtual ~CInterface3DLight();
482 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
484 float getPosX() const { return _Pos
.x
; }
485 float getPosY() const { return _Pos
.y
; }
486 float getPosZ() const { return _Pos
.z
; }
488 void setPosX(float f
);
489 void setPosY(float f
);
490 void setPosZ(float f
);
492 float getNear() const { return _Near
; }
493 float getFar() const { return _Far
; }
495 void setNear(float f
);
496 void setFar(float f
);
498 sint32
getColR() const { return _Color
.R
; }
499 sint32
getColG() const { return _Color
.G
; }
500 sint32
getColB() const { return _Color
.B
; }
502 void setColR(sint32 f
);
503 void setColG(sint32 f
);
504 void setColB(sint32 f
);
506 REFLECT_EXPORT_START(CInterface3DLight
, CInterfaceElement
)
507 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
508 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
509 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
510 REFLECT_FLOAT ("near", getNear
, setNear
);
511 REFLECT_FLOAT ("far", getFar
, setFar
);
512 REFLECT_SINT32 ("colr", getColR
, setColR
);
513 REFLECT_SINT32 ("colg", getColG
, setColG
);
514 REFLECT_SINT32 ("colb", getColB
, setColB
);
519 NLMISC::CVector _Pos
;
521 NLMISC::CRGBA _Color
;
523 NL3D::UPointLight _Light
;
528 * class managing fx 3d elements
529 * \author Matthieu 'TrapII' Besson
530 * \author Nevrax France
533 class CInterface3DFX
: public CInterfaceElement
538 _Pos
= NLMISC::CVector(0,0,0);
542 virtual ~CInterface3DFX();
544 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
546 virtual void checkCoords();
548 NL3D::UParticleSystemInstance
getPS() { return _FX
; }
550 float getPosX () const;
551 float getPosY () const;
552 float getPosZ () const;
554 void setPosX (float f
);
555 void setPosY (float f
);
556 void setPosZ (float f
);
558 float getRotX () const;
559 float getRotY () const;
560 float getRotZ () const;
562 void setRotX (float f
);
563 void setRotY (float f
);
564 void setRotZ (float f
);
566 std::string
getName() const;
567 void setName (const std::string
&ht
);
569 bool getStarted() const;
570 void setStarted (bool b
);
572 REFLECT_EXPORT_START(CInterface3DFX
, CInterfaceElement
)
573 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
574 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
575 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
576 REFLECT_FLOAT ("rotx", getRotX
, setRotX
);
577 REFLECT_FLOAT ("roty", getRotY
, setRotY
);
578 REFLECT_FLOAT ("rotz", getRotZ
, setRotZ
);
579 REFLECT_STRING ("name", getName
, setName
);
580 REFLECT_BOOL ("started", getStarted
, setStarted
);
585 NL3D::UParticleSystemInstance _FX
;
587 NLMISC::CVector _Pos
;
588 NLMISC::CVector _Rot
;
593 #endif // RZ_INTERFACE_SCENE_3D_H
595 /* end of interface_3d_scene.h */