-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Main update with finished product (uncompiled)
- Loading branch information
Zachary Ferguson
committed
Aug 30, 2015
1 parent
30598fa
commit 58df911
Showing
55 changed files
with
1,907,773 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<html> | ||
<body> | ||
<br> | ||
<center> | ||
<b>3D Vertex Picking</b><br> | ||
Zachary Ferguson | ||
</center> | ||
<br><hr><br> | ||
Let E be the Eye world coordinates, C be the viewing direction where |C| is the | ||
viewing distance, U be the up vector, and θ and φ are the view half | ||
angles.<br> | ||
<br> | ||
Convert the point selected in Normalized Device Coordinates to world coordinates | ||
and use it to create a ray equation in 3D space. | ||
<br> | ||
<strong>Step 1:</strong> Compute the horizontal screen vector, H, at the point | ||
E. | ||
<ol> | ||
<li> | ||
A = C <font face="arial">x</font> U, where A||H and starts at E. | ||
</li> | ||
<li> | ||
H = (A*|C|*tan(θ))/(|A|), rescale A to H. | ||
</li> | ||
</ol> | ||
<strong>Step 2:</strong> Compute the vertical screen vector, V, at the point E. | ||
<ol> | ||
<li> | ||
B = A <font face="arial">x</font> C, where B||V and starts at E. | ||
</li> | ||
<li> | ||
V = (B*|C|*tan(φ))/(|B|), rescale B to V. | ||
</li> | ||
</ol> | ||
<strong>Step 3:</strong> Compute the midpoint of the screen, M. | ||
<ol> | ||
<li> | ||
M = E + C. | ||
</li> | ||
</ol> | ||
<strong>Step 4:</strong> Compute P, the point in world 2D coordinates that the | ||
user points at, given the point in Normalized Device Coordinates, | ||
(s<sub>x</sub>, s<sub>y</sub>), | ||
where 0 ≤ s<sub>x</sub> ≤ 1 and 0 ≤ s<sub>y</sub> ≤ 1. | ||
<ol> | ||
<li> | ||
P = M + (2s<sub>x</sub>-1)*H + (2s<sub>y</sub>-1)*V. | ||
</li> | ||
</ol> | ||
<strong>Step 5:</strong> Compute the ray equation, R. | ||
<ol> | ||
<li> | ||
R = E + (t*(P - E))/(|P-E|), where t is the independent variable. | ||
</li> | ||
</ol> | ||
Check for the vertices that the ray passes through, within a radius of r from | ||
the vertex. | ||
<br> | ||
<strong>Step 6:</strong> For each vertex, v, in the mesh, compute the distance | ||
from v to the ray, R, computed in step 5. If the distance is less than or equal | ||
to r, then select that vertex. | ||
<ol> | ||
<li> | ||
R<sub>01</sub> = R(1) - R(0), where R<sub>01</sub> is the direction | ||
vector of the ray. | ||
</li> | ||
<li> | ||
d = |(R<sub>01</sub> <font face="arial">x</font> (v - R(0)))|, where d | ||
is the distance from the point to the ray and R(0) is the rays origin. | ||
</li> | ||
<li> | ||
If d ≤ r, then select v. | ||
</li> | ||
</ol> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
3D Vertex Picking | ||
Zachary Ferguson | ||
|
||
Let E be the Eye world coordinates, C be the viewing direction where |C| is the | ||
viewing distance, U be the up vector, and theta and phi are the view half | ||
angles. | ||
|
||
Convert the point selected in Normalized Device Coordinates to world coordinates | ||
and use it to create a ray equation in 3D space. | ||
|
||
Step 1: Compute the horizontal screen vector, H, at the point E. | ||
|
||
a. A = C x U, where A||H and starts at E. | ||
b. H = (A*|C|*tan(theta))/(|A|), rescale A to H. | ||
|
||
Step 2: Compute the vertical screen vector, V, at the point E. | ||
|
||
a. B = A x C, where B||V and starts at E. | ||
b. V = (B*|C|*tan(phi))/(|B|), rescale B to V. | ||
|
||
Step 3: Compute the midpoint of the screen, M. | ||
|
||
a. M = E + C. | ||
|
||
Step 4: Compute P, the point in world 2D coordinates that the user points at, | ||
given the point in Normalized Device Coordinates, (s_x, s_y), where | ||
0 <= s_x <= 1 and 0 <= s_y <= 1. | ||
|
||
a. P = M + (2*s_x - 1) * H + (2*s_y - 1) * V. | ||
|
||
Step 5: Compute the ray equation, R. | ||
|
||
a. R = E + (t*(P - E))/(|P-E|), where t is the independent variable. | ||
|
||
Check for the vertices that the ray passes through, within a radius of r from | ||
the vertex. | ||
|
||
Step 6: For each vertex, v, in the mesh, compute the distance from v to the ray, | ||
R, computed in step 5. If the distance is less than or equal to r, then select | ||
that vertex. | ||
|
||
a. R_01 = R(1) - R(0), where R_01 is the direction vector of the ray. | ||
b. d = |(R_01 x (v - R(0)))|, where d is the distance from the point to the | ||
ray and R(0) is the rays origin. | ||
c. If d <= r, then select v. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<html> | ||
<body> | ||
<br> | ||
<center> | ||
<b>Fractalized Mesh Algorithm</b><br> | ||
Zachary Ferguson | ||
</center> | ||
<br><hr><br> | ||
<strong>Step 1:</strong> Sub-divide the mesh to create new vertices between the | ||
original ones. | ||
<ol> | ||
<li> | ||
Use the original mesh to create a new mesh. | ||
</li> | ||
<li> | ||
Copy over the values of the original mesh. | ||
</li> | ||
<li> | ||
Add new rows and cols between the original rows and cols while copying. | ||
<br> | ||
These new vertices' heights should be the average of the adjacent | ||
original vertices' heights. | ||
</li> | ||
</ol> | ||
|
||
<strong>Step 2:</strong> Change the new vertices' height value to a value | ||
specified by a random function. <br> | ||
The range of the random function is half the previous range that the fractalize | ||
function was called. | ||
<ol> | ||
<li> | ||
Iterate over the new vertices | ||
</li> | ||
<li> | ||
Change their heights by the result of the random function. | ||
</li> | ||
</ol> | ||
|
||
<strong>Step 3:</strong> Set the mesh to be drawn to the newly fractalized mesh. | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Step 1: Sub-divide the mesh to create new vertices between the original ones. | ||
|
||
a.Use the original mesh to create a new mesh. | ||
b.Copy over the values of the original mesh. | ||
c.Add new rows and cols between the original rows and cols while copying. | ||
|
||
Step 2: Change the new vertices' height value to a value specified by a random | ||
function. The range of the random function is half the previous range that the | ||
fractalize function was called. | ||
|
||
a. Iterate over the new vertices | ||
b. Set their height to be the result of the random function. | ||
|
||
Step 3: Set the mesh to be drawn to the newly fractalized mesh. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* Copies this mesh into a larger mesh and fractalizes it with a */ | ||
/* range of deltaH. */ | ||
Mesh* Mesh::fractalize(float deltaH) const | ||
{ | ||
/* Get the first and last vertex to calculate the width and depth. */ | ||
vec4 begin = this->getVertex(0,0); | ||
vec4 end = this->getVertex(this->getRows() - 1, this->getCols() - 1); | ||
/* Create a new larger mesh. */ | ||
Mesh* newMesh = new Mesh((this->getRows()*2)-2, (this->getCols()*2)-2, | ||
end[0] - begin[0], end[2] - begin[2], this->color, | ||
this->snowCapHeight); | ||
|
||
/* Copy over the original values of the Mesh to the new mesh's even */ | ||
/* indecies. Run time complexity of O((r*c)/4). */ | ||
for (unsigned int newRow = 0, originalRow = 0; newRow < newMesh->getRows(); | ||
newRow+=2, originalRow++) | ||
{ | ||
for (unsigned int newCol = 0, originalCol = 0; newCol < newMesh-> | ||
getCols(); newCol+=2, originalCol++) | ||
{ | ||
newMesh->setVertex(newRow, newCol, | ||
this->getVertex(originalRow, originalCol)); | ||
} | ||
} | ||
|
||
/* Create new vectors that are averages of the original mesh's vectors. */ | ||
/* Run time complexity of O((r*c)/4). */ | ||
for (unsigned int r = 0; r < newMesh->getRows(); r+=2) | ||
{ | ||
for (unsigned int c = 1; c < newMesh->getCols(); c+=2) | ||
{ | ||
vec4 prev = newMesh->getVertex(r, c - 1); | ||
vec4 next = newMesh->getVertex(r, c + 1); | ||
newMesh->setVertex(r, c, vec4((prev[0]+next[0])/2.0f, | ||
(prev[1]+next[1])/2.0f, (prev[2]+next[2])/2.0f, 1.0)); | ||
} | ||
} | ||
|
||
/* Create new rows that are average of the above and below column */ | ||
/* values. Run time complexity of O((r*c)/2). */ | ||
for (unsigned int r = 1; r < newMesh->getRows(); r+=2) | ||
{ | ||
for (unsigned int c = 0; c < newMesh->getCols(); c++) | ||
{ | ||
vec4 prev = newMesh->getVertex(r-1, c); | ||
vec4 next = newMesh->getVertex(r+1, c); | ||
newMesh->setVertex(r, c, vec4((prev[0]+next[0])/2.0f, | ||
(prev[1]+next[1])/2.0f, (prev[2]+next[2])/2.0f, 1.0)); | ||
} | ||
} | ||
|
||
return newMesh; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<html> | ||
<body> | ||
<br> | ||
<center> | ||
<b>Catmull-Clark Subdivision Algorithm</b><br> | ||
Zachary Ferguson | ||
</center> | ||
<br><hr><br> | ||
<strong>Step 1:</strong> For each face in the mesh, create a new vertex at the | ||
center of the face. | ||
<ol> | ||
<li> | ||
Average the face vertices' x, y, and z values. | ||
</li> | ||
<li> | ||
Create a new vertex with these x, y, and z (center vertex). | ||
</li> | ||
</ol> | ||
|
||
<strong>Step 2:</strong> For each edge in the mesh, create a new edge midpoint | ||
vertex that is the average of the adjacent edge vertices and the adjacent face | ||
vertices. | ||
<ol> | ||
<li> | ||
Sum the two adjacent edge vertices and the two adjacent face vertices | ||
created in "Step 1". | ||
</li> | ||
<li> | ||
Divide this sum by four to yield the new edge vertex. | ||
</li> | ||
</ol> | ||
<strong>Step 3:</strong> Update the original vertices to be an weighted average | ||
of the surrounding face centres, new edge midpoints, and vertex. | ||
<ol> | ||
<li> | ||
Sum all of the face vertices for the faces that the vertex is part of, | ||
then divide the sum by the number of edges connected to the vertex. | ||
</li> | ||
<li> | ||
Sum all of the midpoints of the edges that the vertex is part of, then | ||
multiply the sum by two and divide by the number of edges connected to the | ||
vertex. | ||
</li> | ||
<li> | ||
Multiply the vertex that is being updated by the number of edges | ||
connected to the vertex minus three and then divide by the number of | ||
edges connected to the vertex. | ||
</li> | ||
<li> | ||
Update the vertex being updated to be the sum of the results from 1, 2, | ||
and 3. | ||
</li> | ||
</ol> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Step 1: For each face in the mesh, create a new vertex at the center of the | ||
face. | ||
|
||
a. Average the face vertices' x, y, and z values. | ||
b. Create a new vertex with these x, y, and z (center vertex). | ||
|
||
Step 2: For each edge in the mesh, create a new edge midpoint vertex that is the | ||
average of the adjacent edge vertices and the adjacent face vertices. | ||
|
||
a. Sum the two adjacent edge vertices and the two adjacent face vertices | ||
created in "Step 1". | ||
b. Divide this sum by four to yield the new edge vertex. | ||
|
||
Step 3: Update the original vertices to be an weighted average of the | ||
surrounding face centres, new edge midpoints, and vertex. | ||
|
||
a. Sum all of the face vertices for the faces that the vertex is part of, | ||
then divide the sum by the number of edges connected to the vertex. | ||
b. Sum all of the midpoints of the edges that the vertex is part of, then | ||
multiply the sum by 2 and divide by the number of edges connected to the | ||
vertex. | ||
c. Multiply the vertex that is being updated by (the number of edges | ||
connected to the vertex - 3) and then divide by the number of edges | ||
connected to the vertex. | ||
d. Update the vertex being updated to be the sum of the results from a, b, | ||
and c. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.30501.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CS351_FP_FERGUSON", "CS351_FP_FERGUSON.vcxproj", "{5F5D63DB-5BC0-4F1F-8861-D407A15420BC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Win32 = Debug|Win32 | ||
Release|Win32 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5F5D63DB-5BC0-4F1F-8861-D407A15420BC}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{5F5D63DB-5BC0-4F1F-8861-D407A15420BC}.Debug|Win32.Build.0 = Debug|Win32 | ||
{5F5D63DB-5BC0-4F1F-8861-D407A15420BC}.Release|Win32.ActiveCfg = Release|Win32 | ||
{5F5D63DB-5BC0-4F1F-8861-D407A15420BC}.Release|Win32.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.