示例#1
0
        public virtual void Load(XmlElement xmlNode)
        {
            if (xmlNode.HasAttribute("DiffuseColor"))
            {
                diffuseColor = Vector4Helper.FromString(xmlNode.GetAttribute("DiffuseColor"));
            }
            if (xmlNode.HasAttribute("AmbientColor"))
            {
                ambientColor = Vector4Helper.FromString(xmlNode.GetAttribute("AmbientColor"));
            }
            if (xmlNode.HasAttribute("SpecularColor"))
            {
                specularColor = Vector4Helper.FromString(xmlNode.GetAttribute("SpecularColor"));
            }
            if (xmlNode.HasAttribute("SpecularPower"))
            {
                specularPower = float.Parse(xmlNode.GetAttribute("SpecularPower"));
            }
            if (xmlNode.HasAttribute("EmissiveColor"))
            {
                emissiveColor = Vector4Helper.FromString(xmlNode.GetAttribute("EmissiveColor"));
            }

            if (xmlNode.HasAttribute("TextureName"))
            {
                String textureName = xmlNode.GetAttribute("TextureName");
                texture = State.Content.Load <Texture2D>(textureName);
            }
        }
示例#2
0
        public override void Load(XmlElement xmlNode)
        {
            base.Load(xmlNode);

            if (xmlNode.HasAttribute("Readonly"))
            {
                isReadOnly = bool.Parse(xmlNode.GetAttribute("Readonly"));
            }
            if (xmlNode.HasAttribute("UseUserDefinedTransform"))
            {
                useUserDefinedTransform = bool.Parse(xmlNode.GetAttribute("UseUserDefinedTransform"));
            }

            if (useUserDefinedTransform)
            {
                if (xmlNode.HasAttribute("WorldTransform"))
                {
                    worldTransformation = MatrixHelper.FromString(xmlNode.GetAttribute("WorldTransform"));
                }
            }
            else
            {
                if (xmlNode.HasAttribute("PreTranslation"))
                {
                    preTranslation = Vector3Helper.FromString(xmlNode.GetAttribute("PreTranslation"));
                }
                if (xmlNode.HasAttribute("Scale"))
                {
                    scaling = Vector3Helper.FromString(xmlNode.GetAttribute("Scale"));
                }
                if (xmlNode.HasAttribute("PostTranslation"))
                {
                    postTranslation = Vector3Helper.FromString(xmlNode.GetAttribute("PostTranslation"));
                }
                if (xmlNode.HasAttribute("Rotation"))
                {
                    Vector4 vec4 = Vector4Helper.FromString(xmlNode.GetAttribute("Rotation"));
                    rotation = new Quaternion(vec4.X, vec4.Y, vec4.Z, vec4.W);
                }
            }
        }
示例#3
0
        public override void Load(XmlElement xmlNode)
        {
            base.Load(xmlNode);

            if (xmlNode.HasAttribute("Global"))
            {
                global = bool.Parse(xmlNode.GetAttribute("Global"));
            }
            if (xmlNode.HasAttribute("CastShadows"))
            {
                castShadows = bool.Parse(xmlNode.GetAttribute("CastShadows"));
            }
            if (xmlNode.HasAttribute("AmbientLightColor"))
            {
                ambientLightColor = Vector4Helper.FromString(xmlNode.GetAttribute("AmbientLightColor"));
            }

            XmlElement lightSourceXml = (XmlElement)xmlNode.ChildNodes[0];

            lightSource = (LightSource)Activator.CreateInstance(
                Type.GetType(lightSourceXml.Name));
            lightSource.Load(lightSourceXml);
        }
示例#4
0
 public virtual void Load(XmlElement xmlNode)
 {
     if (xmlNode.HasAttribute("Translation"))
     {
         translation = Vector3Helper.FromString(xmlNode.GetAttribute("Translation"));
     }
     if (xmlNode.HasAttribute("Rotation"))
     {
         Vector4 vec4 = Vector4Helper.FromString(xmlNode.GetAttribute("Rotation"));
         rotation = new Quaternion(vec4.X, vec4.Y, vec4.Z, vec4.W);
     }
     if (xmlNode.HasAttribute("FieldOfViewY"))
     {
         fieldOfView = float.Parse(xmlNode.GetAttribute("FieldOfViewY"));
     }
     if (xmlNode.HasAttribute("AspectRatio"))
     {
         aspectRatio = float.Parse(xmlNode.GetAttribute("AspectRatio"));
     }
     if (xmlNode.HasAttribute("ZNearPlane"))
     {
         zNearPlane = float.Parse(xmlNode.GetAttribute("ZNearPlane"));
     }
     if (xmlNode.HasAttribute("ZFarPlane"))
     {
         zFarPlane = float.Parse(xmlNode.GetAttribute("ZFarPlane"));
     }
     if (xmlNode.HasAttribute("ViewMatrix"))
     {
         view = MatrixHelper.FromString(xmlNode.GetAttribute("ViewMatrix"));
     }
     if (xmlNode.HasAttribute("ProjectionMatrix"))
     {
         projection = MatrixHelper.FromString(xmlNode.GetAttribute("ProjectionMatrix"));
     }
 }
示例#5
0
        public virtual void Load(XmlElement xmlNode)
        {
            if (xmlNode.HasAttribute("LightType"))
            {
                lightType = (LightType)Enum.Parse(typeof(LightType), xmlNode.GetAttribute("LightType"));
            }
            if (xmlNode.HasAttribute("Enabled"))
            {
                enabled = bool.Parse(xmlNode.GetAttribute("Enabled"));
            }
            if (xmlNode.HasAttribute("Diffuse"))
            {
                diffuse = Vector4Helper.FromString(xmlNode.GetAttribute("Diffuse"));
            }
            if (xmlNode.HasAttribute("Specular"))
            {
                specular = Vector4Helper.FromString(xmlNode.GetAttribute("Specular"));
            }

            if (lightType == LightType.Point)
            {
                if (xmlNode.HasAttribute("Position"))
                {
                    position = Vector3Helper.FromString(xmlNode.GetAttribute("Position"));
                }
                if (xmlNode.HasAttribute("Attenuation0"))
                {
                    attenuation0 = float.Parse(xmlNode.GetAttribute("Attenuation0"));
                }
                if (xmlNode.HasAttribute("Attenuation1"))
                {
                    attenuation1 = float.Parse(xmlNode.GetAttribute("Attenuation1"));
                }
                if (xmlNode.HasAttribute("Attenuation2"))
                {
                    attenuation2 = float.Parse(xmlNode.GetAttribute("Attenuation2"));
                }
                if (xmlNode.HasAttribute("Range"))
                {
                    range = float.Parse(xmlNode.GetAttribute("Range"));
                }
            }
            else if (lightType == LightType.Directional)
            {
                if (xmlNode.HasAttribute("Direction"))
                {
                    direction = Vector3Helper.FromString(xmlNode.GetAttribute("Direction"));
                }
            }
            else
            {
                if (xmlNode.HasAttribute("Position"))
                {
                    position = Vector3Helper.FromString(xmlNode.GetAttribute("Position"));
                }
                if (xmlNode.HasAttribute("Direction"))
                {
                    direction = Vector3Helper.FromString(xmlNode.GetAttribute("Direction"));
                }
                if (xmlNode.HasAttribute("Attenuation0"))
                {
                    attenuation0 = float.Parse(xmlNode.GetAttribute("Attenuation0"));
                }
                if (xmlNode.HasAttribute("Attenuation1"))
                {
                    attenuation1 = float.Parse(xmlNode.GetAttribute("Attenuation1"));
                }
                if (xmlNode.HasAttribute("Attenuation2"))
                {
                    attenuation2 = float.Parse(xmlNode.GetAttribute("Attenuation2"));
                }
                if (xmlNode.HasAttribute("Range"))
                {
                    range = float.Parse(xmlNode.GetAttribute("Range"));
                }
                if (xmlNode.HasAttribute("Falloff"))
                {
                    falloff = float.Parse(xmlNode.GetAttribute("Falloff"));
                }
                if (xmlNode.HasAttribute("InnerConeAngle"))
                {
                    innerConeAngle = float.Parse(xmlNode.GetAttribute("InnerConeAngle"));
                }
                if (xmlNode.HasAttribute("OuterConeAngle"))
                {
                    outerConeAngle = float.Parse(xmlNode.GetAttribute("OuterConeAngle"));
                }
            }
        }