Commit 1678733f authored by amandaghassaei's avatar amandaghassaei

ui

parent 6039dba4
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
vec4 neighborIndices = texture2D(u_meta, scaledFragCoord); vec4 neighborIndices = texture2D(u_meta, scaledFragCoord);
vec2 meta = texture2D(u_meta, scaledFragCoord).xy; vec2 meta = texture2D(u_meta, scaledFragCoord).xy;
for (int j=0;j<100;j++){//for all beams for (int j=0;j<100;j++){//for all beams (up to 100, had to put a const int in here)
if (j >= int(meta[1])) break; if (j >= int(meta[1])) break;
float beamIndex1D = meta[0]+float(j); float beamIndex1D = meta[0]+float(j);
...@@ -201,30 +201,31 @@ ...@@ -201,30 +201,31 @@
</div> </div>
<br/><br/> <br/><br/>
<div class="dynamicSim"> <div class="dynamicSim">
Dynamic Sim Settings:<br/> <div class="paddingBottom">Dynamic Sim Settings:</div>
<div class="indent"> <div class="indent">
<div class="sliderContainer"> <div class="sliderContainer">
<span class="label-slider">Damping : </span><div id="damping" class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div><br/> <span class="label-slider">Damping : </span><div id="damping" class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div><br/>
</div> </div>
<a href="#" id="resetDynamicSim" class="btn btn-lg btn-default">Replay Dynamic Simulation</a> <a href="#" id="resetDynamicSim" class="paddingBottom btn btn-lg btn-default">Replay Dynamic Simulation</a>
<div>&Delta; t = <span id="deltaT"></span> seconds</div>
</div> </div>
</div> </div>
<div id="extraSpace"></div> <div id="extraSpace"></div>
</div> </div>
<div id="controls"> <div id="controls">
<a href="#" id="about" class="btn btn-lg btn-default">About</a><br/><br/> <a href="#" id="about" class="btn btn-lg btn-default">About</a><br/><br/>
<!--<div class="sliderInput" id="density">--> <div class="sliderInput" id="axialStiffness">
<!--<span class="label-slider">Density : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>--> <span class="label-slider">Axial Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>
<!--<input value="" placeholder="" class="form-control int" type="text">--> <input value="" placeholder="" class="form-control int" type="text">
<!--</div>--> </div>
<!--<div class="sliderInput" id="width">--> <div class="sliderInput" id="creaseStiffness">
<!--<span class="label-slider">Width (m) : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>--> <span class="label-slider">Crease Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>
<!--<input value="" placeholder="" class="form-control int" type="text">--> <input value="" placeholder="" class="form-control int" type="text">
<!--</div>--> </div>
<!--<div class="sliderInput" id="length">--> <div class="sliderInput" id="panelStiffness">
<!--<span class="label-slider">Length (m) : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>--> <span class="label-slider">Panel Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>
<!--<input value="" placeholder="" class="form-control int" type="text">--> <input value="" placeholder="" class="form-control int" type="text">
<!--</div>--> </div>
<!--<a href="#" id="addRemoveFixed" class="btn btn-lg btn-default">Add/Remove Fixed Constraint</a>--> <!--<a href="#" id="addRemoveFixed" class="btn btn-lg btn-default">Add/Remove Fixed Constraint</a>-->
<!--<span class="titleSpan">Available Materials:</span>--> <!--<span class="titleSpan">Available Materials:</span>-->
<!--<div id="materialTypes" class="indent">--> <!--<div id="materialTypes" class="indent">-->
......
...@@ -36,10 +36,32 @@ function initControls(globals){ ...@@ -36,10 +36,32 @@ function initControls(globals){
globals.schematicVisible = val; globals.schematicVisible = val;
}); });
setSlider("#damping", globals.percentDamping, 0.01, 1, 0.01, function(val){ setSliderInput("#axialStiffness", globals.axialStiffness, 1, 1000, 1, function(val){
globals.axialStiffness = val;
globals.dynamicModel.updateMaterials();
});
setSliderInput("#creaseStiffness", globals.creaseStiffness, 1, 1000, 1, function(val){
globals.creaseStiffness = val;
});
setSliderInput("#panelStiffness", globals.panelStiffness, 1, 1000, 1, function(val){
globals.panelStiffness = val;
});
setSlider("#damping", globals.percentDamping, 0, 1, 0.01, function(val){
globals.percentDamping = val; globals.percentDamping = val;
}, function(){ }, function(){
// globals.resetSimFromInitialState(); globals.dynamicModel.updateMaterials();
globals.dynamicModel.reset();
});
function setDeltaT(val){
$("#deltaT").html(val.toFixed(4));
}
setLink("#resetDynamicSim", function(){
globals.dynamicModel.reset();
}); });
function setButtonGroup(id, callback){ function setButtonGroup(id, callback){
...@@ -200,7 +222,8 @@ function initControls(globals){ ...@@ -200,7 +222,8 @@ function initControls(globals){
} }
return { return {
update:update update:update,
setDeltaT: setDeltaT
} }
} }
...@@ -65,16 +65,6 @@ function initDynamicModel(globals){ ...@@ -65,16 +65,6 @@ function initDynamicModel(globals){
object3D.visible = state; object3D.visible = state;
} }
function setSelfWeight(){
// console.log(nodes[0].getSelfWeight().length());
for (var i=0;i<nodes.length;i++){
var node = nodes[i];
if (globals.applySelfWeight) globals.schematic.forces[i].setSelfWeight(node.getSelfWeight());
else globals.schematic.forces[i].setSelfWeight(new THREE.Vector3(0,0,0));
}
globals.forceArrayUpdated();
}
function solveStep(){ function solveStep(){
if (globals.forceHasChanged){ if (globals.forceHasChanged){
...@@ -85,9 +75,9 @@ function initDynamicModel(globals){ ...@@ -85,9 +75,9 @@ function initDynamicModel(globals){
updateFixed(); updateFixed();
globals.fixedHasChanged = false; globals.fixedHasChanged = false;
} }
if (globals.dynamicSimMaterialsChanged){ if (globals.materialHasChanged){
updateMaterials(); updateMaterials();
globals.dynamicSimMaterialsChanged = false; globals.materialHasChanged = false;
} }
if (globals.shouldResetDynamicSim){ if (globals.shouldResetDynamicSim){
reset(); reset();
...@@ -149,6 +139,7 @@ function initDynamicModel(globals){ ...@@ -149,6 +139,7 @@ function initDynamicModel(globals){
globals.gpuMath.setUniformForProgram("velocityCalc", "u_dt", dt, "1f"); globals.gpuMath.setUniformForProgram("velocityCalc", "u_dt", dt, "1f");
globals.gpuMath.setProgram("positionCalc"); globals.gpuMath.setProgram("positionCalc");
globals.gpuMath.setUniformForProgram("positionCalc", "u_dt", dt, "1f"); globals.gpuMath.setUniformForProgram("positionCalc", "u_dt", dt, "1f");
globals.controls.setDeltaT(dt);
return numSteps; return numSteps;
} }
...@@ -160,12 +151,6 @@ function initDynamicModel(globals){ ...@@ -160,12 +151,6 @@ function initDynamicModel(globals){
return (1/(2*Math.PI*maxFreqNat))*0.5;//half of max delta t for good measure return (1/(2*Math.PI*maxFreqNat))*0.5;//half of max delta t for good measure
} }
function updateTextures(gpuMath){
gpuMath.initTextureFromData("u_originalPosition", textureDim, textureDim, "FLOAT", originalPosition, true);
gpuMath.initTextureFromData("u_meta", textureDim, textureDim, "FLOAT", meta, true);
reset();
}
function initTexturesAndPrograms(gpuMath){ function initTexturesAndPrograms(gpuMath){
var vertexShader = document.getElementById("vertexShader").text; var vertexShader = document.getElementById("vertexShader").text;
...@@ -222,7 +207,7 @@ function initDynamicModel(globals){ ...@@ -222,7 +207,7 @@ function initDynamicModel(globals){
return 0; return 0;
} }
function updateMaterials(){ function updateMaterials(shouldUpdateLength){
var index = 0; var index = 0;
for (var i=0;i<nodes.length;i++){ for (var i=0;i<nodes.length;i++){
meta[4*i] = index; meta[4*i] = index;
...@@ -231,7 +216,7 @@ function initDynamicModel(globals){ ...@@ -231,7 +216,7 @@ function initDynamicModel(globals){
var beam = nodes[i].beams[j]; var beam = nodes[i].beams[j];
beamMeta[4*index] = beam.getK(); beamMeta[4*index] = beam.getK();
beamMeta[4*index+1] = beam.getD(); beamMeta[4*index+1] = beam.getD();
beamMeta[4*index+2] = beam.getLength(); if (shouldUpdateLength) beamMeta[4*index+2] = beam.getLength();
beamMeta[4*index+3] = beam.getOtherNode(nodes[i]).getIndex(); beamMeta[4*index+3] = beam.getOtherNode(nodes[i]).getIndex();
index+=1; index+=1;
} }
...@@ -297,7 +282,7 @@ function initDynamicModel(globals){ ...@@ -297,7 +282,7 @@ function initDynamicModel(globals){
}); });
updateOriginalPosition(); updateOriginalPosition();
updateMaterials(); updateMaterials(true);
updateFixed(); updateFixed();
updateExternalForces(); updateExternalForces();
} }
...@@ -311,6 +296,8 @@ function initDynamicModel(globals){ ...@@ -311,6 +296,8 @@ function initDynamicModel(globals){
getChildren: getChildren, getChildren: getChildren,
setViewMode: setViewMode, setViewMode: setViewMode,
syncNodesAndEdges: syncNodesAndEdges, syncNodesAndEdges: syncNodesAndEdges,
updateOriginalPosition: updateOriginalPosition updateOriginalPosition: updateOriginalPosition,
updateMaterials:updateMaterials,
reset: reset
} }
} }
\ No newline at end of file
...@@ -7,6 +7,12 @@ function initGlobals(){ ...@@ -7,6 +7,12 @@ function initGlobals(){
var _globals = { var _globals = {
//flags
fixedHasChanged: false,
forceHasChanged: false,
materialHasChanged: false,
shouldResetDynamicSim: false,
//3d vis //3d vis
dynamicSimVisible: true, dynamicSimVisible: true,
staticSimVisible: false, staticSimVisible: false,
......
...@@ -249,7 +249,7 @@ span.modal-close{ ...@@ -249,7 +249,7 @@ span.modal-close{
} }
.sliderInput>.flat-slider{ .sliderInput>.flat-slider{
width: 162px; width: 132px;
} }
.label-slider{ .label-slider{
...@@ -281,6 +281,6 @@ span.modal-close{ ...@@ -281,6 +281,6 @@ span.modal-close{
text-align: left; text-align: left;
} }
#paddingBottom{ .paddingBottom{
margin-bottom: 50px; margin-bottom: 20px;
} }
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