forked from evan69/RayTrace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add camera class, fix bug in diffuse reflection
- Loading branch information
Showing
11 changed files
with
100 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
2016.5.23 ���������� | ||
2016.5.24 �������� | ||
2016.5.24 ��������Ӱ���ֲھ��淴�� | ||
2016.5.26 ����������࣬���ֲھ��淴���bug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef CAMERA_H | ||
#define CAMERA_H | ||
|
||
#include "all.h" | ||
|
||
namespace HYF | ||
{ | ||
|
||
class Camera | ||
{ | ||
public: | ||
Camera():m_Eye(0,0,-5),m_Target(0,0,0),m_Dist(5.0),m_Width(8.0),m_Height(6.0),m_Ratio(0.01){} | ||
Camera(vector3 p_Eye,vector3 p_Target,double p_Dist,double p_Width,double p_Height,double p_Ratio): | ||
m_Eye(p_Eye),m_Target(p_Target),m_Dist(p_Dist),m_Width(p_Width),m_Height(p_Width),m_Ratio(p_Ratio){} | ||
inline vector3 getEye(){return m_Eye;} | ||
vector3 getDir(double x,double y)//像素坐标,整数,也可以在超采样中取小数 | ||
{ | ||
vector3 dir = m_Target - m_Eye; | ||
NORMALIZE(dir); | ||
dir = dir * m_Dist; | ||
//return dir; | ||
m_x = dir.Cross(vector3(0,1,0)); | ||
NORMALIZE(m_x); | ||
m_y = m_x.Cross(dir); | ||
NORMALIZE(m_y); | ||
vector3 ret = dir + (x * m_Ratio - 0.5 * m_Width) * m_x + (y * m_Ratio - 0.5 * m_Height) * m_y; | ||
NORMALIZE(ret); | ||
return ret; | ||
} | ||
private: | ||
vector3 m_Eye; | ||
vector3 m_Target; | ||
double m_Dist; | ||
double m_Width; | ||
double m_Height; | ||
vector3 m_x;//投影平面的x方向基向量 | ||
vector3 m_y;//投影平面的y方向基向量 | ||
double m_Ratio;//从整点像素到三维坐标系的缩放比,即图像单位像素对应投影平面在坐标系中的长度 | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters