⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ray.h

📁 file code.zip are used to implement ray tracing technology.
💻 H
字号:
#ifndef _RAY_COMMON_#define _RAY_COMMON_#include "common.h"#include "affine.h"//Maximum number of hits for a single ray#define maxNumHits 20// Need to declare class for Ray & hitInfo classesclass GeomObj;//@@@@@@@@@@@@@@@@@@ HitInfo @@@@@@@@@@@@@@@@@@@@class HitInfo{ // data for each hit with a surfacepublic:    double hitTime;    		// the hit time    GeomObj* hitObject;  	// the object hit    int surface;		// which surface is hit?    int isEntering;		// is ray entering the object?    Point3 hitPoint;		// hit point    Vector3 hitNormal;		// normal at hit point    HitInfo();    void set(HitInfo& h);};//@@@@@@@@@@@@@@@@@ Intersection @@@@@@@@@@@@@@@@@@@@@class Intersection{ // hold the hit listpublic:    int numHits;			// the number of hits    HitInfo hit[maxNumHits];		// list of hits    Intersection();    void set(Intersection& intr);    void sort();};//@@@@@@@@@@@@@@@@@@@@ light class @@@@@@@@@@@@@@@@@@@// Linked list of light sourcesclass Light{public:    Point3 pos;    Color3 color;    Light* next;    Light() {next = NULL;}    void setPosition(Point3 p){pos.set(p);}    void setColor(Color3 c){color.set(c);}};//@@@@@@@@@@@@@@@@@@@@ Ray @@@@@@@@@@@@@@@@@@@@@@@@@class Ray{public:    // Constructors    Ray();										// Initialize all values empty    Ray(Point3& origin);						// Set origin of ray    Ray(Point3& origin, Vector3& direction);	// Set origin and direction of ray    Ray(Point3& origin, Light *L);				// Set origin and direct towards light    void set(Ray& copyMe);    // Accessor Functions    void setStart(float x, float y, float z);    void setStart(Point3& p);    Point3& getStart();    void setDir(float x, float y, float z);    void setDir(Vector3& v);    void setDir(Light *L);    Vector3& getDir();    void setRecurseLevel(int newLevel);    int getRecurseLevel();    void setAttenuation(float newAttenuation);    void accumulateAttenuation(float newAttenuation);    float getAttenuation();    HitInfo* getHit();    void setHit(HitInfo *hit);        // Miscelaneous Functions    Point3 calculatePointOnRay(float t);    void nudgeForward(float epsilon);	//To avoid unwanted self occlusion    void nudgeForward();private:    Point3 start;	// Origin of Ray    Vector3 dir;	// Direction of Ray    HitInfo *hit;	// Information about the first intersection along the ray	int recurseLevel;		// Current level in recursion tree    float attenuation;		// The attenuation of the energy present in the light ray    void setDefaults();		// Set all variables to default values};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -