Exemplo n.º 1
0
        /// <summary>
        /// Metoda postavlja sve paramtere potrebne za crtanje slike pomocu raytracinga
        /// </summary>
        public void read()
        {
            CultureInfo c = CultureInfo.InvariantCulture;
            float       x = float.Parse(getNextParameter().ToString(), c);
            float       y = float.Parse(getNextParameter().ToString(), c);
            float       z = float.Parse(getNextParameter().ToString(), c);

            eyePosition = new Point(x, y, z);

            screenSize       = float.Parse(getNextParameter().ToString(), c);
            screenResolution = float.Parse(getNextParameter().ToString(), c);

            x               = float.Parse(getNextParameter().ToString(), c);
            y               = float.Parse(getNextParameter().ToString(), c);
            z               = float.Parse(getNextParameter().ToString(), c);
            lightPosition   = new Point(x, y, z);
            numberOfObjects = float.Parse(getNextParameter().ToString(), c);

            sphereParameters = new SphereParameters[Convert.ToInt32(numberOfObjects)];

            for (int j = 0; j < Convert.ToInt32(numberOfObjects); j++)
            {
                x = float.Parse(getNextParameter().ToString(), c);
                y = float.Parse(getNextParameter().ToString(), c);
                z = float.Parse(getNextParameter().ToString(), c);
                Point centerPosition = new Point(x, y, z);

                float radius = float.Parse(getNextParameter().ToString(), c);

                float[] raysContributions = { 0, 0 };
                float   contribution      = float.Parse(getNextParameter().ToString(), c);
                raysContributions[0] = contribution;
                contribution         = float.Parse(getNextParameter().ToString(), c);
                raysContributions[1] = contribution;

                PropertyVector[] materialParameters = new PropertyVector[3];
                float            k1 = float.Parse(getNextParameter().ToString(), c);
                float            k2 = float.Parse(getNextParameter().ToString(), c);
                float            k3 = float.Parse(getNextParameter().ToString(), c);
                materialParameters[0] = new PropertyVector(k1, k2, k3);

                k1 = float.Parse(getNextParameter().ToString(), c);
                k2 = float.Parse(getNextParameter().ToString(), c);
                k3 = float.Parse(getNextParameter().ToString(), c);
                materialParameters[1] = new PropertyVector(k1, k2, k3);

                k1 = float.Parse(getNextParameter().ToString(), c);
                k2 = float.Parse(getNextParameter().ToString(), c);
                k3 = float.Parse(getNextParameter().ToString(), c);
                materialParameters[2] = new PropertyVector(k1, k2, k3);

                k1 = float.Parse(getNextParameter().ToString(), c);
                n  = k1;

                k1 = float.Parse(getNextParameter().ToString(), c);

                ni = k1;
                sphereParameters[j] = new SphereParameters(centerPosition, radius, raysContributions, materialParameters, n, ni);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Inicijalni konstruktor koji postavlja sve parametre kugle. Za prijenos
 /// parametara koristi se pomocna klasa SphereParameters.
 /// </summary>
 /// <param name="sphereParameters">parametri kugle</param>
 public Sphere(SphereParameters sphereParameters)
     : base(sphereParameters.getCenterPosition(), sphereParameters.getRaysContributions(),
            sphereParameters.getMaterialParameters(), sphereParameters.getN(),
            sphereParameters.getNi())
 {
     this.radius = sphereParameters.getRadius();
 }