コード例 #1
0
    public void build()
    {
        DestroyRenderAreaTexture();

        texture = new Texture2D(200, 200);
        GameObject.Find("ViewRectangle").GetComponent <MeshRenderer> ().material.mainTexture = texture;
        vp           = new ViewPlane(texture.width, texture.height, 1.0f, 1);
        vp.max_depth = 5;

        tracer_ptr = new GlobalTracer(this);

        Ambient amblight = new Ambient();

        amblight.scale_radiance(1.0f);
        amblight.set_color(new Color(1, 1, 1, 1));
        set_ambient_light(amblight);


        PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera();

        pinhole_ptr1.set_eye(new Vector3(0, 0, 500));
        pinhole_ptr1.set_lookat(Vector3.zero);
        pinhole_ptr1.set_view_distance(600.0f);
        pinhole_ptr1.compute_uvw();
        set_camera(pinhole_ptr1);

        Directional directional = new Directional();

        directional.set_color(new Color(1, 1, 1, 1));
        directional.set_direction(new Vector3(-1, -1, 0));
        directional.cast_shadows = false;
        directional.scale_radiance(3.0f);
        add_light(directional);

        Reflective mat_ptr = new Reflective();

        mat_ptr.set_kr(1.0f);
        mat_ptr.set_exp(1.0f);
        mat_ptr.set_cr(sphere_1_col);

        Sphere sphere = new Sphere();

        sphere.sphereCenter = new Vector3(0, 0, 0);
        sphere.sphereRad    = 1.0f;
        sphere.set_material(mat_ptr);

        Instance sphereInst = new Instance(sphere);

        sphereInst.set_material(mat_ptr);
        add_object(sphereInst);

        sphereInst.set_identity();
        sphereInst.Scale(20, 20, 20);
        sphereInst.Translate(60.0f, 20.0f, 0);

        Matte mat_ptr1 = new Matte();

        mat_ptr1.ambient_brdf.Set_Sampler(100, 0.5f);
        mat_ptr1.diffuse_brdf.Set_Sampler(100, 0.5f);
        mat_ptr1.set_ka(1.0f);
        mat_ptr1.set_kd(1);
        mat_ptr1.set_cd(plane_col);


        Plane p = new Plane();

        p.planeNormal       = new Vector3(0, 1, 0);
        p.planePassThrghPnt = new Vector3(0, -20, 0);
        p.set_material(mat_ptr1);
        add_object(p);

        Emissive mat_ptr2 = new Emissive();

        mat_ptr2.scale_radiance(1);
        mat_ptr2.set_ce(sphere_2_col);

        Sphere sphere1 = new Sphere();

        sphere1.sphereCenter = new Vector3(0, 0, 0);
        sphere1.sphereRad    = 1.0f;
        sphere1.set_material(mat_ptr2);

        Instance sphereInst1 = new Instance(sphere1);

        sphereInst1.set_material(mat_ptr2);
        add_object(sphereInst1);

        sphereInst1.set_identity();
        sphereInst1.Scale(20, 20, 20);
        sphereInst1.Translate(-60.0f, 20.0f, 0);

        render_scene();
    }