예제 #1
0
 public static IFilter CreateFilter(ParameterSet ps)
 {
     double xw = ps.FindOneDouble ("xwidth", 2.0);
     double yw = ps.FindOneDouble ("ywidth", 2.0);
     double B = ps.FindOneDouble ("B", 1.0 / 3.0);
     double C = ps.FindOneDouble ("C", 1.0 / 3.0);
     return new Mitchell (B, C, xw, yw);
 }
예제 #2
0
파일: Sphere.cs 프로젝트: Kintaro/Hyperion
 public static IShape CreateShape(Transform o2w, Transform w2o, bool reverseOrientation, ParameterSet parameters, Dictionary<string, ITexture<double>> floatTextures, Dictionary<string, ITexture<Spectrum>> spectrumTextures)
 {
     double radius = parameters.FindOneDouble ("radius", 1.0);
     double zmin = parameters.FindOneDouble ("zmin", -radius);
     double zmax = parameters.FindOneDouble ("zmax", radius);
     double phimax = parameters.FindOneDouble ("phimax", 360.0);
     return new Sphere (o2w, w2o, reverseOrientation, radius, zmin, zmax, phimax);
 }
예제 #3
0
파일: Disk.cs 프로젝트: Kintaro/Hyperion
 public static IShape CreateShape(Transform o2w, Transform w2o, bool reverseOrientation, ParameterSet parameters, Dictionary<string, ITexture<double>> floatTextures, Dictionary<string, ITexture<Spectrum>> spectrumTextures)
 {
     double height = parameters.FindOneDouble ("height", 0.0);
     double radius = parameters.FindOneDouble ("radius", 1);
     double inner_radius = parameters.FindOneDouble ("innerradius", 0);
     double phimax = parameters.FindOneDouble ("phimax", 360);
     return new Disk (o2w, w2o, reverseOrientation, height, radius, inner_radius, phimax);
 }
예제 #4
0
 public static ICamera CreateCamera(ParameterSet parameters, AnimatedTransform cameraToWorld, IFilm film)
 {
     double shutteropen = parameters.FindOneDouble ("shutteropen", 0.0);
     double shutterclose = parameters.FindOneDouble ("shutterclose", 1.0);
     double lensradius = parameters.FindOneDouble ("lensradius", 0.0);
     double focaldistance = parameters.FindOneDouble ("focaldistance", 1E+30);
     double frame = parameters.FindOneDouble ("frameaspectratio", (double)(film.xResolution) / (double)(film.yResolution));
     double[] screen = new double[4];
     if (frame > 1.0)
     {
         screen[0] = -frame;
         screen[1] = frame;
         screen[2] = -1.0;
         screen[3] = 1.0;
     } else
     {
         screen[0] = -1.0;
         screen[1] = 1.0;
         screen[2] = -1.0 / frame;
         screen[3] = 1.0 / frame;
     }
     int swi = 0;
     double[] sw = parameters.FindDouble ("screenwindow", ref swi);
     if (sw != null && swi == 4)
         screen = sw;
     double fov = parameters.FindOneDouble ("fov", 90.0);
     return new Perspective (cameraToWorld, screen, shutteropen, shutterclose, lensradius, focaldistance, fov, film);
 }
예제 #5
0
        /// <summary>
        ///     Creates a new Kd-Tree
        /// </summary>
        /// <param name="primitives">
        ///     List of primitives to include in the Tree
        /// </param>
        /// <param name="parameterSet">
        ///     Parameters for the Kd-Tree
        /// </param>
        /// <returns>
        ///     The newly created Kd-Tree
        /// </returns>
        public static IAggregate CreateAccelerator(List<IPrimitive> primitives, ParameterSet parameterSet)
        {
            int isectCost = parameterSet.FindOneInt ("intersectcost", 80);
            int traversalCost = parameterSet.FindOneInt ("traversalcost", 1);
            double emptyBonus = parameterSet.FindOneDouble ("emptybonus", 0.5);
            int maxPrimitives = parameterSet.FindOneInt ("maxprims", 1);
            int maxDepth = parameterSet.FindOneInt ("maxdepth", -1);

            return new KdTree (primitives, isectCost, traversalCost, emptyBonus, maxPrimitives, maxDepth);
        }
예제 #6
0
        public static IShape CreateShape(Transform o2w, Transform w2o, bool reverseOrientation, ParameterSet parameters, Dictionary<string, ITexture<double>> floatTextures, Dictionary<string, ITexture<Spectrum>> spectrumTextures)
        {
            int nvi = 0, npi = 0, nuvi = 0, nsi = 0, nni = 0;
            int[] vi = parameters.FindInt ("indices", ref nvi);
            Point[] P = parameters.FindPoint ("P", ref npi);
            double[] uvs = parameters.FindDouble ("uv", ref nuvi);
            if (uvs == null)
                uvs = parameters.FindDouble ("st", ref nuvi);
            bool discardDegnerateUVs = parameters.FindOneBool ("discarddegenerateUVs", false);
            // XXX should complain if uvs aren't an array of 2...
            if (uvs != null)
            {
                if (nuvi < 2 * npi)
                {
                    uvs = null;
                }
            }
            if (vi == null || P == null)
                return null;
            Vector[] S = parameters.FindVector ("S", ref nsi);
            if (S != null && nsi != npi)
            {

                S = null;
            }
            Normal[] N = parameters.FindNormal ("N", ref nni);
            if (N != null && nni != npi)
            {
                N = null;
            }
            if (discardDegnerateUVs && uvs != null && N != null)
            {
                // if there are normals, check for bad uv's that
                // give degenerate mappings; discard them if so
                int vp = 0;
                for (int i = 0; i < nvi; i += 3,vp += 3)
                {
                    double area = 0.5 * ((P[vi[vp + 0]] - P[vi[vp + 1]]) % (P[vi[vp + 2]] - P[vi[vp + 1]])).Length;
                    if (area < 1E-07)
                        continue;
                    // ignore degenerate tris.
                    if ((uvs[2 * vi[vp + 0]] == uvs[2 * vi[vp + 1]] && uvs[2 * vi[vp + 0] + 1] == uvs[2 * vi[vp + 1] + 1]) || (uvs[2 * vi[vp + 1]] == uvs[2 * vi[vp + 2]] && uvs[2 * vi[vp + 1] + 1] == uvs[2 * vi[vp + 2] + 1]) || (uvs[2 * vi[vp + 2]] == uvs[2 * vi[vp + 0]] && uvs[2 * vi[vp + 2] + 1] == uvs[2 * vi[vp + 0] + 1]))
                    {
                        uvs = null;
                        break;
                    }
                }
            }
            for (int i = 0; i < nvi; ++i)
                if (vi[i] >= npi)
                {
                    return null;
                }

            ITexture<double> alphaTex = null;
            string alphaTexName = parameters.FindTexture ("alpha");
            if (alphaTexName != "")
            {
                if (floatTextures.ContainsKey (alphaTexName))
                    alphaTex = floatTextures[alphaTexName];
            } else if (parameters.FindOneDouble ("alpha", 1.0) == 0.0)
                alphaTex = new ConstantTexture<double> (0.0);
            return new TriangleMesh (o2w, w2o, reverseOrientation, nvi / 3, npi, vi, P, N, S, uvs,
            alphaTex);
        }
예제 #7
0
파일: Disk.cs 프로젝트: Kintaro/Art
        public static IShape CreateDiskShape(Transform o2w, Transform w2o, bool reverseOrientation, ParameterSet parameters)
        {
            var height = parameters.FindOneDouble ("height", 0.0);
            var radius = parameters.FindOneDouble ("radius", 1.0);
            var innerRadius = parameters.FindOneDouble ("innerradius", 0.0);
            var phimax = parameters.FindOneDouble ("phimax", 360.0);

            return new Disk (o2w, w2o, reverseOrientation, height, radius, innerRadius, phimax);
        }
예제 #8
0
 public static IVolumeIntegrator CreateVolumeIntegrator(ParameterSet parameters)
 {
     double stepSize = parameters.FindOneDouble ("stepsize", 1.0);
     return new Emission (stepSize);
 }