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"
31 class CInterface3DCharacter
;
32 class CInterface3DShape
;
34 class CInterface3DCamera
;
35 class CInterface3DLight
;
40 class UParticleSystemInstance
;
45 * class managing all 3d elements
46 * \author Matthieu 'TrapII' Besson
47 * \author Nevrax France
50 class CInterface3DScene
: public CInterfaceGroup
55 CInterface3DScene(const TCtorParam
¶m
);
56 virtual ~CInterface3DScene();
58 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
60 virtual void checkCoords();
62 virtual void updateCoords ();
66 virtual bool handleEvent (const NLGUI::CEventDescriptor
&eventDesc
);
68 virtual CInterfaceElement
* getElement (const std::string
&id
);
70 NL3D::UScene
*getScene() { return _Scene
; }
72 std::string
getCurrentCamera() const;
73 void setCurrentCamera(const std::string
&sCameraName
);
75 std::string
getCurrentClusterSystem () const;
76 void setCurrentClusterSystem(const std::string
&sCameraName
);
78 float getRotFactor() const { return _RotZFactor
; }
79 void setRotFactor(float f
) { _RotZFactor
= f
; }
81 void setFlareContext(uint context
) { _Scene
->setFlareContext(context
); }
83 float getDistLimitMin() const { return _DistLimitMin
;}
84 void setDistLimitMin(float limitMin
) { _DistLimitMin
= limitMin
;}
86 float getDistLimitMax() const { return _DistLimitMax
;}
87 void setDistLimitMax(float limitMax
) { _DistLimitMax
= limitMax
;}
89 int luaGetElement(CLuaState
&ls
);
91 REFLECT_EXPORT_START(CInterface3DScene
, CInterfaceGroup
)
92 REFLECT_LUA_METHOD ("getElement", luaGetElement
);
93 REFLECT_STRING ("curcam", getCurrentCamera
, setCurrentCamera
);
94 REFLECT_STRING ("curcs", getCurrentClusterSystem
, setCurrentClusterSystem
);
95 REFLECT_FLOAT ("rotzfactor", getRotFactor
, setRotFactor
);
96 REFLECT_FLOAT ("distlimitmin", getDistLimitMin
, setDistLimitMin
);
97 REFLECT_FLOAT ("distlimitmax", getDistLimitMax
, setDistLimitMax
);
100 void remove(NL3D::UInstanceGroup
*pIG
);
102 uint
getCharacter3DCount() const { return (uint
)_Characters
.size(); }
103 CInterface3DCharacter
*getCharacter3D(uint index
);
105 CInterface3DCamera
*getCamera(uint index
);
109 // If this value is not NULL the current scene is just a view onto another one
110 CInterface3DScene
*_Ref3DScene
;
113 NL3D::UScene
*_Scene
; // The scene containing all the 3D elements
115 uint _CurrentCS
; // Current Cluster System
116 // The AutoAnimSet (if some auto_anim)
117 NL3D::UAnimationSet
*_AutoAnimSet
;
119 std::vector
<CInterface3DCharacter
*> _Characters
;
120 std::vector
<CInterface3DShape
*> _Shapes
;
121 std::vector
<CInterface3DIG
*> _IGs
;
122 std::vector
<CInterface3DCamera
*> _Cameras
;
123 std::vector
<CInterface3DLight
*> _Lights
;
124 std::vector
<CInterface3DFX
*> _FXs
;
126 // Mouse event handling
127 bool _UserInteraction
;
128 float _RotZLimitMin
, _RotZLimitMax
;
130 float _RotYLimitMin
, _RotYLimitMax
;
133 float _DistLimitMin
, _DistLimitMax
;
136 bool _MouseLDown
, _MouseRDown
;
137 sint32 _MouseLDownX
, _MouseRDownX
;
138 sint32 _MouseLDownY
, _MouseRDownY
;
140 void mouseLMove (sint32 dx
, sint32 dy
);
141 void mouseRMove (sint32 dx
, sint32 dy
);
146 * class managing character 3d elements
147 * \author Matthieu 'TrapII' Besson
148 * \author Nevrax France
151 class CInterface3DCharacter
: public CInterfaceElement
154 CInterface3DCharacter();
155 virtual ~CInterface3DCharacter();
157 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
159 virtual void checkCoords();
161 void setClusterSystem (NL3D::UInstanceGroup
*pIG
);
163 float getRotX () const;
164 float getRotY () const;
165 float getRotZ () const;
167 void setRotX (float f
);
168 void setRotY (float f
);
169 void setRotZ (float f
);
171 float getPosX () const;
172 float getPosY () const;
173 float getPosZ () const;
175 void setPosX (float f
);
176 void setPosY (float f
);
177 void setPosZ (float f
);
179 float getHeadX () const;
180 float getHeadY () const;
181 float getHeadZ () const;
183 void setHeadX (float /* f */) {}
184 void setHeadY (float /* f */) {}
185 void setHeadZ (float /* f */) {}
187 sint32
getAnim () const {return 0;}
188 void setAnim (sint32 anim
);
190 CCharacter3D
* getCharacter3D() { return _Char3D
; }
192 void setPeople(const std::string
& people
);
193 std::string
getPeople() const;
195 void setSex(bool male
);
198 void setupCharacter3D(sint32 slot
);
199 int luaSetupCharacter3D(CLuaState
&ls
);
201 // active/inactive LOD of skeleton
202 int luaEnableLOD(CLuaState
&ls
);
205 REFLECT_EXPORT_START(CInterface3DCharacter
, CInterfaceElement
)
206 REFLECT_LUA_METHOD("setupCharacter3D", luaSetupCharacter3D
);
207 REFLECT_LUA_METHOD("enableLOD", luaEnableLOD
);
208 REFLECT_FLOAT ("headx", getHeadX
, setHeadX
);
209 REFLECT_FLOAT ("heady", getHeadY
, setHeadY
);
210 REFLECT_FLOAT ("headz", getHeadZ
, setHeadZ
);
211 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
212 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
213 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
214 REFLECT_FLOAT ("rotx", getRotX
, setRotX
);
215 REFLECT_FLOAT ("roty", getRotY
, setRotY
);
216 REFLECT_FLOAT ("rotz", getRotZ
, setRotZ
);
217 REFLECT_SINT32 ("anim", getAnim
, setAnim
);
218 REFLECT_STRING ("people", getPeople
, setPeople
);
219 REFLECT_BOOL ("sex", getSex
, setSex
);
223 CCharacter3D
*_Char3D
;
228 * class managing shape instance 3d elements
229 * \author Matthieu 'TrapII' Besson
230 * \author Nevrax France
233 class CInterface3DShape
: public CInterfaceElement
239 _Pos
= NLMISC::CVector(0,0,0);
240 _Rot
= NLMISC::CVector(0,0,0);
243 virtual ~CInterface3DShape();
245 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
247 NL3D::UInstance
getShape() { return _Instance
; }
249 float getPosX () const;
250 float getPosY () const;
251 float getPosZ () const;
253 void setPosX (float f
);
254 void setPosY (float f
);
255 void setPosZ (float f
);
257 float getRotX () const;
258 float getRotY () const;
259 float getRotZ () const;
261 void setRotX (float f
);
262 void setRotY (float f
);
263 void setRotZ (float f
);
265 std::string
getName() const;
266 void setName (const std::string
&ht
);
268 float getBBoxSizeX () const;
269 float getBBoxSizeY () const;
270 float getBBoxSizeZ () const;
273 REFLECT_EXPORT_START(CInterface3DShape
, CInterfaceElement
)
274 REFLECT_FLOAT("getBBoxSizeX", getBBoxSizeX
, setPosX
);
275 REFLECT_FLOAT("getBBoxSizeY", getBBoxSizeY
, setPosX
);
276 REFLECT_FLOAT("getBBoxSizeZ", getBBoxSizeZ
, setPosX
);
277 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
278 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
279 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
280 REFLECT_FLOAT ("rotx", getRotX
, setRotX
);
281 REFLECT_FLOAT ("roty", getRotY
, setRotY
);
282 REFLECT_FLOAT ("rotz", getRotZ
, setRotZ
);
283 REFLECT_STRING ("name", getName
, setName
);
288 NL3D::UInstance _Instance
;
289 NLMISC::CVector _Pos
;
290 NLMISC::CVector _Rot
;
295 * class managing instance group 3d elements
296 * \author Matthieu 'TrapII' Besson
297 * \author Nevrax France
300 class CInterface3DIG
: public CInterfaceElement
306 _Pos
= NLMISC::CVector(0,0,0);
307 _Rot
= NLMISC::CVector(0,0,0);
310 virtual ~CInterface3DIG();
312 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
314 NL3D::UInstanceGroup
*getIG() { return _IG
; }
316 float getPosX () const;
317 float getPosY () const;
318 float getPosZ () const;
320 void setPosX (float f
);
321 void setPosY (float f
);
322 void setPosZ (float f
);
324 float getRotX () const;
325 float getRotY () const;
326 float getRotZ () const;
328 void setRotX (float f
);
329 void setRotY (float f
);
330 void setRotZ (float f
);
332 std::string
getName() const;
333 void setName (const std::string
&ht
);
335 REFLECT_EXPORT_START(CInterface3DIG
, CInterfaceElement
)
336 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
337 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
338 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
339 REFLECT_FLOAT ("rotx", getRotX
, setRotX
);
340 REFLECT_FLOAT ("roty", getRotY
, setRotY
);
341 REFLECT_FLOAT ("rotz", getRotZ
, setRotZ
);
342 REFLECT_STRING ("name", getName
, setName
);
347 NL3D::UInstanceGroup
*_IG
;
348 NLMISC::CVector _Pos
;
349 NLMISC::CVector _Rot
;
354 * class managing camera 3d elements
355 * \author Matthieu 'TrapII' Besson
356 * \author Nevrax France
359 class CInterface3DCamera
: public CInterfaceElement
366 _Rot
= NLMISC::CVector(0,0,0);
367 _Pos
= NLMISC::CVector(0,0,0);
368 _Target
= NLMISC::CVector(0,0,1);
374 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
375 float getFOV() { return _FOV
; }
376 NLMISC::CVector
getPos() { return _Pos
; }
377 NLMISC::CVector
getTarget() { return _Target
; }
379 void setRoll(float f
) { _Roll
= f
; }
380 float getRoll() const { return _Roll
; }
381 void setFOV(float f
) { _FOV
= f
; }
382 float getFOV() const { return _FOV
; }
384 void setPosX(float f
) { _Pos
.x
= f
; _Dist
= (_Pos
-_Target
).norm(); }
385 void setPosY(float f
) { _Pos
.y
= f
; _Dist
= (_Pos
-_Target
).norm(); }
386 void setPosZ(float f
) { _Pos
.z
= f
; _Dist
= (_Pos
-_Target
).norm(); }
388 float getPosX() const { return _Pos
.x
; }
389 float getPosY() const { return _Pos
.y
; }
390 float getPosZ() const { return _Pos
.z
; }
392 void setTgtX(float f
) { _Target
.x
= f
; _Dist
= (_Pos
-_Target
).norm(); }
393 void setTgtY(float f
) { _Target
.y
= f
; _Dist
= (_Pos
-_Target
).norm(); }
394 void setTgtZ(float f
) { _Target
.z
= f
; _Dist
= (_Pos
-_Target
).norm(); }
396 float getTgtX() const { return _Target
.x
; }
397 float getTgtY() const { return _Target
.y
; }
398 float getTgtZ() const { return _Target
.z
; }
400 REFLECT_EXPORT_START(CInterface3DCamera
, CInterfaceElement
)
401 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
402 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
403 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
404 REFLECT_FLOAT ("tgtx", getTgtX
, setTgtX
);
405 REFLECT_FLOAT ("tgty", getTgtY
, setTgtY
);
406 REFLECT_FLOAT ("tgtz", getTgtZ
, setTgtZ
);
407 REFLECT_FLOAT ("fov", getFOV
, setFOV
);
408 REFLECT_FLOAT ("roll", getRoll
, setRoll
);
411 float getRotZ() const { return _Rot
.z
; }
412 void setRotZ(float f
) { _Rot
.z
= f
; }
414 float getRotY() const { return _Rot
.y
; }
415 void setRotY(float f
) { _Rot
.y
= f
; }
417 float getDist() const { return _Dist
; }
418 void setDist(float f
) { _Dist
= f
; }
420 void reset(); // Reset user interaction
424 NLMISC::CVector _Rot
;
427 NLMISC::CVector _Pos
;
428 NLMISC::CVector _Target
;
434 * class managing light 3d elements
435 * \author Matthieu 'TrapII' Besson
436 * \author Nevrax France
439 class CInterface3DLight
: public CInterfaceElement
444 _Pos
= NLMISC::CVector(0,0,0);
447 _Color
= NLMISC::CRGBA(255,255,255);
451 virtual ~CInterface3DLight();
453 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
455 float getPosX() const { return _Pos
.x
; }
456 float getPosY() const { return _Pos
.y
; }
457 float getPosZ() const { return _Pos
.z
; }
459 void setPosX(float f
);
460 void setPosY(float f
);
461 void setPosZ(float f
);
463 float getNear() const { return _Near
; }
464 float getFar() const { return _Far
; }
466 void setNear(float f
);
467 void setFar(float f
);
469 sint32
getColR() const { return _Color
.R
; }
470 sint32
getColG() const { return _Color
.G
; }
471 sint32
getColB() const { return _Color
.B
; }
473 void setColR(sint32 f
);
474 void setColG(sint32 f
);
475 void setColB(sint32 f
);
477 REFLECT_EXPORT_START(CInterface3DLight
, CInterfaceElement
)
478 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
479 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
480 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
481 REFLECT_FLOAT ("near", getNear
, setNear
);
482 REFLECT_FLOAT ("far", getFar
, setFar
);
483 REFLECT_SINT32 ("colr", getColR
, setColR
);
484 REFLECT_SINT32 ("colg", getColG
, setColG
);
485 REFLECT_SINT32 ("colb", getColB
, setColB
);
490 NLMISC::CVector _Pos
;
492 NLMISC::CRGBA _Color
;
494 NL3D::UPointLight _Light
;
499 * class managing fx 3d elements
500 * \author Matthieu 'TrapII' Besson
501 * \author Nevrax France
504 class CInterface3DFX
: public CInterfaceElement
509 _Pos
= NLMISC::CVector(0,0,0);
513 virtual ~CInterface3DFX();
515 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
517 virtual void checkCoords();
519 NL3D::UParticleSystemInstance
getPS() { return _FX
; }
521 float getPosX () const;
522 float getPosY () const;
523 float getPosZ () const;
525 void setPosX (float f
);
526 void setPosY (float f
);
527 void setPosZ (float f
);
529 float getRotX () const;
530 float getRotY () const;
531 float getRotZ () const;
533 void setRotX (float f
);
534 void setRotY (float f
);
535 void setRotZ (float f
);
537 std::string
getName() const;
538 void setName (const std::string
&ht
);
540 bool getStarted() const;
541 void setStarted (bool b
);
543 REFLECT_EXPORT_START(CInterface3DFX
, CInterfaceElement
)
544 REFLECT_FLOAT ("posx", getPosX
, setPosX
);
545 REFLECT_FLOAT ("posy", getPosY
, setPosY
);
546 REFLECT_FLOAT ("posz", getPosZ
, setPosZ
);
547 REFLECT_FLOAT ("rotx", getRotX
, setRotX
);
548 REFLECT_FLOAT ("roty", getRotY
, setRotY
);
549 REFLECT_FLOAT ("rotz", getRotZ
, setRotZ
);
550 REFLECT_STRING ("name", getName
, setName
);
551 REFLECT_BOOL ("started", getStarted
, setStarted
);
556 NL3D::UParticleSystemInstance _FX
;
558 NLMISC::CVector _Pos
;
559 NLMISC::CVector _Rot
;
564 #endif // RZ_INTERFACE_SCENE_3D_H
566 /* end of interface_3d_scene.h */