Class List W07 | | six | seven | eight | nine | ten | eleven | | Home |

Week 7



Got the sphere hit detection implemented.
I had a hard time figuring out what was broken because my renders were just black.
Finally I "stumbled" onto a scene set up that put colored pixels on the screen.


Now, when I move my camera, the difference between my lookat vector and
the vector to the center of my rendering plane(0.5, 0.5) increases. This is bad. To further test this
I want to get a mel script running to export object data from maya to generate scene data files.

Ok. The weird image was because I accidentally reversed my height & width in my render loops.


Now I need to fix my variables so that it makes sense.

wrong code:

int pixIndex = 0;
for( int x = 0; x < _width; x++ )
{
 double nX = (x + 0.5)/static_cast(w);

 for( int y = 0; y < _height; y++ )
 {
  double nY = (y + 0.5)/static_cast(h);

  _pixel[pixIndex] = theTracer.Trace( nX, nY );
  pixIndex++;
 }
}


fixed code:

int pixIndex = 0;
for( int x = 0; x < _height; x++ )
{
 double nX = (x + 0.5)/static_cast(w);

 for( int y = 0; y < _width; y++ )
 {
  double nY = (y + 0.5)/static_cast(h);

  _pixel[pixIndex] = theTracer.Trace( nX, nY );
  pixIndex++;
 }
}