Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
#include "Headers/XMLParser.h"

#include "Core/Headers/Application.h"
#include "Core/Headers/ParamHandler.h"
#include "Rendering/Headers/Renderer.h"
#include "Managers/Headers/SceneManager.h"
#include "Hardware/Video/Headers/GFXDevice.h"
#include "Geometry/Material/Headers/Material.h"
#include "Environment/Terrain/Headers/Terrain.h"
#include "Environment/Terrain/Headers/TerrainDescriptor.h"

namespace Divide {
namespace XML {
    using boost::property_tree::ptree;
    ptree pt;

    namespace {
        const char* getFilterName(TextureFilter filter)	{
            if (filter == TEXTURE_FILTER_LINEAR) {
                return "TEXTURE_FILTER_LINEAR";
            } else if (filter == TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST) {
                return "TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST";
            } else if (filter == TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST) {
                return "TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST";
            } else if (filter == TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR) {
                return "TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR";
            } else if (filter == TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR) {
                return "TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR";
            }

            return "TEXTURE_FILTER_NEAREST";
        }

        TextureFilter getFilter(const char* filter)	{
            if (strcmp(filter, "TEXTURE_FILTER_LINEAR") == 0 ) {
                return TEXTURE_FILTER_LINEAR;
            } else if (strcmp(filter, "TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST") == 0 ) {
                return TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST;
            } else if (strcmp(filter, "TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST") == 0 ) {
                return TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST;
            } else if (strcmp(filter, "TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR") == 0 ) {
                return TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR;
            } else if (strcmp(filter, "TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR") == 0 ) {
                return TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR;
            }

            return TEXTURE_FILTER_NEAREST;
        }

        const char* getWrapModeName(TextureWrap wrapMode) {
            if (wrapMode == TEXTURE_CLAMP) {
                return "TEXTURE_CLAMP";
            } else if (wrapMode == TEXTURE_CLAMP_TO_EDGE) {
                return "TEXTURE_CLAMP_TO_EDGE";
            } else if (wrapMode == TEXTURE_CLAMP_TO_BORDER) {
                return "TEXTURE_CLAMP_TO_BORDER";
            } else if (wrapMode == TEXTURE_DECAL) {
                return "TEXTURE_DECAL";
            }

            return "TEXTURE_REPEAT";
        }

        TextureWrap getWrapMode(const char* wrapMode) {
            if (strcmp(wrapMode, "TEXTURE_CLAMP") == 0) {
                return TEXTURE_CLAMP;
            } else if (strcmp(wrapMode, "TEXTURE_CLAMP_TO_EDGE")  == 0 ) {
                return TEXTURE_CLAMP_TO_EDGE;
            } else if (strcmp(wrapMode, "TEXTURE_CLAMP_TO_BORDER") == 0 ) {
                return TEXTURE_CLAMP_TO_BORDER;
            } else if (strcmp(wrapMode, "TEXTURE_DECAL") == 0 ) {
                return TEXTURE_DECAL;
            }

            return TEXTURE_REPEAT;
        }

        const char* getBumpMethodName(Material::BumpMethod bumpMethod)	{
            if (bumpMethod == Material::BUMP_NORMAL) {
                return "BUMP_NORMAL";
            } else if (bumpMethod == Material::BUMP_PARALLAX) {
                return "BUMP_PARALLAX";
            } else if (bumpMethod == Material::BUMP_RELIEF) {
                return "BUMP_RELIEF";
            }

            return "BUMP_NONE";
        }

        Material::BumpMethod getBumpMethod(const char* bumpMethod) {
            if (strcmp(bumpMethod, "BUMP_NORMAL") == 0 ) {
                return Material::BUMP_NORMAL;
            } else if (strcmp(bumpMethod, "BUMP_PARALLAX") == 0 ) {
                return Material::BUMP_PARALLAX;
            } else if (strcmp(bumpMethod, "BUMP_RELIEF") == 0 ) {
                return Material::BUMP_RELIEF;
            }

            return Material::BUMP_NONE;
        }

        const char* getTextureOperationName(Material::TextureOperation textureOp) {
            if (textureOp == Material::TextureOperation_Multiply) {
                return "TEX_OP_MULTIPLY";
            } else if (textureOp == Material::TextureOperation_Decal) {
                return "TEX_OP_DECAL";
            } else if (textureOp == Material::TextureOperation_Add) {
                return "TEX_OP_ADD";
            } else if (textureOp == Material::TextureOperation_SmoothAdd) {
                return "TEX_OP_SMOOTH_ADD";
            } else if (textureOp == Material::TextureOperation_SignedAdd) {
                return "TEX_OP_SIGNED_ADD";
            } else if (textureOp == Material::TextureOperation_Divide) {
                return "TEX_OP_DIVIDE";
            } else if (textureOp == Material::TextureOperation_Subtract) {
                return "TEX_OP_SUBTRACT";
            }

            return "TEX_OP_REPLACE";
        }

        Material::TextureOperation getTextureOperation(const char* operation) {
            if (strcmp(operation, "TEX_OP_MULTIPLY") == 0 ) {
                return Material::TextureOperation_Multiply;
            } else if (strcmp(operation, "TEX_OP_DECAL") == 0 ) {
                return Material::TextureOperation_Decal;
            } else if (strcmp(operation, "TEX_OP_ADD") == 0 ) {
                return Material::TextureOperation_Add;
            } else if (strcmp(operation, "TEX_OP_SMOOTH_ADD") == 0 ) {
                return Material::TextureOperation_SmoothAdd;
            } else if (strcmp(operation, "TEX_OP_SIGNED_ADD") == 0 ) {
                return Material::TextureOperation_SignedAdd;
            } else if (strcmp(operation, "TEX_OP_DIVIDE") == 0 ) {
                return Material::TextureOperation_Divide;
            } else if (strcmp(operation, "TEX_OP_SUBTRACT") == 0 ) {
                return Material::TextureOperation_Subtract;
            }

            return Material::TextureOperation_Replace;
        }

        void saveTextureXML(const std::string& textureNode, Texture* texture, ptree& tree, const std::string& operation = "") {
            const SamplerDescriptor& sampler = texture->getCurrentSampler();
            while(texture->getState() != RES_LOADED) {
                //texture not fully loaded yet
            }

            std::string fileLocation = texture->getResourceLocation();
            DIVIDE_ASSERT(!fileLocation.empty(), "INVALID TEXTURE SAVE FILE -------------------------------------");
            tree.put(textureNode+".file",fileLocation);
            tree.put(textureNode+".flip",texture->isVerticallyFlipped());
            tree.put(textureNode+".MapU", getWrapModeName(sampler.wrapU()));
            tree.put(textureNode+".MapV", getWrapModeName(sampler.wrapV()));
            tree.put(textureNode+".MapW", getWrapModeName(sampler.wrapW()));
            tree.put(textureNode+".minFilter",getFilterName(sampler.minFilter()));
            tree.put(textureNode+".magFilter",getFilterName(sampler.magFilter()));
            tree.put(textureNode+".anisotropy",(U32)sampler.anisotropyLevel());

            if (!operation.empty()) {
                tree.put(textureNode+".operation", operation);
            }
        }

        Texture* loadTextureXML(const std::string& textureNode, const std::string& textureName) {
            std::string img_name = textureName.substr( textureName.find_last_of( '/' ) + 1 );
            std::string pathName = textureName.substr( 0, textureName.rfind("/")+1 );

            TextureWrap wrapU = getWrapMode(pt.get<std::string>(textureNode+".MapU","TEXTURE_REPEAT").c_str());
            TextureWrap wrapV = getWrapMode(pt.get<std::string>(textureNode+".MapV","TEXTURE_REPEAT").c_str());
            TextureWrap wrapW = getWrapMode(pt.get<std::string>(textureNode+".MapW","TEXTURE_REPEAT").c_str());
            TextureFilter minFilterValue = getFilter(pt.get<std::string>(textureNode+".minFilter","TEXTURE_FILTER_LINEAR").c_str());
            TextureFilter magFilterValue = getFilter(pt.get<std::string>(textureNode+".magFilter","TEXTURE_FILTER_LINEAR").c_str());
            U32 anisotropy = pt.get(textureNode+".anisotropy", 0);

            SamplerDescriptor sampDesc;
            sampDesc.setWrapMode(wrapU,wrapV,wrapW);
            sampDesc.setFilters(minFilterValue,magFilterValue);
            sampDesc.setAnisotropy(anisotropy);

            ResourceDescriptor texture(img_name);
            texture.setResourceLocation(pathName + img_name);
            texture.setFlag(pt.get(textureNode+".flip",true));
            texture.setPropertyDescriptor<SamplerDescriptor>(sampDesc);

            return CreateResource<Texture>(texture);
        }

        inline std::string getRendererTypeName(RendererType type) {
            switch(type) {
                default:
                case RendererType_PLACEHOLDER   : return "Unknown_Renderer_Type";
                case RENDERER_FORWARD_PLUS      : return "Forward_Renderer";
                case RENDERER_DEFERRED_SHADING  : return "Deferred_Shading Renderer";
            }
        }
    }

    std::string loadScripts(const std::string& file) {
        ParamHandler &par = ParamHandler::getInstance();
        PRINT_FN(Locale::get("XML_LOAD_SCRIPTS"));
        read_xml(file,pt);
        std::string activeScene("MainScene");
        par.setParam("scriptLocation",pt.get("scriptLocation","XML"));
        par.setParam("assetsLocation",pt.get("assets","assets"));
        par.setParam("scenesLocation",pt.get("scenesLocation","Scenes"));
        par.setParam("serverAddress",pt.get("server","127.0.0.1"));
        loadConfig(par.getParam<std::string>("scriptLocation") + "/" + pt.get("config","config.xml"));
        read_xml(par.getParam<std::string>("scriptLocation") + "/" + pt.get("startupScene","scenes.xml"),pt);
        activeScene = pt.get("StartupScene",activeScene);

        return activeScene;
    }

    void loadConfig(const std::string& file) {
        ParamHandler &par = ParamHandler::getInstance();
        pt.clear();
        PRINT_FN(Locale::get("XML_LOAD_CONFIG"), file.c_str());
        read_xml(file,pt);
        par.setParam("locale",pt.get("language","enGB"));
        par.setParam("logFile",pt.get("debug.logFile","none"));
        par.setParam("memFile",pt.get("debug.memFile","none"));
        par.setParam("simSpeed",pt.get("runtime.simSpeed",1.0f));
        par.setParam("appTitle",pt.get("title","DIVIDE Framework"));
        par.setParam("defaultTextureLocation",pt.get("defaultTextureLocation","textures/"));
        par.setParam("shaderLocation",pt.get("defaultShadersLocation","shaders/"));

        I32 shadowDetailLevel = pt.get<I32>("rendering.shadowDetailLevel", 2);
        if (shadowDetailLevel <= 0) {
            GFX_DEVICE.shadowDetailLevel(DETAIL_LOW);
            par.setParam("rendering.enableShadows", false);
        } else {
            GFX_DEVICE.shadowDetailLevel(static_cast<RenderDetailLevel>(std::min(shadowDetailLevel, 3) - 1));
            par.setParam("rendering.enableShadows", true);
        }

        GFX_DEVICE.postProcessingEnabled(pt.get("rendering.enablePostFX", false));
        GFX_DEVICE.anaglyphEnabled(pt.get("rendering.enable3D",false));
        par.setParam("rendering.MSAAsampless",std::max(pt.get<I32>("rendering.MSAAsamples", 0), 0));
        par.setParam("rendering.FXAAsamples", std::max(pt.get<I32>("rendering.FXAAsamples", 0), 0));
        par.setParam("GUI.CEGUI.ExtraStates",pt.get("GUI.CEGUI.ExtraStates",false));
        par.setParam("GUI.CEGUI.SkipRendering",pt.get("GUI.CEGUI.SkipRendering",false));
        par.setParam("GUI.defaultScheme",pt.get("GUI.defaultGUIScheme","GWEN"));
        par.setParam("GUI.consoleLayout",pt.get("GUI.consoleLayoutFile","console.layout"));
        par.setParam("GUI.editorLayout",pt.get("GUI.editorLayoutFile","editor.layout"));
        par.setParam("rendering.anisotropicFilteringLevel", std::max(pt.get<GLint>("rendering.anisotropicFilteringLevel", 1), 1));
        par.setParam("rendering.shadowDetailLevel",shadowDetailLevel);
        par.setParam("rendering.enableFog", pt.get("rendering.enableFog",true));
        vec2<U16> resolution(pt.get("runtime.resolutionWidth",1024), pt.get("runtime.resolutionHeight",768));
        par.setParam("runtime.windowedMode",pt.get("rendering.windowedMode",true));
        par.setParam("runtime.allowWindowResize",pt.get("runtime.allowWindowResize",false));
        par.setParam("runtime.enableVSync",pt.get("runtime.enableVSync",false));
        par.setParam("runtime.groundPos", pt.get("runtime.groundPos",-2000.0f)); ///<Safety net for physics actors
        par.setParam("postProcessing.anaglyphOffset",pt.get("rendering.anaglyphOffset",0.16f));
        par.setParam("postProcessing.enableNoise",pt.get("rendering.enableNoise",false));
        par.setParam("postProcessing.enableDepthOfField",pt.get("rendering.enableDepthOfField",false));
        par.setParam("postProcessing.enableBloom",pt.get("rendering.enableBloom",false));
        par.setParam("postProcessing.enableSSAO",pt.get("rendering.enableSSAO",false));
        par.setParam("postProcessing.bloomFactor",pt.get("rendering.bloomFactor",0.4f));
        par.setParam("mesh.playAnimations",pt.get("mesh.playAnimations",true));
        par.setParam("rendering.verticalFOV", pt.get("runtime.verticalFOV", 60.0f));
        par.setParam("rendering.zNear", pt.get("runtime.zNear", 0.1f));
        par.setParam("rendering.zFar", pt.get("runtime.zFar", 700.0f));
        Application::getInstance().setResolution(resolution.width, resolution.height);

        //global fog values
        par.setParam("rendering.sceneState.fogDensity", pt.get("rendering.fogDensity",0.01f));
        par.setParam("rendering.sceneState.fogColor.r", pt.get<F32>("rendering.fogColor.<xmlattr>.r", 0.2f));
        par.setParam("rendering.sceneState.fogColor.g", pt.get<F32>("rendering.fogColor.<xmlattr>.g", 0.2f));
        par.setParam("rendering.sceneState.fogColor.b",	pt.get<F32>("rendering.fogColor.<xmlattr>.b", 0.2f));
    }

    void loadScene(const std::string& sceneName, SceneManager& sceneMgr) {
        ParamHandler &par = ParamHandler::getInstance();
        pt.clear();
        PRINT_FN(Locale::get("XML_LOAD_SCENE"), sceneName.c_str());
        std::string sceneLocation = par.getParam<std::string>("scriptLocation") + "/" +
                                    par.getParam<std::string>("scenesLocation") + "/" + sceneName;
        try {
            read_xml(sceneLocation + ".xml", pt);
        } catch ( boost::property_tree::xml_parser_error & e) {
            ERROR_FN(Locale::get("ERROR_XML_INVALID_SCENE"),sceneName.c_str());
            std::string error = e.what();
            error += " [check error log!]";
            throw error.c_str();
        }

        par.setParam("currentScene",sceneName);
        Scene* scene = sceneMgr.createScene(sceneName);

        if (!scene)	{
            ERROR_FN(Locale::get("ERROR_XML_LOAD_INVALID_SCENE"));
            return;
        }

        sceneMgr.setActiveScene(scene);
        scene->setName(sceneName);
        scene->state().getGrassVisibility() = pt.get("vegetation.grassVisibility",1000.0f);
        scene->state().getTreeVisibility()  = pt.get("vegetation.treeVisibility",1000.0f);
        scene->state().getGeneralVisibility()  = pt.get("options.visibility",1000.0f);

        scene->state().getWindDirX()  = pt.get("wind.windDirX",1.0f);
        scene->state().getWindDirZ()  = pt.get("wind.windDirZ",1.0f);
        scene->state().getWindSpeed() = pt.get("wind.windSpeed",1.0f);

        scene->state().getWaterLevel() = pt.get("water.waterLevel",0.0f);
        scene->state().getWaterDepth() = pt.get("water.waterDepth",-75);

        if (boost::optional<ptree &> cameraPositionOverride = pt.get_child_optional("options.cameraStartPosition")) {
            par.setParam("options.cameraStartPosition.x", pt.get("options.cameraStartPosition.<xmlattr>.x",0.0f));
            par.setParam("options.cameraStartPosition.y", pt.get("options.cameraStartPosition.<xmlattr>.y",0.0f));
            par.setParam("options.cameraStartPosition.z", pt.get("options.cameraStartPosition.<xmlattr>.z",0.0f));
            par.setParam("options.cameraStartOrientation.xOffsetDegrees",pt.get("options.cameraStartPosition.<xmlattr>.xOffsetDegrees",0.0f));
            par.setParam("options.cameraStartOrientation.yOffsetDegrees",pt.get("options.cameraStartPosition.<xmlattr>.yOffsetDegrees",0.0f));
            par.setParam("options.cameraStartPositionOverride",true);
        } else {
            par.setParam("options.cameraStartPositionOverride",false);
        }

        if (boost::optional<ptree &> physicsCook = pt.get_child_optional("options.autoCookPhysicsAssets")) {
            par.setParam("options.autoCookPhysicsAssets", pt.get<bool>("options.autoCookPhysicsAssets",false));
        } else {
            par.setParam("options.autoCookPhysicsAssets", false);
        }

        if (boost::optional<ptree &> cameraPositionOverride = pt.get_child_optional("options.cameraSpeed")) {
            par.setParam("options.cameraSpeed.move",pt.get("options.cameraSpeed.<xmlattr>.move", 35.0f));
            par.setParam("options.cameraSpeed.turn",pt.get("options.cameraSpeed.<xmlattr>.turn", 35.0f));
        } else {
            par.setParam("options.cameraSpeed.move", 35.0f);
            par.setParam("options.cameraSpeed.turn", 35.0f);
        }

        if (boost::optional<ptree &> fog = pt.get_child_optional("fog")) {
            par.setParam("rendering.sceneState.fogDensity", pt.get("fog.fogDensity",0.01f));
            par.setParam("rendering.sceneState.fogColor.r", pt.get<F32>("fog.fogColor.<xmlattr>.r", 0.2f));
            par.setParam("rendering.sceneState.fogColor.g", pt.get<F32>("fog.fogColor.<xmlattr>.g", 0.2f));
            par.setParam("rendering.sceneState.fogColor.b",	pt.get<F32>("fog.fogColor.<xmlattr>.b", 0.2f));
        }

        scene->state().getFogDesc()._fogDensity = par.getParam<F32>("rendering.sceneState.fogDensity");
        scene->state().getFogDesc()._fogColor.set(par.getParam<F32>("rendering.sceneState.fogColor.r"),
                                                  par.getParam<F32>("rendering.sceneState.fogColor.g"),
                                                  par.getParam<F32>("rendering.sceneState.fogColor.b"));

        loadTerrain(sceneLocation + "/" + pt.get("terrain","terrain.xml"),scene);
        loadGeometry(sceneLocation + "/" + pt.get("assets","assets.xml"),scene);
    }

    void loadTerrain(const std::string &file, Scene* const scene) {
        U8 count = 0;
        pt.clear();
        PRINT_FN(Locale::get("XML_LOAD_TERRAIN"),file.c_str());
        read_xml(file,pt);
        ptree::iterator itTerrain;
        ptree::iterator itTexture;
        std::string assetLocation = ParamHandler::getInstance().getParam<std::string>("assetsLocation") + "/";

        for (itTerrain = pt.get_child("terrainList").begin(); itTerrain != pt.get_child("terrainList").end(); ++itTerrain) {
            std::string name = itTerrain->second.data(); //The actual terrain name
            std::string tag = itTerrain->first.data();   //The <name> tag for valid terrains or <xmlcomment> for comments
            //Check and skip commented terrain
            if(tag.find("<xmlcomment>") != std::string::npos) continue;
            //Load the rest of the terrain
            TerrainDescriptor* ter = CreateResource<TerrainDescriptor>(name+"_descriptor");
            ter->addVariable("terrainName",name);
            ter->addVariable("heightmap",assetLocation + pt.get<std::string>(name + ".heightmap"));
            ter->addVariable("waterCaustics", assetLocation + pt.get<std::string>(name + ".waterCaustics"));
            ter->addVariable("underwaterAlbedoTexture", assetLocation + pt.get<std::string>(name + ".underwaterAlbedoTexture"));
            ter->addVariable("underwaterDetailTexture", assetLocation + pt.get<std::string>(name + ".underwaterDetailTexture"));
            ter->addVariable("underwaterDiffuseScale", pt.get<F32>(name + ".underwaterDiffuseScale"));

            I32 i = 0;
            std::string temp;
            std::string layerOffsetStr;
            for (itTexture = pt.get_child(name + ".textureLayers").begin(); itTexture != pt.get_child(name + ".textureLayers").end(); ++itTexture, ++i) {
                std::string layerName = itTexture->second.data();
                std::string format = itTexture->first.data();
                if (format.find("<xmlcomment>") != std::string::npos) {
                    i--;
                    continue;
                }
                layerName = name + ".textureLayers." + format;

                layerOffsetStr = Util::toString(i);
                temp = pt.get<std::string>(layerName + ".blendMap", "");
                DIVIDE_ASSERT(!temp.empty(), "Blend Map for terrain missing!");
                ter->addVariable("blendMap" + layerOffsetStr, assetLocation + temp);

                temp = pt.get<std::string>(layerName + ".redAlbedo", "");
                if (!temp.empty()) {
                    ter->addVariable("redAlbedo" + layerOffsetStr, assetLocation + temp);
                }
                temp = pt.get<std::string>(layerName + ".redDetail", "");
                if (!temp.empty()) {
                    ter->addVariable("redDetail" + layerOffsetStr, assetLocation + temp);
                }
                temp = pt.get<std::string>(layerName + ".greenAlbedo", "");
                if (!temp.empty()) {
                    ter->addVariable("greenAlbedo" + layerOffsetStr, assetLocation + temp);
                }
                temp = pt.get<std::string>(layerName + ".greenDetail", "");
                if (!temp.empty()) {
                    ter->addVariable("greenDetail" + layerOffsetStr, assetLocation + temp);
                }
                temp = pt.get<std::string>(layerName + ".blueAlbedo", "");
                if (!temp.empty()) {
                    ter->addVariable("blueAlbedo" + layerOffsetStr, assetLocation + temp);
                }
                temp = pt.get<std::string>(layerName + ".blueDetail", "");
                if (!temp.empty()) {
                    ter->addVariable("blueDetail" + layerOffsetStr, assetLocation + temp);
                }
                temp = pt.get<std::string>(layerName + ".alphaAlbedo", "");
                if (!temp.empty()) {
                    ter->addVariable("alphaAlbedo" + layerOffsetStr, assetLocation + temp);
                }
                temp = pt.get<std::string>(layerName + ".alphaDetail", "");
                if (!temp.empty()) {
                    ter->addVariable("alphaDetail" + layerOffsetStr, assetLocation + temp);
                }

                ter->addVariable("diffuseScaleR" + layerOffsetStr, pt.get<F32>(layerName + ".redDiffuseScale", 0.0f));
                ter->addVariable("detailScaleR"  + layerOffsetStr, pt.get<F32>(layerName + ".redDetailScale", 0.0f));
                ter->addVariable("diffuseScaleG" + layerOffsetStr, pt.get<F32>(layerName + ".greenDiffuseScale", 0.0f));
                ter->addVariable("detailScaleG"  + layerOffsetStr, pt.get<F32>(layerName + ".greenDetailScale", 0.0f));
                ter->addVariable("diffuseScaleB" + layerOffsetStr, pt.get<F32>(layerName + ".blueDiffuseScale", 0.0f));
                ter->addVariable("detailScaleB"  + layerOffsetStr, pt.get<F32>(layerName + ".blueDetailScale", 0.0f));
                ter->addVariable("diffuseScaleA" + layerOffsetStr, pt.get<F32>(layerName + ".alphaDiffuseScale", 0.0f));
                ter->addVariable("detailScaleA"  + layerOffsetStr, pt.get<F32>(layerName + ".alphaDetailScale", 0.0f));
            }

            ter->setTextureLayerCount(i);
            ter->addVariable("grassMap",assetLocation + pt.get<std::string>(name + ".vegetation.map"));
            ter->addVariable("grassBillboard1", assetLocation + pt.get<std::string>(name + ".vegetation.grassBillboard1", ""));
            ter->addVariable("grassBillboard2", assetLocation + pt.get<std::string>(name + ".vegetation.grassBillboard2", ""));
            ter->addVariable("grassBillboard3", assetLocation + pt.get<std::string>(name + ".vegetation.grassBillboard3", ""));
            ter->addVariable("grassBillboard4", assetLocation + pt.get<std::string>(name + ".vegetation.grassBillboard4", ""));
            ter->setGrassDensity(pt.get<F32>(name + ".vegetation.<xmlattr>.grassDensity"));
            ter->setTreeDensity(pt.get<F32>(name + ".vegetation.<xmlattr>.treeDensity"));
            ter->setGrassScale(pt.get<F32>(name + ".vegetation.<xmlattr>.grassScale"));
            ter->setTreeScale(pt.get<F32>(name + ".vegetation.<xmlattr>.treeScale"));
            ter->set16Bit(pt.get<bool>(name + ".is16Bit", false));
            ter->setPosition(vec3<F32>(pt.get<F32>(name + ".position.<xmlattr>.x", 0.0f), pt.get<F32>(name + ".position.<xmlattr>.y", 0.0f), pt.get<F32>(name + ".position.<xmlattr>.z", 0.0f)));
            ter->setScale(vec2<F32>(pt.get<F32>(name + ".scale", 1.0f), pt.get<F32>(name + ".heightFactor", 1.0f)));
            ter->setDimensions(vec2<U16>(pt.get<U16>(name + ".terrainWidth", 0), pt.get<U16>(name + ".terrainHeight", 0)));
            ter->setAltitudeRange(vec2<F32>(pt.get<F32>(name + ".altitudeRange.<xmlattr>.min", 0.0f), pt.get<F32>(name + ".altitudeRange.<xmlattr>.max", 255.0f)));
            ter->setActive(pt.get<bool>(name + ".active", true));
            ter->setChunkSize(pt.get<U32>(name + ".nodeChunkSize", 256));
            ter->setCreatePXActor(pt.get<bool>(name + ".addToPhysics", false));

            scene->addTerrain(ter);
            count++;
        }

        PRINT_FN(Locale::get("XML_TERRAIN_COUNT"),count);
    }

    void loadGeometry(const std::string &file, Scene* const scene) {
        pt.clear();
        PRINT_FN(Locale::get("XML_LOAD_GEOMETRY"),file.c_str());
        read_xml(file,pt);
        ptree::iterator it;
        std::string assetLocation = ParamHandler::getInstance().getParam<std::string>("assetsLocation")+"/";

        if(boost::optional<ptree &> geometry = pt.get_child_optional("geometry")) {
            for (it = pt.get_child("geometry").begin(); it != pt.get_child("geometry").end(); ++it ) {
                std::string name = it->second.data();
                std::string format = it->first.data();
                if(format.find("<xmlcomment>") != std::string::npos) continue;
                FileData model;
                model.ItemName = name;
                model.ModelName  = assetLocation + pt.get<std::string>(name + ".model");
                model.position.x = pt.get<F32>(name + ".position.<xmlattr>.x",1);
                model.position.y = pt.get<F32>(name + ".position.<xmlattr>.y",1);
                model.position.z = pt.get<F32>(name + ".position.<xmlattr>.z",1);
                model.orientation.x = pt.get<F32>(name + ".orientation.<xmlattr>.x");
                model.orientation.y = pt.get<F32>(name + ".orientation.<xmlattr>.y");
                model.orientation.z = pt.get<F32>(name + ".orientation.<xmlattr>.z");
                model.scale.x    = pt.get<F32>(name + ".scale.<xmlattr>.x");
                model.scale.y    = pt.get<F32>(name + ".scale.<xmlattr>.y");
                model.scale.z    = pt.get<F32>(name + ".scale.<xmlattr>.z");
                model.type = GEOMETRY;
                model.version = pt.get<F32>(name + ".version");

                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".castsShadows")) {
                    model.castsShadows = pt.get<bool>(name + ".castsShadows",false);
                } else {
                    model.castsShadows = true;
                }
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".receivesShadows")) {
                    model.receivesShadows = pt.get<bool>(name + ".receivesShadows",false);
                } else {
                    model.receivesShadows = true;
                }
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".staticObject")) {
                    model.staticUsage = pt.get<bool>(name + ".staticObject",false);
                } else {
                    model.staticUsage = false;
                }
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".addToNavigation")) {
                    model.navigationUsage = pt.get<bool>(name + ".addToNavigation",false);
                } else {
                    model.navigationUsage = false;
                }
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".useHighNavigationDetail")) {
                    model.useHighDetailNavMesh = pt.get<bool>(name + ".useHighNavigationDetail",false);
                } else {
                    model.useHighDetailNavMesh = false;
                }
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".addToPhysics")) {
                    model.physicsUsage = pt.get<bool>(name + ".addToPhysics",false);
                    model.physicsPushable = pt.get<bool>(name + ".addToPhysicsGroupPushable",false);
                } else {
                    model.physicsUsage = false;
                }

                scene->addModel(model);
            }
        }

        if(boost::optional<ptree &> vegetation = pt.get_child_optional("vegetation")) {
            for (it = pt.get_child("vegetation").begin(); it != pt.get_child("vegetation").end(); ++it ) {
                std::string name = it->second.data();
                std::string format = it->first.data();
                if(format.find("<xmlcomment>") != std::string::npos) continue;
                FileData model;
                model.ItemName = name;
                model.ModelName  = assetLocation + pt.get<std::string>(name + ".model");
                model.position.x = pt.get<F32>(name + ".position.<xmlattr>.x");
                model.position.y = pt.get<F32>(name + ".position.<xmlattr>.y");
                model.position.z = pt.get<F32>(name + ".position.<xmlattr>.z");
                model.orientation.x = pt.get<F32>(name + ".orientation.<xmlattr>.x");
                model.orientation.y = pt.get<F32>(name + ".orientation.<xmlattr>.y");
                model.orientation.z = pt.get<F32>(name + ".orientation.<xmlattr>.z");
                model.scale.x    = pt.get<F32>(name + ".scale.<xmlattr>.x");
                model.scale.y    = pt.get<F32>(name + ".scale.<xmlattr>.y");
                model.scale.z    = pt.get<F32>(name + ".scale.<xmlattr>.z");
                model.type = VEGETATION;
                model.version = pt.get<F32>(name + ".version");
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".castsShadows")) {
                    model.castsShadows = pt.get<bool>(name + ".castsShadows",false);
                } else {
                    model.castsShadows = true;
                }
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".receivesShadows")) {
                    model.receivesShadows = pt.get<bool>(name + ".receivesShadows",false);
                } else {
                    model.receivesShadows = true;
                }
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".staticObject")) {
                    model.staticUsage = pt.get<bool>(name + ".staticObject",false);
                } else {
                    model.staticUsage = false;
                }
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".addToNavigation")) {
                    model.navigationUsage = pt.get<bool>(name + ".addToNavigation",false);
                } else {
                    model.navigationUsage = false;
                }
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".useHighNavigationDetail")) {
                    model.useHighDetailNavMesh = pt.get<bool>(name + ".useHighNavigationDetail",false);
                } else {
                    model.useHighDetailNavMesh = false;
                }
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".addToPhysics")) {
                    model.physicsUsage = pt.get<bool>(name + ".addToPhysics",false);
                } else {
                    model.physicsUsage = false;
                }
                scene->addModel(model);
            }
        }

        if(boost::optional<ptree &> primitives = pt.get_child_optional("primitives")) {
            for (it = pt.get_child("primitives").begin(); it != pt.get_child("primitives").end(); ++it ) {
                std::string name = it->second.data();
                std::string format = it->first.data();
                if(format.find("<xmlcomment>") != std::string::npos) continue;

                FileData model;
                model.ItemName = name;
                model.ModelName = pt.get<std::string>(name + ".model");
                model.position.x = pt.get<F32>(name + ".position.<xmlattr>.x");
                model.position.y = pt.get<F32>(name + ".position.<xmlattr>.y");
                model.position.z = pt.get<F32>(name + ".position.<xmlattr>.z");
                model.orientation.x = pt.get<F32>(name + ".orientation.<xmlattr>.x");
                model.orientation.y = pt.get<F32>(name + ".orientation.<xmlattr>.y");
                model.orientation.z = pt.get<F32>(name + ".orientation.<xmlattr>.z");
                model.scale.x    = pt.get<F32>(name + ".scale.<xmlattr>.x");
                model.scale.y    = pt.get<F32>(name + ".scale.<xmlattr>.y");
                model.scale.z    = pt.get<F32>(name + ".scale.<xmlattr>.z");
                model.color.r    = pt.get<F32>(name + ".color.<xmlattr>.r");
                model.color.g    = pt.get<F32>(name + ".color.<xmlattr>.g");
                model.color.b    = pt.get<F32>(name + ".color.<xmlattr>.b");
                /*The data variable stores a float variable (not void*) that can represent anything you want*/
                /*For Text3D, it's the line width and for Box3D it's the edge length*/
                if (model.ModelName.compare("Text3D") == 0) {
                    model.data = pt.get<F32>(name + ".lineWidth");
                    model.data2 = pt.get<std::string>(name + ".text");
                    model.data3 = pt.get<std::string>(name + ".fontName");
                } else if (model.ModelName.compare("Box3D") == 0) {
                    model.data = pt.get<F32>(name + ".size");
                } else if (model.ModelName.compare("Sphere3D") == 0) {
                    model.data = pt.get<F32>(name + ".radius");
                } else {
                    model.data = 0;
                }

                model.type = PRIMITIVE;
                model.version = pt.get<F32>(name + ".version");
            
                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".castsShadows")) {
                    model.castsShadows = pt.get<bool>(name + ".castsShadows",false);
                } else {
                    model.castsShadows = true;
                }

                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".receivesShadows")) {
                    model.receivesShadows = pt.get<bool>(name + ".receivesShadows",false);
                } else {
                    model.receivesShadows = true;
                }

                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".staticObject")) {
                    model.staticUsage = pt.get<bool>(name + ".staticObject",false);
                } else {
                    model.staticUsage = false;
                }

                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".addToNavigation")) {
                    model.navigationUsage = pt.get<bool>(name + ".addToNavigation",false);
                } else {
                    model.navigationUsage = false;
                }

                if (boost::optional<ptree &> child = pt.get_child_optional(name + ".useHighNavigationDetail")) {
                    model.useHighDetailNavMesh = pt.get<bool>(name + ".useHighNavigationDetail",false);
                } else {
                    model.useHighDetailNavMesh = false;
                }
                scene->addModel(model);
            }
        }
    }

    Material* loadMaterial(const std::string &file){
        ParamHandler &par = ParamHandler::getInstance();
        std::string location = par.getParam<std::string>("scriptLocation") + "/" +
                               par.getParam<std::string>("scenesLocation") + "/" +
                               par.getParam<std::string>("currentScene") + "/materials/";

        return loadMaterialXML(location+file);
    }

    Material* loadMaterialXML(const std::string &matName, bool rendererDependent){
        std::string materialFile(matName);
        if (rendererDependent ) {
            materialFile += "-" + getRendererTypeName(GFX_DEVICE.getRenderer()->getType()) + ".xml";
        } else {
            materialFile += ".xml";
        }

        pt.clear();
        std::ifstream inp;
        inp.open(materialFile.c_str(), std::ifstream::in);

        if (inp.fail()) {
            inp.clear(std::ios::failbit);
            inp.close();
            return nullptr;
        }

        inp.close();
        bool skip = false;
        PRINT_FN(Locale::get("XML_LOAD_MATERIAL"),matName.c_str());
        read_xml(materialFile, pt);

        std::string materialName = matName.substr(matName.rfind("/")+1,matName.length());

        if (FindResourceImpl<Material>(materialName)) {
            skip = true;
        }

        Material* mat = CreateResource<Material>(ResourceDescriptor(materialName));
        if (skip) {
            return mat;
        }

        //Skip if the material was cooked by a different renderer

        mat->setDiffuse(vec4<F32>(pt.get<F32>("material.diffuse.<xmlattr>.r",0.6f),
                                  pt.get<F32>("material.diffuse.<xmlattr>.g",0.6f),
                                  pt.get<F32>("material.diffuse.<xmlattr>.b",0.6f),
                                  pt.get<F32>("material.diffuse.<xmlattr>.a",1.f)));
        mat->setAmbient(vec4<F32>(pt.get<F32>("material.ambient.<xmlattr>.r",0.6f),
                                  pt.get<F32>("material.ambient.<xmlattr>.g",0.6f),
                                  pt.get<F32>("material.ambient.<xmlattr>.b",0.6f),
                                  pt.get<F32>("material.ambient.<xmlattr>.a",1.f)));
        mat->setSpecular(vec4<F32>(pt.get<F32>("material.specular.<xmlattr>.r",1.f),
                                   pt.get<F32>("material.specular.<xmlattr>.g",1.f),
                                   pt.get<F32>("material.specular.<xmlattr>.b",1.f),
                                   pt.get<F32>("material.specular.<xmlattr>.a",1.f)));
        mat->setEmissive(vec3<F32>(pt.get<F32>("material.emissive.<xmlattr>.r",1.f),
                                   pt.get<F32>("material.emissive.<xmlattr>.g",1.f),
                                   pt.get<F32>("material.emissive.<xmlattr>.b",1.f)));

        mat->setShininess(pt.get<F32>("material.shininess.<xmlattr>.v",50.f));

        mat->setDoubleSided(pt.get<bool>("material.doubleSided",false));

        if (boost::optional<ptree &> child = pt.get_child_optional("diffuseTexture1")) {
            mat->setTexture(ShaderProgram::TEXTURE_UNIT0, loadTextureXML("diffuseTexture1", pt.get("diffuseTexture1.file","none")));
        }

        if (boost::optional<ptree &> child = pt.get_child_optional("diffuseTexture2")) {
            mat->setTexture(ShaderProgram::TEXTURE_UNIT1,loadTextureXML("diffuseTexture2", pt.get("diffuseTexture2.file","none")),
                            getTextureOperation(pt.get<std::string>("diffuseTexture2.operation","TEX_OP_MULTIPLY").c_str()));
        }

        if (boost::optional<ptree &> child = pt.get_child_optional("bumpMap")) {
            mat->setTexture(ShaderProgram::TEXTURE_NORMALMAP,loadTextureXML("bumpMap", pt.get("bumpMap.file","none")));
            if (boost::optional<ptree &> child = pt.get_child_optional("bumpMap.method")) {
                mat->setBumpMethod(getBumpMethod(pt.get<std::string>("bumpMap.method","BUMP_NORMAL").c_str()));
            }
        }

        if (boost::optional<ptree &> child = pt.get_child_optional("opacityMap")) {
            mat->setTexture(ShaderProgram::TEXTURE_OPACITY,loadTextureXML("opacityMap", pt.get("opacityMap.file","none")));
        }

        if (boost::optional<ptree &> child = pt.get_child_optional("specularMap")) {
            mat->setTexture(ShaderProgram::TEXTURE_SPECULAR,loadTextureXML("specularMap", pt.get("specularMap.file","none")));
        }
 
        return mat;
    }

    void dumpMaterial(Material& mat) {
        if(!mat.isDirty()) {
            return;
        }

        ptree pt_writer;
        ParamHandler &par = ParamHandler::getInstance();
        std::string file = mat.getName();
        file = file.substr(file.rfind("/")+1,file.length());

        std::string location = par.getParam<std::string>("scriptLocation") + "/" +
                               par.getParam<std::string>("scenesLocation") + "/" +
                               par.getParam<std::string>("currentScene") + "/materials/";

        std::string fileLocation = location +  file + "-" + getRendererTypeName(GFX_DEVICE.getRenderer()->getType()) + ".xml";
        pt_writer.clear();
        pt_writer.put("material.name",file);
        pt_writer.put("material.ambient.<xmlattr>.r",  mat.getShaderData()._ambient.r);
        pt_writer.put("material.ambient.<xmlattr>.g",  mat.getShaderData()._ambient.g);
        pt_writer.put("material.ambient.<xmlattr>.b",  mat.getShaderData()._ambient.b);
        pt_writer.put("material.ambient.<xmlattr>.a",  mat.getShaderData()._ambient.a);
        pt_writer.put("material.diffuse.<xmlattr>.r",  mat.getShaderData()._diffuse.r);
        pt_writer.put("material.diffuse.<xmlattr>.g",  mat.getShaderData()._diffuse.g);
        pt_writer.put("material.diffuse.<xmlattr>.b",  mat.getShaderData()._diffuse.b);
        pt_writer.put("material.diffuse.<xmlattr>.a" , mat.getShaderData()._diffuse.a);
        pt_writer.put("material.specular.<xmlattr>.r", mat.getShaderData()._specular.r);
        pt_writer.put("material.specular.<xmlattr>.g", mat.getShaderData()._specular.g);
        pt_writer.put("material.specular.<xmlattr>.b", mat.getShaderData()._specular.b);
        pt_writer.put("material.specular.<xmlattr>.a", mat.getShaderData()._specular.a);
        pt_writer.put("material.shininess.<xmlattr>.v",mat.getShaderData()._shininess);
        pt_writer.put("material.emissive.<xmlattr>.r", mat.getShaderData()._emissive.y);
        pt_writer.put("material.emissive.<xmlattr>.g", mat.getShaderData()._emissive.z);
        pt_writer.put("material.emissive.<xmlattr>.b", mat.getShaderData()._emissive.w);
        pt_writer.put("material.doubleSided", mat.isDoubleSided());

        Texture* texture = nullptr;

        if ((texture = mat.getTexture(ShaderProgram::TEXTURE_UNIT0)) != nullptr) {
            saveTextureXML("diffuseTexture1", texture, pt_writer);
        }

        if ((texture = mat.getTexture(ShaderProgram::TEXTURE_UNIT1)) != nullptr) {
            saveTextureXML("diffuseTexture2", texture, pt_writer, getTextureOperationName(mat.getTextureOperation())); 
        }

        if ((texture = mat.getTexture(ShaderProgram::TEXTURE_NORMALMAP)) != nullptr) {
            saveTextureXML("bumpMap", texture, pt_writer);
            pt_writer.put("bumpMap.method", getBumpMethodName(mat.getBumpMethod()));
        }

        if ((texture = mat.getTexture(ShaderProgram::TEXTURE_OPACITY)) != nullptr) {
            saveTextureXML("opacityMap", texture, pt_writer);
        }

        if ((texture = mat.getTexture(ShaderProgram::TEXTURE_SPECULAR)) != nullptr) {
            saveTextureXML("specularMap", texture, pt_writer);
        }

        ShaderProgram* shaderProg = mat.getShaderInfo().getProgram();
        if (shaderProg) {
            pt_writer.put("shaderProgram.effect", shaderProg->getName());
        }

        shaderProg = mat.getShaderInfo(SHADOW_STAGE).getProgram();
        if (shaderProg) {
            pt_writer.put("shaderProgram.shadowEffect", shaderProg->getName());
        }

        shaderProg = mat.getShaderInfo(Z_PRE_PASS_STAGE).getProgram();
        if (shaderProg) {
            pt_writer.put("shaderProgram.zPrePassEffect", shaderProg->getName());
        }

        boost::property_tree::xml_writer_settings<char> settings('\t', 1);
        FILE * xml = fopen(fileLocation.c_str(), "w");
        fclose(xml);
        write_xml(fileLocation, pt_writer,std::locale(),settings);
    }
}; //namespace XML
}; //namespace Divide

Commits for Divide-Framework/trunk/Source Code/Utility/XMLParser.cpp

Diff revisions: vs.
Revision Author Commited Message
318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

311 Diff Diff IonutCava picture IonutCava Mon 18 Aug, 2014 21:40:52 +0000

[Ionut]
- Added a basic AESOP implementation
- Moved all AI related classes under the “AI” namespace

301 Diff Diff IonutCava picture IonutCava Tue 05 Aug, 2014 20:55:30 +0000

[Ionut]
- Code cleanups and comments (ShaderManager, ShaderProgram, Texture)
- Fixed some singleton destruction order between ResourceCache and ShaderManager to properly unload remaining shader programs

296 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Aug, 2014 14:54:21 +0000

[Ionut]
- nVidia compatibility fixes (GUI, shadows, post-processing)
- Texture bind slots are now part of ShaderProgram class
- Renamed ForwardRenderer class to ForwardPlusRenderer and moved ligh grid creation to it
- More code cleanups and comments

294 Diff Diff k1ngp1n picture k1ngp1n Wed 30 Jul, 2014 20:19:14 +0000

[Ionut]
- More nVidia compatibility fixes (lighting shaders with textures still fail to compile):
— NS_GLIM compatibility fix (set ELEMENT_ARRAY_BUFFER to 0 in glimBatchData’s VAO on creation when setting attrib pointers)

  • Could improve NS_GLIM performance a lot by caching some buffers instead of re-creating them every time a batch is generated, but it’s suppose to be used only for debugging, so low prio*

- Removed interpolation factor from FrameEvent struct. Only using interpolation factor stored in GFXDevice instance
- Fixed the close button (added GLFW close callback)
- More code style improvements (no new comments yet)

293 Diff Diff k1ngp1n picture k1ngp1n Tue 29 Jul, 2014 20:01:28 +0000

[Ionut]
- Code cleanup and comments in GLFWWrapper (for starters. more to follow)
- Reworked main loop logic (no more delegates and rendering api querying)
- Replaced all GLvoid with regular void
- replaced all boost::this_thread::sleep (deprecated calls) with boost::this_thread::sleep_for

290 Diff Diff IonutCava picture IonutCava Sun 27 Jul, 2014 14:54:01 +0000

[Ionut]
- Small change to the resource loading thread
- Fixed array texture loading in framebuffer
- Temporarily disabled shadows (caused an assert)
- Fixed double close call for LightManager
- Removed unused options from config.xml

287 Diff Diff IonutCava picture IonutCava Tue 22 Jul, 2014 16:11:05 +0000

[Ionut]
- Unified matrix transforms and node info and made it a vertex-shader only buffer
- World matrix queries have to be issued from the SceneGraphNode instead of the SGN’s Transform class to allow future interpolation algorithms to be more easily implemented
- Moved all lighting calculations per pixel to save varying and register space (caused compilation issues both on nVidia and AMD)
- Stored GPU buffer info (view, projection, viewport etc) into a special struct to avoid multiple redundant buffer uploads and to remove redundant client side matrix caches
- Some work on shader buffer locking system
- Cleaned up MathClasses.h and Transform.h
- Updated ASSIMP to 3.1.1

286 Diff Diff IonutCava picture IonutCava Fri 18 Jul, 2014 16:32:03 +0000

[Ionut] [[BR]]

    • very buggy commit ** [[BR]]

- New rendering pipeline: [[BR]]
— Bumped OpenGL version to 4.4 [[BR]]
— Command based rendering. GFXDevice dispatches rendering commands to their respective buffers [[BR]]
— State changing is exclusively controlled by the GFXDevice class [[BR]]
— Material properties and transform matrices are stored in shader storage buffers that are updated after culling and uploaded once per RenderPass. Objects use drawIDs to index data in shaders [[BR]]
— Removed all custom matrices and other, per shader, bind data [[BR]]
— Removed per node light data. Light culling and shader buffers will replace the old light management system [[BR]]
— Framebuffers now use the Texture class for attachments [[BR]]
— Sampler objects now work like RenderStateBlocks. GL_API handles them and stores them in a hash indexed map [[BR]]
— Removed “prepareMaterial” calls. Pre-draw material setup is now only limited to texture binding [[BR]]
— Moved immediate mode emulation and primitive rendering from API level to GFXDevice level [[BR]]
— Framebuffer rendering must be completed with a call to end() to ensure proper MSAA resolve (asserts, otherwise) [[BR]]
- Fixed hash code generation for RenderStateBlock (and now, glSamplerObject) using boost::hash_combine [[BR]]
- Temporarily disabled XML caching for materials [[BR]]

273 IonutCava picture IonutCava Wed 11 Jun, 2014 20:34:00 +0000

[Ionut] [[BR]]
- Improved batching part2: [[BR]]
— Moved all bone transformation matrices upload from uniform functions in SceneNode to Shader Storage Buffers in AnimationController class with updates controlled by SceneGraphNode’s AnimationComponent [[BR]]
-— No double-buffering or efficient mapping of data yet. Just raw buffer updates [[BR]]
— Replaced all RenderStateBlock* pointers with I64 hash values [[BR]]
-— Will be used later in draw commands as per-shader state hash [[BR]]
— Moved getShaderProgram from Material to Material::ShaderInfo [[BR]]
-— Improved redundant uniform checks [[BR]]
— Improved texture unit changing in case of redundant texture bind case (i.e. skip changing the texture unit) [[BR]]
[[BR]]
- Improved float and double comparison functions using algorithms described in http://randomascii.wordpress.com/2012/02/13/dont-store-that-in-a-float/ [[BR]]
- Added a new utility function, DIVIDE_ASSERT, to more easily bind an assert check with a specific message [[BR]]
- Added missing files from Forward+ renderer’s initial code [[BR]]