Exemplo n.º 1
0
 public static Light CreateLightFromElement(this RElement ele, int ns)
 {
     bool shad = getShadow(ele);
     float rad = ele.Attributes[P.Radi].ToFloat();
     string n = ele.Name;
     if (n == P.Lights.Amb)
     {
         Ambient amb = new Ambient();
         amb.RadianceScale = rad;
         amb.Color = ele.Attributes[P.Col].ToVector3();
         amb.Shadows = shad;
         return amb;
     }
     else if (n == P.Lights.AmbOcc)
     {
         AmbientOccluder amb = new AmbientOccluder();
         amb.SetSampler(ele.Attributes[P.Sampler].CreateSamplerFromAttribute(ns));
         amb.RadianceScale = rad;
         amb.Color = ele.Attributes[P.Col].ToVector3();
         amb.Shadows = shad;
         return amb;
     }
     else if (n == P.Lights.PL)
     {
         PointLight pl = new PointLight();
         pl.Position = ele.Attributes[P.Pos].ToVector3();
         pl.RadianceScale = rad;
         pl.Color = ele.Attributes[P.Col].ToVector3();
         pl.Shadows = shad;
         return pl;
     }
     else if (n == P.Lights.Direc)
     {
         Directional d = new Directional();
         d.Direction = ele.Attributes[P.Dir].ToVector3();
         d.RadianceScale = rad;
         d.Color = ele.Attributes[P.Col].ToVector3();
         d.Shadows = shad;
         return d;
     }
     else if (n == P.Lights.AL)
     {
         AreaLight al = new AreaLight();
         al.SetObject(GeometricObject.GetObject(ele.Attributes[P.Name].Value));
         al.Shadows = shad;
         return al;
     }
     throw new Exception();
 }