($square/2) == floor($square/2) ???
Posted: Tue Jan 04, 2011 6:41 pm
I'm converting a simple raytracer I made in php over to c++ and I can't figure out how to convert a certain part. The code below creates a "tile/checkered" pattern that can be put on a plane, I didn't make it up myself, I copied it from a javascript raytracer and just modified the function calls to make it work, so the javascript version of this code was very similar. Anyways, what is the == doing? In c++ it doesn't work at all and when I run it with just setColorRed((square/2)) it doesn't make the correct pattern of every other square being black or white. Any suggestions?
Code: Select all
$square = floor($intersection_position->getVectorX()) + floor($intersection_position->getVectorZ());
$winning_object_color->setColorRed(($square/2) == floor($square/2));
$winning_object_color->setColorGreen(($square/2) == floor($square/2));
$winning_object_color->setColorBlue(($square/2) == floor($square/2));