33namespace Unilight
44{
55 // 1st = Origin, 2nd = Direction
6- using Ray = Tuple < Vector , Vector > ;
6+ using Ray = Tuple < Vector3D , Vector3D > ;
77
88 using IntPair = Tuple < int , int > ;
99
1010 // Eye, LookAt, ViewportWidth, ViewportHeight
11- using TCamera = Tuple < Vector , Vector , float , float > ;
11+ using TCamera = Tuple < Vector3D , Vector3D , float , float > ;
1212
1313 public class Raytracer
1414 {
@@ -21,7 +21,7 @@ private struct RayTraversalResult
2121 {
2222 public GObject ? Closest { get ; set ; }
2323 public float Distance { get ; set ; }
24- public Vector ? IntersectionPoint { get ; set ; }
24+ public Vector3D ? IntersectionPoint { get ; set ; }
2525 }
2626
2727 public delegate void UpdateCallback ( int percent ) ;
@@ -67,7 +67,7 @@ private RgbColor trace(Ray ray, int depth)
6767
6868 GObject ? closest = null ;
6969 float dist = float . MaxValue ;
70- Vector intersectionPoint = new ( ) ;
70+ Vector3D intersectionPoint = new ( ) ;
7171
7272 for ( int k = 0 ; k < Scene . CountObjects ( ) ; ++ k )
7373 {
@@ -90,16 +90,16 @@ private RgbColor trace(Ray ray, int depth)
9090
9191 if ( closest != null && mIntersector . Result == Intersector . IntersectionResult . Hit )
9292 {
93- Vector n = closest . GetNormalAt ( intersectionPoint ) ;
93+ Vector3D n = closest . GetNormalAt ( intersectionPoint ) ;
9494 n . Normalize ( ) ;
9595
9696 Material mat = closest . Material ;
9797 float refl = mat . Reflection ;
9898
99- Vector v = ray . Item1 - intersectionPoint ; // point to eye vector
99+ Vector3D v = ray . Item1 - intersectionPoint ; // point to eye vector
100100 v . Normalize ( ) ;
101- Vector r ; // reflected ray
102- Vector l ; // light vector
101+ Vector3D r ; // reflected ray
102+ Vector3D l ; // light vector
103103
104104 for ( int k = 0 ; k < Scene . CountLights ( ) ; ++ k )
105105 {
@@ -150,7 +150,7 @@ private Matrix4 imageToViewportTransform(int imgWidth, int imgHeight, Camera cam
150150
151151 Matrix4 finalTransform = Matrix4 . translate ( cam . LookAt . X , cam . LookAt . Y , cam . LookAt . Z ) ;
152152
153- Vector invNormal = cam . Eye - cam . LookAt ;
153+ Vector3D invNormal = cam . Eye - cam . LookAt ;
154154 invNormal . Normalize ( ) ;
155155
156156 Matrix4 scale = Matrix4 . identity ( ) ;
@@ -222,8 +222,8 @@ private void RenderChunk(Point start, Point end, byte[] pixels, int stride)
222222
223223 while ( ! iter . Done ( ) )
224224 {
225- Vector mapped = i2v . Multiply ( new Vector ( iter . Cursor . X , iter . Cursor . Y , 0 ) ) ;
226- Vector dir = mapped - Camera . Eye ;
225+ Vector3D mapped = i2v . Multiply ( new Vector3D ( iter . Cursor . X , iter . Cursor . Y , 0 ) ) ;
226+ Vector3D dir = mapped - Camera . Eye ;
227227 dir . Normalize ( ) ;
228228 Ray ray = new Ray ( Camera . Eye , dir ) ;
229229
0 commit comments