source: OniSplit/Dae/Visitor.cs@ 1115

Last change on this file since 1115 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: 4.4 KB
RevLine 
[1114]1namespace Oni.Dae
2{
3 internal class Visitor
4 {
5 public virtual void VisitScene(Scene scene)
6 {
7 foreach (var node in scene.Nodes)
8 VisitNode(node);
9 }
10
11 public virtual void VisitNode(Node node)
12 {
13 foreach (var transform in node.Transforms)
14 VisitTransform(transform);
15
16 foreach (var instance in node.Instances)
17 {
18 if (instance is GeometryInstance)
19 VisitGeometryInstance((GeometryInstance)instance);
20 else if (instance is LightInstance)
21 VisitLightInstance((LightInstance)instance);
22 else if (instance is CameraInstance)
23 VisitCameraInstance((CameraInstance)instance);
24 }
25
26 foreach (var child in node.Nodes)
27 VisitNode(child);
28 }
29
30 public virtual void VisitGeometryInstance(GeometryInstance instance)
31 {
32 foreach (var materialInstance in instance.Materials)
33 VisitMaterialInstance(materialInstance);
34
35 VisitGeometry(instance.Target);
36 }
37
38 public virtual void VisitGeometry(Geometry geometry)
39 {
40 foreach (var input in geometry.Vertices)
41 VisitInput(input);
42
43 foreach (var primitives in geometry.Primitives)
44 VisitMeshPrimitives(primitives);
45 }
46
47 public virtual void VisitMeshPrimitives(MeshPrimitives primitives)
48 {
49 foreach (var input in primitives.Inputs)
50 VisitInput(input);
51 }
52
53 public virtual void VisitMaterialInstance(MaterialInstance instance)
54 {
55 VisitMaterial(instance.Target);
56 }
57
58 public virtual void VisitMaterial(Material material)
59 {
60 VisitEffect(material.Effect);
61 }
62
63 public virtual void VisitLightInstance(LightInstance instance)
64 {
65 VisitLight(instance.Target);
66 }
67
68 public virtual void VisitLight(Light light)
69 {
70 }
71
72 public virtual void VisitCameraInstance(CameraInstance instance)
73 {
74 VisitCamera(instance.Target);
75 }
76
77 public virtual void VisitCamera(Camera camera)
78 {
79 }
80
81 public virtual void VisitTransform(Transform transform)
82 {
83 if (transform.HasAnimations)
84 {
85 foreach (var sampler in transform.Animations.Where(s => s != null))
86 VisitSampler(sampler);
87 }
88 }
89
90 public virtual void VisitSampler(Sampler sampler)
91 {
92 foreach (var input in sampler.Inputs)
93 VisitInput(input);
94 }
95
96 public virtual void VisitEffect(Effect effect)
97 {
98 foreach (var parameter in effect.Parameters)
99 VisitEffectParameter(parameter);
100
101 VisitEffectParameter(effect.Ambient);
102 VisitEffectParameter(effect.Diffuse);
103 VisitEffectParameter(effect.Emission);
104 VisitEffectParameter(effect.IndexOfRefraction);
105 VisitEffectParameter(effect.Reflective);
106 VisitEffectParameter(effect.Shininess);
107 VisitEffectParameter(effect.Specular);
108 VisitEffectParameter(effect.Transparency);
109 VisitEffectParameter(effect.Transparent);
110 }
111
112 public virtual void VisitEffectParameter(EffectParameter parameter)
113 {
114 if (parameter.Value is EffectTexture)
115 VisitEffectTexture((EffectTexture)parameter.Value);
116 }
117
118 public virtual void VisitEffectTexture(EffectTexture texture)
119 {
120 VisitEffectSampler(texture.Sampler);
121 }
122
123 public virtual void VisitEffectSampler(EffectSampler sampler)
124 {
125 VisitEffectSurface(sampler.Surface);
126 }
127
128 public virtual void VisitEffectSurface(EffectSurface surface)
129 {
130 VisitImage(surface.InitFrom);
131 }
132
133 public virtual void VisitInput(Input input)
134 {
135 VisitSource(input.Source);
136 }
137
138 public virtual void VisitSource(Source source)
139 {
140 }
141
142 public virtual void VisitImage(Image image)
143 {
144 }
145 }
146}
Note: See TracBrowser for help on using the repository browser.