1 module sbylib.wrapper.assimp.light;
2 
3 import bindbc.assimp.types;
4 import sbylib.wrapper.assimp.constants : LightSourceType;
5 import sbylib.wrapper.assimp.functions : toRegularString, toSbylibVector, toEnum;
6 import sbylib.math : vec3, vec2;
7 
8 struct Light {
9 
10     private const(aiLight)* light;
11 
12     string name() {
13         return light.mName.toRegularString;
14     }
15 
16     LightSourceType type() {
17         return light.mType.toEnum!LightSourceType;
18     }
19 
20     vec3 position() {
21         return light.mPosition.toSbylibVector;
22     }
23 
24     vec3 direction() {
25         return light.mDirection.toSbylibVector;
26     }
27 
28     vec3 up() {
29         return light.mUp.toSbylibVector;
30     }
31 
32     float attenuationConstant() {
33         return light.mAttenuationConstant;
34     }
35 
36     float attenuationLinear() {
37         return light.mAttenuationLinear;
38     }
39 
40     float attenuationQuadratic() {
41         return light.mAttenuationQuadratic;
42     }
43 
44     vec3 colorDiffuse() {
45         return light.mColorDiffuse.toSbylibVector;
46     }
47 
48     vec3 colorSpecular() {
49         return light.mColorSpecular.toSbylibVector;
50     }
51 
52     vec3 colorAmbient() {
53         return light.mColorAmbient.toSbylibVector;
54     }
55 
56     float angleInnerCone() {
57         return light.mAngleInnerCone;
58     }
59 
60     float angleOuterCone() {
61         return light.mAngleOuterCone;
62     }
63 
64     vec2 size() {
65         return light.mSize.toSbylibVector;
66     }
67 
68     string toString() {
69         import std.format : format;
70         import sbylib.wrapper.assimp.functions : tree;
71 
72         string[] strs;
73         strs ~= format!"type: %s"(type);
74         strs ~= format!"position: %s"(position);
75         strs ~= format!"direction: %s"(direction);
76         strs ~= format!"up: %s"(up);
77         strs ~= format!"attenuationConstant: %s"(attenuationConstant);
78         strs ~= format!"attenuationLinear: %s"(attenuationLinear);
79         strs ~= format!"attenuationQuadratic: %s"(attenuationQuadratic);
80         strs ~= format!"colorDiffuse: %s"(colorDiffuse);
81         strs ~= format!"colorSpecular: %s"(colorSpecular);
82         strs ~= format!"colorAmbient: %s"(colorAmbient);
83         strs ~= format!"angleInnerCone: %s"(angleInnerCone);
84         strs ~= format!"angleOuterCone: %s"(angleOuterCone);
85         strs ~= format!"size: %s"(size);
86 
87         return tree(format!"Light[%s]"(name), strs);
88     }
89 }