Holland

Untitled

Nov 7th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. bool Scene::Render(unsigned int a_Width, unsigned int a_Height)
  2.     {
  3.         Engine * t_Engine = Engine::Get();
  4.         Colour * t_Buffer = t_Engine->GetBuffer();
  5.        
  6.         Ray t_Ray;
  7.         for(int y = -((int)a_Height) / 2; y <((int)a_Height) / 2; y++ )
  8.         {
  9.             vector3 *t_CamPos = m_Camera->GetPos();
  10.             matrix t_CamOrientation = m_Camera->GetOrientationMatrix();
  11.             t_Ray.SetPos(t_CamPos->x, t_CamPos->y, t_CamPos->z);
  12.             for(int x = -((int)a_Width) / 2; x <((int)a_Width) / 2; x++)
  13.             {
  14.                 int xy = (x +((int)a_Width) / 2) +(y +((int)a_Height) / 2) *((int)a_Width);
  15.                 vector3 t_Direction((float)x, -(float)y,(float)(((int)a_Width) + ((int)a_Height)) );
  16.                 t_Direction.Normalize();
  17.                 t_Direction = t_CamOrientation.Transform(t_Direction);
  18.                 t_Ray.SetDir(t_Direction.x, t_Direction.y, t_Direction.z);
  19.  
  20.                 double t_Distance;
  21.                 bool t_InObject;
  22.                 Primitive * t_Prim = Trace(t_Ray, t_Distance, t_InObject);
  23.  
  24.                 if(t_Prim==0) t_Buffer[xy].ARGB = CLEAR_COLOUR;
  25.                 else
  26.                 {
  27.                     vector3 t_RayVector = t_Ray.origin + t_Ray.direction * (float)t_Distance;
  28.                     t_Buffer[xy] = CalculateLight(t_Ray, &t_RayVector, t_Prim, Engine::Get()->GetRecursionCount(), t_InObject);
  29.                 }
  30.             }
  31.         }
  32.  
  33.         return true;
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment