source: OniSplit/Dae/Effect.cs@ 1194

Last change on this file since 1194 was 1114, checked in by iritscen, 5 years ago

Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.

File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3
4namespace Oni.Dae
5{
6 internal class Effect : Entity
7 {
8 private readonly List<EffectParameter> parameters;
9 private readonly EffectParameter emission;
10 private readonly EffectParameter ambient;
11 private readonly EffectParameter diffuse;
12 private readonly EffectParameter specular;
13 private readonly EffectParameter shininess;
14 private readonly EffectParameter reflective;
15 private readonly EffectParameter reflectivity;
16 private readonly EffectParameter transparent;
17 private readonly EffectParameter transparency;
18 private readonly EffectParameter indexOfRefraction;
19
20 public Effect()
21 {
22 parameters = new List<EffectParameter>();
23
24 var alphaOne = new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
25
26 emission = new EffectParameter("emission", alphaOne, this);
27 ambient = new EffectParameter("ambient", alphaOne, this);
28 diffuse = new EffectParameter("diffuse", alphaOne, this);
29 specular = new EffectParameter("specular", alphaOne, this);
30 shininess = new EffectParameter("shininess", 20.0f, this);
31 reflective = new EffectParameter("reflective", 1.0f, this);
32 reflectivity = new EffectParameter("reflectivity", Vector4.One, this);
33 transparent = new EffectParameter("transparent", alphaOne, this);
34 transparency = new EffectParameter("transparency", 1.0f, this);
35 indexOfRefraction = new EffectParameter("index_of_refraction", 1.0f, this);
36 }
37
38 public EffectType Type { get; set; }
39
40 public List<EffectParameter> Parameters => parameters;
41
42 public IEnumerable<EffectTexture> Textures
43 {
44 get
45 {
46 foreach (var param in new[] { diffuse, ambient, specular, reflective, transparent, emission })
47 {
48 var texture = param.Value as EffectTexture;
49
50 if (texture != null)
51 yield return texture;
52 }
53 }
54 }
55
56 public EffectParameter Emission => emission;
57
58 public EffectParameter Ambient => ambient;
59
60 public object AmbientValue
61 {
62 get { return ambient.Value; }
63 set { ambient.Value = value; }
64 }
65
66 public EffectParameter Diffuse => diffuse;
67
68 public object DiffuseValue
69 {
70 get { return diffuse.Value; }
71 set { diffuse.Value = value; }
72 }
73
74 public EffectParameter Specular => specular;
75
76 public object SpecularValue
77 {
78 get { return specular.Value; }
79 set { specular.Value = value; }
80 }
81
82 public EffectParameter Shininess => shininess;
83
84 public EffectParameter Reflective => reflective;
85
86 public EffectParameter Reflectivity => reflectivity;
87
88 public EffectParameter Transparent => transparent;
89
90 public object TransparentValue
91 {
92 get { return transparent.Value; }
93 set { transparent.Value = value; }
94 }
95
96 public EffectParameter Transparency => transparency;
97
98 public EffectParameter IndexOfRefraction => indexOfRefraction;
99 }
100}
Note: See TracBrowser for help on using the repository browser.