next up previous contents
Next: Density Mapping Up: Media Previous: Media   Contents

absorbing, emitting, scattering

Example Scene 1: Inversed menger sponge filled with scattering media.

Pigment3D* setUpScene_MediaMenger() {

    Scene* s = new Scene();

    CSG* mengerc = new CSG(CSG::INTERSECT);

    Object3D* menger = make_menger(3,2);

    Box* b = new Box(Vector3(-1.499),Vector3(1.499));
    mengerc->addObject(b);

    menger->inverse();
    mengerc->addObject(menger);

    mengerc->setPigment(Pigment3DConstant(Colour5(1,1,1,0,1)));
    mengerc->rotate(Vector3(11,23,0));
    mengerc->translate(Vector3(0,0,6));
    Media3DSingle media(Colour3(0),Colour3(2.5),Colour3(2.5),Media3D::MIE_MURKY,s,0.0,0.0001,0.1);
    mengerc->setMedia(media);
    s->addObject(mengerc);

    Plane *pl = new Plane(Vector3(0,1,0));
    pl->setPigment(Pigment3DConstant(Colour5(0,0,.5,0,0)));
    pl->translate(Vector3(0,-2.5,0));
    s->addObject(pl);

    Plane *pl2 = new Plane(Vector3(0,0,1));
    pl2->setPigment(Pigment3DConstant(Colour5(0,0,.5,0,0)));
    pl2->translate(Vector3(0,0,11.5));
    s->addObject(pl2);

    PointLight* p = new PointLight(Vector3(0,10,-8),Colour3(1*1.5),s);
    s->addLight(p);

    PointLight* p2 = new PointLight(Vector3(-3,4,-6),Colour3(.5*1.5),s);
    s->addLight(p2);

    Material3D m = Material3D(new Texture3D(new Pigment3DConstant(Colour5(0)), new Finish(0.1,0.6,0,0,0)), new Interior() );
    s->setDefaultMaterial(m);

    s->object.prepareToRender();

    CameraPerspective* c = new CameraPerspective(s);

    return c;

};
Note that the menger sponge is created by differencing it from a unit-sized cube. This is certainly not the best way to do it as in this case you could easily construct it otherwise. But often this is not that easy. Note that this had catastrophical impact on the performance when you would render it with POV-Ray: because the csg consists of an intersection of inversed boxes POV-Ray does not create any bounding-boxes.

Another media example:



Micha Riser 2002-10-24