예제 #1
0
        public static Filter MakeFilter(string name, ParamSet parameters)
        {
            switch (name)
            {
            case "mitchell":
            {
                var xWidth = parameters.FindSingle("xwidth", 2.0f);
                var yWidth = parameters.FindSingle("ywidth", 2.0f);
                var b      = parameters.FindSingle("B", 1.0f / 3.0f);
                var c      = parameters.FindSingle("C", 1.0f / 3.0f);
                return(new MitchellFilter(xWidth, yWidth, b, c));
            }

            default:
                throw new ArgumentException("Unknown filter: " + name);
            }
        }
예제 #2
0
        public static Camera MakeCamera(string name, ParamSet parameters,
            TransformSet cameraToWorldSet, float transformStart, float transformEnd,
            Film film)
        {
            var animatedCameraToWorld = new AnimatedTransform(
                cameraToWorldSet[0], transformStart,
                cameraToWorldSet[1], transformEnd);

            switch (name)
            {
                case "perspective" :
                {
                    var shutterOpen = parameters.FindSingle("shutteropen", 0.0f);
                    var shutterClose = parameters.FindSingle("shutterclose", 1.0f);
                    if (shutterOpen < shutterClose)
                        MathUtility.Swap(ref shutterOpen, ref shutterClose);
                    var lensRadius = parameters.FindSingle("lensradius", 0.0f);
                    var focalDistance = parameters.FindSingle("focaldistance", 1e30f);
                    var frame = parameters.FindSingle("frameaspectratio", film.XResolution / (float) film.YResolution);
                    var screenWindow = parameters.FindSingleList("screenwindow");
                    if (screenWindow.Length != 4)
                        screenWindow = (frame > 1.0f)
                            ? new[] { -frame, frame, -1, 1 }
                            : new[] { -1, 1, -1 / frame, 1 / frame };
                    var fieldOfView = parameters.FindSingle("fov", 90.0f);

                    return new PerspectiveCamera(animatedCameraToWorld, screenWindow, shutterOpen, shutterClose,
                        lensRadius, focalDistance, fieldOfView, film);
                }
                default :
                    throw new ArgumentException("Unknown camera: " + name);
            }
        }
예제 #3
0
        public static VolumeIntegrator MakeVolumeIntegrator(string name, ParamSet parameters)
        {
            switch (name)
            {
            case "emission":
            {
                var stepSize = parameters.FindSingle("stepsize", 1.0f);
                return(new EmissionIntegrator(stepSize));
            }

            default:
                throw new ArgumentException("Unknown volume integrator: " + name);
            }
        }
예제 #4
0
        public Texture <float> GetFloatTexture(string n, float defaultValue)
        {
            var name = _geomParams.FindTexture(n);

            if (string.IsNullOrEmpty(name))
            {
                name = _materialParams.FindTexture(n);
            }

            if (!string.IsNullOrEmpty(name))
            {
                if (_floatTextures.ContainsKey(name))
                {
                    return(_floatTextures[name]);
                }
                throw new InvalidOperationException(string.Format("Couldn't find float texture named '{0}' for parameter '{1}'", name, n));
            }
            var value = _geomParams.FindSingle(n, _materialParams.FindSingle(n, defaultValue));

            return(new ConstantTexture <float>(value));
        }
예제 #5
0
        public static Camera MakeCamera(string name, ParamSet parameters,
                                        TransformSet cameraToWorldSet, float transformStart, float transformEnd,
                                        Film film)
        {
            var animatedCameraToWorld = new AnimatedTransform(
                cameraToWorldSet[0], transformStart,
                cameraToWorldSet[1], transformEnd);

            switch (name)
            {
            case "perspective":
            {
                var shutterOpen  = parameters.FindSingle("shutteropen", 0.0f);
                var shutterClose = parameters.FindSingle("shutterclose", 1.0f);
                if (shutterOpen < shutterClose)
                {
                    MathUtility.Swap(ref shutterOpen, ref shutterClose);
                }
                var lensRadius    = parameters.FindSingle("lensradius", 0.0f);
                var focalDistance = parameters.FindSingle("focaldistance", 1e30f);
                var frame         = parameters.FindSingle("frameaspectratio", film.XResolution / (float)film.YResolution);
                var screenWindow  = parameters.FindSingleList("screenwindow");
                if (screenWindow.Length != 4)
                {
                    screenWindow = (frame > 1.0f)
                            ? new[] { -frame, frame, -1, 1 }
                }
                : new[] { -1, 1, -1 / frame, 1 / frame };
                var fieldOfView = parameters.FindSingle("fov", 90.0f);

                return(new PerspectiveCamera(animatedCameraToWorld, screenWindow, shutterOpen, shutterClose,
                                             lensRadius, focalDistance, fieldOfView, film));
            }

            default:
                throw new ArgumentException("Unknown camera: " + name);
            }
        }
예제 #6
0
 public static VolumeIntegrator MakeVolumeIntegrator(string name, ParamSet parameters)
 {
     switch (name)
     {
         case "emission":
             {
                 var stepSize = parameters.FindSingle("stepsize", 1.0f);
                 return new EmissionIntegrator(stepSize);
             }
         default:
             throw new ArgumentException("Unknown volume integrator: " + name);
     }
 }
예제 #7
0
 public static Shape MakeShape(string name, Transform objectToWorld, 
     bool reverseOrientation, ParamSet parameters)
 {
     switch (name)
     {
         case "cylinder":
             {
                 var radius = parameters.FindSingle("radius", 1.0f);
                 var zMin = parameters.FindSingle("zmin", -1);
                 var zMax = parameters.FindSingle("zmax", 1);
                 var phiMax = parameters.FindSingle("phimax", 360.0f);
                 return new Cylinder(objectToWorld, reverseOrientation,
                     radius, zMin, zMax, phiMax);
             }
         case "disk" :
         {
             var height = parameters.FindSingle("height", 0.0f);
             var radius = parameters.FindSingle("radius", 1.0f);
             var innerRadius = parameters.FindSingle("innerradius", 0.0f);
             var phiMax = parameters.FindSingle("phimax", 360.0f);
             return new Disk(objectToWorld, reverseOrientation,
                 height, radius, innerRadius, phiMax);
         }
         case "sphere":
         {
             var radius = parameters.FindSingle("radius", 1.0f);
             var zMin = parameters.FindSingle("zmin", -radius);
             var zMax = parameters.FindSingle("zmax", radius);
             var phiMax = parameters.FindSingle("phimax", 360.0f);
             return new Sphere(objectToWorld, reverseOrientation, radius,
                 zMin, zMax, phiMax);
         }
         default:
             throw new ArgumentException("Unknown shape: " + name);
     }
 }
예제 #8
0
 public static Filter MakeFilter(string name, ParamSet parameters)
 {
     switch (name)
     {
         case "mitchell" :
         {
             var xWidth = parameters.FindSingle("xwidth", 2.0f);
             var yWidth = parameters.FindSingle("ywidth", 2.0f);
             var b = parameters.FindSingle("B", 1.0f / 3.0f);
             var c = parameters.FindSingle("C", 1.0f / 3.0f);
             return new MitchellFilter(xWidth, yWidth, b, c);
         }
         default :
             throw new ArgumentException("Unknown filter: " + name);
     }
 }
예제 #9
0
        public static Shape MakeShape(string name, Transform objectToWorld,
                                      bool reverseOrientation, ParamSet parameters)
        {
            switch (name)
            {
            case "cylinder":
            {
                var radius = parameters.FindSingle("radius", 1.0f);
                var zMin   = parameters.FindSingle("zmin", -1);
                var zMax   = parameters.FindSingle("zmax", 1);
                var phiMax = parameters.FindSingle("phimax", 360.0f);
                return(new Cylinder(objectToWorld, reverseOrientation,
                                    radius, zMin, zMax, phiMax));
            }

            case "disk":
            {
                var height      = parameters.FindSingle("height", 0.0f);
                var radius      = parameters.FindSingle("radius", 1.0f);
                var innerRadius = parameters.FindSingle("innerradius", 0.0f);
                var phiMax      = parameters.FindSingle("phimax", 360.0f);
                return(new Disk(objectToWorld, reverseOrientation,
                                height, radius, innerRadius, phiMax));
            }

            case "sphere":
            {
                var radius = parameters.FindSingle("radius", 1.0f);
                var zMin   = parameters.FindSingle("zmin", -radius);
                var zMax   = parameters.FindSingle("zmax", radius);
                var phiMax = parameters.FindSingle("phimax", 360.0f);
                return(new Sphere(objectToWorld, reverseOrientation, radius,
                                  zMin, zMax, phiMax));
            }

            default:
                throw new ArgumentException("Unknown shape: " + name);
            }
        }
예제 #10
0
 public float FindSingle(string name, float defaultValue)
 {
     return(_geomParams.FindSingle(name, defaultValue));
 }