Physics

I have now implemented the physics part of GPU Gems. So far I just have 1 object of particles, resembling a fox that collide with the floor. The floor is not made of particles and is just a special case that enables me to visualize things and make it easier to show the simulation later. I did run into a lot of problems implementing this but I think that I have solved all the important bits. So what is left is adding more objects with initial forces and aim these to hit one another. This is more or less required if I want to demonstrate my project, which obviously is pretty important.

One big issue that I encountered was that the "actual" world position of particles that I calculated in a function differed from how the visual particles were drawn on the screen. So either the drawing process was wrong or some other calculation. In the end I managed to see that the non-visual particle positions rotated twice as much as the drawn particles which used a rotation-matrix (given by the same quaternion). I checked what the minimum y-value was for the particles when they weren't rotating that much and got the intuition that the rendering was correct, but the other calculations wrong. In short, I removed 1 single multiplication and it worked much better after that. The problematic formula was from GPU-Gems and can be seen in this image:

All I did was to remove Q* and the rotation got cut in half. When googling, it appears that the *-sign is used for the conjugate transpose in linear algebra, but you can't take the transpose of a quaternion in glm, and it wouldn't make much sense anyway.

When it comes to gravity it was way too fast, so I divide the force and torque by a large number to make the simulation go slower. Otherwise things would run too fast for humans to see everything. I may also have taken a few shortcuts when simulating a floor, since I directly halve the rigid objects velocity when it hits the floor. If I instead add too much of a force to the rigid body coming from the floor, it will instead make large bounces.

I will also post some recordings I did here. Both videos showing problems and also video(s) showing improvements.






Explanation: The particle adds a force in a static direction to the particles it collides with. Thus, the rigid body in this example goes in the "wrong" direction, relative to where it gets hit.


Kommentarer

Populära inlägg i den här bloggen

Collisions

Optimizing Particles With VBO

Particle Generation