Add a command-line option that sets an object color temporarily
completed by: javamonn
This task involves adding probably less than 10 lines of code.
BRL-CAD has a raytracer / renderer command-line application called "rt" that generates pretty pictures. It has a whole slew of command-line options, and this task entails adding support for one more that sets an object's color.
This task is meant to be proof-of-concept, so here's a crash-course:
- Run "mged -c test.g"
- Say 'y' for yes when it asks whether to create a new database
- Select "nu" on the attach prompt so we stay in command-line mode
- Run "make sph sph" to create a sphere
- Run "r sph.r u sph" to make a solid region out of the sphere
- Run "mater sph.r plastic 255 0 0 ." to make the sphere red
- Run "quit" to exit mged
- Run "rt -s1024 -C255/255/255 test.g sph.r" to render the sphere in a 1024x1024 window with a white background specified.
Now your task is to make it so that we can override that sphere's red color (just temporarily) during rt. Make something like this work:
rt -s1024 -C255/255/255 -O0/0/255 test.g sph.r
That will set the 0/0/255 color on the specified sph.r object and it should render blue. That is it!
You won't necessarily need to modify all of those (I did claim this was probably <10 lines after all), but the code you add will probably be to one of those five files. A hint to get you started, look for bu_getopt() and find where -C is getting processed. That may help creating a -O (or similar option if -O is already taken).
Submit your work as a single patch file. See http://brlcad.org/wiki/Patches for help.