示例#1
0
        public override Scene CreateScene(Film film)
        {
            var camera = new PerspectiveCamera(film,
                1.0f, 100.0f, Vector3D.Forward, Vector3D.Up,
                new Point3D(0, 0, 15), MathUtility.PI_OVER_4);

            var surfaceIntegrator = new WhittedIntegrator(6);

            var sampler = new RegularSampler(
                new IntPoint2D(0, 0),
                new IntPoint2D(film.XRes, film.YRes));

            var shape = new Aether.Shapes.Sphere(new TranslateTransform(), 5);
            var material = new MatteMaterial(ColorsF.Red);
            var primitive = new GeometricPrimitive(shape, material);

            var lights = new List<Light>
            {
//                new PointLight(
//                    new TranslateTransform { OffsetX = 10, OffsetY = 10, OffsetZ = 10},
//                    new ColorF(0.5f))
                new DirectionalLight(new RotateTransform3D(), Vector3D.Down, new ColorF(0.5f))
            };

            return new Scene(camera, surfaceIntegrator, sampler, primitive,
                             lights);
        }
示例#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
 protected Camera(AnimatedTransform cameraToWorld,
     float shutterOpen, float shutterClose,
     Film film)
 {
     _cameraToWorld = cameraToWorld;
     _shutterOpen = shutterOpen;
     _shutterClose = shutterClose;
     _film = film;
 }
示例#4
0
 public PerspectiveCamera(
     AnimatedTransform cameraToWorld, float[] screenWindow, 
     float shutterOpen, float shutterClose, 
     float lensRadius, float focalDistance, 
     float fieldOfView,
     Film film)
     : base(cameraToWorld, Transform.Perspective(fieldOfView, 1e-2f, 1000.0f), screenWindow, shutterOpen, shutterClose, lensRadius, focalDistance, film)
 {
     // Compute differential changes in origin for perspective camera rays
     _dxCamera = RasterToCamera.TransformPoint(new Point(1, 0, 0)) - RasterToCamera.TransformPoint(new Point(0, 0, 0));
     _dyCamera = RasterToCamera.TransformPoint(new Point(0, 1, 0)) - RasterToCamera.TransformPoint(new Point(0, 0, 0));
 }
示例#5
0
        protected ProjectiveCamera(AnimatedTransform cameraToWorld, Transform cameraToScreen,
            float[] screenWindow, float shutterOpen, float shutterClose,
            float lensRadius, float focalDistance, Film film)
            : base(cameraToWorld, shutterOpen, shutterClose, film)
        {
            _cameraToScreen = cameraToScreen;
            _lensRadius = lensRadius;
            _focalDistance = focalDistance;

            // Compute projective camera screen transformations
            _screenToRaster = Transform.Scale(film.XResolution, film.YResolution, 1.0f)
                * Transform.Scale(1.0f / (screenWindow[1] - screenWindow[0]), 1.0f / (screenWindow[2] - screenWindow[3]), 1.0f)
                * Transform.Translate(new Vector(-screenWindow[0], -screenWindow[3], 0.0f));
            _rasterToScreen = Transform.Invert(_screenToRaster);
            _rasterToCamera = Transform.Invert(_cameraToScreen) * _rasterToScreen;
        }
示例#6
0
 public static Sampler MakeSampler(string name, ParamSet parameters, Film film, Camera camera)
 {
     switch (name)
     {
         case "stratified":
         {
             var jitter = parameters.FindBoolean("jitter", true);
             var xSamples = parameters.FindInt32("xsamples", 2);
             var ySamples = parameters.FindInt32("ysamples", 2);
             var sampleExtent = film.SampleExtent;
             return new StratifiedSampler(sampleExtent, xSamples, ySamples, jitter, 
                 camera.ShutterOpen, camera.ShutterClose);
             }
         default:
             throw new ArgumentException("Unknown sampler: " + name);
     }
 }
 public abstract Scene CreateScene(Film film);