Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zack Elliott #2

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vscode/.browse.VC.db
Binary file not shown.
Binary file added .vscode/.browse.VC.db-wal
Binary file not shown.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# [Project2: Toolbox Functions](https://github.com/CIS700-Procedural-Graphics/Project2-Toolbox-Functions)

## Description

I'm not a very good sketcher, so this project was pretty challenging. I spent a lot of time browsing realistic images of wings, feather distributions, and flapping patterns, and struggled to bring a lot of them to life in my implementation. That being said, I learned a lot about toolbox functions in this project, which was cool.

#### Wing shape

The shape of the wing is a cubic spline, with two of the endpoints connected with a straight line to make a curved 3D plane. It's not the most realistic shape of a wing, but I thought it looked neat. I added GUI functionality to modify the 4 control points of the spline so that I could quickly move the points around and create the curve shape I wanted.

#### Wing flapping

I defined five stroke "positions" (various low/mid/high strokes) and attempted to make my wing flap by interpolating my spline's control points to the various flap positions. That is, if my wing begins in stroke position 1, it first interpolates to stroke position 2, then stroke position 3, and so on. These stroke positions are defined in the `coordinates.js` file. Given that I am using basic LERP to transform my spline, the flapping motion looks as though it is broken down into five steps, unfortunately. I tried to use smooth step & sine curves to make the flapping smoother, to no avail. If given more time, I would have defined another cubic spline by the five stroke position points that I would have moved my wing along.

#### Feathers

Feathers are positioned around the curved portion of the wing in three separate layers. Each layer has customizable sizes, colors, and feather distributions. One of the things I struggled with was getting the feathers to "point" in the correct direction. Given I flap my wing by moving my spline's control points, the feathers occasionally point in an incorrect direction, and it's pretty difficult to calculate the correct axis and angle to use to rotate each feather during flapping. In hindsight, I would have **not** used control points to flap my wing, and instead used normal matrix rotations & translations. I would have constructed a scene-graph implementation where the feathers are children of the wing root node. This way, the feathers would trivially point in the correct direction, regardless of the wing's overall rotation.

#### Wind

Based upon the wind direction and strength, I vibrate the feathers in a specific direction.

#### GUI

Many, many aspects of this implementation can be modified in the GUI. This includes (1) which portions of the wing are visible (control points, outline, feathers, etc...), (2) whether or not the wing is flapping or wind exists, (3) various feather customizations, and (4) the wing's overall shape.

## Overview

The objective of this assignment is to procedurally model and animate a bird wing. Let's get creative!
Expand All @@ -18,7 +42,7 @@ Begin with a 3D curve for your basic wing shape. Three.js provides classes to cr

##### Distribute feathers

We have provided a simple feather model from which to begin. You are not required to use this model if you have others that you prefer. From this base, you must duplicate the feather to model a complete wing, and your wing should consist of at least thirty feathers. Distribute points along the curve you created previously; you will append the feather primitives to the curve at these points. Make sure that you modify the size, orientation, and color of your feathers depending on their location on the wing.
We have provided a simple feather model from which to begin. You are not required to use this model if you have others that you prefer. From this base, you must duplicate the feather to model a complete wing, and your wing should consist of at least thirty feathers. Distribute points along the curve you created previously; you will append the feather primitives to the curve at these points. Make sure that you modify the size, orientation, and color of your feathers depending on their location on the wing.

Feel free to diversify your wings by using multiple base feather models.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"scripts": {
"start": "webpack-dev-server --hot --inline",
"build": "webpack",
"deploy": "rm -rf npm-debug.log && git checkout master && git commit -am 'update' && gh-pages-deploy"
"deploy": "gh-pages-deploy"
},
"gh-pages-deploy": {
"prep": [
Expand Down
Binary file added references/wing-flapping-1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added references/wing-flapping-2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added references/wing-flapping-3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions src/coordinates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
A: {
A: { x: -20, y: 0, z: 0 },
B: { x: -5, y: -15, z: 0 },
C: { x: 20, y: -15, z: 0 },
D: { x: 10, y: 0, z: 0 }
},
B: {
A: { x: 0, y: 0, z: -25 },
B: { x: 10, y: 0, z: -20 },
C: { x: 20, y: 0, z: -5 },
D: { x: 10, y: 0, z: 0 }
},
C: {
A: { x: 5, y: 0, z: -15 },
B: { x: 10, y: 0, z: -10 },
C: { x: 20, y: 0, z: -5 },
D: { x: 10, y: 0, z: 0 }
},
D: {
A: { x: -20, y: 0, z: 0 },
B: { x: -5, y: -15, z: 0 },
C: { x: 20, y: -15, z: 0 },
D: { x: 10, y: 0, z: 0 }
},
E: {
A: { x: 0, y: 0, z: 25 },
B: { x: 10, y: 0, z: 20 },
C: { x: 20, y: 0, z: 5 },
D: { x: 10, y: 0, z: 0 }
}
}
16 changes: 16 additions & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
smoothstep: function (a, b, t) {
var c = Math.max(0, Math.min(1, (t - a) / (b - a)));
return c * c * (3 - 2 * c);
},

smootherstep: function (a, b, t) {
var c = Math.max(0, Math.min(1, (t - a) / (b - a)));
return c * c * c * (c * (c * 6 - 15) + 10);
},

bezier: function (a, b, c, t) {
var c = (a * t * t) + (b * 2 * t * (1 - t)) + (c * (1 - t) * (1 - t));
return c;
}
}
Loading