//public virtual bool castsShadows() { return _castsShadows; } //public virtual void setShadow(bool shad) { _castsShadows = shad; } //public RGBColor getColor() { return _color; } //public void setColor(RGBColor c) { _color = new RGBColor(c); } public static Light LoadLight(XmlElement lightRoot) { //Determine light type... Light toReturn; string light_type = lightRoot.GetAttribute("type"); //...and defer loading task to correct loader. if (light_type.Equals("point")) { toReturn = PointLight.LoadPointLight(lightRoot); } else if (light_type.Equals("directional")) { toReturn = DirectionalLight.LoadDirectionalLight(lightRoot); } else { toReturn = new PointLight(); Console.WriteLine("Unknown light type " + light_type + ", treating as point light"); } //Load attributes common to all lights string node_shadow = lightRoot.GetAttribute("shadow"); if (!node_shadow.Equals("")) { toReturn.CastsShadows = Convert.ToBoolean(node_shadow); } XmlNode node_color = lightRoot.SelectSingleNode("color"); if (node_color != null) { string str_color = ((XmlText)node_color.FirstChild).Data; RGBColor color = new RGBColor(System.Drawing.ColorTranslator.FromHtml(str_color)); //if (color.r != null) //{ toReturn.Color = color; //} } return toReturn; }
public static PointLight LoadPointLight(XmlElement lightRoot) { PointLight toReturn = new PointLight(); //Load all provided attributes unique to point lights XmlNode node_point = lightRoot.SelectSingleNode("point"); if (node_point != null) { string str_point = ((XmlText)node_point.FirstChild).Data; Point3D point = Point3D.FromCsv(str_point); //if (point != 0) //{ toReturn.Location = point; //} } XmlNode node_int = lightRoot.SelectSingleNode("intensity"); if (node_int != null) { string str_int = ((XmlText)node_int.FirstChild).Data; float intensity = Convert.ToSingle(str_int); toReturn.Intensity = intensity; } return toReturn; }