Polygonal models exist for lots and lots of objects. To make a coherent scene, however, you need to be able to read and write models to disk, along with manipulation them. For example, tranlating and scaling them. In this assignment you will take existing polygonal models (in PLY format) and 'normalize' them. In particular, translating them so that their average vertex is the origin, and also rescaling them so their sample variance along the x, y and axes are equal to one. This last operation, here called 'rounding', is admitedly contrived in the context of 3D models. However, it is an excellent first step in learning to manipulate models.
You will write a program that takes one argument: an input file name. The input file should be a polygonal model in ASCII PLY format. Your program should read the model file and then 'normalize' the model in two ways.
The first normalization is sometimes called 'centering' and what your code must do is translate the model vertices such that the average vertex becomes the origin. In other words, after this normailzation the average of all the vertices should be the point (0.0, 0.0, 0.0); or as close as double precision floats will allow. The resulting modified model should be written to disk using the same file name as the input with one exception - the text '_centered' should be inserted after the original name and before the '.ply' suffix.
The second normalization rescales the model making it occupy roughly equal amounts of the x, y and z axis. In 'rounding', a set of data points that has already been centered is scaled such that the sample standard deviation along each axis is one. This is related to, but not idientical, to a process called Whitening The resulting modified model should be written to disk using the same file name as the input with one exception - the text '_rounded' should be inserted after the original name and before the '.ply' suffix.
Here is an example of a simple file containing a cube.
Your program should produce output directly comparable to what is shown here.
To help you with this assignment you are being provided before and after examples for two modesl, a cube and a cow.
You are going to be rendering these models in the future. Be sure to build a model object class that includes not only vertices but faces, and make sure that your input is robust. Some of the models have three coordinates per vertex (x, y, z), but have additional values that can be ignored (and don’t need to be written out), but should not cause input problems.
Make a tar file that includes your source files, a makefile if appropriate, and a README.txt file that explicitly tells us (1) how to compile your program and (2) how to execute it. Submit this tar file via the CANVAS assignment. The GTA will unpack your tar file, compile your program, and then test it on some the models you have been given along with other models. Note that your tar file should not contain executable or compiled files, just source files.
There is no “late period”. The program is due when it is due. All work you submit must be your own. You may not copy code from colleagues or the web or anywhere else. Cheating will not be tolerated, and will be handled in accordance with university and department policy.
If you are using C++, your executable should be named 'geonorm' exactly as shown above. If your are using java, the main executable class should be named 'Geonorm'. Notice the change in case for the first letter between C++ and Java.
There were two mistakes in the output originally shown from the sample run. There was an extra line with the text 'before centering' and also the bounding box output used 'x' when it should have used 'z' for the final range. Both of these mistakes have been corrected above.
The description above was clarified to indicate the precise file names needed for both output files generated by your program. Note that the '_centered' and '_rounded' cube and cow files are provided to help you test your own code.
Here is are before and after screen shots of the cow for this assignment.