Commit e3e1c192 authored by amandaghassaei's avatar amandaghassaei
Browse files

debugging

parent 52ee52b4
......@@ -92,7 +92,7 @@
vec3 lastPosition = texture2D(u_lastPosition, scaledFragCoord).xyz;
vec3 velocity = texture2D(u_velocity, scaledFragCoord).xyz;
vec3 position = velocity*u_dt + lastPosition;
gl_FragColor = vec4(position,0.0);
gl_FragColor = vec4(position, 0.0);
}
</script>
......@@ -122,7 +122,7 @@
vec2 scaledFragCoord = fragCoord/u_textureDim;
vec2 mass = texture2D(u_mass, scaledFragCoord).xy;
if (mass.y == 1.0){
if (mass.y == 1.0){//fixed
gl_FragColor = vec4(0.0);
return;
}
......@@ -154,7 +154,7 @@
deltaP -= normalize(deltaP)*beamMeta[2];
vec3 deltaV = neighborLastVelocity-lastVelocity;
vec3 _force = deltaP*beamMeta[0] + deltaV*beamMeta[1];
vec3 _force = deltaP*beamMeta[0];// + deltaV*beamMeta[1];
force += _force;
}
......@@ -183,7 +183,7 @@
vec2 scaledNormalsIndex = normalsIndex/u_textureDimFaces;
vec3 normal = texture2D(u_normals, scaledNormalsIndex).xyz;
float angForce = creaseMeta[0]*(targetTheta-thetas[0]) + creaseMeta[1]*thetas[1];;
float angForce = creaseMeta[0]*(targetTheta-thetas[0]);// + creaseMeta[1]*thetas[1];
float momentArm = creaseMeta2[1];
vec3 _force = angForce/momentArm*normal;
......@@ -330,7 +330,7 @@
</div>
<div id="controls">
<div class="sliderInput" id="creasePercent">
<span class="label-slider">Crease Angle : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>
<span class="label-slider">Crease Percent : </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>
<br/><br/><br/>
......
......@@ -51,9 +51,9 @@ function initGPUMath(){
GPUMath.prototype.initFrameBufferForTexture = function(textureName){
GPUMath.prototype.initFrameBufferForTexture = function(textureName, shouldReplace){
var framebuffer = this.frameBuffers[textureName];
if (framebuffer) {
if (framebuffer && (shouldReplace === undefined || !shouldReplace)) {
console.warn("framebuffer already exists for texture " + textureName);
return;
}
......
......@@ -57,6 +57,7 @@ function initDynamicModel(globals){
object3D.position.set(-avg.x, 0, -avg.z);
initTypedArrays();
if (firstTime === undefined) firstTime = false;
initTexturesAndPrograms(globals.gpuMath, firstTime);
steps = parseInt(setSolveParams());
}
......@@ -184,6 +185,7 @@ function initDynamicModel(globals){
for (var i = 0; i < nodes.length; i++) {
var rgbaIndex = i * vectorLength;
var nodePosition = new THREE.Vector3(parsedPixels[rgbaIndex], parsedPixels[rgbaIndex + 1], parsedPixels[rgbaIndex + 2]);
// console.log(nodePosition);
nodes[i].render(nodePosition);
}
for (var i=0;i<edges.length;i++){
......@@ -229,14 +231,12 @@ function initDynamicModel(globals){
gpuMath.initTextureFromData("u_theta", textureDimCreases, textureDimCreases, "FLOAT", theta, !firstTime);
gpuMath.initTextureFromData("u_lastTheta", textureDimCreases, textureDimCreases, "FLOAT", lastTheta, !firstTime);
if (firstTime) {
gpuMath.initFrameBufferForTexture("u_position");
gpuMath.initFrameBufferForTexture("u_lastPosition");
gpuMath.initFrameBufferForTexture("u_velocity");
gpuMath.initFrameBufferForTexture("u_lastVelocity");
gpuMath.initFrameBufferForTexture("u_theta");
gpuMath.initFrameBufferForTexture("u_lastTheta");
}
gpuMath.initFrameBufferForTexture("u_position", !firstTime);
gpuMath.initFrameBufferForTexture("u_lastPosition", !firstTime);
gpuMath.initFrameBufferForTexture("u_velocity", !firstTime);
gpuMath.initFrameBufferForTexture("u_lastVelocity", !firstTime);
gpuMath.initFrameBufferForTexture("u_theta", !firstTime);
gpuMath.initFrameBufferForTexture("u_lastTheta", !firstTime);
gpuMath.initTextureFromData("u_meta", textureDim, textureDim, "FLOAT", meta, true);
gpuMath.initTextureFromData("u_creaseMeta2", textureDimNodeCreases, textureDimNodeCreases, "FLOAT", creaseMeta2, true);
......@@ -275,7 +275,7 @@ function initDynamicModel(globals){
gpuMath.createProgram("packToBytes", vertexShader, document.getElementById("packToBytesShader").text);
gpuMath.initTextureFromData("outputBytes", textureDim*4, textureDim, "UNSIGNED_BYTE", null, !firstTime);
if (firstTime) gpuMath.initFrameBufferForTexture("outputBytes");
gpuMath.initFrameBufferForTexture("outputBytes", !firstTime);
gpuMath.setUniformForProgram("packToBytes", "u_floatTextureDim", [textureDim, textureDim], "2f");
gpuMath.createProgram("zeroTexture", vertexShader, document.getElementById("zeroTexture").text);
......
......@@ -28,15 +28,16 @@ function initModel(globals){
var creases = [];
creases.push(new Crease(edges[2], 1, 0, Math.PI/2, 1, nodes[3], nodes[1], 0));
function buildModel(_faces, _vertices, _allEdges, allCreaseParams, numOutline, numMountians, numValleys, numCuts){
function buildModel(_faces, _vertices, _allEdges, allCreaseParams){
var _nodes = [];
for (var i=0;i<_vertices.length;i++){
_nodes.push(new Node(_vertices[i].clone(), _nodes.length));
}
_nodes[0].setFixed(true);
_nodes[1].setFixed(true);
_nodes[2].setFixed(true);
console.log(_faces[0]);
_nodes[_faces[0].a].setFixed(true);
_nodes[_faces[0].b].setFixed(true);
_nodes[_faces[0].c].setFixed(true);
var _edges = [];
for (var i=0;i<_allEdges.length;i++) {
......
......@@ -167,8 +167,7 @@ function initPattern(globals){
var allCreaseParams = getFacesAndVerticesForEdges(faces, allEdges);
globals.model.buildModel(faces, vertices, allEdges, allCreaseParams, outlines.length, outlines.length+mountains.length,
outlines.length+mountains.length+valleys.length, outlines.length+mountains.length+valleys.length+cuts.length);
globals.model.buildModel(faces, vertices, allEdges, allCreaseParams);
}
function getFacesAndVerticesForEdges(faces, allEdges){
......
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