Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Scene::Render(unsigned int a_Width, unsigned int a_Height)
- {
- Engine * t_Engine = Engine::Get();
- Colour * t_Buffer = t_Engine->GetBuffer();
- Ray t_Ray;
- for(int y = -((int)a_Height) / 2; y <((int)a_Height) / 2; y++ )
- {
- vector3 *t_CamPos = m_Camera->GetPos();
- matrix t_CamOrientation = m_Camera->GetOrientationMatrix();
- t_Ray.SetPos(t_CamPos->x, t_CamPos->y, t_CamPos->z);
- for(int x = -((int)a_Width) / 2; x <((int)a_Width) / 2; x++)
- {
- int xy = (x +((int)a_Width) / 2) +(y +((int)a_Height) / 2) *((int)a_Width);
- vector3 t_Direction((float)x, -(float)y,(float)(((int)a_Width) + ((int)a_Height)) );
- t_Direction.Normalize();
- t_Direction = t_CamOrientation.Transform(t_Direction);
- t_Ray.SetDir(t_Direction.x, t_Direction.y, t_Direction.z);
- double t_Distance;
- bool t_InObject;
- Primitive * t_Prim = Trace(t_Ray, t_Distance, t_InObject);
- if(t_Prim==0) t_Buffer[xy].ARGB = CLEAR_COLOUR;
- else
- {
- vector3 t_RayVector = t_Ray.origin + t_Ray.direction * (float)t_Distance;
- t_Buffer[xy] = CalculateLight(t_Ray, &t_RayVector, t_Prim, Engine::Get()->GetRecursionCount(), t_InObject);
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment