Skip to content

Commit 1135728

Browse files
authored
Merge pull request #130 from Yellow-Dog-Man/frooxius/feat/spherical-harmonics
Added support for spherical harmonics types
2 parents 7f92dba + 8c87f52 commit 1135728

3 files changed

Lines changed: 316 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.Text.Json.Serialization;
5+
6+
namespace ResoniteLink
7+
{
8+
public class Field_SH_L1 : Field
9+
{
10+
[JsonPropertyName("value")]
11+
public SphericalHarmonicsL1 Value { get; set; }
12+
13+
[JsonIgnore]
14+
public override object BoxedValue { get => Value; set => Value = (SphericalHarmonicsL1)value; }
15+
[JsonIgnore]
16+
public override Type ValueType => typeof(SphericalHarmonicsL1);
17+
}
18+
19+
public class Field_SH_L2 : Field
20+
{
21+
[JsonPropertyName("value")]
22+
public SphericalHarmonicsL2 Value { get; set; }
23+
24+
[JsonIgnore]
25+
public override object BoxedValue { get => Value; set => Value = (SphericalHarmonicsL2)value; }
26+
[JsonIgnore]
27+
public override Type ValueType => typeof(SphericalHarmonicsL2);
28+
}
29+
30+
public class Field_SH_L3 : Field
31+
{
32+
[JsonPropertyName("value")]
33+
public SphericalHarmonicsL3 Value { get; set; }
34+
35+
[JsonIgnore]
36+
public override object BoxedValue { get => Value; set => Value = (SphericalHarmonicsL3)value; }
37+
[JsonIgnore]
38+
public override Type ValueType => typeof(SphericalHarmonicsL3);
39+
}
40+
41+
public class Field_SH_L4 : Field
42+
{
43+
[JsonPropertyName("value")]
44+
public SphericalHarmonicsL4 Value { get; set; }
45+
46+
[JsonIgnore]
47+
public override object BoxedValue { get => Value; set => Value = (SphericalHarmonicsL4)value; }
48+
[JsonIgnore]
49+
public override Type ValueType => typeof(SphericalHarmonicsL4);
50+
}
51+
52+
[JsonDerivedType(typeof(Field_SH_L1), "sh_l1")]
53+
[JsonDerivedType(typeof(Field_SH_L2), "sh_l2")]
54+
[JsonDerivedType(typeof(Field_SH_L3), "sh_l3")]
55+
[JsonDerivedType(typeof(Field_SH_L4), "sh_l4")]
56+
public partial class Member { }
57+
}
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.Text.Json.Serialization;
5+
6+
// Representation of spherical harmonics values
7+
// This is a bit more complicated from other types, because spherical harmonics in FrooxEngine are generic types
8+
// This means that the types of the coefficients can be a number of different types - potentially even other
9+
// spherical harmonic types and other generic nested types.
10+
// That's why these are represted as "Data" elements
11+
// Special care should be taken with these - all Data elements MUST be of same type
12+
// The Data elements also MUST be a type that is supported by FrooxEngine - typically any primitives that support multiplication & scaling
13+
14+
namespace ResoniteLink
15+
{
16+
/// <summary>
17+
/// First order spherical harmonic
18+
/// </summary>
19+
public class SphericalHarmonicsL1
20+
{
21+
[JsonPropertyName("sh0")]
22+
public Data SH0 { get; set; }
23+
24+
[JsonPropertyName("sh1")]
25+
public Data SH1 { get; set; }
26+
27+
[JsonPropertyName("sh2")]
28+
public Data SH2 { get; set; }
29+
30+
[JsonPropertyName("sh3")]
31+
public Data SH3 { get; set; }
32+
}
33+
34+
/// <summary>
35+
/// Second order spherical harmonic
36+
/// </summary>
37+
public class SphericalHarmonicsL2
38+
{
39+
[JsonPropertyName("sh0")]
40+
public Data SH0 { get; set; }
41+
42+
[JsonPropertyName("sh1")]
43+
public Data SH1 { get; set; }
44+
45+
[JsonPropertyName("sh2")]
46+
public Data SH2 { get; set; }
47+
48+
[JsonPropertyName("sh3")]
49+
public Data SH3 { get; set; }
50+
51+
[JsonPropertyName("sh4")]
52+
public Data SH4 { get; set; }
53+
54+
[JsonPropertyName("sh5")]
55+
public Data SH5 { get; set; }
56+
57+
[JsonPropertyName("sh6")]
58+
public Data SH6 { get; set; }
59+
60+
[JsonPropertyName("sh7")]
61+
public Data SH7 { get; set; }
62+
63+
[JsonPropertyName("sh8")]
64+
public Data SH8 { get; set; }
65+
}
66+
67+
/// <summary>
68+
/// Third order spherical harmonic
69+
/// </summary>
70+
public class SphericalHarmonicsL3
71+
{
72+
[JsonPropertyName("sh0")]
73+
public Data SH0 { get; set; }
74+
75+
[JsonPropertyName("sh1")]
76+
public Data SH1 { get; set; }
77+
78+
[JsonPropertyName("sh2")]
79+
public Data SH2 { get; set; }
80+
81+
[JsonPropertyName("sh3")]
82+
public Data SH3 { get; set; }
83+
84+
[JsonPropertyName("sh4")]
85+
public Data SH4 { get; set; }
86+
87+
[JsonPropertyName("sh5")]
88+
public Data SH5 { get; set; }
89+
90+
[JsonPropertyName("sh6")]
91+
public Data SH6 { get; set; }
92+
93+
[JsonPropertyName("sh7")]
94+
public Data SH7 { get; set; }
95+
96+
[JsonPropertyName("sh8")]
97+
public Data SH8 { get; set; }
98+
99+
[JsonPropertyName("sh9")]
100+
public Data SH9 { get; set; }
101+
102+
[JsonPropertyName("sh10")]
103+
public Data SH10 { get; set; }
104+
105+
[JsonPropertyName("sh11")]
106+
public Data SH11 { get; set; }
107+
108+
[JsonPropertyName("sh12")]
109+
public Data SH12 { get; set; }
110+
111+
[JsonPropertyName("sh13")]
112+
public Data SH13 { get; set; }
113+
114+
[JsonPropertyName("sh14")]
115+
public Data SH14 { get; set; }
116+
117+
[JsonPropertyName("sh15")]
118+
public Data SH15 { get; set; }
119+
}
120+
121+
122+
/// <summary>
123+
/// Fourth order spherical harmonic
124+
/// </summary>
125+
public class SphericalHarmonicsL4
126+
{
127+
[JsonPropertyName("sh0")]
128+
public Data SH0 { get; set; }
129+
130+
[JsonPropertyName("sh1")]
131+
public Data SH1 { get; set; }
132+
133+
[JsonPropertyName("sh2")]
134+
public Data SH2 { get; set; }
135+
136+
[JsonPropertyName("sh3")]
137+
public Data SH3 { get; set; }
138+
139+
[JsonPropertyName("sh4")]
140+
public Data SH4 { get; set; }
141+
142+
[JsonPropertyName("sh5")]
143+
public Data SH5 { get; set; }
144+
145+
[JsonPropertyName("sh6")]
146+
public Data SH6 { get; set; }
147+
148+
[JsonPropertyName("sh7")]
149+
public Data SH7 { get; set; }
150+
151+
[JsonPropertyName("sh8")]
152+
public Data SH8 { get; set; }
153+
154+
[JsonPropertyName("sh9")]
155+
public Data SH9 { get; set; }
156+
157+
[JsonPropertyName("sh10")]
158+
public Data SH10 { get; set; }
159+
160+
[JsonPropertyName("sh11")]
161+
public Data SH11 { get; set; }
162+
163+
[JsonPropertyName("sh12")]
164+
public Data SH12 { get; set; }
165+
166+
[JsonPropertyName("sh13")]
167+
public Data SH13 { get; set; }
168+
169+
[JsonPropertyName("sh14")]
170+
public Data SH14 { get; set; }
171+
172+
[JsonPropertyName("sh15")]
173+
public Data SH15 { get; set; }
174+
175+
[JsonPropertyName("sh16")]
176+
public Data SH16 { get; set; }
177+
178+
[JsonPropertyName("sh17")]
179+
public Data SH17 { get; set; }
180+
181+
[JsonPropertyName("sh18")]
182+
public Data SH18 { get; set; }
183+
184+
[JsonPropertyName("sh19")]
185+
public Data SH19 { get; set; }
186+
187+
[JsonPropertyName("sh20")]
188+
public Data SH20 { get; set; }
189+
190+
[JsonPropertyName("sh21")]
191+
public Data SH21 { get; set; }
192+
193+
[JsonPropertyName("sh22")]
194+
public Data SH22 { get; set; }
195+
196+
[JsonPropertyName("sh23")]
197+
public Data SH23 { get; set; }
198+
199+
[JsonPropertyName("sh24")]
200+
public Data SH24 { get; set; }
201+
}
202+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.Text.Json.Serialization;
5+
6+
namespace ResoniteLink
7+
{
8+
public class Data_SH_L1 : DataValue
9+
{
10+
[JsonPropertyName("value")]
11+
public SphericalHarmonicsL1 Value { get; set; }
12+
13+
[JsonIgnore]
14+
public override object BoxedValue { get => Value; set => Value = (SphericalHarmonicsL1)value; }
15+
[JsonIgnore]
16+
public override Type ValueType => typeof(SphericalHarmonicsL1);
17+
}
18+
19+
public class Data_SH_L2 : DataValue
20+
{
21+
[JsonPropertyName("value")]
22+
public SphericalHarmonicsL2 Value { get; set; }
23+
24+
[JsonIgnore]
25+
public override object BoxedValue { get => Value; set => Value = (SphericalHarmonicsL2)value; }
26+
[JsonIgnore]
27+
public override Type ValueType => typeof(SphericalHarmonicsL2);
28+
}
29+
30+
public class Data_SH_L3 : DataValue
31+
{
32+
[JsonPropertyName("value")]
33+
public SphericalHarmonicsL3 Value { get; set; }
34+
35+
[JsonIgnore]
36+
public override object BoxedValue { get => Value; set => Value = (SphericalHarmonicsL3)value; }
37+
[JsonIgnore]
38+
public override Type ValueType => typeof(SphericalHarmonicsL3);
39+
}
40+
41+
public class Data_SH_L4 : DataValue
42+
{
43+
[JsonPropertyName("value")]
44+
public SphericalHarmonicsL4 Value { get; set; }
45+
46+
[JsonIgnore]
47+
public override object BoxedValue { get => Value; set => Value = (SphericalHarmonicsL4)value; }
48+
[JsonIgnore]
49+
public override Type ValueType => typeof(SphericalHarmonicsL4);
50+
}
51+
52+
[JsonDerivedType(typeof(Data_SH_L1), "sh_l1")]
53+
[JsonDerivedType(typeof(Data_SH_L2), "sh_l2")]
54+
[JsonDerivedType(typeof(Data_SH_L3), "sh_l3")]
55+
[JsonDerivedType(typeof(Data_SH_L4), "sh_l4")]
56+
public partial class Data { }
57+
}

0 commit comments

Comments
 (0)