// *********************************************************
// Ray Class
// Author : Tamy Boubekeur (boubek@gmail.com).
// Copyright (C) 2010 Tamy Boubekeur.
// All rights reserved.
// *********************************************************

#ifndef RAY_H
#define RAY_H

#include <iostream>
#include <vector>

#include "Vec3D.h"
#include "BoundingBox.h"

class Ray {
public:
    inline Ray () {}
    inline Ray (const Vec3Df & origin, const Vec3Df & direction)
        : origin (origin), direction (direction) {}
    inline virtual ~Ray () {}

    inline const Vec3Df & getOrigin () const { return origin; }
    inline Vec3Df & getOrigin () { return origin; }
    inline const Vec3Df & getDirection () const { return direction; }
    inline Vec3Df & getDirection () { return direction; }

    void setOrigin(const Vec3Df& o) { origin = o; }
    void setDirection(const Vec3Df& d) { direction = d; }

    bool intersect(const BoundingBox & bbox, Vec3Df & intersectionPoint) const;
    bool intersect(const Vec3Df& tri0, const Vec3Df& tri1, const Vec3Df& tri2, Vec3Df& ipoint, float& u, float& v, float& t) const;
    bool intersect(const Vec3Df& center, float radius, Vec3Df& ipoint, float& t) const;
    bool getRange(const BoundingBox& bbox, float& tmin, float& tmax);
    float getT(const Vec3Df& pt) const;

private:
    Vec3Df origin;
    Vec3Df direction;
};


#endif // RAY_H

// Some Emacs-Hints -- please don't remove:
//
//  Local Variables:
//  mode:C++
//  tab-width:4
//  End:
