예제 #1
0
        /// <summary>
        /// Exports the light.
        /// </summary>
        /// <param name="light">
        /// The light.
        /// </param>
        /// <param name="inheritedTransform">
        /// The inherited transform.
        /// </param>
        protected override void ExportLight(Light light, Transform3D inheritedTransform)
        {
            base.ExportLight(light, inheritedTransform);

            // todo...
            // http://www.povray.org/documentation/view/3.6.1/34/
        }
 public Vieport3DExt()
     : base()
 {
     _kaleidoscopes = new KaleidoscopeFactory<Node3D, Geometry3D, Transformation3D>();
     _light = new AmbientLight(Colors.White);
     SizeChanged += OnSizeChanged;
     DataContextChanged += OnDataContextChanged;
     _camera = new PerspectiveCamera()
     {
         Position= new Point3D(0, 0, 1067),
         LookDirection = new Vector3D(0, 0, -40),
         UpDirection = new Vector3D(0, -1, 0)
     };
     Camera = _camera;
 }
예제 #3
0
        private static Tuple<LightStrength, double> CalculateLighting(IGeometry[] spheres, Vector3D directionToEye, Vector3D surfaceNormal, Material sphere, Vector3D intersectionPoint, Light light)
        {
            var directionToLight = light.CenterPoint - intersectionPoint;
            directionToLight.Normalize();
            var lightT = (light.CenterPoint.X - intersectionPoint.X)/directionToLight.X;
            var blocked = spheres.Any(s => ObscuresLight(s, intersectionPoint, directionToLight, lightT));
            if (blocked)
            {
                return Tuple.Create(LightStrength.Zero,0.0);
            }

            var ldotn = Math.Max(0.0,Vector3D.DotProduct(surfaceNormal, directionToLight));
            var diffuse = light.Brightness*ldotn;
            var H = directionToLight + directionToEye;
            H.Normalize();
            var ndoth = Math.Max(0.0,Vector3D.DotProduct(surfaceNormal, H));
            var specular = Math.Pow(ndoth, sphere.Shinyness);
            return Tuple.Create(diffuse, specular);
        }
        /// <summary>
        /// Exports the light.
        /// </summary>
        /// <param name="light">
        /// The light.
        /// </param>
        /// <param name="inheritedTransform">
        /// The inherited transform.
        /// </param>
        protected override void ExportLight(Light light, Transform3D inheritedTransform)
        {
            base.ExportLight(light, inheritedTransform);

            // todo...
        }
예제 #5
0
        /// <summary>
        /// Exports the light.
        /// </summary>
        /// <param name="l">
        /// The l.
        /// </param>
        /// <param name="t">
        /// The t.
        /// </param>
        protected override void ExportLight(Light l, Transform3D t)
        {
            if (l is AmbientLight)
            {
                return;
            }

            string name = this.GetUniqueName(l, l.GetType().Name);

            var d = l as DirectionalLight;
            var s = l as SpotLight;
            var p = l as PointLight;

            this.WriteStartObject("./Lights/" + name, "Default Light", name, "Light");
            {
                string stype = "Projector Light";
                if (s != null)
                {
                    stype = "Spot Light";
                }

                if (p != null)
                {
                    stype = "Omni Light";
                }

                this.WriteStartObject(stype, stype, string.Empty, "Emittance");

                // emitter Radiance
                this.WriteStartObject("./Radiance/Constant Texture", "Constant Texture", string.Empty, "Texture");
                var c = Colors.White;
                WriteParameter("Color", c);
                this.WriteEndObject();

                // var v = new Vector3D(l.Color.R, l.Color.G, l.Color.B);
                // double lum = v.Length;
                this.WriteParameter("Attenuation", "None");

                // SpotLight (Spot Light)
                if (s != null)
                {
                    // todo : export the specular parameters
                    // s.ConstantAttenuation
                    // s.LinearAttenuation
                    // s.QuadraticAttenuation
                    WriteParameter("Fall Off", s.OuterConeAngle);
                    WriteParameter("Hot Spot", s.InnerConeAngle);
                }

                // DirectionalLight (Projector Light)
                if (d != null)
                {
                    this.WriteParameter("Width", 2.0);
                    this.WriteParameter("Height", 2.0);
                }

                // PointLight (Omni light)
                if (p != null)
                {
                    // todo: export pointlight parameters
                    // p.ConstantAttenuation
                    // p.LinearAttenuation
                    // p.QuadraticAttenuation
                    // p.Range // distance beyond which the light has no effect
                }

                this.WriteParameter("Focal Length", 1.0);

                this.WriteEndObject(); // stype

                this.WriteParameter("Enabled", true);
                this.WriteParameter("Shadow", this.Shadows);
                this.WriteParameter("Soft Shadow", this.SoftShadows);

                this.WriteParameter("Negative Light", false);
                this.WriteParameter("Global Photons", true);
                this.WriteParameter("Caustic Photons", true);
                this.WriteParameter("Multiplier", this.LightMultiplier);

                Matrix3D transform;
                var upVector = new Vector3D(0, 0, 1);
                if (s != null)
                {
                    transform = CreateTransform(s.Position, s.Direction, upVector);
                    this.WriteTransform("Frame", transform);
                }

                if (d != null)
                {
                    var origin = new Point3D(-1000 * d.Direction.X, -1000 * d.Direction.Y, -1000 * d.Direction.Z);
                    transform = CreateTransform(origin, d.Direction, upVector);
                    this.WriteTransform("Frame", transform);
                }

                if (p != null)
                {
                    var direction = new Vector3D(-p.Position.X, -p.Position.Y, -p.Position.Z);
                    transform = CreateTransform(p.Position, direction, upVector);
                    this.WriteTransform("Frame", transform);
                }

                this.WriteParameter("Focus Distance", 4.0);
                this.WriteParameter("Radius", 0.2);
                this.WriteParameter("Shadow Color", this.ShadowColor);
            }

            this.WriteEndObject();
        }
예제 #6
0
 /// <summary>
 /// Exports the light.
 /// </summary>
 /// <param name="light">
 /// The light.
 /// </param>
 /// <param name="inheritedTransform">
 /// The inherited transform.
 /// </param>
 protected virtual void ExportLight(Light light, Transform3D inheritedTransform)
 {
 }
예제 #7
0
        /// <summary>
        /// The export light.
        /// </summary>
        /// <param name="light">
        /// The light.
        /// </param>
        private void ExportLight(Light light)
        {
            if (light == null || this.lights.ContainsKey(light))
            {
                return;
            }

            string id = "light_" + this.lights.Count;
            this.lights.Add(light, id);
            this.writer.WriteStartElement("light");
            this.writer.WriteAttributeString("id", id);
            this.writer.WriteAttributeString("name", id);
            this.writer.WriteStartElement("technique_common");

            var al = light as AmbientLight;
            if (al != null)
            {
                this.writer.WriteStartElement("ambient");
                this.WriteColor(al.Color);
                this.writer.WriteEndElement();
            }

            var dl = light as DirectionalLight;
            if (dl != null)
            {
                this.writer.WriteStartElement("directional");
                this.WriteColor(dl.Color);
                this.writer.WriteEndElement();
            }

            var pl = light as PointLight;
            if (pl != null)
            {
                this.writer.WriteStartElement("point");
                this.WriteColor(pl.Color);
                this.WriteDouble("constant_attenuation", pl.ConstantAttenuation);
                this.WriteDouble("linear_attenuation", pl.LinearAttenuation);
                this.WriteDouble("quadratic_attenuation", pl.QuadraticAttenuation);
                this.writer.WriteEndElement();
            }

            var sl = light as SpotLight;
            if (sl != null)
            {
                this.writer.WriteStartElement("spot");
                this.WriteColor(sl.Color);
                this.WriteDouble("constant_attenuation", sl.ConstantAttenuation);
                this.WriteDouble("linear_attenuation", sl.LinearAttenuation);
                this.WriteDouble("quadratic_attenuation", sl.QuadraticAttenuation);
                this.WriteDouble("falloff_angle", sl.InnerConeAngle);

                // writer.WriteElementString("falloff_exponent",sl.xxx.ToString(CultureInfo.InvariantCulture));
                this.writer.WriteEndElement();
            }

            this.writer.WriteEndElement(); // technique_common
            this.writer.WriteEndElement(); // light
        }
예제 #8
0
파일: 3DView.cs 프로젝트: litdev1/LitDev
 public Lighting(string _name, Light _light)
 {
     name = _name;
     light = _light;
 }
예제 #9
0
 public Lamp(Light light)
 {
     Content = light;
 }