/*
|
* To change this template, choose Tools | Templates
|
* and open the template in the editor.
|
*/
|
|
/**
|
*
|
* @author nbriere
|
*/
|
public class cFlag extends cSpring
|
{
|
cFlag()
|
{
|
this("Flag");
|
}
|
|
cFlag(String name)
|
{
|
super(name);
|
|
timeout = 100000000;
|
|
//numY *= 2;
|
numX = 40;
|
numY = 30;
|
}
|
|
Object3D deepCopy()
|
{
|
cFlag e = new cFlag();
|
deepCopySelf(e);
|
return e;
|
}
|
|
void setup()
|
{
|
Phys = new PhysicsController3D();
|
mesh = new DynamicNode[numX][numY];
|
|
if(thick)
|
mesh2 = new DynamicNode[numX][numY];
|
else
|
mesh2 = null;
|
|
//centers = new DynamicNode[numX-1][numY-1];
|
handles = new DynamicNode[numX];
|
|
time = 0;
|
|
//Create Nodes
|
for (int r = 0; r < numX; r++)
|
{
|
for (int c = 0; c < numY; c++)
|
{
|
//mesh[r][c] = new DynamicNode(-(double)(c+r/10.0f)/numY, ((double)r+c/10.0f+5)/numY, (double)c/numY, 1.0f/(numX*numY), 0); // .01f); // 1f);
|
mesh[r][c] = new DynamicNode(-2*c, 2*r+height, Math.random()*0.001, ((r==0||r==numX-1)&&c==0)?Float.MAX_VALUE:M, 0.01f); // 1f);
|
if(thick)
|
mesh2[r][c] = new DynamicNode(-2*c, 2*r+height, restlengthFactor, M, 0.01f); // 1f);
|
mesh[r][c].addForce(W);
|
mesh[r][c].addForce(G);
|
//mesh[r][c].addForce(C);
|
Phys.addNode(mesh[r][c]);
|
if(thick)
|
{
|
mesh2[r][c].addForce(W);
|
mesh2[r][c].addForce(G);
|
Phys.addNode(mesh2[r][c]);
|
}
|
}
|
}
|
|
//Phys.addForce(G);
|
//Phys.addForce(W);
|
Phys.addForce(C);
|
|
//Create Handles
|
for (int r = 0; r < numX; r++)
|
{
|
//handles[r] = new DynamicNode(0, ((double)r+5)/numY, 0, Float.MAX_VALUE, 0);
|
handles[r] = new DynamicNode(0, ((double)2*r+height), 0, Float.MAX_VALUE, 0);
|
Phys.addNode(handles[r]);
|
}
|
|
//connect mesh
|
// structural
|
for (int i=1; i<1; i++)
|
{
|
for (int r = 0; r < numX; r++)
|
{
|
for (int c = 0; c < numY - i; c++)
|
{
|
new Spring(mesh[r][c], mesh[r][c + i], K*1, 1);
|
if(thick)
|
new Spring(mesh2[r][c], mesh2[r][c + i], K*1, 1);
|
}
|
}
|
for (int r = 0; r < numX - i; r++)
|
{
|
for (int c = 0; c < numY; c++)
|
{
|
new Spring(mesh[r][c], mesh[r + i][c], K*1, 1);
|
if(thick)
|
new Spring(mesh2[r][c], mesh2[r + i][c], K*1, 1);
|
}
|
}
|
}
|
/*
|
// flexion
|
for (int r = 0; r < numX; r++)
|
{
|
for (int c = 0; c < numY - 2; c++)
|
{
|
new Spring(mesh[r][c], mesh[r][c + 2], K*1, 1);
|
if(thick)
|
new Spring(mesh2[r][c], mesh2[r][c + 2], K*1, 1);
|
}
|
}
|
for (int r = 0; r < numX - 2; r++)
|
{
|
for (int c = 0; c < numY; c++)
|
{
|
new Spring(mesh[r][c], mesh[r + 2][c], K*1, 1);
|
if(thick)
|
new Spring(mesh2[r][c], mesh2[r + 2][c], K*1, 1);
|
}
|
}
|
*/
|
|
// center
|
/*
|
for (int r = 0; r < numX-1; r++)
|
{
|
for (int c = 0; c < numY-1; c++)
|
{
|
centers[r][c] = new DynamicNode(-2*c-1, 2*r+3, 2*r, 10f, 0.01f);
|
//centers[r][c].addForce(W);
|
centers[r][c].addForce(G);
|
Phys.addNode(centers[r][c]);
|
new Spring(centers[r][c], mesh[r][c], K*1, 1f);
|
new Spring(centers[r][c], mesh[r+1][c], K*1, 1f);
|
new Spring(centers[r][c], mesh[r][c+1], K*1, 1f);
|
new Spring(centers[r][c], mesh[r+1][c+1], K*1, 1f);
|
new Spring(centers[r][c], mesh2[r][c], K*1, 1f);
|
new Spring(centers[r][c], mesh2[r+1][c], K*1, 1f);
|
new Spring(centers[r][c], mesh2[r][c+1], K*1, 1f);
|
new Spring(centers[r][c], mesh2[r+1][c+1], K*1, 1f);
|
//new Spring(mesh[0][r], mesh[numX-1][r], K*1, 0.1f);
|
}
|
}
|
*/
|
// structural II
|
for (int r = 0; r < numX; r++)
|
{
|
for (int c = 0; c < numY; c++)
|
{
|
if(thick)
|
new Spring(mesh[r][c], mesh2[r][c], K*1, 1f);
|
}
|
}
|
|
// shear
|
for (int i=0; i<=2; i++)
|
for (int j=0; j<=2; j++)
|
for (int r = 0; r < numX; r++)
|
{
|
for (int c = 0; c < numY - j; c++)
|
{
|
if (i==0 && j==0)
|
continue;
|
|
//new Spring(mesh2[r][c], mesh2[r + 1][c + 1], K/1, 1);
|
//new Spring(mesh2[r + 1][c], mesh2[r][c + 1], K/1, 1);
|
|
if (r-i>=0)
|
{
|
if(thick)
|
{
|
new Spring(mesh[r][c], mesh2[r-i][c+j], K*1, 1);
|
new Spring(mesh[r-i][c], mesh2[r][c+j], K*1, 1);
|
new Spring(mesh[r][c+j], mesh2[r-i][c], K*1, 1);
|
new Spring(mesh[r-i][c+j], mesh2[r][c], K*1, 1);
|
}
|
else
|
{
|
new Spring(mesh[r][c], mesh[r - i][c + j], K/1, 1);
|
new Spring(mesh[r - i][c], mesh[r][c + j], K/1, 1);
|
}
|
}
|
if (r+i<numX)
|
{
|
if(thick)
|
{
|
new Spring(mesh[r][c], mesh2[r+i][c+j], K*1, 1);
|
new Spring(mesh[r+i][c], mesh2[r][c+j], K*1, 1);
|
new Spring(mesh[r][c+j], mesh2[r+i][c], K*1, 1);
|
new Spring(mesh[r+i][c+j], mesh2[r][c], K*1, 1);
|
}
|
else
|
{
|
new Spring(mesh[r][c], mesh[r + i][c + j], K/1, 1);
|
new Spring(mesh[r + i][c], mesh[r][c + j], K/1, 1);
|
}
|
}
|
}
|
}
|
//connect handles
|
for (int r = 0; r < numX; r++)
|
//int r = numX - 1;
|
{
|
//new Spring(mesh[r][0], handles[r], K, 0.5f);
|
new Spring(mesh[r/*/10*/][0], handles[0*r/10], K, 1); //0.5f);
|
new Spring(mesh[(numX - 1) - r/*/10*/][0], handles[(numX - 1) - 0*r/10], K*1, 1); //0.5f);
|
}
|
}
|
}
|