I have been constantly deleting my own thread about this topic simply because I am not completely proud or happy with what I have done... Because I wanted clothing simulation sooooo badly~ I did some googling and yahooing for such, and encountered a C++ source for clothing simulation... I decided to try translating the code from C++ to JPCT, and I did sort of got it to work... My problem is that the rested cloth looks like this...
I know that cannot possibly be correct because I did not apply any forces onto the cloth yet... Since I can not find out how to contact the original author, I decided to try to tackle the problem myself, but as usual, failed... Here is the complete source and a texture for my project!
*editted: I took the file down for now!*
Anyway, I suspect that the problem has something to do with the way the SpringConstraints are set up; SpringConstraints hold data on how far particles along a plane can stretch...
int off = 0;
for(int i = 0; i < numParticles; i++){
if(i % (gridx) < gridx-1 && i < numParticles-gridx || i == 0){
//System.out.println("i: "+i+" 1");
constraints[off++] = new SpringConstraint(particles[i],particles[i+1],spacing,stff);
constraints[off++] = new SpringConstraint(particles[i],particles[i+gridx],spacing,stff);
constraints[off++] = new SpringConstraint(particles[i],particles[i+gridx+1],spacing*rt2,diagstff);
if(i % gridx > 0){
//System.out.println("i: "+i+" 1a");
constraints[off++] = new SpringConstraint(particles[i],particles[i+gridx-1],spacing*rt2,diagstff);
}
}else if ((i % (gridx) == gridx-1) && (i < (gridx*gridy-(gridx)))){
//System.out.println("i: "+i+" 2");
constraints[off++] = new SpringConstraint(particles[i],particles[i+gridx],spacing,stff);
constraints[off++] = new SpringConstraint(particles[i],particles[i+gridx-1],spacing*rt2,diagstff);
}else if (i > numParticles-2){
//System.out.println("i: "+i+" 3");
}else{
//System.out.println("i: "+i+" 4");
constraints[off++] = new SpringConstraint(particles[i],particles[i+1],spacing,stff);
}
}
To Egon: this code is updated from the last time I sent it to you...
To everyone: you can use your mouse to click and drag some vertices/particles around... Since I pretty much used Egon's code, "w" is wireframe mode and "x" is hardware render mode... You cannot play with the vertices on hardware render mode...
If there is anyone knowledgeable on such a subject, I would love to be your friend, since my game programming background is pretty much non-existent...