Commit 0ed99583 authored by amandaghassaei's avatar amandaghassaei

basic fold working

parent ae08183c
......@@ -228,7 +228,7 @@ filter.edgesAssigned = function(fold, target) {
for (i = k = 0, len = ref.length; k < len; i = ++k) {
assignment = ref[i];
if (assignment === target) {
results.push(i);
results.push(fold.edges_vertices[i]);
}
}
return results;
......
......@@ -845,6 +845,11 @@
<input id="passiveEdgesVisible" data-toggle="checkbox" class="custom-checkbox layersSelector" type="checkbox"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
Undriven Edges <span id="numPassive"></span>
</label>
<label class="checkbox" for="boundaryEdgesVisible">
<input id="boundaryEdgesVisible" data-toggle="checkbox" class="custom-checkbox layersSelector" type="checkbox"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
Boundary Edges <span id="numBoundary"></span>
</label>
</div>
<br/>
</div>
......
......@@ -337,6 +337,10 @@ function initControls(globals){
globals.passiveEdgesVisible = val;
globals.model.updateEdgeVisibility();
});
setCheckbox("#boundaryEdgesVisible", globals.boundaryEdgesVisible, function(val){
globals.boundaryEdgesVisible = val;
globals.model.updateEdgeVisibility();
});
setCheckbox("#meshVisible", globals.meshVisible, function(val){
globals.meshVisible = val;
......
......@@ -19,6 +19,7 @@ function initGlobals(){
valleysVisible: true,
panelsVisible: false,
passiveEdgesVisible: false,
boundaryEdgesVisible: true,
meshVisible: true,
ambientOcclusion: false,
......
......@@ -363,14 +363,11 @@ function initPattern(globals){
if (max.z < scale) scale = max.z;
var strokeWidth = scale/300;
// $mountains.css({'stroke-dasharray': strokeWidth*6 + ', ' + strokeWidth*3 + ', ' + strokeWidth*1.5 + ', ' + strokeWidth*3});
// $valleys.css({'stroke-dasharray': strokeWidth*4 + ', ' + strokeWidth*3 + ', ' + strokeWidth*4 + ', ' + strokeWidth*3});
$paths.css({'stroke-width':strokeWidth});
border.multiplyScalar(scale);
min.sub(border);
max.add(border.multiplyScalar(2));
var viewBoxTxt = min.x + " " + min.z + " " + max.x + " " + max.z;
var ns = 'http://www.w3.org/2000/svg';
var svg = document.createElementNS(ns, 'svg');
svg.setAttribute('viewBox', viewBoxTxt);
......@@ -443,7 +440,7 @@ function initPattern(globals){
foldData = FOLD.convert.vertices_vertices_to_faces_vertices(foldData);
console.log(JSON.stringify(foldData));
// var faces = triangulatePolys(polygons, allEdges);
// var foldData = triangulatePolys(foldData);
vertices = [];
for (var i=0;i<foldData.vertices_coords.length;i++){
......@@ -462,20 +459,19 @@ function initPattern(globals){
$("#numBoundary").html("(" + borders.length + ")");
$("#numPassive").html("(" + hinges.length + ")");
// var allCreaseParams = getFacesAndVerticesForEdges(faces, allEdges);
//
// var allTypes = [borders.length, mountains.length, valleys.length, cuts.length];
//
// globals.model.buildModel(faces, vertices, allEdges, allCreaseParams, allTypes);
var allCreaseParams = getFacesAndVerticesForEdges(foldData);
globals.model.buildModel(foldData.faces_vertices, vertices, foldData.edges_vertices, allCreaseParams, getAllEdges());
}
function getFacesAndVerticesForEdges(faces, allEdges){
function getFacesAndVerticesForEdges(fold){
var allCreaseParams = [];//face1Ind, vertInd, face2Ind, ver2Ind, edgeInd, angle
for (var i=borders.length;i<allEdges.length;i++){
if (i>=borders.length+mountains.length+valleys.length &&
i<borders.length+mountains.length+valleys.length+cuts.length) continue;
var v1 = allEdges[i][0];
var v2 = allEdges[i][1];
var faces = fold.faces_vertices;
for (var i=0;i<fold.edges_vertices.length;i++){
var assignment = fold.edges_assignment[i];
if (assignment == "B" || assignment == "U" || assignment == "C") continue;
var edge = fold.edges_vertices[i];
var v1 = edge[0];
var v2 = edge[1];
var creaseParams = [];
for (var j=0;j<faces.length;j++){
var face = faces[j];
......@@ -500,12 +496,12 @@ function initPattern(globals){
}
creaseParams.push(i);
if (i<(borders.length+mountains.length+valleys.length)){
var angle = allEdges[i][2];
creaseParams.push(angle);
} else {
creaseParams.push(0);
var angle = fold.edges_foldAngles[i];
if (angle === null) {
console.warn("shouldn't be here");
continue;
}
creaseParams.push(angle);
allCreaseParams.push(creaseParams);
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment