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 applying manipulations to them. For example, translating, rotating, and scaling them. In this assignment you will take existing polygonal models (in .OBJ format) and apply some 3D transformations to them. In particular, you will be using Axis-Angle Rotation specifications to rotate the model about a given axis, followed by scaling it uniformly along three axes, followed by a translation along three axes. A 'driver' (scene file) - read as an argument by your program - will contain pairs of 3D transformations and object model names to be transformed.
Here is an example of a driver file (driver00.txt):
# You may include comments
model 1.0 0.0 0.0 45 1.0 10.0 10.0
10.0 cube.obj
model 0.0 1.0 0.0 90 1.0 0.0 0.0 0.0
ellelltri.obj
model 0.0 0.0 1.0 30 2.0 -10.0 -10.0 -10.0
cube.obj
The general format is as follows:
model wx wy wz theta scale tx ty tz model.obj
. The keyword
model
identifies that the line is a description model and its transform.
The triplet
wx wy wz
represents the axis about which to rotate followed by
theta
in degrees representing the angle by which to rotate (thus
Axis-Angle format). Next, the
scale
is a uniform scaling factor to shrink or grow a model. Next, the
triplet
tx ty tz
defines a model-to-world translation. Finally,
model.obj
is the model file on which you will be applying the defined 3D
transformation.
Note that the axis of rotation may not be unit length (normalized). Also, the order of transformation is rotate, scale, and then translate. Moreover, there could be multiple model lines in a driver file. This ‘driver’ file will grow over the course of the semester to include camera information, lighting information, and other models such as spheres.
You will write a program that takes a single command line argument:
the driver file name. Your program will read the driver file and
create a memory versions of the objects mentioned in the driver file.
Then, the program will apply corresponding 3D transformations to the
objects. Finally, it will write back to disk a new *.obj file that is
a clone of the corresponding .obj file with FOUR key differences:
1) Your program must write the outputs to a folder named after
driver file. Example: if driver file is named as driver00.txt then
your program writes the new (transformed) .obj files to a folder
named driver00 located where your program is located.
2) The new
file will have “_mw00” appended after the name and before “.obj”.
Example: cube_mw00.obj
3) The order of vertices in this new
*_mw00.obj file will be the same as it was in the original *.obj
file. Also, any line in the original file starting with ‘vn’ should
NOT be written into the new file.
4) The same file, e.g.,
cube.obj may be read twice with different model to world 3D
transformation. If this happens, then the file names must become
Here are three driver files and some models that your program will input. Your program will be tested for seven more driver files that might contain unseen models.
You are going to be rendering these models in the future. Therefore, the best software practice would be to build a model object class that includes not only vertices but faces, and to make sure that your input is robust.
Submit a tar file via the CANVAS assignment page that includes:
If you are using C++, your executable should be named 'modeltoworld' exactly as shown above. If your are using java, the main executable class should be named 'Modeltoworld'. Notice the change in case for the first letter between C++ and Java.
Grading will be based upon 10 distinct tests with 10 driver files involving different combinations of models and transformations, out of which 3 are given to you.
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.
Here are the ideal outputs for the three driver files that are provided to you. As a reminder, your program will be tested on seven more driver files that might contain unseen models.
Moreover, please take a look at which discusses a bit of how we intend to test model files and also provides instructions for how to handle the comments in the input model files while you write out the output files.Here are the test driver files and their outputs: test_transformed_models.tar and test_drivers.tar