Commit 1678733f authored by amandaghassaei's avatar amandaghassaei

ui

parent 6039dba4
......@@ -125,7 +125,7 @@
vec4 neighborIndices = texture2D(u_meta, scaledFragCoord);
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;
float beamIndex1D = meta[0]+float(j);
......@@ -201,30 +201,31 @@
</div>
<br/><br/>
<div class="dynamicSim">
Dynamic Sim Settings:<br/>
<div class="paddingBottom">Dynamic Sim Settings:</div>
<div class="indent">
<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/>
</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 id="extraSpace"></div>
</div>
<div id="controls">
<a href="#" id="about" class="btn btn-lg btn-default">About</a><br/><br/>
<!--<div class="sliderInput" id="density">-->
<!--<span class="label-slider">Density : </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">-->
<!--</div>-->
<!--<div class="sliderInput" id="width">-->
<!--<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>-->
<!--<input value="" placeholder="" class="form-control int" type="text">-->
<!--</div>-->
<!--<div class="sliderInput" id="length">-->
<!--<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>-->
<!--<input value="" placeholder="" class="form-control int" type="text">-->
<!--</div>-->
<div class="sliderInput" id="axialStiffness">
<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">
</div>
<div class="sliderInput" id="creaseStiffness">
<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">
</div>
<div class="sliderInput" id="panelStiffness">
<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">
</div>
<!--<a href="#" id="addRemoveFixed" class="btn btn-lg btn-default">Add/Remove Fixed Constraint</a>-->
<!--<span class="titleSpan">Available Materials:</span>-->
<!--<div id="materialTypes" class="indent">-->
......
......@@ -36,10 +36,32 @@ function initControls(globals){
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;
}, 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){
......@@ -200,7 +222,8 @@ function initControls(globals){
}
return {
update:update
update:update,
setDeltaT: setDeltaT
}
}
......@@ -65,16 +65,6 @@ function initDynamicModel(globals){
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(){
if (globals.forceHasChanged){
......@@ -85,9 +75,9 @@ function initDynamicModel(globals){
updateFixed();
globals.fixedHasChanged = false;
}
if (globals.dynamicSimMaterialsChanged){
if (globals.materialHasChanged){
updateMaterials();
globals.dynamicSimMaterialsChanged = false;
globals.materialHasChanged = false;
}
if (globals.shouldResetDynamicSim){
reset();
......@@ -149,6 +139,7 @@ function initDynamicModel(globals){
globals.gpuMath.setUniformForProgram("velocityCalc", "u_dt", dt, "1f");
globals.gpuMath.setProgram("positionCalc");
globals.gpuMath.setUniformForProgram("positionCalc", "u_dt", dt, "1f");
globals.controls.setDeltaT(dt);
return numSteps;
}
......@@ -160,12 +151,6 @@ function initDynamicModel(globals){
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){
var vertexShader = document.getElementById("vertexShader").text;
......@@ -222,7 +207,7 @@ function initDynamicModel(globals){
return 0;
}
function updateMaterials(){
function updateMaterials(shouldUpdateLength){
var index = 0;
for (var i=0;i<nodes.length;i++){
meta[4*i] = index;
......@@ -231,7 +216,7 @@ function initDynamicModel(globals){
var beam = nodes[i].beams[j];
beamMeta[4*index] = beam.getK();
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();
index+=1;
}
......@@ -297,7 +282,7 @@ function initDynamicModel(globals){
});
updateOriginalPosition();
updateMaterials();
updateMaterials(true);
updateFixed();
updateExternalForces();
}
......@@ -311,6 +296,8 @@ function initDynamicModel(globals){
getChildren: getChildren,
setViewMode: setViewMode,
syncNodesAndEdges: syncNodesAndEdges,
updateOriginalPosition: updateOriginalPosition
updateOriginalPosition: updateOriginalPosition,
updateMaterials:updateMaterials,
reset: reset
}
}
\ No newline at end of file
......@@ -7,6 +7,12 @@ function initGlobals(){
var _globals = {
//flags
fixedHasChanged: false,
forceHasChanged: false,
materialHasChanged: false,
shouldResetDynamicSim: false,
//3d vis
dynamicSimVisible: true,
staticSimVisible: false,
......
......@@ -249,7 +249,7 @@ span.modal-close{
}
.sliderInput>.flat-slider{
width: 162px;
width: 132px;
}
.label-slider{
......@@ -281,6 +281,6 @@ span.modal-close{
text-align: left;
}
#paddingBottom{
margin-bottom: 50px;
.paddingBottom{
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