librtl

Super Ellipsoids

This example demonstrates rtl_superellipsoid objects. These objects are defined by an equation that parameterizes the roundedness in the horizontal and vertical direction of a sphere. Three examples are shown in the following code that demonstrates the affect of the range of the parameters.
#include <iostream.h>
#include <jgl/jgl.h>
#include <rtl/rtl.h>

void main()
{
    rtl_initialize();
    
    rtl_world scene(35);
    jImage map(320,240,jColour::white);

    rtl_superellipsoid se0(1.6,1.6);
    rtl_superellipsoid se1(0.2,0.2);
    rtl_superellipsoid se2(0.3,1,1,1,2);
    
    rtl_material m0(jColour::slate_blue);
    rtl_material m1(jColour::med_plum);
    rtl_material m2(jColour::sea_green);

    rtl_light l0,l1;
    l0.position(jVec3(-2,10,15)), l0.colour(jColour(0.7,0.7,0.7));
    l1.position(jVec3(10,10,15)), l1.colour(jColour(0.7,0.7,0.7));

    scene.illumination()->add(&l0), scene.illumination()->add(&l1);
   
    scene.illumination()->flags().setoff(rtl_illumination::Shadows|
                                         rtl_illumination::Recursion);
    
    scene.translate(0,1,0);

    scene.push();
    {
        scene.material(&m0);
        scene.translate(-1.2,0,1);
        scene.rotate(1,-5);
        scene.add(&se0);
    }
    scene.pop();

    scene.push();
    {
        scene.material(&m1);
        scene.translate(1.2,0,0);
        scene.add(&se1);
    }
    scene.pop();

    scene.push();
    {
        scene.material(&m2);
        scene.translate(-1,-1,-2);
        scene.rotate(0,90);
        scene.add(&se2);
    };
    scene.pop();

    scene.lookat(jVec3(2,3,6),jVec3(0,0,0),jNorm3(0,1,0));

    cerr.setf(ios::fixed);
    cerr.precision(3);
    
    scene.raytrace(map,5,25);

    jImage::writePPM(cout,map);

    rtl_terminate();
}


JSP / librtl v0.2 mtigges@cpsc.ucalgary.ca