66 lines
2.2 KiB
Markdown
66 lines
2.2 KiB
Markdown
# Building and Running
|
|
|
|
Clone the repository, navigate to the root of the project, and initialize the
|
|
submodules:
|
|
|
|
```sh
|
|
git clone https://github.com/humanoidsandvichdispenser/cs381.git
|
|
cd cs381
|
|
git submodule update --init --recursive
|
|
```
|
|
|
|
Navigate to the `as2` directory, create a build directory, and run CMake to
|
|
generate the build files:
|
|
|
|
```sh
|
|
cd as2
|
|
mkdir -p build
|
|
cd build
|
|
cmake ..
|
|
```
|
|
|
|
Compile the code using `make`:
|
|
|
|
```sh
|
|
make
|
|
```
|
|
|
|
This should create an executable named `as2` in the `build` directory. You can
|
|
run the executable with the following command:
|
|
|
|
```sh
|
|
./as2
|
|
```
|
|
|
|
# Extra credit
|
|
|
|
The models spin at a rate of 10 degrees per second.
|
|
|
|
# Readme Question
|
|
|
|
The `DrawBoundedModel` function takes a model and transformer lambda function
|
|
as parameters. We use this because the lambda defines the transformation for
|
|
this particular draw call without affecting the model's original transformation
|
|
matrix. This allows us to apply different transformations to the same model
|
|
when drawing it multiple times. It also consistently draws the model with a
|
|
bounding box that respects the transformations. The function does both of these
|
|
operations atomically, so you don't have to worry about forgetting to apply the
|
|
transform or draw the bounding box separately.
|
|
|
|
The same function could be used in the future after the model has been loaded
|
|
to apply transforms that are not known at load time and temporary transforms
|
|
that only apply under specific conditions. For example, we could make the model
|
|
spin by constantly applying a transformation on the identity transform with a
|
|
rotation value that changes over time that only applies if a specific key is
|
|
being held.
|
|
|
|
The same function can also be used for transforms relative to the parent. In
|
|
the lambda, we could multiply the transform passed to the function by a parent
|
|
transform to get a final transform that is relative to the parent.
|
|
|
|
The leftmost penguin looks funny because the model only has half of the
|
|
penguin. In its default orientation, the faces of the model are away from the
|
|
camera (the surface normal points away), so the back faces are culled and the
|
|
model almost appears invisible. When the model is rotated, the faces are no
|
|
longer culled and the model looks normal.
|