Thursday, April 19, 2007

Rendering chess positions


Chess, 3-D graphics and FOSS are three areas I like. I have been using the POV-Ray program for sometime now and prepared files to render individual chess pieces, which can be included in a POV-Ray scene. I tested the include files with a board and a few lights. This way, I could include the shape definition for a piece and place it on a given position on the board by translating it.

Next, I studied the CPAN Chess libraries in Perl and figured how to read in a file saved in FEN with a Perl script. The script would then generate a POV-Ray file with necessary translate instructions to place different pieces in different positions, as specified in the input FEN file. Now, I simply used POV-Ray to render the file generated above and I have a 3-D view of the board position. I have included a sample image. I got this position by editing the start position in Xboard using the "Edit Game" feature. I saved the position as an FEN file and then ran the perl script and the povray program on my ubuntu powered laptop.

No comments: