1 /**
2  * Copyright:       Copyright (C) 2018 Gabriel Gheorghe, All Rights Reserved
3  * Authors:         $(Gabriel Gheorghe)
4  * License:         $(LINK2 https://www.gnu.org/licenses/gpl-3.0.txt, GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007)
5  * Source:          $(LINK2 https://github.com/GabyForceQ/LibertyEngine/blob/master/source/liberty/world/impl.d)
6  * Documentation:
7  * Coverage:
8 **/
9 module liberty.world.impl;
10 
11 import liberty.camera;
12 import liberty.math.vector;
13 import liberty.world.constants;
14 
15 /**
16  * Class containing world settings used in a scene.
17 **/
18 final class World {
19   private {
20     Vector3F expHeightFogColor = WORLD_DEFAULT_EXP_HEIGHT_FOG_COLOR;
21     int killZ = WORLD_DEFUALT_KILL_Z;
22   }
23 
24   /**
25    * Set the exp height fog color of the scene using 3 floats for the color (RGB) in a template stream function.
26    * Assign a value to exp height fog color using world.setExpHeightFogColor(r, g, b) or world.setExpHeightFogColor!"="(r, g, b).
27    * Increment exp height fog color by value using world.setExpHeightFogColor!"+="(r, g, b).
28    * Decrement exp height fog color by value using world.setExpHeightFogColor!"-="(r, g, b).
29    * Multiply exp height fog color by value using world.setExpHeightFogColor!"*="(r, g, b).
30    * Divide exp height fog color by value using world.setExpHeightFogColor!"/="(r, g, b).
31    * Returns reference to this so it can be used in a stream.
32   **/
33   typeof(this) setExpHeightFogColor(string op = "=")(float r, float g, float b)  
34   if (op == "=" || op == "+=" || op == "-=" || op == "*=" || op == "/=")
35   do {
36     return setExpHeightFogColor!op(Vector3F(r, g, b));
37   }
38 
39   /**
40    * Set the exp height fog color of the scene using a vector of 3 values for the color (RGB) in a template stream function.
41    * Assign a value to exp height fog color using world.setExpHeightFogColor(vector3) or world.setExpHeightFogColor!"="(vector3).
42    * Increment exp height fog color by value using world.setExpHeightFogColor!"+="(vector3).
43    * Decrement exp height fog color by value using world.setExpHeightFogColor!"-="(vector3).
44    * Multiply exp height fog color by value using world.setExpHeightFogColor!"*="(vector3).
45    * Divide exp height fog color by value using world.setExpHeightFogColor!"/="(vector3).
46    * Returns reference to this so it can be used in a stream.
47   **/
48   typeof(this) setExpHeightFogColor(string op = "=")(Vector3F expHeightFogColor)   {
49     mixin("this.expHeightFogColor " ~ op ~ " expHeightFogColor;");
50     return this;
51   }
52 
53   /**
54    * Returns the exponential height fog color.
55   **/
56   Vector3F getExpHeightFogColor()   const {
57     return expHeightFogColor;
58   }
59 
60   /**
61    * Set exp height fog color to default value $(D WORLD_DEFAULT_EXP_HEIGHT_FOG_COLOR).
62    * Returns reference to this so it can be used in a stream.
63   **/
64   typeof(this) setDefaultExpHeightFogColor()   {
65     expHeightFogColor = WORLD_DEFAULT_EXP_HEIGHT_FOG_COLOR;
66     return this;
67   }
68 
69   /**
70    * Set the kill-z of the scene using a value in a template stream function.
71    * Assign a value to kill-z using world.setKillZ(value) or world.setKillZ!"="(value).
72    * Increment kill-z by value using world.setKillZ!"+="(value).
73    * Decrement kill-z by value using world.setKillZ!"-="(value).
74    * Multiply kill-z by value using world.setKillZ!"*="(value).
75    * Divide kill-z by value using world.setKillZ!"/="(value).
76    * Returns reference to this so it can be used in a stream.
77   **/
78   typeof(this) setKillZ(string op = "=")(float value)  
79   if (op == "=" || op == "+=" || op == "-=" || op == "*=" || op == "/=")
80   do {
81     mixin("killZ " ~ op ~ " value;");
82   }
83 
84   /**
85    * Returns the kill-z value.
86   **/
87   float getKillZ()   const {
88     return killZ;
89   }
90 
91   /**
92    * Set kill-z to default value $(D WORLD_DEFUALT_KILL_Z).
93    * Returns reference to this so it can be used in a stream.
94   **/
95   typeof(this) setDefaultKillZ()   {
96     killZ = WORLD_DEFUALT_KILL_Z;
97     return this;
98   }
99 
100   /**
101    * Disable kill-z using value $(D WORLD_NO_KILL_Z).
102    * Returns reference to this so it can be used in a stream.
103   **/
104   typeof(this) setNoKillZ()   {
105     killZ = WORLD_NO_KILL_Z;
106     return this;
107   }
108 }