librtl

box.h

This is the verbatim text of the box.h include file.
#ifndef box_h
#define box_h

#include "object.h"


class rtl_box : public rtl_object
{
public:
    rtl_box ();
    rtl_box( const jBBox& );

    Type type() const { return objBox; }

protected:    

    jFlt lclintersect ( const rtl_ray& ray )
    {
        jFlt t = NOHIT;
        if(bb.intersect(ray))
        {
            if(bb.in()>EPS)  t = bb.in(),flags().seton(Entrance);
            else if(bb.out()>EPS) t = bb.out(),flags().setoff(Entrance);
            if(t>EPS && (bb.out()-bb.in())<EPS)t = -1;
        }
        return t;
    }

    jNorm3 lclnormal( const jVec3& i )
    {
        jInt a = i.majorAxis();
        return jNorm3(a==0 ? sgn(i[0]) : 0,
                      a==1 ? sgn(i[1]) : 0,
                      a==2 ? sgn(i[2]) : 0);
    }

    jFlt rehit() 
    {
        jFlt t = NOHIT;
        if(flags().on(Entrance)) t = bb.out();
        flags().setoff(Entrance);
        return t;
    }
    
    jBBox bb;
};

#endif

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