TDME2 1.9.121
PrototypeWriter.cpp
Go to the documentation of this file.
2
3#include <iomanip>
4#include <iostream>
5#include <sstream>
6#include <string>
7
8#include <tdme/tdme.h>
42#include <tdme/engine/Engine.h>
46#include <tdme/math/Vector3.h>
54
55#include <ext/rapidjson/document.h>
56#include <ext/rapidjson/stringbuffer.h>
57#include <ext/rapidjson/writer.h>
58
59using std::ostringstream;
60using std::string;
61
63
108
109using rapidjson::Document;
110using rapidjson::StringBuffer;
111using rapidjson::Value;
112using rapidjson::Writer;
113
114void PrototypeWriter::copyFile(const string& source, const string& dest)
115{
116}
117
118void PrototypeWriter::write(const string& pathName, const string& fileName, Prototype* prototype)
119{
120 prototype->setFileName((pathName.empty() == false?pathName + "/":"") + fileName);
121
122 Document jRoot;
123 jRoot.SetObject();
124 write(jRoot, jRoot, prototype);
125
126 StringBuffer strbuf;
127 Writer<StringBuffer> writer(strbuf);
128 jRoot.Accept(writer);
129
130 FileSystem::getInstance()->setContentFromString(pathName, fileName, strbuf.GetString());
131}
132
133void PrototypeWriter::writeLODLevelToJSON(Document& jDocument, Value& jLodLevelRoot, PrototypeLODLevel* lodLevel) {
134 auto& jAllocator = jDocument.GetAllocator();
135 jLodLevelRoot.SetObject();
136 jLodLevelRoot.AddMember("t", Value(lodLevel->getType()), jAllocator);
137 if (lodLevel->getType() == LODObject3D::LODLEVELTYPE_MODEL) {
138 //
139 auto modelPathName = Tools::getPathName(lodLevel->getFileName());
140 auto modelFileName = Tools::removeFileEnding(Tools::getFileName(lodLevel->getFileName())) + ".tm";
141 TMWriter::write(
142 lodLevel->getModel(),
143 modelPathName,
144 modelFileName
145 );
146 jLodLevelRoot.AddMember("f", Value(modelPathName + "/" + modelFileName, jAllocator), jAllocator);
147 }
148 jLodLevelRoot.AddMember("d", Value(lodLevel->getMinDistance()), jAllocator);
149 jLodLevelRoot.AddMember("cmr", Value(lodLevel->getColorMul().getRed()), jAllocator);
150 jLodLevelRoot.AddMember("cmg", Value(lodLevel->getColorMul().getGreen()), jAllocator);
151 jLodLevelRoot.AddMember("cmb", Value(lodLevel->getColorMul().getBlue()), jAllocator);
152 jLodLevelRoot.AddMember("cma", Value(lodLevel->getColorMul().getAlpha()), jAllocator);
153 jLodLevelRoot.AddMember("car", Value(lodLevel->getColorAdd().getRed()), jAllocator);
154 jLodLevelRoot.AddMember("cag", Value(lodLevel->getColorAdd().getGreen()), jAllocator);
155 jLodLevelRoot.AddMember("cab", Value(lodLevel->getColorAdd().getBlue()), jAllocator);
156 jLodLevelRoot.AddMember("caa", Value(lodLevel->getColorAdd().getAlpha()), jAllocator);
157}
158
159void PrototypeWriter::write(Document& jDocument, Value& jPrototypeRoot, Prototype* prototype)
160{
161 auto& jAllocator = jDocument.GetAllocator();
162 if (prototype->getType() == Prototype_Type::MODEL && prototype->getModelFileName().length() > 0) {
163 auto modelPathName = Tools::getPathName(prototype->getModelFileName());
164 auto modelFileName = Tools::removeFileEnding(Tools::getFileName(prototype->getModelFileName())) + ".tm";
165 TMWriter::write(
166 prototype->getModel(),
167 modelPathName,
168 modelFileName
169 );
170
171 // we can only use the offscreen engine currently if having a GL/Vulkan window and context
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);
178 }
179
180 jPrototypeRoot.AddMember("file", Value(modelPathName + "/" + modelFileName, jAllocator), jAllocator);
181 jPrototypeRoot.AddMember("tm", Value(prototype->isTerrainMesh()), jAllocator);
182 int lodLevelIdx = 2;
183 {
184 auto lodLevel = prototype->getLODLevel2();
185 if (lodLevel != nullptr &&
186 (lodLevel->getType() == LODObject3D::LODLEVELTYPE_IGNORE ||
187 ((lodLevel->getType() == LODObject3D::LODLEVELTYPE_MODEL) &&
188 lodLevel->getModel() != nullptr))) {
189 //
190 Value jLodLevel;
191 jLodLevel.SetObject();
192 writeLODLevelToJSON(jDocument, jLodLevel, lodLevel);
193 jPrototypeRoot.AddMember(Value("ll" + to_string(lodLevelIdx), jAllocator), jLodLevel, jAllocator);
194 lodLevelIdx++;
195 }
196 }
197 {
198 auto lodLevel = prototype->getLODLevel3();
199 if (lodLevel != nullptr &&
200 (lodLevel->getType() == LODObject3D::LODLEVELTYPE_IGNORE ||
201 ((lodLevel->getType() == LODObject3D::LODLEVELTYPE_MODEL) &&
202 lodLevel->getModel() != nullptr))) {
203 //
204 //
205 Value jLodLevel;
206 jLodLevel.SetObject();
207 writeLODLevelToJSON(jDocument, jLodLevel, lodLevel);
208 jPrototypeRoot.AddMember(Value("ll" + to_string(lodLevelIdx), jAllocator), jLodLevel, jAllocator);
209 lodLevelIdx++;
210 }
211 }
212 {
213 auto imposterLOD = prototype->getImposterLOD();
214 if (imposterLOD != nullptr) {
215 Value jImposterLOD;
216 Value jImposterLODFiles;
217 jImposterLODFiles.SetArray();
218 for (auto& fileName: imposterLOD->getFileNames()) {
219 jImposterLODFiles.PushBack(Value(fileName, jAllocator), jAllocator);
220 }
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);
233 }
234 }
235 }
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();
246 for (auto i = 0; i < prototype->getParticleSystemsCount(); i++) {
247 auto particleSystem = prototype->getParticleSystemAt(i);
248 Value jParticleSystem;
249 jParticleSystem.SetObject();
250 jParticleSystem.AddMember("t", Value(particleSystem->getType()->getName(), jAllocator), jAllocator);
251 {
252 auto v = particleSystem->getType();
253 if (v == PrototypeParticleSystem_Type::NONE) {
254 // no op
255 } else
256 if (v == PrototypeParticleSystem_Type::OBJECT_PARTICLE_SYSTEM)
257 {
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";
263 TMWriter::write(
264 particleSystem->getObjectParticleSystem()->getModel(),
265 modelPathName,
266 modelFileName
267 );
268 particleSystem->getObjectParticleSystem()->setModelFile(modelPathName + "/" + modelFileName);
269 }
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);
277 } else
278 if (v == PrototypeParticleSystem_Type::POINT_PARTICLE_SYSTEM)
279 {
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);
291 } else
292 if (v == PrototypeParticleSystem_Type::FOG_PARTICLE_SYSTEM)
293 {
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);
304 } else {
305 Console::println(
306 string(
307 "PrototypeWriter::export(): unknown particle system type '" +
308 particleSystem->getType()->getName() +
309 "'"
310 )
311 );
312 }
313 }
314
315 jParticleSystem.AddMember("e", Value(particleSystem->getEmitter()->getName(), jAllocator), jAllocator);
316 {
317 auto v = particleSystem->getEmitter();
318 if (v == PrototypeParticleSystem_Emitter::NONE)
319 {
320 } else
321 if (v == PrototypeParticleSystem_Emitter::POINT_PARTICLE_EMITTER)
322 {
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);
349 } else
350 if (v == PrototypeParticleSystem_Emitter::BOUNDINGBOX_PARTICLE_EMITTER)
351 {
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);
390 } else
391 if (v == PrototypeParticleSystem_Emitter::CIRCLE_PARTICLE_EMITTER)
392 {
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);
426 } else
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);
457 } else
458 if (v == PrototypeParticleSystem_Emitter::SPHERE_PARTICLE_EMITTER)
459 {
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);
487 } else
488 {
489 Console::println(
490 string(
491 "PrototypeWriter::export(): unknown particle system emitter '" +
492 particleSystem->getEmitter()->getName() +
493 "'"
494 )
495 );
496 }
497 }
498 jParticleSystems.PushBack(jParticleSystem, jAllocator);
499 }
500 jPrototypeRoot.AddMember("pss", jParticleSystems, jAllocator);
501 }
502 Value jBoundingVolumes;
503 jBoundingVolumes.SetArray();
504 for (auto i = 0; i < prototype->getBoundingVolumeCount(); i++) {
505 auto prototypeBoundingVolume = prototype->getBoundingVolume(i);
506 auto bv = prototypeBoundingVolume->getBoundingVolume();
507 if (bv == nullptr) continue;
508 Value jBoundingVolume;
509 jBoundingVolume.SetObject();
510 if (bv == nullptr) {
511 jBoundingVolume.AddMember("type", Value("none", jAllocator), jAllocator);
512 } else
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);
520 } else
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);
531 } else
532 if (dynamic_cast< BoundingBox* >(bv) != nullptr) {
533 auto aabb = dynamic_cast< BoundingBox* >(bv);
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);
541 } else
542 if (dynamic_cast< OrientedBoundingBox* >(bv) != nullptr) {
543 auto obb = dynamic_cast< OrientedBoundingBox* >(bv);
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);
560 } else
561 if (dynamic_cast< ConvexMesh* >(bv) != nullptr) {
562 jBoundingVolume.AddMember("type", Value("convexmesh", jAllocator), jAllocator);
563 if (prototypeBoundingVolume->getConvexMeshData().empty() == false) {
564 string base64TMData;
565 Base64::encode(prototypeBoundingVolume->getConvexMeshData(), base64TMData);
566 jBoundingVolume.AddMember("data", Value(base64TMData, jAllocator), jAllocator);
567 } else {
568 jBoundingVolume.AddMember("file", Value(prototypeBoundingVolume->getConvexMeshFile(), jAllocator), jAllocator);
569 auto convexMeshModel =
570 TMReader::read(
571 Tools::getPathName(prototypeBoundingVolume->getConvexMeshFile()),
572 Tools::getFileName(prototypeBoundingVolume->getConvexMeshFile())
573 );
574 TMWriter::write(
575 convexMeshModel,
576 Tools::getPathName(prototypeBoundingVolume->getConvexMeshFile()),
577 Tools::getFileName(prototypeBoundingVolume->getConvexMeshFile())
578 );
579 }
580 }
581 jBoundingVolume.AddMember("g", Value(prototypeBoundingVolume->isGenerated()), jAllocator);
582 jBoundingVolumes.PushBack(jBoundingVolume, jAllocator);
583 }
584 jPrototypeRoot.AddMember("bvs", jBoundingVolumes, jAllocator);
585 auto physics = prototype->getPhysics();
586 if (physics != nullptr) {
587 Value jPhysics;
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);
597 }
598 Value jPrototypeProperties;
599 jPrototypeProperties.SetArray();
600 for (auto i = 0; i < prototype->getPropertyCount(); i++) {
601 BaseProperty* modelProperty = prototype->getPropertyByIndex(i);
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);
607 }
608 jPrototypeRoot.AddMember("properties", jPrototypeProperties, jAllocator);
609 jPrototypeRoot.AddMember("cs", Value(prototype->isContributesShadows()), 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);
614 jPrototypeRoot.AddMember("sdsd", Value(prototype->getDistanceShaderDistance()), jAllocator);
615 {
616 Value jShaderParameters;
617 jShaderParameters.SetObject();
618 for (auto& shaderParameterIt: Engine::getShaderParameterDefaults(prototype->getShader())) {
619 auto& shaderParameterName = shaderParameterIt.first;
620 jShaderParameters.AddMember(Value(shaderParameterName, jAllocator), Value(prototype->getShaderParameters().getShaderParameter(shaderParameterName).toString(), jAllocator), jAllocator);
621 }
622 jPrototypeRoot.AddMember("sps", jShaderParameters, jAllocator);
623 }
624 {
625 Value jDistanceShaderParameters;
626 jDistanceShaderParameters.SetObject();
627 for (auto& shaderParameterIt: Engine::getShaderParameterDefaults(prototype->getDistanceShader())) {
628 auto& shaderParameterName = shaderParameterIt.first;
629 jDistanceShaderParameters.AddMember(Value(shaderParameterName, jAllocator), Value(prototype->getDistanceShaderParameters().getShaderParameter(shaderParameterName).toString(), jAllocator), jAllocator);
630 }
631 jPrototypeRoot.AddMember("spds", jDistanceShaderParameters, jAllocator);
632 }
633 if (prototype->getSounds().size() > 0) {
634 Value jSounds;
635 jSounds.SetArray();
636 for (auto sound: prototype->getSounds()) {
637 if (sound->getFileName().length() == 0) continue;
638 Value jSound;
639 jSound.SetObject();
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);
649 }
650 jPrototypeRoot.AddMember("sd", jSounds, jAllocator);
651 }
652 if (prototype->getType() == Prototype_Type::ENVIRONMENTMAPPING) {
653 jPrototypeRoot.AddMember("emrpm", Value(prototype->getEnvironmentMapRenderPassMask()), jAllocator);
654 jPrototypeRoot.AddMember("emtf", Value(prototype->getEnvironmentMapTimeRenderUpdateFrequency()), jAllocator);
655 }
656 if (prototype->getType() == Prototype_Type::TERRAIN) {
657 auto terrain = prototype->getTerrain();
658 Value jTerrain;
659 jTerrain.SetObject();
660 {
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);
667 }
668 {
669 Value jWaterPositionMaps;
670 jWaterPositionMaps.SetArray();
671 auto waterPositionMapsIndices = terrain->getWaterPositionMapsIndices();
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);
685 }
686 jWaterPositionMapWater.AddMember(Value(to_string(z).c_str(), jAllocator), jWaterPositionMapWaterXArray, jAllocator);
687 }
688 jWaterPositionMap.AddMember("w", jWaterPositionMapWater, jAllocator);
689 jWaterPositionMaps.PushBack(jWaterPositionMap, jAllocator);
690 }
691 jTerrain.AddMember("W", jWaterPositionMaps, jAllocator);
692 }
693 {
694 Value jFoliage;
695 jFoliage.SetObject();
696 auto& foliageMaps = prototype->getTerrain()->getFoliageMaps();
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);
704
705 //
706 Value jFoliagePrototypePartitions;
707 jFoliagePrototypePartitions.SetArray();
708
709 //
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);
727 }
728 jFoliagePrototypePartitions.PushBack(jFoliagePrototypePartitionTransformations, jAllocator);
729 }
730 jFoliagePrototype.AddMember("t", jFoliagePrototypePartitions, jAllocator);
731
732 //
733 jFoliage.AddMember(Value(to_string(foliagePrototypeIdx).c_str(), jAllocator), jFoliagePrototype, jAllocator);
734 }
735 jTerrain.AddMember("f", jFoliage, jAllocator);
736 }
737 {
738 //
739 Value jFoliageBrushes;
740 jFoliageBrushes.SetArray();
741 //
742 for (auto brush: terrain->getBrushes()) {
743 Value jFoliageBrush;
744 jFoliageBrush.SetObject();
745
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);
749
750 Value jFoliageBrushPrototypes;
751 jFoliageBrushPrototypes.SetArray();
752 for (auto brushPrototype: brush->getPrototypes()) {
753 Value jFoliageBrushPrototype;
754 jFoliageBrushPrototype.SetObject();
755
756 jFoliageBrushPrototype.AddMember("f", Value(brushPrototype->getFileName(), jAllocator), jAllocator);
757
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);
772
773
774 jFoliageBrushPrototypes.PushBack(jFoliageBrushPrototype, jAllocator);
775 }
776 jFoliageBrush.AddMember("p", jFoliageBrushPrototypes, jAllocator);
777
778 jFoliageBrushes.PushBack(jFoliageBrush, jAllocator);
779 }
780 jTerrain.AddMember("b", jFoliageBrushes, jAllocator);
781 }
782 jPrototypeRoot.AddMember("t", jTerrain, jAllocator);
783 }
784}
Application base class, please make sure to allocate application on heap to have correct application ...
Definition: Application.h:37
Engine main class.
Definition: Engine.h:122
static const map< string, ShaderParameter > getShaderParameterDefaults(const string &shaderId)
Returns parameter defaults of shader with given id.
Definition: Engine.cpp:2134
TDME2 engine entity shader parameters.
const ShaderParameter getShaderParameter(const string &parameterName) 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.
Definition: LODObject3D.h:47
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.
Color 4 definition.
Definition: Color4.h:20
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:25
Capsule physics primitive.
Definition: Capsule.h:18
Convex mesh physics primitive.
Definition: ConvexMesh.h:33
Oriented bounding box physics primitive.
Sphere physics primitive.
Definition: Sphere.h:18
Triangle entity, this is not directly connectable with physics engine.
Definition: Triangle.h:19
BaseProperty * getPropertyByIndex(int idx)
Get property by index.
Base property model class.
Definition: BaseProperty.h:16
Prototype audio definition.
Prototype LOD level definition.
LODObject3D::LODLevelType getType() const
Prototype physics body definitions.
Prototype terrain brush prototype definition.
vector< int > getWaterPositionMapsIndices()
Get water position maps indices.
vector< unordered_map< int, vector< Transformations > > > & getFoliageMaps()
Prototype definition.
Definition: Prototype.h:49
PrototypeLODLevel * getLODLevel2()
Definition: Prototype.h:251
void setFileName(const string &fileName)
Set up prototype file name including relative path.
Definition: Prototype.h:155
const vector< PrototypeAudio * > & getSounds()
Definition: Prototype.h:479
PrototypeImposterLOD * getImposterLOD()
Definition: Prototype.h:283
const string & getShader()
Get shader.
Definition: Prototype.h:398
PrototypeLODLevel * getLODLevel3()
Definition: Prototype.h:264
float getDistanceShaderDistance()
Get distance shader distance.
Definition: Prototype.h:432
bool isRenderGroups()
Is using render groups.
Definition: Prototype.h:382
bool isTerrainMesh()
Is terrain mesh.
Definition: Prototype.h:366
const string & getDistanceShader()
Get distance shader.
Definition: Prototype.h:415
PrototypePhysics * getPhysics()
Definition: Prototype.h:244
PrototypeParticleSystem * getParticleSystemAt(int idx)
Get particle system at given index.
Definition: Prototype.h:327
const EntityShaderParameters & getDistanceShaderParameters()
Get distance shader parameters.
Definition: Prototype.h:464
int64_t getEnvironmentMapTimeRenderUpdateFrequency()
Definition: Prototype.h:546
PrototypeBoundingVolume * getBoundingVolume(int idx)
Get bounding volume at given index.
Definition: Prototype.h:223
PrototypeTerrain * getTerrain()
Definition: Prototype.h:561
const EntityShaderParameters & getShaderParameters()
Get shader parameters.
Definition: Prototype.h:448
const string & getModelFileName()
Definition: Prototype.h:162
3D vector 3 class
Definition: Vector3.h:22
float getY() const
Definition: Vector3.h:119
float getX() const
Definition: Vector3.h:103
float getZ() const
Definition: Vector3.h:136
File system singleton class.
Definition: FileSystem.h:14
Base64 encoding/decoding class.
Definition: Base64.h:16
Console class.
Definition: Console.h:26
const string & getName() const
Definition: Enum.h:30
String tools class.
Definition: StringTools.h:20
std::exception Exception
Exception base class.
Definition: Exception.h:19