1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef CL_SCENE_PARSER_H
21 #define CL_SCENE_PARSER_H
28 #include "nel/misc/types_nl.h"
29 #include "nel/misc/vector.h"
30 #include "nel/misc/quat.h"
32 #include "nel/3d/u_animation_set.h"
33 #include "nel/3d/u_play_list_manager.h"
34 #include "nel/3d/u_play_list.h"
35 #include "nel/3d/u_instance_group.h"
48 using NLMISC::CVector
;
50 using NL3D::UPlayListManager
;
51 using NL3D::UAnimationSet
;
52 using NL3D::UAnimation
;
53 using NL3D::UPlayList
;
54 using NL3D::UInstanceGroup
;
68 * Class to parse a scene.
69 * \author Guillaume PUZIN
70 * \author Nevrax France
76 static const uint MAX_LINE_SIZE
;
77 static const char *delimiter
;
80 void parse(ifstream
&file
);
82 /// Skip empty lines and comment lines.
83 void getNextValidLine(ifstream
&file
, char *buff
);
87 /// Parse the list of IG to load for the scene.
88 void parseIG(ifstream
&file
, char *buff
);
89 /// Get the name of the IG to initialize entities.
93 void parseParticle(ifstream
&file
, char *buff
);
94 /// Parse Particle's Id.
95 void parseParticleId();
96 /// Parse Particle's IG.
97 void parseParticleIG();
98 /// Parse Particle's Cluster
99 void parseParticleCluster();
100 /// Parse Particle's Actor.
101 void parseParticleActor();
102 /// Parse Particle's anims.
103 void parseParticleAnims(ifstream
&file
, char *buff
);
106 void parseActor(ifstream
&file
, char *buff
);
107 /// Parse the current actor Id.
109 /// Parse the current actor Name.
111 /// Is the Actor a flyer.
113 /// Parse Actor's Actor.
114 void parseActorActor();
115 /// Parse the current actor Skeleton Name.
117 /// Parse meshes used for the current actor.
118 void parseMeshes(ifstream
&file
, char *buff
);
119 /// Parse anims used for the current actor.
120 void parseAnims(ifstream
&file
, char *buff
);
122 /// Parse all anims used for the camera in all sequence.
123 void parseCamAnims(ifstream
&file
, char *buff
);
125 /// Parse a sequence.
126 void parseSequence(ifstream
&file
, char *buff
);
127 /// Parse the current sequence Id.
129 /// Parse particle in the sequence.
130 void parseSeqParticle(ifstream
&file
, char *buff
);
131 /// Parse the current particle's Id in the current sequence.
132 void parseSeqParticleId();
133 /// Parse anims used for the current particle in the current sequence.
134 void parseSeqParticleAnims(ifstream
&file
, char *buff
);
135 /// Parse an actor in a sequence.
136 void parseSeqActor(ifstream
&file
, char *buff
);
137 /// Parse the current actor's Id in the current sequence.
138 void parseSeqActorId();
139 /// Parse anims used for the current actor in the current sequence.
140 void parseSeqActorAnims(ifstream
&file
, char *buff
);
141 /// Parse camera in the sequence.
142 void parseSeqCam(ifstream
&file
, char *buff
);
144 /// Initialize Actors Position and rotation .
149 /// Reset all particles.
150 void resetParticles();
151 /// Reset all actors.
154 /// Initialize the Camera and reset it the second time.
156 /// Initialize IG for the scenery (IG present from start to end like trees or torch.
158 /// Initialize the scene with the parameters loaded from the script for particles.
159 void applyParticles();
160 /// Initialize actors.
168 /// List of IG to load for the scene.
173 /// Class to stock parameters for a particle (system).
183 UInstanceGroup
*IGPtr
;
184 vector
<CVector
> IGPos
;
186 map
<string
, uint
> AnimToId
;
187 UAnimationSet
*AnimationSet
;
207 /// Class to stock parameters for an actor.
231 /// Class to stock parameters for an actor in a sequence.
245 /// Class to stock parameters for an actor in a sequence.
259 /// Class to stock parameters for a sequence.
264 map
<uint
, CParticleSeq
> ParticlesSeq
;
265 map
<uint
, CActorSeq
> ActorsSeq
;
266 list
<string
> CamAnims
;
276 list
<string
> _CamAnims
;
277 /// Particle with the parse in progress.
278 CParticle _CurrentParticle
;
279 /// All particles in the scene.
280 map
<uint
, CParticle
> _Particles
;
281 /// Actor with the parse in progress.
282 CActor _CurrentActor
;
283 /// All actors in the scene.
284 map
<uint
, CActor
> _Actors
;
286 CParticleSeq _CurParticleSeq
;
288 CActorSeq _CurrentActorSeq
;
290 CSequence _CurrentSequence
;
291 /// All Sequences in the scene.
292 map
<uint
, CSequence
> _Sequences
;
295 UPlayListManager
*_PlayListManager
;
296 UAnimationSet
*_AnimationSet
;
297 UPlayList
*_PlayList
;
298 map
<string
, uint
> _AnimCamToId
;
300 set
<UInstanceGroup
*> _IGInScene
;
303 typedef list
<pair
<sint
, double> > TScene
;
305 TScene::iterator _ItScene
;
309 /// Update the camera (position, target, roll, fov).
310 void updateCamera(double timeInSec
);
311 /// Update actor position (for actor on another actor).
313 /// Update particles.
314 void updateParticles(double timeInSec
);
315 void updateParticlesNoActor(float difTime
, CParticle
&particle
, UAnimation
&animation
);
316 void updateParticlesActor(float difTime
, CParticle
&particle
, UAnimation
&animation
);
322 inline bool Time() {return _Day
;}
324 /// Load the file with the scene.
325 void load(const string
&filename
);
327 /// Initialize the scene with the parameters loaded from the script.
331 void update(double timeInSec
);
333 /// Play the sequence with the ID 'seq'.
334 void playSeq(uint seq
, double timeInSec
);
336 inline double frameRate() {return _FrameRate
;}
337 inline void frameRate(double fr
) {_FrameRate
= fr
;}
340 * Functions to manage a scene.
344 * Load a scene from a file and put it in memory.
345 * \param filename : filename for the file that contains the scene.
346 * \warning This function clear the old scene.
348 void loadScene(const string
&filename
);
350 * Play a scene in memory.
351 * \param timeInSec : current time in second.
353 void playScene(double timeInSec
);
355 * Update the scene currently playing.
356 * \param timeInSec : current time in second.
358 void updateScene(double timeInSec
);
360 * Stop the scene currently playing.
364 * Function to know if there is a scene currently playing.
365 * \return bool : 'true' if there is a scene currently playing.
367 bool isScenePlaying();
372 #endif // CL_SCENE_PARSER_H
374 /* End of scene_parser.h */