?? ray.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 + -