T1 Add an abstract class material

T1.1 Add material.h and define class material

#ifndef MATERIAL_H
#define MATERIAL_H

#include "hittable.h"

class material {
  public:
    virtual ~material() = default;

    virtual bool scatter(
        const ray& r_in, const hit_record& rec, color& attenuation, ray& scattered
    ) const {
        return false;
    }
};

#endif

T1.2 Adding material in hit_record

In hittable.h, make the following revisions to add material information to hit_record

T 1.3 Adding material in class sphere (sphere.h)

In class sphere add a private memember of the material pointer.

Add init of the mat pointer in the sphre construtor.

In its hit() method, add one line to set the material for the hit point

Last updated