55#include <ext/rapidjson/document.h>
56#include <ext/rapidjson/stringbuffer.h>
57#include <ext/rapidjson/writer.h>
59using std::ostringstream;
109using rapidjson::Document;
110using rapidjson::StringBuffer;
111using rapidjson::Value;
112using rapidjson::Writer;
114void PrototypeWriter::copyFile(
const string& source,
const string& dest)
120 prototype->
setFileName((pathName.empty() ==
false?pathName +
"/":
"") + fileName);
124 write(jRoot, jRoot, prototype);
127 Writer<StringBuffer> writer(strbuf);
128 jRoot.Accept(writer);
130 FileSystem::getInstance()->setContentFromString(pathName, fileName, strbuf.GetString());
134 auto& jAllocator = jDocument.GetAllocator();
135 jLodLevelRoot.SetObject();
136 jLodLevelRoot.AddMember(
"t", Value(lodLevel->
getType()), jAllocator);
139 auto modelPathName = Tools::getPathName(lodLevel->
getFileName());
140 auto modelFileName = Tools::removeFileEnding(Tools::getFileName(lodLevel->
getFileName())) +
".tm";
146 jLodLevelRoot.AddMember(
"f", Value(modelPathName +
"/" + modelFileName, jAllocator), jAllocator);
148 jLodLevelRoot.AddMember(
"d", Value(lodLevel->
getMinDistance()), jAllocator);
149 jLodLevelRoot.AddMember(
"cmr", Value(lodLevel->
getColorMul().
getRed()), jAllocator);
153 jLodLevelRoot.AddMember(
"car", Value(lodLevel->
getColorAdd().
getRed()), jAllocator);
161 auto& jAllocator = jDocument.GetAllocator();
164 auto modelFileName = Tools::removeFileEnding(Tools::getFileName(prototype->
getModelFileName())) +
".tm";
172 if (Application::hasApplication() ==
true) {
173 vector<uint8_t> pngData;
174 string base64PNGData;
175 Tools::oseThumbnail(prototype, pngData);
176 Base64::encode(pngData, base64PNGData);
177 jPrototypeRoot.AddMember(
"thumbnail", Value(base64PNGData, jAllocator), jAllocator);
180 jPrototypeRoot.AddMember(
"file", Value(modelPathName +
"/" + modelFileName, jAllocator), jAllocator);
181 jPrototypeRoot.AddMember(
"tm", Value(prototype->
isTerrainMesh()), jAllocator);
185 if (lodLevel !=
nullptr &&
188 lodLevel->getModel() !=
nullptr))) {
191 jLodLevel.SetObject();
193 jPrototypeRoot.AddMember(Value(
"ll" + to_string(lodLevelIdx), jAllocator), jLodLevel, jAllocator);
199 if (lodLevel !=
nullptr &&
202 lodLevel->getModel() !=
nullptr))) {
206 jLodLevel.SetObject();
208 jPrototypeRoot.AddMember(Value(
"ll" + to_string(lodLevelIdx), jAllocator), jLodLevel, jAllocator);
214 if (imposterLOD !=
nullptr) {
216 Value jImposterLODFiles;
217 jImposterLODFiles.SetArray();
218 for (
auto& fileName: imposterLOD->getFileNames()) {
219 jImposterLODFiles.PushBack(Value(fileName, jAllocator), jAllocator);
221 jImposterLOD.SetObject();
222 jImposterLOD.AddMember(
"f", jImposterLODFiles, jAllocator);
223 jImposterLOD.AddMember(
"d", Value(imposterLOD->getMinDistance()), jAllocator);
224 jImposterLOD.AddMember(
"cmr", Value(imposterLOD->getColorMul().getRed()), jAllocator);
225 jImposterLOD.AddMember(
"cmg", Value(imposterLOD->getColorMul().getGreen()), jAllocator);
226 jImposterLOD.AddMember(
"cmb", Value(imposterLOD->getColorMul().getBlue()), jAllocator);
227 jImposterLOD.AddMember(
"cma", Value(imposterLOD->getColorMul().getAlpha()), jAllocator);
228 jImposterLOD.AddMember(
"car", Value(imposterLOD->getColorAdd().getRed()), jAllocator);
229 jImposterLOD.AddMember(
"cag", Value(imposterLOD->getColorAdd().getGreen()), jAllocator);
230 jImposterLOD.AddMember(
"cab", Value(imposterLOD->getColorAdd().getBlue()), jAllocator);
231 jImposterLOD.AddMember(
"caa", Value(imposterLOD->getColorAdd().getAlpha()), jAllocator);
232 jPrototypeRoot.AddMember(
"il", jImposterLOD, jAllocator);
236 jPrototypeRoot.AddMember(
"version", Value(
"1.99", jAllocator), jAllocator);
237 jPrototypeRoot.AddMember(
"type", Value(prototype->
getType()->
getName(), jAllocator), jAllocator);
238 jPrototypeRoot.AddMember(
"name", Value(prototype->
getName(), jAllocator), jAllocator);
239 jPrototypeRoot.AddMember(
"descr", Value(prototype->
getDescription(), jAllocator), jAllocator);
240 jPrototypeRoot.AddMember(
"px", Value(prototype->
getPivot().
getX()), jAllocator);
241 jPrototypeRoot.AddMember(
"py", Value(prototype->
getPivot().
getY()), jAllocator);
242 jPrototypeRoot.AddMember(
"pz", Value(prototype->
getPivot().
getZ()), jAllocator);
243 if (prototype->
getType() == Prototype_Type::PARTICLESYSTEM) {
244 Value jParticleSystems;
245 jParticleSystems.SetArray();
248 Value jParticleSystem;
249 jParticleSystem.SetObject();
250 jParticleSystem.AddMember(
"t", Value(particleSystem->getType()->getName(), jAllocator), jAllocator);
252 auto v = particleSystem->
getType();
253 if (v == PrototypeParticleSystem_Type::NONE) {
256 if (v == PrototypeParticleSystem_Type::OBJECT_PARTICLE_SYSTEM)
258 Value jObjectParticleSystem;
259 jObjectParticleSystem.SetObject();
260 if (particleSystem->getObjectParticleSystem()->getModelFileName().length() > 0) {
261 auto modelPathName = Tools::getPathName(particleSystem->getObjectParticleSystem()->getModelFileName());
262 auto modelFileName = Tools::removeFileEnding(Tools::getFileName(particleSystem->getObjectParticleSystem()->getModelFileName())) +
".tm";
264 particleSystem->getObjectParticleSystem()->getModel(),
268 particleSystem->getObjectParticleSystem()->setModelFile(modelPathName +
"/" + modelFileName);
270 jObjectParticleSystem.AddMember(
"mc", Value(particleSystem->getObjectParticleSystem()->getMaxCount()), jAllocator);
271 jObjectParticleSystem.AddMember(
"sx", Value(particleSystem->getObjectParticleSystem()->getScale().getX()), jAllocator);
272 jObjectParticleSystem.AddMember(
"sy", Value(particleSystem->getObjectParticleSystem()->getScale().getY()), jAllocator);
273 jObjectParticleSystem.AddMember(
"sz", Value(particleSystem->getObjectParticleSystem()->getScale().getZ()), jAllocator);
274 jObjectParticleSystem.AddMember(
"mf", Value(particleSystem->getObjectParticleSystem()->getModelFileName(), jAllocator), jAllocator);
275 jObjectParticleSystem.AddMember(
"ae", Value(particleSystem->getObjectParticleSystem()->isAutoEmit()), jAllocator);
276 jParticleSystem.AddMember(
"ops", jObjectParticleSystem, jAllocator);
278 if (v == PrototypeParticleSystem_Type::POINT_PARTICLE_SYSTEM)
280 Value jPointParticleSystem;
281 jPointParticleSystem.SetObject();
282 jPointParticleSystem.AddMember(
"mp", Value(particleSystem->getPointParticleSystem()->getMaxPoints()), jAllocator);
283 jPointParticleSystem.AddMember(
"ps", Value(particleSystem->getPointParticleSystem()->getPointSize()), jAllocator);
284 jPointParticleSystem.AddMember(
"t", Value(particleSystem->getPointParticleSystem()->getTextureFileName(), jAllocator), jAllocator);
285 jPointParticleSystem.AddMember(
"tt", Value(particleSystem->getPointParticleSystem()->getTransparencyTextureFileName(), jAllocator), jAllocator);
286 jPointParticleSystem.AddMember(
"ths", Value(particleSystem->getPointParticleSystem()->getTextureHorizontalSprites()), jAllocator);
287 jPointParticleSystem.AddMember(
"tvs", Value(particleSystem->getPointParticleSystem()->getTextureVerticalSprites()), jAllocator);
288 jPointParticleSystem.AddMember(
"fps", Value(particleSystem->getPointParticleSystem()->getTextureSpritesFPS()), jAllocator);
289 jPointParticleSystem.AddMember(
"ae", Value(particleSystem->getPointParticleSystem()->isAutoEmit()), jAllocator);
290 jParticleSystem.AddMember(
"pps", jPointParticleSystem, jAllocator);
292 if (v == PrototypeParticleSystem_Type::FOG_PARTICLE_SYSTEM)
294 Value jFogParticleSystem;
295 jFogParticleSystem.SetObject();
296 jFogParticleSystem.AddMember(
"mp", Value(particleSystem->getFogParticleSystem()->getMaxPoints()), jAllocator);
297 jFogParticleSystem.AddMember(
"ps", Value(particleSystem->getFogParticleSystem()->getPointSize()), jAllocator);
298 jFogParticleSystem.AddMember(
"t", Value(particleSystem->getFogParticleSystem()->getTextureFileName(), jAllocator), jAllocator);
299 jFogParticleSystem.AddMember(
"tt", Value(particleSystem->getFogParticleSystem()->getTransparencyTextureFileName(), jAllocator), jAllocator);
300 jFogParticleSystem.AddMember(
"ths", Value(particleSystem->getFogParticleSystem()->getTextureHorizontalSprites()), jAllocator);
301 jFogParticleSystem.AddMember(
"tvs", Value(particleSystem->getFogParticleSystem()->getTextureVerticalSprites()), jAllocator);
302 jFogParticleSystem.AddMember(
"fps", Value(particleSystem->getFogParticleSystem()->getTextureSpritesFPS()), jAllocator);
303 jParticleSystem.AddMember(
"fps", jFogParticleSystem, jAllocator);
307 "PrototypeWriter::export(): unknown particle system type '" +
308 particleSystem->getType()->getName() +
315 jParticleSystem.AddMember(
"e", Value(particleSystem->getEmitter()->getName(), jAllocator), jAllocator);
317 auto v = particleSystem->getEmitter();
318 if (v == PrototypeParticleSystem_Emitter::NONE)
321 if (v == PrototypeParticleSystem_Emitter::POINT_PARTICLE_EMITTER)
323 Value jPointParticleEmitter;
324 jPointParticleEmitter.SetObject();
325 auto emitter = particleSystem->getPointParticleEmitter();
326 jPointParticleEmitter.AddMember(
"c", Value(emitter->getCount()), jAllocator);
327 jPointParticleEmitter.AddMember(
"lt", Value(emitter->getLifeTime()), jAllocator);
328 jPointParticleEmitter.AddMember(
"ltrnd", Value(emitter->getLifeTimeRnd()), jAllocator);
329 jPointParticleEmitter.AddMember(
"m", Value(emitter->getMass()), jAllocator);
330 jPointParticleEmitter.AddMember(
"mrnd", Value(emitter->getMassRnd()), jAllocator);
331 jPointParticleEmitter.AddMember(
"px", Value(emitter->getPosition().getX()), jAllocator);
332 jPointParticleEmitter.AddMember(
"py", Value(emitter->getPosition().getY()), jAllocator);
333 jPointParticleEmitter.AddMember(
"pz", Value(emitter->getPosition().getZ()), jAllocator);
334 jPointParticleEmitter.AddMember(
"vx", Value(emitter->getVelocity().getX()), jAllocator);
335 jPointParticleEmitter.AddMember(
"vy", Value(emitter->getVelocity().getY()), jAllocator);
336 jPointParticleEmitter.AddMember(
"vz", Value(emitter->getVelocity().getZ()), jAllocator);
337 jPointParticleEmitter.AddMember(
"vrndx", Value(emitter->getVelocityRnd().getX()), jAllocator);
338 jPointParticleEmitter.AddMember(
"vrndy", Value(emitter->getVelocityRnd().getY()), jAllocator);
339 jPointParticleEmitter.AddMember(
"vrndz", Value(emitter->getVelocityRnd().getZ()), jAllocator);
340 jPointParticleEmitter.AddMember(
"csr", Value(emitter->getColorStart().getRed()), jAllocator);
341 jPointParticleEmitter.AddMember(
"csg", Value(emitter->getColorStart().getGreen()), jAllocator);
342 jPointParticleEmitter.AddMember(
"csb", Value(emitter->getColorStart().getBlue()), jAllocator);
343 jPointParticleEmitter.AddMember(
"csa", Value(emitter->getColorStart().getAlpha()), jAllocator);
344 jPointParticleEmitter.AddMember(
"cer", Value(emitter->getColorEnd().getRed()), jAllocator);
345 jPointParticleEmitter.AddMember(
"ceg", Value(emitter->getColorEnd().getGreen()), jAllocator);
346 jPointParticleEmitter.AddMember(
"ceb", Value(emitter->getColorEnd().getBlue()), jAllocator);
347 jPointParticleEmitter.AddMember(
"cea", Value(emitter->getColorEnd().getAlpha()), jAllocator);
348 jParticleSystem.AddMember(
"ppe", jPointParticleEmitter, jAllocator);
350 if (v == PrototypeParticleSystem_Emitter::BOUNDINGBOX_PARTICLE_EMITTER)
352 Value jBoundingBoxParticleEmitter;
353 jBoundingBoxParticleEmitter.SetObject();
354 auto emitter = particleSystem->getBoundingBoxParticleEmitters();
355 jBoundingBoxParticleEmitter.AddMember(
"c", Value(emitter->getCount()), jAllocator);
356 jBoundingBoxParticleEmitter.AddMember(
"lt", Value(emitter->getLifeTime()), jAllocator);
357 jBoundingBoxParticleEmitter.AddMember(
"ltrnd", Value(emitter->getLifeTimeRnd()), jAllocator);
358 jBoundingBoxParticleEmitter.AddMember(
"m", Value(emitter->getMass()), jAllocator);
359 jBoundingBoxParticleEmitter.AddMember(
"mrnd", Value(emitter->getMassRnd()), jAllocator);
360 jBoundingBoxParticleEmitter.AddMember(
"vx", Value(emitter->getVelocity().getX()), jAllocator);
361 jBoundingBoxParticleEmitter.AddMember(
"vy", Value(emitter->getVelocity().getY()), jAllocator);
362 jBoundingBoxParticleEmitter.AddMember(
"vz", Value(emitter->getVelocity().getZ()), jAllocator);
363 jBoundingBoxParticleEmitter.AddMember(
"vrndx", Value(emitter->getVelocityRnd().getX()), jAllocator);
364 jBoundingBoxParticleEmitter.AddMember(
"vrndy", Value(emitter->getVelocityRnd().getY()), jAllocator);
365 jBoundingBoxParticleEmitter.AddMember(
"vrndz", Value(emitter->getVelocityRnd().getZ()), jAllocator);
366 jBoundingBoxParticleEmitter.AddMember(
"csr", Value(emitter->getColorStart().getRed()), jAllocator);
367 jBoundingBoxParticleEmitter.AddMember(
"csg", Value(emitter->getColorStart().getGreen()), jAllocator);
368 jBoundingBoxParticleEmitter.AddMember(
"csb", Value(emitter->getColorStart().getBlue()), jAllocator);
369 jBoundingBoxParticleEmitter.AddMember(
"csa", Value(emitter->getColorStart().getAlpha()), jAllocator);
370 jBoundingBoxParticleEmitter.AddMember(
"cer", Value(emitter->getColorEnd().getRed()), jAllocator);
371 jBoundingBoxParticleEmitter.AddMember(
"ceg", Value(emitter->getColorEnd().getGreen()), jAllocator);
372 jBoundingBoxParticleEmitter.AddMember(
"ceb", Value(emitter->getColorEnd().getBlue()), jAllocator);
373 jBoundingBoxParticleEmitter.AddMember(
"cea", Value(emitter->getColorEnd().getAlpha()), jAllocator);
374 jBoundingBoxParticleEmitter.AddMember(
"ocx", Value(emitter->getObbCenter().getX()), jAllocator);
375 jBoundingBoxParticleEmitter.AddMember(
"ocy", Value(emitter->getObbCenter().getY()), jAllocator);
376 jBoundingBoxParticleEmitter.AddMember(
"ocz", Value(emitter->getObbCenter().getZ()), jAllocator);
377 jBoundingBoxParticleEmitter.AddMember(
"ohex", Value(emitter->getObbHalfextension().getX()), jAllocator);
378 jBoundingBoxParticleEmitter.AddMember(
"ohey", Value(emitter->getObbHalfextension().getY()), jAllocator);
379 jBoundingBoxParticleEmitter.AddMember(
"ohez", Value(emitter->getObbHalfextension().getZ()), jAllocator);
380 jBoundingBoxParticleEmitter.AddMember(
"oa0x", Value(emitter->getObbAxis0().getX()), jAllocator);
381 jBoundingBoxParticleEmitter.AddMember(
"oa0y", Value(emitter->getObbAxis0().getY()), jAllocator);
382 jBoundingBoxParticleEmitter.AddMember(
"oa0z", Value(emitter->getObbAxis0().getZ()), jAllocator);
383 jBoundingBoxParticleEmitter.AddMember(
"oa1x", Value(emitter->getObbAxis1().getX()), jAllocator);
384 jBoundingBoxParticleEmitter.AddMember(
"oa1y", Value(emitter->getObbAxis1().getY()), jAllocator);
385 jBoundingBoxParticleEmitter.AddMember(
"oa1z", Value(emitter->getObbAxis1().getZ()), jAllocator);
386 jBoundingBoxParticleEmitter.AddMember(
"oa2x", Value(emitter->getObbAxis2().getX()), jAllocator);
387 jBoundingBoxParticleEmitter.AddMember(
"oa2y", Value(emitter->getObbAxis2().getY()), jAllocator);
388 jBoundingBoxParticleEmitter.AddMember(
"oa2z", Value(emitter->getObbAxis2().getZ()), jAllocator);
389 jParticleSystem.AddMember(
"bbpe", jBoundingBoxParticleEmitter, jAllocator);
391 if (v == PrototypeParticleSystem_Emitter::CIRCLE_PARTICLE_EMITTER)
393 Value jCircleParticleEmitter;
394 jCircleParticleEmitter.SetObject();
395 auto emitter = particleSystem->getCircleParticleEmitter();
396 jCircleParticleEmitter.AddMember(
"c", Value(emitter->getCount()), jAllocator);
397 jCircleParticleEmitter.AddMember(
"lt", Value(emitter->getLifeTime()), jAllocator);
398 jCircleParticleEmitter.AddMember(
"ltrnd", Value(emitter->getLifeTimeRnd()), jAllocator);
399 jCircleParticleEmitter.AddMember(
"m", Value(emitter->getMass()), jAllocator);
400 jCircleParticleEmitter.AddMember(
"mrnd", Value(emitter->getMassRnd()), jAllocator);
401 jCircleParticleEmitter.AddMember(
"vx", Value(emitter->getVelocity().getX()), jAllocator);
402 jCircleParticleEmitter.AddMember(
"vy", Value(emitter->getVelocity().getY()), jAllocator);
403 jCircleParticleEmitter.AddMember(
"vz", Value(emitter->getVelocity().getZ()), jAllocator);
404 jCircleParticleEmitter.AddMember(
"vrndx", Value(emitter->getVelocityRnd().getX()), jAllocator);
405 jCircleParticleEmitter.AddMember(
"vrndy", Value(emitter->getVelocityRnd().getY()), jAllocator);
406 jCircleParticleEmitter.AddMember(
"vrndz", Value(emitter->getVelocityRnd().getZ()), jAllocator);
407 jCircleParticleEmitter.AddMember(
"csr", Value(emitter->getColorStart().getRed()), jAllocator);
408 jCircleParticleEmitter.AddMember(
"csg", Value(emitter->getColorStart().getGreen()), jAllocator);
409 jCircleParticleEmitter.AddMember(
"csb", Value(emitter->getColorStart().getBlue()), jAllocator);
410 jCircleParticleEmitter.AddMember(
"csa", Value(emitter->getColorStart().getAlpha()), jAllocator);
411 jCircleParticleEmitter.AddMember(
"cer", Value(emitter->getColorEnd().getRed()), jAllocator);
412 jCircleParticleEmitter.AddMember(
"ceg", Value(emitter->getColorEnd().getGreen()), jAllocator);
413 jCircleParticleEmitter.AddMember(
"ceb", Value(emitter->getColorEnd().getBlue()), jAllocator);
414 jCircleParticleEmitter.AddMember(
"cea", Value(emitter->getColorEnd().getAlpha()), jAllocator);
415 jCircleParticleEmitter.AddMember(
"cx", Value(emitter->getCenter().getX()), jAllocator);
416 jCircleParticleEmitter.AddMember(
"cy", Value(emitter->getCenter().getY()), jAllocator);
417 jCircleParticleEmitter.AddMember(
"cz", Value(emitter->getCenter().getZ()), jAllocator);
418 jCircleParticleEmitter.AddMember(
"r", Value(emitter->getRadius()), jAllocator);
419 jCircleParticleEmitter.AddMember(
"a0x", Value(emitter->getAxis0().getX()), jAllocator);
420 jCircleParticleEmitter.AddMember(
"a0y", Value(emitter->getAxis0().getY()), jAllocator);
421 jCircleParticleEmitter.AddMember(
"a0z", Value(emitter->getAxis0().getZ()), jAllocator);
422 jCircleParticleEmitter.AddMember(
"a1x", Value(emitter->getAxis1().getX()), jAllocator);
423 jCircleParticleEmitter.AddMember(
"a1y", Value(emitter->getAxis1().getY()), jAllocator);
424 jCircleParticleEmitter.AddMember(
"a1z", Value(emitter->getAxis1().getZ()), jAllocator);
425 jParticleSystem.AddMember(
"cpe", jCircleParticleEmitter, jAllocator);
427 if (v == PrototypeParticleSystem_Emitter::CIRCLE_PARTICLE_EMITTER_PLANE_VELOCITY) {
428 Value jCircleParticleEmitterPlaneVelocity;
429 jCircleParticleEmitterPlaneVelocity.SetObject();
430 auto emitter = particleSystem->getCircleParticleEmitterPlaneVelocity();
431 jCircleParticleEmitterPlaneVelocity.AddMember(
"c", Value(emitter->getCount()), jAllocator);
432 jCircleParticleEmitterPlaneVelocity.AddMember(
"lt", Value(emitter->getLifeTime()), jAllocator);
433 jCircleParticleEmitterPlaneVelocity.AddMember(
"ltrnd", Value(emitter->getLifeTimeRnd()), jAllocator);
434 jCircleParticleEmitterPlaneVelocity.AddMember(
"m", Value(emitter->getMass()), jAllocator);
435 jCircleParticleEmitterPlaneVelocity.AddMember(
"mrnd", Value(emitter->getMassRnd()), jAllocator);
436 jCircleParticleEmitterPlaneVelocity.AddMember(
"v", Value(emitter->getVelocity()), jAllocator);
437 jCircleParticleEmitterPlaneVelocity.AddMember(
"vrnd", Value(emitter->getVelocityRnd()), jAllocator);
438 jCircleParticleEmitterPlaneVelocity.AddMember(
"csr", Value(emitter->getColorStart().getRed()), jAllocator);
439 jCircleParticleEmitterPlaneVelocity.AddMember(
"csg", Value(emitter->getColorStart().getGreen()), jAllocator);
440 jCircleParticleEmitterPlaneVelocity.AddMember(
"csb", Value(emitter->getColorStart().getBlue()), jAllocator);
441 jCircleParticleEmitterPlaneVelocity.AddMember(
"csa", Value(emitter->getColorStart().getAlpha()), jAllocator);
442 jCircleParticleEmitterPlaneVelocity.AddMember(
"cer", Value(emitter->getColorEnd().getRed()), jAllocator);
443 jCircleParticleEmitterPlaneVelocity.AddMember(
"ceg", Value(emitter->getColorEnd().getGreen()), jAllocator);
444 jCircleParticleEmitterPlaneVelocity.AddMember(
"ceb", Value(emitter->getColorEnd().getBlue()), jAllocator);
445 jCircleParticleEmitterPlaneVelocity.AddMember(
"cea", Value(emitter->getColorEnd().getAlpha()), jAllocator);
446 jCircleParticleEmitterPlaneVelocity.AddMember(
"cx", Value(emitter->getCenter().getX()), jAllocator);
447 jCircleParticleEmitterPlaneVelocity.AddMember(
"cy", Value(emitter->getCenter().getY()), jAllocator);
448 jCircleParticleEmitterPlaneVelocity.AddMember(
"cz", Value(emitter->getCenter().getZ()), jAllocator);
449 jCircleParticleEmitterPlaneVelocity.AddMember(
"r", Value(emitter->getRadius()), jAllocator);
450 jCircleParticleEmitterPlaneVelocity.AddMember(
"a0x", Value(emitter->getAxis0().getX()), jAllocator);
451 jCircleParticleEmitterPlaneVelocity.AddMember(
"a0y", Value(emitter->getAxis0().getY()), jAllocator);
452 jCircleParticleEmitterPlaneVelocity.AddMember(
"a0z", Value(emitter->getAxis0().getZ()), jAllocator);
453 jCircleParticleEmitterPlaneVelocity.AddMember(
"a1x", Value(emitter->getAxis1().getX()), jAllocator);
454 jCircleParticleEmitterPlaneVelocity.AddMember(
"a1y", Value(emitter->getAxis1().getY()), jAllocator);
455 jCircleParticleEmitterPlaneVelocity.AddMember(
"a1z", Value(emitter->getAxis1().getZ()), jAllocator);
456 jParticleSystem.AddMember(
"cpeev", jCircleParticleEmitterPlaneVelocity, jAllocator);
458 if (v == PrototypeParticleSystem_Emitter::SPHERE_PARTICLE_EMITTER)
460 Value jSphereParticleEmitter;
461 jSphereParticleEmitter.SetObject();
462 auto emitter = particleSystem->getSphereParticleEmitter();
463 jSphereParticleEmitter.AddMember(
"c", Value(emitter->getCount()), jAllocator);
464 jSphereParticleEmitter.AddMember(
"lt", Value(emitter->getLifeTime()), jAllocator);
465 jSphereParticleEmitter.AddMember(
"ltrnd", Value(emitter->getLifeTimeRnd()), jAllocator);
466 jSphereParticleEmitter.AddMember(
"m", Value(emitter->getMass()), jAllocator);
467 jSphereParticleEmitter.AddMember(
"mrnd", Value(emitter->getMassRnd()), jAllocator);
468 jSphereParticleEmitter.AddMember(
"vx", Value(emitter->getVelocity().getX()), jAllocator);
469 jSphereParticleEmitter.AddMember(
"vy", Value(emitter->getVelocity().getY()), jAllocator);
470 jSphereParticleEmitter.AddMember(
"vz", Value(emitter->getVelocity().getZ()), jAllocator);
471 jSphereParticleEmitter.AddMember(
"vrndx", Value(emitter->getVelocityRnd().getX()), jAllocator);
472 jSphereParticleEmitter.AddMember(
"vrndy", Value(emitter->getVelocityRnd().getY()), jAllocator);
473 jSphereParticleEmitter.AddMember(
"vrndz", Value(emitter->getVelocityRnd().getZ()), jAllocator);
474 jSphereParticleEmitter.AddMember(
"csr", Value(emitter->getColorStart().getRed()), jAllocator);
475 jSphereParticleEmitter.AddMember(
"csg", Value(emitter->getColorStart().getGreen()), jAllocator);
476 jSphereParticleEmitter.AddMember(
"csb", Value(emitter->getColorStart().getBlue()), jAllocator);
477 jSphereParticleEmitter.AddMember(
"csa", Value(emitter->getColorStart().getAlpha()), jAllocator);
478 jSphereParticleEmitter.AddMember(
"cer", Value(emitter->getColorEnd().getRed()), jAllocator);
479 jSphereParticleEmitter.AddMember(
"ceg", Value(emitter->getColorEnd().getGreen()), jAllocator);
480 jSphereParticleEmitter.AddMember(
"ceb", Value(emitter->getColorEnd().getBlue()), jAllocator);
481 jSphereParticleEmitter.AddMember(
"cea", Value(emitter->getColorEnd().getAlpha()), jAllocator);
482 jSphereParticleEmitter.AddMember(
"cx", Value(emitter->getCenter().getX()), jAllocator);
483 jSphereParticleEmitter.AddMember(
"cy", Value(emitter->getCenter().getY()), jAllocator);
484 jSphereParticleEmitter.AddMember(
"cz", Value(emitter->getCenter().getZ()), jAllocator);
485 jSphereParticleEmitter.AddMember(
"r", Value(emitter->getRadius()), jAllocator);
486 jParticleSystem.AddMember(
"spe", jSphereParticleEmitter, jAllocator);
491 "PrototypeWriter::export(): unknown particle system emitter '" +
492 particleSystem->getEmitter()->getName() +
498 jParticleSystems.PushBack(jParticleSystem, jAllocator);
500 jPrototypeRoot.AddMember(
"pss", jParticleSystems, jAllocator);
502 Value jBoundingVolumes;
503 jBoundingVolumes.SetArray();
507 if (bv ==
nullptr)
continue;
508 Value jBoundingVolume;
509 jBoundingVolume.SetObject();
511 jBoundingVolume.AddMember(
"type", Value(
"none", jAllocator), jAllocator);
513 if (
dynamic_cast< Sphere*
>(bv) !=
nullptr) {
514 auto sphere =
dynamic_cast< Sphere*
>(bv);
515 jBoundingVolume.AddMember(
"type", Value(
"sphere", jAllocator), jAllocator);
516 jBoundingVolume.AddMember(
"cx", Value(sphere->getCenter().getX()), jAllocator);
517 jBoundingVolume.AddMember(
"cy", Value(sphere->getCenter().getY()), jAllocator);
518 jBoundingVolume.AddMember(
"cz", Value(sphere->getCenter().getZ()), jAllocator);
519 jBoundingVolume.AddMember(
"r", Value(sphere->getRadius()), jAllocator);
521 if (
dynamic_cast< Capsule*
>(bv) !=
nullptr) {
522 auto capsule =
dynamic_cast< Capsule*
>(bv);
523 jBoundingVolume.AddMember(
"type", Value(
"capsule", jAllocator), jAllocator);
524 jBoundingVolume.AddMember(
"ax", Value(capsule->getA().getX()), jAllocator);
525 jBoundingVolume.AddMember(
"ay", Value(capsule->getA().getY()), jAllocator);
526 jBoundingVolume.AddMember(
"az", Value(capsule->getA().getZ()), jAllocator);
527 jBoundingVolume.AddMember(
"bx", Value(capsule->getB().getX()), jAllocator);
528 jBoundingVolume.AddMember(
"by", Value(capsule->getB().getY()), jAllocator);
529 jBoundingVolume.AddMember(
"bz", Value(capsule->getB().getZ()), jAllocator);
530 jBoundingVolume.AddMember(
"r", Value(capsule->getRadius()), jAllocator);
534 jBoundingVolume.AddMember(
"type", Value(
"aabb", jAllocator), jAllocator);
535 jBoundingVolume.AddMember(
"mix", Value(aabb->getMin().getX()), jAllocator);
536 jBoundingVolume.AddMember(
"miy", Value(aabb->getMin().getY()), jAllocator);
537 jBoundingVolume.AddMember(
"miz", Value(aabb->getMin().getZ()), jAllocator);
538 jBoundingVolume.AddMember(
"max", Value(aabb->getMax().getX()), jAllocator);
539 jBoundingVolume.AddMember(
"may", Value(aabb->getMax().getY()), jAllocator);
540 jBoundingVolume.AddMember(
"maz", Value(aabb->getMax().getZ()), jAllocator);
544 jBoundingVolume.AddMember(
"type", Value(
"obb", jAllocator), jAllocator);
545 jBoundingVolume.AddMember(
"cx", Value(obb->getCenter().getX()), jAllocator);
546 jBoundingVolume.AddMember(
"cy", Value(obb->getCenter().getY()), jAllocator);
547 jBoundingVolume.AddMember(
"cz", Value(obb->getCenter().getZ()), jAllocator);
548 jBoundingVolume.AddMember(
"a0x", Value(obb->getAxes()[0].getX()), jAllocator);
549 jBoundingVolume.AddMember(
"a0y", Value(obb->getAxes()[0].getY()), jAllocator);
550 jBoundingVolume.AddMember(
"a0z", Value(obb->getAxes()[0].getZ()), jAllocator);
551 jBoundingVolume.AddMember(
"a1x", Value(obb->getAxes()[1].getX()), jAllocator);
552 jBoundingVolume.AddMember(
"a1y", Value(obb->getAxes()[1].getY()), jAllocator);
553 jBoundingVolume.AddMember(
"a1z", Value(obb->getAxes()[1].getZ()), jAllocator);
554 jBoundingVolume.AddMember(
"a2x", Value(obb->getAxes()[2].getX()), jAllocator);
555 jBoundingVolume.AddMember(
"a2y", Value(obb->getAxes()[2].getY()), jAllocator);
556 jBoundingVolume.AddMember(
"a2z", Value(obb->getAxes()[2].getZ()), jAllocator);
557 jBoundingVolume.AddMember(
"hex", Value(obb->getHalfExtension().getX()), jAllocator);
558 jBoundingVolume.AddMember(
"hey", Value(obb->getHalfExtension().getY()), jAllocator);
559 jBoundingVolume.AddMember(
"hez", Value(obb->getHalfExtension().getZ()), jAllocator);
561 if (
dynamic_cast< ConvexMesh*
>(bv) !=
nullptr) {
562 jBoundingVolume.AddMember(
"type", Value(
"convexmesh", jAllocator), jAllocator);
563 if (prototypeBoundingVolume->getConvexMeshData().empty() ==
false) {
565 Base64::encode(prototypeBoundingVolume->getConvexMeshData(), base64TMData);
566 jBoundingVolume.AddMember(
"data", Value(base64TMData, jAllocator), jAllocator);
568 jBoundingVolume.AddMember(
"file", Value(prototypeBoundingVolume->getConvexMeshFile(), jAllocator), jAllocator);
569 auto convexMeshModel =
571 Tools::getPathName(prototypeBoundingVolume->getConvexMeshFile()),
572 Tools::getFileName(prototypeBoundingVolume->getConvexMeshFile())
576 Tools::getPathName(prototypeBoundingVolume->getConvexMeshFile()),
577 Tools::getFileName(prototypeBoundingVolume->getConvexMeshFile())
581 jBoundingVolume.AddMember(
"g", Value(prototypeBoundingVolume->isGenerated()), jAllocator);
582 jBoundingVolumes.PushBack(jBoundingVolume, jAllocator);
584 jPrototypeRoot.AddMember(
"bvs", jBoundingVolumes, jAllocator);
586 if (physics !=
nullptr) {
588 jPhysics.SetObject();
589 jPhysics.AddMember(
"type", Value(physics->getType()->getName(), jAllocator), jAllocator);
590 jPhysics.AddMember(
"mass", Value(physics->getMass()), jAllocator);
591 jPhysics.AddMember(
"restitution", Value(physics->getRestitution()), jAllocator);
592 jPhysics.AddMember(
"friction", Value(physics->getFriction()), jAllocator);
593 jPhysics.AddMember(
"itx", Value(physics->getInertiaTensor().getX()), jAllocator);
594 jPhysics.AddMember(
"ity", Value(physics->getInertiaTensor().getY()), jAllocator);
595 jPhysics.AddMember(
"itz", Value(physics->getInertiaTensor().getZ()), jAllocator);
596 jPrototypeRoot.AddMember(
"p", jPhysics, jAllocator);
598 Value jPrototypeProperties;
599 jPrototypeProperties.SetArray();
602 Value jObjectProperty;
603 jObjectProperty.SetObject();
604 jObjectProperty.AddMember(
"name", Value(modelProperty->
getName(), jAllocator), jAllocator);
605 jObjectProperty.AddMember(
"value", Value(modelProperty->
getValue(), jAllocator), jAllocator);
606 jPrototypeProperties.PushBack(jObjectProperty, jAllocator);
608 jPrototypeRoot.AddMember(
"properties", jPrototypeProperties, jAllocator);
610 jPrototypeRoot.AddMember(
"rs", Value(prototype->
isReceivesShadows()), jAllocator);
611 jPrototypeRoot.AddMember(
"rg", Value(prototype->
isRenderGroups()), jAllocator);
612 jPrototypeRoot.AddMember(
"s", Value(prototype->
getShader(), jAllocator), jAllocator);
613 jPrototypeRoot.AddMember(
"sds", Value(prototype->
getDistanceShader(), jAllocator), jAllocator);
616 Value jShaderParameters;
617 jShaderParameters.SetObject();
619 auto& shaderParameterName = shaderParameterIt.first;
622 jPrototypeRoot.AddMember(
"sps", jShaderParameters, jAllocator);
625 Value jDistanceShaderParameters;
626 jDistanceShaderParameters.SetObject();
628 auto& shaderParameterName = shaderParameterIt.first;
631 jPrototypeRoot.AddMember(
"spds", jDistanceShaderParameters, jAllocator);
636 for (
auto sound: prototype->
getSounds()) {
637 if (sound->getFileName().length() == 0)
continue;
640 jSound.AddMember(
"i", Value(sound->getId(), jAllocator), jAllocator);
641 jSound.AddMember(
"a", Value(sound->getAnimation(), jAllocator), jAllocator);
642 jSound.AddMember(
"file", Value(sound->getFileName(), jAllocator), jAllocator);
643 jSound.AddMember(
"g", Value(sound->getGain()), jAllocator);
644 jSound.AddMember(
"p", Value(sound->getPitch()), jAllocator);
645 jSound.AddMember(
"o", Value(sound->getOffset()), jAllocator);
646 jSound.AddMember(
"l", Value(sound->isLooping()), jAllocator);
647 jSound.AddMember(
"f", Value(sound->isFixed()), jAllocator);
648 jSounds.PushBack(jSound, jAllocator);
650 jPrototypeRoot.AddMember(
"sd", jSounds, jAllocator);
652 if (prototype->
getType() == Prototype_Type::ENVIRONMENTMAPPING) {
656 if (prototype->
getType() == Prototype_Type::TERRAIN) {
659 jTerrain.SetObject();
661 jTerrain.AddMember(
"w", Value(terrain->getWidth()), jAllocator);
662 jTerrain.AddMember(
"d", Value(terrain->getDepth()), jAllocator);
663 Value jTerrainValues;
664 jTerrainValues.SetArray();
665 for (
auto& v: terrain->getHeightVector()) jTerrainValues.PushBack(Value(v), jAllocator);
666 jTerrain.AddMember(
"t", jTerrainValues, jAllocator);
669 Value jWaterPositionMaps;
670 jWaterPositionMaps.SetArray();
672 for (
auto i: waterPositionMapsIndices) {
673 const auto& waterPositionMap = terrain->getWaterPositionMap(i);
674 Value jWaterPositionMap;
675 jWaterPositionMap.SetObject();
676 jWaterPositionMap.AddMember(
"h", Value(terrain->getWaterPositionMapHeight(i)), jAllocator);
677 Value jWaterPositionMapWater;
678 jWaterPositionMapWater.SetObject();
679 for (
auto& waterPositionMapIt: waterPositionMap) {
680 auto z = waterPositionMapIt.first;
681 Value jWaterPositionMapWaterXArray;
682 jWaterPositionMapWaterXArray.SetArray();
683 for (
auto x: waterPositionMapIt.second) {
684 jWaterPositionMapWaterXArray.PushBack(Value(x), jAllocator);
686 jWaterPositionMapWater.AddMember(Value(to_string(z).c_str(), jAllocator), jWaterPositionMapWaterXArray, jAllocator);
688 jWaterPositionMap.AddMember(
"w", jWaterPositionMapWater, jAllocator);
689 jWaterPositionMaps.PushBack(jWaterPositionMap, jAllocator);
691 jTerrain.AddMember(
"W", jWaterPositionMaps, jAllocator);
695 jFoliage.SetObject();
697 auto foliagePrototypeIndices = terrain->getFoliagePrototypeIndices();
698 for (
auto foliagePrototypeIdx: foliagePrototypeIndices) {
699 auto foliagePrototype = terrain->getFoliagePrototype(foliagePrototypeIdx);
700 if (foliagePrototype ==
nullptr)
continue;
701 Value jFoliagePrototype;
702 jFoliagePrototype.SetObject();
703 jFoliagePrototype.AddMember(
"f", Value(foliagePrototype->getFileName(), jAllocator), jAllocator);
706 Value jFoliagePrototypePartitions;
707 jFoliagePrototypePartitions.SetArray();
710 for (
auto& foliagePrototypeMapPartition: foliageMaps) {
711 auto& foliagePrototypePartitionTransformationsVector = foliagePrototypeMapPartition[foliagePrototypeIdx];
712 Value jFoliagePrototypePartitionTransformations;
713 jFoliagePrototypePartitionTransformations.SetArray();
714 for (
auto& transformations: foliagePrototypePartitionTransformationsVector) {
715 Value jFoliagePrototypeTransformations;
716 jFoliagePrototypeTransformations.SetObject();
717 jFoliagePrototypeTransformations.AddMember(
"tx", Value(transformations.getTranslation().getX()), jAllocator);
718 jFoliagePrototypeTransformations.AddMember(
"ty", Value(transformations.getTranslation().getY()), jAllocator);
719 jFoliagePrototypeTransformations.AddMember(
"tz", Value(transformations.getTranslation().getZ()), jAllocator);
720 jFoliagePrototypeTransformations.AddMember(
"sx", Value(transformations.getScale().getX()), jAllocator);
721 jFoliagePrototypeTransformations.AddMember(
"sy", Value(transformations.getScale().getY()), jAllocator);
722 jFoliagePrototypeTransformations.AddMember(
"sz", Value(transformations.getScale().getZ()), jAllocator);
723 jFoliagePrototypeTransformations.AddMember(
"rz", Value(transformations.getRotationAngle(0)), jAllocator);
724 jFoliagePrototypeTransformations.AddMember(
"ry", Value(transformations.getRotationAngle(1)), jAllocator);
725 jFoliagePrototypeTransformations.AddMember(
"rx", Value(transformations.getRotationAngle(2)), jAllocator);
726 jFoliagePrototypePartitionTransformations.PushBack(jFoliagePrototypeTransformations, jAllocator);
728 jFoliagePrototypePartitions.PushBack(jFoliagePrototypePartitionTransformations, jAllocator);
730 jFoliagePrototype.AddMember(
"t", jFoliagePrototypePartitions, jAllocator);
733 jFoliage.AddMember(Value(to_string(foliagePrototypeIdx).c_str(), jAllocator), jFoliagePrototype, jAllocator);
735 jTerrain.AddMember(
"f", jFoliage, jAllocator);
739 Value jFoliageBrushes;
740 jFoliageBrushes.SetArray();
742 for (
auto brush: terrain->getBrushes()) {
744 jFoliageBrush.SetObject();
746 jFoliageBrush.AddMember(
"f", Value(brush->getFileName(), jAllocator), jAllocator);
747 jFoliageBrush.AddMember(
"s", Value(brush->getSize()), jAllocator);
748 jFoliageBrush.AddMember(
"d", Value(brush->getDensity()), jAllocator);
750 Value jFoliageBrushPrototypes;
751 jFoliageBrushPrototypes.SetArray();
752 for (
auto brushPrototype: brush->getPrototypes()) {
753 Value jFoliageBrushPrototype;
754 jFoliageBrushPrototype.SetObject();
756 jFoliageBrushPrototype.AddMember(
"f", Value(brushPrototype->getFileName(), jAllocator), jAllocator);
758 jFoliageBrushPrototype.AddMember(
"c", Value(brushPrototype->getCount()), jAllocator);
759 jFoliageBrushPrototype.AddMember(
"n", Value(brushPrototype->isNormalAlign()), jAllocator);
760 jFoliageBrushPrototype.AddMember(
"xi", Value(brushPrototype->getRotationXMin()), jAllocator);
761 jFoliageBrushPrototype.AddMember(
"xa", Value(brushPrototype->getRotationXMax()), jAllocator);
762 jFoliageBrushPrototype.AddMember(
"yi", Value(brushPrototype->getRotationYMin()), jAllocator);
763 jFoliageBrushPrototype.AddMember(
"ya", Value(brushPrototype->getRotationYMax()), jAllocator);
764 jFoliageBrushPrototype.AddMember(
"zi", Value(brushPrototype->getRotationZMin()), jAllocator);
765 jFoliageBrushPrototype.AddMember(
"za", Value(brushPrototype->getRotationZMax()), jAllocator);
766 jFoliageBrushPrototype.AddMember(
"si", Value(brushPrototype->getScaleMin()), jAllocator);
767 jFoliageBrushPrototype.AddMember(
"sa", Value(brushPrototype->getScaleMax()), jAllocator);
768 jFoliageBrushPrototype.AddMember(
"hi", Value(brushPrototype->getHeightMin()), jAllocator);
769 jFoliageBrushPrototype.AddMember(
"ha", Value(brushPrototype->getHeightMax()), jAllocator);
770 jFoliageBrushPrototype.AddMember(
"li", Value(brushPrototype->getSlopeMin()), jAllocator);
771 jFoliageBrushPrototype.AddMember(
"la", Value(brushPrototype->getSlopeMax()), jAllocator);
774 jFoliageBrushPrototypes.PushBack(jFoliageBrushPrototype, jAllocator);
776 jFoliageBrush.AddMember(
"p", jFoliageBrushPrototypes, jAllocator);
778 jFoliageBrushes.PushBack(jFoliageBrush, jAllocator);
780 jTerrain.AddMember(
"b", jFoliageBrushes, jAllocator);
782 jPrototypeRoot.AddMember(
"t", jTerrain, jAllocator);
Application base class, please make sure to allocate application on heap to have correct application ...
static const map< string, ShaderParameter > getShaderParameterDefaults(const string &shaderId)
Returns parameter defaults of shader with given id.
TDME2 engine entity shader parameters.
const ShaderParameter getShaderParameter(const string ¶meterName) const
Returns shader parameter for given parameter name, if the value does not exist, the default will be r...
LOD object 3D to be used with engine class.
Shader parameter model class.
const string toString(float value) const
static void write(const string &pathName, const string &fileName, Prototype *prototype)
Writes a prototype to file.
static void writeLODLevelToJSON(Document &jDocument, Value &jLodLevelRoot, PrototypeLODLevel *lodLevel)
Writes LOD level to JSON.
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Bounding volume interface.
Capsule physics primitive.
Convex mesh physics primitive.
Oriented bounding box physics primitive.
Sphere physics primitive.
Triangle entity, this is not directly connectable with physics engine.
BaseProperty * getPropertyByIndex(int idx)
Get property by index.
const string & getDescription()
Base property model class.
const string & getValue()
Prototype audio definition.
Prototype bounding volume definition.
BoundingVolume * getBoundingVolume()
Prototype LOD level definition.
LODObject3D::LODLevelType getType() const
const string & getFileName()
const Color4 & getColorAdd() const
const Color4 & getColorMul() const
float getMinDistance() const
Prototype bounding box particle emitter definition.
Prototype circle particle emitter plane velocity definition.
Prototype circle particle emitter definition.
Prototype particle system emitter type enum.
Prototype point particle system definition.
Prototype object particle system definition.
Prototype point particle emitter definition.
Prototype point particle system definition.
Prototype sphere particle emitter definition.
Prototype particle system type enum.
Prototype particle system definition.
PrototypeParticleSystem_Type * getType()
Prototype physics body type enum.
Prototype physics body definitions.
Prototype terrain brush prototype definition.
Prototype terrain brush prototype definition.
Prototype terrain definition.
vector< int > getWaterPositionMapsIndices()
Get water position maps indices.
vector< unordered_map< int, vector< Transformations > > > & getFoliageMaps()
int getParticleSystemsCount()
PrototypeLODLevel * getLODLevel2()
void setFileName(const string &fileName)
Set up prototype file name including relative path.
const vector< PrototypeAudio * > & getSounds()
PrototypeImposterLOD * getImposterLOD()
const string & getShader()
Get shader.
PrototypeLODLevel * getLODLevel3()
float getDistanceShaderDistance()
Get distance shader distance.
bool isRenderGroups()
Is using render groups.
bool isContributesShadows()
bool isTerrainMesh()
Is terrain mesh.
const string & getDistanceShader()
Get distance shader.
PrototypePhysics * getPhysics()
PrototypeParticleSystem * getParticleSystemAt(int idx)
Get particle system at given index.
const EntityShaderParameters & getDistanceShaderParameters()
Get distance shader parameters.
int getBoundingVolumeCount()
int64_t getEnvironmentMapTimeRenderUpdateFrequency()
PrototypeBoundingVolume * getBoundingVolume(int idx)
Get bounding volume at given index.
PrototypeTerrain * getTerrain()
const EntityShaderParameters & getShaderParameters()
Get shader parameters.
const string & getModelFileName()
int getEnvironmentMapRenderPassMask()
Prototype_Type * getType()
File system singleton class.
Base64 encoding/decoding class.
const string & getName() const
std::exception Exception
Exception base class.