Heyho everyone,
This will be just a quick post tonight since I am busy studying for my Pixar interview and for the alpha presentation tomorrow.
This week in addition to preparing my alpha video I did the following things:
-Cleaned up some code
-Experimented with adding friction forces to the paper when it collides with the ground
-Added quad rendering for the lattice to make it look like paper
-Removed the bend springs that lied along the fold axis
-Experimented with where I apply the torque
-Played with constant values for gravity and spring constants
The coolest thing is that I was able to get a complete fold done. The rest angle of the fold can also be toggled between 0 and PI so that the fold can be undone. The lattice is also incredibly stable, so the folding can happen multiple times. Enjoy the video:
Thursday, February 24, 2011
Thursday, February 17, 2011
Torsion Springs
Heyho,
So I did not get to implicit or imex this week, but I did get to work on the rotational springs and got stuff folding.
I will first go over the implementation of the rotational springs.
Variables:
-axisPoint1
-axisPoint2
-momentArmPoint1
-momentArmPoint2
-springConst
-dampingConst
-restAngle
The first two points form the axis of rotation. The other two points define two moment arms from the midpoint of the axis. The spring and damping consts are used for force calculation. The rest angle is the desired angle between the moment arms.
In order to calculate the forces on the points on the moment arms I need to first calculate the torque generated by the spring on each moment arm. I am currently missing the damping part of the function, which causes explosions (see later in the post). Once I calculate the torque I can figure out the forces from that value. But since these are scalar values, I still need to find the force vector. I determined that if I take the cross product between the axis and the moment arm I get the force vector I want. So this lets me update the forces on the moment arm points and integrate the springs into the rest of the system.
So what does this all mean? Folding! I was truly amazed how well the rotational springs worked with the rest of the cloth sim. I setup relatively stiff values for all the linear springs and added the springs. I seem to get a surprising result that looks pretty close to paper. I have two videos showing the rotational springs interacting with the system. Note the videos are at x2 speed, because they are amazing slow otherwise.
In this first video I do a few things. The lattice is setup like a normal cloth sim grid. The red line through the center of the paper is the rotational spring. At the beginning I start the simulation with structure, shear, bend and rotational springs. One thing to note is that there is no spring between the center of the rotational axis that goes along the moment arm. Because of this the paper curls inward, responding to gravity and the bend springs keeping it from being completely stiff. I am pretty happy with this because it looks like if you were to roll up the paper. When the rotational spring is removed, the system unrolls back to normal. I then remove the bend springs and add the rotation spring back to show how it looks without the bend springs. You can really see where they got their name ;) The cool thing is that I have folded and unfolded in this manner several times and it seems like it goes pretty stable.
In the second video I made some changes to the lattice. There are two structural springs that run from the center to the ends of the paper where the moment arms are. They provide a good way to judge the angle you are seeing the paper folding. Another thing to not is that the shear springs that run across the bend spring are removed. I found that this is necessary or they will prevent a total fold.
The simulator goes pretty smooth until it gets to a point where gravity starts to out do the springs and the thing starts to collapse. At least I hope it is gravity. It is sort of hard to tell, but it is cool to see the lattice turn inside out... and then explode.
For next week I will play with constants, look at the explosion a little more closely and prepare for alpha reviews on Friday (Fear!). In front of Pixar (FEAR!).
So I did not get to implicit or imex this week, but I did get to work on the rotational springs and got stuff folding.
I will first go over the implementation of the rotational springs.
Variables:
-axisPoint1
-axisPoint2
-momentArmPoint1
-momentArmPoint2
-springConst
-dampingConst
-restAngle
The first two points form the axis of rotation. The other two points define two moment arms from the midpoint of the axis. The spring and damping consts are used for force calculation. The rest angle is the desired angle between the moment arms.
In order to calculate the forces on the points on the moment arms I need to first calculate the torque generated by the spring on each moment arm. I am currently missing the damping part of the function, which causes explosions (see later in the post). Once I calculate the torque I can figure out the forces from that value. But since these are scalar values, I still need to find the force vector. I determined that if I take the cross product between the axis and the moment arm I get the force vector I want. So this lets me update the forces on the moment arm points and integrate the springs into the rest of the system.
So what does this all mean? Folding! I was truly amazed how well the rotational springs worked with the rest of the cloth sim. I setup relatively stiff values for all the linear springs and added the springs. I seem to get a surprising result that looks pretty close to paper. I have two videos showing the rotational springs interacting with the system. Note the videos are at x2 speed, because they are amazing slow otherwise.
In this first video I do a few things. The lattice is setup like a normal cloth sim grid. The red line through the center of the paper is the rotational spring. At the beginning I start the simulation with structure, shear, bend and rotational springs. One thing to note is that there is no spring between the center of the rotational axis that goes along the moment arm. Because of this the paper curls inward, responding to gravity and the bend springs keeping it from being completely stiff. I am pretty happy with this because it looks like if you were to roll up the paper. When the rotational spring is removed, the system unrolls back to normal. I then remove the bend springs and add the rotation spring back to show how it looks without the bend springs. You can really see where they got their name ;) The cool thing is that I have folded and unfolded in this manner several times and it seems like it goes pretty stable.
In the second video I made some changes to the lattice. There are two structural springs that run from the center to the ends of the paper where the moment arms are. They provide a good way to judge the angle you are seeing the paper folding. Another thing to not is that the shear springs that run across the bend spring are removed. I found that this is necessary or they will prevent a total fold.
The simulator goes pretty smooth until it gets to a point where gravity starts to out do the springs and the thing starts to collapse. At least I hope it is gravity. It is sort of hard to tell, but it is cool to see the lattice turn inside out... and then explode.
For next week I will play with constants, look at the explosion a little more closely and prepare for alpha reviews on Friday (Fear!). In front of Pixar (FEAR!).
Thursday, February 10, 2011
RK4 and Reading
Heyho,
This past week was pretty hectic. I spent a lot of time working on internship applications and getting my demo reel in order for said applications. So this week I was able to do the following things:
-Reformatted parts of my spring code so it is easier to debug
-Fixed a fatal flaw in my midpoint implementation that was causing problems
-Implemented RK4
I also been reading through the papers Joe posted as comments in my last post in an effort to understanding implicit and imex integrators. So now I think I am better prepared to implement them for next week. I also hope to start the implementation of rotational springs to get some basic folding going. That way I can have some folding going for alpha review. As a final treat, enjoy the hammock images from my RK4 integration:
This past week was pretty hectic. I spent a lot of time working on internship applications and getting my demo reel in order for said applications. So this week I was able to do the following things:
-Reformatted parts of my spring code so it is easier to debug
-Fixed a fatal flaw in my midpoint implementation that was causing problems
-Implemented RK4
I also been reading through the papers Joe posted as comments in my last post in an effort to understanding implicit and imex integrators. So now I think I am better prepared to implement them for next week. I also hope to start the implementation of rotational springs to get some basic folding going. That way I can have some folding going for alpha review. As a final treat, enjoy the hammock images from my RK4 integration:
Thursday, February 3, 2011
Bringing it Back to Basics
Heyho,
Taking Joe's advice I brought the project back a little. I did start in with some CUDA code, taking the always favorite SimpleGl code sample and adding variables and preparing kernels. Nothing really complicated, mostly setup.
However most of the week's progress went to the CPU. I built up a new framework of particles and springs for a cloth simulation in C++. The framework is simple, but it has a nice little camera that lets me pan around a bit. There are three different types of springs: Structural, Shear and Bend. Those apply forces to the particles and the particles have different integration schemes to move them based on those forces. The particles also respond to gravity and hit a floor at z = 0. It also has callbacks all setup for mouse and keyboard. It mostly came from code from my 277 projects.
Then I implemented 3 different integrators: Verlet, Euler and Midpoint. Currently Verlet and Midpoint are stable, while Euler blows up with the current spring and damping constants. Playing around with those can be fun, because it certainly makes the cloth do interesting things. Currently I've found a balance in the constants that makes the cloth kind of obey the constraints and does not make the cloth explode. Some screenshots below:
So as you can see in the second image, there are some bending along the cloth, which in certainly interesting. Bend springs should be preventing that, but playing with the constants can cause explosions.
The next steps is more integrators, working my way to an implicit euler or implicit RK4. I can already see that Midpoint is starting to change the frame rate a bit, so a smaller lattice might be indicated already. It also might be how I have implemented it, but we'll see. If I have time, I'll also start on the rotational springs in C++ and see if I can integrate them and maybe get some first folding action.
Taking Joe's advice I brought the project back a little. I did start in with some CUDA code, taking the always favorite SimpleGl code sample and adding variables and preparing kernels. Nothing really complicated, mostly setup.
However most of the week's progress went to the CPU. I built up a new framework of particles and springs for a cloth simulation in C++. The framework is simple, but it has a nice little camera that lets me pan around a bit. There are three different types of springs: Structural, Shear and Bend. Those apply forces to the particles and the particles have different integration schemes to move them based on those forces. The particles also respond to gravity and hit a floor at z = 0. It also has callbacks all setup for mouse and keyboard. It mostly came from code from my 277 projects.
Then I implemented 3 different integrators: Verlet, Euler and Midpoint. Currently Verlet and Midpoint are stable, while Euler blows up with the current spring and damping constants. Playing around with those can be fun, because it certainly makes the cloth do interesting things. Currently I've found a balance in the constants that makes the cloth kind of obey the constraints and does not make the cloth explode. Some screenshots below:
So as you can see in the second image, there are some bending along the cloth, which in certainly interesting. Bend springs should be preventing that, but playing with the constants can cause explosions.
The next steps is more integrators, working my way to an implicit euler or implicit RK4. I can already see that Midpoint is starting to change the frame rate a bit, so a smaller lattice might be indicated already. It also might be how I have implemented it, but we'll see. If I have time, I'll also start on the rotational springs in C++ and see if I can integrate them and maybe get some first folding action.
Subscribe to:
Posts (Atom)