Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
5720d271
Commit
5720d271
authored
May 01, 2017
by
amandaghassaei
Browse files
update crease vector
parent
7945e46a
Changes
2
Hide whitespace changes
Inline
Side-by-side
index.html
View file @
5720d271
...
...
@@ -256,7 +256,7 @@
float
dotNormals
=
dot
(
normal1
,
normal2
);
//normals are already normalized, no need to divide by length
if
(
dotNormals
<
-
1.0
)
dotNormals
=
-
1.0
;
else
if
(
dotNormals
>
1.0
)
dotNormals
=
1.0
;
float
theta
=
acos
(
dotNormals
);
//
float theta = acos(dotNormals);
vec2
creaseVectorIndices
=
texture2D
(
u_creaseVectors
,
scaledFragCoord
).
xy
;
vec2
creaseNodeIndex
=
vec2
(
mod
(
creaseVectorIndices
[
0
],
u_textureDim
.
x
)
+
0.5
,
floor
(
creaseVectorIndices
[
0
]
/
u_textureDim
.
x
)
+
0.5
);
...
...
@@ -266,10 +266,15 @@
scaledNodeIndex
=
creaseNodeIndex
/
u_textureDim
;
vec3
node1
=
texture2D
(
u_lastPosition
,
scaledNodeIndex
).
xyz
+
texture2D
(
u_originalPosition
,
scaledNodeIndex
).
xyz
;
vec3
creaseVector
=
node0
-
node1
;
//https://math.stackexchange.com/questions/47059/how-do-i-calculate-a-dihedral-angle-given-cartesian-coordinates
vec3
creaseVector
=
normalize
(
node1
-
node0
);
float
x
=
dotNormals
;
float
y
=
dot
(
cross
(
normal1
,
creaseVector
),
normal2
);
float
sign
=
dot
(
cross
(
normal1
,
normal2
),
creaseVector
);
if
(
sign
<
0.0
)
theta
*=
-
1.0
;
float
theta
=
atan
(
y
,
x
);
//float sign = dot(cross(normal1, normal2), creaseVector);
//if (sign
<
0.0
)
theta
*=
-
1.0
;
float
diff
=
theta
-
lastTheta
[
0
];
float
projectedTheta
=
lastTheta
[
0
]
+
lastTheta
[
1
]
*
u_dt
;
if
(
diff
<
-
5.0
)
{
...
...
@@ -279,7 +284,7 @@
diff
-=
TWO_PI
;
theta
=
lastTheta
[
0
]
+
diff
;
}
gl_FragColor
=
vec4
(
theta
,
diff
,
lastTheta
[
2
],
lastTheta
[
3
]);
//[theta, w, normal1Index, normal2Index]
gl_FragColor
=
vec4
(
theta
,
creaseVectorIndices
[
1
]
,
lastTheta
[
2
],
lastTheta
[
3
]);
//[theta, w, normal1Index, normal2Index]
}
</script>
...
...
js/dynamic/dynamicModel.js
View file @
5720d271
...
...
@@ -150,7 +150,8 @@ function initDynamicModel(globals){
gpuMath
.
setProgram
(
"
thetaCalc
"
);
gpuMath
.
setSize
(
textureDimCreases
,
textureDimCreases
);
gpuMath
.
step
(
"
thetaCalc
"
,
[
"
u_normals
"
,
"
u_lastTheta
"
,
"
u_creaseVectors
"
,
"
u_lastPosition
"
,
"
u_originalPosition
"
],
"
u_theta
"
);
gpuMath
.
step
(
"
thetaCalc
"
,
[
"
u_normals
"
,
"
u_lastTheta
"
,
"
u_creaseVectors
"
,
"
u_lastPosition
"
,
"
u_originalPosition
"
],
"
u_theta
"
);
gpuMath
.
setProgram
(
"
velocityCalc
"
);
gpuMath
.
setSize
(
textureDim
,
textureDim
);
...
...
@@ -380,8 +381,8 @@ function initDynamicModel(globals){
var
rgbaIndex
=
i
*
4
;
var
nodes
=
creases
[
i
].
edge
.
nodes
;
// this.vertices[1].clone().sub(this.vertices[0]);
creaseVectors
[
rgbaIndex
]
=
nodes
[
0
];
creaseVectors
[
rgbaIndex
+
1
]
=
nodes
[
1
];
creaseVectors
[
rgbaIndex
]
=
nodes
[
0
]
.
getIndex
()
;
creaseVectors
[
rgbaIndex
+
1
]
=
nodes
[
1
]
.
getIndex
()
;
// creaseVectors[rgbaIndex] = -vector.x;
// creaseVectors[rgbaIndex+1] = -vector.y;
// creaseVectors[rgbaIndex+2] = -vector.z;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment