ShadeRec class definition

This class is mainly used to record the type of collision data, the book have made it very clear. This class will then slowly expand, will expand in this essay, first define a simple, easy to compile to see results.

Class declaration (World after the main program category, and finally realize the test):

#ifndef __SHADEREC_HEADER__
#define __SHADEREC_HEADER__

#include "ray.h"

class World;

class ShadeRec {
public:
	ShadeRec(World& wr);
	~ShadeRec();
	ShadeRec(const ShadeRec& sr);
	bool hit_an_object;		
	Point3 local_hit_point;	
	Normal3 normal;
	Ray ray;	
	RGBColor color;
	World& w;
};
#endif

The current record is the first collision, the color of the collision point, the normal light and collisions.

Class implementation:

#include "pch.h"
#include "shaderec.h"
#include "world.h" //这个文件头最后实现

ShadeRec::ShadeRec(World& wr)
	:hit_an_object(false), local_hit_point(), normal(), ray(), color(), w(wr) {}

ShadeRec::~ShadeRec() {}

ShadeRec::ShadeRec(const ShadeRec& sr)
	: hit_an_object(sr.hit_an_object), local_hit_point(sr.local_hit_point), normal(sr.normal),
	ray(sr.ray), color(sr.color), w(sr.w) {}

-------------------------------------------------------------------------------------------------

Guess you like

Origin www.cnblogs.com/dalgleish/p/12602726.html