Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
30e2f145
Commit
30e2f145
authored
May 29, 2017
by
amandaghassaei
Browse files
update h and coefs dynamically
parent
e5bbfd9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
index.html
View file @
30e2f145
...
@@ -137,7 +137,7 @@
...
@@ -137,7 +137,7 @@
uniform
sampler2D
u_meta
;
//[beamsIndex, numBeam, creaseMeta2Index, numCreases]
uniform
sampler2D
u_meta
;
//[beamsIndex, numBeam, creaseMeta2Index, numCreases]
uniform
sampler2D
u_beamMeta
;
//[k, d, length, otherNodeIndex]
uniform
sampler2D
u_beamMeta
;
//[k, d, length, otherNodeIndex]
uniform
sampler2D
u_creaseMeta
;
//[k, d, targetTheta]
uniform
sampler2D
u_creaseMeta
;
//[k, d, targetTheta]
uniform
sampler2D
u_creaseMeta2
;
//[creaseIndex,
momentArmLength,
nodeIndex]
uniform
sampler2D
u_creaseMeta2
;
//[creaseIndex, nodeIndex
, -, -
]
uniform
sampler2D
u_normals
;
uniform
sampler2D
u_normals
;
uniform
sampler2D
u_theta
;
//[theta, z, normal1Index, normal2Index]
uniform
sampler2D
u_theta
;
//[theta, z, normal1Index, normal2Index]
uniform
sampler2D
u_creaseGeo
;
//[h1, h2, coef1, coef2]
uniform
sampler2D
u_creaseGeo
;
//[h1, h2, coef1, coef2]
...
@@ -207,9 +207,9 @@
...
@@ -207,9 +207,9 @@
float
targetTheta
=
creaseMeta
[
2
]
*
u_creasePercent
;
float
targetTheta
=
creaseMeta
[
2
]
*
u_creasePercent
;
float
angForce
=
creaseMeta
[
0
]
*
(
targetTheta
-
thetas
[
0
]);
// + creaseMeta[1]*thetas[1];
float
angForce
=
creaseMeta
[
0
]
*
(
targetTheta
-
thetas
[
0
]);
// + creaseMeta[1]*thetas[1];
float
nodeNum
=
creaseMeta2
[
2
];
//1, 2, 3, 4
float
nodeNum
=
creaseMeta2
[
1
];
//1, 2, 3, 4
if
(
creaseMeta2
[
3
]
<
0
.0
){
//crease reaction, node is on a crease
if
(
nodeNum
>
2
.0
){
//crease reaction, node is on a crease
//node #1
//node #1
float
normalIndex1D
=
thetas
[
2
];
float
normalIndex1D
=
thetas
[
2
];
...
@@ -223,13 +223,13 @@
...
@@ -223,13 +223,13 @@
scaledNormalsIndex
=
normalsIndex
/
u_textureDimFaces
;
scaledNormalsIndex
=
normalsIndex
/
u_textureDimFaces
;
vec3
normal2
=
texture2D
(
u_normals
,
scaledNormalsIndex
).
xyz
;
vec3
normal2
=
texture2D
(
u_normals
,
scaledNormalsIndex
).
xyz
;
float
coef1
=
crease
Meta2
[
1
];
float
coef1
=
crease
Geo
[
2
];
float
coef2
=
crease
Meta2
[
2
];
float
coef2
=
crease
Geo
[
3
];
//
if (nodeNum == 3.0){
if
(
nodeNum
==
3.0
){
//
coef1 = 1.0-coef1;
coef1
=
1.0
-
coef1
;
//
coef2 = 1.0-coef2;
coef2
=
1.0
-
coef2
;
//
}
}
vec3
_force
=
-
angForce
*
(
coef1
/
creaseGeo
[
0
]
*
normal1
+
coef2
/
creaseGeo
[
1
]
*
normal2
);
vec3
_force
=
-
angForce
*
(
coef1
/
creaseGeo
[
0
]
*
normal1
+
coef2
/
creaseGeo
[
1
]
*
normal2
);
force
+=
_force
;
force
+=
_force
;
...
@@ -375,10 +375,10 @@
...
@@ -375,10 +375,10 @@
vec2
node3Index
=
vec2
(
mod
(
creaseMeta
[
2
],
u_textureDim
.
x
)
+
0.5
,
floor
(
creaseMeta
[
2
]
/
u_textureDim
.
x
)
+
0.5
)
/
u_textureDim
;
vec2
node3Index
=
vec2
(
mod
(
creaseMeta
[
2
],
u_textureDim
.
x
)
+
0.5
,
floor
(
creaseMeta
[
2
]
/
u_textureDim
.
x
)
+
0.5
)
/
u_textureDim
;
vec2
node4Index
=
vec2
(
mod
(
creaseMeta
[
3
],
u_textureDim
.
x
)
+
0.5
,
floor
(
creaseMeta
[
3
]
/
u_textureDim
.
x
)
+
0.5
)
/
u_textureDim
;
vec2
node4Index
=
vec2
(
mod
(
creaseMeta
[
3
],
u_textureDim
.
x
)
+
0.5
,
floor
(
creaseMeta
[
3
]
/
u_textureDim
.
x
)
+
0.5
)
/
u_textureDim
;
vec3
node1
=
texture2D
(
u_
last
Position
,
node1Index
).
xyz
+
texture2D
(
u_
original
Position
,
node1Index
).
xyz
;
vec3
node1
=
texture2D
(
u_
original
Position
,
node1Index
).
xyz
+
texture2D
(
u_
last
Position
,
node1Index
).
xyz
;
vec3
node2
=
texture2D
(
u_
last
Position
,
node2Index
).
xyz
+
texture2D
(
u_
original
Position
,
node2Index
).
xyz
;
vec3
node2
=
texture2D
(
u_
original
Position
,
node2Index
).
xyz
+
texture2D
(
u_
last
Position
,
node2Index
).
xyz
;
vec3
node3
=
texture2D
(
u_
last
Position
,
node3Index
).
xyz
+
texture2D
(
u_
original
Position
,
node3Index
).
xyz
;
vec3
node3
=
texture2D
(
u_
original
Position
,
node3Index
).
xyz
+
texture2D
(
u_
last
Position
,
node3Index
).
xyz
;
vec3
node4
=
texture2D
(
u_
last
Position
,
node4Index
).
xyz
+
texture2D
(
u_
original
Position
,
node4Index
).
xyz
;
vec3
node4
=
texture2D
(
u_
original
Position
,
node4Index
).
xyz
+
texture2D
(
u_
last
Position
,
node4Index
).
xyz
;
vec3
creaseVector
=
node4
-
node3
;
vec3
creaseVector
=
node4
-
node3
;
float
creaseLength
=
length
(
creaseVector
);
float
creaseLength
=
length
(
creaseVector
);
...
@@ -392,11 +392,7 @@
...
@@ -392,11 +392,7 @@
float
dist1
=
sqrt
(
vector1
.
x
*
vector1
.
x
+
vector1
.
y
*
vector1
.
y
+
vector1
.
z
*
vector1
.
z
-
proj1Length
*
proj1Length
);
float
dist1
=
sqrt
(
vector1
.
x
*
vector1
.
x
+
vector1
.
y
*
vector1
.
y
+
vector1
.
z
*
vector1
.
z
-
proj1Length
*
proj1Length
);
float
dist2
=
sqrt
(
vector2
.
x
*
vector2
.
x
+
vector2
.
y
*
vector2
.
y
+
vector2
.
z
*
vector2
.
z
-
proj2Length
*
proj2Length
);
float
dist2
=
sqrt
(
vector2
.
x
*
vector2
.
x
+
vector2
.
y
*
vector2
.
y
+
vector2
.
z
*
vector2
.
z
-
proj2Length
*
proj2Length
);
float
tol
=
0.0001
;
gl_FragColor
=
vec4
(
dist1
,
dist2
,
proj1Length
/
creaseLength
,
proj2Length
/
creaseLength
);
if
(
dist1
<
tol
)
dist1
=
tol
;
if
(
dist2
<
tol
)
dist2
=
tol
;
gl_FragColor
=
vec4
(
dist1
,
dist2
,
(
proj1Length
/
creaseLength
)
/
dist1
,
(
proj2Length
/
creaseLength
)
/
dist2
);
}
}
</script>
</script>
...
...
js/crease.js
View file @
30e2f145
...
@@ -103,6 +103,7 @@ Crease.prototype.getNodeIndex = function(node){
...
@@ -103,6 +103,7 @@ Crease.prototype.getNodeIndex = function(node){
else
if
(
node
==
this
.
node2
)
return
2
;
else
if
(
node
==
this
.
node2
)
return
2
;
else
if
(
node
==
this
.
edge
.
nodes
[
0
])
return
3
;
else
if
(
node
==
this
.
edge
.
nodes
[
0
])
return
3
;
else
if
(
node
==
this
.
edge
.
nodes
[
1
])
return
4
;
else
if
(
node
==
this
.
edge
.
nodes
[
1
])
return
4
;
console
.
log
(
"
unknown node type
"
);
return
0
;
return
0
;
};
};
...
...
js/dynamic/dynamicSolver.js
View file @
30e2f145
...
@@ -26,8 +26,7 @@ function initDynamicSolver(globals){
...
@@ -26,8 +26,7 @@ function initDynamicSolver(globals){
var
normals
;
var
normals
;
var
faceVertexIndices
;
//[a,b,c]
var
faceVertexIndices
;
//[a,b,c]
var
creaseMeta
;
//[k, d, targetTheta]
var
creaseMeta
;
//[k, d, targetTheta]
var
creaseMeta2
;
//[creaseIndex (thetaIndex), length to node, nodeIndex (1/2), 0] - this is for nodes which are opposite the crease
var
creaseMeta2
;
//[creaseIndex (thetaIndex), nodeIndex (1/2/3/4), -, -]
//[creaseIndex (thetaIndex), coef1, coef2, -1] - this is for nodes which are on the crease
var
creaseMeta3
;
//[node1Index, node2Index, node3index, node4index]//nodes 1 and 2 are opposite crease, 3 and 4 are on crease
var
creaseMeta3
;
//[node1Index, node2Index, node3index, node4index]//nodes 1 and 2 are opposite crease, 3 and 4 are on crease
var
creaseGeo
;
//[h1, h2, coef1, coef2]
var
creaseGeo
;
//[h1, h2, coef1, coef2]
var
creaseVectors
;
//indices of crease nodes
var
creaseVectors
;
//indices of crease nodes
...
@@ -511,15 +510,12 @@ function initDynamicSolver(globals){
...
@@ -511,15 +510,12 @@ function initDynamicSolver(globals){
meta
[
i
*
4
+
3
]
=
nodeCreases
.
length
+
nodeInvCreases
.
length
;
meta
[
i
*
4
+
3
]
=
nodeCreases
.
length
+
nodeInvCreases
.
length
;
for
(
var
j
=
0
;
j
<
nodeCreases
.
length
;
j
++
){
for
(
var
j
=
0
;
j
<
nodeCreases
.
length
;
j
++
){
creaseMeta2
[
index
*
4
]
=
nodeCreases
[
j
].
getIndex
();
creaseMeta2
[
index
*
4
]
=
nodeCreases
[
j
].
getIndex
();
creaseMeta2
[
index
*
4
+
2
]
=
nodeCreases
[
j
].
getNodeIndex
(
nodes
[
i
]);
//type 1, 2, 3, 4
creaseMeta2
[
index
*
4
+
1
]
=
nodeCreases
[
j
].
getNodeIndex
(
nodes
[
i
]);
//type 1, 2, 3, 4
//creaseMeta2[index*4+2] = 0 tells us that it is a node opposite a crease
index
++
;
index
++
;
}
}
for
(
var
j
=
0
;
j
<
nodeInvCreases
.
length
;
j
++
){
for
(
var
j
=
0
;
j
<
nodeInvCreases
.
length
;
j
++
){
creaseMeta2
[
index
*
4
]
=
nodeInvCreases
[
j
].
getIndex
();
creaseMeta2
[
index
*
4
]
=
nodeInvCreases
[
j
].
getIndex
();
creaseMeta2
[
index
*
4
+
1
]
=
nodeInvCreases
[
j
].
getCoef1
(
nodes
[
i
]);
creaseMeta2
[
index
*
4
+
1
]
=
nodeInvCreases
[
j
].
getNodeIndex
(
nodes
[
i
]);
//type 1, 2, 3, 4
creaseMeta2
[
index
*
4
+
2
]
=
nodeInvCreases
[
j
].
getCoef2
(
nodes
[
i
]);
creaseMeta2
[
index
*
4
+
3
]
=
-
1
;
//this tells us that it is node on a crease
index
++
;
index
++
;
}
}
}
}
...
...
js/pattern.js
View file @
30e2f145
...
@@ -717,7 +717,7 @@ function initPattern(globals){
...
@@ -717,7 +717,7 @@ function initPattern(globals){
if
(
!
containsInnerCrease
)
{
if
(
!
containsInnerCrease
)
{
polygons
.
splice
(
i
,
1
);
polygons
.
splice
(
i
,
1
);
polygonEdges
.
splice
(
i
,
1
);
polygonEdges
.
splice
(
i
,
1
);
break
;
//todo only remove once
//
break;//todo only remove once
}
}
}
}
...
...
Write
Preview
Supports
Markdown
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